fpga: dfl: optional VSEC for start of dfl
Subsystems (3)
v4 cover fpga: dfl: optional VSEC for start of dfl
From: Matthew Gerlach <[email protected]>
The start of a Device Feature List (DFL) is currently assumed to be at Bar0/Offset 0 on the PCIe bus by drivers/fpga/dfl-pci.c. This patchset adds support for the start one or more DFLs to be specified in a Vendor-Specific Capability (VSEC) structure in PCIe config space. If no such VSEC structure exists, then the start is assumed to be Bar0/Offset 0 for backward compatibility.
Matthew Gerlach (2):
fpga: dfl: refactor cci_enumerate_feature_devs()
fpga: dfl-pci: locate DFLs by PCIe vendor specific capability
Documentation/fpga/dfl.rst | 27 ++++++ drivers/fpga/dfl-pci.c | 165 +++++++++++++++++++++++++++++-------- 2 files changed, 157 insertions(+), 35 deletions(-)
Signature · 1 line
2.25.2
PATCH v4 1/2 fpga: dfl: refactor cci_enumerate_feature_devs()
From: Matthew Gerlach <[email protected]>
In preparation of looking for dfls based on a vendor specific pci capability, move the code for the default method of finding the first dfl at offset 0 of Bar 0 to its own function.
---
v4: add comment
squash local variable definition
v3: no change
v2: remove spurious blank lines
rename find_dfl_in_bar0 to find_dfls_by_default
--- drivers/fpga/dfl-pci.c | 84 +++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 37 deletions(-)
drivers/fpga/dfl-pci.c +47 -37
@@ -119,49 +119,20 @@ static int *cci_pci_create_irq_table(struct pci_dev *pcidev, unsigned int nvec)return table; } -/* enumerate feature devices under pci device */ -static int cci_enumerate_feature_devs (struct pci_dev *pcidev) +/* default method of finding dfls starting at offset 0 of bar 0 */ +static int find_dfls_by_default (struct pci_dev *pcidev, +struct dfl_fpga_enum_info *info) { -struct cci_drvdata *drvdata =pci_get_drvdata (pcidev); -int port_num, bar, i, nvec, ret =0 ; -struct dfl_fpga_enum_info *info; -struct dfl_fpga_cdev *cdev; +int port_num, bar, i, ret =0 ;resource_size_t start, len;void __iomem *base; -int *irq_table;u32 offset;u64 v; -/* allocate enumeration info via pci_dev */ - info =dfl_fpga_enum_info_alloc (&pcidev->dev); -if (!info) -return -ENOMEM ; - -/* add irq info for enumeration if the device support irq */ - nvec =cci_pci_alloc_irq (pcidev); -if (nvec <0 ) { -dev_err (&pcidev->dev,"Fail to alloc irq %d.\n" , nvec); - ret = nvec; - goto enum_info_free_exit; - }else if (nvec) { - irq_table =cci_pci_create_irq_table (pcidev, nvec); -if (!irq_table) { - ret = -ENOMEM ; - goto irq_free_exit; - } - - ret =dfl_fpga_enum_info_add_irq (info, nvec, irq_table); -kfree (irq_table); -if (ret) - goto irq_free_exit; - } - -/* start to find Device Feature List in Bar 0 */ +/* start to find Device Feature List from Bar 0 */ base =cci_pci_ioremap_bar0 (pcidev); -if (!base) { - ret = -ENOMEM ; - goto irq_free_exit; - } +if (!base) +return -ENOMEM ;/* * PF device has FME and Ports/AFUs, and VF device only has one
@@ -208,12 +179,51 @@ static int cci_enumerate_feature_devs(struct pci_dev *pcidev)dfl_fpga_enum_info_add_dfl (info, start, len); }else { ret = -ENODEV ; - goto irq_free_exit; }/* release I/O mappings for next step enumeration */ pcim_iounmap_regions (pcidev,BIT (0 )); +return ret; +} + +/* enumerate feature devices under pci device */ +static int cci_enumerate_feature_devs (struct pci_dev *pcidev) +{ +struct cci_drvdata *drvdata =pci_get_drvdata (pcidev); +struct dfl_fpga_enum_info *info; +struct dfl_fpga_cdev *cdev; +int nvec, ret =0 ; +int *irq_table; + +/* allocate enumeration info via pci_dev */ + info =dfl_fpga_enum_info_alloc (&pcidev->dev); +if (!info) +return -ENOMEM ; + +/* add irq info for enumeration if the device support irq */ + nvec =cci_pci_alloc_irq (pcidev); +if (nvec <0 ) { +dev_err (&pcidev->dev,"Fail to alloc irq %d.\n" , nvec); + ret = nvec; + goto enum_info_free_exit; + }else if (nvec) { + irq_table =cci_pci_create_irq_table (pcidev, nvec); +if (!irq_table) { + ret = -ENOMEM ; + goto irq_free_exit; + } + + ret =dfl_fpga_enum_info_add_irq (info, nvec, irq_table); +kfree (irq_table); +if (ret) + goto irq_free_exit; + } + + ret =find_dfls_by_default (pcidev, info); +if (ret) + goto irq_free_exit; +/* start enumeration with prepared enumeration information */ cdev =dfl_fpga_feature_devs_enumerate (info);if (IS_ERR (cdev)) {
Signature · 1 line
2.25.2
PATCH v4 2/2 fpga: dfl-pci: locate DFLs by PCIe vendor specific capability
In reply to [email protected]From: Matthew Gerlach <[email protected]>
A PCIe vendor specific extended capability is introduced by Intel to specify the start of a number of DFLs.
---
v4: Clarify PCI vs. PCIe in documentation
Various cleanup suggested by [email protected] Document and enforce specifying a single DFL per BAR
v3: Add text and ascii art to documentation.
Ensure not to exceed PCIe config space in loop.
v2: Update documentation for clarity.
Clean up macro names.
Use GENMASK.
Removed spurious blank lines.
Changed some calls from dev_info to dev_dbg.
Specifically check for VSEC not found, -ENODEV.
Ensure correct pci vendor id.
Remove check for page alignment.
Rename find_dfl_in_cfg to find_dfls_by_vsec.
Initialize target memory of pci_read_config_dword to invalid values before use.
--- Documentation/fpga/dfl.rst | 27 ++++++++++++ drivers/fpga/dfl-pci.c | 87 +++++++++++++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 1 deletion(-)
Documentation/fpga/dfl.rst +27 -0
@@ -501,6 +501,33 @@ Developer only needs to provide a sub feature driver with matched feature id. FME Partial Reconfiguration Sub Feature driver (see drivers/fpga/dfl-fme-pr.c) could be a reference. +Location of DFLs on a PCI Device +=========================== +The original method for finding a DFL on a PCI device assumed the start of the +first DFL to offset 0 of bar 0. If the first node of the DFL is an FME, +then further DFLs in the port(s) are specified in FME header registers. +Alternatively, a PCIe vendor specific capability structure can be used to +specify the location of all the DFLs on the device, providing flexibility +for the type of starting node in the DFL. Intel has reserved the +VSEC ID of 0x43 for this purpose. The vendor specific +data begins with a 4 byte vendor specific register for the number of DFLs followed 4 byte +Offset/BIR vendor specific registers for each DFL. Bits 2:0 of Offset/BIR register +indicates the BAR, and bits 31:3 form the 8 byte aligned offset where bits 2:0 are +zero. + + +----------------------------+ + |31 Number of DFLS 0| + +----------------------------+ + |31 Offset 3|2 BIR 0| + +----------------------------+ + . . . + +----------------------------+ + |31 Offset 3|2 BIR 0| + +----------------------------+ + +Being able to specify more than one DFL per BAR has been considered, but it +was determined the use case did not provide value. Specifying a single DFL +per BAR simplifies the implementation and allows for extra error checking. Open discussion ===============
drivers/fpga/dfl-pci.c +86 -1
105 lines not on this page · raw message
Signature · 1 line
2.25.2