From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 86EB6A00BE; Fri, 12 Jun 2020 14:55:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB0BD1B3BB; Fri, 12 Jun 2020 14:55:01 +0200 (CEST) Received: from relay.smtp.broadcom.com (unknown [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id F04D04CA6 for ; Fri, 12 Jun 2020 14:54:58 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id B80AD1BD6A1; Fri, 12 Jun 2020 05:54:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com B80AD1BD6A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591966499; bh=PBK4oVezq9MthssJXF1U/AeA8aXKXo59kvGK77N5tr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMRscixPbaMMe8oKH5s7rQ3kd4EwKOUJ66Nnr1f2mGCJ5WnG8KVEuopnWaGHu0z/d 0Kh1WOUZVB7UZr/S/OCtqiCowSpmCxwNIIFxC2BtPw/pxCcRorvTjhX0PX3bAbKPfE hziAaIMXnqbmHsBRWlJVAg3MB9uRkKNiqt9VFla8= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:19:52 +0530 Message-Id: <20200612125024.15989-5-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200612125024.15989-1-somnath.kotur@broadcom.com> References: <20200612125024.15989-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 04/36] net/bnxt: support for mark action for LFID rules X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kishore Padmanabha The ulp mapper changes to support mark actions for non GFID entries that support only LFID rules. Signed-off-by: Kishore Padmanabha Reviewed-by: Michael Baucom Signed-off-by: Somnath Kotur --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 198 +++++++++++++++++++----------- drivers/net/bnxt/tf_ulp/ulp_mapper.h | 3 +- drivers/net/bnxt/tf_ulp/ulp_template_db.h | 3 +- 3 files changed, 132 insertions(+), 72 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 1a0d577..41800d5 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -313,8 +313,8 @@ ulp_mapper_cache_res_type_get(struct ulp_flow_db_res_params *res, static int32_t ulp_mapper_cache_entry_free(struct bnxt_ulp_context *ulp, - struct tf *tfp, - struct ulp_flow_db_res_params *res) + struct tf *tfp, + struct ulp_flow_db_res_params *res) { struct bnxt_ulp_mapper_cache_entry *cache_entry; struct tf_free_identifier_parms ident_parms; @@ -945,7 +945,7 @@ ulp_mapper_action_info_process(struct bnxt_ulp_mapper_parms *parms, bit_size = BNXT_ULP_FLMP_BLOB_SIZE_IN_BITS; else bit_size = tbl->result_bit_size; - if (!ulp_blob_init(&blob, bit_size, parms->order)) { + if (!ulp_blob_init(&blob, bit_size, parms->device_params->byte_order)) { BNXT_TF_DBG(ERR, "action blob init failed\n"); return -EINVAL; } @@ -968,7 +968,7 @@ ulp_mapper_action_info_process(struct bnxt_ulp_mapper_parms *parms, return rc; } /* set the swap index if 64 bit swap is enabled */ - if (parms->encap_byte_swap && encap_flds) { + if (parms->device_params->encap_byte_swap && encap_flds) { if ((i + 1) == num_flds) ulp_blob_encap_swap_idx_set(&blob); /* if 64 bit swap is enabled perform the 64bit swap */ @@ -982,6 +982,98 @@ ulp_mapper_action_info_process(struct bnxt_ulp_mapper_parms *parms, } static int32_t +ulp_mapper_mark_gfid_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_class_tbl_info *tbl, + uint64_t flow_id) +{ + struct ulp_flow_db_res_params fid_parms; + uint32_t vfr_flag, mark, gfid, mark_flag; + int32_t rc = 0; + + vfr_flag = ULP_UTIL_CHF_IDX_RD(parms, BNXT_ULP_CHF_IDX_VFR_FLAG); + if (!(tbl->mark_enable && + (ULP_BITMAP_ISSET(parms->act_bitmap->bits, + BNXT_ULP_ACTION_BIT_MARK) || vfr_flag))) + return rc; /* no need to perform gfid process */ + + /* Get the mark id details from action property */ + memcpy(&mark, &parms->act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_MARK], + sizeof(mark)); + mark = tfp_be_to_cpu_32(mark); + + TF_GET_GFID_FROM_FLOW_ID(flow_id, gfid); + mark_flag = BNXT_ULP_MARK_GLOBAL_HW_FID; + mark_flag |= (vfr_flag) ? BNXT_ULP_MARK_VFR_ID : 0; + rc = ulp_mark_db_mark_add(parms->ulp_ctx, mark_flag, + gfid, mark); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to add mark to flow\n"); + return rc; + } + fid_parms.direction = tbl->direction; + fid_parms.resource_func = BNXT_ULP_RESOURCE_FUNC_HW_FID; + fid_parms.critical_resource = 0; + fid_parms.resource_type = mark_flag; + fid_parms.resource_hndl = gfid; + rc = ulp_flow_db_resource_add(parms->ulp_ctx, + parms->tbl_idx, + parms->fid, + &fid_parms); + if (rc) + BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", rc); + return rc; +} + +static int32_t +ulp_mapper_mark_act_ptr_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_class_tbl_info *tbl) +{ + struct ulp_flow_db_res_params fid_parms; + uint32_t vfr_flag, act_idx, mark, mark_flag; + uint64_t val64; + int32_t rc = 0; + + vfr_flag = ULP_UTIL_CHF_IDX_RD(parms, BNXT_ULP_CHF_IDX_VFR_FLAG); + if (!(tbl->mark_enable && + (ULP_BITMAP_ISSET(parms->act_bitmap->bits, + BNXT_ULP_ACTION_BIT_MARK) || vfr_flag))) + return rc; /* no need to perform mark action process */ + + /* Get the mark id details from action property */ + memcpy(&mark, &parms->act_prop->act_details[BNXT_ULP_ACT_PROP_IDX_MARK], + sizeof(mark)); + mark = tfp_be_to_cpu_32(mark); + + if (!ulp_regfile_read(parms->regfile, + BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN, + &val64)) { + BNXT_TF_DBG(ERR, "read action ptr main failed\n"); + return -EINVAL; + } + act_idx = tfp_be_to_cpu_64(val64); + mark_flag = BNXT_ULP_MARK_LOCAL_HW_FID; + mark_flag |= (vfr_flag) ? BNXT_ULP_MARK_VFR_ID : 0; + rc = ulp_mark_db_mark_add(parms->ulp_ctx, mark_flag, + act_idx, mark); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to add mark to flow\n"); + return rc; + } + fid_parms.direction = tbl->direction; + fid_parms.resource_func = BNXT_ULP_RESOURCE_FUNC_HW_FID; + fid_parms.critical_resource = 0; + fid_parms.resource_type = mark_flag; + fid_parms.resource_hndl = act_idx; + rc = ulp_flow_db_resource_add(parms->ulp_ctx, + parms->tbl_idx, + parms->fid, + &fid_parms); + if (rc) + BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", rc); + return rc; +} + +static int32_t ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, struct bnxt_ulp_mapper_class_tbl_info *tbl) { @@ -1015,9 +1107,12 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, return -EINVAL; } - if (!ulp_blob_init(&key, tbl->key_bit_size, parms->order) || - !ulp_blob_init(&mask, tbl->key_bit_size, parms->order) || - !ulp_blob_init(&data, tbl->result_bit_size, parms->order)) { + if (!ulp_blob_init(&key, tbl->key_bit_size, + parms->device_params->byte_order) || + !ulp_blob_init(&mask, tbl->key_bit_size, + parms->device_params->byte_order) || + !ulp_blob_init(&data, tbl->result_bit_size, + parms->device_params->byte_order)) { BNXT_TF_DBG(ERR, "blob inits failed.\n"); return -EINVAL; } @@ -1160,6 +1255,11 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms, parms->cache_ptr->tcam_idx = aparms.idx; } + /* Mark action */ + rc = ulp_mapper_mark_act_ptr_process(parms, tbl); + if (rc) + goto error; + } else { BNXT_TF_DBG(ERR, "Not supporting search before alloc now\n"); rc = -EINVAL; @@ -1220,7 +1320,6 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms, uint32_t i, num_kflds, num_dflds; uint16_t tmplen; struct tf *tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx); - struct ulp_rte_act_prop *a_prop = parms->act_prop; 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 }; @@ -1234,8 +1333,10 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms, } /* Initialize the key/result blobs */ - if (!ulp_blob_init(&key, tbl->blob_key_bit_size, parms->order) || - !ulp_blob_init(&data, tbl->result_bit_size, parms->order)) { + if (!ulp_blob_init(&key, tbl->blob_key_bit_size, + parms->device_params->byte_order) || + !ulp_blob_init(&data, tbl->result_bit_size, + parms->device_params->byte_order)) { BNXT_TF_DBG(ERR, "blob inits failed.\n"); return -EINVAL; } @@ -1305,56 +1406,16 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms, return rc; } - if (tbl->mark_enable && - ULP_BITMAP_ISSET(parms->act_bitmap->bits, - BNXT_ULP_ACTION_BIT_MARK)) { - uint32_t val, mark, gfid, flag; - /* TBD: Need to determine if GFID is enabled globally */ - if (sizeof(val) != BNXT_ULP_ACT_PROP_SZ_MARK) { - BNXT_TF_DBG(ERR, "Mark size (%d) != expected (%zu)\n", - BNXT_ULP_ACT_PROP_SZ_MARK, sizeof(val)); - rc = -EINVAL; - goto error; - } - - memcpy(&val, - &a_prop->act_details[BNXT_ULP_ACT_PROP_IDX_MARK], - sizeof(val)); - - mark = tfp_be_to_cpu_32(val); - - TF_GET_GFID_FROM_FLOW_ID(iparms.flow_id, gfid); - flag = BNXT_ULP_MARK_GLOBAL_HW_FID; - rc = ulp_mark_db_mark_add(parms->ulp_ctx, - flag, - gfid, - mark); - if (rc) { - BNXT_TF_DBG(ERR, "Failed to add mark to flow\n"); - goto error; - } - - /* - * Link the mark resource to the flow in the flow db - * The mark is never the critical resource, so it is 0. - */ - memset(&fid_parms, 0, sizeof(fid_parms)); - fid_parms.direction = tbl->direction; - fid_parms.resource_func = BNXT_ULP_RESOURCE_FUNC_HW_FID; - fid_parms.resource_type = flag; - fid_parms.resource_hndl = gfid; - fid_parms.critical_resource = 0; - - rc = ulp_flow_db_resource_add(parms->ulp_ctx, - parms->tbl_idx, - parms->fid, - &fid_parms); - if (rc) { - BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n", - rc); - /* Need to free the identifier, so goto error */ - goto error; - } + /* Mark action process */ + if (parms->device_params->global_fid_enable && + tbl->table_type == TF_MEM_EXTERNAL) + rc = ulp_mapper_mark_gfid_process(parms, tbl, iparms.flow_id); + else if (!parms->device_params->global_fid_enable && + tbl->table_type == TF_MEM_INTERNAL) + rc = ulp_mapper_mark_act_ptr_process(parms, tbl); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to add mark to flow\n"); + goto error; } /* Link the EM resource to the flow in the flow db */ @@ -1409,7 +1470,8 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms, bnxt_ulp_cntxt_tbl_scope_id_get(parms->ulp_ctx, &tbl_scope_id); - if (!ulp_blob_init(&data, tbl->result_bit_size, parms->order)) { + if (!ulp_blob_init(&data, tbl->result_bit_size, + parms->device_params->byte_order)) { BNXT_TF_DBG(ERR, "Failed initial index table blob\n"); return -EINVAL; } @@ -1538,7 +1600,8 @@ ulp_mapper_cache_tbl_process(struct bnxt_ulp_mapper_parms *parms, BNXT_TF_DBG(ERR, "Failed to get key fields\n"); return -EINVAL; } - if (!ulp_blob_init(&key, tbl->key_bit_size, parms->order)) { + if (!ulp_blob_init(&key, tbl->key_bit_size, + parms->device_params->byte_order)) { BNXT_TF_DBG(ERR, "Failed to alloc blob\n"); return -EINVAL; } @@ -1858,7 +1921,6 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, struct bnxt_ulp_mapper_create_parms *cparms, uint32_t *flowid) { - struct bnxt_ulp_device_params *device_params; struct bnxt_ulp_mapper_parms parms; struct ulp_regfile regfile; int32_t rc, trc; @@ -1916,15 +1978,13 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, return -EINVAL; } - /* Get the byte order for the further processing from device params */ - device_params = bnxt_ulp_device_params_get(parms.dev_id); - if (!device_params) { + /* Get the device params, it will be used in later processing */ + parms.device_params = bnxt_ulp_device_params_get(parms.dev_id); + if (!parms.device_params) { BNXT_TF_DBG(ERR, "No class tables for %d:%d\n", parms.dev_id, parms.class_tid); return -EINVAL; } - parms.order = device_params->byte_order; - parms.encap_byte_swap = device_params->encap_byte_swap; /* initialize the registry file for further processing */ if (!ulp_regfile_init(parms.regfile)) { @@ -2033,7 +2093,7 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx) /* All regfile entries are stored as 64bit big-endian values. */ regval = tfp_cpu_to_be_64((uint64_t)iparms.id); rc = ulp_mapper_def_regfile_write(data, iparms.dir, - reg_idx, regval); + reg_idx, regval); if (rc) { BNXT_TF_DBG(ERR, "Failed to write to default " "regfile.\n"); diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h index e794795..0754e39 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h @@ -57,7 +57,6 @@ struct bnxt_ulp_mapper_data { /* Internal Structure for passing the arguments around */ struct bnxt_ulp_mapper_parms { uint32_t dev_id; - enum bnxt_ulp_byte_order order; uint32_t act_tid; struct bnxt_ulp_mapper_act_tbl_info *atbls; uint32_t num_atbls; @@ -71,12 +70,12 @@ struct bnxt_ulp_mapper_parms { struct ulp_regfile *regfile; struct tf *tfp; struct bnxt_ulp_context *ulp_ctx; - uint8_t encap_byte_swap; uint32_t fid; enum bnxt_ulp_flow_db_tables tbl_idx; struct bnxt_ulp_mapper_data *mapper_data; enum bnxt_ulp_cache_table_opc tcam_tbl_opc; struct bnxt_ulp_mapper_cache_entry *cache_ptr; + struct bnxt_ulp_device_params *device_params; }; struct bnxt_ulp_mapper_create_parms { diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.h b/drivers/net/bnxt/tf_ulp/ulp_template_db.h index 212068f..fcd80d9 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.h @@ -111,7 +111,8 @@ enum bnxt_ulp_chf_idx { BNXT_ULP_CHF_IDX_I_L3 = 11, BNXT_ULP_CHF_IDX_O_L4 = 12, BNXT_ULP_CHF_IDX_I_L4 = 13, - BNXT_ULP_CHF_IDX_LAST = 14 + BNXT_ULP_CHF_IDX_VFR_FLAG = 14, + BNXT_ULP_CHF_IDX_LAST = 15 }; enum bnxt_ulp_def_regfile_index { -- 2.7.4