xref: /dpdk/lib/net/rte_macsec.h (revision fba9875559906e04eaeb74532f4cfd51194259a2)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2022 Marvell.
3  */
4 
5 #ifndef RTE_MACSEC_H
6 #define RTE_MACSEC_H
7 
8 /**
9  * @file
10  *
11  * MACsec-related defines
12  */
13 
14 #include <rte_byteorder.h>
15 
16 #define RTE_MACSEC_TCI_VER_MASK	0x80 /**< Version mask for MACsec. Should be 0. */
17 #define RTE_MACSEC_TCI_ES	0x40 /**< Mask for End station (ES) bit - SCI is not valid. */
18 #define RTE_MACSEC_TCI_SC	0x20 /**< Mask for SCI present bit. */
19 #define RTE_MACSEC_TCI_SCB	0x10 /**< Mask for EPON single copy broadcast bit. */
20 #define RTE_MACSEC_TCI_E	0x08 /**< Mask for encrypted user data bit. */
21 #define RTE_MACSEC_TCI_C	0x04 /**< Mask for changed user data bit (because of encryption). */
22 #define RTE_MACSEC_AN_MASK	0x03 /**< Association number mask in tci_an. */
23 
24 /**
25  * MACsec Header (SecTAG)
26  */
27 __extension__
28 struct __rte_packed_begin rte_macsec_hdr {
29 	/**
30 	 * Tag control information and Association number of secure channel.
31 	 * Various bits of TCI and AN are masked using RTE_MACSEC_TCI_* and RTE_MACSEC_AN_MASK.
32 	 */
33 	uint8_t tci_an;
34 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
35 	uint8_t short_length:6; /**< Short Length. */
36 	uint8_t unused:2;
37 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
38 	uint8_t unused:2;
39 	uint8_t short_length:6; /**< Short Length. */
40 #endif
41 	rte_be32_t packet_number; /**< Packet number to support replay protection. */
42 } __rte_packed_end;
43 
44 /** SCI length in MACsec header if present. */
45 #define RTE_MACSEC_SCI_LEN 8
46 
47 /**
48  * MACsec SCI header (8 bytes) after the MACsec header
49  * which is present if SC bit is set in tci_an.
50  */
51 struct __rte_packed_begin rte_macsec_sci_hdr {
52 	uint8_t sci[RTE_MACSEC_SCI_LEN]; /**< Optional secure channel ID. */
53 } __rte_packed_end;
54 
55 #endif /* RTE_MACSEC_H */
56