X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_ulp%2Fulp_mapper.c;h=871dbad0fe4743419414d9de8a862327925767aa;hb=45633c460c223a67dd1a7cc084c3eceb5e17687c;hp=8fd8a329bf7cb2e1966292f059def650092b3808;hpb=5b73c859f4586a743e815824b60bce5a36ff60e4;p=dpdk.git diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 8fd8a329bf..871dbad0fe 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -19,6 +19,8 @@ #include "tf_util.h" #include "ulp_template_db_tbl.h" #include "ulp_port_db.h" +#include "ulp_ha_mgr.h" +#include "bnxt_tf_pmd_shim.h" static uint8_t mapper_fld_zeros[16] = { 0 }; @@ -121,7 +123,7 @@ ulp_mapper_resource_ident_allocate(struct bnxt_ulp_context *ulp_ctx, struct tf *tfp; int32_t rc = 0; - tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx, BNXT_ULP_SHARED_SESSION_NO); if (!tfp) return -EINVAL; @@ -174,7 +176,7 @@ ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx, uint32_t tbl_scope_id; int32_t rc = 0; - tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx, BNXT_ULP_SHARED_SESSION_NO); if (!tfp) return -EINVAL; @@ -419,7 +421,7 @@ ulp_mapper_ident_fields_get(struct bnxt_ulp_mapper_parms *mparms, } static inline int32_t -ulp_mapper_tcam_entry_free(struct bnxt_ulp_context *ulp __rte_unused, +ulp_mapper_tcam_entry_free(struct bnxt_ulp_context *ulp, struct tf *tfp, struct ulp_flow_db_res_params *res) { @@ -429,6 +431,30 @@ ulp_mapper_tcam_entry_free(struct bnxt_ulp_context *ulp __rte_unused, .idx = (uint16_t)res->resource_hndl }; + /* If HA is enabled, we may have to remap the TF Type */ + if (bnxt_ulp_cntxt_ha_enabled(ulp)) { + enum ulp_ha_mgr_region region; + int32_t rc; + + switch (res->resource_type) { + case TF_TCAM_TBL_TYPE_WC_TCAM_HIGH: + case TF_TCAM_TBL_TYPE_WC_TCAM_LOW: + rc = ulp_ha_mgr_region_get(ulp, ®ion); + if (rc) + /* Log this, but assume region is correct */ + BNXT_TF_DBG(ERR, + "Unable to get HA region (%d)\n", + rc); + else + fparms.tcam_tbl_type = + (region == ULP_HA_REGION_LOW) ? + TF_TCAM_TBL_TYPE_WC_TCAM_LOW : + TF_TCAM_TBL_TYPE_WC_TCAM_HIGH; + break; + default: + break; + } + } return tf_free_tcam_entry(tfp, &fparms); } @@ -741,7 +767,7 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms, struct tf *tfp; int rc; - tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session); if (!tfp) { BNXT_TF_DBG(ERR, "Failed to get tf pointer\n"); return -EINVAL; @@ -776,6 +802,7 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_type = ident->ident_type; fid_parms.resource_hndl = iparms.id; fid_parms.critical_resource = tbl->critical_resource; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) { @@ -822,7 +849,7 @@ ulp_mapper_ident_extract(struct bnxt_ulp_mapper_parms *parms, int rc; /* Get the tfp from ulp context */ - tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session); if (!tfp) { BNXT_TF_DBG(ERR, "Failed to get tf pointer\n"); return -EINVAL; @@ -868,6 +895,8 @@ ulp_mapper_ident_extract(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_type = ident->ident_type; fid_parms.resource_hndl = sparms.search_id; fid_parms.critical_resource = tbl->critical_resource; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) { BNXT_TF_DBG(ERR, "Failed to link res to flow rc = %d\n", @@ -968,13 +997,13 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms *parms, return -EINVAL; } idx = tfp_be_to_cpu_16(idx); - if (idx >= BNXT_ULP_CF_IDX_LAST || bytelen > sizeof(uint32_t)) { + if (idx >= BNXT_ULP_CF_IDX_LAST || bytelen > sizeof(uint64_t)) { BNXT_TF_DBG(ERR, "comp field [%d] read oob %d\n", idx, bytelen); return -EINVAL; } buffer = (uint8_t *)&parms->comp_fld[idx]; - *val = &buffer[sizeof(uint32_t) - bytelen]; + *val = &buffer[sizeof(uint64_t) - bytelen]; *value = ULP_COMP_FLD_IDX_RD(parms, idx); break; case BNXT_ULP_FIELD_SRC_RF: @@ -1513,6 +1542,8 @@ ulp_mapper_mark_gfid_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.critical_resource = tbl->critical_resource; fid_parms.resource_type = mark_flag; fid_parms.resource_hndl = gfid; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", rc); @@ -1559,6 +1590,8 @@ ulp_mapper_mark_act_ptr_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.critical_resource = tbl->critical_resource; fid_parms.resource_type = mark_flag; fid_parms.resource_hndl = act_idx; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", rc); @@ -1605,6 +1638,8 @@ ulp_mapper_mark_vfr_idx_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.critical_resource = tbl->critical_resource; fid_parms.resource_type = mark_flag; fid_parms.resource_hndl = act_idx; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", rc); @@ -1671,7 +1706,7 @@ ulp_mapper_tcam_tbl_entry_write(struct bnxt_ulp_mapper_parms *parms, uint16_t tmplen; int32_t rc; - tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session); if (!tfp) { BNXT_TF_DBG(ERR, "Failed to get truflow pointer\n"); return -EINVAL; @@ -1838,7 +1873,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, return 0; } - tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session); if (!tfp) { BNXT_TF_DBG(ERR, "Failed to get truflow pointer\n"); return -EINVAL; @@ -1887,7 +1922,9 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, } /* For wild card tcam perform the post process to swap the blob */ - if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM) { + 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 (dparms->dynamic_pad_en) { /* Sets up the slices for writing to the WC TCAM */ rc = ulp_mapper_wc_tcam_tbl_dyn_post_process(dparms, @@ -2004,6 +2041,8 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_type = tbl->resource_type; fid_parms.critical_resource = tbl->critical_resource; fid_parms.resource_hndl = idx; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) { BNXT_TF_DBG(ERR, "Failed to link resource to flow rc = %d\n", @@ -2032,7 +2071,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct ulp_blob key, data; uint32_t i, num_kflds; uint16_t tmplen; - struct tf *tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); + struct tf *tfp; struct ulp_flow_db_res_params fid_parms = { 0 }; struct tf_insert_em_entry_parms iparms = { 0 }; struct tf_delete_em_entry_parms free_parms = { 0 }; @@ -2042,6 +2081,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms, int32_t rc = 0; int32_t pad = 0; + tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session); rc = bnxt_ulp_cntxt_mem_type_get(parms->ulp_ctx, &mtype); if (rc) { BNXT_TF_DBG(ERR, "Failed to get the mem type for EM\n"); @@ -2208,8 +2248,8 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct tf_get_tbl_entry_parms gparms = { 0 }; struct tf_free_tbl_entry_parms free_parms = { 0 }; uint32_t tbl_scope_id; - struct tf *tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); - struct bnxt_ulp_glb_resource_info glb_res; + struct tf *tfp; + struct bnxt_ulp_glb_resource_info glb_res = { 0 }; uint16_t bit_size; bool alloc = false; bool write = false; @@ -2217,6 +2257,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, uint64_t act_rec_size; bool shared = false; + 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; @@ -2296,8 +2337,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, tbl->tbl_operand, ®val, &shared)) { BNXT_TF_DBG(ERR, - "Failed to get tbl idx from Global " - "regfile[%d].\n", + "Failed to get tbl idx from Glb RF[%d].\n", tbl->tbl_operand); return -EINVAL; } @@ -2347,8 +2387,9 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, gparms.data_sz_in_bytes, data.byte_order); if (rc) { - BNXT_TF_DBG(ERR, "Failed to read fields on tbl read " - "rc=%d\n", rc); + BNXT_TF_DBG(ERR, + "Failed to get flds on tbl read rc=%d\n", + rc); return rc; } return 0; @@ -2433,8 +2474,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, rc = tf_set_tbl_entry(tfp, &sparms); if (rc) { BNXT_TF_DBG(ERR, - "Index table[%s][%s][%x] write failed " - "rc=%d\n", + "Index table[%s][%s][%x] write fail rc=%d\n", tf_tbl_type_2_str(sparms.type), tf_dir_2_str(sparms.dir), sparms.idx, rc); @@ -2461,6 +2501,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_sub_type = tbl->resource_sub_type; fid_parms.resource_hndl = index; fid_parms.critical_resource = tbl->critical_resource; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) { @@ -2506,10 +2547,11 @@ ulp_mapper_if_tbl_process(struct bnxt_ulp_mapper_parms *parms, int32_t rc = 0; struct tf_set_if_tbl_entry_parms iftbl_params = { 0 }; struct tf_get_if_tbl_entry_parms get_parms = { 0 }; - struct tf *tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); + struct tf *tfp; enum bnxt_ulp_if_tbl_opc if_opc = tbl->tbl_opcode; uint32_t res_size; + tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx, tbl->shared_session); /* Initialize the blob data */ if (!ulp_blob_init(&data, tbl->result_bit_size, parms->device_params->byte_order)) { @@ -2611,7 +2653,7 @@ ulp_mapper_gen_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct ulp_flow_db_res_params fid_parms; struct ulp_mapper_gen_tbl_entry gen_tbl_ent, *g; struct ulp_gen_hash_entry_params hash_entry; - uint16_t tmplen; + uint16_t tmplen = 0; struct ulp_blob key, data; uint8_t *cache_key; int32_t tbl_idx; @@ -2688,6 +2730,11 @@ ulp_mapper_gen_tbl_process(struct bnxt_ulp_mapper_parms *parms, } } else { /* convert key to index directly */ + if (ULP_BITS_2_BYTE(tmplen) > (int32_t)sizeof(key_index)) { + BNXT_TF_DBG(ERR, "%s: keysize is bigger then 4 bytes\n", + gen_tbl_list->gen_tbl_name); + return -EINVAL; + } memcpy(&key_index, cache_key, ULP_BITS_2_BYTE(tmplen)); /* Get the generic table entry */ if (ulp_mapper_gen_tbl_entry_get(gen_tbl_list, key_index, @@ -2792,6 +2839,8 @@ ulp_mapper_gen_tbl_process(struct bnxt_ulp_mapper_parms *parms, fid_parms.resource_sub_type = tbl->resource_sub_type; fid_parms.resource_hndl = key_index; fid_parms.critical_resource = tbl->critical_resource; + ulp_flow_db_shared_session_set(&fid_parms, tbl->shared_session); + rc = ulp_mapper_fdb_opc_process(parms, tbl, &fid_parms); if (rc) BNXT_TF_DBG(ERR, "Fail to add gen ent flowdb %d\n", rc); @@ -2833,15 +2882,15 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id); if (rc) { - BNXT_TF_DBG(ERR, "Failed to get device id for " - "global init (%d)\n", rc); + BNXT_TF_DBG(ERR, "Failed to get device id for glb init (%d)\n", + rc); return rc; } rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id); if (rc) { - BNXT_TF_DBG(ERR, "Failed to get app id for " - "global init (%d)\n", rc); + BNXT_TF_DBG(ERR, "Failed to get app id for glb init (%d)\n", + rc); return rc; } @@ -2881,10 +2930,12 @@ static int32_t ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, struct bnxt_ulp_mapper_data *mapper_data) { + struct tf_get_shared_tbl_increment_parms iparms; struct bnxt_ulp_glb_resource_info *glb_res; struct tf_get_session_info_parms sparms; uint32_t num_entries, i, dev_id, res; struct tf_resource_info *res_info; + uint32_t addend; uint64_t regval; enum tf_dir dir; int32_t rc = 0; @@ -2892,13 +2943,11 @@ ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, uint8_t app_id; memset(&sparms, 0, sizeof(sparms)); - glb_res = bnxt_ulp_app_glb_resource_info_list_get(&num_entries); if (!glb_res || !num_entries) { BNXT_TF_DBG(ERR, "Invalid Arguments\n"); return -EINVAL; } - tfp = bnxt_ulp_cntxt_shared_tfp_get(ulp_ctx); if (!tfp) { BNXT_TF_DBG(ERR, "Failed to get tfp for app global init"); @@ -2916,15 +2965,15 @@ ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id); if (rc) { - BNXT_TF_DBG(ERR, "Failed to get the app id in global init " - "(%d).\n", rc); + BNXT_TF_DBG(ERR, "Failed to get the app id in glb init (%d).\n", + rc); return rc; } rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id); if (rc) { - BNXT_TF_DBG(ERR, "Failed to get device id for app " - "global init (%d)\n", rc); + BNXT_TF_DBG(ERR, "Failed to get dev id for app glb init (%d)\n", + rc); return rc; } @@ -2935,12 +2984,29 @@ ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, continue; dir = glb_res[i].direction; res = glb_res[i].resource_type; + addend = 1; switch (glb_res[i].resource_func) { case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER: res_info = &sparms.session_info.ident[dir].info[res]; break; case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE: + /* + * Tables may have various strides for the allocations. + * Need to account. + */ + memset(&iparms, 0, sizeof(iparms)); + iparms.dir = dir; + iparms.type = res; + rc = tf_get_shared_tbl_increment(tfp, &iparms); + if (rc) { + BNXT_TF_DBG(ERR, + "Failed to get addend for %s[%s] rc=(%d)\n", + tf_tbl_type_2_str(res), + tf_dir_2_str(dir), rc); + return rc; + } + addend = iparms.increment_cnt; res_info = &sparms.session_info.tbl[dir].info[res]; break; case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE: @@ -2954,10 +3020,8 @@ ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, glb_res[i].resource_func); continue; } - regval = tfp_cpu_to_be_64((uint64_t)res_info->start); - res_info->start++; - + res_info->start += addend; /* * All resources written to the global regfile are shared for * this function. @@ -3114,109 +3178,141 @@ ulp_mapper_cond_opc_process(struct bnxt_ulp_mapper_parms *parms, } static int32_t -ulp_mapper_cc_upd_opr_compute(struct bnxt_ulp_mapper_parms *parms, - enum tf_dir dir, - enum bnxt_ulp_cc_upd_src cc_src, - uint16_t cc_opr, - uint64_t *result) +ulp_mapper_func_opr_compute(struct bnxt_ulp_mapper_parms *parms, + enum tf_dir dir, + enum bnxt_ulp_func_src func_src, + uint16_t func_opr, + uint64_t *result) { uint64_t regval; bool shared; *result = false; - switch (cc_src) { - case BNXT_ULP_CC_UPD_SRC_COMP_FIELD: - if (cc_opr >= BNXT_ULP_CF_IDX_LAST) { - BNXT_TF_DBG(ERR, "invalid index %u\n", cc_opr); + switch (func_src) { + case BNXT_ULP_FUNC_SRC_COMP_FIELD: + if (func_opr >= BNXT_ULP_CF_IDX_LAST) { + BNXT_TF_DBG(ERR, "invalid index %u\n", func_opr); return -EINVAL; } - *result = (uint64_t)ULP_COMP_FLD_IDX_RD(parms, cc_opr); + *result = ULP_COMP_FLD_IDX_RD(parms, func_opr); break; - case BNXT_ULP_CC_UPD_SRC_REGFILE: - if (!ulp_regfile_read(parms->regfile, cc_opr, ®val)) { - BNXT_TF_DBG(ERR, "regfile[%d] read oob\n", cc_opr); + case BNXT_ULP_FUNC_SRC_REGFILE: + if (!ulp_regfile_read(parms->regfile, func_opr, ®val)) { + BNXT_TF_DBG(ERR, "regfile[%d] read oob\n", func_opr); return -EINVAL; } *result = tfp_be_to_cpu_64(regval); break; - case BNXT_ULP_CC_UPD_SRC_GLB_REGFILE: + case BNXT_ULP_FUNC_SRC_GLB_REGFILE: if (ulp_mapper_glb_resource_read(parms->mapper_data, dir, - cc_opr, ®val, &shared)) { + func_opr, ®val, &shared)) { BNXT_TF_DBG(ERR, "global regfile[%d] read failed.\n", - cc_opr); + func_opr); return -EINVAL; } *result = tfp_be_to_cpu_64(regval); break; - case BNXT_ULP_CC_UPD_SRC_CONST: - *result = cc_opr; + case BNXT_ULP_FUNC_SRC_CONST: + *result = func_opr; break; default: - BNXT_TF_DBG(ERR, "invalid src code %u\n", cc_src); + BNXT_TF_DBG(ERR, "invalid src code %u\n", func_src); return -EINVAL; } return 0; } static int32_t -ulp_mapper_cc_upd_info_process(struct bnxt_ulp_mapper_parms *parms, - struct bnxt_ulp_mapper_tbl_info *tbl) +ulp_mapper_func_info_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_tbl_info *tbl) { - struct bnxt_ulp_mapper_cc_upd_info *cc_upd = &tbl->cc_upd_info; - uint64_t res = 0, res1, res2; + struct bnxt_ulp_mapper_func_info *func_info = &tbl->func_info; + uint64_t res = 0, res1 = 0, res2 = 0; int32_t rc = 0; + uint32_t process_src1 = 0, process_src2 = 0; - if (cc_upd->cc_opc == BNXT_ULP_CC_UPD_OPC_NOP) + /* determine which functional operands to compute */ + switch (func_info->func_opc) { + case BNXT_ULP_FUNC_OPC_NOP: return rc; + case BNXT_ULP_FUNC_OPC_EQ: + case BNXT_ULP_FUNC_OPC_NE: + case BNXT_ULP_FUNC_OPC_GE: + case BNXT_ULP_FUNC_OPC_GT: + case BNXT_ULP_FUNC_OPC_LE: + case BNXT_ULP_FUNC_OPC_LT: + process_src1 = 1; + process_src2 = 1; + break; + case BNXT_ULP_FUNC_OPC_COPY_SRC1_TO_RF: + process_src1 = 1; + break; + default: + break; + } - rc = ulp_mapper_cc_upd_opr_compute(parms, tbl->direction, - cc_upd->cc_src1, - cc_upd->cc_opr1, &res1); - if (rc) - return rc; + if (process_src1) { + rc = ulp_mapper_func_opr_compute(parms, tbl->direction, + func_info->func_src1, + func_info->func_opr1, &res1); + if (rc) + return rc; + } - rc = ulp_mapper_cc_upd_opr_compute(parms, tbl->direction, - cc_upd->cc_src2, - cc_upd->cc_opr2, &res2); - if (rc) - return rc; + if (process_src2) { + rc = ulp_mapper_func_opr_compute(parms, tbl->direction, + func_info->func_src2, + func_info->func_opr2, &res2); + if (rc) + return rc; + } - switch (cc_upd->cc_opc) { - case BNXT_ULP_CC_UPD_OPC_NOP: - res = 1; - break; - case BNXT_ULP_CC_UPD_OPC_EQ: + /* perform the functional opcode operations */ + switch (func_info->func_opc) { + case BNXT_ULP_FUNC_OPC_EQ: if (res1 == res2) res = 1; break; - case BNXT_ULP_CC_UPD_OPC_NE: + case BNXT_ULP_FUNC_OPC_NE: if (res1 != res2) res = 1; break; - case BNXT_ULP_CC_UPD_OPC_GE: + case BNXT_ULP_FUNC_OPC_GE: if (res1 >= res2) res = 1; break; - case BNXT_ULP_CC_UPD_OPC_GT: + case BNXT_ULP_FUNC_OPC_GT: if (res1 > res2) res = 1; break; - case BNXT_ULP_CC_UPD_OPC_LE: + case BNXT_ULP_FUNC_OPC_LE: if (res1 <= res2) res = 1; break; - case BNXT_ULP_CC_UPD_OPC_LT: + case BNXT_ULP_FUNC_OPC_LT: if (res1 < res2) res = 1; break; - case BNXT_ULP_CC_UPD_OPC_LAST: - BNXT_TF_DBG(ERR, "invalid code %u\n", cc_upd->cc_opc); + case BNXT_ULP_FUNC_OPC_COPY_SRC1_TO_RF: + res = res1; + break; + case BNXT_ULP_FUNC_OPC_RSS_CONFIG: + /* apply the rss config using pmd method */ + return bnxt_rss_config_action_apply(parms); + case BNXT_ULP_FUNC_OPC_GET_PARENT_MAC_ADDR: + rc = bnxt_pmd_get_parent_mac_addr(parms, (uint8_t *)&res); + if (rc) + return -EINVAL; + res = tfp_be_to_cpu_64(res); + break; + default: + BNXT_TF_DBG(ERR, "invalid func code %u\n", func_info->func_opc); return -EINVAL; } - if (ulp_regfile_write(parms->regfile, cc_upd->cc_dst_opr, + if (ulp_regfile_write(parms->regfile, func_info->func_dst_opr, tfp_cpu_to_be_64(res))) { - BNXT_TF_DBG(ERR, "Failed write the cc_opc %u\n", - cc_upd->cc_dst_opr); + BNXT_TF_DBG(ERR, "Failed write the func_opc %u\n", + func_info->func_dst_opr); return -EINVAL; } @@ -3303,7 +3399,7 @@ ulp_mapper_conflict_resolution_process(struct bnxt_ulp_mapper_parms *parms, { int32_t rc = 0; uint64_t regval; - uint64_t comp_sig_id; + uint64_t comp_sig; *res = 0; switch (tbl->accept_opcode) { @@ -3336,14 +3432,14 @@ ulp_mapper_conflict_resolution_process(struct bnxt_ulp_mapper_parms *parms, BNXT_ULP_RF_IDX_FLOW_SIG_ID); return -EINVAL; } - comp_sig_id = ULP_COMP_FLD_IDX_RD(parms, - BNXT_ULP_CF_IDX_FLOW_SIG_ID); + comp_sig = ULP_COMP_FLD_IDX_RD(parms, + BNXT_ULP_CF_IDX_FLOW_SIG_ID); regval = tfp_be_to_cpu_64(regval); - if (comp_sig_id == regval) + if (comp_sig == regval) *res = 1; else - BNXT_TF_DBG(ERR, "failed signature match %x:%x\n", - (uint32_t)comp_sig_id, (uint32_t)regval); + BNXT_TF_DBG(ERR, "failed signature match 0x%016" + PRIX64 ":%x\n", comp_sig, (uint32_t)regval); break; default: BNXT_TF_DBG(ERR, "Invalid accept opcode %d\n", @@ -3399,8 +3495,9 @@ ulp_mapper_tbls_process(struct bnxt_ulp_mapper_parms *parms, uint32_t tid) for (tbl_idx = 0; tbl_idx < num_tbls && cond_goto;) { tbl = &tbls[tbl_idx]; - /* Process the conditional code update opcodes */ - if (ulp_mapper_cc_upd_info_process(parms, tbl)) { + cond_goto = tbl->execute_info.cond_true_goto; + /* Process the conditional func code opcodes */ + if (ulp_mapper_func_info_process(parms, tbl)) { BNXT_TF_DBG(ERR, "Failed to process cond update\n"); rc = -EINVAL; goto error; @@ -3413,8 +3510,8 @@ ulp_mapper_tbls_process(struct bnxt_ulp_mapper_parms *parms, uint32_t tid) cond_tbls, num_cond_tbls, &cond_rc); if (rc) { - BNXT_TF_DBG(ERR, "Failed to process cond opc list " - "(%d)\n", rc); + BNXT_TF_DBG(ERR, "Failed to proc cond opc list (%d)\n", + rc); goto error; } /* Skip the table if False */ @@ -3515,8 +3612,10 @@ ulp_mapper_resource_free(struct bnxt_ulp_context *ulp, BNXT_TF_DBG(ERR, "Unable to free resource\n "); return -EINVAL; } - - tfp = bnxt_ulp_cntxt_tfp_get(ulp); + if (res->fdb_flags & ULP_FDB_FLAG_SHARED_SESSION) + tfp = bnxt_ulp_cntxt_tfp_get(ulp, BNXT_ULP_SHARED_SESSION_YES); + else + tfp = bnxt_ulp_cntxt_tfp_get(ulp, BNXT_ULP_SHARED_SESSION_NO); if (!tfp) { BNXT_TF_DBG(ERR, "Unable to free resource failed to get tfp\n"); return -EINVAL; @@ -3681,7 +3780,6 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, parms.hdr_field = cparms->hdr_field; parms.fld_bitmap = cparms->fld_bitmap; parms.comp_fld = cparms->comp_fld; - parms.tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx); parms.ulp_ctx = ulp_ctx; parms.act_tid = cparms->act_tid; parms.class_tid = cparms->class_tid; @@ -3694,6 +3792,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, parms.flow_pattern_id = cparms->flow_pattern_id; parms.act_pattern_id = cparms->act_pattern_id; parms.app_id = cparms->app_id; + parms.port_id = cparms->port_id; /* Get the device id from the ulp context */ if (bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &parms.dev_id)) { @@ -3780,7 +3879,7 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx) if (!ulp_ctx) return -EINVAL; - tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx, BNXT_ULP_SHARED_SESSION_NO); if (!tfp) return -EINVAL; @@ -3812,8 +3911,7 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx) if (bnxt_ulp_cntxt_shared_session_enabled(ulp_ctx)) { rc = ulp_mapper_app_glb_resource_info_init(ulp_ctx, data); if (rc) { - BNXT_TF_DBG(ERR, "Failed to initialize app " - "global resources\n"); + BNXT_TF_DBG(ERR, "Failed to init app glb resources\n"); goto error; } } @@ -3840,8 +3938,7 @@ ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx) if (!ulp_ctx) { BNXT_TF_DBG(ERR, - "Failed to acquire ulp context, so data may " - "not be released.\n"); + "Failed to acquire ulp context, so data may not be released.\n"); return; } @@ -3853,7 +3950,7 @@ ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx) return; } - tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx); + tfp = bnxt_ulp_cntxt_tfp_get(ulp_ctx, BNXT_ULP_SHARED_SESSION_NO); if (!tfp) { BNXT_TF_DBG(ERR, "Failed to acquire tfp.\n"); /* Free the mapper data regardless of errors. */