#include "ulp_ha_mgr.h"
#include "bnxt_tf_pmd_shim.h"
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#include "ulp_template_debug_proto.h"
-#include "ulp_tf_debug.h"
-#endif
-
static uint8_t mapper_fld_zeros[16] = { 0 };
static uint8_t mapper_fld_ones[16] = {
tf_free_identifier(tfp, &fparms);
return rc;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_TF_DBG(DEBUG, "Allocated Glb Res Ident [%s][%d][%d] = 0x%04x\n",
- tf_dir_2_str(iparms.dir),
- glb_res->glb_regfile_index, iparms.ident_type, iparms.id);
-#endif
-#endif
return rc;
}
tf_free_tbl_entry(tfp, &free_parms);
return rc;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_TF_DBG(DEBUG, "Allocated Glb Res Index [%s][%d][%d] = 0x%04x\n",
- tf_dir_2_str(aparms.dir),
- glb_res->glb_regfile_index, aparms.type, aparms.idx);
-#endif
-#endif
return rc;
}
return &dev_tbls->ident_list[idx];
}
+static enum tf_tbl_type
+ulp_mapper_dyn_tbl_type_get(struct bnxt_ulp_mapper_parms *mparms,
+ struct bnxt_ulp_mapper_tbl_info *tbl,
+ struct ulp_blob *bdata,
+ uint16_t *out_len)
+{
+ struct bnxt_ulp_device_params *d_params = mparms->device_params;
+ uint16_t blob_len = ulp_blob_data_len_get(bdata);
+ struct bnxt_ulp_dyn_size_map *size_map;
+ uint32_t i;
+
+ if (d_params->dynamic_sram_en) {
+ switch (tbl->resource_type) {
+ case TF_TBL_TYPE_ACT_ENCAP_8B:
+ case TF_TBL_TYPE_ACT_ENCAP_16B:
+ case TF_TBL_TYPE_ACT_ENCAP_32B:
+ case TF_TBL_TYPE_ACT_ENCAP_64B:
+ size_map = d_params->dyn_encap_sizes;
+ for (i = 0; i < d_params->dyn_encap_list_size; i++) {
+ if (blob_len <= size_map[i].slab_size) {
+ *out_len = size_map[i].slab_size;
+ return size_map[i].tbl_type;
+ }
+ }
+ break;
+ case TF_TBL_TYPE_ACT_MODIFY_8B:
+ case TF_TBL_TYPE_ACT_MODIFY_16B:
+ case TF_TBL_TYPE_ACT_MODIFY_32B:
+ case TF_TBL_TYPE_ACT_MODIFY_64B:
+ size_map = d_params->dyn_modify_sizes;
+ for (i = 0; i < d_params->dyn_modify_list_size; i++) {
+ if (blob_len <= size_map[i].slab_size) {
+ *out_len = size_map[i].slab_size;
+ return size_map[i].tbl_type;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return tbl->resource_type;
+}
+
+static uint16_t
+ulp_mapper_dyn_blob_size_get(struct bnxt_ulp_mapper_parms *mparms,
+ struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+ struct bnxt_ulp_device_params *d_params = mparms->device_params;
+
+ if (d_params->dynamic_sram_en) {
+ switch (tbl->resource_type) {
+ case TF_TBL_TYPE_ACT_ENCAP_8B:
+ case TF_TBL_TYPE_ACT_ENCAP_16B:
+ case TF_TBL_TYPE_ACT_ENCAP_32B:
+ case TF_TBL_TYPE_ACT_ENCAP_64B:
+ case TF_TBL_TYPE_ACT_MODIFY_8B:
+ case TF_TBL_TYPE_ACT_MODIFY_16B:
+ case TF_TBL_TYPE_ACT_MODIFY_32B:
+ case TF_TBL_TYPE_ACT_MODIFY_64B:
+ /* return max size */
+ return BNXT_ULP_FLMP_BLOB_SIZE_IN_BITS;
+ default:
+ break;
+ }
+ } else if (tbl->encap_num_fields) {
+ return BNXT_ULP_FLMP_BLOB_SIZE_IN_BITS;
+ }
+ return tbl->result_bit_size;
+}
+
static inline int32_t
ulp_mapper_tcam_entry_free(struct bnxt_ulp_context *ulp,
struct tf *tfp,
} else {
*val = iparms.id;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_ident_field_dump("Ident", ident, tbl, iparms.id);
-#endif
-#endif
return 0;
error:
goto error;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_ident_field_dump("Ident", ident, tbl, sparms.search_id);
-#endif
-#endif
return 0;
error:
}
if (!rc) {
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- if (fld->field_src1 != BNXT_ULP_FIELD_SRC_ZERO && val_len)
- ulp_mapper_field_dump(name, fld, blob, write_idx, val,
- val_len);
-#endif
-#endif
return rc;
}
error:
if (encap_flds) {
uint32_t pad = 0;
/* Initialize the encap blob */
- if (!tbl->record_size) {
+ if (!tbl->record_size &&
+ !parms->device_params->dynamic_sram_en) {
BNXT_TF_DBG(ERR, "Encap tbl record size incorrect\n");
return -EINVAL;
}
}
}
/* add the dynamic pad push */
- pad = ULP_BYTE_2_BITS(tbl->record_size) -
- ulp_blob_data_len_get(&encap_blob);
- ulp_blob_pad_push(&encap_blob, pad);
+ if (parms->device_params->dynamic_sram_en) {
+ uint16_t rec_s = ULP_BYTE_2_BITS(tbl->record_size);
+
+ (void)ulp_mapper_dyn_tbl_type_get(parms, tbl,
+ &encap_blob, &rec_s);
+ pad = rec_s - ulp_blob_data_len_get(&encap_blob);
+ } else {
+ pad = ULP_BYTE_2_BITS(tbl->record_size) -
+ ulp_blob_data_len_get(&encap_blob);
+ }
+ if (ulp_blob_pad_push(&encap_blob, pad) < 0) {
+ BNXT_TF_DBG(ERR, "encap buffer padding failed\n");
+ return -EINVAL;
+ }
+
/* perform the 64 bit byte swap */
ulp_blob_perform_64B_byte_swap(&encap_blob);
return rc;
}
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_TF_DBG(DEBUG, "Result dump\n");
- ulp_mapper_blob_dump(data);
-#endif
-#endif
return rc;
}
return rc;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_tcam_entry_dump("TCAM", idx, tbl, key, mask, data);
-#endif
-#endif
return rc;
}
{
ulp_blob_perform_64B_word_swap(blob);
ulp_blob_perform_64B_byte_swap(blob);
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_TF_DBG(INFO, "Dump after wc tcam post process\n");
- ulp_mapper_blob_dump(blob);
-#endif
-#endif
+}
+
+static int32_t ulp_mapper_tcam_is_wc_tcam(struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+ if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM ||
+ tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH ||
+ tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_LOW)
+ return 1;
+ return 0;
}
static int32_t
uint32_t hit = 0;
uint16_t tmplen = 0;
uint16_t idx;
+ enum bnxt_ulp_byte_order key_byte_order;
/* Set the key and mask to the original key and mask. */
key = &okey;
return -EINVAL;
}
- if (!ulp_blob_init(key, tbl->blob_key_bit_size,
- dparms->key_byte_order) ||
- !ulp_blob_init(mask, tbl->blob_key_bit_size,
- dparms->key_byte_order) ||
+ if (ulp_mapper_tcam_is_wc_tcam(tbl))
+ key_byte_order = dparms->wc_key_byte_order;
+ else
+ key_byte_order = dparms->key_byte_order;
+
+ if (!ulp_blob_init(key, tbl->blob_key_bit_size, key_byte_order) ||
+ !ulp_blob_init(mask, tbl->blob_key_bit_size, key_byte_order) ||
!ulp_blob_init(&data, tbl->result_bit_size,
dparms->result_byte_order) ||
!ulp_blob_init(&update_data, tbl->result_bit_size,
}
/* For wild card tcam perform the post process to swap the blob */
- if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM ||
- tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH ||
- tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_LOW) {
+ if (ulp_mapper_tcam_is_wc_tcam(tbl)) {
if (dparms->dynamic_pad_en) {
/* Sets up the slices for writing to the WC TCAM */
rc = ulp_mapper_wc_tcam_tbl_dyn_post_process(dparms,
int32_t trc;
int32_t rc = 0;
int32_t pad = 0;
+ enum bnxt_ulp_byte_order key_order, res_order;
tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session);
rc = bnxt_ulp_cntxt_mem_type_get(parms->ulp_ctx, &mtype);
return -EINVAL;
}
+ key_order = dparms->em_byte_order;
+ res_order = dparms->em_byte_order;
+
/* Initialize the key/result blobs */
- if (!ulp_blob_init(&key, tbl->blob_key_bit_size,
- dparms->key_byte_order) ||
- !ulp_blob_init(&data, tbl->result_bit_size,
- dparms->result_byte_order)) {
+ if (!ulp_blob_init(&key, tbl->blob_key_bit_size, key_order) ||
+ !ulp_blob_init(&data, tbl->result_bit_size, res_order)) {
BNXT_TF_DBG(ERR, "blob inits failed.\n");
return -EINVAL;
}
BNXT_TF_DBG(ERR, "Failed to build the result blob\n");
return rc;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_result_dump("EM Result", tbl, &data);
-#endif
-#endif
if (dparms->dynamic_pad_en) {
uint32_t abits = dparms->em_blk_align_bits;
ulp_blob_pad_align(&data, abits);
ulp_blob_perform_byte_reverse(&data, ULP_BITS_2_BYTE(abits));
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_result_dump("EM Merged Result", tbl, &data);
-#endif
-#endif
}
/* do the transpose for the internal EM keys */
}
tmplen = ulp_blob_data_len_get(&key);
ulp_blob_perform_byte_reverse(&key, ULP_BITS_2_BYTE(tmplen));
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_result_dump("EM Key Transpose", tbl, &key);
-#endif
-#endif
}
rc = bnxt_ulp_cntxt_tbl_scope_id_get(parms->ulp_ctx,
return rc;
}
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_em_dump("EM", &key, &data, &iparms);
- /* tf_dump_tables(tfp, iparms.tbl_scope_id); */
-#endif
-#endif
/* Mark action process */
if (mtype == BNXT_ULP_FLOW_MEM_TYPE_EXT &&
tbl->resource_type == TF_MEM_EXTERNAL)
bool global = false;
uint64_t act_rec_size;
bool shared = false;
+ enum tf_tbl_type tbl_type = tbl->resource_type;
tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session);
- /* use the max size if encap is enabled */
- if (tbl->encap_num_fields)
- bit_size = BNXT_ULP_FLMP_BLOB_SIZE_IN_BITS;
- else
- bit_size = tbl->result_bit_size;
+ /* compute the blob size */
+ bit_size = ulp_mapper_dyn_blob_size_get(parms, tbl);
/* Initialize the blob data */
if (!ulp_blob_init(&data, bit_size,
gparms.dir = tbl->direction;
gparms.type = tbl->resource_type;
gparms.data = ulp_blob_data_get(&data, &tmplen);
- gparms.data_sz_in_bytes = ULP_BITS_2_BYTE(tbl->result_bit_size);
+ gparms.data_sz_in_bytes = ULP_BITS_2_BYTE(tmplen);
gparms.idx = index;
rc = tf_get_tbl_entry(tfp, &gparms);
if (rc) {
if (alloc) {
aparms.dir = tbl->direction;
- aparms.type = tbl->resource_type;
+ tbl_type = ulp_mapper_dyn_tbl_type_get(parms, tbl,
+ &data, &tmplen);
+ aparms.type = tbl_type;
aparms.tbl_scope_id = tbl_scope_id;
/* All failures after the alloc succeeds require a free */
rc = tf_alloc_tbl_entry(tfp, &aparms);
if (rc) {
BNXT_TF_DBG(ERR, "Alloc table[%s][%s] failed rc=%d\n",
- tf_tbl_type_2_str(tbl->resource_type),
+ tf_tbl_type_2_str(aparms.type),
tf_dir_2_str(tbl->direction), rc);
return rc;
}
if (write) {
sparms.dir = tbl->direction;
- sparms.type = tbl->resource_type;
sparms.data = ulp_blob_data_get(&data, &tmplen);
+ tbl_type = ulp_mapper_dyn_tbl_type_get(parms, tbl, &data,
+ &tmplen);
+ sparms.type = tbl_type;
sparms.data_sz_in_bytes = ULP_BITS_2_BYTE(tmplen);
sparms.idx = index;
sparms.tbl_scope_id = tbl_scope_id;
memset(&fid_parms, 0, sizeof(fid_parms));
fid_parms.direction = tbl->direction;
fid_parms.resource_func = tbl->resource_func;
- fid_parms.resource_type = tbl->resource_type;
+ fid_parms.resource_type = tbl_type;
fid_parms.resource_sub_type = tbl->resource_sub_type;
fid_parms.resource_hndl = index;
fid_parms.critical_resource = tbl->critical_resource;
* write to the entry or link the flow
*/
free_parms.dir = tbl->direction;
- free_parms.type = tbl->resource_type;
+ free_parms.type = tbl_type;
free_parms.idx = index;
free_parms.tbl_scope_id = tbl_scope_id;
/* The_key is a byte array convert it to a search index */
cache_key = ulp_blob_data_get(&key, &tmplen);
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_TF_DBG(DEBUG, "The gen_tbl[%u] key\n", tbl_idx);
- ulp_mapper_blob_dump(&key);
-#endif
-#endif
/* get the generic table */
gen_tbl_list = &parms->mapper_data->gen_tbl_list[tbl_idx];
*res = regval == 0;
break;
case BNXT_ULP_COND_OPC_FLOW_PAT_MATCH:
- if (parms->flow_pattern_id == operand) {
- BNXT_TF_DBG(ERR, "field pattern match failed %x\n",
- parms->flow_pattern_id);
- return -EINVAL;
- }
+ *res = parms->flow_pattern_id == operand;
break;
case BNXT_ULP_COND_OPC_ACT_PAT_MATCH:
- if (parms->act_pattern_id == operand) {
- BNXT_TF_DBG(ERR, "act pattern match failed %x\n",
- parms->act_pattern_id);
- return -EINVAL;
- }
+ *res = parms->act_pattern_id == operand;
break;
case BNXT_ULP_COND_OPC_EXT_MEM_IS_SET:
if (bnxt_ulp_cntxt_mem_type_get(parms->ulp_ctx, &mtype)) {
return rc;
}
-
/*
* Processes a list of conditions and returns both a status and result of the
* list. The status must be checked prior to verifying the result.
for (tbl_idx = 0; tbl_idx < num_tbls && cond_goto;) {
tbl = &tbls[tbl_idx];
cond_goto = tbl->execute_info.cond_true_goto;
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
-#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- ulp_mapper_table_dump(tbl, tbl_idx);
-#endif
-#endif
/* Process the conditional func code opcodes */
if (ulp_mapper_func_info_process(parms, tbl)) {
BNXT_TF_DBG(ERR, "Failed to process cond update\n");
* Set the critical resource on the first resource del, then iterate
* while status is good
*/
- if (flow_type != BNXT_ULP_FDB_TYPE_RID)
- res_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES;
+ res_parms.critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES;
rc = ulp_flow_db_resource_del(ulp_ctx, flow_type, fid, &res_parms);