Skip to contentSkip to conversation

enhancements to host based flow table management

PATCH New Venkat Duvvuru 2 participants 26 messages Apr 15, 2020 – Apr 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover enhancements to host based flow table management

This patchset introduces enhancements to the flow table management related to resource sharing and deletion, flow matching performance, and flow flushing. Additionally, a new port database was introduced to store frequently required port mappings and resources.

Kishore Padmanabha (5):
net/bnxt: Added flow database resource iteration API net/bnxt: aggregated ulp rte parser arguments to single structure net/bnxt: use hashing for flow template matching net/bnxt: addition of session and function flow flush net/bnxt: addition of the port database

Mike Baucom (6):
net/bnxt: SVIF changes for dpdk port id
net/bnxt: allow usage of more resources in flow db net/bnxt: added type of resource name to debug messages net/bnxt: aggregated ulp mapper create arguments to single structure net/bnxt: default identifiers added to ulp mapper net/bnxt: cache table type added for tcam lookups

 drivers/net/bnxt/Makefile                       |    1 +
 drivers/net/bnxt/bnxt.h                         |    1 +
 drivers/net/bnxt/bnxt_ethdev.c                  |   12 +
 drivers/net/bnxt/meson.build                    |    1 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c              |   90 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h              |   20 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c         |  170 ++--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c           |  221 ++++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h           |   63 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c            |  801 ++++++++++++++--
 drivers/net/bnxt/tf_ulp/ulp_mapper.h            |   72 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c           |  220 ++---
 drivers/net/bnxt/tf_ulp/ulp_matcher.h           |   12 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c           |  264 ++++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h           |  134 +++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c        | 1124 ++++++++++++-----------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h        |  155 ++--
 drivers/net/bnxt/tf_ulp/ulp_template_db.c       |  459 +++++----
 drivers/net/bnxt/tf_ulp/ulp_template_db.h       |  313 ++++---
 drivers/net/bnxt/tf_ulp/ulp_template_field_db.h |  171 ++--
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h   |  117 ++-
 drivers/net/bnxt/tf_ulp/ulp_utils.c             |   33 +
 drivers/net/bnxt/tf_ulp/ulp_utils.h             |   17 +-
 23 files changed, 3050 insertions(+), 1421 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/11 net/bnxt: SVIF changes for dpdk port id

From: Mike Baucom <[email protected]>

Modification of the parser to get the SVIF from the driver for matches on port_id, pf, and phy_port.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c  | 31 +++++------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 92 +++++++++++++++++++++++++-------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h |  5 ++
 3 files changed, 90 insertions(+), 38 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +12 -19
index 4958895..6203a49 100644
@@ -72,14 +72,14 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	struct ulp_rte_act_bitmap act_bitmap;
 	struct ulp_rte_act_prop act_prop;
 	enum ulp_direction_type dir = ULP_DIR_INGRESS;
-	uint32_t class_id, act_tmpl;
-	uint32_t app_priority;
-	int ret;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
-	uint32_t vnic;
-	uint8_t svif;
+	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
+	uint32_t app_priority;
 	uint32_t fid;
+	uint8_t	*buffer;
+	uint32_t vnic;
+	int ret;
 
 	if (bnxt_ulp_flow_validate_args(attr,
 					pattern, actions,
@@ -100,19 +100,15 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	memset(&act_bitmap, 0, sizeof(act_bitmap));
 	memset(&act_prop, 0, sizeof(act_prop));
 
-	svif = bnxt_get_svif(dev->data->port_id, false);
-	BNXT_TF_DBG(ERR, "SVIF for port[%d][port]=0x%08x\n",
-		    dev->data->port_id, svif);
+	if (attr->egress)
+		dir = ULP_DIR_EGRESS;
 
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif);
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec[0] = svif;
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask[0] = -1;
-	ULP_BITMAP_SET(hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF);
+	/* copy the device port id and direction in svif for further process */
+	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
+	rte_memcpy(buffer + sizeof(uint16_t), &dir, sizeof(uint32_t));
 
-	/*
-	 * VNIC is being pushed as 32bit and the pop will take care of
-	 * proper size
-	 */
+	/* Set the implicit vnic in the action property */
 	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
 	vnic = htonl(vnic);
 	rte_memcpy(&act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
@@ -132,9 +128,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
-
 	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
 					&act_bitmap, &class_id);
 
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +73 -19

168 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +5 -0
index 0ab43d2..0d571bb 100644
@@ -20,6 +20,11 @@
 #define BNXT_ULP_ENCAP_IPV6_SIZE		8
 #define BNXT_ULP_ENCAP_UDP_SIZE			4
 
+/* Function to handle the parsing of the RTE port id. */
+int32_t
+ulp_rte_parser_svif_process(struct ulp_rte_hdr_bitmap	*hdr_bitmap,
+			    struct ulp_rte_hdr_field	*hdr_field);
+
 /*
  * Function to handle the parsing of RTE Flows and placing
  * the RTE flow items into the ulp structures.
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/11 net/bnxt: allow usage of more resources in flow db

In reply to Venkat Duvvuru

From: Mike Baucom <[email protected]>

Allow the flow db resources to be more effectively utilized.

---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +5 -1
index aed5078..e99e94a 100644
@@ -331,6 +331,10 @@ int32_t ulp_flow_db_fid_alloc(struct bnxt_ulp_context		*ulp_ctxt,
 		BNXT_TF_DBG(ERR, "Flow database has reached max flows\n");
 		return -ENOMEM;
 	}
+	if (flow_tbl->tail_index <= (flow_tbl->head_index + 1)) {
+		BNXT_TF_DBG(ERR, "Flow database has reached max resources\n");
+		return -ENOMEM;
+	}
 	*fid = flow_tbl->flow_tbl_stack[flow_tbl->head_index];
 	flow_tbl->head_index++;
 	ulp_flow_db_active_flow_set(flow_tbl, *fid, 1);
@@ -385,7 +389,7 @@ int32_t	ulp_flow_db_resource_add(struct bnxt_ulp_context	*ulp_ctxt,
 	}
 
 	/* check for max resource */
-	if ((flow_tbl->num_flows + 1) >= flow_tbl->tail_index) {
+	if ((flow_tbl->head_index + 1) >= flow_tbl->tail_index) {
 		BNXT_TF_DBG(ERR, "Flow db has reached max resources\n");
 		return -ENOMEM;
 	}
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/11 net/bnxt: Added flow database resource iteration API

In reply to Venkat Duvvuru

From: Kishore Padmanabha <[email protected]>

This API can be used to iterate individual resource functions in the flow database.

---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 66 ++++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 17 +++++++++
 2 files changed, 82 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +65 -1
index e99e94a..9e7f9f5 100644
@@ -560,7 +560,71 @@ int32_t	ulp_flow_db_fid_free(struct bnxt_ulp_context		*ulp_ctxt,
 	return 0;
 }
 
-/** Get the flow database entry iteratively
+/*
+ * Get the flow database entry details
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * tbl_idx [in] Specify it is regular or default flow
+ * fid [in] The index to the flow entry
+ * nxt_idx [in/out] the index to the next entry
+ * params [out] The contents to be copied into params.
+ *
+ * returns 0 on success and negative on failure.
+ */
+int32_t	ulp_flow_db_resource_get(struct bnxt_ulp_context	*ulp_ctxt,
+				 enum bnxt_ulp_flow_db_tables	tbl_idx,
+				 uint32_t			fid,
+				 uint32_t			*nxt_idx,
+				 struct ulp_flow_db_res_params	*params)
+{
+	struct bnxt_ulp_flow_db		*flow_db;
+	struct bnxt_ulp_flow_tbl	*flow_tbl;
+	struct ulp_fdb_resource_info	*nxt_resource, *fid_resource;
+
+	flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+	if (!flow_db) {
+		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+		return -EINVAL;
+	}
+
+	if (tbl_idx >= BNXT_ULP_FLOW_TABLE_MAX) {
+		BNXT_TF_DBG(ERR, "Invalid table index\n");
+		return -EINVAL;
+	}
+
+	flow_tbl = &flow_db->flow_tbl[tbl_idx];
+
+	/* check for limits of fid */
+	if (fid >= flow_tbl->num_flows || !fid) {
+		BNXT_TF_DBG(ERR, "Invalid flow index\n");
+		return -EINVAL;
+	}
+
+	/* check if the flow is active or not */
+	if (!ulp_flow_db_active_flow_is_set(flow_tbl, fid)) {
+		BNXT_TF_DBG(ERR, "flow does not exist\n");
+		return -EINVAL;
+	}
+
+	if (!*nxt_idx) {
+		fid_resource = &flow_tbl->flow_resources[fid];
+		ulp_flow_db_res_info_to_params(fid_resource, params);
+		ULP_FLOW_DB_RES_NXT_SET(*nxt_idx,
+					fid_resource->nxt_resource_idx);
+	} else {
+		nxt_resource = &flow_tbl->flow_resources[*nxt_idx];
+		ulp_flow_db_res_info_to_params(nxt_resource, params);
+		*nxt_idx = 0;
+		ULP_FLOW_DB_RES_NXT_SET(*nxt_idx,
+					nxt_resource->nxt_resource_idx);
+	}
+
+	/* all good, return success */
+	return 0;
+}
+
+/*
+ * Get the flow database entry iteratively
  *
  * flow_tbl [in] Ptr to flow table
  * fid [in/out] The index to the flow entry
drivers/net/bnxt/tf_ulp/ulp_flow_db.h +17 -0
index 5435415..5361dd0 100644
@@ -143,6 +143,23 @@ int32_t	ulp_flow_db_fid_free(struct bnxt_ulp_context		*ulp_ctxt,
 			     uint32_t				fid);
 
 /*
+ *Get the flow database entry details
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * tbl_idx [in] Specify it is regular or default flow
+ * fid [in] The index to the flow entry
+ * nxt_idx [in/out] the index to the next entry
+ * params [out] The contents to be copied into params.
+ *
+ * returns 0 on success and negative on failure.
+ */
+int32_t	ulp_flow_db_resource_get(struct bnxt_ulp_context	*ulp_ctxt,
+				 enum bnxt_ulp_flow_db_tables	tbl_idx,
+				 uint32_t			fid,
+				 uint32_t			*nxt_idx,
+				 struct ulp_flow_db_res_params	*params);
+
+/*
  * Flush all flows in the flow database.
  *
  * ulp_ctxt [in] Ptr to ulp context
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/11 net/bnxt: added type of resource name to debug messages

In reply to Venkat Duvvuru

From: Mike Baucom <[email protected]>

Added the name of the resource to the index/result and key/mask common builder functions.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 61 ++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 27 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +34 -27
index a5fb1a3..84d5ac6 100644
@@ -365,7 +365,8 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 static int32_t
 ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 				struct bnxt_ulp_mapper_result_field_info *fld,
-				struct ulp_blob *blob)
+				struct ulp_blob *blob,
+				const char *name)
 {
 	uint16_t idx, size_idx;
 	uint8_t	 *val = NULL;
@@ -376,20 +377,20 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT:
 		val = fld->result_operand;
 		if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
-			BNXT_TF_DBG(ERR, "Failed to add field\n");
+			BNXT_TF_DBG(ERR, "%s failed to add field\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
 
 		if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) {
-			BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", idx);
+			BNXT_TF_DBG(ERR, "%s act_prop[%d] oob\n", name, idx);
 			return -EINVAL;
 		}
 		val = &parms->act_prop->act_details[idx];
@@ -400,20 +401,20 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 			val += field_size;
 		}
 		if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
-			BNXT_TF_DBG(ERR, "push field failed\n");
+			BNXT_TF_DBG(ERR, "%s push field failed\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP_SZ:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
 
 		if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) {
-			BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", idx);
+			BNXT_TF_DBG(ERR, "%s act_prop[%d] oob\n", name, idx);
 			return -EINVAL;
 		}
 		val = &parms->act_prop->act_details[idx];
@@ -421,7 +422,7 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 		/* get the size index next */
 		if (!ulp_operand_read(&fld->result_operand[sizeof(uint16_t)],
 				      (uint8_t *)&size_idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 		size_idx = tfp_be_to_cpu_16(size_idx);
@@ -439,20 +440,21 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_RESULT_OPC_SET_TO_REGFILE:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 
 		idx = tfp_be_to_cpu_16(idx);
 		/* Uninitialized regfile entries return 0 */
 		if (!ulp_regfile_read(parms->regfile, idx, &regval)) {
-			BNXT_TF_DBG(ERR, "regfile[%d] read oob\n", idx);
+			BNXT_TF_DBG(ERR, "%s regfile[%d] read oob\n",
+				    name, idx);
 			return -EINVAL;
 		}
 
 		val = ulp_blob_push_64(blob, &regval, fld->field_bit_size);
 		if (!val) {
-			BNXT_TF_DBG(ERR, "push field failed\n");
+			BNXT_TF_DBG(ERR, "%s push field failed\n", name);
 			return -EINVAL;
 		}
 		break;
@@ -468,7 +470,8 @@ static int32_t
 ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 				 struct bnxt_ulp_mapper_class_key_field_info *f,
 				 struct ulp_blob *blob,
-				 uint8_t is_key)
+				 uint8_t is_key,
+				 const char *name)
 {
 	uint64_t regval;
 	uint16_t idx, bitlen;
@@ -493,13 +496,13 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_SPEC_OPC_SET_TO_CONSTANT:
 		val = operand;
 		if (!ulp_blob_push(blob, val, bitlen)) {
-			BNXT_TF_DBG(ERR, "push to key blob failed\n");
+			BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_SPEC_OPC_ADD_PAD:
 		if (!ulp_blob_pad_push(blob, bitlen)) {
-			BNXT_TF_DBG(ERR, "Pad too large for blob\n");
+			BNXT_TF_DBG(ERR, "%s pad too large for blob\n", name);
 			return -EINVAL;
 		}
 
@@ -507,7 +510,7 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_SPEC_OPC_SET_TO_HDR_FIELD:
 		if (!ulp_operand_read(operand, (uint8_t *)&idx,
 				      sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "key operand read failed.\n");
+			BNXT_TF_DBG(ERR, "%s key operand read failed.\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
@@ -527,27 +530,27 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 		}
 
 		if (!ulp_blob_push(blob, val, bitlen)) {
-			BNXT_TF_DBG(ERR, "push to key blob failed\n");
+			BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_SPEC_OPC_SET_TO_REGFILE:
 		if (!ulp_operand_read(operand, (uint8_t *)&idx,
 				      sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "key operand read failed.\n");
+			BNXT_TF_DBG(ERR, "%s key operand read failed.\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
 
 		if (!ulp_regfile_read(regfile, idx, &regval)) {
-			BNXT_TF_DBG(ERR, "regfile[%d] read failed.\n",
-				    idx);
+			BNXT_TF_DBG(ERR, "%s regfile[%d] read failed.\n",
+				    name, idx);
 			return -EINVAL;
 		}
 
 		val = ulp_blob_push_64(blob, &regval, bitlen);
 		if (!val) {
-			BNXT_TF_DBG(ERR, "push to key blob failed\n");
+			BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
 			return -EINVAL;
 		}
 	default:
@@ -715,7 +718,8 @@ ulp_mapper_action_info_process(struct bnxt_ulp_mapper_parms *parms,
 		fld = &flds[i];
 		rc = ulp_mapper_result_field_process(parms,
 						     fld,
-						     &blob);
+						     &blob,
+						     "Action");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Action field failed\n");
 			return rc;
@@ -777,7 +781,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < num_kflds; i++) {
 		/* Setup the key */
 		rc = ulp_mapper_keymask_field_process(parms, &kflds[i],
-						      &key, 1);
+						      &key, 1, "TCAM Key");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Key field set failed.\n");
 			return rc;
@@ -785,7 +789,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
 		/* Setup the mask */
 		rc = ulp_mapper_keymask_field_process(parms, &kflds[i],
-						      &mask, 0);
+						      &mask, 0, "TCAM Mask");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Mask field set failed.\n");
 			return rc;
@@ -852,7 +856,8 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		for (i = 0; i < num_dflds; i++) {
 			rc = ulp_mapper_result_field_process(parms,
 							     &dflds[i],
-							     &data);
+							     &data,
+							     "TCAM Result");
 			if (rc) {
 				BNXT_TF_DBG(ERR, "Failed to set data fields\n");
 				goto error;
@@ -955,7 +960,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < num_kflds; i++) {
 		/* Setup the key */
 		rc = ulp_mapper_keymask_field_process(parms, &kflds[i],
-						      &key, 1);
+						      &key, 1, "EM Key");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Key field set failed.\n");
 			return rc;
@@ -981,7 +986,8 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
 		rc = ulp_mapper_result_field_process(parms,
 						     fld,
-						     &data);
+						     &data,
+						     "EM Result");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Failed to set data fields.\n");
 			return rc;
@@ -1130,7 +1136,8 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < num_flds; i++) {
 		rc = ulp_mapper_result_field_process(parms,
 						     &flds[i],
-						     &data);
+						     &data,
+						     "Indexed Result");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "data field failed\n");
 			return rc;
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/11 net/bnxt: aggregated ulp rte parser arguments to single structure

In reply to Venkat Duvvuru

From: Kishore Padmanabha <[email protected]>

The changes are to the ulp rte parser, the API are changed to take the parser param structure instead of individual fields.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  75 +--
 drivers/net/bnxt/tf_ulp/ulp_matcher.c         |  20 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.h         |  12 +-
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      | 882 +++++++++++++-------------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      | 150 ++---
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  42 +-
 6 files changed, 560 insertions(+), 621 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +25 -50
index 6203a49..026f33f 100644
@@ -67,11 +67,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		     const struct rte_flow_action	actions[],
 		     struct rte_flow_error		*error)
 {
-	struct ulp_rte_hdr_bitmap hdr_bitmap;
-	struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX];
-	struct ulp_rte_act_bitmap act_bitmap;
-	struct ulp_rte_act_prop act_prop;
-	enum ulp_direction_type dir = ULP_DIR_INGRESS;
+	struct ulp_rte_parser_params params;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
@@ -94,47 +90,38 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		return NULL;
 	}
 
-	/* clear the header bitmap and field structure */
-	memset(&hdr_bitmap, 0, sizeof(struct ulp_rte_hdr_bitmap));
-	memset(hdr_field, 0, sizeof(hdr_field));
-	memset(&act_bitmap, 0, sizeof(act_bitmap));
-	memset(&act_prop, 0, sizeof(act_prop));
+	/* Initialize the parser params */
+	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
 
 	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
+		params.dir = ULP_DIR_EGRESS;
 
-	/* copy the device port id and direction in svif for further process */
-	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	/* copy the device port id and direction for further processing */
+	buffer = params.hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
 	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
-	rte_memcpy(buffer + sizeof(uint16_t), &dir, sizeof(uint32_t));
 
 	/* Set the implicit vnic in the action property */
 	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
 	vnic = htonl(vnic);
-	rte_memcpy(&act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
+	rte_memcpy(&params.act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
 		   &vnic, BNXT_ULP_ACT_PROP_SZ_VNIC);
 
 	/* Parse the rte flow pattern */
-	ret = bnxt_ulp_rte_parser_hdr_parse(pattern,
-					    &hdr_bitmap,
-					    hdr_field);
+	ret = bnxt_ulp_rte_parser_hdr_parse(pattern, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
 	/* Parse the rte flow action */
-	ret = bnxt_ulp_rte_parser_act_parse(actions,
-					    &act_bitmap,
-					    &act_prop);
+	ret = bnxt_ulp_rte_parser_act_parse(actions, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
-					&act_bitmap, &class_id);
+	ret = ulp_matcher_pattern_match(&params, &class_id);
 
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	ret = ulp_matcher_action_match(dir, &act_bitmap, &act_tmpl);
+	ret = ulp_matcher_action_match(&params, &act_tmpl);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
@@ -142,10 +129,10 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	/* call the ulp mapper to create the flow in the hardware */
 	ret = ulp_mapper_flow_create(ulp_ctx,
 				     app_priority,
-				     &hdr_bitmap,
-				     hdr_field,
-				     &act_bitmap,
-				     &act_prop,
+				     &params.hdr_bitmap,
+				     params.hdr_field,
+				     &params.act_bitmap,
+				     &params.act_prop,
 				     class_id,
 				     act_tmpl,
 				     &fid);
@@ -168,11 +155,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 		       const struct rte_flow_action actions[],
 		       struct rte_flow_error *error)
 {
-	struct ulp_rte_hdr_bitmap hdr_bitmap;
-	struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX];
-	struct ulp_rte_act_bitmap act_bitmap;
-	struct ulp_rte_act_prop act_prop;
-	enum ulp_direction_type dir = ULP_DIR_INGRESS;
+	struct ulp_rte_parser_params		params;
 	uint32_t class_id, act_tmpl;
 	int ret;
 
@@ -183,36 +166,28 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 		return -EINVAL;
 	}
 
-	/* clear the header bitmap and field structure */
-	memset(&hdr_bitmap, 0, sizeof(struct ulp_rte_hdr_bitmap));
-	memset(hdr_field, 0, sizeof(hdr_field));
-	memset(&act_bitmap, 0, sizeof(act_bitmap));
-	memset(&act_prop, 0, sizeof(act_prop));
+	/* Initialize the parser params */
+	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
+
+	if (attr->egress)
+		params.dir = ULP_DIR_EGRESS;
 
 	/* Parse the rte flow pattern */
-	ret = bnxt_ulp_rte_parser_hdr_parse(pattern,
-					    &hdr_bitmap,
-					    hdr_field);
+	ret = bnxt_ulp_rte_parser_hdr_parse(pattern, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
 	/* Parse the rte flow action */
-	ret = bnxt_ulp_rte_parser_act_parse(actions,
-					    &act_bitmap,
-					    &act_prop);
+	ret = bnxt_ulp_rte_parser_act_parse(actions, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
-
-	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
-					&act_bitmap, &class_id);
+	ret = ulp_matcher_pattern_match(&params, &class_id);
 
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	ret = ulp_matcher_action_match(dir, &act_bitmap, &act_tmpl);
+	ret = ulp_matcher_action_match(&params, &act_tmpl);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
drivers/net/bnxt/tf_ulp/ulp_matcher.c +10 -10
index ec4121d..e04bfa0 100644
@@ -67,11 +67,8 @@ ulp_matcher_hdr_fields_normalize(struct ulp_rte_hdr_bitmap *hdr1,
  * the pattern masks against the flow templates.
  */
 int32_t
-ulp_matcher_pattern_match(enum ulp_direction_type   dir,
-			  struct ulp_rte_hdr_bitmap *hdr_bitmap,
-			  struct ulp_rte_hdr_field  *hdr_field,
-			  struct ulp_rte_act_bitmap *act_bitmap,
-			  uint32_t		    *class_id)
+ulp_matcher_pattern_match(struct ulp_rte_parser_params *params,
+			  uint32_t *class_id)
 {
 	struct bnxt_ulp_header_match_info	*sel_hdr_match;
 	uint32_t				hdr_num, idx, jdx;
@@ -80,9 +77,12 @@ ulp_matcher_pattern_match(enum ulp_direction_type   dir,
 	uint32_t				start_idx;
 	struct ulp_rte_hdr_field		*m_field;
 	struct bnxt_ulp_matcher_field_info	*sf;
+	struct ulp_rte_hdr_bitmap *hdr_bitmap = &params->hdr_bitmap;
+	struct ulp_rte_act_bitmap *act_bitmap = &params->act_bitmap;
+	struct ulp_rte_hdr_field *hdr_field = params->hdr_field;
 
 	/* Select the ingress or egress template to match against */
-	if (dir == ULP_DIR_INGRESS) {
+	if (params->dir == ULP_DIR_INGRESS) {
 		sel_hdr_match = ulp_ingress_hdr_match_list;
 		hdr_num = BNXT_ULP_INGRESS_HDR_MATCH_SZ;
 	} else {
@@ -156,15 +156,15 @@ ulp_matcher_pattern_match(enum ulp_direction_type   dir,
  * the action against the flow templates.
  */
 int32_t
-ulp_matcher_action_match(enum ulp_direction_type		dir,
-			 struct ulp_rte_act_bitmap		*act_bitmap,
-			 uint32_t				*act_id)
+ulp_matcher_action_match(struct ulp_rte_parser_params *params,
+			 uint32_t *act_id)
 {
 	struct bnxt_ulp_action_match_info	*sel_act_match;
 	uint32_t				act_num, idx;
+	struct ulp_rte_act_bitmap *act_bitmap = &params->act_bitmap;
 
 	/* Select the ingress or egress template to match against */
-	if (dir == ULP_DIR_INGRESS) {
+	if (params->dir == ULP_DIR_INGRESS) {
 		sel_act_match = ulp_ingress_act_match_list;
 		act_num = BNXT_ULP_INGRESS_ACT_MATCH_SZ;
 	} else {
drivers/net/bnxt/tf_ulp/ulp_matcher.h +4 -8
index c818bbe..fc19783 100644
@@ -17,19 +17,15 @@
  * the pattern masks against the flow templates.
  */
 int32_t
-ulp_matcher_pattern_match(enum ulp_direction_type	    dir,
-			  struct ulp_rte_hdr_bitmap	   *hdr_bitmap,
-			  struct ulp_rte_hdr_field	   *hdr_field,
-			  struct ulp_rte_act_bitmap	   *act_bitmap,
-			  uint32_t			   *class_id);
+ulp_matcher_pattern_match(struct ulp_rte_parser_params *params,
+			  uint32_t *class_id);
 
 /*
  * Function to handle the matching of RTE Flows and validating
  * the action against the flow templates.
  */
 int32_t
-ulp_matcher_action_match(enum ulp_direction_type	dir,
-			 struct ulp_rte_act_bitmap	*act_bitmap,
-			 uint32_t			*act_id);
+ulp_matcher_action_match(struct ulp_rte_parser_params *params,
+			 uint32_t *act_id);
 
 #endif /* ULP_MATCHER_H_ */
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +448 -434

1,329 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +50 -100

236 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_struct.h +23 -19

64 lines not on this page · raw message

Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/11 net/bnxt: aggregated ulp mapper create arguments to single structure

In reply to Venkat Duvvuru

From: Mike Baucom <[email protected]>

The changes are to the ulp mapper flow_create, the API changed to take the bnxt_ulp_mapper_create_parms structure instead of individual fields.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 19 ++++++++++---------
 drivers/net/bnxt/tf_ulp/ulp_mapper.c    | 33 +++++++++++++++------------------
 drivers/net/bnxt/tf_ulp/ulp_mapper.h    | 20 ++++++++++++--------
 3 files changed, 37 insertions(+), 35 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +10 -9
index 026f33f..9326401 100644
@@ -67,11 +67,11 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		     const struct rte_flow_action	actions[],
 		     struct rte_flow_error		*error)
 {
+	struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };
 	struct ulp_rte_parser_params params;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
-	uint32_t app_priority;
 	uint32_t fid;
 	uint8_t	*buffer;
 	uint32_t vnic;
@@ -125,16 +125,17 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	app_priority = attr->priority;
+	mapper_cparms.app_priority = attr->priority;
+	mapper_cparms.hdr_bitmap = &params.hdr_bitmap;
+	mapper_cparms.hdr_field = params.hdr_field;
+	mapper_cparms.act = &params.act_bitmap;
+	mapper_cparms.act_prop = &params.act_prop;
+	mapper_cparms.class_tid = class_id;
+	mapper_cparms.act_tid = act_tmpl;
+
 	/* call the ulp mapper to create the flow in the hardware */
 	ret = ulp_mapper_flow_create(ulp_ctx,
-				     app_priority,
-				     &params.hdr_bitmap,
-				     params.hdr_field,
-				     &params.act_bitmap,
-				     &params.act_prop,
-				     class_id,
-				     act_tmpl,
+				     &mapper_cparms,
 				     &fid);
 	if (!ret) {
 		flow_id = (struct rte_flow *)((uintptr_t)fid);
drivers/net/bnxt/tf_ulp/ulp_mapper.c +15 -18
index 84d5ac6..dd44938 100644
@@ -1411,26 +1411,23 @@ ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid)
  */
 int32_t
 ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
-		       uint32_t app_priority __rte_unused,
-		       struct ulp_rte_hdr_bitmap *hdr_bitmap __rte_unused,
-		       struct ulp_rte_hdr_field *hdr_field,
-		       struct ulp_rte_act_bitmap *act_bitmap,
-		       struct ulp_rte_act_prop *act_prop,
-		       uint32_t class_tid,
-		       uint32_t act_tid,
-		       uint32_t *flow_id)
+		       struct bnxt_ulp_mapper_create_parms *cparms,
+		       uint32_t *flowid)
 {
-	struct ulp_regfile		regfile;
-	struct bnxt_ulp_mapper_parms	parms;
-	struct bnxt_ulp_device_params	*device_params;
-	int32_t				rc, trc;
+	struct bnxt_ulp_device_params *device_params;
+	struct bnxt_ulp_mapper_parms parms;
+	struct ulp_regfile regfile;
+	int32_t	 rc, trc;
+
+	if (!ulp_ctx || !cparms)
+		return -EINVAL;
 
 	/* Initialize the parms structure */
 	memset(&parms, 0, sizeof(parms));
-	parms.act_prop = act_prop;
-	parms.act_bitmap = act_bitmap;
+	parms.act_prop = cparms->act_prop;
+	parms.act_bitmap = cparms->act;
 	parms.regfile = &regfile;
-	parms.hdr_field = hdr_field;
+	parms.hdr_field = cparms->hdr_field;
 	parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
 	parms.ulp_ctx = ulp_ctx;
 
@@ -1441,7 +1438,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	}
 
 	/* Get the action table entry from device id and act context id */
-	parms.act_tid = act_tid;
+	parms.act_tid = cparms->act_tid;
 	parms.atbls = ulp_mapper_action_tbl_list_get(parms.dev_id,
 						     parms.act_tid,
 						     &parms.num_atbls);
@@ -1452,7 +1449,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	}
 
 	/* Get the class table entry from device id and act context id */
-	parms.class_tid = class_tid;
+	parms.class_tid = cparms->class_tid;
 	parms.ctbls = ulp_mapper_class_tbl_list_get(parms.dev_id,
 						    parms.class_tid,
 						    &parms.num_ctbls);
@@ -1506,7 +1503,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 		goto flow_error;
 	}
 
-	*flow_id = parms.fid;
+	*flowid = parms.fid;
 
 	return rc;
 
drivers/net/bnxt/tf_ulp/ulp_mapper.h +12 -8
index 5f3d46e..24727a3 100644
@@ -38,20 +38,24 @@ struct bnxt_ulp_mapper_parms {
 	enum bnxt_ulp_flow_db_tables		tbl_idx;
 };
 
+struct bnxt_ulp_mapper_create_parms {
+	uint32_t			app_priority;
+	struct ulp_rte_hdr_bitmap	*hdr_bitmap;
+	struct ulp_rte_hdr_field	*hdr_field;
+	struct ulp_rte_act_bitmap	*act;
+	struct ulp_rte_act_prop		*act_prop;
+	uint32_t			class_tid;
+	uint32_t			act_tid;
+};
+
 /*
  * Function to handle the mapping of the Flow to be compatible
  * with the underlying hardware.
  */
 int32_t
 ulp_mapper_flow_create(struct bnxt_ulp_context	*ulp_ctx,
-		       uint32_t		app_priority,
-		       struct ulp_rte_hdr_bitmap  *hdr_bitmap,
-		       struct ulp_rte_hdr_field *hdr_field,
-		       struct ulp_rte_act_bitmap *act,
-		       struct ulp_rte_act_prop *act_prop,
-		       uint32_t		class_tid,
-		       uint32_t		act_tid,
-		       uint32_t		*flow_id);
+		       struct bnxt_ulp_mapper_create_parms *parms,
+		       uint32_t *flowid);
 
 /* Function that frees all resources associated with the flow. */
 int32_t
Signature · 1 line
2.7.4
#7 lore raw

PATCH 7/11 net/bnxt: use hashing for flow template matching

In reply to Venkat Duvvuru

From: Kishore Padmanabha <[email protected]>

Currently, all the flow templates are sequentially searched to find out whether there is a matching template for the incoming RTE_FLOW offload request. As sequential search will have performance concerns, this patch will address it by using hash algorithm to find out the flow template. This change resulted in creation of computed fields to remove the fields that do not participate in the hash calculations. The field bitmap is created for this purpose.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c         |  23 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c            |   4 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c           | 214 +++++++----------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c        | 282 ++++++++++++----------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h        |   4 +
 drivers/net/bnxt/tf_ulp/ulp_template_db.c       | 307 ++++++++++--------------
 drivers/net/bnxt/tf_ulp/ulp_template_db.h       | 280 +++++++++++++--------
 drivers/net/bnxt/tf_ulp/ulp_template_field_db.h | 171 ++++---------
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h   |  50 ++--
 drivers/net/bnxt/tf_ulp/ulp_utils.c             |  33 +++
 drivers/net/bnxt/tf_ulp/ulp_utils.h             |  17 +-
 11 files changed, 686 insertions(+), 699 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +8 -15
index 9326401..7f7aa24 100644
@@ -61,11 +61,11 @@ bnxt_ulp_flow_validate_args(const struct rte_flow_attr *attr,
 
 /* Function to create the rte flow. */
 static struct rte_flow *
-bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
-		     const struct rte_flow_attr		*attr,
-		     const struct rte_flow_item		pattern[],
-		     const struct rte_flow_action	actions[],
-		     struct rte_flow_error		*error)
+bnxt_ulp_flow_create(struct rte_eth_dev *dev,
+		     const struct rte_flow_attr *attr,
+		     const struct rte_flow_item pattern[],
+		     const struct rte_flow_action actions[],
+		     struct rte_flow_error *error)
 {
 	struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };
 	struct ulp_rte_parser_params params;
@@ -73,8 +73,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
 	uint32_t fid;
-	uint8_t	*buffer;
-	uint32_t vnic;
 	int ret;
 
 	if (bnxt_ulp_flow_validate_args(attr,
@@ -97,14 +95,9 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		params.dir = ULP_DIR_EGRESS;
 
 	/* copy the device port id and direction for further processing */
-	buffer = params.hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
-	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
-
-	/* Set the implicit vnic in the action property */
-	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
-	vnic = htonl(vnic);
-	rte_memcpy(&params.act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
-		   &vnic, BNXT_ULP_ACT_PROP_SZ_VNIC);
+	ULP_UTIL_CHF_IDX_WR(&params, BNXT_ULP_CHF_IDX_INCOMING_IF,
+			    dev->data->port_id);
+	ULP_UTIL_CHF_IDX_WR(&params, BNXT_ULP_CHF_IDX_DIRECTION, params.dir);
 
 	/* Parse the rte flow pattern */
 	ret = bnxt_ulp_rte_parser_hdr_parse(pattern, &params);
drivers/net/bnxt/tf_ulp/ulp_mapper.c +2 -2
index dd44938..b8907b6 100644
@@ -357,7 +357,7 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 	(void)tf_free_identifier(tfp, &free_parms);
 
 	BNXT_TF_DBG(ERR, "Ident process failed for %s:%s\n",
-		    ident->name,
+		    ident->description,
 		    (tbl->direction == TF_DIR_RX) ? "RX" : "TX");
 	return rc;
 }
@@ -405,7 +405,7 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 			return -EINVAL;
 		}
 		break;
-	case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP_SZ:
+	case BNXT_ULP_RESULT_OPC_SET_TO_ENCAP_ACT_PROP_SZ:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
 			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
drivers/net/bnxt/tf_ulp/ulp_matcher.c +88 -126

249 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +150 -132

506 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +4 -0
index 4cc9dcc..cbc8a43 100644
@@ -24,6 +24,10 @@
 int32_t
 ulp_rte_parser_svif_process(struct ulp_rte_parser_params *params);
 
+/* Function to handle the implicit VNIC RTE port id */
+int32_t
+ulp_rte_parser_vnic_process(struct ulp_rte_parser_params *params);
+
 /*
  * Function to handle the parsing of RTE Flows and placing
  * the RTE flow items into the ulp structures.
drivers/net/bnxt/tf_ulp/ulp_template_db.c +122 -185

478 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db.h +177 -103

378 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_field_db.h +52 -119

182 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_struct.h +34 -16

105 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_utils.c +33 -0
index 1d463cd..521109d 100644
@@ -519,3 +519,36 @@ int32_t ulp_buffer_is_empty(const uint8_t *buf, uint32_t size)
 {
 	return buf[0] == 0 && !memcmp(buf, buf + 1, size - 1);
 }
+
+/* Function to check if bitmap is zero.Return 1 on success */
+uint32_t ulp_bitmap_is_zero(uint8_t *bitmap, int32_t size)
+{
+	while (size-- > 0) {
+		if (*bitmap != 0)
+			return 0;
+		bitmap++;
+	}
+	return 1;
+}
+
+/* Function to check if bitmap is ones. Return 1 on success */
+uint32_t ulp_bitmap_is_ones(uint8_t *bitmap, int32_t size)
+{
+	while (size-- > 0) {
+		if (*bitmap != 0xFF)
+			return 0;
+		bitmap++;
+	}
+	return 1;
+}
+
+/* Function to check if bitmap is not zero. Return 1 on success */
+uint32_t ulp_bitmap_notzero(uint8_t *bitmap, int32_t size)
+{
+	while (size-- > 0) {
+		if (*bitmap != 0)
+			return 1;
+		bitmap++;
+	}
+	return 0;
+}
drivers/net/bnxt/tf_ulp/ulp_utils.h +16 -1
index db88546..e7f2e3b 100644
@@ -16,7 +16,7 @@
 #define ULP_BITMAP_SET(bitmap, val)	((bitmap) |= (val))
 #define ULP_BITMAP_RESET(bitmap, val)	((bitmap) &= ~(val))
 #define ULP_BITMAP_ISSET(bitmap, val)	((bitmap) & (val))
-#define ULP_BITSET_CMP(b1, b2)  memcmp(&(b1)->bits, \
+#define ULP_BITMAP_CMP(b1, b2)  memcmp(&(b1)->bits, \
 				&(b2)->bits, sizeof((b1)->bits))
 /*
  * Macros for bitmap sets and gets
@@ -50,6 +50,12 @@
 /* Macro to convert bits to bytes with no round off*/
 #define ULP_BITS_2_BYTE_NR(bits_x)	((bits_x) / 8)
 
+/* Macros to read the computed fields */
+#define ULP_UTIL_CHF_IDX_RD(params, idx) \
+	rte_be_to_cpu_32((params)->comp_fld[(idx)])
+
+#define ULP_UTIL_CHF_IDX_WR(params, idx, val)	\
+	((params)->comp_fld[(idx)] = rte_cpu_to_be_32((val)))
 /*
  * Making the blob statically sized to 128 bytes for now.
  * The blob must be initialized with ulp_blob_init prior to using.
@@ -276,4 +282,13 @@ ulp_encap_buffer_copy(uint8_t *dst,
  */
 int32_t ulp_buffer_is_empty(const uint8_t *buf, uint32_t size);
 
+/* Function to check if bitmap is zero.Return 1 on success */
+uint32_t ulp_bitmap_is_zero(uint8_t *bitmap, int32_t size);
+
+/* Function to check if bitmap is ones. Return 1 on success */
+uint32_t ulp_bitmap_is_ones(uint8_t *bitmap, int32_t size);
+
+/* Function to check if bitmap is not zero. Return 1 on success */
+uint32_t ulp_bitmap_notzero(uint8_t *bitmap, int32_t size);
+
 #endif /* _ULP_UTILS_H_ */
Signature · 1 line
2.7.4
#8 lore raw

PATCH 8/11 net/bnxt: addition of session and function flow flush

In reply to Venkat Duvvuru

From: Kishore Padmanabha <[email protected]>

The ulp flow flush has been extended to support session flow flush and function flow flush. The session flow flush is called when there the device is sole owner of the session and it deletes all the flows associated with that session. The function flow flush is called if the device function is not the sole owner of the session, it deletes all the flows that are associated with that device function.

---
 drivers/net/bnxt/bnxt.h                 |   1 +
 drivers/net/bnxt/bnxt_ethdev.c          |  12 +++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c      |   9 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c |  31 +++++--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c   | 149 ++++++++++++++++++++++++++++++--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h   |  46 +++++++++-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c    |   2 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h    |   1 +
 8 files changed, 225 insertions(+), 26 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index a70cdff..fb3bbdb 100644
@@ -737,5 +737,6 @@ void bnxt_ulp_deinit(struct bnxt *bp);
 
 uint16_t bnxt_get_vnic_id(uint16_t port);
 uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif);
+uint16_t bnxt_get_fw_func_id(uint16_t port);
 
 #endif
drivers/net/bnxt/bnxt_ethdev.c +12 -0
index 5d5b8e0..76ac284 100644
@@ -4748,6 +4748,18 @@ bnxt_get_vnic_id(uint16_t port)
 	return vnic->fw_vnic_id;
 }
 
+uint16_t
+bnxt_get_fw_func_id(uint16_t port)
+{
+	struct rte_eth_dev *eth_dev;
+	struct bnxt *bp;
+
+	eth_dev = &rte_eth_devices[port];
+	bp = eth_dev->data->dev_private;
+
+	return bp->fw_fid;
+}
+
 static int bnxt_init_fw(struct bnxt *bp)
 {
 	uint16_t mtu;
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +3 -6
index 56e08f2..4c36747 100644
@@ -659,10 +659,8 @@ int32_t
 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context	*ulp_ctx,
 				struct bnxt_ulp_flow_db	*flow_db)
 {
-	if (!ulp_ctx || !ulp_ctx->cfg_data) {
-		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+	if (!ulp_ctx || !ulp_ctx->cfg_data)
 		return -EINVAL;
-	}
 
 	ulp_ctx->cfg_data->flow_db = flow_db;
 	return 0;
@@ -672,10 +670,8 @@ bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context	*ulp_ctx,
 struct bnxt_ulp_flow_db	*
 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context	*ulp_ctx)
 {
-	if (!ulp_ctx || !ulp_ctx->cfg_data) {
-		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+	if (!ulp_ctx || !ulp_ctx->cfg_data)
 		return NULL;
-	}
 
 	return ulp_ctx->cfg_data->flow_db;
 }
@@ -693,3 +689,4 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev	*dev)
 	}
 	return &bp->ulp_ctx;
 }
