DPDK patches and discussions
 help / color / mirror / Atom feed
From: Somnath Kotur <somnath.kotur@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count
Date: Mon, 13 Jul 2020 11:58:25 +0530	[thread overview]
Message-ID: <20200713062828.19626-8-somnath.kotur@broadcom.com> (raw)
In-Reply-To: <20200713062828.19626-1-somnath.kotur@broadcom.com>

From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Add support to search for identifiers and increase the reference
count for identifiers that are already allocated.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Michael Baucom <michael.baucom@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 118 ++++++++++++++++++++++++++++++++++-
 1 file changed, 115 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 86858b8..157c451 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -677,6 +677,103 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
 	return rc;
 }
 
+/*
+ * Process the identifier instruction and extract it from result blob.
+ * Increment the identifier reference count and store it in the flow database.
+ */
+static int32_t
+ulp_mapper_ident_extract(struct bnxt_ulp_mapper_parms *parms,
+			 struct bnxt_ulp_mapper_tbl_info *tbl,
+			 struct bnxt_ulp_mapper_ident_info *ident,
+			 struct ulp_blob *res_blob)
+{
+	struct ulp_flow_db_res_params	fid_parms;
+	uint64_t id = 0;
+	uint32_t idx;
+	struct tf_search_identifier_parms sparms = { 0 };
+	struct tf_free_identifier_parms free_parms = { 0 };
+	struct tf *tfp;
+	int rc;
+
+	/* Get the tfp from ulp context */
+	tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
+	if (!tfp) {
+		BNXT_TF_DBG(ERR, "Failed to get tf pointer\n");
+		return -EINVAL;
+	}
+
+	/* Extract the index from the result blob */
+	rc = ulp_blob_pull(res_blob, (uint8_t *)&idx, sizeof(idx),
+			   ident->ident_bit_pos, ident->ident_bit_size);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Failed to extract identifier from blob\n");
+		return -EIO;
+	}
+
+	/* populate the search params and search identifier shadow table */
+	sparms.ident_type = ident->ident_type;
+	sparms.dir = tbl->direction;
+	/* convert the idx into cpu format */
+	sparms.search_id = tfp_be_to_cpu_32(idx);
+
+	/* Search identifier also increase the reference count */
+	rc = tf_search_identifier(tfp, &sparms);
+	if (rc) {
+		BNXT_TF_DBG(ERR, "Search ident %s:%s:%x failed.\n",
+			    tf_dir_2_str(sparms.dir),
+			    tf_tbl_type_2_str(sparms.ident_type),
+			    sparms.search_id);
+		return rc;
+	}
+	BNXT_TF_INF("Search ident %s:%s:%x.success.\n",
+		    tf_dir_2_str(sparms.dir),
+		    tf_tbl_type_2_str(sparms.ident_type),
+		    sparms.search_id);
+
+	/* Write it to the regfile */
+	id = (uint64_t)tfp_cpu_to_be_64(sparms.search_id);
+	if (!ulp_regfile_write(parms->regfile, ident->regfile_idx, id)) {
+		BNXT_TF_DBG(ERR, "Regfile[%d] write failed.\n", idx);
+		rc = -EINVAL;
+		/* Need to free the identifier, so goto error */
+		goto error;
+	}
+
+	/* 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 = sparms.search_id;
+	fid_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO;
+	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;
+	}
+
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
+	ulp_mapper_ident_field_dump("Ident", ident, tbl, sparms.search_id);
+#endif
+	return 0;
+
+error:
+	/* Need to free the identifier */
+	free_parms.dir = tbl->direction;
+	free_parms.ident_type = ident->ident_type;
+	free_parms.id = sparms.search_id;
+	(void)tf_free_identifier(tfp, &free_parms);
+	BNXT_TF_DBG(ERR, "Ident extract failed for %s:%s:%x\n",
+		    ident->description,
+		    tf_dir_2_str(tbl->direction), sparms.search_id);
+	return rc;
+}
+
 static int32_t
 ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms,
 				enum tf_dir dir,
@@ -1204,6 +1301,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	struct tf_free_tcam_entry_parms free_parms	= { 0 };
 	uint32_t hit = 0;
 	uint16_t tmplen = 0;
+	struct ulp_blob res_blob;
 
 	/* Skip this if was handled by the cache. */
 	if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_CACHE_SKIP) {
@@ -1379,9 +1477,23 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 			goto error;
 
 	} else {
-		BNXT_TF_DBG(ERR, "Not supporting search before alloc now\n");
-		rc = -EINVAL;
-		goto error;
+		struct bnxt_ulp_mapper_ident_info *idents;
+		uint32_t num_idents;
+
+		/*
+		 * Extract the listed identifiers from the result field,
+		 * no need to allocate them.
+		 */
+		idents = ulp_mapper_ident_fields_get(tbl, &num_idents);
+		for (i = 0; i < num_idents; i++) {
+			rc = ulp_mapper_ident_extract(parms, tbl,
+						      &idents[i], &res_blob);
+			if (rc) {
+				BNXT_TF_DBG(ERR,
+					    "Error in ident extraction\n");
+				goto error;
+			}
+		}
 	}
 
 	/*
-- 
2.7.4


  parent reply	other threads:[~2020-07-13  6:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13  6:28 [dpdk-dev] [v2 PATCH 00/10] bnxt patches Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 02/10] net/bnxt: implement TF Identifier search Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 03/10] net/bnxt: check index range in bulk get Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 04/10] net/bnxt: add changes to support 2 table scopes Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 05/10] net/bnxt: add support to extract data from the ulp blob Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 06/10] net/bnxt: ignore ipv4 tos mask Somnath Kotur
2020-07-13  6:28 ` Somnath Kotur [this message]
2020-07-13  6:28 ` [dpdk-dev] [PATCH 08/10] net/bnxt: consider vlan fields for the template match criteria Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 09/10] net/bnxt: increase the number of egress flow entries Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 10/10] net/bnxt: add support for decrement ttl action Somnath Kotur
2020-07-13  7:56 ` [dpdk-dev] [v2 PATCH 00/10] bnxt patches Thomas Monjalon
  -- strict thread matches above, loose matches on Subject: below --
2020-07-13  6:15 [dpdk-dev] [PATCH " Somnath Kotur
2020-07-13  6:15 ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
2020-07-13  9:42 ` [dpdk-dev] [PATCH v3 00/10] bnxt patches Somnath Kotur
2020-07-13  9:42   ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH v4 00/10] bnxt patches Somnath Kotur
2020-07-15 13:50   ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200713062828.19626-8-somnath.kotur@broadcom.com \
    --to=somnath.kotur@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).