struct tf_alloc_tcam_entry_parms *parms)
{
int rc;
- int index;
+ int index = 0;
struct tf_session *tfs;
struct bitalloc *session_pool;
if (rc)
return rc;
- index = ba_alloc(session_pool);
- if (index == BA_FAIL) {
- PMD_DRV_LOG(ERR, "%s: %s: No resource available\n",
- tf_dir_2_str(parms->dir),
- tf_tcam_tbl_2_str(parms->tcam_tbl_type));
- return -ENOMEM;
+ /*
+ * priority 0: allocate from top of the tcam i.e. high
+ * priority !0: allocate index from bottom i.e lowest
+ */
+ if (parms->priority) {
+ for (index = session_pool->size - 1; index >= 0; index--) {
+ if (ba_inuse(session_pool,
+ index) == BA_ENTRY_FREE) {
+ break;
+ }
+ }
+ if (ba_alloc_index(session_pool,
+ index) == BA_FAIL) {
+ TFP_DRV_LOG(ERR,
+ "%s: %s: ba_alloc index %d failed\n",
+ tf_dir_2_str(parms->dir),
+ tf_tcam_tbl_2_str(parms->tcam_tbl_type),
+ index);
+ return -ENOMEM;
+ }
+ } else {
+ index = ba_alloc(session_pool);
+ if (index == BA_FAIL) {
+ TFP_DRV_LOG(ERR, "%s: %s: Out of resource\n",
+ tf_dir_2_str(parms->dir),
+ tf_tcam_tbl_2_str(parms->tcam_tbl_type));
+ return -ENOMEM;
+ }
}
parms->idx = index;
rc = stack_pop(pool, &index);
if (rc != 0) {
- PMD_DRV_LOG
- (ERR,
+ TFP_DRV_LOG(ERR,
"dir:%d, EM entry index allocation failed\n",
parms->dir);
return rc;
if (rc != 0)
return -1;
- PMD_DRV_LOG
- (ERR,
+ TFP_DRV_LOG(INFO,
"Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
index * TF_SESSION_EM_ENTRY_SIZE,
rptr_index,
tbl_scope_cb = tbl_scope_cb_find(session,
tbl_scope_id);
if (tbl_scope_cb == NULL)
- PMD_DRV_LOG(ERR, "No table scope\n");
+ TFP_DRV_LOG(ERR, "No table scope\n");
for (dir = 0; dir < TF_DIR_MAX; dir++) {
printf("Direction %s:\n", (dir == TF_DIR_RX ? "Rx" : "Tx"));