ce33e2857a3ce6328070e691f9eadf01df19fc93
[dpdk.git] / doc / guides / dmadevs / idxd.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(c) 2021 Intel Corporation.
3
4 .. include:: <isonum.txt>
5
6 IDXD DMA Device Driver
7 ======================
8
9 The ``idxd`` dmadev driver provides a poll-mode driver (PMD) for Intel\ |reg|
10 Data Streaming Accelerator `(Intel DSA)
11 <https://software.intel.com/content/www/us/en/develop/articles/intel-data-streaming-accelerator-architecture-specification.html>`_.
12 This PMD can be used in conjunction with Intel\ |reg| DSA devices to offload
13 data operations, such as data copies, to hardware, freeing up CPU cycles for
14 other tasks.
15
16 Hardware Requirements
17 ----------------------
18
19 The ``dpdk-devbind.py`` script, included with DPDK, can be used to show the
20 presence of supported hardware. Running ``dpdk-devbind.py --status-dev dma``
21 will show all the DMA devices on the system, including IDXD supported devices.
22 Intel\ |reg| DSA devices, are currently (at time of writing) appearing
23 as devices with type “0b25”, due to the absence of pci-id database entries for
24 them at this point.
25
26 Compilation
27 ------------
28
29 For builds using ``meson`` and ``ninja``, the driver will be built when the
30 target platform is x86-based. No additional compilation steps are necessary.
31
32 Device Setup
33 -------------
34
35 Intel\ |reg| DSA devices can use the IDXD kernel driver or DPDK-supported drivers,
36 such as ``vfio-pci``. Both are supported by the IDXD PMD.
37
38 Intel\ |reg| DSA devices using IDXD kernel driver
39 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40
41 To use an Intel\ |reg| DSA device bound to the IDXD kernel driver, the device must first be configured.
42 The `accel-config <https://github.com/intel/idxd-config>`_ utility library can be used for configuration.
43
44 .. note::
45         The device configuration can also be done by directly interacting with the sysfs nodes.
46         An example of how this may be done can be seen in the script ``dpdk_idxd_cfg.py``
47         included in the driver source directory.
48
49 There are some mandatory configuration steps before being able to use a device with an application.
50 The internal engines, which do the copies or other operations,
51 and the work-queues, which are used by applications to assign work to the device,
52 need to be assigned to groups, and the various other configuration options,
53 such as priority or queue depth, need to be set for each queue.
54
55 To assign an engine to a group::
56
57         $ accel-config config-engine dsa0/engine0.0 --group-id=0
58         $ accel-config config-engine dsa0/engine0.1 --group-id=1
59
60 To assign work queues to groups for passing descriptors to the engines a similar accel-config command can be used.
61 However, the work queues also need to be configured depending on the use case.
62 Some configuration options include:
63
64 * mode (Dedicated/Shared): Indicates whether a WQ may accept jobs from multiple queues simultaneously.
65 * priority: WQ priority between 1 and 15. Larger value means higher priority.
66 * wq-size: the size of the WQ. Sum of all WQ sizes must be less that the total-size defined by the device.
67 * type: WQ type (kernel/mdev/user). Determines how the device is presented.
68 * name: identifier given to the WQ.
69
70 Example configuration for a work queue::
71
72         $ accel-config config-wq dsa0/wq0.0 --group-id=0 \
73            --mode=dedicated --priority=10 --wq-size=8 \
74            --type=user --name=dpdk_app1
75
76 Once the devices have been configured, they need to be enabled::
77
78         $ accel-config enable-device dsa0
79         $ accel-config enable-wq dsa0/wq0.0
80
81 Check the device configuration::
82
83         $ accel-config list
84
85 Devices using VFIO/UIO drivers
86 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87
88 The HW devices to be used will need to be bound to a user-space IO driver for use.
89 The ``dpdk-devbind.py`` script can be used to view the state of the devices
90 and to bind them to a suitable DPDK-supported driver, such as ``vfio-pci``.
91 For example::
92
93         $ dpdk-devbind.py -b vfio-pci 6a:01.0
94
95 Device Probing and Initialization
96 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
98 For devices bound to a suitable DPDK-supported VFIO/UIO driver, the HW devices will
99 be found as part of the device scan done at application initialization time without
100 the need to pass parameters to the application.
101
102 For Intel\ |reg| DSA devices, DPDK will automatically configure the device with the
103 maximum number of workqueues available on it, partitioning all resources equally
104 among the queues.
105 If fewer workqueues are required, then the ``max_queues`` parameter may be passed to
106 the device driver on the EAL commandline, via the ``allowlist`` or ``-a`` flag e.g.::
107
108         $ dpdk-test -a <b:d:f>,max_queues=4
109
110 For devices bound to the IDXD kernel driver,
111 the DPDK IDXD driver will automatically perform a scan for available workqueues
112 to use. Any workqueues found listed in ``/dev/dsa`` on the system will be checked
113 in ``/sys``, and any which have ``dpdk_`` prefix in their name will be automatically
114 probed by the driver to make them available to the application.
115 Alternatively, to support use by multiple DPDK processes simultaneously,
116 the value used as the DPDK ``--file-prefix`` parameter may be used as a workqueue
117 name prefix, instead of ``dpdk_``, allowing each DPDK application instance to only
118 use a subset of configured queues.
119
120 Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``,
121 that is a "DMA device type" inside DPDK, and can be accessed using APIs from the
122 ``rte_dmadev`` library.