xref: /dpdk/doc/guides/prog_guide/rte_security.rst (revision dcee1520f37a7ccfc75c262e284740197d1e42c0)
1..  SPDX-License-Identifier: BSD-3-Clause
2    Copyright 2017,2020-2021 NXP
3
4
5
6Security Library
7================
8
9The security library provides a framework for management and provisioning
10of security protocol operations offloaded to hardware based devices. The
11library defines generic APIs to create and free security sessions which can
12support full protocol offload as well as inline crypto operation with
13NIC or crypto devices. The framework currently only supports the IPsec, PDCP
14and DOCSIS protocols and associated operations, other protocols will be added
15in the future.
16
17Design Principles
18-----------------
19
20The security library provides an additional offload capability to an existing
21crypto device and/or ethernet device.
22
23.. code-block:: console
24
25               +---------------+
26               | rte_security  |
27               +---------------+
28                 \            /
29        +-----------+    +--------------+
30        |  NIC PMD  |    |  CRYPTO PMD  |
31        +-----------+    +--------------+
32
33.. note::
34
35    Currently, the security library does not support the case of multi-process.
36    It will be updated in the future releases.
37
38The supported offload types are explained in the sections below.
39
40Inline Crypto
41~~~~~~~~~~~~~
42
43RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
44The crypto processing for security protocol (e.g. IPsec) is processed
45inline during receive and transmission on NIC port. The flow based
46security action should be configured on the port.
47
48Ingress Data path - The packet is decrypted in RX path and relevant
49crypto status is set in Rx descriptors. After the successful inline
50crypto processing the packet is presented to host as a regular Rx packet
51however all security protocol related headers are still attached to the
52packet. e.g. In case of IPsec, the IPsec tunnel headers (if any),
53ESP/AH headers will remain in the packet but the received packet
54contains the decrypted data where the encrypted data was when the packet
55arrived. The driver Rx path check the descriptors and based on the
56crypto status sets additional flags in the rte_mbuf.ol_flags field.
57
58.. note::
59
60    The underlying device may not support crypto processing for all ingress packet
61    matching to a particular flow (e.g. fragmented packets), such packets will
62    be passed as encrypted packets. It is the responsibility of application to
63    process such encrypted packets using other crypto driver instance.
64
65Egress Data path - The software prepares the egress packet by adding
66relevant security protocol headers. Only the data will not be
67encrypted by the software. The driver will accordingly configure the
68tx descriptors. The hardware device will encrypt the data before sending the
69packet out.
70
71.. note::
72
73    The underlying device may support post encryption TSO.
74
75.. code-block:: console
76
77          Egress Data Path
78                 |
79        +--------|--------+
80        |  egress IPsec   |
81        |        |        |
82        | +------V------+ |
83        | | SADB lookup | |
84        | +------|------+ |
85        | +------V------+ |
86        | |   Tunnel    | |   <------ Add tunnel header to packet
87        | +------|------+ |
88        | +------V------+ |
89        | |     ESP     | |   <------ Add ESP header without trailer to packet
90        | |             | |   <------ Mark packet to be offloaded, add trailer
91        | +------|------+ |            meta-data to mbuf
92        +--------V--------+
93                 |
94        +--------V--------+
95        |    L2 Stack     |
96        +--------|--------+
97                 |
98        +--------V--------+
99        |                 |
100        |     NIC PMD     |   <------ Set hw context for inline crypto offload
101        |                 |
102        +--------|--------+
103                 |
104        +--------|--------+
105        |  HW ACCELERATED |   <------ Packet Encryption and
106        |        NIC      |           Authentication happens inline
107        |                 |
108        +-----------------+
109
110
111Inline protocol offload
112~~~~~~~~~~~~~~~~~~~~~~~
113
114RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL:
115The crypto and protocol processing for security protocol (e.g. IPsec)
116is processed inline during receive and transmission.  The flow based
117security action should be configured on the port.
118
119Ingress Data path - The packet is decrypted in the RX path and relevant
120crypto status is set in the Rx descriptors. After the successful inline
121crypto processing the packet is presented to the host as a regular Rx packet
122but all security protocol related headers are optionally removed from the
123packet. e.g. in the case of IPsec, the IPsec tunnel headers (if any),
124ESP/AH headers will be removed from the packet and the received packet
125will contains the decrypted packet only. The driver Rx path checks the
126descriptors and based on the crypto status sets additional flags in
127``rte_mbuf.ol_flags`` field. The driver would also set device-specific
128metadata in ``RTE_SECURITY_DYNFIELD_NAME`` field.
129This will allow the application to identify the security processing
130done on the packet.
131
132.. note::
133
134    The underlying device in this case is stateful. It is expected that
135    the device shall support crypto processing for all kind of packets matching
136    to a given flow, this includes fragmented packets (post reassembly).
137    E.g. in case of IPsec the device may internally manage anti-replay etc.
138    It will provide a configuration option for anti-replay behavior i.e. to drop
139    the packets or pass them to driver with error flags set in the descriptor.
140
141Egress Data path - The software will send the plain packet without any
142security protocol headers added to the packet. The driver will configure
143the security index and other requirement in tx descriptors.
144The hardware device will do security processing on the packet that includes
145adding the relevant protocol headers and encrypting the data before sending
146the packet out. The software should make sure that the buffer
147has required head room and tail room for any protocol header addition. The
148software may also do early fragmentation if the resultant packet is expected
149to cross the MTU size. The software should also make sure that L2 header contents
150are updated with the final L2 header which is expected post IPsec processing as
151the IPsec offload will only update L3 and above in egress path.
152
153
154.. note::
155
156    The underlying device will manage state information required for egress
157    processing. E.g. in case of IPsec, the seq number will be added to the
158    packet, however the device shall provide indication when the sequence number
159    is about to overflow. The underlying device may support post encryption TSO.
160
161.. code-block:: console
162
163         Egress Data Path
164                 |
165        +--------|--------+
166        |  egress IPsec   |
167        |        |        |
168        | +------V------+ |
169        | | SADB lookup | |
170        | +------|------+ |
171        | +------V------+ |
172        | |   Desc      | |   <------ Mark packet to be offloaded
173        | +------|------+ |
174        +--------V--------+
175                 |
176        +--------V--------+
177        |    L2 Stack     |
178        +--------|--------+
179                 |
180        +--------V--------+
181        |                 |
182        |     NIC PMD     |   <------ Set hw context for inline crypto offload
183        |                 |
184        +--------|--------+
185                 |
186        +--------|--------+
187        |  HW ACCELERATED |   <------ Add tunnel, ESP header etc header to
188        |        NIC      |           packet. Packet Encryption and
189        |                 |           Authentication happens inline.
190        +-----------------+
191
192
193Lookaside protocol offload
194~~~~~~~~~~~~~~~~~~~~~~~~~~
195
196RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL:
197This extends librte_cryptodev to support the programming of IPsec
198Security Association (SA) as part of a crypto session creation including
199the definition. In addition to standard crypto processing, as defined by
200the cryptodev, the security protocol processing is also offloaded to the
201crypto device.
202
203Decryption: The packet is sent to the crypto device for security
204protocol processing. The device will decrypt the packet and it will also
205optionally remove additional security headers from the packet.
206E.g. in case of IPsec, IPsec tunnel headers (if any), ESP/AH headers
207will be removed from the packet and the decrypted packet may contain
208plain data only.
209
210.. note::
211
212    In case of IPsec the device may internally manage anti-replay etc.
213    It will provide a configuration option for anti-replay behavior i.e. to drop
214    the packets or pass them to driver with error flags set in descriptor.
215
216Encryption: The software will submit the packet to cryptodev as usual
217for encryption, the hardware device in this case will also add the relevant
218security protocol header along with encrypting the packet. The software
219should make sure that the buffer has required head room and tail room
220for any protocol header addition.
221
222.. note::
223
224    In the case of IPsec, the seq number will be added to the packet,
225    It shall provide an indication when the sequence number is about to
226    overflow.
227
228.. code-block:: console
229
230          Egress Data Path
231                 |
232        +--------|--------+
233        |  egress IPsec   |
234        |        |        |
235        | +------V------+ |
236        | | SADB lookup | |   <------ SA maps to cryptodev session
237        | +------|------+ |
238        | +------|------+ |
239        | |      \--------------------\
240        | |    Crypto   | |           |  <- Crypto processing through
241        | |      /----------------\   |     inline crypto PMD
242        | +------|------+ |       |   |
243        +--------V--------+       |   |
244                 |                |   |
245        +--------V--------+       |   |  create   <-- SA is added to hw
246        |    L2 Stack     |       |   |  inline       using existing create
247        +--------|--------+       |   |  session      sym session APIs
248                 |                |   |    |
249        +--------V--------+   +---|---|----V---+
250        |                 |   |   \---/    |   | <--- Add tunnel, ESP header etc
251        |     NIC PMD     |   |   INLINE   |   |      header to packet.Packet
252        |                 |   | CRYPTO PMD |   |      Encryption/Decryption and
253        +--------|--------+   +----------------+      Authentication happens
254                 |                                    inline.
255        +--------|--------+
256        |       NIC       |
257        +--------|--------+
258                 V
259
260PDCP Flow Diagram
261~~~~~~~~~~~~~~~~~
262
263Based on 3GPP TS 36.323 Evolved Universal Terrestrial Radio Access (E-UTRA);
264Packet Data Convergence Protocol (PDCP) specification
265
266.. code-block:: c
267
268        Transmitting PDCP Entity          Receiving PDCP Entity
269                  |                                   ^
270                  |                       +-----------|-----------+
271                  V                       | In order delivery and |
272        +---------|----------+            | Duplicate detection   |
273        | Sequence Numbering |            |  (Data Plane only)    |
274        +---------|----------+            +-----------|-----------+
275                  |                                   |
276        +---------|----------+            +-----------|----------+
277        | Header Compression*|            | Header Decompression*|
278        | (Data-Plane only)  |            |   (Data Plane only)  |
279        +---------|----------+            +-----------|----------+
280                  |                                   |
281        +---------|-----------+           +-----------|----------+
282        | Integrity Protection|           |Integrity Verification|
283        | (Control Plane only)|           | (Control Plane only) |
284        +---------|-----------+           +-----------|----------+
285        +---------|-----------+            +----------|----------+
286        |     Ciphering       |            |     Deciphering     |
287        +---------|-----------+            +----------|----------+
288        +---------|-----------+            +----------|----------+
289        |   Add PDCP header   |            | Remove PDCP Header  |
290        +---------|-----------+            +----------|----------+
291                  |                                   |
292                  +----------------->>----------------+
293
294
295.. note::
296
297    * Header Compression and decompression are not supported currently.
298
299Just like IPsec, in case of PDCP also header addition/deletion, cipher/
300de-cipher, integrity protection/verification is done based on the action
301type chosen.
302
303DOCSIS Protocol
304~~~~~~~~~~~~~~~
305
306The Data Over Cable Service Interface Specification (DOCSIS) support comprises
307the combination of encryption/decryption and CRC generation/verification, for
308use in a DOCSIS-MAC pipeline.
309
310.. code-block:: c
311
312
313               Downlink                       Uplink
314               --------                       ------
315
316            Ethernet frame                Ethernet frame
317           from core network              to core network
318                  |                              ^
319                  ~                              |
320                  |                              ~         ----+
321                  V                              |             |
322        +---------|----------+        +----------|---------+   |
323        |   CRC generation   |        |  CRC verification  |   |
324        +---------|----------+        +----------|---------+   |   combined
325                  |                              |             > Crypto + CRC
326        +---------|----------+        +----------|---------+   |
327        |     Encryption     |        |     Decryption     |   |
328        +---------|----------+        +----------|---------+   |
329                  |                              ^             |
330                  ~                              |         ----+
331                  |                              ~
332                  V                              |
333             DOCSIS frame                  DOCSIS frame
334            to Cable Modem               from Cable Modem
335
336The encryption/decryption is a combination of CBC and CFB modes using either AES
337or DES algorithms as specified in the DOCSIS Security Specification (from DPDK
338lib_rtecryptodev perspective, these are RTE_CRYPTO_CIPHER_AES_DOCSISBPI and
339RTE_CRYPTO_CIPHER_DES_DOCSISBPI).
340
341The CRC is Ethernet CRC-32 as specified in Ethernet/[ISO/IEC 8802-3].
342
343.. note::
344
345    * The offset and length of data for which CRC needs to be computed are
346      specified via the auth offset and length fields of the rte_crypto_sym_op.
347    * Other DOCSIS protocol functionality such as Header Checksum (HCS)
348      calculation may be added in the future.
349
350Device Features and Capabilities
351---------------------------------
352
353Device Capabilities For Security Operations
354~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
355
356The device (crypto or ethernet) capabilities which support security operations,
357are defined by the security action type, security protocol, protocol
358capabilities and corresponding crypto capabilities for security. For the full
359scope of the Security capability see definition of rte_security_capability
360structure in the *DPDK API Reference*.
361
362.. code-block:: c
363
364   struct rte_security_capability;
365
366Each driver (crypto or ethernet) defines its own private array of capabilities
367for the operations it supports. Below is an example of the capabilities for a
368PMD which supports the IPsec and PDCP protocol.
369
370.. code-block:: c
371
372    static const struct rte_security_capability pmd_security_capabilities[] = {
373        { /* IPsec Lookaside Protocol offload ESP Tunnel Egress */
374                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
375                .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
376                .ipsec = {
377                        .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
378                        .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
379                        .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
380                        .options = { 0 }
381                },
382                .crypto_capabilities = pmd_capabilities
383        },
384        { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */
385                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
386                .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
387                .ipsec = {
388                        .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
389                        .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
390                        .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
391                        .options = { 0 }
392                },
393                .crypto_capabilities = pmd_capabilities
394        },
395        { /* PDCP Lookaside Protocol offload Data Plane */
396                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
397                .protocol = RTE_SECURITY_PROTOCOL_PDCP,
398                .pdcp = {
399                        .domain = RTE_SECURITY_PDCP_MODE_DATA,
400                        .capa_flags = 0
401                },
402                .crypto_capabilities = pmd_capabilities
403        },
404        { /* PDCP Lookaside Protocol offload Control */
405                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
406                .protocol = RTE_SECURITY_PROTOCOL_PDCP,
407                .pdcp = {
408                        .domain = RTE_SECURITY_PDCP_MODE_CONTROL,
409                        .capa_flags = 0
410                },
411                .crypto_capabilities = pmd_capabilities
412        },
413	{ /* PDCP Lookaside Protocol offload short MAC-I */
414                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
415                .protocol = RTE_SECURITY_PROTOCOL_PDCP,
416                .pdcp = {
417                        .domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC,
418                        .capa_flags = 0
419                },
420                .crypto_capabilities = pmd_capabilities
421        },
422        {
423                .action = RTE_SECURITY_ACTION_TYPE_NONE
424        }
425    };
426    static const struct rte_cryptodev_capabilities pmd_capabilities[] = {
427        {    /* SHA1 HMAC */
428            .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
429            .sym = {
430                .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
431                .auth = {
432                    .algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
433                    .block_size = 64,
434                    .key_size = {
435                        .min = 64,
436                        .max = 64,
437                        .increment = 0
438                    },
439                    .digest_size = {
440                        .min = 12,
441                        .max = 12,
442                        .increment = 0
443                    },
444                    .aad_size = { 0 },
445                    .iv_size = { 0 }
446                }
447            }
448        },
449        {    /* AES CBC */
450            .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
451            .sym = {
452                .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
453                .cipher = {
454                    .algo = RTE_CRYPTO_CIPHER_AES_CBC,
455                    .block_size = 16,
456                    .key_size = {
457                        .min = 16,
458                        .max = 32,
459                        .increment = 8
460                    },
461                    .iv_size = {
462                        .min = 16,
463                        .max = 16,
464                        .increment = 0
465                    }
466                }
467            }
468        }
469    }
470
471Below is an example of the capabilities for a PMD which supports the DOCSIS
472protocol.
473
474.. code-block:: c
475
476    static const struct rte_security_capability pmd_security_capabilities[] = {
477        { /* DOCSIS Uplink */
478                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
479                .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
480                .docsis = {
481                        .direction = RTE_SECURITY_DOCSIS_UPLINK
482                },
483                .crypto_capabilities = pmd_capabilities
484        },
485        { /* DOCSIS Downlink */
486                .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
487                .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
488                .docsis = {
489                        .direction = RTE_SECURITY_DOCSIS_DOWNLINK
490                },
491                .crypto_capabilities = pmd_capabilities
492        },
493        {
494                .action = RTE_SECURITY_ACTION_TYPE_NONE
495        }
496    };
497    static const struct rte_cryptodev_capabilities pmd_capabilities[] = {
498        {    /* AES DOCSIS BPI */
499            .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
500            .sym = {
501                .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
502                .cipher = {
503                    .algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI,
504                    .block_size = 16,
505                    .key_size = {
506                        .min = 16,
507                        .max = 32,
508                        .increment = 16
509                    },
510                    .iv_size = {
511                        .min = 16,
512                        .max = 16,
513                        .increment = 0
514                    }
515                }
516            }
517        },
518
519        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
520    };
521
522Capabilities Discovery
523~~~~~~~~~~~~~~~~~~~~~~
524
525Discovering the features and capabilities of a driver (crypto/ethernet)
526is achieved through the ``rte_security_capabilities_get()`` function.
527
528.. code-block:: c
529
530   const struct rte_security_capability *rte_security_capabilities_get(uint16_t id);
531
532This allows the user to query a specific driver and get all device
533security capabilities. It returns an array of ``rte_security_capability`` structures
534which contains all the capabilities for that device.
535
536Security Session Create/Free
537~~~~~~~~~~~~~~~~~~~~~~~~~~~~
538
539Security Sessions are created to store the immutable fields of a particular Security
540Association for a particular protocol which is defined by a security session
541configuration structure which is used in the operation processing of a packet flow.
542Sessions are used to manage protocol specific information as well as crypto parameters.
543Security sessions cache this immutable data in a optimal way for the underlying PMD
544and this allows further acceleration of the offload of Crypto workloads.
545
546The Security framework provides APIs to create and free sessions for crypto/ethernet
547devices, where sessions are mempool objects. It is the application's responsibility
548to create and manage two session mempools - one for session and other for session
549private data. The private session data mempool object size should be able to
550accommodate the driver's private data of security session. The application can get
551the size of session private data using API ``rte_security_session_get_size``.
552And the session mempool object size should be enough to accommodate
553``rte_security_session``.
554
555Once the session mempools have been created, ``rte_security_session_create()``
556is used to allocate and initialize a session for the required crypto/ethernet device.
557
558Session APIs need a parameter ``rte_security_ctx`` to identify the crypto/ethernet
559security ops. This parameter can be retrieved using the APIs
560``rte_cryptodev_get_sec_ctx()`` (for crypto device) or ``rte_eth_dev_get_sec_ctx``
561(for ethernet port).
562
563Sessions already created can be updated with ``rte_security_session_update()``.
564
565When a session is no longer used, the user must call ``rte_security_session_destroy()``
566to free the driver private session data and return the memory back to the mempool.
567
568For look aside protocol offload to hardware crypto device, the ``rte_crypto_op``
569created by the application is attached to the security session by the API
570``rte_security_attach_session()``.
571
572For Inline Crypto and Inline protocol offload, device specific defined metadata is
573updated in the mbuf using ``rte_security_set_pkt_metadata()`` if
574``RTE_ETH_TX_OFFLOAD_SEC_NEED_MDATA`` is set.
575
576For inline protocol offloaded ingress traffic, the application can register a
577pointer, ``userdata`` , in the security session. When the packet is received,
578``rte_security_get_userdata()`` would return the userdata registered for the
579security session which processed the packet.
580
581.. note::
582
583    In case of inline processed packets, ``RTE_SECURITY_DYNFIELD_NAME`` field
584    would be used by the driver to relay information on the security processing
585    associated with the packet. In ingress, the driver would set this in Rx
586    path while in egress, ``rte_security_set_pkt_metadata()`` would perform a
587    similar operation. The application is expected not to modify the field
588    when it has relevant info. For ingress, this device-specific 64 bit value
589    is required to derive other information (like userdata), required for
590    identifying the security processing done on the packet.
591
592Security session configuration
593~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
594
595Security Session configuration structure is defined as ``rte_security_session_conf``
596
597.. code-block:: c
598
599    struct rte_security_session_conf {
600        enum rte_security_session_action_type action_type;
601        /**< Type of action to be performed on the session */
602        enum rte_security_session_protocol protocol;
603        /**< Security protocol to be configured */
604        union {
605                struct rte_security_ipsec_xform ipsec;
606                struct rte_security_macsec_xform macsec;
607                struct rte_security_pdcp_xform pdcp;
608                struct rte_security_docsis_xform docsis;
609        };
610        /**< Configuration parameters for security session */
611        struct rte_crypto_sym_xform *crypto_xform;
612        /**< Security Session Crypto Transformations */
613        void *userdata;
614        /**< Application specific userdata to be saved with session */
615    };
616
617The configuration structure reuses the ``rte_crypto_sym_xform`` struct for crypto related
618configuration. The ``rte_security_session_action_type`` struct is used to specify whether the
619session is configured for Lookaside Protocol offload or Inline Crypto or Inline Protocol
620Offload.
621
622.. code-block:: c
623
624    enum rte_security_session_action_type {
625        RTE_SECURITY_ACTION_TYPE_NONE,
626        /**< No security actions */
627        RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
628        /**< Crypto processing for security protocol is processed inline
629         * during transmission
630         */
631        RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL,
632        /**< All security protocol processing is performed inline during
633         * transmission
634         */
635        RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
636        /**< All security protocol processing including crypto is performed
637         * on a lookaside accelerator
638         */
639        RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO
640        /**< Similar to ACTION_TYPE_NONE but crypto processing for security
641         * protocol is processed synchronously by a CPU.
642         */
643    };
644
645The ``rte_security_session_protocol`` is defined as
646
647.. code-block:: c
648
649    enum rte_security_session_protocol {
650        RTE_SECURITY_PROTOCOL_IPSEC = 1,
651        /**< IPsec Protocol */
652        RTE_SECURITY_PROTOCOL_MACSEC,
653        /**< MACSec Protocol */
654        RTE_SECURITY_PROTOCOL_PDCP,
655        /**< PDCP Protocol */
656        RTE_SECURITY_PROTOCOL_DOCSIS,
657        /**< DOCSIS Protocol */
658    };
659
660Currently the library defines configuration parameters for IPsec and PDCP only.
661For other protocols like MACSec, structures and enums are defined as place holders
662which will be updated in the future.
663
664IPsec related configuration parameters are defined in ``rte_security_ipsec_xform``
665
666PDCP related configuration parameters are defined in ``rte_security_pdcp_xform``
667
668DOCSIS related configuration parameters are defined in ``rte_security_docsis_xform``
669
670
671Security API
672~~~~~~~~~~~~
673
674The rte_security Library API is described in the *DPDK API Reference* document.
675
676Flow based Security Session
677~~~~~~~~~~~~~~~~~~~~~~~~~~~
678
679In the case of NIC based offloads, the security session specified in the
680'rte_flow_action_security' must be created on the same port as the
681flow action that is being specified.
682
683The ingress/egress flow attribute should match that specified in the security
684session if the security session supports the definition of the direction.
685
686Multiple flows can be configured to use the same security session. For
687example if the security session specifies an egress IPsec SA, then multiple
688flows can be specified to that SA. In the case of an ingress IPsec SA then
689it is only valid to have a single flow to map to that security session.
690
691.. code-block:: console
692
693         Configuration Path
694                 |
695        +--------|--------+
696        |    Add/Remove   |
697        |     IPsec SA    |   <------ Build security flow action of
698        |        |        |           ipsec transform
699        |--------|--------|
700                 |
701        +--------V--------+
702        |   Flow API      |
703        +--------|--------+
704                 |
705        +--------V--------+
706        |                 |
707        |     NIC PMD     |   <------ Add/Remove SA to/from hw context
708        |                 |
709        +--------|--------+
710                 |
711        +--------|--------+
712        |  HW ACCELERATED |
713        |        NIC      |
714        |                 |
715        +--------|--------+
716
717* Add/Delete SA flow:
718  To add a new inline SA construct a rte_flow_item for Ethernet + IP + ESP
719  using the SA selectors and the ``rte_crypto_ipsec_xform`` as the ``rte_flow_action``.
720  Note that any rte_flow_items may be empty, which means it is not checked.
721
722.. code-block:: console
723
724    In its most basic form, IPsec flow specification is as follows:
725        +-------+     +----------+    +--------+    +-----+
726        |  Eth  | ->  |   IP4/6  | -> |   ESP  | -> | END |
727        +-------+     +----------+    +--------+    +-----+
728
729    However, the API can represent, IPsec crypto offload with any encapsulation:
730        +-------+            +--------+    +-----+
731        |  Eth  | ->  ... -> |   ESP  | -> | END |
732        +-------+            +--------+    +-----+
733
734
735Telemetry support
736-----------------
737
738The Security library has support for displaying Crypto device information
739with respect to its Security capabilities. Telemetry commands that can be used
740are shown below.
741
742#. Get the list of available Crypto devices by ID, that supports Security features::
743
744     --> /security/cryptodev/list
745     {"/security/cryptodev/list": [0, 1, 2, 3]}
746
747#. Get the security capabilities of a Crypto device::
748
749     --> /security/cryptodev/sec_caps,0
750	 {"/security/cryptodev/sec_caps": {"sec_caps": [<array of serialized bytes of
751	 capabilities>], "sec_caps_n": <number of capabilities>}}
752
753 #. Get the security crypto capabilities of a Crypto device::
754
755     --> /security/cryptodev/crypto_caps,0,0
756	 {"/security/cryptodev/crypto_caps": {"crypto_caps": [<array of serialized bytes of
757	 capabilities>], "crypto_caps_n": <number of capabilities>}}
758
759For more information on how to use the Telemetry interface, see
760the :doc:`../howto/telemetry`.
761