1866e46bcSConor Walsh.. SPDX-License-Identifier: BSD-3-Clause 2866e46bcSConor Walsh Copyright(c) 2021 Intel Corporation. 3866e46bcSConor Walsh 4866e46bcSConor Walsh.. include:: <isonum.txt> 5866e46bcSConor Walsh 6866e46bcSConor WalshIOAT DMA Device Driver 7866e46bcSConor Walsh======================= 8866e46bcSConor Walsh 9866e46bcSConor WalshThe ``ioat`` dmadev driver provides a poll-mode driver (PMD) for Intel\ 10866e46bcSConor Walsh|reg| QuickData Technology which is part of part of Intel\ |reg| I/O 11866e46bcSConor WalshAcceleration Technology (`Intel I/OAT 12866e46bcSConor Walsh<https://www.intel.com/content/www/us/en/wireless-network/accel-technology.html>`_). 13866e46bcSConor WalshThis PMD, when used on supported hardware, allows data copies, for example, 14866e46bcSConor Walshcloning packet data, to be accelerated by IOAT hardware rather than having to 15866e46bcSConor Walshbe done by software, freeing up CPU cycles for other tasks. 16866e46bcSConor Walsh 17866e46bcSConor WalshHardware Requirements 18866e46bcSConor Walsh---------------------- 19866e46bcSConor Walsh 20866e46bcSConor WalshThe ``dpdk-devbind.py`` script, included with DPDK, can be used to show the 21866e46bcSConor Walshpresence of supported hardware. Running ``dpdk-devbind.py --status-dev dma`` 22866e46bcSConor Walshwill show all the DMA devices on the system, IOAT devices are included in this 23866e46bcSConor Walshlist. For Intel\ |reg| IOAT devices, the hardware will often be listed as 24866e46bcSConor Walsh"Crystal Beach DMA", or "CBDMA" or on some newer systems '0b00' due to the 25866e46bcSConor Walshabsence of pci-id database entries for them at this point. 26866e46bcSConor Walsh 27866e46bcSConor Walsh.. note:: 28866e46bcSConor Walsh Error handling is not supported by this driver on hardware prior to 29866e46bcSConor Walsh Intel Ice Lake. Unsupported systems include Broadwell, Skylake and 30866e46bcSConor Walsh Cascade Lake. 31866e46bcSConor Walsh 32866e46bcSConor WalshCompilation 33866e46bcSConor Walsh------------ 34866e46bcSConor Walsh 35866e46bcSConor WalshFor builds using ``meson`` and ``ninja``, the driver will be built when the 36866e46bcSConor Walshtarget platform is x86-based. No additional compilation steps are necessary. 37866e46bcSConor Walsh 38866e46bcSConor WalshDevice Setup 39866e46bcSConor Walsh------------- 40866e46bcSConor Walsh 41866e46bcSConor WalshIntel\ |reg| IOAT devices will need to be bound to a suitable DPDK-supported 42866e46bcSConor Walshuser-space IO driver such as ``vfio-pci`` in order to be used by DPDK. 43866e46bcSConor Walsh 44866e46bcSConor WalshThe ``dpdk-devbind.py`` script can be used to view the state of the devices using:: 45866e46bcSConor Walsh 46866e46bcSConor Walsh $ dpdk-devbind.py --status-dev dma 47866e46bcSConor Walsh 48866e46bcSConor WalshThe ``dpdk-devbind.py`` script can also be used to bind devices to a suitable driver. 49866e46bcSConor WalshFor example:: 50866e46bcSConor Walsh 51866e46bcSConor Walsh $ dpdk-devbind.py -b vfio-pci 00:01.0 00:01.1 52866e46bcSConor Walsh 53866e46bcSConor WalshDevice Probing and Initialization 54866e46bcSConor Walsh~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55866e46bcSConor Walsh 56866e46bcSConor WalshFor devices bound to a suitable DPDK-supported driver (``vfio-pci``), the HW 57866e46bcSConor Walshdevices will be found as part of the device scan done at application 58866e46bcSConor Walshinitialization time without the need to pass parameters to the application. 59866e46bcSConor Walsh 60866e46bcSConor WalshIf the application does not require all the devices available an allowlist can 61866e46bcSConor Walshbe used in the same way that other DPDK devices use them. 62866e46bcSConor Walsh 63866e46bcSConor WalshFor example:: 64866e46bcSConor Walsh 65866e46bcSConor Walsh $ dpdk-test -a <b:d:f> 66866e46bcSConor Walsh 67866e46bcSConor WalshOnce probed successfully, the device will appear as a ``dmadev``, that is a 68866e46bcSConor Walsh"DMA device type" inside DPDK, and can be accessed using APIs from the 69866e46bcSConor Walsh``rte_dmadev`` library. 70a19a2dceSConor Walsh 71a19a2dceSConor WalshUsing IOAT DMAdev Devices 72a19a2dceSConor Walsh-------------------------- 73a19a2dceSConor Walsh 74a19a2dceSConor WalshTo use IOAT devices from an application, the ``dmadev`` API can be used. 75a19a2dceSConor Walsh 76a19a2dceSConor WalshDevice Configuration 77a19a2dceSConor Walsh~~~~~~~~~~~~~~~~~~~~~ 78a19a2dceSConor Walsh 79a19a2dceSConor WalshIOAT configuration requirements: 80a19a2dceSConor Walsh 81a19a2dceSConor Walsh* ``ring_size`` must be a power of two, between 64 and 4096. 82a19a2dceSConor Walsh* Only one ``vchan`` is supported per device. 83a19a2dceSConor Walsh* Silent mode is not supported. 84a19a2dceSConor Walsh* The transfer direction must be set to ``RTE_DMA_DIR_MEM_TO_MEM`` to copy from memory to memory. 85583f046dSConor Walsh 86583f046dSConor WalshOnce configured, the device can then be made ready for use by calling the 87583f046dSConor Walsh``rte_dma_start()`` API. 883d4b0273SConor Walsh 893d4b0273SConor WalshPerforming Data Copies 903d4b0273SConor Walsh~~~~~~~~~~~~~~~~~~~~~~~ 913d4b0273SConor Walsh 923d4b0273SConor WalshRefer to the :ref:`Enqueue / Dequeue APIs <dmadev_enqueue_dequeue>` section of the dmadev library 93*9f46de12SConor Walshdocumentation for details on operation enqueue, submission and completion API usage. 943d4b0273SConor Walsh 953d4b0273SConor WalshIt is expected that, for efficiency reasons, a burst of operations will be enqueued to the 963d4b0273SConor Walshdevice via multiple enqueue calls between calls to the ``rte_dma_submit()`` function. 97*9f46de12SConor Walsh 98*9f46de12SConor WalshWhen gathering completions, ``rte_dma_completed()`` should be used, up until the point an error 99*9f46de12SConor Walshoccurs with an operation. If an error was encountered, ``rte_dma_completed_status()`` must be used 100*9f46de12SConor Walshto reset the device and continue processing operations. This function will also gather the status 101*9f46de12SConor Walshof each individual operation which is filled in to the ``status`` array provided as parameter 102*9f46de12SConor Walshby the application. 103*9f46de12SConor Walsh 104*9f46de12SConor WalshThe status codes supported by IOAT are: 105*9f46de12SConor Walsh 106*9f46de12SConor Walsh* ``RTE_DMA_STATUS_SUCCESSFUL``: The operation was successful. 107*9f46de12SConor Walsh* ``RTE_DMA_STATUS_INVALID_SRC_ADDR``: The operation failed due to an invalid source address. 108*9f46de12SConor Walsh* ``RTE_DMA_STATUS_INVALID_DST_ADDR``: The operation failed due to an invalid destination address. 109*9f46de12SConor Walsh* ``RTE_DMA_STATUS_INVALID_LENGTH``: The operation failed due to an invalid descriptor length. 110*9f46de12SConor Walsh* ``RTE_DMA_STATUS_DESCRIPTOR_READ_ERROR``: The device could not read the descriptor. 111*9f46de12SConor Walsh* ``RTE_DMA_STATUS_ERROR_UNKNOWN``: The operation failed due to an unspecified error. 112*9f46de12SConor Walsh 113*9f46de12SConor WalshThe following code shows how to retrieve the number of successfully completed 114*9f46de12SConor Walshcopies within a burst and then uses ``rte_dma_completed_status()`` to check 115*9f46de12SConor Walshwhich operation failed and reset the device to continue processing operations: 116*9f46de12SConor Walsh 117*9f46de12SConor Walsh.. code-block:: C 118*9f46de12SConor Walsh 119*9f46de12SConor Walsh enum rte_dma_status_code status[COMP_BURST_SZ]; 120*9f46de12SConor Walsh uint16_t count, idx, status_count; 121*9f46de12SConor Walsh bool error = 0; 122*9f46de12SConor Walsh 123*9f46de12SConor Walsh count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); 124*9f46de12SConor Walsh 125*9f46de12SConor Walsh if (error){ 126*9f46de12SConor Walsh status_count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, &idx, status); 127*9f46de12SConor Walsh } 128