1d81734caSHemant Agrawal.. SPDX-License-Identifier: BSD-3-Clause 2864c1a40SHemant Agrawal Copyright 2017,2020-2021 NXP 340ff8c99SAkhil Goyal 440ff8c99SAkhil GoyalSecurity Library 540ff8c99SAkhil Goyal================ 640ff8c99SAkhil Goyal 740ff8c99SAkhil GoyalThe security library provides a framework for management and provisioning 840ff8c99SAkhil Goyalof security protocol operations offloaded to hardware based devices. The 940ff8c99SAkhil Goyallibrary defines generic APIs to create and free security sessions which can 1040ff8c99SAkhil Goyalsupport full protocol offload as well as inline crypto operation with 11*8711af29SNandini PersadNIC or crypto devices. 12*8711af29SNandini Persad 13*8711af29SNandini PersadThe security protocols are discussed in the :doc:`../howto/security` guide. 1440ff8c99SAkhil Goyal 1540ff8c99SAkhil GoyalDesign Principles 1640ff8c99SAkhil Goyal----------------- 1740ff8c99SAkhil Goyal 1840ff8c99SAkhil GoyalThe security library provides an additional offload capability to an existing 1940ff8c99SAkhil Goyalcrypto device and/or ethernet device. 2040ff8c99SAkhil Goyal 2140ff8c99SAkhil Goyal.. code-block:: console 2240ff8c99SAkhil Goyal 2340ff8c99SAkhil Goyal +---------------+ 2440ff8c99SAkhil Goyal | rte_security | 2540ff8c99SAkhil Goyal +---------------+ 2640ff8c99SAkhil Goyal \ / 2740ff8c99SAkhil Goyal +-----------+ +--------------+ 2840ff8c99SAkhil Goyal | NIC PMD | | CRYPTO PMD | 2940ff8c99SAkhil Goyal +-----------+ +--------------+ 3040ff8c99SAkhil Goyal 3140ff8c99SAkhil Goyal.. note:: 3240ff8c99SAkhil Goyal 3340ff8c99SAkhil Goyal Currently, the security library does not support the case of multi-process. 3440ff8c99SAkhil Goyal It will be updated in the future releases. 3540ff8c99SAkhil Goyal 3640ff8c99SAkhil GoyalThe supported offload types are explained in the sections below. 3740ff8c99SAkhil Goyal 3840ff8c99SAkhil GoyalInline Crypto 3940ff8c99SAkhil Goyal~~~~~~~~~~~~~ 4040ff8c99SAkhil Goyal 4140ff8c99SAkhil GoyalRTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO: 42d629b7b5SJohn McNamaraThe crypto processing for security protocol (e.g. IPsec) is processed 4340ff8c99SAkhil Goyalinline during receive and transmission on NIC port. The flow based 4440ff8c99SAkhil Goyalsecurity action should be configured on the port. 4540ff8c99SAkhil Goyal 4640ff8c99SAkhil GoyalIngress Data path - The packet is decrypted in RX path and relevant 4740ff8c99SAkhil Goyalcrypto status is set in Rx descriptors. After the successful inline 4840ff8c99SAkhil Goyalcrypto processing the packet is presented to host as a regular Rx packet 4940ff8c99SAkhil Goyalhowever all security protocol related headers are still attached to the 50d629b7b5SJohn McNamarapacket. e.g. In case of IPsec, the IPsec tunnel headers (if any), 5140ff8c99SAkhil GoyalESP/AH headers will remain in the packet but the received packet 5240ff8c99SAkhil Goyalcontains the decrypted data where the encrypted data was when the packet 53f43d3dbbSDavid Marchandarrived. The driver Rx path check the descriptors and based on the 5440ff8c99SAkhil Goyalcrypto status sets additional flags in the rte_mbuf.ol_flags field. 5540ff8c99SAkhil Goyal 5640ff8c99SAkhil Goyal.. note:: 5740ff8c99SAkhil Goyal 5840ff8c99SAkhil Goyal The underlying device may not support crypto processing for all ingress packet 5940ff8c99SAkhil Goyal matching to a particular flow (e.g. fragmented packets), such packets will 6040ff8c99SAkhil Goyal be passed as encrypted packets. It is the responsibility of application to 6140ff8c99SAkhil Goyal process such encrypted packets using other crypto driver instance. 6240ff8c99SAkhil Goyal 6340ff8c99SAkhil GoyalEgress Data path - The software prepares the egress packet by adding 6440ff8c99SAkhil Goyalrelevant security protocol headers. Only the data will not be 6540ff8c99SAkhil Goyalencrypted by the software. The driver will accordingly configure the 6640ff8c99SAkhil Goyaltx descriptors. The hardware device will encrypt the data before sending the 67f43d3dbbSDavid Marchandpacket out. 6840ff8c99SAkhil Goyal 6940ff8c99SAkhil Goyal.. note:: 7040ff8c99SAkhil Goyal 7140ff8c99SAkhil Goyal The underlying device may support post encryption TSO. 7240ff8c99SAkhil Goyal 7340ff8c99SAkhil Goyal.. code-block:: console 7440ff8c99SAkhil Goyal 7540ff8c99SAkhil Goyal Egress Data Path 7640ff8c99SAkhil Goyal | 7740ff8c99SAkhil Goyal +--------|--------+ 7840ff8c99SAkhil Goyal | egress IPsec | 7940ff8c99SAkhil Goyal | | | 8040ff8c99SAkhil Goyal | +------V------+ | 8140ff8c99SAkhil Goyal | | SADB lookup | | 8240ff8c99SAkhil Goyal | +------|------+ | 8340ff8c99SAkhil Goyal | +------V------+ | 8440ff8c99SAkhil Goyal | | Tunnel | | <------ Add tunnel header to packet 8540ff8c99SAkhil Goyal | +------|------+ | 8640ff8c99SAkhil Goyal | +------V------+ | 8740ff8c99SAkhil Goyal | | ESP | | <------ Add ESP header without trailer to packet 8840ff8c99SAkhil Goyal | | | | <------ Mark packet to be offloaded, add trailer 8940ff8c99SAkhil Goyal | +------|------+ | meta-data to mbuf 9040ff8c99SAkhil Goyal +--------V--------+ 9140ff8c99SAkhil Goyal | 9240ff8c99SAkhil Goyal +--------V--------+ 9340ff8c99SAkhil Goyal | L2 Stack | 9440ff8c99SAkhil Goyal +--------|--------+ 9540ff8c99SAkhil Goyal | 9640ff8c99SAkhil Goyal +--------V--------+ 9740ff8c99SAkhil Goyal | | 9840ff8c99SAkhil Goyal | NIC PMD | <------ Set hw context for inline crypto offload 9940ff8c99SAkhil Goyal | | 10040ff8c99SAkhil Goyal +--------|--------+ 10140ff8c99SAkhil Goyal | 10240ff8c99SAkhil Goyal +--------|--------+ 10340ff8c99SAkhil Goyal | HW ACCELERATED | <------ Packet Encryption and 10440ff8c99SAkhil Goyal | NIC | Authentication happens inline 10540ff8c99SAkhil Goyal | | 10640ff8c99SAkhil Goyal +-----------------+ 10740ff8c99SAkhil Goyal 10840ff8c99SAkhil Goyal 10940ff8c99SAkhil GoyalInline protocol offload 11040ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~~ 11140ff8c99SAkhil Goyal 11240ff8c99SAkhil GoyalRTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL: 113d629b7b5SJohn McNamaraThe crypto and protocol processing for security protocol (e.g. IPsec) 11440ff8c99SAkhil Goyalis processed inline during receive and transmission. The flow based 11540ff8c99SAkhil Goyalsecurity action should be configured on the port. 11640ff8c99SAkhil Goyal 11740ff8c99SAkhil GoyalIngress Data path - The packet is decrypted in the RX path and relevant 11840ff8c99SAkhil Goyalcrypto status is set in the Rx descriptors. After the successful inline 11940ff8c99SAkhil Goyalcrypto processing the packet is presented to the host as a regular Rx packet 12040ff8c99SAkhil Goyalbut all security protocol related headers are optionally removed from the 121d629b7b5SJohn McNamarapacket. e.g. in the case of IPsec, the IPsec tunnel headers (if any), 12240ff8c99SAkhil GoyalESP/AH headers will be removed from the packet and the received packet 12340ff8c99SAkhil Goyalwill contains the decrypted packet only. The driver Rx path checks the 12440ff8c99SAkhil Goyaldescriptors and based on the crypto status sets additional flags in 1251a08c379SAnoob Joseph``rte_mbuf.ol_flags`` field. The driver would also set device-specific 126614af754SThomas Monjalonmetadata in ``RTE_SECURITY_DYNFIELD_NAME`` field. 127614af754SThomas MonjalonThis will allow the application to identify the security processing 128614af754SThomas Monjalondone on the packet. 12940ff8c99SAkhil Goyal 13040ff8c99SAkhil Goyal.. note:: 13140ff8c99SAkhil Goyal 13240ff8c99SAkhil Goyal The underlying device in this case is stateful. It is expected that 13340ff8c99SAkhil Goyal the device shall support crypto processing for all kind of packets matching 13440ff8c99SAkhil Goyal to a given flow, this includes fragmented packets (post reassembly). 135d629b7b5SJohn McNamara E.g. in case of IPsec the device may internally manage anti-replay etc. 13640ff8c99SAkhil Goyal It will provide a configuration option for anti-replay behavior i.e. to drop 13740ff8c99SAkhil Goyal the packets or pass them to driver with error flags set in the descriptor. 13840ff8c99SAkhil Goyal 13940ff8c99SAkhil GoyalEgress Data path - The software will send the plain packet without any 14040ff8c99SAkhil Goyalsecurity protocol headers added to the packet. The driver will configure 14140ff8c99SAkhil Goyalthe security index and other requirement in tx descriptors. 14240ff8c99SAkhil GoyalThe hardware device will do security processing on the packet that includes 14340ff8c99SAkhil Goyaladding the relevant protocol headers and encrypting the data before sending 14440ff8c99SAkhil Goyalthe packet out. The software should make sure that the buffer 14540ff8c99SAkhil Goyalhas required head room and tail room for any protocol header addition. The 14640ff8c99SAkhil Goyalsoftware may also do early fragmentation if the resultant packet is expected 147dcee1520SNithin Dabilpuramto cross the MTU size. The software should also make sure that L2 header contents 148dcee1520SNithin Dabilpuramare updated with the final L2 header which is expected post IPsec processing as 149dcee1520SNithin Dabilpuramthe IPsec offload will only update L3 and above in egress path. 15040ff8c99SAkhil Goyal 15140ff8c99SAkhil Goyal 15240ff8c99SAkhil Goyal.. note:: 15340ff8c99SAkhil Goyal 15440ff8c99SAkhil Goyal The underlying device will manage state information required for egress 155d629b7b5SJohn McNamara processing. E.g. in case of IPsec, the seq number will be added to the 15640ff8c99SAkhil Goyal packet, however the device shall provide indication when the sequence number 15740ff8c99SAkhil Goyal is about to overflow. The underlying device may support post encryption TSO. 15840ff8c99SAkhil Goyal 15940ff8c99SAkhil Goyal.. code-block:: console 16040ff8c99SAkhil Goyal 16140ff8c99SAkhil Goyal Egress Data Path 16240ff8c99SAkhil Goyal | 16340ff8c99SAkhil Goyal +--------|--------+ 16440ff8c99SAkhil Goyal | egress IPsec | 16540ff8c99SAkhil Goyal | | | 16640ff8c99SAkhil Goyal | +------V------+ | 16740ff8c99SAkhil Goyal | | SADB lookup | | 16840ff8c99SAkhil Goyal | +------|------+ | 16940ff8c99SAkhil Goyal | +------V------+ | 17040ff8c99SAkhil Goyal | | Desc | | <------ Mark packet to be offloaded 17140ff8c99SAkhil Goyal | +------|------+ | 17240ff8c99SAkhil Goyal +--------V--------+ 17340ff8c99SAkhil Goyal | 17440ff8c99SAkhil Goyal +--------V--------+ 17540ff8c99SAkhil Goyal | L2 Stack | 17640ff8c99SAkhil Goyal +--------|--------+ 17740ff8c99SAkhil Goyal | 17840ff8c99SAkhil Goyal +--------V--------+ 17940ff8c99SAkhil Goyal | | 18040ff8c99SAkhil Goyal | NIC PMD | <------ Set hw context for inline crypto offload 18140ff8c99SAkhil Goyal | | 18240ff8c99SAkhil Goyal +--------|--------+ 18340ff8c99SAkhil Goyal | 18440ff8c99SAkhil Goyal +--------|--------+ 18540ff8c99SAkhil Goyal | HW ACCELERATED | <------ Add tunnel, ESP header etc header to 18640ff8c99SAkhil Goyal | NIC | packet. Packet Encryption and 18740ff8c99SAkhil Goyal | | Authentication happens inline. 18840ff8c99SAkhil Goyal +-----------------+ 18940ff8c99SAkhil Goyal 19040ff8c99SAkhil Goyal 19140ff8c99SAkhil GoyalLookaside protocol offload 19240ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~~~~~ 19340ff8c99SAkhil Goyal 19440ff8c99SAkhil GoyalRTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL: 19540ff8c99SAkhil GoyalThis extends librte_cryptodev to support the programming of IPsec 19640ff8c99SAkhil GoyalSecurity Association (SA) as part of a crypto session creation including 19740ff8c99SAkhil Goyalthe definition. In addition to standard crypto processing, as defined by 19840ff8c99SAkhil Goyalthe cryptodev, the security protocol processing is also offloaded to the 19940ff8c99SAkhil Goyalcrypto device. 20040ff8c99SAkhil Goyal 20140ff8c99SAkhil GoyalDecryption: The packet is sent to the crypto device for security 20240ff8c99SAkhil Goyalprotocol processing. The device will decrypt the packet and it will also 20340ff8c99SAkhil Goyaloptionally remove additional security headers from the packet. 204d629b7b5SJohn McNamaraE.g. in case of IPsec, IPsec tunnel headers (if any), ESP/AH headers 20540ff8c99SAkhil Goyalwill be removed from the packet and the decrypted packet may contain 20640ff8c99SAkhil Goyalplain data only. 20740ff8c99SAkhil Goyal 20840ff8c99SAkhil Goyal.. note:: 20940ff8c99SAkhil Goyal 210d629b7b5SJohn McNamara In case of IPsec the device may internally manage anti-replay etc. 21140ff8c99SAkhil Goyal It will provide a configuration option for anti-replay behavior i.e. to drop 21240ff8c99SAkhil Goyal the packets or pass them to driver with error flags set in descriptor. 21340ff8c99SAkhil Goyal 21440ff8c99SAkhil GoyalEncryption: The software will submit the packet to cryptodev as usual 21540ff8c99SAkhil Goyalfor encryption, the hardware device in this case will also add the relevant 21640ff8c99SAkhil Goyalsecurity protocol header along with encrypting the packet. The software 21740ff8c99SAkhil Goyalshould make sure that the buffer has required head room and tail room 21840ff8c99SAkhil Goyalfor any protocol header addition. 21940ff8c99SAkhil Goyal 22040ff8c99SAkhil Goyal.. note:: 22140ff8c99SAkhil Goyal 222d629b7b5SJohn McNamara In the case of IPsec, the seq number will be added to the packet, 22340ff8c99SAkhil Goyal It shall provide an indication when the sequence number is about to 22440ff8c99SAkhil Goyal overflow. 22540ff8c99SAkhil Goyal 22640ff8c99SAkhil Goyal.. code-block:: console 22740ff8c99SAkhil Goyal 22840ff8c99SAkhil Goyal Egress Data Path 22940ff8c99SAkhil Goyal | 23040ff8c99SAkhil Goyal +--------|--------+ 23140ff8c99SAkhil Goyal | egress IPsec | 23240ff8c99SAkhil Goyal | | | 23340ff8c99SAkhil Goyal | +------V------+ | 23440ff8c99SAkhil Goyal | | SADB lookup | | <------ SA maps to cryptodev session 23540ff8c99SAkhil Goyal | +------|------+ | 23640ff8c99SAkhil Goyal | +------|------+ | 23740ff8c99SAkhil Goyal | | \--------------------\ 23840ff8c99SAkhil Goyal | | Crypto | | | <- Crypto processing through 23940ff8c99SAkhil Goyal | | /----------------\ | inline crypto PMD 24040ff8c99SAkhil Goyal | +------|------+ | | | 24140ff8c99SAkhil Goyal +--------V--------+ | | 24240ff8c99SAkhil Goyal | | | 24340ff8c99SAkhil Goyal +--------V--------+ | | create <-- SA is added to hw 24440ff8c99SAkhil Goyal | L2 Stack | | | inline using existing create 24540ff8c99SAkhil Goyal +--------|--------+ | | session sym session APIs 24640ff8c99SAkhil Goyal | | | | 24740ff8c99SAkhil Goyal +--------V--------+ +---|---|----V---+ 24840ff8c99SAkhil Goyal | | | \---/ | | <--- Add tunnel, ESP header etc 24940ff8c99SAkhil Goyal | NIC PMD | | INLINE | | header to packet.Packet 25040ff8c99SAkhil Goyal | | | CRYPTO PMD | | Encryption/Decryption and 25140ff8c99SAkhil Goyal +--------|--------+ +----------------+ Authentication happens 25240ff8c99SAkhil Goyal | inline. 25340ff8c99SAkhil Goyal +--------|--------+ 25440ff8c99SAkhil Goyal | NIC | 25540ff8c99SAkhil Goyal +--------|--------+ 25640ff8c99SAkhil Goyal V 25740ff8c99SAkhil Goyal 2588b593b8cSAkhil GoyalPDCP Flow Diagram 2598b593b8cSAkhil Goyal~~~~~~~~~~~~~~~~~ 2608b593b8cSAkhil Goyal 2618b593b8cSAkhil GoyalBased on 3GPP TS 36.323 Evolved Universal Terrestrial Radio Access (E-UTRA); 2628b593b8cSAkhil GoyalPacket Data Convergence Protocol (PDCP) specification 2638b593b8cSAkhil Goyal 2648b593b8cSAkhil Goyal.. code-block:: c 2658b593b8cSAkhil Goyal 2668b593b8cSAkhil Goyal Transmitting PDCP Entity Receiving PDCP Entity 2678b593b8cSAkhil Goyal | ^ 2688b593b8cSAkhil Goyal | +-----------|-----------+ 2698b593b8cSAkhil Goyal V | In order delivery and | 2708b593b8cSAkhil Goyal +---------|----------+ | Duplicate detection | 2718b593b8cSAkhil Goyal | Sequence Numbering | | (Data Plane only) | 2728b593b8cSAkhil Goyal +---------|----------+ +-----------|-----------+ 2738b593b8cSAkhil Goyal | | 2748b593b8cSAkhil Goyal +---------|----------+ +-----------|----------+ 2758b593b8cSAkhil Goyal | Header Compression*| | Header Decompression*| 2768b593b8cSAkhil Goyal | (Data-Plane only) | | (Data Plane only) | 2778b593b8cSAkhil Goyal +---------|----------+ +-----------|----------+ 2788b593b8cSAkhil Goyal | | 2798b593b8cSAkhil Goyal +---------|-----------+ +-----------|----------+ 2808b593b8cSAkhil Goyal | Integrity Protection| |Integrity Verification| 2818b593b8cSAkhil Goyal | (Control Plane only)| | (Control Plane only) | 2828b593b8cSAkhil Goyal +---------|-----------+ +-----------|----------+ 2838b593b8cSAkhil Goyal +---------|-----------+ +----------|----------+ 2848b593b8cSAkhil Goyal | Ciphering | | Deciphering | 2858b593b8cSAkhil Goyal +---------|-----------+ +----------|----------+ 2868b593b8cSAkhil Goyal +---------|-----------+ +----------|----------+ 2878b593b8cSAkhil Goyal | Add PDCP header | | Remove PDCP Header | 2888b593b8cSAkhil Goyal +---------|-----------+ +----------|----------+ 2898b593b8cSAkhil Goyal | | 2908b593b8cSAkhil Goyal +----------------->>----------------+ 2918b593b8cSAkhil Goyal 2928b593b8cSAkhil Goyal 2938b593b8cSAkhil Goyal.. note:: 2948b593b8cSAkhil Goyal 2958b593b8cSAkhil Goyal * Header Compression and decompression are not supported currently. 2968b593b8cSAkhil Goyal 2978b593b8cSAkhil GoyalJust like IPsec, in case of PDCP also header addition/deletion, cipher/ 2988b593b8cSAkhil Goyalde-cipher, integrity protection/verification is done based on the action 2998b593b8cSAkhil Goyaltype chosen. 3008b593b8cSAkhil Goyal 301e44b3fafSDavid CoyleDOCSIS Protocol 302e44b3fafSDavid Coyle~~~~~~~~~~~~~~~ 303e44b3fafSDavid Coyle 304e44b3fafSDavid CoyleThe Data Over Cable Service Interface Specification (DOCSIS) support comprises 305e44b3fafSDavid Coylethe combination of encryption/decryption and CRC generation/verification, for 306e44b3fafSDavid Coyleuse in a DOCSIS-MAC pipeline. 307e44b3fafSDavid Coyle 308e44b3fafSDavid Coyle.. code-block:: c 309e44b3fafSDavid Coyle 310e44b3fafSDavid Coyle 311e44b3fafSDavid Coyle Downlink Uplink 312e44b3fafSDavid Coyle -------- ------ 313e44b3fafSDavid Coyle 314e44b3fafSDavid Coyle Ethernet frame Ethernet frame 315e44b3fafSDavid Coyle from core network to core network 316e44b3fafSDavid Coyle | ^ 317e44b3fafSDavid Coyle ~ | 318e44b3fafSDavid Coyle | ~ ----+ 319e44b3fafSDavid Coyle V | | 320e44b3fafSDavid Coyle +---------|----------+ +----------|---------+ | 321e44b3fafSDavid Coyle | CRC generation | | CRC verification | | 322e44b3fafSDavid Coyle +---------|----------+ +----------|---------+ | combined 323e44b3fafSDavid Coyle | | > Crypto + CRC 324e44b3fafSDavid Coyle +---------|----------+ +----------|---------+ | 325e44b3fafSDavid Coyle | Encryption | | Decryption | | 326e44b3fafSDavid Coyle +---------|----------+ +----------|---------+ | 327e44b3fafSDavid Coyle | ^ | 328e44b3fafSDavid Coyle ~ | ----+ 329e44b3fafSDavid Coyle | ~ 330e44b3fafSDavid Coyle V | 331e44b3fafSDavid Coyle DOCSIS frame DOCSIS frame 332e44b3fafSDavid Coyle to Cable Modem from Cable Modem 333e44b3fafSDavid Coyle 334e44b3fafSDavid CoyleThe encryption/decryption is a combination of CBC and CFB modes using either AES 335e44b3fafSDavid Coyleor DES algorithms as specified in the DOCSIS Security Specification (from DPDK 336e44b3fafSDavid Coylelib_rtecryptodev perspective, these are RTE_CRYPTO_CIPHER_AES_DOCSISBPI and 337e44b3fafSDavid CoyleRTE_CRYPTO_CIPHER_DES_DOCSISBPI). 338e44b3fafSDavid Coyle 339e44b3fafSDavid CoyleThe CRC is Ethernet CRC-32 as specified in Ethernet/[ISO/IEC 8802-3]. 340e44b3fafSDavid Coyle 341e44b3fafSDavid Coyle.. note:: 342e44b3fafSDavid Coyle 343e44b3fafSDavid Coyle * The offset and length of data for which CRC needs to be computed are 344e44b3fafSDavid Coyle specified via the auth offset and length fields of the rte_crypto_sym_op. 345e44b3fafSDavid Coyle * Other DOCSIS protocol functionality such as Header Checksum (HCS) 346e44b3fafSDavid Coyle calculation may be added in the future. 347e44b3fafSDavid Coyle 348bbbe6c59SAkhil GoyalMACSEC Protocol 349bbbe6c59SAkhil Goyal~~~~~~~~~~~~~~~ 350bbbe6c59SAkhil Goyal 351bbbe6c59SAkhil GoyalMedia Access Control security (MACsec) provides point-to-point security 352bbbe6c59SAkhil Goyalon Ethernet links and is defined by IEEE standard 802.1AE. 353bbbe6c59SAkhil GoyalMACsec secures an Ethernet link for almost all traffic, 354bbbe6c59SAkhil Goyalincluding frames from the Link Layer Discovery Protocol (LLDP), 355bbbe6c59SAkhil GoyalLink Aggregation Control Protocol (LACP), 356bbbe6c59SAkhil GoyalDynamic Host Configuration Protocol (DHCP), 357bbbe6c59SAkhil GoyalAddress Resolution Protocol (ARP), 358bbbe6c59SAkhil Goyaland other protocols that are not typically secured on an Ethernet link 359bbbe6c59SAkhil Goyalbecause of limitations with other security solutions. 360bbbe6c59SAkhil Goyal 361bbbe6c59SAkhil Goyal.. code-block:: c 362bbbe6c59SAkhil Goyal 363bbbe6c59SAkhil Goyal Receive Transmit 364bbbe6c59SAkhil Goyal ------- -------- 365bbbe6c59SAkhil Goyal 366bbbe6c59SAkhil Goyal Ethernet frame Ethernet frame 367bbbe6c59SAkhil Goyal from network towards network 368bbbe6c59SAkhil Goyal | ^ 369bbbe6c59SAkhil Goyal ~ | 370bbbe6c59SAkhil Goyal | ~ 371bbbe6c59SAkhil Goyal V | 372bbbe6c59SAkhil Goyal +-----------------------+ +------------------+ +-------------------------+ 373bbbe6c59SAkhil Goyal | Secure Frame Verify | | Cipher Suite(SA) | | Secure Frame Generation | 374bbbe6c59SAkhil Goyal +-----------------------+<-----+------------------+----->+-------------------------+ 375bbbe6c59SAkhil Goyal | SecTAG + ICV remove | | SECY | SC | | SecTAG + ICV Added | 376bbbe6c59SAkhil Goyal +---+-------------------+ +------------------+ +-------------------------+ 377bbbe6c59SAkhil Goyal | ^ 378bbbe6c59SAkhil Goyal | | 379bbbe6c59SAkhil Goyal V | 380bbbe6c59SAkhil Goyal Packet to Core/App Packet from Core/App 381bbbe6c59SAkhil Goyal 382bbbe6c59SAkhil Goyal 383bbbe6c59SAkhil Goyal 384bbbe6c59SAkhil GoyalTo configure MACsec on an inline NIC device or a lookaside crypto device, 385bbbe6c59SAkhil Goyala security association (SA) and a secure channel (SC) are created 386bbbe6c59SAkhil Goyalbefore creating rte_security session. 387bbbe6c59SAkhil Goyal 388bbbe6c59SAkhil GoyalSA is created using API ``rte_security_macsec_sa_create`` 389bbbe6c59SAkhil Goyalwhich allows setting SA keys, salt, SSCI, packet number (PN) into the PMD, 390bbbe6c59SAkhil Goyaland the API returns a handle which can be used to map it with a secure channel, 391bbbe6c59SAkhil Goyalusing the API ``rte_security_macsec_sc_create``. 392bbbe6c59SAkhil GoyalSame SAs can be used for multiple SCs. 393bbbe6c59SAkhil GoyalThe Rx SC will need a set of 4 SAs for each of the association numbers (AN). 394bbbe6c59SAkhil GoyalFor Tx SC a single SA is set which will be used by hardware to process the packet. 395bbbe6c59SAkhil Goyal 396bbbe6c59SAkhil GoyalThe API ``rte_security_macsec_sc_create`` returns a handle for SC, 397bbbe6c59SAkhil Goyaland this handle is set in ``rte_security_macsec_xform`` 398bbbe6c59SAkhil Goyalto create a MACsec session using ``rte_security_session_create``. 399bbbe6c59SAkhil Goyal 4007ebdf16aSAnoob JosephTLS-Record Protocol 4017ebdf16aSAnoob Joseph~~~~~~~~~~~~~~~~~~~ 4027ebdf16aSAnoob Joseph 4037ebdf16aSAnoob JosephThe Transport Layer Protocol provides communications security over the Internet. 4047ebdf16aSAnoob JosephThe protocol allows client/server applications to communicate in a way 4057ebdf16aSAnoob Josephthat is designed to prevent eavesdropping, tampering, or message forgery. 4067ebdf16aSAnoob Joseph 4077ebdf16aSAnoob JosephTLS protocol is composed of two layers: the TLS Record Protocol and the TLS Handshake Protocol. 4087ebdf16aSAnoob JosephAt the lowest level, layered on top of some reliable transport protocol (e.g., TCP), 4097ebdf16aSAnoob Josephis the TLS Record Protocol. 4107ebdf16aSAnoob JosephThe TLS Record Protocol provides connection security that has two basic properties: 4117ebdf16aSAnoob Joseph 4127ebdf16aSAnoob Joseph - The connection is private. 4137ebdf16aSAnoob Joseph Symmetric cryptography is used for data encryption (e.g., AES, DES, etc.). 4147ebdf16aSAnoob Joseph The keys for this symmetric encryption are generated uniquely 4157ebdf16aSAnoob Joseph for each connection and are based on a secret negotiated during TLS Handshake Protocol. 4167ebdf16aSAnoob Joseph The Record Protocol can also be used without encryption. 4177ebdf16aSAnoob Joseph 4187ebdf16aSAnoob Joseph - The connection is reliable. 4197ebdf16aSAnoob Joseph Message transport includes a message integrity check using a keyed MAC. 4207ebdf16aSAnoob Joseph Secure hash functions (e.g., SHA-1, etc.) are used for MAC computations. 4217ebdf16aSAnoob Joseph The Record Protocol can operate without a MAC when it is being used as a transport 4227ebdf16aSAnoob Joseph for negotiating security parameters by another protocol. 4237ebdf16aSAnoob Joseph 4247ebdf16aSAnoob Joseph.. code-block:: c 4257ebdf16aSAnoob Joseph 4267ebdf16aSAnoob Joseph Record Write Record Read 4277ebdf16aSAnoob Joseph ------------ ----------- 4287ebdf16aSAnoob Joseph 4297ebdf16aSAnoob Joseph TLSPlaintext TLSCiphertext 4307ebdf16aSAnoob Joseph | | 4317ebdf16aSAnoob Joseph ~ ~ 4327ebdf16aSAnoob Joseph | | 4337ebdf16aSAnoob Joseph V V 4347ebdf16aSAnoob Joseph +----------|-----------+ +----------|-----------+ 4357ebdf16aSAnoob Joseph | Generate sequence no.| | Generate sequence no.| 4367ebdf16aSAnoob Joseph +----------|-----------+ +----------------------+ 4377ebdf16aSAnoob Joseph | | AR check (DTLS) | 4387ebdf16aSAnoob Joseph +----------|-----------+ +----------|-----------+ 4397ebdf16aSAnoob Joseph | Insert TLS header | | 4407ebdf16aSAnoob Joseph | & trailer. | +----------|-----------+ 4417ebdf16aSAnoob Joseph | (including padding) | | Decrypt & MAC verify | 4427ebdf16aSAnoob Joseph +----------|-----------+ +----------|-----------+ 4437ebdf16aSAnoob Joseph | | 4447ebdf16aSAnoob Joseph +---------|-----------+ +----------|-----------+ 4457ebdf16aSAnoob Joseph | MAC generate & | | Remove TLS header | 4467ebdf16aSAnoob Joseph | Encrypt | | & trailer. | 4477ebdf16aSAnoob Joseph +---------|-----------+ | (including padding) | 4487ebdf16aSAnoob Joseph | +----------|-----------+ 4497ebdf16aSAnoob Joseph | | 4507ebdf16aSAnoob Joseph ~ ~ 4517ebdf16aSAnoob Joseph | | 4527ebdf16aSAnoob Joseph V V 4537ebdf16aSAnoob Joseph TLSCiphertext TLSPlaintext 4547ebdf16aSAnoob Joseph 455f306fabfSVidya Sagar VelumuriTLS and DTLS header formation (in record write operation) 456f306fabfSVidya Sagar Velumuriwould depend on type of content. 457f306fabfSVidya Sagar VelumuriIt is a per packet variable and would need to be handled by the same session. 458f306fabfSVidya Sagar VelumuriApplication may pass this info to a cryptodev performing lookaside protocol offload 459f306fabfSVidya Sagar Velumuriby passing the same in ``rte_crypto_op.param1``. 460f306fabfSVidya Sagar Velumuri 461f306fabfSVidya Sagar VelumuriIn record read operation, application is required to preserve any info 462f306fabfSVidya Sagar Velumuriit may need from the TLS/DTLS header (such as content type and sequence number) 463f306fabfSVidya Sagar Velumurias the cryptodev would remove the header and padding 464f306fabfSVidya Sagar Velumurias part of the lookaside protocol processing. 465f306fabfSVidya Sagar VelumuriWith TLS 1.3, the actual content type is part of the trailer (before padding) 466f306fabfSVidya Sagar Velumuriand would be stripped by the PMD. 467f306fabfSVidya Sagar VelumuriFor applications that may need this info, 468f306fabfSVidya Sagar VelumuriPMD would return the value in ``rte_crypto_op.param1`` field. 469f306fabfSVidya Sagar Velumuri 4707ebdf16aSAnoob JosephSupported Versions 4717ebdf16aSAnoob Joseph^^^^^^^^^^^^^^^^^^ 4727ebdf16aSAnoob Joseph 4737ebdf16aSAnoob Joseph* TLS 1.2 4747ebdf16aSAnoob Joseph* TLS 1.3 4757ebdf16aSAnoob Joseph* DTLS 1.2 476bbbe6c59SAkhil Goyal 47740ff8c99SAkhil GoyalDevice Features and Capabilities 47840ff8c99SAkhil Goyal--------------------------------- 47940ff8c99SAkhil Goyal 48040ff8c99SAkhil GoyalDevice Capabilities For Security Operations 48140ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 48240ff8c99SAkhil Goyal 48340ff8c99SAkhil GoyalThe device (crypto or ethernet) capabilities which support security operations, 48440ff8c99SAkhil Goyalare defined by the security action type, security protocol, protocol 48540ff8c99SAkhil Goyalcapabilities and corresponding crypto capabilities for security. For the full 48640ff8c99SAkhil Goyalscope of the Security capability see definition of rte_security_capability 48740ff8c99SAkhil Goyalstructure in the *DPDK API Reference*. 48840ff8c99SAkhil Goyal 48940ff8c99SAkhil Goyal.. code-block:: c 49040ff8c99SAkhil Goyal 49140ff8c99SAkhil Goyal struct rte_security_capability; 49240ff8c99SAkhil Goyal 49340ff8c99SAkhil GoyalEach driver (crypto or ethernet) defines its own private array of capabilities 49440ff8c99SAkhil Goyalfor the operations it supports. Below is an example of the capabilities for a 4958b593b8cSAkhil GoyalPMD which supports the IPsec and PDCP protocol. 49640ff8c99SAkhil Goyal 49740ff8c99SAkhil Goyal.. code-block:: c 49840ff8c99SAkhil Goyal 49940ff8c99SAkhil Goyal static const struct rte_security_capability pmd_security_capabilities[] = { 50040ff8c99SAkhil Goyal { /* IPsec Lookaside Protocol offload ESP Tunnel Egress */ 50140ff8c99SAkhil Goyal .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 50240ff8c99SAkhil Goyal .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 50340ff8c99SAkhil Goyal .ipsec = { 50440ff8c99SAkhil Goyal .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 50540ff8c99SAkhil Goyal .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 50640ff8c99SAkhil Goyal .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS, 50740ff8c99SAkhil Goyal .options = { 0 } 50840ff8c99SAkhil Goyal }, 50940ff8c99SAkhil Goyal .crypto_capabilities = pmd_capabilities 51040ff8c99SAkhil Goyal }, 51140ff8c99SAkhil Goyal { /* IPsec Lookaside Protocol offload ESP Tunnel Ingress */ 51240ff8c99SAkhil Goyal .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 51340ff8c99SAkhil Goyal .protocol = RTE_SECURITY_PROTOCOL_IPSEC, 51440ff8c99SAkhil Goyal .ipsec = { 51540ff8c99SAkhil Goyal .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, 51640ff8c99SAkhil Goyal .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL, 51740ff8c99SAkhil Goyal .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS, 51840ff8c99SAkhil Goyal .options = { 0 } 51940ff8c99SAkhil Goyal }, 52040ff8c99SAkhil Goyal .crypto_capabilities = pmd_capabilities 52140ff8c99SAkhil Goyal }, 5228b593b8cSAkhil Goyal { /* PDCP Lookaside Protocol offload Data Plane */ 5238b593b8cSAkhil Goyal .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 5248b593b8cSAkhil Goyal .protocol = RTE_SECURITY_PROTOCOL_PDCP, 5258b593b8cSAkhil Goyal .pdcp = { 5268b593b8cSAkhil Goyal .domain = RTE_SECURITY_PDCP_MODE_DATA, 5278b593b8cSAkhil Goyal .capa_flags = 0 5288b593b8cSAkhil Goyal }, 5298b593b8cSAkhil Goyal .crypto_capabilities = pmd_capabilities 5308b593b8cSAkhil Goyal }, 5318b593b8cSAkhil Goyal { /* PDCP Lookaside Protocol offload Control */ 5328b593b8cSAkhil Goyal .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 5338b593b8cSAkhil Goyal .protocol = RTE_SECURITY_PROTOCOL_PDCP, 5348b593b8cSAkhil Goyal .pdcp = { 5358b593b8cSAkhil Goyal .domain = RTE_SECURITY_PDCP_MODE_CONTROL, 5368b593b8cSAkhil Goyal .capa_flags = 0 5378b593b8cSAkhil Goyal }, 5388b593b8cSAkhil Goyal .crypto_capabilities = pmd_capabilities 5398b593b8cSAkhil Goyal }, 540864c1a40SHemant Agrawal { /* PDCP Lookaside Protocol offload short MAC-I */ 541864c1a40SHemant Agrawal .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 542864c1a40SHemant Agrawal .protocol = RTE_SECURITY_PROTOCOL_PDCP, 543864c1a40SHemant Agrawal .pdcp = { 544864c1a40SHemant Agrawal .domain = RTE_SECURITY_PDCP_MODE_SHORT_MAC, 545864c1a40SHemant Agrawal .capa_flags = 0 546864c1a40SHemant Agrawal }, 547864c1a40SHemant Agrawal .crypto_capabilities = pmd_capabilities 548864c1a40SHemant Agrawal }, 54940ff8c99SAkhil Goyal { 55040ff8c99SAkhil Goyal .action = RTE_SECURITY_ACTION_TYPE_NONE 55140ff8c99SAkhil Goyal } 55240ff8c99SAkhil Goyal }; 55340ff8c99SAkhil Goyal static const struct rte_cryptodev_capabilities pmd_capabilities[] = { 55440ff8c99SAkhil Goyal { /* SHA1 HMAC */ 55540ff8c99SAkhil Goyal .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 55640ff8c99SAkhil Goyal .sym = { 55740ff8c99SAkhil Goyal .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, 55840ff8c99SAkhil Goyal .auth = { 55940ff8c99SAkhil Goyal .algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 56040ff8c99SAkhil Goyal .block_size = 64, 56140ff8c99SAkhil Goyal .key_size = { 56240ff8c99SAkhil Goyal .min = 64, 56340ff8c99SAkhil Goyal .max = 64, 56440ff8c99SAkhil Goyal .increment = 0 56540ff8c99SAkhil Goyal }, 56640ff8c99SAkhil Goyal .digest_size = { 56740ff8c99SAkhil Goyal .min = 12, 56840ff8c99SAkhil Goyal .max = 12, 56940ff8c99SAkhil Goyal .increment = 0 57040ff8c99SAkhil Goyal }, 57140ff8c99SAkhil Goyal .aad_size = { 0 }, 57240ff8c99SAkhil Goyal .iv_size = { 0 } 57340ff8c99SAkhil Goyal } 57440ff8c99SAkhil Goyal } 57540ff8c99SAkhil Goyal }, 57640ff8c99SAkhil Goyal { /* AES CBC */ 57740ff8c99SAkhil Goyal .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 57840ff8c99SAkhil Goyal .sym = { 57940ff8c99SAkhil Goyal .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 58040ff8c99SAkhil Goyal .cipher = { 58140ff8c99SAkhil Goyal .algo = RTE_CRYPTO_CIPHER_AES_CBC, 58240ff8c99SAkhil Goyal .block_size = 16, 58340ff8c99SAkhil Goyal .key_size = { 58440ff8c99SAkhil Goyal .min = 16, 58540ff8c99SAkhil Goyal .max = 32, 58640ff8c99SAkhil Goyal .increment = 8 58740ff8c99SAkhil Goyal }, 58840ff8c99SAkhil Goyal .iv_size = { 58940ff8c99SAkhil Goyal .min = 16, 59040ff8c99SAkhil Goyal .max = 16, 59140ff8c99SAkhil Goyal .increment = 0 59240ff8c99SAkhil Goyal } 59340ff8c99SAkhil Goyal } 59440ff8c99SAkhil Goyal } 59540ff8c99SAkhil Goyal } 59640ff8c99SAkhil Goyal } 59740ff8c99SAkhil Goyal 598e44b3fafSDavid CoyleBelow is an example of the capabilities for a PMD which supports the DOCSIS 599e44b3fafSDavid Coyleprotocol. 600e44b3fafSDavid Coyle 601e44b3fafSDavid Coyle.. code-block:: c 602e44b3fafSDavid Coyle 603e44b3fafSDavid Coyle static const struct rte_security_capability pmd_security_capabilities[] = { 604e44b3fafSDavid Coyle { /* DOCSIS Uplink */ 605e44b3fafSDavid Coyle .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 606e44b3fafSDavid Coyle .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 607e44b3fafSDavid Coyle .docsis = { 608e44b3fafSDavid Coyle .direction = RTE_SECURITY_DOCSIS_UPLINK 609e44b3fafSDavid Coyle }, 610e44b3fafSDavid Coyle .crypto_capabilities = pmd_capabilities 611e44b3fafSDavid Coyle }, 612e44b3fafSDavid Coyle { /* DOCSIS Downlink */ 613e44b3fafSDavid Coyle .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 614e44b3fafSDavid Coyle .protocol = RTE_SECURITY_PROTOCOL_DOCSIS, 615e44b3fafSDavid Coyle .docsis = { 616e44b3fafSDavid Coyle .direction = RTE_SECURITY_DOCSIS_DOWNLINK 617e44b3fafSDavid Coyle }, 618e44b3fafSDavid Coyle .crypto_capabilities = pmd_capabilities 619e44b3fafSDavid Coyle }, 620e44b3fafSDavid Coyle { 621e44b3fafSDavid Coyle .action = RTE_SECURITY_ACTION_TYPE_NONE 622e44b3fafSDavid Coyle } 623e44b3fafSDavid Coyle }; 624e44b3fafSDavid Coyle static const struct rte_cryptodev_capabilities pmd_capabilities[] = { 625e44b3fafSDavid Coyle { /* AES DOCSIS BPI */ 626e44b3fafSDavid Coyle .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, 627e44b3fafSDavid Coyle .sym = { 628e44b3fafSDavid Coyle .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, 629e44b3fafSDavid Coyle .cipher = { 630e44b3fafSDavid Coyle .algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI, 631e44b3fafSDavid Coyle .block_size = 16, 632e44b3fafSDavid Coyle .key_size = { 633e44b3fafSDavid Coyle .min = 16, 634e44b3fafSDavid Coyle .max = 32, 635e44b3fafSDavid Coyle .increment = 16 636e44b3fafSDavid Coyle }, 637e44b3fafSDavid Coyle .iv_size = { 638e44b3fafSDavid Coyle .min = 16, 639e44b3fafSDavid Coyle .max = 16, 640e44b3fafSDavid Coyle .increment = 0 641e44b3fafSDavid Coyle } 642e44b3fafSDavid Coyle } 643e44b3fafSDavid Coyle } 644e44b3fafSDavid Coyle }, 645e44b3fafSDavid Coyle 646e44b3fafSDavid Coyle RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() 647e44b3fafSDavid Coyle }; 64840ff8c99SAkhil Goyal 649bbbe6c59SAkhil GoyalBelow is the example PMD capability for MACsec 650bbbe6c59SAkhil Goyal 651bbbe6c59SAkhil Goyal.. code-block:: c 652bbbe6c59SAkhil Goyal 653bbbe6c59SAkhil Goyal static const struct rte_security_capability pmd_security_capabilities[] = { 654bbbe6c59SAkhil Goyal { 655bbbe6c59SAkhil Goyal .action = RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL, 656bbbe6c59SAkhil Goyal .protocol = RTE_SECURITY_PROTOCOL_MACSEC, 657bbbe6c59SAkhil Goyal .macsec = { 658bbbe6c59SAkhil Goyal .mtu = 1500, 659bbbe6c59SAkhil Goyal .alg = RTE_SECURITY_MACSEC_ALG_GCM_128, 660bbbe6c59SAkhil Goyal .max_nb_sc = 64, 661bbbe6c59SAkhil Goyal .max_nb_sa = 128, 662bbbe6c59SAkhil Goyal .max_nb_sess = 64, 663bbbe6c59SAkhil Goyal .replay_win_sz = 4096, 664bbbe6c59SAkhil Goyal .relative_sectag_insert = 1, 665bbbe6c59SAkhil Goyal .fixed_sectag_insert = 1, 666bbbe6c59SAkhil Goyal .icv_include_da_sa = 1, 667bbbe6c59SAkhil Goyal .ctrl_port_enable = 1, 668bbbe6c59SAkhil Goyal .preserve_sectag = 1, 669bbbe6c59SAkhil Goyal .preserve_icv = 1, 670bbbe6c59SAkhil Goyal .validate_frames = 1, 671bbbe6c59SAkhil Goyal .re_key = 1, 672bbbe6c59SAkhil Goyal .anti_replay = 1, 673bbbe6c59SAkhil Goyal }, 674bbbe6c59SAkhil Goyal .crypto_capabilities = NULL, 675bbbe6c59SAkhil Goyal }, 676bbbe6c59SAkhil Goyal }; 677bbbe6c59SAkhil Goyal 67840ff8c99SAkhil GoyalCapabilities Discovery 67940ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~ 68040ff8c99SAkhil Goyal 68140ff8c99SAkhil GoyalDiscovering the features and capabilities of a driver (crypto/ethernet) 68240ff8c99SAkhil Goyalis achieved through the ``rte_security_capabilities_get()`` function. 68340ff8c99SAkhil Goyal 68440ff8c99SAkhil Goyal.. code-block:: c 68540ff8c99SAkhil Goyal 68640ff8c99SAkhil Goyal const struct rte_security_capability *rte_security_capabilities_get(uint16_t id); 68740ff8c99SAkhil Goyal 68840ff8c99SAkhil GoyalThis allows the user to query a specific driver and get all device 68940ff8c99SAkhil Goyalsecurity capabilities. It returns an array of ``rte_security_capability`` structures 69040ff8c99SAkhil Goyalwhich contains all the capabilities for that device. 69140ff8c99SAkhil Goyal 69240ff8c99SAkhil GoyalSecurity Session Create/Free 69340ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69440ff8c99SAkhil Goyal 69540ff8c99SAkhil GoyalSecurity Sessions are created to store the immutable fields of a particular Security 69640ff8c99SAkhil GoyalAssociation for a particular protocol which is defined by a security session 69740ff8c99SAkhil Goyalconfiguration structure which is used in the operation processing of a packet flow. 69840ff8c99SAkhil GoyalSessions are used to manage protocol specific information as well as crypto parameters. 69940ff8c99SAkhil GoyalSecurity sessions cache this immutable data in a optimal way for the underlying PMD 70040ff8c99SAkhil Goyaland this allows further acceleration of the offload of Crypto workloads. 70140ff8c99SAkhil Goyal 70240ff8c99SAkhil GoyalThe Security framework provides APIs to create and free sessions for crypto/ethernet 70340ff8c99SAkhil Goyaldevices, where sessions are mempool objects. It is the application's responsibility 704e30b2833SAkhil Goyalto create and manage two session mempools - one for session and other for session 705e30b2833SAkhil Goyalprivate data. The private session data mempool object size should be able to 706e30b2833SAkhil Goyalaccommodate the driver's private data of security session. The application can get 707e30b2833SAkhil Goyalthe size of session private data using API ``rte_security_session_get_size``. 708e30b2833SAkhil GoyalAnd the session mempool object size should be enough to accommodate 709e30b2833SAkhil Goyal``rte_security_session``. 71040ff8c99SAkhil Goyal 71140ff8c99SAkhil GoyalOnce the session mempools have been created, ``rte_security_session_create()`` 71240ff8c99SAkhil Goyalis used to allocate and initialize a session for the required crypto/ethernet device. 71340ff8c99SAkhil Goyal 71479bdb787SAkhil GoyalSession APIs need an opaque handle to identify the crypto/ethernet 71540ff8c99SAkhil Goyalsecurity ops. This parameter can be retrieved using the APIs 71640ff8c99SAkhil Goyal``rte_cryptodev_get_sec_ctx()`` (for crypto device) or ``rte_eth_dev_get_sec_ctx`` 71740ff8c99SAkhil Goyal(for ethernet port). 71840ff8c99SAkhil Goyal 71940ff8c99SAkhil GoyalSessions already created can be updated with ``rte_security_session_update()``. 72040ff8c99SAkhil Goyal 72140ff8c99SAkhil GoyalWhen a session is no longer used, the user must call ``rte_security_session_destroy()`` 72240ff8c99SAkhil Goyalto free the driver private session data and return the memory back to the mempool. 72340ff8c99SAkhil Goyal 72440ff8c99SAkhil GoyalFor look aside protocol offload to hardware crypto device, the ``rte_crypto_op`` 72540ff8c99SAkhil Goyalcreated by the application is attached to the security session by the API 72640ff8c99SAkhil Goyal``rte_security_attach_session()``. 72740ff8c99SAkhil Goyal 72840ff8c99SAkhil GoyalFor Inline Crypto and Inline protocol offload, device specific defined metadata is 72940ff8c99SAkhil Goyalupdated in the mbuf using ``rte_security_set_pkt_metadata()`` if 730295968d1SFerruh Yigit``RTE_ETH_TX_OFFLOAD_SEC_NEED_MDATA`` is set. 73140ff8c99SAkhil Goyal 7321a08c379SAnoob Joseph.. note:: 7331a08c379SAnoob Joseph 734614af754SThomas Monjalon In case of inline processed packets, ``RTE_SECURITY_DYNFIELD_NAME`` field 735614af754SThomas Monjalon would be used by the driver to relay information on the security processing 7361a08c379SAnoob Joseph associated with the packet. In ingress, the driver would set this in Rx 7371a08c379SAnoob Joseph path while in egress, ``rte_security_set_pkt_metadata()`` would perform a 7381a08c379SAnoob Joseph similar operation. The application is expected not to modify the field 7391a08c379SAnoob Joseph when it has relevant info. For ingress, this device-specific 64 bit value 7401a08c379SAnoob Joseph is required to derive other information (like userdata), required for 7411a08c379SAnoob Joseph identifying the security processing done on the packet. 7421a08c379SAnoob Joseph 74340ff8c99SAkhil GoyalSecurity session configuration 74440ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 74540ff8c99SAkhil Goyal 74640ff8c99SAkhil GoyalSecurity Session configuration structure is defined as ``rte_security_session_conf`` 74740ff8c99SAkhil Goyal 74803e3cfdaSAnoob Joseph.. literalinclude:: ../../../lib/security/rte_security.h 74903e3cfdaSAnoob Joseph :language: c 75003e3cfdaSAnoob Joseph :start-after: Structure rte_security_session_conf 8< 75103e3cfdaSAnoob Joseph :end-before: >8 End of structure rte_security_session_conf. 75240ff8c99SAkhil Goyal 75340ff8c99SAkhil GoyalThe configuration structure reuses the ``rte_crypto_sym_xform`` struct for crypto related 75440ff8c99SAkhil Goyalconfiguration. The ``rte_security_session_action_type`` struct is used to specify whether the 75540ff8c99SAkhil Goyalsession is configured for Lookaside Protocol offload or Inline Crypto or Inline Protocol 75640ff8c99SAkhil GoyalOffload. 75740ff8c99SAkhil Goyal 75803e3cfdaSAnoob Joseph.. literalinclude:: ../../../lib/security/rte_security.h 75903e3cfdaSAnoob Joseph :language: c 76003e3cfdaSAnoob Joseph :start-after: Enumeration of rte_security_session_action_type 8< 76103e3cfdaSAnoob Joseph :end-before: >8 End enumeration of rte_security_session_action_type. 76240ff8c99SAkhil Goyal 76340ff8c99SAkhil GoyalThe ``rte_security_session_protocol`` is defined as 76440ff8c99SAkhil Goyal 76503e3cfdaSAnoob Joseph.. literalinclude:: ../../../lib/security/rte_security.h 76603e3cfdaSAnoob Joseph :language: c 76703e3cfdaSAnoob Joseph :start-after: Enumeration of rte_security_session_protocol 8< 76803e3cfdaSAnoob Joseph :end-before: >8 End enumeration of rte_security_session_protocol. 76940ff8c99SAkhil Goyal 77040ff8c99SAkhil GoyalIPsec related configuration parameters are defined in ``rte_security_ipsec_xform`` 77140ff8c99SAkhil Goyal 772bbbe6c59SAkhil GoyalMACsec related configuration parameters are defined in ``rte_security_macsec_xform`` 773bbbe6c59SAkhil Goyal 7748b593b8cSAkhil GoyalPDCP related configuration parameters are defined in ``rte_security_pdcp_xform`` 7758b593b8cSAkhil Goyal 776e44b3fafSDavid CoyleDOCSIS related configuration parameters are defined in ``rte_security_docsis_xform`` 777e44b3fafSDavid Coyle 7787ebdf16aSAnoob JosephTLS record related configuration parameters are defined in ``rte_security_tls_record_xform`` 7797ebdf16aSAnoob Joseph 78040ff8c99SAkhil Goyal 78140ff8c99SAkhil GoyalSecurity API 78240ff8c99SAkhil Goyal~~~~~~~~~~~~ 78340ff8c99SAkhil Goyal 78440ff8c99SAkhil GoyalThe rte_security Library API is described in the *DPDK API Reference* document. 78540ff8c99SAkhil Goyal 78640ff8c99SAkhil GoyalFlow based Security Session 78740ff8c99SAkhil Goyal~~~~~~~~~~~~~~~~~~~~~~~~~~~ 78840ff8c99SAkhil Goyal 78940ff8c99SAkhil GoyalIn the case of NIC based offloads, the security session specified in the 79040ff8c99SAkhil Goyal'rte_flow_action_security' must be created on the same port as the 79140ff8c99SAkhil Goyalflow action that is being specified. 79240ff8c99SAkhil Goyal 79340ff8c99SAkhil GoyalThe ingress/egress flow attribute should match that specified in the security 79440ff8c99SAkhil Goyalsession if the security session supports the definition of the direction. 79540ff8c99SAkhil Goyal 79640ff8c99SAkhil GoyalMultiple flows can be configured to use the same security session. For 797bbbe6c59SAkhil Goyalexample if the security session specifies an egress IPsec/MACsec SA, then multiple 79840ff8c99SAkhil Goyalflows can be specified to that SA. In the case of an ingress IPsec SA then 79940ff8c99SAkhil Goyalit is only valid to have a single flow to map to that security session. 80040ff8c99SAkhil Goyal 80140ff8c99SAkhil Goyal.. code-block:: console 80240ff8c99SAkhil Goyal 80340ff8c99SAkhil Goyal Configuration Path 80440ff8c99SAkhil Goyal | 80540ff8c99SAkhil Goyal +--------|--------+ 80640ff8c99SAkhil Goyal | Add/Remove | 807bbbe6c59SAkhil Goyal | IPsec/MACsec SA | <------ Build security flow action of 808bbbe6c59SAkhil Goyal | | | IPsec/MACsec transform 80940ff8c99SAkhil Goyal |--------|--------| 81040ff8c99SAkhil Goyal | 81140ff8c99SAkhil Goyal +--------V--------+ 81240ff8c99SAkhil Goyal | Flow API | 81340ff8c99SAkhil Goyal +--------|--------+ 81440ff8c99SAkhil Goyal | 81540ff8c99SAkhil Goyal +--------V--------+ 81640ff8c99SAkhil Goyal | | 81740ff8c99SAkhil Goyal | NIC PMD | <------ Add/Remove SA to/from hw context 81840ff8c99SAkhil Goyal | | 81940ff8c99SAkhil Goyal +--------|--------+ 82040ff8c99SAkhil Goyal | 82140ff8c99SAkhil Goyal +--------|--------+ 82240ff8c99SAkhil Goyal | HW ACCELERATED | 82340ff8c99SAkhil Goyal | NIC | 82440ff8c99SAkhil Goyal | | 82540ff8c99SAkhil Goyal +--------|--------+ 82640ff8c99SAkhil Goyal 827bbbe6c59SAkhil Goyal* Add/Delete IPsec SA flow: 82840ff8c99SAkhil Goyal To add a new inline SA construct a rte_flow_item for Ethernet + IP + ESP 829bbbe6c59SAkhil Goyal using the SA selectors and the ``rte_security_ipsec_xform`` as the ``rte_flow_action``. 83040ff8c99SAkhil Goyal Note that any rte_flow_items may be empty, which means it is not checked. 83140ff8c99SAkhil Goyal 83240ff8c99SAkhil Goyal.. code-block:: console 83340ff8c99SAkhil Goyal 83440ff8c99SAkhil Goyal In its most basic form, IPsec flow specification is as follows: 83540ff8c99SAkhil Goyal +-------+ +----------+ +--------+ +-----+ 83640ff8c99SAkhil Goyal | Eth | -> | IP4/6 | -> | ESP | -> | END | 83740ff8c99SAkhil Goyal +-------+ +----------+ +--------+ +-----+ 83840ff8c99SAkhil Goyal 83940ff8c99SAkhil Goyal However, the API can represent, IPsec crypto offload with any encapsulation: 84040ff8c99SAkhil Goyal +-------+ +--------+ +-----+ 84140ff8c99SAkhil Goyal | Eth | -> ... -> | ESP | -> | END | 84240ff8c99SAkhil Goyal +-------+ +--------+ +-----+ 843259ca6d1SGowrishankar Muthukrishnan 844bbbe6c59SAkhil Goyal* Add/Delete MACsec SA flow: 845bbbe6c59SAkhil Goyal To add a new inline SA construct a rte_flow_item for Ethernet + SecTAG 846bbbe6c59SAkhil Goyal using the SA selectors and the ``rte_security_macsec_xform`` as the ``rte_flow_action``. 847bbbe6c59SAkhil Goyal Note that any rte_flow_items may be empty, which means it is not checked. 848bbbe6c59SAkhil Goyal 849bbbe6c59SAkhil Goyal.. code-block:: console 850bbbe6c59SAkhil Goyal 851bbbe6c59SAkhil Goyal In its most basic form, MACsec flow specification is as follows: 852bbbe6c59SAkhil Goyal +-------+ +----------+ +-----+ 853bbbe6c59SAkhil Goyal | Eth | -> | SecTag | -> | END | 854bbbe6c59SAkhil Goyal +-------+ +----------+ +-----+ 855bbbe6c59SAkhil Goyal 856bbbe6c59SAkhil Goyal However, the API can represent, MACsec offload with any encapsulation: 857bbbe6c59SAkhil Goyal +-------+ +--------+ +-----+ 858bbbe6c59SAkhil Goyal | Eth | -> ... -> | SecTag | -> | END | 859bbbe6c59SAkhil Goyal +-------+ +--------+ +-----+ 860bbbe6c59SAkhil Goyal 861259ca6d1SGowrishankar Muthukrishnan 862259ca6d1SGowrishankar MuthukrishnanTelemetry support 863259ca6d1SGowrishankar Muthukrishnan----------------- 864259ca6d1SGowrishankar Muthukrishnan 865259ca6d1SGowrishankar MuthukrishnanThe Security library has support for displaying Crypto device information 866259ca6d1SGowrishankar Muthukrishnanwith respect to its Security capabilities. Telemetry commands that can be used 867259ca6d1SGowrishankar Muthukrishnanare shown below. 868259ca6d1SGowrishankar Muthukrishnan 869259ca6d1SGowrishankar Muthukrishnan#. Get the list of available Crypto devices by ID, that supports Security features:: 870259ca6d1SGowrishankar Muthukrishnan 871259ca6d1SGowrishankar Muthukrishnan --> /security/cryptodev/list 872259ca6d1SGowrishankar Muthukrishnan {"/security/cryptodev/list": [0, 1, 2, 3]} 873259ca6d1SGowrishankar Muthukrishnan 874259ca6d1SGowrishankar Muthukrishnan#. Get the security capabilities of a Crypto device:: 875259ca6d1SGowrishankar Muthukrishnan 876259ca6d1SGowrishankar Muthukrishnan --> /security/cryptodev/sec_caps,0 877259ca6d1SGowrishankar Muthukrishnan {"/security/cryptodev/sec_caps": {"sec_caps": [<array of serialized bytes of 878259ca6d1SGowrishankar Muthukrishnan capabilities>], "sec_caps_n": <number of capabilities>}} 879259ca6d1SGowrishankar Muthukrishnan 880259ca6d1SGowrishankar Muthukrishnan #. Get the security crypto capabilities of a Crypto device:: 881259ca6d1SGowrishankar Muthukrishnan 882259ca6d1SGowrishankar Muthukrishnan --> /security/cryptodev/crypto_caps,0,0 883259ca6d1SGowrishankar Muthukrishnan {"/security/cryptodev/crypto_caps": {"crypto_caps": [<array of serialized bytes of 884259ca6d1SGowrishankar Muthukrishnan capabilities>], "crypto_caps_n": <number of capabilities>}} 885259ca6d1SGowrishankar Muthukrishnan 886259ca6d1SGowrishankar MuthukrishnanFor more information on how to use the Telemetry interface, see 887259ca6d1SGowrishankar Muthukrishnanthe :doc:`../howto/telemetry`. 888