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 A97A8A0563; Wed, 15 Apr 2020 10:24:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3AD791D5CC; Wed, 15 Apr 2020 10:20:17 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 65B5F1D560 for ; Wed, 15 Apr 2020 10:20:15 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id c138so1206615pfc.0 for ; Wed, 15 Apr 2020 01:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zb8KVfgjCwaD6/lNHV0J0jgYZSLNjFDtQeZ9yuUqcuc=; b=df+TTUU06bM0H31cIvTkp3j+CGdwO5ENX9ghiCqGDd/sEbtTDZ52suM05Xseh8dSGU 32Jb4Kt1/lpA3wOw8LgBp4N5acGFrGC3kh54nkcThZrmPMZHOz+ca+i0KOB5r7g2Df0z jqJUqelsCAhLchtmv7qRMiTxLBbYeZc0Sn7zA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zb8KVfgjCwaD6/lNHV0J0jgYZSLNjFDtQeZ9yuUqcuc=; b=Q76IKEDewNnEuzCxYfH3bhxcbNCGeToQslOS3K0IDc14PjD6eAXA585UdrGQzkz48w RrO9yMRoJmNPqWYcnBHidZd3/0BE8SgD5iClxu3952yBnJOaT0x264VfEePxBUWfeGXZ hgYksn6Jg6DCxdF+436hozWun4A4CM9N+8B9V0S2inmeY5YapoJOcTZops9ZDsG56UDU PSmEuFGNl36wvIVMynL95tiZbr79piEyWpnZsfvKtAx5rAUcT9/fvNeN0XFzTCWpf6AB yIuZQf8Jexki2JzfO9xFuMABiqO/Z6WQp6/9Lh7FDr7yZH0JNUE4e7r316yg6uySIG7c mxTA== X-Gm-Message-State: AGi0PubFQujUbMEWwdsptkyQIFwi5EmcJAj19BxZEFPpPalhxCiBORN4 el4nDjXYFQ51hPYoQbAFOkW9W2xnmBv7rocgeIvzq11m8T5biphXtjasXcf2iq76m5gLwTdWWJq JH1NSIV750C0FUHxRxCy2dXLHwCaS3VfL4D/VveBStKsbkfy0ypFK7rcfZpgtjlDUJXFF X-Google-Smtp-Source: APiQypKrKhfThW8RhbDGB2hSxwtPCkdRNtPf/VAMB/kw8P3bt4Zcjlb0r2la1gVXu1yb5sSh+c9udg== X-Received: by 2002:a62:e30f:: with SMTP id g15mr674777pfh.150.1586938813385; Wed, 15 Apr 2020 01:20:13 -0700 (PDT) Received: from S60.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id fy21sm3819019pjb.25.2020.04.15.01.20.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2020 01:20:12 -0700 (PDT) From: Venkat Duvvuru To: dev@dpdk.org Cc: Mike Baucom , Kishore Padmanabha , Venkat Duvvuru Date: Wed, 15 Apr 2020 13:48:56 +0530 Message-Id: <1586938751-32808-20-git-send-email-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> References: <1586852011-37536-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <1586938751-32808-1-git-send-email-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v4 19/34] net/bnxt: add support to process action tables 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: Mike Baucom This patch processes the action template. Iterates through the list of action info templates and processes it. Signed-off-by: Mike Baucom Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Lance Richardson --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 136 ++++++++++ drivers/net/bnxt/tf_ulp/ulp_flow_db.h | 25 ++ drivers/net/bnxt/tf_ulp/ulp_mapper.c | 364 ++++++++++++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_mapper.h | 39 +++ drivers/net/bnxt/tf_ulp/ulp_template_db.c | 245 +++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_template_db.h | 104 ++++++++ drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 48 +++- 8 files changed, 959 insertions(+), 3 deletions(-) create mode 100644 drivers/net/bnxt/tf_ulp/ulp_mapper.c create mode 100644 drivers/net/bnxt/tf_ulp/ulp_mapper.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 4e0dea1..f464d9e 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -62,6 +62,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mark_mgr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_flow_db.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_template_db.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_utils.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mapper.c # # Export include files diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c index 3dd39c1..6e73f25 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c @@ -7,7 +7,68 @@ #include "bnxt.h" #include "bnxt_tf_common.h" #include "ulp_flow_db.h" +#include "ulp_utils.h" #include "ulp_template_struct.h" +#include "ulp_mapper.h" + +#define ULP_FLOW_DB_RES_DIR_BIT 31 +#define ULP_FLOW_DB_RES_DIR_MASK 0x80000000 +#define ULP_FLOW_DB_RES_FUNC_BITS 28 +#define ULP_FLOW_DB_RES_FUNC_MASK 0x70000000 +#define ULP_FLOW_DB_RES_NXT_MASK 0x0FFFFFFF + +/* Macro to copy the nxt_resource_idx */ +#define ULP_FLOW_DB_RES_NXT_SET(dst, src) {(dst) |= ((src) &\ + ULP_FLOW_DB_RES_NXT_MASK); } +#define ULP_FLOW_DB_RES_NXT_RESET(dst) ((dst) &= ~(ULP_FLOW_DB_RES_NXT_MASK)) + +/* + * Helper function to allocate the flow table and initialize + * is set.No validation being done in this function. + * + * flow_tbl [in] Ptr to flow table + * idx [in] The index to bit to be set or reset. + * + * returns 1 on set or 0 if not set. + */ +static int32_t +ulp_flow_db_active_flow_is_set(struct bnxt_ulp_flow_tbl *flow_tbl, + uint32_t idx) +{ + uint32_t active_index; + + active_index = idx / ULP_INDEX_BITMAP_SIZE; + return ULP_INDEX_BITMAP_GET(flow_tbl->active_flow_tbl[active_index], + idx); +} + +/* + * Helper function to copy the resource params to resource info + * No validation being done in this function. + * + * resource_info [out] Ptr to resource information + * params [in] The input params from the caller + * returns none + */ +static void +ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info *resource_info, + struct ulp_flow_db_res_params *params) +{ + resource_info->nxt_resource_idx |= ((params->direction << + ULP_FLOW_DB_RES_DIR_BIT) & + ULP_FLOW_DB_RES_DIR_MASK); + resource_info->nxt_resource_idx |= ((params->resource_func << + ULP_FLOW_DB_RES_FUNC_BITS) & + ULP_FLOW_DB_RES_FUNC_MASK); + + if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EM_TABLE) { + resource_info->resource_hndl = (uint32_t)params->resource_hndl; + resource_info->resource_type = params->resource_type; + + } else { + resource_info->resource_em_handle = params->resource_hndl; + } +} /* * Helper function to allocate the flow table and initialize @@ -185,3 +246,78 @@ int32_t ulp_flow_db_deinit(struct bnxt_ulp_context *ulp_ctxt) return 0; } + +/* + * Allocate the flow database entry. + * The params->critical_resource has to be set to 0 to allocate a new resource. + * + * ulp_ctxt [in] Ptr to ulp_context + * tbl_idx [in] Specify it is regular or default flow + * fid [in] The index to the flow entry + * params [in] The contents to be copied into resource + * + * returns 0 on success and negative on failure. + */ +int32_t ulp_flow_db_resource_add(struct bnxt_ulp_context *ulp_ctxt, + enum bnxt_ulp_flow_db_tables tbl_idx, + uint32_t fid, + struct ulp_flow_db_res_params *params) +{ + struct bnxt_ulp_flow_db *flow_db; + struct bnxt_ulp_flow_tbl *flow_tbl; + struct ulp_fdb_resource_info *resource, *fid_resource; + uint32_t idx; + + flow_db = bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctxt); + if (!flow_db) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + + if (tbl_idx >= BNXT_ULP_FLOW_TABLE_MAX) { + BNXT_TF_DBG(ERR, "Invalid table index\n"); + return -EINVAL; + } + flow_tbl = &flow_db->flow_tbl[tbl_idx]; + + /* check for max flows */ + if (fid >= flow_tbl->num_flows || !fid) { + BNXT_TF_DBG(ERR, "Invalid flow index\n"); + return -EINVAL; + } + + /* check if the flow is active or not */ + if (!ulp_flow_db_active_flow_is_set(flow_tbl, fid)) { + BNXT_TF_DBG(ERR, "flow does not exist\n"); + return -EINVAL; + } + + /* check for max resource */ + if ((flow_tbl->num_flows + 1) >= flow_tbl->tail_index) { + BNXT_TF_DBG(ERR, "Flow db has reached max resources\n"); + return -ENOMEM; + } + fid_resource = &flow_tbl->flow_resources[fid]; + + if (!params->critical_resource) { + /* Not the critical_resource so allocate a resource */ + idx = flow_tbl->flow_tbl_stack[flow_tbl->tail_index]; + resource = &flow_tbl->flow_resources[idx]; + flow_tbl->tail_index--; + + /* Update the chain list of resource*/ + ULP_FLOW_DB_RES_NXT_SET(resource->nxt_resource_idx, + fid_resource->nxt_resource_idx); + /* update the contents */ + ulp_flow_db_res_params_to_info(resource, params); + ULP_FLOW_DB_RES_NXT_RESET(fid_resource->nxt_resource_idx); + ULP_FLOW_DB_RES_NXT_SET(fid_resource->nxt_resource_idx, + idx); + } else { + /* critical resource. Just update the fid resource */ + ulp_flow_db_res_params_to_info(fid_resource, params); + } + + /* all good, return success */ + return 0; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h index a2ee8fa..f6055a5 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.h @@ -53,6 +53,15 @@ struct bnxt_ulp_flow_db { struct bnxt_ulp_flow_tbl flow_tbl[BNXT_ULP_FLOW_TABLE_MAX]; }; +/* flow db resource params to add resources */ +struct ulp_flow_db_res_params { + enum tf_dir direction; + enum bnxt_ulp_resource_func resource_func; + uint64_t resource_hndl; + uint32_t resource_type; + uint32_t critical_resource; +}; + /* * Initialize the flow database. Memory is allocated in this * call and assigned to the flow database. @@ -74,4 +83,20 @@ int32_t ulp_flow_db_init(struct bnxt_ulp_context *ulp_ctxt); */ int32_t ulp_flow_db_deinit(struct bnxt_ulp_context *ulp_ctxt); +/* + * Allocate the flow database entry. + * The params->critical_resource has to be set to 0 to allocate a new resource. + * + * ulp_ctxt [in] Ptr to ulp_context + * tbl_idx [in] Specify it is regular or default flow + * fid [in] The index to the flow entry + * params [in] The contents to be copied into resource + * + * returns 0 on success and negative on failure. + */ +int32_t ulp_flow_db_resource_add(struct bnxt_ulp_context *ulp_ctxt, + enum bnxt_ulp_flow_db_tables tbl_idx, + uint32_t fid, + struct ulp_flow_db_res_params *params); + #endif /* _ULP_FLOW_DB_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c new file mode 100644 index 0000000..9cfc382 --- /dev/null +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -0,0 +1,364 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2020 Broadcom + * All rights reserved. + */ + +#include +#include "bnxt.h" +#include "ulp_template_db.h" +#include "ulp_template_struct.h" +#include "bnxt_tf_common.h" +#include "ulp_utils.h" +#include "bnxt_ulp.h" +#include "tfp.h" +#include "tf_ext_flow_handle.h" +#include "ulp_mark_mgr.h" +#include "ulp_flow_db.h" +#include "ulp_mapper.h" + +int32_t +ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms); + +/* + * Get the size of the action property for a given index. + * + * idx [in] The index for the action property + * + * returns the size of the action property. + */ +static uint32_t +ulp_mapper_act_prop_size_get(uint32_t idx) +{ + if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) + return 0; + return ulp_act_prop_map_table[idx]; +} + +/* + * Get the list of result fields that implement the flow action + * + * tbl [in] A single table instance to get the results fields + * from num_flds [out] The number of data fields in the returned + * array + * returns array of data fields, or NULL on error + */ +static struct bnxt_ulp_mapper_result_field_info * +ulp_mapper_act_result_fields_get(struct bnxt_ulp_mapper_act_tbl_info *tbl, + uint32_t *num_rslt_flds, + uint32_t *num_encap_flds) +{ + uint32_t idx; + + if (!tbl || !num_rslt_flds || !num_encap_flds) + return NULL; + + idx = tbl->result_start_idx; + *num_rslt_flds = tbl->result_num_fields; + *num_encap_flds = tbl->encap_num_fields; + + /* NOTE: Need template to provide range checking define */ + return &ulp_act_result_field_list[idx]; +} + +static int32_t +ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_result_field_info *fld, + struct ulp_blob *blob) +{ + uint16_t idx, size_idx; + uint8_t *val = NULL; + uint64_t regval; + uint32_t val_size = 0, field_size = 0; + + switch (fld->result_opcode) { + case BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT: + val = fld->result_operand; + if (!ulp_blob_push(blob, val, fld->field_bit_size)) { + BNXT_TF_DBG(ERR, "Failed to add field\n"); + return -EINVAL; + } + break; + case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP: + if (!ulp_operand_read(fld->result_operand, + (uint8_t *)&idx, sizeof(uint16_t))) { + BNXT_TF_DBG(ERR, "operand read failed\n"); + return -EINVAL; + } + idx = tfp_be_to_cpu_16(idx); + + if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) { + BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", idx); + return -EINVAL; + } + val = &parms->act_prop->act_details[idx]; + field_size = ulp_mapper_act_prop_size_get(idx); + if (fld->field_bit_size < ULP_BYTE_2_BITS(field_size)) { + field_size = field_size - + ((fld->field_bit_size + 7) / 8); + val += field_size; + } + if (!ulp_blob_push(blob, val, fld->field_bit_size)) { + BNXT_TF_DBG(ERR, "push field failed\n"); + return -EINVAL; + } + break; + case BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP_SZ: + if (!ulp_operand_read(fld->result_operand, + (uint8_t *)&idx, sizeof(uint16_t))) { + BNXT_TF_DBG(ERR, "operand read failed\n"); + return -EINVAL; + } + idx = tfp_be_to_cpu_16(idx); + + if (idx >= BNXT_ULP_ACT_PROP_IDX_LAST) { + BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", idx); + return -EINVAL; + } + val = &parms->act_prop->act_details[idx]; + + /* get the size index next */ + if (!ulp_operand_read(&fld->result_operand[sizeof(uint16_t)], + (uint8_t *)&size_idx, sizeof(uint16_t))) { + BNXT_TF_DBG(ERR, "operand read failed\n"); + return -EINVAL; + } + size_idx = tfp_be_to_cpu_16(size_idx); + + if (size_idx >= BNXT_ULP_ACT_PROP_IDX_LAST) { + BNXT_TF_DBG(ERR, "act_prop[%d] oob\n", size_idx); + return -EINVAL; + } + memcpy(&val_size, &parms->act_prop->act_details[size_idx], + sizeof(uint32_t)); + val_size = tfp_be_to_cpu_32(val_size); + val_size = ULP_BYTE_2_BITS(val_size); + ulp_blob_push_encap(blob, val, val_size); + break; + case BNXT_ULP_RESULT_OPC_SET_TO_REGFILE: + if (!ulp_operand_read(fld->result_operand, + (uint8_t *)&idx, sizeof(uint16_t))) { + BNXT_TF_DBG(ERR, "operand read failed\n"); + return -EINVAL; + } + + idx = tfp_be_to_cpu_16(idx); + /* Uninitialized regfile entries return 0 */ + if (!ulp_regfile_read(parms->regfile, idx, ®val)) { + BNXT_TF_DBG(ERR, "regfile[%d] read oob\n", idx); + return -EINVAL; + } + + val = ulp_blob_push_64(blob, ®val, fld->field_bit_size); + if (!val) { + BNXT_TF_DBG(ERR, "push field failed\n"); + return -EINVAL; + } + break; + default: + return -EINVAL; + } + + return 0; +} + +/* Function to alloc action record and set the table. */ +static int32_t +ulp_mapper_action_alloc_and_set(struct bnxt_ulp_mapper_parms *parms, + struct ulp_blob *blob) +{ + struct ulp_flow_db_res_params fid_parms; + struct tf_alloc_tbl_entry_parms alloc_parms = { 0 }; + struct tf_free_tbl_entry_parms free_parms = { 0 }; + struct bnxt_ulp_mapper_act_tbl_info *atbls = parms->atbls; + int32_t rc = 0; + int32_t trc; + uint64_t idx; + + /* Set the allocation parameters for the table*/ + alloc_parms.dir = atbls->direction; + alloc_parms.type = atbls->table_type; + alloc_parms.search_enable = atbls->srch_b4_alloc; + alloc_parms.result = ulp_blob_data_get(blob, + &alloc_parms.result_sz_in_bytes); + if (!alloc_parms.result) { + BNXT_TF_DBG(ERR, "blob is not populated\n"); + return -EINVAL; + } + + rc = tf_alloc_tbl_entry(parms->tfp, &alloc_parms); + if (rc) { + BNXT_TF_DBG(ERR, "table type= [%d] dir = [%s] alloc failed\n", + alloc_parms.type, + (alloc_parms.dir == TF_DIR_RX) ? "RX" : "TX"); + return rc; + } + + /* Need to calculate the idx for the result record */ + /* + * TBD: Need to get the stride from tflib instead of having to + * understand the constrution of the pointer + */ + uint64_t tmpidx = alloc_parms.idx; + + if (atbls->table_type == TF_TBL_TYPE_EXT) + tmpidx = (alloc_parms.idx * TF_ACTION_RECORD_SZ) >> 4; + else + tmpidx = alloc_parms.idx; + + idx = tfp_cpu_to_be_64(tmpidx); + + /* Store the allocated index for future use in the regfile */ + rc = ulp_regfile_write(parms->regfile, atbls->regfile_wr_idx, idx); + if (!rc) { + BNXT_TF_DBG(ERR, "regfile[%d] write failed\n", + atbls->regfile_wr_idx); + rc = -EINVAL; + goto error; + } + + /* + * The set_tbl_entry API if search is not enabled or searched entry + * is not found. + */ + if (!atbls->srch_b4_alloc || !alloc_parms.hit) { + struct tf_set_tbl_entry_parms set_parm = { 0 }; + uint16_t length; + + set_parm.dir = atbls->direction; + set_parm.type = atbls->table_type; + set_parm.idx = alloc_parms.idx; + set_parm.data = ulp_blob_data_get(blob, &length); + set_parm.data_sz_in_bytes = length / 8; + + if (set_parm.type == TF_TBL_TYPE_EXT) + bnxt_ulp_cntxt_tbl_scope_id_get(parms->ulp_ctx, + &set_parm.tbl_scope_id); + else + set_parm.tbl_scope_id = 0; + + /* set the table entry */ + rc = tf_set_tbl_entry(parms->tfp, &set_parm); + if (rc) { + BNXT_TF_DBG(ERR, "table[%d][%s][%d] set failed\n", + set_parm.type, + (set_parm.dir == TF_DIR_RX) ? "RX" : "TX", + set_parm.idx); + goto error; + } + } + + /* Link the resource to the flow in the flow db */ + memset(&fid_parms, 0, sizeof(fid_parms)); + fid_parms.direction = atbls->direction; + fid_parms.resource_func = atbls->resource_func; + fid_parms.resource_type = atbls->table_type; + fid_parms.resource_hndl = alloc_parms.idx; + 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, "Failed to link resource to flow rc = %d\n", + rc); + rc = -EINVAL; + goto error; + } + + return 0; +error: + + free_parms.dir = alloc_parms.dir; + free_parms.type = alloc_parms.type; + free_parms.idx = alloc_parms.idx; + + trc = tf_free_tbl_entry(parms->tfp, &free_parms); + if (trc) + BNXT_TF_DBG(ERR, "Failed to free table entry on failure\n"); + + return rc; +} + +/* + * Function to process the action Info. Iterate through the list + * action info templates and process it. + */ +static int32_t +ulp_mapper_action_info_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_act_tbl_info *tbl) +{ + struct ulp_blob blob; + struct bnxt_ulp_mapper_result_field_info *flds, *fld; + uint32_t num_flds = 0; + uint32_t encap_flds = 0; + uint32_t i; + int32_t rc; + uint16_t bit_size; + + if (!tbl || !parms->act_prop || !parms->act_bitmap || !parms->regfile) + return -EINVAL; + + /* 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; + if (!ulp_blob_init(&blob, bit_size, parms->order)) { + BNXT_TF_DBG(ERR, "action blob init failed\n"); + return -EINVAL; + } + + flds = ulp_mapper_act_result_fields_get(tbl, &num_flds, &encap_flds); + if (!flds || !num_flds) { + BNXT_TF_DBG(ERR, "Template undefined for action\n"); + return -EINVAL; + } + + for (i = 0; i < (num_flds + encap_flds); i++) { + fld = &flds[i]; + rc = ulp_mapper_result_field_process(parms, + fld, + &blob); + if (rc) { + BNXT_TF_DBG(ERR, "Action field failed\n"); + return rc; + } + /* set the swap index if 64 bit swap is enabled */ + if (parms->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 */ + if ((i + 1) == (num_flds + encap_flds)) + ulp_blob_perform_encap_swap(&blob); + } + } + + rc = ulp_mapper_action_alloc_and_set(parms, &blob); + return rc; +} + +/* + * Function to process the action template. Iterate through the list + * action info templates and process it. + */ +int32_t +ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms) +{ + uint32_t i; + int32_t rc = 0; + + if (!parms->atbls || !parms->num_atbls) { + BNXT_TF_DBG(ERR, "No action tables for template[%d][%d].\n", + parms->dev_id, parms->act_tid); + return -EINVAL; + } + + for (i = 0; i < parms->num_atbls; i++) { + rc = ulp_mapper_action_info_process(parms, &parms->atbls[i]); + if (rc) + return rc; + } + + return rc; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h new file mode 100644 index 0000000..adbcec2 --- /dev/null +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2019 Broadcom + * All rights reserved. + */ + +#ifndef _ULP_MAPPER_H_ +#define _ULP_MAPPER_H_ + +#include +#include +#include +#include +#include "ulp_template_db.h" +#include "ulp_template_struct.h" +#include "bnxt_ulp.h" +#include "ulp_utils.h" + +/* 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; + uint32_t class_tid; + struct bnxt_ulp_mapper_class_tbl_info *ctbls; + uint32_t num_ctbls; + struct ulp_rte_act_prop *act_prop; + struct ulp_rte_act_bitmap *act_bitmap; + struct ulp_rte_hdr_field *hdr_field; + 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; +}; + +#endif /* _ULP_MAPPER_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.c b/drivers/net/bnxt/tf_ulp/ulp_template_db.c index 9670635..fc77800 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.c @@ -11,6 +11,89 @@ #include "ulp_template_db.h" #include "ulp_template_struct.h" +uint32_t ulp_act_prop_map_table[] = { + [BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN_SZ] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_TUN_SZ, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SZ] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_IP_SZ, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_SZ] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG_SZ, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_TYPE] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG_TYPE, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_NUM] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG_NUM, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_L3_TYPE, + [BNXT_ULP_ACT_PROP_IDX_MPLS_POP_NUM] = + BNXT_ULP_ACT_PROP_SZ_MPLS_POP_NUM, + [BNXT_ULP_ACT_PROP_IDX_MPLS_PUSH_NUM] = + BNXT_ULP_ACT_PROP_SZ_MPLS_PUSH_NUM, + [BNXT_ULP_ACT_PROP_IDX_VNIC] = + BNXT_ULP_ACT_PROP_SZ_VNIC, + [BNXT_ULP_ACT_PROP_IDX_VPORT] = + BNXT_ULP_ACT_PROP_SZ_VPORT, + [BNXT_ULP_ACT_PROP_IDX_MARK] = + BNXT_ULP_ACT_PROP_SZ_MARK, + [BNXT_ULP_ACT_PROP_IDX_COUNT] = + BNXT_ULP_ACT_PROP_SZ_COUNT, + [BNXT_ULP_ACT_PROP_IDX_METER] = + BNXT_ULP_ACT_PROP_SZ_METER, + [BNXT_ULP_ACT_PROP_IDX_SET_MAC_SRC] = + BNXT_ULP_ACT_PROP_SZ_SET_MAC_SRC, + [BNXT_ULP_ACT_PROP_IDX_SET_MAC_DST] = + BNXT_ULP_ACT_PROP_SZ_SET_MAC_DST, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_VLAN] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_VLAN, + [BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_PCP] = + BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_PCP, + [BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_VID] = + BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_VID, + [BNXT_ULP_ACT_PROP_IDX_SET_IPV4_SRC] = + BNXT_ULP_ACT_PROP_SZ_SET_IPV4_SRC, + [BNXT_ULP_ACT_PROP_IDX_SET_IPV4_DST] = + BNXT_ULP_ACT_PROP_SZ_SET_IPV4_DST, + [BNXT_ULP_ACT_PROP_IDX_SET_IPV6_SRC] = + BNXT_ULP_ACT_PROP_SZ_SET_IPV6_SRC, + [BNXT_ULP_ACT_PROP_IDX_SET_IPV6_DST] = + BNXT_ULP_ACT_PROP_SZ_SET_IPV6_DST, + [BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC] = + BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC, + [BNXT_ULP_ACT_PROP_IDX_SET_TP_DST] = + BNXT_ULP_ACT_PROP_SZ_SET_TP_DST, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_0] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_0, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_1] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_1, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_2] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_2, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_3] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_3, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_4] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_4, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_5] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_5, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_6] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_6, + [BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_7] = + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_7, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_DMAC, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_SMAC, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_IP] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_IP, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_IP_SRC, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_UDP, + [BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN] = + BNXT_ULP_ACT_PROP_SZ_ENCAP_TUN, + [BNXT_ULP_ACT_PROP_IDX_LAST] = + BNXT_ULP_ACT_PROP_SZ_LAST +}; + struct bnxt_ulp_device_params ulp_device_params[] = { [BNXT_ULP_DEVICE_ID_WH_PLUS] = { .global_fid_enable = BNXT_ULP_SYM_YES, @@ -25,3 +108,165 @@ struct bnxt_ulp_device_params ulp_device_params[] = { .num_resources_per_flow = 8 } }; + +struct bnxt_ulp_mapper_result_field_info ulp_act_result_field_list[] = { + { + .field_bit_size = 14, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 8, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 11, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 10, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 16, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 10, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 16, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 10, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 4, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {BNXT_ULP_SYM_DECAP_FUNC_NONE, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 12, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP, + .result_operand = {(BNXT_ULP_ACT_PROP_IDX_VNIC >> 8) & 0xff, + BNXT_ULP_ACT_PROP_IDX_VNIC & 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 2, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + }, + { + .field_bit_size = 1, + .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT, + .result_operand = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + } +}; diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db.h b/drivers/net/bnxt/tf_ulp/ulp_template_db.h index 1eed828..e52cc3f 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db.h @@ -39,9 +39,113 @@ enum bnxt_ulp_regfile_index { BNXT_ULP_REGFILE_INDEX_LAST }; +enum bnxt_ulp_resource_func { + BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0, + BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 1, + BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 2, + BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 3, + BNXT_ULP_RESOURCE_FUNC_HW_FID = 4, + BNXT_ULP_RESOURCE_FUNC_LAST = 5 +}; + +enum bnxt_ulp_result_opc { + BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT = 0, + BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP = 1, + BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP_SZ = 2, + BNXT_ULP_RESULT_OPC_SET_TO_REGFILE = 3, + BNXT_ULP_RESULT_OPC_LAST = 4 +}; + enum bnxt_ulp_sym { + BNXT_ULP_SYM_DECAP_FUNC_NONE = 0, BNXT_ULP_SYM_LITTLE_ENDIAN = 1, BNXT_ULP_SYM_YES = 1 }; +enum bnxt_ulp_act_prop_sz { + BNXT_ULP_ACT_PROP_SZ_ENCAP_TUN_SZ = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_IP_SZ = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG_SZ = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG_TYPE = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG_NUM = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_L3_TYPE = 4, + BNXT_ULP_ACT_PROP_SZ_MPLS_POP_NUM = 4, + BNXT_ULP_ACT_PROP_SZ_MPLS_PUSH_NUM = 4, + BNXT_ULP_ACT_PROP_SZ_VNIC = 4, + BNXT_ULP_ACT_PROP_SZ_VPORT = 4, + BNXT_ULP_ACT_PROP_SZ_MARK = 4, + BNXT_ULP_ACT_PROP_SZ_COUNT = 4, + BNXT_ULP_ACT_PROP_SZ_METER = 4, + BNXT_ULP_ACT_PROP_SZ_SET_MAC_SRC = 8, + BNXT_ULP_ACT_PROP_SZ_SET_MAC_DST = 8, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_VLAN = 4, + BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_PCP = 4, + BNXT_ULP_ACT_PROP_SZ_OF_SET_VLAN_VID = 4, + BNXT_ULP_ACT_PROP_SZ_SET_IPV4_SRC = 4, + BNXT_ULP_ACT_PROP_SZ_SET_IPV4_DST = 4, + BNXT_ULP_ACT_PROP_SZ_SET_IPV6_SRC = 16, + BNXT_ULP_ACT_PROP_SZ_SET_IPV6_DST = 16, + BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC = 4, + BNXT_ULP_ACT_PROP_SZ_SET_TP_DST = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_0 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_1 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_2 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_3 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_4 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_5 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_6 = 4, + BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_7 = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_DMAC = 6, + BNXT_ULP_ACT_PROP_SZ_ENCAP_L2_SMAC = 6, + BNXT_ULP_ACT_PROP_SZ_ENCAP_VTAG = 8, + BNXT_ULP_ACT_PROP_SZ_ENCAP_IP = 32, + BNXT_ULP_ACT_PROP_SZ_ENCAP_IP_SRC = 16, + BNXT_ULP_ACT_PROP_SZ_ENCAP_UDP = 4, + BNXT_ULP_ACT_PROP_SZ_ENCAP_TUN = 32, + BNXT_ULP_ACT_PROP_SZ_LAST = 4 +}; + +enum bnxt_ulp_act_prop_idx { + BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN_SZ = 0, + BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SZ = 4, + BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_SZ = 8, + BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_TYPE = 12, + BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG_NUM = 16, + BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE = 20, + BNXT_ULP_ACT_PROP_IDX_MPLS_POP_NUM = 24, + BNXT_ULP_ACT_PROP_IDX_MPLS_PUSH_NUM = 28, + BNXT_ULP_ACT_PROP_IDX_VNIC = 32, + BNXT_ULP_ACT_PROP_IDX_VPORT = 36, + BNXT_ULP_ACT_PROP_IDX_MARK = 40, + BNXT_ULP_ACT_PROP_IDX_COUNT = 44, + BNXT_ULP_ACT_PROP_IDX_METER = 48, + BNXT_ULP_ACT_PROP_IDX_SET_MAC_SRC = 52, + BNXT_ULP_ACT_PROP_IDX_SET_MAC_DST = 60, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_VLAN = 68, + BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_PCP = 72, + BNXT_ULP_ACT_PROP_IDX_OF_SET_VLAN_VID = 76, + BNXT_ULP_ACT_PROP_IDX_SET_IPV4_SRC = 80, + BNXT_ULP_ACT_PROP_IDX_SET_IPV4_DST = 84, + BNXT_ULP_ACT_PROP_IDX_SET_IPV6_SRC = 88, + BNXT_ULP_ACT_PROP_IDX_SET_IPV6_DST = 104, + BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC = 120, + BNXT_ULP_ACT_PROP_IDX_SET_TP_DST = 124, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_0 = 128, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_1 = 132, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_2 = 136, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_3 = 140, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_4 = 144, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_5 = 148, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_6 = 152, + BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_7 = 156, + BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC = 160, + BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC = 166, + BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG = 172, + BNXT_ULP_ACT_PROP_IDX_ENCAP_IP = 180, + BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC = 212, + BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP = 228, + BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN = 232, + BNXT_ULP_ACT_PROP_IDX_LAST = 264 +}; + #endif /* _ULP_TEMPLATE_DB_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index 4b9d0b2..2b0a3d7 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -17,7 +17,15 @@ #include "rte_flow.h" #include "tf_core.h" -/* Device specific parameters. */ +/* + * structure to hold the action property details + * It is a array of 128 bytes + */ +struct ulp_rte_act_prop { + uint8_t act_details[BNXT_ULP_ACT_PROP_IDX_LAST]; +}; + +/* Device specific parameters */ struct bnxt_ulp_device_params { uint8_t description[16]; uint32_t global_fid_enable; @@ -31,10 +39,44 @@ struct bnxt_ulp_device_params { uint32_t num_resources_per_flow; }; +struct bnxt_ulp_mapper_act_tbl_info { + enum bnxt_ulp_resource_func resource_func; + enum tf_tbl_type table_type; + uint8_t direction; + uint8_t srch_b4_alloc; + uint32_t result_start_idx; + uint16_t result_bit_size; + uint16_t encap_num_fields; + uint16_t result_num_fields; + + enum bnxt_ulp_regfile_index regfile_wr_idx; +}; + +struct bnxt_ulp_mapper_result_field_info { + uint8_t name[64]; + enum bnxt_ulp_result_opc result_opcode; + uint16_t field_bit_size; + uint8_t result_operand[16]; +}; + /* - * The ulp_device_params is indexed by the dev_id. - * This table maintains the device specific parameters. + * The ulp_device_params is indexed by the dev_id + * This table maintains the device specific parameters */ extern struct bnxt_ulp_device_params ulp_device_params[]; +/* + * The ulp_data_field_list provides the instructions for creating an action + * record. It uses the same structure as the result list, but is only used for + * actions. + */ +extern +struct bnxt_ulp_mapper_result_field_info ulp_act_result_field_list[]; + +/* + * The ulp_act_prop_map_table provides the mapping to index and size of action + * properties. + */ +extern uint32_t ulp_act_prop_map_table[]; + #endif /* _ULP_TEMPLATE_STRUCT_H_ */ -- 2.7.4