xref: /dpdk/doc/guides/cryptodevs/scheduler.rst (revision 4e30ead5e7ca886535e2b30632b2948d2aac1681)
1d58a3f31SFan Zhang..  BSD LICENSE
2d58a3f31SFan Zhang    Copyright(c) 2017 Intel Corporation. All rights reserved.
3d58a3f31SFan Zhang    All rights reserved.
4d58a3f31SFan Zhang
5d58a3f31SFan Zhang    Redistribution and use in source and binary forms, with or without
6d58a3f31SFan Zhang    modification, are permitted provided that the following conditions
7d58a3f31SFan Zhang    are met:
8d58a3f31SFan Zhang
9d58a3f31SFan Zhang    * Redistributions of source code must retain the above copyright
10d58a3f31SFan Zhang    notice, this list of conditions and the following disclaimer.
11d58a3f31SFan Zhang    * Redistributions in binary form must reproduce the above copyright
12d58a3f31SFan Zhang    notice, this list of conditions and the following disclaimer in
13d58a3f31SFan Zhang    the documentation and/or other materials provided with the
14d58a3f31SFan Zhang    distribution.
15d58a3f31SFan Zhang    * Neither the name of Intel Corporation nor the names of its
16d58a3f31SFan Zhang    contributors may be used to endorse or promote products derived
17d58a3f31SFan Zhang    from this software without specific prior written permission.
18d58a3f31SFan Zhang
19d58a3f31SFan Zhang    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20d58a3f31SFan Zhang    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21d58a3f31SFan Zhang    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22d58a3f31SFan Zhang    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23d58a3f31SFan Zhang    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24d58a3f31SFan Zhang    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25d58a3f31SFan Zhang    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26d58a3f31SFan Zhang    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27d58a3f31SFan Zhang    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28d58a3f31SFan Zhang    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29d58a3f31SFan Zhang    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30d58a3f31SFan Zhang
31d58a3f31SFan ZhangCryptodev Scheduler Poll Mode Driver Library
32d58a3f31SFan Zhang============================================
33d58a3f31SFan Zhang
34d58a3f31SFan ZhangScheduler PMD is a software crypto PMD, which has the capabilities of
35d58a3f31SFan Zhangattaching hardware and/or software cryptodevs, and distributes ingress
36d58a3f31SFan Zhangcrypto ops among them in a certain manner.
37d58a3f31SFan Zhang
38d58a3f31SFan Zhang.. figure:: img/scheduler-overview.*
39d58a3f31SFan Zhang
40d58a3f31SFan Zhang   Cryptodev Scheduler Overview
41d58a3f31SFan Zhang
42d58a3f31SFan Zhang
43d58a3f31SFan ZhangThe Cryptodev Scheduler PMD library (**librte_pmd_crypto_scheduler**) acts as
44d58a3f31SFan Zhanga software crypto PMD and shares the same API provided by librte_cryptodev.
45d58a3f31SFan ZhangThe PMD supports attaching multiple crypto PMDs, software or hardware, as
46d58a3f31SFan Zhangslaves, and distributes the crypto workload to them with certain behavior.
47d58a3f31SFan ZhangThe behaviors are categorizes as different "modes". Basically, a scheduling
48d58a3f31SFan Zhangmode defines certain actions for scheduling crypto ops to its slaves.
49d58a3f31SFan Zhang
50d58a3f31SFan ZhangThe librte_pmd_crypto_scheduler library exports a C API which provides an API
51d58a3f31SFan Zhangfor attaching/detaching slaves, set/get scheduling modes, and enable/disable
52d58a3f31SFan Zhangcrypto ops reordering.
53d58a3f31SFan Zhang
54d58a3f31SFan ZhangLimitations
55d58a3f31SFan Zhang-----------
56d58a3f31SFan Zhang
57d58a3f31SFan Zhang* Sessionless crypto operation is not supported
58d58a3f31SFan Zhang* OOP crypto operation is not supported when the crypto op reordering feature
59d58a3f31SFan Zhang  is enabled.
60d58a3f31SFan Zhang
61d58a3f31SFan Zhang
62d58a3f31SFan ZhangInstallation
63d58a3f31SFan Zhang------------
64d58a3f31SFan Zhang
65d58a3f31SFan ZhangTo build DPDK with CRYTPO_SCHEDULER_PMD the user is required to set
66d58a3f31SFan ZhangCONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER=y in config/common_base, and
67d58a3f31SFan Zhangrecompile DPDK
68d58a3f31SFan Zhang
69d58a3f31SFan Zhang
70d58a3f31SFan ZhangInitialization
71d58a3f31SFan Zhang--------------
72d58a3f31SFan Zhang
73d58a3f31SFan ZhangTo use the PMD in an application, user must:
74d58a3f31SFan Zhang
75d58a3f31SFan Zhang* Call rte_eal_vdev_init("crpyto_scheduler") within the application.
76d58a3f31SFan Zhang
77d58a3f31SFan Zhang* Use --vdev="crpyto_scheduler" in the EAL options, which will call
78d58a3f31SFan Zhang  rte_eal_vdev_init() internally.
79d58a3f31SFan Zhang
80d58a3f31SFan Zhang
81d58a3f31SFan ZhangThe following parameters (all optional) can be provided in the previous
82d58a3f31SFan Zhangtwo calls:
83d58a3f31SFan Zhang
84d58a3f31SFan Zhang* socket_id: Specify the socket where the memory for the device is going
85d58a3f31SFan Zhang  to be allocated (by default, socket_id will be the socket where the core
86d58a3f31SFan Zhang  that is creating the PMD is running on).
87d58a3f31SFan Zhang
88d58a3f31SFan Zhang* max_nb_sessions: Specify the maximum number of sessions that can be
89d58a3f31SFan Zhang  created. This value may be overwritten internally if there are too
90d58a3f31SFan Zhang  many devices are attached.
91d58a3f31SFan Zhang
92d58a3f31SFan Zhang* slave: If a cryptodev has been initialized with specific name, it can be
93d58a3f31SFan Zhang  attached to the scheduler using this parameter, simply filling the name
94d58a3f31SFan Zhang  here. Multiple cryptodevs can be attached initially by presenting this
95d58a3f31SFan Zhang  parameter multiple times.
96d58a3f31SFan Zhang
97a0e805eeSFan Zhang* mode: Specify the scheduling mode of the PMD. The supported scheduling
98a0e805eeSFan Zhang  mode parameter values are specified in the "Cryptodev Scheduler Modes
99a0e805eeSFan Zhang  Overview" section.
100a0e805eeSFan Zhang
101a0e805eeSFan Zhang* ordering: Specify the status of the crypto operations ordering feature.
102a0e805eeSFan Zhang  The value of this parameter can be "enable" or "disable". This feature
103a0e805eeSFan Zhang  is disabled by default.
104a0e805eeSFan Zhang
105d58a3f31SFan ZhangExample:
106d58a3f31SFan Zhang
107d58a3f31SFan Zhang.. code-block:: console
108d58a3f31SFan Zhang
109d58a3f31SFan Zhang    ... --vdev "crypto_aesni_mb_pmd,name=aesni_mb_1" --vdev "crypto_aesni_mb_pmd,name=aesni_mb_2" --vdev "crypto_scheduler_pmd,slave=aesni_mb_1,slave=aesni_mb_2" ...
110d58a3f31SFan Zhang
111d58a3f31SFan Zhang.. note::
112d58a3f31SFan Zhang
113d58a3f31SFan Zhang    * The scheduler cryptodev cannot be started unless the scheduling mode
114d58a3f31SFan Zhang      is set and at least one slave is attached. Also, to configure the
115d58a3f31SFan Zhang      scheduler in the run-time, like attach/detach slave(s), change
116d58a3f31SFan Zhang      scheduling mode, or enable/disable crypto op ordering, one should stop
117d58a3f31SFan Zhang      the scheduler first, otherwise an error will be returned.
118d58a3f31SFan Zhang
119d58a3f31SFan Zhang    * The crypto op reordering feature requires using the userdata field of
120d58a3f31SFan Zhang      every mbuf to be processed to store temporary data. By the end of
121d58a3f31SFan Zhang      processing, the field is set to pointing to NULL, any previously
122d58a3f31SFan Zhang      stored value of this field will be lost.
123d58a3f31SFan Zhang
124d58a3f31SFan Zhang
125d58a3f31SFan ZhangCryptodev Scheduler Modes Overview
126d58a3f31SFan Zhang----------------------------------
127d58a3f31SFan Zhang
128d58a3f31SFan ZhangCurrently the Crypto Scheduler PMD library supports following modes of
129d58a3f31SFan Zhangoperation:
130d58a3f31SFan Zhang
131d58a3f31SFan Zhang*   **CDEV_SCHED_MODE_ROUNDROBIN:**
132d58a3f31SFan Zhang
133a0e805eeSFan Zhang   *Initialization mode parameter*: **round-robin**
134a0e805eeSFan Zhang
135d58a3f31SFan Zhang   Round-robin mode, which distributes the enqueued burst of crypto ops
136d58a3f31SFan Zhang   among its slaves in a round-robin manner. This mode may help to fill
137d58a3f31SFan Zhang   the throughput gap between the physical core and the existing cryptodevs
138d58a3f31SFan Zhang   to increase the overall performance.
139a783aa63SFan Zhang
140a783aa63SFan Zhang*   **CDEV_SCHED_MODE_PKT_SIZE_DISTR:**
141a783aa63SFan Zhang
142a0e805eeSFan Zhang   *Initialization mode parameter*: **packet-size-distr**
143a0e805eeSFan Zhang
144a783aa63SFan Zhang   Packet-size based distribution mode, which works with 2 slaves, the primary
145a783aa63SFan Zhang   slave and the secondary slave, and distributes the enqueued crypto
146a783aa63SFan Zhang   operations to them based on their data lengths. A crypto operation will be
147a783aa63SFan Zhang   distributed to the primary slave if its data length is equal to or bigger
148a783aa63SFan Zhang   than the designated threshold, otherwise it will be handled by the secondary
149a783aa63SFan Zhang   slave.
150a783aa63SFan Zhang
151a783aa63SFan Zhang   A typical usecase in this mode is with the QAT cryptodev as the primary and
152a783aa63SFan Zhang   a software cryptodev as the secondary slave. This may help applications to
153a783aa63SFan Zhang   process additional crypto workload than what the QAT cryptodev can handle on
154a783aa63SFan Zhang   its own, by making use of the available CPU cycles to deal with smaller
155a783aa63SFan Zhang   crypto workloads.
15637f075daSFan Zhang
157*4e30ead5SFan Zhang   The threshold is set to 128 bytes by default. It can be updated by calling
158*4e30ead5SFan Zhang   function **rte_cryptodev_scheduler_option_set**. The parameter of
159*4e30ead5SFan Zhang   **option_type** must be **CDEV_SCHED_OPTION_THRESHOLD** and **option** should
160*4e30ead5SFan Zhang   point to a rte_cryptodev_scheduler_threshold_option structure filled with
161*4e30ead5SFan Zhang   appropriate threshold value. Please NOTE this threshold has be a power-of-2
162*4e30ead5SFan Zhang   unsigned integer.
163*4e30ead5SFan Zhang
16437f075daSFan Zhang*   **CDEV_SCHED_MODE_FAILOVER:**
16537f075daSFan Zhang
166a0e805eeSFan Zhang   *Initialization mode parameter*: **fail-over**
167a0e805eeSFan Zhang
16837f075daSFan Zhang   Fail-over mode, which works with 2 slaves, the primary slave and the
16937f075daSFan Zhang   secondary slave. In this mode, the scheduler will enqueue the incoming
17037f075daSFan Zhang   crypto operation burst to the primary slave. When one or more crypto
17137f075daSFan Zhang   operations fail to be enqueued, then they will be enqueued to the secondary
17237f075daSFan Zhang   slave.
173