+
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +23 -8
index 7f7aa24..f0c812c 100644
@@ -125,6 +125,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 	mapper_cparms.act_prop = &params.act_prop;
 	mapper_cparms.class_tid = class_id;
 	mapper_cparms.act_tid = act_tmpl;
+	mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id);
 
 	/* call the ulp mapper to create the flow in the hardware */
 	ret = ulp_mapper_flow_create(ulp_ctx,
@@ -202,7 +203,8 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 {
 	int ret = 0;
 	struct bnxt_ulp_context *ulp_ctx;
-	uint32_t fid;
+	uint32_t flow_id;
+	uint16_t func_id;
 
 	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);
 	if (!ulp_ctx) {
@@ -213,9 +215,19 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
-	fid = (uint32_t)(uintptr_t)flow;
+	flow_id = (uint32_t)(uintptr_t)flow;
+	func_id = bnxt_get_fw_func_id(dev->data->port_id);
 
-	ret = ulp_mapper_flow_destroy(ulp_ctx, fid);
+	if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) ==
+	    false) {
+		BNXT_TF_DBG(ERR, "Incorrect device params\n");
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Failed to destroy flow.");
+		return -EINVAL;
+	}
+
+	ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id);
 	if (ret)
 		rte_flow_error_set(error, -ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -230,8 +242,9 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
 		    struct rte_flow_error *error)
 {
 	struct bnxt_ulp_context *ulp_ctx;
-	int32_t ret;
+	int32_t ret = 0;
 	struct bnxt *bp;
+	uint16_t func_id;
 
 	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev);
 	if (!ulp_ctx) {
@@ -244,10 +257,12 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
 	bp = eth_dev->data->dev_private;
 
 	/* Free the resources for the last device */
-	if (!ulp_ctx_deinit_allowed(bp))
-		return 0;
-
-	ret = ulp_flow_db_flush_flows(ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
+	if (ulp_ctx_deinit_allowed(bp)) {
+		ret = ulp_flow_db_session_flow_flush(ulp_ctx);
+	} else if (bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctx)) {
+		func_id = bnxt_get_fw_func_id(eth_dev->data->port_id);
+		ret = ulp_flow_db_function_flow_flush(ulp_ctx, func_id);
+	}
 	if (ret)
 		rte_flow_error_set(error, ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +141 -8

216 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_flow_db.h +43 -3

66 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mapper.c +1 -1
index b8907b6..8675247 100644
@@ -461,7 +461,6 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 	default:
 		return -EINVAL;
 	}
-
 	return 0;
 }
 
@@ -1481,6 +1480,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	 */
 	rc = ulp_flow_db_fid_alloc(ulp_ctx,
 				   BNXT_ULP_REGULAR_FLOW_TABLE,
+				   cparms->func_id,
 				   &parms.fid);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Unable to allocate flow table entry\n");
drivers/net/bnxt/tf_ulp/ulp_mapper.h +1 -0
index 24727a3..2fa6ffc 100644
@@ -46,6 +46,7 @@ struct bnxt_ulp_mapper_create_parms {
 	struct ulp_rte_act_prop		*act_prop;
 	uint32_t			class_tid;
 	uint32_t			act_tid;
+	uint16_t			func_id;
 };
 
 /*
Signature · 1 line
2.7.4
#9 lore raw

PATCH 9/11 net/bnxt: default identifiers added to ulp mapper

In reply to Venkat Duvvuru

From: Mike Baucom <[email protected]>

- Added ulp_mapper_init/deinit to allocate/deallocate mapper data for storing the default identifiers
- Modified the template_db to include the new opcode for accessing the default ids.
- Modified the result and key field builders to use the new opcode for writing the default ids into blobs

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  33 ++++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |  10 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |   8 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 251 +++++++++++++++++++++++++-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |  22 ++-
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     |  35 ++--
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  25 ++-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  11 ++
 8 files changed, 363 insertions(+), 32 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +33 -0
index 4c36747..202b4a5 100644
@@ -19,6 +19,7 @@
 #include "ulp_template_struct.h"
 #include "ulp_mark_mgr.h"
 #include "ulp_flow_db.h"
+#include "ulp_mapper.h"
 
 /* Linked list of all TF sessions. */
 STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
@@ -485,6 +486,12 @@ bnxt_ulp_init(struct bnxt *bp)
 		goto jump_to_error;
 	}
 
+	rc = ulp_mapper_init(&bp->ulp_ctx);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to initialize ulp mapper\n");
+		goto jump_to_error;
+	}
+
 	return rc;
 
 jump_to_error:
@@ -529,6 +536,9 @@ bnxt_ulp_deinit(struct bnxt *bp)
 	/* Delete the Mark database */
 	ulp_mark_db_deinit(&bp->ulp_ctx);
 
+	/* cleanup the ulp mapper */
+	ulp_mapper_deinit(&bp->ulp_ctx);
+
 	/* Delete the ulp context and tf session */
 	ulp_ctx_detach(bp, session);
 
@@ -690,3 +700,26 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev	*dev)
 	return &bp->ulp_ctx;
 }
 
+int32_t
+bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
+				    void *mapper_data)
+{
+	if (!ulp_ctx || !ulp_ctx->cfg_data) {
+		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+		return -EINVAL;
+	}
+
+	ulp_ctx->cfg_data->mapper_data = mapper_data;
+	return 0;
+}
+
+void *
+bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx)
+{
+	if (!ulp_ctx || !ulp_ctx->cfg_data) {
+		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+		return NULL;
+	}
+
+	return ulp_ctx->cfg_data->mapper_data;
+}
drivers/net/bnxt/tf_ulp/bnxt_ulp.h +10 -0
index b3e9e96..d2ca178 100644
@@ -18,6 +18,7 @@ struct bnxt_ulp_data {
 	uint32_t			dev_id; /* Hardware device id */
 	uint32_t			ref_cnt;
 	struct bnxt_ulp_flow_db		*flow_db;
+	void				*mapper_data;
 };
 
 struct bnxt_ulp_context {
@@ -107,4 +108,13 @@ bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context	*ulp_ctx);
 struct bnxt_ulp_context	*
 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
 
+/* Function to add the ulp mapper data to the ulp context */
+int32_t
+bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
+				    void *mapper_data);
+
+/* Function to get the ulp mapper data from the ulp context */
+void *
+bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
+
 #endif /* _BNXT_ULP_H_ */
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +3 -5
index f0c812c..7783f85 100644
@@ -110,7 +110,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 		goto parse_error;
 
 	ret = ulp_matcher_pattern_match(&params, &class_id);
-
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
@@ -126,11 +125,10 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 	mapper_cparms.class_tid = class_id;
 	mapper_cparms.act_tid = act_tmpl;
 	mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id);
+	mapper_cparms.dir = params.dir;
 
