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 81F80A0597; Fri, 17 Apr 2020 18:21:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8D4371EA86; Fri, 17 Apr 2020 18:19:46 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 49A081E9E6 for ; Fri, 17 Apr 2020 18:19:29 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 77CA430C1F6; Fri, 17 Apr 2020 09:08:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 77CA430C1F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1587139688; bh=SR/nTXKTc++U5Iq7Po7gzc4z6lCScn2RVIZRlaBaAhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aFt6Xc7lmfQPU4JTQXH0ytXMZuUJEtqF/WZMjoT2A8iPOV9CdnRM2af4HkH027BpB zuJJ9cRlBc/XU7XtaYDNQfBlMDM0CEN1Ccmqc07pFetjcq1/axsIT9zx6SLBPtFn+T 3d1MJ/Lwf4MW8D8oDl39Lz0+u6rLjyTiXf/eVaeM= Received: from localhost.localdomain (unknown [10.230.185.215]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id E471E14008C; Fri, 17 Apr 2020 09:19:27 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Kishore Padmanabha , Mike Baucom , Venkat Duvvuru Date: Fri, 17 Apr 2020 09:19:19 -0700 Message-Id: <20200417161920.85858-12-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200417161920.85858-1-ajit.khaparde@broadcom.com> References: <1586962156-11179-1-git-send-email-venkatkumar.duvvuru@broadcom.com> <20200417161920.85858-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 11/12] net/bnxt: add port database 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 port database is a repository of the port details it is used by the ulp code to query any port related details. Reviewed-by: Mike Baucom Reviewed-by: Ajit Khaparde Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/meson.build | 1 + drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 47 ++++ drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 10 + drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 13 +- drivers/net/bnxt/tf_ulp/ulp_port_db.c | 263 ++++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_port_db.h | 134 +++++++++ drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 16 +- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 1 + 9 files changed, 480 insertions(+), 6 deletions(-) create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.c create mode 100644 drivers/net/bnxt/tf_ulp/ulp_port_db.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 5ed33ccbf..2a39ed139 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_mapper.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_matcher.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_rte_parser.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/bnxt_ulp_flow.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += tf_ulp/ulp_port_db.c # # Export include files diff --git a/drivers/net/bnxt/meson.build b/drivers/net/bnxt/meson.build index d75f887d1..59dda6932 100644 --- a/drivers/net/bnxt/meson.build +++ b/drivers/net/bnxt/meson.build @@ -41,6 +41,7 @@ sources = files('bnxt_cpr.c', 'tf_ulp/ulp_matcher.c', 'tf_ulp/ulp_rte_parser.c', 'tf_ulp/bnxt_ulp_flow.c', + 'tf_ulp/ulp_port_db.c', 'rte_pmd_bnxt.c') diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 202b4a529..f8047f0d6 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -20,6 +20,7 @@ #include "ulp_mark_mgr.h" #include "ulp_flow_db.h" #include "ulp_mapper.h" +#include "ulp_port_db.h" /* Linked list of all TF sessions. */ STAILQ_HEAD(, bnxt_ulp_session_state) bnxt_ulp_session_list = @@ -454,6 +455,13 @@ bnxt_ulp_init(struct bnxt *bp) if (rc) { BNXT_TF_DBG(ERR, "Failed to attach the ulp context\n"); + return rc; + } + /* update the port database */ + rc = ulp_port_db_dev_port_intf_update(&bp->ulp_ctx, bp); + if (rc) { + BNXT_TF_DBG(ERR, + "Failed to update port database\n"); } return rc; } @@ -465,6 +473,20 @@ bnxt_ulp_init(struct bnxt *bp) goto jump_to_error; } + /* create the port database */ + rc = ulp_port_db_init(&bp->ulp_ctx); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to create the port database\n"); + goto jump_to_error; + } + + /* update the port database */ + rc = ulp_port_db_dev_port_intf_update(&bp->ulp_ctx, bp); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to update port database\n"); + goto jump_to_error; + } + /* Create the Mark database. */ rc = ulp_mark_db_init(&bp->ulp_ctx); if (rc) { @@ -539,6 +561,9 @@ bnxt_ulp_deinit(struct bnxt *bp) /* cleanup the ulp mapper */ ulp_mapper_deinit(&bp->ulp_ctx); + /* Delete the Port database */ + ulp_port_db_deinit(&bp->ulp_ctx); + /* Delete the ulp context and tf session */ ulp_ctx_detach(bp, session); @@ -723,3 +748,25 @@ bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx) return ulp_ctx->cfg_data->mapper_data; } + +/* Function to set the port database to the ulp context. */ +int32_t +bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx, + struct bnxt_ulp_port_db *port_db) +{ + if (!ulp_ctx || !ulp_ctx->cfg_data) + return -EINVAL; + + ulp_ctx->cfg_data->port_db = port_db; + return 0; +} + +/* Function to get the port database from the ulp context. */ +struct bnxt_ulp_port_db * +bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx) +{ + if (!ulp_ctx || !ulp_ctx->cfg_data) + return NULL; + + return ulp_ctx->cfg_data->port_db; +} diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h index d2ca17857..eecc09cea 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h @@ -19,6 +19,7 @@ struct bnxt_ulp_data { uint32_t ref_cnt; struct bnxt_ulp_flow_db *flow_db; void *mapper_data; + struct bnxt_ulp_port_db *port_db; }; struct bnxt_ulp_context { @@ -117,4 +118,13 @@ bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx, void * bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx); +/* Function to set the port database to the ulp context. */ +int32_t +bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx, + struct bnxt_ulp_port_db *port_db); + +/* Function to get the port database from the ulp context. */ +struct bnxt_ulp_port_db * +bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx); + #endif /* _BNXT_ULP_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 7783f85d9..dbec8cecf 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -69,7 +69,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, { struct bnxt_ulp_mapper_create_parms mapper_cparms = { 0 }; struct ulp_rte_parser_params params; - struct bnxt_ulp_context *ulp_ctx = NULL; + struct bnxt_ulp_context *ulp_ctx; uint32_t class_id, act_tmpl; struct rte_flow *flow_id; uint32_t fid; @@ -90,6 +90,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, /* Initialize the parser params */ memset(¶ms, 0, sizeof(struct ulp_rte_parser_params)); + params.ulp_ctx = ulp_ctx; if (attr->egress) params.dir = ULP_DIR_EGRESS; @@ -142,7 +143,7 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, /* Function to validate the rte flow. */ static int -bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, +bnxt_ulp_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item pattern[], const struct rte_flow_action actions[], @@ -151,6 +152,7 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, struct ulp_rte_parser_params params; uint32_t class_id, act_tmpl; int ret; + struct bnxt_ulp_context *ulp_ctx; if (bnxt_ulp_flow_validate_args(attr, pattern, actions, @@ -159,8 +161,15 @@ bnxt_ulp_flow_validate(struct rte_eth_dev *dev __rte_unused, return -EINVAL; } + ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(dev); + if (!ulp_ctx) { + BNXT_TF_DBG(ERR, "ULP context is not initialized\n"); + return -EINVAL; + } + /* Initialize the parser params */ memset(¶ms, 0, sizeof(struct ulp_rte_parser_params)); + params.ulp_ctx = ulp_ctx; if (attr->egress) params.dir = ULP_DIR_EGRESS; diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.c b/drivers/net/bnxt/tf_ulp/ulp_port_db.c new file mode 100644 index 000000000..e3b924289 --- /dev/null +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.c @@ -0,0 +1,263 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2020 Broadcom + * All rights reserved. + */ + +#include +#include "bnxt.h" +#include "bnxt_vnic.h" +#include "bnxt_tf_common.h" +#include "ulp_port_db.h" + +static uint32_t +ulp_port_db_allocate_ifindex(struct bnxt_ulp_port_db *port_db) +{ + uint32_t idx = 1; + + while (idx < port_db->ulp_intf_list_size && + port_db->ulp_intf_list[idx].type != BNXT_ULP_INTF_TYPE_INVALID) + idx++; + + if (idx >= port_db->ulp_intf_list_size) { + BNXT_TF_DBG(ERR, "Port DB interface list is full\n"); + return 0; + } + return idx; +} + +/* + * Initialize the port database. Memory is allocated in this + * call and assigned to the port database. + * + * ulp_ctxt [in] Ptr to ulp context + * + * Returns 0 on success or negative number on failure. + */ +int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt) +{ + struct bnxt_ulp_port_db *port_db; + + port_db = rte_zmalloc("bnxt_ulp_port_db", + sizeof(struct bnxt_ulp_port_db), 0); + if (!port_db) { + BNXT_TF_DBG(ERR, + "Failed to allocate memory for port db\n"); + return -ENOMEM; + } + + /* Attach the port database to the ulp context. */ + bnxt_ulp_cntxt_ptr2_port_db_set(ulp_ctxt, port_db); + + /* index 0 is not being used hence add 1 to size */ + port_db->ulp_intf_list_size = BNXT_PORT_DB_MAX_INTF_LIST + 1; + /* Allocate the port tables */ + port_db->ulp_intf_list = rte_zmalloc("bnxt_ulp_port_db_intf_list", + port_db->ulp_intf_list_size * + sizeof(struct ulp_interface_info), + 0); + if (!port_db->ulp_intf_list) { + BNXT_TF_DBG(ERR, + "Failed to allocate mem for port interface list\n"); + goto error_free; + } + return 0; + +error_free: + ulp_port_db_deinit(ulp_ctxt); + return -ENOMEM; +} + +/* + * Deinitialize the port database. Memory is deallocated in + * this call. + * + * ulp_ctxt [in] Ptr to ulp context + * + * Returns 0 on success. + */ +int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt) +{ + struct bnxt_ulp_port_db *port_db; + + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + + /* Detach the flow database from the ulp context. */ + bnxt_ulp_cntxt_ptr2_port_db_set(ulp_ctxt, NULL); + + /* Free up all the memory. */ + rte_free(port_db->ulp_intf_list); + rte_free(port_db); + return 0; +} + +/* + * Update the port database.This api is called when the port + * details are available during the startup. + * + * ulp_ctxt [in] Ptr to ulp context + * bp [in]. ptr to the device function. + * + * Returns 0 on success or negative number on failure. + */ +int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, + struct bnxt *bp) +{ + struct bnxt_ulp_port_db *port_db; + uint32_t port_id = bp->eth_dev->data->port_id; + uint32_t ifindex; + struct ulp_interface_info *intf; + int32_t rc; + struct bnxt_vnic_info *vnic; + + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + + rc = ulp_port_db_dev_port_to_ulp_index(ulp_ctxt, port_id, &ifindex); + if (rc == -ENOENT) { + /* port not found, allocate one */ + ifindex = ulp_port_db_allocate_ifindex(port_db); + if (!ifindex) + return -ENOMEM; + port_db->dev_port_list[port_id] = ifindex; + } else if (rc == -EINVAL) { + return -EINVAL; + } + + /* update the interface details */ + intf = &port_db->ulp_intf_list[ifindex]; + if (BNXT_PF(bp) || BNXT_VF(bp)) { + if (BNXT_PF(bp)) { + intf->type = BNXT_ULP_INTF_TYPE_PF; + intf->port_svif = bp->port_svif; + } else { + intf->type = BNXT_ULP_INTF_TYPE_VF; + } + intf->func_id = bp->fw_fid; + intf->func_svif = bp->func_svif; + vnic = BNXT_GET_DEFAULT_VNIC(bp); + if (vnic) + intf->default_vnic = vnic->fw_vnic_id; + intf->bp = bp; + memcpy(intf->mac_addr, bp->mac_addr, sizeof(intf->mac_addr)); + } else { + BNXT_TF_DBG(ERR, "Invalid interface type\n"); + } + + return 0; +} + +/* + * Api to get the ulp ifindex for a given device port. + * + * ulp_ctxt [in] Ptr to ulp context + * port_id [in].device port id + * ifindex [out] ulp ifindex + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt, + uint32_t port_id, + uint32_t *ifindex) +{ + struct bnxt_ulp_port_db *port_db; + + *ifindex = 0; + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db || port_id >= RTE_MAX_ETHPORTS) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + if (!port_db->dev_port_list[port_id]) + return -ENOENT; + + *ifindex = port_db->dev_port_list[port_id]; + return 0; +} + +/* + * Api to get the function id for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * func_id [out] the function id of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, + uint16_t *func_id) +{ + struct bnxt_ulp_port_db *port_db; + + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + *func_id = port_db->ulp_intf_list[ifindex].func_id; + return 0; +} + +/* + * Api to get the svid for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * dir [in] the direction for the flow. + * svif [out] the svif of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, + uint32_t dir, + uint16_t *svif) +{ + struct bnxt_ulp_port_db *port_db; + + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + if (dir == ULP_DIR_EGRESS) + *svif = port_db->ulp_intf_list[ifindex].func_svif; + else + *svif = port_db->ulp_intf_list[ifindex].port_svif; + return 0; +} + +/* + * Api to get the vnic id for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * vnic [out] the vnic of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, + uint16_t *vnic) +{ + struct bnxt_ulp_port_db *port_db; + + port_db = bnxt_ulp_cntxt_ptr2_port_db_get(ulp_ctxt); + if (!port_db || ifindex >= port_db->ulp_intf_list_size || !ifindex) { + BNXT_TF_DBG(ERR, "Invalid Arguments\n"); + return -EINVAL; + } + *vnic = port_db->ulp_intf_list[ifindex].default_vnic; + return 0; +} diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h new file mode 100644 index 000000000..271c29a47 --- /dev/null +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h @@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2014-2019 Broadcom + * All rights reserved. + */ + +#ifndef _ULP_PORT_DB_H_ +#define _ULP_PORT_DB_H_ + +#include "bnxt_ulp.h" + +#define BNXT_PORT_DB_MAX_INTF_LIST 256 + +/* enumeration of the interface types */ +enum bnxt_ulp_intf_type { + BNXT_ULP_INTF_TYPE_INVALID = 0, + BNXT_ULP_INTF_TYPE_PF = 1, + BNXT_ULP_INTF_TYPE_VF, + BNXT_ULP_INTF_TYPE_PF_REP, + BNXT_ULP_INTF_TYPE_VF_REP, + BNXT_ULP_INTF_TYPE_LAST +}; + +/* Structure for the Port database resource information. */ +struct ulp_interface_info { + enum bnxt_ulp_intf_type type; + uint16_t func_id; + uint16_t func_svif; + uint16_t port_svif; + uint16_t default_vnic; + uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; + /* back pointer to the bnxt driver, it is null for rep ports */ + struct bnxt *bp; +}; + +/* Structure for the Port database */ +struct bnxt_ulp_port_db { + struct ulp_interface_info *ulp_intf_list; + uint32_t ulp_intf_list_size; + + /* dpdk device external port list */ + uint16_t dev_port_list[RTE_MAX_ETHPORTS]; +}; + +/* + * Initialize the port database. Memory is allocated in this + * call and assigned to the port database. + * + * ulp_ctxt [in] Ptr to ulp context + * + * Returns 0 on success or negative number on failure. + */ +int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt); + +/* + * Deinitialize the port database. Memory is deallocated in + * this call. + * + * ulp_ctxt [in] Ptr to ulp context + * + * Returns 0 on success. + */ +int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt); + +/* + * Update the port database.This api is called when the port + * details are available during the startup. + * + * ulp_ctxt [in] Ptr to ulp context + * bp [in]. ptr to the device function. + * + * Returns 0 on success or negative number on failure. + */ +int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, + struct bnxt *bp); + +/* + * Api to get the ulp ifindex for a given device port. + * + * ulp_ctxt [in] Ptr to ulp context + * port_id [in].device port id + * ifindex [out] ulp ifindex + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt, + uint32_t port_id, + uint32_t *ifindex); + +/* + * Api to get the function id for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * func_id [out] the function id of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, + uint16_t *func_id); + +/* + * Api to get the svid for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * dir [in] the direction for the flow. + * svif [out] the svif of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, + uint32_t dir, + uint16_t *svif); + +/* + * Api to get the vnic id for a given ulp ifindex. + * + * ulp_ctxt [in] Ptr to ulp context + * ifindex [in] ulp ifindex + * vnic [out] the vnic of the given ifindex. + * + * Returns 0 on success or negative number on failure. + */ +int32_t +ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt, + uint32_t ifindex, + uint16_t *vnic); + +#endif /* _ULP_PORT_DB_H_ */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 873f86494..ace5fad97 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -10,6 +10,7 @@ #include "ulp_rte_parser.h" #include "ulp_utils.h" #include "tfp.h" +#include "ulp_port_db.h" /* Utility function to skip the void items. */ static inline int32_t @@ -161,6 +162,8 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, uint16_t port_id = svif; uint32_t dir = 0; struct ulp_rte_hdr_field *hdr_field; + uint32_t ifindex; + int32_t rc; if (ULP_BITMAP_ISSET(params->hdr_bitmap.bits, BNXT_ULP_HDR_BIT_SVIF)) { BNXT_TF_DBG(ERR, @@ -175,10 +178,15 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, dir = ULP_UTIL_CHF_IDX_RD(params, BNXT_ULP_CHF_IDX_DIRECTION); /* perform the conversion from dpdk port to bnxt svif */ - if (dir == ULP_DIR_EGRESS) - svif = bnxt_get_svif(port_id, true); - else - svif = bnxt_get_svif(port_id, false); + rc = ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, port_id, + &ifindex); + if (rc) { + BNXT_TF_DBG(ERR, + "Invalid port id\n"); + return BNXT_TF_RC_ERROR; + } + ulp_port_db_svif_get(params->ulp_ctx, ifindex, dir, &svif); + svif = rte_cpu_to_be_16(svif); } hdr_field = ¶ms->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX]; memcpy(hdr_field->spec, &svif, sizeof(svif)); diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index 1bef5ab0e..0e0d02ff4 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -66,6 +66,7 @@ struct ulp_rte_parser_params { struct ulp_rte_act_bitmap act_bitmap; struct ulp_rte_act_prop act_prop; uint32_t dir; + struct bnxt_ulp_context *ulp_ctx; }; /* Flow Parser Header Information Structure */ -- 2.21.1 (Apple Git-122.3)