Commit | Line | Data |
---|---|---|
4ec14b76 IS |
1 | /* |
2 | * drivers/net/ethernet/mellanox/mlxsw/reg.h | |
3 | * Copyright (c) 2015 Mellanox Technologies. All rights reserved. | |
4 | * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com> | |
5 | * Copyright (c) 2015 Elad Raz <eladr@mellanox.com> | |
6 | * Copyright (c) 2015 Jiri Pirko <jiri@mellanox.com> | |
7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions are met: | |
10 | * | |
11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | |
15 | * documentation and/or other materials provided with the distribution. | |
16 | * 3. Neither the names of the copyright holders nor the names of its | |
17 | * contributors may be used to endorse or promote products derived from | |
18 | * this software without specific prior written permission. | |
19 | * | |
20 | * Alternatively, this software may be distributed under the terms of the | |
21 | * GNU General Public License ("GPL") version 2 as published by the Free | |
22 | * Software Foundation. | |
23 | * | |
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
34 | * POSSIBILITY OF SUCH DAMAGE. | |
35 | */ | |
36 | ||
37 | #ifndef _MLXSW_REG_H | |
38 | #define _MLXSW_REG_H | |
39 | ||
40 | #include <linux/string.h> | |
41 | #include <linux/bitops.h> | |
42 | #include <linux/if_vlan.h> | |
43 | ||
44 | #include "item.h" | |
45 | #include "port.h" | |
46 | ||
47 | struct mlxsw_reg_info { | |
48 | u16 id; | |
49 | u16 len; /* In u8 */ | |
50 | }; | |
51 | ||
52 | #define MLXSW_REG(type) (&mlxsw_reg_##type) | |
53 | #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len | |
54 | #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len) | |
55 | ||
56 | /* SGCR - Switch General Configuration Register | |
57 | * -------------------------------------------- | |
58 | * This register is used for configuration of the switch capabilities. | |
59 | */ | |
60 | #define MLXSW_REG_SGCR_ID 0x2000 | |
61 | #define MLXSW_REG_SGCR_LEN 0x10 | |
62 | ||
63 | static const struct mlxsw_reg_info mlxsw_reg_sgcr = { | |
64 | .id = MLXSW_REG_SGCR_ID, | |
65 | .len = MLXSW_REG_SGCR_LEN, | |
66 | }; | |
67 | ||
68 | /* reg_sgcr_llb | |
69 | * Link Local Broadcast (Default=0) | |
70 | * When set, all Link Local packets (224.0.0.X) will be treated as broadcast | |
71 | * packets and ignore the IGMP snooping entries. | |
72 | * Access: RW | |
73 | */ | |
74 | MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1); | |
75 | ||
76 | static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb) | |
77 | { | |
78 | MLXSW_REG_ZERO(sgcr, payload); | |
79 | mlxsw_reg_sgcr_llb_set(payload, !!llb); | |
80 | } | |
81 | ||
82 | /* SPAD - Switch Physical Address Register | |
83 | * --------------------------------------- | |
84 | * The SPAD register configures the switch physical MAC address. | |
85 | */ | |
86 | #define MLXSW_REG_SPAD_ID 0x2002 | |
87 | #define MLXSW_REG_SPAD_LEN 0x10 | |
88 | ||
89 | static const struct mlxsw_reg_info mlxsw_reg_spad = { | |
90 | .id = MLXSW_REG_SPAD_ID, | |
91 | .len = MLXSW_REG_SPAD_LEN, | |
92 | }; | |
93 | ||
94 | /* reg_spad_base_mac | |
95 | * Base MAC address for the switch partitions. | |
96 | * Per switch partition MAC address is equal to: | |
97 | * base_mac + swid | |
98 | * Access: RW | |
99 | */ | |
100 | MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6); | |
101 | ||
e61011b5 IS |
102 | /* SSPR - Switch System Port Record Register |
103 | * ----------------------------------------- | |
104 | * Configures the system port to local port mapping. | |
105 | */ | |
106 | #define MLXSW_REG_SSPR_ID 0x2008 | |
107 | #define MLXSW_REG_SSPR_LEN 0x8 | |
108 | ||
109 | static const struct mlxsw_reg_info mlxsw_reg_sspr = { | |
110 | .id = MLXSW_REG_SSPR_ID, | |
111 | .len = MLXSW_REG_SSPR_LEN, | |
112 | }; | |
113 | ||
114 | /* reg_sspr_m | |
115 | * Master - if set, then the record describes the master system port. | |
116 | * This is needed in case a local port is mapped into several system ports | |
117 | * (for multipathing). That number will be reported as the source system | |
118 | * port when packets are forwarded to the CPU. Only one master port is allowed | |
119 | * per local port. | |
120 | * | |
121 | * Note: Must be set for Spectrum. | |
122 | * Access: RW | |
123 | */ | |
124 | MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1); | |
125 | ||
126 | /* reg_sspr_local_port | |
127 | * Local port number. | |
128 | * | |
129 | * Access: RW | |
130 | */ | |
131 | MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8); | |
132 | ||
133 | /* reg_sspr_sub_port | |
134 | * Virtual port within the physical port. | |
135 | * Should be set to 0 when virtual ports are not enabled on the port. | |
136 | * | |
137 | * Access: RW | |
138 | */ | |
139 | MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8); | |
140 | ||
141 | /* reg_sspr_system_port | |
142 | * Unique identifier within the stacking domain that represents all the ports | |
143 | * that are available in the system (external ports). | |
144 | * | |
145 | * Currently, only single-ASIC configurations are supported, so we default to | |
146 | * 1:1 mapping between system ports and local ports. | |
147 | * Access: Index | |
148 | */ | |
149 | MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16); | |
150 | ||
151 | static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port) | |
152 | { | |
153 | MLXSW_REG_ZERO(sspr, payload); | |
154 | mlxsw_reg_sspr_m_set(payload, 1); | |
155 | mlxsw_reg_sspr_local_port_set(payload, local_port); | |
156 | mlxsw_reg_sspr_sub_port_set(payload, 0); | |
157 | mlxsw_reg_sspr_system_port_set(payload, local_port); | |
158 | } | |
159 | ||
e534a56a JP |
160 | /* SFDAT - Switch Filtering Database Aging Time |
161 | * -------------------------------------------- | |
162 | * Controls the Switch aging time. Aging time is able to be set per Switch | |
163 | * Partition. | |
164 | */ | |
165 | #define MLXSW_REG_SFDAT_ID 0x2009 | |
166 | #define MLXSW_REG_SFDAT_LEN 0x8 | |
167 | ||
168 | static const struct mlxsw_reg_info mlxsw_reg_sfdat = { | |
169 | .id = MLXSW_REG_SFDAT_ID, | |
170 | .len = MLXSW_REG_SFDAT_LEN, | |
171 | }; | |
172 | ||
173 | /* reg_sfdat_swid | |
174 | * Switch partition ID. | |
175 | * Access: Index | |
176 | */ | |
177 | MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8); | |
178 | ||
179 | /* reg_sfdat_age_time | |
180 | * Aging time in seconds | |
181 | * Min - 10 seconds | |
182 | * Max - 1,000,000 seconds | |
183 | * Default is 300 seconds. | |
184 | * Access: RW | |
185 | */ | |
186 | MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20); | |
187 | ||
188 | static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time) | |
189 | { | |
190 | MLXSW_REG_ZERO(sfdat, payload); | |
191 | mlxsw_reg_sfdat_swid_set(payload, 0); | |
192 | mlxsw_reg_sfdat_age_time_set(payload, age_time); | |
193 | } | |
194 | ||
236033b3 JP |
195 | /* SFD - Switch Filtering Database |
196 | * ------------------------------- | |
197 | * The following register defines the access to the filtering database. | |
198 | * The register supports querying, adding, removing and modifying the database. | |
199 | * The access is optimized for bulk updates in which case more than one | |
200 | * FDB record is present in the same command. | |
201 | */ | |
202 | #define MLXSW_REG_SFD_ID 0x200A | |
203 | #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */ | |
204 | #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */ | |
205 | #define MLXSW_REG_SFD_REC_MAX_COUNT 64 | |
206 | #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \ | |
207 | MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT) | |
208 | ||
209 | static const struct mlxsw_reg_info mlxsw_reg_sfd = { | |
210 | .id = MLXSW_REG_SFD_ID, | |
211 | .len = MLXSW_REG_SFD_LEN, | |
212 | }; | |
213 | ||
214 | /* reg_sfd_swid | |
215 | * Switch partition ID for queries. Reserved on Write. | |
216 | * Access: Index | |
217 | */ | |
218 | MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8); | |
219 | ||
220 | enum mlxsw_reg_sfd_op { | |
221 | /* Dump entire FDB a (process according to record_locator) */ | |
222 | MLXSW_REG_SFD_OP_QUERY_DUMP = 0, | |
223 | /* Query records by {MAC, VID/FID} value */ | |
224 | MLXSW_REG_SFD_OP_QUERY_QUERY = 1, | |
225 | /* Query and clear activity. Query records by {MAC, VID/FID} value */ | |
226 | MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2, | |
227 | /* Test. Response indicates if each of the records could be | |
228 | * added to the FDB. | |
229 | */ | |
230 | MLXSW_REG_SFD_OP_WRITE_TEST = 0, | |
231 | /* Add/modify. Aged-out records cannot be added. This command removes | |
232 | * the learning notification of the {MAC, VID/FID}. Response includes | |
233 | * the entries that were added to the FDB. | |
234 | */ | |
235 | MLXSW_REG_SFD_OP_WRITE_EDIT = 1, | |
236 | /* Remove record by {MAC, VID/FID}. This command also removes | |
237 | * the learning notification and aged-out notifications | |
238 | * of the {MAC, VID/FID}. The response provides current (pre-removal) | |
239 | * entries as non-aged-out. | |
240 | */ | |
241 | MLXSW_REG_SFD_OP_WRITE_REMOVE = 2, | |
242 | /* Remove learned notification by {MAC, VID/FID}. The response provides | |
243 | * the removed learning notification. | |
244 | */ | |
245 | MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2, | |
246 | }; | |
247 | ||
248 | /* reg_sfd_op | |
249 | * Operation. | |
250 | * Access: OP | |
251 | */ | |
252 | MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2); | |
253 | ||
254 | /* reg_sfd_record_locator | |
255 | * Used for querying the FDB. Use record_locator=0 to initiate the | |
256 | * query. When a record is returned, a new record_locator is | |
257 | * returned to be used in the subsequent query. | |
258 | * Reserved for database update. | |
259 | * Access: Index | |
260 | */ | |
261 | MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30); | |
262 | ||
263 | /* reg_sfd_num_rec | |
264 | * Request: Number of records to read/add/modify/remove | |
265 | * Response: Number of records read/added/replaced/removed | |
266 | * See above description for more details. | |
267 | * Ranges 0..64 | |
268 | * Access: RW | |
269 | */ | |
270 | MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8); | |
271 | ||
272 | static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op, | |
273 | u32 record_locator) | |
274 | { | |
275 | MLXSW_REG_ZERO(sfd, payload); | |
276 | mlxsw_reg_sfd_op_set(payload, op); | |
277 | mlxsw_reg_sfd_record_locator_set(payload, record_locator); | |
278 | } | |
279 | ||
280 | /* reg_sfd_rec_swid | |
281 | * Switch partition ID. | |
282 | * Access: Index | |
283 | */ | |
284 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8, | |
285 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
286 | ||
287 | enum mlxsw_reg_sfd_rec_type { | |
288 | MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0, | |
289 | }; | |
290 | ||
291 | /* reg_sfd_rec_type | |
292 | * FDB record type. | |
293 | * Access: RW | |
294 | */ | |
295 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4, | |
296 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
297 | ||
298 | enum mlxsw_reg_sfd_rec_policy { | |
299 | /* Replacement disabled, aging disabled. */ | |
300 | MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0, | |
301 | /* (mlag remote): Replacement enabled, aging disabled, | |
302 | * learning notification enabled on this port. | |
303 | */ | |
304 | MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1, | |
305 | /* (ingress device): Replacement enabled, aging enabled. */ | |
306 | MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3, | |
307 | }; | |
308 | ||
309 | /* reg_sfd_rec_policy | |
310 | * Policy. | |
311 | * Access: RW | |
312 | */ | |
313 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2, | |
314 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
315 | ||
316 | /* reg_sfd_rec_a | |
317 | * Activity. Set for new static entries. Set for static entries if a frame SMAC | |
318 | * lookup hits on the entry. | |
319 | * To clear the a bit, use "query and clear activity" op. | |
320 | * Access: RO | |
321 | */ | |
322 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1, | |
323 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
324 | ||
325 | /* reg_sfd_rec_mac | |
326 | * MAC address. | |
327 | * Access: Index | |
328 | */ | |
329 | MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6, | |
330 | MLXSW_REG_SFD_REC_LEN, 0x02); | |
331 | ||
332 | enum mlxsw_reg_sfd_rec_action { | |
333 | /* forward */ | |
334 | MLXSW_REG_SFD_REC_ACTION_NOP = 0, | |
335 | /* forward and trap, trap_id is FDB_TRAP */ | |
336 | MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1, | |
337 | /* trap and do not forward, trap_id is FDB_TRAP */ | |
338 | MLXSW_REG_SFD_REC_ACTION_TRAP = 3, | |
339 | MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15, | |
340 | }; | |
341 | ||
342 | /* reg_sfd_rec_action | |
343 | * Action to apply on the packet. | |
344 | * Note: Dynamic entries can only be configured with NOP action. | |
345 | * Access: RW | |
346 | */ | |
347 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4, | |
348 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
349 | ||
350 | /* reg_sfd_uc_sub_port | |
351 | * LAG sub port. | |
352 | * Must be 0 if multichannel VEPA is not enabled. | |
353 | * Access: RW | |
354 | */ | |
355 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8, | |
356 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
357 | ||
358 | /* reg_sfd_uc_fid_vid | |
359 | * Filtering ID or VLAN ID | |
360 | * For SwitchX and SwitchX-2: | |
361 | * - Dynamic entries (policy 2,3) use FID | |
362 | * - Static entries (policy 0) use VID | |
363 | * - When independent learning is configured, VID=FID | |
364 | * For Spectrum: use FID for both Dynamic and Static entries. | |
365 | * VID should not be used. | |
366 | * Access: Index | |
367 | */ | |
368 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
369 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
370 | ||
371 | /* reg_sfd_uc_system_port | |
372 | * Unique port identifier for the final destination of the packet. | |
373 | * Access: RW | |
374 | */ | |
375 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
376 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
377 | ||
378 | static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index, | |
379 | enum mlxsw_reg_sfd_rec_policy policy, | |
380 | const char *mac, u16 vid, | |
381 | enum mlxsw_reg_sfd_rec_action action, | |
382 | u8 local_port) | |
383 | { | |
384 | u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload); | |
385 | ||
386 | if (rec_index >= num_rec) | |
387 | mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1); | |
388 | mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0); | |
389 | mlxsw_reg_sfd_rec_type_set(payload, rec_index, | |
390 | MLXSW_REG_SFD_REC_TYPE_UNICAST); | |
391 | mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); | |
392 | mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac); | |
393 | mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0); | |
394 | mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, vid); | |
395 | mlxsw_reg_sfd_rec_action_set(payload, rec_index, action); | |
396 | mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port); | |
397 | } | |
398 | ||
399 | static inline void | |
400 | mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index, | |
401 | char *mac, u16 *p_vid, | |
402 | u8 *p_local_port) | |
403 | { | |
404 | mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac); | |
405 | *p_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index); | |
406 | *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index); | |
407 | } | |
408 | ||
f5d88f58 JP |
409 | /* SFN - Switch FDB Notification Register |
410 | * ------------------------------------------- | |
411 | * The switch provides notifications on newly learned FDB entries and | |
412 | * aged out entries. The notifications can be polled by software. | |
413 | */ | |
414 | #define MLXSW_REG_SFN_ID 0x200B | |
415 | #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */ | |
416 | #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */ | |
417 | #define MLXSW_REG_SFN_REC_MAX_COUNT 64 | |
418 | #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \ | |
419 | MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT) | |
420 | ||
421 | static const struct mlxsw_reg_info mlxsw_reg_sfn = { | |
422 | .id = MLXSW_REG_SFN_ID, | |
423 | .len = MLXSW_REG_SFN_LEN, | |
424 | }; | |
425 | ||
426 | /* reg_sfn_swid | |
427 | * Switch partition ID. | |
428 | * Access: Index | |
429 | */ | |
430 | MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8); | |
431 | ||
432 | /* reg_sfn_num_rec | |
433 | * Request: Number of learned notifications and aged-out notification | |
434 | * records requested. | |
435 | * Response: Number of notification records returned (must be smaller | |
436 | * than or equal to the value requested) | |
437 | * Ranges 0..64 | |
438 | * Access: OP | |
439 | */ | |
440 | MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8); | |
441 | ||
442 | static inline void mlxsw_reg_sfn_pack(char *payload) | |
443 | { | |
444 | MLXSW_REG_ZERO(sfn, payload); | |
445 | mlxsw_reg_sfn_swid_set(payload, 0); | |
446 | mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT); | |
447 | } | |
448 | ||
449 | /* reg_sfn_rec_swid | |
450 | * Switch partition ID. | |
451 | * Access: RO | |
452 | */ | |
453 | MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8, | |
454 | MLXSW_REG_SFN_REC_LEN, 0x00, false); | |
455 | ||
456 | enum mlxsw_reg_sfn_rec_type { | |
457 | /* MAC addresses learned on a regular port. */ | |
458 | MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5, | |
459 | /* Aged-out MAC address on a regular port */ | |
460 | MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7, | |
461 | }; | |
462 | ||
463 | /* reg_sfn_rec_type | |
464 | * Notification record type. | |
465 | * Access: RO | |
466 | */ | |
467 | MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4, | |
468 | MLXSW_REG_SFN_REC_LEN, 0x00, false); | |
469 | ||
470 | /* reg_sfn_rec_mac | |
471 | * MAC address. | |
472 | * Access: RO | |
473 | */ | |
474 | MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6, | |
475 | MLXSW_REG_SFN_REC_LEN, 0x02); | |
476 | ||
477 | /* reg_sfd_mac_sub_port | |
478 | * VEPA channel on the local port. | |
479 | * 0 if multichannel VEPA is not enabled. | |
480 | * Access: RO | |
481 | */ | |
482 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8, | |
483 | MLXSW_REG_SFN_REC_LEN, 0x08, false); | |
484 | ||
485 | /* reg_sfd_mac_fid | |
486 | * Filtering identifier. | |
487 | * Access: RO | |
488 | */ | |
489 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16, | |
490 | MLXSW_REG_SFN_REC_LEN, 0x08, false); | |
491 | ||
492 | /* reg_sfd_mac_system_port | |
493 | * Unique port identifier for the final destination of the packet. | |
494 | * Access: RO | |
495 | */ | |
496 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16, | |
497 | MLXSW_REG_SFN_REC_LEN, 0x0C, false); | |
498 | ||
499 | static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index, | |
500 | char *mac, u16 *p_vid, | |
501 | u8 *p_local_port) | |
502 | { | |
503 | mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac); | |
504 | *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index); | |
505 | *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index); | |
506 | } | |
507 | ||
4ec14b76 IS |
508 | /* SPMS - Switch Port MSTP/RSTP State Register |
509 | * ------------------------------------------- | |
510 | * Configures the spanning tree state of a physical port. | |
511 | */ | |
3f0effd1 | 512 | #define MLXSW_REG_SPMS_ID 0x200D |
4ec14b76 IS |
513 | #define MLXSW_REG_SPMS_LEN 0x404 |
514 | ||
515 | static const struct mlxsw_reg_info mlxsw_reg_spms = { | |
516 | .id = MLXSW_REG_SPMS_ID, | |
517 | .len = MLXSW_REG_SPMS_LEN, | |
518 | }; | |
519 | ||
520 | /* reg_spms_local_port | |
521 | * Local port number. | |
522 | * Access: Index | |
523 | */ | |
524 | MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8); | |
525 | ||
526 | enum mlxsw_reg_spms_state { | |
527 | MLXSW_REG_SPMS_STATE_NO_CHANGE, | |
528 | MLXSW_REG_SPMS_STATE_DISCARDING, | |
529 | MLXSW_REG_SPMS_STATE_LEARNING, | |
530 | MLXSW_REG_SPMS_STATE_FORWARDING, | |
531 | }; | |
532 | ||
533 | /* reg_spms_state | |
534 | * Spanning tree state of each VLAN ID (VID) of the local port. | |
535 | * 0 - Do not change spanning tree state (used only when writing). | |
536 | * 1 - Discarding. No learning or forwarding to/from this port (default). | |
537 | * 2 - Learning. Port is learning, but not forwarding. | |
538 | * 3 - Forwarding. Port is learning and forwarding. | |
539 | * Access: RW | |
540 | */ | |
541 | MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2); | |
542 | ||
ebb7963f | 543 | static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port) |
4ec14b76 IS |
544 | { |
545 | MLXSW_REG_ZERO(spms, payload); | |
546 | mlxsw_reg_spms_local_port_set(payload, local_port); | |
ebb7963f JP |
547 | } |
548 | ||
549 | static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid, | |
550 | enum mlxsw_reg_spms_state state) | |
551 | { | |
4ec14b76 IS |
552 | mlxsw_reg_spms_state_set(payload, vid, state); |
553 | } | |
554 | ||
b2e345f9 ER |
555 | /* SPVID - Switch Port VID |
556 | * ----------------------- | |
557 | * The switch port VID configures the default VID for a port. | |
558 | */ | |
559 | #define MLXSW_REG_SPVID_ID 0x200E | |
560 | #define MLXSW_REG_SPVID_LEN 0x08 | |
561 | ||
562 | static const struct mlxsw_reg_info mlxsw_reg_spvid = { | |
563 | .id = MLXSW_REG_SPVID_ID, | |
564 | .len = MLXSW_REG_SPVID_LEN, | |
565 | }; | |
566 | ||
567 | /* reg_spvid_local_port | |
568 | * Local port number. | |
569 | * Access: Index | |
570 | */ | |
571 | MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8); | |
572 | ||
573 | /* reg_spvid_sub_port | |
574 | * Virtual port within the physical port. | |
575 | * Should be set to 0 when virtual ports are not enabled on the port. | |
576 | * Access: Index | |
577 | */ | |
578 | MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8); | |
579 | ||
580 | /* reg_spvid_pvid | |
581 | * Port default VID | |
582 | * Access: RW | |
583 | */ | |
584 | MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12); | |
585 | ||
586 | static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid) | |
587 | { | |
588 | MLXSW_REG_ZERO(spvid, payload); | |
589 | mlxsw_reg_spvid_local_port_set(payload, local_port); | |
590 | mlxsw_reg_spvid_pvid_set(payload, pvid); | |
591 | } | |
592 | ||
593 | /* SPVM - Switch Port VLAN Membership | |
594 | * ---------------------------------- | |
595 | * The Switch Port VLAN Membership register configures the VLAN membership | |
596 | * of a port in a VLAN denoted by VID. VLAN membership is managed per | |
597 | * virtual port. The register can be used to add and remove VID(s) from a port. | |
598 | */ | |
599 | #define MLXSW_REG_SPVM_ID 0x200F | |
600 | #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */ | |
601 | #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */ | |
602 | #define MLXSW_REG_SPVM_REC_MAX_COUNT 256 | |
603 | #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \ | |
604 | MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT) | |
605 | ||
606 | static const struct mlxsw_reg_info mlxsw_reg_spvm = { | |
607 | .id = MLXSW_REG_SPVM_ID, | |
608 | .len = MLXSW_REG_SPVM_LEN, | |
609 | }; | |
610 | ||
611 | /* reg_spvm_pt | |
612 | * Priority tagged. If this bit is set, packets forwarded to the port with | |
613 | * untagged VLAN membership (u bit is set) will be tagged with priority tag | |
614 | * (VID=0) | |
615 | * Access: RW | |
616 | */ | |
617 | MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1); | |
618 | ||
619 | /* reg_spvm_pte | |
620 | * Priority Tagged Update Enable. On Write operations, if this bit is cleared, | |
621 | * the pt bit will NOT be updated. To update the pt bit, pte must be set. | |
622 | * Access: WO | |
623 | */ | |
624 | MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1); | |
625 | ||
626 | /* reg_spvm_local_port | |
627 | * Local port number. | |
628 | * Access: Index | |
629 | */ | |
630 | MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8); | |
631 | ||
632 | /* reg_spvm_sub_port | |
633 | * Virtual port within the physical port. | |
634 | * Should be set to 0 when virtual ports are not enabled on the port. | |
635 | * Access: Index | |
636 | */ | |
637 | MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8); | |
638 | ||
639 | /* reg_spvm_num_rec | |
640 | * Number of records to update. Each record contains: i, e, u, vid. | |
641 | * Access: OP | |
642 | */ | |
643 | MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8); | |
644 | ||
645 | /* reg_spvm_rec_i | |
646 | * Ingress membership in VLAN ID. | |
647 | * Access: Index | |
648 | */ | |
649 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_i, | |
650 | MLXSW_REG_SPVM_BASE_LEN, 14, 1, | |
651 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
652 | ||
653 | /* reg_spvm_rec_e | |
654 | * Egress membership in VLAN ID. | |
655 | * Access: Index | |
656 | */ | |
657 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_e, | |
658 | MLXSW_REG_SPVM_BASE_LEN, 13, 1, | |
659 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
660 | ||
661 | /* reg_spvm_rec_u | |
662 | * Untagged - port is an untagged member - egress transmission uses untagged | |
663 | * frames on VID<n> | |
664 | * Access: Index | |
665 | */ | |
666 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_u, | |
667 | MLXSW_REG_SPVM_BASE_LEN, 12, 1, | |
668 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
669 | ||
670 | /* reg_spvm_rec_vid | |
671 | * Egress membership in VLAN ID. | |
672 | * Access: Index | |
673 | */ | |
674 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid, | |
675 | MLXSW_REG_SPVM_BASE_LEN, 0, 12, | |
676 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
677 | ||
678 | static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port, | |
679 | u16 vid_begin, u16 vid_end, | |
680 | bool is_member, bool untagged) | |
681 | { | |
682 | int size = vid_end - vid_begin + 1; | |
683 | int i; | |
684 | ||
685 | MLXSW_REG_ZERO(spvm, payload); | |
686 | mlxsw_reg_spvm_local_port_set(payload, local_port); | |
687 | mlxsw_reg_spvm_num_rec_set(payload, size); | |
688 | ||
689 | for (i = 0; i < size; i++) { | |
690 | mlxsw_reg_spvm_rec_i_set(payload, i, is_member); | |
691 | mlxsw_reg_spvm_rec_e_set(payload, i, is_member); | |
692 | mlxsw_reg_spvm_rec_u_set(payload, i, untagged); | |
693 | mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i); | |
694 | } | |
695 | } | |
696 | ||
4ec14b76 IS |
697 | /* SFGC - Switch Flooding Group Configuration |
698 | * ------------------------------------------ | |
699 | * The following register controls the association of flooding tables and MIDs | |
700 | * to packet types used for flooding. | |
701 | */ | |
36b78e8a | 702 | #define MLXSW_REG_SFGC_ID 0x2011 |
4ec14b76 IS |
703 | #define MLXSW_REG_SFGC_LEN 0x10 |
704 | ||
705 | static const struct mlxsw_reg_info mlxsw_reg_sfgc = { | |
706 | .id = MLXSW_REG_SFGC_ID, | |
707 | .len = MLXSW_REG_SFGC_LEN, | |
708 | }; | |
709 | ||
710 | enum mlxsw_reg_sfgc_type { | |
fa6ad058 IS |
711 | MLXSW_REG_SFGC_TYPE_BROADCAST, |
712 | MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST, | |
713 | MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4, | |
714 | MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6, | |
715 | MLXSW_REG_SFGC_TYPE_RESERVED, | |
716 | MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP, | |
717 | MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL, | |
718 | MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST, | |
719 | MLXSW_REG_SFGC_TYPE_MAX, | |
4ec14b76 IS |
720 | }; |
721 | ||
722 | /* reg_sfgc_type | |
723 | * The traffic type to reach the flooding table. | |
724 | * Access: Index | |
725 | */ | |
726 | MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4); | |
727 | ||
728 | enum mlxsw_reg_sfgc_bridge_type { | |
729 | MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0, | |
730 | MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1, | |
731 | }; | |
732 | ||
733 | /* reg_sfgc_bridge_type | |
734 | * Access: Index | |
735 | * | |
736 | * Note: SwitchX-2 only supports 802.1Q mode. | |
737 | */ | |
738 | MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3); | |
739 | ||
740 | enum mlxsw_flood_table_type { | |
741 | MLXSW_REG_SFGC_TABLE_TYPE_VID = 1, | |
742 | MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2, | |
743 | MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0, | |
744 | MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3, | |
745 | MLXSW_REG_SFGC_TABLE_TYPE_FID = 4, | |
746 | }; | |
747 | ||
748 | /* reg_sfgc_table_type | |
749 | * See mlxsw_flood_table_type | |
750 | * Access: RW | |
751 | * | |
752 | * Note: FID offset and FID types are not supported in SwitchX-2. | |
753 | */ | |
754 | MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3); | |
755 | ||
756 | /* reg_sfgc_flood_table | |
757 | * Flooding table index to associate with the specific type on the specific | |
758 | * switch partition. | |
759 | * Access: RW | |
760 | */ | |
761 | MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6); | |
762 | ||
763 | /* reg_sfgc_mid | |
764 | * The multicast ID for the swid. Not supported for Spectrum | |
765 | * Access: RW | |
766 | */ | |
767 | MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16); | |
768 | ||
769 | /* reg_sfgc_counter_set_type | |
770 | * Counter Set Type for flow counters. | |
771 | * Access: RW | |
772 | */ | |
773 | MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8); | |
774 | ||
775 | /* reg_sfgc_counter_index | |
776 | * Counter Index for flow counters. | |
777 | * Access: RW | |
778 | */ | |
779 | MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24); | |
780 | ||
781 | static inline void | |
782 | mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type, | |
783 | enum mlxsw_reg_sfgc_bridge_type bridge_type, | |
784 | enum mlxsw_flood_table_type table_type, | |
785 | unsigned int flood_table) | |
786 | { | |
787 | MLXSW_REG_ZERO(sfgc, payload); | |
788 | mlxsw_reg_sfgc_type_set(payload, type); | |
789 | mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type); | |
790 | mlxsw_reg_sfgc_table_type_set(payload, table_type); | |
791 | mlxsw_reg_sfgc_flood_table_set(payload, flood_table); | |
792 | mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID); | |
793 | } | |
794 | ||
795 | /* SFTR - Switch Flooding Table Register | |
796 | * ------------------------------------- | |
797 | * The switch flooding table is used for flooding packet replication. The table | |
798 | * defines a bit mask of ports for packet replication. | |
799 | */ | |
800 | #define MLXSW_REG_SFTR_ID 0x2012 | |
801 | #define MLXSW_REG_SFTR_LEN 0x420 | |
802 | ||
803 | static const struct mlxsw_reg_info mlxsw_reg_sftr = { | |
804 | .id = MLXSW_REG_SFTR_ID, | |
805 | .len = MLXSW_REG_SFTR_LEN, | |
806 | }; | |
807 | ||
808 | /* reg_sftr_swid | |
809 | * Switch partition ID with which to associate the port. | |
810 | * Access: Index | |
811 | */ | |
812 | MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8); | |
813 | ||
814 | /* reg_sftr_flood_table | |
815 | * Flooding table index to associate with the specific type on the specific | |
816 | * switch partition. | |
817 | * Access: Index | |
818 | */ | |
819 | MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6); | |
820 | ||
821 | /* reg_sftr_index | |
822 | * Index. Used as an index into the Flooding Table in case the table is | |
823 | * configured to use VID / FID or FID Offset. | |
824 | * Access: Index | |
825 | */ | |
826 | MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16); | |
827 | ||
828 | /* reg_sftr_table_type | |
829 | * See mlxsw_flood_table_type | |
830 | * Access: RW | |
831 | */ | |
832 | MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3); | |
833 | ||
834 | /* reg_sftr_range | |
835 | * Range of entries to update | |
836 | * Access: Index | |
837 | */ | |
838 | MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16); | |
839 | ||
840 | /* reg_sftr_port | |
841 | * Local port membership (1 bit per port). | |
842 | * Access: RW | |
843 | */ | |
844 | MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1); | |
845 | ||
846 | /* reg_sftr_cpu_port_mask | |
847 | * CPU port mask (1 bit per port). | |
848 | * Access: W | |
849 | */ | |
850 | MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1); | |
851 | ||
852 | static inline void mlxsw_reg_sftr_pack(char *payload, | |
853 | unsigned int flood_table, | |
854 | unsigned int index, | |
855 | enum mlxsw_flood_table_type table_type, | |
bc2055f8 | 856 | unsigned int range, u8 port, bool set) |
4ec14b76 IS |
857 | { |
858 | MLXSW_REG_ZERO(sftr, payload); | |
859 | mlxsw_reg_sftr_swid_set(payload, 0); | |
860 | mlxsw_reg_sftr_flood_table_set(payload, flood_table); | |
861 | mlxsw_reg_sftr_index_set(payload, index); | |
862 | mlxsw_reg_sftr_table_type_set(payload, table_type); | |
863 | mlxsw_reg_sftr_range_set(payload, range); | |
bc2055f8 IS |
864 | mlxsw_reg_sftr_port_set(payload, port, set); |
865 | mlxsw_reg_sftr_port_mask_set(payload, port, 1); | |
4ec14b76 IS |
866 | } |
867 | ||
868 | /* SPMLR - Switch Port MAC Learning Register | |
869 | * ----------------------------------------- | |
870 | * Controls the Switch MAC learning policy per port. | |
871 | */ | |
872 | #define MLXSW_REG_SPMLR_ID 0x2018 | |
873 | #define MLXSW_REG_SPMLR_LEN 0x8 | |
874 | ||
875 | static const struct mlxsw_reg_info mlxsw_reg_spmlr = { | |
876 | .id = MLXSW_REG_SPMLR_ID, | |
877 | .len = MLXSW_REG_SPMLR_LEN, | |
878 | }; | |
879 | ||
880 | /* reg_spmlr_local_port | |
881 | * Local port number. | |
882 | * Access: Index | |
883 | */ | |
884 | MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8); | |
885 | ||
886 | /* reg_spmlr_sub_port | |
887 | * Virtual port within the physical port. | |
888 | * Should be set to 0 when virtual ports are not enabled on the port. | |
889 | * Access: Index | |
890 | */ | |
891 | MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8); | |
892 | ||
893 | enum mlxsw_reg_spmlr_learn_mode { | |
894 | MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0, | |
895 | MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2, | |
896 | MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3, | |
897 | }; | |
898 | ||
899 | /* reg_spmlr_learn_mode | |
900 | * Learning mode on the port. | |
901 | * 0 - Learning disabled. | |
902 | * 2 - Learning enabled. | |
903 | * 3 - Security mode. | |
904 | * | |
905 | * In security mode the switch does not learn MACs on the port, but uses the | |
906 | * SMAC to see if it exists on another ingress port. If so, the packet is | |
907 | * classified as a bad packet and is discarded unless the software registers | |
908 | * to receive port security error packets usign HPKT. | |
909 | */ | |
910 | MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2); | |
911 | ||
912 | static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port, | |
913 | enum mlxsw_reg_spmlr_learn_mode mode) | |
914 | { | |
915 | MLXSW_REG_ZERO(spmlr, payload); | |
916 | mlxsw_reg_spmlr_local_port_set(payload, local_port); | |
917 | mlxsw_reg_spmlr_sub_port_set(payload, 0); | |
918 | mlxsw_reg_spmlr_learn_mode_set(payload, mode); | |
919 | } | |
920 | ||
64790239 IS |
921 | /* SVFA - Switch VID to FID Allocation Register |
922 | * -------------------------------------------- | |
923 | * Controls the VID to FID mapping and {Port, VID} to FID mapping for | |
924 | * virtualized ports. | |
925 | */ | |
926 | #define MLXSW_REG_SVFA_ID 0x201C | |
927 | #define MLXSW_REG_SVFA_LEN 0x10 | |
928 | ||
929 | static const struct mlxsw_reg_info mlxsw_reg_svfa = { | |
930 | .id = MLXSW_REG_SVFA_ID, | |
931 | .len = MLXSW_REG_SVFA_LEN, | |
932 | }; | |
933 | ||
934 | /* reg_svfa_swid | |
935 | * Switch partition ID. | |
936 | * Access: Index | |
937 | */ | |
938 | MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8); | |
939 | ||
940 | /* reg_svfa_local_port | |
941 | * Local port number. | |
942 | * Access: Index | |
943 | * | |
944 | * Note: Reserved for 802.1Q FIDs. | |
945 | */ | |
946 | MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8); | |
947 | ||
948 | enum mlxsw_reg_svfa_mt { | |
949 | MLXSW_REG_SVFA_MT_VID_TO_FID, | |
950 | MLXSW_REG_SVFA_MT_PORT_VID_TO_FID, | |
951 | }; | |
952 | ||
953 | /* reg_svfa_mapping_table | |
954 | * Mapping table: | |
955 | * 0 - VID to FID | |
956 | * 1 - {Port, VID} to FID | |
957 | * Access: Index | |
958 | * | |
959 | * Note: Reserved for SwitchX-2. | |
960 | */ | |
961 | MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3); | |
962 | ||
963 | /* reg_svfa_v | |
964 | * Valid. | |
965 | * Valid if set. | |
966 | * Access: RW | |
967 | * | |
968 | * Note: Reserved for SwitchX-2. | |
969 | */ | |
970 | MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1); | |
971 | ||
972 | /* reg_svfa_fid | |
973 | * Filtering ID. | |
974 | * Access: RW | |
975 | */ | |
976 | MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16); | |
977 | ||
978 | /* reg_svfa_vid | |
979 | * VLAN ID. | |
980 | * Access: Index | |
981 | */ | |
982 | MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12); | |
983 | ||
984 | /* reg_svfa_counter_set_type | |
985 | * Counter set type for flow counters. | |
986 | * Access: RW | |
987 | * | |
988 | * Note: Reserved for SwitchX-2. | |
989 | */ | |
990 | MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8); | |
991 | ||
992 | /* reg_svfa_counter_index | |
993 | * Counter index for flow counters. | |
994 | * Access: RW | |
995 | * | |
996 | * Note: Reserved for SwitchX-2. | |
997 | */ | |
998 | MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24); | |
999 | ||
1000 | static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port, | |
1001 | enum mlxsw_reg_svfa_mt mt, bool valid, | |
1002 | u16 fid, u16 vid) | |
1003 | { | |
1004 | MLXSW_REG_ZERO(svfa, payload); | |
1005 | local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port; | |
1006 | mlxsw_reg_svfa_swid_set(payload, 0); | |
1007 | mlxsw_reg_svfa_local_port_set(payload, local_port); | |
1008 | mlxsw_reg_svfa_mapping_table_set(payload, mt); | |
1009 | mlxsw_reg_svfa_v_set(payload, valid); | |
1010 | mlxsw_reg_svfa_fid_set(payload, fid); | |
1011 | mlxsw_reg_svfa_vid_set(payload, vid); | |
1012 | } | |
1013 | ||
1f65da74 IS |
1014 | /* SVPE - Switch Virtual-Port Enabling Register |
1015 | * -------------------------------------------- | |
1016 | * Enables port virtualization. | |
1017 | */ | |
1018 | #define MLXSW_REG_SVPE_ID 0x201E | |
1019 | #define MLXSW_REG_SVPE_LEN 0x4 | |
1020 | ||
1021 | static const struct mlxsw_reg_info mlxsw_reg_svpe = { | |
1022 | .id = MLXSW_REG_SVPE_ID, | |
1023 | .len = MLXSW_REG_SVPE_LEN, | |
1024 | }; | |
1025 | ||
1026 | /* reg_svpe_local_port | |
1027 | * Local port number | |
1028 | * Access: Index | |
1029 | * | |
1030 | * Note: CPU port is not supported (uses VLAN mode only). | |
1031 | */ | |
1032 | MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8); | |
1033 | ||
1034 | /* reg_svpe_vp_en | |
1035 | * Virtual port enable. | |
1036 | * 0 - Disable, VLAN mode (VID to FID). | |
1037 | * 1 - Enable, Virtual port mode ({Port, VID} to FID). | |
1038 | * Access: RW | |
1039 | */ | |
1040 | MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1); | |
1041 | ||
1042 | static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port, | |
1043 | bool enable) | |
1044 | { | |
1045 | MLXSW_REG_ZERO(svpe, payload); | |
1046 | mlxsw_reg_svpe_local_port_set(payload, local_port); | |
1047 | mlxsw_reg_svpe_vp_en_set(payload, enable); | |
1048 | } | |
1049 | ||
f1fb693a IS |
1050 | /* SFMR - Switch FID Management Register |
1051 | * ------------------------------------- | |
1052 | * Creates and configures FIDs. | |
1053 | */ | |
1054 | #define MLXSW_REG_SFMR_ID 0x201F | |
1055 | #define MLXSW_REG_SFMR_LEN 0x18 | |
1056 | ||
1057 | static const struct mlxsw_reg_info mlxsw_reg_sfmr = { | |
1058 | .id = MLXSW_REG_SFMR_ID, | |
1059 | .len = MLXSW_REG_SFMR_LEN, | |
1060 | }; | |
1061 | ||
1062 | enum mlxsw_reg_sfmr_op { | |
1063 | MLXSW_REG_SFMR_OP_CREATE_FID, | |
1064 | MLXSW_REG_SFMR_OP_DESTROY_FID, | |
1065 | }; | |
1066 | ||
1067 | /* reg_sfmr_op | |
1068 | * Operation. | |
1069 | * 0 - Create or edit FID. | |
1070 | * 1 - Destroy FID. | |
1071 | * Access: WO | |
1072 | */ | |
1073 | MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4); | |
1074 | ||
1075 | /* reg_sfmr_fid | |
1076 | * Filtering ID. | |
1077 | * Access: Index | |
1078 | */ | |
1079 | MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16); | |
1080 | ||
1081 | /* reg_sfmr_fid_offset | |
1082 | * FID offset. | |
1083 | * Used to point into the flooding table selected by SFGC register if | |
1084 | * the table is of type FID-Offset. Otherwise, this field is reserved. | |
1085 | * Access: RW | |
1086 | */ | |
1087 | MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16); | |
1088 | ||
1089 | /* reg_sfmr_vtfp | |
1090 | * Valid Tunnel Flood Pointer. | |
1091 | * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL. | |
1092 | * Access: RW | |
1093 | * | |
1094 | * Note: Reserved for 802.1Q FIDs. | |
1095 | */ | |
1096 | MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1); | |
1097 | ||
1098 | /* reg_sfmr_nve_tunnel_flood_ptr | |
1099 | * Underlay Flooding and BC Pointer. | |
1100 | * Used as a pointer to the first entry of the group based link lists of | |
1101 | * flooding or BC entries (for NVE tunnels). | |
1102 | * Access: RW | |
1103 | */ | |
1104 | MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24); | |
1105 | ||
1106 | /* reg_sfmr_vv | |
1107 | * VNI Valid. | |
1108 | * If not set, then vni is reserved. | |
1109 | * Access: RW | |
1110 | * | |
1111 | * Note: Reserved for 802.1Q FIDs. | |
1112 | */ | |
1113 | MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1); | |
1114 | ||
1115 | /* reg_sfmr_vni | |
1116 | * Virtual Network Identifier. | |
1117 | * Access: RW | |
1118 | * | |
1119 | * Note: A given VNI can only be assigned to one FID. | |
1120 | */ | |
1121 | MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24); | |
1122 | ||
1123 | static inline void mlxsw_reg_sfmr_pack(char *payload, | |
1124 | enum mlxsw_reg_sfmr_op op, u16 fid, | |
1125 | u16 fid_offset) | |
1126 | { | |
1127 | MLXSW_REG_ZERO(sfmr, payload); | |
1128 | mlxsw_reg_sfmr_op_set(payload, op); | |
1129 | mlxsw_reg_sfmr_fid_set(payload, fid); | |
1130 | mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset); | |
1131 | mlxsw_reg_sfmr_vtfp_set(payload, false); | |
1132 | mlxsw_reg_sfmr_vv_set(payload, false); | |
1133 | } | |
1134 | ||
4ec14b76 IS |
1135 | /* PMLP - Ports Module to Local Port Register |
1136 | * ------------------------------------------ | |
1137 | * Configures the assignment of modules to local ports. | |
1138 | */ | |
1139 | #define MLXSW_REG_PMLP_ID 0x5002 | |
1140 | #define MLXSW_REG_PMLP_LEN 0x40 | |
1141 | ||
1142 | static const struct mlxsw_reg_info mlxsw_reg_pmlp = { | |
1143 | .id = MLXSW_REG_PMLP_ID, | |
1144 | .len = MLXSW_REG_PMLP_LEN, | |
1145 | }; | |
1146 | ||
1147 | /* reg_pmlp_rxtx | |
1148 | * 0 - Tx value is used for both Tx and Rx. | |
1149 | * 1 - Rx value is taken from a separte field. | |
1150 | * Access: RW | |
1151 | */ | |
1152 | MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1); | |
1153 | ||
1154 | /* reg_pmlp_local_port | |
1155 | * Local port number. | |
1156 | * Access: Index | |
1157 | */ | |
1158 | MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8); | |
1159 | ||
1160 | /* reg_pmlp_width | |
1161 | * 0 - Unmap local port. | |
1162 | * 1 - Lane 0 is used. | |
1163 | * 2 - Lanes 0 and 1 are used. | |
1164 | * 4 - Lanes 0, 1, 2 and 3 are used. | |
1165 | * Access: RW | |
1166 | */ | |
1167 | MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8); | |
1168 | ||
1169 | /* reg_pmlp_module | |
1170 | * Module number. | |
1171 | * Access: RW | |
1172 | */ | |
1173 | MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0, false); | |
1174 | ||
1175 | /* reg_pmlp_tx_lane | |
1176 | * Tx Lane. When rxtx field is cleared, this field is used for Rx as well. | |
1177 | * Access: RW | |
1178 | */ | |
1179 | MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 16, false); | |
1180 | ||
1181 | /* reg_pmlp_rx_lane | |
1182 | * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is | |
1183 | * equal to Tx lane. | |
1184 | * Access: RW | |
1185 | */ | |
1186 | MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 24, false); | |
1187 | ||
1188 | static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port) | |
1189 | { | |
1190 | MLXSW_REG_ZERO(pmlp, payload); | |
1191 | mlxsw_reg_pmlp_local_port_set(payload, local_port); | |
1192 | } | |
1193 | ||
1194 | /* PMTU - Port MTU Register | |
1195 | * ------------------------ | |
1196 | * Configures and reports the port MTU. | |
1197 | */ | |
1198 | #define MLXSW_REG_PMTU_ID 0x5003 | |
1199 | #define MLXSW_REG_PMTU_LEN 0x10 | |
1200 | ||
1201 | static const struct mlxsw_reg_info mlxsw_reg_pmtu = { | |
1202 | .id = MLXSW_REG_PMTU_ID, | |
1203 | .len = MLXSW_REG_PMTU_LEN, | |
1204 | }; | |
1205 | ||
1206 | /* reg_pmtu_local_port | |
1207 | * Local port number. | |
1208 | * Access: Index | |
1209 | */ | |
1210 | MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8); | |
1211 | ||
1212 | /* reg_pmtu_max_mtu | |
1213 | * Maximum MTU. | |
1214 | * When port type (e.g. Ethernet) is configured, the relevant MTU is | |
1215 | * reported, otherwise the minimum between the max_mtu of the different | |
1216 | * types is reported. | |
1217 | * Access: RO | |
1218 | */ | |
1219 | MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16); | |
1220 | ||
1221 | /* reg_pmtu_admin_mtu | |
1222 | * MTU value to set port to. Must be smaller or equal to max_mtu. | |
1223 | * Note: If port type is Infiniband, then port must be disabled, when its | |
1224 | * MTU is set. | |
1225 | * Access: RW | |
1226 | */ | |
1227 | MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16); | |
1228 | ||
1229 | /* reg_pmtu_oper_mtu | |
1230 | * The actual MTU configured on the port. Packets exceeding this size | |
1231 | * will be dropped. | |
1232 | * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband | |
1233 | * oper_mtu might be smaller than admin_mtu. | |
1234 | * Access: RO | |
1235 | */ | |
1236 | MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16); | |
1237 | ||
1238 | static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port, | |
1239 | u16 new_mtu) | |
1240 | { | |
1241 | MLXSW_REG_ZERO(pmtu, payload); | |
1242 | mlxsw_reg_pmtu_local_port_set(payload, local_port); | |
1243 | mlxsw_reg_pmtu_max_mtu_set(payload, 0); | |
1244 | mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu); | |
1245 | mlxsw_reg_pmtu_oper_mtu_set(payload, 0); | |
1246 | } | |
1247 | ||
1248 | /* PTYS - Port Type and Speed Register | |
1249 | * ----------------------------------- | |
1250 | * Configures and reports the port speed type. | |
1251 | * | |
1252 | * Note: When set while the link is up, the changes will not take effect | |
1253 | * until the port transitions from down to up state. | |
1254 | */ | |
1255 | #define MLXSW_REG_PTYS_ID 0x5004 | |
1256 | #define MLXSW_REG_PTYS_LEN 0x40 | |
1257 | ||
1258 | static const struct mlxsw_reg_info mlxsw_reg_ptys = { | |
1259 | .id = MLXSW_REG_PTYS_ID, | |
1260 | .len = MLXSW_REG_PTYS_LEN, | |
1261 | }; | |
1262 | ||
1263 | /* reg_ptys_local_port | |
1264 | * Local port number. | |
1265 | * Access: Index | |
1266 | */ | |
1267 | MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8); | |
1268 | ||
1269 | #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2) | |
1270 | ||
1271 | /* reg_ptys_proto_mask | |
1272 | * Protocol mask. Indicates which protocol is used. | |
1273 | * 0 - Infiniband. | |
1274 | * 1 - Fibre Channel. | |
1275 | * 2 - Ethernet. | |
1276 | * Access: Index | |
1277 | */ | |
1278 | MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3); | |
1279 | ||
1280 | #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0) | |
1281 | #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1) | |
1282 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2) | |
1283 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3) | |
1284 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4) | |
1285 | #define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5) | |
1286 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6) | |
1287 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7) | |
1288 | #define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8) | |
1289 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12) | |
1290 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13) | |
1291 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14) | |
1292 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15) | |
1293 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16) | |
1294 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19) | |
1295 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20) | |
1296 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21) | |
1297 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22) | |
1298 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23) | |
1299 | #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24) | |
1300 | #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25) | |
1301 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26) | |
1302 | #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27) | |
1303 | #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28) | |
1304 | #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29) | |
1305 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30) | |
1306 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31) | |
1307 | ||
1308 | /* reg_ptys_eth_proto_cap | |
1309 | * Ethernet port supported speeds and protocols. | |
1310 | * Access: RO | |
1311 | */ | |
1312 | MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32); | |
1313 | ||
1314 | /* reg_ptys_eth_proto_admin | |
1315 | * Speed and protocol to set port to. | |
1316 | * Access: RW | |
1317 | */ | |
1318 | MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32); | |
1319 | ||
1320 | /* reg_ptys_eth_proto_oper | |
1321 | * The current speed and protocol configured for the port. | |
1322 | * Access: RO | |
1323 | */ | |
1324 | MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32); | |
1325 | ||
1326 | static inline void mlxsw_reg_ptys_pack(char *payload, u8 local_port, | |
1327 | u32 proto_admin) | |
1328 | { | |
1329 | MLXSW_REG_ZERO(ptys, payload); | |
1330 | mlxsw_reg_ptys_local_port_set(payload, local_port); | |
1331 | mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH); | |
1332 | mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin); | |
1333 | } | |
1334 | ||
1335 | static inline void mlxsw_reg_ptys_unpack(char *payload, u32 *p_eth_proto_cap, | |
1336 | u32 *p_eth_proto_adm, | |
1337 | u32 *p_eth_proto_oper) | |
1338 | { | |
1339 | if (p_eth_proto_cap) | |
1340 | *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload); | |
1341 | if (p_eth_proto_adm) | |
1342 | *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload); | |
1343 | if (p_eth_proto_oper) | |
1344 | *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload); | |
1345 | } | |
1346 | ||
1347 | /* PPAD - Port Physical Address Register | |
1348 | * ------------------------------------- | |
1349 | * The PPAD register configures the per port physical MAC address. | |
1350 | */ | |
1351 | #define MLXSW_REG_PPAD_ID 0x5005 | |
1352 | #define MLXSW_REG_PPAD_LEN 0x10 | |
1353 | ||
1354 | static const struct mlxsw_reg_info mlxsw_reg_ppad = { | |
1355 | .id = MLXSW_REG_PPAD_ID, | |
1356 | .len = MLXSW_REG_PPAD_LEN, | |
1357 | }; | |
1358 | ||
1359 | /* reg_ppad_single_base_mac | |
1360 | * 0: base_mac, local port should be 0 and mac[7:0] is | |
1361 | * reserved. HW will set incremental | |
1362 | * 1: single_mac - mac of the local_port | |
1363 | * Access: RW | |
1364 | */ | |
1365 | MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1); | |
1366 | ||
1367 | /* reg_ppad_local_port | |
1368 | * port number, if single_base_mac = 0 then local_port is reserved | |
1369 | * Access: RW | |
1370 | */ | |
1371 | MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8); | |
1372 | ||
1373 | /* reg_ppad_mac | |
1374 | * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved. | |
1375 | * If single_base_mac = 1 - the per port MAC address | |
1376 | * Access: RW | |
1377 | */ | |
1378 | MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6); | |
1379 | ||
1380 | static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac, | |
1381 | u8 local_port) | |
1382 | { | |
1383 | MLXSW_REG_ZERO(ppad, payload); | |
1384 | mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac); | |
1385 | mlxsw_reg_ppad_local_port_set(payload, local_port); | |
1386 | } | |
1387 | ||
1388 | /* PAOS - Ports Administrative and Operational Status Register | |
1389 | * ----------------------------------------------------------- | |
1390 | * Configures and retrieves per port administrative and operational status. | |
1391 | */ | |
1392 | #define MLXSW_REG_PAOS_ID 0x5006 | |
1393 | #define MLXSW_REG_PAOS_LEN 0x10 | |
1394 | ||
1395 | static const struct mlxsw_reg_info mlxsw_reg_paos = { | |
1396 | .id = MLXSW_REG_PAOS_ID, | |
1397 | .len = MLXSW_REG_PAOS_LEN, | |
1398 | }; | |
1399 | ||
1400 | /* reg_paos_swid | |
1401 | * Switch partition ID with which to associate the port. | |
1402 | * Note: while external ports uses unique local port numbers (and thus swid is | |
1403 | * redundant), router ports use the same local port number where swid is the | |
1404 | * only indication for the relevant port. | |
1405 | * Access: Index | |
1406 | */ | |
1407 | MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8); | |
1408 | ||
1409 | /* reg_paos_local_port | |
1410 | * Local port number. | |
1411 | * Access: Index | |
1412 | */ | |
1413 | MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8); | |
1414 | ||
1415 | /* reg_paos_admin_status | |
1416 | * Port administrative state (the desired state of the port): | |
1417 | * 1 - Up. | |
1418 | * 2 - Down. | |
1419 | * 3 - Up once. This means that in case of link failure, the port won't go | |
1420 | * into polling mode, but will wait to be re-enabled by software. | |
1421 | * 4 - Disabled by system. Can only be set by hardware. | |
1422 | * Access: RW | |
1423 | */ | |
1424 | MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4); | |
1425 | ||
1426 | /* reg_paos_oper_status | |
1427 | * Port operational state (the current state): | |
1428 | * 1 - Up. | |
1429 | * 2 - Down. | |
1430 | * 3 - Down by port failure. This means that the device will not let the | |
1431 | * port up again until explicitly specified by software. | |
1432 | * Access: RO | |
1433 | */ | |
1434 | MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4); | |
1435 | ||
1436 | /* reg_paos_ase | |
1437 | * Admin state update enabled. | |
1438 | * Access: WO | |
1439 | */ | |
1440 | MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1); | |
1441 | ||
1442 | /* reg_paos_ee | |
1443 | * Event update enable. If this bit is set, event generation will be | |
1444 | * updated based on the e field. | |
1445 | * Access: WO | |
1446 | */ | |
1447 | MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1); | |
1448 | ||
1449 | /* reg_paos_e | |
1450 | * Event generation on operational state change: | |
1451 | * 0 - Do not generate event. | |
1452 | * 1 - Generate Event. | |
1453 | * 2 - Generate Single Event. | |
1454 | * Access: RW | |
1455 | */ | |
1456 | MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2); | |
1457 | ||
1458 | static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port, | |
1459 | enum mlxsw_port_admin_status status) | |
1460 | { | |
1461 | MLXSW_REG_ZERO(paos, payload); | |
1462 | mlxsw_reg_paos_swid_set(payload, 0); | |
1463 | mlxsw_reg_paos_local_port_set(payload, local_port); | |
1464 | mlxsw_reg_paos_admin_status_set(payload, status); | |
1465 | mlxsw_reg_paos_oper_status_set(payload, 0); | |
1466 | mlxsw_reg_paos_ase_set(payload, 1); | |
1467 | mlxsw_reg_paos_ee_set(payload, 1); | |
1468 | mlxsw_reg_paos_e_set(payload, 1); | |
1469 | } | |
1470 | ||
1471 | /* PPCNT - Ports Performance Counters Register | |
1472 | * ------------------------------------------- | |
1473 | * The PPCNT register retrieves per port performance counters. | |
1474 | */ | |
1475 | #define MLXSW_REG_PPCNT_ID 0x5008 | |
1476 | #define MLXSW_REG_PPCNT_LEN 0x100 | |
1477 | ||
1478 | static const struct mlxsw_reg_info mlxsw_reg_ppcnt = { | |
1479 | .id = MLXSW_REG_PPCNT_ID, | |
1480 | .len = MLXSW_REG_PPCNT_LEN, | |
1481 | }; | |
1482 | ||
1483 | /* reg_ppcnt_swid | |
1484 | * For HCA: must be always 0. | |
1485 | * Switch partition ID to associate port with. | |
1486 | * Switch partitions are numbered from 0 to 7 inclusively. | |
1487 | * Switch partition 254 indicates stacking ports. | |
1488 | * Switch partition 255 indicates all switch partitions. | |
1489 | * Only valid on Set() operation with local_port=255. | |
1490 | * Access: Index | |
1491 | */ | |
1492 | MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8); | |
1493 | ||
1494 | /* reg_ppcnt_local_port | |
1495 | * Local port number. | |
1496 | * 255 indicates all ports on the device, and is only allowed | |
1497 | * for Set() operation. | |
1498 | * Access: Index | |
1499 | */ | |
1500 | MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8); | |
1501 | ||
1502 | /* reg_ppcnt_pnat | |
1503 | * Port number access type: | |
1504 | * 0 - Local port number | |
1505 | * 1 - IB port number | |
1506 | * Access: Index | |
1507 | */ | |
1508 | MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2); | |
1509 | ||
1510 | /* reg_ppcnt_grp | |
1511 | * Performance counter group. | |
1512 | * Group 63 indicates all groups. Only valid on Set() operation with | |
1513 | * clr bit set. | |
1514 | * 0x0: IEEE 802.3 Counters | |
1515 | * 0x1: RFC 2863 Counters | |
1516 | * 0x2: RFC 2819 Counters | |
1517 | * 0x3: RFC 3635 Counters | |
1518 | * 0x5: Ethernet Extended Counters | |
1519 | * 0x8: Link Level Retransmission Counters | |
1520 | * 0x10: Per Priority Counters | |
1521 | * 0x11: Per Traffic Class Counters | |
1522 | * 0x12: Physical Layer Counters | |
1523 | * Access: Index | |
1524 | */ | |
1525 | MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6); | |
1526 | ||
1527 | /* reg_ppcnt_clr | |
1528 | * Clear counters. Setting the clr bit will reset the counter value | |
1529 | * for all counters in the counter group. This bit can be set | |
1530 | * for both Set() and Get() operation. | |
1531 | * Access: OP | |
1532 | */ | |
1533 | MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1); | |
1534 | ||
1535 | /* reg_ppcnt_prio_tc | |
1536 | * Priority for counter set that support per priority, valid values: 0-7. | |
1537 | * Traffic class for counter set that support per traffic class, | |
1538 | * valid values: 0- cap_max_tclass-1 . | |
1539 | * For HCA: cap_max_tclass is always 8. | |
1540 | * Otherwise must be 0. | |
1541 | * Access: Index | |
1542 | */ | |
1543 | MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5); | |
1544 | ||
1545 | /* reg_ppcnt_a_frames_transmitted_ok | |
1546 | * Access: RO | |
1547 | */ | |
1548 | MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok, | |
1549 | 0x08 + 0x00, 0, 64); | |
1550 | ||
1551 | /* reg_ppcnt_a_frames_received_ok | |
1552 | * Access: RO | |
1553 | */ | |
1554 | MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok, | |
1555 | 0x08 + 0x08, 0, 64); | |
1556 | ||
1557 | /* reg_ppcnt_a_frame_check_sequence_errors | |
1558 | * Access: RO | |
1559 | */ | |
1560 | MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors, | |
1561 | 0x08 + 0x10, 0, 64); | |
1562 | ||
1563 | /* reg_ppcnt_a_alignment_errors | |
1564 | * Access: RO | |
1565 | */ | |
1566 | MLXSW_ITEM64(reg, ppcnt, a_alignment_errors, | |
1567 | 0x08 + 0x18, 0, 64); | |
1568 | ||
1569 | /* reg_ppcnt_a_octets_transmitted_ok | |
1570 | * Access: RO | |
1571 | */ | |
1572 | MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok, | |
1573 | 0x08 + 0x20, 0, 64); | |
1574 | ||
1575 | /* reg_ppcnt_a_octets_received_ok | |
1576 | * Access: RO | |
1577 | */ | |
1578 | MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok, | |
1579 | 0x08 + 0x28, 0, 64); | |
1580 | ||
1581 | /* reg_ppcnt_a_multicast_frames_xmitted_ok | |
1582 | * Access: RO | |
1583 | */ | |
1584 | MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok, | |
1585 | 0x08 + 0x30, 0, 64); | |
1586 | ||
1587 | /* reg_ppcnt_a_broadcast_frames_xmitted_ok | |
1588 | * Access: RO | |
1589 | */ | |
1590 | MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok, | |
1591 | 0x08 + 0x38, 0, 64); | |
1592 | ||
1593 | /* reg_ppcnt_a_multicast_frames_received_ok | |
1594 | * Access: RO | |
1595 | */ | |
1596 | MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok, | |
1597 | 0x08 + 0x40, 0, 64); | |
1598 | ||
1599 | /* reg_ppcnt_a_broadcast_frames_received_ok | |
1600 | * Access: RO | |
1601 | */ | |
1602 | MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok, | |
1603 | 0x08 + 0x48, 0, 64); | |
1604 | ||
1605 | /* reg_ppcnt_a_in_range_length_errors | |
1606 | * Access: RO | |
1607 | */ | |
1608 | MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors, | |
1609 | 0x08 + 0x50, 0, 64); | |
1610 | ||
1611 | /* reg_ppcnt_a_out_of_range_length_field | |
1612 | * Access: RO | |
1613 | */ | |
1614 | MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field, | |
1615 | 0x08 + 0x58, 0, 64); | |
1616 | ||
1617 | /* reg_ppcnt_a_frame_too_long_errors | |
1618 | * Access: RO | |
1619 | */ | |
1620 | MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors, | |
1621 | 0x08 + 0x60, 0, 64); | |
1622 | ||
1623 | /* reg_ppcnt_a_symbol_error_during_carrier | |
1624 | * Access: RO | |
1625 | */ | |
1626 | MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier, | |
1627 | 0x08 + 0x68, 0, 64); | |
1628 | ||
1629 | /* reg_ppcnt_a_mac_control_frames_transmitted | |
1630 | * Access: RO | |
1631 | */ | |
1632 | MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted, | |
1633 | 0x08 + 0x70, 0, 64); | |
1634 | ||
1635 | /* reg_ppcnt_a_mac_control_frames_received | |
1636 | * Access: RO | |
1637 | */ | |
1638 | MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received, | |
1639 | 0x08 + 0x78, 0, 64); | |
1640 | ||
1641 | /* reg_ppcnt_a_unsupported_opcodes_received | |
1642 | * Access: RO | |
1643 | */ | |
1644 | MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received, | |
1645 | 0x08 + 0x80, 0, 64); | |
1646 | ||
1647 | /* reg_ppcnt_a_pause_mac_ctrl_frames_received | |
1648 | * Access: RO | |
1649 | */ | |
1650 | MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received, | |
1651 | 0x08 + 0x88, 0, 64); | |
1652 | ||
1653 | /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted | |
1654 | * Access: RO | |
1655 | */ | |
1656 | MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted, | |
1657 | 0x08 + 0x90, 0, 64); | |
1658 | ||
1659 | static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port) | |
1660 | { | |
1661 | MLXSW_REG_ZERO(ppcnt, payload); | |
1662 | mlxsw_reg_ppcnt_swid_set(payload, 0); | |
1663 | mlxsw_reg_ppcnt_local_port_set(payload, local_port); | |
1664 | mlxsw_reg_ppcnt_pnat_set(payload, 0); | |
1665 | mlxsw_reg_ppcnt_grp_set(payload, 0); | |
1666 | mlxsw_reg_ppcnt_clr_set(payload, 0); | |
1667 | mlxsw_reg_ppcnt_prio_tc_set(payload, 0); | |
1668 | } | |
1669 | ||
e0594369 JP |
1670 | /* PBMC - Port Buffer Management Control Register |
1671 | * ---------------------------------------------- | |
1672 | * The PBMC register configures and retrieves the port packet buffer | |
1673 | * allocation for different Prios, and the Pause threshold management. | |
1674 | */ | |
1675 | #define MLXSW_REG_PBMC_ID 0x500C | |
1676 | #define MLXSW_REG_PBMC_LEN 0x68 | |
1677 | ||
1678 | static const struct mlxsw_reg_info mlxsw_reg_pbmc = { | |
1679 | .id = MLXSW_REG_PBMC_ID, | |
1680 | .len = MLXSW_REG_PBMC_LEN, | |
1681 | }; | |
1682 | ||
1683 | /* reg_pbmc_local_port | |
1684 | * Local port number. | |
1685 | * Access: Index | |
1686 | */ | |
1687 | MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8); | |
1688 | ||
1689 | /* reg_pbmc_xoff_timer_value | |
1690 | * When device generates a pause frame, it uses this value as the pause | |
1691 | * timer (time for the peer port to pause in quota-512 bit time). | |
1692 | * Access: RW | |
1693 | */ | |
1694 | MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16); | |
1695 | ||
1696 | /* reg_pbmc_xoff_refresh | |
1697 | * The time before a new pause frame should be sent to refresh the pause RW | |
1698 | * state. Using the same units as xoff_timer_value above (in quota-512 bit | |
1699 | * time). | |
1700 | * Access: RW | |
1701 | */ | |
1702 | MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16); | |
1703 | ||
1704 | /* reg_pbmc_buf_lossy | |
1705 | * The field indicates if the buffer is lossy. | |
1706 | * 0 - Lossless | |
1707 | * 1 - Lossy | |
1708 | * Access: RW | |
1709 | */ | |
1710 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false); | |
1711 | ||
1712 | /* reg_pbmc_buf_epsb | |
1713 | * Eligible for Port Shared buffer. | |
1714 | * If epsb is set, packets assigned to buffer are allowed to insert the port | |
1715 | * shared buffer. | |
1716 | * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved. | |
1717 | * Access: RW | |
1718 | */ | |
1719 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false); | |
1720 | ||
1721 | /* reg_pbmc_buf_size | |
1722 | * The part of the packet buffer array is allocated for the specific buffer. | |
1723 | * Units are represented in cells. | |
1724 | * Access: RW | |
1725 | */ | |
1726 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false); | |
1727 | ||
1728 | static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port, | |
1729 | u16 xoff_timer_value, u16 xoff_refresh) | |
1730 | { | |
1731 | MLXSW_REG_ZERO(pbmc, payload); | |
1732 | mlxsw_reg_pbmc_local_port_set(payload, local_port); | |
1733 | mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value); | |
1734 | mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh); | |
1735 | } | |
1736 | ||
1737 | static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload, | |
1738 | int buf_index, | |
1739 | u16 size) | |
1740 | { | |
1741 | mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1); | |
1742 | mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0); | |
1743 | mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size); | |
1744 | } | |
1745 | ||
4ec14b76 IS |
1746 | /* PSPA - Port Switch Partition Allocation |
1747 | * --------------------------------------- | |
1748 | * Controls the association of a port with a switch partition and enables | |
1749 | * configuring ports as stacking ports. | |
1750 | */ | |
3f0effd1 | 1751 | #define MLXSW_REG_PSPA_ID 0x500D |
4ec14b76 IS |
1752 | #define MLXSW_REG_PSPA_LEN 0x8 |
1753 | ||
1754 | static const struct mlxsw_reg_info mlxsw_reg_pspa = { | |
1755 | .id = MLXSW_REG_PSPA_ID, | |
1756 | .len = MLXSW_REG_PSPA_LEN, | |
1757 | }; | |
1758 | ||
1759 | /* reg_pspa_swid | |
1760 | * Switch partition ID. | |
1761 | * Access: RW | |
1762 | */ | |
1763 | MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8); | |
1764 | ||
1765 | /* reg_pspa_local_port | |
1766 | * Local port number. | |
1767 | * Access: Index | |
1768 | */ | |
1769 | MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8); | |
1770 | ||
1771 | /* reg_pspa_sub_port | |
1772 | * Virtual port within the local port. Set to 0 when virtual ports are | |
1773 | * disabled on the local port. | |
1774 | * Access: Index | |
1775 | */ | |
1776 | MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8); | |
1777 | ||
1778 | static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port) | |
1779 | { | |
1780 | MLXSW_REG_ZERO(pspa, payload); | |
1781 | mlxsw_reg_pspa_swid_set(payload, swid); | |
1782 | mlxsw_reg_pspa_local_port_set(payload, local_port); | |
1783 | mlxsw_reg_pspa_sub_port_set(payload, 0); | |
1784 | } | |
1785 | ||
1786 | /* HTGT - Host Trap Group Table | |
1787 | * ---------------------------- | |
1788 | * Configures the properties for forwarding to CPU. | |
1789 | */ | |
1790 | #define MLXSW_REG_HTGT_ID 0x7002 | |
1791 | #define MLXSW_REG_HTGT_LEN 0x100 | |
1792 | ||
1793 | static const struct mlxsw_reg_info mlxsw_reg_htgt = { | |
1794 | .id = MLXSW_REG_HTGT_ID, | |
1795 | .len = MLXSW_REG_HTGT_LEN, | |
1796 | }; | |
1797 | ||
1798 | /* reg_htgt_swid | |
1799 | * Switch partition ID. | |
1800 | * Access: Index | |
1801 | */ | |
1802 | MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8); | |
1803 | ||
1804 | #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */ | |
1805 | ||
1806 | /* reg_htgt_type | |
1807 | * CPU path type. | |
1808 | * Access: RW | |
1809 | */ | |
1810 | MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4); | |
1811 | ||
801bd3de IS |
1812 | enum mlxsw_reg_htgt_trap_group { |
1813 | MLXSW_REG_HTGT_TRAP_GROUP_EMAD, | |
1814 | MLXSW_REG_HTGT_TRAP_GROUP_RX, | |
1815 | MLXSW_REG_HTGT_TRAP_GROUP_CTRL, | |
1816 | }; | |
4ec14b76 IS |
1817 | |
1818 | /* reg_htgt_trap_group | |
1819 | * Trap group number. User defined number specifying which trap groups | |
1820 | * should be forwarded to the CPU. The mapping between trap IDs and trap | |
1821 | * groups is configured using HPKT register. | |
1822 | * Access: Index | |
1823 | */ | |
1824 | MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8); | |
1825 | ||
1826 | enum { | |
1827 | MLXSW_REG_HTGT_POLICER_DISABLE, | |
1828 | MLXSW_REG_HTGT_POLICER_ENABLE, | |
1829 | }; | |
1830 | ||
1831 | /* reg_htgt_pide | |
1832 | * Enable policer ID specified using 'pid' field. | |
1833 | * Access: RW | |
1834 | */ | |
1835 | MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1); | |
1836 | ||
1837 | /* reg_htgt_pid | |
1838 | * Policer ID for the trap group. | |
1839 | * Access: RW | |
1840 | */ | |
1841 | MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8); | |
1842 | ||
1843 | #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0 | |
1844 | ||
1845 | /* reg_htgt_mirror_action | |
1846 | * Mirror action to use. | |
1847 | * 0 - Trap to CPU. | |
1848 | * 1 - Trap to CPU and mirror to a mirroring agent. | |
1849 | * 2 - Mirror to a mirroring agent and do not trap to CPU. | |
1850 | * Access: RW | |
1851 | * | |
1852 | * Note: Mirroring to a mirroring agent is only supported in Spectrum. | |
1853 | */ | |
1854 | MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2); | |
1855 | ||
1856 | /* reg_htgt_mirroring_agent | |
1857 | * Mirroring agent. | |
1858 | * Access: RW | |
1859 | */ | |
1860 | MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3); | |
1861 | ||
1862 | /* reg_htgt_priority | |
1863 | * Trap group priority. | |
1864 | * In case a packet matches multiple classification rules, the packet will | |
1865 | * only be trapped once, based on the trap ID associated with the group (via | |
1866 | * register HPKT) with the highest priority. | |
1867 | * Supported values are 0-7, with 7 represnting the highest priority. | |
1868 | * Access: RW | |
1869 | * | |
1870 | * Note: In SwitchX-2 this field is ignored and the priority value is replaced | |
1871 | * by the 'trap_group' field. | |
1872 | */ | |
1873 | MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4); | |
1874 | ||
1875 | /* reg_htgt_local_path_cpu_tclass | |
1876 | * CPU ingress traffic class for the trap group. | |
1877 | * Access: RW | |
1878 | */ | |
1879 | MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6); | |
1880 | ||
1881 | #define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD 0x15 | |
1882 | #define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX 0x14 | |
801bd3de | 1883 | #define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL 0x13 |
4ec14b76 IS |
1884 | |
1885 | /* reg_htgt_local_path_rdq | |
1886 | * Receive descriptor queue (RDQ) to use for the trap group. | |
1887 | * Access: RW | |
1888 | */ | |
1889 | MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6); | |
1890 | ||
801bd3de IS |
1891 | static inline void mlxsw_reg_htgt_pack(char *payload, |
1892 | enum mlxsw_reg_htgt_trap_group group) | |
4ec14b76 IS |
1893 | { |
1894 | u8 swid, rdq; | |
1895 | ||
1896 | MLXSW_REG_ZERO(htgt, payload); | |
801bd3de IS |
1897 | switch (group) { |
1898 | case MLXSW_REG_HTGT_TRAP_GROUP_EMAD: | |
4ec14b76 IS |
1899 | swid = MLXSW_PORT_SWID_ALL_SWIDS; |
1900 | rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD; | |
801bd3de IS |
1901 | break; |
1902 | case MLXSW_REG_HTGT_TRAP_GROUP_RX: | |
4ec14b76 IS |
1903 | swid = 0; |
1904 | rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX; | |
801bd3de IS |
1905 | break; |
1906 | case MLXSW_REG_HTGT_TRAP_GROUP_CTRL: | |
1907 | swid = 0; | |
1908 | rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL; | |
1909 | break; | |
4ec14b76 IS |
1910 | } |
1911 | mlxsw_reg_htgt_swid_set(payload, swid); | |
1912 | mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL); | |
801bd3de | 1913 | mlxsw_reg_htgt_trap_group_set(payload, group); |
4ec14b76 IS |
1914 | mlxsw_reg_htgt_pide_set(payload, MLXSW_REG_HTGT_POLICER_DISABLE); |
1915 | mlxsw_reg_htgt_pid_set(payload, 0); | |
1916 | mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU); | |
1917 | mlxsw_reg_htgt_mirroring_agent_set(payload, 0); | |
1918 | mlxsw_reg_htgt_priority_set(payload, 0); | |
1919 | mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, 7); | |
1920 | mlxsw_reg_htgt_local_path_rdq_set(payload, rdq); | |
1921 | } | |
1922 | ||
1923 | /* HPKT - Host Packet Trap | |
1924 | * ----------------------- | |
1925 | * Configures trap IDs inside trap groups. | |
1926 | */ | |
1927 | #define MLXSW_REG_HPKT_ID 0x7003 | |
1928 | #define MLXSW_REG_HPKT_LEN 0x10 | |
1929 | ||
1930 | static const struct mlxsw_reg_info mlxsw_reg_hpkt = { | |
1931 | .id = MLXSW_REG_HPKT_ID, | |
1932 | .len = MLXSW_REG_HPKT_LEN, | |
1933 | }; | |
1934 | ||
1935 | enum { | |
1936 | MLXSW_REG_HPKT_ACK_NOT_REQUIRED, | |
1937 | MLXSW_REG_HPKT_ACK_REQUIRED, | |
1938 | }; | |
1939 | ||
1940 | /* reg_hpkt_ack | |
1941 | * Require acknowledgements from the host for events. | |
1942 | * If set, then the device will wait for the event it sent to be acknowledged | |
1943 | * by the host. This option is only relevant for event trap IDs. | |
1944 | * Access: RW | |
1945 | * | |
1946 | * Note: Currently not supported by firmware. | |
1947 | */ | |
1948 | MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1); | |
1949 | ||
1950 | enum mlxsw_reg_hpkt_action { | |
1951 | MLXSW_REG_HPKT_ACTION_FORWARD, | |
1952 | MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU, | |
1953 | MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU, | |
1954 | MLXSW_REG_HPKT_ACTION_DISCARD, | |
1955 | MLXSW_REG_HPKT_ACTION_SOFT_DISCARD, | |
1956 | MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD, | |
1957 | }; | |
1958 | ||
1959 | /* reg_hpkt_action | |
1960 | * Action to perform on packet when trapped. | |
1961 | * 0 - No action. Forward to CPU based on switching rules. | |
1962 | * 1 - Trap to CPU (CPU receives sole copy). | |
1963 | * 2 - Mirror to CPU (CPU receives a replica of the packet). | |
1964 | * 3 - Discard. | |
1965 | * 4 - Soft discard (allow other traps to act on the packet). | |
1966 | * 5 - Trap and soft discard (allow other traps to overwrite this trap). | |
1967 | * Access: RW | |
1968 | * | |
1969 | * Note: Must be set to 0 (forward) for event trap IDs, as they are already | |
1970 | * addressed to the CPU. | |
1971 | */ | |
1972 | MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3); | |
1973 | ||
1974 | /* reg_hpkt_trap_group | |
1975 | * Trap group to associate the trap with. | |
1976 | * Access: RW | |
1977 | */ | |
1978 | MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6); | |
1979 | ||
1980 | /* reg_hpkt_trap_id | |
1981 | * Trap ID. | |
1982 | * Access: Index | |
1983 | * | |
1984 | * Note: A trap ID can only be associated with a single trap group. The device | |
1985 | * will associate the trap ID with the last trap group configured. | |
1986 | */ | |
1987 | MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9); | |
1988 | ||
1989 | enum { | |
1990 | MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT, | |
1991 | MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER, | |
1992 | MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER, | |
1993 | }; | |
1994 | ||
1995 | /* reg_hpkt_ctrl | |
1996 | * Configure dedicated buffer resources for control packets. | |
1997 | * 0 - Keep factory defaults. | |
1998 | * 1 - Do not use control buffer for this trap ID. | |
1999 | * 2 - Use control buffer for this trap ID. | |
2000 | * Access: RW | |
2001 | */ | |
2002 | MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2); | |
2003 | ||
f24af330 | 2004 | static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id) |
4ec14b76 | 2005 | { |
801bd3de | 2006 | enum mlxsw_reg_htgt_trap_group trap_group; |
f24af330 | 2007 | |
4ec14b76 IS |
2008 | MLXSW_REG_ZERO(hpkt, payload); |
2009 | mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED); | |
2010 | mlxsw_reg_hpkt_action_set(payload, action); | |
f24af330 IS |
2011 | switch (trap_id) { |
2012 | case MLXSW_TRAP_ID_ETHEMAD: | |
2013 | case MLXSW_TRAP_ID_PUDE: | |
2014 | trap_group = MLXSW_REG_HTGT_TRAP_GROUP_EMAD; | |
2015 | break; | |
2016 | default: | |
2017 | trap_group = MLXSW_REG_HTGT_TRAP_GROUP_RX; | |
2018 | break; | |
2019 | } | |
4ec14b76 IS |
2020 | mlxsw_reg_hpkt_trap_group_set(payload, trap_group); |
2021 | mlxsw_reg_hpkt_trap_id_set(payload, trap_id); | |
2022 | mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT); | |
2023 | } | |
2024 | ||
e0594369 JP |
2025 | /* SBPR - Shared Buffer Pools Register |
2026 | * ----------------------------------- | |
2027 | * The SBPR configures and retrieves the shared buffer pools and configuration. | |
2028 | */ | |
2029 | #define MLXSW_REG_SBPR_ID 0xB001 | |
2030 | #define MLXSW_REG_SBPR_LEN 0x14 | |
2031 | ||
2032 | static const struct mlxsw_reg_info mlxsw_reg_sbpr = { | |
2033 | .id = MLXSW_REG_SBPR_ID, | |
2034 | .len = MLXSW_REG_SBPR_LEN, | |
2035 | }; | |
2036 | ||
2037 | enum mlxsw_reg_sbpr_dir { | |
2038 | MLXSW_REG_SBPR_DIR_INGRESS, | |
2039 | MLXSW_REG_SBPR_DIR_EGRESS, | |
2040 | }; | |
2041 | ||
2042 | /* reg_sbpr_dir | |
2043 | * Direction. | |
2044 | * Access: Index | |
2045 | */ | |
2046 | MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2); | |
2047 | ||
2048 | /* reg_sbpr_pool | |
2049 | * Pool index. | |
2050 | * Access: Index | |
2051 | */ | |
2052 | MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4); | |
2053 | ||
2054 | /* reg_sbpr_size | |
2055 | * Pool size in buffer cells. | |
2056 | * Access: RW | |
2057 | */ | |
2058 | MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24); | |
2059 | ||
2060 | enum mlxsw_reg_sbpr_mode { | |
2061 | MLXSW_REG_SBPR_MODE_STATIC, | |
2062 | MLXSW_REG_SBPR_MODE_DYNAMIC, | |
2063 | }; | |
2064 | ||
2065 | /* reg_sbpr_mode | |
2066 | * Pool quota calculation mode. | |
2067 | * Access: RW | |
2068 | */ | |
2069 | MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4); | |
2070 | ||
2071 | static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool, | |
2072 | enum mlxsw_reg_sbpr_dir dir, | |
2073 | enum mlxsw_reg_sbpr_mode mode, u32 size) | |
2074 | { | |
2075 | MLXSW_REG_ZERO(sbpr, payload); | |
2076 | mlxsw_reg_sbpr_pool_set(payload, pool); | |
2077 | mlxsw_reg_sbpr_dir_set(payload, dir); | |
2078 | mlxsw_reg_sbpr_mode_set(payload, mode); | |
2079 | mlxsw_reg_sbpr_size_set(payload, size); | |
2080 | } | |
2081 | ||
2082 | /* SBCM - Shared Buffer Class Management Register | |
2083 | * ---------------------------------------------- | |
2084 | * The SBCM register configures and retrieves the shared buffer allocation | |
2085 | * and configuration according to Port-PG, including the binding to pool | |
2086 | * and definition of the associated quota. | |
2087 | */ | |
2088 | #define MLXSW_REG_SBCM_ID 0xB002 | |
2089 | #define MLXSW_REG_SBCM_LEN 0x28 | |
2090 | ||
2091 | static const struct mlxsw_reg_info mlxsw_reg_sbcm = { | |
2092 | .id = MLXSW_REG_SBCM_ID, | |
2093 | .len = MLXSW_REG_SBCM_LEN, | |
2094 | }; | |
2095 | ||
2096 | /* reg_sbcm_local_port | |
2097 | * Local port number. | |
2098 | * For Ingress: excludes CPU port and Router port | |
2099 | * For Egress: excludes IP Router | |
2100 | * Access: Index | |
2101 | */ | |
2102 | MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8); | |
2103 | ||
2104 | /* reg_sbcm_pg_buff | |
2105 | * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress) | |
2106 | * For PG buffer: range is 0..cap_max_pg_buffers - 1 | |
2107 | * For traffic class: range is 0..cap_max_tclass - 1 | |
2108 | * Note that when traffic class is in MC aware mode then the traffic | |
2109 | * classes which are MC aware cannot be configured. | |
2110 | * Access: Index | |
2111 | */ | |
2112 | MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6); | |
2113 | ||
2114 | enum mlxsw_reg_sbcm_dir { | |
2115 | MLXSW_REG_SBCM_DIR_INGRESS, | |
2116 | MLXSW_REG_SBCM_DIR_EGRESS, | |
2117 | }; | |
2118 | ||
2119 | /* reg_sbcm_dir | |
2120 | * Direction. | |
2121 | * Access: Index | |
2122 | */ | |
2123 | MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2); | |
2124 | ||
2125 | /* reg_sbcm_min_buff | |
2126 | * Minimum buffer size for the limiter, in cells. | |
2127 | * Access: RW | |
2128 | */ | |
2129 | MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24); | |
2130 | ||
2131 | /* reg_sbcm_max_buff | |
2132 | * When the pool associated to the port-pg/tclass is configured to | |
2133 | * static, Maximum buffer size for the limiter configured in cells. | |
2134 | * When the pool associated to the port-pg/tclass is configured to | |
2135 | * dynamic, the max_buff holds the "alpha" parameter, supporting | |
2136 | * the following values: | |
2137 | * 0: 0 | |
2138 | * i: (1/128)*2^(i-1), for i=1..14 | |
2139 | * 0xFF: Infinity | |
2140 | * Access: RW | |
2141 | */ | |
2142 | MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24); | |
2143 | ||
2144 | /* reg_sbcm_pool | |
2145 | * Association of the port-priority to a pool. | |
2146 | * Access: RW | |
2147 | */ | |
2148 | MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4); | |
2149 | ||
2150 | static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff, | |
2151 | enum mlxsw_reg_sbcm_dir dir, | |
2152 | u32 min_buff, u32 max_buff, u8 pool) | |
2153 | { | |
2154 | MLXSW_REG_ZERO(sbcm, payload); | |
2155 | mlxsw_reg_sbcm_local_port_set(payload, local_port); | |
2156 | mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff); | |
2157 | mlxsw_reg_sbcm_dir_set(payload, dir); | |
2158 | mlxsw_reg_sbcm_min_buff_set(payload, min_buff); | |
2159 | mlxsw_reg_sbcm_max_buff_set(payload, max_buff); | |
2160 | mlxsw_reg_sbcm_pool_set(payload, pool); | |
2161 | } | |
2162 | ||
2163 | /* SBPM - Shared Buffer Class Management Register | |
2164 | * ---------------------------------------------- | |
2165 | * The SBPM register configures and retrieves the shared buffer allocation | |
2166 | * and configuration according to Port-Pool, including the definition | |
2167 | * of the associated quota. | |
2168 | */ | |
2169 | #define MLXSW_REG_SBPM_ID 0xB003 | |
2170 | #define MLXSW_REG_SBPM_LEN 0x28 | |
2171 | ||
2172 | static const struct mlxsw_reg_info mlxsw_reg_sbpm = { | |
2173 | .id = MLXSW_REG_SBPM_ID, | |
2174 | .len = MLXSW_REG_SBPM_LEN, | |
2175 | }; | |
2176 | ||
2177 | /* reg_sbpm_local_port | |
2178 | * Local port number. | |
2179 | * For Ingress: excludes CPU port and Router port | |
2180 | * For Egress: excludes IP Router | |
2181 | * Access: Index | |
2182 | */ | |
2183 | MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8); | |
2184 | ||
2185 | /* reg_sbpm_pool | |
2186 | * The pool associated to quota counting on the local_port. | |
2187 | * Access: Index | |
2188 | */ | |
2189 | MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4); | |
2190 | ||
2191 | enum mlxsw_reg_sbpm_dir { | |
2192 | MLXSW_REG_SBPM_DIR_INGRESS, | |
2193 | MLXSW_REG_SBPM_DIR_EGRESS, | |
2194 | }; | |
2195 | ||
2196 | /* reg_sbpm_dir | |
2197 | * Direction. | |
2198 | * Access: Index | |
2199 | */ | |
2200 | MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2); | |
2201 | ||
2202 | /* reg_sbpm_min_buff | |
2203 | * Minimum buffer size for the limiter, in cells. | |
2204 | * Access: RW | |
2205 | */ | |
2206 | MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24); | |
2207 | ||
2208 | /* reg_sbpm_max_buff | |
2209 | * When the pool associated to the port-pg/tclass is configured to | |
2210 | * static, Maximum buffer size for the limiter configured in cells. | |
2211 | * When the pool associated to the port-pg/tclass is configured to | |
2212 | * dynamic, the max_buff holds the "alpha" parameter, supporting | |
2213 | * the following values: | |
2214 | * 0: 0 | |
2215 | * i: (1/128)*2^(i-1), for i=1..14 | |
2216 | * 0xFF: Infinity | |
2217 | * Access: RW | |
2218 | */ | |
2219 | MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24); | |
2220 | ||
2221 | static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool, | |
2222 | enum mlxsw_reg_sbpm_dir dir, | |
2223 | u32 min_buff, u32 max_buff) | |
2224 | { | |
2225 | MLXSW_REG_ZERO(sbpm, payload); | |
2226 | mlxsw_reg_sbpm_local_port_set(payload, local_port); | |
2227 | mlxsw_reg_sbpm_pool_set(payload, pool); | |
2228 | mlxsw_reg_sbpm_dir_set(payload, dir); | |
2229 | mlxsw_reg_sbpm_min_buff_set(payload, min_buff); | |
2230 | mlxsw_reg_sbpm_max_buff_set(payload, max_buff); | |
2231 | } | |
2232 | ||
2233 | /* SBMM - Shared Buffer Multicast Management Register | |
2234 | * -------------------------------------------------- | |
2235 | * The SBMM register configures and retrieves the shared buffer allocation | |
2236 | * and configuration for MC packets according to Switch-Priority, including | |
2237 | * the binding to pool and definition of the associated quota. | |
2238 | */ | |
2239 | #define MLXSW_REG_SBMM_ID 0xB004 | |
2240 | #define MLXSW_REG_SBMM_LEN 0x28 | |
2241 | ||
2242 | static const struct mlxsw_reg_info mlxsw_reg_sbmm = { | |
2243 | .id = MLXSW_REG_SBMM_ID, | |
2244 | .len = MLXSW_REG_SBMM_LEN, | |
2245 | }; | |
2246 | ||
2247 | /* reg_sbmm_prio | |
2248 | * Switch Priority. | |
2249 | * Access: Index | |
2250 | */ | |
2251 | MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4); | |
2252 | ||
2253 | /* reg_sbmm_min_buff | |
2254 | * Minimum buffer size for the limiter, in cells. | |
2255 | * Access: RW | |
2256 | */ | |
2257 | MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24); | |
2258 | ||
2259 | /* reg_sbmm_max_buff | |
2260 | * When the pool associated to the port-pg/tclass is configured to | |
2261 | * static, Maximum buffer size for the limiter configured in cells. | |
2262 | * When the pool associated to the port-pg/tclass is configured to | |
2263 | * dynamic, the max_buff holds the "alpha" parameter, supporting | |
2264 | * the following values: | |
2265 | * 0: 0 | |
2266 | * i: (1/128)*2^(i-1), for i=1..14 | |
2267 | * 0xFF: Infinity | |
2268 | * Access: RW | |
2269 | */ | |
2270 | MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24); | |
2271 | ||
2272 | /* reg_sbmm_pool | |
2273 | * Association of the port-priority to a pool. | |
2274 | * Access: RW | |
2275 | */ | |
2276 | MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4); | |
2277 | ||
2278 | static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff, | |
2279 | u32 max_buff, u8 pool) | |
2280 | { | |
2281 | MLXSW_REG_ZERO(sbmm, payload); | |
2282 | mlxsw_reg_sbmm_prio_set(payload, prio); | |
2283 | mlxsw_reg_sbmm_min_buff_set(payload, min_buff); | |
2284 | mlxsw_reg_sbmm_max_buff_set(payload, max_buff); | |
2285 | mlxsw_reg_sbmm_pool_set(payload, pool); | |
2286 | } | |
2287 | ||
4ec14b76 IS |
2288 | static inline const char *mlxsw_reg_id_str(u16 reg_id) |
2289 | { | |
2290 | switch (reg_id) { | |
2291 | case MLXSW_REG_SGCR_ID: | |
2292 | return "SGCR"; | |
2293 | case MLXSW_REG_SPAD_ID: | |
2294 | return "SPAD"; | |
e61011b5 IS |
2295 | case MLXSW_REG_SSPR_ID: |
2296 | return "SSPR"; | |
e534a56a JP |
2297 | case MLXSW_REG_SFDAT_ID: |
2298 | return "SFDAT"; | |
236033b3 JP |
2299 | case MLXSW_REG_SFD_ID: |
2300 | return "SFD"; | |
f5d88f58 JP |
2301 | case MLXSW_REG_SFN_ID: |
2302 | return "SFN"; | |
4ec14b76 IS |
2303 | case MLXSW_REG_SPMS_ID: |
2304 | return "SPMS"; | |
b2e345f9 ER |
2305 | case MLXSW_REG_SPVID_ID: |
2306 | return "SPVID"; | |
2307 | case MLXSW_REG_SPVM_ID: | |
2308 | return "SPVM"; | |
4ec14b76 IS |
2309 | case MLXSW_REG_SFGC_ID: |
2310 | return "SFGC"; | |
2311 | case MLXSW_REG_SFTR_ID: | |
2312 | return "SFTR"; | |
2313 | case MLXSW_REG_SPMLR_ID: | |
2314 | return "SPMLR"; | |
64790239 IS |
2315 | case MLXSW_REG_SVFA_ID: |
2316 | return "SVFA"; | |
1f65da74 IS |
2317 | case MLXSW_REG_SVPE_ID: |
2318 | return "SVPE"; | |
f1fb693a IS |
2319 | case MLXSW_REG_SFMR_ID: |
2320 | return "SFMR"; | |
4ec14b76 IS |
2321 | case MLXSW_REG_PMLP_ID: |
2322 | return "PMLP"; | |
2323 | case MLXSW_REG_PMTU_ID: | |
2324 | return "PMTU"; | |
2325 | case MLXSW_REG_PTYS_ID: | |
2326 | return "PTYS"; | |
2327 | case MLXSW_REG_PPAD_ID: | |
2328 | return "PPAD"; | |
2329 | case MLXSW_REG_PAOS_ID: | |
2330 | return "PAOS"; | |
2331 | case MLXSW_REG_PPCNT_ID: | |
2332 | return "PPCNT"; | |
e0594369 JP |
2333 | case MLXSW_REG_PBMC_ID: |
2334 | return "PBMC"; | |
4ec14b76 IS |
2335 | case MLXSW_REG_PSPA_ID: |
2336 | return "PSPA"; | |
2337 | case MLXSW_REG_HTGT_ID: | |
2338 | return "HTGT"; | |
2339 | case MLXSW_REG_HPKT_ID: | |
2340 | return "HPKT"; | |
e0594369 JP |
2341 | case MLXSW_REG_SBPR_ID: |
2342 | return "SBPR"; | |
2343 | case MLXSW_REG_SBCM_ID: | |
2344 | return "SBCM"; | |
2345 | case MLXSW_REG_SBPM_ID: | |
2346 | return "SBPM"; | |
2347 | case MLXSW_REG_SBMM_ID: | |
2348 | return "SBMM"; | |
4ec14b76 IS |
2349 | default: |
2350 | return "*UNKNOWN*"; | |
2351 | } | |
2352 | } | |
2353 | ||
2354 | /* PUDE - Port Up / Down Event | |
2355 | * --------------------------- | |
2356 | * Reports the operational state change of a port. | |
2357 | */ | |
2358 | #define MLXSW_REG_PUDE_LEN 0x10 | |
2359 | ||
2360 | /* reg_pude_swid | |
2361 | * Switch partition ID with which to associate the port. | |
2362 | * Access: Index | |
2363 | */ | |
2364 | MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8); | |
2365 | ||
2366 | /* reg_pude_local_port | |
2367 | * Local port number. | |
2368 | * Access: Index | |
2369 | */ | |
2370 | MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8); | |
2371 | ||
2372 | /* reg_pude_admin_status | |
2373 | * Port administrative state (the desired state). | |
2374 | * 1 - Up. | |
2375 | * 2 - Down. | |
2376 | * 3 - Up once. This means that in case of link failure, the port won't go | |
2377 | * into polling mode, but will wait to be re-enabled by software. | |
2378 | * 4 - Disabled by system. Can only be set by hardware. | |
2379 | * Access: RO | |
2380 | */ | |
2381 | MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4); | |
2382 | ||
2383 | /* reg_pude_oper_status | |
2384 | * Port operatioanl state. | |
2385 | * 1 - Up. | |
2386 | * 2 - Down. | |
2387 | * 3 - Down by port failure. This means that the device will not let the | |
2388 | * port up again until explicitly specified by software. | |
2389 | * Access: RO | |
2390 | */ | |
2391 | MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4); | |
2392 | ||
2393 | #endif |