xref: /dpdk/doc/guides/cryptodevs/scheduler.rst (revision 25d11a86c56d50947af33d0b79ede622809bd8b9)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright(c) 2017 Intel Corporation.
3
4Cryptodev Scheduler Poll Mode Driver Library
5============================================
6
7Scheduler PMD is a software crypto PMD, which has the capabilities of
8attaching hardware and/or software cryptodevs, and distributes ingress
9crypto ops among them in a certain manner.
10
11.. figure:: img/scheduler-overview.*
12
13   Cryptodev Scheduler Overview
14
15
16The Cryptodev Scheduler PMD library (**librte_pmd_crypto_scheduler**) acts as
17a software crypto PMD and shares the same API provided by librte_cryptodev.
18The PMD supports attaching multiple crypto PMDs, software or hardware, as
19slaves, and distributes the crypto workload to them with certain behavior.
20The behaviors are categorizes as different "modes". Basically, a scheduling
21mode defines certain actions for scheduling crypto ops to its slaves.
22
23The librte_pmd_crypto_scheduler library exports a C API which provides an API
24for attaching/detaching slaves, set/get scheduling modes, and enable/disable
25crypto ops reordering.
26
27Limitations
28-----------
29
30* Sessionless crypto operation is not supported
31* OOP crypto operation is not supported when the crypto op reordering feature
32  is enabled.
33
34
35Installation
36------------
37
38To build DPDK with CRYTPO_SCHEDULER_PMD the user is required to set
39CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER=y in config/common_base, and
40recompile DPDK
41
42
43Initialization
44--------------
45
46To use the PMD in an application, user must:
47
48* Call rte_vdev_init("crypto_scheduler") within the application.
49
50* Use --vdev="crypto_scheduler" in the EAL options, which will call
51  rte_vdev_init() internally.
52
53
54The following parameters (all optional) can be provided in the previous
55two calls:
56
57* socket_id: Specify the socket where the memory for the device is going
58  to be allocated (by default, socket_id will be the socket where the core
59  that is creating the PMD is running on).
60
61* max_nb_sessions: Specify the maximum number of sessions that can be
62  created. This value may be overwritten internally if there are too
63  many devices are attached.
64
65* slave: If a cryptodev has been initialized with specific name, it can be
66  attached to the scheduler using this parameter, simply filling the name
67  here. Multiple cryptodevs can be attached initially by presenting this
68  parameter multiple times.
69
70* mode: Specify the scheduling mode of the PMD. The supported scheduling
71  mode parameter values are specified in the "Cryptodev Scheduler Modes
72  Overview" section.
73
74* mode_param: Specify the mode-specific parameter. Some scheduling modes
75  may be initialized with specific parameters other than the default ones,
76  such as the **threshold** packet size of **packet-size-distr** mode. This
77  parameter fulfills the purpose.
78
79* ordering: Specify the status of the crypto operations ordering feature.
80  The value of this parameter can be "enable" or "disable". This feature
81  is disabled by default.
82
83Example:
84
85.. code-block:: console
86
87    ... --vdev "crypto_aesni_mb0,name=aesni_mb_1" --vdev "crypto_aesni_mb1,name=aesni_mb_2" --vdev "crypto_scheduler,slave=aesni_mb_1,slave=aesni_mb_2" ...
88
89.. note::
90
91    * The scheduler cryptodev cannot be started unless the scheduling mode
92      is set and at least one slave is attached. Also, to configure the
93      scheduler in the run-time, like attach/detach slave(s), change
94      scheduling mode, or enable/disable crypto op ordering, one should stop
95      the scheduler first, otherwise an error will be returned.
96
97    * The crypto op reordering feature requires using the userdata field of
98      every mbuf to be processed to store temporary data. By the end of
99      processing, the field is set to pointing to NULL, any previously
100      stored value of this field will be lost.
101
102
103Cryptodev Scheduler Modes Overview
104----------------------------------
105
106Currently the Crypto Scheduler PMD library supports following modes of
107operation:
108
109*   **CDEV_SCHED_MODE_ROUNDROBIN:**
110
111   *Initialization mode parameter*: **round-robin**
112
113   Round-robin mode, which distributes the enqueued burst of crypto ops
114   among its slaves in a round-robin manner. This mode may help to fill
115   the throughput gap between the physical core and the existing cryptodevs
116   to increase the overall performance.
117
118*   **CDEV_SCHED_MODE_PKT_SIZE_DISTR:**
119
120   *Initialization mode parameter*: **packet-size-distr**
121
122   Packet-size based distribution mode, which works with 2 slaves, the primary
123   slave and the secondary slave, and distributes the enqueued crypto
124   operations to them based on their data lengths. A crypto operation will be
125   distributed to the primary slave if its data length is equal to or bigger
126   than the designated threshold, otherwise it will be handled by the secondary
127   slave.
128
129   A typical usecase in this mode is with the QAT cryptodev as the primary and
130   a software cryptodev as the secondary slave. This may help applications to
131   process additional crypto workload than what the QAT cryptodev can handle on
132   its own, by making use of the available CPU cycles to deal with smaller
133   crypto workloads.
134
135   The threshold is set to 128 bytes by default. It can be updated by calling
136   function **rte_cryptodev_scheduler_option_set**. The parameter of
137   **option_type** must be **CDEV_SCHED_OPTION_THRESHOLD** and **option** should
138   point to a rte_cryptodev_scheduler_threshold_option structure filled with
139   appropriate threshold value. Please NOTE this threshold has be a power-of-2
140   unsigned integer. It is possible to use **mode_param** initialization
141   parameter to achieve the same purpose. For example:
142
143   ... --vdev "crypto_scheduler,mode=packet-size-distr,mode_param=threshold:512" ...
144
145   The above parameter will overwrite the threshold value to 512.
146
147*   **CDEV_SCHED_MODE_FAILOVER:**
148
149   *Initialization mode parameter*: **fail-over**
150
151   Fail-over mode, which works with 2 slaves, the primary slave and the
152   secondary slave. In this mode, the scheduler will enqueue the incoming
153   crypto operation burst to the primary slave. When one or more crypto
154   operations fail to be enqueued, then they will be enqueued to the secondary
155   slave.
156
157*   **CDEV_SCHED_MODE_MULTICORE:**
158
159   *Initialization mode parameter*: **multi-core**
160
161   Multi-core mode, which distributes the workload with several (up to eight)
162   worker cores. The enqueued bursts are distributed among the worker cores in a
163   round-robin manner. If scheduler cannot enqueue entire burst to the same worker,
164   it will enqueue the remaining operations to the next available worker.
165   For pure small packet size (64 bytes) traffic however the multi-core mode is not
166   an optimal solution, as it doesn't give significant per-core performance improvement.
167   For mixed traffic (IMIX) the optimal number of worker cores is around 2-3.
168   For large packets (1.5 Kbytes) scheduler shows linear scaling in performance
169   up to eight cores.
170   Each worker uses its own slave cryptodev. Only software cryptodevs
171   are supported. Only the same type of cryptodevs should be used concurrently.
172
173   The multi-core mode uses one extra parameter:
174
175   * corelist: Semicolon-separated list of logical cores to be used as workers.
176     The number of worker cores should be equal to the number of slave cryptodevs.
177     These cores should be present in EAL core list parameter and
178     should not be used by the application or any other process.
179
180   Example:
181    ... --vdev "crypto_aesni_mb1,name=aesni_mb_1" --vdev "crypto_aesni_mb_pmd2,name=aesni_mb_2" \
182    --vdev "crypto_scheduler,slave=aesni_mb_1,slave=aesni_mb_2,mode=multi-core,corelist=23;24" ...
183