-	/* call the ulp mapper to create the flow in the hardware */
-	ret = ulp_mapper_flow_create(ulp_ctx,
-				     &mapper_cparms,
-				     &fid);
+	/* Call the ulp mapper to create the flow in the hardware. */
+	ret = ulp_mapper_flow_create(ulp_ctx, &mapper_cparms, &fid);
 	if (!ret) {
 		flow_id = (struct rte_flow *)((uintptr_t)fid);
 		return flow_id;
drivers/net/bnxt/tf_ulp/ulp_mapper.c +245 -6

352 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mapper.h +21 -1
index 2fa6ffc..fb47f1c 100644
@@ -6,10 +6,10 @@
 #ifndef _ULP_MAPPER_H_
 #define _ULP_MAPPER_H_
 
-#include <tf_core.h>
 #include <rte_log.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
+#include "tf_core.h"
 #include "ulp_template_db.h"
 #include "ulp_template_struct.h"
 #include "bnxt_ulp.h"
@@ -17,6 +17,16 @@
 
 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
 
+struct bnxt_ulp_mapper_def_id_entry {
+	enum tf_identifier_type ident_type;
+	uint64_t ident;
+};
+
+struct bnxt_ulp_mapper_data {
+	struct bnxt_ulp_mapper_def_id_entry
+		dflt_ids[TF_DIR_MAX][BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ];
+};
+
 /* Internal Structure for passing the arguments around */
 struct bnxt_ulp_mapper_parms {
 	uint32_t				dev_id;
@@ -36,6 +46,7 @@ struct bnxt_ulp_mapper_parms {
 	uint8_t					encap_byte_swap;
 	uint32_t				fid;
 	enum bnxt_ulp_flow_db_tables		tbl_idx;
+	struct bnxt_ulp_mapper_data		*mapper_data;
 };
 
 struct bnxt_ulp_mapper_create_parms {
@@ -47,8 +58,17 @@ struct bnxt_ulp_mapper_create_parms {
 	uint32_t			class_tid;
 	uint32_t			act_tid;
 	uint16_t			func_id;
+	enum ulp_direction_type		dir;
 };
 
+/* Function to initialize any dynamic mapper data. */
+int32_t
+ulp_mapper_init(struct bnxt_ulp_context	*ulp_ctx);
+
+/* Function to release all dynamic mapper data. */
+void
+ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
+
 /*
  * Function to handle the mapping of the Flow to be compatible
  * with the underlying hardware.
drivers/net/bnxt/tf_ulp/ulp_template_db.c +20 -15
index 25a558a..cd3f65f 100644
@@ -297,6 +297,15 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = {
 	}
 };
 
+struct bnxt_ulp_def_ident_info ulp_def_ident_tbl[] = {
+	[0] = {
+		.ident_type              = TF_IDENT_TYPE_PROF_FUNC,
+		.def_regfile_index       =
+			BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID,
+		.direction               = TF_DIR_RX
+	}
+};
+
 struct bnxt_ulp_device_params ulp_device_params[] = {
 	[BNXT_ULP_DEVICE_ID_WH_PLUS] = {
 		.global_fid_enable       = BNXT_ULP_SYM_YES,
@@ -577,7 +586,7 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
 	.result_bit_size = 64,
 	.result_num_fields = 13,
 	.ident_start_idx = 0,
-	.ident_nums = 2,
+	.ident_nums = 1,
 	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
 	.critical_resource = 0,
 	.regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
@@ -595,7 +604,7 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
 	.result_start_idx = 13,
 	.result_bit_size = 38,
 	.result_num_fields = 8,
-	.ident_start_idx = 2,
+	.ident_start_idx = 1,
 	.ident_nums = 1,
 	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
 	.critical_resource = 0,
@@ -614,6 +623,7 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
 	.result_start_idx = 21,
 	.result_bit_size = 64,
 	.result_num_fields = 9,
+	.ident_start_idx = 2,
 	.ident_nums = 0,
 	.mark_enable = BNXT_ULP_MARK_ENABLE_YES,
 	.critical_resource = 1,
@@ -1088,9 +1098,10 @@ struct bnxt_ulp_mapper_class_key_field_info ulp_class_key_field_list[] = {
 	.mask_opcode = BNXT_ULP_MASK_OPC_SET_TO_CONSTANT,
 	.mask_operand = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
-	.spec_opcode = BNXT_ULP_SPEC_OPC_SET_TO_REGFILE,
-	.spec_operand = {(BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 >> 8) & 0xff,
-		BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 & 0xff,
+	.spec_opcode = BNXT_ULP_SPEC_OPC_SET_TO_DEF_REGFILE,
+	.spec_operand = {
+		(BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID >> 8) & 0xff,
+		BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID & 0xff,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	},
@@ -1256,9 +1267,10 @@ struct bnxt_ulp_mapper_result_field_info ulp_class_result_field_list[] = {
 	},
 	{
 	.field_bit_size = 7,
-	.result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_REGFILE,
-	.result_operand = {(BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 >> 8) & 0xff,
-		BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 & 0xff,
+	.result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_DEF_REGFILE,
+	.result_operand = {
+		(BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID >> 8) & 0xff,
+		BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID & 0xff,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	},
@@ -1443,13 +1455,6 @@ struct bnxt_ulp_mapper_result_field_info ulp_class_result_field_list[] = {
 struct bnxt_ulp_mapper_ident_info ulp_ident_list[] = {
 	{
 	.resource_func = BNXT_ULP_RESOURCE_FUNC_IDENTIFIER,
-	.ident_type = TF_IDENT_TYPE_PROF_FUNC,
-	.regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0,
-	.ident_bit_size = 7,
-	.ident_bit_pos = 47
-	},
-	{
-	.resource_func = BNXT_ULP_RESOURCE_FUNC_IDENTIFIER,
 	.ident_type = TF_IDENT_TYPE_L2_CTXT,
 	.regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_L2_CNTXT_ID_0,
 	.ident_bit_size = 10,
drivers/net/bnxt/tf_ulp/ulp_template_db.h +20 -5
index 94d4253..cf4ff9f 100644
@@ -28,6 +28,7 @@
 #define BNXT_ULP_ACT_HID_SHFTR 0
 #define BNXT_ULP_ACT_HID_SHFTL 23
 #define BNXT_ULP_ACT_HID_MASK 255
+#define BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ 1
 
 enum bnxt_ulp_action_bit {
 	BNXT_ULP_ACTION_BIT_MARK             = 0x0000000000000001,
@@ -112,6 +113,11 @@ enum bnxt_ulp_chf_idx {
 	BNXT_ULP_CHF_IDX_LAST = 14
 };
 
+enum bnxt_ulp_def_regfile_index {
+	BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID = 0,
+	BNXT_ULP_DEF_REGFILE_INDEX_LAST = 1
+};
+
 enum bnxt_ulp_device_id {
 	BNXT_ULP_DEVICE_ID_WH_PLUS = 0,
 	BNXT_ULP_DEVICE_ID_THOR = 1,
@@ -120,6 +126,12 @@ enum bnxt_ulp_device_id {
 	BNXT_ULP_DEVICE_ID_LAST = 4
 };
 
+enum bnxt_ulp_direction {
+	BNXT_ULP_DIRECTION_INGRESS = 0,
+	BNXT_ULP_DIRECTION_EGRESS = 1,
+	BNXT_ULP_DIRECTION_LAST = 2
+};
+
 enum bnxt_ulp_hdr_type {
 	BNXT_ULP_HDR_TYPE_NOT_SUPPORTED = 0,
 	BNXT_ULP_HDR_TYPE_SUPPORTED = 1,
@@ -137,8 +149,9 @@ enum bnxt_ulp_mask_opc {
 	BNXT_ULP_MASK_OPC_SET_TO_CONSTANT = 0,
 	BNXT_ULP_MASK_OPC_SET_TO_HDR_FIELD = 1,
 	BNXT_ULP_MASK_OPC_SET_TO_REGFILE = 2,
-	BNXT_ULP_MASK_OPC_ADD_PAD = 3,
-	BNXT_ULP_MASK_OPC_LAST = 4
+	BNXT_ULP_MASK_OPC_SET_TO_DEF_REGFILE = 3,
+	BNXT_ULP_MASK_OPC_ADD_PAD = 4,
+	BNXT_ULP_MASK_OPC_LAST = 5
 };
 
 enum bnxt_ulp_match_type {
@@ -193,7 +206,8 @@ enum bnxt_ulp_result_opc {
 	BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP = 1,
 	BNXT_ULP_RESULT_OPC_SET_TO_ENCAP_ACT_PROP_SZ = 2,
 	BNXT_ULP_RESULT_OPC_SET_TO_REGFILE = 3,
-	BNXT_ULP_RESULT_OPC_LAST = 4
+	BNXT_ULP_RESULT_OPC_SET_TO_DEF_REGFILE = 4,
+	BNXT_ULP_RESULT_OPC_LAST = 5
 };
 
 enum bnxt_ulp_search_before_alloc {
@@ -206,8 +220,9 @@ enum bnxt_ulp_spec_opc {
 	BNXT_ULP_SPEC_OPC_SET_TO_CONSTANT = 0,
 	BNXT_ULP_SPEC_OPC_SET_TO_HDR_FIELD = 1,
 	BNXT_ULP_SPEC_OPC_SET_TO_REGFILE = 2,
-	BNXT_ULP_SPEC_OPC_ADD_PAD = 3,
-	BNXT_ULP_SPEC_OPC_LAST = 4
+	BNXT_ULP_SPEC_OPC_SET_TO_DEF_REGFILE = 3,
+	BNXT_ULP_SPEC_OPC_ADD_PAD = 4,
+	BNXT_ULP_SPEC_OPC_LAST = 5
 };
 
 enum bnxt_ulp_encap_vtag_encoding {
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +11 -0
index c2d3ccb..476d5b9 100644
@@ -222,6 +222,12 @@ struct bnxt_ulp_mapper_ident_info {
 	enum bnxt_ulp_regfile_index	regfile_wr_idx;
 };
 
+struct bnxt_ulp_def_ident_info {
+	enum tf_dir direction;
+	enum tf_identifier_type ident_type;
+	enum bnxt_ulp_def_regfile_index def_regfile_index;
+};
+
 /*
  * Flow Mapper Static Data Externs:
  * Access to the below static data should be done through access functions and
@@ -285,4 +291,9 @@ extern struct bnxt_ulp_mapper_ident_info	ulp_ident_list[];
  */
 extern uint32_t ulp_act_prop_map_table[];
 
+/*
+ * The ulp_def_ident_tbl provides the list of default identifiers that need to
+ * be initialized and where to store them.
+ */
+extern struct bnxt_ulp_def_ident_info ulp_def_ident_tbl[];
 #endif /* _ULP_TEMPLATE_STRUCT_H_ */
Signature · 1 line
2.7.4
#10 lore raw

PATCH 10/11 net/bnxt: cache table type added for tcam lookups

In reply to Venkat Duvvuru

From: Mike Baucom <[email protected]>

In order to re-use allocated resources and reduce search complexity for simple keys, a generic software cache table was added for the TCAM. The implementation is specifically only for keys that can be compressed to less than 16 bits. The keys are generated using the same mechanisms as other search tables, but the table type is set to a cache that mirrors the actual TCAM table. The allocated result fields are stored in the cache entry and can be used for subsequent searches in future tables.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 460 +++++++++++++++++++++++---
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |  29 ++
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     | 155 ++++++++-
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  24 +-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  13 +
 5 files changed, 616 insertions(+), 65 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +414 -46
index 76addf2..76d18f6 100644
@@ -66,6 +66,16 @@ ulp_mapper_def_regfile_write(struct bnxt_ulp_mapper_data *mapper_data,
 	return 0;
 }
 
+/* Retrieve the cache initialization parameters for the tbl_idx */
+static struct bnxt_ulp_cache_tbl_params *
+ulp_mapper_cache_tbl_params_get(uint32_t tbl_idx)
+{
+	if (tbl_idx >= BNXT_ULP_CACHE_TBL_MAX_SZ)
+		return NULL;
+
+	return &ulp_cache_tbl_params[tbl_idx];
+}
+
 /*
  * Get the size of the action property for a given index.
  *
@@ -256,6 +266,126 @@ ulp_mapper_ident_fields_get(struct bnxt_ulp_mapper_class_tbl_info *tbl,
 	return &ulp_ident_list[idx];
 }
 
+static struct bnxt_ulp_mapper_cache_entry *
+ulp_mapper_cache_entry_get(struct bnxt_ulp_context *ulp,
+			   enum bnxt_ulp_cache_tbl_id id,
+			   uint16_t key)
+{
+	struct bnxt_ulp_mapper_data *mapper_data;
+
+	mapper_data = bnxt_ulp_cntxt_ptr2_mapper_data_get(ulp);
+	if (!mapper_data || !mapper_data->cache_tbl[id]) {
+		BNXT_TF_DBG(ERR, "Unable to acquire the cache tbl (%d)\n", id);
+		return NULL;
+	}
+
+	return &mapper_data->cache_tbl[id][key];
+}
+
+/*
+ * Concatenates the tbl_type and tbl_id into a 32bit value for storing in the
+ * resource_type.  This is done to conserve memory since both the tbl_type and
+ * tbl_id are 16bit.
+ */
+static inline void
+ulp_mapper_cache_res_type_set(struct ulp_flow_db_res_params *res,
+			      uint16_t tbl_type,
+			      uint16_t tbl_id)
+{
+	res->resource_type =
+		((uint32_t)tbl_id << ULP_MAPPER_CACHE_RES_TBL_ID_SHFT) |
+		((uint32_t)tbl_type << ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT);
+}
+
+/* Extracts the tbl_type and tbl_id from the 32bit resource type. */
+static inline void
+ulp_mapper_cache_res_type_get(struct ulp_flow_db_res_params *res,
+			      uint16_t *tbl_type,
+			      uint16_t *tbl_id)
+{
+	*tbl_type = (uint16_t)((res->resource_type >>
+				ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT) &
+			       ULP_MAPPER_CACHE_RES_TBL_MASK);
+	*tbl_id = (uint16_t)((res->resource_type >>
+			      ULP_MAPPER_CACHE_RES_TBL_ID_SHFT) &
+			     ULP_MAPPER_CACHE_RES_TBL_MASK);
+}
+
+static int32_t
+ulp_mapper_cache_entry_free(struct bnxt_ulp_context *ulp,
+			   struct tf *tfp,
+			   struct ulp_flow_db_res_params *res)
+{
+	struct bnxt_ulp_mapper_cache_entry *cache_entry;
+	struct tf_free_identifier_parms ident_parms;
+	struct tf_free_tcam_entry_parms tcam_parms;
+	uint16_t table_id, table_type;
+	int32_t rc, trc, i;
+
+	/*
+	 * The table id, used for cache, and table_type, used for tcam, are
+	 * both encoded within the resource.  We must first extract them to
+	 * formulate the args for tf calls.
+	 */
+	ulp_mapper_cache_res_type_get(res, &table_type, &table_id);
+
+	cache_entry = ulp_mapper_cache_entry_get(ulp, table_id,
+						 (uint16_t)res->resource_hndl);
+	if (!cache_entry || !cache_entry->ref_count) {
+		BNXT_TF_DBG(ERR, "Cache entry (%d:%d) not valid on free.\n",
+			    table_id, (uint16_t)res->resource_hndl);
+		return -EINVAL;
+	}
+
+	/*
+	 * See if we need to delete the entry.  The tcam and identifiers are all
+	 * tracked by the cached entries reference count.  All are deleted when
+	 * the reference count hit zero.
+	 */
+	cache_entry->ref_count--;
+	if (cache_entry->ref_count)
+		return 0;
+
+	/*
+	 * Need to delete the tcam entry and the allocated identifiers.
+	 * In the event of a failure, need to try to delete the remaining
+	 * resources before returning error.
+	 */
+	tcam_parms.dir = res->direction;
+	tcam_parms.tcam_tbl_type = table_type;
+	tcam_parms.idx = cache_entry->tcam_idx;
+	rc = tf_free_tcam_entry(tfp, &tcam_parms);
+	if (rc)
+		BNXT_TF_DBG(ERR, "Failed to free tcam [%d][%s][0x%04x] rc=%d\n",
+			    table_type,
+			    (res->direction == TF_DIR_RX) ? "RX" : "TX",
+			    tcam_parms.idx, rc);
+
+	/*
+	 * Free the identifiers associated with the tcam entry.  Entries with
+	 * negative one are considered uninitialized.
+	 */
+	for (i = 0; i < BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM; i++) {
+		if (cache_entry->idents[i] == ULP_IDENTS_INVALID)
+			continue;
+
+		ident_parms.dir = res->direction;
+		ident_parms.ident_type = cache_entry->ident_types[i];
+		ident_parms.id = cache_entry->idents[i];
+		trc = tf_free_identifier(tfp, &ident_parms);
+		if (trc) {
+			BNXT_TF_DBG(ERR, "Failed to free identifier "
+				    "[%d][%s][0x%04x] rc=%d\n",
+				    ident_parms.ident_type,
+				    (res->direction == TF_DIR_RX) ? "RX" : "TX",
+				    ident_parms.id, trc);
+			rc = trc;
+		}
+	}
+
+	return rc;
+}
+
 static inline int32_t
 ulp_mapper_tcam_entry_free(struct bnxt_ulp_context *ulp  __rte_unused,
 			   struct tf *tfp,
@@ -337,10 +467,16 @@ ulp_mapper_mark_free(struct bnxt_ulp_context *ulp,
 				    0);
 }
 
+/*
+ * Process the identifier instruction and either store it in the flow database
+ * or return it in the val (if not NULL) on success.  If val is NULL, the
+ * identifier is to be stored in the flow database.
+ */
 static int32_t
 ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 			 struct bnxt_ulp_mapper_class_tbl_info *tbl,
-			 struct bnxt_ulp_mapper_ident_info *ident)
+			 struct bnxt_ulp_mapper_ident_info *ident,
+			 uint16_t *val)
 {
 	struct ulp_flow_db_res_params	fid_parms;
 	uint64_t id = 0;
@@ -378,22 +514,26 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 	}
 
 	/* Link the resource to the flow in the flow db */
-	memset(&fid_parms, 0, sizeof(fid_parms));
-	fid_parms.direction		= tbl->direction;
-	fid_parms.resource_func	= ident->resource_func;
-	fid_parms.resource_type	= ident->ident_type;
-	fid_parms.resource_hndl	= iparms.id;
-	fid_parms.critical_resource	= 0;
+	if (!val) {
+		memset(&fid_parms, 0, sizeof(fid_parms));
+		fid_parms.direction		= tbl->direction;
+		fid_parms.resource_func	= ident->resource_func;
+		fid_parms.resource_type	= ident->ident_type;
+		fid_parms.resource_hndl	= iparms.id;
+		fid_parms.critical_resource	= 0;
 
-	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
-				      parms->tbl_idx,
-				      parms->fid,
-				      &fid_parms);
-	if (rc) {
-		BNXT_TF_DBG(ERR, "Failed to link resource to flow rc = %d\n",
-			    rc);
-		/* Need to free the identifier, so goto error */
-		goto error;
+		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+					      parms->tbl_idx,
+					      parms->fid,
+					      &fid_parms);
+		if (rc) {
+			BNXT_TF_DBG(ERR, "Failed to link res to flow rc = %d\n",
+				    rc);
+			/* Need to free the identifier, so goto error */
+			goto error;
+		}
+	} else {
+		*val = iparms.id;
 	}
 
 	return 0;
@@ -848,6 +988,12 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	uint32_t hit = 0;
 	uint16_t tmplen = 0;
 
+	/* Skip this if was handled by the cache. */
+	if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP) {
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
+		return 0;
+	}
+
 	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
 	if (!tfp) {
 		BNXT_TF_DBG(ERR, "Failed to get truflow pointer\n");
@@ -930,15 +1076,22 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		struct bnxt_ulp_mapper_ident_info *idents;
 		uint32_t num_dflds, num_idents;
 
-		/* Alloc identifiers */
-		idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
-
-		for (i = 0; i < num_idents; i++) {
-			rc = ulp_mapper_ident_process(parms, tbl, &idents[i]);
-
-			/* Already logged the error, just return */
-			if (rc)
-				goto error;
+		/*
+		 * Since the cache entry is responsible for allocating
+		 * identifiers when in use, allocate the identifiers only
+		 * during normal processing.
+		 */
+		if (parms->tcam_tbl_opc ==
+		    BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL) {
+			idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
+
+			for (i = 0; i < num_idents; i++) {
+				rc = ulp_mapper_ident_process(parms, tbl,
+							      &idents[i], NULL);
+				/* Already logged the error, just return */
+				if (rc)
+					goto error;
+			}
 		}
 
 		/* Create the result data blob */
@@ -986,32 +1139,57 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 				    sparms.idx);
 			goto error;
 		}
+
+		/* Update cache with TCAM index if the was cache allocated. */
+		if (parms->tcam_tbl_opc ==
+		    BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC) {
+			if (!parms->cache_ptr) {
+				BNXT_TF_DBG(ERR, "Unable to update cache");
+				rc = -EINVAL;
+				goto error;
+			}
+			parms->cache_ptr->tcam_idx = aparms.idx;
+		}
+
 	} else {
 		BNXT_TF_DBG(ERR, "Not supporting search before alloc now\n");
 		rc = -EINVAL;
 		goto error;
 	}
 
-	/* Link the resource to the flow in the flow db */
-	fid_parms.direction = tbl->direction;
-	fid_parms.resource_func	= tbl->resource_func;
-	fid_parms.resource_type	= tbl->table_type;
-	fid_parms.critical_resource = tbl->critical_resource;
-	fid_parms.resource_hndl	= aparms.idx;
-
-	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
-				      parms->tbl_idx,
-				      parms->fid,
-				      &fid_parms);
-	if (rc) {
-		BNXT_TF_DBG(ERR, "Failed to link resource to flow rc = %d\n",
-			    rc);
-		/* Need to free the identifier, so goto error */
-		goto error;
+	/*
+	 * Only link the entry to the flow db in the event that cache was not
+	 * used.
+	 */
+	if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL) {
+		fid_parms.direction = tbl->direction;
+		fid_parms.resource_func	= tbl->resource_func;
+		fid_parms.resource_type	= tbl->table_type;
+		fid_parms.critical_resource = tbl->critical_resource;
+		fid_parms.resource_hndl	= aparms.idx;
+		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+					      parms->tbl_idx,
+					      parms->fid,
+					      &fid_parms);
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Failed to link resource to flow rc = %d\n",
+				    rc);
+			/* Need to free the identifier, so goto error */
+			goto error;
+		}
+	} else {
+		/*
+		 * Reset the tcam table opcode to normal in case the next tcam
+		 * entry does not use cache.
+		 */
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
+		parms->cache_ptr = NULL;
 	}
 
 	return 0;
 error:
+	parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
 	free_parms.dir			= tbl->direction;
 	free_parms.tcam_tbl_type	= tbl->table_type;
 	free_parms.idx			= aparms.idx;
@@ -1324,6 +1502,153 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	return rc;
 }
 
