|
| 1 | +Intel QuickAssist crypto driver |
| 2 | +=============================== |
| 3 | + |
| 4 | +Overview |
| 5 | +-------- |
| 6 | + |
| 7 | +This driver provides native symmetric crypto support for Intel QuickAssist |
| 8 | +(QAT) virtual functions. The physical function (PF) stays with the kernel |
| 9 | +driver (e.g. ``qat_4xxx``), which loads the firmware and assigns a service to |
| 10 | +each ring pair. The driver uses the VF ring pairs assigned to symmetric |
| 11 | +crypto, one crypto queue each. |
| 12 | + |
| 13 | +Device setup |
| 14 | +------------ |
| 15 | + |
| 16 | +Bind the VFs to ``vfio-pci`` and attach them to VPP, either with |
| 17 | +``device attach pci/<vf address> driver qat`` or in the startup config: |
| 18 | + |
| 19 | +:: |
| 20 | + |
| 21 | + devices { |
| 22 | + dev pci/<vf address> { driver qat } |
| 23 | + } |
| 24 | + |
| 25 | +Thread to queue assignment |
| 26 | +-------------------------- |
| 27 | + |
| 28 | +All VFs of the same QAT generation serve one crypto engine (e.g. |
| 29 | +``qat-gen4-sym``), and the queues of all of them are assigned to the VPP |
| 30 | +threads together. A device uses its first ``num-crypto-queues`` queues, by |
| 31 | +default as many as there are threads, up to the number of its symmetric |
| 32 | +crypto ring pairs. |
| 33 | + |
| 34 | +Requests are completed by the thread which submitted them, so each queue |
| 35 | +serves exactly one thread. A thread may have several queues, also of |
| 36 | +different VFs; it submits each frame to its queue with the fewest requests in |
| 37 | +flight. A queue configured with a thread serves that thread, the other queues |
| 38 | +are spread round robin over all threads. A thread without a queue drops its |
| 39 | +requests and counts them as ``no-queue`` errors of the engine enqueue nodes. |
| 40 | + |
| 41 | +The throughput limit is per PF, so a thread which should use more than one PF |
| 42 | +needs queues of VFs of different PFs. For example, with two VFs of different |
| 43 | +PFs and four threads: |
| 44 | + |
| 45 | +:: |
| 46 | + |
| 47 | + devices { |
| 48 | + dev pci/<vf of pf 0> { |
| 49 | + driver qat |
| 50 | + crypto-queue 0 { threads 0 } |
| 51 | + crypto-queue 1 { threads 1 } |
| 52 | + } |
| 53 | + dev pci/<vf of pf 1> { |
| 54 | + driver qat |
| 55 | + crypto-queue 0 { threads 2 } |
| 56 | + crypto-queue 1 { threads 3 } |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | +Without the ``crypto-queue`` settings the same queues are spread over the |
| 61 | +threads automatically. ``show device`` shows the threads of each queue. |
| 62 | + |
| 63 | +PF service configuration |
| 64 | +------------------------ |
| 65 | + |
| 66 | +The services of a PF are set by the kernel driver through |
| 67 | +``/sys/bus/pci/devices/<pf address>/qat/cfg_services``. With the common |
| 68 | +default ``sym;asym``, the symmetric crypto throughput of the PF is about half |
| 69 | +of what the same PF reaches when configured for ``sym`` only. If the system |
| 70 | +doesn't need asymmetric crypto offload, configure the PF for ``sym``. |
| 71 | + |
| 72 | +The throughput limit is per PF. Using more VFs of the same PF, or more ring |
| 73 | +pairs of a VF, doesn't increase it; to scale, use VFs of several PFs. |
| 74 | + |
| 75 | +The services can only be changed while the PF is down and has no VFs. The VFs |
| 76 | +are recreated and need to be bound to ``vfio-pci`` again afterwards: |
| 77 | + |
| 78 | +:: |
| 79 | + |
| 80 | + $ PF=/sys/bus/pci/devices/<pf address> |
| 81 | + $ echo 0 | sudo tee $PF/sriov_numvfs |
| 82 | + $ echo down | sudo tee $PF/qat/state |
| 83 | + $ echo sym | sudo tee $PF/qat/cfg_services |
| 84 | + $ echo up | sudo tee $PF/qat/state |
| 85 | + $ echo <number of vfs> | sudo tee $PF/sriov_numvfs |
| 86 | + |
| 87 | +The setting doesn't survive a reboot; make it persistent in the configuration |
| 88 | +of whatever sets up the QAT devices at boot. |
0 commit comments