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 7716BA04DD; Tue, 20 Oct 2020 23:56:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50FD7AC9F; Tue, 20 Oct 2020 23:55:51 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 20777AC95 for ; Tue, 20 Oct 2020 23:55:48 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id d23so97637pll.7 for ; Tue, 20 Oct 2020 14:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=BjMmyceqysztbaO1ivR3Nz/gWc9AK4jh12wY1VQP/TM=; b=eHv8+D/yJCFvdwh5W8Qp2EUG4B8EIeNv4MqK4F4C+QVpVHjvMzJAoK0vk590UBHuKT +DJS5uHq1gZ1Djttqm4TspMhqih5tS9iVJDkUAu3pfBpsSc00i0NXQpv2dLAucGsShAs 4Azbl4pepVsKY3i+7hDs8IA562kZ+MDWh7odY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=BjMmyceqysztbaO1ivR3Nz/gWc9AK4jh12wY1VQP/TM=; b=HXQH65c3DGWiXI7qwezm9Tx6wrjHKM1YDQoLrJbsYsWOPu08phnsByjudi/F/xe4Bh tDgi8IWwoFNcesM7JYp36lYzLPqXd2BBeQVP+QPykqaDTHJ1LjJvWtls6P2U74iGX/Kf 2LBmerRw8BdZFJQfUk7oy8xugxV6Ti2fvYNTwfqnxS6eTXT4MF8XdsLXzACaCsZKeWmS OSaXIRk/r6G3LAlpBhIoN3Z1ELQ8K3nAYCV+BlYOF+z3bsSXRrI46tqloslzauOhUs4G k9G272sa0Py8XHWC1pl9Ol1fFpHkOFkKMqfcue3rBC5DSqvNXjfbS/QapFU7D2TGCZvX jqtw== X-Gm-Message-State: AOAM5305OeNpis4ZaXnER+HOWtVY6wVKLxj3vbQslCVu+NyhzrOaUU7w 5tfhLcIvhgLKcVJVBk4EuYQ7lNmb6jBiG5/hAYESTnuEivYdpm9bjeDP7oEZJvFzLKYirbKKrU7 DuibjsRdTfYbTnH0NWPX4r+GD9PGPysIsiaHVblbnYS3fGdnOCguSwur5gYEJpvvOzA== X-Google-Smtp-Source: ABdhPJyVJggUP/8PDsdA3YUhrupChCw+HcQXAnkHWEpOQVZg+hRmp5CfsQNB0aRu6g4tJYPozJu9eQ== X-Received: by 2002:a17:90a:8684:: with SMTP id p4mr154383pjn.232.1603230945596; Tue, 20 Oct 2020 14:55:45 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id e6sm24113pfn.190.2020.10.20.14.55.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2020 14:55:45 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Jay Ding , Farah Smith , Randy Schacher Date: Tue, 20 Oct 2020 14:55:29 -0700 Message-Id: <20201020215538.59242-3-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20201020215538.59242-1-ajit.khaparde@broadcom.com> References: <1602916089-18576-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <20201020215538.59242-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH v2 02/11] net/bnxt: changes to support two table scopes 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: Jay Ding New API to map a PARIF to an EEM table scope (set of Rx and Tx EEM base addresses). It uses HWRM_TF_GLOBAL_CFG_SET HWRM to configure. PARIF is handler to a partition of the physical port. Adjustments to tf_global_cfg_set() to reduce overhead and nominal name clarification. Signed-off-by: Jay Ding Signed-off-by: Farah Smith Reviewed-by: Randy Schacher Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_core/tf_core.c | 54 +++++-- drivers/net/bnxt/tf_core/tf_core.h | 55 ++++++- drivers/net/bnxt/tf_core/tf_device.h | 43 +++++- drivers/net/bnxt/tf_core/tf_device_p4.c | 44 ++++++ drivers/net/bnxt/tf_core/tf_em.h | 19 ++- drivers/net/bnxt/tf_core/tf_em_common.c | 174 ++++++++++++----------- drivers/net/bnxt/tf_core/tf_em_common.h | 27 +--- drivers/net/bnxt/tf_core/tf_em_host.c | 23 ++- drivers/net/bnxt/tf_core/tf_global_cfg.c | 4 +- drivers/net/bnxt/tf_core/tf_global_cfg.h | 42 ++---- drivers/net/bnxt/tf_core/tf_msg.c | 13 +- drivers/net/bnxt/tf_core/tf_msg.h | 4 +- 12 files changed, 326 insertions(+), 176 deletions(-) diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 788335b81..0f49a0025 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -303,7 +303,6 @@ int tf_get_global_cfg(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; - struct tf_dev_global_cfg_parms gparms = { 0 }; TF_CHECK_PARMS2(tfp, parms); @@ -342,12 +341,7 @@ int tf_get_global_cfg(struct tf *tfp, return -EOPNOTSUPP; } - gparms.dir = parms->dir; - gparms.type = parms->type; - gparms.offset = parms->offset; - gparms.config = parms->config; - gparms.config_sz_in_bytes = parms->config_sz_in_bytes; - rc = dev->ops->tf_dev_get_global_cfg(tfp, &gparms); + rc = dev->ops->tf_dev_get_global_cfg(tfp, parms); if (rc) { TFP_DRV_LOG(ERR, "%s: Global Cfg get failed, rc:%s\n", @@ -371,7 +365,6 @@ int tf_set_global_cfg(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; - struct tf_dev_global_cfg_parms gparms = { 0 }; TF_CHECK_PARMS2(tfp, parms); @@ -410,12 +403,7 @@ int tf_set_global_cfg(struct tf *tfp, return -EOPNOTSUPP; } - gparms.dir = parms->dir; - gparms.type = parms->type; - gparms.offset = parms->offset; - gparms.config = parms->config; - gparms.config_sz_in_bytes = parms->config_sz_in_bytes; - rc = dev->ops->tf_dev_set_global_cfg(tfp, &gparms); + rc = dev->ops->tf_dev_set_global_cfg(tfp, parms); if (rc) { TFP_DRV_LOG(ERR, "%s: Global Cfg set failed, rc:%s\n", @@ -1352,6 +1340,44 @@ tf_alloc_tbl_scope(struct tf *tfp, return rc; } +int +tf_map_tbl_scope(struct tf *tfp, + struct tf_map_tbl_scope_parms *parms) +{ + struct tf_session *tfs; + struct tf_dev_info *dev; + int rc; + + TF_CHECK_PARMS2(tfp, parms); + + /* Retrieve the session information */ + rc = tf_session_get_session(tfp, &tfs); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup session, rc:%s\n", + strerror(-rc)); + return rc; + } + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) { + TFP_DRV_LOG(ERR, + "Failed to lookup device, rc:%s\n", + strerror(-rc)); + return rc; + } + + if (dev->ops->tf_dev_map_tbl_scope != NULL) { + rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms); + } else { + TFP_DRV_LOG(ERR, + "Map table scope not supported by device\n"); + return -EINVAL; + } + + return rc; +} int tf_free_tbl_scope(struct tf *tfp, diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h index 65be8f54a..fa8ab52af 100644 --- a/drivers/net/bnxt/tf_core/tf_core.h +++ b/drivers/net/bnxt/tf_core/tf_core.h @@ -898,7 +898,9 @@ struct tf_alloc_tbl_scope_parms { */ uint32_t tbl_scope_id; }; - +/** + * tf_free_tbl_scope_parms definition + */ struct tf_free_tbl_scope_parms { /** * [in] table scope identifier @@ -906,6 +908,21 @@ struct tf_free_tbl_scope_parms { uint32_t tbl_scope_id; }; +/** + * tf_map_tbl_scope_parms definition + */ +struct tf_map_tbl_scope_parms { + /** + * [in] table scope identifier + */ + uint32_t tbl_scope_id; + /** + * [in] Which parifs are associated with this table scope. Bit 0 + * indicates parif 0. + */ + uint16_t parif_bitmask; +}; + /** * allocate a table scope * @@ -915,13 +932,13 @@ struct tf_free_tbl_scope_parms { * device constraints based upon calculations using either the number of flows * requested or the size of memory indicated. Other parameters passed in * determine the configuration (maximum key size, maximum external action record - * size. + * size). * - * This API will allocate the table region in - * DRAM, program the PTU page table entries, and program the number of static - * buckets (if SR2) in the RX and TX CFAs. Buckets are assumed to start at - * 0 in the EM memory for the scope. Upon successful completion of this API, - * hash tables are fully initialized and ready for entries to be inserted. + * This API will allocate the table region in DRAM, program the PTU page table + * entries, and program the number of static buckets (if SR2) in the RX and TX + * CFAs. Buckets are assumed to start at 0 in the EM memory for the scope. + * Upon successful completion of this API, hash tables are fully initialized and + * ready for entries to be inserted. * * A single API is used to allocate a common table scope identifier in both * receive and transmit CFA. The scope identifier is common due to nature of @@ -944,7 +961,25 @@ struct tf_free_tbl_scope_parms { int tf_alloc_tbl_scope(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms); +/** + * map a table scope (legacy device only Wh+/SR) + * + * Map a table scope to one or more partition interfaces (parifs). + * The parif can be remapped in the L2 context lookup for legacy devices. This + * API allows a number of parifs to be mapped to the same table scope. On + * legacy devices a table scope identifies one of 16 sets of EEM table base + * addresses and is associated with a PF communication channel. The associated + * PF must be configured for the table scope to operate. + * + * An L2 context TCAM lookup returns a remapped parif value used to + * index into the set of 16 parif_to_pf registers which are used to map to one + * of the 16 table scopes. This API allows the user to map the parifs in the + * mask to the previously allocated table scope (EEM table). + * Returns success or failure code. + */ +int tf_map_tbl_scope(struct tf *tfp, + struct tf_map_tbl_scope_parms *parms); /** * free a table scope * @@ -1908,6 +1943,12 @@ struct tf_global_cfg_parms { * get - Read the full configuration */ uint8_t *config; + /** + * [in] Configuration mask + * set - Read, Modify with mask and Write + * get - unused + */ + uint8_t *config_mask; /** * [in] struct containing size */ diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h index fce7f25a8..cf7c36e0e 100644 --- a/drivers/net/bnxt/tf_core/tf_device.h +++ b/drivers/net/bnxt/tf_core/tf_device.h @@ -573,6 +573,45 @@ struct tf_dev_ops { */ int (*tf_dev_alloc_tbl_scope)(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms); + /** + * Map EEM parif + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table scope map parameters + * + * [in/out] pointer to the parif_2_pf data to be updated + * + * [in/out] pointer to the parif_2_pf mask to be updated + * + * [in] sz_in_bytes - number of bytes to be written + * + * returns: + * 0 - Success + * -EINVAL - Error + */ + int (*tf_dev_map_parif)(struct tf *tfp, + struct tf_map_tbl_scope_parms *parms, + uint8_t *data, + uint8_t *mask, + uint16_t sz_in_bytes); + /** + * Map EEM table scope + * + * [in] tfp + * Pointer to TF handle + * + * [in] parms + * Pointer to table scope map parameters + * + * returns: + * 0 - Success + * -EINVAL - Error + */ + int (*tf_dev_map_tbl_scope)(struct tf *tfp, + struct tf_map_tbl_scope_parms *parms); /** * Free EEM table scope @@ -642,7 +681,7 @@ struct tf_dev_ops { * -EINVAL - Error */ int (*tf_dev_set_global_cfg)(struct tf *tfp, - struct tf_dev_global_cfg_parms *parms); + struct tf_global_cfg_parms *parms); /** * Get global cfg @@ -658,7 +697,7 @@ struct tf_dev_ops { * -EINVAL - Error */ int (*tf_dev_get_global_cfg)(struct tf *tfp, - struct tf_dev_global_cfg_parms *parms); + struct tf_global_cfg_parms *parms); }; /** diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c index 0344565d7..07c8d02fa 100644 --- a/drivers/net/bnxt/tf_core/tf_device_p4.c +++ b/drivers/net/bnxt/tf_core/tf_device_p4.c @@ -12,6 +12,10 @@ #include "tf_tcam.h" #include "tf_em.h" #include "tf_if_tbl.h" +#include "tfp.h" + +#define TF_DEV_P4_PARIF_MAX 16 +#define TF_DEV_P4_PF_MASK 0xfUL /** * Device specific function that retrieves the MAX number of HCAPI @@ -97,6 +101,42 @@ tf_dev_p4_get_tcam_slice_info(struct tf *tfp __rte_unused, return 0; } +static int +tf_dev_p4_map_parif(struct tf *tfp __rte_unused, + struct tf_map_tbl_scope_parms *parms, + uint8_t *data, + uint8_t *mask, + uint16_t sz_in_bytes) +{ + uint32_t parif_pf[2] = { 0 }; + uint32_t parif_pf_mask[2] = { 0 }; + uint32_t parif; + uint32_t shift; + uint32_t scope_id = (uint32_t)(parms->tbl_scope_id); + + if (sz_in_bytes != sizeof(uint64_t)) + return -ENOTSUP; + + for (parif = 0; parif < TF_DEV_P4_PARIF_MAX; parif++) { + if (parms->parif_bitmask & (1UL << parif)) { + if (parif < 8) { + shift = 4 * parif; + parif_pf_mask[0] |= TF_DEV_P4_PF_MASK << shift; + parif_pf[0] |= scope_id << shift; + } else { + shift = 4 * (parif - 8); + parif_pf_mask[1] |= TF_DEV_P4_PF_MASK << shift; + parif_pf[1] |= scope_id << shift; + } + } + } + tfp_memcpy(data, parif_pf, sz_in_bytes); + tfp_memcpy(mask, parif_pf_mask, sz_in_bytes); + + return 0; +} + + /** * Truflow P4 device specific functions */ @@ -125,6 +165,8 @@ const struct tf_dev_ops tf_dev_ops_p4_init = { .tf_dev_insert_ext_em_entry = NULL, .tf_dev_delete_ext_em_entry = NULL, .tf_dev_alloc_tbl_scope = NULL, + .tf_dev_map_tbl_scope = NULL, + .tf_dev_map_parif = NULL, .tf_dev_free_tbl_scope = NULL, .tf_dev_set_if_tbl = NULL, .tf_dev_get_if_tbl = NULL, @@ -160,6 +202,8 @@ const struct tf_dev_ops tf_dev_ops_p4 = { .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry, .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry, .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc, + .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope, + .tf_dev_map_parif = tf_dev_p4_map_parif, .tf_dev_free_tbl_scope = tf_em_ext_common_free, .tf_dev_set_if_tbl = tf_if_tbl_set, .tf_dev_get_if_tbl = tf_if_tbl_get, diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h index 51b08138e..8820b28ef 100644 --- a/drivers/net/bnxt/tf_core/tf_em.h +++ b/drivers/net/bnxt/tf_core/tf_em.h @@ -358,7 +358,7 @@ int tf_em_ext_free(struct tf *tfp, struct tf_free_tbl_scope_parms *parms); /** - * Common free for external EEM using host or system memory + * Common free table scope for external EEM using host or system memory * * [in] tfp * Pointer to TruFlow handle @@ -374,7 +374,7 @@ int tf_em_ext_common_free(struct tf *tfp, struct tf_free_tbl_scope_parms *parms); /** - * Common alloc for external EEM using host or system memory + * Common alloc table scope for external EEM using host or system memory * * [in] tfp * Pointer to TruFlow handle @@ -388,6 +388,21 @@ int tf_em_ext_common_free(struct tf *tfp, */ int tf_em_ext_common_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms); +/** + * Map a set of parifs to a set of EEM base addresses (table scope) + * + * [in] tfp + * Pointer to TruFlow handle + * + * [in] parms + * Pointer to input parameters + * + * Returns: + * 0 - Success + * -EINVAL - Parameter error + */ +int tf_em_ext_map_tbl_scope(struct tf *tfp, + struct tf_map_tbl_scope_parms *parms); /** * Allocate External Tbl entry from the scope pool. diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index 0d8b90871..a6ddb4eaf 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -44,28 +44,6 @@ static enum tf_mem_type mem_type; /** Table scope array */ struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE]; -/** Table scope reversal table - * - * Table scope are allocated from 15 to 0 within HCAPI RM. Because of the - * association between PFs and legacy table scopes, reverse table scope ids. - * 15 indicates 0, 14 indicates 1, etc... The application will only see the 0 - * based number. The firmware will only use the 0 based number. Only HCAPI RM - * and Truflow RM believe the number is 15. When HCAPI RM support allocation - * from low to high is supported, this adjust function can be removed. - */ -const uint32_t tbl_scope_reverse[TF_NUM_TBL_SCOPE] = { - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; - -static uint32_t -tf_tbl_scope_adjust(uint32_t tbl_scope_id) -{ - if (tbl_scope_id < TF_NUM_TBL_SCOPE) - return tbl_scope_reverse[tbl_scope_id]; - else - return TF_TBL_SCOPE_INVALID; -}; - - /* API defined in tf_em.h */ struct tf_tbl_scope_cb * tbl_scope_cb_find(uint32_t tbl_scope_id) @@ -73,17 +51,11 @@ tbl_scope_cb_find(uint32_t tbl_scope_id) int i; struct tf_rm_is_allocated_parms parms = { 0 }; int allocated; - uint32_t rm_tbl_scope_id; - - rm_tbl_scope_id = tf_tbl_scope_adjust(tbl_scope_id); - - if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID) - return NULL; /* Check that id is valid */ parms.rm_db = eem_db[TF_DIR_RX]; parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; - parms.index = rm_tbl_scope_id; + parms.index = tbl_scope_id; parms.allocated = &allocated; i = tf_rm_is_allocated(&parms); @@ -99,61 +71,6 @@ tbl_scope_cb_find(uint32_t tbl_scope_id) return NULL; } -int tf_tbl_scope_alloc(uint32_t *tbl_scope_id) -{ - int rc; - struct tf_rm_allocate_parms parms = { 0 }; - uint32_t rm_tbl_scope_id; - uint32_t usr_tbl_scope_id = TF_TBL_SCOPE_INVALID; - - /* Get Table Scope control block from the session pool */ - parms.rm_db = eem_db[TF_DIR_RX]; - parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; - parms.index = &rm_tbl_scope_id; - - rc = tf_rm_allocate(&parms); - if (rc) { - TFP_DRV_LOG(ERR, - "Failed to allocate table scope rc:%s\n", - strerror(-rc)); - return rc; - } - - usr_tbl_scope_id = tf_tbl_scope_adjust(rm_tbl_scope_id); - - if (usr_tbl_scope_id == TF_TBL_SCOPE_INVALID) { - TFP_DRV_LOG(ERR, - "Invalid table scope allocated id:%d\n", - (int)rm_tbl_scope_id); - return -EINVAL; - } - *tbl_scope_id = usr_tbl_scope_id; - return 0; -}; - -int tf_tbl_scope_free(uint32_t tbl_scope_id) -{ - struct tf_rm_free_parms parms = { 0 }; - uint32_t rm_tbl_scope_id; - uint32_t rc; - - rm_tbl_scope_id = tf_tbl_scope_adjust(tbl_scope_id); - - if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID) { - TFP_DRV_LOG(ERR, - "Invalid table scope allocated id:%d\n", - (int)tbl_scope_id); - return -EINVAL; - } - - parms.rm_db = eem_db[TF_DIR_RX]; - parms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; - parms.index = rm_tbl_scope_id; - - rc = tf_rm_free(&parms); - return rc; -}; - int tf_create_tbl_pool_external(enum tf_dir dir, struct tf_tbl_scope_cb *tbl_scope_cb, @@ -1129,3 +1046,92 @@ tf_em_ext_common_free(struct tf *tfp, { return tf_em_ext_free(tfp, parms); } + +int tf_em_ext_map_tbl_scope(struct tf *tfp, + struct tf_map_tbl_scope_parms *parms) +{ + int rc = 0; + struct tf_session *tfs; + struct tf_tbl_scope_cb *tbl_scope_cb; + struct tf_global_cfg_parms gcfg_parms = { 0 }; + struct tfp_calloc_parms aparms; + uint32_t *data, *mask; + uint32_t sz_in_bytes = 8; + struct tf_dev_info *dev; + + tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id); + + if (tbl_scope_cb == NULL) { + TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb tbl_scope_id(%d)\n", + parms->tbl_scope_id); + return -EINVAL; + } + + /* Retrieve the session information */ + rc = tf_session_get_session_internal(tfp, &tfs); + if (rc) + return rc; + + /* Retrieve the device information */ + rc = tf_session_get_device(tfs, &dev); + if (rc) + return rc; + + if (dev->ops->tf_dev_map_tbl_scope == NULL) { + rc = -EOPNOTSUPP; + TFP_DRV_LOG(ERR, + "Map table scope operation not supported, rc:%s\n", + strerror(-rc)); + return rc; + } + + aparms.nitems = 2; + aparms.size = sizeof(uint32_t); + aparms.alignment = 0; + + if (tfp_calloc(&aparms) != 0) { + TFP_DRV_LOG(ERR, "Map tbl scope alloc data error %s\n", + strerror(ENOMEM)); + return -ENOMEM; + } + data = aparms.mem_va; + + if (tfp_calloc(&aparms) != 0) { + TFP_DRV_LOG(ERR, "Map tbl scope alloc mask error %s\n", + strerror(ENOMEM)); + rc = -ENOMEM; + goto clean; + } + mask = aparms.mem_va; + + rc = dev->ops->tf_dev_map_parif(tfp, parms, (uint8_t *)data, + (uint8_t *)mask, sz_in_bytes); + + if (rc) { + TFP_DRV_LOG(ERR, + "Map table scope config failure, rc:%s\n", + strerror(-rc)); + goto cleaner; + } + + gcfg_parms.type = + (enum tf_global_config_type) TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF; + gcfg_parms.offset = 0; + gcfg_parms.config = (uint8_t *)data; + gcfg_parms.config_mask = (uint8_t *)mask; + gcfg_parms.config_sz_in_bytes = sizeof(uint64_t); + + + rc = tf_msg_set_global_cfg(tfp, &gcfg_parms); + if (rc) { + TFP_DRV_LOG(ERR, + "Map tbl scope, set failed, rc:%s\n", + strerror(-rc)); + } +cleaner: + tfp_free(mask); +clean: + tfp_free(data); + + return rc; +} diff --git a/drivers/net/bnxt/tf_core/tf_em_common.h b/drivers/net/bnxt/tf_core/tf_em_common.h index f71a48767..fa313c458 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.h +++ b/drivers/net/bnxt/tf_core/tf_em_common.h @@ -9,6 +9,7 @@ #include "tf_core.h" #include "tf_session.h" + /** * Function to search for table scope control block structure * with specified table scope ID. @@ -22,32 +23,6 @@ */ struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id); -/** - * Table Scope Allocate - * - * Allocate a table scope - * - * [in/out] pointer to tbl_scope_id - * - * Returns: - * 0 - success - * -EINVAL - error - */ -int tf_tbl_scope_alloc(uint32_t *tbl_scope_id); - -/** - * Table Scope Free - * - * Free a table scope - * - * [in] tbl_scope_id to free - * - * Returns: - * 0 - success - * -EINVAL - error - */ -int tf_tbl_scope_free(uint32_t tbl_scope_id); - /** * Create and initialize a stack to use for action entries * diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c index cfcb12f3b..b5db94f3e 100644 --- a/drivers/net/bnxt/tf_core/tf_em_host.c +++ b/drivers/net/bnxt/tf_core/tf_em_host.c @@ -374,8 +374,14 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms) struct tf_tbl_scope_cb *tbl_scope_cb; struct hcapi_cfa_em_table *em_tables; struct tf_free_tbl_scope_parms free_parms; - - rc = tf_tbl_scope_alloc(&parms->tbl_scope_id); + struct tf_rm_allocate_parms aparms = { 0 }; + struct tf_rm_free_parms fparms = { 0 }; + + /* Get Table Scope control block from the session pool */ + aparms.rm_db = eem_db[TF_DIR_RX]; + aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; + aparms.index = (uint32_t *)&parms->tbl_scope_id; + rc = tf_rm_allocate(&aparms); if (rc) { TFP_DRV_LOG(ERR, "Failed to allocate table scope\n"); @@ -472,7 +478,11 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms) return -EINVAL; cleanup: - tf_tbl_scope_free(parms->tbl_scope_id); + /* Free Table control block */ + fparms.rm_db = eem_db[TF_DIR_RX]; + fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; + fparms.index = parms->tbl_scope_id; + tf_rm_free(&fparms); return -EINVAL; } @@ -483,6 +493,7 @@ tf_em_ext_free(struct tf *tfp, int rc = 0; enum tf_dir dir; struct tf_tbl_scope_cb *tbl_scope_cb; + struct tf_rm_free_parms aparms = { 0 }; tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id); @@ -491,7 +502,11 @@ tf_em_ext_free(struct tf *tfp, return -EINVAL; } - rc = tf_tbl_scope_free(parms->tbl_scope_id); + /* Free Table control block */ + aparms.rm_db = eem_db[TF_DIR_RX]; + aparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE; + aparms.index = parms->tbl_scope_id; + rc = tf_rm_free(&aparms); if (rc) { TFP_DRV_LOG(ERR, "Failed to free table scope\n"); diff --git a/drivers/net/bnxt/tf_core/tf_global_cfg.c b/drivers/net/bnxt/tf_core/tf_global_cfg.c index 4ed4039db..ebd1a86ad 100644 --- a/drivers/net/bnxt/tf_core/tf_global_cfg.c +++ b/drivers/net/bnxt/tf_core/tf_global_cfg.c @@ -113,7 +113,7 @@ tf_global_cfg_unbind(struct tf *tfp __rte_unused) int tf_global_cfg_set(struct tf *tfp, - struct tf_dev_global_cfg_parms *parms) + struct tf_global_cfg_parms *parms) { int rc; struct tf_global_cfg_get_hcapi_parms hparms; @@ -156,7 +156,7 @@ tf_global_cfg_set(struct tf *tfp, int tf_global_cfg_get(struct tf *tfp, - struct tf_dev_global_cfg_parms *parms) + struct tf_global_cfg_parms *parms) { int rc; diff --git a/drivers/net/bnxt/tf_core/tf_global_cfg.h b/drivers/net/bnxt/tf_core/tf_global_cfg.h index 5c73bb115..685f38dc7 100644 --- a/drivers/net/bnxt/tf_core/tf_global_cfg.h +++ b/drivers/net/bnxt/tf_core/tf_global_cfg.h @@ -13,7 +13,15 @@ * The global cfg module provides processing of global cfg types. */ -struct tf; +/* struct tf; */ + +/* Internal type not available to user + * but available internally within Truflow + */ +enum tf_global_config_internal_type { + TF_GLOBAL_CFG_INTERNAL_PARIF_2_PF = TF_GLOBAL_CFG_TYPE_MAX, + TF_GLOBAL_CFG_INTERNAL_TYPE_MAX +}; /** * Global cfg configuration enumeration. @@ -61,34 +69,6 @@ struct tf_global_cfg_cfg_parms { struct tf_global_cfg_cfg *cfg; }; -/** - * global cfg parameters - */ -struct tf_dev_global_cfg_parms { - /** - * [in] Receive or transmit direction - */ - enum tf_dir dir; - /** - * [in] Global config type - */ - enum tf_global_config_type type; - /** - * [in] Offset @ the type - */ - uint32_t offset; - /** - * [in/out] Value of the configuration - * set - Read, Modify and Write - * get - Read the full configuration - */ - uint8_t *config; - /** - * [in] struct containing size - */ - uint16_t config_sz_in_bytes; -}; - /** * @page global cfg * @@ -149,7 +129,7 @@ tf_global_cfg_unbind(struct tf *tfp); * - (-EINVAL) on failure. */ int tf_global_cfg_set(struct tf *tfp, - struct tf_dev_global_cfg_parms *parms); + struct tf_global_cfg_parms *parms); /** * Get global configuration @@ -165,6 +145,6 @@ int tf_global_cfg_set(struct tf *tfp, * - (-EINVAL) on failure. */ int tf_global_cfg_get(struct tf *tfp, - struct tf_dev_global_cfg_parms *parms); + struct tf_global_cfg_parms *parms); #endif /* TF_GLOBAL_CFG_H */ diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 7c2ad172f..5615eedbb 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -1075,7 +1075,7 @@ tf_msg_get_tbl_entry(struct tf *tfp, int tf_msg_get_global_cfg(struct tf *tfp, - struct tf_dev_global_cfg_parms *params) + struct tf_global_cfg_parms *params) { int rc = 0; struct tfp_send_msg_parms parms = { 0 }; @@ -1133,7 +1133,7 @@ tf_msg_get_global_cfg(struct tf *tfp, int tf_msg_set_global_cfg(struct tf *tfp, - struct tf_dev_global_cfg_parms *params) + struct tf_global_cfg_parms *params) { int rc = 0; struct tfp_send_msg_parms parms = { 0 }; @@ -1173,6 +1173,15 @@ tf_msg_set_global_cfg(struct tf *tfp, tfp_memcpy(req.data, params->config, params->config_sz_in_bytes); + + /* Only set mask if pointer is provided + */ + if (params->config_mask) { + tfp_memcpy(req.data + params->config_sz_in_bytes, + params->config_mask, + params->config_sz_in_bytes); + } + req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes); parms.tf_type = HWRM_TF_GLOBAL_CFG_SET; diff --git a/drivers/net/bnxt/tf_core/tf_msg.h b/drivers/net/bnxt/tf_core/tf_msg.h index 195710eb8..72bf85048 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.h +++ b/drivers/net/bnxt/tf_core/tf_msg.h @@ -462,7 +462,7 @@ int tf_msg_get_tbl_entry(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_get_global_cfg(struct tf *tfp, - struct tf_dev_global_cfg_parms *params); + struct tf_global_cfg_parms *params); /** * Sends global cfg update request to Firmware @@ -477,7 +477,7 @@ int tf_msg_get_global_cfg(struct tf *tfp, * 0 on Success else internal Truflow error */ int tf_msg_set_global_cfg(struct tf *tfp, - struct tf_dev_global_cfg_parms *params); + struct tf_global_cfg_parms *params); /** * Sends bulk get message of a Table Type element to the firmware. -- 2.21.1 (Apple Git-122.3)