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 350MACSEC Protocol 351~~~~~~~~~~~~~~~ 352 353Media Access Control security (MACsec) provides point-to-point security 354on Ethernet links and is defined by IEEE standard 802.1AE. 355MACsec secures an Ethernet link for almost all traffic, 356including frames from the Link Layer Discovery Protocol (LLDP), 357Link Aggregation Control Protocol (LACP), 358Dynamic Host Configuration Protocol (DHCP), 359Address Resolution Protocol (ARP), 360and other protocols that are not typically secured on an Ethernet link 361because of limitations with other security solutions. 362 363.. code-block:: c 364 365 Receive Transmit 366 ------- -------- 367 368 Ethernet frame Ethernet frame 369 from network towards network 370 | ^ 371 ~ | 372 | ~ 373 V | 374 +-----------------------+ +------------------+ +-------------------------+ 375 | Secure Frame Verify | | Cipher Suite(SA) | | Secure Frame Generation | 376 +-----------------------+<-----+------------------+----->+-------------------------+ 377 | SecTAG + ICV remove | | SECY | SC | | SecTAG + ICV Added | 378 +---+-------------------+ +------------------+ +-------------------------+ 379 | ^ 380 | | 381 V | 382 Packet to Core/App Packet from Core/App 383 384 385 386To configure MACsec on an inline NIC device or a lookaside crypto device, 387a security association (SA) and a secure channel (SC) are created 388before creating rte_security session. 389 390SA is created using API ``rte_security_macsec_sa_create`` 391which allows setting SA keys, salt, SSCI, packet number (PN) into the PMD, 392and the API returns a handle which can be used to map it with a secure channel, 393using the API ``rte_security_macsec_sc_create``. 394Same SAs can be used for multiple SCs. 395The Rx SC will need a set of 4 SAs for each of the association numbers (AN). 396For Tx SC a single SA is set which will be used by hardware to process the packet. 397 398The API ``rte_security_macsec_sc_create`` returns a handle for SC, 399and this handle is set in ``rte_security_macsec_xform`` 400to create a MACsec session using ``rte_security_session_create``. 401 402 403Device Features and Capabilities 404--------------------------------- 405 406Device Capabilities For Security Operations 407~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 408 409The device (crypto or ethernet) capabilities which support security operations, 410are defined by the security action type, security protocol, protocol 411capabilities and corresponding crypto capabilities for security. For the full 412scope of the Security capability see definition of rte_security_capability 413structure in the *DPDK API Reference*. 414 415.. code-block:: c 416 417 struct rte_security_capability; 418 419Each driver (crypto or ethernet) defines its own private array of capabilities 420for the operations it supports. Below is an example of the capabilities for a 421PMD which supports the IPsec and PDCP protocol. 422 423.. code-block:: c 424 425 static const struct rte_security_capability pmd_security_capabilities[] = { 426 { /* IPsec Lookaside Protocol offload ESP Tunnel Egress */ 427 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 428 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 429 .ipsec = { 430 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 431 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 432 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS, 433 .options = { 0 } 434 }, 435 .crypto_capabilities = pmd_capabilities 436 }, 437 { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */ 438 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 439 .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 440 .ipsec = { 441 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 442 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 443 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS, 444 .options = { 0 } 445 }, 446 .crypto_capabilities = pmd_capabilities 447 }, 448 { /* PDCP Lookaside Protocol offload Data Plane */ 449 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 450 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 451 .pdcp = { 452 .domain = RTE_SECURITY_PDCP_MODE_DATA, 453 .capa_flags = 0 454 }, 455 .crypto_capabilities = pmd_capabilities 456 }, 457 { /* PDCP Lookaside Protocol offload Control */ 458 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 459 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 460 .pdcp = { 461 .domain = RTE_SECURITY_PDCP_MODE_CONTROL, 462 .capa_flags = 0 463 }, 464 .crypto_capabilities = pmd_capabilities 465 }, 466 { /* PDCP Lookaside Protocol offload short MAC-I */ 467 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 468 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 469 .pdcp = { 470 .domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC, 471 .capa_flags = 0 472 }, 473 .crypto_capabilities = pmd_capabilities 474 }, 475 { 476 .action = RTE_SECURITY_ACTION_TYPE_NONE 477 } 478 }; 479 static const struct rte_cryptodev_capabilities pmd_capabilities[] = { 480 { /* SHA1 HMAC */ 481 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 482 .sym = { 483 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 484 .auth = { 485 .algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 486 .block_size = 64, 487 .key_size = { 488 .min = 64, 489 .max = 64, 490 .increment = 0 491 }, 492 .digest_size = { 493 .min = 12, 494 .max = 12, 495 .increment = 0 496 }, 497 .aad_size = { 0 }, 498 .iv_size = { 0 } 499 } 500 } 501 }, 502 { /* AES CBC */ 503 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 504 .sym = { 505 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 506 .cipher = { 507 .algo = RTE_CRYPTO_CIPHER_AES_CBC, 508 .block_size = 16, 509 .key_size = { 510 .min = 16, 511 .max = 32, 512 .increment = 8 513 }, 514 .iv_size = { 515 .min = 16, 516 .max = 16, 517 .increment = 0 518 } 519 } 520 } 521 } 522 } 523 524Below is an example of the capabilities for a PMD which supports the DOCSIS 525protocol. 526 527.. code-block:: c 528 529 static const struct rte_security_capability pmd_security_capabilities[] = { 530 { /* DOCSIS Uplink */ 531 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 532 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 533 .docsis = { 534 .direction = RTE_SECURITY_DOCSIS_UPLINK 535 }, 536 .crypto_capabilities = pmd_capabilities 537 }, 538 { /* DOCSIS Downlink */ 539 .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 540 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 541 .docsis = { 542 .direction = RTE_SECURITY_DOCSIS_DOWNLINK 543 }, 544 .crypto_capabilities = pmd_capabilities 545 }, 546 { 547 .action = RTE_SECURITY_ACTION_TYPE_NONE 548 } 549 }; 550 static const struct rte_cryptodev_capabilities pmd_capabilities[] = { 551 { /* AES DOCSIS BPI */ 552 .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 553 .sym = { 554 .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 555 .cipher = { 556 .algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI, 557 .block_size = 16, 558 .key_size = { 559 .min = 16, 560 .max = 32, 561 .increment = 16 562 }, 563 .iv_size = { 564 .min = 16, 565 .max = 16, 566 .increment = 0 567 } 568 } 569 } 570 }, 571 572 RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() 573 }; 574 575Below is the example PMD capability for MACsec 576 577.. code-block:: c 578 579 static const struct rte_security_capability pmd_security_capabilities[] = { 580 { 581 .action = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL, 582 .protocol = RTE_SECURITY_PROTOCOL_MACSEC, 583 .macsec = { 584 .mtu = 1500, 585 .alg = RTE_SECURITY_MACSEC_ALG_GCM_128, 586 .max_nb_sc = 64, 587 .max_nb_sa = 128, 588 .max_nb_sess = 64, 589 .replay_win_sz = 4096, 590 .relative_sectag_insert = 1, 591 .fixed_sectag_insert = 1, 592 .icv_include_da_sa = 1, 593 .ctrl_port_enable = 1, 594 .preserve_sectag = 1, 595 .preserve_icv = 1, 596 .validate_frames = 1, 597 .re_key = 1, 598 .anti_replay = 1, 599 }, 600 .crypto_capabilities = NULL, 601 }, 602 }; 603 604Capabilities Discovery 605~~~~~~~~~~~~~~~~~~~~~~ 606 607Discovering the features and capabilities of a driver (crypto/ethernet) 608is achieved through the ``rte_security_capabilities_get()`` function. 609 610.. code-block:: c 611 612 const struct rte_security_capability *rte_security_capabilities_get(uint16_t id); 613 614This allows the user to query a specific driver and get all device 615security capabilities. It returns an array of ``rte_security_capability`` structures 616which contains all the capabilities for that device. 617 618Security Session Create/Free 619~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 620 621Security Sessions are created to store the immutable fields of a particular Security 622Association for a particular protocol which is defined by a security session 623configuration structure which is used in the operation processing of a packet flow. 624Sessions are used to manage protocol specific information as well as crypto parameters. 625Security sessions cache this immutable data in a optimal way for the underlying PMD 626and this allows further acceleration of the offload of Crypto workloads. 627 628The Security framework provides APIs to create and free sessions for crypto/ethernet 629devices, where sessions are mempool objects. It is the application's responsibility 630to create and manage two session mempools - one for session and other for session 631private data. The private session data mempool object size should be able to 632accommodate the driver's private data of security session. The application can get 633the size of session private data using API ``rte_security_session_get_size``. 634And the session mempool object size should be enough to accommodate 635``rte_security_session``. 636 637Once the session mempools have been created, ``rte_security_session_create()`` 638is used to allocate and initialize a session for the required crypto/ethernet device. 639 640Session APIs need a parameter ``rte_security_ctx`` to identify the crypto/ethernet 641security ops. This parameter can be retrieved using the APIs 642``rte_cryptodev_get_sec_ctx()`` (for crypto device) or ``rte_eth_dev_get_sec_ctx`` 643(for ethernet port). 644 645Sessions already created can be updated with ``rte_security_session_update()``. 646 647When a session is no longer used, the user must call ``rte_security_session_destroy()`` 648to free the driver private session data and return the memory back to the mempool. 649 650For look aside protocol offload to hardware crypto device, the ``rte_crypto_op`` 651created by the application is attached to the security session by the API 652``rte_security_attach_session()``. 653 654For Inline Crypto and Inline protocol offload, device specific defined metadata is 655updated in the mbuf using ``rte_security_set_pkt_metadata()`` if 656``RTE_ETH_TX_OFFLOAD_SEC_NEED_MDATA`` is set. 657 658.. note:: 659 660 In case of inline processed packets, ``RTE_SECURITY_DYNFIELD_NAME`` field 661 would be used by the driver to relay information on the security processing 662 associated with the packet. In ingress, the driver would set this in Rx 663 path while in egress, ``rte_security_set_pkt_metadata()`` would perform a 664 similar operation. The application is expected not to modify the field 665 when it has relevant info. For ingress, this device-specific 64 bit value 666 is required to derive other information (like userdata), required for 667 identifying the security processing done on the packet. 668 669Security session configuration 670~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 671 672Security Session configuration structure is defined as ``rte_security_session_conf`` 673 674.. literalinclude:: ../../../lib/security/rte_security.h 675 :language: c 676 :start-after: Structure rte_security_session_conf 8< 677 :end-before: >8 End of structure rte_security_session_conf. 678 679The configuration structure reuses the ``rte_crypto_sym_xform`` struct for crypto related 680configuration. The ``rte_security_session_action_type`` struct is used to specify whether the 681session is configured for Lookaside Protocol offload or Inline Crypto or Inline Protocol 682Offload. 683 684.. literalinclude:: ../../../lib/security/rte_security.h 685 :language: c 686 :start-after: Enumeration of rte_security_session_action_type 8< 687 :end-before: >8 End enumeration of rte_security_session_action_type. 688 689The ``rte_security_session_protocol`` is defined as 690 691.. literalinclude:: ../../../lib/security/rte_security.h 692 :language: c 693 :start-after: Enumeration of rte_security_session_protocol 8< 694 :end-before: >8 End enumeration of rte_security_session_protocol. 695 696IPsec related configuration parameters are defined in ``rte_security_ipsec_xform`` 697 698MACsec related configuration parameters are defined in ``rte_security_macsec_xform`` 699 700PDCP related configuration parameters are defined in ``rte_security_pdcp_xform`` 701 702DOCSIS related configuration parameters are defined in ``rte_security_docsis_xform`` 703 704 705Security API 706~~~~~~~~~~~~ 707 708The rte_security Library API is described in the *DPDK API Reference* document. 709 710Flow based Security Session 711~~~~~~~~~~~~~~~~~~~~~~~~~~~ 712 713In the case of NIC based offloads, the security session specified in the 714'rte_flow_action_security' must be created on the same port as the 715flow action that is being specified. 716 717The ingress/egress flow attribute should match that specified in the security 718session if the security session supports the definition of the direction. 719 720Multiple flows can be configured to use the same security session. For 721example if the security session specifies an egress IPsec/MACsec SA, then multiple 722flows can be specified to that SA. In the case of an ingress IPsec SA then 723it is only valid to have a single flow to map to that security session. 724 725.. code-block:: console 726 727 Configuration Path 728 | 729 +--------|--------+ 730 | Add/Remove | 731 | IPsec/MACsec SA | <------ Build security flow action of 732 | | | IPsec/MACsec transform 733 |--------|--------| 734 | 735 +--------V--------+ 736 | Flow API | 737 +--------|--------+ 738 | 739 +--------V--------+ 740 | | 741 | NIC PMD | <------ Add/Remove SA to/from hw context 742 | | 743 +--------|--------+ 744 | 745 +--------|--------+ 746 | HW ACCELERATED | 747 | NIC | 748 | | 749 +--------|--------+ 750 751* Add/Delete IPsec SA flow: 752 To add a new inline SA construct a rte_flow_item for Ethernet + IP + ESP 753 using the SA selectors and the ``rte_security_ipsec_xform`` as the ``rte_flow_action``. 754 Note that any rte_flow_items may be empty, which means it is not checked. 755 756.. code-block:: console 757 758 In its most basic form, IPsec flow specification is as follows: 759 +-------+ +----------+ +--------+ +-----+ 760 | Eth | -> | IP4/6 | -> | ESP | -> | END | 761 +-------+ +----------+ +--------+ +-----+ 762 763 However, the API can represent, IPsec crypto offload with any encapsulation: 764 +-------+ +--------+ +-----+ 765 | Eth | -> ... -> | ESP | -> | END | 766 +-------+ +--------+ +-----+ 767 768* Add/Delete MACsec SA flow: 769 To add a new inline SA construct a rte_flow_item for Ethernet + SecTAG 770 using the SA selectors and the ``rte_security_macsec_xform`` as the ``rte_flow_action``. 771 Note that any rte_flow_items may be empty, which means it is not checked. 772 773.. code-block:: console 774 775 In its most basic form, MACsec flow specification is as follows: 776 +-------+ +----------+ +-----+ 777 | Eth | -> | SecTag | -> | END | 778 +-------+ +----------+ +-----+ 779 780 However, the API can represent, MACsec offload with any encapsulation: 781 +-------+ +--------+ +-----+ 782 | Eth | -> ... -> | SecTag | -> | END | 783 +-------+ +--------+ +-----+ 784 785 786Telemetry support 787----------------- 788 789The Security library has support for displaying Crypto device information 790with respect to its Security capabilities. Telemetry commands that can be used 791are shown below. 792 793#. Get the list of available Crypto devices by ID, that supports Security features:: 794 795 --> /security/cryptodev/list 796 {"/security/cryptodev/list": [0, 1, 2, 3]} 797 798#. Get the security capabilities of a Crypto device:: 799 800 --> /security/cryptodev/sec_caps,0 801 {"/security/cryptodev/sec_caps": {"sec_caps": [<array of serialized bytes of 802 capabilities>], "sec_caps_n": <number of capabilities>}} 803 804 #. Get the security crypto capabilities of a Crypto device:: 805 806 --> /security/cryptodev/crypto_caps,0,0 807 {"/security/cryptodev/crypto_caps": {"crypto_caps": [<array of serialized bytes of 808 capabilities>], "crypto_caps_n": <number of capabilities>}} 809 810For more information on how to use the Telemetry interface, see 811the :doc:`../howto/telemetry`. 812