+static int32_t
+ulp_mapper_cache_tbl_process(struct bnxt_ulp_mapper_parms *parms,
+			     struct bnxt_ulp_mapper_class_tbl_info *tbl)
+{
+	struct bnxt_ulp_mapper_class_key_field_info *kflds;
+	struct bnxt_ulp_mapper_cache_entry *cache_entry;
+	struct bnxt_ulp_mapper_ident_info *idents;
+	uint32_t i, num_kflds = 0, num_idents = 0;
+	struct ulp_flow_db_res_params fid_parms;
+	struct tf_free_identifier_parms fparms;
+	uint16_t tmplen, tmp_ident;
+	struct ulp_blob key;
+	uint8_t *cache_key;
+	uint64_t regval;
+	uint16_t *ckey;
+	int32_t rc;
+
+	/* Get the key fields list and build the key. */
+	kflds = ulp_mapper_key_fields_get(tbl, &num_kflds);
+	if (!kflds || !num_kflds) {
+		BNXT_TF_DBG(ERR, "Failed to get key fields\n");
+		return -EINVAL;
+	}
+	if (!ulp_blob_init(&key, tbl->key_bit_size, parms->order)) {
+		BNXT_TF_DBG(ERR, "Failed to alloc blob\n");
+		return -EINVAL;
+	}
+	for (i = 0; i < num_kflds; i++) {
+		/* Setup the key */
+		rc = ulp_mapper_keymask_field_process(parms, tbl->direction,
+						      &kflds[i],
+						      &key, 1, "Cache Key");
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Failed to create key for Cache rc=%d\n",
+				    rc);
+			return -EINVAL;
+		}
+	}
+
+	/*
+	 * Perform the lookup in the cache table with constructed key.  The
+	 * cache_key is a byte array of tmplen, it needs to be converted to a
+	 * index for the cache table.
+	 */
+	cache_key = ulp_blob_data_get(&key, &tmplen);
+	ckey = (uint16_t *)cache_key;
+	cache_entry = ulp_mapper_cache_entry_get(parms->ulp_ctx,
+						 tbl->cache_tbl_id,
+						 *ckey);
+
+	/*
+	 * Get the identifier list for processing by both the hit and miss
+	 * processing.
+	 */
+	idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
+
+	if (!cache_entry->ref_count) {
+		/* Initialize the cache entry */
+		cache_entry->tcam_idx = 0;
+		cache_entry->ref_count = 0;
+		for (i = 0; i < BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM; i++)
+			cache_entry->idents[i] = ULP_IDENTS_INVALID;
+
+		/* Need to allocate identifiers for storing in the cache. */
+		for (i = 0; i < num_idents; i++) {
+			/*
+			 * Since we are using the cache, the identifier does not
+			 * get added to the flow db.  Pass in the pointer to the
+			 * tmp_ident.
+			 */
+			rc = ulp_mapper_ident_process(parms, tbl,
+						      &idents[i], &tmp_ident);
+			if (rc)
+				goto error;
+
+			cache_entry->ident_types[i] = idents[i].ident_type;
+			cache_entry->idents[i] = tmp_ident;
+		}
+
+		/* Tell the TCAM processor to alloc an entry */
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC;
+		/* Store the cache key for use by the tcam process code */
+		parms->cache_ptr = cache_entry;
+	} else {
+		/* Cache hit, get values from result. */
+		for (i = 0; i < num_idents; i++) {
+			regval = (uint64_t)cache_entry->idents[i];
+			if (!ulp_regfile_write(parms->regfile,
+					       idents[i].regfile_wr_idx,
+					       tfp_cpu_to_be_64(regval))) {
+				BNXT_TF_DBG(ERR,
+					    "Failed to write to regfile\n");
+				return -EINVAL;
+			}
+		}
+		/*
+		 * The cached entry is being used, so let the tcam processing
+		 * know not to process this table.
+		 */
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP;
+	}
+
+	/* Made through the cache processing, increment the reference count. */
+	cache_entry->ref_count++;
+
+	/* Link the cache to the flow db. */
+	memset(&fid_parms, 0, sizeof(fid_parms));
+	fid_parms.direction = tbl->direction;
+	fid_parms.resource_func	= tbl->resource_func;
+
+	/*
+	 * Cache resource type is composed of both table_type and cache_tbl_id
+	 * need to set it appropriately via setter.
+	 */
+	ulp_mapper_cache_res_type_set(&fid_parms,
+				      tbl->table_type,
+				      tbl->cache_tbl_id);
+	fid_parms.resource_hndl	= (uint64_t)*ckey;
+	fid_parms.critical_resource = tbl->critical_resource;
+	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+				      parms->tbl_idx,
+				      parms->fid,
+				      &fid_parms);
+	if (rc)
+		BNXT_TF_DBG(ERR, "Failed to add cache to flow db.\n");
+
+	return rc;
+error:
+	/*
+	 * This error handling only gets called when the idents are being
+	 * allocated for the cache on misses.  Using the num_idents that was
+	 * previously set.
+	 */
+	for (i = 0; i < num_idents; i++) {
+		if (cache_entry->idents[i] == ULP_IDENTS_INVALID)
+			continue;
+
+		fparms.dir = tbl->direction;
+		fparms.ident_type = idents[i].ident_type;
+		fparms.id = cache_entry->idents[i];
+		tf_free_identifier(parms->tfp, &fparms);
+	}
+
+	return rc;
+}
+
 /*
  * Function to process the action template. Iterate through the list
  * action info templates and process it.
@@ -1378,6 +1703,9 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
 			rc = ulp_mapper_index_tbl_process(parms, tbl);
 			break;
+		case BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE:
+			rc = ulp_mapper_cache_tbl_process(parms, tbl);
+			break;
 		default:
 			BNXT_TF_DBG(ERR, "Unexpected class resource %d\n",
 				    tbl->resource_func);
@@ -1413,6 +1741,9 @@ ulp_mapper_resource_free(struct bnxt_ulp_context *ulp,
 	}
 
 	switch (res->resource_func) {
+	case BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE:
+		rc = ulp_mapper_cache_entry_free(ulp, tfp, res);
+		break;
 	case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
 		rc = ulp_mapper_tcam_entry_free(ulp, tfp, res);
 		break;
@@ -1530,6 +1861,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	parms.hdr_field = cparms->hdr_field;
 	parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
 	parms.ulp_ctx = ulp_ctx;
+	parms.tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
 
 	/* Get the device id from the ulp context */
 	if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &parms.dev_id)) {
@@ -1586,6 +1918,14 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 		return -EINVAL;
 	}
 
+	rc = ulp_regfile_write(parms.regfile,
+			       BNXT_ULP_REGFILE_INDEX_CLASS_TID,
+			       tfp_cpu_to_be_64((uint64_t)parms.class_tid));
+	if (!rc) {
+		BNXT_TF_DBG(ERR, "Unable to write template ID to regfile\n");
+		return -EINVAL;
+	}
+
 	/* Allocate a Flow ID for attaching all resources for the flow to.
 	 * Once allocated, all errors have to walk the list of resources and
 	 * free each of them.
@@ -1631,13 +1971,14 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 int32_t
 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 {
+	struct bnxt_ulp_cache_tbl_params *tbl;
 	struct tf_alloc_identifier_parms iparms;
 	struct bnxt_ulp_mapper_data *data;
 	struct bnxt_ulp_def_ident_info *dflt_ids;
 	uint32_t i, num_dflt_ids, reg_idx;
 	uint64_t regval;
 	struct tf *tfp;
-	int32_t rc;
+	int32_t rc, csize;
 
 	if (!ulp_ctx)
 		return -EINVAL;
@@ -1677,16 +2018,37 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 		reg_idx = dflt_ids[i].def_regfile_index;
 		/* All regfile entries are stored as 64bit big-endian values. */
 		regval = tfp_cpu_to_be_64((uint64_t)iparms.id);
-		if (ulp_mapper_def_regfile_write(data,
-						 iparms.dir,
-						 reg_idx,
-						 regval)) {
+		rc = ulp_mapper_def_regfile_write(data, iparms.dir,
+						 reg_idx, regval);
+		if (rc) {
 			BNXT_TF_DBG(ERR, "Failed to write to default "
 				    "regfile.\n");
 			goto error;
 		}
 	}
 
+	/* Allocate the ulp cache tables. */
+	for (i = 0; i < BNXT_ULP_CACHE_TBL_MAX_SZ; i++) {
+		tbl = ulp_mapper_cache_tbl_params_get(i);
+		if (!tbl) {
+			BNXT_TF_DBG(ERR, "Failed to get cache table parms (%d)",
+				    i);
+			goto error;
+		}
+		if (tbl->num_entries != 0) {
+			csize = sizeof(struct bnxt_ulp_mapper_cache_entry) *
+				tbl->num_entries;
+			data->cache_tbl[i] = rte_zmalloc("ulp mapper cache tbl",
+							 csize, 0);
+			if (!data->cache_tbl[i]) {
+				BNXT_TF_DBG(ERR, "Failed to allocate Cache "
+					    "table %d.\n", i);
+				rc = -ENOMEM;
+				goto error;
+			}
+		}
+	}
+
 	return 0;
 error:
 	/* Ignore the return code in favor of returning the original error. */
@@ -1750,6 +2112,12 @@ ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx)
 	}
 
 free_mapper_data:
+	/* Free the ulp cache tables */
+	for (i = 0; i < BNXT_ULP_CACHE_TBL_MAX_SZ; i++) {
+		rte_free(data->cache_tbl[i]);
+		data->cache_tbl[i] = NULL;
+	}
+
 	rte_free(data);
 	/* Reset the data pointer within the ulp_ctx. */
 	bnxt_ulp_cntxt_ptr2_mapper_data_set(ulp_ctx, NULL);
drivers/net/bnxt/tf_ulp/ulp_mapper.h +29 -0
index fb47f1c..c50d555 100644
@@ -16,6 +16,31 @@
 #include "ulp_utils.h"
 
 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
+#define ULP_IDENTS_INVALID ((uint16_t)0xffff)
+#define ULP_MAPPER_CACHE_RES_TBL_ID_SHFT 16
+#define ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT 0
+#define ULP_MAPPER_CACHE_RES_TBL_MASK ((uint32_t)0x0000ffff)
+
+/*
+ * The cache table opcode is used to convey informat from the cache handler
+ * to the tcam handler.  The opcodes do the following:
+ * NORMAL - tcam should process all instructions as normnal
+ * SKIP - tcam is using the cached entry and doesn't need to process the
+ *	instruction.
+ * ALLOC - tcam needs to allocate the tcam index and store in the cache entry
+ */
+enum bnxt_ulp_cache_table_opc {
+	BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL,
+	BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP,
+	BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC
+};
+
+struct bnxt_ulp_mapper_cache_entry {
+	uint32_t ref_count;
+	uint16_t tcam_idx;
+	uint16_t idents[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM];
+	uint8_t ident_types[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM];
+};
 
 struct bnxt_ulp_mapper_def_id_entry {
 	enum tf_identifier_type ident_type;
@@ -25,6 +50,8 @@ struct bnxt_ulp_mapper_def_id_entry {
 struct bnxt_ulp_mapper_data {
 	struct bnxt_ulp_mapper_def_id_entry
 		dflt_ids[TF_DIR_MAX][BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ];
+	struct bnxt_ulp_mapper_cache_entry
+		*cache_tbl[BNXT_ULP_CACHE_TBL_MAX_SZ];
 };
 
 /* Internal Structure for passing the arguments around */
@@ -47,6 +74,8 @@ struct bnxt_ulp_mapper_parms {
 	uint32_t				fid;
 	enum bnxt_ulp_flow_db_tables		tbl_idx;
 	struct bnxt_ulp_mapper_data		*mapper_data;
+	enum bnxt_ulp_cache_table_opc		tcam_tbl_opc;
+	struct bnxt_ulp_mapper_cache_entry	*cache_ptr;
 };
 
 struct bnxt_ulp_mapper_create_parms {
drivers/net/bnxt/tf_ulp/ulp_template_db.c +142 -13

249 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db.h +18 -6
index cf4ff9f..a5606bd 100644
@@ -11,9 +11,10 @@
 #ifndef ULP_TEMPLATE_DB_H_
 #define ULP_TEMPLATE_DB_H_
 
-#define BNXT_ULP_REGFILE_MAX_SZ 15
+#define BNXT_ULP_REGFILE_MAX_SZ 16
 #define BNXT_ULP_MAX_NUM_DEVICES 4
 #define BNXT_ULP_LOG2_MAX_NUM_DEV 2
+#define BNXT_ULP_CACHE_TBL_MAX_SZ 4
 #define BNXT_ULP_CLASS_SIG_TBL_MAX_SZ 256
 #define BNXT_ULP_CLASS_MATCH_LIST_MAX_SZ 2
 #define BNXT_ULP_CLASS_HID_LOW_PRIME 7919
@@ -28,6 +29,7 @@
 #define BNXT_ULP_ACT_HID_SHFTR 0
 #define BNXT_ULP_ACT_HID_SHFTL 23
 #define BNXT_ULP_ACT_HID_MASK 255
+#define BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM 2
 #define BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ 1
 
 enum bnxt_ulp_action_bit {
@@ -95,6 +97,14 @@ enum bnxt_ulp_byte_order {
 	BNXT_ULP_BYTE_ORDER_LAST = 2
 };
 
+enum bnxt_ulp_cache_tbl_id {
+	BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_INGRESS = 0,
+	BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_EGRESS = 1,
+	BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_INGRESS = 2,
+	BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_EGRESS = 3,
+	BNXT_ULP_CACHE_TBL_ID_LAST = 4
+};
+
 enum bnxt_ulp_chf_idx {
 	BNXT_ULP_CHF_IDX_MPLS_TAG_NUM = 0,
 	BNXT_ULP_CHF_IDX_O_VTAG_NUM = 1,
@@ -188,17 +198,19 @@ enum bnxt_ulp_regfile_index {
 	BNXT_ULP_REGFILE_INDEX_ENCAP_PTR_0 = 11,
 	BNXT_ULP_REGFILE_INDEX_ENCAP_PTR_1 = 12,
 	BNXT_ULP_REGFILE_INDEX_CRITICAL_RESOURCE = 13,
-	BNXT_ULP_REGFILE_INDEX_NOT_USED = 14,
-	BNXT_ULP_REGFILE_INDEX_LAST = 15
+	BNXT_ULP_REGFILE_INDEX_CACHE_ENTRY_PTR = 14,
+	BNXT_ULP_REGFILE_INDEX_NOT_USED = 15,
+	BNXT_ULP_REGFILE_INDEX_LAST = 16
 };
 
 enum bnxt_ulp_resource_func {
 	BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0,
 	BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 1,
 	BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 2,
-	BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 3,
-	BNXT_ULP_RESOURCE_FUNC_HW_FID = 4,
-	BNXT_ULP_RESOURCE_FUNC_LAST = 5
+	BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE = 3,
+	BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 4,
+	BNXT_ULP_RESOURCE_FUNC_HW_FID = 5,
+	BNXT_ULP_RESOURCE_FUNC_LAST = 6
 };
 
 enum bnxt_ulp_result_opc {
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +13 -0
index 476d5b9..1bef5ab 100644
@@ -181,6 +181,8 @@ struct bnxt_ulp_mapper_class_tbl_info {
 
 	uint8_t		mark_enable;
 	enum bnxt_ulp_regfile_index	regfile_wr_idx;
+
+	enum bnxt_ulp_cache_tbl_id cache_tbl_id;
 };
 
 struct bnxt_ulp_mapper_act_tbl_info {
@@ -228,6 +230,10 @@ struct bnxt_ulp_def_ident_info {
 	enum bnxt_ulp_def_regfile_index def_regfile_index;
 };
 
+struct bnxt_ulp_cache_tbl_params {
+	uint16_t num_entries;
+};
+
 /*
  * Flow Mapper Static Data Externs:
  * Access to the below static data should be done through access functions and
@@ -296,4 +302,11 @@ extern uint32_t ulp_act_prop_map_table[];
  * be initialized and where to store them.
  */
 extern struct bnxt_ulp_def_ident_info ulp_def_ident_tbl[];
+
+/*
+ * The ulp_cache_tbl_parms table provides the sizes of the cache tables the
+ * mapper must dynamically allocate during initialization.
+ */
+extern struct bnxt_ulp_cache_tbl_params ulp_cache_tbl_params[];
+
 #endif /* _ULP_TEMPLATE_STRUCT_H_ */
Signature · 1 line
2.7.4
#11 lore raw

PATCH 11/11 net/bnxt: addition of the port database

In reply to Venkat Duvvuru

From: Kishore Padmanabha <[email protected]>

The port database is a repository of the port details it is used by the ulp code to query any port related details.

---
 drivers/net/bnxt/Makefile                     |   1 +
 drivers/net/bnxt/meson.build                  |   1 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  48 +++++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |  10 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  13 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c         | 264 ++++++++++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h         | 134 +++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |  16 +-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   1 +
 9 files changed, 482 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h
drivers/net/bnxt/Makefile +1 -0
index 5ed33cc..2a39ed1 100644
@@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mapper.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_matcher.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_rte_parser.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c
 
 #
 # Export include files
drivers/net/bnxt/meson.build +1 -0
index d75f887..59dda69 100644
@@ -41,6 +41,7 @@ sources = files('bnxt_cpr.c',
 	'tf_ulp/ulp_matcher.c',
 	'tf_ulp/ulp_rte_parser.c',
 	'tf_ulp/bnxt_ulp_flow.c',
+	'tf_ulp/ulp_port_db.c',
 
 	'rte_pmd_bnxt.c')
 
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +48 -0

75 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/bnxt_ulp.h +10 -0
index d2ca178..eecc09c 100644
@@ -19,6 +19,7 @@ struct bnxt_ulp_data {
 	uint32_t			ref_cnt;
 	struct bnxt_ulp_flow_db		*flow_db;
 	void				*mapper_data;
+	struct bnxt_ulp_port_db		*port_db;
 };
 
 struct bnxt_ulp_context {
@@ -117,4 +118,13 @@ bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
 void *
 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
 
+/* Function to set the port database to the ulp context. */
+int32_t
+bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context	*ulp_ctx,
+				struct bnxt_ulp_port_db	*port_db);
+
+/* Function to get the port database from the ulp context. */
+struct bnxt_ulp_port_db *
+bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context	*ulp_ctx);
+
 #endif /* _BNXT_ULP_H_ */
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +11 -2
index 7783f85..dbec8ce 100644
@@ -69,7 +69,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 {
 	struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };
 	struct ulp_rte_parser_params params;
-	struct bnxt_ulp_context *ulp_ctx = NULL;
+	struct bnxt_ulp_context *ulp_ctx;
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
 	uint32_t fid;
@@ -90,6 +90,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 
 	/* Initialize the parser params */
 	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
+	params.ulp_ctx = ulp_ctx;
 
 	if (attr->egress)
 		params.dir = ULP_DIR_EGRESS;
@@ -142,7 +143,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 
 /* Function to validate the rte flow. */
 static int
-bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
+bnxt_ulp_flow_validate(struct rte_eth_dev *dev,
 		       const struct rte_flow_attr *attr,
 		       const struct rte_flow_item pattern[],
 		       const struct rte_flow_action actions[],
@@ -151,6 +152,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 	struct ulp_rte_parser_params		params;
 	uint32_t class_id, act_tmpl;
 	int ret;
+	struct bnxt_ulp_context *ulp_ctx;
 
 	if (bnxt_ulp_flow_validate_args(attr,
 					pattern, actions,
@@ -159,8 +161,15 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 		return -EINVAL;
 	}
 
+	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);
+	if (!ulp_ctx) {
+		BNXT_TF_DBG(ERR, "ULP context is not initialized\n");
+		return -EINVAL;
+	}
+
 	/* Initialize the parser params */
 	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
+	params.ulp_ctx = ulp_ctx;
 
 	if (attr->egress)
 		params.dir = ULP_DIR_EGRESS;
drivers/net/bnxt/tf_ulp/ulp_port_db.c new file +264 -0

264 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_port_db.h new file +134 -0

134 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +12 -4
index 873f864..ace5fad 100644
@@ -10,6 +10,7 @@
 #include "ulp_rte_parser.h"
 #include "ulp_utils.h"
 #include "tfp.h"
+#include "ulp_port_db.h"
 
 /* Utility function to skip the void items. */
 static inline int32_t
@@ -161,6 +162,8 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,
 	uint16_t port_id = svif;
 	uint32_t dir = 0;
 	struct ulp_rte_hdr_field *hdr_field;
+	uint32_t ifindex;
+	int32_t rc;
 
 	if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF)) {
 		BNXT_TF_DBG(ERR,
@@ -175,10 +178,15 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,
 		dir = ULP_UTIL_CHF_IDX_RD(params,
 					  BNXT_ULP_CHF_IDX_DIRECTION);
 		/* perform the conversion from dpdk port to bnxt svif */
-		if (dir == ULP_DIR_EGRESS)
-			svif = bnxt_get_svif(port_id, true);
-		else
-			svif = bnxt_get_svif(port_id, false);
+		rc = ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, port_id,
+						       &ifindex);
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Invalid port id\n");
+			return BNXT_TF_RC_ERROR;
+		}
+		ulp_port_db_svif_get(params->ulp_ctx, ifindex, dir, &svif);
+		svif = rte_cpu_to_be_16(svif);
 	}
 	hdr_field = &params->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];
 	memcpy(hdr_field->spec, &svif, sizeof(svif));
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +1 -0
index 1bef5ab..0e0d02f 100644
@@ -66,6 +66,7 @@ struct ulp_rte_parser_params {
 	struct ulp_rte_act_bitmap	act_bitmap;
 	struct ulp_rte_act_prop		act_prop;
 	uint32_t			dir;
+	struct bnxt_ulp_context		*ulp_ctx;
 };
 
 /* Flow Parser Header Information Structure */
Signature · 1 line
2.7.4
#12 lore raw

v2 cover enhancements to host based flow table management

In reply to Venkat Duvvuru

This patchset introduces enhancements to the flow table management related to resource sharing and deletion, flow matching performance, and flow flushing.
Additionally, a new port database was introduced to store frequently required port mappings and resources.

v1->v2:
Rebased to latest code base.

Ajit Khaparde (1):
net/bnxt: remove redefinition of page size

Kishore Padmanabha (5):
net/bnxt: add flow database resource iteration API net/bnxt: aggregate ulp rte parser arguments net/bnxt: use hashing for flow template match net/bnxt: add session and function flow flush net/bnxt: add port database

Mike Baucom (6):
net/bnxt: add SVIF changes for dpdk port id net/bnxt: allow usage of more resources in flow db net/bnxt: add resource name type to debug messages net/bnxt: aggregate ulp mapper create arguments net/bnxt: add default identifiers to ulp mapper net/bnxt: add cache table type for TCAM lookup

 drivers/net/bnxt/Makefile                     |    1 +
 drivers/net/bnxt/bnxt.h                       |    1 +
 drivers/net/bnxt/bnxt_ethdev.c                |   12 +
 drivers/net/bnxt/meson.build                  |    1 +
 drivers/net/bnxt/tf_core/tf_tbl.h             |   18 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |   89 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |   20 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  170 ++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c         |  221 +++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h         |   63 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |  801 ++++++++++--
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |   72 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c         |  220 ++--
 drivers/net/bnxt/tf_ulp/ulp_matcher.h         |   12 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c         |  263 ++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h         |  134 ++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      | 1124 +++++++++--------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      |  155 +--
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     |  459 ++++---
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  313 +++--
 .../net/bnxt/tf_ulp/ulp_template_field_db.h   |  171 +--
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  117 +-
 drivers/net/bnxt/tf_ulp/ulp_utils.c           |   33 +
 drivers/net/bnxt/tf_ulp/ulp_utils.h           |   17 +-
 24 files changed, 3057 insertions(+), 1430 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h
Signature · 1 line
2.21.1 (Apple Git-122.3)
#13 lore raw

PATCH v2 1/12 net/bnxt: add SVIF changes for dpdk port id

From: Mike Baucom <[email protected]>

Modification of the parser to get the SVIF from the driver for matches on port_id, pf, and phy_port.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c  | 31 ++++----
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 92 +++++++++++++++++++-----
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h |  5 ++
 3 files changed, 90 insertions(+), 38 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +12 -19
index 49588953c..6203a495c 100644
@@ -72,14 +72,14 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	struct ulp_rte_act_bitmap act_bitmap;
 	struct ulp_rte_act_prop act_prop;
 	enum ulp_direction_type dir = ULP_DIR_INGRESS;
-	uint32_t class_id, act_tmpl;
-	uint32_t app_priority;
-	int ret;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
-	uint32_t vnic;
-	uint8_t svif;
+	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
+	uint32_t app_priority;
 	uint32_t fid;
+	uint8_t	*buffer;
+	uint32_t vnic;
+	int ret;
 
 	if (bnxt_ulp_flow_validate_args(attr,
 					pattern, actions,
@@ -100,19 +100,15 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	memset(&act_bitmap, 0, sizeof(act_bitmap));
 	memset(&act_prop, 0, sizeof(act_prop));
 
-	svif = bnxt_get_svif(dev->data->port_id, false);
-	BNXT_TF_DBG(ERR, "SVIF for port[%d][port]=0x%08x\n",
-		    dev->data->port_id, svif);
+	if (attr->egress)
+		dir = ULP_DIR_EGRESS;
 
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].size = sizeof(svif);
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec[0] = svif;
-	hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].mask[0] = -1;
-	ULP_BITMAP_SET(hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF);
+	/* copy the device port id and direction in svif for further process */
+	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
+	rte_memcpy(buffer + sizeof(uint16_t), &dir, sizeof(uint32_t));
 
-	/*
-	 * VNIC is being pushed as 32bit and the pop will take care of
-	 * proper size
-	 */
+	/* Set the implicit vnic in the action property */
 	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
 	vnic = htonl(vnic);
 	rte_memcpy(&act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
@@ -132,9 +128,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
-
 	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
 					&act_bitmap, &class_id);
 
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +73 -19

168 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +5 -0
index 0ab43d2a6..0d571bbba 100644
@@ -20,6 +20,11 @@
 #define BNXT_ULP_ENCAP_IPV6_SIZE		8
 #define BNXT_ULP_ENCAP_UDP_SIZE			4
 
+/* Function to handle the parsing of the RTE port id. */
+int32_t
+ulp_rte_parser_svif_process(struct ulp_rte_hdr_bitmap	*hdr_bitmap,
+			    struct ulp_rte_hdr_field	*hdr_field);
+
 /*
  * Function to handle the parsing of RTE Flows and placing
  * the RTE flow items into the ulp structures.
Signature · 1 line
2.21.1 (Apple Git-122.3)
#14 lore raw

PATCH v2 2/12 net/bnxt: allow usage of more resources in flow db

In reply to Ajit Khaparde

From: Mike Baucom <[email protected]>

Allow the flow db resources to be more effectively utilized.

---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +5 -1
index aed50785c..e99e94ab7 100644
@@ -331,6 +331,10 @@ int32_t ulp_flow_db_fid_alloc(struct bnxt_ulp_context		*ulp_ctxt,
 		BNXT_TF_DBG(ERR, "Flow database has reached max flows\n");
 		return -ENOMEM;
 	}
+	if (flow_tbl->tail_index <= (flow_tbl->head_index + 1)) {
+		BNXT_TF_DBG(ERR, "Flow database has reached max resources\n");
+		return -ENOMEM;
+	}
 	*fid = flow_tbl->flow_tbl_stack[flow_tbl->head_index];
 	flow_tbl->head_index++;
 	ulp_flow_db_active_flow_set(flow_tbl, *fid, 1);
@@ -385,7 +389,7 @@ int32_t	ulp_flow_db_resource_add(struct bnxt_ulp_context	*ulp_ctxt,
 	}
 
 	/* check for max resource */
-	if ((flow_tbl->num_flows + 1) >= flow_tbl->tail_index) {
+	if ((flow_tbl->head_index + 1) >= flow_tbl->tail_index) {
 		BNXT_TF_DBG(ERR, "Flow db has reached max resources\n");
 		return -ENOMEM;
 	}
Signature · 1 line
2.21.1 (Apple Git-122.3)
#15 lore raw

PATCH v2 3/12 net/bnxt: add flow database resource iteration API

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

This API can be used to iterate individual resource functions in the flow database.

---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 66 ++++++++++++++++++++++++++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 17 +++++++
 2 files changed, 82 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +65 -1
index e99e94ab7..9e7f9f5e3 100644
@@ -560,7 +560,71 @@ int32_t	ulp_flow_db_fid_free(struct bnxt_ulp_context		*ulp_ctxt,
 	return 0;
 }
 
-/** Get the flow database entry iteratively
+/*
+ * Get the flow database entry details
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * tbl_idx [in] Specify it is regular or default flow
+ * fid [in] The index to the flow entry
+ * nxt_idx [in/out] the index to the next entry
+ * params [out] The contents to be copied into params.
+ *
+ * returns 0 on success and negative on failure.
+ */
+int32_t	ulp_flow_db_resource_get(struct bnxt_ulp_context	*ulp_ctxt,
+				 enum bnxt_ulp_flow_db_tables	tbl_idx,
+				 uint32_t			fid,
+				 uint32_t			*nxt_idx,
+				 struct ulp_flow_db_res_params	*params)
+{
+	struct bnxt_ulp_flow_db		*flow_db;
+	struct bnxt_ulp_flow_tbl	*flow_tbl;
+	struct ulp_fdb_resource_info	*nxt_resource, *fid_resource;
+
+	flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt);
+	if (!flow_db) {
+		BNXT_TF_DBG(ERR, "Invalid Arguments\n");
+		return -EINVAL;
+	}
+
+	if (tbl_idx >= BNXT_ULP_FLOW_TABLE_MAX) {
+		BNXT_TF_DBG(ERR, "Invalid table index\n");
+		return -EINVAL;
+	}
+
+	flow_tbl = &flow_db->flow_tbl[tbl_idx];
+
+	/* check for limits of fid */
+	if (fid >= flow_tbl->num_flows || !fid) {
+		BNXT_TF_DBG(ERR, "Invalid flow index\n");
+		return -EINVAL;
+	}
+
+	/* check if the flow is active or not */
+	if (!ulp_flow_db_active_flow_is_set(flow_tbl, fid)) {
+		BNXT_TF_DBG(ERR, "flow does not exist\n");
+		return -EINVAL;
+	}
+
+	if (!*nxt_idx) {
+		fid_resource = &flow_tbl->flow_resources[fid];
+		ulp_flow_db_res_info_to_params(fid_resource, params);
+		ULP_FLOW_DB_RES_NXT_SET(*nxt_idx,
+					fid_resource->nxt_resource_idx);
+	} else {
+		nxt_resource = &flow_tbl->flow_resources[*nxt_idx];
+		ulp_flow_db_res_info_to_params(nxt_resource, params);
+		*nxt_idx = 0;
+		ULP_FLOW_DB_RES_NXT_SET(*nxt_idx,
+					nxt_resource->nxt_resource_idx);
+	}
+
+	/* all good, return success */
+	return 0;
+}
+
+/*
+ * Get the flow database entry iteratively
  *
  * flow_tbl [in] Ptr to flow table
  * fid [in/out] The index to the flow entry
drivers/net/bnxt/tf_ulp/ulp_flow_db.h +17 -0
index 543541565..5361dd025 100644
@@ -142,6 +142,23 @@ int32_t	ulp_flow_db_fid_free(struct bnxt_ulp_context		*ulp_ctxt,
 			     enum bnxt_ulp_flow_db_tables	tbl_idx,
 			     uint32_t				fid);
 
+/*
+ *Get the flow database entry details
+ *
+ * ulp_ctxt [in] Ptr to ulp_context
+ * tbl_idx [in] Specify it is regular or default flow
+ * fid [in] The index to the flow entry
+ * nxt_idx [in/out] the index to the next entry
+ * params [out] The contents to be copied into params.
+ *
+ * returns 0 on success and negative on failure.
+ */
+int32_t	ulp_flow_db_resource_get(struct bnxt_ulp_context	*ulp_ctxt,
+				 enum bnxt_ulp_flow_db_tables	tbl_idx,
+				 uint32_t			fid,
+				 uint32_t			*nxt_idx,
+				 struct ulp_flow_db_res_params	*params);
+
 /*
  * Flush all flows in the flow database.
  *
Signature · 1 line
2.21.1 (Apple Git-122.3)
#16 lore raw

PATCH v2 4/12 net/bnxt: add resource name type to debug messages

In reply to Ajit Khaparde

From: Mike Baucom <[email protected]>

Added the name of the resource to the index/result and key/mask common builder functions.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 61 ++++++++++++++++------------
 1 file changed, 34 insertions(+), 27 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +34 -27
index ca4dd4562..f787c6e4d 100644
@@ -365,7 +365,8 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 static int32_t
 ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 				struct bnxt_ulp_mapper_result_field_info *fld,
-				struct ulp_blob *blob)
+				struct ulp_blob *blob,
+				const char *name)
 {
 	uint16_t idx, size_idx;
 	uint8_t	 *val = NULL;
@@ -376,20 +377,20 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT:
 		val = fld->result_operand;
 		if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
-			BNXT_TF_DBG(ERR, "Failed to add field\n");
+			BNXT_TF_DBG(ERR, "%s failed to add field\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
 
 		if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) {
-			BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", idx);
+			BNXT_TF_DBG(ERR, "%s act_prop[%d] oob\n", name, idx);
 			return -EINVAL;
 		}
 		val = &parms->act_prop->act_details[idx];
@@ -400,20 +401,20 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 			val += field_size;
 		}
 		if (!ulp_blob_push(blob, val, fld->field_bit_size)) {
-			BNXT_TF_DBG(ERR, "push field failed\n");
+			BNXT_TF_DBG(ERR, "%s push field failed\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP_SZ:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
 
 		if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) {
-			BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", idx);
+			BNXT_TF_DBG(ERR, "%s act_prop[%d] oob\n", name, idx);
 			return -EINVAL;
 		}
 		val = &parms->act_prop->act_details[idx];
@@ -421,7 +422,7 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 		/* get the size index next */
 		if (!ulp_operand_read(&fld->result_operand[sizeof(uint16_t)],
 				      (uint8_t *)&size_idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 		size_idx = tfp_be_to_cpu_16(size_idx);
@@ -439,20 +440,21 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_RESULT_OPC_SET_TO_REGFILE:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "operand read failed\n");
+			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
 			return -EINVAL;
 		}
 
 		idx = tfp_be_to_cpu_16(idx);
 		/* Uninitialized regfile entries return 0 */
 		if (!ulp_regfile_read(parms->regfile, idx, &regval)) {
-			BNXT_TF_DBG(ERR, "regfile[%d] read oob\n", idx);
+			BNXT_TF_DBG(ERR, "%s regfile[%d] read oob\n",
+				    name, idx);
 			return -EINVAL;
 		}
 
 		val = ulp_blob_push_64(blob, &regval, fld->field_bit_size);
 		if (!val) {
-			BNXT_TF_DBG(ERR, "push field failed\n");
+			BNXT_TF_DBG(ERR, "%s push field failed\n", name);
 			return -EINVAL;
 		}
 		break;
@@ -468,7 +470,8 @@ static int32_t
 ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 				 struct bnxt_ulp_mapper_class_key_field_info *f,
 				 struct ulp_blob *blob,
-				 uint8_t is_key)
+				 uint8_t is_key,
+				 const char *name)
 {
 	uint64_t regval;
 	uint16_t idx, bitlen;
@@ -493,13 +496,13 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_SPEC_OPC_SET_TO_CONSTANT:
 		val = operand;
 		if (!ulp_blob_push(blob, val, bitlen)) {
-			BNXT_TF_DBG(ERR, "push to key blob failed\n");
+			BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_SPEC_OPC_ADD_PAD:
 		if (!ulp_blob_pad_push(blob, bitlen)) {
-			BNXT_TF_DBG(ERR, "Pad too large for blob\n");
+			BNXT_TF_DBG(ERR, "%s pad too large for blob\n", name);
 			return -EINVAL;
 		}
 
@@ -507,7 +510,7 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 	case BNXT_ULP_SPEC_OPC_SET_TO_HDR_FIELD:
 		if (!ulp_operand_read(operand, (uint8_t *)&idx,
 				      sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "key operand read failed.\n");
+			BNXT_TF_DBG(ERR, "%s key operand read failed.\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
@@ -527,27 +530,27 @@ ulp_mapper_keymask_field_process(struct bnxt_ulp_mapper_parms *parms,
 		}
 
 		if (!ulp_blob_push(blob, val, bitlen)) {
-			BNXT_TF_DBG(ERR, "push to key blob failed\n");
+			BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
 			return -EINVAL;
 		}
 		break;
 	case BNXT_ULP_SPEC_OPC_SET_TO_REGFILE:
 		if (!ulp_operand_read(operand, (uint8_t *)&idx,
 				      sizeof(uint16_t))) {
-			BNXT_TF_DBG(ERR, "key operand read failed.\n");
+			BNXT_TF_DBG(ERR, "%s key operand read failed.\n", name);
 			return -EINVAL;
 		}
 		idx = tfp_be_to_cpu_16(idx);
 
 		if (!ulp_regfile_read(regfile, idx, &regval)) {
-			BNXT_TF_DBG(ERR, "regfile[%d] read failed.\n",
-				    idx);
+			BNXT_TF_DBG(ERR, "%s regfile[%d] read failed.\n",
+				    name, idx);
 			return -EINVAL;
 		}
 
 		val = ulp_blob_push_64(blob, &regval, bitlen);
 		if (!val) {
-			BNXT_TF_DBG(ERR, "push to key blob failed\n");
+			BNXT_TF_DBG(ERR, "%s push to key blob failed\n", name);
 			return -EINVAL;
 		}
 	default:
@@ -715,7 +718,8 @@ ulp_mapper_action_info_process(struct bnxt_ulp_mapper_parms *parms,
 		fld = &flds[i];
 		rc = ulp_mapper_result_field_process(parms,
 						     fld,
-						     &blob);
+						     &blob,
+						     "Action");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Action field failed\n");
 			return rc;
@@ -777,7 +781,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < num_kflds; i++) {
 		/* Setup the key */
 		rc = ulp_mapper_keymask_field_process(parms, &kflds[i],
-						      &key, 1);
+						      &key, 1, "TCAM Key");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Key field set failed.\n");
 			return rc;
@@ -785,7 +789,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
 		/* Setup the mask */
 		rc = ulp_mapper_keymask_field_process(parms, &kflds[i],
-						      &mask, 0);
+						      &mask, 0, "TCAM Mask");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Mask field set failed.\n");
 			return rc;
@@ -852,7 +856,8 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		for (i = 0; i < num_dflds; i++) {
 			rc = ulp_mapper_result_field_process(parms,
 							     &dflds[i],
-							     &data);
+							     &data,
+							     "TCAM Result");
 			if (rc) {
 				BNXT_TF_DBG(ERR, "Failed to set data fields\n");
 				goto error;
@@ -955,7 +960,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < num_kflds; i++) {
 		/* Setup the key */
 		rc = ulp_mapper_keymask_field_process(parms, &kflds[i],
-						      &key, 1);
+						      &key, 1, "EM Key");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Key field set failed.\n");
 			return rc;
@@ -981,7 +986,8 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
 		rc = ulp_mapper_result_field_process(parms,
 						     fld,
-						     &data);
+						     &data,
+						     "EM Result");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "Failed to set data fields.\n");
 			return rc;
@@ -1130,7 +1136,8 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	for (i = 0; i < num_flds; i++) {
 		rc = ulp_mapper_result_field_process(parms,
 						     &flds[i],
-						     &data);
+						     &data,
+						     "Indexed Result");
 		if (rc) {
 			BNXT_TF_DBG(ERR, "data field failed\n");
 			return rc;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#17 lore raw

PATCH v2 5/12 net/bnxt: aggregate ulp rte parser arguments

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

The changes are to the ulp rte parser, the API are changed to take the parser param structure instead of individual fields.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  75 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c         |  20 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.h         |  12 +-
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      | 882 +++++++++---------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      | 150 +--
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  42 +-
 6 files changed, 560 insertions(+), 621 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +25 -50
index 6203a495c..026f33f66 100644
@@ -67,11 +67,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		     const struct rte_flow_action	actions[],
 		     struct rte_flow_error		*error)
 {
-	struct ulp_rte_hdr_bitmap hdr_bitmap;
-	struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX];
-	struct ulp_rte_act_bitmap act_bitmap;
-	struct ulp_rte_act_prop act_prop;
-	enum ulp_direction_type dir = ULP_DIR_INGRESS;
+	struct ulp_rte_parser_params params;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
@@ -94,47 +90,38 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		return NULL;
 	}
 
