From: Somnath Kotur <somnath.kotur@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 04/10] net/bnxt: add changes to support 2 table scopes
Date: Mon, 13 Jul 2020 11:58:22 +0530 [thread overview]
Message-ID: <20200713062828.19626-5-somnath.kotur@broadcom.com> (raw)
In-Reply-To: <20200713062828.19626-1-somnath.kotur@broadcom.com>
From: Farah Smith <farah.smith@broadcom.com>
Need to remap the table scope ids allocated from HCAPI RM from high
to low value because for legacy devices a table scope is a set of base
addresses. The PCIe addresses must map to a PCIe PF which exists in
the hardware.
Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
drivers/net/bnxt/tf_core/tf_em_common.c | 106 +++++++++++++++++++++++++++++++-
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_em_system.c | 19 +-----
4 files changed, 137 insertions(+), 38 deletions(-)
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index 65b9abf..10c3f16 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -44,6 +44,28 @@ 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)
@@ -51,11 +73,17 @@ tbl_scope_cb_find(uint32_t tbl_scope_id)
int i;
struct tf_rm_is_allocated_parms parms;
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 = tbl_scope_id;
+ parms.index = rm_tbl_scope_id;
parms.allocated = &allocated;
i = tf_rm_is_allocated(&parms);
@@ -71,6 +99,61 @@ 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,
@@ -706,9 +789,17 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
if (rc) {
struct tf_rm_free_parms fparms = { 0 };
+ uint32_t rm_tbl_scope_id;
TFP_DRV_LOG(ERR,
"System alloc mmap failed\n");
+
+ rm_tbl_scope_id =
+ tf_tbl_scope_adjust(parms->tbl_scope_id);
+
+ if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID)
+ return -EINVAL;
+
/* Free Table control block */
fparms.rm_db = eem_db[TF_DIR_RX];
fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
@@ -1043,13 +1134,24 @@ int tf_tbl_ext_common_set(struct tf *tfp,
if (rc) {
struct tf_rm_free_parms fparms = { 0 };
+ uint32_t rm_tbl_scope_id;
+
+ /* TODO: support allocation of table scope from
+ * min in HCAPI RM. For now call adjust function
+ * on value obtained from RM.
+ */
+ rm_tbl_scope_id =
+ tf_tbl_scope_adjust(parms->tbl_scope_id);
+
+ if (rm_tbl_scope_id == TF_TBL_SCOPE_INVALID)
+ return -EINVAL;
TFP_DRV_LOG(ERR,
"System alloc mmap failed\n");
/* 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;
+ fparms.index = rm_tbl_scope_id;
tf_rm_free(&fparms);
return -EINVAL;
}
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.h b/drivers/net/bnxt/tf_core/tf_em_common.h
index fa313c4..f71a487 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.h
+++ b/drivers/net/bnxt/tf_core/tf_em_common.h
@@ -9,7 +9,6 @@
#include "tf_core.h"
#include "tf_session.h"
-
/**
* Function to search for table scope control block structure
* with specified table scope ID.
@@ -24,6 +23,32 @@
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
*
* [in] dir
diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c
index b5db94f..cfcb12f 100644
--- a/drivers/net/bnxt/tf_core/tf_em_host.c
+++ b/drivers/net/bnxt/tf_core/tf_em_host.c
@@ -374,14 +374,8 @@ 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;
- 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);
+
+ rc = tf_tbl_scope_alloc(&parms->tbl_scope_id);
if (rc) {
TFP_DRV_LOG(ERR,
"Failed to allocate table scope\n");
@@ -478,11 +472,7 @@ tf_em_ext_alloc(struct tf *tfp, struct tf_alloc_tbl_scope_parms *parms)
return -EINVAL;
cleanup:
- /* 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);
+ tf_tbl_scope_free(parms->tbl_scope_id);
return -EINVAL;
}
@@ -493,7 +483,6 @@ 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);
@@ -502,11 +491,7 @@ tf_em_ext_free(struct tf *tfp,
return -EINVAL;
}
- /* 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);
+ rc = tf_tbl_scope_free(parms->tbl_scope_id);
if (rc) {
TFP_DRV_LOG(ERR,
"Failed to free table scope\n");
diff --git a/drivers/net/bnxt/tf_core/tf_em_system.c b/drivers/net/bnxt/tf_core/tf_em_system.c
index 1c3c702..32ee1ee 100644
--- a/drivers/net/bnxt/tf_core/tf_em_system.c
+++ b/drivers/net/bnxt/tf_core/tf_em_system.c
@@ -364,9 +364,7 @@ tf_em_ext_alloc(struct tf *tfp,
int rc;
struct tf_session *tfs;
struct tf_tbl_scope_cb *tbl_scope_cb;
- struct tf_rm_allocate_parms aparms = { 0 };
struct tf_free_tbl_scope_parms free_parms;
- struct tf_rm_free_parms fparms = { 0 };
int dir;
int i;
struct hcapi_cfa_em_table *em_tables;
@@ -382,10 +380,7 @@ tf_em_ext_alloc(struct tf *tfp,
return rc;
}
- 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);
+ rc = tf_tbl_scope_alloc(&parms->tbl_scope_id);
if (rc) {
TFP_DRV_LOG(ERR,
"Failed to allocate table scope\n");
@@ -473,10 +468,7 @@ tf_em_ext_alloc(struct tf *tfp,
cleanup:
/* 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);
+ tf_tbl_scope_free(parms->tbl_scope_id);
return -EINVAL;
}
@@ -488,7 +480,6 @@ tf_em_ext_free(struct tf *tfp,
struct tf_session *tfs;
struct tf_tbl_scope_cb *tbl_scope_cb;
int dir;
- struct tf_rm_free_parms aparms = { 0 };
TF_CHECK_PARMS2(tfp, parms);
@@ -503,11 +494,7 @@ tf_em_ext_free(struct tf *tfp,
tbl_scope_cb = &tbl_scopes[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);
+ rc = tf_tbl_scope_free(parms->tbl_scope_id);
if (rc) {
TFP_DRV_LOG(ERR,
"Failed to free table scope\n");
--
2.7.4
next prev 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 ` Somnath Kotur [this message]
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 ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
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 04/10] net/bnxt: add changes to support 2 table scopes 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 04/10] net/bnxt: add changes to support 2 table scopes 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 04/10] net/bnxt: add changes to support 2 table scopes 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-5-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).