From patchwork Fri Jun 12 13:29:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 71433 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 72C9DA00BE; Fri, 12 Jun 2020 15:50:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B9CEF1D167; Fri, 12 Jun 2020 15:35:03 +0200 (CEST) Received: from relay.smtp.broadcom.com (unknown [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id C24051D127 for ; Fri, 12 Jun 2020 15:34:59 +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 8C75C1BD7AC; Fri, 12 Jun 2020 06:34:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 8C75C1BD7AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591968899; bh=k8PF1EEeJshZMS4dcecsq47EEEjc0CbOfoozW63eD+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YD8ZmZ2z7bZSVc26H3XWWkkjRp8HarTxcly/dTGKqjTFBsaxAo/oBiXmAg6eRNO4o qyNiILozV1747VPQ5GW860K7I7AW3uD4qUV3FiOmwJbbbPy4fUwz4nYC09zFFE54R6 Lk+y0ifC0Wir3reXvyrSJeEhBesNFtakEaT+KWR0= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:59:25 +0530 Message-Id: <20200612132934.16488-42-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200612132934.16488-1-somnath.kotur@broadcom.com> References: <20200612132934.16488-1-somnath.kotur@broadcom.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 41/50] net/bnxt: enhancements for port db 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: Venkat Duvvuru 1. Add "enum bnxt_ulp_intf_type” as the second parameter for the port & func helper functions 2. Return vfrep related port & func information in the helper functions 3. Allocate phy_port_list dynamically based on port count 4. Introduce ulp_func_id_tbl array for book keeping func related information indexed by func_id Signed-off-by: Venkat Duvvuru Reviewed-by: Ajit Kumar Khaparde Signed-off-by: Somnath Kotur --- drivers/net/bnxt/bnxt.h | 10 ++- drivers/net/bnxt/bnxt_ethdev.c | 64 ++++++++++++-- drivers/net/bnxt/tf_ulp/bnxt_tf_common.h | 6 ++ drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 2 +- drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 9 +- drivers/net/bnxt/tf_ulp/ulp_port_db.c | 142 ++++++++++++++++++++++++------- drivers/net/bnxt/tf_ulp/ulp_port_db.h | 56 ++++++++++-- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 22 ++++- 8 files changed, 249 insertions(+), 62 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 43e5e71..32acced 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -23,6 +23,7 @@ #include "tf_core.h" #include "bnxt_ulp.h" +#include "bnxt_tf_common.h" /* Vendor ID */ #define PCI_VENDOR_ID_BROADCOM 0x14E4 @@ -879,10 +880,11 @@ extern const struct rte_flow_ops bnxt_ulp_rte_flow_ops; int32_t bnxt_ulp_init(struct bnxt *bp); void bnxt_ulp_deinit(struct bnxt *bp); -uint16_t bnxt_get_vnic_id(uint16_t port); -uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif); -uint16_t bnxt_get_fw_func_id(uint16_t port); -uint16_t bnxt_get_parif(uint16_t port); +uint16_t bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type); +uint16_t bnxt_get_svif(uint16_t port_id, bool func_svif, + enum bnxt_ulp_intf_type type); +uint16_t bnxt_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type); +uint16_t bnxt_get_parif(uint16_t port, enum bnxt_ulp_intf_type type); uint16_t bnxt_get_phy_port_id(uint16_t port); uint16_t bnxt_get_vport(uint16_t port); enum bnxt_ulp_intf_type diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3550257..332644d 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -5067,25 +5067,48 @@ static void bnxt_config_vf_req_fwd(struct bnxt *bp) } uint16_t -bnxt_get_svif(uint16_t port_id, bool func_svif) +bnxt_get_svif(uint16_t port_id, bool func_svif, + enum bnxt_ulp_intf_type type) { struct rte_eth_dev *eth_dev; struct bnxt *bp; eth_dev = &rte_eth_devices[port_id]; + if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + struct bnxt_vf_representor *vfr = eth_dev->data->dev_private; + if (!vfr) + return 0; + + if (type == BNXT_ULP_INTF_TYPE_VF_REP) + return vfr->svif; + + eth_dev = vfr->parent_dev; + } + bp = eth_dev->data->dev_private; return func_svif ? bp->func_svif : bp->port_svif; } uint16_t -bnxt_get_vnic_id(uint16_t port) +bnxt_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type) { struct rte_eth_dev *eth_dev; struct bnxt_vnic_info *vnic; struct bnxt *bp; eth_dev = &rte_eth_devices[port]; + if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + struct bnxt_vf_representor *vfr = eth_dev->data->dev_private; + if (!vfr) + return 0; + + if (type == BNXT_ULP_INTF_TYPE_VF_REP) + return vfr->dflt_vnic_id; + + eth_dev = vfr->parent_dev; + } + bp = eth_dev->data->dev_private; vnic = BNXT_GET_DEFAULT_VNIC(bp); @@ -5094,12 +5117,23 @@ bnxt_get_vnic_id(uint16_t port) } uint16_t -bnxt_get_fw_func_id(uint16_t port) +bnxt_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type) { struct rte_eth_dev *eth_dev; struct bnxt *bp; eth_dev = &rte_eth_devices[port]; + if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + struct bnxt_vf_representor *vfr = eth_dev->data->dev_private; + if (!vfr) + return 0; + + if (type == BNXT_ULP_INTF_TYPE_VF_REP) + return vfr->fw_fid; + + eth_dev = vfr->parent_dev; + } + bp = eth_dev->data->dev_private; return bp->fw_fid; @@ -5116,8 +5150,14 @@ bnxt_get_interface_type(uint16_t port) return BNXT_ULP_INTF_TYPE_VF_REP; bp = eth_dev->data->dev_private; - return BNXT_PF(bp) ? BNXT_ULP_INTF_TYPE_PF - : BNXT_ULP_INTF_TYPE_VF; + if (BNXT_PF(bp)) + return BNXT_ULP_INTF_TYPE_PF; + else if (BNXT_VF_IS_TRUSTED(bp)) + return BNXT_ULP_INTF_TYPE_TRUSTED_VF; + else if (BNXT_VF(bp)) + return BNXT_ULP_INTF_TYPE_VF; + + return BNXT_ULP_INTF_TYPE_INVALID; } uint16_t @@ -5130,6 +5170,9 @@ bnxt_get_phy_port_id(uint16_t port_id) eth_dev = &rte_eth_devices[port_id]; if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { vfr = eth_dev->data->dev_private; + if (!vfr) + return 0; + eth_dev = vfr->parent_dev; } @@ -5139,15 +5182,20 @@ bnxt_get_phy_port_id(uint16_t port_id) } uint16_t -bnxt_get_parif(uint16_t port_id) +bnxt_get_parif(uint16_t port_id, enum bnxt_ulp_intf_type type) { - struct bnxt_vf_representor *vfr; struct rte_eth_dev *eth_dev; struct bnxt *bp; eth_dev = &rte_eth_devices[port_id]; if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { - vfr = eth_dev->data->dev_private; + struct bnxt_vf_representor *vfr = eth_dev->data->dev_private; + if (!vfr) + return 0; + + if (type == BNXT_ULP_INTF_TYPE_VF_REP) + return vfr->fw_fid - 1; + eth_dev = vfr->parent_dev; } diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h index f772d49..ebb7140 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h @@ -6,6 +6,11 @@ #ifndef _BNXT_TF_COMMON_H_ #define _BNXT_TF_COMMON_H_ +#include + +#include "bnxt_ulp.h" +#include "ulp_template_db_enum.h" + #define BNXT_TF_DBG(lvl, fmt, args...) PMD_DRV_LOG(lvl, fmt, ## args) #define BNXT_ULP_EM_FLOWS 8192 @@ -48,6 +53,7 @@ enum ulp_direction_type { enum bnxt_ulp_intf_type { BNXT_ULP_INTF_TYPE_INVALID = 0, BNXT_ULP_INTF_TYPE_PF, + BNXT_ULP_INTF_TYPE_TRUSTED_VF, BNXT_ULP_INTF_TYPE_VF, BNXT_ULP_INTF_TYPE_PF_REP, BNXT_ULP_INTF_TYPE_VF_REP, diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 1b52861..e5e7e5f 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -658,7 +658,7 @@ bnxt_ulp_init(struct bnxt *bp) rc = ulp_dparms_init(bp, bp->ulp_ctx); /* create the port database */ - rc = ulp_port_db_init(bp->ulp_ctx); + rc = ulp_port_db_init(bp->ulp_ctx, bp->port_cnt); if (rc) { BNXT_TF_DBG(ERR, "Failed to create the port database\n"); goto jump_to_error; diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 6eb2d61..138b0b7 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -128,7 +128,8 @@ bnxt_ulp_flow_create(struct rte_eth_dev *dev, mapper_cparms.act_prop = ¶ms.act_prop; mapper_cparms.class_tid = class_id; mapper_cparms.act_tid = act_tmpl; - mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id); + mapper_cparms.func_id = bnxt_get_fw_func_id(dev->data->port_id, + BNXT_ULP_INTF_TYPE_INVALID); mapper_cparms.dir = params.dir; /* Call the ulp mapper to create the flow in the hardware. */ @@ -226,7 +227,8 @@ bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, } flow_id = (uint32_t)(uintptr_t)flow; - func_id = bnxt_get_fw_func_id(dev->data->port_id); + func_id = bnxt_get_fw_func_id(dev->data->port_id, + BNXT_ULP_INTF_TYPE_INVALID); if (ulp_flow_db_validate_flow_func(ulp_ctx, flow_id, func_id) == false) { @@ -270,7 +272,8 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev, if (ulp_ctx_deinit_allowed(bp)) { ret = ulp_flow_db_session_flow_flush(ulp_ctx); } else if (bnxt_ulp_cntxt_ptr2_flow_db_get(ulp_ctx)) { - func_id = bnxt_get_fw_func_id(eth_dev->data->port_id); + func_id = bnxt_get_fw_func_id(eth_dev->data->port_id, + BNXT_ULP_INTF_TYPE_INVALID); ret = ulp_flow_db_function_flow_flush(ulp_ctx, func_id); } if (ret) diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.c b/drivers/net/bnxt/tf_ulp/ulp_port_db.c index ea27ef4..de276f7 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.c +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.c @@ -33,7 +33,7 @@ ulp_port_db_allocate_ifindex(struct bnxt_ulp_port_db *port_db) * * Returns 0 on success or negative number on failure. */ -int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt) +int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt) { struct bnxt_ulp_port_db *port_db; @@ -60,6 +60,18 @@ int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt) "Failed to allocate mem for port interface list\n"); goto error_free; } + + /* Allocate the phy port list */ + port_db->phy_port_list = rte_zmalloc("bnxt_ulp_phy_port_list", + port_cnt * + sizeof(struct ulp_phy_port_info), + 0); + if (!port_db->phy_port_list) { + BNXT_TF_DBG(ERR, + "Failed to allocate mem for phy port list\n"); + goto error_free; + } + return 0; error_free: @@ -89,6 +101,7 @@ int32_t ulp_port_db_deinit(struct bnxt_ulp_context *ulp_ctxt) bnxt_ulp_cntxt_ptr2_port_db_set(ulp_ctxt, NULL); /* Free up all the memory. */ + rte_free(port_db->phy_port_list); rte_free(port_db->ulp_intf_list); rte_free(port_db); return 0; @@ -110,6 +123,7 @@ int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, struct ulp_phy_port_info *port_data; struct bnxt_ulp_port_db *port_db; struct ulp_interface_info *intf; + struct ulp_func_if_info *func; uint32_t ifindex; int32_t rc; @@ -134,20 +148,47 @@ int32_t ulp_port_db_dev_port_intf_update(struct bnxt_ulp_context *ulp_ctxt, intf = &port_db->ulp_intf_list[ifindex]; intf->type = bnxt_get_interface_type(port_id); + intf->drv_func_id = bnxt_get_fw_func_id(port_id, + BNXT_ULP_INTF_TYPE_INVALID); + + func = &port_db->ulp_func_id_tbl[intf->drv_func_id]; + if (!func->func_valid) { + func->func_svif = bnxt_get_svif(port_id, true, + BNXT_ULP_INTF_TYPE_INVALID); + func->func_spif = bnxt_get_phy_port_id(port_id); + func->func_parif = + bnxt_get_parif(port_id, BNXT_ULP_INTF_TYPE_INVALID); + func->func_vnic = + bnxt_get_vnic_id(port_id, BNXT_ULP_INTF_TYPE_INVALID); + func->phy_port_id = bnxt_get_phy_port_id(port_id); + func->func_valid = true; + } - intf->func_id = bnxt_get_fw_func_id(port_id); - intf->func_svif = bnxt_get_svif(port_id, 1); - intf->func_spif = bnxt_get_phy_port_id(port_id); - intf->func_parif = bnxt_get_parif(port_id); - intf->default_vnic = bnxt_get_vnic_id(port_id); - intf->phy_port_id = bnxt_get_phy_port_id(port_id); + if (intf->type == BNXT_ULP_INTF_TYPE_VF_REP) { + intf->vf_func_id = + bnxt_get_fw_func_id(port_id, BNXT_ULP_INTF_TYPE_VF_REP); + + func = &port_db->ulp_func_id_tbl[intf->vf_func_id]; + func->func_svif = + bnxt_get_svif(port_id, true, BNXT_ULP_INTF_TYPE_VF_REP); + func->func_spif = + bnxt_get_phy_port_id(port_id); + func->func_parif = + bnxt_get_parif(port_id, BNXT_ULP_INTF_TYPE_INVALID); + func->func_vnic = + bnxt_get_vnic_id(port_id, BNXT_ULP_INTF_TYPE_VF_REP); + func->phy_port_id = bnxt_get_phy_port_id(port_id); + } - if (intf->type == BNXT_ULP_INTF_TYPE_PF) { - port_data = &port_db->phy_port_list[intf->phy_port_id]; - port_data->port_svif = bnxt_get_svif(port_id, 0); + port_data = &port_db->phy_port_list[func->phy_port_id]; + if (!port_data->port_valid) { + port_data->port_svif = + bnxt_get_svif(port_id, false, BNXT_ULP_INTF_TYPE_INVALID); port_data->port_spif = bnxt_get_phy_port_id(port_id); - port_data->port_parif = bnxt_get_parif(port_id); + port_data->port_parif = + bnxt_get_parif(port_id, BNXT_ULP_INTF_TYPE_INVALID); port_data->port_vport = bnxt_get_vport(port_id); + port_data->port_valid = true; } return 0; @@ -194,6 +235,7 @@ ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt, int32_t ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, + uint32_t fid_type, uint16_t *func_id) { struct bnxt_ulp_port_db *port_db; @@ -203,7 +245,12 @@ ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, BNXT_TF_DBG(ERR, "Invalid Arguments\n"); return -EINVAL; } - *func_id = port_db->ulp_intf_list[ifindex].func_id; + + if (fid_type == BNXT_ULP_DRV_FUNC_FID) + *func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + else + *func_id = port_db->ulp_intf_list[ifindex].vf_func_id; + return 0; } @@ -212,7 +259,7 @@ ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, * * ulp_ctxt [in] Ptr to ulp context * ifindex [in] ulp ifindex - * dir [in] the direction for the flow. + * svif_type [in] the svif type of the given ifindex. * svif [out] the svif of the given ifindex. * * Returns 0 on success or negative number on failure. @@ -220,21 +267,27 @@ ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, int32_t ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, - uint32_t dir, + uint32_t svif_type, uint16_t *svif) { struct bnxt_ulp_port_db *port_db; - uint16_t phy_port_id; + uint16_t phy_port_id, func_id; 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; + + if (svif_type == BNXT_ULP_DRV_FUNC_SVIF) { + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + *svif = port_db->ulp_func_id_tbl[func_id].func_svif; + } else if (svif_type == BNXT_ULP_VF_FUNC_SVIF) { + func_id = port_db->ulp_intf_list[ifindex].vf_func_id; + *svif = port_db->ulp_func_id_tbl[func_id].func_svif; } else { - phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id; + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id; *svif = port_db->phy_port_list[phy_port_id].port_svif; } @@ -246,7 +299,7 @@ ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, * * ulp_ctxt [in] Ptr to ulp context * ifindex [in] ulp ifindex - * dir [in] the direction for the flow. + * spif_type [in] the spif type of the given ifindex. * spif [out] the spif of the given ifindex. * * Returns 0 on success or negative number on failure. @@ -254,21 +307,27 @@ ulp_port_db_svif_get(struct bnxt_ulp_context *ulp_ctxt, int32_t ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, - uint32_t dir, + uint32_t spif_type, uint16_t *spif) { struct bnxt_ulp_port_db *port_db; - uint16_t phy_port_id; + uint16_t phy_port_id, func_id; 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) { - *spif = port_db->ulp_intf_list[ifindex].func_spif; + + if (spif_type == BNXT_ULP_DRV_FUNC_SPIF) { + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + *spif = port_db->ulp_func_id_tbl[func_id].func_spif; + } else if (spif_type == BNXT_ULP_VF_FUNC_SPIF) { + func_id = port_db->ulp_intf_list[ifindex].vf_func_id; + *spif = port_db->ulp_func_id_tbl[func_id].func_spif; } else { - phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id; + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id; *spif = port_db->phy_port_list[phy_port_id].port_spif; } @@ -280,7 +339,7 @@ ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt, * * ulp_ctxt [in] Ptr to ulp context * ifindex [in] ulp ifindex - * dir [in] the direction for the flow. + * parif_type [in] the parif type of the given ifindex. * parif [out] the parif of the given ifindex. * * Returns 0 on success or negative number on failure. @@ -288,21 +347,26 @@ ulp_port_db_spif_get(struct bnxt_ulp_context *ulp_ctxt, int32_t ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, - uint32_t dir, + uint32_t parif_type, uint16_t *parif) { struct bnxt_ulp_port_db *port_db; - uint16_t phy_port_id; + uint16_t phy_port_id, func_id; 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) { - *parif = port_db->ulp_intf_list[ifindex].func_parif; + if (parif_type == BNXT_ULP_DRV_FUNC_PARIF) { + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + *parif = port_db->ulp_func_id_tbl[func_id].func_parif; + } else if (parif_type == BNXT_ULP_VF_FUNC_PARIF) { + func_id = port_db->ulp_intf_list[ifindex].vf_func_id; + *parif = port_db->ulp_func_id_tbl[func_id].func_parif; } else { - phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id; + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id; *parif = port_db->phy_port_list[phy_port_id].port_parif; } @@ -321,16 +385,26 @@ ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt, int32_t ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, + uint32_t vnic_type, uint16_t *vnic) { struct bnxt_ulp_port_db *port_db; + uint16_t func_id; 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; + + if (vnic_type == BNXT_ULP_DRV_FUNC_VNIC) { + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + *vnic = port_db->ulp_func_id_tbl[func_id].func_vnic; + } else { + func_id = port_db->ulp_intf_list[ifindex].vf_func_id; + *vnic = port_db->ulp_func_id_tbl[func_id].func_vnic; + } + return 0; } @@ -348,14 +422,16 @@ ulp_port_db_vport_get(struct bnxt_ulp_context *ulp_ctxt, uint32_t ifindex, uint16_t *vport) { struct bnxt_ulp_port_db *port_db; - uint16_t phy_port_id; + uint16_t phy_port_id, func_id; 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; } - phy_port_id = port_db->ulp_intf_list[ifindex].phy_port_id; + + func_id = port_db->ulp_intf_list[ifindex].drv_func_id; + phy_port_id = port_db->ulp_func_id_tbl[func_id].phy_port_id; *vport = port_db->phy_port_list[phy_port_id].port_vport; return 0; } diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h index 87de3bc..b1419a3 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h @@ -9,19 +9,54 @@ #include "bnxt_ulp.h" #define BNXT_PORT_DB_MAX_INTF_LIST 256 +#define BNXT_PORT_DB_MAX_FUNC 2048 -/* Structure for the Port database resource information. */ -struct ulp_interface_info { - enum bnxt_ulp_intf_type type; - uint16_t func_id; +enum bnxt_ulp_svif_type { + BNXT_ULP_DRV_FUNC_SVIF = 0, + BNXT_ULP_VF_FUNC_SVIF, + BNXT_ULP_PHY_PORT_SVIF +}; + +enum bnxt_ulp_spif_type { + BNXT_ULP_DRV_FUNC_SPIF = 0, + BNXT_ULP_VF_FUNC_SPIF, + BNXT_ULP_PHY_PORT_SPIF +}; + +enum bnxt_ulp_parif_type { + BNXT_ULP_DRV_FUNC_PARIF = 0, + BNXT_ULP_VF_FUNC_PARIF, + BNXT_ULP_PHY_PORT_PARIF +}; + +enum bnxt_ulp_vnic_type { + BNXT_ULP_DRV_FUNC_VNIC = 0, + BNXT_ULP_VF_FUNC_VNIC +}; + +enum bnxt_ulp_fid_type { + BNXT_ULP_DRV_FUNC_FID, + BNXT_ULP_VF_FUNC_FID +}; + +struct ulp_func_if_info { + uint16_t func_valid; uint16_t func_svif; uint16_t func_spif; uint16_t func_parif; - uint16_t default_vnic; + uint16_t func_vnic; uint16_t phy_port_id; }; +/* Structure for the Port database resource information. */ +struct ulp_interface_info { + enum bnxt_ulp_intf_type type; + uint16_t drv_func_id; + uint16_t vf_func_id; +}; + struct ulp_phy_port_info { + uint16_t port_valid; uint16_t port_svif; uint16_t port_spif; uint16_t port_parif; @@ -35,7 +70,8 @@ struct bnxt_ulp_port_db { /* dpdk device external port list */ uint16_t dev_port_list[RTE_MAX_ETHPORTS]; - struct ulp_phy_port_info phy_port_list[RTE_MAX_ETHPORTS]; + struct ulp_phy_port_info *phy_port_list; + struct ulp_func_if_info ulp_func_id_tbl[BNXT_PORT_DB_MAX_FUNC]; }; /* @@ -46,7 +82,7 @@ struct bnxt_ulp_port_db { * * Returns 0 on success or negative number on failure. */ -int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt); +int32_t ulp_port_db_init(struct bnxt_ulp_context *ulp_ctxt, uint8_t port_cnt); /* * Deinitialize the port database. Memory is deallocated in @@ -94,7 +130,8 @@ ulp_port_db_dev_port_to_ulp_index(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_port_db_function_id_get(struct bnxt_ulp_context *ulp_ctxt, - uint32_t ifindex, uint16_t *func_id); + uint32_t ifindex, uint32_t fid_type, + uint16_t *func_id); /* * Api to get the svif for a given ulp ifindex. @@ -150,7 +187,8 @@ ulp_port_db_parif_get(struct bnxt_ulp_context *ulp_ctxt, */ int32_t ulp_port_db_default_vnic_get(struct bnxt_ulp_context *ulp_ctxt, - uint32_t ifindex, uint16_t *vnic); + uint32_t ifindex, uint32_t vnic_type, + uint16_t *vnic); /* * Api to get the vport id for a given ulp ifindex. diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 8fffaec..073b353 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -166,6 +166,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; + enum bnxt_ulp_svif_type svif_type; + enum bnxt_ulp_intf_type if_type; uint32_t ifindex; int32_t rc; @@ -187,7 +189,18 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, "Invalid port id\n"); return BNXT_TF_RC_ERROR; } - ulp_port_db_svif_get(params->ulp_ctx, ifindex, dir, &svif); + + if (dir == ULP_DIR_INGRESS) { + svif_type = BNXT_ULP_PHY_PORT_SVIF; + } else { + if_type = bnxt_get_interface_type(port_id); + if (if_type == BNXT_ULP_INTF_TYPE_VF_REP) + svif_type = BNXT_ULP_VF_FUNC_SVIF; + else + svif_type = BNXT_ULP_DRV_FUNC_SVIF; + } + ulp_port_db_svif_get(params->ulp_ctx, ifindex, svif_type, + &svif); svif = rte_cpu_to_be_16(svif); } hdr_field = ¶ms->hdr_field[BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX]; @@ -1256,7 +1269,7 @@ ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused, /* copy the PF of the current device into VNIC Property */ svif = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF); - svif = bnxt_get_vnic_id(svif); + svif = bnxt_get_vnic_id(svif, BNXT_ULP_INTF_TYPE_INVALID); svif = rte_cpu_to_be_32(svif); memcpy(¶ms->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], &svif, BNXT_ULP_ACT_PROP_SZ_VNIC); @@ -1280,7 +1293,8 @@ ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, return BNXT_TF_RC_PARSE_ERR; } /* TBD: Update the computed VNIC using VF conversion */ - pid = bnxt_get_vnic_id(vf_action->id); + pid = bnxt_get_vnic_id(vf_action->id, + BNXT_ULP_INTF_TYPE_INVALID); pid = rte_cpu_to_be_32(pid); memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], &pid, BNXT_ULP_ACT_PROP_SZ_VNIC); @@ -1307,7 +1321,7 @@ ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, return BNXT_TF_RC_PARSE_ERR; } /* TBD: Update the computed VNIC using port conversion */ - pid = bnxt_get_vnic_id(port_id->id); + pid = bnxt_get_vnic_id(port_id->id, BNXT_ULP_INTF_TYPE_INVALID); pid = rte_cpu_to_be_32(pid); memcpy(¶m->act_prop.act_details[BNXT_ULP_ACT_PROP_IDX_VNIC], &pid, BNXT_ULP_ACT_PROP_SZ_VNIC);