-	/* clear the header bitmap and field structure */
-	memset(&hdr_bitmap, 0, sizeof(struct ulp_rte_hdr_bitmap));
-	memset(hdr_field, 0, sizeof(hdr_field));
-	memset(&act_bitmap, 0, sizeof(act_bitmap));
-	memset(&act_prop, 0, sizeof(act_prop));
+	/* Initialize the parser params */
+	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
 
 	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
+		params.dir = ULP_DIR_EGRESS;
 
-	/* copy the device port id and direction in svif for further process */
-	buffer = hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
+	/* copy the device port id and direction for further processing */
+	buffer = params.hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
 	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
-	rte_memcpy(buffer + sizeof(uint16_t), &dir, sizeof(uint32_t));
 
 	/* Set the implicit vnic in the action property */
 	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
 	vnic = htonl(vnic);
-	rte_memcpy(&act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
+	rte_memcpy(&params.act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
 		   &vnic, BNXT_ULP_ACT_PROP_SZ_VNIC);
 
 	/* Parse the rte flow pattern */
-	ret = bnxt_ulp_rte_parser_hdr_parse(pattern,
-					    &hdr_bitmap,
-					    hdr_field);
+	ret = bnxt_ulp_rte_parser_hdr_parse(pattern, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
 	/* Parse the rte flow action */
-	ret = bnxt_ulp_rte_parser_act_parse(actions,
-					    &act_bitmap,
-					    &act_prop);
+	ret = bnxt_ulp_rte_parser_act_parse(actions, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
-					&act_bitmap, &class_id);
+	ret = ulp_matcher_pattern_match(&params, &class_id);
 
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	ret = ulp_matcher_action_match(dir, &act_bitmap, &act_tmpl);
+	ret = ulp_matcher_action_match(&params, &act_tmpl);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
@@ -142,10 +129,10 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	/* call the ulp mapper to create the flow in the hardware */
 	ret = ulp_mapper_flow_create(ulp_ctx,
 				     app_priority,
-				     &hdr_bitmap,
-				     hdr_field,
-				     &act_bitmap,
-				     &act_prop,
+				     &params.hdr_bitmap,
+				     params.hdr_field,
+				     &params.act_bitmap,
+				     &params.act_prop,
 				     class_id,
 				     act_tmpl,
 				     &fid);
@@ -168,11 +155,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 		       const struct rte_flow_action actions[],
 		       struct rte_flow_error *error)
 {
-	struct ulp_rte_hdr_bitmap hdr_bitmap;
-	struct ulp_rte_hdr_field hdr_field[BNXT_ULP_PROTO_HDR_MAX];
-	struct ulp_rte_act_bitmap act_bitmap;
-	struct ulp_rte_act_prop act_prop;
-	enum ulp_direction_type dir = ULP_DIR_INGRESS;
+	struct ulp_rte_parser_params		params;
 	uint32_t class_id, act_tmpl;
 	int ret;
 
@@ -183,36 +166,28 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 		return -EINVAL;
 	}
 
-	/* clear the header bitmap and field structure */
-	memset(&hdr_bitmap, 0, sizeof(struct ulp_rte_hdr_bitmap));
-	memset(hdr_field, 0, sizeof(hdr_field));
-	memset(&act_bitmap, 0, sizeof(act_bitmap));
-	memset(&act_prop, 0, sizeof(act_prop));
+	/* Initialize the parser params */
+	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
+
+	if (attr->egress)
+		params.dir = ULP_DIR_EGRESS;
 
 	/* Parse the rte flow pattern */
-	ret = bnxt_ulp_rte_parser_hdr_parse(pattern,
-					    &hdr_bitmap,
-					    hdr_field);
+	ret = bnxt_ulp_rte_parser_hdr_parse(pattern, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
 	/* Parse the rte flow action */
-	ret = bnxt_ulp_rte_parser_act_parse(actions,
-					    &act_bitmap,
-					    &act_prop);
+	ret = bnxt_ulp_rte_parser_act_parse(actions, &params);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	if (attr->egress)
-		dir = ULP_DIR_EGRESS;
-
-	ret = ulp_matcher_pattern_match(dir, &hdr_bitmap, hdr_field,
-					&act_bitmap, &class_id);
+	ret = ulp_matcher_pattern_match(&params, &class_id);
 
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	ret = ulp_matcher_action_match(dir, &act_bitmap, &act_tmpl);
+	ret = ulp_matcher_action_match(&params, &act_tmpl);
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
drivers/net/bnxt/tf_ulp/ulp_matcher.c +10 -10
index ec4121d5c..e04bfa094 100644
@@ -67,11 +67,8 @@ ulp_matcher_hdr_fields_normalize(struct ulp_rte_hdr_bitmap *hdr1,
  * the pattern masks against the flow templates.
  */
 int32_t
-ulp_matcher_pattern_match(enum ulp_direction_type   dir,
-			  struct ulp_rte_hdr_bitmap *hdr_bitmap,
-			  struct ulp_rte_hdr_field  *hdr_field,
-			  struct ulp_rte_act_bitmap *act_bitmap,
-			  uint32_t		    *class_id)
+ulp_matcher_pattern_match(struct ulp_rte_parser_params *params,
+			  uint32_t *class_id)
 {
 	struct bnxt_ulp_header_match_info	*sel_hdr_match;
 	uint32_t				hdr_num, idx, jdx;
@@ -80,9 +77,12 @@ ulp_matcher_pattern_match(enum ulp_direction_type   dir,
 	uint32_t				start_idx;
 	struct ulp_rte_hdr_field		*m_field;
 	struct bnxt_ulp_matcher_field_info	*sf;
+	struct ulp_rte_hdr_bitmap *hdr_bitmap = &params->hdr_bitmap;
+	struct ulp_rte_act_bitmap *act_bitmap = &params->act_bitmap;
+	struct ulp_rte_hdr_field *hdr_field = params->hdr_field;
 
 	/* Select the ingress or egress template to match against */
-	if (dir == ULP_DIR_INGRESS) {
+	if (params->dir == ULP_DIR_INGRESS) {
 		sel_hdr_match = ulp_ingress_hdr_match_list;
 		hdr_num = BNXT_ULP_INGRESS_HDR_MATCH_SZ;
 	} else {
@@ -156,15 +156,15 @@ ulp_matcher_pattern_match(enum ulp_direction_type   dir,
  * the action against the flow templates.
  */
 int32_t
-ulp_matcher_action_match(enum ulp_direction_type		dir,
-			 struct ulp_rte_act_bitmap		*act_bitmap,
-			 uint32_t				*act_id)
+ulp_matcher_action_match(struct ulp_rte_parser_params *params,
+			 uint32_t *act_id)
 {
 	struct bnxt_ulp_action_match_info	*sel_act_match;
 	uint32_t				act_num, idx;
+	struct ulp_rte_act_bitmap *act_bitmap = &params->act_bitmap;
 
 	/* Select the ingress or egress template to match against */
-	if (dir == ULP_DIR_INGRESS) {
+	if (params->dir == ULP_DIR_INGRESS) {
 		sel_act_match = ulp_ingress_act_match_list;
 		act_num = BNXT_ULP_INGRESS_ACT_MATCH_SZ;
 	} else {
drivers/net/bnxt/tf_ulp/ulp_matcher.h +4 -8
index c818bbe31..fc197830f 100644
@@ -17,19 +17,15 @@
  * the pattern masks against the flow templates.
  */
 int32_t
-ulp_matcher_pattern_match(enum ulp_direction_type	    dir,
-			  struct ulp_rte_hdr_bitmap	   *hdr_bitmap,
-			  struct ulp_rte_hdr_field	   *hdr_field,
-			  struct ulp_rte_act_bitmap	   *act_bitmap,
-			  uint32_t			   *class_id);
+ulp_matcher_pattern_match(struct ulp_rte_parser_params *params,
+			  uint32_t *class_id);
 
 /*
  * Function to handle the matching of RTE Flows and validating
  * the action against the flow templates.
  */
 int32_t
-ulp_matcher_action_match(enum ulp_direction_type	dir,
-			 struct ulp_rte_act_bitmap	*act_bitmap,
-			 uint32_t			*act_id);
+ulp_matcher_action_match(struct ulp_rte_parser_params *params,
+			 uint32_t *act_id);
 
 #endif /* ULP_MATCHER_H_ */
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +448 -434

1,329 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +50 -100

236 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_struct.h +23 -19

64 lines not on this page · raw message

Signature · 1 line
2.21.1 (Apple Git-122.3)
#18 lore raw

PATCH v2 6/12 net/bnxt: aggregate ulp mapper create arguments

In reply to Ajit Khaparde

From: Mike Baucom <[email protected]>

The changes are to the ulp mapper flow_create, the API changed to take the bnxt_ulp_mapper_create_parms structure instead of individual fields.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 19 +++++++-------
 drivers/net/bnxt/tf_ulp/ulp_mapper.c    | 33 +++++++++++--------------
 drivers/net/bnxt/tf_ulp/ulp_mapper.h    | 20 +++++++++------
 3 files changed, 37 insertions(+), 35 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +10 -9
index 026f33f66..9326401b4 100644
@@ -67,11 +67,11 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		     const struct rte_flow_action	actions[],
 		     struct rte_flow_error		*error)
 {
+	struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };
 	struct ulp_rte_parser_params params;
 	struct bnxt_ulp_context *ulp_ctx = NULL;
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
-	uint32_t app_priority;
 	uint32_t fid;
 	uint8_t	*buffer;
 	uint32_t vnic;
@@ -125,16 +125,17 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
-	app_priority = attr->priority;
+	mapper_cparms.app_priority = attr->priority;
+	mapper_cparms.hdr_bitmap = &params.hdr_bitmap;
+	mapper_cparms.hdr_field = params.hdr_field;
+	mapper_cparms.act = &params.act_bitmap;
+	mapper_cparms.act_prop = &params.act_prop;
+	mapper_cparms.class_tid = class_id;
+	mapper_cparms.act_tid = act_tmpl;
+
 	/* call the ulp mapper to create the flow in the hardware */
 	ret = ulp_mapper_flow_create(ulp_ctx,
-				     app_priority,
-				     &params.hdr_bitmap,
-				     params.hdr_field,
-				     &params.act_bitmap,
-				     &params.act_prop,
-				     class_id,
-				     act_tmpl,
+				     &mapper_cparms,
 				     &fid);
 	if (!ret) {
 		flow_id = (struct rte_flow *)((uintptr_t)fid);
drivers/net/bnxt/tf_ulp/ulp_mapper.c +15 -18
index f787c6e4d..f70afa47f 100644
@@ -1411,26 +1411,23 @@ ulp_mapper_flow_destroy(struct bnxt_ulp_context	*ulp_ctx, uint32_t fid)
  */
 int32_t
 ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
-		       uint32_t app_priority __rte_unused,
-		       struct ulp_rte_hdr_bitmap *hdr_bitmap __rte_unused,
-		       struct ulp_rte_hdr_field *hdr_field,
-		       struct ulp_rte_act_bitmap *act_bitmap,
-		       struct ulp_rte_act_prop *act_prop,
-		       uint32_t class_tid,
-		       uint32_t act_tid,
-		       uint32_t *flow_id)
+		       struct bnxt_ulp_mapper_create_parms *cparms,
+		       uint32_t *flowid)
 {
-	struct ulp_regfile		regfile;
-	struct bnxt_ulp_mapper_parms	parms;
-	struct bnxt_ulp_device_params	*device_params;
-	int32_t				rc, trc;
+	struct bnxt_ulp_device_params *device_params;
+	struct bnxt_ulp_mapper_parms parms;
+	struct ulp_regfile regfile;
+	int32_t	 rc, trc;
+
+	if (!ulp_ctx || !cparms)
+		return -EINVAL;
 
 	/* Initialize the parms structure */
 	memset(&parms, 0, sizeof(parms));
-	parms.act_prop = act_prop;
-	parms.act_bitmap = act_bitmap;
+	parms.act_prop = cparms->act_prop;
+	parms.act_bitmap = cparms->act;
 	parms.regfile = &regfile;
-	parms.hdr_field = hdr_field;
+	parms.hdr_field = cparms->hdr_field;
 	parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
 	parms.ulp_ctx = ulp_ctx;
 
@@ -1441,7 +1438,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	}
 
 	/* Get the action table entry from device id and act context id */
-	parms.act_tid = act_tid;
+	parms.act_tid = cparms->act_tid;
 	parms.atbls = ulp_mapper_action_tbl_list_get(parms.dev_id,
 						     parms.act_tid,
 						     &parms.num_atbls);
@@ -1452,7 +1449,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	}
 
 	/* Get the class table entry from device id and act context id */
-	parms.class_tid = class_tid;
+	parms.class_tid = cparms->class_tid;
 	parms.ctbls = ulp_mapper_class_tbl_list_get(parms.dev_id,
 						    parms.class_tid,
 						    &parms.num_ctbls);
@@ -1506,7 +1503,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 		goto flow_error;
 	}
 
-	*flow_id = parms.fid;
+	*flowid = parms.fid;
 
 	return rc;
 
drivers/net/bnxt/tf_ulp/ulp_mapper.h +12 -8
index 5f3d46eff..24727a32d 100644
@@ -38,20 +38,24 @@ struct bnxt_ulp_mapper_parms {
 	enum bnxt_ulp_flow_db_tables		tbl_idx;
 };
 
+struct bnxt_ulp_mapper_create_parms {
+	uint32_t			app_priority;
+	struct ulp_rte_hdr_bitmap	*hdr_bitmap;
+	struct ulp_rte_hdr_field	*hdr_field;
+	struct ulp_rte_act_bitmap	*act;
+	struct ulp_rte_act_prop		*act_prop;
+	uint32_t			class_tid;
+	uint32_t			act_tid;
+};
+
 /*
  * Function to handle the mapping of the Flow to be compatible
  * with the underlying hardware.
  */
 int32_t
 ulp_mapper_flow_create(struct bnxt_ulp_context	*ulp_ctx,
-		       uint32_t		app_priority,
-		       struct ulp_rte_hdr_bitmap  *hdr_bitmap,
-		       struct ulp_rte_hdr_field *hdr_field,
-		       struct ulp_rte_act_bitmap *act,
-		       struct ulp_rte_act_prop *act_prop,
-		       uint32_t		class_tid,
-		       uint32_t		act_tid,
-		       uint32_t		*flow_id);
+		       struct bnxt_ulp_mapper_create_parms *parms,
+		       uint32_t *flowid);
 
 /* Function that frees all resources associated with the flow. */
 int32_t
Signature · 1 line
2.21.1 (Apple Git-122.3)
#19 lore raw

PATCH v2 7/12 net/bnxt: use hashing for flow template match

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

Currently, all the flow templates are sequentially searched to find out whether there is a matching template for the incoming RTE_FLOW offload request. As sequential search will have performance concerns, this patch will address it by using hash algorithm to find out the flow template. This change resulted in creation of computed fields to remove the fields that do not participate in the hash calculations. The field bitmap is created for this purpose.

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  23 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |   4 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c         | 214 +++++-------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      | 282 ++++++++--------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      |   4 +
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     | 307 +++++++-----------
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     | 280 ++++++++++------
 .../net/bnxt/tf_ulp/ulp_template_field_db.h   | 171 +++-------
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  50 ++-
 drivers/net/bnxt/tf_ulp/ulp_utils.c           |  33 ++
 drivers/net/bnxt/tf_ulp/ulp_utils.h           |  17 +-
 11 files changed, 686 insertions(+), 699 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +8 -15
index 9326401b4..7f7aa24e6 100644
@@ -61,11 +61,11 @@ bnxt_ulp_flow_validate_args(const struct rte_flow_attr *attr,
 
 /* Function to create the rte flow. */
 static struct rte_flow *
-bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
-		     const struct rte_flow_attr		*attr,
-		     const struct rte_flow_item		pattern[],
-		     const struct rte_flow_action	actions[],
-		     struct rte_flow_error		*error)
+bnxt_ulp_flow_create(struct rte_eth_dev *dev,
+		     const struct rte_flow_attr *attr,
+		     const struct rte_flow_item pattern[],
+		     const struct rte_flow_action actions[],
+		     struct rte_flow_error *error)
 {
 	struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };
 	struct ulp_rte_parser_params params;
@@ -73,8 +73,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
 	uint32_t fid;
-	uint8_t	*buffer;
-	uint32_t vnic;
 	int ret;
 
 	if (bnxt_ulp_flow_validate_args(attr,
@@ -97,14 +95,9 @@ bnxt_ulp_flow_create(struct rte_eth_dev			*dev,
 		params.dir = ULP_DIR_EGRESS;
 
 	/* copy the device port id and direction for further processing */
-	buffer = params.hdr_field[BNXT_ULP_HDR_FIELD_SVIF_INDEX].spec;
-	rte_memcpy(buffer, &dev->data->port_id, sizeof(uint16_t));
-
-	/* Set the implicit vnic in the action property */
-	vnic = (uint32_t)bnxt_get_vnic_id(dev->data->port_id);
-	vnic = htonl(vnic);
-	rte_memcpy(&params.act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC],
-		   &vnic, BNXT_ULP_ACT_PROP_SZ_VNIC);
+	ULP_UTIL_CHF_IDX_WR(&params, BNXT_ULP_CHF_IDX_INCOMING_IF,
+			    dev->data->port_id);
+	ULP_UTIL_CHF_IDX_WR(&params, BNXT_ULP_CHF_IDX_DIRECTION, params.dir);
 
 	/* Parse the rte flow pattern */
 	ret = bnxt_ulp_rte_parser_hdr_parse(pattern, &params);
drivers/net/bnxt/tf_ulp/ulp_mapper.c +2 -2
index f70afa47f..a0aba403f 100644
@@ -357,7 +357,7 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 	(void)tf_free_identifier(tfp, &free_parms);
 
 	BNXT_TF_DBG(ERR, "Ident process failed for %s:%s\n",
-		    ident->name,
+		    ident->description,
 		    (tbl->direction == TF_DIR_RX) ? "RX" : "TX");
 	return rc;
 }
@@ -405,7 +405,7 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 			return -EINVAL;
 		}
 		break;
-	case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP_SZ:
+	case BNXT_ULP_RESULT_OPC_SET_TO_ENCAP_ACT_PROP_SZ:
 		if (!ulp_operand_read(fld->result_operand,
 				      (uint8_t *)&idx, sizeof(uint16_t))) {
 			BNXT_TF_DBG(ERR, "%s operand read failed\n", name);
drivers/net/bnxt/tf_ulp/ulp_matcher.c +88 -126

249 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +150 -132

506 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +4 -0
index 4cc9dcc4e..cbc8a43de 100644
@@ -24,6 +24,10 @@
 int32_t
 ulp_rte_parser_svif_process(struct ulp_rte_parser_params *params);
 
+/* Function to handle the implicit VNIC RTE port id */
+int32_t
+ulp_rte_parser_vnic_process(struct ulp_rte_parser_params *params);
+
 /*
  * Function to handle the parsing of RTE Flows and placing
  * the RTE flow items into the ulp structures.
drivers/net/bnxt/tf_ulp/ulp_template_db.c +122 -185

478 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db.h +177 -103

378 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_field_db.h +52 -119

182 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_struct.h +34 -16

105 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_utils.c +33 -0
index e1d652864..0150c1d49 100644
@@ -519,3 +519,36 @@ int32_t ulp_buffer_is_empty(const uint8_t *buf, uint32_t size)
 {
 	return buf[0] == 0 && !memcmp(buf, buf + 1, size - 1);
 }
+
+/* Function to check if bitmap is zero.Return 1 on success */
+uint32_t ulp_bitmap_is_zero(uint8_t *bitmap, int32_t size)
+{
+	while (size-- > 0) {
+		if (*bitmap != 0)
+			return 0;
+		bitmap++;
+	}
+	return 1;
+}
+
+/* Function to check if bitmap is ones. Return 1 on success */
+uint32_t ulp_bitmap_is_ones(uint8_t *bitmap, int32_t size)
+{
+	while (size-- > 0) {
+		if (*bitmap != 0xFF)
+			return 0;
+		bitmap++;
+	}
+	return 1;
+}
+
+/* Function to check if bitmap is not zero. Return 1 on success */
+uint32_t ulp_bitmap_notzero(uint8_t *bitmap, int32_t size)
+{
+	while (size-- > 0) {
+		if (*bitmap != 0)
+			return 1;
+		bitmap++;
+	}
+	return 0;
+}
drivers/net/bnxt/tf_ulp/ulp_utils.h +16 -1
index f729ff681..5db393398 100644
@@ -16,7 +16,7 @@
 #define ULP_BITMAP_SET(bitmap, val)	((bitmap) |= (val))
 #define ULP_BITMAP_RESET(bitmap, val)	((bitmap) &= ~(val))
 #define ULP_BITMAP_ISSET(bitmap, val)	((bitmap) & (val))
-#define ULP_BITSET_CMP(b1, b2)  memcmp(&(b1)->bits, \
+#define ULP_BITMAP_CMP(b1, b2)  memcmp(&(b1)->bits, \
 				&(b2)->bits, sizeof((b1)->bits))
 /*
  * Macros for bitmap sets and gets
@@ -50,6 +50,12 @@
 /* Macro to convert bits to bytes with no round off*/
 #define ULP_BITS_2_BYTE_NR(bits_x)	((bits_x) / 8)
 
+/* Macros to read the computed fields */
+#define ULP_UTIL_CHF_IDX_RD(params, idx) \
+	rte_be_to_cpu_32((params)->comp_fld[(idx)])
+
+#define ULP_UTIL_CHF_IDX_WR(params, idx, val)	\
+	((params)->comp_fld[(idx)] = rte_cpu_to_be_32((val)))
 /*
  * Making the blob statically sized to 128 bytes for now.
  * The blob must be initialized with ulp_blob_init prior to using.
@@ -276,4 +282,13 @@ ulp_encap_buffer_copy(uint8_t *dst,
  */
 int32_t ulp_buffer_is_empty(const uint8_t *buf, uint32_t size);
 
+/* Function to check if bitmap is zero.Return 1 on success */
+uint32_t ulp_bitmap_is_zero(uint8_t *bitmap, int32_t size);
+
+/* Function to check if bitmap is ones. Return 1 on success */
+uint32_t ulp_bitmap_is_ones(uint8_t *bitmap, int32_t size);
+
+/* Function to check if bitmap is not zero. Return 1 on success */
+uint32_t ulp_bitmap_notzero(uint8_t *bitmap, int32_t size);
+
 #endif /* _ULP_UTILS_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#20 lore raw

PATCH v2 8/12 net/bnxt: add session and function flow flush

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

The ulp flow flush has been extended to support session flow flush and function flow flush. The session flow flush is called when there the device is sole owner of the session and it deletes all the flows associated with that session. The function flow flush is called if the device function is not the sole owner of the session, it deletes all the flows that are associated with that device function.

---
 drivers/net/bnxt/bnxt.h                 |   1 +
 drivers/net/bnxt/bnxt_ethdev.c          |  12 ++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c      |   8 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c |  31 +++--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c   | 149 ++++++++++++++++++++++--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h   |  46 +++++++-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c    |   2 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h    |   1 +
 8 files changed, 224 insertions(+), 26 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 00a4d0b3e..941eee6cd 100644
@@ -755,6 +755,7 @@ void bnxt_ulp_deinit(struct bnxt *bp);
 
 uint16_t bnxt_get_vnic_id(uint16_t port);
 uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif);
+uint16_t bnxt_get_fw_func_id(uint16_t port);
 
 void bnxt_cancel_fc_thread(struct bnxt *bp);
 void bnxt_flow_cnt_alarm_cb(void *arg);
drivers/net/bnxt/bnxt_ethdev.c +12 -0
index bd2c3fcb6..3fa0daffd 100644
@@ -4901,6 +4901,18 @@ bnxt_get_vnic_id(uint16_t port)
 	return vnic->fw_vnic_id;
 }
 
+uint16_t
+bnxt_get_fw_func_id(uint16_t port)
+{
+	struct rte_eth_dev *eth_dev;
+	struct bnxt *bp;
+
+	eth_dev = &rte_eth_devices[port];
+	bp = eth_dev->data->dev_private;
+
+	return bp->fw_fid;
+}
+
 static int bnxt_init_fw(struct bnxt *bp)
 {
 	uint16_t mtu;
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +2 -6
index 56e08f233..c67da6d76 100644
@@ -659,10 +659,8 @@ int32_t
 bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context	*ulp_ctx,
 				struct bnxt_ulp_flow_db	*flow_db)
 {
-	if (!ulp_ctx || !ulp_ctx->cfg_data) {
-		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+	if (!ulp_ctx || !ulp_ctx->cfg_data)
 		return -EINVAL;
-	}
 
 	ulp_ctx->cfg_data->flow_db = flow_db;
 	return 0;
@@ -672,10 +670,8 @@ bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context	*ulp_ctx,
 struct bnxt_ulp_flow_db	*
 bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context	*ulp_ctx)
 {
-	if (!ulp_ctx || !ulp_ctx->cfg_data) {
-		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+	if (!ulp_ctx || !ulp_ctx->cfg_data)
 		return NULL;
-	}
 
 	return ulp_ctx->cfg_data->flow_db;
 }
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +23 -8
index 7f7aa24e6..f0c812ced 100644
@@ -125,6 +125,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 	mapper_cparms.act_prop = &params.act_prop;
 	mapper_cparms.class_tid = class_id;
 	mapper_cparms.act_tid = act_tmpl;
+	mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id);
 
 	/* call the ulp mapper to create the flow in the hardware */
 	ret = ulp_mapper_flow_create(ulp_ctx,
@@ -202,7 +203,8 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 {
 	int ret = 0;
 	struct bnxt_ulp_context *ulp_ctx;
-	uint32_t fid;
+	uint32_t flow_id;
+	uint16_t func_id;
 
 	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);
 	if (!ulp_ctx) {
@@ -213,9 +215,19 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
-	fid = (uint32_t)(uintptr_t)flow;
+	flow_id = (uint32_t)(uintptr_t)flow;
+	func_id = bnxt_get_fw_func_id(dev->data->port_id);
 
-	ret = ulp_mapper_flow_destroy(ulp_ctx, fid);
+	if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) ==
+	    false) {
+		BNXT_TF_DBG(ERR, "Incorrect device params\n");
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Failed to destroy flow.");
+		return -EINVAL;
+	}
+
+	ret = ulp_mapper_flow_destroy(ulp_ctx, flow_id);
 	if (ret)
 		rte_flow_error_set(error, -ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -230,8 +242,9 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
 		    struct rte_flow_error *error)
 {
 	struct bnxt_ulp_context *ulp_ctx;
-	int32_t ret;
+	int32_t ret = 0;
 	struct bnxt *bp;
+	uint16_t func_id;
 
 	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev);
 	if (!ulp_ctx) {
@@ -244,10 +257,12 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
 	bp = eth_dev->data->dev_private;
 
 	/* Free the resources for the last device */
-	if (!ulp_ctx_deinit_allowed(bp))
-		return 0;
-
-	ret = ulp_flow_db_flush_flows(ulp_ctx, BNXT_ULP_REGULAR_FLOW_TABLE);
+	if (ulp_ctx_deinit_allowed(bp)) {
+		ret = ulp_flow_db_session_flow_flush(ulp_ctx);
+	} else if (bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctx)) {
+		func_id = bnxt_get_fw_func_id(eth_dev->data->port_id);
+		ret = ulp_flow_db_function_flow_flush(ulp_ctx, func_id);
+	}
 	if (ret)
 		rte_flow_error_set(error, ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
drivers/net/bnxt/tf_ulp/ulp_flow_db.c +141 -8

216 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_flow_db.h +43 -3

66 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mapper.c +1 -1
index a0aba403f..94899c005 100644
@@ -461,7 +461,6 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 	default:
 		return -EINVAL;
 	}
-
 	return 0;
 }
 
@@ -1481,6 +1480,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	 */
 	rc = ulp_flow_db_fid_alloc(ulp_ctx,
 				   BNXT_ULP_REGULAR_FLOW_TABLE,
+				   cparms->func_id,
 				   &parms.fid);
 	if (rc) {
 		BNXT_TF_DBG(ERR, "Unable to allocate flow table entry\n");
drivers/net/bnxt/tf_ulp/ulp_mapper.h +1 -0
index 24727a32d..2fa6ffce2 100644
@@ -46,6 +46,7 @@ struct bnxt_ulp_mapper_create_parms {
 	struct ulp_rte_act_prop		*act_prop;
 	uint32_t			class_tid;
 	uint32_t			act_tid;
+	uint16_t			func_id;
 };
 
 /*
Signature · 1 line
2.21.1 (Apple Git-122.3)
#21 lore raw

PATCH v2 9/12 net/bnxt: add default identifiers to ulp mapper

In reply to Ajit Khaparde

From: Mike Baucom <[email protected]>

- Added ulp_mapper_init/deinit to allocate/deallocate mapper data for storing the default identifiers
- Modified the template_db to include the new opcode for accessing the default ids.
- Modified the result and key field builders to use the new opcode for writing the default ids into blobs

---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  34 +++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |  10 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |   8 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 251 +++++++++++++++++-
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |  22 +-
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     |  35 +--
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  25 +-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  11 +
 8 files changed, 364 insertions(+), 32 deletions(-)
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +34 -0
index c67da6d76..202b4a529 100644
@@ -19,6 +19,7 @@
 #include "ulp_template_struct.h"
 #include "ulp_mark_mgr.h"
 #include "ulp_flow_db.h"
+#include "ulp_mapper.h"
 
 /* Linked list of all TF sessions. */
 STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list =
@@ -485,6 +486,12 @@ bnxt_ulp_init(struct bnxt *bp)
 		goto jump_to_error;
 	}
 
+	rc = ulp_mapper_init(&bp->ulp_ctx);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to initialize ulp mapper\n");
+		goto jump_to_error;
+	}
+
 	return rc;
 
 jump_to_error:
@@ -529,6 +536,9 @@ bnxt_ulp_deinit(struct bnxt *bp)
 	/* Delete the Mark database */
 	ulp_mark_db_deinit(&bp->ulp_ctx);
 
+	/* cleanup the ulp mapper */
+	ulp_mapper_deinit(&bp->ulp_ctx);
+
 	/* Delete the ulp context and tf session */
 	ulp_ctx_detach(bp, session);
 
@@ -689,3 +699,27 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev	*dev)
 	}
 	return &bp->ulp_ctx;
 }
