457f817c029f78d8bbbb1a11389288521a347e5a
[deb_dpdk.git] / doc / guides / tools / cryptoperf.rst
1 ..  BSD LICENSE
2     Copyright(c) 2016 Intel Corporation. All rights reserved.
3     All rights reserved.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     * Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in
13     the documentation and/or other materials provided with the
14     distribution.
15     * Neither the name of Intel Corporation nor the names of its
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 dpdk-test-crypto-perf Application
32 =================================
33
34 The ``dpdk-test-crypto-perf`` tool is a Data Plane Development Kit (DPDK)
35 utility that allows measuring performance parameters of PMDs available in the
36 crypto tree. There are available two measurement types: throughput and latency.
37 User can use multiply cores to run tests on but only
38 one type of crypto PMD can be measured during single application
39 execution. Cipher parameters, type of device, type of operation and
40 chain mode have to be specified in the command line as application
41 parameters. These parameters are checked using device capabilities
42 structure.
43
44 Limitations
45 -----------
46 On hardware devices the cycle-count doesn't always represent the actual offload
47 cost. The cycle-count only represents the offload cost when the hardware
48 accelerator is not fully loaded, when loaded the cpu cycles freed up by the
49 offload are still consumed by the test tool and included in the cycle-count.
50 These cycles are consumed by retries and inefficient API calls enqueuing and
51 dequeuing smaller bursts than specified by the cmdline parameter. This results
52 in a larger cycle-count measurement and should not be interpreted as an offload
53 cost measurement.
54
55 On hardware devices the throughput measurement is not necessarily the maximum
56 possible for the device, e.g. it may be necessary to use multiple cores to keep
57 the hardware accelerator fully loaded and so measure maximum throughput.
58
59 Compiling the Application
60 -------------------------
61
62 **Step 1: PMD setting**
63
64 The ``dpdk-test-crypto-perf`` tool depends on crypto device drivers PMD which
65 are disabled by default in the build configuration file ``common_base``.
66 The crypto device drivers PMD which should be tested can be enabled by setting::
67
68    CONFIG_RTE_LIBRTE_PMD_<name>=y
69
70 Setting example for open ssl PMD::
71
72    CONFIG_RTE_LIBRTE_PMD_OPENSSL=y
73
74 **Step 2: Linearization setting**
75
76 It is possible linearized input segmented packets just before crypto operation
77 for devices which doesn't support scatter-gather, and allows to measure
78 performance also for this use case.
79
80 To set on the linearization options add below definition to the
81 ``cperf_ops.h`` file::
82
83    #define CPERF_LINEARIZATION_ENABLE
84
85 **Step 3: Build the application**
86
87 Execute the ``dpdk-setup.sh`` script to build the DPDK library together with the
88 ``dpdk-test-crypto-perf`` applcation.
89
90 Initially, the user must select a DPDK target to choose the correct target type
91 and compiler options to use when building the libraries.
92 The user must have all libraries, modules, updates and compilers installed
93 in the system prior to this,
94 as described in the earlier chapters in this Getting Started Guide.
95
96 Running the Application
97 -----------------------
98
99 The tool application has a number of command line options:
100
101 .. code-block:: console
102
103    dpdk-test-crypto-perf [EAL Options] -- [Application Options]
104
105 EAL Options
106 ~~~~~~~~~~~
107
108 The following are the EAL command-line options that can be used in conjunction
109 with the ``dpdk-test-crypto-perf`` applcation.
110 See the DPDK Getting Started Guides for more information on these options.
111
112 *   ``-c <COREMASK>`` or ``-l <CORELIST>``
113
114         Set the hexadecimal bitmask of the cores to run on. The corelist is a
115         list cores to use.
116
117 *   ``-w <PCI>``
118
119         Add a PCI device in white list.
120
121 *   ``--vdev <driver><id>``
122
123         Add a virtual device.
124
125 Appication Options
126 ~~~~~~~~~~~~~~~~~~
127
128 The following are the appication command-line options:
129
130 * ``--ptest type``
131
132         Set test type, where ``type`` is one of the following::
133
134            throughput
135            latency
136            verify
137
138 * ``--silent``
139
140         Disable options dump.
141
142 * ``--pool-sz <n>``
143
144         Set the number of mbufs to be allocated in the mbuf pool.
145
146 * ``--total-ops <n>``
147
148         Set the number of total operations performed.
149
150 * ``--burst-sz <n>``
151
152         Set the number of packets per burst.
153
154         This can be set as:
155           * Single value (i.e. ``--burst-sz 16``)
156           * Range of values, using the following structure ``min:inc:max``,
157             where ``min`` is minimum size, ``inc`` is the increment size and ``max``
158             is the maximum size (i.e. ``--burst-sz 16:2:32``)
159           * List of values, up to 32 values, separated in commas (i.e. ``--burst-sz 16,24,32``)
160
161 * ``--buffer-sz <n>``
162
163         Set the size of single packet (plaintext or ciphertext in it).
164
165         This can be set as:
166           * Single value (i.e. ``--buffer-sz 16``)
167           * Range of values, using the following structure ``min:inc:max``,
168             where ``min`` is minimum size, ``inc`` is the increment size and ``max``
169             is the maximum size (i.e. ``--buffer-sz 16:2:32``)
170           * List of values, up to 32 values, separated in commas (i.e. ``--buffer-sz 32,64,128``)
171
172
173 * ``--segments-nb <n>``
174
175         Set the number of segments per packet.
176
177 * ``--devtype <name>``
178
179         Set device type, where ``name`` is one of the following::
180
181            crypto_null
182            crypto_aesni_mb
183            crypto_aesni_gcm
184            crypto_openssl
185            crypto_qat
186            crypto_snow3g
187            crypto_kasumi
188            crypto_zuc
189            crypto_dpaa2_sec
190            crypto_armv8
191            crypto_scheduler
192
193 * ``--optype <name>``
194
195         Set operation type, where ``name`` is one of the following::
196
197            cipher-only
198            auth-only
199            cipher-then-auth
200            auth-then-cipher
201            aead
202
203         For GCM/CCM algorithms you should use aead flag.
204
205 * ``--sessionless``
206
207         Enable session-less crypto operations mode.
208
209 * ``--out-of-place``
210
211         Enable out-of-place crypto operations mode.
212
213 * ``--test-file <name>``
214
215         Set test vector file path. See the Test Vector File chapter.
216
217 * ``--test-name <name>``
218
219         Set specific test name section in the test vector file.
220
221 * ``--cipher-algo <name>``
222
223         Set cipher algorithm name, where ``name`` is one of the following::
224
225            3des-cbc
226            3des-ecb
227            3des-ctr
228            aes-cbc
229            aes-ctr
230            aes-ecb
231            aes-f8
232            aes-xts
233            arc4
234            null
235            kasumi-f8
236            snow3g-uea2
237            zuc-eea3
238
239 * ``--cipher-op <mode>``
240
241         Set cipher operation mode, where ``mode`` is one of the following::
242
243            encrypt
244            decrypt
245
246 * ``--cipher-key-sz <n>``
247
248         Set the size of cipher key.
249
250 * ``--cipher-iv-sz <n>``
251
252         Set the size of cipher iv.
253
254 * ``--auth-algo <name>``
255
256         Set authentication algorithm name, where ``name`` is one
257         of the following::
258
259            3des-cbc
260            aes-cbc-mac
261            aes-cmac
262            aes-gmac
263            aes-xcbc-mac
264            md5
265            md5-hmac
266            sha1
267            sha1-hmac
268            sha2-224
269            sha2-224-hmac
270            sha2-256
271            sha2-256-hmac
272            sha2-384
273            sha2-384-hmac
274            sha2-512
275            sha2-512-hmac
276            kasumi-f9
277            snow3g-uia2
278            zuc-eia3
279
280 * ``--auth-op <mode>``
281
282         Set authentication operation mode, where ``mode`` is one of
283         the following::
284
285            verify
286            generate
287
288 * ``--auth-key-sz <n>``
289
290         Set the size of authentication key.
291
292 * ``--auth-iv-sz <n>``
293
294         Set the size of auth iv.
295
296 * ``--aead-algo <name>``
297
298         Set AEAD algorithm name, where ``name`` is one
299         of the following::
300
301            aes-ccm
302            aes-gcm
303
304 * ``--aead-op <mode>``
305
306         Set AEAD operation mode, where ``mode`` is one of
307         the following::
308
309            encrypt
310            decrypt
311
312 * ``--aead-key-sz <n>``
313
314         Set the size of AEAD key.
315
316 * ``--aead-iv-sz <n>``
317
318         Set the size of AEAD iv.
319
320 * ``--aead-aad-sz <n>``
321
322         Set the size of AEAD aad.
323
324 * ``--digest-sz <n>``
325
326         Set the size of digest.
327
328 * ``--csv-friendly``
329
330         Enable test result output CSV friendly rather than human friendly.
331
332 Test Vector File
333 ~~~~~~~~~~~~~~~~
334
335 The test vector file is a text file contain information about test vectors.
336 The file is made of the sections. The first section doesn't have header.
337 It contain global information used in each test variant vectors -
338 typically information about plaintext, ciphertext, cipher key, aut key,
339 initial vector. All other sections begin header.
340 The sections contain particular information typically digest.
341
342 **Format of the file:**
343
344 Each line beginig with sign '#' contain comment and it is ignored by parser::
345
346    # <comment>
347
348 Header line is just name in square bracket::
349
350    [<section name>]
351
352 Data line contain information tocken then sign '=' and
353 a string of bytes in C byte array format::
354
355    <tocken> = <C byte array>
356
357 **Tockens list:**
358
359 * ``plaintext``
360
361         Original plaintext to be crypted.
362
363 * ``ciphertext``
364
365         Encrypted plaintext string.
366
367 * ``cipher_key``
368
369         Key used in cipher operation.
370
371 * ``auth_key``
372
373         Key used in auth operation.
374
375 * ``cipher_iv``
376
377         Cipher Initial Vector.
378
379 * ``auth_iv``
380
381         Auth Initial Vector.
382
383 * ``aad``
384
385         Additional data.
386
387 * ``digest``
388
389         Digest string.
390
391 Examples
392 --------
393
394 Call application for performance throughput test of single Aesni MB PMD
395 for cipher encryption aes-cbc and auth generation sha1-hmac,
396 one million operations, burst size 32, packet size 64::
397
398    dpdk-test-crypto-perf -l 6-7 --vdev crypto_aesni_mb -w 0000:00:00.0 --
399    --ptest throughput --devtype crypto_aesni_mb --optype cipher-then-auth
400    --cipher-algo aes-cbc --cipher-op encrypt --cipher-key-sz 16 --auth-algo
401    sha1-hmac --auth-op generate --auth-key-sz 64 --digest-sz 12
402    --total-ops 10000000 --burst-sz 32 --buffer-sz 64
403
404 Call application for performance latency test of two Aesni MB PMD executed
405 on two cores for cipher encryption aes-cbc, ten operations in silent mode::
406
407    dpdk-test-crypto-perf -l 4-7 --vdev crypto_aesni_mb1
408    --vdev crypto_aesni_mb2 -w 0000:00:00.0 -- --devtype crypto_aesni_mb
409    --cipher-algo aes-cbc --cipher-key-sz 16 --cipher-iv-sz 16
410    --cipher-op encrypt --optype cipher-only --silent
411    --ptest latency --total-ops 10
412
413 Call application for verification test of single open ssl PMD
414 for cipher encryption aes-gcm and auth generation aes-gcm,ten operations
415 in silent mode, test vector provide in file "test_aes_gcm.data"
416 with packet verification::
417
418    dpdk-test-crypto-perf -l 4-7 --vdev crypto_openssl -w 0000:00:00.0 --
419    --devtype crypto_openssl --aead-algo aes-gcm --aead-key-sz 16
420    --aead-iv-sz 16 --aead-op encrypt --aead-aad-sz 16 --digest-sz 16
421    --optype aead --silent --ptest verify --total-ops 10
422    --test-file test_aes_gcm.data
423
424 Test vector file for cipher algorithm aes cbc 256 with authorization sha::
425
426    # Global Section
427    plaintext =
428    0xff, 0xca, 0xfb, 0xf1, 0x38, 0x20, 0x2f, 0x7b, 0x24, 0x98, 0x26, 0x7d, 0x1d, 0x9f, 0xb3, 0x93,
429    0xd9, 0xef, 0xbd, 0xad, 0x4e, 0x40, 0xbd, 0x60, 0xe9, 0x48, 0x59, 0x90, 0x67, 0xd7, 0x2b, 0x7b,
430    0x8a, 0xe0, 0x4d, 0xb0, 0x70, 0x38, 0xcc, 0x48, 0x61, 0x7d, 0xee, 0xd6, 0x35, 0x49, 0xae, 0xb4,
431    0xaf, 0x6b, 0xdd, 0xe6, 0x21, 0xc0, 0x60, 0xce, 0x0a, 0xf4, 0x1c, 0x2e, 0x1c, 0x8d, 0xe8, 0x7b
432    ciphertext =
433    0x77, 0xF9, 0xF7, 0x7A, 0xA3, 0xCB, 0x68, 0x1A, 0x11, 0x70, 0xD8, 0x7A, 0xB6, 0xE2, 0x37, 0x7E,
434    0xD1, 0x57, 0x1C, 0x8E, 0x85, 0xD8, 0x08, 0xBF, 0x57, 0x1F, 0x21, 0x6C, 0xAD, 0xAD, 0x47, 0x1E,
435    0x0D, 0x6B, 0x79, 0x39, 0x15, 0x4E, 0x5B, 0x59, 0x2D, 0x76, 0x87, 0xA6, 0xD6, 0x47, 0x8F, 0x82,
436    0xB8, 0x51, 0x91, 0x32, 0x60, 0xCB, 0x97, 0xDE, 0xBE, 0xF0, 0xAD, 0xFC, 0x23, 0x2E, 0x22, 0x02
437    cipher_key =
438    0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A,
439    0xd0, 0xe7, 0x4b, 0xfb, 0x5d, 0xe5, 0x0c, 0xe7, 0x6f, 0x21, 0xb5, 0x52, 0x2a, 0xbb, 0xc7, 0xf7
440    auth_key =
441    0xaf, 0x96, 0x42, 0xf1, 0x8c, 0x50, 0xdc, 0x67, 0x1a, 0x43, 0x47, 0x62, 0xc7, 0x04, 0xab, 0x05,
442    0xf5, 0x0c, 0xe7, 0xa2, 0xa6, 0x23, 0xd5, 0x3d, 0x95, 0xd8, 0xcd, 0x86, 0x79, 0xf5, 0x01, 0x47,
443    0x4f, 0xf9, 0x1d, 0x9d, 0x36, 0xf7, 0x68, 0x1a, 0x64, 0x44, 0x58, 0x5d, 0xe5, 0x81, 0x15, 0x2a,
444    0x41, 0xe4, 0x0e, 0xaa, 0x1f, 0x04, 0x21, 0xff, 0x2c, 0xf3, 0x73, 0x2b, 0x48, 0x1e, 0xd2, 0xf7
445    cipher_iv =
446    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
447    # Section sha 1 hmac buff 32
448    [sha1_hmac_buff_32]
449    digest =
450    0x36, 0xCA, 0x49, 0x6A, 0xE3, 0x54, 0xD8, 0x4F, 0x0B, 0x76, 0xD8, 0xAA, 0x78, 0xEB, 0x9D, 0x65,
451    0x2C, 0xCA, 0x1F, 0x97
452    # Section sha 256 hmac buff 32
453    [sha256_hmac_buff_32]
454    digest =
455    0x1C, 0xB2, 0x3D, 0xD1, 0xF9, 0xC7, 0x6C, 0x49, 0x2E, 0xDA, 0x94, 0x8B, 0xF1, 0xCF, 0x96, 0x43,
456    0x67, 0x50, 0x39, 0x76, 0xB5, 0xA1, 0xCE, 0xA1, 0xD7, 0x77, 0x10, 0x07, 0x43, 0x37, 0x05, 0xB4