net/bnxt: support VLAN push and pop actions
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Mon, 6 Jul 2020 08:24:51 +0000 (13:54 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:53 +0000 (06:18 +0200)
Add support for the vlan push and vlan pop actions

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
doc/guides/rel_notes/release_20_08.rst
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c

index 7d8f462..0c56af1 100644 (file)
@@ -98,6 +98,7 @@ New Features
   * Added support for rte_flow_query for COUNT action.
   * Added support for rx_burst_mode_get and tx_burst_mode_get.
   * Added vector mode support for ARM CPUs.
+  * Added support for VLAN push and pop actions.
 
 * **Updated Mellanox mlx5 driver.**
 
index b8146c8..8d35429 100644 (file)
@@ -1415,3 +1415,87 @@ ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item,
        ULP_BITMAP_SET(prm->act_bitmap.bits, BNXT_ULP_ACTION_BIT_VPORT);
        return BNXT_TF_RC_SUCCESS;
 }
+
+/* Function to handle the parsing of RTE Flow action pop vlan. */
+int32_t
+ulp_rte_of_pop_vlan_act_handler(const struct rte_flow_action *a __rte_unused,
+                               struct ulp_rte_parser_params *params)
+{
+       /* Update the act_bitmap with pop */
+       ULP_BITMAP_SET(params->act_bitmap.bits, BNXT_ULP_ACTION_BIT_POP_VLAN);
+       return BNXT_TF_RC_SUCCESS;
+}
+
+/* Function to handle the parsing of RTE Flow action push vlan. */
+int32_t
+ulp_rte_of_push_vlan_act_handler(const struct rte_flow_action *action_item,
+                                struct ulp_rte_parser_params *params)
+{
+       const struct rte_flow_action_of_push_vlan *push_vlan;
+       uint16_t ethertype;
+       struct ulp_rte_act_prop *act = &params->act_prop;
+
+       push_vlan = action_item->conf;
+       if (push_vlan) {
+               ethertype = push_vlan->ethertype;
+               if (tfp_cpu_to_be_16(ethertype) != RTE_ETHER_TYPE_VLAN) {
+                       BNXT_TF_DBG(ERR,
+                                   "Parse Err: Ethertype not supported\n");
+                       return BNXT_TF_RC_PARSE_ERR;
+               }
+               memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_PUSH_VLAN],
+                      &ethertype, BNXT_ULP_ACT_PROP_SZ_PUSH_VLAN);
+               /* Update the hdr_bitmap with push vlan */
+               ULP_BITMAP_SET(params->act_bitmap.bits,
+                              BNXT_ULP_ACTION_BIT_PUSH_VLAN);
+               return BNXT_TF_RC_SUCCESS;
+       }
+       BNXT_TF_DBG(ERR, "Parse Error: Push vlan arg is invalid\n");
+       return BNXT_TF_RC_ERROR;
+}
+
+/* Function to handle the parsing of RTE Flow action set vlan id. */
+int32_t
+ulp_rte_of_set_vlan_vid_act_handler(const struct rte_flow_action *action_item,
+                                   struct ulp_rte_parser_params *params)
+{
+       const struct rte_flow_action_of_set_vlan_vid *vlan_vid;
+       uint32_t vid;
+       struct ulp_rte_act_prop *act = &params->act_prop;
+
+       vlan_vid = action_item->conf;
+       if (vlan_vid && vlan_vid->vlan_vid) {
+               vid = vlan_vid->vlan_vid;
+               memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_VLAN_VID],
+                      &vid, BNXT_ULP_ACT_PROP_SZ_SET_VLAN_VID);
+               /* Update the hdr_bitmap with vlan vid */
+               ULP_BITMAP_SET(params->act_bitmap.bits,
+                              BNXT_ULP_ACTION_BIT_SET_VLAN_VID);
+               return BNXT_TF_RC_SUCCESS;
+       }
+       BNXT_TF_DBG(ERR, "Parse Error: Vlan vid arg is invalid\n");
+       return BNXT_TF_RC_ERROR;
+}
+
+/* Function to handle the parsing of RTE Flow action set vlan pcp. */
+int32_t
+ulp_rte_of_set_vlan_pcp_act_handler(const struct rte_flow_action *action_item,
+                                   struct ulp_rte_parser_params *params)
+{
+       const struct rte_flow_action_of_set_vlan_pcp *vlan_pcp;
+       uint8_t pcp;
+       struct ulp_rte_act_prop *act = &params->act_prop;
+
+       vlan_pcp = action_item->conf;
+       if (vlan_pcp) {
+               pcp = vlan_pcp->vlan_pcp;
+               memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_VLAN_PCP],
+                      &pcp, BNXT_ULP_ACT_PROP_SZ_SET_VLAN_PCP);
+               /* Update the hdr_bitmap with vlan vid */
+               ULP_BITMAP_SET(params->act_bitmap.bits,
+                              BNXT_ULP_ACTION_BIT_SET_VLAN_PCP);
+               return BNXT_TF_RC_SUCCESS;
+       }
+       BNXT_TF_DBG(ERR, "Parse Error: Vlan pcp arg is invalid\n");
+       return BNXT_TF_RC_ERROR;
+}
index 8788431..1bb4721 100644 (file)
@@ -170,4 +170,24 @@ int32_t
 ulp_rte_phy_port_act_handler(const struct rte_flow_action *action_item,
                             struct ulp_rte_parser_params *params);
 