+
+int32_t
+bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
+				    void *mapper_data)
+{
+	if (!ulp_ctx || !ulp_ctx->cfg_data) {
+		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+		return -EINVAL;
+	}
+
+	ulp_ctx->cfg_data->mapper_data = mapper_data;
+	return 0;
+}
+
+void *
+bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx)
+{
+	if (!ulp_ctx || !ulp_ctx->cfg_data) {
+		BNXT_TF_DBG(ERR, "Invalid ulp context data\n");
+		return NULL;
+	}
+
+	return ulp_ctx->cfg_data->mapper_data;
+}
drivers/net/bnxt/tf_ulp/bnxt_ulp.h +10 -0
index b3e9e960d..d2ca17857 100644
@@ -18,6 +18,7 @@ struct bnxt_ulp_data {
 	uint32_t			dev_id; /* Hardware device id */
 	uint32_t			ref_cnt;
 	struct bnxt_ulp_flow_db		*flow_db;
+	void				*mapper_data;
 };
 
 struct bnxt_ulp_context {
@@ -107,4 +108,13 @@ bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context	*ulp_ctx);
 struct bnxt_ulp_context	*
 bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
 
+/* Function to add the ulp mapper data to the ulp context */
+int32_t
+bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
+				    void *mapper_data);
+
+/* Function to get the ulp mapper data from the ulp context */
+void *
+bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
+
 #endif /* _BNXT_ULP_H_ */
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +3 -5
index f0c812ced..7783f85d9 100644
@@ -110,7 +110,6 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 		goto parse_error;
 
 	ret = ulp_matcher_pattern_match(&params, &class_id);
-
 	if (ret != BNXT_TF_RC_SUCCESS)
 		goto parse_error;
 
@@ -126,11 +125,10 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 	mapper_cparms.class_tid = class_id;
 	mapper_cparms.act_tid = act_tmpl;
 	mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id);
+	mapper_cparms.dir = params.dir;
 
