- }
-
- return rc;
-}
-
-#if (TF_SHADOW == 1)
-/**
- * Allocate Tbl entry from the Shadow DB. Shadow DB is searched for
- * the requested entry. If found the ref count is incremente and
- * returned.
- *
- * [in] tfs
- * Pointer to session
- * [in] parms
- * Allocation parameters
- *
- * Return:
- * 0 - Success, entry found and ref count incremented
- * -ENOENT - Failure, entry not found
- */
-static int
-tf_alloc_tbl_entry_shadow(struct tf_session *tfs __rte_unused,
- struct tf_alloc_tbl_entry_parms *parms __rte_unused)
-{
- TFP_DRV_LOG(ERR,
- "%s, Entry Alloc with search not supported\n",
- tf_dir_2_str(parms->dir));
-
- return -EOPNOTSUPP;
-}
-
-/**
- * Free Tbl entry from the Shadow DB. Shadow DB is searched for
- * the requested entry. If found the ref count is decremente and
- * new ref_count returned.
- *
- * [in] tfs
- * Pointer to session
- * [in] parms
- * Allocation parameters
- *
- * Return:
- * 0 - Success, entry found and ref count decremented
- * -ENOENT - Failure, entry not found
- */
-static int
-tf_free_tbl_entry_shadow(struct tf_session *tfs,
- struct tf_free_tbl_entry_parms *parms)
-{
- TFP_DRV_LOG(ERR,
- "%s, Entry Free with search not supported\n",
- tf_dir_2_str(parms->dir));
-
- return -EOPNOTSUPP;
-}
-#endif /* TF_SHADOW */
-
-/**
- * Create External Tbl pool of memory indexes.
- *
- * [in] dir
- * direction
- * [in] tbl_scope_cb
- * pointer to the table scope
- * [in] num_entries
- * number of entries to write
- * [in] entry_sz_bytes
- * size of each entry
- *
- * Return:
- * 0 - Success, entry allocated - no search support
- * -ENOMEM -EINVAL -EOPNOTSUPP
- * - Failure, entry not allocated, out of resources
- */
-static int
-tf_create_tbl_pool_external(enum tf_dir dir,
- struct tf_tbl_scope_cb *tbl_scope_cb,
- uint32_t num_entries,
- uint32_t entry_sz_bytes)
-{
- struct tfp_calloc_parms parms;
- uint32_t i;
- int32_t j;
- int rc = 0;
- struct stack *pool = &tbl_scope_cb->ext_act_pool[dir];
-
- parms.nitems = num_entries;
- parms.size = sizeof(uint32_t);
- parms.alignment = 0;
-
- if (tfp_calloc(&parms) != 0) {
- TFP_DRV_LOG(ERR, "%s: TBL: external pool failure %s\n",
- tf_dir_2_str(dir), strerror(ENOMEM));
- return -ENOMEM;
- }
-
- /* Create empty stack
- */
- rc = stack_init(num_entries, parms.mem_va, pool);
-
- if (rc != 0) {
- TFP_DRV_LOG(ERR, "%s: TBL: stack init failure %s\n",
- tf_dir_2_str(dir), strerror(-rc));
- goto cleanup;
- }
-
- /* Save the malloced memory address so that it can
- * be freed when the table scope is freed.
- */
- tbl_scope_cb->ext_act_pool_mem[dir] = (uint32_t *)parms.mem_va;
-
- /* Fill pool with indexes in reverse
- */
- j = (num_entries - 1) * entry_sz_bytes;
-
- for (i = 0; i < num_entries; i++) {
- rc = stack_push(pool, j);
- if (rc != 0) {
- TFP_DRV_LOG(ERR, "%s TBL: stack failure %s\n",
- tf_dir_2_str(dir), strerror(-rc));
- goto cleanup;
- }
-
- if (j < 0) {
- TFP_DRV_LOG(ERR, "%d TBL: invalid offset (%d)\n",
- dir, j);
- goto cleanup;
- }
- j -= entry_sz_bytes;
- }
-
- if (!stack_is_full(pool)) {
- rc = -EINVAL;
- TFP_DRV_LOG(ERR, "%s TBL: stack failure %s\n",
- tf_dir_2_str(dir), strerror(-rc));
- goto cleanup;
- }
- return 0;
-cleanup:
- tfp_free((void *)parms.mem_va);
- return rc;
-}
-
-/**
- * Destroy External Tbl pool of memory indexes.
- *
- * [in] dir
- * direction
- * [in] tbl_scope_cb
- * pointer to the table scope
- *
- */
-static void
-tf_destroy_tbl_pool_external(enum tf_dir dir,
- struct tf_tbl_scope_cb *tbl_scope_cb)
-{
- uint32_t *ext_act_pool_mem =
- tbl_scope_cb->ext_act_pool_mem[dir];
-
- tfp_free(ext_act_pool_mem);
-}
-
-/**
- * Allocate External Tbl entry from the Session Pool.
- *
- * [in] tfp
- * Pointer to Truflow Handle
- * [in] parms
- * Allocation parameters
- *
- * Return:
- * 0 - Success, entry allocated - no search support
- * -ENOMEM -EINVAL -EOPNOTSUPP
- * - Failure, entry not allocated, out of resources
- */
-static int
-tf_alloc_tbl_entry_pool_external(struct tf *tfp,
- struct tf_alloc_tbl_entry_parms *parms)
-{
- int rc;
- uint32_t index;
- struct tf_session *tfs;
- struct tf_tbl_scope_cb *tbl_scope_cb;
- struct stack *pool;
-
- TF_CHECK_PARMS_SESSION(tfp, parms);
-
- tfs = (struct tf_session *)(tfp->session->core_data);
-
- /* Get the pool info from the table scope
- */
- tbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id);
-
- if (tbl_scope_cb == NULL) {
- TFP_DRV_LOG(ERR,
- "%s, table scope not allocated\n",
- tf_dir_2_str(parms->dir));
- return -EINVAL;
- }
- pool = &tbl_scope_cb->ext_act_pool[parms->dir];
-
- /* Allocate an element
- */
- rc = stack_pop(pool, &index);
-
- if (rc != 0) {
- TFP_DRV_LOG(ERR,
- "%s, Allocation failed, type:%d\n",
- tf_dir_2_str(parms->dir),
- parms->type);