+/* Function to handle the parsing of RTE Flow action pop vlan. */
+int32_t
+ulp_rte_of_pop_vlan_act_handler(const struct rte_flow_action *action_item,
+                               struct ulp_rte_parser_params *params);
+
+/* Function to handle the parsing of RTE Flow action push vlan. */
+int32_t
+ulp_rte_of_push_vlan_act_handler(const struct rte_flow_action *action_item,
+                                struct ulp_rte_parser_params *params);
+
+/* Function to handle the parsing of RTE Flow action set vlan id. */
+int32_t
+ulp_rte_of_set_vlan_vid_act_handler(const struct rte_flow_action *action_item,
+                                   struct ulp_rte_parser_params *params);
+
+/* Function to handle the parsing of RTE Flow action set vlan pcp. */
+int32_t
+ulp_rte_of_set_vlan_pcp_act_handler(const struct rte_flow_action *action_item,
+                                   struct ulp_rte_parser_params *params);
+
 #endif /* _ULP_RTE_PARSER_H_ */
index 892d8ea..f232bdb 100644 (file)
@@ -539,9 +539,9 @@ enum bnxt_ulp_act_prop_sz {
        BNXT_ULP_ACT_PROP_SZ_METER = 4,
        BNXT_ULP_ACT_PROP_SZ_SET_MAC_SRC = 8,
        BNXT_ULP_ACT_PROP_SZ_SET_MAC_DST = 8,
-       BNXT_ULP_ACT_PROP_SZ_OF_PUSH_VLAN = 4,
-       BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_PCP = 4,
-       BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_VID = 4,
+       BNXT_ULP_ACT_PROP_SZ_PUSH_VLAN = 2,
+       BNXT_ULP_ACT_PROP_SZ_SET_VLAN_PCP = 1,
+       BNXT_ULP_ACT_PROP_SZ_SET_VLAN_VID = 2,
        BNXT_ULP_ACT_PROP_SZ_SET_IPV4_SRC = 4,
        BNXT_ULP_ACT_PROP_SZ_SET_IPV4_DST = 4,
        BNXT_ULP_ACT_PROP_SZ_SET_IPV6_SRC = 16,
@@ -583,31 +583,31 @@ enum bnxt_ulp_act_prop_idx {
        BNXT_ULP_ACT_PROP_IDX_METER = 52,
        BNXT_ULP_ACT_PROP_IDX_SET_MAC_SRC = 56,
        BNXT_ULP_ACT_PROP_IDX_SET_MAC_DST = 64,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_VLAN = 72,
-       BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_PCP = 76,
-       BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_VID = 80,
-       BNXT_ULP_ACT_PROP_IDX_SET_IPV4_SRC = 84,
-       BNXT_ULP_ACT_PROP_IDX_SET_IPV4_DST = 88,
-       BNXT_ULP_ACT_PROP_IDX_SET_IPV6_SRC = 92,
-       BNXT_ULP_ACT_PROP_IDX_SET_IPV6_DST = 108,
-       BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC = 124,
-       BNXT_ULP_ACT_PROP_IDX_SET_TP_DST = 128,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_0 = 132,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_1 = 136,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_2 = 140,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_3 = 144,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_4 = 148,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_5 = 152,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_6 = 156,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_7 = 160,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC = 164,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC = 170,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG = 176,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP = 184,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC = 216,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP = 232,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN = 236,
-       BNXT_ULP_ACT_PROP_IDX_LAST = 268
+       BNXT_ULP_ACT_PROP_IDX_PUSH_VLAN = 72,
+       BNXT_ULP_ACT_PROP_IDX_SET_VLAN_PCP = 74,
+       BNXT_ULP_ACT_PROP_IDX_SET_VLAN_VID = 75,
+       BNXT_ULP_ACT_PROP_IDX_SET_IPV4_SRC = 77,
+       BNXT_ULP_ACT_PROP_IDX_SET_IPV4_DST = 81,
+       BNXT_ULP_ACT_PROP_IDX_SET_IPV6_SRC = 85,
+       BNXT_ULP_ACT_PROP_IDX_SET_IPV6_DST = 101,
+       BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC = 117,
+       BNXT_ULP_ACT_PROP_IDX_SET_TP_DST = 121,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_0 = 125,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_1 = 129,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_2 = 133,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_3 = 137,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_4 = 141,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_5 = 145,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_6 = 149,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_7 = 153,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC = 157,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC = 163,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG = 169,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP = 177,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC = 209,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP = 225,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN = 229,
+       BNXT_ULP_ACT_PROP_IDX_LAST = 261
 };
 
 enum bnxt_ulp_class_hid {
index f0a57cf..2cc3458 100644 (file)
@@ -41,12 +41,12 @@ uint32_t ulp_act_prop_map_table[] = {
                BNXT_ULP_ACT_PROP_SZ_SET_MAC_SRC,
        [BNXT_ULP_ACT_PROP_IDX_SET_MAC_DST] =
                BNXT_ULP_ACT_PROP_SZ_SET_MAC_DST,
-       [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_VLAN] =
-               BNXT_ULP_ACT_PROP_SZ_OF_PUSH_VLAN,
-       [BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_PCP] =
-               BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_PCP,
-       [BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_VID] =
-               BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_VID,
+       [BNXT_ULP_ACT_PROP_IDX_PUSH_VLAN] =
+               BNXT_ULP_ACT_PROP_SZ_PUSH_VLAN,
+       [BNXT_ULP_ACT_PROP_IDX_SET_VLAN_PCP] =
+               BNXT_ULP_ACT_PROP_SZ_SET_VLAN_PCP,
+       [BNXT_ULP_ACT_PROP_IDX_SET_VLAN_VID] =
+               BNXT_ULP_ACT_PROP_SZ_SET_VLAN_VID,
        [BNXT_ULP_ACT_PROP_IDX_SET_IPV4_SRC] =
                BNXT_ULP_ACT_PROP_SZ_SET_IPV4_SRC,
        [BNXT_ULP_ACT_PROP_IDX_SET_IPV4_DST] =
@@ -183,20 +183,20 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = {
                .proto_act_func          = NULL
        },
        [RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_of_pop_vlan_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_of_push_vlan_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_of_set_vlan_vid_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_of_set_vlan_pcp_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_OF_POP_MPLS] = {
                .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,