-	/* call the ulp mapper to create the flow in the hardware */
-	ret = ulp_mapper_flow_create(ulp_ctx,
-				     &mapper_cparms,
-				     &fid);
+	/* Call the ulp mapper to create the flow in the hardware. */
+	ret = ulp_mapper_flow_create(ulp_ctx, &mapper_cparms, &fid);
 	if (!ret) {
 		flow_id = (struct rte_flow *)((uintptr_t)fid);
 		return flow_id;
drivers/net/bnxt/tf_ulp/ulp_mapper.c +245 -6

352 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_mapper.h +21 -1
index 2fa6ffce2..fb47f1c27 100644
@@ -6,10 +6,10 @@
 #ifndef _ULP_MAPPER_H_
 #define _ULP_MAPPER_H_
 
-#include <tf_core.h>
 #include <rte_log.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
+#include "tf_core.h"
 #include "ulp_template_db.h"
 #include "ulp_template_struct.h"
 #include "bnxt_ulp.h"
@@ -17,6 +17,16 @@
 
 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
 
+struct bnxt_ulp_mapper_def_id_entry {
+	enum tf_identifier_type ident_type;
+	uint64_t ident;
+};
+
+struct bnxt_ulp_mapper_data {
+	struct bnxt_ulp_mapper_def_id_entry
+		dflt_ids[TF_DIR_MAX][BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ];
+};
+
 /* Internal Structure for passing the arguments around */
 struct bnxt_ulp_mapper_parms {
 	uint32_t				dev_id;
@@ -36,6 +46,7 @@ struct bnxt_ulp_mapper_parms {
 	uint8_t					encap_byte_swap;
 	uint32_t				fid;
 	enum bnxt_ulp_flow_db_tables		tbl_idx;
+	struct bnxt_ulp_mapper_data		*mapper_data;
 };
 
 struct bnxt_ulp_mapper_create_parms {
@@ -47,8 +58,17 @@ struct bnxt_ulp_mapper_create_parms {
 	uint32_t			class_tid;
 	uint32_t			act_tid;
 	uint16_t			func_id;
+	enum ulp_direction_type		dir;
 };
 
+/* Function to initialize any dynamic mapper data. */
+int32_t
+ulp_mapper_init(struct bnxt_ulp_context	*ulp_ctx);
+
+/* Function to release all dynamic mapper data. */
+void
+ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
+
 /*
  * Function to handle the mapping of the Flow to be compatible
  * with the underlying hardware.
drivers/net/bnxt/tf_ulp/ulp_template_db.c +20 -15
index 25a558a4e..cd3f65f7a 100644
@@ -297,6 +297,15 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = {
 	}
 };
 
+struct bnxt_ulp_def_ident_info ulp_def_ident_tbl[] = {
+	[0] = {
+		.ident_type              = TF_IDENT_TYPE_PROF_FUNC,
+		.def_regfile_index       =
+			BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID,
+		.direction               = TF_DIR_RX
+	}
+};
+
 struct bnxt_ulp_device_params ulp_device_params[] = {
 	[BNXT_ULP_DEVICE_ID_WH_PLUS] = {
 		.global_fid_enable       = BNXT_ULP_SYM_YES,
@@ -577,7 +586,7 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
 	.result_bit_size = 64,
 	.result_num_fields = 13,
 	.ident_start_idx = 0,
-	.ident_nums = 2,
+	.ident_nums = 1,
 	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
 	.critical_resource = 0,
 	.regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
@@ -595,7 +604,7 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
 	.result_start_idx = 13,
 	.result_bit_size = 38,
 	.result_num_fields = 8,
-	.ident_start_idx = 2,
+	.ident_start_idx = 1,
 	.ident_nums = 1,
 	.mark_enable = BNXT_ULP_MARK_ENABLE_NO,
 	.critical_resource = 0,
@@ -614,6 +623,7 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
 	.result_start_idx = 21,
 	.result_bit_size = 64,
 	.result_num_fields = 9,
+	.ident_start_idx = 2,
 	.ident_nums = 0,
 	.mark_enable = BNXT_ULP_MARK_ENABLE_YES,
 	.critical_resource = 1,
@@ -1088,9 +1098,10 @@ struct bnxt_ulp_mapper_class_key_field_info ulp_class_key_field_list[] = {
 	.mask_opcode = BNXT_ULP_MASK_OPC_SET_TO_CONSTANT,
 	.mask_operand = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
-	.spec_opcode = BNXT_ULP_SPEC_OPC_SET_TO_REGFILE,
-	.spec_operand = {(BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 >> 8) & 0xff,
-		BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 & 0xff,
+	.spec_opcode = BNXT_ULP_SPEC_OPC_SET_TO_DEF_REGFILE,
+	.spec_operand = {
+		(BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID >> 8) & 0xff,
+		BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID & 0xff,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	},
@@ -1256,9 +1267,10 @@ struct bnxt_ulp_mapper_result_field_info ulp_class_result_field_list[] = {
 	},
 	{
 	.field_bit_size = 7,
-	.result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_REGFILE,
-	.result_operand = {(BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 >> 8) & 0xff,
-		BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0 & 0xff,
+	.result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_DEF_REGFILE,
+	.result_operand = {
+		(BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID >> 8) & 0xff,
+		BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID & 0xff,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 	},
@@ -1441,13 +1453,6 @@ struct bnxt_ulp_mapper_result_field_info ulp_class_result_field_list[] = {
 };
 
 struct bnxt_ulp_mapper_ident_info ulp_ident_list[] = {
-	{
-	.resource_func = BNXT_ULP_RESOURCE_FUNC_IDENTIFIER,
-	.ident_type = TF_IDENT_TYPE_PROF_FUNC,
-	.regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_PROF_FUNC_ID_0,
-	.ident_bit_size = 7,
-	.ident_bit_pos = 47
-	},
 	{
 	.resource_func = BNXT_ULP_RESOURCE_FUNC_IDENTIFIER,
 	.ident_type = TF_IDENT_TYPE_L2_CTXT,
drivers/net/bnxt/tf_ulp/ulp_template_db.h +20 -5
index 94d425315..cf4ff9f39 100644
@@ -28,6 +28,7 @@
 #define BNXT_ULP_ACT_HID_SHFTR 0
 #define BNXT_ULP_ACT_HID_SHFTL 23
 #define BNXT_ULP_ACT_HID_MASK 255
+#define BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ 1
 
 enum bnxt_ulp_action_bit {
 	BNXT_ULP_ACTION_BIT_MARK             = 0x0000000000000001,
@@ -112,6 +113,11 @@ enum bnxt_ulp_chf_idx {
 	BNXT_ULP_CHF_IDX_LAST = 14
 };
 
+enum bnxt_ulp_def_regfile_index {
+	BNXT_ULP_DEF_REGFILE_INDEX_DEF_PROF_FUNC_ID = 0,
+	BNXT_ULP_DEF_REGFILE_INDEX_LAST = 1
+};
+
 enum bnxt_ulp_device_id {
 	BNXT_ULP_DEVICE_ID_WH_PLUS = 0,
 	BNXT_ULP_DEVICE_ID_THOR = 1,
@@ -120,6 +126,12 @@ enum bnxt_ulp_device_id {
 	BNXT_ULP_DEVICE_ID_LAST = 4
 };
 
+enum bnxt_ulp_direction {
+	BNXT_ULP_DIRECTION_INGRESS = 0,
+	BNXT_ULP_DIRECTION_EGRESS = 1,
+	BNXT_ULP_DIRECTION_LAST = 2
+};
+
 enum bnxt_ulp_hdr_type {
 	BNXT_ULP_HDR_TYPE_NOT_SUPPORTED = 0,
 	BNXT_ULP_HDR_TYPE_SUPPORTED = 1,
@@ -137,8 +149,9 @@ enum bnxt_ulp_mask_opc {
 	BNXT_ULP_MASK_OPC_SET_TO_CONSTANT = 0,
 	BNXT_ULP_MASK_OPC_SET_TO_HDR_FIELD = 1,
 	BNXT_ULP_MASK_OPC_SET_TO_REGFILE = 2,
-	BNXT_ULP_MASK_OPC_ADD_PAD = 3,
-	BNXT_ULP_MASK_OPC_LAST = 4
+	BNXT_ULP_MASK_OPC_SET_TO_DEF_REGFILE = 3,
+	BNXT_ULP_MASK_OPC_ADD_PAD = 4,
+	BNXT_ULP_MASK_OPC_LAST = 5
 };
 
 enum bnxt_ulp_match_type {
@@ -193,7 +206,8 @@ enum bnxt_ulp_result_opc {
 	BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP = 1,
 	BNXT_ULP_RESULT_OPC_SET_TO_ENCAP_ACT_PROP_SZ = 2,
 	BNXT_ULP_RESULT_OPC_SET_TO_REGFILE = 3,
-	BNXT_ULP_RESULT_OPC_LAST = 4
+	BNXT_ULP_RESULT_OPC_SET_TO_DEF_REGFILE = 4,
+	BNXT_ULP_RESULT_OPC_LAST = 5
 };
 
 enum bnxt_ulp_search_before_alloc {
@@ -206,8 +220,9 @@ enum bnxt_ulp_spec_opc {
 	BNXT_ULP_SPEC_OPC_SET_TO_CONSTANT = 0,
 	BNXT_ULP_SPEC_OPC_SET_TO_HDR_FIELD = 1,
 	BNXT_ULP_SPEC_OPC_SET_TO_REGFILE = 2,
-	BNXT_ULP_SPEC_OPC_ADD_PAD = 3,
-	BNXT_ULP_SPEC_OPC_LAST = 4
+	BNXT_ULP_SPEC_OPC_SET_TO_DEF_REGFILE = 3,
+	BNXT_ULP_SPEC_OPC_ADD_PAD = 4,
+	BNXT_ULP_SPEC_OPC_LAST = 5
 };
 
 enum bnxt_ulp_encap_vtag_encoding {
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +11 -0
index c2d3ccb3e..476d5b9bb 100644
@@ -222,6 +222,12 @@ struct bnxt_ulp_mapper_ident_info {
 	enum bnxt_ulp_regfile_index	regfile_wr_idx;
 };
 
+struct bnxt_ulp_def_ident_info {
+	enum tf_dir direction;
+	enum tf_identifier_type ident_type;
+	enum bnxt_ulp_def_regfile_index def_regfile_index;
+};
+
 /*
  * Flow Mapper Static Data Externs:
  * Access to the below static data should be done through access functions and
@@ -285,4 +291,9 @@ extern struct bnxt_ulp_mapper_ident_info	ulp_ident_list[];
  */
 extern uint32_t ulp_act_prop_map_table[];
 
+/*
+ * The ulp_def_ident_tbl provides the list of default identifiers that need to
+ * be initialized and where to store them.
+ */
+extern struct bnxt_ulp_def_ident_info ulp_def_ident_tbl[];
 #endif /* _ULP_TEMPLATE_STRUCT_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#22 lore raw

PATCH v2 10/12 net/bnxt: add cache table type for TCAM lookup

In reply to Ajit Khaparde

From: Mike Baucom <[email protected]>

In order to re-use allocated resources and reduce search complexity for simple keys, a generic software cache table was added for the TCAM. The implementation is specifically only for keys that can be compressed to less than 16 bits. The keys are generated using the same mechanisms as other search tables, but the table type is set to a cache that mirrors the actual TCAM table. The allocated result fields are stored in the cache entry and can be used for subsequent searches in future tables.

---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 460 ++++++++++++++++--
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |  29 ++
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     | 155 +++++-
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  24 +-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  13 +
 5 files changed, 616 insertions(+), 65 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_mapper.c +414 -46
index c67a9e186..1b270d3a5 100644
@@ -66,6 +66,16 @@ ulp_mapper_def_regfile_write(struct bnxt_ulp_mapper_data *mapper_data,
 	return 0;
 }
 
+/* Retrieve the cache initialization parameters for the tbl_idx */
+static struct bnxt_ulp_cache_tbl_params *
+ulp_mapper_cache_tbl_params_get(uint32_t tbl_idx)
+{
+	if (tbl_idx >= BNXT_ULP_CACHE_TBL_MAX_SZ)
+		return NULL;
+
+	return &ulp_cache_tbl_params[tbl_idx];
+}
+
 /*
  * Get the size of the action property for a given index.
  *
@@ -256,6 +266,126 @@ ulp_mapper_ident_fields_get(struct bnxt_ulp_mapper_class_tbl_info *tbl,
 	return &ulp_ident_list[idx];
 }
 
+static struct bnxt_ulp_mapper_cache_entry *
+ulp_mapper_cache_entry_get(struct bnxt_ulp_context *ulp,
+			   enum bnxt_ulp_cache_tbl_id id,
+			   uint16_t key)
+{
+	struct bnxt_ulp_mapper_data *mapper_data;
+
+	mapper_data = bnxt_ulp_cntxt_ptr2_mapper_data_get(ulp);
+	if (!mapper_data || !mapper_data->cache_tbl[id]) {
+		BNXT_TF_DBG(ERR, "Unable to acquire the cache tbl (%d)\n", id);
+		return NULL;
+	}
+
+	return &mapper_data->cache_tbl[id][key];
+}
+
+/*
+ * Concatenates the tbl_type and tbl_id into a 32bit value for storing in the
+ * resource_type.  This is done to conserve memory since both the tbl_type and
+ * tbl_id are 16bit.
+ */
+static inline void
+ulp_mapper_cache_res_type_set(struct ulp_flow_db_res_params *res,
+			      uint16_t tbl_type,
+			      uint16_t tbl_id)
+{
+	res->resource_type =
+		((uint32_t)tbl_id << ULP_MAPPER_CACHE_RES_TBL_ID_SHFT) |
+		((uint32_t)tbl_type << ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT);
+}
+
+/* Extracts the tbl_type and tbl_id from the 32bit resource type. */
+static inline void
+ulp_mapper_cache_res_type_get(struct ulp_flow_db_res_params *res,
+			      uint16_t *tbl_type,
+			      uint16_t *tbl_id)
+{
+	*tbl_type = (uint16_t)((res->resource_type >>
+				ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT) &
+			       ULP_MAPPER_CACHE_RES_TBL_MASK);
+	*tbl_id = (uint16_t)((res->resource_type >>
+			      ULP_MAPPER_CACHE_RES_TBL_ID_SHFT) &
+			     ULP_MAPPER_CACHE_RES_TBL_MASK);
+}
+
+static int32_t
+ulp_mapper_cache_entry_free(struct bnxt_ulp_context *ulp,
+			   struct tf *tfp,
+			   struct ulp_flow_db_res_params *res)
+{
+	struct bnxt_ulp_mapper_cache_entry *cache_entry;
+	struct tf_free_identifier_parms ident_parms;
+	struct tf_free_tcam_entry_parms tcam_parms;
+	uint16_t table_id, table_type;
+	int32_t rc, trc, i;
+
+	/*
+	 * The table id, used for cache, and table_type, used for tcam, are
+	 * both encoded within the resource.  We must first extract them to
+	 * formulate the args for tf calls.
+	 */
+	ulp_mapper_cache_res_type_get(res, &table_type, &table_id);
+
+	cache_entry = ulp_mapper_cache_entry_get(ulp, table_id,
+						 (uint16_t)res->resource_hndl);
+	if (!cache_entry || !cache_entry->ref_count) {
+		BNXT_TF_DBG(ERR, "Cache entry (%d:%d) not valid on free.\n",
+			    table_id, (uint16_t)res->resource_hndl);
+		return -EINVAL;
+	}
+
+	/*
+	 * See if we need to delete the entry.  The tcam and identifiers are all
+	 * tracked by the cached entries reference count.  All are deleted when
+	 * the reference count hit zero.
+	 */
+	cache_entry->ref_count--;
+	if (cache_entry->ref_count)
+		return 0;
+
+	/*
+	 * Need to delete the tcam entry and the allocated identifiers.
+	 * In the event of a failure, need to try to delete the remaining
+	 * resources before returning error.
+	 */
+	tcam_parms.dir = res->direction;
+	tcam_parms.tcam_tbl_type = table_type;
+	tcam_parms.idx = cache_entry->tcam_idx;
+	rc = tf_free_tcam_entry(tfp, &tcam_parms);
+	if (rc)
+		BNXT_TF_DBG(ERR, "Failed to free tcam [%d][%s][0x%04x] rc=%d\n",
+			    table_type,
+			    (res->direction == TF_DIR_RX) ? "RX" : "TX",
+			    tcam_parms.idx, rc);
+
+	/*
+	 * Free the identifiers associated with the tcam entry.  Entries with
+	 * negative one are considered uninitialized.
+	 */
+	for (i = 0; i < BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM; i++) {
+		if (cache_entry->idents[i] == ULP_IDENTS_INVALID)
+			continue;
+
+		ident_parms.dir = res->direction;
+		ident_parms.ident_type = cache_entry->ident_types[i];
+		ident_parms.id = cache_entry->idents[i];
+		trc = tf_free_identifier(tfp, &ident_parms);
+		if (trc) {
+			BNXT_TF_DBG(ERR, "Failed to free identifier "
+				    "[%d][%s][0x%04x] rc=%d\n",
+				    ident_parms.ident_type,
+				    (res->direction == TF_DIR_RX) ? "RX" : "TX",
+				    ident_parms.id, trc);
+			rc = trc;
+		}
+	}
+
+	return rc;
+}
+
 static inline int32_t
 ulp_mapper_tcam_entry_free(struct bnxt_ulp_context *ulp  __rte_unused,
 			   struct tf *tfp,
@@ -337,10 +467,16 @@ ulp_mapper_mark_free(struct bnxt_ulp_context *ulp,
 				    0);
 }
 
+/*
+ * Process the identifier instruction and either store it in the flow database
+ * or return it in the val (if not NULL) on success.  If val is NULL, the
+ * identifier is to be stored in the flow database.
+ */
 static int32_t
 ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 			 struct bnxt_ulp_mapper_class_tbl_info *tbl,
-			 struct bnxt_ulp_mapper_ident_info *ident)
+			 struct bnxt_ulp_mapper_ident_info *ident,
+			 uint16_t *val)
 {
 	struct ulp_flow_db_res_params	fid_parms;
 	uint64_t id = 0;
@@ -378,22 +514,26 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 	}
 
 	/* Link the resource to the flow in the flow db */
-	memset(&fid_parms, 0, sizeof(fid_parms));
-	fid_parms.direction		= tbl->direction;
-	fid_parms.resource_func	= ident->resource_func;
-	fid_parms.resource_type	= ident->ident_type;
-	fid_parms.resource_hndl	= iparms.id;
-	fid_parms.critical_resource	= 0;
+	if (!val) {
+		memset(&fid_parms, 0, sizeof(fid_parms));
+		fid_parms.direction		= tbl->direction;
+		fid_parms.resource_func	= ident->resource_func;
+		fid_parms.resource_type	= ident->ident_type;
+		fid_parms.resource_hndl	= iparms.id;
+		fid_parms.critical_resource	= 0;
 
-	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
-				      parms->tbl_idx,
-				      parms->fid,
-				      &fid_parms);
-	if (rc) {
-		BNXT_TF_DBG(ERR, "Failed to link resource to flow rc = %d\n",
-			    rc);
-		/* Need to free the identifier, so goto error */
-		goto error;
+		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+					      parms->tbl_idx,
+					      parms->fid,
+					      &fid_parms);
+		if (rc) {
+			BNXT_TF_DBG(ERR, "Failed to link res to flow rc = %d\n",
+				    rc);
+			/* Need to free the identifier, so goto error */
+			goto error;
+		}
+	} else {
+		*val = iparms.id;
 	}
 
 	return 0;
@@ -848,6 +988,12 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	uint32_t hit = 0;
 	uint16_t tmplen = 0;
 
+	/* Skip this if was handled by the cache. */
+	if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP) {
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
+		return 0;
+	}
+
 	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
 	if (!tfp) {
 		BNXT_TF_DBG(ERR, "Failed to get truflow pointer\n");
@@ -930,15 +1076,22 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		struct bnxt_ulp_mapper_ident_info *idents;
 		uint32_t num_dflds, num_idents;
 
-		/* Alloc identifiers */
-		idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
-
-		for (i = 0; i < num_idents; i++) {
-			rc = ulp_mapper_ident_process(parms, tbl, &idents[i]);
-
-			/* Already logged the error, just return */
-			if (rc)
-				goto error;
+		/*
+		 * Since the cache entry is responsible for allocating
+		 * identifiers when in use, allocate the identifiers only
+		 * during normal processing.
+		 */
+		if (parms->tcam_tbl_opc ==
+		    BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL) {
+			idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
+
+			for (i = 0; i < num_idents; i++) {
+				rc = ulp_mapper_ident_process(parms, tbl,
+							      &idents[i], NULL);
+				/* Already logged the error, just return */
+				if (rc)
+					goto error;
+			}
 		}
 
 		/* Create the result data blob */
@@ -986,32 +1139,57 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 				    sparms.idx);
 			goto error;
 		}
+
+		/* Update cache with TCAM index if the was cache allocated. */
+		if (parms->tcam_tbl_opc ==
+		    BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC) {
+			if (!parms->cache_ptr) {
+				BNXT_TF_DBG(ERR, "Unable to update cache");
+				rc = -EINVAL;
+				goto error;
+			}
+			parms->cache_ptr->tcam_idx = aparms.idx;
+		}
+
 	} else {
 		BNXT_TF_DBG(ERR, "Not supporting search before alloc now\n");
 		rc = -EINVAL;
 		goto error;
 	}
 
-	/* Link the resource to the flow in the flow db */
-	fid_parms.direction = tbl->direction;
-	fid_parms.resource_func	= tbl->resource_func;
-	fid_parms.resource_type	= tbl->table_type;
-	fid_parms.critical_resource = tbl->critical_resource;
-	fid_parms.resource_hndl	= aparms.idx;
-
-	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
-				      parms->tbl_idx,
-				      parms->fid,
-				      &fid_parms);
-	if (rc) {
-		BNXT_TF_DBG(ERR, "Failed to link resource to flow rc = %d\n",
-			    rc);
-		/* Need to free the identifier, so goto error */
-		goto error;
+	/*
+	 * Only link the entry to the flow db in the event that cache was not
+	 * used.
+	 */
+	if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL) {
+		fid_parms.direction = tbl->direction;
+		fid_parms.resource_func	= tbl->resource_func;
+		fid_parms.resource_type	= tbl->table_type;
+		fid_parms.critical_resource = tbl->critical_resource;
+		fid_parms.resource_hndl	= aparms.idx;
+		rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+					      parms->tbl_idx,
+					      parms->fid,
+					      &fid_parms);
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Failed to link resource to flow rc = %d\n",
+				    rc);
+			/* Need to free the identifier, so goto error */
+			goto error;
+		}
+	} else {
+		/*
+		 * Reset the tcam table opcode to normal in case the next tcam
+		 * entry does not use cache.
+		 */
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
+		parms->cache_ptr = NULL;
 	}
 
 	return 0;
 error:
+	parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
 	free_parms.dir			= tbl->direction;
 	free_parms.tcam_tbl_type	= tbl->table_type;
 	free_parms.idx			= aparms.idx;
@@ -1324,6 +1502,153 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	return rc;
 }
 
+static int32_t
+ulp_mapper_cache_tbl_process(struct bnxt_ulp_mapper_parms *parms,
+			     struct bnxt_ulp_mapper_class_tbl_info *tbl)
+{
+	struct bnxt_ulp_mapper_class_key_field_info *kflds;
+	struct bnxt_ulp_mapper_cache_entry *cache_entry;
+	struct bnxt_ulp_mapper_ident_info *idents;
+	uint32_t i, num_kflds = 0, num_idents = 0;
+	struct ulp_flow_db_res_params fid_parms;
+	struct tf_free_identifier_parms fparms;
+	uint16_t tmplen, tmp_ident;
+	struct ulp_blob key;
+	uint8_t *cache_key;
+	uint64_t regval;
+	uint16_t *ckey;
+	int32_t rc;
+
+	/* Get the key fields list and build the key. */
+	kflds = ulp_mapper_key_fields_get(tbl, &num_kflds);
+	if (!kflds || !num_kflds) {
+		BNXT_TF_DBG(ERR, "Failed to get key fields\n");
+		return -EINVAL;
+	}
+	if (!ulp_blob_init(&key, tbl->key_bit_size, parms->order)) {
+		BNXT_TF_DBG(ERR, "Failed to alloc blob\n");
+		return -EINVAL;
+	}
+	for (i = 0; i < num_kflds; i++) {
+		/* Setup the key */
+		rc = ulp_mapper_keymask_field_process(parms, tbl->direction,
+						      &kflds[i],
+						      &key, 1, "Cache Key");
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Failed to create key for Cache rc=%d\n",
+				    rc);
+			return -EINVAL;
+		}
+	}
+
+	/*
+	 * Perform the lookup in the cache table with constructed key.  The
+	 * cache_key is a byte array of tmplen, it needs to be converted to a
+	 * index for the cache table.
+	 */
+	cache_key = ulp_blob_data_get(&key, &tmplen);
+	ckey = (uint16_t *)cache_key;
+	cache_entry = ulp_mapper_cache_entry_get(parms->ulp_ctx,
+						 tbl->cache_tbl_id,
+						 *ckey);
+
+	/*
+	 * Get the identifier list for processing by both the hit and miss
+	 * processing.
+	 */
+	idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
+
+	if (!cache_entry->ref_count) {
+		/* Initialize the cache entry */
+		cache_entry->tcam_idx = 0;
+		cache_entry->ref_count = 0;
+		for (i = 0; i < BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM; i++)
+			cache_entry->idents[i] = ULP_IDENTS_INVALID;
+
+		/* Need to allocate identifiers for storing in the cache. */
+		for (i = 0; i < num_idents; i++) {
+			/*
+			 * Since we are using the cache, the identifier does not
+			 * get added to the flow db.  Pass in the pointer to the
+			 * tmp_ident.
+			 */
+			rc = ulp_mapper_ident_process(parms, tbl,
+						      &idents[i], &tmp_ident);
+			if (rc)
+				goto error;
+
+			cache_entry->ident_types[i] = idents[i].ident_type;
+			cache_entry->idents[i] = tmp_ident;
+		}
+
+		/* Tell the TCAM processor to alloc an entry */
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC;
+		/* Store the cache key for use by the tcam process code */
+		parms->cache_ptr = cache_entry;
+	} else {
+		/* Cache hit, get values from result. */
+		for (i = 0; i < num_idents; i++) {
+			regval = (uint64_t)cache_entry->idents[i];
+			if (!ulp_regfile_write(parms->regfile,
+					       idents[i].regfile_wr_idx,
+					       tfp_cpu_to_be_64(regval))) {
+				BNXT_TF_DBG(ERR,
+					    "Failed to write to regfile\n");
+				return -EINVAL;
+			}
+		}
+		/*
+		 * The cached entry is being used, so let the tcam processing
+		 * know not to process this table.
+		 */
+		parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP;
+	}
+
+	/* Made through the cache processing, increment the reference count. */
+	cache_entry->ref_count++;
+
+	/* Link the cache to the flow db. */
+	memset(&fid_parms, 0, sizeof(fid_parms));
+	fid_parms.direction = tbl->direction;
+	fid_parms.resource_func	= tbl->resource_func;
+
+	/*
+	 * Cache resource type is composed of both table_type and cache_tbl_id
+	 * need to set it appropriately via setter.
+	 */
+	ulp_mapper_cache_res_type_set(&fid_parms,
+				      tbl->table_type,
+				      tbl->cache_tbl_id);
+	fid_parms.resource_hndl	= (uint64_t)*ckey;
+	fid_parms.critical_resource = tbl->critical_resource;
+	rc = ulp_flow_db_resource_add(parms->ulp_ctx,
+				      parms->tbl_idx,
+				      parms->fid,
+				      &fid_parms);
+	if (rc)
+		BNXT_TF_DBG(ERR, "Failed to add cache to flow db.\n");
+
+	return rc;
+error:
+	/*
+	 * This error handling only gets called when the idents are being
+	 * allocated for the cache on misses.  Using the num_idents that was
+	 * previously set.
+	 */
+	for (i = 0; i < num_idents; i++) {
+		if (cache_entry->idents[i] == ULP_IDENTS_INVALID)
+			continue;
+
+		fparms.dir = tbl->direction;
+		fparms.ident_type = idents[i].ident_type;
+		fparms.id = cache_entry->idents[i];
+		tf_free_identifier(parms->tfp, &fparms);
+	}
+
+	return rc;
+}
+
 /*
  * Function to process the action template. Iterate through the list
  * action info templates and process it.
@@ -1378,6 +1703,9 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms)
 		case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
 			rc = ulp_mapper_index_tbl_process(parms, tbl);
 			break;
+		case BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE:
+			rc = ulp_mapper_cache_tbl_process(parms, tbl);
+			break;
 		default:
 			BNXT_TF_DBG(ERR, "Unexpected class resource %d\n",
 				    tbl->resource_func);
@@ -1413,6 +1741,9 @@ ulp_mapper_resource_free(struct bnxt_ulp_context *ulp,
 	}
 
 	switch (res->resource_func) {
+	case BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE:
+		rc = ulp_mapper_cache_entry_free(ulp, tfp, res);
+		break;
 	case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
 		rc = ulp_mapper_tcam_entry_free(ulp, tfp, res);
 		break;
@@ -1530,6 +1861,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 	parms.hdr_field = cparms->hdr_field;
 	parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx);
 	parms.ulp_ctx = ulp_ctx;
+	parms.tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
 
 	/* Get the device id from the ulp context */
 	if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &parms.dev_id)) {
@@ -1586,6 +1918,14 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 		return -EINVAL;
 	}
 
