enum tf_mem_type mem_type;
};
+/**
+ * EM database
+ *
+ * EM rm database
+ *
+ */
+struct em_rm_db {
+ struct rm_db *em_db[TF_DIR_MAX];
+};
+
/**
* @page em EM
*
#include "bnxt.h"
-/**
- * EM DBs.
- */
-static void *em_db[TF_DIR_MAX];
-
#define TF_EM_DB_EM_REC 0
/**
uint8_t db_exists = 0;
struct tf_rm_get_alloc_info_parms iparms;
struct tf_rm_alloc_info info;
+ struct em_rm_db *em_db;
+ struct tfp_calloc_parms cparms;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
+ memset(&db_cfg, 0, sizeof(db_cfg));
+ cparms.nitems = 1;
+ cparms.size = sizeof(struct em_rm_db);
+ cparms.alignment = 0;
+ if (tfp_calloc(&cparms) != 0) {
+ TFP_DRV_LOG(ERR, "em_rm_db alloc error %s\n",
+ strerror(ENOMEM));
+ return -ENOMEM;
+ }
+
+ em_db = cparms.mem_va;
+ for (i = 0; i < TF_DIR_MAX; i++)
+ em_db->em_db[i] = NULL;
+ tf_session_set_db(tfp, TF_MODULE_TYPE_EM, em_db);
+
db_cfg.module = TF_MODULE_TYPE_EM;
db_cfg.num_elements = parms->num_elements;
db_cfg.cfg = parms->cfg;
return rc;
}
- db_cfg.rm_db = &em_db[i];
+ db_cfg.rm_db = (void *)&em_db->em_db[i];
+
rc = tf_rm_create_db(tfp, &db_cfg);
if (rc) {
TFP_DRV_LOG(ERR,
init = 1;
for (i = 0; i < TF_DIR_MAX; i++) {
- iparms.rm_db = em_db[i];
+ iparms.rm_db = em_db->em_db[i];
iparms.subtype = TF_EM_DB_EM_REC;
iparms.info = &info;
int rc;
int i;
struct tf_rm_free_db_parms fparms = { 0 };
+ struct em_rm_db *em_db;
+ void *em_db_ptr = NULL;
TF_CHECK_PARMS1(tfp);
for (i = 0; i < TF_DIR_MAX; i++)
tf_free_em_pool(i);
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_EM, &em_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ em_db = (struct em_rm_db *)em_db_ptr;
+
for (i = 0; i < TF_DIR_MAX; i++) {
fparms.dir = i;
- fparms.rm_db = em_db[i];
- if (em_db[i] != NULL) {
+ fparms.rm_db = em_db->em_db[i];
+ if (em_db->em_db[i] != NULL) {
rc = tf_rm_free_db(tfp, &fparms);
if (rc)
return rc;
}
- em_db[i] = NULL;
+ em_db->em_db[i] = NULL;
}
init = 0;
#include "tf_rm.h"
#include "tf_util.h"
#include "tfp.h"
+#include "tf_session.h"
struct tf;
-/**
- * Identifier DBs.
- */
-static void *ident_db[TF_DIR_MAX];
-
/**
* Init flag, set on bind and cleared on unbind
*/
struct tf_rm_create_db_parms db_cfg = { 0 };
struct tf_shadow_ident_cfg_parms shadow_cfg = { 0 };
struct tf_shadow_ident_create_db_parms shadow_cdb = { 0 };
+ struct ident_rm_db *ident_db;
+ struct tfp_calloc_parms cparms;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
+ memset(&db_cfg, 0, sizeof(db_cfg));
+ cparms.nitems = 1;
+ cparms.size = sizeof(struct ident_rm_db);
+ cparms.alignment = 0;
+ if (tfp_calloc(&cparms) != 0) {
+ TFP_DRV_LOG(ERR, "ident_rm_db alloc error %s\n",
+ strerror(ENOMEM));
+ return -ENOMEM;
+ }
+
+ ident_db = cparms.mem_va;
+ for (i = 0; i < TF_DIR_MAX; i++)
+ ident_db->ident_db[i] = NULL;
+ tf_session_set_db(tfp, TF_MODULE_TYPE_IDENTIFIER, ident_db);
+
db_cfg.module = TF_MODULE_TYPE_IDENTIFIER;
db_cfg.num_elements = parms->num_elements;
db_cfg.cfg = parms->cfg;
for (i = 0; i < TF_DIR_MAX; i++) {
+ db_cfg.rm_db = (void *)&ident_db->ident_db[i];
db_cfg.dir = i;
db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
- db_cfg.rm_db = &ident_db[i];
rc = tf_rm_create_db(tfp, &db_cfg);
if (rc) {
TFP_DRV_LOG(ERR,
int i;
struct tf_rm_free_db_parms fparms = { 0 };
struct tf_shadow_ident_free_db_parms sparms = { 0 };
+ struct ident_rm_db *ident_db;
+ void *ident_db_ptr = NULL;
TF_CHECK_PARMS1(tfp);
return 0;
}
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get ident_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ ident_db = (struct ident_rm_db *)ident_db_ptr;
+
for (i = 0; i < TF_DIR_MAX; i++) {
+ fparms.rm_db = ident_db->ident_db[i];
fparms.dir = i;
- fparms.rm_db = ident_db[i];
rc = tf_rm_free_db(tfp, &fparms);
if (rc) {
TFP_DRV_LOG(ERR,
}
ident_shadow_db[i] = NULL;
}
- ident_db[i] = NULL;
+ ident_db->ident_db[i] = NULL;
}
init = 0;
uint32_t base_id;
struct tf_rm_allocate_parms aparms = { 0 };
struct tf_shadow_ident_insert_parms iparms = { 0 };
+ struct ident_rm_db *ident_db;
+ void *ident_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
- /* Allocate requested element */
- aparms.rm_db = ident_db[parms->dir];
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get ident_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ ident_db = (struct ident_rm_db *)ident_db_ptr;
+
+ aparms.rm_db = ident_db->ident_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = &id;
aparms.base_index = &base_id;
struct tf_shadow_ident_remove_parms rparms = { 0 };
int allocated = 0;
uint32_t base_id;
+ struct ident_rm_db *ident_db;
+ void *ident_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get ident_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ ident_db = (struct ident_rm_db *)ident_db_ptr;
+
/* Check if element is in use */
- aparms.rm_db = ident_db[parms->dir];
+ aparms.rm_db = ident_db->ident_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = parms->id;
aparms.base_index = &base_id;
}
/* Free requested element */
- fparms.rm_db = ident_db[parms->dir];
+ fparms.rm_db = ident_db->ident_db[parms->dir];
fparms.subtype = parms->type;
fparms.index = parms->id;
rc = tf_rm_free(&fparms);
struct tf_shadow_ident_search_parms sparms = { 0 };
int allocated = 0;
uint32_t base_id;
+ struct ident_rm_db *ident_db;
+ void *ident_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get ident_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ ident_db = (struct ident_rm_db *)ident_db_ptr;
+
/* Check if element is in use */
- aparms.rm_db = ident_db[parms->dir];
+ aparms.rm_db = ident_db->ident_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = parms->search_id;
aparms.base_index = &base_id;
uint32_t *ref_cnt;
};
+/**
+ * Identifier database
+ *
+ * Identifier rm database
+ *
+ */
+struct ident_rm_db {
+ struct rm_db *ident_db[TF_DIR_MAX];
+};
+
/**
* @page ident Identity Management
*
struct tf;
-/**
- * Table DBs.
- */
-static void *tbl_db[TF_DIR_MAX];
-
/**
* Table Shadow DBs
*/
tf_tbl_bind(struct tf *tfp,
struct tf_tbl_cfg_parms *parms)
{
- int rc, d;
+ int rc, d, i;
struct tf_rm_create_db_parms db_cfg = { 0 };
+ struct tbl_rm_db *tbl_db;
+ struct tfp_calloc_parms cparms;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
+ memset(&db_cfg, 0, sizeof(db_cfg));
+ cparms.nitems = 1;
+ cparms.size = sizeof(struct tbl_rm_db);
+ cparms.alignment = 0;
+ if (tfp_calloc(&cparms) != 0) {
+ TFP_DRV_LOG(ERR, "tbl_rm_db alloc error %s\n",
+ strerror(ENOMEM));
+ return -ENOMEM;
+ }
+
+ tbl_db = cparms.mem_va;
+ for (i = 0; i < TF_DIR_MAX; i++)
+ tbl_db->tbl_db[i] = NULL;
+ tf_session_set_db(tfp, TF_MODULE_TYPE_TABLE, tbl_db);
+
db_cfg.num_elements = parms->num_elements;
db_cfg.module = TF_MODULE_TYPE_TABLE;
db_cfg.num_elements = parms->num_elements;
for (d = 0; d < TF_DIR_MAX; d++) {
db_cfg.dir = d;
db_cfg.alloc_cnt = parms->resources->tbl_cnt[d].cnt;
- db_cfg.rm_db = &tbl_db[d];
+ db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
+
rc = tf_rm_create_db(tfp, &db_cfg);
if (rc) {
TFP_DRV_LOG(ERR,
return rc;
}
}
-
init = 1;
TFP_DRV_LOG(INFO,
int rc;
int i;
struct tf_rm_free_db_parms fparms = { 0 };
+ struct tbl_rm_db *tbl_db;
+ void *tbl_db_ptr = NULL;
TF_CHECK_PARMS1(tfp);
/* Bail if nothing has been initialized */
return 0;
}
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
for (i = 0; i < TF_DIR_MAX; i++) {
fparms.dir = i;
- fparms.rm_db = tbl_db[i];
+ fparms.rm_db = tbl_db->tbl_db[i];
rc = tf_rm_free_db(tfp, &fparms);
if (rc)
return rc;
- tbl_db[i] = NULL;
+ tbl_db->tbl_db[i] = NULL;
}
init = 0;
struct tf_session *tfs;
struct tf_dev_info *dev;
uint16_t base = 0, shift = 0;
+ struct tbl_rm_db *tbl_db;
+ void *tbl_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
/* Only get table info if required for the device */
if (dev->ops->tf_dev_get_tbl_info) {
- rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
- parms->type, &base, &shift);
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[parms->dir],
+ parms->type,
+ &base,
+ &shift);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to get table info:%d\n",
}
/* Allocate requested element */
- aparms.rm_db = tbl_db[parms->dir];
+ aparms.rm_db = tbl_db->tbl_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = &idx;
rc = tf_rm_allocate(&aparms);
struct tf_session *tfs;
struct tf_dev_info *dev;
uint16_t base = 0, shift = 0;
+ struct tbl_rm_db *tbl_db;
+ void *tbl_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
/* Only get table info if required for the device */
if (dev->ops->tf_dev_get_tbl_info) {
- rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
- parms->type, &base, &shift);
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[parms->dir],
+ parms->type,
+ &base,
+ &shift);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to get table info:%d\n",
}
/* Check if element is in use */
- aparms.rm_db = tbl_db[parms->dir];
+ aparms.rm_db = tbl_db->tbl_db[parms->dir];
aparms.subtype = parms->type;
TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
return -EINVAL;
}
/* Free requested element */
- fparms.rm_db = tbl_db[parms->dir];
+ fparms.rm_db = tbl_db->tbl_db[parms->dir];
fparms.subtype = parms->type;
TF_TBL_PTR_TO_RM(&fparms.index, parms->idx, base, shift);
struct tf_session *tfs;
struct tf_dev_info *dev;
uint16_t base = 0, shift = 0;
+ struct tbl_rm_db *tbl_db;
+ void *tbl_db_ptr = NULL;
TF_CHECK_PARMS3(tfp, parms, parms->data);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
/* Only get table info if required for the device */
if (dev->ops->tf_dev_get_tbl_info) {
- rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
- parms->type, &base, &shift);
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[parms->dir],
+ parms->type,
+ &base,
+ &shift);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to get table info:%d\n",
}
/* Verify that the entry has been previously allocated */
- aparms.rm_db = tbl_db[parms->dir];
+ aparms.rm_db = tbl_db->tbl_db[parms->dir];
aparms.subtype = parms->type;
TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
}
/* Set the entry */
- hparms.rm_db = tbl_db[parms->dir];
+ hparms.rm_db = tbl_db->tbl_db[parms->dir];
hparms.subtype = parms->type;
hparms.hcapi_type = &hcapi_type;
rc = tf_rm_get_hcapi_type(&hparms);
struct tf_session *tfs;
struct tf_dev_info *dev;
uint16_t base = 0, shift = 0;
+ struct tbl_rm_db *tbl_db;
+ void *tbl_db_ptr = NULL;
TF_CHECK_PARMS3(tfp, parms, parms->data);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
/* Only get table info if required for the device */
if (dev->ops->tf_dev_get_tbl_info) {
- rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
- parms->type, &base, &shift);
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[parms->dir],
+ parms->type,
+ &base,
+ &shift);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to get table info:%d\n",
}
/* Verify that the entry has been previously allocated */
- aparms.rm_db = tbl_db[parms->dir];
+ aparms.rm_db = tbl_db->tbl_db[parms->dir];
aparms.subtype = parms->type;
TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
}
/* Set the entry */
- hparms.rm_db = tbl_db[parms->dir];
+ hparms.rm_db = tbl_db->tbl_db[parms->dir];
hparms.subtype = parms->type;
hparms.hcapi_type = &hcapi_type;
rc = tf_rm_get_hcapi_type(&hparms);
struct tf_session *tfs;
struct tf_dev_info *dev;
uint16_t base = 0, shift = 0;
+ struct tbl_rm_db *tbl_db;
+ void *tbl_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
/* Only get table info if required for the device */
if (dev->ops->tf_dev_get_tbl_info) {
- rc = dev->ops->tf_dev_get_tbl_info(tfp, tbl_db[parms->dir],
- parms->type, &base, &shift);
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[parms->dir],
+ parms->type,
+ &base,
+ &shift);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Failed to get table info:%d\n",
}
/* Verify that the entries are in the range of reserved resources. */
- cparms.rm_db = tbl_db[parms->dir];
+ cparms.rm_db = tbl_db->tbl_db[parms->dir];
cparms.subtype = parms->type;
TF_TBL_PTR_TO_RM(&cparms.starting_index, parms->starting_idx,
return rc;
}
- hparms.rm_db = tbl_db[parms->dir];
+ hparms.rm_db = tbl_db->tbl_db[parms->dir];
hparms.subtype = parms->type;
hparms.hcapi_type = &hcapi_type;
rc = tf_rm_get_hcapi_type(&hparms);
uint64_t physical_mem_addr;
};
+/**
+ * Table RM database
+ *
+ * Table rm database
+ *
+ */
+struct tbl_rm_db {
+ struct rm_db *tbl_db[TF_DIR_MAX];
+};
+
/**
* @page tbl Table
*
struct tf;
-/**
- * TCAM DBs.
- */
-static void *tcam_db[TF_DIR_MAX];
-
/**
* TCAM Shadow DBs
*/
uint16_t num_slices = 1;
struct tf_session *tfs;
struct tf_dev_info *dev;
+ struct tcam_rm_db *tcam_db;
+ struct tfp_calloc_parms cparms;
TF_CHECK_PARMS2(tfp, parms);
}
memset(&db_cfg, 0, sizeof(db_cfg));
+ cparms.nitems = 1;
+ cparms.size = sizeof(struct tcam_rm_db);
+ cparms.alignment = 0;
+ if (tfp_calloc(&cparms) != 0) {
+ TFP_DRV_LOG(ERR, "tcam_rm_db alloc error %s\n",
+ strerror(ENOMEM));
+ return -ENOMEM;
+ }
+
+ tcam_db = cparms.mem_va;
+ for (i = 0; i < TF_DIR_MAX; i++)
+ tcam_db->tcam_db[i] = NULL;
+ tf_session_set_db(tfp, TF_MODULE_TYPE_TCAM, tcam_db);
db_cfg.module = TF_MODULE_TYPE_TCAM;
db_cfg.num_elements = parms->num_elements;
for (d = 0; d < TF_DIR_MAX; d++) {
db_cfg.dir = d;
db_cfg.alloc_cnt = parms->resources->tcam_cnt[d].cnt;
- db_cfg.rm_db = &tcam_db[d];
+ db_cfg.rm_db = (void *)&tcam_db->tcam_db[d];
rc = tf_rm_create_db(tfp, &db_cfg);
if (rc) {
TFP_DRV_LOG(ERR,
/* check if reserved resource for WC is multiple of num_slices */
for (d = 0; d < TF_DIR_MAX; d++) {
memset(&info, 0, sizeof(info));
- ainfo.rm_db = tcam_db[d];
+ ainfo.rm_db = tcam_db->tcam_db[d];
ainfo.subtype = TF_TCAM_TBL_TYPE_WC_TCAM;
ainfo.info = &info;
rc = tf_rm_get_info(&ainfo);
if (!parms->resources->tcam_cnt[d].cnt[i])
continue;
- ainfo.rm_db = tcam_db[d];
+ ainfo.rm_db = tcam_db->tcam_db[d];
ainfo.subtype = i;
ainfo.info = &info;
rc = tf_rm_get_info(&ainfo);
for (i = 0; i < TF_DIR_MAX; i++) {
memset(&fparms, 0, sizeof(fparms));
fparms.dir = i;
- fparms.rm_db = tcam_db[i];
+ fparms.rm_db = tcam_db->tcam_db[i];
/* Ignoring return here since we are in the error case */
(void)tf_rm_free_db(tfp, &fparms);
shadow_tcam_db[i] = NULL;
}
- tcam_db[i] = NULL;
+ tcam_db->tcam_db[i] = NULL;
+ tf_session_set_db(tfp, TF_MODULE_TYPE_TCAM, NULL);
}
shadow_init = 0;
int rc;
int i;
struct tf_rm_free_db_parms fparms;
+ struct tcam_rm_db *tcam_db;
+ void *tcam_db_ptr = NULL;
struct tf_shadow_tcam_free_db_parms fshadow;
TF_CHECK_PARMS1(tfp);
return 0;
}
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
for (i = 0; i < TF_DIR_MAX; i++) {
memset(&fparms, 0, sizeof(fparms));
fparms.dir = i;
- fparms.rm_db = tcam_db[i];
+ fparms.rm_db = tcam_db->tcam_db[i];
rc = tf_rm_free_db(tfp, &fparms);
if (rc)
return rc;
- tcam_db[i] = NULL;
+ tcam_db->tcam_db[i] = NULL;
if (shadow_init) {
memset(&fshadow, 0, sizeof(fshadow));
struct tf_rm_allocate_parms aparms;
uint16_t num_slices = 1;
uint32_t index;
+ struct tcam_rm_db *tcam_db;
+ void *tcam_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
/*
* For WC TCAM, number of slices could be 4, 2, 1 based on
* the key_size. For other TCAM, it is always 1
*/
for (i = 0; i < num_slices; i++) {
memset(&aparms, 0, sizeof(aparms));
- aparms.rm_db = tcam_db[parms->dir];
+ aparms.rm_db = tcam_db->tcam_db[parms->dir];
aparms.subtype = parms->type;
aparms.priority = parms->priority;
aparms.index = &index;
int allocated = 0;
struct tf_shadow_tcam_remove_parms shparms;
int i;
+ struct tcam_rm_db *tcam_db;
+ void *tcam_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
return -EINVAL;
}
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
/* Check if element is in use */
memset(&aparms, 0, sizeof(aparms));
-
- aparms.rm_db = tcam_db[parms->dir];
+ aparms.rm_db = tcam_db->tcam_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = parms->idx;
aparms.allocated = &allocated;
for (i = 0; i < num_slices; i++) {
/* Free requested element */
memset(&fparms, 0, sizeof(fparms));
- fparms.rm_db = tcam_db[parms->dir];
+ fparms.rm_db = tcam_db->tcam_db[parms->dir];
fparms.subtype = parms->type;
fparms.index = parms->idx + i;
rc = tf_rm_free(&fparms);
/* Convert TF type to HCAPI RM type */
memset(&hparms, 0, sizeof(hparms));
- hparms.rm_db = tcam_db[parms->dir];
+ hparms.rm_db = tcam_db->tcam_db[parms->dir];
hparms.subtype = parms->type;
hparms.hcapi_type = &parms->hcapi_type;
struct tf_shadow_tcam_insert_parms iparms;
uint16_t num_slice_per_row = 1;
int allocated = 0;
+ struct tcam_rm_db *tcam_db;
+ void *tcam_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
/* Check if element is in use */
memset(&aparms, 0, sizeof(aparms));
- aparms.rm_db = tcam_db[parms->dir];
+ aparms.rm_db = tcam_db->tcam_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = parms->idx;
aparms.allocated = &allocated;
/* Convert TF type to HCAPI RM type */
memset(&hparms, 0, sizeof(hparms));
- hparms.rm_db = tcam_db[parms->dir];
+ hparms.rm_db = tcam_db->tcam_db[parms->dir];
hparms.subtype = parms->type;
hparms.hcapi_type = &parms->hcapi_type;
struct tf_rm_is_allocated_parms aparms;
struct tf_rm_get_hcapi_parms hparms;
int allocated = 0;
+ struct tcam_rm_db *tcam_db;
+ void *tcam_db_ptr = NULL;
TF_CHECK_PARMS2(tfp, parms);
if (rc)
return rc;
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "Failed to get em_ext_db from session, rc:%s\n",
+ strerror(-rc));
+ return rc;
+ }
+ tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
+
/* Check if element is in use */
memset(&aparms, 0, sizeof(aparms));
- aparms.rm_db = tcam_db[parms->dir];
+ aparms.rm_db = tcam_db->tcam_db[parms->dir];
aparms.subtype = parms->type;
aparms.index = parms->idx;
aparms.allocated = &allocated;
/* Convert TF type to HCAPI RM type */
memset(&hparms, 0, sizeof(hparms));
- hparms.rm_db = tcam_db[parms->dir];
+ hparms.rm_db = tcam_db->tcam_db[parms->dir];
hparms.subtype = parms->type;
hparms.hcapi_type = &parms->hcapi_type;
uint16_t result_size;
};
+/**
+ * TCAM database
+ *
+ * Tcam rm database
+ *
+ */
+struct tcam_rm_db {
+ struct rm_db *tcam_db[TF_DIR_MAX];
+};
+
/**
* @page tcam TCAM
*