blob: 40c1149083d1a969e6c0d369032f9da27d4f55c3 [file] [log] [blame]
developer7e32f7e2022-05-18 21:10:08 +08001From 76564261a7db80c5f5c624e0122a28787f266bdf Mon Sep 17 00:00:00 2001
2From: Antoine Tenart <antoine.tenart@bootlin.com>
3Date: Mon, 13 Jan 2020 23:31:40 +0100
4Subject: net: macsec: introduce the macsec_context structure
5
6This patch introduces the macsec_context structure. It will be used
7in the kernel to exchange information between the common MACsec
8implementation (macsec.c) and the MACsec hardware offloading
9implementations. This structure contains pointers to MACsec specific
10structures which contain the actual MACsec configuration, and to the
11underlying device (phydev for now).
12
13Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
14Signed-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
22diff --git a/include/linux/phy.h b/include/linux/phy.h
23index 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
35diff --git a/include/net/macsec.h b/include/net/macsec.h
36index 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_ */
65diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
66index 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,
83diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
84index 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--
102cgit 1.2.3-1.el7
103