From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20A72A0527; Wed, 15 Jul 2020 15:57:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB5E31BF70; Wed, 15 Jul 2020 15:56:05 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id 183981BEA5 for ; Wed, 15 Jul 2020 15:55:53 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 3A1AF299E20; Wed, 15 Jul 2020 06:55:52 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 3A1AF299E20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1594821352; bh=vvYmaqEQnajmiW4EOZHU3Df561iVn/mrEay/dmGKIoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FkCsbJ6EP6EbYcL9X5GXVeIrlwwOoWUldvjctffaD2EVqWIdHUhee40qIpQxxHzC9 hpXuf9LonS7MJF0Oy0e/i9glkM5tbB1f+OfJiY89psQLSZ5HQVO9IDSqa37gYLFhOs +8yw9d4xqmJGRQESr+q2BJ81NfYQOHf35NnlcfdY= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Wed, 15 Jul 2020 19:20:35 +0530 Message-Id: <20200715135038.16662-8-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200715135038.16662-1-somnath.kotur@broadcom.com> References: <20200713061600.19456-1-somnath.kotur@broadcom.com> <20200715135038.16662-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kishore Padmanabha Add support to search for identifiers and increase the reference count for identifiers that are already allocated. Signed-off-by: Kishore Padmanabha Reviewed-by: Michael Baucom Signed-off-by: Somnath Kotur --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 117 ++++++++++++++++++++++++++++++++++- 1 file changed, 114 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..051a095 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -16,6 +16,7 @@ #include "ulp_mark_mgr.h" #include "ulp_flow_db.h" #include "ulp_mapper.h" +#include "tf_util.h" static struct bnxt_ulp_glb_resource_info * ulp_mapper_glb_resource_info_list_get(uint32_t *num_entries) @@ -677,6 +678,101 @@ 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:%x failed.\n", + tf_dir_2_str(sparms.dir), + sparms.search_id); + return rc; + } + BNXT_TF_DBG(INFO, "Search ident %s:%x.success.\n", + tf_dir_2_str(sparms.dir), + 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 +1300,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 +1476,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