*/
static void *shadow_tbl_db[TF_DIR_MAX];
-/**
- * Init flag, set on bind and cleared on unbind
- */
-static uint8_t init;
-
/**
* Shadow init flag, set on bind and cleared on unbind
*/
struct tf_rm_create_db_parms db_cfg = { 0 };
struct tbl_rm_db *tbl_db;
struct tfp_calloc_parms cparms;
+ struct tf_session *tfs;
TF_CHECK_PARMS2(tfp, parms);
- if (init) {
- TFP_DRV_LOG(ERR,
- "Table DB already initialized\n");
- return -EINVAL;
- }
+ /* Retrieve the session information */
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
memset(&db_cfg, 0, sizeof(db_cfg));
cparms.nitems = 1;
db_cfg.dir = d;
db_cfg.alloc_cnt = parms->resources->tbl_cnt[d].cnt;
db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
-
- rc = tf_rm_create_db(tfp, &db_cfg);
+ if (tf_session_is_shared_session(tfs) &&
+ (!tf_session_is_shared_session_creator(tfs)))
+ rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+ else
+ rc = tf_rm_create_db(tfp, &db_cfg);
if (rc) {
TFP_DRV_LOG(ERR,
"%s: Table DB creation failed\n",
return rc;
}
}
- init = 1;
TFP_DRV_LOG(INFO,
"Table Type - initialized\n");
void *tbl_db_ptr = NULL;
TF_CHECK_PARMS1(tfp);
- /* Bail if nothing has been initialized */
- if (!init) {
- TFP_DRV_LOG(INFO,
- "No Table DBs created\n");
- 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",
+ TFP_DRV_LOG(INFO,
+ "Tbl_db is not initialized, rc:%s\n",
strerror(-rc));
- return rc;
+ return 0;
}
tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
for (i = 0; i < TF_DIR_MAX; i++) {
+ if (tbl_db->tbl_db[i] == NULL)
+ continue;
fparms.dir = i;
fparms.rm_db = tbl_db->tbl_db[i];
rc = tf_rm_free_db(tfp, &fparms);
tbl_db->tbl_db[i] = NULL;
}
- init = 0;
shadow_init = 0;
return 0;
TF_CHECK_PARMS2(tfp, parms);
- if (!init) {
- TFP_DRV_LOG(ERR,
- "%s: No Table DBs created\n",
- tf_dir_2_str(parms->dir));
- return -EINVAL;
- }
-
/* Retrieve the session information */
rc = tf_session_get_session_internal(tfp, &tfs);
if (rc)
TF_CHECK_PARMS2(tfp, parms);
- if (!init) {
- TFP_DRV_LOG(ERR,
- "%s: No Table DBs created\n",
- tf_dir_2_str(parms->dir));
- return -EINVAL;
- }
/* Retrieve the session information */
rc = tf_session_get_session_internal(tfp, &tfs);
if (rc)
TF_CHECK_PARMS3(tfp, parms, parms->data);
- if (!init) {
- TFP_DRV_LOG(ERR,
- "%s: No Table DBs created\n",
- tf_dir_2_str(parms->dir));
- return -EINVAL;
- }
-
/* Retrieve the session information */
rc = tf_session_get_session_internal(tfp, &tfs);
if (rc)
TF_CHECK_PARMS3(tfp, parms, parms->data);
- if (!init) {
- TFP_DRV_LOG(ERR,
- "%s: No Table DBs created\n",
- tf_dir_2_str(parms->dir));
- return -EINVAL;
- }
-
-
/* Retrieve the session information */
rc = tf_session_get_session_internal(tfp, &tfs);
if (rc)
TF_CHECK_PARMS2(tfp, parms);
- if (!init) {
- TFP_DRV_LOG(ERR,
- "%s: No Table DBs created\n",
- tf_dir_2_str(parms->dir));
-
- return -EINVAL;
- }
-
/* Retrieve the session information */
rc = tf_session_get_session_internal(tfp, &tfs);
if (rc)
return rc;
}
+
+int
+tf_tbl_get_resc_info(struct tf *tfp,
+ struct tf_tbl_resource_info *tbl)
+{
+ int rc;
+ int d, i;
+ struct tf_resource_info *dinfo;
+ struct tf_rm_get_alloc_info_parms ainfo;
+ void *tbl_db_ptr = NULL;
+ struct tbl_rm_db *tbl_db;
+ uint16_t base = 0, shift = 0;
+ struct tf_dev_info *dev;
+ struct tf_session *tfs;
+
+ TF_CHECK_PARMS2(tfp, tbl);
+
+ /* Retrieve the session information */
+ rc = tf_session_get_session_internal(tfp, &tfs);
+ if (rc)
+ return rc;
+
+ /* Retrieve the device information */
+ rc = tf_session_get_device(tfs, &dev);
+ if (rc)
+ return rc;
+
+ rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
+ if (rc) {
+ TFP_DRV_LOG(INFO,
+ "No resource allocated for table from session\n");
+ return 0;
+ }
+ tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
+
+
+ /* check if reserved resource for WC is multiple of num_slices */
+ for (d = 0; d < TF_DIR_MAX; d++) {
+ ainfo.rm_db = tbl_db->tbl_db[d];
+ dinfo = tbl[d].info;
+
+ ainfo.info = (struct tf_rm_alloc_info *)dinfo;
+ ainfo.subtype = 0;
+ rc = tf_rm_get_all_info(&ainfo, TF_TBL_TYPE_MAX);
+ if (rc)
+ return rc;
+
+ if (dev->ops->tf_dev_get_tbl_info) {
+ /* Adjust all */
+ for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
+ /* Only get table info if required for the device */
+ rc = dev->ops->tf_dev_get_tbl_info(tfp,
+ tbl_db->tbl_db[d],
+ i,
+ &base,
+ &shift);
+ if (rc) {
+ TFP_DRV_LOG(ERR,
+ "%s: Failed to get table info:%d\n",
+ tf_dir_2_str(d),
+ i);
+ return rc;
+ }
+ if (dinfo[i].stride)
+ TF_TBL_RM_TO_PTR(&dinfo[i].start,
+ dinfo[i].start,
+ base,
+ shift);
+ }
+ }
+ }
+
+
+
+ return 0;
+}