[10/10] net/bnxt: add support for decrement ttl action
diff mbox series

Message ID 20200713061600.19456-11-somnath.kotur@broadcom.com
State Superseded
Delegated to: Ajit Khaparde
Headers show
Series
  • bnxt patches
Related show

Checks

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

Commit Message

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

Added support for decrement ttl action.

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>
---
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      | 30 +++++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      |  5 +++++
 drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c |  4 ++--
 3 files changed, 37 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index b63a454..5815024 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -189,6 +189,26 @@  bnxt_ulp_rte_parser_post_process(struct ulp_rte_parser_params *params)
 	    match_port_type == BNXT_ULP_INTF_TYPE_VF_REP)
 		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_VF_TO_VF, 1);
 
+	/* Update the decrement ttl computational fields */
+	if (ULP_BITMAP_ISSET(params->act_bitmap.bits,
+			     BNXT_ULP_ACTION_BIT_DEC_TTL)) {
+		/*
+		 * Check that vxlan proto is included and vxlan decap
+		 * action is not set then decrement tunnel ttl.
+		 * Similarly add GRE and NVGRE in future.
+		 */
+		if ((ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
+				      BNXT_ULP_HDR_BIT_T_VXLAN) &&
+		    !ULP_BITMAP_ISSET(params->act_bitmap.bits,
+				      BNXT_ULP_ACTION_BIT_VXLAN_DECAP))) {
+			ULP_COMP_FLD_IDX_WR(params,
+					    BNXT_ULP_CF_IDX_ACT_T_DEC_TTL, 1);
+		} else {
+			ULP_COMP_FLD_IDX_WR(params,
+					    BNXT_ULP_CF_IDX_ACT_DEC_TTL, 1);
+		}
+	}
+
 	/* TBD: Handle the flow rejection scenarios */
 	return 0;
 }
@@ -1814,3 +1834,13 @@  ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
 	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 dec ttl.*/
+int32_t
+ulp_rte_dec_ttl_act_handler(const struct rte_flow_action *act __rte_unused,
+			    struct ulp_rte_parser_params *params)
+{
+	/* Update the act_bitmap with dec ttl */
+	ULP_BITMAP_SET(params->act_bitmap.bits, BNXT_ULP_ACTION_BIT_DEC_TTL);
+	return BNXT_TF_RC_SUCCESS;
+}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
index e155250..7b6b57e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
@@ -216,4 +216,9 @@  int32_t
 ulp_rte_set_tp_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 dec ttl.*/
+int32_t
+ulp_rte_dec_ttl_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_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
index 5847e58..9a27cbf 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
@@ -259,8 +259,8 @@  struct bnxt_ulp_rte_act_info ulp_act_info[] = {
 		.proto_act_func          = NULL
 	},
 	[RTE_FLOW_ACTION_TYPE_DEC_TTL] = {
-		.act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-		.proto_act_func          = NULL
+		.act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+		.proto_act_func          = ulp_rte_dec_ttl_act_handler
 	},
 	[RTE_FLOW_ACTION_TYPE_SET_TTL] = {
 		.act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,