[v3,39/51] net/bnxt: add conditional execution of mapper tables
diff mbox series

Message ID 20200702041134.43198-40-ajit.khaparde@broadcom.com
State Superseded, archived
Delegated to: Ajit Khaparde
Headers show
Series
  • add features for host-based flow management
Related show

Checks

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

Commit Message

Ajit Khaparde July 2, 2020, 4:11 a.m. UTC
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Added support for conditional execution of the mapper tables so that
actions like count will have table processed only if action count
is configured.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 45 +++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |  1 +
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |  8 ++++
 .../net/bnxt/tf_ulp/ulp_template_db_enum.h    | 12 ++++-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  2 +
 5 files changed, 67 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index e2b771c9f..d0931d411 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -2008,6 +2008,44 @@  ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
 	return rc;
 }
 
+/*
+ * Function to process the conditional opcode of the mapper table.
+ * returns 1 to skip the table.
+ * return 0 to continue processing the table.
+ */
+static int32_t
+ulp_mapper_tbl_cond_opcode_process(struct bnxt_ulp_mapper_parms *parms,
+				   struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+	int32_t rc = 1;
+
+	switch (tbl->cond_opcode) {
+	case BNXT_ULP_COND_OPCODE_NOP:
+		rc = 0;
+		break;
+	case BNXT_ULP_COND_OPCODE_COMP_FIELD:
+		if (tbl->cond_operand < BNXT_ULP_CF_IDX_LAST &&
+		    ULP_COMP_FLD_IDX_RD(parms, tbl->cond_operand))
+			rc = 0;
+		break;
+	case BNXT_ULP_COND_OPCODE_ACTION_BIT:
+		if (ULP_BITMAP_ISSET(parms->act_bitmap->bits,
+				     tbl->cond_operand))
+			rc = 0;
+		break;
+	case BNXT_ULP_COND_OPCODE_HDR_BIT:
+		if (ULP_BITMAP_ISSET(parms->hdr_bitmap->bits,
+				     tbl->cond_operand))
+			rc = 0;
+		break;
+	default:
+		BNXT_TF_DBG(ERR,
+			    "Invalid arg in mapper tbl for cond opcode\n");
+		break;
+	}
+	return rc;
+}
+
 /*
  * Function to process the action template. Iterate through the list
  * action info templates and process it.
@@ -2027,6 +2065,9 @@  ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 
 	for (i = 0; i < parms->num_atbls; i++) {
 		tbl = &parms->atbls[i];
+		if (ulp_mapper_tbl_cond_opcode_process(parms, tbl))
+			continue;
+
 		switch (tbl->resource_func) {
 		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
 			rc = ulp_mapper_index_tbl_process(parms, tbl, false);
@@ -2065,6 +2106,9 @@  ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 	for (i = 0; i < parms->num_ctbls; i++) {
 		struct bnxt_ulp_mapper_tbl_info *tbl = &parms->ctbls[i];
 
+		if (ulp_mapper_tbl_cond_opcode_process(parms, tbl))
+			continue;
+
 		switch (tbl->resource_func) {
 		case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
 			rc = ulp_mapper_tcam_tbl_process(parms, tbl);
@@ -2326,6 +2370,7 @@  ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	memset(&parms, 0, sizeof(parms));
 	parms.act_prop = cparms->act_prop;
 	parms.act_bitmap = cparms->act;
+	parms.hdr_bitmap = cparms->hdr_bitmap;
 	parms.regfile = &regfile;
 	parms.hdr_field = cparms->hdr_field;
 	parms.comp_fld = cparms->comp_fld;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h
index b159081b1..19134830a 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h
@@ -62,6 +62,7 @@  struct bnxt_ulp_mapper_parms {
 	uint32_t				num_ctbls;
 	struct ulp_rte_act_prop			*act_prop;
 	struct ulp_rte_act_bitmap		*act_bitmap;
+	struct ulp_rte_hdr_bitmap		*hdr_bitmap;
 	struct ulp_rte_hdr_field		*hdr_field;
 	uint32_t				*comp_fld;
 	struct ulp_regfile			*regfile;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 41ac77c6f..8fffaecce 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -1128,6 +1128,10 @@  ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
 		memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE],
 		       &ip_type, sizeof(uint32_t));
 
+		/* update the computed field to notify it is ipv4 header */
+		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG,
+				    1);
+
 		if (!ulp_rte_item_skip_void(&item, 1))
 			return BNXT_TF_RC_ERROR;
 	} else if (item->type == RTE_FLOW_ITEM_TYPE_IPV6) {
@@ -1148,6 +1152,10 @@  ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item,
 		memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE],
 		       &ip_type, sizeof(uint32_t));
 
+		/* update the computed field to notify it is ipv6 header */
+		ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG,
+				    1);
+
 		if (!ulp_rte_item_skip_void(&item, 1))
 			return BNXT_TF_RC_ERROR;
 	} else {
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 3168d29a9..27628a510 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
@@ -118,7 +118,17 @@  enum bnxt_ulp_cf_idx {
 	BNXT_ULP_CF_IDX_PHY_PORT_SPIF = 26,
 	BNXT_ULP_CF_IDX_PHY_PORT_PARIF = 27,
 	BNXT_ULP_CF_IDX_PHY_PORT_VPORT = 28,
-	BNXT_ULP_CF_IDX_LAST = 29
+	BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG = 29,
+	BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG = 30,
+	BNXT_ULP_CF_IDX_LAST = 31
+};
+
+enum bnxt_ulp_cond_opcode {
+	BNXT_ULP_COND_OPCODE_NOP = 0,
+	BNXT_ULP_COND_OPCODE_COMP_FIELD = 1,
+	BNXT_ULP_COND_OPCODE_ACTION_BIT = 2,
+	BNXT_ULP_COND_OPCODE_HDR_BIT = 3,
+	BNXT_ULP_COND_OPCODE_LAST = 4
 };
 
 enum bnxt_ulp_critical_resource {
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
index 5a7a7b910..df999b18c 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
@@ -165,6 +165,8 @@  struct bnxt_ulp_mapper_tbl_info {
 	enum bnxt_ulp_resource_func	resource_func;
 	uint32_t			resource_type; /* TF_ enum type */
 	enum bnxt_ulp_resource_sub_type	resource_sub_type;
+	enum bnxt_ulp_cond_opcode	cond_opcode;
+	uint32_t			cond_operand;
 	uint8_t		direction;
 	uint32_t	priority;
 	uint8_t		srch_b4_alloc;