1# Acceleration Framework {#accel_fw} 2 3SPDK provides a framework for abstracting general acceleration capabilities 4that can be implemented through plug-in modules and low-level libraries. These 5plug-in modules include support for hardware acceleration engines such as 6the Intel(R) I/O Acceleration Technology (IOAT) engine and the Intel(R) Data 7Streaming Accelerator (DSA) engine. Additionally, a software plug-in module 8exists to enable use of the framework in environments without hardware 9acceleration capabilities. ISA/L is used for optimized CRC32C calculation within 10the software module. 11 12## Acceleration Framework Functions {#accel_functions} 13 14Functions implemented via the framework can be found in the DoxyGen documentation of the 15framework public header file here [accel_engine.h](https://spdk.io/doc/accel__engine_8h.html) 16 17## Acceleration Framework Design Considerations {#accel_dc} 18 19The general interface is defined by `/include/accel_engine.h` and implemented 20in `/lib/accel`. These functions may be called by an SPDK application and in 21most cases, except where otherwise documented, are asynchronous and follow the 22standard SPDK model for callbacks with a callback argument. 23 24If the acceleration framework is started without initializing a hardware module, 25optimized software implementations of the operations will back the public API. All 26operations supported by the framework have a backing software implementation in 27the event that no hardware accelerators have been enabled for that operation. 28 29When multiple hardware engines are enabled the framework will assign each operation to 30an engine based on the order in which it was initialized. So, for example if two modules are 31enabled, IOAT and software, the software engine will be used for every operation except those 32supported by IOAT. 33 34## Acceleration Low Level Libraries {#accel_libs} 35 36Low level libraries provide only the most basic functions that are specific to 37the hardware. Low level libraries are located in the '/lib' directory with the 38exception of the software implementation which is implemented as part of the 39framework itself. The software low level library does not expose a public API. 40Applications may choose to interact directly with a low level library if there are 41specific needs/considerations not met via accessing the library through the 42framework/module. Note that when using the low level libraries directly, the 43framework abstracted interface is bypassed as the application will call the public 44functions exposed by the individual low level libraries. Thus, code written this 45way needs to be certain that the underlying hardware exists everywhere that it runs. 46 47The low level library for IOAT is located in `/lib/ioat`. The low level library 48for DSA and IAA is in `/lib/idxd` (IDXD stands for Intel(R) Data Acceleration Driver and 49supports both DSA and IAA hardware accelerators). In `/lib/idxd` folder, SPDK supports the ability 50to use either user space and kernel space drivers. The following describes each usage scenario: 51 52Leveraging user space idxd driver: The DSA devices are managed by the SPDK user space 53driver in a dedicated SPDK process, then the device cannot be shared by another 54process. The benefit of this usage is no kernel dependency. 55 56Leveraging kernel space driver: The DSA devices are managed by kernel 57space drivers. And the Work queues inside the DSA device can be shared among 58different processes. Naturally, it can be used in cloud native scenario. The drawback of 59this usage is the kernel dependency, i.e., idxd kernel driver must be supported and loaded 60in the kernel. 61 62## Acceleration Plug-In Modules {#accel_modules} 63 64Plug-in modules depend on low level libraries to interact with the hardware and 65add additional functionality such as queueing during busy conditions or flow 66control in some cases. The framework in turn depends on the modules to provide 67the complete implementation of the acceleration component. A module must be 68selected via startup RPC when the application is started. Otherwise, if no startup 69RPC is provided, the framework is available and will use the software plug-in module. 70 71### IOAT Module {#accel_ioat} 72 73To use the IOAT engine, use the RPC [`ioat_scan_accel_engine`](https://spdk.io/doc/jsonrpc.html) before starting the application. 74 75### IDXD Module {#accel_idxd} 76 77To use the DSA engine, use the RPC 78[`idxd_scan_accel_engine`](https://spdk.io/doc/jsonrpc.html). By default, this 79will attempt to load the SPDK user-space idxd driver. To use the built-in 80kernel driver on Linux, add the `-k` parameter. See the next section for 81details on using the kernel driver. 82 83The DSA hardware supports a limited queue depth and channels. This means that 84only a limited number of `spdk_thread`s will be able to acquire a channel. 85Design software to deal with the inability to get a channel. 86 87### How to use kernel idxd driver {#accel_idxd_kernel} 88 89There are several dependencies to leverage the Linux idxd driver for driving DSA devices. 90 911 Linux kernel support: You need to have a Linux kernel with the `idxd` driver 92loaded. Futher, add the following command line options to the kernel boot 93commands: 94 95```bash 96intel_iommu=on,sm_on 97``` 98 992 User library dependency: Users need to install the `accel-config` library. 100This is often packaged, but the source is available on 101[GitHub](https://github.com/intel/idxd-config). After the library is installed, 102users can use the `accel-config` command to configure the work queues(WQs) of 103the idxd devices managed by the kernel with the following steps: 104 105Note: this library must be installed before you run `configure` 106 107```bash 108accel-config disable-wq dsa0/wq0.1 109accel-config disable-device dsa0 110accel-config config-wq --group-id=0 --mode=dedicated --wq-size=128 --type=user --name="MyApp1" 111 --priority=10 --block-on-fault=1 dsa0/wq0.1 112accel-config config-engine dsa0/engine0.0 --group-id=0 113accel-config config-engine dsa0/engine0.1 --group-id=0 114accel-config config-engine dsa0/engine0.2 --group-id=0 115accel-config config-engine dsa0/engine0.3 --group-id=0 116accel-config enable-device dsa0 117accel-config enable-wq dsa0/wq0.1 118``` 119 120DSA can be configured in many ways, but the above configuration is needed for use with SPDK. 121 122### Software Module {#accel_sw} 123 124The software module is enabled by default. If no hardware engine is explicitly 125enabled via startup RPC as discussed earlier, the software module will use ISA-L 126if available for functions such as CRC32C. Otherwise, standard glibc calls are 127used to back the framework API. 128