162306a36Sopenharmony_ci=================================================
262306a36Sopenharmony_ciFPGA Device Feature List (DFL) Framework Overview
362306a36Sopenharmony_ci=================================================
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciAuthors:
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci- Enno Luebbers <enno.luebbers@intel.com>
862306a36Sopenharmony_ci- Xiao Guangrong <guangrong.xiao@linux.intel.com>
962306a36Sopenharmony_ci- Wu Hao <hao.wu@intel.com>
1062306a36Sopenharmony_ci- Xu Yilun <yilun.xu@intel.com>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciThe Device Feature List (DFL) FPGA framework (and drivers according to
1362306a36Sopenharmony_cithis framework) hides the very details of low layer hardware and provides
1462306a36Sopenharmony_ciunified interfaces to userspace. Applications could use these interfaces to
1562306a36Sopenharmony_ciconfigure, enumerate, open and access FPGA accelerators on platforms which
1662306a36Sopenharmony_ciimplement the DFL in the device memory. Besides this, the DFL framework
1762306a36Sopenharmony_cienables system level management functions such as FPGA reconfiguration.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciDevice Feature List (DFL) Overview
2162306a36Sopenharmony_ci==================================
2262306a36Sopenharmony_ciDevice Feature List (DFL) defines a linked list of feature headers within the
2362306a36Sopenharmony_cidevice MMIO space to provide an extensible way of adding features. Software can
2462306a36Sopenharmony_ciwalk through these predefined data structures to enumerate FPGA features:
2562306a36Sopenharmony_ciFPGA Interface Unit (FIU), Accelerated Function Unit (AFU) and Private Features,
2662306a36Sopenharmony_cias illustrated below::
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci    Header            Header            Header            Header
2962306a36Sopenharmony_ci +----------+  +-->+----------+  +-->+----------+  +-->+----------+
3062306a36Sopenharmony_ci |   Type   |  |   |  Type    |  |   |  Type    |  |   |  Type    |
3162306a36Sopenharmony_ci |   FIU    |  |   | Private  |  |   | Private  |  |   | Private  |
3262306a36Sopenharmony_ci +----------+  |   | Feature  |  |   | Feature  |  |   | Feature  |
3362306a36Sopenharmony_ci | Next_DFH |--+   +----------+  |   +----------+  |   +----------+
3462306a36Sopenharmony_ci +----------+      | Next_DFH |--+   | Next_DFH |--+   | Next_DFH |--> NULL
3562306a36Sopenharmony_ci |    ID    |      +----------+      +----------+      +----------+
3662306a36Sopenharmony_ci +----------+      |    ID    |      |    ID    |      |    ID    |
3762306a36Sopenharmony_ci | Next_AFU |--+   +----------+      +----------+      +----------+
3862306a36Sopenharmony_ci +----------+  |   | Feature  |      | Feature  |      | Feature  |
3962306a36Sopenharmony_ci |  Header  |  |   | Register |      | Register |      | Register |
4062306a36Sopenharmony_ci | Register |  |   |   Set    |      |   Set    |      |   Set    |
4162306a36Sopenharmony_ci |   Set    |  |   +----------+      +----------+      +----------+
4262306a36Sopenharmony_ci +----------+  |      Header
4362306a36Sopenharmony_ci               +-->+----------+
4462306a36Sopenharmony_ci                   |   Type   |
4562306a36Sopenharmony_ci                   |   AFU    |
4662306a36Sopenharmony_ci                   +----------+
4762306a36Sopenharmony_ci                   | Next_DFH |--> NULL
4862306a36Sopenharmony_ci                   +----------+
4962306a36Sopenharmony_ci                   |   GUID   |
5062306a36Sopenharmony_ci                   +----------+
5162306a36Sopenharmony_ci                   |  Header  |
5262306a36Sopenharmony_ci                   | Register |
5362306a36Sopenharmony_ci                   |   Set    |
5462306a36Sopenharmony_ci                   +----------+
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciFPGA Interface Unit (FIU) represents a standalone functional unit for the
5762306a36Sopenharmony_ciinterface to FPGA, e.g. the FPGA Management Engine (FME) and Port (more
5862306a36Sopenharmony_cidescriptions on FME and Port in later sections).
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciAccelerated Function Unit (AFU) represents an FPGA programmable region and
6162306a36Sopenharmony_cialways connects to a FIU (e.g. a Port) as its child as illustrated above.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciPrivate Features represent sub features of the FIU and AFU. They could be
6462306a36Sopenharmony_civarious function blocks with different IDs, but all private features which
6562306a36Sopenharmony_cibelong to the same FIU or AFU, must be linked to one list via the Next Device
6662306a36Sopenharmony_ciFeature Header (Next_DFH) pointer.
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciEach FIU, AFU and Private Feature could implement its own functional registers.
6962306a36Sopenharmony_ciThe functional register set for FIU and AFU, is named as Header Register Set,
7062306a36Sopenharmony_cie.g. FME Header Register Set, and the one for Private Feature, is named as
7162306a36Sopenharmony_ciFeature Register Set, e.g. FME Partial Reconfiguration Feature Register Set.
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciThis Device Feature List provides a way of linking features together, it's
7462306a36Sopenharmony_ciconvenient for software to locate each feature by walking through this list,
7562306a36Sopenharmony_ciand can be implemented in register regions of any FPGA device.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ciDevice Feature Header - Version 0
7962306a36Sopenharmony_ci=================================
8062306a36Sopenharmony_ciVersion 0 (DFHv0) is the original version of the Device Feature Header.
8162306a36Sopenharmony_ciAll multi-byte quantities in DFHv0 are little-endian.
8262306a36Sopenharmony_ciThe format of DFHv0 is shown below::
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
8562306a36Sopenharmony_ci    |63 Type 60|59 DFH VER 52|51 Rsvd 41|40 EOL|39 Next 16|15 REV 12|11 ID 0| 0x00
8662306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
8762306a36Sopenharmony_ci    |63                                 GUID_L                             0| 0x08
8862306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
8962306a36Sopenharmony_ci    |63                                 GUID_H                             0| 0x10
9062306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci- Offset 0x00
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci  * Type - The type of DFH (e.g. FME, AFU, or private feature).
9562306a36Sopenharmony_ci  * DFH VER - The version of the DFH.
9662306a36Sopenharmony_ci  * Rsvd - Currently unused.
9762306a36Sopenharmony_ci  * EOL - Set if the DFH is the end of the Device Feature List (DFL).
9862306a36Sopenharmony_ci  * Next - The offset in bytes of the next DFH in the DFL from the DFH start,
9962306a36Sopenharmony_ci    and the start of a DFH must be aligned to an 8 byte boundary.
10062306a36Sopenharmony_ci    If EOL is set, Next is the size of MMIO of the last feature in the list.
10162306a36Sopenharmony_ci  * REV - The revision of the feature associated with this header.
10262306a36Sopenharmony_ci  * ID - The feature ID if Type is private feature.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci- Offset 0x08
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci  * GUID_L - Least significant 64 bits of a 128-bit Globally Unique Identifier
10762306a36Sopenharmony_ci    (present only if Type is FME or AFU).
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci- Offset 0x10
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci  * GUID_H - Most significant 64 bits of a 128-bit Globally Unique Identifier
11262306a36Sopenharmony_ci    (present only if Type is FME or AFU).
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ciDevice Feature Header - Version 1
11662306a36Sopenharmony_ci=================================
11762306a36Sopenharmony_ciVersion 1 (DFHv1) of the Device Feature Header adds the following functionality:
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci* Provides a standardized mechanism for features to describe
12062306a36Sopenharmony_ci  parameters/capabilities to software.
12162306a36Sopenharmony_ci* Standardize the use of a GUID for all DFHv1 types.
12262306a36Sopenharmony_ci* Decouples the DFH location from the register space of the feature itself.
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ciAll multi-byte quantities in DFHv1 are little-endian.
12562306a36Sopenharmony_ciThe format of Version 1 of the Device Feature Header (DFH) is shown below::
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
12862306a36Sopenharmony_ci    |63 Type 60|59 DFH VER 52|51 Rsvd 41|40 EOL|39 Next 16|15 REV 12|11 ID 0| 0x00
12962306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
13062306a36Sopenharmony_ci    |63                                 GUID_L                             0| 0x08
13162306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
13262306a36Sopenharmony_ci    |63                                 GUID_H                             0| 0x10
13362306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
13462306a36Sopenharmony_ci    |63                   Reg Address/Offset                      1|  Rel  0| 0x18
13562306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
13662306a36Sopenharmony_ci    |63        Reg Size       32|Params 31|30 Group    16|15 Instance      0| 0x20
13762306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
13862306a36Sopenharmony_ci    |63 Next    35|34RSV33|EOP32|31 Param Version 16|15 Param ID           0| 0x28
13962306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
14062306a36Sopenharmony_ci    |63                 Parameter Data                                     0| 0x30
14162306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci                                  ...
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
14662306a36Sopenharmony_ci    |63 Next    35|34RSV33|EOP32|31 Param Version 16|15 Param ID           0|
14762306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
14862306a36Sopenharmony_ci    |63                 Parameter Data                                     0|
14962306a36Sopenharmony_ci    +-----------------------------------------------------------------------+
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci- Offset 0x00
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci  * Type - The type of DFH (e.g. FME, AFU, or private feature).
15462306a36Sopenharmony_ci  * DFH VER - The version of the DFH.
15562306a36Sopenharmony_ci  * Rsvd - Currently unused.
15662306a36Sopenharmony_ci  * EOL - Set if the DFH is the end of the Device Feature List (DFL).
15762306a36Sopenharmony_ci  * Next - The offset in bytes of the next DFH in the DFL from the DFH start,
15862306a36Sopenharmony_ci    and the start of a DFH must be aligned to an 8 byte boundary.
15962306a36Sopenharmony_ci    If EOL is set, Next is the size of MMIO of the last feature in the list.
16062306a36Sopenharmony_ci  * REV - The revision of the feature associated with this header.
16162306a36Sopenharmony_ci  * ID - The feature ID if Type is private feature.
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci- Offset 0x08
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci  * GUID_L - Least significant 64 bits of a 128-bit Globally Unique Identifier.
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci- Offset 0x10
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci  * GUID_H - Most significant 64 bits of a 128-bit Globally Unique Identifier.
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci- Offset 0x18
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci  * Reg Address/Offset - If Rel bit is set, then the value is the high 63 bits
17462306a36Sopenharmony_ci    of a 16-bit aligned absolute address of the feature's registers. Otherwise
17562306a36Sopenharmony_ci    the value is the offset from the start of the DFH of the feature's registers.
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci- Offset 0x20
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci  * Reg Size - Size of feature's register set in bytes.
18062306a36Sopenharmony_ci  * Params - Set if DFH has a list of parameter blocks.
18162306a36Sopenharmony_ci  * Group - Id of group if feature is part of a group.
18262306a36Sopenharmony_ci  * Instance - Id of feature instance within a group.
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci- Offset 0x28 if feature has parameters
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci  * Next - Offset to the next parameter block in 8 byte words. If EOP set,
18762306a36Sopenharmony_ci    size in 8 byte words of last parameter.
18862306a36Sopenharmony_ci  * Param Version - Version of Param ID.
18962306a36Sopenharmony_ci  * Param ID - ID of parameter.
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci- Offset 0x30
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci  * Parameter Data - Parameter data whose size and format is defined by
19462306a36Sopenharmony_ci    version and ID of the parameter.
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ciFIU - FME (FPGA Management Engine)
19862306a36Sopenharmony_ci==================================
19962306a36Sopenharmony_ciThe FPGA Management Engine performs reconfiguration and other infrastructure
20062306a36Sopenharmony_cifunctions. Each FPGA device only has one FME.
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ciUser-space applications can acquire exclusive access to the FME using open(),
20362306a36Sopenharmony_ciand release it using close().
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ciThe following functions are exposed through ioctls:
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci- Get driver API version (DFL_FPGA_GET_API_VERSION)
20862306a36Sopenharmony_ci- Check for extensions (DFL_FPGA_CHECK_EXTENSION)
20962306a36Sopenharmony_ci- Program bitstream (DFL_FPGA_FME_PORT_PR)
21062306a36Sopenharmony_ci- Assign port to PF (DFL_FPGA_FME_PORT_ASSIGN)
21162306a36Sopenharmony_ci- Release port from PF (DFL_FPGA_FME_PORT_RELEASE)
21262306a36Sopenharmony_ci- Get number of irqs of FME global error (DFL_FPGA_FME_ERR_GET_IRQ_NUM)
21362306a36Sopenharmony_ci- Set interrupt trigger for FME error (DFL_FPGA_FME_ERR_SET_IRQ)
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ciMore functions are exposed through sysfs
21662306a36Sopenharmony_ci(/sys/class/fpga_region/regionX/dfl-fme.n/):
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci Read bitstream ID (bitstream_id)
21962306a36Sopenharmony_ci     bitstream_id indicates version of the static FPGA region.
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci Read bitstream metadata (bitstream_metadata)
22262306a36Sopenharmony_ci     bitstream_metadata includes detailed information of static FPGA region,
22362306a36Sopenharmony_ci     e.g. synthesis date and seed.
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci Read number of ports (ports_num)
22662306a36Sopenharmony_ci     one FPGA device may have more than one port, this sysfs interface indicates
22762306a36Sopenharmony_ci     how many ports the FPGA device has.
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci Global error reporting management (errors/)
23062306a36Sopenharmony_ci     error reporting sysfs interfaces allow user to read errors detected by the
23162306a36Sopenharmony_ci     hardware, and clear the logged errors.
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci Power management (dfl_fme_power hwmon)
23462306a36Sopenharmony_ci     power management hwmon sysfs interfaces allow user to read power management
23562306a36Sopenharmony_ci     information (power consumption, thresholds, threshold status, limits, etc.)
23662306a36Sopenharmony_ci     and configure power thresholds for different throttling levels.
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci Thermal management (dfl_fme_thermal hwmon)
23962306a36Sopenharmony_ci     thermal management hwmon sysfs interfaces allow user to read thermal
24062306a36Sopenharmony_ci     management information (current temperature, thresholds, threshold status,
24162306a36Sopenharmony_ci     etc.).
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci Performance reporting
24462306a36Sopenharmony_ci     performance counters are exposed through perf PMU APIs. Standard perf tool
24562306a36Sopenharmony_ci     can be used to monitor all available perf events. Please see performance
24662306a36Sopenharmony_ci     counter section below for more detailed information.
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ciFIU - PORT
25062306a36Sopenharmony_ci==========
25162306a36Sopenharmony_ciA port represents the interface between the static FPGA fabric and a partially
25262306a36Sopenharmony_cireconfigurable region containing an AFU. It controls the communication from SW
25362306a36Sopenharmony_cito the accelerator and exposes features such as reset and debug. Each FPGA
25462306a36Sopenharmony_cidevice may have more than one port, but always one AFU per port.
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ciAFU
25862306a36Sopenharmony_ci===
25962306a36Sopenharmony_ciAn AFU is attached to a port FIU and exposes a fixed length MMIO region to be
26062306a36Sopenharmony_ciused for accelerator-specific control registers.
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ciUser-space applications can acquire exclusive access to an AFU attached to a
26362306a36Sopenharmony_ciport by using open() on the port device node and release it using close().
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ciThe following functions are exposed through ioctls:
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci- Get driver API version (DFL_FPGA_GET_API_VERSION)
26862306a36Sopenharmony_ci- Check for extensions (DFL_FPGA_CHECK_EXTENSION)
26962306a36Sopenharmony_ci- Get port info (DFL_FPGA_PORT_GET_INFO)
27062306a36Sopenharmony_ci- Get MMIO region info (DFL_FPGA_PORT_GET_REGION_INFO)
27162306a36Sopenharmony_ci- Map DMA buffer (DFL_FPGA_PORT_DMA_MAP)
27262306a36Sopenharmony_ci- Unmap DMA buffer (DFL_FPGA_PORT_DMA_UNMAP)
27362306a36Sopenharmony_ci- Reset AFU (DFL_FPGA_PORT_RESET)
27462306a36Sopenharmony_ci- Get number of irqs of port error (DFL_FPGA_PORT_ERR_GET_IRQ_NUM)
27562306a36Sopenharmony_ci- Set interrupt trigger for port error (DFL_FPGA_PORT_ERR_SET_IRQ)
27662306a36Sopenharmony_ci- Get number of irqs of UINT (DFL_FPGA_PORT_UINT_GET_IRQ_NUM)
27762306a36Sopenharmony_ci- Set interrupt trigger for UINT (DFL_FPGA_PORT_UINT_SET_IRQ)
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ciDFL_FPGA_PORT_RESET:
28062306a36Sopenharmony_ci  reset the FPGA Port and its AFU. Userspace can do Port
28162306a36Sopenharmony_ci  reset at any time, e.g. during DMA or Partial Reconfiguration. But it should
28262306a36Sopenharmony_ci  never cause any system level issue, only functional failure (e.g. DMA or PR
28362306a36Sopenharmony_ci  operation failure) and be recoverable from the failure.
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ciUser-space applications can also mmap() accelerator MMIO regions.
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ciMore functions are exposed through sysfs:
28862306a36Sopenharmony_ci(/sys/class/fpga_region/<regionX>/<dfl-port.m>/):
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci Read Accelerator GUID (afu_id)
29162306a36Sopenharmony_ci     afu_id indicates which PR bitstream is programmed to this AFU.
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci Error reporting (errors/)
29462306a36Sopenharmony_ci     error reporting sysfs interfaces allow user to read port/afu errors
29562306a36Sopenharmony_ci     detected by the hardware, and clear the logged errors.
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ciDFL Framework Overview
29962306a36Sopenharmony_ci======================
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci::
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci         +----------+    +--------+ +--------+ +--------+
30462306a36Sopenharmony_ci         |   FME    |    |  AFU   | |  AFU   | |  AFU   |
30562306a36Sopenharmony_ci         |  Module  |    | Module | | Module | | Module |
30662306a36Sopenharmony_ci         +----------+    +--------+ +--------+ +--------+
30762306a36Sopenharmony_ci                 +-----------------------+
30862306a36Sopenharmony_ci                 | FPGA Container Device |    Device Feature List
30962306a36Sopenharmony_ci                 |  (FPGA Base Region)   |         Framework
31062306a36Sopenharmony_ci                 +-----------------------+
31162306a36Sopenharmony_ci  ------------------------------------------------------------------
31262306a36Sopenharmony_ci               +----------------------------+
31362306a36Sopenharmony_ci               |   FPGA DFL Device Module   |
31462306a36Sopenharmony_ci               | (e.g. PCIE/Platform Device)|
31562306a36Sopenharmony_ci               +----------------------------+
31662306a36Sopenharmony_ci                 +------------------------+
31762306a36Sopenharmony_ci                 |  FPGA Hardware Device  |
31862306a36Sopenharmony_ci                 +------------------------+
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ciDFL framework in kernel provides common interfaces to create container device
32162306a36Sopenharmony_ci(FPGA base region), discover feature devices and their private features from the
32262306a36Sopenharmony_cigiven Device Feature Lists and create platform devices for feature devices
32362306a36Sopenharmony_ci(e.g. FME, Port and AFU) with related resources under the container device. It
32462306a36Sopenharmony_cialso abstracts operations for the private features and exposes common ops to
32562306a36Sopenharmony_cifeature device drivers.
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ciThe FPGA DFL Device could be different hardware, e.g. PCIe device, platform
32862306a36Sopenharmony_cidevice and etc. Its driver module is always loaded first once the device is
32962306a36Sopenharmony_cicreated by the system. This driver plays an infrastructural role in the
33062306a36Sopenharmony_cidriver architecture. It locates the DFLs in the device memory, handles them
33162306a36Sopenharmony_ciand related resources to common interfaces from DFL framework for enumeration.
33262306a36Sopenharmony_ci(Please refer to drivers/fpga/dfl.c for detailed enumeration APIs).
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ciThe FPGA Management Engine (FME) driver is a platform driver which is loaded
33562306a36Sopenharmony_ciautomatically after FME platform device creation from the DFL device module. It
33662306a36Sopenharmony_ciprovides the key features for FPGA management, including:
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci	a) Expose static FPGA region information, e.g. version and metadata.
33962306a36Sopenharmony_ci	   Users can read related information via sysfs interfaces exposed
34062306a36Sopenharmony_ci	   by FME driver.
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci	b) Partial Reconfiguration. The FME driver creates FPGA manager, FPGA
34362306a36Sopenharmony_ci	   bridges and FPGA regions during PR sub feature initialization. Once
34462306a36Sopenharmony_ci	   it receives a DFL_FPGA_FME_PORT_PR ioctl from user, it invokes the
34562306a36Sopenharmony_ci	   common interface function from FPGA Region to complete the partial
34662306a36Sopenharmony_ci	   reconfiguration of the PR bitstream to the given port.
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ciSimilar to the FME driver, the FPGA Accelerated Function Unit (AFU) driver is
34962306a36Sopenharmony_ciprobed once the AFU platform device is created. The main function of this module
35062306a36Sopenharmony_ciis to provide an interface for userspace applications to access the individual
35162306a36Sopenharmony_ciaccelerators, including basic reset control on port, AFU MMIO region export, dma
35262306a36Sopenharmony_cibuffer mapping service functions.
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ciAfter feature platform devices creation, matched platform drivers will be loaded
35562306a36Sopenharmony_ciautomatically to handle different functionalities. Please refer to next sections
35662306a36Sopenharmony_cifor detailed information on functional units which have been already implemented
35762306a36Sopenharmony_ciunder this DFL framework.
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ciPartial Reconfiguration
36162306a36Sopenharmony_ci=======================
36262306a36Sopenharmony_ciAs mentioned above, accelerators can be reconfigured through partial
36362306a36Sopenharmony_cireconfiguration of a PR bitstream file. The PR bitstream file must have been
36462306a36Sopenharmony_cigenerated for the exact static FPGA region and targeted reconfigurable region
36562306a36Sopenharmony_ci(port) of the FPGA, otherwise, the reconfiguration operation will fail and
36662306a36Sopenharmony_cipossibly cause system instability. This compatibility can be checked by
36762306a36Sopenharmony_cicomparing the compatibility ID noted in the header of PR bitstream file against
36862306a36Sopenharmony_cithe compat_id exposed by the target FPGA region. This check is usually done by
36962306a36Sopenharmony_ciuserspace before calling the reconfiguration IOCTL.
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ciFPGA virtualization - PCIe SRIOV
37362306a36Sopenharmony_ci================================
37462306a36Sopenharmony_ciThis section describes the virtualization support on DFL based FPGA device to
37562306a36Sopenharmony_cienable accessing an accelerator from applications running in a virtual machine
37662306a36Sopenharmony_ci(VM). This section only describes the PCIe based FPGA device with SRIOV support.
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ciFeatures supported by the particular FPGA device are exposed through Device
37962306a36Sopenharmony_ciFeature Lists, as illustrated below:
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci::
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_ci    +-------------------------------+  +-------------+
38462306a36Sopenharmony_ci    |              PF               |  |     VF      |
38562306a36Sopenharmony_ci    +-------------------------------+  +-------------+
38662306a36Sopenharmony_ci        ^            ^         ^              ^
38762306a36Sopenharmony_ci        |            |         |              |
38862306a36Sopenharmony_ci  +-----|------------|---------|--------------|-------+
38962306a36Sopenharmony_ci  |     |            |         |              |       |
39062306a36Sopenharmony_ci  |  +-----+     +-------+ +-------+      +-------+   |
39162306a36Sopenharmony_ci  |  | FME |     | Port0 | | Port1 |      | Port2 |   |
39262306a36Sopenharmony_ci  |  +-----+     +-------+ +-------+      +-------+   |
39362306a36Sopenharmony_ci  |                  ^         ^              ^       |
39462306a36Sopenharmony_ci  |                  |         |              |       |
39562306a36Sopenharmony_ci  |              +-------+ +------+       +-------+   |
39662306a36Sopenharmony_ci  |              |  AFU  | |  AFU |       |  AFU  |   |
39762306a36Sopenharmony_ci  |              +-------+ +------+       +-------+   |
39862306a36Sopenharmony_ci  |                                                   |
39962306a36Sopenharmony_ci  |            DFL based FPGA PCIe Device             |
40062306a36Sopenharmony_ci  +---------------------------------------------------+
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ciFME is always accessed through the physical function (PF).
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_ciPorts (and related AFUs) are accessed via PF by default, but could be exposed
40562306a36Sopenharmony_cithrough virtual function (VF) devices via PCIe SRIOV. Each VF only contains
40662306a36Sopenharmony_ci1 Port and 1 AFU for isolation. Users could assign individual VFs (accelerators)
40762306a36Sopenharmony_cicreated via PCIe SRIOV interface, to virtual machines.
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ciThe driver organization in virtualization case is illustrated below:
41062306a36Sopenharmony_ci::
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ci    +-------++------++------+             |
41362306a36Sopenharmony_ci    | FME   || FME  || FME  |             |
41462306a36Sopenharmony_ci    | FPGA  || FPGA || FPGA |             |
41562306a36Sopenharmony_ci    |Manager||Bridge||Region|             |
41662306a36Sopenharmony_ci    +-------++------++------+             |
41762306a36Sopenharmony_ci    +-----------------------+  +--------+ |             +--------+
41862306a36Sopenharmony_ci    |          FME          |  |  AFU   | |             |  AFU   |
41962306a36Sopenharmony_ci    |         Module        |  | Module | |             | Module |
42062306a36Sopenharmony_ci    +-----------------------+  +--------+ |             +--------+
42162306a36Sopenharmony_ci          +-----------------------+       |       +-----------------------+
42262306a36Sopenharmony_ci          | FPGA Container Device |       |       | FPGA Container Device |
42362306a36Sopenharmony_ci          |  (FPGA Base Region)   |       |       |  (FPGA Base Region)   |
42462306a36Sopenharmony_ci          +-----------------------+       |       +-----------------------+
42562306a36Sopenharmony_ci            +------------------+          |         +------------------+
42662306a36Sopenharmony_ci            | FPGA PCIE Module |          | Virtual | FPGA PCIE Module |
42762306a36Sopenharmony_ci            +------------------+   Host   | Machine +------------------+
42862306a36Sopenharmony_ci   -------------------------------------- | ------------------------------
42962306a36Sopenharmony_ci             +---------------+            |          +---------------+
43062306a36Sopenharmony_ci             | PCI PF Device |            |          | PCI VF Device |
43162306a36Sopenharmony_ci             +---------------+            |          +---------------+
43262306a36Sopenharmony_ci
43362306a36Sopenharmony_ciFPGA PCIe device driver is always loaded first once an FPGA PCIe PF or VF device
43462306a36Sopenharmony_ciis detected. It:
43562306a36Sopenharmony_ci
43662306a36Sopenharmony_ci* Finishes enumeration on both FPGA PCIe PF and VF device using common
43762306a36Sopenharmony_ci  interfaces from DFL framework.
43862306a36Sopenharmony_ci* Supports SRIOV.
43962306a36Sopenharmony_ci
44062306a36Sopenharmony_ciThe FME device driver plays a management role in this driver architecture, it
44162306a36Sopenharmony_ciprovides ioctls to release Port from PF and assign Port to PF. After release
44262306a36Sopenharmony_cia port from PF, then it's safe to expose this port through a VF via PCIe SRIOV
44362306a36Sopenharmony_cisysfs interface.
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ciTo enable accessing an accelerator from applications running in a VM, the
44662306a36Sopenharmony_cirespective AFU's port needs to be assigned to a VF using the following steps:
44762306a36Sopenharmony_ci
44862306a36Sopenharmony_ci#. The PF owns all AFU ports by default. Any port that needs to be
44962306a36Sopenharmony_ci   reassigned to a VF must first be released through the
45062306a36Sopenharmony_ci   DFL_FPGA_FME_PORT_RELEASE ioctl on the FME device.
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_ci#. Once N ports are released from PF, then user can use command below
45362306a36Sopenharmony_ci   to enable SRIOV and VFs. Each VF owns only one Port with AFU.
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci   ::
45662306a36Sopenharmony_ci
45762306a36Sopenharmony_ci      echo N > $PCI_DEVICE_PATH/sriov_numvfs
45862306a36Sopenharmony_ci
45962306a36Sopenharmony_ci#. Pass through the VFs to VMs
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ci#. The AFU under VF is accessible from applications in VM (using the
46262306a36Sopenharmony_ci   same driver inside the VF).
46362306a36Sopenharmony_ci
46462306a36Sopenharmony_ciNote that an FME can't be assigned to a VF, thus PR and other management
46562306a36Sopenharmony_cifunctions are only available via the PF.
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ciDevice enumeration
46862306a36Sopenharmony_ci==================
46962306a36Sopenharmony_ciThis section introduces how applications enumerate the fpga device from
47062306a36Sopenharmony_cithe sysfs hierarchy under /sys/class/fpga_region.
47162306a36Sopenharmony_ci
47262306a36Sopenharmony_ciIn the example below, two DFL based FPGA devices are installed in the host. Each
47362306a36Sopenharmony_cifpga device has one FME and two ports (AFUs).
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_ciFPGA regions are created under /sys/class/fpga_region/::
47662306a36Sopenharmony_ci
47762306a36Sopenharmony_ci	/sys/class/fpga_region/region0
47862306a36Sopenharmony_ci	/sys/class/fpga_region/region1
47962306a36Sopenharmony_ci	/sys/class/fpga_region/region2
48062306a36Sopenharmony_ci	...
48162306a36Sopenharmony_ci
48262306a36Sopenharmony_ciApplication needs to search each regionX folder, if feature device is found,
48362306a36Sopenharmony_ci(e.g. "dfl-port.n" or "dfl-fme.m" is found), then it's the base
48462306a36Sopenharmony_cifpga region which represents the FPGA device.
48562306a36Sopenharmony_ci
48662306a36Sopenharmony_ciEach base region has one FME and two ports (AFUs) as child devices::
48762306a36Sopenharmony_ci
48862306a36Sopenharmony_ci	/sys/class/fpga_region/region0/dfl-fme.0
48962306a36Sopenharmony_ci	/sys/class/fpga_region/region0/dfl-port.0
49062306a36Sopenharmony_ci	/sys/class/fpga_region/region0/dfl-port.1
49162306a36Sopenharmony_ci	...
49262306a36Sopenharmony_ci
49362306a36Sopenharmony_ci	/sys/class/fpga_region/region3/dfl-fme.1
49462306a36Sopenharmony_ci	/sys/class/fpga_region/region3/dfl-port.2
49562306a36Sopenharmony_ci	/sys/class/fpga_region/region3/dfl-port.3
49662306a36Sopenharmony_ci	...
49762306a36Sopenharmony_ci
49862306a36Sopenharmony_ciIn general, the FME/AFU sysfs interfaces are named as follows::
49962306a36Sopenharmony_ci
50062306a36Sopenharmony_ci	/sys/class/fpga_region/<regionX>/<dfl-fme.n>/
50162306a36Sopenharmony_ci	/sys/class/fpga_region/<regionX>/<dfl-port.m>/
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ciwith 'n' consecutively numbering all FMEs and 'm' consecutively numbering all
50462306a36Sopenharmony_ciports.
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ciThe device nodes used for ioctl() or mmap() can be referenced through::
50762306a36Sopenharmony_ci
50862306a36Sopenharmony_ci	/sys/class/fpga_region/<regionX>/<dfl-fme.n>/dev
50962306a36Sopenharmony_ci	/sys/class/fpga_region/<regionX>/<dfl-port.n>/dev
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ciPerformance Counters
51362306a36Sopenharmony_ci====================
51462306a36Sopenharmony_ciPerformance reporting is one private feature implemented in FME. It could
51562306a36Sopenharmony_cisupports several independent, system-wide, device counter sets in hardware to
51662306a36Sopenharmony_cimonitor and count for performance events, including "basic", "cache", "fabric",
51762306a36Sopenharmony_ci"vtd" and "vtd_sip" counters. Users could use standard perf tool to monitor
51862306a36Sopenharmony_ciFPGA cache hit/miss rate, transaction number, interface clock counter of AFU
51962306a36Sopenharmony_ciand other FPGA performance events.
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ciDifferent FPGA devices may have different counter sets, depending on hardware
52262306a36Sopenharmony_ciimplementation. E.g., some discrete FPGA cards don't have any cache. User could
52362306a36Sopenharmony_ciuse "perf list" to check which perf events are supported by target hardware.
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ciIn order to allow user to use standard perf API to access these performance
52662306a36Sopenharmony_cicounters, driver creates a perf PMU, and related sysfs interfaces in
52762306a36Sopenharmony_ci/sys/bus/event_source/devices/dfl_fme* to describe available perf events and
52862306a36Sopenharmony_ciconfiguration options.
52962306a36Sopenharmony_ci
53062306a36Sopenharmony_ciThe "format" directory describes the format of the config field of struct
53162306a36Sopenharmony_ciperf_event_attr. There are 3 bitfields for config: "evtype" defines which type
53262306a36Sopenharmony_cithe perf event belongs to; "event" is the identity of the event within its
53362306a36Sopenharmony_cicategory; "portid" is introduced to decide counters set to monitor on FPGA
53462306a36Sopenharmony_cioverall data or a specific port.
53562306a36Sopenharmony_ci
53662306a36Sopenharmony_ciThe "events" directory describes the configuration templates for all available
53762306a36Sopenharmony_cievents which can be used with perf tool directly. For example, fab_mmio_read
53862306a36Sopenharmony_cihas the configuration "event=0x06,evtype=0x02,portid=0xff", which shows this
53962306a36Sopenharmony_cievent belongs to fabric type (0x02), the local event id is 0x06 and it is for
54062306a36Sopenharmony_cioverall monitoring (portid=0xff).
54162306a36Sopenharmony_ci
54262306a36Sopenharmony_ciExample usage of perf::
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_ci  $# perf list |grep dfl_fme
54562306a36Sopenharmony_ci
54662306a36Sopenharmony_ci  dfl_fme0/fab_mmio_read/                              [Kernel PMU event]
54762306a36Sopenharmony_ci  <...>
54862306a36Sopenharmony_ci  dfl_fme0/fab_port_mmio_read,portid=?/                [Kernel PMU event]
54962306a36Sopenharmony_ci  <...>
55062306a36Sopenharmony_ci
55162306a36Sopenharmony_ci  $# perf stat -a -e dfl_fme0/fab_mmio_read/ <command>
55262306a36Sopenharmony_ci  or
55362306a36Sopenharmony_ci  $# perf stat -a -e dfl_fme0/event=0x06,evtype=0x02,portid=0xff/ <command>
55462306a36Sopenharmony_ci  or
55562306a36Sopenharmony_ci  $# perf stat -a -e dfl_fme0/config=0xff2006/ <command>
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_ciAnother example, fab_port_mmio_read monitors mmio read of a specific port. So
55862306a36Sopenharmony_ciits configuration template is "event=0x06,evtype=0x01,portid=?". The portid
55962306a36Sopenharmony_cishould be explicitly set.
56062306a36Sopenharmony_ci
56162306a36Sopenharmony_ciIts usage of perf::
56262306a36Sopenharmony_ci
56362306a36Sopenharmony_ci  $# perf stat -a -e dfl_fme0/fab_port_mmio_read,portid=0x0/ <command>
56462306a36Sopenharmony_ci  or
56562306a36Sopenharmony_ci  $# perf stat -a -e dfl_fme0/event=0x06,evtype=0x02,portid=0x0/ <command>
56662306a36Sopenharmony_ci  or
56762306a36Sopenharmony_ci  $# perf stat -a -e dfl_fme0/config=0x2006/ <command>
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_ciPlease note for fabric counters, overall perf events (fab_*) and port perf
57062306a36Sopenharmony_cievents (fab_port_*) actually share one set of counters in hardware, so it can't
57162306a36Sopenharmony_cimonitor both at the same time. If this set of counters is configured to monitor
57262306a36Sopenharmony_cioverall data, then per port perf data is not supported. See below example::
57362306a36Sopenharmony_ci
57462306a36Sopenharmony_ci  $# perf stat -e dfl_fme0/fab_mmio_read/,dfl_fme0/fab_port_mmio_write,\
57562306a36Sopenharmony_ci                                                    portid=0/ sleep 1
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci  Performance counter stats for 'system wide':
57862306a36Sopenharmony_ci
57962306a36Sopenharmony_ci                 3      dfl_fme0/fab_mmio_read/
58062306a36Sopenharmony_ci   <not supported>      dfl_fme0/fab_port_mmio_write,portid=0x0/
58162306a36Sopenharmony_ci
58262306a36Sopenharmony_ci       1.001750904 seconds time elapsed
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_ciThe driver also provides a "cpumask" sysfs attribute, which contains only one
58562306a36Sopenharmony_ciCPU id used to access these perf events. Counting on multiple CPU is not allowed
58662306a36Sopenharmony_cisince they are system-wide counters on FPGA device.
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ciThe current driver does not support sampling. So "perf record" is unsupported.
58962306a36Sopenharmony_ci
59062306a36Sopenharmony_ci
59162306a36Sopenharmony_ciInterrupt support
59262306a36Sopenharmony_ci=================
59362306a36Sopenharmony_ciSome FME and AFU private features are able to generate interrupts. As mentioned
59462306a36Sopenharmony_ciabove, users could call ioctl (DFL_FPGA_*_GET_IRQ_NUM) to know whether or how
59562306a36Sopenharmony_cimany interrupts are supported for this private feature. Drivers also implement
59662306a36Sopenharmony_cian eventfd based interrupt handling mechanism for users to get notified when
59762306a36Sopenharmony_ciinterrupt happens. Users could set eventfds to driver via
59862306a36Sopenharmony_ciioctl (DFL_FPGA_*_SET_IRQ), and then poll/select on these eventfds waiting for
59962306a36Sopenharmony_cinotification.
60062306a36Sopenharmony_ciIn Current DFL, 3 sub features (Port error, FME global error and AFU interrupt)
60162306a36Sopenharmony_cisupport interrupts.
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci
60462306a36Sopenharmony_ciAdd new FIUs support
60562306a36Sopenharmony_ci====================
60662306a36Sopenharmony_ciIt's possible that developers made some new function blocks (FIUs) under this
60762306a36Sopenharmony_ciDFL framework, then new platform device driver needs to be developed for the
60862306a36Sopenharmony_cinew feature dev (FIU) following the same way as existing feature dev drivers
60962306a36Sopenharmony_ci(e.g. FME and Port/AFU platform device driver). Besides that, it requires
61062306a36Sopenharmony_cimodification on DFL framework enumeration code too, for new FIU type detection
61162306a36Sopenharmony_ciand related platform devices creation.
61262306a36Sopenharmony_ci
61362306a36Sopenharmony_ci
61462306a36Sopenharmony_ciAdd new private features support
61562306a36Sopenharmony_ci================================
61662306a36Sopenharmony_ciIn some cases, we may need to add some new private features to existing FIUs
61762306a36Sopenharmony_ci(e.g. FME or Port). Developers don't need to touch enumeration code in DFL
61862306a36Sopenharmony_ciframework, as each private feature will be parsed automatically and related
61962306a36Sopenharmony_cimmio resources can be found under FIU platform device created by DFL framework.
62062306a36Sopenharmony_ciDeveloper only needs to provide a sub feature driver with matched feature id.
62162306a36Sopenharmony_ciFME Partial Reconfiguration Sub Feature driver (see drivers/fpga/dfl-fme-pr.c)
62262306a36Sopenharmony_cicould be a reference.
62362306a36Sopenharmony_ci
62462306a36Sopenharmony_ciPlease refer to below link to existing feature id table and guide for new feature
62562306a36Sopenharmony_ciids application.
62662306a36Sopenharmony_cihttps://github.com/OPAE/dfl-feature-id
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_ci
62962306a36Sopenharmony_ciLocation of DFLs on a PCI Device
63062306a36Sopenharmony_ci================================
63162306a36Sopenharmony_ciThe original method for finding a DFL on a PCI device assumed the start of the
63262306a36Sopenharmony_cifirst DFL to offset 0 of bar 0.  If the first node of the DFL is an FME,
63362306a36Sopenharmony_cithen further DFLs in the port(s) are specified in FME header registers.
63462306a36Sopenharmony_ciAlternatively, a PCIe vendor specific capability structure can be used to
63562306a36Sopenharmony_cispecify the location of all the DFLs on the device, providing flexibility
63662306a36Sopenharmony_cifor the type of starting node in the DFL.  Intel has reserved the
63762306a36Sopenharmony_ciVSEC ID of 0x43 for this purpose.  The vendor specific
63862306a36Sopenharmony_cidata begins with a 4 byte vendor specific register for the number of DFLs followed 4 byte
63962306a36Sopenharmony_ciOffset/BIR vendor specific registers for each DFL. Bits 2:0 of Offset/BIR register
64062306a36Sopenharmony_ciindicates the BAR, and bits 31:3 form the 8 byte aligned offset where bits 2:0 are
64162306a36Sopenharmony_cizero.
64262306a36Sopenharmony_ci::
64362306a36Sopenharmony_ci
64462306a36Sopenharmony_ci        +----------------------------+
64562306a36Sopenharmony_ci        |31     Number of DFLS      0|
64662306a36Sopenharmony_ci        +----------------------------+
64762306a36Sopenharmony_ci        |31     Offset     3|2 BIR  0|
64862306a36Sopenharmony_ci        +----------------------------+
64962306a36Sopenharmony_ci                      . . .
65062306a36Sopenharmony_ci        +----------------------------+
65162306a36Sopenharmony_ci        |31     Offset     3|2 BIR  0|
65262306a36Sopenharmony_ci        +----------------------------+
65362306a36Sopenharmony_ci
65462306a36Sopenharmony_ciBeing able to specify more than one DFL per BAR has been considered, but it
65562306a36Sopenharmony_ciwas determined the use case did not provide value.  Specifying a single DFL
65662306a36Sopenharmony_ciper BAR simplifies the implementation and allows for extra error checking.
65762306a36Sopenharmony_ci
65862306a36Sopenharmony_ci
65962306a36Sopenharmony_ciUserspace driver support for DFL devices
66062306a36Sopenharmony_ci========================================
66162306a36Sopenharmony_ciThe purpose of an FPGA is to be reprogrammed with newly developed hardware
66262306a36Sopenharmony_cicomponents. New hardware can instantiate a new private feature in the DFL, and
66362306a36Sopenharmony_cithen present a DFL device in the system. In some cases users may need a
66462306a36Sopenharmony_ciuserspace driver for the DFL device:
66562306a36Sopenharmony_ci
66662306a36Sopenharmony_ci* Users may need to run some diagnostic test for their hardware.
66762306a36Sopenharmony_ci* Users may prototype the kernel driver in user space.
66862306a36Sopenharmony_ci* Some hardware is designed for specific purposes and does not fit into one of
66962306a36Sopenharmony_ci  the standard kernel subsystems.
67062306a36Sopenharmony_ci
67162306a36Sopenharmony_ciThis requires direct access to MMIO space and interrupt handling from
67262306a36Sopenharmony_ciuserspace. The uio_dfl module exposes the UIO device interfaces for this
67362306a36Sopenharmony_cipurpose.
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_ciCurrently the uio_dfl driver only supports the Ether Group sub feature, which
67662306a36Sopenharmony_cihas no irq in hardware. So the interrupt handling is not added in this driver.
67762306a36Sopenharmony_ci
67862306a36Sopenharmony_ciUIO_DFL should be selected to enable the uio_dfl module driver. To support a
67962306a36Sopenharmony_cinew DFL feature via UIO direct access, its feature id should be added to the
68062306a36Sopenharmony_cidriver's id_table.
68162306a36Sopenharmony_ci
68262306a36Sopenharmony_ci
68362306a36Sopenharmony_ciOpen discussion
68462306a36Sopenharmony_ci===============
68562306a36Sopenharmony_ciFME driver exports one ioctl (DFL_FPGA_FME_PORT_PR) for partial reconfiguration
68662306a36Sopenharmony_cito user now. In the future, if unified user interfaces for reconfiguration are
68762306a36Sopenharmony_ciadded, FME driver should switch to them from ioctl interface.
688