[dpdk-dev] [PATCH 25/58] net/bnxt: add API to clear hi/lo WC region
Venkat Duvvuru
venkatkumar.duvvuru at broadcom.com
Sun May 30 10:58:56 CEST 2021
From: Farah Smith <farah.smith at broadcom.com>
Provide TRUFLOW API to clear either the hi or the low region
for ungraceful exit cleanup.
Signed-off-by: Farah Smith <farah.smith at broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher at broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru at broadcom.com>
Reviewed-by: Jay Ding <jay.ding at broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough at broadcom.com>
---
drivers/net/bnxt/tf_core/tf_core.c | 51 ++++++++++
drivers/net/bnxt/tf_core/tf_core.h | 39 +++++++-
drivers/net/bnxt/tf_core/tf_device.h | 19 +++-
drivers/net/bnxt/tf_core/tf_device_p4.c | 4 +-
drivers/net/bnxt/tf_core/tf_device_p58.c | 1 +
drivers/net/bnxt/tf_core/tf_tcam_shared.c | 111 +++++++++++++++++++++-
drivers/net/bnxt/tf_core/tf_tcam_shared.h | 21 ++++
drivers/net/bnxt/tf_core/tf_util.h | 1 -
8 files changed, 235 insertions(+), 12 deletions(-)
diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 0fbbd40252..97e6165e92 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -968,6 +968,57 @@ tf_move_tcam_shared_entries(struct tf *tfp,
return 0;
}
+
+int
+tf_clear_tcam_shared_entries(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms)
+{
+ int rc;
+ 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;
+ }
+
+ if (dev->ops->tf_dev_clear_tcam == NULL) {
+ rc = -EOPNOTSUPP;
+ TFP_DRV_LOG(ERR,
+ "%s: Operation not supported, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ rc = dev->ops->tf_dev_clear_tcam(tfp, parms);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM shared entries clear failed, rc:%s\n",
+ tf_dir_2_str(parms->dir),
+ strerror(-rc));
+ return rc;
+ }
+
+ return 0;
+}
#endif /* TF_TCAM_SHARED */
int
diff --git a/drivers/net/bnxt/tf_core/tf_core.h b/drivers/net/bnxt/tf_core/tf_core.h
index 44c30fa904..0b06bb2bb5 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -233,7 +233,7 @@ enum tf_identifier_type {
*/
TF_IDENT_TYPE_EM_PROF,
/**
- * TH
+ * (Future)
* The L2 func is included in the ILT result and from recycling to
* enable virtualization of further lookups.
*/
@@ -1244,6 +1244,8 @@ int tf_free_tbl_scope(struct tf *tfp,
*
#ifdef TF_TCAM_SHARED
* @ref tf_move_tcam_shared_entries
+ *
+ * @ref tf_clear_tcam_shared_entries
#endif
*/
@@ -1580,6 +1582,37 @@ struct tf_move_tcam_shared_entries_parms {
int tf_move_tcam_shared_entries(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms);
+/**
+ * tf_clear_tcam_shared_entries parameter definition
+ */
+struct tf_clear_tcam_shared_entries_parms {
+ /**
+ * [in] receive or transmit direction
+ */
+ enum tf_dir dir;
+ /**
+ * [in] TCAM table type
+ */
+ enum tf_tcam_tbl_type tcam_tbl_type;
+};
+
+/**
+ * Clear TCAM shared entries pool
+ *
+ * This API only affects the following TCAM pools within a shared session:
+ *
+ * TF_TCAM_TBL_TYPE_WC_TCAM_HIGH
+ * TF_TCAM_TBL_TYPE_WC_TCAM_LOW
+ *
+ * When called, the indicated WC TCAM high or low pool will be cleared.
+ *
+ * This API is not supported on a non-shared session.
+ *
+ * Returns success or failure code.
+ */
+int tf_clear_tcam_shared_entries(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms);
+
#endif /* TF_TCAM_SHARED */
/**
* @page table Table Access
@@ -2108,7 +2141,7 @@ struct tf_move_em_entry_parms {
uint64_t flow_handle;
};
/**
- * tf_search_em_entry parameter definition
+ * tf_search_em_entry parameter definition (Future)
*/
struct tf_search_em_entry_parms {
/**
@@ -2211,7 +2244,7 @@ int tf_delete_em_entry(struct tf *tfp,
struct tf_delete_em_entry_parms *parms);
/**
- * search em hash entry table memory
+ * search em hash entry table memory (Future)
*
* Internal:
diff --git a/drivers/net/bnxt/tf_core/tf_device.h b/drivers/net/bnxt/tf_core/tf_device.h
index 1893f630e7..da3f541685 100644
--- a/drivers/net/bnxt/tf_core/tf_device.h
+++ b/drivers/net/bnxt/tf_core/tf_device.h
@@ -595,7 +595,24 @@ struct tf_dev_ops {
* -EINVAL - Error
*/
int (*tf_dev_move_tcam)(struct tf *tfp,
- struct tf_move_tcam_shared_entries_parms *parms);
+ struct tf_move_tcam_shared_entries_parms *parms);
+
+ /**
+ * Move TCAM shared entries
+ *
+ * [in] tfp
+ * Pointer to TF handle
+ *
+ * [in] parms
+ * Pointer to parameters
+ *
+ * returns:
+ * 0 - Success
+ * -EINVAL - Error
+ */
+ int (*tf_dev_clear_tcam)(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms);
+
#endif /* TF_TCAM_SHARED */
/**
diff --git a/drivers/net/bnxt/tf_core/tf_device_p4.c b/drivers/net/bnxt/tf_core/tf_device_p4.c
index 28a6e41906..c340098cde 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p4.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p4.c
@@ -251,9 +251,6 @@ const struct tf_dev_ops tf_dev_ops_p4_init = {
.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,
@@ -301,6 +298,7 @@ const struct tf_dev_ops tf_dev_ops_p4 = {
.tf_dev_set_tcam = tf_tcam_shared_set,
.tf_dev_get_tcam = tf_tcam_shared_get,
.tf_dev_move_tcam = tf_tcam_shared_move_p4,
+ .tf_dev_clear_tcam = tf_tcam_shared_clear,
#else /* !TF_TCAM_SHARED */
.tf_dev_alloc_tcam = tf_tcam_alloc,
.tf_dev_free_tcam = tf_tcam_free,
diff --git a/drivers/net/bnxt/tf_core/tf_device_p58.c b/drivers/net/bnxt/tf_core/tf_device_p58.c
index bd6813beef..77a884f645 100644
--- a/drivers/net/bnxt/tf_core/tf_device_p58.c
+++ b/drivers/net/bnxt/tf_core/tf_device_p58.c
@@ -342,6 +342,7 @@ const struct tf_dev_ops tf_dev_ops_p58 = {
.tf_dev_set_tcam = tf_tcam_shared_set,
.tf_dev_get_tcam = tf_tcam_shared_get,
.tf_dev_move_tcam = tf_tcam_shared_move_p58,
+ .tf_dev_clear_tcam = tf_tcam_shared_clear,
#else /* !TF_TCAM_SHARED */
.tf_dev_alloc_tcam = tf_tcam_alloc,
.tf_dev_free_tcam = tf_tcam_free,
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.c b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
index b96d9ca9dd..c1c94829d7 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.c
@@ -1154,8 +1154,9 @@ int tf_tcam_shared_move(struct tf *tfp,
return rc;
}
-int tf_tcam_shared_move_p4(struct tf *tfp,
- struct tf_move_tcam_shared_entries_parms *parms)
+int
+tf_tcam_shared_move_p4(struct tf *tfp,
+ struct tf_move_tcam_shared_entries_parms *parms)
{
int rc = 0;
rc = tf_tcam_shared_move(tfp,
@@ -1167,8 +1168,9 @@ int tf_tcam_shared_move_p4(struct tf *tfp,
}
-int tf_tcam_shared_move_p58(struct tf *tfp,
- struct tf_move_tcam_shared_entries_parms *parms)
+int
+tf_tcam_shared_move_p58(struct tf *tfp,
+ struct tf_move_tcam_shared_entries_parms *parms)
{
int rc = 0;
rc = tf_tcam_shared_move(tfp,
@@ -1178,3 +1180,104 @@ int tf_tcam_shared_move_p58(struct tf *tfp,
true); /* set enable bit */
return rc;
}
+
+int
+tf_tcam_shared_clear(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms)
+{
+ int rc = 0;
+ struct tf_session *tfs;
+ struct tf_dev_info *dev;
+ uint16_t start;
+ int phy_idx;
+ enum tf_tcam_shared_wc_pool_id id;
+ struct tf_tcam_free_parms nparms;
+ uint16_t hcapi_type;
+ struct tf_rm_alloc_info info;
+ void *tcam_shared_db_ptr = NULL;
+ struct tf_tcam_shared_wc_pools *tcam_shared_wc;
+ int i, cnt;
+
+ TF_CHECK_PARMS2(tfp, parms);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ if (!tf_session_is_shared_session(tfs) ||
+ (parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_HIGH &&
+ parms->tcam_tbl_type != TF_TCAM_TBL_TYPE_WC_TCAM_LOW))
+ return -EOPNOTSUPP;
+
+ if (!tf_tcam_db_valid(tfp, parms->dir)) {
+ TFP_DRV_LOG(ERR,
+ "%s: tcam shared pool doesn't exist\n",
+ tf_dir_2_str(parms->dir));
+ return -ENOMEM;
+ }
+
+ rc = tf_session_get_tcam_shared_db(tfp, (void *)&tcam_shared_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get tcam_shared_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_shared_wc = (struct tf_tcam_shared_wc_pools *)tcam_shared_db_ptr;
+
+
+ if (parms->tcam_tbl_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH)
+ id = TF_TCAM_SHARED_WC_POOL_HI;
+ else
+ id = TF_TCAM_SHARED_WC_POOL_LO;
+
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc)
+ return rc;
+
+ rc = tf_tcam_shared_get_rm_info(tfp,
+ parms->dir,
+ &hcapi_type,
+ &info);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: TCAM rm info get failed\n",
+ tf_dir_2_str(parms->dir));
+ return rc;
+ }
+
+ start = tcam_shared_wc->db[parms->dir][id].info.start;
+ cnt = tcam_shared_wc->db[parms->dir][id].info.stride;
+
+ /* Override HI/LO type with parent WC TCAM type */
+ nparms.dir = parms->dir;
+ nparms.type = TF_TCAM_TBL_TYPE_WC_TCAM;
+ nparms.hcapi_type = hcapi_type;
+
+ for (i = 0; i < cnt; i++) {
+ phy_idx = start + i;
+ nparms.idx = phy_idx;
+
+ /* Clear entry */
+ rc = tf_msg_tcam_entry_free(tfp, dev, &nparms);
+ if (rc) {
+ /* Log error */
+ TFP_DRV_LOG(ERR,
+ "%s: %s: log%d free failed, rc:%s\n",
+ tf_dir_2_str(nparms.dir),
+ tf_tcam_tbl_2_str(nparms.type),
+ phy_idx,
+ strerror(-rc));
+ return rc;
+ }
+ }
+
+ TFP_DRV_LOG(DEBUG,
+ "%s: TCAM shared clear pool(%s)\n",
+ tf_dir_2_str(nparms.dir),
+ tf_pool_2_str(id));
+ return 0;
+}
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_shared.h b/drivers/net/bnxt/tf_core/tf_tcam_shared.h
index 5588125470..020763af6b 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_shared.h
+++ b/drivers/net/bnxt/tf_core/tf_tcam_shared.h
@@ -24,6 +24,11 @@
*
* @ref tf_tcam_shared_get
*
+ * @ref tf_tcam_shared_move_p4
+ *
+ * @ref tf_tcam_shared_move_p58
+ *
+ * @ref tf_tcam_shared_clear
*/
/**
@@ -159,4 +164,20 @@ int tf_tcam_shared_move_p4(struct tf *tfp,
int tf_tcam_shared_move_p58(struct tf *tfp,
struct tf_move_tcam_shared_entries_parms *parms);
+/**
+ * Allocates and clears the entire WC_TCAM_HI or WC_TCAM_LO shared pools
+ *
+ * [in] tfp
+ * Pointer to the truflow handle
+ *
+ * [in] parms
+ * Pointer to parameters
+ *
+ * Returns
+ * - (0) if successful.
+ * - (-EINVAL) on failure.
+ */
+int tf_tcam_shared_clear(struct tf *tfp,
+ struct tf_clear_tcam_shared_entries_parms *parms);
+
#endif /* _TF_TCAM_SHARED_H */
diff --git a/drivers/net/bnxt/tf_core/tf_util.h b/drivers/net/bnxt/tf_core/tf_util.h
index 4caf50349d..854c51931a 100644
--- a/drivers/net/bnxt/tf_core/tf_util.h
+++ b/drivers/net/bnxt/tf_core/tf_util.h
@@ -7,7 +7,6 @@
#define _TF_UTIL_H_
#include "tf_core.h"
-#include "tf_device.h"
#define TF_BITS2BYTES(x) (((x) + 7) >> 3)
#define TF_BITS2BYTES_WORD_ALIGN(x) ((((x) + 31) >> 5) * 4)
--
2.17.1
More information about the dev
mailing list