diff mbox series

[09/20] net/bnxt: add support for vlan push and vlan pop actions

Message ID 20200706082502.26935-10-somnath.kotur@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers show
Series bnxt patches | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Somnath Kotur July 6, 2020, 8:24 a.m. UTC
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Add support for the vlan push and vlan pop actions

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Michael Baucom <michael.baucom@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c       | 84 ++++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h       | 20 ++++++
 drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h | 56 ++++++++---------
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c  | 28 ++++-----
 4 files changed, 146 insertions(+), 42 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index b8146c8..8d35429 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -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;
+}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
index 8788431..1bb4721 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
@@ -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_ */
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
index 892d8ea..f232bdb 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
@@ -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 =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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 {
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
index f0a57cf..2cc3458 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
@@ -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,