@@ -573,7 +573,7 @@ tf_free_tcam_entry(struct tf *tfp,
rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
if (rc) {
TFP_DRV_LOG(ERR,
- "%s: TCAM allocation failed, rc:%s\n",
+ "%s: TCAM free failed, rc:%s\n",
tf_dir_2_str(parms->dir),
strerror(-rc));
return rc;
@@ -9,7 +9,6 @@
#include "tf_core.h"
#include "tf_session.h"
-#define TF_HACK_TBL_SCOPE_BASE 68
#define SUPPORT_CFA_HW_P4 1
#define SUPPORT_CFA_HW_P58 0
#define SUPPORT_CFA_HW_P59 0
@@ -29,6 +29,8 @@
*/
void *eem_db[TF_DIR_MAX];
+#define TF_EEM_DB_TBL_SCOPE 1
+
/**
* Init flag, set on bind and cleared on unbind
*/
@@ -39,10 +41,12 @@ static uint8_t init;
*/
static enum tf_mem_type mem_type;
+/** Table scope array */
+struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
+
/* API defined in tf_em.h */
struct tf_tbl_scope_cb *
-tbl_scope_cb_find(struct tf_session *session,
- uint32_t tbl_scope_id)
+tbl_scope_cb_find(uint32_t tbl_scope_id)
{
int i;
struct tf_rm_is_allocated_parms parms;
@@ -50,8 +54,8 @@ tbl_scope_cb_find(struct tf_session *session,
/* Check that id is valid */
parms.rm_db = eem_db[TF_DIR_RX];
- parms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
- parms.index = tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+ parms.db_index = TF_EEM_DB_TBL_SCOPE;
+ parms.index = tbl_scope_id;
parms.allocated = &allocated;
i = tf_rm_is_allocated(&parms);
@@ -60,8 +64,8 @@ tbl_scope_cb_find(struct tf_session *session,
return NULL;
for (i = 0; i < TF_NUM_TBL_SCOPE; i++) {
- if (session->tbl_scopes[i].tbl_scope_id == tbl_scope_id)
- return &session->tbl_scopes[i];
+ if (tbl_scopes[i].tbl_scope_id == tbl_scope_id)
+ return &tbl_scopes[i];
}
return NULL;
@@ -14,8 +14,6 @@
* Function to search for table scope control block structure
* with specified table scope ID.
*
- * [in] session
- * Session to use for the search of the table scope control block
* [in] tbl_scope_id
* Table scope ID to search for
*
@@ -23,8 +21,7 @@
* Pointer to the found table scope control block struct or NULL if
* table scope control block struct not found
*/
-struct tf_tbl_scope_cb *tbl_scope_cb_find(struct tf_session *session,
- uint32_t tbl_scope_id);
+struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
/**
* Create and initialize a stack to use for action entries
@@ -48,6 +48,9 @@
* EM DBs.
*/
extern void *eem_db[TF_DIR_MAX];
+#define TF_EEM_DB_TBL_SCOPE 1
+
+extern struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
/**
* Function to free a page table
@@ -934,14 +937,12 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
* -EINVAL - Error
*/
int
-tf_em_insert_ext_entry(struct tf *tfp,
+tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
struct tf_insert_em_entry_parms *parms)
{
struct tf_tbl_scope_cb *tbl_scope_cb;
- tbl_scope_cb =
- tbl_scope_cb_find((struct tf_session *)(tfp->session->core_data),
- parms->tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
return -EINVAL;
@@ -957,14 +958,12 @@ tf_em_insert_ext_entry(struct tf *tfp,
* -EINVAL - Error
*/
int
-tf_em_delete_ext_entry(struct tf *tfp,
+tf_em_delete_ext_entry(struct tf *tfp __rte_unused,
struct tf_delete_em_entry_parms *parms)
{
struct tf_tbl_scope_cb *tbl_scope_cb;
- tbl_scope_cb =
- tbl_scope_cb_find((struct tf_session *)(tfp->session->core_data),
- parms->tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
return -EINVAL;
@@ -981,16 +980,13 @@ tf_em_ext_host_alloc(struct tf *tfp,
enum tf_dir dir;
struct tf_tbl_scope_cb *tbl_scope_cb;
struct hcapi_cfa_em_table *em_tables;
- struct tf_session *session;
struct tf_free_tbl_scope_parms free_parms;
struct tf_rm_allocate_parms aparms = { 0 };
struct tf_rm_free_parms fparms = { 0 };
- session = (struct tf_session *)tfp->session->core_data;
-
/* Get Table Scope control block from the session pool */
aparms.rm_db = eem_db[TF_DIR_RX];
- aparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
+ aparms.db_index = TF_EEM_DB_TBL_SCOPE;
aparms.index = (uint32_t *)&parms->tbl_scope_id;
rc = tf_rm_allocate(&aparms);
if (rc) {
@@ -999,8 +995,7 @@ tf_em_ext_host_alloc(struct tf *tfp,
return rc;
}
- parms->tbl_scope_id -= TF_HACK_TBL_SCOPE_BASE;
- tbl_scope_cb = &session->tbl_scopes[parms->tbl_scope_id];
+ tbl_scope_cb = &tbl_scopes[parms->tbl_scope_id];
tbl_scope_cb->index = parms->tbl_scope_id;
tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id;
@@ -1092,8 +1087,8 @@ tf_em_ext_host_alloc(struct tf *tfp,
cleanup:
/* Free Table control block */
fparms.rm_db = eem_db[TF_DIR_RX];
- fparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
- fparms.index = parms->tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+ fparms.db_index = TF_EEM_DB_TBL_SCOPE;
+ fparms.index = parms->tbl_scope_id;
tf_rm_free(&fparms);
return -EINVAL;
}
@@ -1105,13 +1100,9 @@ tf_em_ext_host_free(struct tf *tfp,
int rc = 0;
enum tf_dir dir;
struct tf_tbl_scope_cb *tbl_scope_cb;
- struct tf_session *session;
struct tf_rm_free_parms aparms = { 0 };
- session = (struct tf_session *)(tfp->session->core_data);
-
- tbl_scope_cb = tbl_scope_cb_find(session,
- parms->tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
TFP_DRV_LOG(ERR, "Table scope error\n");
@@ -1120,8 +1111,8 @@ tf_em_ext_host_free(struct tf *tfp,
/* Free Table control block */
aparms.rm_db = eem_db[TF_DIR_RX];
- aparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
- aparms.index = parms->tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+ aparms.db_index = TF_EEM_DB_TBL_SCOPE;
+ aparms.index = parms->tbl_scope_id;
rc = tf_rm_free(&aparms);
if (rc) {
TFP_DRV_LOG(ERR,
@@ -1142,5 +1133,6 @@ tf_em_ext_host_free(struct tf *tfp,
tf_em_ctx_unreg(tfp, tbl_scope_cb, dir);
}
+ tbl_scopes[parms->tbl_scope_id].tbl_scope_id = -1;
return rc;
}
@@ -63,14 +63,12 @@ tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb __rte_unused,
* -EINVAL - Error
*/
int
-tf_em_insert_ext_sys_entry(struct tf *tfp,
+tf_em_insert_ext_sys_entry(struct tf *tfp __rte_unused,
struct tf_insert_em_entry_parms *parms)
{
struct tf_tbl_scope_cb *tbl_scope_cb;
- tbl_scope_cb = tbl_scope_cb_find
- ((struct tf_session *)(tfp->session->core_data),
- parms->tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
return -EINVAL;
@@ -87,14 +85,12 @@ tf_em_insert_ext_sys_entry(struct tf *tfp,
* -EINVAL - Error
*/
int
-tf_em_delete_ext_sys_entry(struct tf *tfp,
+tf_em_delete_ext_sys_entry(struct tf *tfp __rte_unused,
struct tf_delete_em_entry_parms *parms)
{
struct tf_tbl_scope_cb *tbl_scope_cb;
- tbl_scope_cb = tbl_scope_cb_find
- ((struct tf_session *)(tfp->session->core_data),
- parms->tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
return -EINVAL;
@@ -100,9 +100,6 @@ struct tf_session {
/** Device handle */
struct tf_dev_info dev;
-
- /** Table scope array */
- struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
};
/**
@@ -287,7 +287,8 @@ tf_tcam_free(struct tf *tfp,
rc = tf_msg_tcam_entry_free(tfp, parms);
if (rc) {
/* Log error */
- TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+ TFP_DRV_LOG(ERR,
+ "%s: %s: Entry %d free failed, rc:%s\n",
tf_dir_2_str(parms->dir),
tf_tcam_tbl_2_str(parms->type),
parms->idx,
@@ -382,7 +383,8 @@ tf_tcam_set(struct tf *tfp __rte_unused,
rc = tf_msg_tcam_entry_set(tfp, parms);
if (rc) {
/* Log error */
- TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+ TFP_DRV_LOG(ERR,
+ "%s: %s: Entry %d set failed, rc:%s",
tf_dir_2_str(parms->dir),
tf_tcam_tbl_2_str(parms->type),
parms->idx,