developer | 7e32f7e | 2022-05-18 21:10:08 +0800 | [diff] [blame] | 1 | From 76564261a7db80c5f5c624e0122a28787f266bdf Mon Sep 17 00:00:00 2001 |
| 2 | From: Antoine Tenart <antoine.tenart@bootlin.com> |
| 3 | Date: Mon, 13 Jan 2020 23:31:40 +0100 |
| 4 | Subject: net: macsec: introduce the macsec_context structure |
| 5 | |
| 6 | This patch introduces the macsec_context structure. It will be used |
| 7 | in the kernel to exchange information between the common MACsec |
| 8 | implementation (macsec.c) and the MACsec hardware offloading |
| 9 | implementations. This structure contains pointers to MACsec specific |
| 10 | structures which contain the actual MACsec configuration, and to the |
| 11 | underlying device (phydev for now). |
| 12 | |
| 13 | Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> |
| 14 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 15 | --- |
| 16 | include/linux/phy.h | 2 ++ |
| 17 | include/net/macsec.h | 21 +++++++++++++++++++++ |
| 18 | include/uapi/linux/if_link.h | 7 +++++++ |
| 19 | tools/include/uapi/linux/if_link.h | 7 +++++++ |
| 20 | 4 files changed, 37 insertions(+) |
| 21 | |
| 22 | diff --git a/include/linux/phy.h b/include/linux/phy.h |
| 23 | index 3a70b756ac1aa..be079a7bb40aa 100644 |
| 24 | --- a/include/linux/phy.h |
| 25 | +++ b/include/linux/phy.h |
| 26 | @@ -332,6 +332,8 @@ struct phy_c45_device_ids { |
| 27 | u32 device_ids[8]; |
| 28 | }; |
| 29 | |
| 30 | +struct macsec_context; |
| 31 | + |
| 32 | /* phy_device: An instance of a PHY |
| 33 | * |
| 34 | * drv: Pointer to the driver for this PHY instance |
| 35 | diff --git a/include/net/macsec.h b/include/net/macsec.h |
| 36 | index e7b41c1043f6f..0b98803f92ec1 100644 |
| 37 | --- a/include/net/macsec.h |
| 38 | +++ b/include/net/macsec.h |
| 39 | @@ -174,4 +174,25 @@ struct macsec_secy { |
| 40 | struct macsec_rx_sc __rcu *rx_sc; |
| 41 | }; |
| 42 | |
| 43 | +/** |
| 44 | + * struct macsec_context - MACsec context for hardware offloading |
| 45 | + */ |
| 46 | +struct macsec_context { |
| 47 | + struct phy_device *phydev; |
| 48 | + enum macsec_offload offload; |
| 49 | + |
| 50 | + struct macsec_secy *secy; |
| 51 | + struct macsec_rx_sc *rx_sc; |
| 52 | + struct { |
| 53 | + unsigned char assoc_num; |
| 54 | + u8 key[MACSEC_KEYID_LEN]; |
| 55 | + union { |
| 56 | + struct macsec_rx_sa *rx_sa; |
| 57 | + struct macsec_tx_sa *tx_sa; |
| 58 | + }; |
| 59 | + } sa; |
| 60 | + |
| 61 | + u8 prepare:1; |
| 62 | +}; |
| 63 | + |
| 64 | #endif /* _NET_MACSEC_H_ */ |
| 65 | diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h |
| 66 | index 1d69f637c5d6a..024af2d1d0af4 100644 |
| 67 | --- a/include/uapi/linux/if_link.h |
| 68 | +++ b/include/uapi/linux/if_link.h |
| 69 | @@ -486,6 +486,13 @@ enum macsec_validation_type { |
| 70 | MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1, |
| 71 | }; |
| 72 | |
| 73 | +enum macsec_offload { |
| 74 | + MACSEC_OFFLOAD_OFF = 0, |
| 75 | + MACSEC_OFFLOAD_PHY = 1, |
| 76 | + __MACSEC_OFFLOAD_END, |
| 77 | + MACSEC_OFFLOAD_MAX = __MACSEC_OFFLOAD_END - 1, |
| 78 | +}; |
| 79 | + |
| 80 | /* IPVLAN section */ |
| 81 | enum { |
| 82 | IFLA_IPVLAN_UNSPEC, |
| 83 | diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h |
| 84 | index 8aec8769d9442..42efdb84d1898 100644 |
| 85 | --- a/tools/include/uapi/linux/if_link.h |
| 86 | +++ b/tools/include/uapi/linux/if_link.h |
| 87 | @@ -485,6 +485,13 @@ enum macsec_validation_type { |
| 88 | MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1, |
| 89 | }; |
| 90 | |
| 91 | +enum macsec_offload { |
| 92 | + MACSEC_OFFLOAD_OFF = 0, |
| 93 | + MACSEC_OFFLOAD_PHY = 1, |
| 94 | + __MACSEC_OFFLOAD_END, |
| 95 | + MACSEC_OFFLOAD_MAX = __MACSEC_OFFLOAD_END - 1, |
| 96 | +}; |
| 97 | + |
| 98 | /* IPVLAN section */ |
| 99 | enum { |
| 100 | IFLA_IPVLAN_UNSPEC, |
| 101 | -- |
| 102 | cgit 1.2.3-1.el7 |
| 103 | |