From patchwork Wed Jul 1 06:51:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 72561 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3E963A0350; Wed, 1 Jul 2020 09:01:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 279C61D50F; Wed, 1 Jul 2020 08:53:11 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 5049F1C0D2 for ; Wed, 1 Jul 2020 08:52:29 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 9B1F230C345; Tue, 30 Jun 2020 23:52:28 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 9B1F230C345 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1593586348; bh=auZ9xWk3uZRlzhBwfdVDwDXMK4f6+d0O9b2SNpy7Dw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PkeJEsA88cl/h0dRarqpeAy8FS4Een6KkbwODvYbGflLinfB5n74hp+NTnufoP1AT tKnX2Rc5FJB+tNCURKsU1PA1iFbS3O7DZviTkBLOyH8KvZ+GL1bkZ5kztvYSHW1WhN wiEC9wMs0bsGylGC4USC333cxIQodLVwFDYuoRMQ= Received: from localhost.localdomain (unknown [10.230.185.215]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 6E51914008C; Tue, 30 Jun 2020 23:52:28 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Kishore Padmanabha , Venkat Duvvuru , Somnath Kotur Date: Tue, 30 Jun 2020 23:51:59 -0700 Message-Id: <20200701065212.41391-39-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200701065212.41391-1-ajit.khaparde@broadcom.com> References: <20200612132934.16488-1-somnath.kotur@broadcom.com> <20200701065212.41391-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 38/51] net/bnxt: add support for internal exact match entries 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 Added support for the internal exact match entries. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 38 +++++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 13 +++++-- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 21 ++++++---- drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c | 4 ++ .../net/bnxt/tf_ulp/ulp_template_db_class.c | 6 +-- .../net/bnxt/tf_ulp/ulp_template_db_enum.h | 13 ++++--- drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c | 7 +++- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 5 +++ 8 files changed, 85 insertions(+), 22 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 4835b951e..1b52861d4 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -213,8 +213,27 @@ static int32_t ulp_eem_tbl_scope_init(struct bnxt *bp) { struct tf_alloc_tbl_scope_parms params = {0}; + uint32_t dev_id; + struct bnxt_ulp_device_params *dparms; int rc; + /* Get the dev specific number of flows that needed to be supported. */ + if (bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id)) { + BNXT_TF_DBG(ERR, "Invalid device id\n"); + return -EINVAL; + } + + dparms = bnxt_ulp_device_params_get(dev_id); + if (!dparms) { + BNXT_TF_DBG(ERR, "could not fetch the device params\n"); + return -ENODEV; + } + + if (dparms->flow_mem_type != BNXT_ULP_FLOW_MEM_TYPE_EXT) { + BNXT_TF_DBG(INFO, "Table Scope alloc is not required\n"); + return 0; + } + bnxt_init_tbl_scope_parms(bp, ¶ms); rc = tf_alloc_tbl_scope(&bp->tfp, ¶ms); @@ -240,6 +259,8 @@ ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx) struct tf_free_tbl_scope_parms params = {0}; struct tf *tfp; int32_t rc = 0; + struct bnxt_ulp_device_params *dparms; + uint32_t dev_id; if (!ulp_ctx || !ulp_ctx->cfg_data) return -EINVAL; @@ -254,6 +275,23 @@ ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx) return -EINVAL; } + /* Get the dev specific number of flows that needed to be supported. */ + if (bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id)) { + BNXT_TF_DBG(ERR, "Invalid device id\n"); + return -EINVAL; + } + + dparms = bnxt_ulp_device_params_get(dev_id); + if (!dparms) { + BNXT_TF_DBG(ERR, "could not fetch the device params\n"); + return -ENODEV; + } + + if (dparms->flow_mem_type != BNXT_ULP_FLOW_MEM_TYPE_EXT) { + BNXT_TF_DBG(INFO, "Table Scope free is not required\n"); + return 0; + } + rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, ¶ms.tbl_scope_id); if (rc) { BNXT_TF_DBG(ERR, "Failed to get the table scope id\n"); diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c index 384dc5b2c..7696de2a5 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c @@ -114,7 +114,8 @@ ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info *resource_info, } /* Store the handle as 64bit only for EM table entries */ - if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EM_TABLE) { + if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE && + params->resource_func != BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) { resource_info->resource_hndl = (uint32_t)params->resource_hndl; resource_info->resource_type = params->resource_type; resource_info->resource_sub_type = params->resource_sub_type; @@ -145,7 +146,8 @@ ulp_flow_db_res_info_to_params(struct ulp_fdb_resource_info *resource_info, /* use the helper function to get the resource func */ params->resource_func = ulp_flow_db_resource_func_get(resource_info); - if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE) { + if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE || + params->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) { params->resource_hndl = resource_info->resource_em_handle; } else if (params->resource_func & ULP_FLOW_DB_RES_FUNC_NEED_LOWER) { params->resource_hndl = resource_info->resource_hndl; @@ -908,7 +910,9 @@ ulp_flow_db_resource_hndl_get(struct bnxt_ulp_context *ulp_ctx, } } else if (resource_func == - BNXT_ULP_RESOURCE_FUNC_EM_TABLE){ + BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE || + resource_func == + BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) { *res_hndl = fid_res->resource_em_handle; return 0; } @@ -966,7 +970,8 @@ static void ulp_flow_db_res_dump(struct ulp_fdb_resource_info *r, BNXT_TF_DBG(DEBUG, "Resource func = %x, nxt_resource_idx = %x\n", res_func, (ULP_FLOW_DB_RES_NXT_MASK & r->nxt_resource_idx)); - if (res_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE) + if (res_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE || + res_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) BNXT_TF_DBG(DEBUG, "EM Handle = 0x%016" PRIX64 "\n", r->resource_em_handle); else diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 6fd55b2a2..e2b771c9f 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -556,15 +556,18 @@ ulp_mapper_index_entry_free(struct bnxt_ulp_context *ulp, } static inline int32_t -ulp_mapper_eem_entry_free(struct bnxt_ulp_context *ulp, - struct tf *tfp, - struct ulp_flow_db_res_params *res) +ulp_mapper_em_entry_free(struct bnxt_ulp_context *ulp, + struct tf *tfp, + struct ulp_flow_db_res_params *res) { struct tf_delete_em_entry_parms fparms = { 0 }; int32_t rc; fparms.dir = res->direction; - fparms.mem = TF_MEM_EXTERNAL; + if (res->resource_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE) + fparms.mem = TF_MEM_EXTERNAL; + else + fparms.mem = TF_MEM_INTERNAL; fparms.flow_handle = res->resource_hndl; rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp, &fparms.tbl_scope_id); @@ -1443,7 +1446,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms, #endif /* do the transpose for the internal EM keys */ - if (tbl->resource_type == TF_MEM_INTERNAL) + if (tbl->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) ulp_blob_perform_byte_reverse(&key); rc = bnxt_ulp_cntxt_tbl_scope_id_get(parms->ulp_ctx, @@ -2066,7 +2069,8 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms) case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE: rc = ulp_mapper_tcam_tbl_process(parms, tbl); break; - case BNXT_ULP_RESOURCE_FUNC_EM_TABLE: + case BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE: + case BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE: rc = ulp_mapper_em_tbl_process(parms, tbl); break; case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE: @@ -2119,8 +2123,9 @@ ulp_mapper_resource_free(struct bnxt_ulp_context *ulp, case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE: rc = ulp_mapper_tcam_entry_free(ulp, tfp, res); break; - case BNXT_ULP_RESOURCE_FUNC_EM_TABLE: - rc = ulp_mapper_eem_entry_free(ulp, tfp, res); + case BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE: + case BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE: + rc = ulp_mapper_em_entry_free(ulp, tfp, res); break; case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE: rc = ulp_mapper_index_entry_free(ulp, tfp, res); diff --git a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c index 517422338..b3527eccb 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c @@ -87,6 +87,9 @@ ulp_mark_db_init(struct bnxt_ulp_context *ctxt) /* Need to allocate 2 * Num flows to account for hash type bit */ mark_tbl->gfid_num_entries = dparms->mark_db_gfid_entries; + if (!mark_tbl->gfid_num_entries) + goto gfid_not_required; + mark_tbl->gfid_tbl = rte_zmalloc("ulp_rx_eem_flow_mark_table", mark_tbl->gfid_num_entries * sizeof(struct bnxt_gfid_mark_info), @@ -109,6 +112,7 @@ ulp_mark_db_init(struct bnxt_ulp_context *ctxt) mark_tbl->gfid_num_entries - 1, mark_tbl->gfid_mask); +gfid_not_required: /* Add the mark tbl to the ulp context. */ bnxt_ulp_cntxt_ptr2_mark_db_set(ctxt, mark_tbl); return 0; diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c index d4c7bfa4d..8eb559050 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c @@ -179,7 +179,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { - .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE, + .resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE, .resource_type = TF_MEM_EXTERNAL, .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED, @@ -284,7 +284,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { - .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE, + .resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE, .resource_type = TF_MEM_EXTERNAL, .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED, @@ -389,7 +389,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { - .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE, + .resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE, .resource_type = TF_MEM_EXTERNAL, .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED, diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h index 7c0dc5ee4..3168d29a9 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h @@ -149,10 +149,11 @@ enum bnxt_ulp_flow_mem_type { }; enum bnxt_ulp_glb_regfile_index { - BNXT_ULP_GLB_REGFILE_INDEX_GLB_PROF_FUNC_ID = 0, - BNXT_ULP_GLB_REGFILE_INDEX_GLB_L2_CNTXT_ID = 1, - BNXT_ULP_GLB_REGFILE_INDEX_GLB_LOOPBACK_AREC_INDEX = 2, - BNXT_ULP_GLB_REGFILE_INDEX_LAST = 3 + BNXT_ULP_GLB_REGFILE_INDEX_NOT_USED = 0, + BNXT_ULP_GLB_REGFILE_INDEX_GLB_PROF_FUNC_ID = 1, + BNXT_ULP_GLB_REGFILE_INDEX_GLB_L2_CNTXT_ID = 2, + BNXT_ULP_GLB_REGFILE_INDEX_GLB_LB_AREC_PTR = 3, + BNXT_ULP_GLB_REGFILE_INDEX_LAST = 4 }; enum bnxt_ulp_hdr_type { @@ -257,8 +258,8 @@ enum bnxt_ulp_match_type_bitmask { enum bnxt_ulp_resource_func { BNXT_ULP_RESOURCE_FUNC_INVALID = 0x00, - BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 0x20, - BNXT_ULP_RESOURCE_FUNC_RSVD1 = 0x40, + BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE = 0x20, + BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE = 0x40, BNXT_ULP_RESOURCE_FUNC_RSVD2 = 0x60, BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0x80, BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 0x81, diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c index beca3baa7..7c440e3a4 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c @@ -321,7 +321,12 @@ struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = { .mark_db_gfid_entries = 65536, .flow_count_db_entries = 16384, .num_resources_per_flow = 8, - .num_phy_ports = 2 + .num_phy_ports = 2, + .ext_cntr_table_type = 0, + .byte_count_mask = 0x00000003ffffffff, + .packet_count_mask = 0xfffffffc00000000, + .byte_count_shift = 0, + .packet_count_shift = 36 } }; diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index 4bcd02ba2..5a7a7b910 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -146,6 +146,11 @@ struct bnxt_ulp_device_params { uint64_t flow_db_num_entries; uint32_t flow_count_db_entries; uint32_t num_resources_per_flow; + uint32_t ext_cntr_table_type; + uint64_t byte_count_mask; + uint64_t packet_count_mask; + uint32_t byte_count_shift; + uint32_t packet_count_shift; }; /* Flow Mapper */