xref: /linux/drivers/net/ethernet/aquantia/atlantic/macsec/macsec_api.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Atlantic Network Driver
3  * Copyright (C) 2020 Marvell International Ltd.
4  */
5 
6 #ifndef __MACSEC_API_H__
7 #define __MACSEC_API_H__
8 
9 #include "aq_hw.h"
10 #include "macsec_struct.h"
11 
12 #define NUMROWS_INGRESSPRECTLFRECORD 24
13 #define ROWOFFSET_INGRESSPRECTLFRECORD 0
14 
15 #define NUMROWS_INGRESSPRECLASSRECORD 48
16 #define ROWOFFSET_INGRESSPRECLASSRECORD 0
17 
18 #define NUMROWS_INGRESSPOSTCLASSRECORD 48
19 #define ROWOFFSET_INGRESSPOSTCLASSRECORD 0
20 
21 #define NUMROWS_INGRESSSCRECORD 32
22 #define ROWOFFSET_INGRESSSCRECORD 0
23 
24 #define NUMROWS_INGRESSSARECORD 32
25 #define ROWOFFSET_INGRESSSARECORD 32
26 
27 #define NUMROWS_INGRESSSAKEYRECORD 32
28 #define ROWOFFSET_INGRESSSAKEYRECORD 0
29 
30 #define NUMROWS_INGRESSPOSTCTLFRECORD 24
31 #define ROWOFFSET_INGRESSPOSTCTLFRECORD 0
32 
33 #define NUMROWS_EGRESSCTLFRECORD 24
34 #define ROWOFFSET_EGRESSCTLFRECORD 0
35 
36 #define NUMROWS_EGRESSCLASSRECORD 48
37 #define ROWOFFSET_EGRESSCLASSRECORD 0
38 
39 #define NUMROWS_EGRESSSCRECORD 32
40 #define ROWOFFSET_EGRESSSCRECORD 0
41 
42 #define NUMROWS_EGRESSSARECORD 32
43 #define ROWOFFSET_EGRESSSARECORD 32
44 
45 #define NUMROWS_EGRESSSAKEYRECORD 32
46 #define ROWOFFSET_EGRESSSAKEYRECORD 96
47 
48 /*!  Read the raw table data from the specified row of the Egress CTL
49  *   Filter table, and unpack it into the fields of rec.
50  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
51  *  table_index - The table row to read (max 23).
52  */
53 int aq_mss_get_egress_ctlf_record(struct aq_hw_s *hw,
54 				  struct aq_mss_egress_ctlf_record *rec,
55 				  u16 table_index);
56 
57 /*!  Pack the fields of rec, and write the packed data into the
58  *   specified row of the Egress CTL Filter table.
59  *  rec - [IN] The bitfield values to write to the table row.
60  *  table_index - The table row to write(max 23).
61  */
62 int aq_mss_set_egress_ctlf_record(struct aq_hw_s *hw,
63 				  const struct aq_mss_egress_ctlf_record *rec,
64 				  u16 table_index);
65 
66 /*!  Read the raw table data from the specified row of the Egress
67  *   Packet Classifier table, and unpack it into the fields of rec.
68  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
69  *  table_index - The table row to read (max 47).
70  */
71 int aq_mss_get_egress_class_record(struct aq_hw_s *hw,
72 				   struct aq_mss_egress_class_record *rec,
73 				   u16 table_index);
74 
75 /*!  Pack the fields of rec, and write the packed data into the
76  *   specified row of the Egress Packet Classifier table.
77  *  rec - [IN] The bitfield values to write to the table row.
78  *  table_index - The table row to write (max 47).
79  */
80 int aq_mss_set_egress_class_record(struct aq_hw_s *hw,
81 				   const struct aq_mss_egress_class_record *rec,
82 				   u16 table_index);
83 
84 /*!  Read the raw table data from the specified row of the Egress SC
85  *   Lookup table, and unpack it into the fields of rec.
86  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
87  *  table_index - The table row to read (max 31).
88  */
89 int aq_mss_get_egress_sc_record(struct aq_hw_s *hw,
90 				struct aq_mss_egress_sc_record *rec,
91 				u16 table_index);
92 
93 /*!  Pack the fields of rec, and write the packed data into the
94  *   specified row of the Egress SC Lookup table.
95  *  rec - [IN] The bitfield values to write to the table row.
96  *  table_index - The table row to write (max 31).
97  */
98 int aq_mss_set_egress_sc_record(struct aq_hw_s *hw,
99 				const struct aq_mss_egress_sc_record *rec,
100 				u16 table_index);
101 
102 /*!  Read the raw table data from the specified row of the Egress SA
103  *   Lookup table, and unpack it into the fields of rec.
104  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
105  *  table_index - The table row to read (max 31).
106  */
107 int aq_mss_get_egress_sa_record(struct aq_hw_s *hw,
108 				struct aq_mss_egress_sa_record *rec,
109 				u16 table_index);
110 
111 /*!  Pack the fields of rec, and write the packed data into the
112  *   specified row of the Egress SA Lookup table.
113  *  rec  - [IN] The bitfield values to write to the table row.
114  *  table_index - The table row to write (max 31).
115  */
116 int aq_mss_set_egress_sa_record(struct aq_hw_s *hw,
117 				const struct aq_mss_egress_sa_record *rec,
118 				u16 table_index);
119 
120 /*!  Read the raw table data from the specified row of the Egress SA
121  *   Key Lookup table, and unpack it into the fields of rec.
122  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
123  *  table_index - The table row to read (max 31).
124  */
125 int aq_mss_get_egress_sakey_record(struct aq_hw_s *hw,
126 				   struct aq_mss_egress_sakey_record *rec,
127 				   u16 table_index);
128 
129 /*!  Pack the fields of rec, and write the packed data into the
130  *   specified row of the Egress SA Key Lookup table.
131  *  rec - [IN] The bitfield values to write to the table row.
132  *  table_index - The table row to write (max 31).
133  */
134 int aq_mss_set_egress_sakey_record(struct aq_hw_s *hw,
135 				   const struct aq_mss_egress_sakey_record *rec,
136 				   u16 table_index);
137 
138 /*!  Read the raw table data from the specified row of the Ingress
139  *   Pre-MACSec CTL Filter table, and unpack it into the fields of rec.
140  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
141  *  table_index - The table row to read (max 23).
142  */
143 int aq_mss_get_ingress_prectlf_record(struct aq_hw_s *hw,
144 				      struct aq_mss_ingress_prectlf_record *rec,
145 				      u16 table_index);
146 
147 /*!  Pack the fields of rec, and write the packed data into the
148  *   specified row of the Ingress Pre-MACSec CTL Filter table.
149  *  rec - [IN] The bitfield values to write to the table row.
150  *  table_index - The table row to write(max 23).
151  */
152 int aq_mss_set_ingress_prectlf_record(struct aq_hw_s *hw,
153 	const struct aq_mss_ingress_prectlf_record *rec,
154 	u16 table_index);
155 
156 /*!  Read the raw table data from the specified row of the Ingress
157  *   Pre-MACSec Packet Classifier table, and unpack it into the fields of rec.
158  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
159  *  table_index - The table row to read (max 47).
160  */
161 int aq_mss_get_ingress_preclass_record(struct aq_hw_s *hw,
162 	struct aq_mss_ingress_preclass_record *rec,
163 	u16 table_index);
164 
165 /*!  Pack the fields of rec, and write the packed data into the
166  *   specified row of the Ingress Pre-MACSec Packet Classifier table.
167  *  rec - [IN] The bitfield values to write to the table row.
168  *  table_index - The table row to write(max 47).
169  */
170 int aq_mss_set_ingress_preclass_record(struct aq_hw_s *hw,
171 	const struct aq_mss_ingress_preclass_record *rec,
172 	u16 table_index);
173 
174 /*!  Read the raw table data from the specified row of the Ingress SC
175  *   Lookup table, and unpack it into the fields of rec.
176  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
177  *  table_index - The table row to read (max 31).
178  */
179 int aq_mss_get_ingress_sc_record(struct aq_hw_s *hw,
180 				 struct aq_mss_ingress_sc_record *rec,
181 				 u16 table_index);
182 
183 /*!  Pack the fields of rec, and write the packed data into the
184  *   specified row of the Ingress SC Lookup table.
185  *  rec - [IN] The bitfield values to write to the table row.
186  *  table_index - The table row to write(max 31).
187  */
188 int aq_mss_set_ingress_sc_record(struct aq_hw_s *hw,
189 				 const struct aq_mss_ingress_sc_record *rec,
190 				 u16 table_index);
191 
192 /*!  Read the raw table data from the specified row of the Ingress SA
193  *   Lookup table, and unpack it into the fields of rec.
194  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
195  *  table_index - The table row to read (max 31).
196  */
197 int aq_mss_get_ingress_sa_record(struct aq_hw_s *hw,
198 				 struct aq_mss_ingress_sa_record *rec,
199 				 u16 table_index);
200 
201 /*!  Pack the fields of rec, and write the packed data into the
202  *   specified row of the Ingress SA Lookup table.
203  *  rec - [IN] The bitfield values to write to the table row.
204  *  table_index - The table row to write(max 31).
205  */
206 int aq_mss_set_ingress_sa_record(struct aq_hw_s *hw,
207 				 const struct aq_mss_ingress_sa_record *rec,
208 				 u16 table_index);
209 
210 /*!  Read the raw table data from the specified row of the Ingress SA
211  *   Key Lookup table, and unpack it into the fields of rec.
212  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
213  *  table_index - The table row to read (max 31).
214  */
215 int aq_mss_get_ingress_sakey_record(struct aq_hw_s *hw,
216 				    struct aq_mss_ingress_sakey_record *rec,
217 				    u16 table_index);
218 
219 /*!  Pack the fields of rec, and write the packed data into the
220  *   specified row of the Ingress SA Key Lookup table.
221  *  rec - [IN] The bitfield values to write to the table row.
222  *  table_index - The table row to write(max 31).
223  */
224 int aq_mss_set_ingress_sakey_record(struct aq_hw_s *hw,
225 	const struct aq_mss_ingress_sakey_record *rec,
226 	u16 table_index);
227 
228 /*!  Read the raw table data from the specified row of the Ingress
229  *   Post-MACSec Packet Classifier table, and unpack it into the
230  *   fields of rec.
231  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
232  *  table_index - The table row to read (max 48).
233  */
234 int aq_mss_get_ingress_postclass_record(struct aq_hw_s *hw,
235 	struct aq_mss_ingress_postclass_record *rec,
236 	u16 table_index);
237 
238 /*!  Pack the fields of rec, and write the packed data into the
239  *   specified row of the Ingress Post-MACSec Packet Classifier table.
240  *  rec - [IN] The bitfield values to write to the table row.
241  *  table_index - The table row to write(max 48).
242  */
243 int aq_mss_set_ingress_postclass_record(struct aq_hw_s *hw,
244 	const struct aq_mss_ingress_postclass_record *rec,
245 	u16 table_index);
246 
247 /*!  Read the raw table data from the specified row of the Ingress
248  *   Post-MACSec CTL Filter table, and unpack it into the fields of rec.
249  *  rec - [OUT] The raw table row data will be unpacked into the fields of rec.
250  *  table_index - The table row to read (max 23).
251  */
252 int aq_mss_get_ingress_postctlf_record(struct aq_hw_s *hw,
253 	struct aq_mss_ingress_postctlf_record *rec,
254 	u16 table_index);
255 
256 /*!  Pack the fields of rec, and write the packed data into the
257  *   specified row of the Ingress Post-MACSec CTL Filter table.
258  *  rec - [IN] The bitfield values to write to the table row.
259  *  table_index - The table row to write(max 23).
260  */
261 int aq_mss_set_ingress_postctlf_record(struct aq_hw_s *hw,
262 	const struct aq_mss_ingress_postctlf_record *rec,
263 	u16 table_index);
264 
265 /*!  Read the counters for the specified SC, and unpack them into the
266  *   fields of counters.
267  *  counters - [OUT] The raw table row data will be unpacked here.
268  *  sc_index - The table row to read (max 31).
269  */
270 int aq_mss_get_egress_sc_counters(struct aq_hw_s *hw,
271 				  struct aq_mss_egress_sc_counters *counters,
272 				  u16 sc_index);
273 
274 /*!  Read the counters for the specified SA, and unpack them into the
275  *   fields of counters.
276  *  counters - [OUT] The raw table row data will be unpacked here.
277  *  sa_index - The table row to read (max 31).
278  */
279 int aq_mss_get_egress_sa_counters(struct aq_hw_s *hw,
280 				  struct aq_mss_egress_sa_counters *counters,
281 				  u16 sa_index);
282 
283 /*!  Read the counters for the common egress counters, and unpack them
284  *   into the fields of counters.
285  *  counters - [OUT] The raw table row data will be unpacked here.
286  */
287 int aq_mss_get_egress_common_counters(struct aq_hw_s *hw,
288 	struct aq_mss_egress_common_counters *counters);
289 
290 /*!  Clear all Egress counters to 0.*/
291 int aq_mss_clear_egress_counters(struct aq_hw_s *hw);
292 
293 /*!  Read the counters for the specified SA, and unpack them into the
294  *   fields of counters.
295  *  counters - [OUT] The raw table row data will be unpacked here.
296  *  sa_index - The table row to read (max 31).
297  */
298 int aq_mss_get_ingress_sa_counters(struct aq_hw_s *hw,
299 				   struct aq_mss_ingress_sa_counters *counters,
300 				   u16 sa_index);
301 
302 /*!  Read the counters for the common ingress counters, and unpack them
303  *   into the fields of counters.
304  *  counters - [OUT] The raw table row data will be unpacked here.
305  */
306 int aq_mss_get_ingress_common_counters(struct aq_hw_s *hw,
307 	struct aq_mss_ingress_common_counters *counters);
308 
309 /*!  Clear all Ingress counters to 0. */
310 int aq_mss_clear_ingress_counters(struct aq_hw_s *hw);
311 
312 /*!  Get Egress SA expired. */
313 int aq_mss_get_egress_sa_expired(struct aq_hw_s *hw, u32 *expired);
314 /*!  Get Egress SA threshold expired. */
315 int aq_mss_get_egress_sa_threshold_expired(struct aq_hw_s *hw,
316 					   u32 *expired);
317 /*!  Set Egress SA expired. */
318 int aq_mss_set_egress_sa_expired(struct aq_hw_s *hw, u32 expired);
319 /*!  Set Egress SA threshold expired. */
320 int aq_mss_set_egress_sa_threshold_expired(struct aq_hw_s *hw,
321 					   u32 expired);
322 
323 #endif /* __MACSEC_API_H__ */
324