net/sfc: use compat for 128-bit unsigned integer
[dpdk.git] / drivers / net / octeontx2 / otx2_flow_parse.c
index 2cba0a4..476195d 100644 (file)
@@ -245,6 +245,11 @@ otx2_flow_parse_le(struct otx2_parse_state *pst)
                info.len = sizeof(struct rte_flow_item_vxlan);
                lt = NPC_LT_LE_VXLAN;
                break;
+       case RTE_FLOW_ITEM_TYPE_ESP:
+               lt = NPC_LT_LE_ESP;
+               info.def_mask = &rte_flow_item_esp_mask;
+               info.len = sizeof(struct rte_flow_item_esp);
+               break;
        case RTE_FLOW_ITEM_TYPE_GTPC:
                lflags = NPC_F_UDP_GTP_GTPC;
                info.def_mask = &rte_flow_item_gtp_mask;
@@ -441,11 +446,6 @@ otx2_flow_parse_ld(struct otx2_parse_state *pst)
                info.def_mask = &rte_flow_item_sctp_mask;
                info.len = sizeof(struct rte_flow_item_sctp);
                break;
-       case RTE_FLOW_ITEM_TYPE_ESP:
-               lt = NPC_LT_LD_ESP;
-               info.def_mask = &rte_flow_item_esp_mask;
-               info.len = sizeof(struct rte_flow_item_esp);
-               break;
        case RTE_FLOW_ITEM_TYPE_GRE:
                lt = NPC_LT_LD_GRE;
                info.def_mask = &rte_flow_item_gre_mask;
@@ -675,6 +675,15 @@ otx2_flow_parse_la(struct otx2_parse_state *pst)
        if (pst->flow->nix_intf == NIX_INTF_TX) {
                lt = NPC_LT_LA_IH_NIX_ETHER;
                info.hw_hdr_len = NPC_IH_LENGTH;
+               if (pst->npc->switch_header_type == OTX2_PRIV_FLAGS_HIGIG) {
+                       lt = NPC_LT_LA_IH_NIX_HIGIG2_ETHER;
+                       info.hw_hdr_len += NPC_HIGIG2_LENGTH;
+               }
+       } else {
+               if (pst->npc->switch_header_type == OTX2_PRIV_FLAGS_HIGIG) {
+                       lt = NPC_LT_LA_HIGIG2_ETHER;
+                       info.hw_hdr_len = NPC_HIGIG2_LENGTH;
+               }
        }
 
        /* Prepare for parsing the item */
@@ -694,6 +703,44 @@ otx2_flow_parse_la(struct otx2_parse_state *pst)
        return otx2_flow_update_parse_state(pst, &info, lid, lt, 0);
 }
 
+int
+otx2_flow_parse_higig2_hdr(struct otx2_parse_state *pst)
+{
+       struct rte_flow_item_higig2_hdr hw_mask;
+       struct otx2_flow_item_info info;
+       int lid, lt;
+       int rc;
+
+       /* Identify the pattern type into lid, lt */
+       if (pst->pattern->type != RTE_FLOW_ITEM_TYPE_HIGIG2)
+               return 0;
+
+       lid = NPC_LID_LA;
+       lt = NPC_LT_LA_HIGIG2_ETHER;
+       info.hw_hdr_len = 0;
+
+       if (pst->flow->nix_intf == NIX_INTF_TX) {
+               lt = NPC_LT_LA_IH_NIX_HIGIG2_ETHER;
+               info.hw_hdr_len = NPC_IH_LENGTH;
+       }
+
+       /* Prepare for parsing the item */
+       info.def_mask = &rte_flow_item_higig2_hdr_mask;
+       info.hw_mask = &hw_mask;
+       info.len = sizeof(struct rte_flow_item_higig2_hdr);
+       otx2_flow_get_hw_supp_mask(pst, &info, lid, lt);
+       info.spec = NULL;
+       info.mask = NULL;
+
+       /* Basic validation of item parameters */
+       rc = otx2_flow_parse_item_basic(pst->pattern, &info, pst->error);
+       if (rc)
+               return rc;
+
+       /* Update pst if not validate only? clash check? */
+       return otx2_flow_update_parse_state(pst, &info, lid, lt, 0);
+}
+
 static int
 parse_rss_action(struct rte_eth_dev *dev,
                 const struct rte_flow_attr *attr,
@@ -766,6 +813,7 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
        const struct rte_flow_action_mark *act_mark;
        const struct rte_flow_action_queue *act_q;
        const struct rte_flow_action_vf *vf_act;
+       bool vlan_insert_action = false;
        const char *errmsg = NULL;
        int sel_act, req_act = 0;
        uint16_t pf_func, vf_id;
@@ -833,14 +881,14 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
                                actions->conf;
                        req_act |= OTX2_FLOW_ACT_VF;
                        if (vf_act->original == 0) {
-                               vf_id = (vf_act->id & RVU_PFVF_FUNC_MASK) + 1;
+                               vf_id = vf_act->id & RVU_PFVF_FUNC_MASK;
                                if (vf_id  >= hw->maxvf) {
                                        errmsg = "invalid vf specified";
                                        errcode = EINVAL;
                                        goto err_exit;
                                }
                                pf_func &= (0xfc00);
-                               pf_func = (pf_func | vf_id);
+                               pf_func = (pf_func | (vf_id + 1));
                        }
                        break;
 
@@ -885,6 +933,18 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
                        req_act |= OTX2_FLOW_ACT_SEC;
                        rq = 0;
                        break;
+               case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+                       req_act |= OTX2_FLOW_ACT_VLAN_INSERT;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
+                       req_act |= OTX2_FLOW_ACT_VLAN_STRIP;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
+                       req_act |= OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT;
+                       break;
+               case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP:
+                       req_act |= OTX2_FLOW_ACT_VLAN_PCP_INSERT;
+                       break;
                default:
                        errmsg = "Unsupported action specified";
                        errcode = ENOTSUP;
@@ -892,20 +952,46 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
                }
        }
 
