qede: SR-IOV PF driver support
Subsystems (2)
v3 cover qede: SR-IOV PF driver support
Hi,
This series adds SR-IOV PF pmd driver support to have VF pmd driver work over PF pmd driver instances in order to run the adapter completely under DPDK environment for one of the use cases like ovs-dpdk.
This is very initial bring-up with following testing covered -
* Enable/Disable SR-IOV VFs through igb_uio sysfs hook.
* Load VFs, run fastpath, teardown VFs in hypervisor and guest VM.
* VF FLR flow (in case of VF PCI passthrough to the guest VM)
* Bulletin mechanism tested to communicate link changes to the VFs.
Note that this series is intended for upcoming DPDK release (20.08) Please consider applying this series to dpdk-next-net-mrvl.git
V2->V3:
=======
* Instead of adding complete pci_regs.h file from linux, define handful PCI symbols (prefixed with RTE_) in dpdk which are required to implement generic rte_pci_find_next_ext_capability() API (patch #1) and to enable various other qede driver's OSAL_* defines (patch #2) (essentially, removed the patch #1 in v2)
* Fixed meson/ninja compilation issues reported
* Incorporated comments by Gaetan for rte_pci_find_next_ext_capability()
V1->V2: (Incorporated comments from Jerin Jacob)
================================================
* Added rte_pci_regs.h file (copy of linux/pci_regs.h) under lib/librte_pci to remove the dependency of dpdk on user headers
* Added generic API to find PCI extended capability and use that in the drivers, removed individual functions implemented by the drivers
Thanks,
Manish
Manish Chopra (6):
drivers: add generic API to find PCI extended cap net/qede: define PCI config space specific osals net/qede: configure VFs on hardware net/qede: add infrastructure support for VF load net/qede: initialize VF MAC and link net/qede: add VF FLR support
doc/guides/nics/features/qede.ini | 1 + doc/guides/nics/qede.rst | 7 +- drivers/bus/pci/pci_common.c | 42 ++++ drivers/bus/pci/rte_bus_pci.h | 19 ++ drivers/bus/pci/rte_bus_pci_version.map | 6 + drivers/net/ice/ice_ethdev.c | 51 +---- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 48 +---- drivers/net/qede/Makefile | 1 + drivers/net/qede/base/bcm_osal.c | 31 +++ drivers/net/qede/base/bcm_osal.h | 29 ++- drivers/net/qede/base/ecore.h | 7 + drivers/net/qede/base/ecore_dev.c | 6 +- drivers/net/qede/base/ecore_iov_api.h | 3 + drivers/net/qede/base/ecore_sriov.c | 28 +-- drivers/net/qede/base/meson.build | 2 +- drivers/net/qede/meson.build | 1 + drivers/net/qede/qede_ethdev.c | 37 +++- drivers/net/qede/qede_ethdev.h | 1 + drivers/net/qede/qede_if.h | 1 + drivers/net/qede/qede_main.c | 13 +- drivers/net/qede/qede_sriov.c | 219 +++++++++++++++++++++ drivers/net/qede/qede_sriov.h | 22 +++ drivers/raw/ifpga/ifpga_rawdev.c | 6 - lib/librte_pci/rte_pci.h | 35 ++++ 24 files changed, 480 insertions(+), 136 deletions(-) create mode 100644 drivers/net/qede/qede_sriov.c create mode 100644 drivers/net/qede/qede_sriov.h
Signature · 1 line
2.17.1
PATCH v3 1/6 drivers: add generic API to find PCI extended cap
By adding generic API, this patch removes individual functions/defines implemented by drivers to find PCI extended capability.
--- drivers/bus/pci/pci_common.c | 42 ++++++++++++++++++ drivers/bus/pci/rte_bus_pci.h | 19 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 6 +++ drivers/net/ice/ice_ethdev.c | 51 +--------------------- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 48 +------------------- drivers/raw/ifpga/ifpga_rawdev.c | 6 --- lib/librte_pci/rte_pci.h | 16 +++++++ 7 files changed, 87 insertions(+), 101 deletions(-)
drivers/bus/pci/pci_common.c +42 -0
@@ -665,6 +665,48 @@ rte_pci_get_iommu_class(void)return iova_mode; } +off_t rte_pci_find_next_ext_capability (struct rte_pci_device *dev,uint32_t cap) +{ +off_t offset =RTE_PCI_CFG_SPACE_SIZE ; +uint32_t header; +int ttl; + +/* minimum 8 bytes per capability */ + ttl = (RTE_PCI_CFG_SPACE_EXP_SIZE -RTE_PCI_CFG_SPACE_SIZE ) /8 ; + +if (rte_pci_read_config (dev, &header,4 , offset) <0 ) { +RTE_LOG (ERR ,EAL ,"error in reading extended capabilities\n" ); +return -1 ; + } + +/* +* If we have no capabilities, this is indicated by cap ID, +* cap version and next pointer all being 0. +*/ +if (header ==0 ) +return 0 ; + +while (ttl !=0 ) { +if (RTE_PCI_EXT_CAP_ID (header) == cap) +return offset; + + offset =RTE_PCI_EXT_CAP_NEXT (header); + +if (offset <RTE_PCI_CFG_SPACE_SIZE ) +break ; + +if (rte_pci_read_config (dev, &header,4 , offset) <0 ) { +RTE_LOG (ERR ,EAL , +"error in reading extended capabilities\n" ); +return -1 ; + } + + ttl--; + } + +return 0 ; +} +struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan,
drivers/bus/pci/rte_bus_pci.h +19 -0
@@ -224,6 +224,25 @@ void rte_pci_unmap_device(struct rte_pci_device *dev);*/ void rte_pci_dump (FILE *f); +/** +* Find device's extended capability +* +* @param dev +* A pointer to rte_pci_device structure +* +* @param cap +* Extended capability to find +* +* @return +* > 0: The offset of the next matching extended capability structure +* within the device's PCI configuration space +* < 0: An error in PCI config space read +* = 0: Device does not support it +*/ +__rte_experimental +off_t rte_pci_find_next_ext_capability(struct rte_pci_device *dev, +uint32_t cap); +/** * Register a PCI driver. *
drivers/bus/pci/rte_bus_pci_version.map +6 -0
@@ -16,3 +16,9 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pci_find_next_ext_capability; +};
drivers/net/ice/ice_ethdev.c +2 -49
67 lines not on this page · raw message
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +2 -46
61 lines not on this page · raw message
drivers/raw/ifpga/ifpga_rawdev.c +0 -6
@@ -41,12 +41,6 @@#include "ifpga_rawdev.h" #include "ipn3ke_rawdev_api.h" -#define RTE_PCI_EXT_CAP_ID_ERR 0x01/* Advanced Error Reporting */ -#define RTE_PCI_CFG_SPACE_SIZE 256 -#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 -#define RTE_PCI_EXT_CAP_ID (header) (int)(header & 0x0000ffff) -#define RTE_PCI_EXT_CAP_NEXT (header) ((header >> 20) & 0xffc) -#define PCI_VENDOR_ID_INTEL 0x8086/* PCI Device ID */ #define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD
lib/librte_pci/rte_pci.h +16 -0
@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> + +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have 4096 bytes of +* configuration space. +*/ +#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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 */ +/** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ #define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8#define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 1/6] drivers: add generic API to find PCI extended cap
Hello Manish,
I have just a few nits below,
Quoted 3 lines · Manish Chopra
By adding generic API, this patch removes individual functions/defines implemented by drivers to find PCI extended capability.
"to find extended PCI capabilities" sounds better.
Quoted 18 lines
Signed-off-by Manish Chopra <[email protected]>Signed-off-by Igor Russkikh <[email protected]>--- drivers/bus/pci/pci_common.c | 42 ++++++++++++++++++ drivers/bus/pci/rte_bus_pci.h | 19 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 6 +++ drivers/net/ice/ice_ethdev.c | 51 +--------------------- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 48 +------------------- drivers/raw/ifpga/ifpga_rawdev.c | 6 --- lib/librte_pci/rte_pci.h | 16 +++++++ 7 files changed, 87 insertions(+), 101 deletions(-)drivers/bus/pci/pci_common.c +0
-0
drivers/bus/pci/pci_common.c rte_pci_get_iommu_class(void) · line 669
Quoted 5 lines
drivers/bus/pci/pci_common.c +2
-0@@ -665,6 +665,48 @@ rte_pci_get_iommu_class(void)return iova_mode; } +off_t rte_pci_find_next_ext_capability (struct rte_pci_device *dev,uint32_t cap) +{
Coding style asks for the return type on its own line, then the function name etc.
Quoted 49 lines
drivers/bus/pci/pci_common.c +40
-0+off_t offset =RTE_PCI_CFG_SPACE_SIZE ; +uint32_t header; +int ttl; + +/* minimum 8 bytes per capability */ + ttl = (RTE_PCI_CFG_SPACE_EXP_SIZE -RTE_PCI_CFG_SPACE_SIZE ) /8 ; + +if (rte_pci_read_config (dev, &header,4 , offset) <0 ) { +RTE_LOG (ERR ,EAL ,"error in reading extended capabilities\n" ); +return -1 ; + } + +/* +* If we have no capabilities, this is indicated by cap ID, +* cap version and next pointer all being 0. +*/ +if (header ==0 ) +return 0 ; + +while (ttl !=0 ) { +if (RTE_PCI_EXT_CAP_ID (header) == cap) +return offset; + + offset =RTE_PCI_EXT_CAP_NEXT (header); + +if (offset <RTE_PCI_CFG_SPACE_SIZE ) +break ; + +if (rte_pci_read_config (dev, &header,4 , offset) <0 ) { +RTE_LOG (ERR ,EAL , +"error in reading extended capabilities\n" ); +return -1 ; + } + + ttl--; + } + +return 0 ; +} +struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan,drivers/bus/pci/rte_bus_pci.h +0
-0@@ -224,6 +224,25 @@ void rte_pci_unmap_device(struct rte_pci_device *dev);*/
drivers/bus/pci/rte_bus_pci.h void rte_pci_unmap_device(struct rte_pci_device *dev); · line 234
Quoted 10 lines
drivers/bus/pci/rte_bus_pci.h +8
-0void rte_pci_dump (FILE *f); +/** +* Find device's extended capability +* +* @param dev +* A pointer to rte_pci_device structure +* +* @param cap +* Extended capability to find
Reading the rest of the file, I see some doc with sentences finished by periods, and not others. Going forward we should be consistent, and write documentation with grammatically correct sentences, so with the periods.
drivers/bus/pci/rte_bus_pci.h void rte_pci_unmap_device(struct rte_pci_device *dev); · line 240
Quoted 6 lines
drivers/bus/pci/rte_bus_pci.h +6
-0+* +* @return +* > 0: The offset of the next matching extended capability structure +* within the device's PCI configuration space +* < 0: An error in PCI config space read +* = 0: Device does not support it
Thanks for the additional details, though the periods are still missing.
Quoted 192 lines
drivers/bus/pci/rte_bus_pci.h +5
-0+*/ +__rte_experimental +off_t rte_pci_find_next_ext_capability(struct rte_pci_device *dev, +uint32_t cap); +/** * Register a PCI driver. * drivers/bus/pci/rte_bus_pci_version.map +6
-0@@ -16,3 +16,9 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pci_find_next_ext_capability; +};drivers/net/ice/ice_ethdev.c +2
-49@@ -1730,53 +1730,6 @@ ice_pf_setup(struct ice_pf *pf)return 0 ; } -/* PCIe configuration space setting */ -#define PCI_CFG_SPACE_SIZE 256 -#define PCI_CFG_SPACE_EXP_SIZE 4096 -#define PCI_EXT_CAP_ID (header) (int)((header) & 0x0000ffff) -#define PCI_EXT_CAP_NEXT (header) (((header) >> 20) & 0xffc) -#define PCI_EXT_CAP_ID_DSN 0x03 - -static int -ice_pci_find_next_ext_capability (struct rte_pci_device *dev,int cap) -{ -uint32_t header; -int ttl; -int pos =PCI_CFG_SPACE_SIZE ; - -/* minimum 8 bytes per capability */ - ttl = (PCI_CFG_SPACE_EXP_SIZE -PCI_CFG_SPACE_SIZE ) /8 ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { -PMD_INIT_LOG (ERR ,"ice error reading extended capabilities\n" ); -return -1 ; - } - -/* -* If we have no capabilities, this is indicated by cap ID, -* cap version and next pointer all being 0. -*/ -if (header ==0 ) -return 0 ; - -while (ttl-- >0 ) { -if (PCI_EXT_CAP_ID (header) == cap) -return pos; - - pos =PCI_EXT_CAP_NEXT (header); - -if (pos <PCI_CFG_SPACE_SIZE ) -break ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { -PMD_INIT_LOG (ERR ,"ice error reading extended capabilities\n" ); -return -1 ; - } - } - -return 0 ; -} -/* * Extract device serial number from PCIe Configuration Space and * determine the pkg file path according to the DSN. @@ -1784,12 +1737,12 @@ ice_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap)static int ice_pkg_file_search_path (struct rte_pci_device *pci_dev,char *pkg_file) { -int pos; +off_t pos;char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE ];uint32_t dsn_low, dsn_high;memset (opt_ddp_filename,0 ,ICE_MAX_PKG_FILENAME_SIZE ); - pos =ice_pci_find_next_ext_capability (pci_dev,PCI_EXT_CAP_ID_DSN ); + pos =rte_pci_find_next_ext_capability (pci_dev,RTE_PCI_EXT_CAP_ID_DSN );if (pos) {rte_pci_read_config (pci_dev, &dsn_low,4 , pos +4 );drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +2
-46@@ -746,59 +746,15 @@ nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp)return 0 ; } -#define PCI_CFG_SPACE_SIZE 256 -#define PCI_CFG_SPACE_EXP_SIZE 4096 -#define PCI_EXT_CAP_ID (header) (int)(header & 0x0000ffff) -#define PCI_EXT_CAP_NEXT (header) ((header >> 20) & 0xffc) -#define PCI_EXT_CAP_ID_DSN 0x03 -static int -nfp_pci_find_next_ext_capability (struct rte_pci_device *dev,int cap) -{ -uint32_t header; -int ttl; -int pos =PCI_CFG_SPACE_SIZE ; - -/* minimum 8 bytes per capability */ - ttl = (PCI_CFG_SPACE_EXP_SIZE -PCI_CFG_SPACE_SIZE ) /8 ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { -printf ("nfp error reading extended capabilities\n" ); -return -1 ; - } - -/* -* If we have no capabilities, this is indicated by cap ID, -* cap version and next pointer all being 0. -*/ -if (header ==0 ) -return 0 ; - -while (ttl-- >0 ) { -if (PCI_EXT_CAP_ID (header) == cap) -return pos; - - pos =PCI_EXT_CAP_NEXT (header); -if (pos <PCI_CFG_SPACE_SIZE ) -break ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { -printf ("nfp error reading extended capabilities\n" ); -return -1 ; - } - } - -return 0 ; -} -static int nfp6000_set_serial (struct rte_pci_device *dev,struct nfp_cpp *cpp) {uint16_t tmp;uint8_t serial[6 ];int serial_len =6 ; -int pos; +off_t pos; - pos =nfp_pci_find_next_ext_capability (dev,PCI_EXT_CAP_ID_DSN ); + pos =rte_pci_find_next_ext_capability (dev,RTE_PCI_EXT_CAP_ID_DSN );if (pos <=0 ) {printf ("PCI_EXT_CAP_ID_DSN not found. nfp set serial failed\n" );return -1 ;drivers/raw/ifpga/ifpga_rawdev.c +0
-6@@ -41,12 +41,6 @@#include "ifpga_rawdev.h" #include "ipn3ke_rawdev_api.h" -#define RTE_PCI_EXT_CAP_ID_ERR 0x01/* Advanced Error Reporting */ -#define RTE_PCI_CFG_SPACE_SIZE 256 -#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 -#define RTE_PCI_EXT_CAP_ID (header) (int)(header & 0x0000ffff) -#define RTE_PCI_EXT_CAP_NEXT (header) ((header >> 20) & 0xffc) -#define PCI_VENDOR_ID_INTEL 0x8086/* PCI Device ID */ #define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBDlib/librte_pci/rte_pci.h +6
-0@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> + +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have 4096 bytes of +* configuration space. +*/
lib/librte_pci/rte_pci.h extern "C" { · line 40
Quoted 10 lines
lib/librte_pci/rte_pci.h +10
-0+#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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 */ +
I understand that it is more natural to have those defines in the PCI lib, but I think there is no point in adding them in a separate lib, while the function using those is in the PCI bus.
I think the defines should be put right before the rte_pci_find_next_ext_capability() prototype in drivers/bus/pci/rte_bus_pci.h.
Quoted 6 lines
lib/librte_pci/rte_pci.h +0
-0/** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ #define PCI_PRI_FMT "%.4" PRIx32 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8#define PCI_PRI_STR_SIZE sizeof("XXXXXXXX:XX:XX.X")Signature · 1 line
2.17.1
Signature · 1 line
Gaëtan
Re: [dpdk-dev] [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended cap
Quoted 348 lines
-----Original Message-----
From: Gaëtan Rivet <[email protected]>
Sent: Saturday, July 25, 2020 11:02 PM
To: Manish Chopra <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; Igor Russkikh <[email protected]>; Rasesh Mody <[email protected]>; GR-Everest- DPDK-Dev <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended capExternal Email
----------------------------------------------------------------------
Hello Manish,I have just a few nits below,
Quoted 2 lines · Manish Chopra
By adding generic API, this patch removes individual functions/defines implemented by drivers to find PCI extended capability.
"to find extended PCI capabilities" sounds better.
Quoted 18 lines
Signed-off-by Manish Chopra <[email protected]>Signed-off-by Igor Russkikh <[email protected]>--- drivers/bus/pci/pci_common.c | 42 ++++++++++++++++++ drivers/bus/pci/rte_bus_pci.h | 19 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 6 +++ drivers/net/ice/ice_ethdev.c | 51 +--------------------- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 48 +------------------- drivers/raw/ifpga/ifpga_rawdev.c | 6 --- lib/librte_pci/rte_pci.h | 16 +++++++ 7 files changed, 87 insertions(+), 101 deletions(-)(quoted diff) +0
-0
b/drivers/bus/pci/pci_common.cindexa8e5fd52c..b877d10e9100644drivers/bus/pci/pci_common.c rte_pci_get_iommu_class(void) · line 669
Quoted 5 lines
drivers/bus/pci/pci_common.c +2
-0@@ -665,6 +665,48 @@ rte_pci_get_iommu_class(void)return iova_mode; } +off_t rte_pci_find_next_ext_capability (struct rte_pci_device *dev, +uint32_t cap) {Coding style asks for the return type on its own line, then the function name etc.
drivers/bus/pci/pci_common.c rte_pci_get_iommu_class(void)
Quoted 9 lines
drivers/bus/pci/pci_common.c +9
-0+off_t offset =RTE_PCI_CFG_SPACE_SIZE ; +uint32_t header; +int ttl; + +/* minimum 8 bytes per capability */ + ttl = (RTE_PCI_CFG_SPACE_EXP_SIZE -RTE_PCI_CFG_SPACE_SIZE ) /8 ; + +if (rte_pci_read_config (dev, &header,4 , offset) <0 ) { + RTE_LOG(ERR, EAL, "error in reading extendedcapabilities\n");
drivers/bus/pci/rte_bus_pci.h void rte_pci_unmap_device(struct rte_pci_device
Quoted 39 lines
drivers/bus/pci/pci_common.c +31
-0+return -1 ; + } + +/* +* If we have no capabilities, this is indicated by cap ID, +* cap version and next pointer all being 0. +*/ +if (header ==0 ) +return 0 ; + +while (ttl !=0 ) { +if (RTE_PCI_EXT_CAP_ID (header) == cap) +return offset; + + offset =RTE_PCI_EXT_CAP_NEXT (header); + +if (offset <RTE_PCI_CFG_SPACE_SIZE ) +break ; + +if (rte_pci_read_config (dev, &header,4 , offset) <0 ) { +RTE_LOG (ERR ,EAL , +"error in reading extended capabilities\n" ); +return -1 ; + } + + ttl--; + } + +return 0 ; +} +struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan,(quoted diff) +0
-0
b/drivers/bus/pci/rte_bus_pci.hindex29bea6d70..de1ed9807100644drivers/bus/pci/rte_bus_pci.h +0
-0@@ -224,6 +224,25 @@ void rte_pci_unmap_device(struct rte_pci_device*dev);
drivers/bus/pci/rte_bus_pci.h void rte_pci_unmap_device(struct rte_pci_device *dev); · line 234
Quoted 11 lines
drivers/bus/pci/rte_bus_pci.h +8
-0*/ void rte_pci_dump (FILE *f); +/** +* Find device's extended capability +* +* @param dev +* A pointer to rte_pci_device structure +* +* @param cap +* Extended capability to find Reading the rest of the file, I see some doc with sentences finished by periods, and not others. Going forward we should be consistent, and write documentation with grammatically correct sentences, so with the periods.
drivers/bus/pci/rte_bus_pci.h void rte_pci_unmap_device(struct rte_pci_device *dev); · line 240
Quoted 6 lines
drivers/bus/pci/rte_bus_pci.h +6
-0+* +* @return +* > 0: The offset of the next matching extended capability structure +* within the device's PCI configuration space +* < 0: An error in PCI config space read +* = 0: Device does not support it Thanks for the additional details, though the periods are still missing.
Quoted 40 lines
drivers/bus/pci/rte_bus_pci.h +5
-0+*/ +__rte_experimental +off_t rte_pci_find_next_ext_capability(struct rte_pci_device *dev, +uint32_t cap); +/** * Register a PCI driver. * drivers/bus/pci/rte_bus_pci_version.map +6
-0@@ -16,3 +16,9 @@ DPDK_20.0 { local: *; }; + +EXPERIMENTAL { + global: + + rte_pci_find_next_ext_capability; +};(quoted diff) +0
-0
b/drivers/net/ice/ice_ethdev.cindex7dd3fcd27..6c8cbea5c100644drivers/net/ice/ice_ethdev.c +0
-9@@ -1730,53 +1730,6 @@ ice_pf_setup(struct ice_pf *pf)return 0 ; } -/* PCIe configuration space setting */ -#define PCI_CFG_SPACE_SIZE 256 -#define PCI_CFG_SPACE_EXP_SIZE 4096 -#define PCI_EXT_CAP_ID (header) (int)((header) & 0x0000ffff) -#define PCI_EXT_CAP_NEXT (header) (((header) >> 20) & 0xffc) -#define PCI_EXT_CAP_ID_DSN 0x03 - -static int -ice_pci_find_next_ext_capability (struct rte_pci_device *dev,int cap)drivers/net/ice/ice_ethdev.c ice_pf_setup(struct ice_pf *pf) · line 1751
Quoted 10 lines
drivers/net/ice/ice_ethdev.c +0
-10-{ -uint32_t header; -int ttl; -int pos =PCI_CFG_SPACE_SIZE ; - -/* minimum 8 bytes per capability */ - ttl = (PCI_CFG_SPACE_EXP_SIZE -PCI_CFG_SPACE_SIZE ) /8 ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { - PMD_INIT_LOG(ERR, "ice error reading extendedcapabilities\n");
Quoted 11 lines
drivers/net/ice/ice_ethdev.c +0
-11-return -1 ; - } - -/* -* If we have no capabilities, this is indicated by cap ID, -* cap version and next pointer all being 0. -*/ -if (header ==0 ) -return 0 ; - -while (ttl-- >0 ) {drivers/net/ice/ice_ethdev.c ice_pf_setup(struct ice_pf *pf)
Quoted 10 lines
drivers/net/ice/ice_ethdev.c +0
-10-if (PCI_EXT_CAP_ID (header) == cap) -return pos; - - pos =PCI_EXT_CAP_NEXT (header); - -if (pos <PCI_CFG_SPACE_SIZE ) -break ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { - PMD_INIT_LOG(ERR, "ice error reading extendedcapabilities\n");
Quoted 14 lines
drivers/net/ice/ice_ethdev.c +0
-7-return -1 ; - } - } - -return 0 ; -} -/* * Extract device serial number from PCIe Configuration Space and * determine the pkg file path according to the DSN. @@ -1784,12 +1737,12 @@ ice_pci_find_next_ext_capability(struct
rte_pci_device*dev, int cap) static intice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file){drivers/net/ice/ice_ethdev.c ice_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap)
Quoted 7 lines
drivers/net/ice/ice_ethdev.c +1
-2-int pos; +off_t pos;char opt_ddp_filename[ICE_MAX_PKG_FILENAME_SIZE ];uint32_t dsn_low, dsn_high;memset (opt_ddp_filename,0 ,ICE_MAX_PKG_FILENAME_SIZE ); - pos = ice_pci_find_next_ext_capability(pci_dev,
PCI_EXT_CAP_ID_DSN);drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c nfp6000_set_interface(struct rte_pci_device
Quoted 11 lines
drivers/net/ice/ice_ethdev.c +2
-0+ pos =rte_pci_find_next_ext_capability (pci_dev, +RTE_PCI_EXT_CAP_ID_DSN );if (pos) { rte_pci_read_config(pci_dev, &dsn_low, 4, pos + 4); diff --git
a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.cb/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index0b9db974e..dbab4f8cb100644drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +0
-0@@ -746,59 +746,15 @@ nfp6000_set_interface(struct rte_pci_device*dev, struct
nfp_cpp*cpp)Quoted 48 lines
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +0
-44return 0 ; } -#define PCI_CFG_SPACE_SIZE 256 -#define PCI_CFG_SPACE_EXP_SIZE 4096 -#define PCI_EXT_CAP_ID (header) (int)(header & 0x0000ffff) -#define PCI_EXT_CAP_NEXT (header) ((header >> 20) & 0xffc) -#define PCI_EXT_CAP_ID_DSN 0x03 -static int -nfp_pci_find_next_ext_capability (struct rte_pci_device *dev,int cap) -{ -uint32_t header; -int ttl; -int pos =PCI_CFG_SPACE_SIZE ; - -/* minimum 8 bytes per capability */ - ttl = (PCI_CFG_SPACE_EXP_SIZE -PCI_CFG_SPACE_SIZE ) /8 ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { -printf ("nfp error reading extended capabilities\n" ); -return -1 ; - } - -/* -* If we have no capabilities, this is indicated by cap ID, -* cap version and next pointer all being 0. -*/ -if (header ==0 ) -return 0 ; - -while (ttl-- >0 ) { -if (PCI_EXT_CAP_ID (header) == cap) -return pos; - - pos =PCI_EXT_CAP_NEXT (header); -if (pos <PCI_CFG_SPACE_SIZE ) -break ; - -if (rte_pci_read_config (dev, &header,4 , pos) <0 ) { -printf ("nfp error reading extended capabilities\n" ); -return -1 ; - } - } - -return 0 ; -} - static intdrivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp)
Quoted 10 lines
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +2
-2nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp) { uint16_t tmp;uint8_t serial[6 ];int serial_len =6 ; -int pos; +off_t pos; - pos =nfp_pci_find_next_ext_capability (dev,PCI_EXT_CAP_ID_DSN ); + pos = rte_pci_find_next_ext_capability(dev,
RTE_PCI_EXT_CAP_ID_DSN);drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c nfp6000_set_interface(struct rte_pci_device · line 759
Quoted 2 lines
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +0
-0if (pos <=0 ) { printf("PCI_EXT_CAP_ID_DSN not found. nfp set serialfailed\n");
drivers/raw/ifpga/ifpga_rawdev.c line 44
Quoted 11 lines
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +0
-0return -1 ;drivers/raw/ifpga/ifpga_rawdev.c +0
-1@@ -41,12 +41,6 @@#include "ifpga_rawdev.h" #include "ipn3ke_rawdev_api.h" -#define RTE_PCI_EXT_CAP_ID_ERR 0x01/* Advanced Error Reporting */
Quoted 21 lines
drivers/raw/ifpga/ifpga_rawdev.c +0
-5-#define RTE_PCI_CFG_SPACE_SIZE 256 -#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 -#define RTE_PCI_EXT_CAP_ID (header) (int)(header & 0x0000ffff) -#define RTE_PCI_EXT_CAP_NEXT (header) ((header >> 20) & 0xffc) -#define PCI_VENDOR_ID_INTEL 0x8086/* PCI Device ID */ #define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBDlib/librte_pci/rte_pci.h index renamed from lib/librte_pci/rte_pci.h +0
-0
a03235da1..fec51e15a100644lib/librte_pci/rte_pci.h +5
-0@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> + +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have 4096 +bytes of lib/librte_pci/rte_pci.h extern "C" { · line 39
Quoted 10 lines
lib/librte_pci/rte_pci.h +10
-0+* configuration space. +*/ +#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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 */
lib/librte_pci/rte_pci.h extern "C" { · line 40
Quoted 2 lines
lib/librte_pci/rte_pci.h +2
-0+#define RTE_PCI_EXT_CAP_ID_DSN 0x03/* Device Serial Number */ +I understand that it is more natural to have those defines in the PCI lib, but I think there is no point in adding them in a separate lib, while the function using those is in the PCI bus.
Quoted 3 lines
I think the defines should be put right before the
rte_pci_find_next_ext_capability()prototype indrivers/bus/pci/rte_bus_pci.h.
Hello Gaetan,
I think these comes in the category of all RTE_PCI_* generic defines (not just use in drivers/bus/pci/), Since caller of the API also need to use it, For example, couple of RTE_PCI_* were added in patch #2 used by qede drivers specifically. rte_pci.h sounds more generic than rte_bus_pci.h hence I thought it is the suitable place to consolidate them in there.
Thanks !!
Re: [dpdk-dev] [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended cap
On 26/07/20 19:47 +0000, Manish Chopra wrote:
[...]
Quoted 35 lines
Quoted 31 lines
Quoted 13 lines
lib/librte_pci/rte_pci.h index renamed from lib/librte_pci/rte_pci.h +0
-0
a03235da1..fec51e15a100644lib/librte_pci/rte_pci.h +5
-0@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> + +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have 4096 +bytes of lib/librte_pci/rte_pci.h extern "C" { · line 39
Quoted 10 lines
lib/librte_pci/rte_pci.h +10
-0+* configuration space. +*/ +#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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 */
lib/librte_pci/rte_pci.h extern "C" { · line 40
Quoted 2 lines
lib/librte_pci/rte_pci.h +2
-0+#define RTE_PCI_EXT_CAP_ID_DSN 0x03/* Device Serial Number */ +I understand that it is more natural to have those defines in the PCI lib, but I think there is no point in adding them in a separate lib, while the function using those is in the PCI bus.
Quoted 3 lines
I think the defines should be put right before the
rte_pci_find_next_ext_capability()prototype indrivers/bus/pci/rte_bus_pci.h.
Quoted 8 lines
Hello Gaetan,
I think these comes in the category of all RTE_PCI_* generic defines (not just use in
drivers/bus/pci/), Since caller of the API also need to use it, For example, couple of RTE_PCI_* were added in patch #2 used by qede drivers specifically.rte_pci.hsounds more generic thanrte_bus_pci.hhence I thought it is the suitable place to consolidate them in there.Thanks !!
Reading the additional symbols, particularly about SRIOV capa, I think you are right, it's probably better to have it all within rte_pci.h.
To help developers, it would be better to point in the doc that the capability IDs useable as parameter cap can be any from RTE_PCI_EXT_CAP_ID_*, defined within librte_pci. The dev can then grep it.
One additional thing:
Quoted 6 lines
Quoted 6 lines
lib/librte_pci/rte_pci.h extern "C" { · line 36
Quoted 6 lines
lib/librte_pci/rte_pci.h +6
-0+#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)
I think those macros are not useful as part of the public API, they are only used to implement rte_pci_find_next_ext_capability(). Can you confirm? If this is correct, I think they should be moved to the compilation unit implementing rte_pci_find_next_ext_capability().
Regards,
Signature · 1 line
Gaëtan
Re: [dpdk-dev] [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended cap
Quoted 64 lines
-----Original Message-----
From: Gaëtan Rivet <[email protected]>
Sent: Monday, July 27, 2020 4:18 AM
To: Manish Chopra <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; Igor Russkikh <[email protected]>; Rasesh Mody <[email protected]>; GR-Everest- DPDK-Dev <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended capOn 26/07/20 19:47 +0000, Manish Chopra wrote:
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_pci/rte_pci.h +0
-0@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_pci/rte_pci.h +5
-0+ +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have 4096 +bytes of Quoted 8 lines
lib/librte_pci/rte_pci.h extern "C" {
Quoted 8 lines
lib/librte_pci/rte_pci.h +8
-0+* configuration space. +*/ +#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)Quoted 2 lines
Quoted 2 lines
lib/librte_pci/rte_pci.h extern "C" { · line 39
Quoted 2 lines
lib/librte_pci/rte_pci.h +2
-0+ +#define RTE_PCI_EXT_CAP_ID_ERR 0x01/* Advanced Error Reporting
Quoted 2 lines
Quoted 2 lines
*/
Quoted 1 line
lib/librte_pci/rte_pci.h +1
-0+#define RTE_PCI_EXT_CAP_ID_DSN 0x03/* Device Serial Number */
Quoted 10 lines
Quoted 9 lines
lib/librte_pci/rte_pci.h extern "C" { · line 41
Quoted 1 line
lib/librte_pci/rte_pci.h +1
-0+I understand that it is more natural to have those defines in the PCI lib, but I think there is no point in adding them in a separate lib, while the function using those is in the PCI bus.
I think the defines should be put right before the
rte_pci_find_next_ext_capability()prototype indrivers/bus/pci/rte_bus_pci.h.Quoted 6 lines
Hello Gaetan,
I think these comes in the category of all RTE_PCI_* generic defines (not just use in
drivers/bus/pci/), Since caller of the API also need to use it, For example, couple of RTE_PCI_* were added in patch #2 used by qede drivers specifically.rte_pci.hsounds more generic than
rte_bus_pci.hhence I thought it is the suitable place to consolidate them in there.Quoted 1 line
Quoted 8 lines
Quoted 1 line
Thanks !!
Reading the additional symbols, particularly about SRIOV capa, I think you are right, it's probably better to have it all within
rte_pci.h.To help developers, it would be better to point in the doc that the capability IDs useable as parameter
capcan be any from RTE_PCI_EXT_CAP_ID_*, defined withinlibrte_pci. The dev can then grep it.
Sure, I will add the pointer to librte_pci in the comment section for rte_pci_find_next_ext_capability()
Quoted 11 lines
One additional thing:
Quoted 6 lines
Quoted 6 lines
lib/librte_pci/rte_pci.h extern "C" {
Quoted 6 lines
lib/librte_pci/rte_pci.h +6
-0+#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)
Quoted 5 lines
I think those macros are not useful as part of the public API, they are only used to implement
rte_pci_find_next_ext_capability(). Can you confirm? If this is correct, I think they should be moved to the compilation unit implementingrte_pci_find_next_ext_capability().
Hi Gaetan,
Yes Mostly, but there is a similar piece of code left in drivers/raw/ifpga [ifpga_pci_find_ext_capability()] only which utilizes these symbols as well, which I did not want to be removed/cleaned up must as a part of this series because that implementation is based on pread() instead of rte_pci_read_config(). I was not sure if that driver can also directly use rte_pci_find_next_ext_capability() too, I do not have those fpga based devices to test if at all I were to do that cleanup/removal now in that driver, so I didn't attempt to make such functional changes in that driver now. [May be this can be cleaned up too later on with proper testing or may be a new API based on pread() can be added further if those drivers can't use rte_pci_find_next_ext_capability() directly].
Thanks.
Re: [dpdk-dev] [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended cap
Quoted 103 lines · Manish Chopra
Quoted 64 lines
-----Original Message-----
From: Gaëtan Rivet <[email protected]>
Sent: Monday, July 27, 2020 4:18 AM
To: Manish Chopra <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; Igor Russkikh <[email protected]>; Rasesh Mody <[email protected]>; GR-Everest- DPDK-Dev <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended capOn 26/07/20 19:47 +0000, Manish Chopra wrote:
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_pci/rte_pci.h +0
-0@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_pci/rte_pci.h +5
-0+ +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have 4096 +bytes of Quoted 8 lines
lib/librte_pci/rte_pci.h extern "C" {
Quoted 8 lines
lib/librte_pci/rte_pci.h +8
-0+* configuration space. +*/ +#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)Quoted 2 lines
Quoted 2 lines
lib/librte_pci/rte_pci.h extern "C" { · line 39
Quoted 2 lines
lib/librte_pci/rte_pci.h +2
-0+ +#define RTE_PCI_EXT_CAP_ID_ERR 0x01/* Advanced Error Reporting
Quoted 2 lines
Quoted 2 lines
*/
Quoted 1 line
lib/librte_pci/rte_pci.h +1
-0+#define RTE_PCI_EXT_CAP_ID_DSN 0x03/* Device Serial Number */
Quoted 10 lines
Quoted 9 lines
lib/librte_pci/rte_pci.h extern "C" { · line 41
Quoted 1 line
lib/librte_pci/rte_pci.h +1
-0+I understand that it is more natural to have those defines in the PCI lib, but I think there is no point in adding them in a separate lib, while the function using those is in the PCI bus.
I think the defines should be put right before the
rte_pci_find_next_ext_capability()prototype indrivers/bus/pci/rte_bus_pci.h.Quoted 6 lines
Hello Gaetan,
I think these comes in the category of all RTE_PCI_* generic defines (not just use in
drivers/bus/pci/), Since caller of the API also need to use it, For example, couple of RTE_PCI_* were added in patch #2 used by qede drivers specifically.rte_pci.hsounds more generic than
rte_bus_pci.hhence I thought it is the suitable place to consolidate them in there.Quoted 1 line
Quoted 8 lines
Quoted 1 line
Thanks !!
Reading the additional symbols, particularly about SRIOV capa, I think you are right, it's probably better to have it all within
rte_pci.h.To help developers, it would be better to point in the doc that the capability IDs useable as parameter
capcan be any from RTE_PCI_EXT_CAP_ID_*, defined withinlibrte_pci. The dev can then grep it.Sure, I will add the pointer to
librte_pciin the comment section forrte_pci_find_next_ext_capability()Quoted 11 lines
One additional thing:
Quoted 6 lines
Quoted 6 lines
lib/librte_pci/rte_pci.h extern "C" {
Quoted 6 lines
lib/librte_pci/rte_pci.h +6
-0+#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)Quoted 5 lines
I think those macros are not useful as part of the public API, they are only used to implement
rte_pci_find_next_ext_capability(). Can you confirm? If this is correct, I think they should be moved to the compilation unit implementingrte_pci_find_next_ext_capability().Hi Gaetan,
Yes Mostly, but there is a similar piece of code left in
drivers/raw/ifpga[ifpga_pci_find_ext_capability()] only which utilizes these symbols as well, which I did not want to be removed/cleaned up must as a part of this series because that implementation is based onpread()instead ofrte_pci_read_config(). I was not sure if that driver can also directly userte_pci_find_next_ext_capability()too, I do not have those fpga based devices to test if at all I were to do that cleanup/removal now in that driver, so I didn't attempt to make such functional changes in that driver now. [May be this can be cleaned up too later on with proper testing or may be a new API based onpread()can be added further if those drivers can't userte_pci_find_next_ext_capability()directly].
Quoted 1 line
Thanks.
Ok, as it is used elsewhere my suggestion does not stand, thanks for clarifying.
Signature · 1 line
Gaëtan
Re: [dpdk-dev] [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended cap
In reply to Manish ChopraHi,
Quoted 111 lines
-----Original Message-----
From: Manish Chopra <[email protected]>
Sent: Monday, July 27, 2020 13:11
To: Gaëtan Rivet <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; Igor Russkikh <[email protected]>; Rasesh Mody <[email protected]>; GR- Everest-DPDK-Dev <[email protected]>; Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: RE: [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended capQuoted 66 lines
-----Original Message-----
From: Gaëtan Rivet <[email protected]>
Sent: Monday, July 27, 2020 4:18 AM
To: Manish Chopra <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; Igor Russkikh <[email protected]>; Rasesh Mody <[email protected]>; GR-Everest- DPDK-Dev <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v3 1/6] drivers: add generic API to find PCI extended capOn 26/07/20 19:47 +0000, Manish Chopra wrote:
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_pci/rte_pci.h +0
-0@@ -22,6 +22,22 @@ extern "C" {#include <inttypes.h> #include <sys/types.h> Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_pci/rte_pci.h +5
-0+ +/* +* Conventional PCI and PCI-X Mode 1 devices have 256 bytes of +* configuration space. PCI-X Mode 2 and PCIe devices have +4096 bytes of Quoted 8 lines
lib/librte_pci/rte_pci.h extern "C" {
Quoted 8 lines
lib/librte_pci/rte_pci.h +8
-0+* configuration space. +*/ +#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)Quoted 2 lines
Quoted 2 lines
lib/librte_pci/rte_pci.h extern "C" { · line 39
Quoted 2 lines
lib/librte_pci/rte_pci.h +2
-0+ +#define RTE_PCI_EXT_CAP_ID_ERR 0x01/* Advanced Error Reporting
Quoted 2 lines
Quoted 2 lines
*/
Quoted 1 line
lib/librte_pci/rte_pci.h +1
-0+#define RTE_PCI_EXT_CAP_ID_DSN 0x03/* Device Serial Number */
Quoted 10 lines
Quoted 9 lines
lib/librte_pci/rte_pci.h extern "C" { · line 41
Quoted 1 line
lib/librte_pci/rte_pci.h +1
-0+I understand that it is more natural to have those defines in the PCI lib, but I think there is no point in adding them in a separate lib, while the function using those is in the PCI bus.
I think the defines should be put right before the
rte_pci_find_next_ext_capability()prototype indrivers/bus/pci/rte_bus_pci.h.Quoted 7 lines
Hello Gaetan,
I think these comes in the category of all RTE_PCI_* generic defines (not just use in
drivers/bus/pci/), Since caller of the API also need to use it, For example, couple of RTE_PCI_* were added in patch #2 used by qede drivers specifically.rte_pci.hsounds more generic than
rte_bus_pci.hhence I thought it is the suitable place to consolidate them in there.Quoted 1 line
Quoted 8 lines
Quoted 1 line
Thanks !!
Reading the additional symbols, particularly about SRIOV capa, I think you are right, it's probably better to have it all within
rte_pci.h.To help developers, it would be better to point in the doc that the capability IDs useable as parameter
capcan be any from RTE_PCI_EXT_CAP_ID_*, defined withinlibrte_pci. The dev can then grep it.Sure, I will add the pointer to
librte_pciin the comment section forrte_pci_find_next_ext_capability()Quoted 11 lines
One additional thing:
Quoted 6 lines
Quoted 6 lines
lib/librte_pci/rte_pci.h extern "C" {
Quoted 6 lines
lib/librte_pci/rte_pci.h +6
-0+#define RTE_PCI_CFG_SPACE_SIZE 256 +#define RTE_PCI_CFG_SPACE_EXP_SIZE 4096 + +/* 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)Quoted 5 lines
I think those macros are not useful as part of the public API, they are only used to implement
rte_pci_find_next_ext_capability(). Can you confirm? If this is correct, I think they should be moved to the compilation unit implementingrte_pci_find_next_ext_capability().Hi Gaetan,
Quoted 11 lines
Yes Mostly, but there is a similar piece of code left in
drivers/raw/ifpga[ifpga_pci_find_ext_capability()] only which utilizes these symbols as well, which I did not want to be removed/cleaned up must as a part of this series because that implementation is based onpread()instead ofrte_pci_read_config(). I was not sure if that driver can also directly userte_pci_find_next_ext_capability()too, I do not have those fpga based devices to test if at all I were to do that cleanup/removal now in that driver, so I didn't attempt to make such functional changes in that driver now. [May be this can be cleaned up too later on with proper testing or may be a new API based onpread()can be added further if those drivers can't userte_pci_find_next_ext_capability()directly].
For drivers/raw/ifpga is using these macros, I prefer to keep it.
Quoted 1 line
Thanks.
PATCH v3 2/6 net/qede: define PCI config space specific osals
In reply to Manish ChopraThis 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.
--- 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(-)
drivers/net/qede/base/bcm_osal.h +9 -5
@@ -21,6 +21,7 @@#include <rte_ether.h> #include <rte_io.h> #include <rte_version.h> +#include <rte_bus_pci.h> /* 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
drivers/net/qede/base/ecore.h +3 -0
@@ -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 {
drivers/net/qede/base/ecore_dev.c +3 -3
@@ -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 */
drivers/net/qede/base/ecore_sriov.c +15 -13
@@ -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 ;
drivers/net/qede/base/meson.build +1 -1
@@ -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_pci], c_args: c_args) base_objs = base_lib.extract_all_objects()
drivers/net/qede/qede_main.c +1 -0
@@ -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
lib/librte_pci/rte_pci.h +21 -2
@@ -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
Signature · 1 line
2.17.1
PATCH v3 3/6 net/qede: configure VFs on hardware
In reply to Manish ChopraBased on number of VFs enabled at PCI, PF-PMD driver instance enables/configures those VFs from hardware perspective, such that in later patches they could get required HW access to communicate with PFs for slowpath configuration and run the fastpath themsleves.
This patch also add two new qede IOV files [qede_sriov(.c|.h)] under qede directory to add non-base driver IOV APIs/contents there.
--- drivers/net/qede/Makefile | 1 + drivers/net/qede/meson.build | 1 + drivers/net/qede/qede_ethdev.c | 1 + drivers/net/qede/qede_ethdev.h | 1 + drivers/net/qede/qede_if.h | 1 + drivers/net/qede/qede_main.c | 1 + drivers/net/qede/qede_sriov.c | 85 ++++++++++++++++++++++++++++++++++ drivers/net/qede/qede_sriov.h | 9 ++++ 8 files changed, 100 insertions(+) create mode 100644 drivers/net/qede/qede_sriov.c create mode 100644 drivers/net/qede/qede_sriov.h
drivers/net/qede/Makefile +1 -0
@@ -105,5 +105,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede_filter.c SRCS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede_debug.c SRCS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede_regs.c +SRCS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede_sriov.c include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/qede/meson.build +1 -0
@@ -11,6 +11,7 @@ sources = files( 'qede_rxtx.c', 'qede_debug.c', 'qede_regs.c', + 'qede_sriov.c', ) if cc.has_argument('-Wno-format-nonliteral')
drivers/net/qede/qede_ethdev.c +1 -0
@@ -2700,6 +2700,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) adapter->vxlan.enable = false; adapter->geneve.enable = false; adapter->ipgre.enable = false; + qed_ops->sriov_configure (edev, pci_dev->max_vfs); } DP_INFO(edev, "MAC address : %02x:%02x:%02x:%02x:%02x:%02x\n",
drivers/net/qede/qede_ethdev.h +1 -0
@@ -34,6 +34,7 @@#include "base/ecore_l2.h" #include "base/ecore_vf.h" +#include "qede_sriov.h" #include "qede_logs.h" #include "qede_if.h" #include "qede_rxtx.h"
drivers/net/qede/qede_if.h +1 -0
@@ -82,6 +82,7 @@ struct qed_eth_ops {const struct qed_common_ops *common;int (*fill_dev_info)(struct ecore_dev *edev,struct qed_dev_eth_info *info); +void (*sriov_configure)(struct ecore_dev *edev,int num_vfs); };struct qed_link_params {
drivers/net/qede/qede_main.c +1 -0
@@ -822,6 +822,7 @@ const struct qed_common_ops qed_common_ops_pass = {const struct qed_eth_ops qed_eth_ops_pass = {INIT_STRUCT_FIELD (common, &qed_common_ops_pass),INIT_STRUCT_FIELD (fill_dev_info, &qed_fill_eth_dev_info), +INIT_STRUCT_FIELD (sriov_configure, &qed_sriov_configure), };const struct qed_eth_ops *qed_get_eth_ops (void )
drivers/net/qede/qede_sriov.c new file +85 -0
85 lines not on this page · raw message
drivers/net/qede/qede_sriov.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2020 Marvell. +* All rights reserved. +* www.marvell.com +*/ + +#include "qede_ethdev.h" + +void qed_sriov_configure (struct ecore_dev *edev,int num_vfs_param);
Signature · 1 line
2.17.1
PATCH v3 4/6 net/qede: add infrastructure support for VF load
In reply to Manish ChopraThis patch adds necessary infrastructure support (required to handle messages from VF and sending ramrod on behalf of VF's configuration request from alarm handler context) to start/load the VF-PMD driver instance on top of PF-PMD driver instance.
--- drivers/net/qede/base/bcm_osal.c | 26 ++++++++++++ drivers/net/qede/base/bcm_osal.h | 11 +++-- drivers/net/qede/base/ecore.h | 4 ++ drivers/net/qede/base/ecore_iov_api.h | 3 ++ drivers/net/qede/qede_ethdev.c | 2 + drivers/net/qede/qede_main.c | 4 +- drivers/net/qede/qede_sriov.c | 61 +++++++++++++++++++++++++++ drivers/net/qede/qede_sriov.h | 16 ++++++- 8 files changed, 121 insertions(+), 6 deletions(-)
drivers/net/qede/base/bcm_osal.c +26 -0
@@ -14,6 +14,32 @@#include "ecore_iov_api.h" #include "ecore_mcp_api.h" #include "ecore_l2_api.h" +#include "../qede_sriov.h" + +int osal_pf_vf_msg (struct ecore_hwfn *p_hwfn) +{ +int rc; + + rc =qed_schedule_iov (p_hwfn,QED_IOV_WQ_MSG_FLAG ); +if (rc) { +DP_VERBOSE (p_hwfn,ECORE_MSG_IOV , +"Failed to schedule alarm handler rc=%d\n" , rc); + } + +return rc; +} + +void osal_poll_mode_dpc (osal_int_ptr_t hwfn_cookie) +{ +struct ecore_hwfn *p_hwfn = (struct ecore_hwfn *)hwfn_cookie; + +if (!p_hwfn) +return ; + +OSAL_SPIN_LOCK (&p_hwfn->spq_lock); +ecore_int_sp_dpc ((osal_int_ptr_t)(p_hwfn)); +OSAL_SPIN_UNLOCK (&p_hwfn->spq_lock); +}/* Array of memzone pointers */ static const struct rte_memzone *ecore_mz_mapping[RTE_MAX_MEMZONE ];
drivers/net/qede/base/bcm_osal.h +8 -3
@@ -178,9 +178,12 @@ typedef pthread_mutex_t osal_mutex_t;/* DPC */ +void osal_poll_mode_dpc (osal_int_ptr_t hwfn_cookie);#define OSAL_DPC_ALLOC (hwfn) OSAL_ALLOC(hwfn, GFP, sizeof(osal_dpc_t)) -#define OSAL_DPC_INIT (dpc, hwfn) nothing -#define OSAL_POLL_MODE_DPC (hwfn) nothing +#define OSAL_DPC_INIT (dpc, hwfn) \ + OSAL_SPIN_LOCK_INIT(&(hwfn)->spq_lock) +#define OSAL_POLL_MODE_DPC (hwfn) \ + osal_poll_mode_dpc((osal_int_ptr_t)(p_hwfn))#define OSAL_DPC_SYNC (hwfn) nothing/* Lists */
@@ -345,10 +348,12 @@ u32 qede_find_first_zero_bit(u32 *bitmap, u32 length);/* SR-IOV channel */ +int osal_pf_vf_msg (struct ecore_hwfn *p_hwfn);#define OSAL_VF_FLR_UPDATE (hwfn) nothing#define OSAL_VF_SEND_MSG2PF (dev, done, msg, reply_addr, msg_size, reply_size) 0#define OSAL_VF_CQE_COMPLETION (_dev_p, _cqe, _protocol) (0) -#define OSAL_PF_VF_MSG (hwfn, vfid) 0 +#define OSAL_PF_VF_MSG (hwfn, vfid) \ + osal_pf_vf_msg(hwfn)#define OSAL_PF_VF_MALICIOUS (hwfn, vfid) nothing#define OSAL_IOV_CHK_UCAST (hwfn, vfid, params) 0#define OSAL_IOV_POST_START_VPORT (hwfn, vf, vport_id, opaque_fid) nothing
drivers/net/qede/base/ecore.h +4 -0
@@ -714,6 +714,10 @@ struct ecore_hwfn {/* @DPDK */ struct ecore_ptt *p_arfs_ptt; + +/* DPDK specific, not the part of vanilla ecore */ +osal_spinlock_t spq_lock; +u32 iov_task_flags; };enum ecore_mf_mode {
drivers/net/qede/base/ecore_iov_api.h +3 -0
@@ -14,6 +14,9 @@#define ECORE_ETH_VF_NUM_VLAN_FILTERS 2#define ECORE_VF_ARRAY_LENGTH (3) +#define ECORE_VF_ARRAY_GET_VFID (arr, vfid) \ + (((arr)[(vfid) / 64]) & (1ULL << ((vfid) % 64))) +#define IS_VF (p_dev) ((p_dev)->b_is_vf)#define IS_PF (p_dev) (!((p_dev)->b_is_vf))#ifdef CONFIG_ECORE_SRIOV
drivers/net/qede/qede_ethdev.c +2 -0
@@ -281,7 +281,9 @@ qede_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)static void qede_interrupt_action (struct ecore_hwfn *p_hwfn) { +OSAL_SPIN_LOCK (&p_hwfn->spq_lock);ecore_int_sp_dpc ((osal_int_ptr_t)(p_hwfn)); +OSAL_SPIN_UNLOCK (&p_hwfn->spq_lock); } static void
drivers/net/qede/qede_main.c +3 -1
@@ -221,7 +221,9 @@ static void qed_stop_iov_task(struct ecore_dev *edev)for_each_hwfn (edev, i) { p_hwfn = &edev->hwfns[i]; -if (!IS_PF (edev)) +if (IS_PF (edev)) +rte_eal_alarm_cancel (qed_iov_pf_task, p_hwfn); +else rte_eal_alarm_cancel (qede_vf_task, p_hwfn); } }
drivers/net/qede/qede_sriov.c +61 -0
70 lines not on this page · raw message
drivers/net/qede/qede_sriov.h +14 -2
@@ -4,6 +4,18 @@* www.marvell.com */ -#include "qede_ethdev.h" -void qed_sriov_configure (struct ecore_dev *edev,int num_vfs_param); + +enum qed_iov_wq_flag { +QED_IOV_WQ_MSG_FLAG , +QED_IOV_WQ_SET_UNICAST_FILTER_FLAG , +QED_IOV_WQ_BULLETIN_UPDATE_FLAG , +QED_IOV_WQ_STOP_WQ_FLAG , +QED_IOV_WQ_FLR_FLAG , +QED_IOV_WQ_TRUST_FLAG , +QED_IOV_WQ_VF_FORCE_LINK_QUERY_FLAG , +QED_IOV_WQ_DB_REC_HANDLER , +}; + +int qed_schedule_iov (struct ecore_hwfn *p_hwfn,enum qed_iov_wq_flag flag); +void qed_iov_pf_task (void *arg);
Signature · 1 line
2.17.1
PATCH v3 5/6 net/qede: initialize VF MAC and link
In reply to Manish ChopraThis patch configures VFs with random mac if no MAC is provided by the PF/bulletin. This also adds required bulletin APIs by PF-PMD driver to communicate LINK properties/changes to the VFs through bulletin update mechanism.
With these changes, VF-PMD instance is able to run fastpath over PF-PMD driver instance.
--- drivers/net/qede/qede_ethdev.c | 34 ++++++++++++++++++++- drivers/net/qede/qede_main.c | 7 ++++- drivers/net/qede/qede_sriov.c | 55 ++++++++++++++++++++++++++++++++++ drivers/net/qede/qede_sriov.h | 1 + 4 files changed, 95 insertions(+), 2 deletions(-)
drivers/net/qede/qede_ethdev.c +33 -1
@@ -2479,6 +2479,24 @@ static void qede_update_pf_params(struct ecore_dev *edev) qed_ops->common->update_pf_params (edev, &pf_params); } +static void qede_generate_random_mac_addr (struct rte_ether_addr *mac_addr) +{ +uint64_t random; + +/* Set Organizationally Unique Identifier (OUI) prefix. */ + mac_addr->addr_bytes[0 ] =0x00 ; + mac_addr->addr_bytes[1 ] =0x09 ; + mac_addr->addr_bytes[2 ] =0xC0 ; + +/* Force indication of locally assigned MAC address. */ + mac_addr->addr_bytes[0 ] |=RTE_ETHER_LOCAL_ADMIN_ADDR ; + +/* Generate the last 3 bytes of the MAC address with a random number. */ + random =rte_rand (); + +memcpy (&mac_addr->addr_bytes[3 ], &random,3 ); +} +static int qede_common_dev_init (struct rte_eth_dev *eth_dev,bool is_vf) {struct rte_pci_device *pci_dev;
@@ -2491,7 +2509,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf)uint8_t bulletin_change;uint8_t vf_mac[RTE_ETHER_ADDR_LEN ];uint8_t is_mac_forced; -bool is_mac_exist; +bool is_mac_exist = false;/* Fix up ecore debug level */ uint32_t dp_module = ~0 & ~ECORE_MSG_HW ;uint8_t dp_level =ECORE_LEVEL_VERBOSE ;
@@ -2669,6 +2687,20 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf)DP_ERR (edev,"No VF macaddr assigned\n" ); } } + +/* If MAC doesn't exist from PF, generate random one */ +if (!is_mac_exist) { +struct rte_ether_addr *mac_addr; + + mac_addr = (struct rte_ether_addr *)&vf_mac; +qede_generate_random_mac_addr (mac_addr); + +rte_ether_addr_copy (mac_addr, + ð_dev->data->mac_addrs[0 ]); + +rte_ether_addr_copy (ð_dev->data->mac_addrs[0 ], + &adapter->primary_mac); + } } eth_dev->dev_ops = (is_vf) ? &qede_eth_vf_dev_ops : &qede_eth_dev_ops;
drivers/net/qede/qede_main.c +6 -1
@@ -651,10 +651,15 @@ void qed_link_update(struct ecore_hwfn *hwfn)struct ecore_dev *edev = hwfn->p_dev;struct qede_dev *qdev = (struct qede_dev *)edev;struct rte_eth_dev *dev = (struct rte_eth_dev *)qdev->ethdev; +int rc; + + rc =qede_link_update (dev,0 ); +qed_inform_vf_link_state (hwfn); -if (!qede_link_update (dev,0 )) +if (!rc) {_rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_INTR_LSC ,NULL ); + } }static int qed_drain (struct ecore_dev *edev)
drivers/net/qede/qede_sriov.c +55 -0
70 lines not on this page · raw message
drivers/net/qede/qede_sriov.h +1 -0
@@ -17,5 +17,6 @@ enum qed_iov_wq_flag { QED_IOV_WQ_DB_REC_HANDLER, }; +void qed_inform_vf_link_state (struct ecore_hwfn *hwfn);int qed_schedule_iov (struct ecore_hwfn *p_hwfn,enum qed_iov_wq_flag flag);void qed_iov_pf_task (void *arg);
Signature · 1 line
2.17.1
PATCH v3 6/6 net/qede: add VF FLR support
In reply to Manish ChopraThis patch adds required bit to handle VF FLR indication from Management FW (MFW) of the device
With that VFs were able to load in VM (VF attached as PCI passthrough to the guest VM) followed by FLR successfully
Updated the docs/guides with the feature support
--- doc/guides/nics/features/qede.ini | 1 + doc/guides/nics/qede.rst | 7 +------ drivers/net/qede/base/bcm_osal.c | 5 +++++ drivers/net/qede/base/bcm_osal.h | 4 +++- drivers/net/qede/qede_sriov.c | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 7 deletions(-)
doc/guides/nics/features/qede.ini +1 -0
@@ -32,6 +32,7 @@ Basic stats = Y Extended stats = Y Stats per queue = Y Registers dump = Y +SR-IOV = Y Multiprocess aware = Y Linux UIO = Y Linux VFIO = Y
doc/guides/nics/qede.rst +1 -6
@@ -34,18 +34,13 @@ Supported Features - VLAN offload - Filtering and stripping - N-tuple filter and flow director (limited support) - NPAR (NIC Partitioning) -- SR-IOV VF +- SR-IOV PF and VF - GRE Tunneling offload - GENEVE Tunneling offload - VXLAN Tunneling offload - MPLSoUDP Tx Tunneling offload - Generic flow API -Non-supported Features ----------------------- - -- SR-IOV PF - Co-existence considerations ---------------------------
drivers/net/qede/base/bcm_osal.c +5 -0
@@ -29,6 +29,11 @@ int osal_pf_vf_msg(struct ecore_hwfn *p_hwfn)return rc; } +void osal_vf_flr_update (struct ecore_hwfn *p_hwfn) +{ +qed_schedule_iov (p_hwfn,QED_IOV_WQ_FLR_FLAG ); +} +void osal_poll_mode_dpc (osal_int_ptr_t hwfn_cookie) {struct ecore_hwfn *p_hwfn = (struct ecore_hwfn *)hwfn_cookie;
drivers/net/qede/base/bcm_osal.h +3 -1
@@ -349,7 +349,9 @@ u32 qede_find_first_zero_bit(u32 *bitmap, u32 length);/* SR-IOV channel */ int osal_pf_vf_msg (struct ecore_hwfn *p_hwfn); -#define OSAL_VF_FLR_UPDATE (hwfn) nothing +void osal_vf_flr_update (struct ecore_hwfn *p_hwfn); +#define OSAL_VF_FLR_UPDATE (hwfn) \ + osal_vf_flr_update(hwfn)#define OSAL_VF_SEND_MSG2PF (dev, done, msg, reply_addr, msg_size, reply_size) 0#define OSAL_VF_CQE_COMPLETION (_dev_p, _cqe, _protocol) (0)#define OSAL_PF_VF_MSG (hwfn, vfid) \
drivers/net/qede/qede_sriov.c +18 -0
@@ -151,6 +151,7 @@ static void qed_handle_bulletin_post(struct ecore_hwfn *hwfn)void qed_iov_pf_task (void *arg) {struct ecore_hwfn *p_hwfn = arg; +int rc;if (OSAL_GET_BIT (QED_IOV_WQ_MSG_FLAG , &p_hwfn->iov_task_flags)) {OSAL_CLEAR_BIT (QED_IOV_WQ_MSG_FLAG , &p_hwfn->iov_task_flags);
@@ -163,6 +164,23 @@ void qed_iov_pf_task(void *arg) &p_hwfn->iov_task_flags);qed_handle_bulletin_post (p_hwfn); } + +if (OSAL_GET_BIT (QED_IOV_WQ_FLR_FLAG , &p_hwfn->iov_task_flags)) { +struct ecore_ptt *p_ptt =ecore_ptt_acquire (p_hwfn); + +OSAL_CLEAR_BIT (QED_IOV_WQ_FLR_FLAG , &p_hwfn->iov_task_flags); + +if (!p_ptt) { +qed_schedule_iov (p_hwfn,QED_IOV_WQ_FLR_FLAG ); +return ; + } + + rc =ecore_iov_vf_flr_cleanup (p_hwfn, p_ptt); +if (rc) +qed_schedule_iov (p_hwfn,QED_IOV_WQ_FLR_FLAG ); + +ecore_ptt_release (p_hwfn, p_ptt); + } }int qed_schedule_iov (struct ecore_hwfn *p_hwfn,enum qed_iov_wq_flag flag)
Signature · 1 line
2.17.1