diff mbox series

[17/20] net/bnxt: add support for tp src/dst rte action items

Message ID 20200706082502.26935-18-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>

Added support for set transport port src and destination
rewrite action items. This allows changing the tcp or udp
source/destination ports for a given flow.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@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       | 44 ++++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h       | 10 ++++++
 drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h | 38 +++++++++++-----------
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c  |  8 ++---
 4 files changed, 77 insertions(+), 23 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 ac432b2..2f6a15d 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -1736,3 +1736,47 @@  ulp_rte_set_ipv4_dst_act_handler(const struct rte_flow_action *action_item,
 	BNXT_TF_DBG(ERR, "Parse Error: set ipv4 dst arg is invalid\n");
 	return BNXT_TF_RC_ERROR;
 }
+
+/* Function to handle the parsing of RTE Flow action set tp src.*/
+int32_t
+ulp_rte_set_tp_src_act_handler(const struct rte_flow_action *action_item,
+			       struct ulp_rte_parser_params *params)
+{
+	const struct rte_flow_action_set_tp *set_tp;
+	struct ulp_rte_act_prop *act = &params->act_prop;
+
+	set_tp = action_item->conf;
+	if (set_tp) {
+		memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC],
+		       &set_tp->port, BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC);
+		/* Update the hdr_bitmap with set tp src */
+		ULP_BITMAP_SET(params->act_bitmap.bits,
+			       BNXT_ULP_ACTION_BIT_SET_TP_SRC);
+		return BNXT_TF_RC_SUCCESS;
+	}
+
+	BNXT_TF_DBG(ERR, "Parse Error: set tp src arg is invalid\n");
+	return BNXT_TF_RC_ERROR;
+}
+
+/* Function to handle the parsing of RTE Flow action set tp dst.*/
+int32_t
+ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
+			       struct ulp_rte_parser_params *params)
+{
+	const struct rte_flow_action_set_tp *set_tp;
+	struct ulp_rte_act_prop *act = &params->act_prop;
+
+	set_tp = action_item->conf;
+	if (set_tp) {
+		memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_TP_DST],
+		       &set_tp->port, BNXT_ULP_ACT_PROP_SZ_SET_TP_DST);
+		/* Update the hdr_bitmap with set tp dst */
+		ULP_BITMAP_SET(params->act_bitmap.bits,
+			       BNXT_ULP_ACTION_BIT_SET_TP_DST);
+		return BNXT_TF_RC_SUCCESS;
+	}
+
+	BNXT_TF_DBG(ERR, "Parse Error: set tp src 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 6cb83b9..e155250 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
@@ -206,4 +206,14 @@  int32_t
 ulp_rte_set_ipv4_dst_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 tp src.*/
+int32_t
+ulp_rte_set_tp_src_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 tp dst.*/
+int32_t
+ulp_rte_set_tp_dst_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 436f54c..6b68b95 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
@@ -560,8 +560,8 @@  enum bnxt_ulp_act_prop_sz {
 	BNXT_ULP_ACT_PROP_SZ_SET_IPV4_DST = 4,
 	BNXT_ULP_ACT_PROP_SZ_SET_IPV6_SRC = 16,
 	BNXT_ULP_ACT_PROP_SZ_SET_IPV6_DST = 16,
-	BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC = 4,
-	BNXT_ULP_ACT_PROP_SZ_SET_TP_DST = 4,
+	BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC = 2,
+	BNXT_ULP_ACT_PROP_SZ_SET_TP_DST = 2,
 	BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_0 = 4,
 	BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_1 = 4,
 	BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_2 = 4,
@@ -605,23 +605,23 @@  enum bnxt_ulp_act_prop_idx {
 	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_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_L2_SMAC = 159,
+	BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG = 165,
+	BNXT_ULP_ACT_PROP_IDX_ENCAP_IP = 173,
+	BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC = 205,
+	BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP = 221,
+	BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN = 225,
+	BNXT_ULP_ACT_PROP_IDX_LAST = 257
 };
 
 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 6fa74f8..5847e58 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
@@ -247,12 +247,12 @@  struct bnxt_ulp_rte_act_info ulp_act_info[] = {
 		.proto_act_func          = NULL
 	},
 	[RTE_FLOW_ACTION_TYPE_SET_TP_SRC] = {
-		.act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-		.proto_act_func          = NULL
+		.act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+		.proto_act_func          = ulp_rte_set_tp_src_act_handler
 	},
 	[RTE_FLOW_ACTION_TYPE_SET_TP_DST] = {
-		.act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-		.proto_act_func          = NULL
+		.act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+		.proto_act_func          = ulp_rte_set_tp_dst_act_handler
 	},
 	[RTE_FLOW_ACTION_TYPE_MAC_SWAP] = {
 		.act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,