--- zzzz-none-000/linux-5.15.111/include/net/macsec.h 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/include/net/macsec.h 2024-02-07 10:23:27.000000000 +0000 @@ -4,6 +4,12 @@ * * Copyright (c) 2015 Sabrina Dubroca */ + +/* +* Includes Intel Corporation's changes dated: 2019. +* Changed portions - Copyright 2019, Intel Corporation. +*/ + #ifndef _NET_MACSEC_H_ #define _NET_MACSEC_H_ @@ -288,6 +294,128 @@ int (*mdo_get_rx_sa_stats)(struct macsec_context *ctx); }; +#ifdef CONFIG_MACSEC_HW_OFFLOAD +struct macsec_hw_driver { + int (*add_rxsc)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_rxsc); + int (*del_rxsc)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_rxsc); + int (*upd_rxsc)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_rxsc); + int (*add_txsa)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_sa); + int (*del_txsa)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_sa); + int (*upd_txsa)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_sa); + int (*add_rxsa)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_rxsc, struct nlattr **tb_sa); + int (*del_rxsa)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_rxsc, struct nlattr **tb_sa); + int (*upd_rxsa)(struct net_device *dev, struct macsec_secy *secy, struct nlattr **tb_rxsc, struct nlattr **tb_sa); + int (*dump)(struct net_device *dev, struct macsec_secy *secy); + int (*change_link)(struct net_device *dev, struct macsec_secy *secy); +}; + +#define MACSEC_SCI_LEN 8 + +/* SecTAG length = macsec_eth_header without the optional SCI */ +#define MACSEC_TAG_LEN 6 + +struct macsec_eth_header { + struct ethhdr eth; + /* SecTAG */ + u8 tci_an; +#if defined(__LITTLE_ENDIAN_BITFIELD) + u8 short_length:6, + unused:2; +#elif defined(__BIG_ENDIAN_BITFIELD) + u8 unused:2, + short_length:6; +#else +#error "Please fix " +#endif + __be32 packet_number; + u8 secure_channel_id[8]; /* optional */ +} __packed; + +#define MACSEC_TCI_VERSION 0x80 +#define MACSEC_TCI_ES 0x40 /* end station */ +#define MACSEC_TCI_SC 0x20 /* SCI present */ +#define MACSEC_TCI_SCB 0x10 /* epon */ +#define MACSEC_TCI_E 0x08 /* encryption */ +#define MACSEC_TCI_C 0x04 /* changed text */ +#define MACSEC_AN_MASK 0x03 /* association number */ +#define MACSEC_TCI_CONFID (MACSEC_TCI_E | MACSEC_TCI_C) + +/* minimum secure data length deemed "not short", see IEEE 802.1AE-2006 9.7 */ +#define MIN_NON_SHORT_LEN 48 + +#define GCM_AES_IV_LEN 12 +#define DEFAULT_ICV_LEN 16 + +#define MACSEC_NUM_AN 4 /* 2 bits for the association number */ + +#define for_each_rxsc(secy, sc) \ + for (sc = rcu_dereference_bh(secy->rx_sc); \ + sc; \ + sc = rcu_dereference_bh(sc->next)) +#define for_each_rxsc_rtnl(secy, sc) \ + for (sc = rtnl_dereference(secy->rx_sc); \ + sc; \ + sc = rtnl_dereference(sc->next)) + +#define pn_same_half(pn1, pn2) (!(((pn1) >> 31) ^ ((pn2) >> 31))) + +struct gcm_iv_xpn { + union { + u8 short_secure_channel_id[4]; + ssci_t ssci; + }; + __be64 pn; +} __packed; + +struct gcm_iv { + union { + u8 secure_channel_id[8]; + sci_t sci; + }; + __be32 pn; +}; + +#define MACSEC_VALIDATE_DEFAULT MACSEC_VALIDATE_STRICT + +struct pcpu_secy_stats { + struct macsec_dev_stats stats; + struct u64_stats_sync syncp; +}; + +/** + * struct macsec_dev - private data + * @secy: SecY config + * @real_dev: pointer to underlying netdevice + * @stats: MACsec device stats + * @secys: linked list of SecY's on the underlying device + * @gro_cells: pointer to the Generic Receive Offload cell + * @offload: status of offloading on the MACsec device + */ +struct macsec_dev { + struct macsec_secy secy; + struct net_device *real_dev; + struct pcpu_secy_stats __percpu *stats; + struct list_head secys; + struct gro_cells gro_cells; + enum macsec_offload offload; +#ifdef CONFIG_MACSEC_HW_OFFLOAD + bool hw_offload; +#endif +}; + +/** + * struct macsec_rxh_data - rx_handler private argument + * @secys: linked list of SecY's on this underlying device + */ +struct macsec_rxh_data { + struct list_head secys; +}; + +struct macsec_dev *macsec_priv(const struct net_device *dev); +int macsec_register_hw_driver(struct macsec_hw_driver * hw_driver); +void macsec_unregister_hw_driver(void); +bool is_macsec_master(struct net_device *dev); +#endif void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa); #endif /* _NET_MACSEC_H_ */