From 4369d847b2fa72f85a171cf4d3a5e41a3ec9d8d6 Mon Sep 17 00:00:00 2001 From: Kishore Padmanabha Date: Thu, 2 Jul 2020 16:28:23 -0700 Subject: [PATCH] net/bnxt: add index opcode and operand to mapper table Extended the regfile and computed field operations to a common index opcode operation and added globlal resource operations are also part of the index opcode operation. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 56 ++++++++++++++++--- drivers/net/bnxt/tf_ulp/ulp_template_db_act.c | 9 ++- .../net/bnxt/tf_ulp/ulp_template_db_class.c | 45 +++++---------- .../net/bnxt/tf_ulp/ulp_template_db_enum.h | 8 +++ drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 4 +- 5 files changed, 80 insertions(+), 42 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 1330a033dd..01514d8c98 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -1443,7 +1443,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct bnxt_ulp_mapper_result_field_info *flds; struct ulp_flow_db_res_params fid_parms; struct ulp_blob data; - uint64_t idx; + uint64_t idx = 0; uint16_t tmplen; uint32_t i, num_flds; int32_t rc = 0, trc = 0; @@ -1516,6 +1516,42 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, #endif } + /* + * Check for index opcode, if it is Global then + * no need to allocate the table, just set the table + * and exit since it is not maintained in the flow db. + */ + if (tbl->index_opcode == BNXT_ULP_INDEX_OPCODE_GLOBAL) { + /* get the index from index operand */ + if (tbl->index_operand < BNXT_ULP_GLB_REGFILE_INDEX_LAST && + ulp_mapper_glb_resource_read(parms->mapper_data, + tbl->direction, + tbl->index_operand, + &idx)) { + BNXT_TF_DBG(ERR, "Glbl regfile[%d] read failed.\n", + tbl->index_operand); + return -EINVAL; + } + /* set the Tf index table */ + sparms.dir = tbl->direction; + sparms.type = tbl->resource_type; + sparms.data = ulp_blob_data_get(&data, &tmplen); + sparms.data_sz_in_bytes = ULP_BITS_2_BYTE(tmplen); + sparms.idx = tfp_be_to_cpu_64(idx); + sparms.tbl_scope_id = tbl_scope_id; + + rc = tf_set_tbl_entry(tfp, &sparms); + if (rc) { + BNXT_TF_DBG(ERR, + "Glbl Set table[%d][%s][%d] failed rc=%d\n", + sparms.type, + (sparms.dir == TF_DIR_RX) ? "RX" : "TX", + sparms.idx, + rc); + return rc; + } + return 0; /* success */ + } /* Perform the tf table allocation by filling the alloc params */ aparms.dir = tbl->direction; aparms.type = tbl->resource_type; @@ -1546,11 +1582,13 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, /* Always storing values in Regfile in BE */ idx = tfp_cpu_to_be_64(idx); - rc = ulp_regfile_write(parms->regfile, tbl->regfile_idx, idx); - if (!rc) { - BNXT_TF_DBG(ERR, "Write regfile[%d] failed\n", - tbl->regfile_idx); - goto error; + if (tbl->index_opcode == BNXT_ULP_INDEX_OPCODE_ALLOCATE) { + rc = ulp_regfile_write(parms->regfile, tbl->index_operand, idx); + if (!rc) { + BNXT_TF_DBG(ERR, "Write regfile[%d] failed\n", + tbl->index_operand); + goto error; + } } /* Perform the tf table set by filling the set params */ @@ -1815,7 +1853,11 @@ ulp_mapper_if_tbl_process(struct bnxt_ulp_mapper_parms *parms, } /* Get the index details from computed field */ - idx = ULP_COMP_FLD_IDX_RD(parms, tbl->comp_field_idx); + if (tbl->index_opcode != BNXT_ULP_INDEX_OPCODE_COMP_FIELD) { + BNXT_TF_DBG(ERR, "Invalid tbl index opcode\n"); + return -EINVAL; + } + idx = ULP_COMP_FLD_IDX_RD(parms, tbl->index_operand); /* Perform the tf table set by filling the set params */ iftbl_params.dir = tbl->direction; diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c index 8af23eff19..9b14fa0bdc 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c @@ -76,7 +76,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = { .result_bit_size = 128, .result_num_fields = 26, .encap_num_fields = 0, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR, + .index_opcode = BNXT_ULP_INDEX_OPCODE_ALLOCATE, + .index_operand = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP }, { @@ -90,7 +91,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = { .result_bit_size = 128, .result_num_fields = 26, .encap_num_fields = 0, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR, + .index_opcode = BNXT_ULP_INDEX_OPCODE_ALLOCATE, + .index_operand = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP }, { @@ -104,7 +106,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = { .result_bit_size = 128, .result_num_fields = 26, .encap_num_fields = 12, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR, + .index_opcode = BNXT_ULP_INDEX_OPCODE_ALLOCATE, + .index_operand = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP } }; diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c index e773afd60d..d4c7bfa4db 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_class.c @@ -113,8 +113,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 0, .ident_nums = 1, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE, @@ -135,8 +134,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 1, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE, @@ -157,8 +155,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 1, .ident_nums = 1, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE, @@ -179,8 +176,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 2, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE, @@ -201,8 +197,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 2, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE, @@ -223,8 +218,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 2, .ident_nums = 1, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE, @@ -245,8 +239,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 3, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE, @@ -267,8 +260,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 3, .ident_nums = 1, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE, @@ -289,8 +281,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 4, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE, @@ -311,8 +302,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 4, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE, @@ -333,8 +323,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 4, .ident_nums = 1, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE, @@ -355,8 +344,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 5, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE, @@ -377,8 +365,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 5, .ident_nums = 1, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE, @@ -399,8 +386,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 6, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_NOP, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO }, { .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE, @@ -421,8 +407,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = { .ident_start_idx = 6, .ident_nums = 0, .mark_db_opcode = BNXT_ULP_MARK_DB_OPCODE_SET_IF_MARK_ACTION, - .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES, - .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED + .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES } }; diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h index 66343b9183..0215a5dde4 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h @@ -161,6 +161,14 @@ enum bnxt_ulp_hdr_type { BNXT_ULP_HDR_TYPE_LAST = 3 }; +enum bnxt_ulp_index_opcode { + BNXT_ULP_INDEX_OPCODE_NOT_USED = 0, + BNXT_ULP_INDEX_OPCODE_ALLOCATE = 1, + BNXT_ULP_INDEX_OPCODE_GLOBAL = 2, + BNXT_ULP_INDEX_OPCODE_COMP_FIELD = 3, + BNXT_ULP_INDEX_OPCODE_LAST = 4 +}; + enum bnxt_ulp_mapper_opc { BNXT_ULP_MAPPER_OPC_SET_TO_CONSTANT = 0, BNXT_ULP_MAPPER_OPC_SET_TO_HDR_FIELD = 1, diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index 1188223aa8..a3ddd33fd7 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -182,9 +182,9 @@ struct bnxt_ulp_mapper_tbl_info { uint32_t ident_start_idx; uint16_t ident_nums; - enum bnxt_ulp_regfile_index regfile_idx; enum bnxt_ulp_mark_db_opcode mark_db_opcode; - uint32_t comp_field_idx; + enum bnxt_ulp_index_opcode index_opcode; + uint32_t index_operand; }; struct bnxt_ulp_mapper_class_key_field_info { -- 2.20.1