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 18F46A00BE; Fri, 12 Jun 2020 15:36:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 706CD1BF58; Fri, 12 Jun 2020 15:34:15 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id 845FF1BEE3 for ; Fri, 12 Jun 2020 15:34:12 +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 1148A1BD7BE; Fri, 12 Jun 2020 06:34:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 1148A1BD7BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1591968851; bh=ZYHtE59bVR4YPae4FDJAnwCGkr1l3VdV5GRerqgd81E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6p3ThVyE/7kdn+4snz2mTkuItyB92HxOJDIedViWgsbWKMn4qK4MOL9SjBEvmrYr 9V0U8xLQrlMthIGzazgAEpByABK4ETe5cFSP1t6I3jWcGAeqneslj5r9USgUTZviiz oUtZBxtOVqN1K3rgPWoHMN+UX2fNhGSR/LcHKKM4= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 12 Jun 2020 18:58:50 +0530 Message-Id: <20200612132934.16488-7-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> Subject: [dpdk-dev] [PATCH 06/50] net/bnxt: get port & function related information 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 add helper functions to get port & function related information like parif, physical port id & vport id. Signed-off-by: Venkat Duvvuru Reviewed-by: Kalesh Anakkur Purayil Reviewed-by: Somnath Kotur Reviewed-by: Kishore Padmanabha Signed-off-by: Somnath Kotur --- drivers/net/bnxt/bnxt.h | 8 +++++ drivers/net/bnxt/bnxt_ethdev.c | 58 ++++++++++++++++++++++++++++++++ drivers/net/bnxt/tf_ulp/bnxt_tf_common.h | 10 ++++++ drivers/net/bnxt/tf_ulp/ulp_port_db.h | 10 ------ 4 files changed, 76 insertions(+), 10 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 2b87899..0bdf8f5 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -855,6 +855,9 @@ extern const struct rte_flow_ops bnxt_flow_ops; } \ } while (0) +#define BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev) \ + ((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + extern int bnxt_logtype_driver; #define PMD_DRV_LOG_RAW(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, bnxt_logtype_driver, "%s(): " fmt, \ @@ -870,6 +873,11 @@ 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_phy_port_id(uint16_t port); +uint16_t bnxt_get_vport(uint16_t port); +enum bnxt_ulp_intf_type +bnxt_get_interface_type(uint16_t port); void bnxt_cancel_fc_thread(struct bnxt *bp); void bnxt_flow_cnt_alarm_cb(void *arg); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index bf018be..af88b36 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -28,6 +28,7 @@ #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" #include "bnxt_nvm_defs.h" +#include "bnxt_tf_common.h" #define DRV_MODULE_NAME "bnxt" static const char bnxt_version[] = @@ -5101,6 +5102,63 @@ bnxt_get_fw_func_id(uint16_t port) return bp->fw_fid; } +enum bnxt_ulp_intf_type +bnxt_get_interface_type(uint16_t port) +{ + struct rte_eth_dev *eth_dev; + struct bnxt *bp; + + eth_dev = &rte_eth_devices[port]; + if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) + 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; +} + +uint16_t +bnxt_get_phy_port_id(uint16_t port_id) +{ + 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; + eth_dev = vfr->parent_dev; + } + + bp = eth_dev->data->dev_private; + + return BNXT_PF(bp) ? bp->pf->port_id : bp->parent->port_id; +} + +uint16_t +bnxt_get_parif(uint16_t port_id) +{ + 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; + eth_dev = vfr->parent_dev; + } + + bp = eth_dev->data->dev_private; + + return BNXT_PF(bp) ? bp->fw_fid - 1 : bp->parent->fid - 1; +} + +uint16_t +bnxt_get_vport(uint16_t port_id) +{ + return (1 << bnxt_get_phy_port_id(port_id)); +} + static void bnxt_alloc_error_recovery_info(struct bnxt *bp) { struct bnxt_error_recovery_info *info = bp->recovery_info; diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h index f417579..f772d49 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_common.h @@ -44,6 +44,16 @@ enum ulp_direction_type { ULP_DIR_EGRESS, }; +/* enumeration of the interface types */ +enum bnxt_ulp_intf_type { + BNXT_ULP_INTF_TYPE_INVALID = 0, + BNXT_ULP_INTF_TYPE_PF, + BNXT_ULP_INTF_TYPE_VF, + BNXT_ULP_INTF_TYPE_PF_REP, + BNXT_ULP_INTF_TYPE_VF_REP, + BNXT_ULP_INTF_TYPE_LAST +}; + struct bnxt_ulp_mark_tbl * bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx); diff --git a/drivers/net/bnxt/tf_ulp/ulp_port_db.h b/drivers/net/bnxt/tf_ulp/ulp_port_db.h index 929a5a5..604c438 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_port_db.h +++ b/drivers/net/bnxt/tf_ulp/ulp_port_db.h @@ -10,16 +10,6 @@ #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; -- 2.7.4