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 75F17A052B; Thu, 30 Jul 2020 16:43:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5ECA037B7; Thu, 30 Jul 2020 16:43:42 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 6A1F9A69 for ; Thu, 30 Jul 2020 16:43:40 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06UEeQrb000651; Thu, 30 Jul 2020 07:43:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=nUDzt2F80IlizjB0fwk9oxUYp+FldBD3y86PSW2SiHs=; b=l+SQFdyfi4zw6OpcSpKqdAoXgIFJ7nmBgptr6Pu8+mjAWSChIp0EDl4Ip4lwy2hHoAb+ hhFh23MrbpUoNwZILwcTaIIYV5yqKBz5MqHAeOkl1LAgitD9h8VQYCJYhabqpnv41lnt PoCmVEcXTw58E/mCcQ5+o8E0ka3sBCDrppamyxfP7xUoWapwSqPORnVmjrF/ZMLHktkJ EkAsmSoiNPQDshindXKWu3XHKc+2WXbWaTUmAts3dxAyrxUIoPZoJ/Wz6eFRIUSFPmt+ Ua28KH5esWCLegHk3RnJI3IEBnePK/DgYcTgGUZvBy9FW8EvJ0rue2EpXIsaOq1YoHUr BA== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 32jt0t0jv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 30 Jul 2020 07:43:39 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 30 Jul 2020 07:43:37 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 30 Jul 2020 07:43:38 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id E55423F703F; Thu, 30 Jul 2020 07:43:37 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 06UEhbK6029105; Thu, 30 Jul 2020 07:43:37 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 06UEhbCF029104; Thu, 30 Jul 2020 07:43:37 -0700 From: Manish Chopra To: , , , CC: , , , , , , , , Date: Thu, 30 Jul 2020 07:42:17 -0700 Message-ID: <20200730144221.29051-3-manishc@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200730144221.29051-1-manishc@marvell.com> References: <20200730144221.29051-1-manishc@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-30_11:2020-07-30, 2020-07-30 signatures=0 Subject: [dpdk-dev] [PATCH v5 2/6] net/qede: define PCI config space specific osals 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" This patch defines various PCI config space access APIs in order to read and find IOV specific PCI capabilities. With these definitions implemented, it enables the base driver to do SR-IOV specific initialization and HW specific configuration required from PF-PMD driver instance. Signed-off-by: Manish Chopra Signed-off-by: Igor Russkikh Signed-off-by: Rasesh Mody --- drivers/net/qede/base/bcm_osal.h | 14 +++++++++----- drivers/net/qede/base/ecore.h | 3 +++ drivers/net/qede/base/ecore_dev.c | 6 +++--- drivers/net/qede/base/ecore_sriov.c | 28 +++++++++++++++------------- drivers/net/qede/base/meson.build | 2 +- drivers/net/qede/qede_main.c | 1 + lib/librte_pci/rte_pci.h | 23 +++++++++++++++++++++-- 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h index 5d4df5907..5f55cc2ee 100644 --- a/drivers/net/qede/base/bcm_osal.h +++ b/drivers/net/qede/base/bcm_osal.h @@ -21,6 +21,7 @@ #include #include #include +#include /* Forward declaration */ struct ecore_dev; @@ -286,11 +287,14 @@ typedef struct osal_list_t { OSAL_LIST_PUSH_HEAD(new_entry, list) /* PCI config space */ - -#define OSAL_PCI_READ_CONFIG_BYTE(dev, address, dst) nothing -#define OSAL_PCI_READ_CONFIG_WORD(dev, address, dst) nothing -#define OSAL_PCI_READ_CONFIG_DWORD(dev, address, dst) nothing -#define OSAL_PCI_FIND_EXT_CAPABILITY(dev, pcie_id) 0 +#define OSAL_PCI_READ_CONFIG_BYTE(dev, address, dst) \ + rte_pci_read_config((dev)->pci_dev, dst, 1, address) +#define OSAL_PCI_READ_CONFIG_WORD(dev, address, dst) \ + rte_pci_read_config((dev)->pci_dev, dst, 2, address) +#define OSAL_PCI_READ_CONFIG_DWORD(dev, address, dst) \ + rte_pci_read_config((dev)->pci_dev, dst, 4, address) +#define OSAL_PCI_FIND_EXT_CAPABILITY(dev, cap) \ + rte_pci_find_next_ext_capability((dev)->pci_dev, cap) #define OSAL_PCI_FIND_CAPABILITY(dev, pcie_id) 0 #define OSAL_PCI_WRITE_CONFIG_WORD(dev, address, val) nothing #define OSAL_BAR_SIZE(dev, bar_id) 0 diff --git a/drivers/net/qede/base/ecore.h b/drivers/net/qede/base/ecore.h index 63bd7466a..750e99a8f 100644 --- a/drivers/net/qede/base/ecore.h +++ b/drivers/net/qede/base/ecore.h @@ -937,6 +937,9 @@ struct ecore_dev { struct ecore_dbg_feature dbg_features[DBG_FEATURE_NUM]; struct ecore_dbg_params dbg_params; osal_mutex_t dbg_lock; + + /* DPDK specific ecore field */ + struct rte_pci_device *pci_dev; }; enum ecore_hsi_def_type { diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c index 35a8394de..e895dee40 100644 --- a/drivers/net/qede/base/ecore_dev.c +++ b/drivers/net/qede/base/ecore_dev.c @@ -2787,7 +2787,7 @@ static enum _ecore_status_t ecore_hw_init_chip(struct ecore_dev *p_dev, return ECORE_IO; } - OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + PCI_EXP_DEVCTL, &ctrl); + OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + RTE_PCI_EXP_DEVCTL, &ctrl); wr_mbs = (ctrl & PCI_EXP_DEVCTL_PAYLOAD) >> 5; ecore_wr(p_hwfn, p_ptt, PSWRQ2_REG_WR_MBS0, wr_mbs); @@ -5499,9 +5499,9 @@ static enum _ecore_status_t ecore_get_dev_info(struct ecore_hwfn *p_hwfn, u32 tmp; /* Read Vendor Id / Device Id */ - OSAL_PCI_READ_CONFIG_WORD(p_dev, PCICFG_VENDOR_ID_OFFSET, + OSAL_PCI_READ_CONFIG_WORD(p_dev, RTE_PCI_VENDOR_ID, &p_dev->vendor_id); - OSAL_PCI_READ_CONFIG_WORD(p_dev, PCICFG_DEVICE_ID_OFFSET, + OSAL_PCI_READ_CONFIG_WORD(p_dev, RTE_PCI_DEVICE_ID, &p_dev->device_id); /* Determine type */ diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c index e60257e19..dac4cbee8 100644 --- a/drivers/net/qede/base/ecore_sriov.c +++ b/drivers/net/qede/base/ecore_sriov.c @@ -417,15 +417,16 @@ static enum _ecore_status_t ecore_iov_pci_cfg_info(struct ecore_dev *p_dev) int pos = iov->pos; DP_VERBOSE(p_dev, ECORE_MSG_IOV, "sriov ext pos %d\n", pos); - OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + PCI_SRIOV_CTRL, &iov->ctrl); + OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + RTE_PCI_SRIOV_CTRL, &iov->ctrl); + OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + RTE_PCI_SRIOV_TOTAL_VF, + &iov->total_vfs); OSAL_PCI_READ_CONFIG_WORD(p_dev, - pos + PCI_SRIOV_TOTAL_VF, &iov->total_vfs); - OSAL_PCI_READ_CONFIG_WORD(p_dev, - pos + PCI_SRIOV_INITIAL_VF, + pos + RTE_PCI_SRIOV_INITIAL_VF, &iov->initial_vfs); - OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + PCI_SRIOV_NUM_VF, &iov->num_vfs); + OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + RTE_PCI_SRIOV_NUM_VF, + &iov->num_vfs); if (iov->num_vfs) { /* @@@TODO - in future we might want to add an OSAL here to * allow each OS to decide on its own how to act. @@ -437,20 +438,21 @@ static enum _ecore_status_t ecore_iov_pci_cfg_info(struct ecore_dev *p_dev) } OSAL_PCI_READ_CONFIG_WORD(p_dev, - pos + PCI_SRIOV_VF_OFFSET, &iov->offset); + pos + RTE_PCI_SRIOV_VF_OFFSET, &iov->offset); OSAL_PCI_READ_CONFIG_WORD(p_dev, - pos + PCI_SRIOV_VF_STRIDE, &iov->stride); + pos + RTE_PCI_SRIOV_VF_STRIDE, &iov->stride); - OSAL_PCI_READ_CONFIG_WORD(p_dev, - pos + PCI_SRIOV_VF_DID, &iov->vf_device_id); + OSAL_PCI_READ_CONFIG_WORD(p_dev, pos + RTE_PCI_SRIOV_VF_DID, + &iov->vf_device_id); OSAL_PCI_READ_CONFIG_DWORD(p_dev, - pos + PCI_SRIOV_SUP_PGSIZE, &iov->pgsz); + pos + RTE_PCI_SRIOV_SUP_PGSIZE, &iov->pgsz); - OSAL_PCI_READ_CONFIG_DWORD(p_dev, pos + PCI_SRIOV_CAP, &iov->cap); + OSAL_PCI_READ_CONFIG_DWORD(p_dev, pos + RTE_PCI_SRIOV_CAP, &iov->cap); - OSAL_PCI_READ_CONFIG_BYTE(p_dev, pos + PCI_SRIOV_FUNC_LINK, &iov->link); + OSAL_PCI_READ_CONFIG_BYTE(p_dev, pos + RTE_PCI_SRIOV_FUNC_LINK, + &iov->link); DP_VERBOSE(p_dev, ECORE_MSG_IOV, "IOV info: nres %d, cap 0x%x," "ctrl 0x%x, total %d, initial %d, num vfs %d, offset %d," @@ -669,7 +671,7 @@ enum _ecore_status_t ecore_iov_hw_info(struct ecore_hwfn *p_hwfn) /* Learn the PCI configuration */ pos = OSAL_PCI_FIND_EXT_CAPABILITY(p_hwfn->p_dev, - PCI_EXT_CAP_ID_SRIOV); + RTE_PCI_EXT_CAP_ID_SRIOV); if (!pos) { DP_VERBOSE(p_hwfn, ECORE_MSG_IOV, "No PCIe IOV support\n"); return ECORE_SUCCESS; diff --git a/drivers/net/qede/base/meson.build b/drivers/net/qede/base/meson.build index 59b41c895..03a6c44f5 100644 --- a/drivers/net/qede/base/meson.build +++ b/drivers/net/qede/base/meson.build @@ -52,6 +52,6 @@ foreach flag: error_cflags endforeach base_lib = static_library('qede_base', sources, - dependencies: static_rte_net, + dependencies: [static_rte_net, static_rte_bus_pci], c_args: c_args) base_objs = base_lib.extract_all_objects() diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c index 987a6f1e1..d919f9f11 100644 --- a/drivers/net/qede/qede_main.c +++ b/drivers/net/qede/qede_main.c @@ -37,6 +37,7 @@ static void qed_init_pci(struct ecore_dev *edev, struct rte_pci_device *pci_dev) edev->regview = pci_dev->mem_resource[0].addr; edev->doorbells = pci_dev->mem_resource[2].addr; edev->db_size = pci_dev->mem_resource[2].len; + edev->pci_dev = pci_dev; } static int diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h index fec51e15a..a018a6e9a 100644 --- a/lib/librte_pci/rte_pci.h +++ b/lib/librte_pci/rte_pci.h @@ -31,12 +31,31 @@ extern "C" { #define RTE_PCI_CFG_SPACE_SIZE 256 #define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 +#define RTE_PCI_VENDOR_ID 0x00 /* 16 bits */ +#define RTE_PCI_DEVICE_ID 0x02 /* 16 bits */ + +/* PCI Express capability registers */ +#define RTE_PCI_EXP_DEVCTL 8 /* Device Control */ + /* Extended Capabilities (PCI-X 2.0 and Express) */ #define RTE_PCI_EXT_CAP_ID(header) (header & 0x0000ffff) #define RTE_PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc) -#define RTE_PCI_EXT_CAP_ID_ERR 0x01 /* Advanced Error Reporting */ -#define RTE_PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */ +#define RTE_PCI_EXT_CAP_ID_ERR 0x01 /* Advanced Error Reporting */ +#define RTE_PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */ +#define RTE_PCI_EXT_CAP_ID_SRIOV 0x10 /* SR-IOV*/ + +/* Single Root I/O Virtualization */ +#define RTE_PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */ +#define RTE_PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */ +#define RTE_PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */ +#define RTE_PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */ +#define RTE_PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */ +#define RTE_PCI_SRIOV_FUNC_LINK 0x12 /* Function Dependency Link */ +#define RTE_PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */ +#define RTE_PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */ +#define RTE_PCI_SRIOV_VF_DID 0x1a /* VF Device ID */ +#define RTE_PCI_SRIOV_SUP_PGSIZE 0x1c /* Supported Page Sizes */ /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ #define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 -- 2.17.1