+	rc = ulp_regfile_write(parms.regfile,
+			       BNXT_ULP_REGFILE_INDEX_CLASS_TID,
+			       tfp_cpu_to_be_64((uint64_t)parms.class_tid));
+	if (!rc) {
+		BNXT_TF_DBG(ERR, "Unable to write template ID to regfile\n");
+		return -EINVAL;
+	}
+
 	/* Allocate a Flow ID for attaching all resources for the flow to.
 	 * Once allocated, all errors have to walk the list of resources and
 	 * free each of them.
@@ -1631,13 +1971,14 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
 int32_t
 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 {
+	struct bnxt_ulp_cache_tbl_params *tbl;
 	struct tf_alloc_identifier_parms iparms;
 	struct bnxt_ulp_mapper_data *data;
 	struct bnxt_ulp_def_ident_info *dflt_ids;
 	uint32_t i, num_dflt_ids, reg_idx;
 	uint64_t regval;
 	struct tf *tfp;
-	int32_t rc;
+	int32_t rc, csize;
 
 	if (!ulp_ctx)
 		return -EINVAL;
@@ -1677,16 +2018,37 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 		reg_idx = dflt_ids[i].def_regfile_index;
 		/* All regfile entries are stored as 64bit big-endian values. */
 		regval = tfp_cpu_to_be_64((uint64_t)iparms.id);
-		if (ulp_mapper_def_regfile_write(data,
-						 iparms.dir,
-						 reg_idx,
-						 regval)) {
+		rc = ulp_mapper_def_regfile_write(data, iparms.dir,
+						 reg_idx, regval);
+		if (rc) {
 			BNXT_TF_DBG(ERR, "Failed to write to default "
 				    "regfile.\n");
 			goto error;
 		}
 	}
 
+	/* Allocate the ulp cache tables. */
+	for (i = 0; i < BNXT_ULP_CACHE_TBL_MAX_SZ; i++) {
+		tbl = ulp_mapper_cache_tbl_params_get(i);
+		if (!tbl) {
+			BNXT_TF_DBG(ERR, "Failed to get cache table parms (%d)",
+				    i);
+			goto error;
+		}
+		if (tbl->num_entries != 0) {
+			csize = sizeof(struct bnxt_ulp_mapper_cache_entry) *
+				tbl->num_entries;
+			data->cache_tbl[i] = rte_zmalloc("ulp mapper cache tbl",
+							 csize, 0);
+			if (!data->cache_tbl[i]) {
+				BNXT_TF_DBG(ERR, "Failed to allocate Cache "
+					    "table %d.\n", i);
+				rc = -ENOMEM;
+				goto error;
+			}
+		}
+	}
+
 	return 0;
 error:
 	/* Ignore the return code in favor of returning the original error. */
@@ -1750,6 +2112,12 @@ ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx)
 	}
 
 free_mapper_data:
+	/* Free the ulp cache tables */
+	for (i = 0; i < BNXT_ULP_CACHE_TBL_MAX_SZ; i++) {
+		rte_free(data->cache_tbl[i]);
+		data->cache_tbl[i] = NULL;
+	}
+
 	rte_free(data);
 	/* Reset the data pointer within the ulp_ctx. */
 	bnxt_ulp_cntxt_ptr2_mapper_data_set(ulp_ctx, NULL);
drivers/net/bnxt/tf_ulp/ulp_mapper.h +29 -0
index fb47f1c27..c50d555a4 100644
@@ -16,6 +16,31 @@
 #include "ulp_utils.h"
 
 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
+#define ULP_IDENTS_INVALID ((uint16_t)0xffff)
+#define ULP_MAPPER_CACHE_RES_TBL_ID_SHFT 16
+#define ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT 0
+#define ULP_MAPPER_CACHE_RES_TBL_MASK ((uint32_t)0x0000ffff)
+
+/*
+ * The cache table opcode is used to convey informat from the cache handler
+ * to the tcam handler.  The opcodes do the following:
+ * NORMAL - tcam should process all instructions as normnal
+ * SKIP - tcam is using the cached entry and doesn't need to process the
+ *	instruction.
+ * ALLOC - tcam needs to allocate the tcam index and store in the cache entry
+ */
+enum bnxt_ulp_cache_table_opc {
+	BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL,
+	BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP,
+	BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_ALLOC
+};
+
+struct bnxt_ulp_mapper_cache_entry {
+	uint32_t ref_count;
+	uint16_t tcam_idx;
+	uint16_t idents[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM];
+	uint8_t ident_types[BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM];
+};
 
 struct bnxt_ulp_mapper_def_id_entry {
 	enum tf_identifier_type ident_type;
@@ -25,6 +50,8 @@ struct bnxt_ulp_mapper_def_id_entry {
 struct bnxt_ulp_mapper_data {
 	struct bnxt_ulp_mapper_def_id_entry
 		dflt_ids[TF_DIR_MAX][BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ];
+	struct bnxt_ulp_mapper_cache_entry
+		*cache_tbl[BNXT_ULP_CACHE_TBL_MAX_SZ];
 };
 
 /* Internal Structure for passing the arguments around */
@@ -47,6 +74,8 @@ struct bnxt_ulp_mapper_parms {
 	uint32_t				fid;
 	enum bnxt_ulp_flow_db_tables		tbl_idx;
 	struct bnxt_ulp_mapper_data		*mapper_data;
+	enum bnxt_ulp_cache_table_opc		tcam_tbl_opc;
+	struct bnxt_ulp_mapper_cache_entry	*cache_ptr;
 };
 
 struct bnxt_ulp_mapper_create_parms {
drivers/net/bnxt/tf_ulp/ulp_template_db.c +142 -13

248 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_template_db.h +18 -6
index cf4ff9f39..a5606bdc4 100644
@@ -11,9 +11,10 @@
 #ifndef ULP_TEMPLATE_DB_H_
 #define ULP_TEMPLATE_DB_H_
 
-#define BNXT_ULP_REGFILE_MAX_SZ 15
+#define BNXT_ULP_REGFILE_MAX_SZ 16
 #define BNXT_ULP_MAX_NUM_DEVICES 4
 #define BNXT_ULP_LOG2_MAX_NUM_DEV 2
+#define BNXT_ULP_CACHE_TBL_MAX_SZ 4
 #define BNXT_ULP_CLASS_SIG_TBL_MAX_SZ 256
 #define BNXT_ULP_CLASS_MATCH_LIST_MAX_SZ 2
 #define BNXT_ULP_CLASS_HID_LOW_PRIME 7919
@@ -28,6 +29,7 @@
 #define BNXT_ULP_ACT_HID_SHFTR 0
 #define BNXT_ULP_ACT_HID_SHFTL 23
 #define BNXT_ULP_ACT_HID_MASK 255
+#define BNXT_ULP_CACHE_TBL_IDENT_MAX_NUM 2
 #define BNXT_ULP_DEF_IDENT_INFO_TBL_MAX_SZ 1
 
 enum bnxt_ulp_action_bit {
@@ -95,6 +97,14 @@ enum bnxt_ulp_byte_order {
 	BNXT_ULP_BYTE_ORDER_LAST = 2
 };
 
+enum bnxt_ulp_cache_tbl_id {
+	BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_INGRESS = 0,
+	BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_EGRESS = 1,
+	BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_INGRESS = 2,
+	BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_EGRESS = 3,
+	BNXT_ULP_CACHE_TBL_ID_LAST = 4
+};
+
 enum bnxt_ulp_chf_idx {
 	BNXT_ULP_CHF_IDX_MPLS_TAG_NUM = 0,
 	BNXT_ULP_CHF_IDX_O_VTAG_NUM = 1,
@@ -188,17 +198,19 @@ enum bnxt_ulp_regfile_index {
 	BNXT_ULP_REGFILE_INDEX_ENCAP_PTR_0 = 11,
 	BNXT_ULP_REGFILE_INDEX_ENCAP_PTR_1 = 12,
 	BNXT_ULP_REGFILE_INDEX_CRITICAL_RESOURCE = 13,
-	BNXT_ULP_REGFILE_INDEX_NOT_USED = 14,
-	BNXT_ULP_REGFILE_INDEX_LAST = 15
+	BNXT_ULP_REGFILE_INDEX_CACHE_ENTRY_PTR = 14,
+	BNXT_ULP_REGFILE_INDEX_NOT_USED = 15,
+	BNXT_ULP_REGFILE_INDEX_LAST = 16
 };
 
 enum bnxt_ulp_resource_func {
 	BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0,
 	BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 1,
 	BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 2,
-	BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 3,
-	BNXT_ULP_RESOURCE_FUNC_HW_FID = 4,
-	BNXT_ULP_RESOURCE_FUNC_LAST = 5
+	BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE = 3,
+	BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 4,
+	BNXT_ULP_RESOURCE_FUNC_HW_FID = 5,
+	BNXT_ULP_RESOURCE_FUNC_LAST = 6
 };
 
 enum bnxt_ulp_result_opc {
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +13 -0
index 476d5b9bb..1bef5ab0e 100644
@@ -181,6 +181,8 @@ struct bnxt_ulp_mapper_class_tbl_info {
 
 	uint8_t		mark_enable;
 	enum bnxt_ulp_regfile_index	regfile_wr_idx;
+
+	enum bnxt_ulp_cache_tbl_id cache_tbl_id;
 };
 
 struct bnxt_ulp_mapper_act_tbl_info {
@@ -228,6 +230,10 @@ struct bnxt_ulp_def_ident_info {
 	enum bnxt_ulp_def_regfile_index def_regfile_index;
 };
 
+struct bnxt_ulp_cache_tbl_params {
+	uint16_t num_entries;
+};
+
 /*
  * Flow Mapper Static Data Externs:
  * Access to the below static data should be done through access functions and
@@ -296,4 +302,11 @@ extern uint32_t ulp_act_prop_map_table[];
  * be initialized and where to store them.
  */
 extern struct bnxt_ulp_def_ident_info ulp_def_ident_tbl[];
+
+/*
+ * The ulp_cache_tbl_parms table provides the sizes of the cache tables the
+ * mapper must dynamically allocate during initialization.
+ */
+extern struct bnxt_ulp_cache_tbl_params ulp_cache_tbl_params[];
+
 #endif /* _ULP_TEMPLATE_STRUCT_H_ */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#23 lore raw

PATCH v2 11/12 net/bnxt: add port database

In reply to Ajit Khaparde

From: Kishore Padmanabha <[email protected]>

The port database is a repository of the port details it is used by the ulp code to query any port related details.

---
 drivers/net/bnxt/Makefile                     |   1 +
 drivers/net/bnxt/meson.build                  |   1 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |  47 ++++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |  10 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  13 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c         | 263 ++++++++++++++++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h         | 134 +++++++++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      |  16 +-
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |   1 +
 9 files changed, 480 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h
drivers/net/bnxt/Makefile +1 -0
index 5ed33ccbf..2a39ed139 100644
@@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mapper.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_matcher.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_rte_parser.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp_flow.c
+SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c
 
 #
 # Export include files
drivers/net/bnxt/meson.build +1 -0
index d75f887d1..59dda6932 100644
@@ -41,6 +41,7 @@ sources = files('bnxt_cpr.c',
 	'tf_ulp/ulp_matcher.c',
 	'tf_ulp/ulp_rte_parser.c',
 	'tf_ulp/bnxt_ulp_flow.c',
+	'tf_ulp/ulp_port_db.c',
 
 	'rte_pmd_bnxt.c')
 
drivers/net/bnxt/tf_ulp/bnxt_ulp.c +47 -0

74 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/bnxt_ulp.h +10 -0
index d2ca17857..eecc09cea 100644
@@ -19,6 +19,7 @@ struct bnxt_ulp_data {
 	uint32_t			ref_cnt;
 	struct bnxt_ulp_flow_db		*flow_db;
 	void				*mapper_data;
+	struct bnxt_ulp_port_db		*port_db;
 };
 
 struct bnxt_ulp_context {
@@ -117,4 +118,13 @@ bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
 void *
 bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
 
+/* Function to set the port database to the ulp context. */
+int32_t
+bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context	*ulp_ctx,
+				struct bnxt_ulp_port_db	*port_db);
+
+/* Function to get the port database from the ulp context. */
+struct bnxt_ulp_port_db *
+bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context	*ulp_ctx);
+
 #endif /* _BNXT_ULP_H_ */
drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +11 -2
index 7783f85d9..dbec8cecf 100644
@@ -69,7 +69,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 {
 	struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 };
 	struct ulp_rte_parser_params params;
-	struct bnxt_ulp_context *ulp_ctx = NULL;
+	struct bnxt_ulp_context *ulp_ctx;
 	uint32_t class_id, act_tmpl;
 	struct rte_flow *flow_id;
 	uint32_t fid;
@@ -90,6 +90,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 
 	/* Initialize the parser params */
 	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
+	params.ulp_ctx = ulp_ctx;
 
 	if (attr->egress)
 		params.dir = ULP_DIR_EGRESS;
@@ -142,7 +143,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev,
 
 /* Function to validate the rte flow. */
 static int
-bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
+bnxt_ulp_flow_validate(struct rte_eth_dev *dev,
 		       const struct rte_flow_attr *attr,
 		       const struct rte_flow_item pattern[],
 		       const struct rte_flow_action actions[],
@@ -151,6 +152,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 	struct ulp_rte_parser_params		params;
 	uint32_t class_id, act_tmpl;
 	int ret;
+	struct bnxt_ulp_context *ulp_ctx;
 
 	if (bnxt_ulp_flow_validate_args(attr,
 					pattern, actions,
@@ -159,8 +161,15 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused,
 		return -EINVAL;
 	}
 
+	ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev);
+	if (!ulp_ctx) {
+		BNXT_TF_DBG(ERR, "ULP context is not initialized\n");
+		return -EINVAL;
+	}
+
 	/* Initialize the parser params */
 	memset(&params, 0, sizeof(struct ulp_rte_parser_params));
+	params.ulp_ctx = ulp_ctx;
 
 	if (attr->egress)
 		params.dir = ULP_DIR_EGRESS;
drivers/net/bnxt/tf_ulp/ulp_port_db.c new file +263 -0

263 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_port_db.h new file +134 -0

134 lines not on this page · raw message

drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +12 -4
index 873f86494..ace5fad97 100644
@@ -10,6 +10,7 @@
 #include "ulp_rte_parser.h"
 #include "ulp_utils.h"
 #include "tfp.h"
+#include "ulp_port_db.h"
 
 /* Utility function to skip the void items. */
 static inline int32_t
@@ -161,6 +162,8 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,
 	uint16_t port_id = svif;
 	uint32_t dir = 0;
 	struct ulp_rte_hdr_field *hdr_field;
+	uint32_t ifindex;
+	int32_t rc;
 
 	if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF)) {
 		BNXT_TF_DBG(ERR,
@@ -175,10 +178,15 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params,
 		dir = ULP_UTIL_CHF_IDX_RD(params,
 					  BNXT_ULP_CHF_IDX_DIRECTION);
 		/* perform the conversion from dpdk port to bnxt svif */
-		if (dir == ULP_DIR_EGRESS)
-			svif = bnxt_get_svif(port_id, true);
-		else
-			svif = bnxt_get_svif(port_id, false);
+		rc = ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, port_id,
+						       &ifindex);
+		if (rc) {
+			BNXT_TF_DBG(ERR,
+				    "Invalid port id\n");
+			return BNXT_TF_RC_ERROR;
+		}
+		ulp_port_db_svif_get(params->ulp_ctx, ifindex, dir, &svif);
+		svif = rte_cpu_to_be_16(svif);
 	}
 	hdr_field = &params->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX];
 	memcpy(hdr_field->spec, &svif, sizeof(svif));
drivers/net/bnxt/tf_ulp/ulp_template_struct.h +1 -0
index 1bef5ab0e..0e0d02ff4 100644
@@ -66,6 +66,7 @@ struct ulp_rte_parser_params {
 	struct ulp_rte_act_bitmap	act_bitmap;
 	struct ulp_rte_act_prop		act_prop;
 	uint32_t			dir;
+	struct bnxt_ulp_context		*ulp_ctx;
 };
 
 /* Flow Parser Header Information Structure */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#24 lore raw

PATCH v2 12/12 net/bnxt: remove redefinition of page size

In reply to Ajit Khaparde

PAGE_SIZE is a common macro and cause redefinition errors. Replace such occurances.

---
 drivers/net/bnxt/tf_core/tf_tbl.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/bnxt/tf_core/tf_tbl.h +9 -9
index cb7ce9d17..5d3ea71f4 100644
@@ -79,30 +79,30 @@ struct tf_tbl_scope_cb {
 /** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.
  * Round-down other page sizes to the lower hardware page size supported.
  */
-#define PAGE_SHIFT 22 /** 2M */
+#define BNXT_PAGE_SHIFT 22 /** 2M */
 
-#if (PAGE_SHIFT < 12)				/** < 4K >> 4K */
+#if (BNXT_PAGE_SHIFT < 12)				/** < 4K >> 4K */
 #define TF_EM_PAGE_SHIFT 12
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4K
-#elif (PAGE_SHIFT <= 13)			/** 4K, 8K */
+#elif (BNXT_PAGE_SHIFT <= 13)			/** 4K, 8K */
 #define TF_EM_PAGE_SHIFT 13
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_8K
-#elif (PAGE_SHIFT < 16)				/** 16K, 32K >> 8K */
+#elif (BNXT_PAGE_SHIFT < 16)				/** 16K, 32K >> 8K */
 #define TF_EM_PAGE_SHIFT 15
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_32K
-#elif (PAGE_SHIFT <= 17)			/** 64K, 128K >> 64K */
+#elif (BNXT_PAGE_SHIFT <= 17)			/** 64K, 128K >> 64K */
 #define TF_EM_PAGE_SHIFT 16
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_64K
-#elif (PAGE_SHIFT <= 19)			/** 256K, 512K >> 256K */
+#elif (BNXT_PAGE_SHIFT <= 19)			/** 256K, 512K >> 256K */
 #define TF_EM_PAGE_SHIFT 18
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_256K
-#elif (PAGE_SHIFT <= 21)			/** 1M */
+#elif (BNXT_PAGE_SHIFT <= 21)			/** 1M */
 #define TF_EM_PAGE_SHIFT 20
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_1M
-#elif (PAGE_SHIFT <= 22)			/** 2M, 4M */
+#elif (BNXT_PAGE_SHIFT <= 22)			/** 2M, 4M */
 #define TF_EM_PAGE_SHIFT 21
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_2M
-#elif (PAGE_SHIFT <= 29)			/** 8M ... 512M >> 4M */
+#elif (BNXT_PAGE_SHIFT <= 29)			/** 8M ... 512M >> 4M */
 #define TF_EM_PAGE_SHIFT 22
 #define TF_EM_PAGE_SIZE_ENUM HWRM_TF_CTXT_MEM_RGTR_INPUT_PAGE_SIZE_4M
 #else						/** >= 1G >> 1G */
Signature · 1 line
2.21.1 (Apple Git-122.3)
#25 lore raw
In reply to Ajit Khaparde
Quoted 9 lines · Ajit Khaparde

This patchset introduces enhancements to the flow table management related to resource sharing and deletion, flow matching performance, and flow flushing.
Additionally, a new port database was introduced to store frequently required port mappings and resources.

v1->v2:
Rebased to latest code base.

Patchset applied to dpdk-next-net-brcm. Thanks

Quoted 51 lines

Ajit Khaparde (1):
net/bnxt: remove redefinition of page size

Kishore Padmanabha (5):
net/bnxt: add flow database resource iteration API net/bnxt: aggregate ulp rte parser arguments net/bnxt: use hashing for flow template match net/bnxt: add session and function flow flush net/bnxt: add port database

Mike Baucom (6):
net/bnxt: add SVIF changes for dpdk port id net/bnxt: allow usage of more resources in flow db net/bnxt: add resource name type to debug messages net/bnxt: aggregate ulp mapper create arguments net/bnxt: add default identifiers to ulp mapper net/bnxt: add cache table type for TCAM lookup

 drivers/net/bnxt/Makefile                     |    1 +
 drivers/net/bnxt/bnxt.h                       |    1 +
 drivers/net/bnxt/bnxt_ethdev.c                |   12 +
 drivers/net/bnxt/meson.build                  |    1 +
 drivers/net/bnxt/tf_core/tf_tbl.h             |   18 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c            |   89 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h            |   20 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c       |  170 ++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c         |  221 +++-
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h         |   63 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          |  801 ++++++++++--
 drivers/net/bnxt/tf_ulp/ulp_mapper.h          |   72 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c         |  220 ++--
 drivers/net/bnxt/tf_ulp/ulp_matcher.h         |   12 +-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c         |  263 ++++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h         |  134 ++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c      | 1124 +++++++++--------
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.h      |  155 +--
 drivers/net/bnxt/tf_ulp/ulp_template_db.c     |  459 ++++---
 drivers/net/bnxt/tf_ulp/ulp_template_db.h     |  313 +++--
 .../net/bnxt/tf_ulp/ulp_template_field_db.h   |  171 +--
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  117 +-
 drivers/net/bnxt/tf_ulp/ulp_utils.c           |   33 +
 drivers/net/bnxt/tf_ulp/ulp_utils.h           |   17 +-
 24 files changed, 3057 insertions(+), 1430 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h

--
2.21.1 (Apple Git-122.3)