132ae9939SAkhil Goyal /* SPDX-License-Identifier: BSD-3-Clause 232ae9939SAkhil Goyal * Copyright(C) 2022 Marvell. 332ae9939SAkhil Goyal */ 432ae9939SAkhil Goyal 532ae9939SAkhil Goyal #ifndef RTE_MACSEC_H 632ae9939SAkhil Goyal #define RTE_MACSEC_H 732ae9939SAkhil Goyal 832ae9939SAkhil Goyal /** 932ae9939SAkhil Goyal * @file 1032ae9939SAkhil Goyal * 1132ae9939SAkhil Goyal * MACsec-related defines 1232ae9939SAkhil Goyal */ 1332ae9939SAkhil Goyal 1432ae9939SAkhil Goyal #include <rte_byteorder.h> 1532ae9939SAkhil Goyal 1632ae9939SAkhil Goyal #define RTE_MACSEC_TCI_VER_MASK 0x80 /**< Version mask for MACsec. Should be 0. */ 1732ae9939SAkhil Goyal #define RTE_MACSEC_TCI_ES 0x40 /**< Mask for End station (ES) bit - SCI is not valid. */ 1832ae9939SAkhil Goyal #define RTE_MACSEC_TCI_SC 0x20 /**< Mask for SCI present bit. */ 1932ae9939SAkhil Goyal #define RTE_MACSEC_TCI_SCB 0x10 /**< Mask for EPON single copy broadcast bit. */ 2032ae9939SAkhil Goyal #define RTE_MACSEC_TCI_E 0x08 /**< Mask for encrypted user data bit. */ 2132ae9939SAkhil Goyal #define RTE_MACSEC_TCI_C 0x04 /**< Mask for changed user data bit (because of encryption). */ 2232ae9939SAkhil Goyal #define RTE_MACSEC_AN_MASK 0x03 /**< Association number mask in tci_an. */ 2332ae9939SAkhil Goyal 2432ae9939SAkhil Goyal /** 2532ae9939SAkhil Goyal * MACsec Header (SecTAG) 2632ae9939SAkhil Goyal */ 279891ded2SAli Alnubani __extension__ 28*fba98755SAndre Muezerie struct __rte_packed_begin rte_macsec_hdr { 2932ae9939SAkhil Goyal /** 3032ae9939SAkhil Goyal * Tag control information and Association number of secure channel. 3132ae9939SAkhil Goyal * Various bits of TCI and AN are masked using RTE_MACSEC_TCI_* and RTE_MACSEC_AN_MASK. 3232ae9939SAkhil Goyal */ 3332ae9939SAkhil Goyal uint8_t tci_an; 3432ae9939SAkhil Goyal #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN 3532ae9939SAkhil Goyal uint8_t short_length:6; /**< Short Length. */ 3632ae9939SAkhil Goyal uint8_t unused:2; 3732ae9939SAkhil Goyal #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN 3832ae9939SAkhil Goyal uint8_t unused:2; 3932ae9939SAkhil Goyal uint8_t short_length:6; /**< Short Length. */ 4032ae9939SAkhil Goyal #endif 4132ae9939SAkhil Goyal rte_be32_t packet_number; /**< Packet number to support replay protection. */ 42*fba98755SAndre Muezerie } __rte_packed_end; 4332ae9939SAkhil Goyal 4432ae9939SAkhil Goyal /** SCI length in MACsec header if present. */ 4532ae9939SAkhil Goyal #define RTE_MACSEC_SCI_LEN 8 4632ae9939SAkhil Goyal 4732ae9939SAkhil Goyal /** 4832ae9939SAkhil Goyal * MACsec SCI header (8 bytes) after the MACsec header 4932ae9939SAkhil Goyal * which is present if SC bit is set in tci_an. 5032ae9939SAkhil Goyal */ 51*fba98755SAndre Muezerie struct __rte_packed_begin rte_macsec_sci_hdr { 5232ae9939SAkhil Goyal uint8_t sci[RTE_MACSEC_SCI_LEN]; /**< Optional secure channel ID. */ 53*fba98755SAndre Muezerie } __rte_packed_end; 5432ae9939SAkhil Goyal 5532ae9939SAkhil Goyal #endif /* RTE_MACSEC_H */ 56