1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
3 * Driver for Microsemi VSC85xx PHYs
5 * Copyright (c) 2018 Microsemi Corporation
8 #ifndef _MSCC_PHY_MACSEC_H_
9 #define _MSCC_PHY_MACSEC_H_
11 #include <net/macsec.h>
13 #define MSCC_MS_MAX_FLOWS 16
15 #define CONTROL_TYPE_EGRESS 0x6
16 #define CONTROL_TYPE_INGRESS 0xf
17 #define CONTROL_IV0 BIT(5)
18 #define CONTROL_IV1 BIT(6)
19 #define CONTROL_IV2 BIT(7)
20 #define CONTROL_UPDATE_SEQ BIT(13)
21 #define CONTROL_IV_IN_SEQ BIT(14)
22 #define CONTROL_ENCRYPT_AUTH BIT(15)
23 #define CONTROL_KEY_IN_CTX BIT(16)
24 #define CONTROL_CRYPTO_ALG(x) ((x) << 17)
25 #define CTRYPTO_ALG_AES_CTR_128 0x5
26 #define CTRYPTO_ALG_AES_CTR_192 0x6
27 #define CTRYPTO_ALG_AES_CTR_256 0x7
28 #define CONTROL_DIGEST_TYPE(x) ((x) << 21)
29 #define CONTROL_AUTH_ALG(x) ((x) << 23)
30 #define AUTH_ALG_AES_GHAS 0x4
31 #define CONTROL_AN(x) ((x) << 26)
32 #define CONTROL_SEQ_TYPE(x) ((x) << 28)
33 #define CONTROL_SEQ_MASK BIT(30)
34 #define CONTROL_CONTEXT_ID BIT(31)
36 enum mscc_macsec_destination_ports {
37 MSCC_MS_PORT_COMMON = 0,
38 MSCC_MS_PORT_RSVD = 1,
39 MSCC_MS_PORT_CONTROLLED = 2,
40 MSCC_MS_PORT_UNCONTROLLED = 3,
43 enum mscc_macsec_drop_actions {
44 MSCC_MS_ACTION_BYPASS_CRC = 0,
45 MSCC_MS_ACTION_BYPASS_BAD = 1,
46 MSCC_MS_ACTION_DROP = 2,
47 MSCC_MS_ACTION_BYPASS = 3,
50 enum mscc_macsec_flow_types {
51 MSCC_MS_FLOW_BYPASS = 0,
52 MSCC_MS_FLOW_DROP = 1,
53 MSCC_MS_FLOW_INGRESS = 2,
54 MSCC_MS_FLOW_EGRESS = 3,
57 enum mscc_macsec_validate_levels {
58 MSCC_MS_VALIDATE_DISABLED = 0,
59 MSCC_MS_VALIDATE_CHECK = 1,
60 MSCC_MS_VALIDATE_STRICT = 2,
73 struct list_head list;
74 enum mscc_macsec_destination_ports port;
75 enum macsec_bank bank;
78 bool has_transformation;
80 /* Highest takes precedence [0..15] */
83 u8 key[MACSEC_KEYID_LEN];
86 struct macsec_rx_sa *rx_sa;
87 struct macsec_tx_sa *tx_sa;
107 #define MSCC_EXT_PAGE_MACSEC_17 17
108 #define MSCC_EXT_PAGE_MACSEC_18 18
110 #define MSCC_EXT_PAGE_MACSEC_19 19
111 #define MSCC_PHY_MACSEC_19_REG_ADDR(x) (x)
112 #define MSCC_PHY_MACSEC_19_TARGET(x) ((x) << 12)
113 #define MSCC_PHY_MACSEC_19_READ BIT(14)
114 #define MSCC_PHY_MACSEC_19_CMD BIT(15)
116 #define MSCC_EXT_PAGE_MACSEC_20 20
117 #define MSCC_PHY_MACSEC_20_TARGET(x) (x)
119 #define MSCC_MS_XFORM_REC(x, y) (((x) << 5) + (y))
120 #define MSCC_MS_ENA_CFG 0x800
121 #define MSCC_MS_FC_CFG 0x804
122 #define MSCC_MS_SAM_MAC_SA_MATCH_LO(x) (0x1000 + ((x) << 4))
123 #define MSCC_MS_SAM_MAC_SA_MATCH_HI(x) (0x1001 + ((x) << 4))
124 #define MSCC_MS_SAM_MISC_MATCH(x) (0x1004 + ((x) << 4))
125 #define MSCC_MS_SAM_MATCH_SCI_LO(x) (0x1005 + ((x) << 4))
126 #define MSCC_MS_SAM_MATCH_SCI_HI(x) (0x1006 + ((x) << 4))
127 #define MSCC_MS_SAM_MASK(x) (0x1007 + ((x) << 4))
128 #define MSCC_MS_SAM_ENTRY_SET1 0x1808
129 #define MSCC_MS_SAM_ENTRY_CLEAR1 0x180c
130 #define MSCC_MS_SAM_FLOW_CTRL(x) (0x1c00 + (x))
131 #define MSCC_MS_SAM_CP_TAG 0x1e40
132 #define MSCC_MS_SAM_NM_FLOW_NCP 0x1e51
133 #define MSCC_MS_SAM_NM_FLOW_CP 0x1e52
134 #define MSCC_MS_MISC_CONTROL 0x1e5f
135 #define MSCC_MS_COUNT_CONTROL 0x3204
136 #define MSCC_MS_PARAMS2_IG_CC_CONTROL 0x3a10
137 #define MSCC_MS_PARAMS2_IG_CP_TAG 0x3a14
138 #define MSCC_MS_VLAN_MTU_CHECK(x) (0x3c40 + (x))
139 #define MSCC_MS_NON_VLAN_MTU_CHECK 0x3c48
140 #define MSCC_MS_PP_CTRL 0x3c4b
141 #define MSCC_MS_STATUS_CONTEXT_CTRL 0x3d02
142 #define MSCC_MS_INTR_CTRL_STATUS 0x3d04
143 #define MSCC_MS_BLOCK_CTX_UPDATE 0x3d0c
144 #define MSCC_MS_AIC_CTRL 0x3e02
147 #define MSCC_MS_ENA_CFG_CLK_ENA BIT(0)
148 #define MSCC_MS_ENA_CFG_SW_RST BIT(1)
149 #define MSCC_MS_ENA_CFG_MACSEC_BYPASS_ENA BIT(8)
150 #define MSCC_MS_ENA_CFG_MACSEC_ENA BIT(9)
151 #define MSCC_MS_ENA_CFG_MACSEC_SPEED_MODE(x) ((x) << 10)
152 #define MSCC_MS_ENA_CFG_MACSEC_SPEED_MODE_M GENMASK(12, 10)
155 #define MSCC_MS_FC_CFG_FCBUF_ENA BIT(0)
156 #define MSCC_MS_FC_CFG_USE_PKT_EXPANSION_INDICATION BIT(1)
157 #define MSCC_MS_FC_CFG_LOW_THRESH(x) ((x) << 4)
158 #define MSCC_MS_FC_CFG_LOW_THRESH_M GENMASK(7, 4)
159 #define MSCC_MS_FC_CFG_HIGH_THRESH(x) ((x) << 8)
160 #define MSCC_MS_FC_CFG_HIGH_THRESH_M GENMASK(11, 8)
161 #define MSCC_MS_FC_CFG_LOW_BYTES_VAL(x) ((x) << 12)
162 #define MSCC_MS_FC_CFG_LOW_BYTES_VAL_M GENMASK(14, 12)
163 #define MSCC_MS_FC_CFG_HIGH_BYTES_VAL(x) ((x) << 16)
164 #define MSCC_MS_FC_CFG_HIGH_BYTES_VAL_M GENMASK(18, 16)
166 /* MSCC_MS_SAM_MAC_SA_MATCH_HI */
167 #define MSCC_MS_SAM_MAC_SA_MATCH_HI_ETYPE(x) ((x) << 16)
168 #define MSCC_MS_SAM_MAC_SA_MATCH_HI_ETYPE_M GENMASK(31, 16)
170 /* MACSEC_SAM_MISC_MATCH */
171 #define MSCC_MS_SAM_MISC_MATCH_VLAN_VALID BIT(0)
172 #define MSCC_MS_SAM_MISC_MATCH_QINQ_FOUND BIT(1)
173 #define MSCC_MS_SAM_MISC_MATCH_STAG_VALID BIT(2)
174 #define MSCC_MS_SAM_MISC_MATCH_QTAG_VALID BIT(3)
175 #define MSCC_MS_SAM_MISC_MATCH_VLAN_UP(x) ((x) << 4)
176 #define MSCC_MS_SAM_MISC_MATCH_VLAN_UP_M GENMASK(6, 4)
177 #define MSCC_MS_SAM_MISC_MATCH_CONTROL_PACKET BIT(7)
178 #define MSCC_MS_SAM_MISC_MATCH_UNTAGGED BIT(8)
179 #define MSCC_MS_SAM_MISC_MATCH_TAGGED BIT(9)
180 #define MSCC_MS_SAM_MISC_MATCH_BAD_TAG BIT(10)
181 #define MSCC_MS_SAM_MISC_MATCH_KAY_TAG BIT(11)
182 #define MSCC_MS_SAM_MISC_MATCH_SOURCE_PORT(x) ((x) << 12)
183 #define MSCC_MS_SAM_MISC_MATCH_SOURCE_PORT_M GENMASK(13, 12)
184 #define MSCC_MS_SAM_MISC_MATCH_PRIORITY(x) ((x) << 16)
185 #define MSCC_MS_SAM_MISC_MATCH_PRIORITY_M GENMASK(19, 16)
186 #define MSCC_MS_SAM_MISC_MATCH_AN(x) ((x) << 24)
187 #define MSCC_MS_SAM_MISC_MATCH_TCI(x) ((x) << 26)
189 /* MACSEC_SAM_MASK */
190 #define MSCC_MS_SAM_MASK_MAC_SA_MASK(x) (x)
191 #define MSCC_MS_SAM_MASK_MAC_SA_MASK_M GENMASK(5, 0)
192 #define MSCC_MS_SAM_MASK_MAC_DA_MASK(x) ((x) << 6)
193 #define MSCC_MS_SAM_MASK_MAC_DA_MASK_M GENMASK(11, 6)
194 #define MSCC_MS_SAM_MASK_MAC_ETYPE_MASK BIT(12)
195 #define MSCC_MS_SAM_MASK_VLAN_VLD_MASK BIT(13)
196 #define MSCC_MS_SAM_MASK_QINQ_FOUND_MASK BIT(14)
197 #define MSCC_MS_SAM_MASK_STAG_VLD_MASK BIT(15)
198 #define MSCC_MS_SAM_MASK_QTAG_VLD_MASK BIT(16)
199 #define MSCC_MS_SAM_MASK_VLAN_UP_MASK BIT(17)
200 #define MSCC_MS_SAM_MASK_VLAN_ID_MASK BIT(18)
201 #define MSCC_MS_SAM_MASK_SOURCE_PORT_MASK BIT(19)
202 #define MSCC_MS_SAM_MASK_CTL_PACKET_MASK BIT(20)
203 #define MSCC_MS_SAM_MASK_VLAN_UP_INNER_MASK BIT(21)
204 #define MSCC_MS_SAM_MASK_VLAN_ID_INNER_MASK BIT(22)
205 #define MSCC_MS_SAM_MASK_SCI_MASK BIT(23)
206 #define MSCC_MS_SAM_MASK_AN_MASK(x) ((x) << 24)
207 #define MSCC_MS_SAM_MASK_TCI_MASK(x) ((x) << 26)
209 /* MACSEC_SAM_FLOW_CTRL_EGR */
210 #define MSCC_MS_SAM_FLOW_CTRL_FLOW_TYPE(x) (x)
211 #define MSCC_MS_SAM_FLOW_CTRL_FLOW_TYPE_M GENMASK(1, 0)
212 #define MSCC_MS_SAM_FLOW_CTRL_DEST_PORT(x) ((x) << 2)
213 #define MSCC_MS_SAM_FLOW_CTRL_DEST_PORT_M GENMASK(3, 2)
214 #define MSCC_MS_SAM_FLOW_CTRL_RESV_4 BIT(4)
215 #define MSCC_MS_SAM_FLOW_CTRL_FLOW_CRYPT_AUTH BIT(5)
216 #define MSCC_MS_SAM_FLOW_CTRL_DROP_ACTION(x) ((x) << 6)
217 #define MSCC_MS_SAM_FLOW_CTRL_DROP_ACTION_M GENMASK(7, 6)
218 #define MSCC_MS_SAM_FLOW_CTRL_RESV_15_TO_8(x) ((x) << 8)
219 #define MSCC_MS_SAM_FLOW_CTRL_RESV_15_TO_8_M GENMASK(15, 8)
220 #define MSCC_MS_SAM_FLOW_CTRL_PROTECT_FRAME BIT(16)
221 #define MSCC_MS_SAM_FLOW_CTRL_REPLAY_PROTECT BIT(16)
222 #define MSCC_MS_SAM_FLOW_CTRL_SA_IN_USE BIT(17)
223 #define MSCC_MS_SAM_FLOW_CTRL_INCLUDE_SCI BIT(18)
224 #define MSCC_MS_SAM_FLOW_CTRL_USE_ES BIT(19)
225 #define MSCC_MS_SAM_FLOW_CTRL_USE_SCB BIT(20)
226 #define MSCC_MS_SAM_FLOW_CTRL_VALIDATE_FRAMES(x) ((x) << 19)
227 #define MSCC_MS_SAM_FLOW_CTRL_TAG_BYPASS_SIZE(x) ((x) << 21)
228 #define MSCC_MS_SAM_FLOW_CTRL_TAG_BYPASS_SIZE_M GENMASK(22, 21)
229 #define MSCC_MS_SAM_FLOW_CTRL_RESV_23 BIT(23)
230 #define MSCC_MS_SAM_FLOW_CTRL_CONFIDENTIALITY_OFFSET(x) ((x) << 24)
231 #define MSCC_MS_SAM_FLOW_CTRL_CONFIDENTIALITY_OFFSET_M GENMASK(30, 24)
232 #define MSCC_MS_SAM_FLOW_CTRL_CONF_PROTECT BIT(31)
234 /* MACSEC_SAM_CP_TAG */
235 #define MSCC_MS_SAM_CP_TAG_MAP_TBL(x) (x)
236 #define MSCC_MS_SAM_CP_TAG_MAP_TBL_M GENMASK(23, 0)
237 #define MSCC_MS_SAM_CP_TAG_DEF_UP(x) ((x) << 24)
238 #define MSCC_MS_SAM_CP_TAG_DEF_UP_M GENMASK(26, 24)
239 #define MSCC_MS_SAM_CP_TAG_STAG_UP_EN BIT(27)
240 #define MSCC_MS_SAM_CP_TAG_QTAG_UP_EN BIT(28)
241 #define MSCC_MS_SAM_CP_TAG_PARSE_QINQ BIT(29)
242 #define MSCC_MS_SAM_CP_TAG_PARSE_STAG BIT(30)
243 #define MSCC_MS_SAM_CP_TAG_PARSE_QTAG BIT(31)
245 /* MACSEC_SAM_NM_FLOW_NCP */
246 #define MSCC_MS_SAM_NM_FLOW_NCP_UNTAGGED_FLOW_TYPE(x) (x)
247 #define MSCC_MS_SAM_NM_FLOW_NCP_UNTAGGED_DEST_PORT(x) ((x) << 2)
248 #define MSCC_MS_SAM_NM_FLOW_NCP_UNTAGGED_DROP_ACTION(x) ((x) << 6)
249 #define MSCC_MS_SAM_NM_FLOW_NCP_TAGGED_FLOW_TYPE(x) ((x) << 8)
250 #define MSCC_MS_SAM_NM_FLOW_NCP_TAGGED_DEST_PORT(x) ((x) << 10)
251 #define MSCC_MS_SAM_NM_FLOW_NCP_TAGGED_DROP_ACTION(x) ((x) << 14)
252 #define MSCC_MS_SAM_NM_FLOW_NCP_BADTAG_FLOW_TYPE(x) ((x) << 16)
253 #define MSCC_MS_SAM_NM_FLOW_NCP_BADTAG_DEST_PORT(x) ((x) << 18)
254 #define MSCC_MS_SAM_NM_FLOW_NCP_BADTAG_DROP_ACTION(x) ((x) << 22)
255 #define MSCC_MS_SAM_NM_FLOW_NCP_KAY_FLOW_TYPE(x) ((x) << 24)
256 #define MSCC_MS_SAM_NM_FLOW_NCP_KAY_DEST_PORT(x) ((x) << 26)
257 #define MSCC_MS_SAM_NM_FLOW_NCP_KAY_DROP_ACTION(x) ((x) << 30)
259 /* MACSEC_SAM_NM_FLOW_CP */
260 #define MSCC_MS_SAM_NM_FLOW_CP_UNTAGGED_FLOW_TYPE(x) (x)
261 #define MSCC_MS_SAM_NM_FLOW_CP_UNTAGGED_DEST_PORT(x) ((x) << 2)
262 #define MSCC_MS_SAM_NM_FLOW_CP_UNTAGGED_DROP_ACTION(x) ((x) << 6)
263 #define MSCC_MS_SAM_NM_FLOW_CP_TAGGED_FLOW_TYPE(x) ((x) << 8)
264 #define MSCC_MS_SAM_NM_FLOW_CP_TAGGED_DEST_PORT(x) ((x) << 10)
265 #define MSCC_MS_SAM_NM_FLOW_CP_TAGGED_DROP_ACTION(x) ((x) << 14)
266 #define MSCC_MS_SAM_NM_FLOW_CP_BADTAG_FLOW_TYPE(x) ((x) << 16)
267 #define MSCC_MS_SAM_NM_FLOW_CP_BADTAG_DEST_PORT(x) ((x) << 18)
268 #define MSCC_MS_SAM_NM_FLOW_CP_BADTAG_DROP_ACTION(x) ((x) << 22)
269 #define MSCC_MS_SAM_NM_FLOW_CP_KAY_FLOW_TYPE(x) ((x) << 24)
270 #define MSCC_MS_SAM_NM_FLOW_CP_KAY_DEST_PORT(x) ((x) << 26)
271 #define MSCC_MS_SAM_NM_FLOW_CP_KAY_DROP_ACTION(x) ((x) << 30)
273 /* MACSEC_MISC_CONTROL */
274 #define MSCC_MS_MISC_CONTROL_MC_LATENCY_FIX(x) (x)
275 #define MSCC_MS_MISC_CONTROL_MC_LATENCY_FIX_M GENMASK(5, 0)
276 #define MSCC_MS_MISC_CONTROL_STATIC_BYPASS BIT(8)
277 #define MSCC_MS_MISC_CONTROL_NM_MACSEC_EN BIT(9)
278 #define MSCC_MS_MISC_CONTROL_VALIDATE_FRAMES(x) ((x) << 10)
279 #define MSCC_MS_MISC_CONTROL_VALIDATE_FRAMES_M GENMASK(11, 10)
280 #define MSCC_MS_MISC_CONTROL_XFORM_REC_SIZE(x) ((x) << 24)
281 #define MSCC_MS_MISC_CONTROL_XFORM_REC_SIZE_M GENMASK(25, 24)
283 /* MACSEC_COUNT_CONTROL */
284 #define MSCC_MS_COUNT_CONTROL_RESET_ALL BIT(0)
285 #define MSCC_MS_COUNT_CONTROL_DEBUG_ACCESS BIT(1)
286 #define MSCC_MS_COUNT_CONTROL_SATURATE_CNTRS BIT(2)
287 #define MSCC_MS_COUNT_CONTROL_AUTO_CNTR_RESET BIT(3)
289 /* MACSEC_PARAMS2_IG_CC_CONTROL */
290 #define MSCC_MS_PARAMS2_IG_CC_CONTROL_NON_MATCH_CTRL_ACT BIT(14)
291 #define MSCC_MS_PARAMS2_IG_CC_CONTROL_NON_MATCH_ACT BIT(15)
293 /* MACSEC_PARAMS2_IG_CP_TAG */
294 #define MSCC_MS_PARAMS2_IG_CP_TAG_MAP_TBL(x) (x)
295 #define MSCC_MS_PARAMS2_IG_CP_TAG_MAP_TBL_M GENMASK(23, 0)
296 #define MSCC_MS_PARAMS2_IG_CP_TAG_DEF_UP(x) ((x) << 24)
297 #define MSCC_MS_PARAMS2_IG_CP_TAG_DEF_UP_M GENMASK(26, 24)
298 #define MSCC_MS_PARAMS2_IG_CP_TAG_STAG_UP_EN BIT(27)
299 #define MSCC_MS_PARAMS2_IG_CP_TAG_QTAG_UP_EN BIT(28)
300 #define MSCC_MS_PARAMS2_IG_CP_TAG_PARSE_QINQ BIT(29)
301 #define MSCC_MS_PARAMS2_IG_CP_TAG_PARSE_STAG BIT(30)
302 #define MSCC_MS_PARAMS2_IG_CP_TAG_PARSE_QTAG BIT(31)
304 /* MACSEC_VLAN_MTU_CHECK */
305 #define MSCC_MS_VLAN_MTU_CHECK_MTU_COMPARE(x) (x)
306 #define MSCC_MS_VLAN_MTU_CHECK_MTU_COMPARE_M GENMASK(14, 0)
307 #define MSCC_MS_VLAN_MTU_CHECK_MTU_COMP_DROP BIT(15)
309 /* MACSEC_NON_VLAN_MTU_CHECK */
310 #define MSCC_MS_NON_VLAN_MTU_CHECK_NV_MTU_COMPARE(x) (x)
311 #define MSCC_MS_NON_VLAN_MTU_CHECK_NV_MTU_COMPARE_M GENMASK(14, 0)
312 #define MSCC_MS_NON_VLAN_MTU_CHECK_NV_MTU_COMP_DROP BIT(15)
315 #define MSCC_MS_PP_CTRL_MACSEC_OCTET_INCR_MODE BIT(0)
317 /* MACSEC_INTR_CTRL_STATUS */
318 #define MSCC_MS_INTR_CTRL_STATUS_INTR_CLR_STATUS(x) (x)
319 #define MSCC_MS_INTR_CTRL_STATUS_INTR_CLR_STATUS_M GENMASK(15, 0)
320 #define MSCC_MS_INTR_CTRL_STATUS_INTR_ENABLE(x) ((x) << 16)
321 #define MSCC_MS_INTR_CTRL_STATUS_INTR_ENABLE_M GENMASK(31, 16)
322 #define MACSEC_INTR_CTRL_STATUS_ROLLOVER BIT(5)
324 #endif /* _MSCC_PHY_MACSEC_H_ */