net/ngbe: support MAC filters
[dpdk.git] / drivers / net / cnxk / cnxk_rte_flow.c
index c61618a..b08d7c3 100644 (file)
@@ -15,8 +15,8 @@ const struct cnxk_rte_flow_term_info term[] = {
        [RTE_FLOW_ITEM_TYPE_IPV6] = {ROC_NPC_ITEM_TYPE_IPV6,
                                     sizeof(struct rte_flow_item_ipv6)},
        [RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4] = {
-               ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4,
-               sizeof(struct rte_flow_item_arp_eth_ipv4)},
+                       ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4,
+                       sizeof(struct rte_flow_item_arp_eth_ipv4)},
        [RTE_FLOW_ITEM_TYPE_MPLS] = {ROC_NPC_ITEM_TYPE_MPLS,
                                     sizeof(struct rte_flow_item_mpls)},
        [RTE_FLOW_ITEM_TYPE_ICMP] = {ROC_NPC_ITEM_TYPE_ICMP,
@@ -50,10 +50,10 @@ const struct cnxk_rte_flow_term_info term[] = {
        [RTE_FLOW_ITEM_TYPE_ANY] = {ROC_NPC_ITEM_TYPE_ANY, 0},
        [RTE_FLOW_ITEM_TYPE_GRE_KEY] = {ROC_NPC_ITEM_TYPE_GRE_KEY,
                                        sizeof(uint32_t)},
-       [RTE_FLOW_ITEM_TYPE_HIGIG2] = {
-               ROC_NPC_ITEM_TYPE_HIGIG2,
-               sizeof(struct rte_flow_item_higig2_hdr)}
-};
+       [RTE_FLOW_ITEM_TYPE_HIGIG2] = {ROC_NPC_ITEM_TYPE_HIGIG2,
+                                      sizeof(struct rte_flow_item_higig2_hdr)},
+       [RTE_FLOW_ITEM_TYPE_RAW] = {ROC_NPC_ITEM_TYPE_RAW,
+                                   sizeof(struct rte_flow_item_raw)}};
 
 static int
 npc_rss_action_validate(struct rte_eth_dev *eth_dev,
@@ -69,7 +69,7 @@ npc_rss_action_validate(struct rte_eth_dev *eth_dev,
                return -EINVAL;
        }
 
-       if (eth_dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
+       if (eth_dev->data->dev_conf.rxmode.mq_mode != RTE_ETH_MQ_RX_RSS) {
                plt_err("multi-queue mode is disabled");
                return -ENOTSUP;
        }
@@ -110,8 +110,13 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
                 struct roc_npc_action in_actions[], uint32_t *flowkey_cfg)
 {
        struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
-       const struct rte_flow_action_count *act_count;
+       const struct rte_flow_action_port_id *port_act;
        const struct rte_flow_action_queue *act_q;
+       struct roc_npc *roc_npc_src = &dev->npc;
+       struct rte_eth_dev *portid_eth_dev;
+       char if_name[RTE_ETH_NAME_MAX_LEN];
+       struct cnxk_eth_dev *hw_dst;
+       struct roc_npc *roc_npc_dst;
        int i = 0, rc = 0;
        int rq;
 
@@ -131,13 +136,6 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
                        break;
 
                case RTE_FLOW_ACTION_TYPE_COUNT:
-                       act_count = (const struct rte_flow_action_count *)
-                                           actions->conf;
-
-                       if (act_count->shared == 1) {
-                               plt_npc_dbg("Shared counter is not supported");
-                               goto err_exit;
-                       }
                        in_actions[i].type = ROC_NPC_ACTION_TYPE_COUNT;
                        break;
 
@@ -154,6 +152,36 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
                        in_actions[i].conf = actions->conf;
                        break;
 
+               case RTE_FLOW_ACTION_TYPE_PORT_ID:
+                       in_actions[i].type = ROC_NPC_ACTION_TYPE_PORT_ID;
+                       in_actions[i].conf = actions->conf;
+                       port_act = (const struct rte_flow_action_port_id *)
+                                          actions->conf;
+                       if (rte_eth_dev_get_name_by_port(port_act->id,
+                                                        if_name)) {
+                               plt_err("Name not found for output port id");
+                               goto err_exit;
+                       }
+                       portid_eth_dev = rte_eth_dev_allocated(if_name);
+                       if (!portid_eth_dev) {
+                               plt_err("eth_dev not found for output port id");
+                               goto err_exit;
+                       }
+                       if (strcmp(portid_eth_dev->device->driver->name,
+                                  eth_dev->device->driver->name) != 0) {
+                               plt_err("Output port not under same driver");
+                               goto err_exit;
+                       }
+                       hw_dst = portid_eth_dev->data->dev_private;
+                       roc_npc_dst = &hw_dst->npc;
+
+                       rc = roc_npc_validate_portid_action(roc_npc_src,
+                                                           roc_npc_dst);
+
+                       if (rc)
+                               goto err_exit;
+                       break;
+
                case RTE_FLOW_ACTION_TYPE_QUEUE:
                        act_q = (const struct rte_flow_action_queue *)
                                        actions->conf;
@@ -178,6 +206,27 @@ cnxk_map_actions(struct rte_eth_dev *eth_dev, const struct rte_flow_attr *attr,
                case RTE_FLOW_ACTION_TYPE_SECURITY:
                        in_actions[i].type = ROC_NPC_ACTION_TYPE_SEC;
                        break;
+               case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
+                       in_actions[i].type = ROC_NPC_ACTION_TYPE_VLAN_STRIP;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+                       in_actions[i].type = ROC_NPC_ACTION_TYPE_VLAN_INSERT;
+                       in_actions[i].conf = actions->conf;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+                       in_actions[i].type =
+                               ROC_NPC_ACTION_TYPE_VLAN_ETHTYPE_INSERT;
+                       in_actions[i].conf = actions->conf;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
+                       in_actions[i].type =
+                               ROC_NPC_ACTION_TYPE_VLAN_PCP_INSERT;
+                       in_actions[i].conf = actions->conf;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_METER:
+                       in_actions[i].type = ROC_NPC_ACTION_TYPE_METER;
+                       in_actions[i].conf = actions->conf;
+                       break;
                default:
                        plt_npc_dbg("Action is not supported = %d",
                                    actions->type);