- Added support variable sized action records
- Additional error checking on table scope params
- Single external pool supported per direction
- Changed to return action record pointer
- Allows action pool to fully utilize the number of flows
Signed-off-by: Farah Smith <farah.smith@broadcom.com>
Signed-off-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
/* Setup hash seeds */
tf_seeds_init(session);
/* Setup hash seeds */
tf_seeds_init(session);
- /* Initialize external pool data structures */
- tf_init_tbl_pool(session);
-
session->ref_count++;
/* Return session ID */
session->ref_count++;
/* Return session ID */
/** EEM record AR helper
*
/** EEM record AR helper
*
- * Helpers to handle the Action Record Pointer in the EEM Record Entry.
+ * Helper to handle the Action Record Pointer in the EEM Record Entry.
*
* Convert absolute offset to action record pointer in EEM record entry
* Convert action record pointer in EEM record entry to absolute offset
*
* Convert absolute offset to action record pointer in EEM record entry
* Convert action record pointer in EEM record entry to absolute offset
#define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
#define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
#define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
#define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
-#define TF_ACT_REC_INDEX_2_OFFSET(idx) ((idx) << 9)
-
* scope. Internal types are not.
*/
TF_TBL_TYPE_EXT,
* scope. Internal types are not.
*/
TF_TBL_TYPE_EXT,
- /** Future - external pool of size0 entries */
- TF_TBL_TYPE_EXT_0,
* [in] Type of the allocation
*/
enum tf_tbl_type type;
* [in] Type of the allocation
*/
enum tf_tbl_type type;
+ /**
+ * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
+ */
+ uint32_t tbl_scope_id;
/**
* [in] Enable search for matching entry. If the table type is
* internal the shadow copy will be searched before
/**
* [in] Enable search for matching entry. If the table type is
* internal the shadow copy will be searched before
* [in] Type of the allocation type
*/
enum tf_tbl_type type;
* [in] Type of the allocation type
*/
enum tf_tbl_type type;
+ /**
+ * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
+ */
+ uint32_t tbl_scope_id;
/**
* [in] Index to free
*/
/**
* [in] Index to free
*/
struct tf_set_tbl_entry_parms {
/**
* [in] Table scope identifier
struct tf_set_tbl_entry_parms {
/**
* [in] Table scope identifier
*/
uint32_t tbl_scope_id;
/**
*/
uint32_t tbl_scope_id;
/**
break;
/* No bitalloc pools for these types */
case TF_TBL_TYPE_EXT:
break;
/* No bitalloc pools for these types */
case TF_TBL_TYPE_EXT:
- case TF_TBL_TYPE_EXT_0:
case TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC:
case TF_TBL_TYPE_VNIC_SVIF:
case TF_TBL_TYPE_EXT: /* No pools for this type */
case TF_TBL_TYPE_ACT_MODIFY_IPV6_SRC:
case TF_TBL_TYPE_VNIC_SVIF:
case TF_TBL_TYPE_EXT: /* No pools for this type */
- case TF_TBL_TYPE_EXT_0: /* No pools for this type */
default:
*hcapi_type = -1;
rc = -EOPNOTSUPP;
default:
*hcapi_type = -1;
rc = -EOPNOTSUPP;
/* Not yet supported */
case TF_TBL_TYPE_VNIC_SVIF:
case TF_TBL_TYPE_EXT: /* No pools for this type */
/* Not yet supported */
case TF_TBL_TYPE_VNIC_SVIF:
case TF_TBL_TYPE_EXT: /* No pools for this type */
- case TF_TBL_TYPE_EXT_0: /* No pools for this type */
default:
return -EOPNOTSUPP;
}
default:
return -EOPNOTSUPP;
}
/** Table scope array */
struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
/** Table scope array */
struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
-
- /** Each external pool is associated with a single table scope
- * For each external pool store the associated table scope in
- * this data structure
- */
- uint32_t ext_pool_2_scope[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX];
};
#endif /* _TF_SESSION_H_ */
};
#endif /* _TF_SESSION_H_ */
+ if (parms->rx_num_flows_in_k != 0 &&
+ (parms->rx_max_key_sz_in_bits / 8 == 0)) {
+ PMD_DRV_LOG(ERR,
+ "EEM: Rx key size required: %u\n",
+ (parms->rx_max_key_sz_in_bits));
+ return -EINVAL;
+ }
+
+ if (parms->tx_num_flows_in_k != 0 &&
+ (parms->tx_max_key_sz_in_bits / 8 == 0)) {
+ PMD_DRV_LOG(ERR,
+ "EEM: Tx key size required: %u\n",
+ (parms->tx_max_key_sz_in_bits));
+ return -EINVAL;
+ }
/* Rx */
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[KEY0_TABLE].num_entries =
parms->rx_num_flows_in_k * TF_KILOBYTE;
/* Rx */
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[KEY0_TABLE].num_entries =
parms->rx_num_flows_in_k * TF_KILOBYTE;
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[RECORD_TABLE].num_entries =
parms->rx_num_flows_in_k * TF_KILOBYTE;
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[RECORD_TABLE].entry_size =
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[RECORD_TABLE].num_entries =
parms->rx_num_flows_in_k * TF_KILOBYTE;
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[RECORD_TABLE].entry_size =
- parms->tx_max_action_entry_sz_in_bits / 8;
+ parms->rx_max_action_entry_sz_in_bits / 8;
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[EFC_TABLE].num_entries =
0;
tbl_scope_cb->em_ctx_info[TF_DIR_RX].em_tables[EFC_TABLE].num_entries =
0;
/**
* Create External Tbl pool of memory indexes.
*
/**
* Create External Tbl pool of memory indexes.
*
- * [in] session
- * Pointer to session
* [in] dir
* direction
* [in] tbl_scope_cb
* pointer to the table scope
* [in] dir
* direction
* [in] tbl_scope_cb
* pointer to the table scope
- * [in] tbl_scope_id
- * id of the table scope
* [in] num_entries
* number of entries to write
* [in] entry_sz_bytes
* [in] num_entries
* number of entries to write
* [in] entry_sz_bytes
* - Failure, entry not allocated, out of resources
*/
static int
* - Failure, entry not allocated, out of resources
*/
static int
-tf_create_tbl_pool_external(struct tf_session *session,
- enum tf_dir dir,
+tf_create_tbl_pool_external(enum tf_dir dir,
struct tf_tbl_scope_cb *tbl_scope_cb,
struct tf_tbl_scope_cb *tbl_scope_cb,
- uint32_t table_scope_id,
uint32_t num_entries,
uint32_t entry_sz_bytes)
uint32_t num_entries,
uint32_t entry_sz_bytes)
{
struct tfp_calloc_parms parms;
{
struct tfp_calloc_parms parms;
+ uint32_t i;
+ int32_t j;
- struct stack *pool = &tbl_scope_cb->ext_pool[dir][TF_EXT_POOL_0];
+ struct stack *pool = &tbl_scope_cb->ext_act_pool[dir];
parms.nitems = num_entries;
parms.size = sizeof(uint32_t);
parms.nitems = num_entries;
parms.size = sizeof(uint32_t);
/* Save the malloced memory address so that it can
* be freed when the table scope is freed.
*/
/* Save the malloced memory address so that it can
* be freed when the table scope is freed.
*/
- tbl_scope_cb->ext_pool_mem[dir][TF_EXT_POOL_0] =
- (uint32_t *)parms.mem_va;
+ tbl_scope_cb->ext_act_pool_mem[dir] = (uint32_t *)parms.mem_va;
- /* Fill pool with indexes
+ /* Fill pool with indexes in reverse
- j = num_entries * entry_sz_bytes - 1;
+ j = (num_entries - 1) * entry_sz_bytes;
for (i = 0; i < num_entries; i++) {
rc = stack_push(pool, j);
if (rc != 0) {
for (i = 0; i < num_entries; i++) {
rc = stack_push(pool, j);
if (rc != 0) {
- PMD_DRV_LOG(ERR, "%d TBL: stack failure %s\n",
- dir, strerror(-rc));
+ PMD_DRV_LOG(ERR, "%s TBL: stack failure %s\n",
+ tf_dir_2_str(dir), strerror(-rc));
+ goto cleanup;
+ }
+
+ if (j < 0) {
+ PMD_DRV_LOG(ERR, "%d TBL: invalid offset (%d)\n",
+ dir, j);
goto cleanup;
}
j -= entry_sz_bytes;
goto cleanup;
}
j -= entry_sz_bytes;
dir, strerror(-rc));
goto cleanup;
}
dir, strerror(-rc));
goto cleanup;
}
- /* Set the table scope associated with the pool
- */
- session->ext_pool_2_scope[dir][TF_EXT_POOL_0] = table_scope_id;
-
return 0;
cleanup:
tfp_free((void *)parms.mem_va);
return 0;
cleanup:
tfp_free((void *)parms.mem_va);
/**
* Destroy External Tbl pool of memory indexes.
*
/**
* Destroy External Tbl pool of memory indexes.
*
- * [in] session
- * Pointer to session
* [in] dir
* direction
* [in] tbl_scope_cb
* [in] dir
* direction
* [in] tbl_scope_cb
-tf_destroy_tbl_pool_external(struct tf_session *session,
- enum tf_dir dir,
- struct tf_tbl_scope_cb *tbl_scope_cb)
+tf_destroy_tbl_pool_external(enum tf_dir dir,
+ struct tf_tbl_scope_cb *tbl_scope_cb)
- uint32_t *ext_pool_mem =
- tbl_scope_cb->ext_pool_mem[dir][TF_EXT_POOL_0];
+ uint32_t *ext_act_pool_mem =
+ tbl_scope_cb->ext_act_pool_mem[dir];
- tfp_free(ext_pool_mem);
-
- /* Set the table scope associated with the pool
- */
- session->ext_pool_2_scope[dir][TF_EXT_POOL_0] = TF_TBL_SCOPE_INVALID;
+ tfp_free(ext_act_pool_mem);
int rc;
uint32_t index;
struct tf_session *tfs;
int rc;
uint32_t index;
struct tf_session *tfs;
struct tf_tbl_scope_cb *tbl_scope_cb;
struct stack *pool;
struct tf_tbl_scope_cb *tbl_scope_cb;
struct stack *pool;
tfs = (struct tf_session *)(tfp->session->core_data);
tfs = (struct tf_session *)(tfp->session->core_data);
- if (parms->type != TF_TBL_TYPE_EXT) {
- PMD_DRV_LOG(ERR,
- "dir:%d, Type not supported, type:%d\n",
- parms->dir,
- parms->type);
- return -EOPNOTSUPP;
- }
-
/* Get the pool info from the table scope
*/
/* Get the pool info from the table scope
*/
- tbl_scope_id = tfs->ext_pool_2_scope[parms->dir][TF_EXT_POOL_0];
- tbl_scope_cb = tbl_scope_cb_find(tfs, tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
PMD_DRV_LOG(ERR,
if (tbl_scope_cb == NULL) {
PMD_DRV_LOG(ERR,
- "dir:%d, table scope not allocated\n",
- parms->dir);
+ "%s, table scope not allocated\n",
+ tf_dir_2_str(parms->dir));
- pool = &tbl_scope_cb->ext_pool[parms->dir][TF_EXT_POOL_0];
+ pool = &tbl_scope_cb->ext_act_pool[parms->dir];
/* Allocate an element
*/
/* Allocate an element
*/
*/
static int
tf_free_tbl_entry_pool_external(struct tf *tfp,
*/
static int
tf_free_tbl_entry_pool_external(struct tf *tfp,
- struct tf_free_tbl_entry_parms *parms)
+ struct tf_free_tbl_entry_parms *parms)
{
int rc = 0;
struct tf_session *tfs;
uint32_t index;
{
int rc = 0;
struct tf_session *tfs;
uint32_t index;
struct tf_tbl_scope_cb *tbl_scope_cb;
struct stack *pool;
struct tf_tbl_scope_cb *tbl_scope_cb;
struct stack *pool;
tfs = (struct tf_session *)(tfp->session->core_data);
tfs = (struct tf_session *)(tfp->session->core_data);
- if (parms->type != TF_TBL_TYPE_EXT) {
- PMD_DRV_LOG(ERR,
- "dir:%d, Type not supported, type:%d\n",
- parms->dir,
- parms->type);
- return -EOPNOTSUPP;
- }
-
/* Get the pool info from the table scope
*/
/* Get the pool info from the table scope
*/
- tbl_scope_id = tfs->ext_pool_2_scope[parms->dir][TF_EXT_POOL_0];
- tbl_scope_cb = tbl_scope_cb_find(tfs, tbl_scope_id);
+ tbl_scope_cb = tbl_scope_cb_find(tfs, parms->tbl_scope_id);
if (tbl_scope_cb == NULL) {
PMD_DRV_LOG(ERR,
if (tbl_scope_cb == NULL) {
PMD_DRV_LOG(ERR,
- "dir:%d, table scope error\n",
+ "dir:%d, Session info invalid\n",
parms->dir);
return -EINVAL;
}
parms->dir);
return -EINVAL;
}
- pool = &tbl_scope_cb->ext_pool[parms->dir][TF_EXT_POOL_0];
+ pool = &tbl_scope_cb->ext_act_pool[parms->dir];
-/* API defined in tf_tbl.h */
-void
-tf_init_tbl_pool(struct tf_session *session)
-{
- enum tf_dir dir;
-
- for (dir = 0; dir < TF_DIR_MAX; dir++) {
- session->ext_pool_2_scope[dir][TF_EXT_POOL_0] =
- TF_TBL_SCOPE_INVALID;
- }
-}
-
/* API defined in tf_em.h */
struct tf_tbl_scope_cb *
tbl_scope_cb_find(struct tf_session *session,
/* API defined in tf_em.h */
struct tf_tbl_scope_cb *
tbl_scope_cb_find(struct tf_session *session,
for (dir = 0; dir < TF_DIR_MAX; dir++) {
/* Free associated external pools
*/
for (dir = 0; dir < TF_DIR_MAX; dir++) {
/* Free associated external pools
*/
- tf_destroy_tbl_pool_external(session,
- dir,
+ tf_destroy_tbl_pool_external(dir,
tbl_scope_cb);
tf_msg_em_op(tfp,
dir,
tbl_scope_cb);
tf_msg_em_op(tfp,
dir,
* Initially, this is a single fixed size pool for all external
* actions related to a single table scope.
*/
* Initially, this is a single fixed size pool for all external
* actions related to a single table scope.
*/
- rc = tf_create_tbl_pool_external(session,
- dir,
- tbl_scope_cb,
- index,
- TF_EXT_POOL_ENTRY_CNT,
- TF_EXT_POOL_ENTRY_SZ_BYTES);
+ rc = tf_create_tbl_pool_external(dir,
+ tbl_scope_cb,
+ em_tables[RECORD_TABLE].num_entries,
+ em_tables[RECORD_TABLE].entry_size);
if (rc) {
PMD_DRV_LOG(ERR,
"%d TBL: Unable to allocate idx pools %s\n",
if (rc) {
PMD_DRV_LOG(ERR,
"%d TBL: Unable to allocate idx pools %s\n",
if (parms->type == TF_TBL_TYPE_EXT) {
void *base_addr;
if (parms->type == TF_TBL_TYPE_EXT) {
void *base_addr;
- uint32_t offset = TF_ACT_REC_INDEX_2_OFFSET(parms->idx);
+ uint32_t offset = parms->idx;
uint32_t tbl_scope_id;
session = (struct tf_session *)(tfp->session->core_data);
uint32_t tbl_scope_id;
session = (struct tf_session *)(tfp->session->core_data);
- tbl_scope_id =
- session->ext_pool_2_scope[parms->dir][TF_EXT_POOL_0];
+ tbl_scope_id = parms->tbl_scope_id;
if (tbl_scope_id == TF_TBL_SCOPE_INVALID) {
PMD_DRV_LOG(ERR,
if (tbl_scope_id == TF_TBL_SCOPE_INVALID) {
PMD_DRV_LOG(ERR,
/* Get the table scope control block associated with the
* external pool
*/
/* Get the table scope control block associated with the
* external pool
*/
tbl_scope_cb = tbl_scope_cb_find(session, tbl_scope_id);
if (tbl_scope_cb == NULL)
tbl_scope_cb = tbl_scope_cb_find(session, tbl_scope_id);
if (tbl_scope_cb == NULL)
int index;
struct tf_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
struct tf_em_caps em_caps[TF_DIR_MAX];
int index;
struct tf_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
struct tf_em_caps em_caps[TF_DIR_MAX];
- struct stack ext_pool[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX];
- uint32_t *ext_pool_mem[TF_DIR_MAX][TF_EXT_POOL_CNT_MAX];
+ struct stack ext_act_pool[TF_DIR_MAX];
+ uint32_t *ext_act_pool_mem[TF_DIR_MAX];
};
/** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.
};
/** Hardware Page sizes supported for EEM: 4K, 8K, 64K, 256K, 1M, 2M, 4M, 1G.