[dpdk-dev] [PATCH v2 21/58] net/bnxt: add API to get shared table increments
Ajit Khaparde
ajit.khaparde at broadcom.com
Sun Jun 13 02:06:15 CEST 2021
From: Farah Smith <farah.smith at broadcom.com>
Add TRUFLOW API to get the shared table increment value
for a given TRUFLOW table type.
The API is being added for Wh+ and Thor devices.
Signed-off-by: Farah Smith <farah.smith at broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru at broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher at broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
---
drivers/net/bnxt/tf_core/tf_core.c | 52 +++++++++++++++++++++++
drivers/net/bnxt/tf_core/tf_core.h | 34 ++++++++++++++-
drivers/net/bnxt/tf_core/tf_device.h | 17 ++++++++
drivers/net/bnxt/tf_core/tf_device_p4.c | 25 +++++++++++
drivers/net/bnxt/tf_core/tf_device_p58.c | 44 +++++++++++++++++++
drivers/net/bnxt/tf_core/tf_tcam_shared.c | 22 +++++++---
6 files changed, 188 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 73dbee2940..0fbbd40252 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -1415,6 +1415,58 @@ tf_bulk_get_tbl_entry(struct tf *tfp,
return rc;
}
+int tf_get_shared_tbl_increment(struct tf *tfp,
+ struct tf_get_shared_tbl_increment_parms *parms)
+{
+ int rc = 0;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session(tfp, &tfs);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to lookup session, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to lookup device, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ /* Internal table type processing */
+
+ if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "%s: Operation not supported, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return -EOPNOTSUPP;
+ }
+
+ rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Get table increment not supported, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ return rc;
+}
+
int
tf_alloc_tbl_scope(struct tf *tfp,
struct tf_alloc_tbl_scope_parms *parms)
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 95cde2e8eb..44c30fa904 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -848,7 +848,6 @@ struct tf_get_session_info_parms {
*/
int tf_get_session_info(struct tf *tfp,
struct tf_get_session_info_parms *parms);
-
/**
* Experimental
*
@@ -1594,6 +1593,8 @@ int tf_move_tcam_shared_entries(struct tf *tfp,
* @ref tf_get_tbl_entry
*
* @ref tf_bulk_get_tbl_entry
+ *
+ * @ref tf_get_shared_tbl_increment
*/
/**
@@ -1844,6 +1845,37 @@ struct tf_set_tbl_entry_parms {
int tf_set_tbl_entry(struct tf *tfp,
struct tf_set_tbl_entry_parms *parms);
+/**
+ * tf_get_shared_tbl_increment parameter definition
+ */
+struct tf_get_shared_tbl_increment_parms {
+ /**
+ * [in] Receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] Type of object to set
+ */
+ enum tf_tbl_type type;
+ /**
+ * [out] Value to increment by for resource type
+ */
+ uint32_t increment_cnt;
+};
+
+/**
+ * tf_get_shared_tbl_increment
+ *
+ * This API is currently only required for use in the shared
+ * session for Thor (p58) actions. An increment count is returned per
+ * type to indicate how much to increment the start by for each
+ * entry (see tf_resource_info)
+ *
+ * Returns success or failure code.
+ */
+int tf_get_shared_tbl_increment(struct tf *tfp,
+ struct tf_get_shared_tbl_increment_parms *parms);
+
/**
* tf_get_tbl_entry parameter definition
*/
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 48ab17d56b..1893f630e7 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -446,6 +446,23 @@ struct tf_dev_ops {
int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
struct tf_tbl_get_bulk_parms *parms);
+ /**
+ * Gets the increment value to add to the shared session resource
+ * start offset by for each count in the "stride"
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to get shared tbl increment parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+ int (*tf_dev_get_shared_tbl_increment)(struct tf *tfp,
+ struct tf_get_shared_tbl_increment_parms *parms);
+
/**
* Retrieves the table resource info.
*
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 67ef765236..239784897d 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -190,6 +190,26 @@ tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
return 0;
}
+/**
+ * Device specific function that retrieves the increment
+ * required for certain table types in a shared session
+ *
+ * [in] tfp
+ * tf handle
+ *
+ * [in/out] parms
+ * pointer to parms structure
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+static int tf_dev_p4_get_shared_tbl_increment(struct tf *tfp __rte_unused,
+ struct tf_get_shared_tbl_increment_parms *parms)
+{
+ parms->increment_cnt = 1;
+ return 0;
+}
static int tf_dev_p4_get_mailbox(void)
{
return TF_KONG_MB;
@@ -221,12 +241,16 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
.tf_dev_set_ext_tbl = NULL,
.tf_dev_get_tbl = NULL,
.tf_dev_get_bulk_tbl = NULL,
+ .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
.tf_dev_get_tbl_resc_info = NULL,
.tf_dev_alloc_tcam = NULL,
.tf_dev_free_tcam = NULL,
.tf_dev_alloc_search_tcam = NULL,
.tf_dev_set_tcam = NULL,
.tf_dev_get_tcam = NULL,
+#ifdef TF_TCAM_SHARED
+ .tf_dev_move_tcam = NULL,
+#endif /* TF_TCAM_SHARED */
.tf_dev_get_tcam_resc_info = NULL,
.tf_dev_insert_int_em_entry = NULL,
.tf_dev_delete_int_em_entry = NULL,
@@ -266,6 +290,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
.tf_dev_get_tbl = tf_tbl_get,
.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+ .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
#ifdef TF_TCAM_SHARED
.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index fd2703129f..483f771999 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -151,6 +151,48 @@ static int tf_dev_p58_word_align(uint16_t size)
return ((((size) + 63) >> 6) * 8);
}
+/**
+ * Device specific function that retrieves the increment
+ * required for certain table types in a shared session
+ *
+ * [in] tfp
+ * tf handle
+ *
+ * [in/out] parms
+ * pointer to parms structure
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+static int tf_dev_p58_get_shared_tbl_increment(struct tf *tfp __rte_unused,
+ struct tf_get_shared_tbl_increment_parms *parms)
+{
+ switch (parms->type) {
+ case TF_TBL_TYPE_FULL_ACT_RECORD:
+ case TF_TBL_TYPE_COMPACT_ACT_RECORD:
+ case TF_TBL_TYPE_ACT_ENCAP_8B:
+ case TF_TBL_TYPE_ACT_ENCAP_16B:
+ case TF_TBL_TYPE_ACT_ENCAP_32B:
+ case TF_TBL_TYPE_ACT_ENCAP_64B:
+ case TF_TBL_TYPE_ACT_SP_SMAC:
+ case TF_TBL_TYPE_ACT_SP_SMAC_IPV4:
+ case TF_TBL_TYPE_ACT_SP_SMAC_IPV6:
+ case TF_TBL_TYPE_ACT_STATS_64:
+ case TF_TBL_TYPE_ACT_MODIFY_IPV4:
+ case TF_TBL_TYPE_ACT_MODIFY_8B:
+ case TF_TBL_TYPE_ACT_MODIFY_16B:
+ case TF_TBL_TYPE_ACT_MODIFY_32B:
+ case TF_TBL_TYPE_ACT_MODIFY_64B:
+ parms->increment_cnt = 8;
+ break;
+ default:
+ parms->increment_cnt = 1;
+ break;
+ }
+ return 0;
+}
+
#define TF_DEV_P58_BANK_SZ_64B 2048
/**
* Get SRAM table information.
@@ -243,6 +285,7 @@ const struct tf_dev_ops tf_dev_ops_p58_init = {
.tf_dev_set_ext_tbl = NULL,
.tf_dev_get_tbl = NULL,
.tf_dev_get_bulk_tbl = NULL,
+ .tf_dev_get_shared_tbl_increment = tf_dev_p58_get_shared_tbl_increment,
.tf_dev_get_tbl_resc_info = NULL,
.tf_dev_alloc_tcam = NULL,
.tf_dev_free_tcam = NULL,
@@ -288,6 +331,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
.tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
.tf_dev_get_tbl = tf_tbl_get,
.tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
+ .tf_dev_get_shared_tbl_increment = tf_dev_p58_get_shared_tbl_increment,
.tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
#ifdef TF_TCAM_SHARED
.tf_dev_alloc_tcam = tf_tcam_shared_alloc,
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
index 0e8cb78f8d..f0727cea80 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
@@ -858,6 +858,10 @@ union tf_tmp_key {
uint8_t bytes[(TF_TMP_MAX_KEY_BITLEN + 7) / 8];
};
+/** p58 has an enable bit, p4 does not
+ */
+#define TF_TCAM_SHARED_ENTRY_ENABLE 0x8
+
/** Move a WC TCAM entry from the high offset to the same low offset
*/
static int
@@ -869,7 +873,8 @@ tf_tcam_shared_move_entry(struct tf *tfp,
int dphy_idx,
int key_sz_bytes,
int remap_sz_bytes,
- uint16_t num_slices)
+ uint16_t num_slices,
+ bool set_enable_bit)
{
int rc = 0;
struct tf_tcam_get_parms gparms;
@@ -911,6 +916,9 @@ tf_tcam_shared_move_entry(struct tf *tfp,
return rc;
}
+ if (set_enable_bit)
+ tcam_key_obj.bytes[0] |= TF_TCAM_SHARED_ENTRY_ENABLE;
+
/* Override HI/LO type with parent WC TCAM type */
sparms.hcapi_type = hcapi_type;
sparms.dir = dir;
@@ -960,7 +968,8 @@ static
int tf_tcam_shared_move(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms,
int key_sz_bytes,
- int remap_sz_bytes)
+ int remap_sz_bytes,
+ bool set_enable_bit)
{
int rc;
struct tf_session *tfs;
@@ -1084,7 +1093,8 @@ int tf_tcam_shared_move(struct tf *tfp,
lo_start + log_idx,
key_sz_bytes,
remap_sz_bytes,
- num_slices);
+ num_slices,
+ set_enable_bit);
if (rc) {
TFP_DRV_LOG(ERR,
"Cannot allocate %s index %d\n",
@@ -1125,7 +1135,8 @@ int tf_tcam_shared_move_p4(struct tf *tfp,
rc = tf_tcam_shared_move(tfp,
parms,
TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P4,
- TF_TCAM_SHARED_REMAP_SZ_BYTES_P4);
+ TF_TCAM_SHARED_REMAP_SZ_BYTES_P4,
+ false); /* no enable bit */
return rc;
}
@@ -1139,6 +1150,7 @@ int tf_tcam_shared_move_p58(struct tf *tfp,
rc = tf_tcam_shared_move(tfp,
parms,
TF_TCAM_SHARED_KEY_SLICE_SZ_BYTES_P58,
- TF_TCAM_SHARED_REMAP_SZ_BYTES_P58);
+ TF_TCAM_SHARED_REMAP_SZ_BYTES_P58,
+ true); /* set enable bit */
return rc;
}
--
2.21.1 (Apple Git-122.3)
More information about the dev
mailing list