+       if (req_act &
+           (OTX2_FLOW_ACT_VLAN_INSERT | OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT |
+            OTX2_FLOW_ACT_VLAN_PCP_INSERT))
+               vlan_insert_action = true;
+
+       if ((req_act &
+            (OTX2_FLOW_ACT_VLAN_INSERT | OTX2_FLOW_ACT_VLAN_ETHTYPE_INSERT |
+             OTX2_FLOW_ACT_VLAN_PCP_INSERT)) ==
+           OTX2_FLOW_ACT_VLAN_PCP_INSERT) {
+               errmsg = " PCP insert action can't be supported alone";
+               errcode = ENOTSUP;
+               goto err_exit;
+       }
+
+       /* Both STRIP and INSERT actions are not supported */
+       if (vlan_insert_action && (req_act & OTX2_FLOW_ACT_VLAN_STRIP)) {
+               errmsg = "Both VLAN insert and strip actions not supported"
+                       " together";
+               errcode = ENOTSUP;
+               goto err_exit;
+       }
+
        /* Check if actions specified are compatible */
        if (attr->egress) {
-               /* Only DROP/COUNT is supported */
-               if (!(req_act & OTX2_FLOW_ACT_DROP)) {
-                       errmsg = "DROP is required action for egress";
-                       errcode = EINVAL;
-                       goto err_exit;
-               } else if (req_act & ~(OTX2_FLOW_ACT_DROP |
-                                      OTX2_FLOW_ACT_COUNT)) {
-                       errmsg = "Unsupported action specified";
+               if (req_act & OTX2_FLOW_ACT_VLAN_STRIP) {
+                       errmsg = "VLAN pop action is not supported on Egress";
                        errcode = ENOTSUP;
                        goto err_exit;
                }
-               flow->npc_action = NIX_TX_ACTIONOP_DROP;
+
+               if (req_act & OTX2_FLOW_ACT_DROP) {
+                       flow->npc_action = NIX_TX_ACTIONOP_DROP;
+               } else if ((req_act & OTX2_FLOW_ACT_COUNT) ||
+                          vlan_insert_action) {
+                       flow->npc_action = NIX_TX_ACTIONOP_UCAST_DEFAULT;
+               } else {
+                       errmsg = "Unsupported action for egress";
+                       errcode = EINVAL;
+                       goto err_exit;
+               }
                goto set_pf_func;
        }
 
@@ -938,8 +1024,20 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
                goto err_exit;
        }
 
+       if (vlan_insert_action) {
+               errmsg = "VLAN push/Insert action is not supported on Ingress";
+               errcode = ENOTSUP;
+               goto err_exit;
+       }
+
+       if (req_act & OTX2_FLOW_ACT_VLAN_STRIP)
+               npc->vtag_actions++;
+
+       /* Only VLAN action is provided */
+       if (req_act == OTX2_FLOW_ACT_VLAN_STRIP)
+               flow->npc_action = NIX_RX_ACTIONOP_UCAST;
        /* Set NIX_RX_ACTIONOP */
-       if (req_act & (OTX2_FLOW_ACT_PF | OTX2_FLOW_ACT_VF)) {
+       else if (req_act & (OTX2_FLOW_ACT_PF | OTX2_FLOW_ACT_VF)) {
                flow->npc_action = NIX_RX_ACTIONOP_UCAST;
                if (req_act & OTX2_FLOW_ACT_QUEUE)
                        flow->npc_action |= (uint64_t)rq << 20;
@@ -985,6 +1083,11 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev,
                otx2_eth_set_rx_function(dev);
        }
 
+       if (npc->vtag_actions == 1) {
+               hw->rx_offload_flags |= NIX_RX_OFFLOAD_VLAN_STRIP_F;
+               otx2_eth_set_rx_function(dev);
+       }
+
 set_pf_func:
        /* Ideally AF must ensure that correct pf_func is set */
        flow->npc_action |= (uint64_t)pf_func << 4;