From patchwork Tue Nov 16 13:04:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkat Duvvuru X-Patchwork-Id: 104400 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ECB4DA0032; Tue, 16 Nov 2021 14:04:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B2E741149; Tue, 16 Nov 2021 14:04:45 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id CE455410EA for ; Tue, 16 Nov 2021 14:04:43 +0100 (CET) Received: from S60.dhcp.broadcom.net (unknown [10.123.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 173DC7FFB; Tue, 16 Nov 2021 05:04:41 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 173DC7FFB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1637067883; bh=7jalqQonVbxKATx14TuIg2klXyeVBnIVN9yGPBUdi3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJAz70HR3ymQQ4joBXsGZo1QGlMNfJY5qvUZq6bKp1/r+9eqglVwPTS8Ok3q2M0wd qHSJ2l16zv7SexrLcYLiPgb61or/oMQO9Ip0Lq4TTfzBIJRLroqwBfrsuuW6V9UYVI rLVcz6dXDqXnPNVxbON9WAuC495Nadu5wLD8kZaE= From: Venkat Duvvuru To: dev@dpdk.org Cc: Jay Ding , Venkat Duvvuru Subject: [PATCH 1/4] net/bnxt: remove settings to support multiple session Date: Tue, 16 Nov 2021 18:34:34 +0530 Message-Id: <20211116130437.2022-2-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211116130437.2022-1-venkatkumar.duvvuru@broadcom.com> References: <20211116130437.2022-1-venkatkumar.duvvuru@broadcom.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jay Ding Move wc_tcam_slices_per_row and database structure of global_cfg and if_tbl to session structure to support multiple TruFlow sessions with different card type under single dpdk application instance. Signed-off-by: Jay Ding Signed-off-by: Venkat Duvvuru Reviewed-by: Farah Smith Reviewed-by: Randy Schacher --- drivers/net/bnxt/tf_core/tf_device.c | 3 - drivers/net/bnxt/tf_core/tf_device_p4.c | 24 ++++++-- drivers/net/bnxt/tf_core/tf_device_p58.c | 24 ++++++-- drivers/net/bnxt/tf_core/tf_global_cfg.c | 75 +++++++++++++++++------ drivers/net/bnxt/tf_core/tf_if_tbl.c | 61 +++++++++++++++---- drivers/net/bnxt/tf_core/tf_session.c | 76 ++++++++++++++++++++++++ drivers/net/bnxt/tf_core/tf_session.h | 69 ++++++++++++++++++++- 7 files changed, 291 insertions(+), 41 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_device.c b/drivers/net/bnxt/tf_core/tf_device.c index 4c416270b6..a35d22841c 100644 --- a/drivers/net/bnxt/tf_core/tf_device.c +++ b/drivers/net/bnxt/tf_core/tf_device.c @@ -16,9 +16,6 @@ struct tf; -/* Number of slices per row for WC TCAM */ -uint16_t g_wc_num_slices_per_row = TF_WC_TCAM_1_SLICE_PER_ROW; - /* Forward declarations */ static int tf_dev_unbind_p4(struct tf *tfp); static int tf_dev_unbind_p58(struct tf *tfp); diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index a6a59b8a07..aa55587ba8 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -239,14 +239,22 @@ tf_dev_p4_get_resource_str(struct tf *tfp __rte_unused, * - (-EINVAL) on failure. */ static int -tf_dev_p4_set_tcam_slice_info(struct tf *tfp __rte_unused, +tf_dev_p4_set_tcam_slice_info(struct tf *tfp, enum tf_wc_num_slice num_slices_per_row) { + int rc; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + switch (num_slices_per_row) { case TF_WC_TCAM_1_SLICE_PER_ROW: case TF_WC_TCAM_2_SLICE_PER_ROW: case TF_WC_TCAM_4_SLICE_PER_ROW: - g_wc_num_slices_per_row = num_slices_per_row; + tfs->wc_num_slices_per_row = num_slices_per_row; break; default: return -EINVAL; @@ -276,16 +284,24 @@ tf_dev_p4_set_tcam_slice_info(struct tf *tfp __rte_unused, * - (-EINVAL) on failure. */ static int -tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused, +tf_dev_p4_get_tcam_slice_info(struct tf *tfp, enum tf_tcam_tbl_type type, uint16_t key_sz, uint16_t *num_slices_per_row) { + int rc; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + /* Single slice support */ #define CFA_P4_WC_TCAM_SLICE_SIZE 12 if (type == TF_TCAM_TBL_TYPE_WC_TCAM) { - *num_slices_per_row = g_wc_num_slices_per_row; + *num_slices_per_row = tfs->wc_num_slices_per_row; if (key_sz > *num_slices_per_row * CFA_P4_WC_TCAM_SLICE_SIZE) return -ENOTSUP; } else { /* for other type of tcam */ diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c index 30c0af7eef..987ad2a564 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p58.c +++ b/drivers/net/bnxt/tf_core/tf_device_p58.c @@ -350,14 +350,22 @@ tf_dev_p58_get_resource_str(struct tf *tfp __rte_unused, * - (-EINVAL) on failure. */ static int -tf_dev_p58_set_tcam_slice_info(struct tf *tfp __rte_unused, +tf_dev_p58_set_tcam_slice_info(struct tf *tfp, enum tf_wc_num_slice num_slices_per_row) { + int rc; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + switch (num_slices_per_row) { case TF_WC_TCAM_1_SLICE_PER_ROW: case TF_WC_TCAM_2_SLICE_PER_ROW: case TF_WC_TCAM_4_SLICE_PER_ROW: - g_wc_num_slices_per_row = num_slices_per_row; + tfs->wc_num_slices_per_row = num_slices_per_row; break; default: return -EINVAL; @@ -387,14 +395,22 @@ tf_dev_p58_set_tcam_slice_info(struct tf *tfp __rte_unused, * - (-EINVAL) on failure. */ static int -tf_dev_p58_get_tcam_slice_info(struct tf *tfp __rte_unused, +tf_dev_p58_get_tcam_slice_info(struct tf *tfp, enum tf_tcam_tbl_type type, uint16_t key_sz, uint16_t *num_slices_per_row) { + int rc; + struct tf_session *tfs; + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + #define CFA_P58_WC_TCAM_SLICE_SIZE 24 if (type == TF_TCAM_TBL_TYPE_WC_TCAM) { - *num_slices_per_row = g_wc_num_slices_per_row; + *num_slices_per_row = tfs->wc_num_slices_per_row; if (key_sz > *num_slices_per_row * CFA_P58_WC_TCAM_SLICE_SIZE) return -ENOTSUP; } else { /* for other type of tcam */ diff --git a/drivers/net/bnxt/tf_core/tf_global_cfg.c b/drivers/net/bnxt/tf_core/tf_global_cfg.c index f420452684..98a42b2fe6 100644 --- a/drivers/net/bnxt/tf_core/tf_global_cfg.c +++ b/drivers/net/bnxt/tf_core/tf_global_cfg.c @@ -12,10 +12,13 @@ #include "tfp.h" struct tf; + /** - * Global Cfg DBs. + * Global cfg database */ -static void *global_cfg_db[TF_DIR_MAX]; +struct tf_global_cfg_db { + struct tf_global_cfg_cfg *global_cfg_db[TF_DIR_MAX]; +}; /** * Init flag, set on bind and cleared on unbind @@ -72,40 +75,62 @@ tf_global_cfg_get_hcapi_type(struct tf_global_cfg_get_hcapi_parms *parms) } int -tf_global_cfg_bind(struct tf *tfp __rte_unused, +tf_global_cfg_bind(struct tf *tfp, struct tf_global_cfg_cfg_parms *parms) { + struct tfp_calloc_parms cparms; + struct tf_global_cfg_db *global_cfg_db; + TF_CHECK_PARMS2(tfp, parms); if (init) { - TFP_DRV_LOG(ERR, - "Global Cfg DB already initialized\n"); + TFP_DRV_LOG(ERR, "Global Cfg DB already initialized\n"); return -EINVAL; } - global_cfg_db[TF_DIR_RX] = parms->cfg; - global_cfg_db[TF_DIR_TX] = parms->cfg; + cparms.nitems = 1; + cparms.size = sizeof(struct tf_global_cfg_db); + cparms.alignment = 0; + if (tfp_calloc(&cparms) != 0) { + TFP_DRV_LOG(ERR, "global_rm_db alloc error %s\n", + strerror(ENOMEM)); + return -ENOMEM; + } + + global_cfg_db = cparms.mem_va; + global_cfg_db->global_cfg_db[TF_DIR_RX] = parms->cfg; + global_cfg_db->global_cfg_db[TF_DIR_TX] = parms->cfg; + + tf_session_set_global_db(tfp, (void *)global_cfg_db); init = 1; - TFP_DRV_LOG(INFO, - "Global Cfg - initialized\n"); + TFP_DRV_LOG(INFO, "Global Cfg - initialized\n"); return 0; } int -tf_global_cfg_unbind(struct tf *tfp __rte_unused) +tf_global_cfg_unbind(struct tf *tfp) { + int rc; + struct tf_global_cfg_db *global_cfg_db_ptr; + + TF_CHECK_PARMS1(tfp); + /* Bail if nothing has been initialized */ if (!init) { - TFP_DRV_LOG(INFO, - "No Global Cfg DBs created\n"); + TFP_DRV_LOG(INFO, "No Global Cfg DBs created\n"); return 0; } - global_cfg_db[TF_DIR_RX] = NULL; - global_cfg_db[TF_DIR_TX] = NULL; + rc = tf_session_get_global_db(tfp, (void **)&global_cfg_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "global_cfg_db is not initialized\n"); + return 0; + } + + tfp_free((void *)global_cfg_db_ptr); init = 0; return 0; @@ -117,19 +142,25 @@ tf_global_cfg_set(struct tf *tfp, { int rc; struct tf_global_cfg_get_hcapi_parms hparms; + struct tf_global_cfg_db *global_cfg_db_ptr; uint16_t hcapi_type; TF_CHECK_PARMS3(tfp, parms, parms->config); if (!init) { - TFP_DRV_LOG(ERR, - "%s: No Global Cfg DBs created\n", + TFP_DRV_LOG(ERR, "%s: No Global Cfg DBs created\n", tf_dir_2_str(parms->dir)); return -EINVAL; } + rc = tf_session_get_global_db(tfp, (void **)&global_cfg_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No global cfg DBs initialized\n"); + return 0; + } + /* Convert TF type to HCAPI type */ - hparms.global_cfg_db = global_cfg_db[parms->dir]; + hparms.global_cfg_db = global_cfg_db_ptr->global_cfg_db[parms->dir]; hparms.db_index = parms->type; hparms.hcapi_type = &hcapi_type; rc = tf_global_cfg_get_hcapi_type(&hparms); @@ -161,6 +192,7 @@ tf_global_cfg_get(struct tf *tfp, { int rc; struct tf_global_cfg_get_hcapi_parms hparms; + struct tf_global_cfg_db *global_cfg_db_ptr; uint16_t hcapi_type; TF_CHECK_PARMS3(tfp, parms, parms->config); @@ -172,7 +204,14 @@ tf_global_cfg_get(struct tf *tfp, return -EINVAL; } - hparms.global_cfg_db = global_cfg_db[parms->dir]; + rc = tf_session_get_global_db(tfp, (void **)&global_cfg_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No Global cfg DBs initialized\n"); + return 0; + } + + /* Convert TF type to HCAPI type */ + hparms.global_cfg_db = global_cfg_db_ptr->global_cfg_db[parms->dir]; hparms.db_index = parms->type; hparms.hcapi_type = &hcapi_type; rc = tf_global_cfg_get_hcapi_type(&hparms); diff --git a/drivers/net/bnxt/tf_core/tf_if_tbl.c b/drivers/net/bnxt/tf_core/tf_if_tbl.c index 762dac0473..e667d6fa6d 100644 --- a/drivers/net/bnxt/tf_core/tf_if_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_if_tbl.c @@ -15,10 +15,11 @@ struct tf; /** - * IF Table DBs. - * TODO: Store this data in session db + * IF Table database */ -static void *if_tbl_db[TF_DIR_MAX]; +struct tf_if_tbl_db { + struct tf_if_tbl_cfg *if_tbl_cfg_db[TF_DIR_MAX]; +}; /** * Init flag, set on bind and cleared on unbind @@ -57,13 +58,27 @@ tf_if_tbl_get_hcapi_type(struct tf_if_tbl_get_hcapi_parms *parms) } int -tf_if_tbl_bind(struct tf *tfp __rte_unused, +tf_if_tbl_bind(struct tf *tfp, struct tf_if_tbl_cfg_parms *parms) { + struct tfp_calloc_parms cparms; + struct tf_if_tbl_db *if_tbl_db; + TF_CHECK_PARMS2(tfp, parms); - if_tbl_db[TF_DIR_RX] = parms->cfg; - if_tbl_db[TF_DIR_TX] = parms->cfg; + cparms.nitems = 1; + cparms.size = sizeof(struct tf_if_tbl_db); + cparms.alignment = 0; + if (tfp_calloc(&cparms) != 0) { + TFP_DRV_LOG(ERR, "if_tbl_rm_db alloc error %s\n", + strerror(ENOMEM)); + return -ENOMEM; + } + + if_tbl_db = cparms.mem_va; + if_tbl_db->if_tbl_cfg_db[TF_DIR_RX] = parms->cfg; + if_tbl_db->if_tbl_cfg_db[TF_DIR_TX] = parms->cfg; + tf_session_set_if_tbl_db(tfp, (void *)if_tbl_db); init = 1; @@ -74,8 +89,11 @@ tf_if_tbl_bind(struct tf *tfp __rte_unused, } int -tf_if_tbl_unbind(struct tf *tfp __rte_unused) +tf_if_tbl_unbind(struct tf *tfp) { + int rc; + struct tf_if_tbl_db *if_tbl_db_ptr; + /* Bail if nothing has been initialized */ if (!init) { TFP_DRV_LOG(INFO, @@ -83,8 +101,15 @@ tf_if_tbl_unbind(struct tf *tfp __rte_unused) return 0; } - if_tbl_db[TF_DIR_RX] = NULL; - if_tbl_db[TF_DIR_TX] = NULL; + TF_CHECK_PARMS1(tfp); + + rc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No IF Table DBs initialized\n"); + return 0; + } + + tfp_free((void *)if_tbl_db_ptr); init = 0; return 0; @@ -95,6 +120,7 @@ tf_if_tbl_set(struct tf *tfp, struct tf_if_tbl_set_parms *parms) { int rc; + struct tf_if_tbl_db *if_tbl_db_ptr; struct tf_if_tbl_get_hcapi_parms hparms; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -106,8 +132,14 @@ tf_if_tbl_set(struct tf *tfp, return -EINVAL; } + rc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No IF Table DBs initialized\n"); + return 0; + } + /* Convert TF type to HCAPI type */ - hparms.tbl_db = if_tbl_db[parms->dir]; + hparms.tbl_db = if_tbl_db_ptr->if_tbl_cfg_db[parms->dir]; hparms.db_index = parms->type; hparms.hcapi_type = &parms->hcapi_type; rc = tf_if_tbl_get_hcapi_type(&hparms); @@ -131,6 +163,7 @@ tf_if_tbl_get(struct tf *tfp, struct tf_if_tbl_get_parms *parms) { int rc = 0; + struct tf_if_tbl_db *if_tbl_db_ptr; struct tf_if_tbl_get_hcapi_parms hparms; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -142,8 +175,14 @@ tf_if_tbl_get(struct tf *tfp, return -EINVAL; } + rc = tf_session_get_if_tbl_db(tfp, (void **)&if_tbl_db_ptr); + if (rc) { + TFP_DRV_LOG(INFO, "No IF Table DBs initialized\n"); + return 0; + } + /* Convert TF type to HCAPI type */ - hparms.tbl_db = if_tbl_db[parms->dir]; + hparms.tbl_db = if_tbl_db_ptr->if_tbl_cfg_db[parms->dir]; hparms.db_index = parms->type; hparms.hcapi_type = &parms->hcapi_type; rc = tf_if_tbl_get_hcapi_type(&hparms); diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c index 3e6664e9f2..9f849a0a76 100644 --- a/drivers/net/bnxt/tf_core/tf_session.c +++ b/drivers/net/bnxt/tf_core/tf_session.c @@ -1069,3 +1069,79 @@ tf_session_set_sram_db(struct tf *tfp, } #endif /* TF_TCAM_SHARED */ + +int +tf_session_get_global_db(struct tf *tfp, + void **global_handle) +{ + struct tf_session *tfs = NULL; + int rc = 0; + + *global_handle = NULL; + + if (tfp == NULL) + return (-EINVAL); + + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + + *global_handle = tfs->global_db_handle; + return rc; +} + +int +tf_session_set_global_db(struct tf *tfp, + void *global_handle) +{ + struct tf_session *tfs = NULL; + int rc = 0; + + if (tfp == NULL) + return (-EINVAL); + + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + + tfs->global_db_handle = global_handle; + return rc; +} + +int +tf_session_get_if_tbl_db(struct tf *tfp, + void **if_tbl_handle) +{ + struct tf_session *tfs = NULL; + int rc = 0; + + *if_tbl_handle = NULL; + + if (tfp == NULL) + return (-EINVAL); + + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + + *if_tbl_handle = tfs->if_tbl_db_handle; + return rc; +} + +int +tf_session_set_if_tbl_db(struct tf *tfp, + void *if_tbl_handle) +{ + struct tf_session *tfs = NULL; + int rc = 0; + + if (tfp == NULL) + return (-EINVAL); + + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + + tfs->if_tbl_db_handle = if_tbl_handle; + return rc; +} diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h index c1d7f70060..19a96c28b1 100644 --- a/drivers/net/bnxt/tf_core/tf_session.h +++ b/drivers/net/bnxt/tf_core/tf_session.h @@ -13,7 +13,6 @@ #include "tf_core.h" #include "tf_device.h" #include "tf_rm.h" -#include "tf_tbl.h" #include "tf_resources.h" #include "stack.h" #include "ll.h" @@ -166,10 +165,26 @@ struct tf_session { */ void *tcam_shared_db_handle; #endif /* TF_TCAM_SHARED */ + /** * SRAM db reference for the session */ void *sram_handle; + + /** + * if table db reference for the session + */ + void *if_tbl_db_handle; + + /** + * global db reference for the session + */ + void *global_db_handle; + + /** + * Number of slices per row for WC TCAM + */ + uint16_t wc_num_slices_per_row; }; /** @@ -666,4 +681,56 @@ int tf_session_get_sram_db(struct tf *tfp, void **sram_handle); +/** + * Set the pointer to the global cfg database + * + * [in] session, pointer to the session + * + * Returns: + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int +tf_session_set_global_db(struct tf *tfp, + void *global_handle); + +/** + * Get the pointer to the global cfg database + * + * [in] session, pointer to the session + * + * Returns: + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int +tf_session_get_global_db(struct tf *tfp, + void **global_handle); + +/** + * Set the pointer to the if table cfg database + * + * [in] session, pointer to the session + * + * Returns: + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int +tf_session_set_if_tbl_db(struct tf *tfp, + void *if_tbl_handle); + +/** + * Get the pointer to the if table cfg database + * + * [in] session, pointer to the session + * + * Returns: + * - (0) if successful. + * - (-EINVAL) on failure. + */ +int +tf_session_get_if_tbl_db(struct tf *tfp, + void **if_tbl_handle); + #endif /* _TF_SESSION_H_ */