Commit | Line | Data |
---|---|---|
4ec14b76 IS |
1 | /* |
2 | * drivers/net/ethernet/mellanox/mlxsw/reg.h | |
3279da4c | 3 | * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved. |
69c407aa | 4 | * Copyright (c) 2015-2016 Ido Schimmel <idosch@mellanox.com> |
4ec14b76 | 5 | * Copyright (c) 2015 Elad Raz <eladr@mellanox.com> |
3279da4c | 6 | * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com> |
4457b3df | 7 | * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com> |
4ec14b76 IS |
8 | * |
9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions are met: | |
11 | * | |
12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | |
17 | * 3. Neither the names of the copyright holders nor the names of its | |
18 | * contributors may be used to endorse or promote products derived from | |
19 | * this software without specific prior written permission. | |
20 | * | |
21 | * Alternatively, this software may be distributed under the terms of the | |
22 | * GNU General Public License ("GPL") version 2 as published by the Free | |
23 | * Software Foundation. | |
24 | * | |
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | |
37 | ||
38 | #ifndef _MLXSW_REG_H | |
39 | #define _MLXSW_REG_H | |
40 | ||
41 | #include <linux/string.h> | |
42 | #include <linux/bitops.h> | |
43 | #include <linux/if_vlan.h> | |
44 | ||
45 | #include "item.h" | |
46 | #include "port.h" | |
47 | ||
48 | struct mlxsw_reg_info { | |
49 | u16 id; | |
50 | u16 len; /* In u8 */ | |
8e9658d5 | 51 | const char *name; |
4ec14b76 IS |
52 | }; |
53 | ||
21978dcf JP |
54 | #define MLXSW_REG_DEFINE(_name, _id, _len) \ |
55 | static const struct mlxsw_reg_info mlxsw_reg_##_name = { \ | |
56 | .id = _id, \ | |
57 | .len = _len, \ | |
8e9658d5 | 58 | .name = #_name, \ |
21978dcf JP |
59 | } |
60 | ||
4ec14b76 IS |
61 | #define MLXSW_REG(type) (&mlxsw_reg_##type) |
62 | #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len | |
63 | #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len) | |
64 | ||
65 | /* SGCR - Switch General Configuration Register | |
66 | * -------------------------------------------- | |
67 | * This register is used for configuration of the switch capabilities. | |
68 | */ | |
69 | #define MLXSW_REG_SGCR_ID 0x2000 | |
70 | #define MLXSW_REG_SGCR_LEN 0x10 | |
71 | ||
21978dcf | 72 | MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN); |
4ec14b76 IS |
73 | |
74 | /* reg_sgcr_llb | |
75 | * Link Local Broadcast (Default=0) | |
76 | * When set, all Link Local packets (224.0.0.X) will be treated as broadcast | |
77 | * packets and ignore the IGMP snooping entries. | |
78 | * Access: RW | |
79 | */ | |
80 | MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1); | |
81 | ||
82 | static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb) | |
83 | { | |
84 | MLXSW_REG_ZERO(sgcr, payload); | |
85 | mlxsw_reg_sgcr_llb_set(payload, !!llb); | |
86 | } | |
87 | ||
88 | /* SPAD - Switch Physical Address Register | |
89 | * --------------------------------------- | |
90 | * The SPAD register configures the switch physical MAC address. | |
91 | */ | |
92 | #define MLXSW_REG_SPAD_ID 0x2002 | |
93 | #define MLXSW_REG_SPAD_LEN 0x10 | |
94 | ||
21978dcf | 95 | MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN); |
4ec14b76 IS |
96 | |
97 | /* reg_spad_base_mac | |
98 | * Base MAC address for the switch partitions. | |
99 | * Per switch partition MAC address is equal to: | |
100 | * base_mac + swid | |
101 | * Access: RW | |
102 | */ | |
103 | MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6); | |
104 | ||
fabe5483 ER |
105 | /* SMID - Switch Multicast ID |
106 | * -------------------------- | |
107 | * The MID record maps from a MID (Multicast ID), which is a unique identifier | |
108 | * of the multicast group within the stacking domain, into a list of local | |
109 | * ports into which the packet is replicated. | |
110 | */ | |
111 | #define MLXSW_REG_SMID_ID 0x2007 | |
112 | #define MLXSW_REG_SMID_LEN 0x240 | |
113 | ||
21978dcf | 114 | MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN); |
fabe5483 ER |
115 | |
116 | /* reg_smid_swid | |
117 | * Switch partition ID. | |
118 | * Access: Index | |
119 | */ | |
120 | MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8); | |
121 | ||
122 | /* reg_smid_mid | |
123 | * Multicast identifier - global identifier that represents the multicast group | |
124 | * across all devices. | |
125 | * Access: Index | |
126 | */ | |
127 | MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16); | |
128 | ||
129 | /* reg_smid_port | |
130 | * Local port memebership (1 bit per port). | |
131 | * Access: RW | |
132 | */ | |
133 | MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1); | |
134 | ||
135 | /* reg_smid_port_mask | |
136 | * Local port mask (1 bit per port). | |
137 | * Access: W | |
138 | */ | |
139 | MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1); | |
140 | ||
141 | static inline void mlxsw_reg_smid_pack(char *payload, u16 mid, | |
142 | u8 port, bool set) | |
143 | { | |
144 | MLXSW_REG_ZERO(smid, payload); | |
145 | mlxsw_reg_smid_swid_set(payload, 0); | |
146 | mlxsw_reg_smid_mid_set(payload, mid); | |
147 | mlxsw_reg_smid_port_set(payload, port, set); | |
148 | mlxsw_reg_smid_port_mask_set(payload, port, 1); | |
149 | } | |
150 | ||
e61011b5 IS |
151 | /* SSPR - Switch System Port Record Register |
152 | * ----------------------------------------- | |
153 | * Configures the system port to local port mapping. | |
154 | */ | |
155 | #define MLXSW_REG_SSPR_ID 0x2008 | |
156 | #define MLXSW_REG_SSPR_LEN 0x8 | |
157 | ||
21978dcf | 158 | MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN); |
e61011b5 IS |
159 | |
160 | /* reg_sspr_m | |
161 | * Master - if set, then the record describes the master system port. | |
162 | * This is needed in case a local port is mapped into several system ports | |
163 | * (for multipathing). That number will be reported as the source system | |
164 | * port when packets are forwarded to the CPU. Only one master port is allowed | |
165 | * per local port. | |
166 | * | |
167 | * Note: Must be set for Spectrum. | |
168 | * Access: RW | |
169 | */ | |
170 | MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1); | |
171 | ||
172 | /* reg_sspr_local_port | |
173 | * Local port number. | |
174 | * | |
175 | * Access: RW | |
176 | */ | |
177 | MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8); | |
178 | ||
179 | /* reg_sspr_sub_port | |
180 | * Virtual port within the physical port. | |
181 | * Should be set to 0 when virtual ports are not enabled on the port. | |
182 | * | |
183 | * Access: RW | |
184 | */ | |
185 | MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8); | |
186 | ||
187 | /* reg_sspr_system_port | |
188 | * Unique identifier within the stacking domain that represents all the ports | |
189 | * that are available in the system (external ports). | |
190 | * | |
191 | * Currently, only single-ASIC configurations are supported, so we default to | |
192 | * 1:1 mapping between system ports and local ports. | |
193 | * Access: Index | |
194 | */ | |
195 | MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16); | |
196 | ||
197 | static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port) | |
198 | { | |
199 | MLXSW_REG_ZERO(sspr, payload); | |
200 | mlxsw_reg_sspr_m_set(payload, 1); | |
201 | mlxsw_reg_sspr_local_port_set(payload, local_port); | |
202 | mlxsw_reg_sspr_sub_port_set(payload, 0); | |
203 | mlxsw_reg_sspr_system_port_set(payload, local_port); | |
204 | } | |
205 | ||
e534a56a JP |
206 | /* SFDAT - Switch Filtering Database Aging Time |
207 | * -------------------------------------------- | |
208 | * Controls the Switch aging time. Aging time is able to be set per Switch | |
209 | * Partition. | |
210 | */ | |
211 | #define MLXSW_REG_SFDAT_ID 0x2009 | |
212 | #define MLXSW_REG_SFDAT_LEN 0x8 | |
213 | ||
21978dcf | 214 | MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN); |
e534a56a JP |
215 | |
216 | /* reg_sfdat_swid | |
217 | * Switch partition ID. | |
218 | * Access: Index | |
219 | */ | |
220 | MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8); | |
221 | ||
222 | /* reg_sfdat_age_time | |
223 | * Aging time in seconds | |
224 | * Min - 10 seconds | |
225 | * Max - 1,000,000 seconds | |
226 | * Default is 300 seconds. | |
227 | * Access: RW | |
228 | */ | |
229 | MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20); | |
230 | ||
231 | static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time) | |
232 | { | |
233 | MLXSW_REG_ZERO(sfdat, payload); | |
234 | mlxsw_reg_sfdat_swid_set(payload, 0); | |
235 | mlxsw_reg_sfdat_age_time_set(payload, age_time); | |
236 | } | |
237 | ||
236033b3 JP |
238 | /* SFD - Switch Filtering Database |
239 | * ------------------------------- | |
240 | * The following register defines the access to the filtering database. | |
241 | * The register supports querying, adding, removing and modifying the database. | |
242 | * The access is optimized for bulk updates in which case more than one | |
243 | * FDB record is present in the same command. | |
244 | */ | |
245 | #define MLXSW_REG_SFD_ID 0x200A | |
246 | #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */ | |
247 | #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */ | |
248 | #define MLXSW_REG_SFD_REC_MAX_COUNT 64 | |
249 | #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \ | |
250 | MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT) | |
251 | ||
21978dcf | 252 | MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN); |
236033b3 JP |
253 | |
254 | /* reg_sfd_swid | |
255 | * Switch partition ID for queries. Reserved on Write. | |
256 | * Access: Index | |
257 | */ | |
258 | MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8); | |
259 | ||
260 | enum mlxsw_reg_sfd_op { | |
261 | /* Dump entire FDB a (process according to record_locator) */ | |
262 | MLXSW_REG_SFD_OP_QUERY_DUMP = 0, | |
263 | /* Query records by {MAC, VID/FID} value */ | |
264 | MLXSW_REG_SFD_OP_QUERY_QUERY = 1, | |
265 | /* Query and clear activity. Query records by {MAC, VID/FID} value */ | |
266 | MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2, | |
267 | /* Test. Response indicates if each of the records could be | |
268 | * added to the FDB. | |
269 | */ | |
270 | MLXSW_REG_SFD_OP_WRITE_TEST = 0, | |
271 | /* Add/modify. Aged-out records cannot be added. This command removes | |
272 | * the learning notification of the {MAC, VID/FID}. Response includes | |
273 | * the entries that were added to the FDB. | |
274 | */ | |
275 | MLXSW_REG_SFD_OP_WRITE_EDIT = 1, | |
276 | /* Remove record by {MAC, VID/FID}. This command also removes | |
277 | * the learning notification and aged-out notifications | |
278 | * of the {MAC, VID/FID}. The response provides current (pre-removal) | |
279 | * entries as non-aged-out. | |
280 | */ | |
281 | MLXSW_REG_SFD_OP_WRITE_REMOVE = 2, | |
282 | /* Remove learned notification by {MAC, VID/FID}. The response provides | |
283 | * the removed learning notification. | |
284 | */ | |
285 | MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2, | |
286 | }; | |
287 | ||
288 | /* reg_sfd_op | |
289 | * Operation. | |
290 | * Access: OP | |
291 | */ | |
292 | MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2); | |
293 | ||
294 | /* reg_sfd_record_locator | |
295 | * Used for querying the FDB. Use record_locator=0 to initiate the | |
296 | * query. When a record is returned, a new record_locator is | |
297 | * returned to be used in the subsequent query. | |
298 | * Reserved for database update. | |
299 | * Access: Index | |
300 | */ | |
301 | MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30); | |
302 | ||
303 | /* reg_sfd_num_rec | |
304 | * Request: Number of records to read/add/modify/remove | |
305 | * Response: Number of records read/added/replaced/removed | |
306 | * See above description for more details. | |
307 | * Ranges 0..64 | |
308 | * Access: RW | |
309 | */ | |
310 | MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8); | |
311 | ||
312 | static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op, | |
313 | u32 record_locator) | |
314 | { | |
315 | MLXSW_REG_ZERO(sfd, payload); | |
316 | mlxsw_reg_sfd_op_set(payload, op); | |
317 | mlxsw_reg_sfd_record_locator_set(payload, record_locator); | |
318 | } | |
319 | ||
320 | /* reg_sfd_rec_swid | |
321 | * Switch partition ID. | |
322 | * Access: Index | |
323 | */ | |
324 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8, | |
325 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
326 | ||
327 | enum mlxsw_reg_sfd_rec_type { | |
328 | MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0, | |
e4bfbae2 | 329 | MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1, |
5230b25f | 330 | MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2, |
236033b3 JP |
331 | }; |
332 | ||
333 | /* reg_sfd_rec_type | |
334 | * FDB record type. | |
335 | * Access: RW | |
336 | */ | |
337 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4, | |
338 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
339 | ||
340 | enum mlxsw_reg_sfd_rec_policy { | |
341 | /* Replacement disabled, aging disabled. */ | |
342 | MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0, | |
343 | /* (mlag remote): Replacement enabled, aging disabled, | |
344 | * learning notification enabled on this port. | |
345 | */ | |
346 | MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1, | |
347 | /* (ingress device): Replacement enabled, aging enabled. */ | |
348 | MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3, | |
349 | }; | |
350 | ||
351 | /* reg_sfd_rec_policy | |
352 | * Policy. | |
353 | * Access: RW | |
354 | */ | |
355 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2, | |
356 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
357 | ||
358 | /* reg_sfd_rec_a | |
359 | * Activity. Set for new static entries. Set for static entries if a frame SMAC | |
360 | * lookup hits on the entry. | |
361 | * To clear the a bit, use "query and clear activity" op. | |
362 | * Access: RO | |
363 | */ | |
364 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1, | |
365 | MLXSW_REG_SFD_REC_LEN, 0x00, false); | |
366 | ||
367 | /* reg_sfd_rec_mac | |
368 | * MAC address. | |
369 | * Access: Index | |
370 | */ | |
371 | MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6, | |
372 | MLXSW_REG_SFD_REC_LEN, 0x02); | |
373 | ||
374 | enum mlxsw_reg_sfd_rec_action { | |
375 | /* forward */ | |
376 | MLXSW_REG_SFD_REC_ACTION_NOP = 0, | |
377 | /* forward and trap, trap_id is FDB_TRAP */ | |
378 | MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1, | |
379 | /* trap and do not forward, trap_id is FDB_TRAP */ | |
d82d8c06 IS |
380 | MLXSW_REG_SFD_REC_ACTION_TRAP = 2, |
381 | /* forward to IP router */ | |
382 | MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3, | |
236033b3 JP |
383 | MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15, |
384 | }; | |
385 | ||
386 | /* reg_sfd_rec_action | |
387 | * Action to apply on the packet. | |
388 | * Note: Dynamic entries can only be configured with NOP action. | |
389 | * Access: RW | |
390 | */ | |
391 | MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4, | |
392 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
393 | ||
394 | /* reg_sfd_uc_sub_port | |
4e9ec083 JP |
395 | * VEPA channel on local port. |
396 | * Valid only if local port is a non-stacking port. Must be 0 if multichannel | |
397 | * VEPA is not enabled. | |
236033b3 JP |
398 | * Access: RW |
399 | */ | |
400 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8, | |
401 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
402 | ||
403 | /* reg_sfd_uc_fid_vid | |
404 | * Filtering ID or VLAN ID | |
405 | * For SwitchX and SwitchX-2: | |
406 | * - Dynamic entries (policy 2,3) use FID | |
407 | * - Static entries (policy 0) use VID | |
408 | * - When independent learning is configured, VID=FID | |
409 | * For Spectrum: use FID for both Dynamic and Static entries. | |
410 | * VID should not be used. | |
411 | * Access: Index | |
412 | */ | |
413 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
414 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
415 | ||
416 | /* reg_sfd_uc_system_port | |
417 | * Unique port identifier for the final destination of the packet. | |
418 | * Access: RW | |
419 | */ | |
420 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
421 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
422 | ||
e4bfbae2 JP |
423 | static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index, |
424 | enum mlxsw_reg_sfd_rec_type rec_type, | |
e4bfbae2 JP |
425 | const char *mac, |
426 | enum mlxsw_reg_sfd_rec_action action) | |
236033b3 JP |
427 | { |
428 | u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload); | |
429 | ||
430 | if (rec_index >= num_rec) | |
431 | mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1); | |
432 | mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0); | |
e4bfbae2 | 433 | mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type); |
236033b3 | 434 | mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac); |
e4bfbae2 JP |
435 | mlxsw_reg_sfd_rec_action_set(payload, rec_index, action); |
436 | } | |
437 | ||
438 | static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index, | |
439 | enum mlxsw_reg_sfd_rec_policy policy, | |
9de6a80e | 440 | const char *mac, u16 fid_vid, |
e4bfbae2 JP |
441 | enum mlxsw_reg_sfd_rec_action action, |
442 | u8 local_port) | |
443 | { | |
444 | mlxsw_reg_sfd_rec_pack(payload, rec_index, | |
5230b25f ER |
445 | MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action); |
446 | mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); | |
236033b3 | 447 | mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0); |
9de6a80e | 448 | mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid); |
236033b3 JP |
449 | mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port); |
450 | } | |
451 | ||
75c09280 | 452 | static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index, |
9de6a80e | 453 | char *mac, u16 *p_fid_vid, |
75c09280 | 454 | u8 *p_local_port) |
236033b3 JP |
455 | { |
456 | mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac); | |
9de6a80e | 457 | *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index); |
236033b3 JP |
458 | *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index); |
459 | } | |
460 | ||
e4bfbae2 JP |
461 | /* reg_sfd_uc_lag_sub_port |
462 | * LAG sub port. | |
463 | * Must be 0 if multichannel VEPA is not enabled. | |
464 | * Access: RW | |
465 | */ | |
466 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8, | |
467 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
468 | ||
469 | /* reg_sfd_uc_lag_fid_vid | |
470 | * Filtering ID or VLAN ID | |
471 | * For SwitchX and SwitchX-2: | |
472 | * - Dynamic entries (policy 2,3) use FID | |
473 | * - Static entries (policy 0) use VID | |
474 | * - When independent learning is configured, VID=FID | |
475 | * For Spectrum: use FID for both Dynamic and Static entries. | |
476 | * VID should not be used. | |
477 | * Access: Index | |
478 | */ | |
479 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
480 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
481 | ||
afd7f979 IS |
482 | /* reg_sfd_uc_lag_lag_vid |
483 | * Indicates VID in case of vFIDs. Reserved for FIDs. | |
484 | * Access: RW | |
485 | */ | |
486 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12, | |
487 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
488 | ||
e4bfbae2 JP |
489 | /* reg_sfd_uc_lag_lag_id |
490 | * LAG Identifier - pointer into the LAG descriptor table. | |
491 | * Access: RW | |
492 | */ | |
493 | MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10, | |
494 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
495 | ||
496 | static inline void | |
497 | mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index, | |
498 | enum mlxsw_reg_sfd_rec_policy policy, | |
9de6a80e | 499 | const char *mac, u16 fid_vid, |
afd7f979 | 500 | enum mlxsw_reg_sfd_rec_action action, u16 lag_vid, |
e4bfbae2 JP |
501 | u16 lag_id) |
502 | { | |
503 | mlxsw_reg_sfd_rec_pack(payload, rec_index, | |
504 | MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG, | |
5230b25f ER |
505 | mac, action); |
506 | mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); | |
e4bfbae2 | 507 | mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0); |
9de6a80e | 508 | mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid); |
afd7f979 | 509 | mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid); |
e4bfbae2 JP |
510 | mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id); |
511 | } | |
512 | ||
513 | static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index, | |
514 | char *mac, u16 *p_vid, | |
515 | u16 *p_lag_id) | |
516 | { | |
517 | mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac); | |
518 | *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index); | |
519 | *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index); | |
520 | } | |
521 | ||
5230b25f ER |
522 | /* reg_sfd_mc_pgi |
523 | * | |
524 | * Multicast port group index - index into the port group table. | |
525 | * Value 0x1FFF indicates the pgi should point to the MID entry. | |
526 | * For Spectrum this value must be set to 0x1FFF | |
527 | * Access: RW | |
528 | */ | |
529 | MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13, | |
530 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
531 | ||
532 | /* reg_sfd_mc_fid_vid | |
533 | * | |
534 | * Filtering ID or VLAN ID | |
535 | * Access: Index | |
536 | */ | |
537 | MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
538 | MLXSW_REG_SFD_REC_LEN, 0x08, false); | |
539 | ||
540 | /* reg_sfd_mc_mid | |
541 | * | |
542 | * Multicast identifier - global identifier that represents the multicast | |
543 | * group across all devices. | |
544 | * Access: RW | |
545 | */ | |
546 | MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16, | |
547 | MLXSW_REG_SFD_REC_LEN, 0x0C, false); | |
548 | ||
549 | static inline void | |
550 | mlxsw_reg_sfd_mc_pack(char *payload, int rec_index, | |
551 | const char *mac, u16 fid_vid, | |
552 | enum mlxsw_reg_sfd_rec_action action, u16 mid) | |
553 | { | |
554 | mlxsw_reg_sfd_rec_pack(payload, rec_index, | |
555 | MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action); | |
556 | mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF); | |
557 | mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid); | |
558 | mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid); | |
559 | } | |
560 | ||
f5d88f58 JP |
561 | /* SFN - Switch FDB Notification Register |
562 | * ------------------------------------------- | |
563 | * The switch provides notifications on newly learned FDB entries and | |
564 | * aged out entries. The notifications can be polled by software. | |
565 | */ | |
566 | #define MLXSW_REG_SFN_ID 0x200B | |
567 | #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */ | |
568 | #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */ | |
569 | #define MLXSW_REG_SFN_REC_MAX_COUNT 64 | |
570 | #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \ | |
571 | MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT) | |
572 | ||
21978dcf | 573 | MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN); |
f5d88f58 JP |
574 | |
575 | /* reg_sfn_swid | |
576 | * Switch partition ID. | |
577 | * Access: Index | |
578 | */ | |
579 | MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8); | |
580 | ||
1803e0fb IS |
581 | /* reg_sfn_end |
582 | * Forces the current session to end. | |
583 | * Access: OP | |
584 | */ | |
585 | MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1); | |
586 | ||
f5d88f58 JP |
587 | /* reg_sfn_num_rec |
588 | * Request: Number of learned notifications and aged-out notification | |
589 | * records requested. | |
590 | * Response: Number of notification records returned (must be smaller | |
591 | * than or equal to the value requested) | |
592 | * Ranges 0..64 | |
593 | * Access: OP | |
594 | */ | |
595 | MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8); | |
596 | ||
597 | static inline void mlxsw_reg_sfn_pack(char *payload) | |
598 | { | |
599 | MLXSW_REG_ZERO(sfn, payload); | |
600 | mlxsw_reg_sfn_swid_set(payload, 0); | |
1803e0fb | 601 | mlxsw_reg_sfn_end_set(payload, 1); |
f5d88f58 JP |
602 | mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT); |
603 | } | |
604 | ||
605 | /* reg_sfn_rec_swid | |
606 | * Switch partition ID. | |
607 | * Access: RO | |
608 | */ | |
609 | MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8, | |
610 | MLXSW_REG_SFN_REC_LEN, 0x00, false); | |
611 | ||
612 | enum mlxsw_reg_sfn_rec_type { | |
613 | /* MAC addresses learned on a regular port. */ | |
614 | MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5, | |
3b71571c JP |
615 | /* MAC addresses learned on a LAG port. */ |
616 | MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6, | |
617 | /* Aged-out MAC address on a regular port. */ | |
f5d88f58 | 618 | MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7, |
3b71571c JP |
619 | /* Aged-out MAC address on a LAG port. */ |
620 | MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8, | |
f5d88f58 JP |
621 | }; |
622 | ||
623 | /* reg_sfn_rec_type | |
624 | * Notification record type. | |
625 | * Access: RO | |
626 | */ | |
627 | MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4, | |
628 | MLXSW_REG_SFN_REC_LEN, 0x00, false); | |
629 | ||
630 | /* reg_sfn_rec_mac | |
631 | * MAC address. | |
632 | * Access: RO | |
633 | */ | |
634 | MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6, | |
635 | MLXSW_REG_SFN_REC_LEN, 0x02); | |
636 | ||
8316f087 | 637 | /* reg_sfn_mac_sub_port |
f5d88f58 JP |
638 | * VEPA channel on the local port. |
639 | * 0 if multichannel VEPA is not enabled. | |
640 | * Access: RO | |
641 | */ | |
642 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8, | |
643 | MLXSW_REG_SFN_REC_LEN, 0x08, false); | |
644 | ||
8316f087 | 645 | /* reg_sfn_mac_fid |
f5d88f58 JP |
646 | * Filtering identifier. |
647 | * Access: RO | |
648 | */ | |
649 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16, | |
650 | MLXSW_REG_SFN_REC_LEN, 0x08, false); | |
651 | ||
8316f087 | 652 | /* reg_sfn_mac_system_port |
f5d88f58 JP |
653 | * Unique port identifier for the final destination of the packet. |
654 | * Access: RO | |
655 | */ | |
656 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16, | |
657 | MLXSW_REG_SFN_REC_LEN, 0x0C, false); | |
658 | ||
659 | static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index, | |
660 | char *mac, u16 *p_vid, | |
661 | u8 *p_local_port) | |
662 | { | |
663 | mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac); | |
664 | *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index); | |
665 | *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index); | |
666 | } | |
667 | ||
3b71571c JP |
668 | /* reg_sfn_mac_lag_lag_id |
669 | * LAG ID (pointer into the LAG descriptor table). | |
670 | * Access: RO | |
671 | */ | |
672 | MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10, | |
673 | MLXSW_REG_SFN_REC_LEN, 0x0C, false); | |
674 | ||
675 | static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index, | |
676 | char *mac, u16 *p_vid, | |
677 | u16 *p_lag_id) | |
678 | { | |
679 | mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac); | |
680 | *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index); | |
681 | *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index); | |
682 | } | |
683 | ||
4ec14b76 IS |
684 | /* SPMS - Switch Port MSTP/RSTP State Register |
685 | * ------------------------------------------- | |
686 | * Configures the spanning tree state of a physical port. | |
687 | */ | |
3f0effd1 | 688 | #define MLXSW_REG_SPMS_ID 0x200D |
4ec14b76 IS |
689 | #define MLXSW_REG_SPMS_LEN 0x404 |
690 | ||
21978dcf | 691 | MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN); |
4ec14b76 IS |
692 | |
693 | /* reg_spms_local_port | |
694 | * Local port number. | |
695 | * Access: Index | |
696 | */ | |
697 | MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8); | |
698 | ||
699 | enum mlxsw_reg_spms_state { | |
700 | MLXSW_REG_SPMS_STATE_NO_CHANGE, | |
701 | MLXSW_REG_SPMS_STATE_DISCARDING, | |
702 | MLXSW_REG_SPMS_STATE_LEARNING, | |
703 | MLXSW_REG_SPMS_STATE_FORWARDING, | |
704 | }; | |
705 | ||
706 | /* reg_spms_state | |
707 | * Spanning tree state of each VLAN ID (VID) of the local port. | |
708 | * 0 - Do not change spanning tree state (used only when writing). | |
709 | * 1 - Discarding. No learning or forwarding to/from this port (default). | |
710 | * 2 - Learning. Port is learning, but not forwarding. | |
711 | * 3 - Forwarding. Port is learning and forwarding. | |
712 | * Access: RW | |
713 | */ | |
714 | MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2); | |
715 | ||
ebb7963f | 716 | static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port) |
4ec14b76 IS |
717 | { |
718 | MLXSW_REG_ZERO(spms, payload); | |
719 | mlxsw_reg_spms_local_port_set(payload, local_port); | |
ebb7963f JP |
720 | } |
721 | ||
722 | static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid, | |
723 | enum mlxsw_reg_spms_state state) | |
724 | { | |
4ec14b76 IS |
725 | mlxsw_reg_spms_state_set(payload, vid, state); |
726 | } | |
727 | ||
b2e345f9 ER |
728 | /* SPVID - Switch Port VID |
729 | * ----------------------- | |
730 | * The switch port VID configures the default VID for a port. | |
731 | */ | |
732 | #define MLXSW_REG_SPVID_ID 0x200E | |
733 | #define MLXSW_REG_SPVID_LEN 0x08 | |
734 | ||
21978dcf | 735 | MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN); |
b2e345f9 ER |
736 | |
737 | /* reg_spvid_local_port | |
738 | * Local port number. | |
739 | * Access: Index | |
740 | */ | |
741 | MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8); | |
742 | ||
743 | /* reg_spvid_sub_port | |
744 | * Virtual port within the physical port. | |
745 | * Should be set to 0 when virtual ports are not enabled on the port. | |
746 | * Access: Index | |
747 | */ | |
748 | MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8); | |
749 | ||
750 | /* reg_spvid_pvid | |
751 | * Port default VID | |
752 | * Access: RW | |
753 | */ | |
754 | MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12); | |
755 | ||
756 | static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid) | |
757 | { | |
758 | MLXSW_REG_ZERO(spvid, payload); | |
759 | mlxsw_reg_spvid_local_port_set(payload, local_port); | |
760 | mlxsw_reg_spvid_pvid_set(payload, pvid); | |
761 | } | |
762 | ||
763 | /* SPVM - Switch Port VLAN Membership | |
764 | * ---------------------------------- | |
765 | * The Switch Port VLAN Membership register configures the VLAN membership | |
766 | * of a port in a VLAN denoted by VID. VLAN membership is managed per | |
767 | * virtual port. The register can be used to add and remove VID(s) from a port. | |
768 | */ | |
769 | #define MLXSW_REG_SPVM_ID 0x200F | |
770 | #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */ | |
771 | #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */ | |
f004ec06 | 772 | #define MLXSW_REG_SPVM_REC_MAX_COUNT 255 |
b2e345f9 ER |
773 | #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \ |
774 | MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT) | |
775 | ||
21978dcf | 776 | MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN); |
b2e345f9 ER |
777 | |
778 | /* reg_spvm_pt | |
779 | * Priority tagged. If this bit is set, packets forwarded to the port with | |
780 | * untagged VLAN membership (u bit is set) will be tagged with priority tag | |
781 | * (VID=0) | |
782 | * Access: RW | |
783 | */ | |
784 | MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1); | |
785 | ||
786 | /* reg_spvm_pte | |
787 | * Priority Tagged Update Enable. On Write operations, if this bit is cleared, | |
788 | * the pt bit will NOT be updated. To update the pt bit, pte must be set. | |
789 | * Access: WO | |
790 | */ | |
791 | MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1); | |
792 | ||
793 | /* reg_spvm_local_port | |
794 | * Local port number. | |
795 | * Access: Index | |
796 | */ | |
797 | MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8); | |
798 | ||
799 | /* reg_spvm_sub_port | |
800 | * Virtual port within the physical port. | |
801 | * Should be set to 0 when virtual ports are not enabled on the port. | |
802 | * Access: Index | |
803 | */ | |
804 | MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8); | |
805 | ||
806 | /* reg_spvm_num_rec | |
807 | * Number of records to update. Each record contains: i, e, u, vid. | |
808 | * Access: OP | |
809 | */ | |
810 | MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8); | |
811 | ||
812 | /* reg_spvm_rec_i | |
813 | * Ingress membership in VLAN ID. | |
814 | * Access: Index | |
815 | */ | |
816 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_i, | |
817 | MLXSW_REG_SPVM_BASE_LEN, 14, 1, | |
818 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
819 | ||
820 | /* reg_spvm_rec_e | |
821 | * Egress membership in VLAN ID. | |
822 | * Access: Index | |
823 | */ | |
824 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_e, | |
825 | MLXSW_REG_SPVM_BASE_LEN, 13, 1, | |
826 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
827 | ||
828 | /* reg_spvm_rec_u | |
829 | * Untagged - port is an untagged member - egress transmission uses untagged | |
830 | * frames on VID<n> | |
831 | * Access: Index | |
832 | */ | |
833 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_u, | |
834 | MLXSW_REG_SPVM_BASE_LEN, 12, 1, | |
835 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
836 | ||
837 | /* reg_spvm_rec_vid | |
838 | * Egress membership in VLAN ID. | |
839 | * Access: Index | |
840 | */ | |
841 | MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid, | |
842 | MLXSW_REG_SPVM_BASE_LEN, 0, 12, | |
843 | MLXSW_REG_SPVM_REC_LEN, 0, false); | |
844 | ||
845 | static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port, | |
846 | u16 vid_begin, u16 vid_end, | |
847 | bool is_member, bool untagged) | |
848 | { | |
849 | int size = vid_end - vid_begin + 1; | |
850 | int i; | |
851 | ||
852 | MLXSW_REG_ZERO(spvm, payload); | |
853 | mlxsw_reg_spvm_local_port_set(payload, local_port); | |
854 | mlxsw_reg_spvm_num_rec_set(payload, size); | |
855 | ||
856 | for (i = 0; i < size; i++) { | |
857 | mlxsw_reg_spvm_rec_i_set(payload, i, is_member); | |
858 | mlxsw_reg_spvm_rec_e_set(payload, i, is_member); | |
859 | mlxsw_reg_spvm_rec_u_set(payload, i, untagged); | |
860 | mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i); | |
861 | } | |
862 | } | |
863 | ||
148f472d IS |
864 | /* SPAFT - Switch Port Acceptable Frame Types |
865 | * ------------------------------------------ | |
866 | * The Switch Port Acceptable Frame Types register configures the frame | |
867 | * admittance of the port. | |
868 | */ | |
869 | #define MLXSW_REG_SPAFT_ID 0x2010 | |
870 | #define MLXSW_REG_SPAFT_LEN 0x08 | |
871 | ||
21978dcf | 872 | MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN); |
148f472d IS |
873 | |
874 | /* reg_spaft_local_port | |
875 | * Local port number. | |
876 | * Access: Index | |
877 | * | |
878 | * Note: CPU port is not supported (all tag types are allowed). | |
879 | */ | |
880 | MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8); | |
881 | ||
882 | /* reg_spaft_sub_port | |
883 | * Virtual port within the physical port. | |
884 | * Should be set to 0 when virtual ports are not enabled on the port. | |
885 | * Access: RW | |
886 | */ | |
887 | MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8); | |
888 | ||
889 | /* reg_spaft_allow_untagged | |
890 | * When set, untagged frames on the ingress are allowed (default). | |
891 | * Access: RW | |
892 | */ | |
893 | MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1); | |
894 | ||
895 | /* reg_spaft_allow_prio_tagged | |
896 | * When set, priority tagged frames on the ingress are allowed (default). | |
897 | * Access: RW | |
898 | */ | |
899 | MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1); | |
900 | ||
901 | /* reg_spaft_allow_tagged | |
902 | * When set, tagged frames on the ingress are allowed (default). | |
903 | * Access: RW | |
904 | */ | |
905 | MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1); | |
906 | ||
907 | static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port, | |
908 | bool allow_untagged) | |
909 | { | |
910 | MLXSW_REG_ZERO(spaft, payload); | |
911 | mlxsw_reg_spaft_local_port_set(payload, local_port); | |
912 | mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged); | |
913 | mlxsw_reg_spaft_allow_prio_tagged_set(payload, true); | |
914 | mlxsw_reg_spaft_allow_tagged_set(payload, true); | |
915 | } | |
916 | ||
4ec14b76 IS |
917 | /* SFGC - Switch Flooding Group Configuration |
918 | * ------------------------------------------ | |
919 | * The following register controls the association of flooding tables and MIDs | |
920 | * to packet types used for flooding. | |
921 | */ | |
36b78e8a | 922 | #define MLXSW_REG_SFGC_ID 0x2011 |
4ec14b76 IS |
923 | #define MLXSW_REG_SFGC_LEN 0x10 |
924 | ||
21978dcf | 925 | MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN); |
4ec14b76 IS |
926 | |
927 | enum mlxsw_reg_sfgc_type { | |
fa6ad058 IS |
928 | MLXSW_REG_SFGC_TYPE_BROADCAST, |
929 | MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST, | |
930 | MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4, | |
931 | MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6, | |
932 | MLXSW_REG_SFGC_TYPE_RESERVED, | |
933 | MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP, | |
934 | MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL, | |
935 | MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST, | |
936 | MLXSW_REG_SFGC_TYPE_MAX, | |
4ec14b76 IS |
937 | }; |
938 | ||
939 | /* reg_sfgc_type | |
940 | * The traffic type to reach the flooding table. | |
941 | * Access: Index | |
942 | */ | |
943 | MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4); | |
944 | ||
945 | enum mlxsw_reg_sfgc_bridge_type { | |
946 | MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0, | |
947 | MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1, | |
948 | }; | |
949 | ||
950 | /* reg_sfgc_bridge_type | |
951 | * Access: Index | |
952 | * | |
953 | * Note: SwitchX-2 only supports 802.1Q mode. | |
954 | */ | |
955 | MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3); | |
956 | ||
957 | enum mlxsw_flood_table_type { | |
958 | MLXSW_REG_SFGC_TABLE_TYPE_VID = 1, | |
959 | MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2, | |
960 | MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0, | |
961 | MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3, | |
962 | MLXSW_REG_SFGC_TABLE_TYPE_FID = 4, | |
963 | }; | |
964 | ||
965 | /* reg_sfgc_table_type | |
966 | * See mlxsw_flood_table_type | |
967 | * Access: RW | |
968 | * | |
969 | * Note: FID offset and FID types are not supported in SwitchX-2. | |
970 | */ | |
971 | MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3); | |
972 | ||
973 | /* reg_sfgc_flood_table | |
974 | * Flooding table index to associate with the specific type on the specific | |
975 | * switch partition. | |
976 | * Access: RW | |
977 | */ | |
978 | MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6); | |
979 | ||
980 | /* reg_sfgc_mid | |
981 | * The multicast ID for the swid. Not supported for Spectrum | |
982 | * Access: RW | |
983 | */ | |
984 | MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16); | |
985 | ||
986 | /* reg_sfgc_counter_set_type | |
987 | * Counter Set Type for flow counters. | |
988 | * Access: RW | |
989 | */ | |
990 | MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8); | |
991 | ||
992 | /* reg_sfgc_counter_index | |
993 | * Counter Index for flow counters. | |
994 | * Access: RW | |
995 | */ | |
996 | MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24); | |
997 | ||
998 | static inline void | |
999 | mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type, | |
1000 | enum mlxsw_reg_sfgc_bridge_type bridge_type, | |
1001 | enum mlxsw_flood_table_type table_type, | |
1002 | unsigned int flood_table) | |
1003 | { | |
1004 | MLXSW_REG_ZERO(sfgc, payload); | |
1005 | mlxsw_reg_sfgc_type_set(payload, type); | |
1006 | mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type); | |
1007 | mlxsw_reg_sfgc_table_type_set(payload, table_type); | |
1008 | mlxsw_reg_sfgc_flood_table_set(payload, flood_table); | |
1009 | mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID); | |
1010 | } | |
1011 | ||
1012 | /* SFTR - Switch Flooding Table Register | |
1013 | * ------------------------------------- | |
1014 | * The switch flooding table is used for flooding packet replication. The table | |
1015 | * defines a bit mask of ports for packet replication. | |
1016 | */ | |
1017 | #define MLXSW_REG_SFTR_ID 0x2012 | |
1018 | #define MLXSW_REG_SFTR_LEN 0x420 | |
1019 | ||
21978dcf | 1020 | MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN); |
4ec14b76 IS |
1021 | |
1022 | /* reg_sftr_swid | |
1023 | * Switch partition ID with which to associate the port. | |
1024 | * Access: Index | |
1025 | */ | |
1026 | MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8); | |
1027 | ||
1028 | /* reg_sftr_flood_table | |
1029 | * Flooding table index to associate with the specific type on the specific | |
1030 | * switch partition. | |
1031 | * Access: Index | |
1032 | */ | |
1033 | MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6); | |
1034 | ||
1035 | /* reg_sftr_index | |
1036 | * Index. Used as an index into the Flooding Table in case the table is | |
1037 | * configured to use VID / FID or FID Offset. | |
1038 | * Access: Index | |
1039 | */ | |
1040 | MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16); | |
1041 | ||
1042 | /* reg_sftr_table_type | |
1043 | * See mlxsw_flood_table_type | |
1044 | * Access: RW | |
1045 | */ | |
1046 | MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3); | |
1047 | ||
1048 | /* reg_sftr_range | |
1049 | * Range of entries to update | |
1050 | * Access: Index | |
1051 | */ | |
1052 | MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16); | |
1053 | ||
1054 | /* reg_sftr_port | |
1055 | * Local port membership (1 bit per port). | |
1056 | * Access: RW | |
1057 | */ | |
1058 | MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1); | |
1059 | ||
1060 | /* reg_sftr_cpu_port_mask | |
1061 | * CPU port mask (1 bit per port). | |
1062 | * Access: W | |
1063 | */ | |
1064 | MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1); | |
1065 | ||
1066 | static inline void mlxsw_reg_sftr_pack(char *payload, | |
1067 | unsigned int flood_table, | |
1068 | unsigned int index, | |
1069 | enum mlxsw_flood_table_type table_type, | |
bc2055f8 | 1070 | unsigned int range, u8 port, bool set) |
4ec14b76 IS |
1071 | { |
1072 | MLXSW_REG_ZERO(sftr, payload); | |
1073 | mlxsw_reg_sftr_swid_set(payload, 0); | |
1074 | mlxsw_reg_sftr_flood_table_set(payload, flood_table); | |
1075 | mlxsw_reg_sftr_index_set(payload, index); | |
1076 | mlxsw_reg_sftr_table_type_set(payload, table_type); | |
1077 | mlxsw_reg_sftr_range_set(payload, range); | |
bc2055f8 IS |
1078 | mlxsw_reg_sftr_port_set(payload, port, set); |
1079 | mlxsw_reg_sftr_port_mask_set(payload, port, 1); | |
4ec14b76 IS |
1080 | } |
1081 | ||
41933271 IS |
1082 | /* SFDF - Switch Filtering DB Flush |
1083 | * -------------------------------- | |
1084 | * The switch filtering DB flush register is used to flush the FDB. | |
1085 | * Note that FDB notifications are flushed as well. | |
1086 | */ | |
1087 | #define MLXSW_REG_SFDF_ID 0x2013 | |
1088 | #define MLXSW_REG_SFDF_LEN 0x14 | |
1089 | ||
21978dcf | 1090 | MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN); |
41933271 IS |
1091 | |
1092 | /* reg_sfdf_swid | |
1093 | * Switch partition ID. | |
1094 | * Access: Index | |
1095 | */ | |
1096 | MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8); | |
1097 | ||
1098 | enum mlxsw_reg_sfdf_flush_type { | |
1099 | MLXSW_REG_SFDF_FLUSH_PER_SWID, | |
1100 | MLXSW_REG_SFDF_FLUSH_PER_FID, | |
1101 | MLXSW_REG_SFDF_FLUSH_PER_PORT, | |
1102 | MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID, | |
1103 | MLXSW_REG_SFDF_FLUSH_PER_LAG, | |
1104 | MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID, | |
1105 | }; | |
1106 | ||
1107 | /* reg_sfdf_flush_type | |
1108 | * Flush type. | |
1109 | * 0 - All SWID dynamic entries are flushed. | |
1110 | * 1 - All FID dynamic entries are flushed. | |
1111 | * 2 - All dynamic entries pointing to port are flushed. | |
1112 | * 3 - All FID dynamic entries pointing to port are flushed. | |
1113 | * 4 - All dynamic entries pointing to LAG are flushed. | |
1114 | * 5 - All FID dynamic entries pointing to LAG are flushed. | |
1115 | * Access: RW | |
1116 | */ | |
1117 | MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4); | |
1118 | ||
1119 | /* reg_sfdf_flush_static | |
1120 | * Static. | |
1121 | * 0 - Flush only dynamic entries. | |
1122 | * 1 - Flush both dynamic and static entries. | |
1123 | * Access: RW | |
1124 | */ | |
1125 | MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1); | |
1126 | ||
1127 | static inline void mlxsw_reg_sfdf_pack(char *payload, | |
1128 | enum mlxsw_reg_sfdf_flush_type type) | |
1129 | { | |
1130 | MLXSW_REG_ZERO(sfdf, payload); | |
1131 | mlxsw_reg_sfdf_flush_type_set(payload, type); | |
1132 | mlxsw_reg_sfdf_flush_static_set(payload, true); | |
1133 | } | |
1134 | ||
1135 | /* reg_sfdf_fid | |
1136 | * FID to flush. | |
1137 | * Access: RW | |
1138 | */ | |
1139 | MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16); | |
1140 | ||
1141 | /* reg_sfdf_system_port | |
1142 | * Port to flush. | |
1143 | * Access: RW | |
1144 | */ | |
1145 | MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16); | |
1146 | ||
1147 | /* reg_sfdf_port_fid_system_port | |
1148 | * Port to flush, pointed to by FID. | |
1149 | * Access: RW | |
1150 | */ | |
1151 | MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16); | |
1152 | ||
1153 | /* reg_sfdf_lag_id | |
1154 | * LAG ID to flush. | |
1155 | * Access: RW | |
1156 | */ | |
1157 | MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10); | |
1158 | ||
1159 | /* reg_sfdf_lag_fid_lag_id | |
1160 | * LAG ID to flush, pointed to by FID. | |
1161 | * Access: RW | |
1162 | */ | |
1163 | MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10); | |
1164 | ||
d1d40be0 JP |
1165 | /* SLDR - Switch LAG Descriptor Register |
1166 | * ----------------------------------------- | |
1167 | * The switch LAG descriptor register is populated by LAG descriptors. | |
1168 | * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to | |
1169 | * max_lag-1. | |
1170 | */ | |
1171 | #define MLXSW_REG_SLDR_ID 0x2014 | |
1172 | #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */ | |
1173 | ||
21978dcf | 1174 | MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN); |
d1d40be0 JP |
1175 | |
1176 | enum mlxsw_reg_sldr_op { | |
1177 | /* Indicates a creation of a new LAG-ID, lag_id must be valid */ | |
1178 | MLXSW_REG_SLDR_OP_LAG_CREATE, | |
1179 | MLXSW_REG_SLDR_OP_LAG_DESTROY, | |
1180 | /* Ports that appear in the list have the Distributor enabled */ | |
1181 | MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST, | |
1182 | /* Removes ports from the disributor list */ | |
1183 | MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST, | |
1184 | }; | |
1185 | ||
1186 | /* reg_sldr_op | |
1187 | * Operation. | |
1188 | * Access: RW | |
1189 | */ | |
1190 | MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3); | |
1191 | ||
1192 | /* reg_sldr_lag_id | |
1193 | * LAG identifier. The lag_id is the index into the LAG descriptor table. | |
1194 | * Access: Index | |
1195 | */ | |
1196 | MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10); | |
1197 | ||
1198 | static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id) | |
1199 | { | |
1200 | MLXSW_REG_ZERO(sldr, payload); | |
1201 | mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE); | |
1202 | mlxsw_reg_sldr_lag_id_set(payload, lag_id); | |
1203 | } | |
1204 | ||
1205 | static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id) | |
1206 | { | |
1207 | MLXSW_REG_ZERO(sldr, payload); | |
1208 | mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY); | |
1209 | mlxsw_reg_sldr_lag_id_set(payload, lag_id); | |
1210 | } | |
1211 | ||
1212 | /* reg_sldr_num_ports | |
1213 | * The number of member ports of the LAG. | |
1214 | * Reserved for Create / Destroy operations | |
1215 | * For Add / Remove operations - indicates the number of ports in the list. | |
1216 | * Access: RW | |
1217 | */ | |
1218 | MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8); | |
1219 | ||
1220 | /* reg_sldr_system_port | |
1221 | * System port. | |
1222 | * Access: RW | |
1223 | */ | |
1224 | MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false); | |
1225 | ||
1226 | static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id, | |
1227 | u8 local_port) | |
1228 | { | |
1229 | MLXSW_REG_ZERO(sldr, payload); | |
1230 | mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST); | |
1231 | mlxsw_reg_sldr_lag_id_set(payload, lag_id); | |
1232 | mlxsw_reg_sldr_num_ports_set(payload, 1); | |
1233 | mlxsw_reg_sldr_system_port_set(payload, 0, local_port); | |
1234 | } | |
1235 | ||
1236 | static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id, | |
1237 | u8 local_port) | |
1238 | { | |
1239 | MLXSW_REG_ZERO(sldr, payload); | |
1240 | mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST); | |
1241 | mlxsw_reg_sldr_lag_id_set(payload, lag_id); | |
1242 | mlxsw_reg_sldr_num_ports_set(payload, 1); | |
1243 | mlxsw_reg_sldr_system_port_set(payload, 0, local_port); | |
1244 | } | |
1245 | ||
1246 | /* SLCR - Switch LAG Configuration 2 Register | |
1247 | * ------------------------------------------- | |
1248 | * The Switch LAG Configuration register is used for configuring the | |
1249 | * LAG properties of the switch. | |
1250 | */ | |
1251 | #define MLXSW_REG_SLCR_ID 0x2015 | |
1252 | #define MLXSW_REG_SLCR_LEN 0x10 | |
1253 | ||
21978dcf | 1254 | MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN); |
d1d40be0 JP |
1255 | |
1256 | enum mlxsw_reg_slcr_pp { | |
1257 | /* Global Configuration (for all ports) */ | |
1258 | MLXSW_REG_SLCR_PP_GLOBAL, | |
1259 | /* Per port configuration, based on local_port field */ | |
1260 | MLXSW_REG_SLCR_PP_PER_PORT, | |
1261 | }; | |
1262 | ||
1263 | /* reg_slcr_pp | |
1264 | * Per Port Configuration | |
1265 | * Note: Reading at Global mode results in reading port 1 configuration. | |
1266 | * Access: Index | |
1267 | */ | |
1268 | MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1); | |
1269 | ||
1270 | /* reg_slcr_local_port | |
1271 | * Local port number | |
1272 | * Supported from CPU port | |
1273 | * Not supported from router port | |
1274 | * Reserved when pp = Global Configuration | |
1275 | * Access: Index | |
1276 | */ | |
1277 | MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8); | |
1278 | ||
1279 | enum mlxsw_reg_slcr_type { | |
1280 | MLXSW_REG_SLCR_TYPE_CRC, /* default */ | |
1281 | MLXSW_REG_SLCR_TYPE_XOR, | |
1282 | MLXSW_REG_SLCR_TYPE_RANDOM, | |
1283 | }; | |
1284 | ||
1285 | /* reg_slcr_type | |
1286 | * Hash type | |
1287 | * Access: RW | |
1288 | */ | |
1289 | MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4); | |
1290 | ||
1291 | /* Ingress port */ | |
1292 | #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0) | |
1293 | /* SMAC - for IPv4 and IPv6 packets */ | |
1294 | #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1) | |
1295 | /* SMAC - for non-IP packets */ | |
1296 | #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2) | |
1297 | #define MLXSW_REG_SLCR_LAG_HASH_SMAC \ | |
1298 | (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \ | |
1299 | MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP) | |
1300 | /* DMAC - for IPv4 and IPv6 packets */ | |
1301 | #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3) | |
1302 | /* DMAC - for non-IP packets */ | |
1303 | #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4) | |
1304 | #define MLXSW_REG_SLCR_LAG_HASH_DMAC \ | |
1305 | (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \ | |
1306 | MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP) | |
1307 | /* Ethertype - for IPv4 and IPv6 packets */ | |
1308 | #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5) | |
1309 | /* Ethertype - for non-IP packets */ | |
1310 | #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6) | |
1311 | #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \ | |
1312 | (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \ | |
1313 | MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP) | |
1314 | /* VLAN ID - for IPv4 and IPv6 packets */ | |
1315 | #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7) | |
1316 | /* VLAN ID - for non-IP packets */ | |
1317 | #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8) | |
1318 | #define MLXSW_REG_SLCR_LAG_HASH_VLANID \ | |
1319 | (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \ | |
1320 | MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP) | |
1321 | /* Source IP address (can be IPv4 or IPv6) */ | |
1322 | #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9) | |
1323 | /* Destination IP address (can be IPv4 or IPv6) */ | |
1324 | #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10) | |
1325 | /* TCP/UDP source port */ | |
1326 | #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11) | |
1327 | /* TCP/UDP destination port*/ | |
1328 | #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12) | |
1329 | /* IPv4 Protocol/IPv6 Next Header */ | |
1330 | #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13) | |
1331 | /* IPv6 Flow label */ | |
1332 | #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14) | |
1333 | /* SID - FCoE source ID */ | |
1334 | #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15) | |
1335 | /* DID - FCoE destination ID */ | |
1336 | #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16) | |
1337 | /* OXID - FCoE originator exchange ID */ | |
1338 | #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17) | |
1339 | /* Destination QP number - for RoCE packets */ | |
1340 | #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19) | |
1341 | ||
1342 | /* reg_slcr_lag_hash | |
1343 | * LAG hashing configuration. This is a bitmask, in which each set | |
1344 | * bit includes the corresponding item in the LAG hash calculation. | |
1345 | * The default lag_hash contains SMAC, DMAC, VLANID and | |
1346 | * Ethertype (for all packet types). | |
1347 | * Access: RW | |
1348 | */ | |
1349 | MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20); | |
1350 | ||
1351 | static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash) | |
1352 | { | |
1353 | MLXSW_REG_ZERO(slcr, payload); | |
1354 | mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL); | |
18c2d2c1 | 1355 | mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC); |
d1d40be0 JP |
1356 | mlxsw_reg_slcr_lag_hash_set(payload, lag_hash); |
1357 | } | |
1358 | ||
1359 | /* SLCOR - Switch LAG Collector Register | |
1360 | * ------------------------------------- | |
1361 | * The Switch LAG Collector register controls the Local Port membership | |
1362 | * in a LAG and enablement of the collector. | |
1363 | */ | |
1364 | #define MLXSW_REG_SLCOR_ID 0x2016 | |
1365 | #define MLXSW_REG_SLCOR_LEN 0x10 | |
1366 | ||
21978dcf | 1367 | MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN); |
d1d40be0 JP |
1368 | |
1369 | enum mlxsw_reg_slcor_col { | |
1370 | /* Port is added with collector disabled */ | |
1371 | MLXSW_REG_SLCOR_COL_LAG_ADD_PORT, | |
1372 | MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED, | |
1373 | MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED, | |
1374 | MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT, | |
1375 | }; | |
1376 | ||
1377 | /* reg_slcor_col | |
1378 | * Collector configuration | |
1379 | * Access: RW | |
1380 | */ | |
1381 | MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2); | |
1382 | ||
1383 | /* reg_slcor_local_port | |
1384 | * Local port number | |
1385 | * Not supported for CPU port | |
1386 | * Access: Index | |
1387 | */ | |
1388 | MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8); | |
1389 | ||
1390 | /* reg_slcor_lag_id | |
1391 | * LAG Identifier. Index into the LAG descriptor table. | |
1392 | * Access: Index | |
1393 | */ | |
1394 | MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10); | |
1395 | ||
1396 | /* reg_slcor_port_index | |
1397 | * Port index in the LAG list. Only valid on Add Port to LAG col. | |
1398 | * Valid range is from 0 to cap_max_lag_members-1 | |
1399 | * Access: RW | |
1400 | */ | |
1401 | MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10); | |
1402 | ||
1403 | static inline void mlxsw_reg_slcor_pack(char *payload, | |
1404 | u8 local_port, u16 lag_id, | |
1405 | enum mlxsw_reg_slcor_col col) | |
1406 | { | |
1407 | MLXSW_REG_ZERO(slcor, payload); | |
1408 | mlxsw_reg_slcor_col_set(payload, col); | |
1409 | mlxsw_reg_slcor_local_port_set(payload, local_port); | |
1410 | mlxsw_reg_slcor_lag_id_set(payload, lag_id); | |
1411 | } | |
1412 | ||
1413 | static inline void mlxsw_reg_slcor_port_add_pack(char *payload, | |
1414 | u8 local_port, u16 lag_id, | |
1415 | u8 port_index) | |
1416 | { | |
1417 | mlxsw_reg_slcor_pack(payload, local_port, lag_id, | |
1418 | MLXSW_REG_SLCOR_COL_LAG_ADD_PORT); | |
1419 | mlxsw_reg_slcor_port_index_set(payload, port_index); | |
1420 | } | |
1421 | ||
1422 | static inline void mlxsw_reg_slcor_port_remove_pack(char *payload, | |
1423 | u8 local_port, u16 lag_id) | |
1424 | { | |
1425 | mlxsw_reg_slcor_pack(payload, local_port, lag_id, | |
1426 | MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT); | |
1427 | } | |
1428 | ||
1429 | static inline void mlxsw_reg_slcor_col_enable_pack(char *payload, | |
1430 | u8 local_port, u16 lag_id) | |
1431 | { | |
1432 | mlxsw_reg_slcor_pack(payload, local_port, lag_id, | |
1433 | MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED); | |
1434 | } | |
1435 | ||
1436 | static inline void mlxsw_reg_slcor_col_disable_pack(char *payload, | |
1437 | u8 local_port, u16 lag_id) | |
1438 | { | |
1439 | mlxsw_reg_slcor_pack(payload, local_port, lag_id, | |
1440 | MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED); | |
1441 | } | |
1442 | ||
4ec14b76 IS |
1443 | /* SPMLR - Switch Port MAC Learning Register |
1444 | * ----------------------------------------- | |
1445 | * Controls the Switch MAC learning policy per port. | |
1446 | */ | |
1447 | #define MLXSW_REG_SPMLR_ID 0x2018 | |
1448 | #define MLXSW_REG_SPMLR_LEN 0x8 | |
1449 | ||
21978dcf | 1450 | MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN); |
4ec14b76 IS |
1451 | |
1452 | /* reg_spmlr_local_port | |
1453 | * Local port number. | |
1454 | * Access: Index | |
1455 | */ | |
1456 | MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8); | |
1457 | ||
1458 | /* reg_spmlr_sub_port | |
1459 | * Virtual port within the physical port. | |
1460 | * Should be set to 0 when virtual ports are not enabled on the port. | |
1461 | * Access: Index | |
1462 | */ | |
1463 | MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8); | |
1464 | ||
1465 | enum mlxsw_reg_spmlr_learn_mode { | |
1466 | MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0, | |
1467 | MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2, | |
1468 | MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3, | |
1469 | }; | |
1470 | ||
1471 | /* reg_spmlr_learn_mode | |
1472 | * Learning mode on the port. | |
1473 | * 0 - Learning disabled. | |
1474 | * 2 - Learning enabled. | |
1475 | * 3 - Security mode. | |
1476 | * | |
1477 | * In security mode the switch does not learn MACs on the port, but uses the | |
1478 | * SMAC to see if it exists on another ingress port. If so, the packet is | |
1479 | * classified as a bad packet and is discarded unless the software registers | |
1480 | * to receive port security error packets usign HPKT. | |
1481 | */ | |
1482 | MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2); | |
1483 | ||
1484 | static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port, | |
1485 | enum mlxsw_reg_spmlr_learn_mode mode) | |
1486 | { | |
1487 | MLXSW_REG_ZERO(spmlr, payload); | |
1488 | mlxsw_reg_spmlr_local_port_set(payload, local_port); | |
1489 | mlxsw_reg_spmlr_sub_port_set(payload, 0); | |
1490 | mlxsw_reg_spmlr_learn_mode_set(payload, mode); | |
1491 | } | |
1492 | ||
64790239 IS |
1493 | /* SVFA - Switch VID to FID Allocation Register |
1494 | * -------------------------------------------- | |
1495 | * Controls the VID to FID mapping and {Port, VID} to FID mapping for | |
1496 | * virtualized ports. | |
1497 | */ | |
1498 | #define MLXSW_REG_SVFA_ID 0x201C | |
1499 | #define MLXSW_REG_SVFA_LEN 0x10 | |
1500 | ||
21978dcf | 1501 | MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN); |
64790239 IS |
1502 | |
1503 | /* reg_svfa_swid | |
1504 | * Switch partition ID. | |
1505 | * Access: Index | |
1506 | */ | |
1507 | MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8); | |
1508 | ||
1509 | /* reg_svfa_local_port | |
1510 | * Local port number. | |
1511 | * Access: Index | |
1512 | * | |
1513 | * Note: Reserved for 802.1Q FIDs. | |
1514 | */ | |
1515 | MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8); | |
1516 | ||
1517 | enum mlxsw_reg_svfa_mt { | |
1518 | MLXSW_REG_SVFA_MT_VID_TO_FID, | |
1519 | MLXSW_REG_SVFA_MT_PORT_VID_TO_FID, | |
1520 | }; | |
1521 | ||
1522 | /* reg_svfa_mapping_table | |
1523 | * Mapping table: | |
1524 | * 0 - VID to FID | |
1525 | * 1 - {Port, VID} to FID | |
1526 | * Access: Index | |
1527 | * | |
1528 | * Note: Reserved for SwitchX-2. | |
1529 | */ | |
1530 | MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3); | |
1531 | ||
1532 | /* reg_svfa_v | |
1533 | * Valid. | |
1534 | * Valid if set. | |
1535 | * Access: RW | |
1536 | * | |
1537 | * Note: Reserved for SwitchX-2. | |
1538 | */ | |
1539 | MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1); | |
1540 | ||
1541 | /* reg_svfa_fid | |
1542 | * Filtering ID. | |
1543 | * Access: RW | |
1544 | */ | |
1545 | MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16); | |
1546 | ||
1547 | /* reg_svfa_vid | |
1548 | * VLAN ID. | |
1549 | * Access: Index | |
1550 | */ | |
1551 | MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12); | |
1552 | ||
1553 | /* reg_svfa_counter_set_type | |
1554 | * Counter set type for flow counters. | |
1555 | * Access: RW | |
1556 | * | |
1557 | * Note: Reserved for SwitchX-2. | |
1558 | */ | |
1559 | MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8); | |
1560 | ||
1561 | /* reg_svfa_counter_index | |
1562 | * Counter index for flow counters. | |
1563 | * Access: RW | |
1564 | * | |
1565 | * Note: Reserved for SwitchX-2. | |
1566 | */ | |
1567 | MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24); | |
1568 | ||
1569 | static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port, | |
1570 | enum mlxsw_reg_svfa_mt mt, bool valid, | |
1571 | u16 fid, u16 vid) | |
1572 | { | |
1573 | MLXSW_REG_ZERO(svfa, payload); | |
1574 | local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port; | |
1575 | mlxsw_reg_svfa_swid_set(payload, 0); | |
1576 | mlxsw_reg_svfa_local_port_set(payload, local_port); | |
1577 | mlxsw_reg_svfa_mapping_table_set(payload, mt); | |
1578 | mlxsw_reg_svfa_v_set(payload, valid); | |
1579 | mlxsw_reg_svfa_fid_set(payload, fid); | |
1580 | mlxsw_reg_svfa_vid_set(payload, vid); | |
1581 | } | |
1582 | ||
1f65da74 IS |
1583 | /* SVPE - Switch Virtual-Port Enabling Register |
1584 | * -------------------------------------------- | |
1585 | * Enables port virtualization. | |
1586 | */ | |
1587 | #define MLXSW_REG_SVPE_ID 0x201E | |
1588 | #define MLXSW_REG_SVPE_LEN 0x4 | |
1589 | ||
21978dcf | 1590 | MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN); |
1f65da74 IS |
1591 | |
1592 | /* reg_svpe_local_port | |
1593 | * Local port number | |
1594 | * Access: Index | |
1595 | * | |
1596 | * Note: CPU port is not supported (uses VLAN mode only). | |
1597 | */ | |
1598 | MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8); | |
1599 | ||
1600 | /* reg_svpe_vp_en | |
1601 | * Virtual port enable. | |
1602 | * 0 - Disable, VLAN mode (VID to FID). | |
1603 | * 1 - Enable, Virtual port mode ({Port, VID} to FID). | |
1604 | * Access: RW | |
1605 | */ | |
1606 | MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1); | |
1607 | ||
1608 | static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port, | |
1609 | bool enable) | |
1610 | { | |
1611 | MLXSW_REG_ZERO(svpe, payload); | |
1612 | mlxsw_reg_svpe_local_port_set(payload, local_port); | |
1613 | mlxsw_reg_svpe_vp_en_set(payload, enable); | |
1614 | } | |
1615 | ||
f1fb693a IS |
1616 | /* SFMR - Switch FID Management Register |
1617 | * ------------------------------------- | |
1618 | * Creates and configures FIDs. | |
1619 | */ | |
1620 | #define MLXSW_REG_SFMR_ID 0x201F | |
1621 | #define MLXSW_REG_SFMR_LEN 0x18 | |
1622 | ||
21978dcf | 1623 | MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN); |
f1fb693a IS |
1624 | |
1625 | enum mlxsw_reg_sfmr_op { | |
1626 | MLXSW_REG_SFMR_OP_CREATE_FID, | |
1627 | MLXSW_REG_SFMR_OP_DESTROY_FID, | |
1628 | }; | |
1629 | ||
1630 | /* reg_sfmr_op | |
1631 | * Operation. | |
1632 | * 0 - Create or edit FID. | |
1633 | * 1 - Destroy FID. | |
1634 | * Access: WO | |
1635 | */ | |
1636 | MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4); | |
1637 | ||
1638 | /* reg_sfmr_fid | |
1639 | * Filtering ID. | |
1640 | * Access: Index | |
1641 | */ | |
1642 | MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16); | |
1643 | ||
1644 | /* reg_sfmr_fid_offset | |
1645 | * FID offset. | |
1646 | * Used to point into the flooding table selected by SFGC register if | |
1647 | * the table is of type FID-Offset. Otherwise, this field is reserved. | |
1648 | * Access: RW | |
1649 | */ | |
1650 | MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16); | |
1651 | ||
1652 | /* reg_sfmr_vtfp | |
1653 | * Valid Tunnel Flood Pointer. | |
1654 | * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL. | |
1655 | * Access: RW | |
1656 | * | |
1657 | * Note: Reserved for 802.1Q FIDs. | |
1658 | */ | |
1659 | MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1); | |
1660 | ||
1661 | /* reg_sfmr_nve_tunnel_flood_ptr | |
1662 | * Underlay Flooding and BC Pointer. | |
1663 | * Used as a pointer to the first entry of the group based link lists of | |
1664 | * flooding or BC entries (for NVE tunnels). | |
1665 | * Access: RW | |
1666 | */ | |
1667 | MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24); | |
1668 | ||
1669 | /* reg_sfmr_vv | |
1670 | * VNI Valid. | |
1671 | * If not set, then vni is reserved. | |
1672 | * Access: RW | |
1673 | * | |
1674 | * Note: Reserved for 802.1Q FIDs. | |
1675 | */ | |
1676 | MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1); | |
1677 | ||
1678 | /* reg_sfmr_vni | |
1679 | * Virtual Network Identifier. | |
1680 | * Access: RW | |
1681 | * | |
1682 | * Note: A given VNI can only be assigned to one FID. | |
1683 | */ | |
1684 | MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24); | |
1685 | ||
1686 | static inline void mlxsw_reg_sfmr_pack(char *payload, | |
1687 | enum mlxsw_reg_sfmr_op op, u16 fid, | |
1688 | u16 fid_offset) | |
1689 | { | |
1690 | MLXSW_REG_ZERO(sfmr, payload); | |
1691 | mlxsw_reg_sfmr_op_set(payload, op); | |
1692 | mlxsw_reg_sfmr_fid_set(payload, fid); | |
1693 | mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset); | |
1694 | mlxsw_reg_sfmr_vtfp_set(payload, false); | |
1695 | mlxsw_reg_sfmr_vv_set(payload, false); | |
1696 | } | |
1697 | ||
a4feea74 IS |
1698 | /* SPVMLR - Switch Port VLAN MAC Learning Register |
1699 | * ----------------------------------------------- | |
1700 | * Controls the switch MAC learning policy per {Port, VID}. | |
1701 | */ | |
1702 | #define MLXSW_REG_SPVMLR_ID 0x2020 | |
1703 | #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */ | |
1704 | #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */ | |
e9093b11 | 1705 | #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255 |
a4feea74 IS |
1706 | #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \ |
1707 | MLXSW_REG_SPVMLR_REC_LEN * \ | |
1708 | MLXSW_REG_SPVMLR_REC_MAX_COUNT) | |
1709 | ||
21978dcf | 1710 | MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN); |
a4feea74 IS |
1711 | |
1712 | /* reg_spvmlr_local_port | |
1713 | * Local ingress port. | |
1714 | * Access: Index | |
1715 | * | |
1716 | * Note: CPU port is not supported. | |
1717 | */ | |
1718 | MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8); | |
1719 | ||
1720 | /* reg_spvmlr_num_rec | |
1721 | * Number of records to update. | |
1722 | * Access: OP | |
1723 | */ | |
1724 | MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8); | |
1725 | ||
1726 | /* reg_spvmlr_rec_learn_enable | |
1727 | * 0 - Disable learning for {Port, VID}. | |
1728 | * 1 - Enable learning for {Port, VID}. | |
1729 | * Access: RW | |
1730 | */ | |
1731 | MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN, | |
1732 | 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false); | |
1733 | ||
1734 | /* reg_spvmlr_rec_vid | |
1735 | * VLAN ID to be added/removed from port or for querying. | |
1736 | * Access: Index | |
1737 | */ | |
1738 | MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12, | |
1739 | MLXSW_REG_SPVMLR_REC_LEN, 0x00, false); | |
1740 | ||
1741 | static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port, | |
1742 | u16 vid_begin, u16 vid_end, | |
1743 | bool learn_enable) | |
1744 | { | |
1745 | int num_rec = vid_end - vid_begin + 1; | |
1746 | int i; | |
1747 | ||
1748 | WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT); | |
1749 | ||
1750 | MLXSW_REG_ZERO(spvmlr, payload); | |
1751 | mlxsw_reg_spvmlr_local_port_set(payload, local_port); | |
1752 | mlxsw_reg_spvmlr_num_rec_set(payload, num_rec); | |
1753 | ||
1754 | for (i = 0; i < num_rec; i++) { | |
1755 | mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable); | |
1756 | mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i); | |
1757 | } | |
1758 | } | |
1759 | ||
af7170ee JP |
1760 | /* PPBT - Policy-Engine Port Binding Table |
1761 | * --------------------------------------- | |
1762 | * This register is used for configuration of the Port Binding Table. | |
1763 | */ | |
1764 | #define MLXSW_REG_PPBT_ID 0x3002 | |
1765 | #define MLXSW_REG_PPBT_LEN 0x14 | |
1766 | ||
1767 | MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN); | |
1768 | ||
1769 | enum mlxsw_reg_pxbt_e { | |
1770 | MLXSW_REG_PXBT_E_IACL, | |
1771 | MLXSW_REG_PXBT_E_EACL, | |
1772 | }; | |
1773 | ||
1774 | /* reg_ppbt_e | |
1775 | * Access: Index | |
1776 | */ | |
1777 | MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1); | |
1778 | ||
1779 | enum mlxsw_reg_pxbt_op { | |
1780 | MLXSW_REG_PXBT_OP_BIND, | |
1781 | MLXSW_REG_PXBT_OP_UNBIND, | |
1782 | }; | |
1783 | ||
1784 | /* reg_ppbt_op | |
1785 | * Access: RW | |
1786 | */ | |
1787 | MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3); | |
1788 | ||
1789 | /* reg_ppbt_local_port | |
1790 | * Local port. Not including CPU port. | |
1791 | * Access: Index | |
1792 | */ | |
1793 | MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8); | |
1794 | ||
1795 | /* reg_ppbt_g | |
1796 | * group - When set, the binding is of an ACL group. When cleared, | |
1797 | * the binding is of an ACL. | |
1798 | * Must be set to 1 for Spectrum. | |
1799 | * Access: RW | |
1800 | */ | |
1801 | MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1); | |
1802 | ||
1803 | /* reg_ppbt_acl_info | |
1804 | * ACL/ACL group identifier. If the g bit is set, this field should hold | |
1805 | * the acl_group_id, else it should hold the acl_id. | |
1806 | * Access: RW | |
1807 | */ | |
1808 | MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16); | |
1809 | ||
1810 | static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e, | |
1811 | enum mlxsw_reg_pxbt_op op, | |
1812 | u8 local_port, u16 acl_info) | |
1813 | { | |
1814 | MLXSW_REG_ZERO(ppbt, payload); | |
1815 | mlxsw_reg_ppbt_e_set(payload, e); | |
1816 | mlxsw_reg_ppbt_op_set(payload, op); | |
1817 | mlxsw_reg_ppbt_local_port_set(payload, local_port); | |
1818 | mlxsw_reg_ppbt_g_set(payload, true); | |
1819 | mlxsw_reg_ppbt_acl_info_set(payload, acl_info); | |
1820 | } | |
1821 | ||
3279da4c JP |
1822 | /* PACL - Policy-Engine ACL Register |
1823 | * --------------------------------- | |
1824 | * This register is used for configuration of the ACL. | |
1825 | */ | |
1826 | #define MLXSW_REG_PACL_ID 0x3004 | |
1827 | #define MLXSW_REG_PACL_LEN 0x70 | |
1828 | ||
1829 | MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN); | |
1830 | ||
1831 | /* reg_pacl_v | |
1832 | * Valid. Setting the v bit makes the ACL valid. It should not be cleared | |
1833 | * while the ACL is bounded to either a port, VLAN or ACL rule. | |
1834 | * Access: RW | |
1835 | */ | |
1836 | MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1); | |
1837 | ||
1838 | /* reg_pacl_acl_id | |
1839 | * An identifier representing the ACL (managed by software) | |
1840 | * Range 0 .. cap_max_acl_regions - 1 | |
1841 | * Access: Index | |
1842 | */ | |
1843 | MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16); | |
1844 | ||
1845 | #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16 | |
1846 | ||
1847 | /* reg_pacl_tcam_region_info | |
1848 | * Opaque object that represents a TCAM region. | |
1849 | * Obtained through PTAR register. | |
1850 | * Access: RW | |
1851 | */ | |
1852 | MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30, | |
1853 | MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); | |
1854 | ||
1855 | static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id, | |
1856 | bool valid, const char *tcam_region_info) | |
1857 | { | |
1858 | MLXSW_REG_ZERO(pacl, payload); | |
1859 | mlxsw_reg_pacl_acl_id_set(payload, acl_id); | |
1860 | mlxsw_reg_pacl_v_set(payload, valid); | |
1861 | mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info); | |
1862 | } | |
1863 | ||
10fabef5 JP |
1864 | /* PAGT - Policy-Engine ACL Group Table |
1865 | * ------------------------------------ | |
1866 | * This register is used for configuration of the ACL Group Table. | |
1867 | */ | |
1868 | #define MLXSW_REG_PAGT_ID 0x3005 | |
1869 | #define MLXSW_REG_PAGT_BASE_LEN 0x30 | |
1870 | #define MLXSW_REG_PAGT_ACL_LEN 4 | |
1871 | #define MLXSW_REG_PAGT_ACL_MAX_NUM 16 | |
1872 | #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \ | |
1873 | MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN) | |
1874 | ||
1875 | MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN); | |
1876 | ||
1877 | /* reg_pagt_size | |
1878 | * Number of ACLs in the group. | |
1879 | * Size 0 invalidates a group. | |
1880 | * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now) | |
1881 | * Total number of ACLs in all groups must be lower or equal | |
1882 | * to cap_max_acl_tot_groups | |
1883 | * Note: a group which is binded must not be invalidated | |
1884 | * Access: Index | |
1885 | */ | |
1886 | MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8); | |
1887 | ||
1888 | /* reg_pagt_acl_group_id | |
1889 | * An identifier (numbered from 0..cap_max_acl_groups-1) representing | |
1890 | * the ACL Group identifier (managed by software). | |
1891 | * Access: Index | |
1892 | */ | |
1893 | MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16); | |
1894 | ||
1895 | /* reg_pagt_acl_id | |
1896 | * ACL identifier | |
1897 | * Access: RW | |
1898 | */ | |
1899 | MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false); | |
1900 | ||
1901 | static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id) | |
1902 | { | |
1903 | MLXSW_REG_ZERO(pagt, payload); | |
1904 | mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id); | |
1905 | } | |
1906 | ||
1907 | static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index, | |
1908 | u16 acl_id) | |
1909 | { | |
1910 | u8 size = mlxsw_reg_pagt_size_get(payload); | |
1911 | ||
1912 | if (index >= size) | |
1913 | mlxsw_reg_pagt_size_set(payload, index + 1); | |
1914 | mlxsw_reg_pagt_acl_id_set(payload, index, acl_id); | |
1915 | } | |
1916 | ||
d9c2661e JP |
1917 | /* PTAR - Policy-Engine TCAM Allocation Register |
1918 | * --------------------------------------------- | |
1919 | * This register is used for allocation of regions in the TCAM. | |
1920 | * Note: Query method is not supported on this register. | |
1921 | */ | |
1922 | #define MLXSW_REG_PTAR_ID 0x3006 | |
1923 | #define MLXSW_REG_PTAR_BASE_LEN 0x20 | |
1924 | #define MLXSW_REG_PTAR_KEY_ID_LEN 1 | |
1925 | #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16 | |
1926 | #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \ | |
1927 | MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN) | |
1928 | ||
1929 | MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN); | |
1930 | ||
1931 | enum mlxsw_reg_ptar_op { | |
1932 | /* allocate a TCAM region */ | |
1933 | MLXSW_REG_PTAR_OP_ALLOC, | |
1934 | /* resize a TCAM region */ | |
1935 | MLXSW_REG_PTAR_OP_RESIZE, | |
1936 | /* deallocate TCAM region */ | |
1937 | MLXSW_REG_PTAR_OP_FREE, | |
1938 | /* test allocation */ | |
1939 | MLXSW_REG_PTAR_OP_TEST, | |
1940 | }; | |
1941 | ||
1942 | /* reg_ptar_op | |
1943 | * Access: OP | |
1944 | */ | |
1945 | MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4); | |
1946 | ||
1947 | /* reg_ptar_action_set_type | |
1948 | * Type of action set to be used on this region. | |
1949 | * For Spectrum, this is always type 2 - "flexible" | |
1950 | * Access: WO | |
1951 | */ | |
1952 | MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8); | |
1953 | ||
1954 | /* reg_ptar_key_type | |
1955 | * TCAM key type for the region. | |
1956 | * For Spectrum, this is always type 0x50 - "FLEX_KEY" | |
1957 | * Access: WO | |
1958 | */ | |
1959 | MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8); | |
1960 | ||
1961 | /* reg_ptar_region_size | |
1962 | * TCAM region size. When allocating/resizing this is the requested size, | |
1963 | * the response is the actual size. Note that actual size may be | |
1964 | * larger than requested. | |
1965 | * Allowed range 1 .. cap_max_rules-1 | |
1966 | * Reserved during op deallocate. | |
1967 | * Access: WO | |
1968 | */ | |
1969 | MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16); | |
1970 | ||
1971 | /* reg_ptar_region_id | |
1972 | * Region identifier | |
1973 | * Range 0 .. cap_max_regions-1 | |
1974 | * Access: Index | |
1975 | */ | |
1976 | MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16); | |
1977 | ||
1978 | /* reg_ptar_tcam_region_info | |
1979 | * Opaque object that represents the TCAM region. | |
1980 | * Returned when allocating a region. | |
1981 | * Provided by software for ACL generation and region deallocation and resize. | |
1982 | * Access: RW | |
1983 | */ | |
1984 | MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10, | |
1985 | MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); | |
1986 | ||
1987 | /* reg_ptar_flexible_key_id | |
1988 | * Identifier of the Flexible Key. | |
1989 | * Only valid if key_type == "FLEX_KEY" | |
1990 | * The key size will be rounded up to one of the following values: | |
1991 | * 9B, 18B, 36B, 54B. | |
1992 | * This field is reserved for in resize operation. | |
1993 | * Access: WO | |
1994 | */ | |
1995 | MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8, | |
1996 | MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false); | |
1997 | ||
1998 | static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op, | |
1999 | u16 region_size, u16 region_id, | |
2000 | const char *tcam_region_info) | |
2001 | { | |
2002 | MLXSW_REG_ZERO(ptar, payload); | |
2003 | mlxsw_reg_ptar_op_set(payload, op); | |
2004 | mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */ | |
2005 | mlxsw_reg_ptar_key_type_set(payload, 0x50); /* "FLEX_KEY" */ | |
2006 | mlxsw_reg_ptar_region_size_set(payload, region_size); | |
2007 | mlxsw_reg_ptar_region_id_set(payload, region_id); | |
2008 | mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info); | |
2009 | } | |
2010 | ||
2011 | static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index, | |
2012 | u16 key_id) | |
2013 | { | |
2014 | mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id); | |
2015 | } | |
2016 | ||
2017 | static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info) | |
2018 | { | |
2019 | mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info); | |
2020 | } | |
2021 | ||
d120649d JP |
2022 | /* PPBS - Policy-Engine Policy Based Switching Register |
2023 | * ---------------------------------------------------- | |
2024 | * This register retrieves and sets Policy Based Switching Table entries. | |
2025 | */ | |
2026 | #define MLXSW_REG_PPBS_ID 0x300C | |
2027 | #define MLXSW_REG_PPBS_LEN 0x14 | |
2028 | ||
2029 | MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN); | |
2030 | ||
2031 | /* reg_ppbs_pbs_ptr | |
2032 | * Index into the PBS table. | |
2033 | * For Spectrum, the index points to the KVD Linear. | |
2034 | * Access: Index | |
2035 | */ | |
2036 | MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24); | |
2037 | ||
2038 | /* reg_ppbs_system_port | |
2039 | * Unique port identifier for the final destination of the packet. | |
2040 | * Access: RW | |
2041 | */ | |
2042 | MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16); | |
2043 | ||
2044 | static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr, | |
2045 | u16 system_port) | |
2046 | { | |
2047 | MLXSW_REG_ZERO(ppbs, payload); | |
2048 | mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr); | |
2049 | mlxsw_reg_ppbs_system_port_set(payload, system_port); | |
2050 | } | |
2051 | ||
937b682c JP |
2052 | /* PRCR - Policy-Engine Rules Copy Register |
2053 | * ---------------------------------------- | |
2054 | * This register is used for accessing rules within a TCAM region. | |
2055 | */ | |
2056 | #define MLXSW_REG_PRCR_ID 0x300D | |
2057 | #define MLXSW_REG_PRCR_LEN 0x40 | |
2058 | ||
2059 | MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN); | |
2060 | ||
2061 | enum mlxsw_reg_prcr_op { | |
2062 | /* Move rules. Moves the rules from "tcam_region_info" starting | |
2063 | * at offset "offset" to "dest_tcam_region_info" | |
2064 | * at offset "dest_offset." | |
2065 | */ | |
2066 | MLXSW_REG_PRCR_OP_MOVE, | |
2067 | /* Copy rules. Copies the rules from "tcam_region_info" starting | |
2068 | * at offset "offset" to "dest_tcam_region_info" | |
2069 | * at offset "dest_offset." | |
2070 | */ | |
2071 | MLXSW_REG_PRCR_OP_COPY, | |
2072 | }; | |
2073 | ||
2074 | /* reg_prcr_op | |
2075 | * Access: OP | |
2076 | */ | |
2077 | MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4); | |
2078 | ||
2079 | /* reg_prcr_offset | |
2080 | * Offset within the source region to copy/move from. | |
2081 | * Access: Index | |
2082 | */ | |
2083 | MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16); | |
2084 | ||
2085 | /* reg_prcr_size | |
2086 | * The number of rules to copy/move. | |
2087 | * Access: WO | |
2088 | */ | |
2089 | MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16); | |
2090 | ||
2091 | /* reg_prcr_tcam_region_info | |
2092 | * Opaque object that represents the source TCAM region. | |
2093 | * Access: Index | |
2094 | */ | |
2095 | MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10, | |
2096 | MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); | |
2097 | ||
2098 | /* reg_prcr_dest_offset | |
2099 | * Offset within the source region to copy/move to. | |
2100 | * Access: Index | |
2101 | */ | |
2102 | MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16); | |
2103 | ||
2104 | /* reg_prcr_dest_tcam_region_info | |
2105 | * Opaque object that represents the destination TCAM region. | |
2106 | * Access: Index | |
2107 | */ | |
2108 | MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30, | |
2109 | MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); | |
2110 | ||
2111 | static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op, | |
2112 | const char *src_tcam_region_info, | |
2113 | u16 src_offset, | |
2114 | const char *dest_tcam_region_info, | |
2115 | u16 dest_offset, u16 size) | |
2116 | { | |
2117 | MLXSW_REG_ZERO(prcr, payload); | |
2118 | mlxsw_reg_prcr_op_set(payload, op); | |
2119 | mlxsw_reg_prcr_offset_set(payload, src_offset); | |
2120 | mlxsw_reg_prcr_size_set(payload, size); | |
2121 | mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload, | |
2122 | src_tcam_region_info); | |
2123 | mlxsw_reg_prcr_dest_offset_set(payload, dest_offset); | |
2124 | mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload, | |
2125 | dest_tcam_region_info); | |
2126 | } | |
2127 | ||
e3426e12 JP |
2128 | /* PEFA - Policy-Engine Extended Flexible Action Register |
2129 | * ------------------------------------------------------ | |
2130 | * This register is used for accessing an extended flexible action entry | |
2131 | * in the central KVD Linear Database. | |
2132 | */ | |
2133 | #define MLXSW_REG_PEFA_ID 0x300F | |
2134 | #define MLXSW_REG_PEFA_LEN 0xB0 | |
2135 | ||
2136 | MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN); | |
2137 | ||
2138 | /* reg_pefa_index | |
2139 | * Index in the KVD Linear Centralized Database. | |
2140 | * Access: Index | |
2141 | */ | |
2142 | MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24); | |
2143 | ||
2144 | #define MLXSW_REG_PXXX_FLEX_ACTION_SET_LEN 0xA8 | |
2145 | ||
2146 | /* reg_pefa_flex_action_set | |
2147 | * Action-set to perform when rule is matched. | |
2148 | * Must be zero padded if action set is shorter. | |
2149 | * Access: RW | |
2150 | */ | |
2151 | MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, | |
2152 | MLXSW_REG_PXXX_FLEX_ACTION_SET_LEN); | |
2153 | ||
2154 | static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, | |
2155 | const char *flex_action_set) | |
2156 | { | |
2157 | MLXSW_REG_ZERO(pefa, payload); | |
2158 | mlxsw_reg_pefa_index_set(payload, index); | |
2159 | mlxsw_reg_pefa_flex_action_set_memcpy_to(payload, flex_action_set); | |
2160 | } | |
2161 | ||
0171cdec JP |
2162 | /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2 |
2163 | * ----------------------------------------------------- | |
2164 | * This register is used for accessing rules within a TCAM region. | |
2165 | * It is a new version of PTCE in order to support wider key, | |
2166 | * mask and action within a TCAM region. This register is not supported | |
2167 | * by SwitchX and SwitchX-2. | |
2168 | */ | |
2169 | #define MLXSW_REG_PTCE2_ID 0x3017 | |
2170 | #define MLXSW_REG_PTCE2_LEN 0x1D8 | |
2171 | ||
2172 | MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN); | |
2173 | ||
2174 | /* reg_ptce2_v | |
2175 | * Valid. | |
2176 | * Access: RW | |
2177 | */ | |
2178 | MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1); | |
2179 | ||
2180 | /* reg_ptce2_a | |
2181 | * Activity. Set if a packet lookup has hit on the specific entry. | |
2182 | * To clear the "a" bit, use "clear activity" op or "clear on read" op. | |
2183 | * Access: RO | |
2184 | */ | |
2185 | MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1); | |
2186 | ||
2187 | enum mlxsw_reg_ptce2_op { | |
2188 | /* Read operation. */ | |
2189 | MLXSW_REG_PTCE2_OP_QUERY_READ = 0, | |
2190 | /* clear on read operation. Used to read entry | |
2191 | * and clear Activity bit. | |
2192 | */ | |
2193 | MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1, | |
2194 | /* Write operation. Used to write a new entry to the table. | |
2195 | * All R/W fields are relevant for new entry. Activity bit is set | |
2196 | * for new entries - Note write with v = 0 will delete the entry. | |
2197 | */ | |
2198 | MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0, | |
2199 | /* Update action. Only action set will be updated. */ | |
2200 | MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1, | |
2201 | /* Clear activity. A bit is cleared for the entry. */ | |
2202 | MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2, | |
2203 | }; | |
2204 | ||
2205 | /* reg_ptce2_op | |
2206 | * Access: OP | |
2207 | */ | |
2208 | MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3); | |
2209 | ||
2210 | /* reg_ptce2_offset | |
2211 | * Access: Index | |
2212 | */ | |
2213 | MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16); | |
2214 | ||
2215 | /* reg_ptce2_tcam_region_info | |
2216 | * Opaque object that represents the TCAM region. | |
2217 | * Access: Index | |
2218 | */ | |
2219 | MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10, | |
2220 | MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); | |
2221 | ||
2222 | #define MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN 96 | |
2223 | ||
2224 | /* reg_ptce2_flex_key_blocks | |
2225 | * ACL Key. | |
2226 | * Access: RW | |
2227 | */ | |
2228 | MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20, | |
2229 | MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN); | |
2230 | ||
2231 | /* reg_ptce2_mask | |
2232 | * mask- in the same size as key. A bit that is set directs the TCAM | |
2233 | * to compare the corresponding bit in key. A bit that is clear directs | |
2234 | * the TCAM to ignore the corresponding bit in key. | |
2235 | * Access: RW | |
2236 | */ | |
2237 | MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80, | |
2238 | MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN); | |
2239 | ||
0171cdec JP |
2240 | /* reg_ptce2_flex_action_set |
2241 | * ACL action set. | |
2242 | * Access: RW | |
2243 | */ | |
2244 | MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0, | |
e3426e12 | 2245 | MLXSW_REG_PXXX_FLEX_ACTION_SET_LEN); |
0171cdec JP |
2246 | |
2247 | static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid, | |
2248 | enum mlxsw_reg_ptce2_op op, | |
2249 | const char *tcam_region_info, | |
2250 | u16 offset) | |
2251 | { | |
2252 | MLXSW_REG_ZERO(ptce2, payload); | |
2253 | mlxsw_reg_ptce2_v_set(payload, valid); | |
2254 | mlxsw_reg_ptce2_op_set(payload, op); | |
2255 | mlxsw_reg_ptce2_offset_set(payload, offset); | |
2256 | mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info); | |
2257 | } | |
2258 | ||
76a4c7d3 NF |
2259 | /* QPCR - QoS Policer Configuration Register |
2260 | * ----------------------------------------- | |
2261 | * The QPCR register is used to create policers - that limit | |
2262 | * the rate of bytes or packets via some trap group. | |
2263 | */ | |
2264 | #define MLXSW_REG_QPCR_ID 0x4004 | |
2265 | #define MLXSW_REG_QPCR_LEN 0x28 | |
2266 | ||
2267 | MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN); | |
2268 | ||
2269 | enum mlxsw_reg_qpcr_g { | |
2270 | MLXSW_REG_QPCR_G_GLOBAL = 2, | |
2271 | MLXSW_REG_QPCR_G_STORM_CONTROL = 3, | |
2272 | }; | |
2273 | ||
2274 | /* reg_qpcr_g | |
2275 | * The policer type. | |
2276 | * Access: Index | |
2277 | */ | |
2278 | MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2); | |
2279 | ||
2280 | /* reg_qpcr_pid | |
2281 | * Policer ID. | |
2282 | * Access: Index | |
2283 | */ | |
2284 | MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14); | |
2285 | ||
2286 | /* reg_qpcr_color_aware | |
2287 | * Is the policer aware of colors. | |
2288 | * Must be 0 (unaware) for cpu port. | |
2289 | * Access: RW for unbounded policer. RO for bounded policer. | |
2290 | */ | |
2291 | MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1); | |
2292 | ||
2293 | /* reg_qpcr_bytes | |
2294 | * Is policer limit is for bytes per sec or packets per sec. | |
2295 | * 0 - packets | |
2296 | * 1 - bytes | |
2297 | * Access: RW for unbounded policer. RO for bounded policer. | |
2298 | */ | |
2299 | MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1); | |
2300 | ||
2301 | enum mlxsw_reg_qpcr_ir_units { | |
2302 | MLXSW_REG_QPCR_IR_UNITS_M, | |
2303 | MLXSW_REG_QPCR_IR_UNITS_K, | |
2304 | }; | |
2305 | ||
2306 | /* reg_qpcr_ir_units | |
2307 | * Policer's units for cir and eir fields (for bytes limits only) | |
2308 | * 1 - 10^3 | |
2309 | * 0 - 10^6 | |
2310 | * Access: OP | |
2311 | */ | |
2312 | MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1); | |
2313 | ||
2314 | enum mlxsw_reg_qpcr_rate_type { | |
2315 | MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1, | |
2316 | MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2, | |
2317 | }; | |
2318 | ||
2319 | /* reg_qpcr_rate_type | |
2320 | * Policer can have one limit (single rate) or 2 limits with specific operation | |
2321 | * for packets that exceed the lower rate but not the upper one. | |
2322 | * (For cpu port must be single rate) | |
2323 | * Access: RW for unbounded policer. RO for bounded policer. | |
2324 | */ | |
2325 | MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2); | |
2326 | ||
2327 | /* reg_qpc_cbs | |
2328 | * Policer's committed burst size. | |
2329 | * The policer is working with time slices of 50 nano sec. By default every | |
2330 | * slice is granted the proportionate share of the committed rate. If we want to | |
2331 | * allow a slice to exceed that share (while still keeping the rate per sec) we | |
2332 | * can allow burst. The burst size is between the default proportionate share | |
2333 | * (and no lower than 8) to 32Gb. (Even though giving a number higher than the | |
2334 | * committed rate will result in exceeding the rate). The burst size must be a | |
2335 | * log of 2 and will be determined by 2^cbs. | |
2336 | * Access: RW | |
2337 | */ | |
2338 | MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6); | |
2339 | ||
2340 | /* reg_qpcr_cir | |
2341 | * Policer's committed rate. | |
2342 | * The rate used for sungle rate, the lower rate for double rate. | |
2343 | * For bytes limits, the rate will be this value * the unit from ir_units. | |
2344 | * (Resolution error is up to 1%). | |
2345 | * Access: RW | |
2346 | */ | |
2347 | MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32); | |
2348 | ||
2349 | /* reg_qpcr_eir | |
2350 | * Policer's exceed rate. | |
2351 | * The higher rate for double rate, reserved for single rate. | |
2352 | * Lower rate for double rate policer. | |
2353 | * For bytes limits, the rate will be this value * the unit from ir_units. | |
2354 | * (Resolution error is up to 1%). | |
2355 | * Access: RW | |
2356 | */ | |
2357 | MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32); | |
2358 | ||
2359 | #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2 | |
2360 | ||
2361 | /* reg_qpcr_exceed_action. | |
2362 | * What to do with packets between the 2 limits for double rate. | |
2363 | * Access: RW for unbounded policer. RO for bounded policer. | |
2364 | */ | |
2365 | MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4); | |
2366 | ||
2367 | enum mlxsw_reg_qpcr_action { | |
2368 | /* Discard */ | |
2369 | MLXSW_REG_QPCR_ACTION_DISCARD = 1, | |
2370 | /* Forward and set color to red. | |
2371 | * If the packet is intended to cpu port, it will be dropped. | |
2372 | */ | |
2373 | MLXSW_REG_QPCR_ACTION_FORWARD = 2, | |
2374 | }; | |
2375 | ||
2376 | /* reg_qpcr_violate_action | |
2377 | * What to do with packets that cross the cir limit (for single rate) or the eir | |
2378 | * limit (for double rate). | |
2379 | * Access: RW for unbounded policer. RO for bounded policer. | |
2380 | */ | |
2381 | MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4); | |
2382 | ||
2383 | static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid, | |
2384 | enum mlxsw_reg_qpcr_ir_units ir_units, | |
2385 | bool bytes, u32 cir, u16 cbs) | |
2386 | { | |
2387 | MLXSW_REG_ZERO(qpcr, payload); | |
2388 | mlxsw_reg_qpcr_pid_set(payload, pid); | |
2389 | mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL); | |
2390 | mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE); | |
2391 | mlxsw_reg_qpcr_violate_action_set(payload, | |
2392 | MLXSW_REG_QPCR_ACTION_DISCARD); | |
2393 | mlxsw_reg_qpcr_cir_set(payload, cir); | |
2394 | mlxsw_reg_qpcr_ir_units_set(payload, ir_units); | |
2395 | mlxsw_reg_qpcr_bytes_set(payload, bytes); | |
2396 | mlxsw_reg_qpcr_cbs_set(payload, cbs); | |
2397 | } | |
2398 | ||
2c63a555 IS |
2399 | /* QTCT - QoS Switch Traffic Class Table |
2400 | * ------------------------------------- | |
2401 | * Configures the mapping between the packet switch priority and the | |
2402 | * traffic class on the transmit port. | |
2403 | */ | |
2404 | #define MLXSW_REG_QTCT_ID 0x400A | |
2405 | #define MLXSW_REG_QTCT_LEN 0x08 | |
2406 | ||
21978dcf | 2407 | MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN); |
2c63a555 IS |
2408 | |
2409 | /* reg_qtct_local_port | |
2410 | * Local port number. | |
2411 | * Access: Index | |
2412 | * | |
2413 | * Note: CPU port is not supported. | |
2414 | */ | |
2415 | MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8); | |
2416 | ||
2417 | /* reg_qtct_sub_port | |
2418 | * Virtual port within the physical port. | |
2419 | * Should be set to 0 when virtual ports are not enabled on the port. | |
2420 | * Access: Index | |
2421 | */ | |
2422 | MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8); | |
2423 | ||
2424 | /* reg_qtct_switch_prio | |
2425 | * Switch priority. | |
2426 | * Access: Index | |
2427 | */ | |
2428 | MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4); | |
2429 | ||
2430 | /* reg_qtct_tclass | |
2431 | * Traffic class. | |
2432 | * Default values: | |
2433 | * switch_prio 0 : tclass 1 | |
2434 | * switch_prio 1 : tclass 0 | |
2435 | * switch_prio i : tclass i, for i > 1 | |
2436 | * Access: RW | |
2437 | */ | |
2438 | MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4); | |
2439 | ||
2440 | static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port, | |
2441 | u8 switch_prio, u8 tclass) | |
2442 | { | |
2443 | MLXSW_REG_ZERO(qtct, payload); | |
2444 | mlxsw_reg_qtct_local_port_set(payload, local_port); | |
2445 | mlxsw_reg_qtct_switch_prio_set(payload, switch_prio); | |
2446 | mlxsw_reg_qtct_tclass_set(payload, tclass); | |
2447 | } | |
2448 | ||
b9b7cee4 IS |
2449 | /* QEEC - QoS ETS Element Configuration Register |
2450 | * --------------------------------------------- | |
2451 | * Configures the ETS elements. | |
2452 | */ | |
2453 | #define MLXSW_REG_QEEC_ID 0x400D | |
2454 | #define MLXSW_REG_QEEC_LEN 0x1C | |
2455 | ||
21978dcf | 2456 | MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN); |
b9b7cee4 IS |
2457 | |
2458 | /* reg_qeec_local_port | |
2459 | * Local port number. | |
2460 | * Access: Index | |
2461 | * | |
2462 | * Note: CPU port is supported. | |
2463 | */ | |
2464 | MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8); | |
2465 | ||
2466 | enum mlxsw_reg_qeec_hr { | |
2467 | MLXSW_REG_QEEC_HIERARCY_PORT, | |
2468 | MLXSW_REG_QEEC_HIERARCY_GROUP, | |
2469 | MLXSW_REG_QEEC_HIERARCY_SUBGROUP, | |
2470 | MLXSW_REG_QEEC_HIERARCY_TC, | |
2471 | }; | |
2472 | ||
2473 | /* reg_qeec_element_hierarchy | |
2474 | * 0 - Port | |
2475 | * 1 - Group | |
2476 | * 2 - Subgroup | |
2477 | * 3 - Traffic Class | |
2478 | * Access: Index | |
2479 | */ | |
2480 | MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4); | |
2481 | ||
2482 | /* reg_qeec_element_index | |
2483 | * The index of the element in the hierarchy. | |
2484 | * Access: Index | |
2485 | */ | |
2486 | MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8); | |
2487 | ||
2488 | /* reg_qeec_next_element_index | |
2489 | * The index of the next (lower) element in the hierarchy. | |
2490 | * Access: RW | |
2491 | * | |
2492 | * Note: Reserved for element_hierarchy 0. | |
2493 | */ | |
2494 | MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8); | |
2495 | ||
2496 | enum { | |
2497 | MLXSW_REG_QEEC_BYTES_MODE, | |
2498 | MLXSW_REG_QEEC_PACKETS_MODE, | |
2499 | }; | |
2500 | ||
2501 | /* reg_qeec_pb | |
2502 | * Packets or bytes mode. | |
2503 | * 0 - Bytes mode | |
2504 | * 1 - Packets mode | |
2505 | * Access: RW | |
2506 | * | |
2507 | * Note: Used for max shaper configuration. For Spectrum, packets mode | |
2508 | * is supported only for traffic classes of CPU port. | |
2509 | */ | |
2510 | MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1); | |
2511 | ||
2512 | /* reg_qeec_mase | |
2513 | * Max shaper configuration enable. Enables configuration of the max | |
2514 | * shaper on this ETS element. | |
2515 | * 0 - Disable | |
2516 | * 1 - Enable | |
2517 | * Access: RW | |
2518 | */ | |
2519 | MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1); | |
2520 | ||
2521 | /* A large max rate will disable the max shaper. */ | |
2522 | #define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */ | |
2523 | ||
2524 | /* reg_qeec_max_shaper_rate | |
2525 | * Max shaper information rate. | |
2526 | * For CPU port, can only be configured for port hierarchy. | |
2527 | * When in bytes mode, value is specified in units of 1000bps. | |
2528 | * Access: RW | |
2529 | */ | |
2530 | MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28); | |
2531 | ||
2532 | /* reg_qeec_de | |
2533 | * DWRR configuration enable. Enables configuration of the dwrr and | |
2534 | * dwrr_weight. | |
2535 | * 0 - Disable | |
2536 | * 1 - Enable | |
2537 | * Access: RW | |
2538 | */ | |
2539 | MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1); | |
2540 | ||
2541 | /* reg_qeec_dwrr | |
2542 | * Transmission selection algorithm to use on the link going down from | |
2543 | * the ETS element. | |
2544 | * 0 - Strict priority | |
2545 | * 1 - DWRR | |
2546 | * Access: RW | |
2547 | */ | |
2548 | MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1); | |
2549 | ||
2550 | /* reg_qeec_dwrr_weight | |
2551 | * DWRR weight on the link going down from the ETS element. The | |
2552 | * percentage of bandwidth guaranteed to an ETS element within | |
2553 | * its hierarchy. The sum of all weights across all ETS elements | |
2554 | * within one hierarchy should be equal to 100. Reserved when | |
2555 | * transmission selection algorithm is strict priority. | |
2556 | * Access: RW | |
2557 | */ | |
2558 | MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8); | |
2559 | ||
2560 | static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port, | |
2561 | enum mlxsw_reg_qeec_hr hr, u8 index, | |
2562 | u8 next_index) | |
2563 | { | |
2564 | MLXSW_REG_ZERO(qeec, payload); | |
2565 | mlxsw_reg_qeec_local_port_set(payload, local_port); | |
2566 | mlxsw_reg_qeec_element_hierarchy_set(payload, hr); | |
2567 | mlxsw_reg_qeec_element_index_set(payload, index); | |
2568 | mlxsw_reg_qeec_next_element_index_set(payload, next_index); | |
2569 | } | |
2570 | ||
4ec14b76 IS |
2571 | /* PMLP - Ports Module to Local Port Register |
2572 | * ------------------------------------------ | |
2573 | * Configures the assignment of modules to local ports. | |
2574 | */ | |
2575 | #define MLXSW_REG_PMLP_ID 0x5002 | |
2576 | #define MLXSW_REG_PMLP_LEN 0x40 | |
2577 | ||
21978dcf | 2578 | MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN); |
4ec14b76 IS |
2579 | |
2580 | /* reg_pmlp_rxtx | |
2581 | * 0 - Tx value is used for both Tx and Rx. | |
2582 | * 1 - Rx value is taken from a separte field. | |
2583 | * Access: RW | |
2584 | */ | |
2585 | MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1); | |
2586 | ||
2587 | /* reg_pmlp_local_port | |
2588 | * Local port number. | |
2589 | * Access: Index | |
2590 | */ | |
2591 | MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8); | |
2592 | ||
2593 | /* reg_pmlp_width | |
2594 | * 0 - Unmap local port. | |
2595 | * 1 - Lane 0 is used. | |
2596 | * 2 - Lanes 0 and 1 are used. | |
2597 | * 4 - Lanes 0, 1, 2 and 3 are used. | |
2598 | * Access: RW | |
2599 | */ | |
2600 | MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8); | |
2601 | ||
2602 | /* reg_pmlp_module | |
2603 | * Module number. | |
2604 | * Access: RW | |
2605 | */ | |
bbeeda27 | 2606 | MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false); |
4ec14b76 IS |
2607 | |
2608 | /* reg_pmlp_tx_lane | |
2609 | * Tx Lane. When rxtx field is cleared, this field is used for Rx as well. | |
2610 | * Access: RW | |
2611 | */ | |
bbeeda27 | 2612 | MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false); |
4ec14b76 IS |
2613 | |
2614 | /* reg_pmlp_rx_lane | |
2615 | * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is | |
2616 | * equal to Tx lane. | |
2617 | * Access: RW | |
2618 | */ | |
bbeeda27 | 2619 | MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false); |
4ec14b76 IS |
2620 | |
2621 | static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port) | |
2622 | { | |
2623 | MLXSW_REG_ZERO(pmlp, payload); | |
2624 | mlxsw_reg_pmlp_local_port_set(payload, local_port); | |
2625 | } | |
2626 | ||
2627 | /* PMTU - Port MTU Register | |
2628 | * ------------------------ | |
2629 | * Configures and reports the port MTU. | |
2630 | */ | |
2631 | #define MLXSW_REG_PMTU_ID 0x5003 | |
2632 | #define MLXSW_REG_PMTU_LEN 0x10 | |
2633 | ||
21978dcf | 2634 | MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN); |
4ec14b76 IS |
2635 | |
2636 | /* reg_pmtu_local_port | |
2637 | * Local port number. | |
2638 | * Access: Index | |
2639 | */ | |
2640 | MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8); | |
2641 | ||
2642 | /* reg_pmtu_max_mtu | |
2643 | * Maximum MTU. | |
2644 | * When port type (e.g. Ethernet) is configured, the relevant MTU is | |
2645 | * reported, otherwise the minimum between the max_mtu of the different | |
2646 | * types is reported. | |
2647 | * Access: RO | |
2648 | */ | |
2649 | MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16); | |
2650 | ||
2651 | /* reg_pmtu_admin_mtu | |
2652 | * MTU value to set port to. Must be smaller or equal to max_mtu. | |
2653 | * Note: If port type is Infiniband, then port must be disabled, when its | |
2654 | * MTU is set. | |
2655 | * Access: RW | |
2656 | */ | |
2657 | MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16); | |
2658 | ||
2659 | /* reg_pmtu_oper_mtu | |
2660 | * The actual MTU configured on the port. Packets exceeding this size | |
2661 | * will be dropped. | |
2662 | * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband | |
2663 | * oper_mtu might be smaller than admin_mtu. | |
2664 | * Access: RO | |
2665 | */ | |
2666 | MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16); | |
2667 | ||
2668 | static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port, | |
2669 | u16 new_mtu) | |
2670 | { | |
2671 | MLXSW_REG_ZERO(pmtu, payload); | |
2672 | mlxsw_reg_pmtu_local_port_set(payload, local_port); | |
2673 | mlxsw_reg_pmtu_max_mtu_set(payload, 0); | |
2674 | mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu); | |
2675 | mlxsw_reg_pmtu_oper_mtu_set(payload, 0); | |
2676 | } | |
2677 | ||
2678 | /* PTYS - Port Type and Speed Register | |
2679 | * ----------------------------------- | |
2680 | * Configures and reports the port speed type. | |
2681 | * | |
2682 | * Note: When set while the link is up, the changes will not take effect | |
2683 | * until the port transitions from down to up state. | |
2684 | */ | |
2685 | #define MLXSW_REG_PTYS_ID 0x5004 | |
2686 | #define MLXSW_REG_PTYS_LEN 0x40 | |
2687 | ||
21978dcf | 2688 | MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN); |
4ec14b76 IS |
2689 | |
2690 | /* reg_ptys_local_port | |
2691 | * Local port number. | |
2692 | * Access: Index | |
2693 | */ | |
2694 | MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8); | |
2695 | ||
79417702 | 2696 | #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0) |
4ec14b76 IS |
2697 | #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2) |
2698 | ||
2699 | /* reg_ptys_proto_mask | |
2700 | * Protocol mask. Indicates which protocol is used. | |
2701 | * 0 - Infiniband. | |
2702 | * 1 - Fibre Channel. | |
2703 | * 2 - Ethernet. | |
2704 | * Access: Index | |
2705 | */ | |
2706 | MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3); | |
2707 | ||
4149b97f IS |
2708 | enum { |
2709 | MLXSW_REG_PTYS_AN_STATUS_NA, | |
2710 | MLXSW_REG_PTYS_AN_STATUS_OK, | |
2711 | MLXSW_REG_PTYS_AN_STATUS_FAIL, | |
2712 | }; | |
2713 | ||
2714 | /* reg_ptys_an_status | |
2715 | * Autonegotiation status. | |
2716 | * Access: RO | |
2717 | */ | |
2718 | MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4); | |
2719 | ||
4ec14b76 IS |
2720 | #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0) |
2721 | #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1) | |
2722 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2) | |
2723 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3) | |
2724 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4) | |
2725 | #define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5) | |
2726 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6) | |
2727 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7) | |
2728 | #define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8) | |
2729 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12) | |
2730 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13) | |
2731 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14) | |
2732 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15) | |
2733 | #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16) | |
b9d66a36 | 2734 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18) |
4ec14b76 IS |
2735 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19) |
2736 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20) | |
2737 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21) | |
2738 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22) | |
2739 | #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23) | |
2740 | #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24) | |
2741 | #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25) | |
2742 | #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26) | |
2743 | #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27) | |
2744 | #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28) | |
2745 | #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29) | |
2746 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30) | |
2747 | #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31) | |
2748 | ||
2749 | /* reg_ptys_eth_proto_cap | |
2750 | * Ethernet port supported speeds and protocols. | |
2751 | * Access: RO | |
2752 | */ | |
2753 | MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32); | |
2754 | ||
79417702 ER |
2755 | /* reg_ptys_ib_link_width_cap |
2756 | * IB port supported widths. | |
2757 | * Access: RO | |
2758 | */ | |
2759 | MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16); | |
2760 | ||
2761 | #define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0) | |
2762 | #define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1) | |
2763 | #define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2) | |
2764 | #define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3) | |
2765 | #define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4) | |
2766 | #define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5) | |
2767 | ||
2768 | /* reg_ptys_ib_proto_cap | |
2769 | * IB port supported speeds and protocols. | |
2770 | * Access: RO | |
2771 | */ | |
2772 | MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16); | |
2773 | ||
4ec14b76 IS |
2774 | /* reg_ptys_eth_proto_admin |
2775 | * Speed and protocol to set port to. | |
2776 | * Access: RW | |
2777 | */ | |
2778 | MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32); | |
2779 | ||
79417702 ER |
2780 | /* reg_ptys_ib_link_width_admin |
2781 | * IB width to set port to. | |
2782 | * Access: RW | |
2783 | */ | |
2784 | MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16); | |
2785 | ||
2786 | /* reg_ptys_ib_proto_admin | |
2787 | * IB speeds and protocols to set port to. | |
2788 | * Access: RW | |
2789 | */ | |
2790 | MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16); | |
2791 | ||
4ec14b76 IS |
2792 | /* reg_ptys_eth_proto_oper |
2793 | * The current speed and protocol configured for the port. | |
2794 | * Access: RO | |
2795 | */ | |
2796 | MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32); | |
2797 | ||
79417702 ER |
2798 | /* reg_ptys_ib_link_width_oper |
2799 | * The current IB width to set port to. | |
2800 | * Access: RO | |
2801 | */ | |
2802 | MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16); | |
2803 | ||
2804 | /* reg_ptys_ib_proto_oper | |
2805 | * The current IB speed and protocol. | |
2806 | * Access: RO | |
2807 | */ | |
2808 | MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16); | |
2809 | ||
4149b97f IS |
2810 | /* reg_ptys_eth_proto_lp_advertise |
2811 | * The protocols that were advertised by the link partner during | |
2812 | * autonegotiation. | |
2813 | * Access: RO | |
2814 | */ | |
2815 | MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32); | |
2816 | ||
401c8b4e ER |
2817 | static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port, |
2818 | u32 proto_admin) | |
4ec14b76 IS |
2819 | { |
2820 | MLXSW_REG_ZERO(ptys, payload); | |
2821 | mlxsw_reg_ptys_local_port_set(payload, local_port); | |
2822 | mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH); | |
2823 | mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin); | |
2824 | } | |
2825 | ||
401c8b4e ER |
2826 | static inline void mlxsw_reg_ptys_eth_unpack(char *payload, |
2827 | u32 *p_eth_proto_cap, | |
2828 | u32 *p_eth_proto_adm, | |
2829 | u32 *p_eth_proto_oper) | |
4ec14b76 IS |
2830 | { |
2831 | if (p_eth_proto_cap) | |
2832 | *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload); | |
2833 | if (p_eth_proto_adm) | |
2834 | *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload); | |
2835 | if (p_eth_proto_oper) | |
2836 | *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload); | |
2837 | } | |
2838 | ||
79417702 ER |
2839 | static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port, |
2840 | u16 proto_admin, u16 link_width) | |
2841 | { | |
2842 | MLXSW_REG_ZERO(ptys, payload); | |
2843 | mlxsw_reg_ptys_local_port_set(payload, local_port); | |
2844 | mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB); | |
2845 | mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin); | |
2846 | mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width); | |
2847 | } | |
2848 | ||
2849 | static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap, | |
2850 | u16 *p_ib_link_width_cap, | |
2851 | u16 *p_ib_proto_oper, | |
2852 | u16 *p_ib_link_width_oper) | |
2853 | { | |
2854 | if (p_ib_proto_cap) | |
2855 | *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload); | |
2856 | if (p_ib_link_width_cap) | |
2857 | *p_ib_link_width_cap = | |
2858 | mlxsw_reg_ptys_ib_link_width_cap_get(payload); | |
2859 | if (p_ib_proto_oper) | |
2860 | *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload); | |
2861 | if (p_ib_link_width_oper) | |
2862 | *p_ib_link_width_oper = | |
2863 | mlxsw_reg_ptys_ib_link_width_oper_get(payload); | |
2864 | } | |
2865 | ||
4ec14b76 IS |
2866 | /* PPAD - Port Physical Address Register |
2867 | * ------------------------------------- | |
2868 | * The PPAD register configures the per port physical MAC address. | |
2869 | */ | |
2870 | #define MLXSW_REG_PPAD_ID 0x5005 | |
2871 | #define MLXSW_REG_PPAD_LEN 0x10 | |
2872 | ||
21978dcf | 2873 | MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN); |
4ec14b76 IS |
2874 | |
2875 | /* reg_ppad_single_base_mac | |
2876 | * 0: base_mac, local port should be 0 and mac[7:0] is | |
2877 | * reserved. HW will set incremental | |
2878 | * 1: single_mac - mac of the local_port | |
2879 | * Access: RW | |
2880 | */ | |
2881 | MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1); | |
2882 | ||
2883 | /* reg_ppad_local_port | |
2884 | * port number, if single_base_mac = 0 then local_port is reserved | |
2885 | * Access: RW | |
2886 | */ | |
2887 | MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8); | |
2888 | ||
2889 | /* reg_ppad_mac | |
2890 | * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved. | |
2891 | * If single_base_mac = 1 - the per port MAC address | |
2892 | * Access: RW | |
2893 | */ | |
2894 | MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6); | |
2895 | ||
2896 | static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac, | |
2897 | u8 local_port) | |
2898 | { | |
2899 | MLXSW_REG_ZERO(ppad, payload); | |
2900 | mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac); | |
2901 | mlxsw_reg_ppad_local_port_set(payload, local_port); | |
2902 | } | |
2903 | ||
2904 | /* PAOS - Ports Administrative and Operational Status Register | |
2905 | * ----------------------------------------------------------- | |
2906 | * Configures and retrieves per port administrative and operational status. | |
2907 | */ | |
2908 | #define MLXSW_REG_PAOS_ID 0x5006 | |
2909 | #define MLXSW_REG_PAOS_LEN 0x10 | |
2910 | ||
21978dcf | 2911 | MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN); |
4ec14b76 IS |
2912 | |
2913 | /* reg_paos_swid | |
2914 | * Switch partition ID with which to associate the port. | |
2915 | * Note: while external ports uses unique local port numbers (and thus swid is | |
2916 | * redundant), router ports use the same local port number where swid is the | |
2917 | * only indication for the relevant port. | |
2918 | * Access: Index | |
2919 | */ | |
2920 | MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8); | |
2921 | ||
2922 | /* reg_paos_local_port | |
2923 | * Local port number. | |
2924 | * Access: Index | |
2925 | */ | |
2926 | MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8); | |
2927 | ||
2928 | /* reg_paos_admin_status | |
2929 | * Port administrative state (the desired state of the port): | |
2930 | * 1 - Up. | |
2931 | * 2 - Down. | |
2932 | * 3 - Up once. This means that in case of link failure, the port won't go | |
2933 | * into polling mode, but will wait to be re-enabled by software. | |
2934 | * 4 - Disabled by system. Can only be set by hardware. | |
2935 | * Access: RW | |
2936 | */ | |
2937 | MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4); | |
2938 | ||
2939 | /* reg_paos_oper_status | |
2940 | * Port operational state (the current state): | |
2941 | * 1 - Up. | |
2942 | * 2 - Down. | |
2943 | * 3 - Down by port failure. This means that the device will not let the | |
2944 | * port up again until explicitly specified by software. | |
2945 | * Access: RO | |
2946 | */ | |
2947 | MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4); | |
2948 | ||
2949 | /* reg_paos_ase | |
2950 | * Admin state update enabled. | |
2951 | * Access: WO | |
2952 | */ | |
2953 | MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1); | |
2954 | ||
2955 | /* reg_paos_ee | |
2956 | * Event update enable. If this bit is set, event generation will be | |
2957 | * updated based on the e field. | |
2958 | * Access: WO | |
2959 | */ | |
2960 | MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1); | |
2961 | ||
2962 | /* reg_paos_e | |
2963 | * Event generation on operational state change: | |
2964 | * 0 - Do not generate event. | |
2965 | * 1 - Generate Event. | |
2966 | * 2 - Generate Single Event. | |
2967 | * Access: RW | |
2968 | */ | |
2969 | MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2); | |
2970 | ||
2971 | static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port, | |
2972 | enum mlxsw_port_admin_status status) | |
2973 | { | |
2974 | MLXSW_REG_ZERO(paos, payload); | |
2975 | mlxsw_reg_paos_swid_set(payload, 0); | |
2976 | mlxsw_reg_paos_local_port_set(payload, local_port); | |
2977 | mlxsw_reg_paos_admin_status_set(payload, status); | |
2978 | mlxsw_reg_paos_oper_status_set(payload, 0); | |
2979 | mlxsw_reg_paos_ase_set(payload, 1); | |
2980 | mlxsw_reg_paos_ee_set(payload, 1); | |
2981 | mlxsw_reg_paos_e_set(payload, 1); | |
2982 | } | |
2983 | ||
6f253d83 IS |
2984 | /* PFCC - Ports Flow Control Configuration Register |
2985 | * ------------------------------------------------ | |
2986 | * Configures and retrieves the per port flow control configuration. | |
2987 | */ | |
2988 | #define MLXSW_REG_PFCC_ID 0x5007 | |
2989 | #define MLXSW_REG_PFCC_LEN 0x20 | |
2990 | ||
21978dcf | 2991 | MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN); |
6f253d83 IS |
2992 | |
2993 | /* reg_pfcc_local_port | |
2994 | * Local port number. | |
2995 | * Access: Index | |
2996 | */ | |
2997 | MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8); | |
2998 | ||
2999 | /* reg_pfcc_pnat | |
3000 | * Port number access type. Determines the way local_port is interpreted: | |
3001 | * 0 - Local port number. | |
3002 | * 1 - IB / label port number. | |
3003 | * Access: Index | |
3004 | */ | |
3005 | MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2); | |
3006 | ||
3007 | /* reg_pfcc_shl_cap | |
3008 | * Send to higher layers capabilities: | |
3009 | * 0 - No capability of sending Pause and PFC frames to higher layers. | |
3010 | * 1 - Device has capability of sending Pause and PFC frames to higher | |
3011 | * layers. | |
3012 | * Access: RO | |
3013 | */ | |
3014 | MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1); | |
3015 | ||
3016 | /* reg_pfcc_shl_opr | |
3017 | * Send to higher layers operation: | |
3018 | * 0 - Pause and PFC frames are handled by the port (default). | |
3019 | * 1 - Pause and PFC frames are handled by the port and also sent to | |
3020 | * higher layers. Only valid if shl_cap = 1. | |
3021 | * Access: RW | |
3022 | */ | |
3023 | MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1); | |
3024 | ||
3025 | /* reg_pfcc_ppan | |
3026 | * Pause policy auto negotiation. | |
3027 | * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx. | |
3028 | * 1 - Enabled. When auto-negotiation is performed, set the Pause policy | |
3029 | * based on the auto-negotiation resolution. | |
3030 | * Access: RW | |
3031 | * | |
3032 | * Note: The auto-negotiation advertisement is set according to pptx and | |
3033 | * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0. | |
3034 | */ | |
3035 | MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4); | |
3036 | ||
3037 | /* reg_pfcc_prio_mask_tx | |
3038 | * Bit per priority indicating if Tx flow control policy should be | |
3039 | * updated based on bit pfctx. | |
3040 | * Access: WO | |
3041 | */ | |
3042 | MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8); | |
3043 | ||
3044 | /* reg_pfcc_prio_mask_rx | |
3045 | * Bit per priority indicating if Rx flow control policy should be | |
3046 | * updated based on bit pfcrx. | |
3047 | * Access: WO | |
3048 | */ | |
3049 | MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8); | |
3050 | ||
3051 | /* reg_pfcc_pptx | |
3052 | * Admin Pause policy on Tx. | |
3053 | * 0 - Never generate Pause frames (default). | |
3054 | * 1 - Generate Pause frames according to Rx buffer threshold. | |
3055 | * Access: RW | |
3056 | */ | |
3057 | MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1); | |
3058 | ||
3059 | /* reg_pfcc_aptx | |
3060 | * Active (operational) Pause policy on Tx. | |
3061 | * 0 - Never generate Pause frames. | |
3062 | * 1 - Generate Pause frames according to Rx buffer threshold. | |
3063 | * Access: RO | |
3064 | */ | |
3065 | MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1); | |
3066 | ||
3067 | /* reg_pfcc_pfctx | |
3068 | * Priority based flow control policy on Tx[7:0]. Per-priority bit mask: | |
3069 | * 0 - Never generate priority Pause frames on the specified priority | |
3070 | * (default). | |
3071 | * 1 - Generate priority Pause frames according to Rx buffer threshold on | |
3072 | * the specified priority. | |
3073 | * Access: RW | |
3074 | * | |
3075 | * Note: pfctx and pptx must be mutually exclusive. | |
3076 | */ | |
3077 | MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8); | |
3078 | ||
3079 | /* reg_pfcc_pprx | |
3080 | * Admin Pause policy on Rx. | |
3081 | * 0 - Ignore received Pause frames (default). | |
3082 | * 1 - Respect received Pause frames. | |
3083 | * Access: RW | |
3084 | */ | |
3085 | MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1); | |
3086 | ||
3087 | /* reg_pfcc_aprx | |
3088 | * Active (operational) Pause policy on Rx. | |
3089 | * 0 - Ignore received Pause frames. | |
3090 | * 1 - Respect received Pause frames. | |
3091 | * Access: RO | |
3092 | */ | |
3093 | MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1); | |
3094 | ||
3095 | /* reg_pfcc_pfcrx | |
3096 | * Priority based flow control policy on Rx[7:0]. Per-priority bit mask: | |
3097 | * 0 - Ignore incoming priority Pause frames on the specified priority | |
3098 | * (default). | |
3099 | * 1 - Respect incoming priority Pause frames on the specified priority. | |
3100 | * Access: RW | |
3101 | */ | |
3102 | MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8); | |
3103 | ||
d81a6bdb IS |
3104 | #define MLXSW_REG_PFCC_ALL_PRIO 0xFF |
3105 | ||
3106 | static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en) | |
3107 | { | |
3108 | mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO); | |
3109 | mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO); | |
3110 | mlxsw_reg_pfcc_pfctx_set(payload, pfc_en); | |
3111 | mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en); | |
3112 | } | |
3113 | ||
6f253d83 IS |
3114 | static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port) |
3115 | { | |
3116 | MLXSW_REG_ZERO(pfcc, payload); | |
3117 | mlxsw_reg_pfcc_local_port_set(payload, local_port); | |
3118 | } | |
3119 | ||
4ec14b76 IS |
3120 | /* PPCNT - Ports Performance Counters Register |
3121 | * ------------------------------------------- | |
3122 | * The PPCNT register retrieves per port performance counters. | |
3123 | */ | |
3124 | #define MLXSW_REG_PPCNT_ID 0x5008 | |
3125 | #define MLXSW_REG_PPCNT_LEN 0x100 | |
3126 | ||
21978dcf | 3127 | MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN); |
4ec14b76 IS |
3128 | |
3129 | /* reg_ppcnt_swid | |
3130 | * For HCA: must be always 0. | |
3131 | * Switch partition ID to associate port with. | |
3132 | * Switch partitions are numbered from 0 to 7 inclusively. | |
3133 | * Switch partition 254 indicates stacking ports. | |
3134 | * Switch partition 255 indicates all switch partitions. | |
3135 | * Only valid on Set() operation with local_port=255. | |
3136 | * Access: Index | |
3137 | */ | |
3138 | MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8); | |
3139 | ||
3140 | /* reg_ppcnt_local_port | |
3141 | * Local port number. | |
3142 | * 255 indicates all ports on the device, and is only allowed | |
3143 | * for Set() operation. | |
3144 | * Access: Index | |
3145 | */ | |
3146 | MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8); | |
3147 | ||
3148 | /* reg_ppcnt_pnat | |
3149 | * Port number access type: | |
3150 | * 0 - Local port number | |
3151 | * 1 - IB port number | |
3152 | * Access: Index | |
3153 | */ | |
3154 | MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2); | |
3155 | ||
34dba0a5 IS |
3156 | enum mlxsw_reg_ppcnt_grp { |
3157 | MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0, | |
3158 | MLXSW_REG_PPCNT_PRIO_CNT = 0x10, | |
df4750e8 | 3159 | MLXSW_REG_PPCNT_TC_CNT = 0x11, |
34dba0a5 IS |
3160 | }; |
3161 | ||
4ec14b76 IS |
3162 | /* reg_ppcnt_grp |
3163 | * Performance counter group. | |
3164 | * Group 63 indicates all groups. Only valid on Set() operation with | |
3165 | * clr bit set. | |
3166 | * 0x0: IEEE 802.3 Counters | |
3167 | * 0x1: RFC 2863 Counters | |
3168 | * 0x2: RFC 2819 Counters | |
3169 | * 0x3: RFC 3635 Counters | |
3170 | * 0x5: Ethernet Extended Counters | |
3171 | * 0x8: Link Level Retransmission Counters | |
3172 | * 0x10: Per Priority Counters | |
3173 | * 0x11: Per Traffic Class Counters | |
3174 | * 0x12: Physical Layer Counters | |
3175 | * Access: Index | |
3176 | */ | |
3177 | MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6); | |
3178 | ||
3179 | /* reg_ppcnt_clr | |
3180 | * Clear counters. Setting the clr bit will reset the counter value | |
3181 | * for all counters in the counter group. This bit can be set | |
3182 | * for both Set() and Get() operation. | |
3183 | * Access: OP | |
3184 | */ | |
3185 | MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1); | |
3186 | ||
3187 | /* reg_ppcnt_prio_tc | |
3188 | * Priority for counter set that support per priority, valid values: 0-7. | |
3189 | * Traffic class for counter set that support per traffic class, | |
3190 | * valid values: 0- cap_max_tclass-1 . | |
3191 | * For HCA: cap_max_tclass is always 8. | |
3192 | * Otherwise must be 0. | |
3193 | * Access: Index | |
3194 | */ | |
3195 | MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5); | |
3196 | ||
34dba0a5 IS |
3197 | /* Ethernet IEEE 802.3 Counter Group */ |
3198 | ||
4ec14b76 IS |
3199 | /* reg_ppcnt_a_frames_transmitted_ok |
3200 | * Access: RO | |
3201 | */ | |
3202 | MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok, | |
3203 | 0x08 + 0x00, 0, 64); | |
3204 | ||
3205 | /* reg_ppcnt_a_frames_received_ok | |
3206 | * Access: RO | |
3207 | */ | |
3208 | MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok, | |
3209 | 0x08 + 0x08, 0, 64); | |
3210 | ||
3211 | /* reg_ppcnt_a_frame_check_sequence_errors | |
3212 | * Access: RO | |
3213 | */ | |
3214 | MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors, | |
3215 | 0x08 + 0x10, 0, 64); | |
3216 | ||
3217 | /* reg_ppcnt_a_alignment_errors | |
3218 | * Access: RO | |
3219 | */ | |
3220 | MLXSW_ITEM64(reg, ppcnt, a_alignment_errors, | |
3221 | 0x08 + 0x18, 0, 64); | |
3222 | ||
3223 | /* reg_ppcnt_a_octets_transmitted_ok | |
3224 | * Access: RO | |
3225 | */ | |
3226 | MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok, | |
3227 | 0x08 + 0x20, 0, 64); | |
3228 | ||
3229 | /* reg_ppcnt_a_octets_received_ok | |
3230 | * Access: RO | |
3231 | */ | |
3232 | MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok, | |
3233 | 0x08 + 0x28, 0, 64); | |
3234 | ||
3235 | /* reg_ppcnt_a_multicast_frames_xmitted_ok | |
3236 | * Access: RO | |
3237 | */ | |
3238 | MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok, | |
3239 | 0x08 + 0x30, 0, 64); | |
3240 | ||
3241 | /* reg_ppcnt_a_broadcast_frames_xmitted_ok | |
3242 | * Access: RO | |
3243 | */ | |
3244 | MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok, | |
3245 | 0x08 + 0x38, 0, 64); | |
3246 | ||
3247 | /* reg_ppcnt_a_multicast_frames_received_ok | |
3248 | * Access: RO | |
3249 | */ | |
3250 | MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok, | |
3251 | 0x08 + 0x40, 0, 64); | |
3252 | ||
3253 | /* reg_ppcnt_a_broadcast_frames_received_ok | |
3254 | * Access: RO | |
3255 | */ | |
3256 | MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok, | |
3257 | 0x08 + 0x48, 0, 64); | |
3258 | ||
3259 | /* reg_ppcnt_a_in_range_length_errors | |
3260 | * Access: RO | |
3261 | */ | |
3262 | MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors, | |
3263 | 0x08 + 0x50, 0, 64); | |
3264 | ||
3265 | /* reg_ppcnt_a_out_of_range_length_field | |
3266 | * Access: RO | |
3267 | */ | |
3268 | MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field, | |
3269 | 0x08 + 0x58, 0, 64); | |
3270 | ||
3271 | /* reg_ppcnt_a_frame_too_long_errors | |
3272 | * Access: RO | |
3273 | */ | |
3274 | MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors, | |
3275 | 0x08 + 0x60, 0, 64); | |
3276 | ||
3277 | /* reg_ppcnt_a_symbol_error_during_carrier | |
3278 | * Access: RO | |
3279 | */ | |
3280 | MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier, | |
3281 | 0x08 + 0x68, 0, 64); | |
3282 | ||
3283 | /* reg_ppcnt_a_mac_control_frames_transmitted | |
3284 | * Access: RO | |
3285 | */ | |
3286 | MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted, | |
3287 | 0x08 + 0x70, 0, 64); | |
3288 | ||
3289 | /* reg_ppcnt_a_mac_control_frames_received | |
3290 | * Access: RO | |
3291 | */ | |
3292 | MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received, | |
3293 | 0x08 + 0x78, 0, 64); | |
3294 | ||
3295 | /* reg_ppcnt_a_unsupported_opcodes_received | |
3296 | * Access: RO | |
3297 | */ | |
3298 | MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received, | |
3299 | 0x08 + 0x80, 0, 64); | |
3300 | ||
3301 | /* reg_ppcnt_a_pause_mac_ctrl_frames_received | |
3302 | * Access: RO | |
3303 | */ | |
3304 | MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received, | |
3305 | 0x08 + 0x88, 0, 64); | |
3306 | ||
3307 | /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted | |
3308 | * Access: RO | |
3309 | */ | |
3310 | MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted, | |
3311 | 0x08 + 0x90, 0, 64); | |
3312 | ||
34dba0a5 IS |
3313 | /* Ethernet Per Priority Group Counters */ |
3314 | ||
3315 | /* reg_ppcnt_rx_octets | |
3316 | * Access: RO | |
3317 | */ | |
3318 | MLXSW_ITEM64(reg, ppcnt, rx_octets, 0x08 + 0x00, 0, 64); | |
3319 | ||
3320 | /* reg_ppcnt_rx_frames | |
3321 | * Access: RO | |
3322 | */ | |
3323 | MLXSW_ITEM64(reg, ppcnt, rx_frames, 0x08 + 0x20, 0, 64); | |
3324 | ||
3325 | /* reg_ppcnt_tx_octets | |
3326 | * Access: RO | |
3327 | */ | |
3328 | MLXSW_ITEM64(reg, ppcnt, tx_octets, 0x08 + 0x28, 0, 64); | |
3329 | ||
3330 | /* reg_ppcnt_tx_frames | |
3331 | * Access: RO | |
3332 | */ | |
3333 | MLXSW_ITEM64(reg, ppcnt, tx_frames, 0x08 + 0x48, 0, 64); | |
3334 | ||
3335 | /* reg_ppcnt_rx_pause | |
3336 | * Access: RO | |
3337 | */ | |
3338 | MLXSW_ITEM64(reg, ppcnt, rx_pause, 0x08 + 0x50, 0, 64); | |
3339 | ||
3340 | /* reg_ppcnt_rx_pause_duration | |
3341 | * Access: RO | |
3342 | */ | |
3343 | MLXSW_ITEM64(reg, ppcnt, rx_pause_duration, 0x08 + 0x58, 0, 64); | |
3344 | ||
3345 | /* reg_ppcnt_tx_pause | |
3346 | * Access: RO | |
3347 | */ | |
3348 | MLXSW_ITEM64(reg, ppcnt, tx_pause, 0x08 + 0x60, 0, 64); | |
3349 | ||
3350 | /* reg_ppcnt_tx_pause_duration | |
3351 | * Access: RO | |
3352 | */ | |
3353 | MLXSW_ITEM64(reg, ppcnt, tx_pause_duration, 0x08 + 0x68, 0, 64); | |
3354 | ||
3355 | /* reg_ppcnt_rx_pause_transition | |
3356 | * Access: RO | |
3357 | */ | |
3358 | MLXSW_ITEM64(reg, ppcnt, tx_pause_transition, 0x08 + 0x70, 0, 64); | |
3359 | ||
df4750e8 IS |
3360 | /* Ethernet Per Traffic Group Counters */ |
3361 | ||
3362 | /* reg_ppcnt_tc_transmit_queue | |
3363 | * Contains the transmit queue depth in cells of traffic class | |
3364 | * selected by prio_tc and the port selected by local_port. | |
3365 | * The field cannot be cleared. | |
3366 | * Access: RO | |
3367 | */ | |
3368 | MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue, 0x08 + 0x00, 0, 64); | |
3369 | ||
3370 | /* reg_ppcnt_tc_no_buffer_discard_uc | |
3371 | * The number of unicast packets dropped due to lack of shared | |
3372 | * buffer resources. | |
3373 | * Access: RO | |
3374 | */ | |
3375 | MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc, 0x08 + 0x08, 0, 64); | |
3376 | ||
34dba0a5 IS |
3377 | static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port, |
3378 | enum mlxsw_reg_ppcnt_grp grp, | |
3379 | u8 prio_tc) | |
4ec14b76 IS |
3380 | { |
3381 | MLXSW_REG_ZERO(ppcnt, payload); | |
3382 | mlxsw_reg_ppcnt_swid_set(payload, 0); | |
3383 | mlxsw_reg_ppcnt_local_port_set(payload, local_port); | |
3384 | mlxsw_reg_ppcnt_pnat_set(payload, 0); | |
34dba0a5 | 3385 | mlxsw_reg_ppcnt_grp_set(payload, grp); |
4ec14b76 | 3386 | mlxsw_reg_ppcnt_clr_set(payload, 0); |
34dba0a5 | 3387 | mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc); |
4ec14b76 IS |
3388 | } |
3389 | ||
7136793e ER |
3390 | /* PLIB - Port Local to InfiniBand Port |
3391 | * ------------------------------------ | |
3392 | * The PLIB register performs mapping from Local Port into InfiniBand Port. | |
3393 | */ | |
3394 | #define MLXSW_REG_PLIB_ID 0x500A | |
3395 | #define MLXSW_REG_PLIB_LEN 0x10 | |
3396 | ||
3397 | MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN); | |
3398 | ||
3399 | /* reg_plib_local_port | |
3400 | * Local port number. | |
3401 | * Access: Index | |
3402 | */ | |
3403 | MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8); | |
3404 | ||
3405 | /* reg_plib_ib_port | |
3406 | * InfiniBand port remapping for local_port. | |
3407 | * Access: RW | |
3408 | */ | |
3409 | MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8); | |
3410 | ||
b98ff151 IS |
3411 | /* PPTB - Port Prio To Buffer Register |
3412 | * ----------------------------------- | |
3413 | * Configures the switch priority to buffer table. | |
3414 | */ | |
3415 | #define MLXSW_REG_PPTB_ID 0x500B | |
11719a58 | 3416 | #define MLXSW_REG_PPTB_LEN 0x10 |
b98ff151 | 3417 | |
21978dcf | 3418 | MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN); |
b98ff151 IS |
3419 | |
3420 | enum { | |
3421 | MLXSW_REG_PPTB_MM_UM, | |
3422 | MLXSW_REG_PPTB_MM_UNICAST, | |
3423 | MLXSW_REG_PPTB_MM_MULTICAST, | |
3424 | }; | |
3425 | ||
3426 | /* reg_pptb_mm | |
3427 | * Mapping mode. | |
3428 | * 0 - Map both unicast and multicast packets to the same buffer. | |
3429 | * 1 - Map only unicast packets. | |
3430 | * 2 - Map only multicast packets. | |
3431 | * Access: Index | |
3432 | * | |
3433 | * Note: SwitchX-2 only supports the first option. | |
3434 | */ | |
3435 | MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2); | |
3436 | ||
3437 | /* reg_pptb_local_port | |
3438 | * Local port number. | |
3439 | * Access: Index | |
3440 | */ | |
3441 | MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8); | |
3442 | ||
3443 | /* reg_pptb_um | |
3444 | * Enables the update of the untagged_buf field. | |
3445 | * Access: RW | |
3446 | */ | |
3447 | MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1); | |
3448 | ||
3449 | /* reg_pptb_pm | |
3450 | * Enables the update of the prio_to_buff field. | |
3451 | * Bit <i> is a flag for updating the mapping for switch priority <i>. | |
3452 | * Access: RW | |
3453 | */ | |
3454 | MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8); | |
3455 | ||
3456 | /* reg_pptb_prio_to_buff | |
3457 | * Mapping of switch priority <i> to one of the allocated receive port | |
3458 | * buffers. | |
3459 | * Access: RW | |
3460 | */ | |
3461 | MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4); | |
3462 | ||
3463 | /* reg_pptb_pm_msb | |
3464 | * Enables the update of the prio_to_buff field. | |
3465 | * Bit <i> is a flag for updating the mapping for switch priority <i+8>. | |
3466 | * Access: RW | |
3467 | */ | |
3468 | MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8); | |
3469 | ||
3470 | /* reg_pptb_untagged_buff | |
3471 | * Mapping of untagged frames to one of the allocated receive port buffers. | |
3472 | * Access: RW | |
3473 | * | |
3474 | * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for | |
3475 | * Spectrum, as it maps untagged packets based on the default switch priority. | |
3476 | */ | |
3477 | MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4); | |
3478 | ||
11719a58 IS |
3479 | /* reg_pptb_prio_to_buff_msb |
3480 | * Mapping of switch priority <i+8> to one of the allocated receive port | |
3481 | * buffers. | |
3482 | * Access: RW | |
3483 | */ | |
3484 | MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4); | |
3485 | ||
b98ff151 IS |
3486 | #define MLXSW_REG_PPTB_ALL_PRIO 0xFF |
3487 | ||
3488 | static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port) | |
3489 | { | |
3490 | MLXSW_REG_ZERO(pptb, payload); | |
3491 | mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM); | |
3492 | mlxsw_reg_pptb_local_port_set(payload, local_port); | |
3493 | mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO); | |
11719a58 IS |
3494 | mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO); |
3495 | } | |
3496 | ||
3497 | static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio, | |
3498 | u8 buff) | |
3499 | { | |
3500 | mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff); | |
3501 | mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff); | |
b98ff151 IS |
3502 | } |
3503 | ||
e0594369 JP |
3504 | /* PBMC - Port Buffer Management Control Register |
3505 | * ---------------------------------------------- | |
3506 | * The PBMC register configures and retrieves the port packet buffer | |
3507 | * allocation for different Prios, and the Pause threshold management. | |
3508 | */ | |
3509 | #define MLXSW_REG_PBMC_ID 0x500C | |
7ad7cd61 | 3510 | #define MLXSW_REG_PBMC_LEN 0x6C |
e0594369 | 3511 | |
21978dcf | 3512 | MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN); |
e0594369 JP |
3513 | |
3514 | /* reg_pbmc_local_port | |
3515 | * Local port number. | |
3516 | * Access: Index | |
3517 | */ | |
3518 | MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8); | |
3519 | ||
3520 | /* reg_pbmc_xoff_timer_value | |
3521 | * When device generates a pause frame, it uses this value as the pause | |
3522 | * timer (time for the peer port to pause in quota-512 bit time). | |
3523 | * Access: RW | |
3524 | */ | |
3525 | MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16); | |
3526 | ||
3527 | /* reg_pbmc_xoff_refresh | |
3528 | * The time before a new pause frame should be sent to refresh the pause RW | |
3529 | * state. Using the same units as xoff_timer_value above (in quota-512 bit | |
3530 | * time). | |
3531 | * Access: RW | |
3532 | */ | |
3533 | MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16); | |
3534 | ||
d6b7c13b IS |
3535 | #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11 |
3536 | ||
e0594369 JP |
3537 | /* reg_pbmc_buf_lossy |
3538 | * The field indicates if the buffer is lossy. | |
3539 | * 0 - Lossless | |
3540 | * 1 - Lossy | |
3541 | * Access: RW | |
3542 | */ | |
3543 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false); | |
3544 | ||
3545 | /* reg_pbmc_buf_epsb | |
3546 | * Eligible for Port Shared buffer. | |
3547 | * If epsb is set, packets assigned to buffer are allowed to insert the port | |
3548 | * shared buffer. | |
3549 | * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved. | |
3550 | * Access: RW | |
3551 | */ | |
3552 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false); | |
3553 | ||
3554 | /* reg_pbmc_buf_size | |
3555 | * The part of the packet buffer array is allocated for the specific buffer. | |
3556 | * Units are represented in cells. | |
3557 | * Access: RW | |
3558 | */ | |
3559 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false); | |
3560 | ||
155f9de2 IS |
3561 | /* reg_pbmc_buf_xoff_threshold |
3562 | * Once the amount of data in the buffer goes above this value, device | |
3563 | * starts sending PFC frames for all priorities associated with the | |
3564 | * buffer. Units are represented in cells. Reserved in case of lossy | |
3565 | * buffer. | |
3566 | * Access: RW | |
3567 | * | |
3568 | * Note: In Spectrum, reserved for buffer[9]. | |
3569 | */ | |
3570 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16, | |
3571 | 0x08, 0x04, false); | |
3572 | ||
3573 | /* reg_pbmc_buf_xon_threshold | |
3574 | * When the amount of data in the buffer goes below this value, device | |
3575 | * stops sending PFC frames for the priorities associated with the | |
3576 | * buffer. Units are represented in cells. Reserved in case of lossy | |
3577 | * buffer. | |
3578 | * Access: RW | |
3579 | * | |
3580 | * Note: In Spectrum, reserved for buffer[9]. | |
3581 | */ | |
3582 | MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16, | |
3583 | 0x08, 0x04, false); | |
3584 | ||
e0594369 JP |
3585 | static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port, |
3586 | u16 xoff_timer_value, u16 xoff_refresh) | |
3587 | { | |
3588 | MLXSW_REG_ZERO(pbmc, payload); | |
3589 | mlxsw_reg_pbmc_local_port_set(payload, local_port); | |
3590 | mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value); | |
3591 | mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh); | |
3592 | } | |
3593 | ||
3594 | static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload, | |
3595 | int buf_index, | |
3596 | u16 size) | |
3597 | { | |
3598 | mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1); | |
3599 | mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0); | |
3600 | mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size); | |
3601 | } | |
3602 | ||
155f9de2 IS |
3603 | static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload, |
3604 | int buf_index, u16 size, | |
3605 | u16 threshold) | |
3606 | { | |
3607 | mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0); | |
3608 | mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0); | |
3609 | mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size); | |
3610 | mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold); | |
3611 | mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold); | |
3612 | } | |
3613 | ||
4ec14b76 IS |
3614 | /* PSPA - Port Switch Partition Allocation |
3615 | * --------------------------------------- | |
3616 | * Controls the association of a port with a switch partition and enables | |
3617 | * configuring ports as stacking ports. | |
3618 | */ | |
3f0effd1 | 3619 | #define MLXSW_REG_PSPA_ID 0x500D |
4ec14b76 IS |
3620 | #define MLXSW_REG_PSPA_LEN 0x8 |
3621 | ||
21978dcf | 3622 | MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN); |
4ec14b76 IS |
3623 | |
3624 | /* reg_pspa_swid | |
3625 | * Switch partition ID. | |
3626 | * Access: RW | |
3627 | */ | |
3628 | MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8); | |
3629 | ||
3630 | /* reg_pspa_local_port | |
3631 | * Local port number. | |
3632 | * Access: Index | |
3633 | */ | |
3634 | MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8); | |
3635 | ||
3636 | /* reg_pspa_sub_port | |
3637 | * Virtual port within the local port. Set to 0 when virtual ports are | |
3638 | * disabled on the local port. | |
3639 | * Access: Index | |
3640 | */ | |
3641 | MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8); | |
3642 | ||
3643 | static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port) | |
3644 | { | |
3645 | MLXSW_REG_ZERO(pspa, payload); | |
3646 | mlxsw_reg_pspa_swid_set(payload, swid); | |
3647 | mlxsw_reg_pspa_local_port_set(payload, local_port); | |
3648 | mlxsw_reg_pspa_sub_port_set(payload, 0); | |
3649 | } | |
3650 | ||
3651 | /* HTGT - Host Trap Group Table | |
3652 | * ---------------------------- | |
3653 | * Configures the properties for forwarding to CPU. | |
3654 | */ | |
3655 | #define MLXSW_REG_HTGT_ID 0x7002 | |
e158e5ef | 3656 | #define MLXSW_REG_HTGT_LEN 0x20 |
4ec14b76 | 3657 | |
21978dcf | 3658 | MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN); |
4ec14b76 IS |
3659 | |
3660 | /* reg_htgt_swid | |
3661 | * Switch partition ID. | |
3662 | * Access: Index | |
3663 | */ | |
3664 | MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8); | |
3665 | ||
3666 | #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */ | |
3667 | ||
3668 | /* reg_htgt_type | |
3669 | * CPU path type. | |
3670 | * Access: RW | |
3671 | */ | |
3672 | MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4); | |
3673 | ||
801bd3de IS |
3674 | enum mlxsw_reg_htgt_trap_group { |
3675 | MLXSW_REG_HTGT_TRAP_GROUP_EMAD, | |
117b0dad NF |
3676 | MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX, |
3677 | MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL, | |
3678 | MLXSW_REG_HTGT_TRAP_GROUP_SP_STP, | |
3679 | MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP, | |
3680 | MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP, | |
3681 | MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP, | |
3682 | MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP_IPV4, | |
3683 | MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF, | |
3684 | MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP, | |
3685 | MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP_MISS, | |
3686 | MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP, | |
3687 | MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE, | |
3688 | MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME, | |
3689 | MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP, | |
3690 | MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT, | |
801bd3de | 3691 | }; |
4ec14b76 IS |
3692 | |
3693 | /* reg_htgt_trap_group | |
3694 | * Trap group number. User defined number specifying which trap groups | |
3695 | * should be forwarded to the CPU. The mapping between trap IDs and trap | |
3696 | * groups is configured using HPKT register. | |
3697 | * Access: Index | |
3698 | */ | |
3699 | MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8); | |
3700 | ||
3701 | enum { | |
3702 | MLXSW_REG_HTGT_POLICER_DISABLE, | |
3703 | MLXSW_REG_HTGT_POLICER_ENABLE, | |
3704 | }; | |
3705 | ||
3706 | /* reg_htgt_pide | |
3707 | * Enable policer ID specified using 'pid' field. | |
3708 | * Access: RW | |
3709 | */ | |
3710 | MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1); | |
3711 | ||
579c82e4 NF |
3712 | #define MLXSW_REG_HTGT_INVALID_POLICER 0xff |
3713 | ||
4ec14b76 IS |
3714 | /* reg_htgt_pid |
3715 | * Policer ID for the trap group. | |
3716 | * Access: RW | |
3717 | */ | |
3718 | MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8); | |
3719 | ||
3720 | #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0 | |
3721 | ||
3722 | /* reg_htgt_mirror_action | |
3723 | * Mirror action to use. | |
3724 | * 0 - Trap to CPU. | |
3725 | * 1 - Trap to CPU and mirror to a mirroring agent. | |
3726 | * 2 - Mirror to a mirroring agent and do not trap to CPU. | |
3727 | * Access: RW | |
3728 | * | |
3729 | * Note: Mirroring to a mirroring agent is only supported in Spectrum. | |
3730 | */ | |
3731 | MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2); | |
3732 | ||
3733 | /* reg_htgt_mirroring_agent | |
3734 | * Mirroring agent. | |
3735 | * Access: RW | |
3736 | */ | |
3737 | MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3); | |
3738 | ||
579c82e4 NF |
3739 | #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0 |
3740 | ||
4ec14b76 IS |
3741 | /* reg_htgt_priority |
3742 | * Trap group priority. | |
3743 | * In case a packet matches multiple classification rules, the packet will | |
3744 | * only be trapped once, based on the trap ID associated with the group (via | |
3745 | * register HPKT) with the highest priority. | |
3746 | * Supported values are 0-7, with 7 represnting the highest priority. | |
3747 | * Access: RW | |
3748 | * | |
3749 | * Note: In SwitchX-2 this field is ignored and the priority value is replaced | |
3750 | * by the 'trap_group' field. | |
3751 | */ | |
3752 | MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4); | |
3753 | ||
579c82e4 NF |
3754 | #define MLXSW_REG_HTGT_DEFAULT_TC 7 |
3755 | ||
4ec14b76 IS |
3756 | /* reg_htgt_local_path_cpu_tclass |
3757 | * CPU ingress traffic class for the trap group. | |
3758 | * Access: RW | |
3759 | */ | |
3760 | MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6); | |
3761 | ||
579c82e4 NF |
3762 | enum mlxsw_reg_htgt_local_path_rdq { |
3763 | MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13, | |
3764 | MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14, | |
3765 | MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15, | |
3766 | MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15, | |
3767 | }; | |
4ec14b76 IS |
3768 | /* reg_htgt_local_path_rdq |
3769 | * Receive descriptor queue (RDQ) to use for the trap group. | |
3770 | * Access: RW | |
3771 | */ | |
3772 | MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6); | |
3773 | ||
579c82e4 NF |
3774 | static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id, |
3775 | u8 priority, u8 tc) | |
4ec14b76 | 3776 | { |
4ec14b76 | 3777 | MLXSW_REG_ZERO(htgt, payload); |
579c82e4 NF |
3778 | |
3779 | if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) { | |
3780 | mlxsw_reg_htgt_pide_set(payload, | |
3781 | MLXSW_REG_HTGT_POLICER_DISABLE); | |
3782 | } else { | |
3783 | mlxsw_reg_htgt_pide_set(payload, | |
3784 | MLXSW_REG_HTGT_POLICER_ENABLE); | |
3785 | mlxsw_reg_htgt_pid_set(payload, policer_id); | |
4ec14b76 | 3786 | } |
579c82e4 | 3787 | |
4ec14b76 | 3788 | mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL); |
801bd3de | 3789 | mlxsw_reg_htgt_trap_group_set(payload, group); |
4ec14b76 IS |
3790 | mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU); |
3791 | mlxsw_reg_htgt_mirroring_agent_set(payload, 0); | |
579c82e4 NF |
3792 | mlxsw_reg_htgt_priority_set(payload, priority); |
3793 | mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc); | |
3794 | mlxsw_reg_htgt_local_path_rdq_set(payload, group); | |
4ec14b76 IS |
3795 | } |
3796 | ||
3797 | /* HPKT - Host Packet Trap | |
3798 | * ----------------------- | |
3799 | * Configures trap IDs inside trap groups. | |
3800 | */ | |
3801 | #define MLXSW_REG_HPKT_ID 0x7003 | |
3802 | #define MLXSW_REG_HPKT_LEN 0x10 | |
3803 | ||
21978dcf | 3804 | MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN); |
4ec14b76 IS |
3805 | |
3806 | enum { | |
3807 | MLXSW_REG_HPKT_ACK_NOT_REQUIRED, | |
3808 | MLXSW_REG_HPKT_ACK_REQUIRED, | |
3809 | }; | |
3810 | ||
3811 | /* reg_hpkt_ack | |
3812 | * Require acknowledgements from the host for events. | |
3813 | * If set, then the device will wait for the event it sent to be acknowledged | |
3814 | * by the host. This option is only relevant for event trap IDs. | |
3815 | * Access: RW | |
3816 | * | |
3817 | * Note: Currently not supported by firmware. | |
3818 | */ | |
3819 | MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1); | |
3820 | ||
3821 | enum mlxsw_reg_hpkt_action { | |
3822 | MLXSW_REG_HPKT_ACTION_FORWARD, | |
3823 | MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU, | |
3824 | MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU, | |
3825 | MLXSW_REG_HPKT_ACTION_DISCARD, | |
3826 | MLXSW_REG_HPKT_ACTION_SOFT_DISCARD, | |
3827 | MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD, | |
3828 | }; | |
3829 | ||
3830 | /* reg_hpkt_action | |
3831 | * Action to perform on packet when trapped. | |
3832 | * 0 - No action. Forward to CPU based on switching rules. | |
3833 | * 1 - Trap to CPU (CPU receives sole copy). | |
3834 | * 2 - Mirror to CPU (CPU receives a replica of the packet). | |
3835 | * 3 - Discard. | |
3836 | * 4 - Soft discard (allow other traps to act on the packet). | |
3837 | * 5 - Trap and soft discard (allow other traps to overwrite this trap). | |
3838 | * Access: RW | |
3839 | * | |
3840 | * Note: Must be set to 0 (forward) for event trap IDs, as they are already | |
3841 | * addressed to the CPU. | |
3842 | */ | |
3843 | MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3); | |
3844 | ||
3845 | /* reg_hpkt_trap_group | |
3846 | * Trap group to associate the trap with. | |
3847 | * Access: RW | |
3848 | */ | |
3849 | MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6); | |
3850 | ||
3851 | /* reg_hpkt_trap_id | |
3852 | * Trap ID. | |
3853 | * Access: Index | |
3854 | * | |
3855 | * Note: A trap ID can only be associated with a single trap group. The device | |
3856 | * will associate the trap ID with the last trap group configured. | |
3857 | */ | |
3858 | MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9); | |
3859 | ||
3860 | enum { | |
3861 | MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT, | |
3862 | MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER, | |
3863 | MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER, | |
3864 | }; | |
3865 | ||
3866 | /* reg_hpkt_ctrl | |
3867 | * Configure dedicated buffer resources for control packets. | |
d570b7ee | 3868 | * Ignored by SwitchX-2. |
4ec14b76 IS |
3869 | * 0 - Keep factory defaults. |
3870 | * 1 - Do not use control buffer for this trap ID. | |
3871 | * 2 - Use control buffer for this trap ID. | |
3872 | * Access: RW | |
3873 | */ | |
3874 | MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2); | |
3875 | ||
d570b7ee NF |
3876 | static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id, |
3877 | enum mlxsw_reg_htgt_trap_group trap_group, | |
3878 | bool is_ctrl) | |
4ec14b76 IS |
3879 | { |
3880 | MLXSW_REG_ZERO(hpkt, payload); | |
3881 | mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED); | |
3882 | mlxsw_reg_hpkt_action_set(payload, action); | |
3883 | mlxsw_reg_hpkt_trap_group_set(payload, trap_group); | |
3884 | mlxsw_reg_hpkt_trap_id_set(payload, trap_id); | |
d570b7ee NF |
3885 | mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ? |
3886 | MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER : | |
3887 | MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER); | |
4ec14b76 IS |
3888 | } |
3889 | ||
69c407aa IS |
3890 | /* RGCR - Router General Configuration Register |
3891 | * -------------------------------------------- | |
3892 | * The register is used for setting up the router configuration. | |
3893 | */ | |
3894 | #define MLXSW_REG_RGCR_ID 0x8001 | |
3895 | #define MLXSW_REG_RGCR_LEN 0x28 | |
3896 | ||
21978dcf | 3897 | MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN); |
69c407aa IS |
3898 | |
3899 | /* reg_rgcr_ipv4_en | |
3900 | * IPv4 router enable. | |
3901 | * Access: RW | |
3902 | */ | |
3903 | MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1); | |
3904 | ||
3905 | /* reg_rgcr_ipv6_en | |
3906 | * IPv6 router enable. | |
3907 | * Access: RW | |
3908 | */ | |
3909 | MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1); | |
3910 | ||
3911 | /* reg_rgcr_max_router_interfaces | |
3912 | * Defines the maximum number of active router interfaces for all virtual | |
3913 | * routers. | |
3914 | * Access: RW | |
3915 | */ | |
3916 | MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16); | |
3917 | ||
3918 | /* reg_rgcr_usp | |
3919 | * Update switch priority and packet color. | |
3920 | * 0 - Preserve the value of Switch Priority and packet color. | |
3921 | * 1 - Recalculate the value of Switch Priority and packet color. | |
3922 | * Access: RW | |
3923 | * | |
3924 | * Note: Not supported by SwitchX and SwitchX-2. | |
3925 | */ | |
3926 | MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1); | |
3927 | ||
3928 | /* reg_rgcr_pcp_rw | |
3929 | * Indicates how to handle the pcp_rewrite_en value: | |
3930 | * 0 - Preserve the value of pcp_rewrite_en. | |
3931 | * 2 - Disable PCP rewrite. | |
3932 | * 3 - Enable PCP rewrite. | |
3933 | * Access: RW | |
3934 | * | |
3935 | * Note: Not supported by SwitchX and SwitchX-2. | |
3936 | */ | |
3937 | MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2); | |
3938 | ||
3939 | /* reg_rgcr_activity_dis | |
3940 | * Activity disable: | |
3941 | * 0 - Activity will be set when an entry is hit (default). | |
3942 | * 1 - Activity will not be set when an entry is hit. | |
3943 | * | |
3944 | * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry | |
3945 | * (RALUE). | |
3946 | * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host | |
3947 | * Entry (RAUHT). | |
3948 | * Bits 2:7 are reserved. | |
3949 | * Access: RW | |
3950 | * | |
3951 | * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB. | |
3952 | */ | |
3953 | MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8); | |
3954 | ||
3955 | static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en) | |
3956 | { | |
3957 | MLXSW_REG_ZERO(rgcr, payload); | |
3958 | mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en); | |
3959 | } | |
3960 | ||
3dc26689 IS |
3961 | /* RITR - Router Interface Table Register |
3962 | * -------------------------------------- | |
3963 | * The register is used to configure the router interface table. | |
3964 | */ | |
3965 | #define MLXSW_REG_RITR_ID 0x8002 | |
3966 | #define MLXSW_REG_RITR_LEN 0x40 | |
3967 | ||
21978dcf | 3968 | MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN); |
3dc26689 IS |
3969 | |
3970 | /* reg_ritr_enable | |
3971 | * Enables routing on the router interface. | |
3972 | * Access: RW | |
3973 | */ | |
3974 | MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1); | |
3975 | ||
3976 | /* reg_ritr_ipv4 | |
3977 | * IPv4 routing enable. Enables routing of IPv4 traffic on the router | |
3978 | * interface. | |
3979 | * Access: RW | |
3980 | */ | |
3981 | MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1); | |
3982 | ||
3983 | /* reg_ritr_ipv6 | |
3984 | * IPv6 routing enable. Enables routing of IPv6 traffic on the router | |
3985 | * interface. | |
3986 | * Access: RW | |
3987 | */ | |
3988 | MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1); | |
3989 | ||
3990 | enum mlxsw_reg_ritr_if_type { | |
3991 | MLXSW_REG_RITR_VLAN_IF, | |
3992 | MLXSW_REG_RITR_FID_IF, | |
3993 | MLXSW_REG_RITR_SP_IF, | |
3994 | }; | |
3995 | ||
3996 | /* reg_ritr_type | |
3997 | * Router interface type. | |
3998 | * 0 - VLAN interface. | |
3999 | * 1 - FID interface. | |
4000 | * 2 - Sub-port interface. | |
4001 | * Access: RW | |
4002 | */ | |
4003 | MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3); | |
4004 | ||
4005 | enum { | |
4006 | MLXSW_REG_RITR_RIF_CREATE, | |
4007 | MLXSW_REG_RITR_RIF_DEL, | |
4008 | }; | |
4009 | ||
4010 | /* reg_ritr_op | |
4011 | * Opcode: | |
4012 | * 0 - Create or edit RIF. | |
4013 | * 1 - Delete RIF. | |
4014 | * Reserved for SwitchX-2. For Spectrum, editing of interface properties | |
4015 | * is not supported. An interface must be deleted and re-created in order | |
4016 | * to update properties. | |
4017 | * Access: WO | |
4018 | */ | |
4019 | MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2); | |
4020 | ||
4021 | /* reg_ritr_rif | |
4022 | * Router interface index. A pointer to the Router Interface Table. | |
4023 | * Access: Index | |
4024 | */ | |
4025 | MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16); | |
4026 | ||
4027 | /* reg_ritr_ipv4_fe | |
4028 | * IPv4 Forwarding Enable. | |
4029 | * Enables routing of IPv4 traffic on the router interface. When disabled, | |
4030 | * forwarding is blocked but local traffic (traps and IP2ME) will be enabled. | |
4031 | * Not supported in SwitchX-2. | |
4032 | * Access: RW | |
4033 | */ | |
4034 | MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1); | |
4035 | ||
4036 | /* reg_ritr_ipv6_fe | |
4037 | * IPv6 Forwarding Enable. | |
4038 | * Enables routing of IPv6 traffic on the router interface. When disabled, | |
4039 | * forwarding is blocked but local traffic (traps and IP2ME) will be enabled. | |
4040 | * Not supported in SwitchX-2. | |
4041 | * Access: RW | |
4042 | */ | |
4043 | MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1); | |
4044 | ||
a94a614f IS |
4045 | /* reg_ritr_lb_en |
4046 | * Loop-back filter enable for unicast packets. | |
4047 | * If the flag is set then loop-back filter for unicast packets is | |
4048 | * implemented on the RIF. Multicast packets are always subject to | |
4049 | * loop-back filtering. | |
4050 | * Access: RW | |
4051 | */ | |
4052 | MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1); | |
4053 | ||
3dc26689 IS |
4054 | /* reg_ritr_virtual_router |
4055 | * Virtual router ID associated with the router interface. | |
4056 | * Access: RW | |
4057 | */ | |
4058 | MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16); | |
4059 | ||
4060 | /* reg_ritr_mtu | |
4061 | * Router interface MTU. | |
4062 | * Access: RW | |
4063 | */ | |
4064 | MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16); | |
4065 | ||
4066 | /* reg_ritr_if_swid | |
4067 | * Switch partition ID. | |
4068 | * Access: RW | |
4069 | */ | |
4070 | MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8); | |
4071 | ||
4072 | /* reg_ritr_if_mac | |
4073 | * Router interface MAC address. | |
4074 | * In Spectrum, all MAC addresses must have the same 38 MSBits. | |
4075 | * Access: RW | |
4076 | */ | |
4077 | MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6); | |
4078 | ||
4079 | /* VLAN Interface */ | |
4080 | ||
4081 | /* reg_ritr_vlan_if_vid | |
4082 | * VLAN ID. | |
4083 | * Access: RW | |
4084 | */ | |
4085 | MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12); | |
4086 | ||
4087 | /* FID Interface */ | |
4088 | ||
4089 | /* reg_ritr_fid_if_fid | |
4090 | * Filtering ID. Used to connect a bridge to the router. Only FIDs from | |
4091 | * the vFID range are supported. | |
4092 | * Access: RW | |
4093 | */ | |
4094 | MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16); | |
4095 | ||
4096 | static inline void mlxsw_reg_ritr_fid_set(char *payload, | |
4097 | enum mlxsw_reg_ritr_if_type rif_type, | |
4098 | u16 fid) | |
4099 | { | |
4100 | if (rif_type == MLXSW_REG_RITR_FID_IF) | |
4101 | mlxsw_reg_ritr_fid_if_fid_set(payload, fid); | |
4102 | else | |
4103 | mlxsw_reg_ritr_vlan_if_vid_set(payload, fid); | |
4104 | } | |
4105 | ||
4106 | /* Sub-port Interface */ | |
4107 | ||
4108 | /* reg_ritr_sp_if_lag | |
4109 | * LAG indication. When this bit is set the system_port field holds the | |
4110 | * LAG identifier. | |
4111 | * Access: RW | |
4112 | */ | |
4113 | MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1); | |
4114 | ||
4115 | /* reg_ritr_sp_system_port | |
4116 | * Port unique indentifier. When lag bit is set, this field holds the | |
4117 | * lag_id in bits 0:9. | |
4118 | * Access: RW | |
4119 | */ | |
4120 | MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16); | |
4121 | ||
4122 | /* reg_ritr_sp_if_vid | |
4123 | * VLAN ID. | |
4124 | * Access: RW | |
4125 | */ | |
4126 | MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12); | |
4127 | ||
0f630fcb AS |
4128 | /* Shared between ingress/egress */ |
4129 | enum mlxsw_reg_ritr_counter_set_type { | |
4130 | /* No Count. */ | |
4131 | MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0, | |
4132 | /* Basic. Used for router interfaces, counting the following: | |
4133 | * - Error and Discard counters. | |
4134 | * - Unicast, Multicast and Broadcast counters. Sharing the | |
4135 | * same set of counters for the different type of traffic | |
4136 | * (IPv4, IPv6 and mpls). | |
4137 | */ | |
4138 | MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9, | |
4139 | }; | |
4140 | ||
4141 | /* reg_ritr_ingress_counter_index | |
4142 | * Counter Index for flow counter. | |
4143 | * Access: RW | |
4144 | */ | |
4145 | MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24); | |
4146 | ||
4147 | /* reg_ritr_ingress_counter_set_type | |
4148 | * Igress Counter Set Type for router interface counter. | |
4149 | * Access: RW | |
4150 | */ | |
4151 | MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8); | |
4152 | ||
4153 | /* reg_ritr_egress_counter_index | |
4154 | * Counter Index for flow counter. | |
4155 | * Access: RW | |
4156 | */ | |
4157 | MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24); | |
4158 | ||
4159 | /* reg_ritr_egress_counter_set_type | |
4160 | * Egress Counter Set Type for router interface counter. | |
4161 | * Access: RW | |
4162 | */ | |
4163 | MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8); | |
4164 | ||
4165 | static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index, | |
4166 | bool enable, bool egress) | |
4167 | { | |
4168 | enum mlxsw_reg_ritr_counter_set_type set_type; | |
4169 | ||
4170 | if (enable) | |
4171 | set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC; | |
4172 | else | |
4173 | set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT; | |
4174 | mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type); | |
4175 | ||
4176 | if (egress) | |
4177 | mlxsw_reg_ritr_egress_counter_index_set(payload, index); | |
4178 | else | |
4179 | mlxsw_reg_ritr_ingress_counter_index_set(payload, index); | |
4180 | } | |
4181 | ||
3dc26689 IS |
4182 | static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif) |
4183 | { | |
4184 | MLXSW_REG_ZERO(ritr, payload); | |
4185 | mlxsw_reg_ritr_rif_set(payload, rif); | |
4186 | } | |
4187 | ||
4188 | static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag, | |
4189 | u16 system_port, u16 vid) | |
4190 | { | |
4191 | mlxsw_reg_ritr_sp_if_lag_set(payload, lag); | |
4192 | mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port); | |
4193 | mlxsw_reg_ritr_sp_if_vid_set(payload, vid); | |
4194 | } | |
4195 | ||
4196 | static inline void mlxsw_reg_ritr_pack(char *payload, bool enable, | |
4197 | enum mlxsw_reg_ritr_if_type type, | |
6913229e IS |
4198 | u16 rif, u16 vr_id, u16 mtu, |
4199 | const char *mac) | |
3dc26689 IS |
4200 | { |
4201 | bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL; | |
4202 | ||
4203 | MLXSW_REG_ZERO(ritr, payload); | |
4204 | mlxsw_reg_ritr_enable_set(payload, enable); | |
4205 | mlxsw_reg_ritr_ipv4_set(payload, 1); | |
4206 | mlxsw_reg_ritr_type_set(payload, type); | |
4207 | mlxsw_reg_ritr_op_set(payload, op); | |
4208 | mlxsw_reg_ritr_rif_set(payload, rif); | |
4209 | mlxsw_reg_ritr_ipv4_fe_set(payload, 1); | |
a94a614f | 4210 | mlxsw_reg_ritr_lb_en_set(payload, 1); |
6913229e | 4211 | mlxsw_reg_ritr_virtual_router_set(payload, vr_id); |
3dc26689 IS |
4212 | mlxsw_reg_ritr_mtu_set(payload, mtu); |
4213 | mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac); | |
4214 | } | |
4215 | ||
089f9816 YG |
4216 | /* RATR - Router Adjacency Table Register |
4217 | * -------------------------------------- | |
4218 | * The RATR register is used to configure the Router Adjacency (next-hop) | |
4219 | * Table. | |
4220 | */ | |
4221 | #define MLXSW_REG_RATR_ID 0x8008 | |
4222 | #define MLXSW_REG_RATR_LEN 0x2C | |
4223 | ||
21978dcf | 4224 | MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN); |
089f9816 YG |
4225 | |
4226 | enum mlxsw_reg_ratr_op { | |
4227 | /* Read */ | |
4228 | MLXSW_REG_RATR_OP_QUERY_READ = 0, | |
4229 | /* Read and clear activity */ | |
4230 | MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2, | |
4231 | /* Write Adjacency entry */ | |
4232 | MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1, | |
4233 | /* Write Adjacency entry only if the activity is cleared. | |
4234 | * The write may not succeed if the activity is set. There is not | |
4235 | * direct feedback if the write has succeeded or not, however | |
4236 | * the get will reveal the actual entry (SW can compare the get | |
4237 | * response to the set command). | |
4238 | */ | |
4239 | MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3, | |
4240 | }; | |
4241 | ||
4242 | /* reg_ratr_op | |
4243 | * Note that Write operation may also be used for updating | |
4244 | * counter_set_type and counter_index. In this case all other | |
4245 | * fields must not be updated. | |
4246 | * Access: OP | |
4247 | */ | |
4248 | MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4); | |
4249 | ||
4250 | /* reg_ratr_v | |
4251 | * Valid bit. Indicates if the adjacency entry is valid. | |
4252 | * Note: the device may need some time before reusing an invalidated | |
4253 | * entry. During this time the entry can not be reused. It is | |
4254 | * recommended to use another entry before reusing an invalidated | |
4255 | * entry (e.g. software can put it at the end of the list for | |
4256 | * reusing). Trying to access an invalidated entry not yet cleared | |
4257 | * by the device results with failure indicating "Try Again" status. | |
4258 | * When valid is '0' then egress_router_interface,trap_action, | |
4259 | * adjacency_parameters and counters are reserved | |
4260 | * Access: RW | |
4261 | */ | |
4262 | MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1); | |
4263 | ||
4264 | /* reg_ratr_a | |
4265 | * Activity. Set for new entries. Set if a packet lookup has hit on | |
4266 | * the specific entry. To clear the a bit, use "clear activity". | |
4267 | * Access: RO | |
4268 | */ | |
4269 | MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1); | |
4270 | ||
4271 | /* reg_ratr_adjacency_index_low | |
4272 | * Bits 15:0 of index into the adjacency table. | |
4273 | * For SwitchX and SwitchX-2, the adjacency table is linear and | |
4274 | * used for adjacency entries only. | |
4275 | * For Spectrum, the index is to the KVD linear. | |
4276 | * Access: Index | |
4277 | */ | |
4278 | MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16); | |
4279 | ||
4280 | /* reg_ratr_egress_router_interface | |
4281 | * Range is 0 .. cap_max_router_interfaces - 1 | |
4282 | * Access: RW | |
4283 | */ | |
4284 | MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16); | |
4285 | ||
4286 | enum mlxsw_reg_ratr_trap_action { | |
4287 | MLXSW_REG_RATR_TRAP_ACTION_NOP, | |
4288 | MLXSW_REG_RATR_TRAP_ACTION_TRAP, | |
4289 | MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU, | |
4290 | MLXSW_REG_RATR_TRAP_ACTION_MIRROR, | |
4291 | MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS, | |
4292 | }; | |
4293 | ||
4294 | /* reg_ratr_trap_action | |
4295 | * see mlxsw_reg_ratr_trap_action | |
4296 | * Access: RW | |
4297 | */ | |
4298 | MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4); | |
4299 | ||
4300 | enum mlxsw_reg_ratr_trap_id { | |
4301 | MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0 = 0, | |
4302 | MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1 = 1, | |
4303 | }; | |
4304 | ||
4305 | /* reg_ratr_adjacency_index_high | |
4306 | * Bits 23:16 of the adjacency_index. | |
4307 | * Access: Index | |
4308 | */ | |
4309 | MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8); | |
4310 | ||
4311 | /* reg_ratr_trap_id | |
4312 | * Trap ID to be reported to CPU. | |
4313 | * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1. | |
4314 | * For trap_action of NOP, MIRROR and DISCARD_ERROR | |
4315 | * Access: RW | |
4316 | */ | |
4317 | MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8); | |
4318 | ||
4319 | /* reg_ratr_eth_destination_mac | |
4320 | * MAC address of the destination next-hop. | |
4321 | * Access: RW | |
4322 | */ | |
4323 | MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6); | |
4324 | ||
4325 | static inline void | |
4326 | mlxsw_reg_ratr_pack(char *payload, | |
4327 | enum mlxsw_reg_ratr_op op, bool valid, | |
4328 | u32 adjacency_index, u16 egress_rif) | |
4329 | { | |
4330 | MLXSW_REG_ZERO(ratr, payload); | |
4331 | mlxsw_reg_ratr_op_set(payload, op); | |
4332 | mlxsw_reg_ratr_v_set(payload, valid); | |
4333 | mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index); | |
4334 | mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16); | |
4335 | mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif); | |
4336 | } | |
4337 | ||
4338 | static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload, | |
4339 | const char *dest_mac) | |
4340 | { | |
4341 | mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac); | |
4342 | } | |
4343 | ||
6f9fc3ce JP |
4344 | /* RALTA - Router Algorithmic LPM Tree Allocation Register |
4345 | * ------------------------------------------------------- | |
4346 | * RALTA is used to allocate the LPM trees of the SHSPM method. | |
4347 | */ | |
4348 | #define MLXSW_REG_RALTA_ID 0x8010 | |
4349 | #define MLXSW_REG_RALTA_LEN 0x04 | |
4350 | ||
21978dcf | 4351 | MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN); |
6f9fc3ce JP |
4352 | |
4353 | /* reg_ralta_op | |
4354 | * opcode (valid for Write, must be 0 on Read) | |
4355 | * 0 - allocate a tree | |
4356 | * 1 - deallocate a tree | |
4357 | * Access: OP | |
4358 | */ | |
4359 | MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2); | |
4360 | ||
4361 | enum mlxsw_reg_ralxx_protocol { | |
4362 | MLXSW_REG_RALXX_PROTOCOL_IPV4, | |
4363 | MLXSW_REG_RALXX_PROTOCOL_IPV6, | |
4364 | }; | |
4365 | ||
4366 | /* reg_ralta_protocol | |
4367 | * Protocol. | |
4368 | * Deallocation opcode: Reserved. | |
4369 | * Access: RW | |
4370 | */ | |
4371 | MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4); | |
4372 | ||
4373 | /* reg_ralta_tree_id | |
4374 | * An identifier (numbered from 1..cap_shspm_max_trees-1) representing | |
4375 | * the tree identifier (managed by software). | |
4376 | * Note that tree_id 0 is allocated for a default-route tree. | |
4377 | * Access: Index | |
4378 | */ | |
4379 | MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8); | |
4380 | ||
4381 | static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc, | |
4382 | enum mlxsw_reg_ralxx_protocol protocol, | |
4383 | u8 tree_id) | |
4384 | { | |
4385 | MLXSW_REG_ZERO(ralta, payload); | |
4386 | mlxsw_reg_ralta_op_set(payload, !alloc); | |
4387 | mlxsw_reg_ralta_protocol_set(payload, protocol); | |
4388 | mlxsw_reg_ralta_tree_id_set(payload, tree_id); | |
4389 | } | |
4390 | ||
a9823359 JP |
4391 | /* RALST - Router Algorithmic LPM Structure Tree Register |
4392 | * ------------------------------------------------------ | |
4393 | * RALST is used to set and query the structure of an LPM tree. | |
4394 | * The structure of the tree must be sorted as a sorted binary tree, while | |
4395 | * each node is a bin that is tagged as the length of the prefixes the lookup | |
4396 | * will refer to. Therefore, bin X refers to a set of entries with prefixes | |
4397 | * of X bits to match with the destination address. The bin 0 indicates | |
4398 | * the default action, when there is no match of any prefix. | |
4399 | */ | |
4400 | #define MLXSW_REG_RALST_ID 0x8011 | |
4401 | #define MLXSW_REG_RALST_LEN 0x104 | |
4402 | ||
21978dcf | 4403 | MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN); |
a9823359 JP |
4404 | |
4405 | /* reg_ralst_root_bin | |
4406 | * The bin number of the root bin. | |
4407 | * 0<root_bin=<(length of IP address) | |
4408 | * For a default-route tree configure 0xff | |
4409 | * Access: RW | |
4410 | */ | |
4411 | MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8); | |
4412 | ||
4413 | /* reg_ralst_tree_id | |
4414 | * Tree identifier numbered from 1..(cap_shspm_max_trees-1). | |
4415 | * Access: Index | |
4416 | */ | |
4417 | MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8); | |
4418 | ||
4419 | #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff | |
4420 | #define MLXSW_REG_RALST_BIN_OFFSET 0x04 | |
4421 | #define MLXSW_REG_RALST_BIN_COUNT 128 | |
4422 | ||
4423 | /* reg_ralst_left_child_bin | |
4424 | * Holding the children of the bin according to the stored tree's structure. | |
4425 | * For trees composed of less than 4 blocks, the bins in excess are reserved. | |
4426 | * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff | |
4427 | * Access: RW | |
4428 | */ | |
4429 | MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false); | |
4430 | ||
4431 | /* reg_ralst_right_child_bin | |
4432 | * Holding the children of the bin according to the stored tree's structure. | |
4433 | * For trees composed of less than 4 blocks, the bins in excess are reserved. | |
4434 | * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff | |
4435 | * Access: RW | |
4436 | */ | |
4437 | MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00, | |
4438 | false); | |
4439 | ||
4440 | static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id) | |
4441 | { | |
4442 | MLXSW_REG_ZERO(ralst, payload); | |
4443 | ||
4444 | /* Initialize all bins to have no left or right child */ | |
4445 | memset(payload + MLXSW_REG_RALST_BIN_OFFSET, | |
4446 | MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2); | |
4447 | ||
4448 | mlxsw_reg_ralst_root_bin_set(payload, root_bin); | |
4449 | mlxsw_reg_ralst_tree_id_set(payload, tree_id); | |
4450 | } | |
4451 | ||
4452 | static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number, | |
4453 | u8 left_child_bin, | |
4454 | u8 right_child_bin) | |
4455 | { | |
4456 | int bin_index = bin_number - 1; | |
4457 | ||
4458 | mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin); | |
4459 | mlxsw_reg_ralst_right_child_bin_set(payload, bin_index, | |
4460 | right_child_bin); | |
4461 | } | |
4462 | ||
20ae4053 JP |
4463 | /* RALTB - Router Algorithmic LPM Tree Binding Register |
4464 | * ---------------------------------------------------- | |
4465 | * RALTB is used to bind virtual router and protocol to an allocated LPM tree. | |
4466 | */ | |
4467 | #define MLXSW_REG_RALTB_ID 0x8012 | |
4468 | #define MLXSW_REG_RALTB_LEN 0x04 | |
4469 | ||
21978dcf | 4470 | MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN); |
20ae4053 JP |
4471 | |
4472 | /* reg_raltb_virtual_router | |
4473 | * Virtual Router ID | |
4474 | * Range is 0..cap_max_virtual_routers-1 | |
4475 | * Access: Index | |
4476 | */ | |
4477 | MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16); | |
4478 | ||
4479 | /* reg_raltb_protocol | |
4480 | * Protocol. | |
4481 | * Access: Index | |
4482 | */ | |
4483 | MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4); | |
4484 | ||
4485 | /* reg_raltb_tree_id | |
4486 | * Tree to be used for the {virtual_router, protocol} | |
4487 | * Tree identifier numbered from 1..(cap_shspm_max_trees-1). | |
4488 | * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0. | |
4489 | * Access: RW | |
4490 | */ | |
4491 | MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8); | |
4492 | ||
4493 | static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router, | |
4494 | enum mlxsw_reg_ralxx_protocol protocol, | |
4495 | u8 tree_id) | |
4496 | { | |
4497 | MLXSW_REG_ZERO(raltb, payload); | |
4498 | mlxsw_reg_raltb_virtual_router_set(payload, virtual_router); | |
4499 | mlxsw_reg_raltb_protocol_set(payload, protocol); | |
4500 | mlxsw_reg_raltb_tree_id_set(payload, tree_id); | |
4501 | } | |
4502 | ||
d5a1c749 JP |
4503 | /* RALUE - Router Algorithmic LPM Unicast Entry Register |
4504 | * ----------------------------------------------------- | |
4505 | * RALUE is used to configure and query LPM entries that serve | |
4506 | * the Unicast protocols. | |
4507 | */ | |
4508 | #define MLXSW_REG_RALUE_ID 0x8013 | |
4509 | #define MLXSW_REG_RALUE_LEN 0x38 | |
4510 | ||
21978dcf | 4511 | MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN); |
d5a1c749 JP |
4512 | |
4513 | /* reg_ralue_protocol | |
4514 | * Protocol. | |
4515 | * Access: Index | |
4516 | */ | |
4517 | MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4); | |
4518 | ||
4519 | enum mlxsw_reg_ralue_op { | |
4520 | /* Read operation. If entry doesn't exist, the operation fails. */ | |
4521 | MLXSW_REG_RALUE_OP_QUERY_READ = 0, | |
4522 | /* Clear on read operation. Used to read entry and | |
4523 | * clear Activity bit. | |
4524 | */ | |
4525 | MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1, | |
4526 | /* Write operation. Used to write a new entry to the table. All RW | |
4527 | * fields are written for new entry. Activity bit is set | |
4528 | * for new entries. | |
4529 | */ | |
4530 | MLXSW_REG_RALUE_OP_WRITE_WRITE = 0, | |
4531 | /* Update operation. Used to update an existing route entry and | |
4532 | * only update the RW fields that are detailed in the field | |
4533 | * op_u_mask. If entry doesn't exist, the operation fails. | |
4534 | */ | |
4535 | MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1, | |
4536 | /* Clear activity. The Activity bit (the field a) is cleared | |
4537 | * for the entry. | |
4538 | */ | |
4539 | MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2, | |
4540 | /* Delete operation. Used to delete an existing entry. If entry | |
4541 | * doesn't exist, the operation fails. | |
4542 | */ | |
4543 | MLXSW_REG_RALUE_OP_WRITE_DELETE = 3, | |
4544 | }; | |
4545 | ||
4546 | /* reg_ralue_op | |
4547 | * Operation. | |
4548 | * Access: OP | |
4549 | */ | |
4550 | MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3); | |
4551 | ||
4552 | /* reg_ralue_a | |
4553 | * Activity. Set for new entries. Set if a packet lookup has hit on the | |
4554 | * specific entry, only if the entry is a route. To clear the a bit, use | |
4555 | * "clear activity" op. | |
4556 | * Enabled by activity_dis in RGCR | |
4557 | * Access: RO | |
4558 | */ | |
4559 | MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1); | |
4560 | ||
4561 | /* reg_ralue_virtual_router | |
4562 | * Virtual Router ID | |
4563 | * Range is 0..cap_max_virtual_routers-1 | |
4564 | * Access: Index | |
4565 | */ | |
4566 | MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16); | |
4567 | ||
4568 | #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0) | |
4569 | #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1) | |
4570 | #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2) | |
4571 | ||
4572 | /* reg_ralue_op_u_mask | |
4573 | * opcode update mask. | |
4574 | * On read operation, this field is reserved. | |
4575 | * This field is valid for update opcode, otherwise - reserved. | |
4576 | * This field is a bitmask of the fields that should be updated. | |
4577 | * Access: WO | |
4578 | */ | |
4579 | MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3); | |
4580 | ||
4581 | /* reg_ralue_prefix_len | |
4582 | * Number of bits in the prefix of the LPM route. | |
4583 | * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes | |
4584 | * two entries in the physical HW table. | |
4585 | * Access: Index | |
4586 | */ | |
4587 | MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8); | |
4588 | ||
4589 | /* reg_ralue_dip* | |
4590 | * The prefix of the route or of the marker that the object of the LPM | |
4591 | * is compared with. The most significant bits of the dip are the prefix. | |
4592 | * The list significant bits must be '0' if the prefix_len is smaller | |
4593 | * than 128 for IPv6 or smaller than 32 for IPv4. | |
4594 | * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved. | |
4595 | * Access: Index | |
4596 | */ | |
4597 | MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32); | |
4598 | ||
4599 | enum mlxsw_reg_ralue_entry_type { | |
4600 | MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1, | |
4601 | MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2, | |
4602 | MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3, | |
4603 | }; | |
4604 | ||
4605 | /* reg_ralue_entry_type | |
4606 | * Entry type. | |
4607 | * Note - for Marker entries, the action_type and action fields are reserved. | |
4608 | * Access: RW | |
4609 | */ | |
4610 | MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2); | |
4611 | ||
4612 | /* reg_ralue_bmp_len | |
4613 | * The best match prefix length in the case that there is no match for | |
4614 | * longer prefixes. | |
4615 | * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len | |
4616 | * Note for any update operation with entry_type modification this | |
4617 | * field must be set. | |
4618 | * Access: RW | |
4619 | */ | |
4620 | MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8); | |
4621 | ||
4622 | enum mlxsw_reg_ralue_action_type { | |
4623 | MLXSW_REG_RALUE_ACTION_TYPE_REMOTE, | |
4624 | MLXSW_REG_RALUE_ACTION_TYPE_LOCAL, | |
4625 | MLXSW_REG_RALUE_ACTION_TYPE_IP2ME, | |
4626 | }; | |
4627 | ||
4628 | /* reg_ralue_action_type | |
4629 | * Action Type | |
4630 | * Indicates how the IP address is connected. | |
4631 | * It can be connected to a local subnet through local_erif or can be | |
4632 | * on a remote subnet connected through a next-hop router, | |
4633 | * or transmitted to the CPU. | |
4634 | * Reserved when entry_type = MARKER_ENTRY | |
4635 | * Access: RW | |
4636 | */ | |
4637 | MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2); | |
4638 | ||
4639 | enum mlxsw_reg_ralue_trap_action { | |
4640 | MLXSW_REG_RALUE_TRAP_ACTION_NOP, | |
4641 | MLXSW_REG_RALUE_TRAP_ACTION_TRAP, | |
4642 | MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU, | |
4643 | MLXSW_REG_RALUE_TRAP_ACTION_MIRROR, | |
4644 | MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR, | |
4645 | }; | |
4646 | ||
4647 | /* reg_ralue_trap_action | |
4648 | * Trap action. | |
4649 | * For IP2ME action, only NOP and MIRROR are possible. | |
4650 | * Access: RW | |
4651 | */ | |
4652 | MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4); | |
4653 | ||
4654 | /* reg_ralue_trap_id | |
4655 | * Trap ID to be reported to CPU. | |
4656 | * Trap ID is RTR_INGRESS0 or RTR_INGRESS1. | |
4657 | * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved. | |
4658 | * Access: RW | |
4659 | */ | |
4660 | MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9); | |
4661 | ||
4662 | /* reg_ralue_adjacency_index | |
4663 | * Points to the first entry of the group-based ECMP. | |
4664 | * Only relevant in case of REMOTE action. | |
4665 | * Access: RW | |
4666 | */ | |
4667 | MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24); | |
4668 | ||
4669 | /* reg_ralue_ecmp_size | |
4670 | * Amount of sequential entries starting | |
4671 | * from the adjacency_index (the number of ECMPs). | |
4672 | * The valid range is 1-64, 512, 1024, 2048 and 4096. | |
4673 | * Reserved when trap_action is TRAP or DISCARD_ERROR. | |
4674 | * Only relevant in case of REMOTE action. | |
4675 | * Access: RW | |
4676 | */ | |
4677 | MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13); | |
4678 | ||
4679 | /* reg_ralue_local_erif | |
4680 | * Egress Router Interface. | |
4681 | * Only relevant in case of LOCAL action. | |
4682 | * Access: RW | |
4683 | */ | |
4684 | MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16); | |
4685 | ||
4686 | /* reg_ralue_v | |
4687 | * Valid bit for the tunnel_ptr field. | |
4688 | * If valid = 0 then trap to CPU as IP2ME trap ID. | |
4689 | * If valid = 1 and the packet format allows NVE or IPinIP tunnel | |
4690 | * decapsulation then tunnel decapsulation is done. | |
4691 | * If valid = 1 and packet format does not allow NVE or IPinIP tunnel | |
4692 | * decapsulation then trap as IP2ME trap ID. | |
4693 | * Only relevant in case of IP2ME action. | |
4694 | * Access: RW | |
4695 | */ | |
4696 | MLXSW_ITEM32(reg, ralue, v, 0x24, 31, 1); | |
4697 | ||
4698 | /* reg_ralue_tunnel_ptr | |
4699 | * Tunnel Pointer for NVE or IPinIP tunnel decapsulation. | |
4700 | * For Spectrum, pointer to KVD Linear. | |
4701 | * Only relevant in case of IP2ME action. | |
4702 | * Access: RW | |
4703 | */ | |
4704 | MLXSW_ITEM32(reg, ralue, tunnel_ptr, 0x24, 0, 24); | |
4705 | ||
4706 | static inline void mlxsw_reg_ralue_pack(char *payload, | |
4707 | enum mlxsw_reg_ralxx_protocol protocol, | |
4708 | enum mlxsw_reg_ralue_op op, | |
4709 | u16 virtual_router, u8 prefix_len) | |
4710 | { | |
4711 | MLXSW_REG_ZERO(ralue, payload); | |
4712 | mlxsw_reg_ralue_protocol_set(payload, protocol); | |
0e7df1a2 | 4713 | mlxsw_reg_ralue_op_set(payload, op); |
d5a1c749 JP |
4714 | mlxsw_reg_ralue_virtual_router_set(payload, virtual_router); |
4715 | mlxsw_reg_ralue_prefix_len_set(payload, prefix_len); | |
4716 | mlxsw_reg_ralue_entry_type_set(payload, | |
4717 | MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY); | |
4718 | mlxsw_reg_ralue_bmp_len_set(payload, prefix_len); | |
4719 | } | |
4720 | ||
4721 | static inline void mlxsw_reg_ralue_pack4(char *payload, | |
4722 | enum mlxsw_reg_ralxx_protocol protocol, | |
4723 | enum mlxsw_reg_ralue_op op, | |
4724 | u16 virtual_router, u8 prefix_len, | |
4725 | u32 dip) | |
4726 | { | |
4727 | mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len); | |
4728 | mlxsw_reg_ralue_dip4_set(payload, dip); | |
4729 | } | |
4730 | ||
4731 | static inline void | |
4732 | mlxsw_reg_ralue_act_remote_pack(char *payload, | |
4733 | enum mlxsw_reg_ralue_trap_action trap_action, | |
4734 | u16 trap_id, u32 adjacency_index, u16 ecmp_size) | |
4735 | { | |
4736 | mlxsw_reg_ralue_action_type_set(payload, | |
4737 | MLXSW_REG_RALUE_ACTION_TYPE_REMOTE); | |
4738 | mlxsw_reg_ralue_trap_action_set(payload, trap_action); | |
4739 | mlxsw_reg_ralue_trap_id_set(payload, trap_id); | |
4740 | mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index); | |
4741 | mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size); | |
4742 | } | |
4743 | ||
4744 | static inline void | |
4745 | mlxsw_reg_ralue_act_local_pack(char *payload, | |
4746 | enum mlxsw_reg_ralue_trap_action trap_action, | |
4747 | u16 trap_id, u16 local_erif) | |
4748 | { | |
4749 | mlxsw_reg_ralue_action_type_set(payload, | |
4750 | MLXSW_REG_RALUE_ACTION_TYPE_LOCAL); | |
4751 | mlxsw_reg_ralue_trap_action_set(payload, trap_action); | |
4752 | mlxsw_reg_ralue_trap_id_set(payload, trap_id); | |
4753 | mlxsw_reg_ralue_local_erif_set(payload, local_erif); | |
4754 | } | |
4755 | ||
4756 | static inline void | |
4757 | mlxsw_reg_ralue_act_ip2me_pack(char *payload) | |
4758 | { | |
4759 | mlxsw_reg_ralue_action_type_set(payload, | |
4760 | MLXSW_REG_RALUE_ACTION_TYPE_IP2ME); | |
4761 | } | |
4762 | ||
4457b3df YG |
4763 | /* RAUHT - Router Algorithmic LPM Unicast Host Table Register |
4764 | * ---------------------------------------------------------- | |
4765 | * The RAUHT register is used to configure and query the Unicast Host table in | |
4766 | * devices that implement the Algorithmic LPM. | |
4767 | */ | |
4768 | #define MLXSW_REG_RAUHT_ID 0x8014 | |
4769 | #define MLXSW_REG_RAUHT_LEN 0x74 | |
4770 | ||
21978dcf | 4771 | MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN); |
4457b3df YG |
4772 | |
4773 | enum mlxsw_reg_rauht_type { | |
4774 | MLXSW_REG_RAUHT_TYPE_IPV4, | |
4775 | MLXSW_REG_RAUHT_TYPE_IPV6, | |
4776 | }; | |
4777 | ||
4778 | /* reg_rauht_type | |
4779 | * Access: Index | |
4780 | */ | |
4781 | MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2); | |
4782 | ||
4783 | enum mlxsw_reg_rauht_op { | |
4784 | MLXSW_REG_RAUHT_OP_QUERY_READ = 0, | |
4785 | /* Read operation */ | |
4786 | MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1, | |
4787 | /* Clear on read operation. Used to read entry and clear | |
4788 | * activity bit. | |
4789 | */ | |
4790 | MLXSW_REG_RAUHT_OP_WRITE_ADD = 0, | |
4791 | /* Add. Used to write a new entry to the table. All R/W fields are | |
4792 | * relevant for new entry. Activity bit is set for new entries. | |
4793 | */ | |
4794 | MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1, | |
4795 | /* Update action. Used to update an existing route entry and | |
4796 | * only update the following fields: | |
4797 | * trap_action, trap_id, mac, counter_set_type, counter_index | |
4798 | */ | |
4799 | MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2, | |
4800 | /* Clear activity. A bit is cleared for the entry. */ | |
4801 | MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3, | |
4802 | /* Delete entry */ | |
4803 | MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4, | |
4804 | /* Delete all host entries on a RIF. In this command, dip | |
4805 | * field is reserved. | |
4806 | */ | |
4807 | }; | |
4808 | ||
4809 | /* reg_rauht_op | |
4810 | * Access: OP | |
4811 | */ | |
4812 | MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3); | |
4813 | ||
4814 | /* reg_rauht_a | |
4815 | * Activity. Set for new entries. Set if a packet lookup has hit on | |
4816 | * the specific entry. | |
4817 | * To clear the a bit, use "clear activity" op. | |
4818 | * Enabled by activity_dis in RGCR | |
4819 | * Access: RO | |
4820 | */ | |
4821 | MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1); | |
4822 | ||
4823 | /* reg_rauht_rif | |
4824 | * Router Interface | |
4825 | * Access: Index | |
4826 | */ | |
4827 | MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16); | |
4828 | ||
4829 | /* reg_rauht_dip* | |
4830 | * Destination address. | |
4831 | * Access: Index | |
4832 | */ | |
4833 | MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32); | |
4834 | ||
4835 | enum mlxsw_reg_rauht_trap_action { | |
4836 | MLXSW_REG_RAUHT_TRAP_ACTION_NOP, | |
4837 | MLXSW_REG_RAUHT_TRAP_ACTION_TRAP, | |
4838 | MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU, | |
4839 | MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR, | |
4840 | MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS, | |
4841 | }; | |
4842 | ||
4843 | /* reg_rauht_trap_action | |
4844 | * Access: RW | |
4845 | */ | |
4846 | MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4); | |
4847 | ||
4848 | enum mlxsw_reg_rauht_trap_id { | |
4849 | MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0, | |
4850 | MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1, | |
4851 | }; | |
4852 | ||
4853 | /* reg_rauht_trap_id | |
4854 | * Trap ID to be reported to CPU. | |
4855 | * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1. | |
4856 | * For trap_action of NOP, MIRROR and DISCARD_ERROR, | |
4857 | * trap_id is reserved. | |
4858 | * Access: RW | |
4859 | */ | |
4860 | MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9); | |
4861 | ||
4862 | /* reg_rauht_counter_set_type | |
4863 | * Counter set type for flow counters | |
4864 | * Access: RW | |
4865 | */ | |
4866 | MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8); | |
4867 | ||
4868 | /* reg_rauht_counter_index | |
4869 | * Counter index for flow counters | |
4870 | * Access: RW | |
4871 | */ | |
4872 | MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24); | |
4873 | ||
4874 | /* reg_rauht_mac | |
4875 | * MAC address. | |
4876 | * Access: RW | |
4877 | */ | |
4878 | MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6); | |
4879 | ||
4880 | static inline void mlxsw_reg_rauht_pack(char *payload, | |
4881 | enum mlxsw_reg_rauht_op op, u16 rif, | |
4882 | const char *mac) | |
4883 | { | |
4884 | MLXSW_REG_ZERO(rauht, payload); | |
4885 | mlxsw_reg_rauht_op_set(payload, op); | |
4886 | mlxsw_reg_rauht_rif_set(payload, rif); | |
4887 | mlxsw_reg_rauht_mac_memcpy_to(payload, mac); | |
4888 | } | |
4889 | ||
4890 | static inline void mlxsw_reg_rauht_pack4(char *payload, | |
4891 | enum mlxsw_reg_rauht_op op, u16 rif, | |
4892 | const char *mac, u32 dip) | |
4893 | { | |
4894 | mlxsw_reg_rauht_pack(payload, op, rif, mac); | |
4895 | mlxsw_reg_rauht_dip4_set(payload, dip); | |
4896 | } | |
4897 | ||
a59f0b31 JP |
4898 | /* RALEU - Router Algorithmic LPM ECMP Update Register |
4899 | * --------------------------------------------------- | |
4900 | * The register enables updating the ECMP section in the action for multiple | |
4901 | * LPM Unicast entries in a single operation. The update is executed to | |
4902 | * all entries of a {virtual router, protocol} tuple using the same ECMP group. | |
4903 | */ | |
4904 | #define MLXSW_REG_RALEU_ID 0x8015 | |
4905 | #define MLXSW_REG_RALEU_LEN 0x28 | |
4906 | ||
21978dcf | 4907 | MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN); |
a59f0b31 JP |
4908 | |
4909 | /* reg_raleu_protocol | |
4910 | * Protocol. | |
4911 | * Access: Index | |
4912 | */ | |
4913 | MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4); | |
4914 | ||
4915 | /* reg_raleu_virtual_router | |
4916 | * Virtual Router ID | |
4917 | * Range is 0..cap_max_virtual_routers-1 | |
4918 | * Access: Index | |
4919 | */ | |
4920 | MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16); | |
4921 | ||
4922 | /* reg_raleu_adjacency_index | |
4923 | * Adjacency Index used for matching on the existing entries. | |
4924 | * Access: Index | |
4925 | */ | |
4926 | MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24); | |
4927 | ||
4928 | /* reg_raleu_ecmp_size | |
4929 | * ECMP Size used for matching on the existing entries. | |
4930 | * Access: Index | |
4931 | */ | |
4932 | MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13); | |
4933 | ||
4934 | /* reg_raleu_new_adjacency_index | |
4935 | * New Adjacency Index. | |
4936 | * Access: WO | |
4937 | */ | |
4938 | MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24); | |
4939 | ||
4940 | /* reg_raleu_new_ecmp_size | |
4941 | * New ECMP Size. | |
4942 | * Access: WO | |
4943 | */ | |
4944 | MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13); | |
4945 | ||
4946 | static inline void mlxsw_reg_raleu_pack(char *payload, | |
4947 | enum mlxsw_reg_ralxx_protocol protocol, | |
4948 | u16 virtual_router, | |
4949 | u32 adjacency_index, u16 ecmp_size, | |
4950 | u32 new_adjacency_index, | |
4951 | u16 new_ecmp_size) | |
4952 | { | |
4953 | MLXSW_REG_ZERO(raleu, payload); | |
4954 | mlxsw_reg_raleu_protocol_set(payload, protocol); | |
4955 | mlxsw_reg_raleu_virtual_router_set(payload, virtual_router); | |
4956 | mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index); | |
4957 | mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size); | |
4958 | mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index); | |
4959 | mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size); | |
4960 | } | |
4961 | ||
7cf2c205 YG |
4962 | /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register |
4963 | * ---------------------------------------------------------------- | |
4964 | * The RAUHTD register allows dumping entries from the Router Unicast Host | |
4965 | * Table. For a given session an entry is dumped no more than one time. The | |
4966 | * first RAUHTD access after reset is a new session. A session ends when the | |
4967 | * num_rec response is smaller than num_rec request or for IPv4 when the | |
4968 | * num_entries is smaller than 4. The clear activity affect the current session | |
4969 | * or the last session if a new session has not started. | |
4970 | */ | |
4971 | #define MLXSW_REG_RAUHTD_ID 0x8018 | |
4972 | #define MLXSW_REG_RAUHTD_BASE_LEN 0x20 | |
4973 | #define MLXSW_REG_RAUHTD_REC_LEN 0x20 | |
4974 | #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32 | |
4975 | #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \ | |
4976 | MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN) | |
4977 | #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4 | |
4978 | ||
21978dcf | 4979 | MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN); |
7cf2c205 YG |
4980 | |
4981 | #define MLXSW_REG_RAUHTD_FILTER_A BIT(0) | |
4982 | #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3) | |
4983 | ||
4984 | /* reg_rauhtd_filter_fields | |
4985 | * if a bit is '0' then the relevant field is ignored and dump is done | |
4986 | * regardless of the field value | |
4987 | * Bit0 - filter by activity: entry_a | |
4988 | * Bit3 - filter by entry rip: entry_rif | |
4989 | * Access: Index | |
4990 | */ | |
4991 | MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8); | |
4992 | ||
4993 | enum mlxsw_reg_rauhtd_op { | |
4994 | MLXSW_REG_RAUHTD_OP_DUMP, | |
4995 | MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR, | |
4996 | }; | |
4997 | ||
4998 | /* reg_rauhtd_op | |
4999 | * Access: OP | |
5000 | */ | |
5001 | MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2); | |
5002 | ||
5003 | /* reg_rauhtd_num_rec | |
5004 | * At request: number of records requested | |
5005 | * At response: number of records dumped | |
5006 | * For IPv4, each record has 4 entries at request and up to 4 entries | |
5007 | * at response | |
5008 | * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM | |
5009 | * Access: Index | |
5010 | */ | |
5011 | MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8); | |
5012 | ||
5013 | /* reg_rauhtd_entry_a | |
5014 | * Dump only if activity has value of entry_a | |
5015 | * Reserved if filter_fields bit0 is '0' | |
5016 | * Access: Index | |
5017 | */ | |
5018 | MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1); | |
5019 | ||
5020 | enum mlxsw_reg_rauhtd_type { | |
5021 | MLXSW_REG_RAUHTD_TYPE_IPV4, | |
5022 | MLXSW_REG_RAUHTD_TYPE_IPV6, | |
5023 | }; | |
5024 | ||
5025 | /* reg_rauhtd_type | |
5026 | * Dump only if record type is: | |
5027 | * 0 - IPv4 | |
5028 | * 1 - IPv6 | |
5029 | * Access: Index | |
5030 | */ | |
5031 | MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4); | |
5032 | ||
5033 | /* reg_rauhtd_entry_rif | |
5034 | * Dump only if RIF has value of entry_rif | |
5035 | * Reserved if filter_fields bit3 is '0' | |
5036 | * Access: Index | |
5037 | */ | |
5038 | MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16); | |
5039 | ||
5040 | static inline void mlxsw_reg_rauhtd_pack(char *payload, | |
5041 | enum mlxsw_reg_rauhtd_type type) | |
5042 | { | |
5043 | MLXSW_REG_ZERO(rauhtd, payload); | |
5044 | mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A); | |
5045 | mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR); | |
5046 | mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM); | |
5047 | mlxsw_reg_rauhtd_entry_a_set(payload, 1); | |
5048 | mlxsw_reg_rauhtd_type_set(payload, type); | |
5049 | } | |
5050 | ||
5051 | /* reg_rauhtd_ipv4_rec_num_entries | |
5052 | * Number of valid entries in this record: | |
5053 | * 0 - 1 valid entry | |
5054 | * 1 - 2 valid entries | |
5055 | * 2 - 3 valid entries | |
5056 | * 3 - 4 valid entries | |
5057 | * Access: RO | |
5058 | */ | |
5059 | MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries, | |
5060 | MLXSW_REG_RAUHTD_BASE_LEN, 28, 2, | |
5061 | MLXSW_REG_RAUHTD_REC_LEN, 0x00, false); | |
5062 | ||
5063 | /* reg_rauhtd_rec_type | |
5064 | * Record type. | |
5065 | * 0 - IPv4 | |
5066 | * 1 - IPv6 | |
5067 | * Access: RO | |
5068 | */ | |
5069 | MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2, | |
5070 | MLXSW_REG_RAUHTD_REC_LEN, 0x00, false); | |
5071 | ||
5072 | #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8 | |
5073 | ||
5074 | /* reg_rauhtd_ipv4_ent_a | |
5075 | * Activity. Set for new entries. Set if a packet lookup has hit on the | |
5076 | * specific entry. | |
5077 | * Access: RO | |
5078 | */ | |
5079 | MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1, | |
5080 | MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false); | |
5081 | ||
5082 | /* reg_rauhtd_ipv4_ent_rif | |
5083 | * Router interface. | |
5084 | * Access: RO | |
5085 | */ | |
5086 | MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0, | |
5087 | 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false); | |
5088 | ||
5089 | /* reg_rauhtd_ipv4_ent_dip | |
5090 | * Destination IPv4 address. | |
5091 | * Access: RO | |
5092 | */ | |
5093 | MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0, | |
5094 | 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false); | |
5095 | ||
5096 | static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload, | |
5097 | int ent_index, u16 *p_rif, | |
5098 | u32 *p_dip) | |
5099 | { | |
5100 | *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index); | |
5101 | *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index); | |
5102 | } | |
5103 | ||
5246f2e2 JP |
5104 | /* MFCR - Management Fan Control Register |
5105 | * -------------------------------------- | |
5106 | * This register controls the settings of the Fan Speed PWM mechanism. | |
5107 | */ | |
5108 | #define MLXSW_REG_MFCR_ID 0x9001 | |
5109 | #define MLXSW_REG_MFCR_LEN 0x08 | |
5110 | ||
21978dcf | 5111 | MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN); |
5246f2e2 JP |
5112 | |
5113 | enum mlxsw_reg_mfcr_pwm_frequency { | |
5114 | MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00, | |
5115 | MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01, | |
5116 | MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02, | |
5117 | MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40, | |
5118 | MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41, | |
5119 | MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42, | |
5120 | MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43, | |
5121 | MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44, | |
5122 | }; | |
5123 | ||
5124 | /* reg_mfcr_pwm_frequency | |
5125 | * Controls the frequency of the PWM signal. | |
5126 | * Access: RW | |
5127 | */ | |
f7ad3d4b | 5128 | MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7); |
5246f2e2 JP |
5129 | |
5130 | #define MLXSW_MFCR_TACHOS_MAX 10 | |
5131 | ||
5132 | /* reg_mfcr_tacho_active | |
5133 | * Indicates which of the tachometer is active (bit per tachometer). | |
5134 | * Access: RO | |
5135 | */ | |
5136 | MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX); | |
5137 | ||
5138 | #define MLXSW_MFCR_PWMS_MAX 5 | |
5139 | ||
5140 | /* reg_mfcr_pwm_active | |
5141 | * Indicates which of the PWM control is active (bit per PWM). | |
5142 | * Access: RO | |
5143 | */ | |
5144 | MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX); | |
5145 | ||
5146 | static inline void | |
5147 | mlxsw_reg_mfcr_pack(char *payload, | |
5148 | enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency) | |
5149 | { | |
5150 | MLXSW_REG_ZERO(mfcr, payload); | |
5151 | mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency); | |
5152 | } | |
5153 | ||
5154 | static inline void | |
5155 | mlxsw_reg_mfcr_unpack(char *payload, | |
5156 | enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency, | |
5157 | u16 *p_tacho_active, u8 *p_pwm_active) | |
5158 | { | |
5159 | *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload); | |
5160 | *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload); | |
5161 | *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload); | |
5162 | } | |
5163 | ||
5164 | /* MFSC - Management Fan Speed Control Register | |
5165 | * -------------------------------------------- | |
5166 | * This register controls the settings of the Fan Speed PWM mechanism. | |
5167 | */ | |
5168 | #define MLXSW_REG_MFSC_ID 0x9002 | |
5169 | #define MLXSW_REG_MFSC_LEN 0x08 | |
5170 | ||
21978dcf | 5171 | MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN); |
5246f2e2 JP |
5172 | |
5173 | /* reg_mfsc_pwm | |
5174 | * Fan pwm to control / monitor. | |
5175 | * Access: Index | |
5176 | */ | |
5177 | MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3); | |
5178 | ||
5179 | /* reg_mfsc_pwm_duty_cycle | |
5180 | * Controls the duty cycle of the PWM. Value range from 0..255 to | |
5181 | * represent duty cycle of 0%...100%. | |
5182 | * Access: RW | |
5183 | */ | |
5184 | MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8); | |
5185 | ||
5186 | static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm, | |
5187 | u8 pwm_duty_cycle) | |
5188 | { | |
5189 | MLXSW_REG_ZERO(mfsc, payload); | |
5190 | mlxsw_reg_mfsc_pwm_set(payload, pwm); | |
5191 | mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle); | |
5192 | } | |
5193 | ||
5194 | /* MFSM - Management Fan Speed Measurement | |
5195 | * --------------------------------------- | |
5196 | * This register controls the settings of the Tacho measurements and | |
5197 | * enables reading the Tachometer measurements. | |
5198 | */ | |
5199 | #define MLXSW_REG_MFSM_ID 0x9003 | |
5200 | #define MLXSW_REG_MFSM_LEN 0x08 | |
5201 | ||
21978dcf | 5202 | MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN); |
5246f2e2 JP |
5203 | |
5204 | /* reg_mfsm_tacho | |
5205 | * Fan tachometer index. | |
5206 | * Access: Index | |
5207 | */ | |
5208 | MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4); | |
5209 | ||
5210 | /* reg_mfsm_rpm | |
5211 | * Fan speed (round per minute). | |
5212 | * Access: RO | |
5213 | */ | |
5214 | MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16); | |
5215 | ||
5216 | static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho) | |
5217 | { | |
5218 | MLXSW_REG_ZERO(mfsm, payload); | |
5219 | mlxsw_reg_mfsm_tacho_set(payload, tacho); | |
5220 | } | |
5221 | ||
55c63aaa JP |
5222 | /* MFSL - Management Fan Speed Limit Register |
5223 | * ------------------------------------------ | |
5224 | * The Fan Speed Limit register is used to configure the fan speed | |
5225 | * event / interrupt notification mechanism. Fan speed threshold are | |
5226 | * defined for both under-speed and over-speed. | |
5227 | */ | |
5228 | #define MLXSW_REG_MFSL_ID 0x9004 | |
5229 | #define MLXSW_REG_MFSL_LEN 0x0C | |
5230 | ||
5231 | MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN); | |
5232 | ||
5233 | /* reg_mfsl_tacho | |
5234 | * Fan tachometer index. | |
5235 | * Access: Index | |
5236 | */ | |
5237 | MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4); | |
5238 | ||
5239 | /* reg_mfsl_tach_min | |
5240 | * Tachometer minimum value (minimum RPM). | |
5241 | * Access: RW | |
5242 | */ | |
5243 | MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16); | |
5244 | ||
5245 | /* reg_mfsl_tach_max | |
5246 | * Tachometer maximum value (maximum RPM). | |
5247 | * Access: RW | |
5248 | */ | |
5249 | MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16); | |
5250 | ||
5251 | static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho, | |
5252 | u16 tach_min, u16 tach_max) | |
5253 | { | |
5254 | MLXSW_REG_ZERO(mfsl, payload); | |
5255 | mlxsw_reg_mfsl_tacho_set(payload, tacho); | |
5256 | mlxsw_reg_mfsl_tach_min_set(payload, tach_min); | |
5257 | mlxsw_reg_mfsl_tach_max_set(payload, tach_max); | |
5258 | } | |
5259 | ||
5260 | static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho, | |
5261 | u16 *p_tach_min, u16 *p_tach_max) | |
5262 | { | |
5263 | if (p_tach_min) | |
5264 | *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload); | |
5265 | ||
5266 | if (p_tach_max) | |
5267 | *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload); | |
5268 | } | |
5269 | ||
85926f87 JP |
5270 | /* MTCAP - Management Temperature Capabilities |
5271 | * ------------------------------------------- | |
5272 | * This register exposes the capabilities of the device and | |
5273 | * system temperature sensing. | |
5274 | */ | |
5275 | #define MLXSW_REG_MTCAP_ID 0x9009 | |
5276 | #define MLXSW_REG_MTCAP_LEN 0x08 | |
5277 | ||
21978dcf | 5278 | MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN); |
85926f87 JP |
5279 | |
5280 | /* reg_mtcap_sensor_count | |
5281 | * Number of sensors supported by the device. | |
5282 | * This includes the QSFP module sensors (if exists in the QSFP module). | |
5283 | * Access: RO | |
5284 | */ | |
5285 | MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7); | |
5286 | ||
5287 | /* MTMP - Management Temperature | |
5288 | * ----------------------------- | |
5289 | * This register controls the settings of the temperature measurements | |
5290 | * and enables reading the temperature measurements. Note that temperature | |
5291 | * is in 0.125 degrees Celsius. | |
5292 | */ | |
5293 | #define MLXSW_REG_MTMP_ID 0x900A | |
5294 | #define MLXSW_REG_MTMP_LEN 0x20 | |
5295 | ||
21978dcf | 5296 | MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN); |
85926f87 JP |
5297 | |
5298 | /* reg_mtmp_sensor_index | |
5299 | * Sensors index to access. | |
5300 | * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially | |
5301 | * (module 0 is mapped to sensor_index 64). | |
5302 | * Access: Index | |
5303 | */ | |
5304 | MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7); | |
5305 | ||
5306 | /* Convert to milli degrees Celsius */ | |
5307 | #define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125) | |
5308 | ||
5309 | /* reg_mtmp_temperature | |
5310 | * Temperature reading from the sensor. Reading is in 0.125 Celsius | |
5311 | * degrees units. | |
5312 | * Access: RO | |
5313 | */ | |
5314 | MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16); | |
5315 | ||
5316 | /* reg_mtmp_mte | |
5317 | * Max Temperature Enable - enables measuring the max temperature on a sensor. | |
5318 | * Access: RW | |
5319 | */ | |
5320 | MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1); | |
5321 | ||
5322 | /* reg_mtmp_mtr | |
5323 | * Max Temperature Reset - clears the value of the max temperature register. | |
5324 | * Access: WO | |
5325 | */ | |
5326 | MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1); | |
5327 | ||
5328 | /* reg_mtmp_max_temperature | |
5329 | * The highest measured temperature from the sensor. | |
5330 | * When the bit mte is cleared, the field max_temperature is reserved. | |
5331 | * Access: RO | |
5332 | */ | |
5333 | MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16); | |
5334 | ||
5335 | #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8 | |
5336 | ||
5337 | /* reg_mtmp_sensor_name | |
5338 | * Sensor Name | |
5339 | * Access: RO | |
5340 | */ | |
5341 | MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE); | |
5342 | ||
5343 | static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index, | |
5344 | bool max_temp_enable, | |
5345 | bool max_temp_reset) | |
5346 | { | |
5347 | MLXSW_REG_ZERO(mtmp, payload); | |
5348 | mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index); | |
5349 | mlxsw_reg_mtmp_mte_set(payload, max_temp_enable); | |
5350 | mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset); | |
5351 | } | |
5352 | ||
5353 | static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp, | |
5354 | unsigned int *p_max_temp, | |
5355 | char *sensor_name) | |
5356 | { | |
5357 | u16 temp; | |
5358 | ||
5359 | if (p_temp) { | |
5360 | temp = mlxsw_reg_mtmp_temperature_get(payload); | |
5361 | *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp); | |
5362 | } | |
5363 | if (p_max_temp) { | |
acf35a4e | 5364 | temp = mlxsw_reg_mtmp_max_temperature_get(payload); |
85926f87 JP |
5365 | *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp); |
5366 | } | |
5367 | if (sensor_name) | |
5368 | mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name); | |
5369 | } | |
5370 | ||
43a46856 YG |
5371 | /* MPAT - Monitoring Port Analyzer Table |
5372 | * ------------------------------------- | |
5373 | * MPAT Register is used to query and configure the Switch PortAnalyzer Table. | |
5374 | * For an enabled analyzer, all fields except e (enable) cannot be modified. | |
5375 | */ | |
5376 | #define MLXSW_REG_MPAT_ID 0x901A | |
5377 | #define MLXSW_REG_MPAT_LEN 0x78 | |
5378 | ||
21978dcf | 5379 | MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN); |
43a46856 YG |
5380 | |
5381 | /* reg_mpat_pa_id | |
5382 | * Port Analyzer ID. | |
5383 | * Access: Index | |
5384 | */ | |
5385 | MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4); | |
5386 | ||
5387 | /* reg_mpat_system_port | |
5388 | * A unique port identifier for the final destination of the packet. | |
5389 | * Access: RW | |
5390 | */ | |
5391 | MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16); | |
5392 | ||
5393 | /* reg_mpat_e | |
5394 | * Enable. Indicating the Port Analyzer is enabled. | |
5395 | * Access: RW | |
5396 | */ | |
5397 | MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1); | |
5398 | ||
5399 | /* reg_mpat_qos | |
5400 | * Quality Of Service Mode. | |
5401 | * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation | |
5402 | * PCP, DEI, DSCP or VL) are configured. | |
5403 | * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the | |
5404 | * same as in the original packet that has triggered the mirroring. For | |
5405 | * SPAN also the pcp,dei are maintained. | |
5406 | * Access: RW | |
5407 | */ | |
5408 | MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1); | |
5409 | ||
23019054 YG |
5410 | /* reg_mpat_be |
5411 | * Best effort mode. Indicates mirroring traffic should not cause packet | |
5412 | * drop or back pressure, but will discard the mirrored packets. Mirrored | |
5413 | * packets will be forwarded on a best effort manner. | |
5414 | * 0: Do not discard mirrored packets | |
5415 | * 1: Discard mirrored packets if causing congestion | |
5416 | * Access: RW | |
5417 | */ | |
5418 | MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1); | |
5419 | ||
43a46856 YG |
5420 | static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id, |
5421 | u16 system_port, bool e) | |
5422 | { | |
5423 | MLXSW_REG_ZERO(mpat, payload); | |
5424 | mlxsw_reg_mpat_pa_id_set(payload, pa_id); | |
5425 | mlxsw_reg_mpat_system_port_set(payload, system_port); | |
5426 | mlxsw_reg_mpat_e_set(payload, e); | |
5427 | mlxsw_reg_mpat_qos_set(payload, 1); | |
23019054 YG |
5428 | mlxsw_reg_mpat_be_set(payload, 1); |
5429 | } | |
5430 | ||
5431 | /* MPAR - Monitoring Port Analyzer Register | |
5432 | * ---------------------------------------- | |
5433 | * MPAR register is used to query and configure the port analyzer port mirroring | |
5434 | * properties. | |
5435 | */ | |
5436 | #define MLXSW_REG_MPAR_ID 0x901B | |
5437 | #define MLXSW_REG_MPAR_LEN 0x08 | |
5438 | ||
21978dcf | 5439 | MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN); |
23019054 YG |
5440 | |
5441 | /* reg_mpar_local_port | |
5442 | * The local port to mirror the packets from. | |
5443 | * Access: Index | |
5444 | */ | |
5445 | MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8); | |
5446 | ||
5447 | enum mlxsw_reg_mpar_i_e { | |
5448 | MLXSW_REG_MPAR_TYPE_EGRESS, | |
5449 | MLXSW_REG_MPAR_TYPE_INGRESS, | |
5450 | }; | |
5451 | ||
5452 | /* reg_mpar_i_e | |
5453 | * Ingress/Egress | |
5454 | * Access: Index | |
5455 | */ | |
5456 | MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4); | |
5457 | ||
5458 | /* reg_mpar_enable | |
5459 | * Enable mirroring | |
5460 | * By default, port mirroring is disabled for all ports. | |
5461 | * Access: RW | |
5462 | */ | |
5463 | MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1); | |
5464 | ||
5465 | /* reg_mpar_pa_id | |
5466 | * Port Analyzer ID. | |
5467 | * Access: RW | |
5468 | */ | |
5469 | MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4); | |
5470 | ||
5471 | static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port, | |
5472 | enum mlxsw_reg_mpar_i_e i_e, | |
5473 | bool enable, u8 pa_id) | |
5474 | { | |
5475 | MLXSW_REG_ZERO(mpar, payload); | |
5476 | mlxsw_reg_mpar_local_port_set(payload, local_port); | |
5477 | mlxsw_reg_mpar_enable_set(payload, enable); | |
5478 | mlxsw_reg_mpar_i_e_set(payload, i_e); | |
5479 | mlxsw_reg_mpar_pa_id_set(payload, pa_id); | |
43a46856 YG |
5480 | } |
5481 | ||
3161c159 IS |
5482 | /* MLCR - Management LED Control Register |
5483 | * -------------------------------------- | |
5484 | * Controls the system LEDs. | |
5485 | */ | |
5486 | #define MLXSW_REG_MLCR_ID 0x902B | |
5487 | #define MLXSW_REG_MLCR_LEN 0x0C | |
5488 | ||
21978dcf | 5489 | MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN); |
3161c159 IS |
5490 | |
5491 | /* reg_mlcr_local_port | |
5492 | * Local port number. | |
5493 | * Access: RW | |
5494 | */ | |
5495 | MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8); | |
5496 | ||
5497 | #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF | |
5498 | ||
5499 | /* reg_mlcr_beacon_duration | |
5500 | * Duration of the beacon to be active, in seconds. | |
5501 | * 0x0 - Will turn off the beacon. | |
5502 | * 0xFFFF - Will turn on the beacon until explicitly turned off. | |
5503 | * Access: RW | |
5504 | */ | |
5505 | MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16); | |
5506 | ||
5507 | /* reg_mlcr_beacon_remain | |
5508 | * Remaining duration of the beacon, in seconds. | |
5509 | * 0xFFFF indicates an infinite amount of time. | |
5510 | * Access: RO | |
5511 | */ | |
5512 | MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16); | |
5513 | ||
5514 | static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port, | |
5515 | bool active) | |
5516 | { | |
5517 | MLXSW_REG_ZERO(mlcr, payload); | |
5518 | mlxsw_reg_mlcr_local_port_set(payload, local_port); | |
5519 | mlxsw_reg_mlcr_beacon_duration_set(payload, active ? | |
5520 | MLXSW_REG_MLCR_DURATION_MAX : 0); | |
5521 | } | |
5522 | ||
0677d682 YG |
5523 | /* MPSC - Monitoring Packet Sampling Configuration Register |
5524 | * -------------------------------------------------------- | |
5525 | * MPSC Register is used to configure the Packet Sampling mechanism. | |
5526 | */ | |
5527 | #define MLXSW_REG_MPSC_ID 0x9080 | |
5528 | #define MLXSW_REG_MPSC_LEN 0x1C | |
5529 | ||
5530 | MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN); | |
5531 | ||
5532 | /* reg_mpsc_local_port | |
5533 | * Local port number | |
5534 | * Not supported for CPU port | |
5535 | * Access: Index | |
5536 | */ | |
5537 | MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8); | |
5538 | ||
5539 | /* reg_mpsc_e | |
5540 | * Enable sampling on port local_port | |
5541 | * Access: RW | |
5542 | */ | |
5543 | MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1); | |
5544 | ||
5545 | #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL | |
5546 | ||
5547 | /* reg_mpsc_rate | |
5548 | * Sampling rate = 1 out of rate packets (with randomization around | |
5549 | * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX | |
5550 | * Access: RW | |
5551 | */ | |
5552 | MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32); | |
5553 | ||
5554 | static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e, | |
5555 | u32 rate) | |
5556 | { | |
5557 | MLXSW_REG_ZERO(mpsc, payload); | |
5558 | mlxsw_reg_mpsc_local_port_set(payload, local_port); | |
5559 | mlxsw_reg_mpsc_e_set(payload, e); | |
5560 | mlxsw_reg_mpsc_rate_set(payload, rate); | |
5561 | } | |
5562 | ||
5766532a AS |
5563 | /* MGPC - Monitoring General Purpose Counter Set Register |
5564 | * The MGPC register retrieves and sets the General Purpose Counter Set. | |
5565 | */ | |
5566 | #define MLXSW_REG_MGPC_ID 0x9081 | |
5567 | #define MLXSW_REG_MGPC_LEN 0x18 | |
5568 | ||
5569 | MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN); | |
5570 | ||
5571 | enum mlxsw_reg_mgpc_counter_set_type { | |
5572 | /* No count */ | |
5573 | MLXSW_REG_MGPC_COUNTER_SET_TYPE_NO_COUT = 0x00, | |
5574 | /* Count packets and bytes */ | |
5575 | MLXSW_REG_MGPC_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03, | |
5576 | /* Count only packets */ | |
5577 | MLXSW_REG_MGPC_COUNTER_SET_TYPE_PACKETS = 0x05, | |
5578 | }; | |
5579 | ||
5580 | /* reg_mgpc_counter_set_type | |
5581 | * Counter set type. | |
5582 | * Access: OP | |
5583 | */ | |
5584 | MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8); | |
5585 | ||
5586 | /* reg_mgpc_counter_index | |
5587 | * Counter index. | |
5588 | * Access: Index | |
5589 | */ | |
5590 | MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24); | |
5591 | ||
5592 | enum mlxsw_reg_mgpc_opcode { | |
5593 | /* Nop */ | |
5594 | MLXSW_REG_MGPC_OPCODE_NOP = 0x00, | |
5595 | /* Clear counters */ | |
5596 | MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08, | |
5597 | }; | |
5598 | ||
5599 | /* reg_mgpc_opcode | |
5600 | * Opcode. | |
5601 | * Access: OP | |
5602 | */ | |
5603 | MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4); | |
5604 | ||
5605 | /* reg_mgpc_byte_counter | |
5606 | * Byte counter value. | |
5607 | * Access: RW | |
5608 | */ | |
5609 | MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64); | |
5610 | ||
5611 | /* reg_mgpc_packet_counter | |
5612 | * Packet counter value. | |
5613 | * Access: RW | |
5614 | */ | |
5615 | MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64); | |
5616 | ||
5617 | static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index, | |
5618 | enum mlxsw_reg_mgpc_opcode opcode, | |
5619 | enum mlxsw_reg_mgpc_counter_set_type set_type) | |
5620 | { | |
5621 | MLXSW_REG_ZERO(mgpc, payload); | |
5622 | mlxsw_reg_mgpc_counter_index_set(payload, counter_index); | |
5623 | mlxsw_reg_mgpc_counter_set_type_set(payload, set_type); | |
5624 | mlxsw_reg_mgpc_opcode_set(payload, opcode); | |
5625 | } | |
5626 | ||
e0594369 JP |
5627 | /* SBPR - Shared Buffer Pools Register |
5628 | * ----------------------------------- | |
5629 | * The SBPR configures and retrieves the shared buffer pools and configuration. | |
5630 | */ | |
5631 | #define MLXSW_REG_SBPR_ID 0xB001 | |
5632 | #define MLXSW_REG_SBPR_LEN 0x14 | |
5633 | ||
21978dcf | 5634 | MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN); |
e0594369 | 5635 | |
497e8592 JP |
5636 | /* shared direstion enum for SBPR, SBCM, SBPM */ |
5637 | enum mlxsw_reg_sbxx_dir { | |
5638 | MLXSW_REG_SBXX_DIR_INGRESS, | |
5639 | MLXSW_REG_SBXX_DIR_EGRESS, | |
e0594369 JP |
5640 | }; |
5641 | ||
5642 | /* reg_sbpr_dir | |
5643 | * Direction. | |
5644 | * Access: Index | |
5645 | */ | |
5646 | MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2); | |
5647 | ||
5648 | /* reg_sbpr_pool | |
5649 | * Pool index. | |
5650 | * Access: Index | |
5651 | */ | |
5652 | MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4); | |
5653 | ||
5654 | /* reg_sbpr_size | |
5655 | * Pool size in buffer cells. | |
5656 | * Access: RW | |
5657 | */ | |
5658 | MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24); | |
5659 | ||
5660 | enum mlxsw_reg_sbpr_mode { | |
5661 | MLXSW_REG_SBPR_MODE_STATIC, | |
5662 | MLXSW_REG_SBPR_MODE_DYNAMIC, | |
5663 | }; | |
5664 | ||
5665 | /* reg_sbpr_mode | |
5666 | * Pool quota calculation mode. | |
5667 | * Access: RW | |
5668 | */ | |
5669 | MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4); | |
5670 | ||
5671 | static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool, | |
497e8592 | 5672 | enum mlxsw_reg_sbxx_dir dir, |
e0594369 JP |
5673 | enum mlxsw_reg_sbpr_mode mode, u32 size) |
5674 | { | |
5675 | MLXSW_REG_ZERO(sbpr, payload); | |
5676 | mlxsw_reg_sbpr_pool_set(payload, pool); | |
5677 | mlxsw_reg_sbpr_dir_set(payload, dir); | |
5678 | mlxsw_reg_sbpr_mode_set(payload, mode); | |
5679 | mlxsw_reg_sbpr_size_set(payload, size); | |
5680 | } | |
5681 | ||
5682 | /* SBCM - Shared Buffer Class Management Register | |
5683 | * ---------------------------------------------- | |
5684 | * The SBCM register configures and retrieves the shared buffer allocation | |
5685 | * and configuration according to Port-PG, including the binding to pool | |
5686 | * and definition of the associated quota. | |
5687 | */ | |
5688 | #define MLXSW_REG_SBCM_ID 0xB002 | |
5689 | #define MLXSW_REG_SBCM_LEN 0x28 | |
5690 | ||
21978dcf | 5691 | MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN); |
e0594369 JP |
5692 | |
5693 | /* reg_sbcm_local_port | |
5694 | * Local port number. | |
5695 | * For Ingress: excludes CPU port and Router port | |
5696 | * For Egress: excludes IP Router | |
5697 | * Access: Index | |
5698 | */ | |
5699 | MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8); | |
5700 | ||
5701 | /* reg_sbcm_pg_buff | |
5702 | * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress) | |
5703 | * For PG buffer: range is 0..cap_max_pg_buffers - 1 | |
5704 | * For traffic class: range is 0..cap_max_tclass - 1 | |
5705 | * Note that when traffic class is in MC aware mode then the traffic | |
5706 | * classes which are MC aware cannot be configured. | |
5707 | * Access: Index | |
5708 | */ | |
5709 | MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6); | |
5710 | ||
e0594369 JP |
5711 | /* reg_sbcm_dir |
5712 | * Direction. | |
5713 | * Access: Index | |
5714 | */ | |
5715 | MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2); | |
5716 | ||
5717 | /* reg_sbcm_min_buff | |
5718 | * Minimum buffer size for the limiter, in cells. | |
5719 | * Access: RW | |
5720 | */ | |
5721 | MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24); | |
5722 | ||
c30a53c7 JP |
5723 | /* shared max_buff limits for dynamic threshold for SBCM, SBPM */ |
5724 | #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1 | |
5725 | #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14 | |
5726 | ||
e0594369 JP |
5727 | /* reg_sbcm_max_buff |
5728 | * When the pool associated to the port-pg/tclass is configured to | |
5729 | * static, Maximum buffer size for the limiter configured in cells. | |
5730 | * When the pool associated to the port-pg/tclass is configured to | |
5731 | * dynamic, the max_buff holds the "alpha" parameter, supporting | |
5732 | * the following values: | |
5733 | * 0: 0 | |
5734 | * i: (1/128)*2^(i-1), for i=1..14 | |
5735 | * 0xFF: Infinity | |
5736 | * Access: RW | |
5737 | */ | |
5738 | MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24); | |
5739 | ||
5740 | /* reg_sbcm_pool | |
5741 | * Association of the port-priority to a pool. | |
5742 | * Access: RW | |
5743 | */ | |
5744 | MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4); | |
5745 | ||
5746 | static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff, | |
497e8592 | 5747 | enum mlxsw_reg_sbxx_dir dir, |
e0594369 JP |
5748 | u32 min_buff, u32 max_buff, u8 pool) |
5749 | { | |
5750 | MLXSW_REG_ZERO(sbcm, payload); | |
5751 | mlxsw_reg_sbcm_local_port_set(payload, local_port); | |
5752 | mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff); | |
5753 | mlxsw_reg_sbcm_dir_set(payload, dir); | |
5754 | mlxsw_reg_sbcm_min_buff_set(payload, min_buff); | |
5755 | mlxsw_reg_sbcm_max_buff_set(payload, max_buff); | |
5756 | mlxsw_reg_sbcm_pool_set(payload, pool); | |
5757 | } | |
5758 | ||
9efc8f65 JP |
5759 | /* SBPM - Shared Buffer Port Management Register |
5760 | * --------------------------------------------- | |
e0594369 JP |
5761 | * The SBPM register configures and retrieves the shared buffer allocation |
5762 | * and configuration according to Port-Pool, including the definition | |
5763 | * of the associated quota. | |
5764 | */ | |
5765 | #define MLXSW_REG_SBPM_ID 0xB003 | |
5766 | #define MLXSW_REG_SBPM_LEN 0x28 | |
5767 | ||
21978dcf | 5768 | MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN); |
e0594369 JP |
5769 | |
5770 | /* reg_sbpm_local_port | |
5771 | * Local port number. | |
5772 | * For Ingress: excludes CPU port and Router port | |
5773 | * For Egress: excludes IP Router | |
5774 | * Access: Index | |
5775 | */ | |
5776 | MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8); | |
5777 | ||
5778 | /* reg_sbpm_pool | |
5779 | * The pool associated to quota counting on the local_port. | |
5780 | * Access: Index | |
5781 | */ | |
5782 | MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4); | |
5783 | ||
e0594369 JP |
5784 | /* reg_sbpm_dir |
5785 | * Direction. | |
5786 | * Access: Index | |
5787 | */ | |
5788 | MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2); | |
5789 | ||
42a7f1d7 JP |
5790 | /* reg_sbpm_buff_occupancy |
5791 | * Current buffer occupancy in cells. | |
5792 | * Access: RO | |
5793 | */ | |
5794 | MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24); | |
5795 | ||
5796 | /* reg_sbpm_clr | |
5797 | * Clear Max Buffer Occupancy | |
5798 | * When this bit is set, max_buff_occupancy field is cleared (and a | |
5799 | * new max value is tracked from the time the clear was performed). | |
5800 | * Access: OP | |
5801 | */ | |
5802 | MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1); | |
5803 | ||
5804 | /* reg_sbpm_max_buff_occupancy | |
5805 | * Maximum value of buffer occupancy in cells monitored. Cleared by | |
5806 | * writing to the clr field. | |
5807 | * Access: RO | |
5808 | */ | |
5809 | MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24); | |
5810 | ||
e0594369 JP |
5811 | /* reg_sbpm_min_buff |
5812 | * Minimum buffer size for the limiter, in cells. | |
5813 | * Access: RW | |
5814 | */ | |
5815 | MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24); | |
5816 | ||
5817 | /* reg_sbpm_max_buff | |
5818 | * When the pool associated to the port-pg/tclass is configured to | |
5819 | * static, Maximum buffer size for the limiter configured in cells. | |
5820 | * When the pool associated to the port-pg/tclass is configured to | |
5821 | * dynamic, the max_buff holds the "alpha" parameter, supporting | |
5822 | * the following values: | |
5823 | * 0: 0 | |
5824 | * i: (1/128)*2^(i-1), for i=1..14 | |
5825 | * 0xFF: Infinity | |
5826 | * Access: RW | |
5827 | */ | |
5828 | MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24); | |
5829 | ||
5830 | static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool, | |
42a7f1d7 | 5831 | enum mlxsw_reg_sbxx_dir dir, bool clr, |
e0594369 JP |
5832 | u32 min_buff, u32 max_buff) |
5833 | { | |
5834 | MLXSW_REG_ZERO(sbpm, payload); | |
5835 | mlxsw_reg_sbpm_local_port_set(payload, local_port); | |
5836 | mlxsw_reg_sbpm_pool_set(payload, pool); | |
5837 | mlxsw_reg_sbpm_dir_set(payload, dir); | |
42a7f1d7 | 5838 | mlxsw_reg_sbpm_clr_set(payload, clr); |
e0594369 JP |
5839 | mlxsw_reg_sbpm_min_buff_set(payload, min_buff); |
5840 | mlxsw_reg_sbpm_max_buff_set(payload, max_buff); | |
5841 | } | |
5842 | ||
42a7f1d7 JP |
5843 | static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy, |
5844 | u32 *p_max_buff_occupancy) | |
5845 | { | |
5846 | *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload); | |
5847 | *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload); | |
5848 | } | |
5849 | ||
e0594369 JP |
5850 | /* SBMM - Shared Buffer Multicast Management Register |
5851 | * -------------------------------------------------- | |
5852 | * The SBMM register configures and retrieves the shared buffer allocation | |
5853 | * and configuration for MC packets according to Switch-Priority, including | |
5854 | * the binding to pool and definition of the associated quota. | |
5855 | */ | |
5856 | #define MLXSW_REG_SBMM_ID 0xB004 | |
5857 | #define MLXSW_REG_SBMM_LEN 0x28 | |
5858 | ||
21978dcf | 5859 | MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN); |
e0594369 JP |
5860 | |
5861 | /* reg_sbmm_prio | |
5862 | * Switch Priority. | |
5863 | * Access: Index | |
5864 | */ | |
5865 | MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4); | |
5866 | ||
5867 | /* reg_sbmm_min_buff | |
5868 | * Minimum buffer size for the limiter, in cells. | |
5869 | * Access: RW | |
5870 | */ | |
5871 | MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24); | |
5872 | ||
5873 | /* reg_sbmm_max_buff | |
5874 | * When the pool associated to the port-pg/tclass is configured to | |
5875 | * static, Maximum buffer size for the limiter configured in cells. | |
5876 | * When the pool associated to the port-pg/tclass is configured to | |
5877 | * dynamic, the max_buff holds the "alpha" parameter, supporting | |
5878 | * the following values: | |
5879 | * 0: 0 | |
5880 | * i: (1/128)*2^(i-1), for i=1..14 | |
5881 | * 0xFF: Infinity | |
5882 | * Access: RW | |
5883 | */ | |
5884 | MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24); | |
5885 | ||
5886 | /* reg_sbmm_pool | |
5887 | * Association of the port-priority to a pool. | |
5888 | * Access: RW | |
5889 | */ | |
5890 | MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4); | |
5891 | ||
5892 | static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff, | |
5893 | u32 max_buff, u8 pool) | |
5894 | { | |
5895 | MLXSW_REG_ZERO(sbmm, payload); | |
5896 | mlxsw_reg_sbmm_prio_set(payload, prio); | |
5897 | mlxsw_reg_sbmm_min_buff_set(payload, min_buff); | |
5898 | mlxsw_reg_sbmm_max_buff_set(payload, max_buff); | |
5899 | mlxsw_reg_sbmm_pool_set(payload, pool); | |
5900 | } | |
5901 | ||
26176def JP |
5902 | /* SBSR - Shared Buffer Status Register |
5903 | * ------------------------------------ | |
5904 | * The SBSR register retrieves the shared buffer occupancy according to | |
5905 | * Port-Pool. Note that this register enables reading a large amount of data. | |
5906 | * It is the user's responsibility to limit the amount of data to ensure the | |
5907 | * response can match the maximum transfer unit. In case the response exceeds | |
5908 | * the maximum transport unit, it will be truncated with no special notice. | |
5909 | */ | |
5910 | #define MLXSW_REG_SBSR_ID 0xB005 | |
5911 | #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */ | |
5912 | #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */ | |
5913 | #define MLXSW_REG_SBSR_REC_MAX_COUNT 120 | |
5914 | #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \ | |
5915 | MLXSW_REG_SBSR_REC_LEN * \ | |
5916 | MLXSW_REG_SBSR_REC_MAX_COUNT) | |
5917 | ||
21978dcf | 5918 | MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN); |
26176def JP |
5919 | |
5920 | /* reg_sbsr_clr | |
5921 | * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy | |
5922 | * field is cleared (and a new max value is tracked from the time the clear | |
5923 | * was performed). | |
5924 | * Access: OP | |
5925 | */ | |
5926 | MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1); | |
5927 | ||
5928 | /* reg_sbsr_ingress_port_mask | |
5929 | * Bit vector for all ingress network ports. | |
5930 | * Indicates which of the ports (for which the relevant bit is set) | |
5931 | * are affected by the set operation. Configuration of any other port | |
5932 | * does not change. | |
5933 | * Access: Index | |
5934 | */ | |
5935 | MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1); | |
5936 | ||
5937 | /* reg_sbsr_pg_buff_mask | |
5938 | * Bit vector for all switch priority groups. | |
5939 | * Indicates which of the priorities (for which the relevant bit is set) | |
5940 | * are affected by the set operation. Configuration of any other priority | |
5941 | * does not change. | |
5942 | * Range is 0..cap_max_pg_buffers - 1 | |
5943 | * Access: Index | |
5944 | */ | |
5945 | MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1); | |
5946 | ||
5947 | /* reg_sbsr_egress_port_mask | |
5948 | * Bit vector for all egress network ports. | |
5949 | * Indicates which of the ports (for which the relevant bit is set) | |
5950 | * are affected by the set operation. Configuration of any other port | |
5951 | * does not change. | |
5952 | * Access: Index | |
5953 | */ | |
5954 | MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1); | |
5955 | ||
5956 | /* reg_sbsr_tclass_mask | |
5957 | * Bit vector for all traffic classes. | |
5958 | * Indicates which of the traffic classes (for which the relevant bit is | |
5959 | * set) are affected by the set operation. Configuration of any other | |
5960 | * traffic class does not change. | |
5961 | * Range is 0..cap_max_tclass - 1 | |
5962 | * Access: Index | |
5963 | */ | |
5964 | MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1); | |
5965 | ||
5966 | static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr) | |
5967 | { | |
5968 | MLXSW_REG_ZERO(sbsr, payload); | |
5969 | mlxsw_reg_sbsr_clr_set(payload, clr); | |
5970 | } | |
5971 | ||
5972 | /* reg_sbsr_rec_buff_occupancy | |
5973 | * Current buffer occupancy in cells. | |
5974 | * Access: RO | |
5975 | */ | |
5976 | MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN, | |
5977 | 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false); | |
5978 | ||
5979 | /* reg_sbsr_rec_max_buff_occupancy | |
5980 | * Maximum value of buffer occupancy in cells monitored. Cleared by | |
5981 | * writing to the clr field. | |
5982 | * Access: RO | |
5983 | */ | |
5984 | MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN, | |
5985 | 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false); | |
5986 | ||
5987 | static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index, | |
5988 | u32 *p_buff_occupancy, | |
5989 | u32 *p_max_buff_occupancy) | |
5990 | { | |
5991 | *p_buff_occupancy = | |
5992 | mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index); | |
5993 | *p_max_buff_occupancy = | |
5994 | mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index); | |
5995 | } | |
5996 | ||
51ae8cc6 YG |
5997 | /* SBIB - Shared Buffer Internal Buffer Register |
5998 | * --------------------------------------------- | |
5999 | * The SBIB register configures per port buffers for internal use. The internal | |
6000 | * buffers consume memory on the port buffers (note that the port buffers are | |
6001 | * used also by PBMC). | |
6002 | * | |
6003 | * For Spectrum this is used for egress mirroring. | |
6004 | */ | |
6005 | #define MLXSW_REG_SBIB_ID 0xB006 | |
6006 | #define MLXSW_REG_SBIB_LEN 0x10 | |
6007 | ||
21978dcf | 6008 | MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN); |
51ae8cc6 YG |
6009 | |
6010 | /* reg_sbib_local_port | |
6011 | * Local port number | |
6012 | * Not supported for CPU port and router port | |
6013 | * Access: Index | |
6014 | */ | |
6015 | MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8); | |
6016 | ||
6017 | /* reg_sbib_buff_size | |
6018 | * Units represented in cells | |
6019 | * Allowed range is 0 to (cap_max_headroom_size - 1) | |
6020 | * Default is 0 | |
6021 | * Access: RW | |
6022 | */ | |
6023 | MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24); | |
6024 | ||
6025 | static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port, | |
6026 | u32 buff_size) | |
6027 | { | |
6028 | MLXSW_REG_ZERO(sbib, payload); | |
6029 | mlxsw_reg_sbib_local_port_set(payload, local_port); | |
6030 | mlxsw_reg_sbib_buff_size_set(payload, buff_size); | |
6031 | } | |
6032 | ||
8e9658d5 JP |
6033 | static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { |
6034 | MLXSW_REG(sgcr), | |
6035 | MLXSW_REG(spad), | |
6036 | MLXSW_REG(smid), | |
6037 | MLXSW_REG(sspr), | |
6038 | MLXSW_REG(sfdat), | |
6039 | MLXSW_REG(sfd), | |
6040 | MLXSW_REG(sfn), | |
6041 | MLXSW_REG(spms), | |
6042 | MLXSW_REG(spvid), | |
6043 | MLXSW_REG(spvm), | |
6044 | MLXSW_REG(spaft), | |
6045 | MLXSW_REG(sfgc), | |
6046 | MLXSW_REG(sftr), | |
6047 | MLXSW_REG(sfdf), | |
6048 | MLXSW_REG(sldr), | |
6049 | MLXSW_REG(slcr), | |
6050 | MLXSW_REG(slcor), | |
6051 | MLXSW_REG(spmlr), | |
6052 | MLXSW_REG(svfa), | |
6053 | MLXSW_REG(svpe), | |
6054 | MLXSW_REG(sfmr), | |
6055 | MLXSW_REG(spvmlr), | |
af7170ee | 6056 | MLXSW_REG(ppbt), |
3279da4c | 6057 | MLXSW_REG(pacl), |
10fabef5 | 6058 | MLXSW_REG(pagt), |
d9c2661e | 6059 | MLXSW_REG(ptar), |
d120649d | 6060 | MLXSW_REG(ppbs), |
937b682c | 6061 | MLXSW_REG(prcr), |
e3426e12 | 6062 | MLXSW_REG(pefa), |
0171cdec | 6063 | MLXSW_REG(ptce2), |
76a4c7d3 | 6064 | MLXSW_REG(qpcr), |
8e9658d5 JP |
6065 | MLXSW_REG(qtct), |
6066 | MLXSW_REG(qeec), | |
6067 | MLXSW_REG(pmlp), | |
6068 | MLXSW_REG(pmtu), | |
6069 | MLXSW_REG(ptys), | |
6070 | MLXSW_REG(ppad), | |
6071 | MLXSW_REG(paos), | |
6072 | MLXSW_REG(pfcc), | |
6073 | MLXSW_REG(ppcnt), | |
7136793e | 6074 | MLXSW_REG(plib), |
8e9658d5 JP |
6075 | MLXSW_REG(pptb), |
6076 | MLXSW_REG(pbmc), | |
6077 | MLXSW_REG(pspa), | |
6078 | MLXSW_REG(htgt), | |
6079 | MLXSW_REG(hpkt), | |
6080 | MLXSW_REG(rgcr), | |
6081 | MLXSW_REG(ritr), | |
6082 | MLXSW_REG(ratr), | |
6083 | MLXSW_REG(ralta), | |
6084 | MLXSW_REG(ralst), | |
6085 | MLXSW_REG(raltb), | |
6086 | MLXSW_REG(ralue), | |
6087 | MLXSW_REG(rauht), | |
6088 | MLXSW_REG(raleu), | |
6089 | MLXSW_REG(rauhtd), | |
6090 | MLXSW_REG(mfcr), | |
6091 | MLXSW_REG(mfsc), | |
6092 | MLXSW_REG(mfsm), | |
55c63aaa | 6093 | MLXSW_REG(mfsl), |
8e9658d5 JP |
6094 | MLXSW_REG(mtcap), |
6095 | MLXSW_REG(mtmp), | |
6096 | MLXSW_REG(mpat), | |
6097 | MLXSW_REG(mpar), | |
6098 | MLXSW_REG(mlcr), | |
0677d682 | 6099 | MLXSW_REG(mpsc), |
5766532a | 6100 | MLXSW_REG(mgpc), |
8e9658d5 JP |
6101 | MLXSW_REG(sbpr), |
6102 | MLXSW_REG(sbcm), | |
6103 | MLXSW_REG(sbpm), | |
6104 | MLXSW_REG(sbmm), | |
6105 | MLXSW_REG(sbsr), | |
6106 | MLXSW_REG(sbib), | |
6107 | }; | |
6108 | ||
4ec14b76 IS |
6109 | static inline const char *mlxsw_reg_id_str(u16 reg_id) |
6110 | { | |
8e9658d5 JP |
6111 | const struct mlxsw_reg_info *reg_info; |
6112 | int i; | |
6113 | ||
6114 | for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) { | |
6115 | reg_info = mlxsw_reg_infos[i]; | |
6116 | if (reg_info->id == reg_id) | |
6117 | return reg_info->name; | |
4ec14b76 | 6118 | } |
8e9658d5 | 6119 | return "*UNKNOWN*"; |
4ec14b76 IS |
6120 | } |
6121 | ||
6122 | /* PUDE - Port Up / Down Event | |
6123 | * --------------------------- | |
6124 | * Reports the operational state change of a port. | |
6125 | */ | |
6126 | #define MLXSW_REG_PUDE_LEN 0x10 | |
6127 | ||
6128 | /* reg_pude_swid | |
6129 | * Switch partition ID with which to associate the port. | |
6130 | * Access: Index | |
6131 | */ | |
6132 | MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8); | |
6133 | ||
6134 | /* reg_pude_local_port | |
6135 | * Local port number. | |
6136 | * Access: Index | |
6137 | */ | |
6138 | MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8); | |
6139 | ||
6140 | /* reg_pude_admin_status | |
6141 | * Port administrative state (the desired state). | |
6142 | * 1 - Up. | |
6143 | * 2 - Down. | |
6144 | * 3 - Up once. This means that in case of link failure, the port won't go | |
6145 | * into polling mode, but will wait to be re-enabled by software. | |
6146 | * 4 - Disabled by system. Can only be set by hardware. | |
6147 | * Access: RO | |
6148 | */ | |
6149 | MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4); | |
6150 | ||
6151 | /* reg_pude_oper_status | |
6152 | * Port operatioanl state. | |
6153 | * 1 - Up. | |
6154 | * 2 - Down. | |
6155 | * 3 - Down by port failure. This means that the device will not let the | |
6156 | * port up again until explicitly specified by software. | |
6157 | * Access: RO | |
6158 | */ | |
6159 | MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4); | |
6160 | ||
6161 | #endif |