1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
7 #include <linux/kernel.h>
8 #include <linux/string.h>
9 #include <linux/bitops.h>
10 #include <linux/if_vlan.h>
15 struct mlxsw_reg_info {
21 #define MLXSW_REG_DEFINE(_name, _id, _len) \
22 static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
28 #define MLXSW_REG(type) (&mlxsw_reg_##type)
29 #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
30 #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
32 /* SGCR - Switch General Configuration Register
33 * --------------------------------------------
34 * This register is used for configuration of the switch capabilities.
36 #define MLXSW_REG_SGCR_ID 0x2000
37 #define MLXSW_REG_SGCR_LEN 0x10
39 MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
42 * Link Local Broadcast (Default=0)
43 * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
44 * packets and ignore the IGMP snooping entries.
47 MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
49 static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
51 MLXSW_REG_ZERO(sgcr, payload);
52 mlxsw_reg_sgcr_llb_set(payload, !!llb);
55 /* SPAD - Switch Physical Address Register
56 * ---------------------------------------
57 * The SPAD register configures the switch physical MAC address.
59 #define MLXSW_REG_SPAD_ID 0x2002
60 #define MLXSW_REG_SPAD_LEN 0x10
62 MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
65 * Base MAC address for the switch partitions.
66 * Per switch partition MAC address is equal to:
70 MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
72 /* SMID - Switch Multicast ID
73 * --------------------------
74 * The MID record maps from a MID (Multicast ID), which is a unique identifier
75 * of the multicast group within the stacking domain, into a list of local
76 * ports into which the packet is replicated.
78 #define MLXSW_REG_SMID_ID 0x2007
79 #define MLXSW_REG_SMID_LEN 0x240
81 MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
84 * Switch partition ID.
87 MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
90 * Multicast identifier - global identifier that represents the multicast group
94 MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
97 * Local port memebership (1 bit per port).
100 MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
102 /* reg_smid_port_mask
103 * Local port mask (1 bit per port).
106 MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
108 static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
111 MLXSW_REG_ZERO(smid, payload);
112 mlxsw_reg_smid_swid_set(payload, 0);
113 mlxsw_reg_smid_mid_set(payload, mid);
114 mlxsw_reg_smid_port_set(payload, port, set);
115 mlxsw_reg_smid_port_mask_set(payload, port, 1);
118 /* SSPR - Switch System Port Record Register
119 * -----------------------------------------
120 * Configures the system port to local port mapping.
122 #define MLXSW_REG_SSPR_ID 0x2008
123 #define MLXSW_REG_SSPR_LEN 0x8
125 MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
128 * Master - if set, then the record describes the master system port.
129 * This is needed in case a local port is mapped into several system ports
130 * (for multipathing). That number will be reported as the source system
131 * port when packets are forwarded to the CPU. Only one master port is allowed
134 * Note: Must be set for Spectrum.
137 MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
139 /* reg_sspr_local_port
144 MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
147 * Virtual port within the physical port.
148 * Should be set to 0 when virtual ports are not enabled on the port.
152 MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
154 /* reg_sspr_system_port
155 * Unique identifier within the stacking domain that represents all the ports
156 * that are available in the system (external ports).
158 * Currently, only single-ASIC configurations are supported, so we default to
159 * 1:1 mapping between system ports and local ports.
162 MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
164 static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
166 MLXSW_REG_ZERO(sspr, payload);
167 mlxsw_reg_sspr_m_set(payload, 1);
168 mlxsw_reg_sspr_local_port_set(payload, local_port);
169 mlxsw_reg_sspr_sub_port_set(payload, 0);
170 mlxsw_reg_sspr_system_port_set(payload, local_port);
173 /* SFDAT - Switch Filtering Database Aging Time
174 * --------------------------------------------
175 * Controls the Switch aging time. Aging time is able to be set per Switch
178 #define MLXSW_REG_SFDAT_ID 0x2009
179 #define MLXSW_REG_SFDAT_LEN 0x8
181 MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
184 * Switch partition ID.
187 MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
189 /* reg_sfdat_age_time
190 * Aging time in seconds
192 * Max - 1,000,000 seconds
193 * Default is 300 seconds.
196 MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
198 static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
200 MLXSW_REG_ZERO(sfdat, payload);
201 mlxsw_reg_sfdat_swid_set(payload, 0);
202 mlxsw_reg_sfdat_age_time_set(payload, age_time);
205 /* SFD - Switch Filtering Database
206 * -------------------------------
207 * The following register defines the access to the filtering database.
208 * The register supports querying, adding, removing and modifying the database.
209 * The access is optimized for bulk updates in which case more than one
210 * FDB record is present in the same command.
212 #define MLXSW_REG_SFD_ID 0x200A
213 #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
214 #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
215 #define MLXSW_REG_SFD_REC_MAX_COUNT 64
216 #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
217 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
219 MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
222 * Switch partition ID for queries. Reserved on Write.
225 MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
227 enum mlxsw_reg_sfd_op {
228 /* Dump entire FDB a (process according to record_locator) */
229 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
230 /* Query records by {MAC, VID/FID} value */
231 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
232 /* Query and clear activity. Query records by {MAC, VID/FID} value */
233 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
234 /* Test. Response indicates if each of the records could be
237 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
238 /* Add/modify. Aged-out records cannot be added. This command removes
239 * the learning notification of the {MAC, VID/FID}. Response includes
240 * the entries that were added to the FDB.
242 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
243 /* Remove record by {MAC, VID/FID}. This command also removes
244 * the learning notification and aged-out notifications
245 * of the {MAC, VID/FID}. The response provides current (pre-removal)
246 * entries as non-aged-out.
248 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
249 /* Remove learned notification by {MAC, VID/FID}. The response provides
250 * the removed learning notification.
252 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
259 MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
261 /* reg_sfd_record_locator
262 * Used for querying the FDB. Use record_locator=0 to initiate the
263 * query. When a record is returned, a new record_locator is
264 * returned to be used in the subsequent query.
265 * Reserved for database update.
268 MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
271 * Request: Number of records to read/add/modify/remove
272 * Response: Number of records read/added/replaced/removed
273 * See above description for more details.
277 MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
279 static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
282 MLXSW_REG_ZERO(sfd, payload);
283 mlxsw_reg_sfd_op_set(payload, op);
284 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
288 * Switch partition ID.
291 MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
292 MLXSW_REG_SFD_REC_LEN, 0x00, false);
294 enum mlxsw_reg_sfd_rec_type {
295 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
296 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
297 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
298 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC,
305 MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
306 MLXSW_REG_SFD_REC_LEN, 0x00, false);
308 enum mlxsw_reg_sfd_rec_policy {
309 /* Replacement disabled, aging disabled. */
310 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
311 /* (mlag remote): Replacement enabled, aging disabled,
312 * learning notification enabled on this port.
314 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
315 /* (ingress device): Replacement enabled, aging enabled. */
316 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
319 /* reg_sfd_rec_policy
323 MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
324 MLXSW_REG_SFD_REC_LEN, 0x00, false);
327 * Activity. Set for new static entries. Set for static entries if a frame SMAC
328 * lookup hits on the entry.
329 * To clear the a bit, use "query and clear activity" op.
332 MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
333 MLXSW_REG_SFD_REC_LEN, 0x00, false);
339 MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
340 MLXSW_REG_SFD_REC_LEN, 0x02);
342 enum mlxsw_reg_sfd_rec_action {
344 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
345 /* forward and trap, trap_id is FDB_TRAP */
346 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
347 /* trap and do not forward, trap_id is FDB_TRAP */
348 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
349 /* forward to IP router */
350 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
351 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
354 /* reg_sfd_rec_action
355 * Action to apply on the packet.
356 * Note: Dynamic entries can only be configured with NOP action.
359 MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
360 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
362 /* reg_sfd_uc_sub_port
363 * VEPA channel on local port.
364 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
365 * VEPA is not enabled.
368 MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
369 MLXSW_REG_SFD_REC_LEN, 0x08, false);
371 /* reg_sfd_uc_fid_vid
372 * Filtering ID or VLAN ID
373 * For SwitchX and SwitchX-2:
374 * - Dynamic entries (policy 2,3) use FID
375 * - Static entries (policy 0) use VID
376 * - When independent learning is configured, VID=FID
377 * For Spectrum: use FID for both Dynamic and Static entries.
378 * VID should not be used.
381 MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
382 MLXSW_REG_SFD_REC_LEN, 0x08, false);
384 /* reg_sfd_uc_system_port
385 * Unique port identifier for the final destination of the packet.
388 MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
389 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
391 static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
392 enum mlxsw_reg_sfd_rec_type rec_type,
394 enum mlxsw_reg_sfd_rec_action action)
396 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
398 if (rec_index >= num_rec)
399 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
400 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
401 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
402 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
403 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
406 static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
407 enum mlxsw_reg_sfd_rec_policy policy,
408 const char *mac, u16 fid_vid,
409 enum mlxsw_reg_sfd_rec_action action,
412 mlxsw_reg_sfd_rec_pack(payload, rec_index,
413 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
414 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
415 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
416 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
417 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
420 static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
421 char *mac, u16 *p_fid_vid,
424 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
425 *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
426 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
429 /* reg_sfd_uc_lag_sub_port
431 * Must be 0 if multichannel VEPA is not enabled.
434 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
435 MLXSW_REG_SFD_REC_LEN, 0x08, false);
437 /* reg_sfd_uc_lag_fid_vid
438 * Filtering ID or VLAN ID
439 * For SwitchX and SwitchX-2:
440 * - Dynamic entries (policy 2,3) use FID
441 * - Static entries (policy 0) use VID
442 * - When independent learning is configured, VID=FID
443 * For Spectrum: use FID for both Dynamic and Static entries.
444 * VID should not be used.
447 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
448 MLXSW_REG_SFD_REC_LEN, 0x08, false);
450 /* reg_sfd_uc_lag_lag_vid
451 * Indicates VID in case of vFIDs. Reserved for FIDs.
454 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
455 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
457 /* reg_sfd_uc_lag_lag_id
458 * LAG Identifier - pointer into the LAG descriptor table.
461 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
462 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
465 mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
466 enum mlxsw_reg_sfd_rec_policy policy,
467 const char *mac, u16 fid_vid,
468 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
471 mlxsw_reg_sfd_rec_pack(payload, rec_index,
472 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
474 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
475 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
476 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
477 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
478 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
481 static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
482 char *mac, u16 *p_vid,
485 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
486 *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
487 *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
492 * Multicast port group index - index into the port group table.
493 * Value 0x1FFF indicates the pgi should point to the MID entry.
494 * For Spectrum this value must be set to 0x1FFF
497 MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
498 MLXSW_REG_SFD_REC_LEN, 0x08, false);
500 /* reg_sfd_mc_fid_vid
502 * Filtering ID or VLAN ID
505 MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
506 MLXSW_REG_SFD_REC_LEN, 0x08, false);
510 * Multicast identifier - global identifier that represents the multicast
511 * group across all devices.
514 MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
515 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
518 mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
519 const char *mac, u16 fid_vid,
520 enum mlxsw_reg_sfd_rec_action action, u16 mid)
522 mlxsw_reg_sfd_rec_pack(payload, rec_index,
523 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
524 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
525 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
526 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
529 /* reg_sfd_uc_tunnel_uip_msb
530 * When protocol is IPv4, the most significant byte of the underlay IPv4
532 * When protocol is IPv6, reserved.
535 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24,
536 8, MLXSW_REG_SFD_REC_LEN, 0x08, false);
538 /* reg_sfd_uc_tunnel_fid
542 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
543 MLXSW_REG_SFD_REC_LEN, 0x08, false);
545 enum mlxsw_reg_sfd_uc_tunnel_protocol {
546 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4,
547 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6,
550 /* reg_sfd_uc_tunnel_protocol
554 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27,
555 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
557 /* reg_sfd_uc_tunnel_uip_lsb
558 * When protocol is IPv4, the least significant bytes of the underlay
559 * IPv4 destination IP.
560 * When protocol is IPv6, pointer to the underlay IPv6 destination IP
561 * which is configured by RIPS.
564 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0,
565 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
568 mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
569 enum mlxsw_reg_sfd_rec_policy policy,
570 const char *mac, u16 fid,
571 enum mlxsw_reg_sfd_rec_action action, u32 uip,
572 enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
574 mlxsw_reg_sfd_rec_pack(payload, rec_index,
575 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
577 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
578 mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
579 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
580 mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
581 mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
584 /* SFN - Switch FDB Notification Register
585 * -------------------------------------------
586 * The switch provides notifications on newly learned FDB entries and
587 * aged out entries. The notifications can be polled by software.
589 #define MLXSW_REG_SFN_ID 0x200B
590 #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
591 #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
592 #define MLXSW_REG_SFN_REC_MAX_COUNT 64
593 #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
594 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
596 MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
599 * Switch partition ID.
602 MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
605 * Forces the current session to end.
608 MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
611 * Request: Number of learned notifications and aged-out notification
613 * Response: Number of notification records returned (must be smaller
614 * than or equal to the value requested)
618 MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
620 static inline void mlxsw_reg_sfn_pack(char *payload)
622 MLXSW_REG_ZERO(sfn, payload);
623 mlxsw_reg_sfn_swid_set(payload, 0);
624 mlxsw_reg_sfn_end_set(payload, 1);
625 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
629 * Switch partition ID.
632 MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
633 MLXSW_REG_SFN_REC_LEN, 0x00, false);
635 enum mlxsw_reg_sfn_rec_type {
636 /* MAC addresses learned on a regular port. */
637 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
638 /* MAC addresses learned on a LAG port. */
639 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
640 /* Aged-out MAC address on a regular port. */
641 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
642 /* Aged-out MAC address on a LAG port. */
643 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
644 /* Learned unicast tunnel record. */
645 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
646 /* Aged-out unicast tunnel record. */
647 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
651 * Notification record type.
654 MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
655 MLXSW_REG_SFN_REC_LEN, 0x00, false);
661 MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
662 MLXSW_REG_SFN_REC_LEN, 0x02);
664 /* reg_sfn_mac_sub_port
665 * VEPA channel on the local port.
666 * 0 if multichannel VEPA is not enabled.
669 MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
670 MLXSW_REG_SFN_REC_LEN, 0x08, false);
673 * Filtering identifier.
676 MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
677 MLXSW_REG_SFN_REC_LEN, 0x08, false);
679 /* reg_sfn_mac_system_port
680 * Unique port identifier for the final destination of the packet.
683 MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
684 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
686 static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
687 char *mac, u16 *p_vid,
690 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
691 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
692 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
695 /* reg_sfn_mac_lag_lag_id
696 * LAG ID (pointer into the LAG descriptor table).
699 MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
700 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
702 static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
703 char *mac, u16 *p_vid,
706 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
707 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
708 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
711 /* reg_sfn_uc_tunnel_uip_msb
712 * When protocol is IPv4, the most significant byte of the underlay IPv4
713 * address of the remote VTEP.
714 * When protocol is IPv6, reserved.
717 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
718 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
720 enum mlxsw_reg_sfn_uc_tunnel_protocol {
721 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
722 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
725 /* reg_sfn_uc_tunnel_protocol
729 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
730 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
732 /* reg_sfn_uc_tunnel_uip_lsb
733 * When protocol is IPv4, the least significant bytes of the underlay
734 * IPv4 address of the remote VTEP.
735 * When protocol is IPv6, ipv6_id to be queried from TNIPSD.
738 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
739 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
741 enum mlxsw_reg_sfn_tunnel_port {
742 MLXSW_REG_SFN_TUNNEL_PORT_NVE,
743 MLXSW_REG_SFN_TUNNEL_PORT_VPLS,
744 MLXSW_REG_SFN_TUNNEL_FLEX_TUNNEL0,
745 MLXSW_REG_SFN_TUNNEL_FLEX_TUNNEL1,
748 /* reg_sfn_uc_tunnel_port
750 * Reserved on Spectrum.
753 MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4,
754 MLXSW_REG_SFN_REC_LEN, 0x10, false);
757 mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac,
758 u16 *p_fid, u32 *p_uip,
759 enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto)
761 u32 uip_msb, uip_lsb;
763 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
764 *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
765 uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index);
766 uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index);
767 *p_uip = uip_msb << 24 | uip_lsb;
768 *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index);
771 /* SPMS - Switch Port MSTP/RSTP State Register
772 * -------------------------------------------
773 * Configures the spanning tree state of a physical port.
775 #define MLXSW_REG_SPMS_ID 0x200D
776 #define MLXSW_REG_SPMS_LEN 0x404
778 MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
780 /* reg_spms_local_port
784 MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
786 enum mlxsw_reg_spms_state {
787 MLXSW_REG_SPMS_STATE_NO_CHANGE,
788 MLXSW_REG_SPMS_STATE_DISCARDING,
789 MLXSW_REG_SPMS_STATE_LEARNING,
790 MLXSW_REG_SPMS_STATE_FORWARDING,
794 * Spanning tree state of each VLAN ID (VID) of the local port.
795 * 0 - Do not change spanning tree state (used only when writing).
796 * 1 - Discarding. No learning or forwarding to/from this port (default).
797 * 2 - Learning. Port is learning, but not forwarding.
798 * 3 - Forwarding. Port is learning and forwarding.
801 MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
803 static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
805 MLXSW_REG_ZERO(spms, payload);
806 mlxsw_reg_spms_local_port_set(payload, local_port);
809 static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
810 enum mlxsw_reg_spms_state state)
812 mlxsw_reg_spms_state_set(payload, vid, state);
815 /* SPVID - Switch Port VID
816 * -----------------------
817 * The switch port VID configures the default VID for a port.
819 #define MLXSW_REG_SPVID_ID 0x200E
820 #define MLXSW_REG_SPVID_LEN 0x08
822 MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
824 /* reg_spvid_local_port
828 MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
830 /* reg_spvid_sub_port
831 * Virtual port within the physical port.
832 * Should be set to 0 when virtual ports are not enabled on the port.
835 MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
841 MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
843 static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
845 MLXSW_REG_ZERO(spvid, payload);
846 mlxsw_reg_spvid_local_port_set(payload, local_port);
847 mlxsw_reg_spvid_pvid_set(payload, pvid);
850 /* SPVM - Switch Port VLAN Membership
851 * ----------------------------------
852 * The Switch Port VLAN Membership register configures the VLAN membership
853 * of a port in a VLAN denoted by VID. VLAN membership is managed per
854 * virtual port. The register can be used to add and remove VID(s) from a port.
856 #define MLXSW_REG_SPVM_ID 0x200F
857 #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
858 #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
859 #define MLXSW_REG_SPVM_REC_MAX_COUNT 255
860 #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
861 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
863 MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
866 * Priority tagged. If this bit is set, packets forwarded to the port with
867 * untagged VLAN membership (u bit is set) will be tagged with priority tag
871 MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
874 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
875 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
878 MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
880 /* reg_spvm_local_port
884 MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
887 * Virtual port within the physical port.
888 * Should be set to 0 when virtual ports are not enabled on the port.
891 MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
894 * Number of records to update. Each record contains: i, e, u, vid.
897 MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
900 * Ingress membership in VLAN ID.
903 MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
904 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
905 MLXSW_REG_SPVM_REC_LEN, 0, false);
908 * Egress membership in VLAN ID.
911 MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
912 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
913 MLXSW_REG_SPVM_REC_LEN, 0, false);
916 * Untagged - port is an untagged member - egress transmission uses untagged
920 MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
921 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
922 MLXSW_REG_SPVM_REC_LEN, 0, false);
925 * Egress membership in VLAN ID.
928 MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
929 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
930 MLXSW_REG_SPVM_REC_LEN, 0, false);
932 static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
933 u16 vid_begin, u16 vid_end,
934 bool is_member, bool untagged)
936 int size = vid_end - vid_begin + 1;
939 MLXSW_REG_ZERO(spvm, payload);
940 mlxsw_reg_spvm_local_port_set(payload, local_port);
941 mlxsw_reg_spvm_num_rec_set(payload, size);
943 for (i = 0; i < size; i++) {
944 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
945 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
946 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
947 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
951 /* SPAFT - Switch Port Acceptable Frame Types
952 * ------------------------------------------
953 * The Switch Port Acceptable Frame Types register configures the frame
954 * admittance of the port.
956 #define MLXSW_REG_SPAFT_ID 0x2010
957 #define MLXSW_REG_SPAFT_LEN 0x08
959 MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
961 /* reg_spaft_local_port
965 * Note: CPU port is not supported (all tag types are allowed).
967 MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
969 /* reg_spaft_sub_port
970 * Virtual port within the physical port.
971 * Should be set to 0 when virtual ports are not enabled on the port.
974 MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
976 /* reg_spaft_allow_untagged
977 * When set, untagged frames on the ingress are allowed (default).
980 MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
982 /* reg_spaft_allow_prio_tagged
983 * When set, priority tagged frames on the ingress are allowed (default).
986 MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
988 /* reg_spaft_allow_tagged
989 * When set, tagged frames on the ingress are allowed (default).
992 MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
994 static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
997 MLXSW_REG_ZERO(spaft, payload);
998 mlxsw_reg_spaft_local_port_set(payload, local_port);
999 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
1000 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
1001 mlxsw_reg_spaft_allow_tagged_set(payload, true);
1004 /* SFGC - Switch Flooding Group Configuration
1005 * ------------------------------------------
1006 * The following register controls the association of flooding tables and MIDs
1007 * to packet types used for flooding.
1009 #define MLXSW_REG_SFGC_ID 0x2011
1010 #define MLXSW_REG_SFGC_LEN 0x10
1012 MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
1014 enum mlxsw_reg_sfgc_type {
1015 MLXSW_REG_SFGC_TYPE_BROADCAST,
1016 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
1017 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
1018 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
1019 MLXSW_REG_SFGC_TYPE_RESERVED,
1020 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
1021 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
1022 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
1023 MLXSW_REG_SFGC_TYPE_MAX,
1027 * The traffic type to reach the flooding table.
1030 MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
1032 enum mlxsw_reg_sfgc_bridge_type {
1033 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
1034 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
1037 /* reg_sfgc_bridge_type
1040 * Note: SwitchX-2 only supports 802.1Q mode.
1042 MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
1044 enum mlxsw_flood_table_type {
1045 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
1046 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
1047 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
1048 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
1049 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
1052 /* reg_sfgc_table_type
1053 * See mlxsw_flood_table_type
1056 * Note: FID offset and FID types are not supported in SwitchX-2.
1058 MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
1060 /* reg_sfgc_flood_table
1061 * Flooding table index to associate with the specific type on the specific
1065 MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
1068 * The multicast ID for the swid. Not supported for Spectrum
1071 MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
1073 /* reg_sfgc_counter_set_type
1074 * Counter Set Type for flow counters.
1077 MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
1079 /* reg_sfgc_counter_index
1080 * Counter Index for flow counters.
1083 MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
1086 mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1087 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1088 enum mlxsw_flood_table_type table_type,
1089 unsigned int flood_table)
1091 MLXSW_REG_ZERO(sfgc, payload);
1092 mlxsw_reg_sfgc_type_set(payload, type);
1093 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1094 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1095 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1096 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1099 /* SFTR - Switch Flooding Table Register
1100 * -------------------------------------
1101 * The switch flooding table is used for flooding packet replication. The table
1102 * defines a bit mask of ports for packet replication.
1104 #define MLXSW_REG_SFTR_ID 0x2012
1105 #define MLXSW_REG_SFTR_LEN 0x420
1107 MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
1110 * Switch partition ID with which to associate the port.
1113 MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
1115 /* reg_sftr_flood_table
1116 * Flooding table index to associate with the specific type on the specific
1120 MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1123 * Index. Used as an index into the Flooding Table in case the table is
1124 * configured to use VID / FID or FID Offset.
1127 MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1129 /* reg_sftr_table_type
1130 * See mlxsw_flood_table_type
1133 MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1136 * Range of entries to update
1139 MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1142 * Local port membership (1 bit per port).
1145 MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1147 /* reg_sftr_cpu_port_mask
1148 * CPU port mask (1 bit per port).
1151 MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1153 static inline void mlxsw_reg_sftr_pack(char *payload,
1154 unsigned int flood_table,
1156 enum mlxsw_flood_table_type table_type,
1157 unsigned int range, u8 port, bool set)
1159 MLXSW_REG_ZERO(sftr, payload);
1160 mlxsw_reg_sftr_swid_set(payload, 0);
1161 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1162 mlxsw_reg_sftr_index_set(payload, index);
1163 mlxsw_reg_sftr_table_type_set(payload, table_type);
1164 mlxsw_reg_sftr_range_set(payload, range);
1165 mlxsw_reg_sftr_port_set(payload, port, set);
1166 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
1169 /* SFDF - Switch Filtering DB Flush
1170 * --------------------------------
1171 * The switch filtering DB flush register is used to flush the FDB.
1172 * Note that FDB notifications are flushed as well.
1174 #define MLXSW_REG_SFDF_ID 0x2013
1175 #define MLXSW_REG_SFDF_LEN 0x14
1177 MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
1180 * Switch partition ID.
1183 MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1185 enum mlxsw_reg_sfdf_flush_type {
1186 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1187 MLXSW_REG_SFDF_FLUSH_PER_FID,
1188 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1189 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1190 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1191 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1192 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1193 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
1196 /* reg_sfdf_flush_type
1198 * 0 - All SWID dynamic entries are flushed.
1199 * 1 - All FID dynamic entries are flushed.
1200 * 2 - All dynamic entries pointing to port are flushed.
1201 * 3 - All FID dynamic entries pointing to port are flushed.
1202 * 4 - All dynamic entries pointing to LAG are flushed.
1203 * 5 - All FID dynamic entries pointing to LAG are flushed.
1204 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1206 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1210 MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1212 /* reg_sfdf_flush_static
1214 * 0 - Flush only dynamic entries.
1215 * 1 - Flush both dynamic and static entries.
1218 MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1220 static inline void mlxsw_reg_sfdf_pack(char *payload,
1221 enum mlxsw_reg_sfdf_flush_type type)
1223 MLXSW_REG_ZERO(sfdf, payload);
1224 mlxsw_reg_sfdf_flush_type_set(payload, type);
1225 mlxsw_reg_sfdf_flush_static_set(payload, true);
1232 MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1234 /* reg_sfdf_system_port
1238 MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1240 /* reg_sfdf_port_fid_system_port
1241 * Port to flush, pointed to by FID.
1244 MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1250 MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1252 /* reg_sfdf_lag_fid_lag_id
1253 * LAG ID to flush, pointed to by FID.
1256 MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1258 /* SLDR - Switch LAG Descriptor Register
1259 * -----------------------------------------
1260 * The switch LAG descriptor register is populated by LAG descriptors.
1261 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1264 #define MLXSW_REG_SLDR_ID 0x2014
1265 #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1267 MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
1269 enum mlxsw_reg_sldr_op {
1270 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1271 MLXSW_REG_SLDR_OP_LAG_CREATE,
1272 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1273 /* Ports that appear in the list have the Distributor enabled */
1274 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1275 /* Removes ports from the disributor list */
1276 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1283 MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1286 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1289 MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1291 static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1293 MLXSW_REG_ZERO(sldr, payload);
1294 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1295 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1298 static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1300 MLXSW_REG_ZERO(sldr, payload);
1301 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1302 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1305 /* reg_sldr_num_ports
1306 * The number of member ports of the LAG.
1307 * Reserved for Create / Destroy operations
1308 * For Add / Remove operations - indicates the number of ports in the list.
1311 MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1313 /* reg_sldr_system_port
1317 MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1319 static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1322 MLXSW_REG_ZERO(sldr, payload);
1323 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1324 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1325 mlxsw_reg_sldr_num_ports_set(payload, 1);
1326 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1329 static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1332 MLXSW_REG_ZERO(sldr, payload);
1333 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1334 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1335 mlxsw_reg_sldr_num_ports_set(payload, 1);
1336 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1339 /* SLCR - Switch LAG Configuration 2 Register
1340 * -------------------------------------------
1341 * The Switch LAG Configuration register is used for configuring the
1342 * LAG properties of the switch.
1344 #define MLXSW_REG_SLCR_ID 0x2015
1345 #define MLXSW_REG_SLCR_LEN 0x10
1347 MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
1349 enum mlxsw_reg_slcr_pp {
1350 /* Global Configuration (for all ports) */
1351 MLXSW_REG_SLCR_PP_GLOBAL,
1352 /* Per port configuration, based on local_port field */
1353 MLXSW_REG_SLCR_PP_PER_PORT,
1357 * Per Port Configuration
1358 * Note: Reading at Global mode results in reading port 1 configuration.
1361 MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1363 /* reg_slcr_local_port
1365 * Supported from CPU port
1366 * Not supported from router port
1367 * Reserved when pp = Global Configuration
1370 MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1372 enum mlxsw_reg_slcr_type {
1373 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1374 MLXSW_REG_SLCR_TYPE_XOR,
1375 MLXSW_REG_SLCR_TYPE_RANDOM,
1382 MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1385 #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1386 /* SMAC - for IPv4 and IPv6 packets */
1387 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1388 /* SMAC - for non-IP packets */
1389 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1390 #define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1391 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1392 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1393 /* DMAC - for IPv4 and IPv6 packets */
1394 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1395 /* DMAC - for non-IP packets */
1396 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1397 #define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1398 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1399 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1400 /* Ethertype - for IPv4 and IPv6 packets */
1401 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1402 /* Ethertype - for non-IP packets */
1403 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1404 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1405 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1406 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1407 /* VLAN ID - for IPv4 and IPv6 packets */
1408 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1409 /* VLAN ID - for non-IP packets */
1410 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1411 #define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1412 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1413 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1414 /* Source IP address (can be IPv4 or IPv6) */
1415 #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1416 /* Destination IP address (can be IPv4 or IPv6) */
1417 #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1418 /* TCP/UDP source port */
1419 #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1420 /* TCP/UDP destination port*/
1421 #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1422 /* IPv4 Protocol/IPv6 Next Header */
1423 #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1424 /* IPv6 Flow label */
1425 #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1426 /* SID - FCoE source ID */
1427 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1428 /* DID - FCoE destination ID */
1429 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1430 /* OXID - FCoE originator exchange ID */
1431 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1432 /* Destination QP number - for RoCE packets */
1433 #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1435 /* reg_slcr_lag_hash
1436 * LAG hashing configuration. This is a bitmask, in which each set
1437 * bit includes the corresponding item in the LAG hash calculation.
1438 * The default lag_hash contains SMAC, DMAC, VLANID and
1439 * Ethertype (for all packet types).
1442 MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1445 * LAG seed value. The seed is the same for all ports.
1448 MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1450 static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
1452 MLXSW_REG_ZERO(slcr, payload);
1453 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
1454 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
1455 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1456 mlxsw_reg_slcr_seed_set(payload, seed);
1459 /* SLCOR - Switch LAG Collector Register
1460 * -------------------------------------
1461 * The Switch LAG Collector register controls the Local Port membership
1462 * in a LAG and enablement of the collector.
1464 #define MLXSW_REG_SLCOR_ID 0x2016
1465 #define MLXSW_REG_SLCOR_LEN 0x10
1467 MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
1469 enum mlxsw_reg_slcor_col {
1470 /* Port is added with collector disabled */
1471 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1472 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1473 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1474 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1478 * Collector configuration
1481 MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1483 /* reg_slcor_local_port
1485 * Not supported for CPU port
1488 MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1491 * LAG Identifier. Index into the LAG descriptor table.
1494 MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1496 /* reg_slcor_port_index
1497 * Port index in the LAG list. Only valid on Add Port to LAG col.
1498 * Valid range is from 0 to cap_max_lag_members-1
1501 MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1503 static inline void mlxsw_reg_slcor_pack(char *payload,
1504 u8 local_port, u16 lag_id,
1505 enum mlxsw_reg_slcor_col col)
1507 MLXSW_REG_ZERO(slcor, payload);
1508 mlxsw_reg_slcor_col_set(payload, col);
1509 mlxsw_reg_slcor_local_port_set(payload, local_port);
1510 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1513 static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1514 u8 local_port, u16 lag_id,
1517 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1518 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1519 mlxsw_reg_slcor_port_index_set(payload, port_index);
1522 static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1523 u8 local_port, u16 lag_id)
1525 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1526 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1529 static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1530 u8 local_port, u16 lag_id)
1532 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1533 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1536 static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1537 u8 local_port, u16 lag_id)
1539 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1540 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1543 /* SPMLR - Switch Port MAC Learning Register
1544 * -----------------------------------------
1545 * Controls the Switch MAC learning policy per port.
1547 #define MLXSW_REG_SPMLR_ID 0x2018
1548 #define MLXSW_REG_SPMLR_LEN 0x8
1550 MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
1552 /* reg_spmlr_local_port
1553 * Local port number.
1556 MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1558 /* reg_spmlr_sub_port
1559 * Virtual port within the physical port.
1560 * Should be set to 0 when virtual ports are not enabled on the port.
1563 MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1565 enum mlxsw_reg_spmlr_learn_mode {
1566 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1567 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1568 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1571 /* reg_spmlr_learn_mode
1572 * Learning mode on the port.
1573 * 0 - Learning disabled.
1574 * 2 - Learning enabled.
1575 * 3 - Security mode.
1577 * In security mode the switch does not learn MACs on the port, but uses the
1578 * SMAC to see if it exists on another ingress port. If so, the packet is
1579 * classified as a bad packet and is discarded unless the software registers
1580 * to receive port security error packets usign HPKT.
1582 MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1584 static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1585 enum mlxsw_reg_spmlr_learn_mode mode)
1587 MLXSW_REG_ZERO(spmlr, payload);
1588 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1589 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1590 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1593 /* SVFA - Switch VID to FID Allocation Register
1594 * --------------------------------------------
1595 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1596 * virtualized ports.
1598 #define MLXSW_REG_SVFA_ID 0x201C
1599 #define MLXSW_REG_SVFA_LEN 0x10
1601 MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
1604 * Switch partition ID.
1607 MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1609 /* reg_svfa_local_port
1610 * Local port number.
1613 * Note: Reserved for 802.1Q FIDs.
1615 MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1617 enum mlxsw_reg_svfa_mt {
1618 MLXSW_REG_SVFA_MT_VID_TO_FID,
1619 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1622 /* reg_svfa_mapping_table
1625 * 1 - {Port, VID} to FID
1628 * Note: Reserved for SwitchX-2.
1630 MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1637 * Note: Reserved for SwitchX-2.
1639 MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1645 MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1651 MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1653 /* reg_svfa_counter_set_type
1654 * Counter set type for flow counters.
1657 * Note: Reserved for SwitchX-2.
1659 MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1661 /* reg_svfa_counter_index
1662 * Counter index for flow counters.
1665 * Note: Reserved for SwitchX-2.
1667 MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1669 static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1670 enum mlxsw_reg_svfa_mt mt, bool valid,
1673 MLXSW_REG_ZERO(svfa, payload);
1674 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1675 mlxsw_reg_svfa_swid_set(payload, 0);
1676 mlxsw_reg_svfa_local_port_set(payload, local_port);
1677 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1678 mlxsw_reg_svfa_v_set(payload, valid);
1679 mlxsw_reg_svfa_fid_set(payload, fid);
1680 mlxsw_reg_svfa_vid_set(payload, vid);
1683 /* SVPE - Switch Virtual-Port Enabling Register
1684 * --------------------------------------------
1685 * Enables port virtualization.
1687 #define MLXSW_REG_SVPE_ID 0x201E
1688 #define MLXSW_REG_SVPE_LEN 0x4
1690 MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
1692 /* reg_svpe_local_port
1696 * Note: CPU port is not supported (uses VLAN mode only).
1698 MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1701 * Virtual port enable.
1702 * 0 - Disable, VLAN mode (VID to FID).
1703 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1706 MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1708 static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1711 MLXSW_REG_ZERO(svpe, payload);
1712 mlxsw_reg_svpe_local_port_set(payload, local_port);
1713 mlxsw_reg_svpe_vp_en_set(payload, enable);
1716 /* SFMR - Switch FID Management Register
1717 * -------------------------------------
1718 * Creates and configures FIDs.
1720 #define MLXSW_REG_SFMR_ID 0x201F
1721 #define MLXSW_REG_SFMR_LEN 0x18
1723 MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
1725 enum mlxsw_reg_sfmr_op {
1726 MLXSW_REG_SFMR_OP_CREATE_FID,
1727 MLXSW_REG_SFMR_OP_DESTROY_FID,
1732 * 0 - Create or edit FID.
1736 MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1742 MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1744 /* reg_sfmr_fid_offset
1746 * Used to point into the flooding table selected by SFGC register if
1747 * the table is of type FID-Offset. Otherwise, this field is reserved.
1750 MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1753 * Valid Tunnel Flood Pointer.
1754 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1757 * Note: Reserved for 802.1Q FIDs.
1759 MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1761 /* reg_sfmr_nve_tunnel_flood_ptr
1762 * Underlay Flooding and BC Pointer.
1763 * Used as a pointer to the first entry of the group based link lists of
1764 * flooding or BC entries (for NVE tunnels).
1767 MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1771 * If not set, then vni is reserved.
1774 * Note: Reserved for 802.1Q FIDs.
1776 MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1779 * Virtual Network Identifier.
1782 * Note: A given VNI can only be assigned to one FID.
1784 MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1786 static inline void mlxsw_reg_sfmr_pack(char *payload,
1787 enum mlxsw_reg_sfmr_op op, u16 fid,
1790 MLXSW_REG_ZERO(sfmr, payload);
1791 mlxsw_reg_sfmr_op_set(payload, op);
1792 mlxsw_reg_sfmr_fid_set(payload, fid);
1793 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1794 mlxsw_reg_sfmr_vtfp_set(payload, false);
1795 mlxsw_reg_sfmr_vv_set(payload, false);
1798 /* SPVMLR - Switch Port VLAN MAC Learning Register
1799 * -----------------------------------------------
1800 * Controls the switch MAC learning policy per {Port, VID}.
1802 #define MLXSW_REG_SPVMLR_ID 0x2020
1803 #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1804 #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
1805 #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
1806 #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1807 MLXSW_REG_SPVMLR_REC_LEN * \
1808 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1810 MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
1812 /* reg_spvmlr_local_port
1813 * Local ingress port.
1816 * Note: CPU port is not supported.
1818 MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1820 /* reg_spvmlr_num_rec
1821 * Number of records to update.
1824 MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1826 /* reg_spvmlr_rec_learn_enable
1827 * 0 - Disable learning for {Port, VID}.
1828 * 1 - Enable learning for {Port, VID}.
1831 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1832 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1834 /* reg_spvmlr_rec_vid
1835 * VLAN ID to be added/removed from port or for querying.
1838 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1839 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1841 static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1842 u16 vid_begin, u16 vid_end,
1845 int num_rec = vid_end - vid_begin + 1;
1848 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1850 MLXSW_REG_ZERO(spvmlr, payload);
1851 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1852 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1854 for (i = 0; i < num_rec; i++) {
1855 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1856 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1860 /* CWTP - Congetion WRED ECN TClass Profile
1861 * ----------------------------------------
1862 * Configures the profiles for queues of egress port and traffic class
1864 #define MLXSW_REG_CWTP_ID 0x2802
1865 #define MLXSW_REG_CWTP_BASE_LEN 0x28
1866 #define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
1867 #define MLXSW_REG_CWTP_LEN 0x40
1869 MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
1871 /* reg_cwtp_local_port
1873 * Not supported for CPU port
1876 MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
1878 /* reg_cwtp_traffic_class
1879 * Traffic Class to configure
1882 MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
1884 /* reg_cwtp_profile_min
1885 * Minimum Average Queue Size of the profile in cells.
1888 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
1889 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
1891 /* reg_cwtp_profile_percent
1892 * Percentage of WRED and ECN marking for maximum Average Queue size
1893 * Range is 0 to 100, units of integer percentage
1896 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
1897 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1899 /* reg_cwtp_profile_max
1900 * Maximum Average Queue size of the profile in cells
1903 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
1904 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1906 #define MLXSW_REG_CWTP_MIN_VALUE 64
1907 #define MLXSW_REG_CWTP_MAX_PROFILE 2
1908 #define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
1910 static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
1915 MLXSW_REG_ZERO(cwtp, payload);
1916 mlxsw_reg_cwtp_local_port_set(payload, local_port);
1917 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
1919 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
1920 mlxsw_reg_cwtp_profile_min_set(payload, i,
1921 MLXSW_REG_CWTP_MIN_VALUE);
1922 mlxsw_reg_cwtp_profile_max_set(payload, i,
1923 MLXSW_REG_CWTP_MIN_VALUE);
1927 #define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
1930 mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
1933 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
1935 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
1936 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
1937 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
1940 /* CWTPM - Congestion WRED ECN TClass and Pool Mapping
1941 * ---------------------------------------------------
1942 * The CWTPM register maps each egress port and traffic class to profile num.
1944 #define MLXSW_REG_CWTPM_ID 0x2803
1945 #define MLXSW_REG_CWTPM_LEN 0x44
1947 MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
1949 /* reg_cwtpm_local_port
1951 * Not supported for CPU port
1954 MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
1956 /* reg_cwtpm_traffic_class
1957 * Traffic Class to configure
1960 MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
1963 * Control enablement of WRED for traffic class:
1968 MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
1971 * Control enablement of ECN for traffic class:
1976 MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
1979 * TCP Green Profile.
1980 * Index of the profile within {port, traffic class} to use.
1981 * 0 for disabling both WRED and ECN for this type of traffic.
1984 MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
1987 * TCP Yellow Profile.
1988 * Index of the profile within {port, traffic class} to use.
1989 * 0 for disabling both WRED and ECN for this type of traffic.
1992 MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
1996 * Index of the profile within {port, traffic class} to use.
1997 * 0 for disabling both WRED and ECN for this type of traffic.
2000 MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
2003 * Non-TCP Green Profile.
2004 * Index of the profile within {port, traffic class} to use.
2005 * 0 for disabling both WRED and ECN for this type of traffic.
2008 MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
2011 * Non-TCP Yellow Profile.
2012 * Index of the profile within {port, traffic class} to use.
2013 * 0 for disabling both WRED and ECN for this type of traffic.
2016 MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
2019 * Non-TCP Red Profile.
2020 * Index of the profile within {port, traffic class} to use.
2021 * 0 for disabling both WRED and ECN for this type of traffic.
2024 MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
2026 #define MLXSW_REG_CWTPM_RESET_PROFILE 0
2028 static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
2029 u8 traffic_class, u8 profile,
2030 bool wred, bool ecn)
2032 MLXSW_REG_ZERO(cwtpm, payload);
2033 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
2034 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
2035 mlxsw_reg_cwtpm_ew_set(payload, wred);
2036 mlxsw_reg_cwtpm_ee_set(payload, ecn);
2037 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
2038 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
2039 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
2040 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
2041 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
2042 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
2045 /* PGCR - Policy-Engine General Configuration Register
2046 * ---------------------------------------------------
2047 * This register configures general Policy-Engine settings.
2049 #define MLXSW_REG_PGCR_ID 0x3001
2050 #define MLXSW_REG_PGCR_LEN 0x20
2052 MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
2054 /* reg_pgcr_default_action_pointer_base
2055 * Default action pointer base. Each region has a default action pointer
2056 * which is equal to default_action_pointer_base + region_id.
2059 MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
2061 static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
2063 MLXSW_REG_ZERO(pgcr, payload);
2064 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
2067 /* PPBT - Policy-Engine Port Binding Table
2068 * ---------------------------------------
2069 * This register is used for configuration of the Port Binding Table.
2071 #define MLXSW_REG_PPBT_ID 0x3002
2072 #define MLXSW_REG_PPBT_LEN 0x14
2074 MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
2076 enum mlxsw_reg_pxbt_e {
2077 MLXSW_REG_PXBT_E_IACL,
2078 MLXSW_REG_PXBT_E_EACL,
2084 MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
2086 enum mlxsw_reg_pxbt_op {
2087 MLXSW_REG_PXBT_OP_BIND,
2088 MLXSW_REG_PXBT_OP_UNBIND,
2094 MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
2096 /* reg_ppbt_local_port
2097 * Local port. Not including CPU port.
2100 MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
2103 * group - When set, the binding is of an ACL group. When cleared,
2104 * the binding is of an ACL.
2105 * Must be set to 1 for Spectrum.
2108 MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2110 /* reg_ppbt_acl_info
2111 * ACL/ACL group identifier. If the g bit is set, this field should hold
2112 * the acl_group_id, else it should hold the acl_id.
2115 MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2117 static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2118 enum mlxsw_reg_pxbt_op op,
2119 u8 local_port, u16 acl_info)
2121 MLXSW_REG_ZERO(ppbt, payload);
2122 mlxsw_reg_ppbt_e_set(payload, e);
2123 mlxsw_reg_ppbt_op_set(payload, op);
2124 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2125 mlxsw_reg_ppbt_g_set(payload, true);
2126 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2129 /* PACL - Policy-Engine ACL Register
2130 * ---------------------------------
2131 * This register is used for configuration of the ACL.
2133 #define MLXSW_REG_PACL_ID 0x3004
2134 #define MLXSW_REG_PACL_LEN 0x70
2136 MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2139 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2140 * while the ACL is bounded to either a port, VLAN or ACL rule.
2143 MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2146 * An identifier representing the ACL (managed by software)
2147 * Range 0 .. cap_max_acl_regions - 1
2150 MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2152 #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2154 /* reg_pacl_tcam_region_info
2155 * Opaque object that represents a TCAM region.
2156 * Obtained through PTAR register.
2159 MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2160 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2162 static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2163 bool valid, const char *tcam_region_info)
2165 MLXSW_REG_ZERO(pacl, payload);
2166 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2167 mlxsw_reg_pacl_v_set(payload, valid);
2168 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2171 /* PAGT - Policy-Engine ACL Group Table
2172 * ------------------------------------
2173 * This register is used for configuration of the ACL Group Table.
2175 #define MLXSW_REG_PAGT_ID 0x3005
2176 #define MLXSW_REG_PAGT_BASE_LEN 0x30
2177 #define MLXSW_REG_PAGT_ACL_LEN 4
2178 #define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2179 #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2180 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2182 MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2185 * Number of ACLs in the group.
2186 * Size 0 invalidates a group.
2187 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2188 * Total number of ACLs in all groups must be lower or equal
2189 * to cap_max_acl_tot_groups
2190 * Note: a group which is binded must not be invalidated
2193 MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2195 /* reg_pagt_acl_group_id
2196 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2197 * the ACL Group identifier (managed by software).
2200 MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2204 * 0 - This ACL is the last ACL in the multi-ACL
2205 * 1 - This ACL is part of a multi-ACL
2208 MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
2214 MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2216 static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2218 MLXSW_REG_ZERO(pagt, payload);
2219 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2222 static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2223 u16 acl_id, bool multi)
2225 u8 size = mlxsw_reg_pagt_size_get(payload);
2228 mlxsw_reg_pagt_size_set(payload, index + 1);
2229 mlxsw_reg_pagt_multi_set(payload, index, multi);
2230 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2233 /* PTAR - Policy-Engine TCAM Allocation Register
2234 * ---------------------------------------------
2235 * This register is used for allocation of regions in the TCAM.
2236 * Note: Query method is not supported on this register.
2238 #define MLXSW_REG_PTAR_ID 0x3006
2239 #define MLXSW_REG_PTAR_BASE_LEN 0x20
2240 #define MLXSW_REG_PTAR_KEY_ID_LEN 1
2241 #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2242 #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2243 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2245 MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2247 enum mlxsw_reg_ptar_op {
2248 /* allocate a TCAM region */
2249 MLXSW_REG_PTAR_OP_ALLOC,
2250 /* resize a TCAM region */
2251 MLXSW_REG_PTAR_OP_RESIZE,
2252 /* deallocate TCAM region */
2253 MLXSW_REG_PTAR_OP_FREE,
2254 /* test allocation */
2255 MLXSW_REG_PTAR_OP_TEST,
2261 MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2263 /* reg_ptar_action_set_type
2264 * Type of action set to be used on this region.
2265 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
2268 MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2270 enum mlxsw_reg_ptar_key_type {
2271 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2272 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2275 /* reg_ptar_key_type
2276 * TCAM key type for the region.
2279 MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2281 /* reg_ptar_region_size
2282 * TCAM region size. When allocating/resizing this is the requested size,
2283 * the response is the actual size. Note that actual size may be
2284 * larger than requested.
2285 * Allowed range 1 .. cap_max_rules-1
2286 * Reserved during op deallocate.
2289 MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2291 /* reg_ptar_region_id
2293 * Range 0 .. cap_max_regions-1
2296 MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2298 /* reg_ptar_tcam_region_info
2299 * Opaque object that represents the TCAM region.
2300 * Returned when allocating a region.
2301 * Provided by software for ACL generation and region deallocation and resize.
2304 MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2305 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2307 /* reg_ptar_flexible_key_id
2308 * Identifier of the Flexible Key.
2309 * Only valid if key_type == "FLEX_KEY"
2310 * The key size will be rounded up to one of the following values:
2311 * 9B, 18B, 36B, 54B.
2312 * This field is reserved for in resize operation.
2315 MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2316 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2318 static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
2319 enum mlxsw_reg_ptar_key_type key_type,
2320 u16 region_size, u16 region_id,
2321 const char *tcam_region_info)
2323 MLXSW_REG_ZERO(ptar, payload);
2324 mlxsw_reg_ptar_op_set(payload, op);
2325 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
2326 mlxsw_reg_ptar_key_type_set(payload, key_type);
2327 mlxsw_reg_ptar_region_size_set(payload, region_size);
2328 mlxsw_reg_ptar_region_id_set(payload, region_id);
2329 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2332 static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2335 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2338 static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2340 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2343 /* PPBS - Policy-Engine Policy Based Switching Register
2344 * ----------------------------------------------------
2345 * This register retrieves and sets Policy Based Switching Table entries.
2347 #define MLXSW_REG_PPBS_ID 0x300C
2348 #define MLXSW_REG_PPBS_LEN 0x14
2350 MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2353 * Index into the PBS table.
2354 * For Spectrum, the index points to the KVD Linear.
2357 MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2359 /* reg_ppbs_system_port
2360 * Unique port identifier for the final destination of the packet.
2363 MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2365 static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2368 MLXSW_REG_ZERO(ppbs, payload);
2369 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2370 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2373 /* PRCR - Policy-Engine Rules Copy Register
2374 * ----------------------------------------
2375 * This register is used for accessing rules within a TCAM region.
2377 #define MLXSW_REG_PRCR_ID 0x300D
2378 #define MLXSW_REG_PRCR_LEN 0x40
2380 MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2382 enum mlxsw_reg_prcr_op {
2383 /* Move rules. Moves the rules from "tcam_region_info" starting
2384 * at offset "offset" to "dest_tcam_region_info"
2385 * at offset "dest_offset."
2387 MLXSW_REG_PRCR_OP_MOVE,
2388 /* Copy rules. Copies the rules from "tcam_region_info" starting
2389 * at offset "offset" to "dest_tcam_region_info"
2390 * at offset "dest_offset."
2392 MLXSW_REG_PRCR_OP_COPY,
2398 MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2401 * Offset within the source region to copy/move from.
2404 MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2407 * The number of rules to copy/move.
2410 MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2412 /* reg_prcr_tcam_region_info
2413 * Opaque object that represents the source TCAM region.
2416 MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2417 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2419 /* reg_prcr_dest_offset
2420 * Offset within the source region to copy/move to.
2423 MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2425 /* reg_prcr_dest_tcam_region_info
2426 * Opaque object that represents the destination TCAM region.
2429 MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2430 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2432 static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2433 const char *src_tcam_region_info,
2435 const char *dest_tcam_region_info,
2436 u16 dest_offset, u16 size)
2438 MLXSW_REG_ZERO(prcr, payload);
2439 mlxsw_reg_prcr_op_set(payload, op);
2440 mlxsw_reg_prcr_offset_set(payload, src_offset);
2441 mlxsw_reg_prcr_size_set(payload, size);
2442 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2443 src_tcam_region_info);
2444 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2445 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2446 dest_tcam_region_info);
2449 /* PEFA - Policy-Engine Extended Flexible Action Register
2450 * ------------------------------------------------------
2451 * This register is used for accessing an extended flexible action entry
2452 * in the central KVD Linear Database.
2454 #define MLXSW_REG_PEFA_ID 0x300F
2455 #define MLXSW_REG_PEFA_LEN 0xB0
2457 MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2460 * Index in the KVD Linear Centralized Database.
2463 MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2466 * Index in the KVD Linear Centralized Database.
2468 * For a new entry: set if ca=0, clear if ca=1
2469 * Set if a packet lookup has hit on the specific entry
2472 MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2476 * When write: activity is according to this field
2477 * When read: after reading the activity is cleared according to ca
2480 MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2482 #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
2484 /* reg_pefa_flex_action_set
2485 * Action-set to perform when rule is matched.
2486 * Must be zero padded if action set is shorter.
2489 MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
2491 static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
2492 const char *flex_action_set)
2494 MLXSW_REG_ZERO(pefa, payload);
2495 mlxsw_reg_pefa_index_set(payload, index);
2496 mlxsw_reg_pefa_ca_set(payload, ca);
2497 if (flex_action_set)
2498 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2502 static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2504 *p_a = mlxsw_reg_pefa_a_get(payload);
2507 /* PEMRBT - Policy-Engine Multicast Router Binding Table Register
2508 * --------------------------------------------------------------
2509 * This register is used for binding Multicast router to an ACL group
2510 * that serves the MC router.
2511 * This register is not supported by SwitchX/-2 and Spectrum.
2513 #define MLXSW_REG_PEMRBT_ID 0x3014
2514 #define MLXSW_REG_PEMRBT_LEN 0x14
2516 MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
2518 enum mlxsw_reg_pemrbt_protocol {
2519 MLXSW_REG_PEMRBT_PROTO_IPV4,
2520 MLXSW_REG_PEMRBT_PROTO_IPV6,
2523 /* reg_pemrbt_protocol
2526 MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
2528 /* reg_pemrbt_group_id
2529 * ACL group identifier.
2530 * Range 0..cap_max_acl_groups-1
2533 MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
2536 mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
2539 MLXSW_REG_ZERO(pemrbt, payload);
2540 mlxsw_reg_pemrbt_protocol_set(payload, protocol);
2541 mlxsw_reg_pemrbt_group_id_set(payload, group_id);
2544 /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
2545 * -----------------------------------------------------
2546 * This register is used for accessing rules within a TCAM region.
2547 * It is a new version of PTCE in order to support wider key,
2548 * mask and action within a TCAM region. This register is not supported
2549 * by SwitchX and SwitchX-2.
2551 #define MLXSW_REG_PTCE2_ID 0x3017
2552 #define MLXSW_REG_PTCE2_LEN 0x1D8
2554 MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2560 MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2563 * Activity. Set if a packet lookup has hit on the specific entry.
2564 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
2567 MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2569 enum mlxsw_reg_ptce2_op {
2570 /* Read operation. */
2571 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2572 /* clear on read operation. Used to read entry
2573 * and clear Activity bit.
2575 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2576 /* Write operation. Used to write a new entry to the table.
2577 * All R/W fields are relevant for new entry. Activity bit is set
2578 * for new entries - Note write with v = 0 will delete the entry.
2580 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2581 /* Update action. Only action set will be updated. */
2582 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2583 /* Clear activity. A bit is cleared for the entry. */
2584 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2590 MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2595 MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2597 /* reg_ptce2_priority
2598 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
2599 * Note: priority does not have to be unique per rule.
2600 * Within a region, higher priority should have lower offset (no limitation
2601 * between regions in a multi-region).
2604 MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2606 /* reg_ptce2_tcam_region_info
2607 * Opaque object that represents the TCAM region.
2610 MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2611 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2613 #define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
2615 /* reg_ptce2_flex_key_blocks
2619 MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
2620 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2623 * mask- in the same size as key. A bit that is set directs the TCAM
2624 * to compare the corresponding bit in key. A bit that is clear directs
2625 * the TCAM to ignore the corresponding bit in key.
2628 MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
2629 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2631 /* reg_ptce2_flex_action_set
2635 MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
2636 MLXSW_REG_FLEX_ACTION_SET_LEN);
2638 static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2639 enum mlxsw_reg_ptce2_op op,
2640 const char *tcam_region_info,
2641 u16 offset, u32 priority)
2643 MLXSW_REG_ZERO(ptce2, payload);
2644 mlxsw_reg_ptce2_v_set(payload, valid);
2645 mlxsw_reg_ptce2_op_set(payload, op);
2646 mlxsw_reg_ptce2_offset_set(payload, offset);
2647 mlxsw_reg_ptce2_priority_set(payload, priority);
2648 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2651 /* PERPT - Policy-Engine ERP Table Register
2652 * ----------------------------------------
2653 * This register adds and removes eRPs from the eRP table.
2655 #define MLXSW_REG_PERPT_ID 0x3021
2656 #define MLXSW_REG_PERPT_LEN 0x80
2658 MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2660 /* reg_perpt_erpt_bank
2662 * Range 0 .. cap_max_erp_table_banks - 1
2665 MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2667 /* reg_perpt_erpt_index
2668 * Index to eRP table within the eRP bank.
2669 * Range is 0 .. cap_max_erp_table_bank_size - 1
2672 MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2674 enum mlxsw_reg_perpt_key_size {
2675 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2676 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2677 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2678 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2681 /* reg_perpt_key_size
2684 MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2686 /* reg_perpt_bf_bypass
2687 * 0 - The eRP is used only if bloom filter state is set for the given
2689 * 1 - The eRP is used regardless of bloom filter state.
2690 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
2693 MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2696 * eRP ID for use by the rules.
2699 MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2701 /* reg_perpt_erpt_base_bank
2702 * Base eRP table bank, points to head of erp_vector
2703 * Range is 0 .. cap_max_erp_table_banks - 1
2706 MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2708 /* reg_perpt_erpt_base_index
2709 * Base index to eRP table within the eRP bank
2710 * Range is 0 .. cap_max_erp_table_bank_size - 1
2713 MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2715 /* reg_perpt_erp_index_in_vector
2716 * eRP index in the vector.
2719 MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2721 /* reg_perpt_erp_vector
2725 MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2729 * 0 - A-TCAM will ignore the bit in key
2730 * 1 - A-TCAM will compare the bit in key
2733 MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2735 static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
2736 unsigned long *erp_vector,
2741 for_each_set_bit(bit, erp_vector, size)
2742 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
2746 mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
2747 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
2748 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
2751 MLXSW_REG_ZERO(perpt, payload);
2752 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
2753 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
2754 mlxsw_reg_perpt_key_size_set(payload, key_size);
2755 mlxsw_reg_perpt_bf_bypass_set(payload, false);
2756 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
2757 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
2758 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
2759 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
2760 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
2763 /* PERAR - Policy-Engine Region Association Register
2764 * -------------------------------------------------
2765 * This register associates a hw region for region_id's. Changing on the fly
2766 * is supported by the device.
2768 #define MLXSW_REG_PERAR_ID 0x3026
2769 #define MLXSW_REG_PERAR_LEN 0x08
2771 MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
2773 /* reg_perar_region_id
2775 * Range 0 .. cap_max_regions-1
2778 MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
2780 static inline unsigned int
2781 mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
2783 return DIV_ROUND_UP(block_num, 4);
2786 /* reg_perar_hw_region
2788 * Range 0 .. cap_max_regions-1
2789 * Default: hw_region = region_id
2790 * For a 8 key block region, 2 consecutive regions are used
2791 * For a 12 key block region, 3 consecutive regions are used
2794 MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
2796 static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
2799 MLXSW_REG_ZERO(perar, payload);
2800 mlxsw_reg_perar_region_id_set(payload, region_id);
2801 mlxsw_reg_perar_hw_region_set(payload, hw_region);
2804 /* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
2805 * -----------------------------------------------------
2806 * This register is a new version of PTCE-V2 in order to support the
2807 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
2809 #define MLXSW_REG_PTCE3_ID 0x3027
2810 #define MLXSW_REG_PTCE3_LEN 0xF0
2812 MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
2818 MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
2820 enum mlxsw_reg_ptce3_op {
2821 /* Write operation. Used to write a new entry to the table.
2822 * All R/W fields are relevant for new entry. Activity bit is set
2823 * for new entries. Write with v = 0 will delete the entry. Must
2824 * not be used if an entry exists.
2826 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
2827 /* Update operation */
2828 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
2829 /* Read operation */
2830 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
2836 MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
2838 /* reg_ptce3_priority
2839 * Priority of the rule. Higher values win.
2840 * For Spectrum-2 range is 1..cap_kvd_size - 1
2841 * Note: Priority does not have to be unique per rule.
2844 MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
2846 /* reg_ptce3_tcam_region_info
2847 * Opaque object that represents the TCAM region.
2850 MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
2851 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2853 /* reg_ptce3_flex2_key_blocks
2854 * ACL key. The key must be masked according to eRP (if exists) or
2855 * according to master mask.
2858 MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
2859 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2865 MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
2867 /* reg_ptce3_delta_start
2868 * Start point of delta_value and delta_mask, in bits. Must not exceed
2869 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
2872 MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
2874 /* reg_ptce3_delta_mask
2876 * 0 - Ignore relevant bit in delta_value
2877 * 1 - Compare relevant bit in delta_value
2878 * Delta mask must not be set for reserved fields in the key blocks.
2879 * Note: No delta when no eRPs. Thus, for regions with
2880 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
2883 MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
2885 /* reg_ptce3_delta_value
2887 * Bits which are masked by delta_mask must be 0.
2890 MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
2892 /* reg_ptce3_prune_vector
2893 * Pruning vector relative to the PERPT.erp_id.
2894 * Used for reducing lookups.
2895 * 0 - NEED: Do a lookup using the eRP.
2896 * 1 - PRUNE: Do not perform a lookup using the eRP.
2897 * Maybe be modified by PEAPBL and PEAPBM.
2898 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
2899 * all 1's or all 0's.
2902 MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
2904 /* reg_ptce3_prune_ctcam
2905 * Pruning on C-TCAM. Used for reducing lookups.
2906 * 0 - NEED: Do a lookup in the C-TCAM.
2907 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
2910 MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
2912 /* reg_ptce3_large_exists
2913 * Large entry key ID exists.
2914 * Within the region:
2915 * 0 - SINGLE: The large_entry_key_id is not currently in use.
2916 * For rule insert: The MSB of the key (blocks 6..11) will be added.
2917 * For rule delete: The MSB of the key will be removed.
2918 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
2919 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
2920 * For rule delete: The MSB of the key will not be removed.
2923 MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
2925 /* reg_ptce3_large_entry_key_id
2926 * Large entry key ID.
2927 * A key for 12 key blocks rules. Reserved when region has less than 12 key
2928 * blocks. Must be different for different keys which have the same common
2929 * 6 key blocks (MSB, blocks 6..11) key within a region.
2930 * Range is 0..cap_max_pe_large_key_id - 1
2933 MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
2935 /* reg_ptce3_action_pointer
2936 * Pointer to action.
2937 * Range is 0..cap_max_kvd_action_sets - 1
2940 MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
2942 static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
2943 enum mlxsw_reg_ptce3_op op,
2945 const char *tcam_region_info,
2946 const char *key, u8 erp_id,
2947 u16 delta_start, u8 delta_mask,
2948 u8 delta_value, bool large_exists,
2949 u32 lkey_id, u32 action_pointer)
2951 MLXSW_REG_ZERO(ptce3, payload);
2952 mlxsw_reg_ptce3_v_set(payload, valid);
2953 mlxsw_reg_ptce3_op_set(payload, op);
2954 mlxsw_reg_ptce3_priority_set(payload, priority);
2955 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
2956 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
2957 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
2958 mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
2959 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
2960 mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
2961 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
2962 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
2963 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
2966 /* PERCR - Policy-Engine Region Configuration Register
2967 * ---------------------------------------------------
2968 * This register configures the region parameters. The region_id must be
2971 #define MLXSW_REG_PERCR_ID 0x302A
2972 #define MLXSW_REG_PERCR_LEN 0x80
2974 MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
2976 /* reg_percr_region_id
2977 * Region identifier.
2978 * Range 0..cap_max_regions-1
2981 MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
2983 /* reg_percr_atcam_ignore_prune
2984 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
2987 MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
2989 /* reg_percr_ctcam_ignore_prune
2990 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
2993 MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
2995 /* reg_percr_bf_bypass
2996 * Bloom filter bypass.
2997 * 0 - Bloom filter is used (default)
2998 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
2999 * region_id or eRP. See PERPT.bf_bypass
3002 MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
3004 /* reg_percr_master_mask
3005 * Master mask. Logical OR mask of all masks of all rules of a region
3006 * (both A-TCAM and C-TCAM). When there are no eRPs
3007 * (erpt_pointer_valid = 0), then this provides the mask.
3010 MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
3012 static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
3014 MLXSW_REG_ZERO(percr, payload);
3015 mlxsw_reg_percr_region_id_set(payload, region_id);
3016 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
3017 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
3018 mlxsw_reg_percr_bf_bypass_set(payload, false);
3021 /* PERERP - Policy-Engine Region eRP Register
3022 * ------------------------------------------
3023 * This register configures the region eRP. The region_id must be
3026 #define MLXSW_REG_PERERP_ID 0x302B
3027 #define MLXSW_REG_PERERP_LEN 0x1C
3029 MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
3031 /* reg_pererp_region_id
3032 * Region identifier.
3033 * Range 0..cap_max_regions-1
3036 MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
3038 /* reg_pererp_ctcam_le
3039 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
3042 MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
3044 /* reg_pererp_erpt_pointer_valid
3045 * erpt_pointer is valid.
3048 MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
3050 /* reg_pererp_erpt_bank_pointer
3051 * Pointer to eRP table bank. May be modified at any time.
3052 * Range 0..cap_max_erp_table_banks-1
3053 * Reserved when erpt_pointer_valid = 0
3055 MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
3057 /* reg_pererp_erpt_pointer
3058 * Pointer to eRP table within the eRP bank. Can be changed for an
3060 * Range 0..cap_max_erp_table_size-1
3061 * Reserved when erpt_pointer_valid = 0
3064 MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
3066 /* reg_pererp_erpt_vector
3067 * Vector of allowed eRP indexes starting from erpt_pointer within the
3068 * erpt_bank_pointer. Next entries will be in next bank.
3069 * Note that eRP index is used and not eRP ID.
3070 * Reserved when erpt_pointer_valid = 0
3073 MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
3075 /* reg_pererp_master_rp_id
3076 * Master RP ID. When there are no eRPs, then this provides the eRP ID
3077 * for the lookup. Can be changed for an existing region.
3078 * Reserved when erpt_pointer_valid = 1
3081 MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
3083 static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
3084 unsigned long *erp_vector,
3089 for_each_set_bit(bit, erp_vector, size)
3090 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
3093 static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
3094 bool ctcam_le, bool erpt_pointer_valid,
3095 u8 erpt_bank_pointer, u8 erpt_pointer,
3098 MLXSW_REG_ZERO(pererp, payload);
3099 mlxsw_reg_pererp_region_id_set(payload, region_id);
3100 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
3101 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
3102 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
3103 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
3104 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
3107 /* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
3108 * ----------------------------------------------------------------
3109 * This register configures the Bloom filter entries.
3111 #define MLXSW_REG_PEABFE_ID 0x3022
3112 #define MLXSW_REG_PEABFE_BASE_LEN 0x10
3113 #define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3114 #define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3115 #define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3116 MLXSW_REG_PEABFE_BF_REC_LEN * \
3117 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3119 MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3122 * Number of BF entries to be updated.
3126 MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3128 /* reg_peabfe_bf_entry_state
3129 * Bloom filter state
3134 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3135 MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3136 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3138 /* reg_peabfe_bf_entry_bank
3139 * Bloom filter bank ID
3140 * Range 0..cap_max_erp_table_banks-1
3143 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3144 MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3145 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3147 /* reg_peabfe_bf_entry_index
3148 * Bloom filter entry index
3149 * Range 0..2^cap_max_bf_log-1
3152 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3153 MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3154 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3156 static inline void mlxsw_reg_peabfe_pack(char *payload)
3158 MLXSW_REG_ZERO(peabfe, payload);
3161 static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3162 u8 state, u8 bank, u32 bf_index)
3164 u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3166 if (rec_index >= num_rec)
3167 mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3168 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3169 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3170 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3173 /* IEDR - Infrastructure Entry Delete Register
3174 * ----------------------------------------------------
3175 * This register is used for deleting entries from the entry tables.
3176 * It is legitimate to attempt to delete a nonexisting entry (the device will
3177 * respond as a good flow).
3179 #define MLXSW_REG_IEDR_ID 0x3804
3180 #define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
3181 #define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
3182 #define MLXSW_REG_IEDR_REC_MAX_COUNT 64
3183 #define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
3184 MLXSW_REG_IEDR_REC_LEN * \
3185 MLXSW_REG_IEDR_REC_MAX_COUNT)
3187 MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
3190 * Number of records.
3193 MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
3195 /* reg_iedr_rec_type
3199 MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
3200 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3202 /* reg_iedr_rec_size
3203 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
3206 MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 11,
3207 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3209 /* reg_iedr_rec_index_start
3210 * Resource index start.
3213 MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3214 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3216 static inline void mlxsw_reg_iedr_pack(char *payload)
3218 MLXSW_REG_ZERO(iedr, payload);
3221 static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3222 u8 rec_type, u16 rec_size,
3223 u32 rec_index_start)
3225 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3227 if (rec_index >= num_rec)
3228 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3229 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3230 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3231 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3234 /* QPTS - QoS Priority Trust State Register
3235 * ----------------------------------------
3236 * This register controls the port policy to calculate the switch priority and
3237 * packet color based on incoming packet fields.
3239 #define MLXSW_REG_QPTS_ID 0x4002
3240 #define MLXSW_REG_QPTS_LEN 0x8
3242 MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3244 /* reg_qpts_local_port
3245 * Local port number.
3248 * Note: CPU port is supported.
3250 MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
3252 enum mlxsw_reg_qpts_trust_state {
3253 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3254 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3257 /* reg_qpts_trust_state
3258 * Trust state for a given port.
3261 MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3263 static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
3264 enum mlxsw_reg_qpts_trust_state ts)
3266 MLXSW_REG_ZERO(qpts, payload);
3268 mlxsw_reg_qpts_local_port_set(payload, local_port);
3269 mlxsw_reg_qpts_trust_state_set(payload, ts);
3272 /* QPCR - QoS Policer Configuration Register
3273 * -----------------------------------------
3274 * The QPCR register is used to create policers - that limit
3275 * the rate of bytes or packets via some trap group.
3277 #define MLXSW_REG_QPCR_ID 0x4004
3278 #define MLXSW_REG_QPCR_LEN 0x28
3280 MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3282 enum mlxsw_reg_qpcr_g {
3283 MLXSW_REG_QPCR_G_GLOBAL = 2,
3284 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3291 MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3297 MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3299 /* reg_qpcr_color_aware
3300 * Is the policer aware of colors.
3301 * Must be 0 (unaware) for cpu port.
3302 * Access: RW for unbounded policer. RO for bounded policer.
3304 MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3307 * Is policer limit is for bytes per sec or packets per sec.
3310 * Access: RW for unbounded policer. RO for bounded policer.
3312 MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3314 enum mlxsw_reg_qpcr_ir_units {
3315 MLXSW_REG_QPCR_IR_UNITS_M,
3316 MLXSW_REG_QPCR_IR_UNITS_K,
3319 /* reg_qpcr_ir_units
3320 * Policer's units for cir and eir fields (for bytes limits only)
3325 MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3327 enum mlxsw_reg_qpcr_rate_type {
3328 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3329 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3332 /* reg_qpcr_rate_type
3333 * Policer can have one limit (single rate) or 2 limits with specific operation
3334 * for packets that exceed the lower rate but not the upper one.
3335 * (For cpu port must be single rate)
3336 * Access: RW for unbounded policer. RO for bounded policer.
3338 MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3341 * Policer's committed burst size.
3342 * The policer is working with time slices of 50 nano sec. By default every
3343 * slice is granted the proportionate share of the committed rate. If we want to
3344 * allow a slice to exceed that share (while still keeping the rate per sec) we
3345 * can allow burst. The burst size is between the default proportionate share
3346 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3347 * committed rate will result in exceeding the rate). The burst size must be a
3348 * log of 2 and will be determined by 2^cbs.
3351 MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3354 * Policer's committed rate.
3355 * The rate used for sungle rate, the lower rate for double rate.
3356 * For bytes limits, the rate will be this value * the unit from ir_units.
3357 * (Resolution error is up to 1%).
3360 MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3363 * Policer's exceed rate.
3364 * The higher rate for double rate, reserved for single rate.
3365 * Lower rate for double rate policer.
3366 * For bytes limits, the rate will be this value * the unit from ir_units.
3367 * (Resolution error is up to 1%).
3370 MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3372 #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3374 /* reg_qpcr_exceed_action.
3375 * What to do with packets between the 2 limits for double rate.
3376 * Access: RW for unbounded policer. RO for bounded policer.
3378 MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3380 enum mlxsw_reg_qpcr_action {
3382 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3383 /* Forward and set color to red.
3384 * If the packet is intended to cpu port, it will be dropped.
3386 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3389 /* reg_qpcr_violate_action
3390 * What to do with packets that cross the cir limit (for single rate) or the eir
3391 * limit (for double rate).
3392 * Access: RW for unbounded policer. RO for bounded policer.
3394 MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3396 static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3397 enum mlxsw_reg_qpcr_ir_units ir_units,
3398 bool bytes, u32 cir, u16 cbs)
3400 MLXSW_REG_ZERO(qpcr, payload);
3401 mlxsw_reg_qpcr_pid_set(payload, pid);
3402 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3403 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3404 mlxsw_reg_qpcr_violate_action_set(payload,
3405 MLXSW_REG_QPCR_ACTION_DISCARD);
3406 mlxsw_reg_qpcr_cir_set(payload, cir);
3407 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3408 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3409 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3412 /* QTCT - QoS Switch Traffic Class Table
3413 * -------------------------------------
3414 * Configures the mapping between the packet switch priority and the
3415 * traffic class on the transmit port.
3417 #define MLXSW_REG_QTCT_ID 0x400A
3418 #define MLXSW_REG_QTCT_LEN 0x08
3420 MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
3422 /* reg_qtct_local_port
3423 * Local port number.
3426 * Note: CPU port is not supported.
3428 MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
3430 /* reg_qtct_sub_port
3431 * Virtual port within the physical port.
3432 * Should be set to 0 when virtual ports are not enabled on the port.
3435 MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3437 /* reg_qtct_switch_prio
3441 MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3446 * switch_prio 0 : tclass 1
3447 * switch_prio 1 : tclass 0
3448 * switch_prio i : tclass i, for i > 1
3451 MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3453 static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3454 u8 switch_prio, u8 tclass)
3456 MLXSW_REG_ZERO(qtct, payload);
3457 mlxsw_reg_qtct_local_port_set(payload, local_port);
3458 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3459 mlxsw_reg_qtct_tclass_set(payload, tclass);
3462 /* QEEC - QoS ETS Element Configuration Register
3463 * ---------------------------------------------
3464 * Configures the ETS elements.
3466 #define MLXSW_REG_QEEC_ID 0x400D
3467 #define MLXSW_REG_QEEC_LEN 0x20
3469 MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
3471 /* reg_qeec_local_port
3472 * Local port number.
3475 * Note: CPU port is supported.
3477 MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
3479 enum mlxsw_reg_qeec_hr {
3480 MLXSW_REG_QEEC_HR_PORT,
3481 MLXSW_REG_QEEC_HR_GROUP,
3482 MLXSW_REG_QEEC_HR_SUBGROUP,
3483 MLXSW_REG_QEEC_HR_TC,
3486 /* reg_qeec_element_hierarchy
3493 MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3495 /* reg_qeec_element_index
3496 * The index of the element in the hierarchy.
3499 MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3501 /* reg_qeec_next_element_index
3502 * The index of the next (lower) element in the hierarchy.
3505 * Note: Reserved for element_hierarchy 0.
3507 MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3510 * Min shaper configuration enable. Enables configuration of the min
3511 * shaper on this ETS element
3516 MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3520 * 0: regular shaper mode
3521 * 1: PTP oriented shaper
3522 * Allowed only for hierarchy 0
3523 * Not supported for CPU port
3524 * Note that ptps mode may affect the shaper rates of all hierarchies
3525 * Supported only on Spectrum-1
3528 MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
3531 MLXSW_REG_QEEC_BYTES_MODE,
3532 MLXSW_REG_QEEC_PACKETS_MODE,
3536 * Packets or bytes mode.
3541 * Note: Used for max shaper configuration. For Spectrum, packets mode
3542 * is supported only for traffic classes of CPU port.
3544 MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3546 /* The smallest permitted min shaper rate. */
3547 #define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
3549 /* reg_qeec_min_shaper_rate
3550 * Min shaper information rate.
3551 * For CPU port, can only be configured for port hierarchy.
3552 * When in bytes mode, value is specified in units of 1000bps.
3555 MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3558 * Max shaper configuration enable. Enables configuration of the max
3559 * shaper on this ETS element.
3564 MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3566 /* A large max rate will disable the max shaper. */
3567 #define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */
3569 /* reg_qeec_max_shaper_rate
3570 * Max shaper information rate.
3571 * For CPU port, can only be configured for port hierarchy.
3572 * When in bytes mode, value is specified in units of 1000bps.
3575 MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
3578 * DWRR configuration enable. Enables configuration of the dwrr and
3584 MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3587 * Transmission selection algorithm to use on the link going down from
3589 * 0 - Strict priority
3593 MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3595 /* reg_qeec_dwrr_weight
3596 * DWRR weight on the link going down from the ETS element. The
3597 * percentage of bandwidth guaranteed to an ETS element within
3598 * its hierarchy. The sum of all weights across all ETS elements
3599 * within one hierarchy should be equal to 100. Reserved when
3600 * transmission selection algorithm is strict priority.
3603 MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3605 static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
3606 enum mlxsw_reg_qeec_hr hr, u8 index,
3609 MLXSW_REG_ZERO(qeec, payload);
3610 mlxsw_reg_qeec_local_port_set(payload, local_port);
3611 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3612 mlxsw_reg_qeec_element_index_set(payload, index);
3613 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3616 static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u8 local_port,
3619 MLXSW_REG_ZERO(qeec, payload);
3620 mlxsw_reg_qeec_local_port_set(payload, local_port);
3621 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
3622 mlxsw_reg_qeec_ptps_set(payload, ptps);
3625 /* QRWE - QoS ReWrite Enable
3626 * -------------------------
3627 * This register configures the rewrite enable per receive port.
3629 #define MLXSW_REG_QRWE_ID 0x400F
3630 #define MLXSW_REG_QRWE_LEN 0x08
3632 MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3634 /* reg_qrwe_local_port
3635 * Local port number.
3638 * Note: CPU port is supported. No support for router port.
3640 MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
3643 * Whether to enable DSCP rewrite (default is 0, don't rewrite).
3646 MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3649 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
3652 MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3654 static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
3655 bool rewrite_pcp, bool rewrite_dscp)
3657 MLXSW_REG_ZERO(qrwe, payload);
3658 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3659 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3660 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3663 /* QPDSM - QoS Priority to DSCP Mapping
3664 * ------------------------------------
3665 * QoS Priority to DSCP Mapping Register
3667 #define MLXSW_REG_QPDSM_ID 0x4011
3668 #define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
3669 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
3670 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3671 #define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3672 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3673 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3675 MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3677 /* reg_qpdsm_local_port
3678 * Local Port. Supported for data packets from CPU port.
3681 MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
3683 /* reg_qpdsm_prio_entry_color0_e
3684 * Enable update of the entry for color 0 and a given port.
3687 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
3688 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
3689 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3691 /* reg_qpdsm_prio_entry_color0_dscp
3692 * DSCP field in the outer label of the packet for color 0 and a given port.
3693 * Reserved when e=0.
3696 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
3697 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
3698 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3700 /* reg_qpdsm_prio_entry_color1_e
3701 * Enable update of the entry for color 1 and a given port.
3704 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
3705 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
3706 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3708 /* reg_qpdsm_prio_entry_color1_dscp
3709 * DSCP field in the outer label of the packet for color 1 and a given port.
3710 * Reserved when e=0.
3713 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
3714 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
3715 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3717 /* reg_qpdsm_prio_entry_color2_e
3718 * Enable update of the entry for color 2 and a given port.
3721 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
3722 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
3723 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3725 /* reg_qpdsm_prio_entry_color2_dscp
3726 * DSCP field in the outer label of the packet for color 2 and a given port.
3727 * Reserved when e=0.
3730 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
3731 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
3732 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3734 static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
3736 MLXSW_REG_ZERO(qpdsm, payload);
3737 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
3741 mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
3743 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
3744 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
3745 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
3746 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
3747 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
3748 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
3751 /* QPDP - QoS Port DSCP to Priority Mapping Register
3752 * -------------------------------------------------
3753 * This register controls the port default Switch Priority and Color. The
3754 * default Switch Priority and Color are used for frames where the trust state
3755 * uses default values. All member ports of a LAG should be configured with the
3756 * same default values.
3758 #define MLXSW_REG_QPDP_ID 0x4007
3759 #define MLXSW_REG_QPDP_LEN 0x8
3761 MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
3763 /* reg_qpdp_local_port
3764 * Local Port. Supported for data packets from CPU port.
3767 MLXSW_ITEM32(reg, qpdp, local_port, 0x00, 16, 8);
3769 /* reg_qpdp_switch_prio
3770 * Default port Switch Priority (default 0)
3773 MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
3775 static inline void mlxsw_reg_qpdp_pack(char *payload, u8 local_port,
3778 MLXSW_REG_ZERO(qpdp, payload);
3779 mlxsw_reg_qpdp_local_port_set(payload, local_port);
3780 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
3783 /* QPDPM - QoS Port DSCP to Priority Mapping Register
3784 * --------------------------------------------------
3785 * This register controls the mapping from DSCP field to
3786 * Switch Priority for IP packets.
3788 #define MLXSW_REG_QPDPM_ID 0x4013
3789 #define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
3790 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
3791 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
3792 #define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
3793 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
3794 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
3796 MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
3798 /* reg_qpdpm_local_port
3799 * Local Port. Supported for data packets from CPU port.
3802 MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
3805 * Enable update of the specific entry. When cleared, the switch_prio and color
3806 * fields are ignored and the previous switch_prio and color values are
3810 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
3811 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3813 /* reg_qpdpm_dscp_prio
3814 * The new Switch Priority value for the relevant DSCP value.
3817 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
3818 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
3819 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3821 static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
3823 MLXSW_REG_ZERO(qpdpm, payload);
3824 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
3828 mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
3830 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
3831 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
3834 /* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
3835 * ------------------------------------------------------------------
3836 * This register configures if the Switch Priority to Traffic Class mapping is
3837 * based on Multicast packet indication. If so, then multicast packets will get
3838 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
3840 * By default, Switch Priority to Traffic Class mapping is not based on
3841 * Multicast packet indication.
3843 #define MLXSW_REG_QTCTM_ID 0x401A
3844 #define MLXSW_REG_QTCTM_LEN 0x08
3846 MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
3848 /* reg_qtctm_local_port
3849 * Local port number.
3850 * No support for CPU port.
3853 MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
3857 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
3858 * indication (default is 0, not based on Multicast packet indication).
3860 MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
3863 mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
3865 MLXSW_REG_ZERO(qtctm, payload);
3866 mlxsw_reg_qtctm_local_port_set(payload, local_port);
3867 mlxsw_reg_qtctm_mc_set(payload, mc);
3870 /* QPSC - QoS PTP Shaper Configuration Register
3871 * --------------------------------------------
3872 * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1.
3873 * Supported only on Spectrum-1.
3875 #define MLXSW_REG_QPSC_ID 0x401B
3876 #define MLXSW_REG_QPSC_LEN 0x28
3878 MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
3880 enum mlxsw_reg_qpsc_port_speed {
3881 MLXSW_REG_QPSC_PORT_SPEED_100M,
3882 MLXSW_REG_QPSC_PORT_SPEED_1G,
3883 MLXSW_REG_QPSC_PORT_SPEED_10G,
3884 MLXSW_REG_QPSC_PORT_SPEED_25G,
3887 /* reg_qpsc_port_speed
3891 MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
3893 /* reg_qpsc_shaper_time_exp
3894 * The base-time-interval for updating the shapers tokens (for all hierarchies).
3895 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
3896 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
3899 MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
3901 /* reg_qpsc_shaper_time_mantissa
3902 * The base-time-interval for updating the shapers tokens (for all hierarchies).
3903 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
3904 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
3907 MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
3909 /* reg_qpsc_shaper_inc
3910 * Number of tokens added to shaper on each update.
3914 MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
3916 /* reg_qpsc_shaper_bs
3917 * Max shaper Burst size.
3918 * Burst size is 2 ^ max_shaper_bs * 512 [bits]
3919 * Range is: 5..25 (from 2KB..2GB)
3922 MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
3925 * Write enable to port_to_shaper_credits.
3928 MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
3930 /* reg_qpsc_port_to_shaper_credits
3931 * For split ports: range 1..57
3932 * For non-split ports: range 1..112
3933 * Written only when ptsc_we is set.
3936 MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
3938 /* reg_qpsc_ing_timestamp_inc
3939 * Ingress timestamp increment.
3941 * The timestamp of MTPPTR at ingress will be incremented by this value. Global
3942 * value for all ports.
3943 * Same units as used by MTPPTR.
3946 MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
3948 /* reg_qpsc_egr_timestamp_inc
3949 * Egress timestamp increment.
3951 * The timestamp of MTPPTR at egress will be incremented by this value. Global
3952 * value for all ports.
3953 * Same units as used by MTPPTR.
3956 MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
3959 mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
3960 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
3961 u8 shaper_bs, u8 port_to_shaper_credits,
3962 int ing_timestamp_inc, int egr_timestamp_inc)
3964 MLXSW_REG_ZERO(qpsc, payload);
3965 mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
3966 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
3967 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
3968 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
3969 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
3970 mlxsw_reg_qpsc_ptsc_we_set(payload, true);
3971 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
3972 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
3973 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
3976 /* PMLP - Ports Module to Local Port Register
3977 * ------------------------------------------
3978 * Configures the assignment of modules to local ports.
3980 #define MLXSW_REG_PMLP_ID 0x5002
3981 #define MLXSW_REG_PMLP_LEN 0x40
3983 MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
3986 * 0 - Tx value is used for both Tx and Rx.
3987 * 1 - Rx value is taken from a separte field.
3990 MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
3992 /* reg_pmlp_local_port
3993 * Local port number.
3996 MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
3999 * 0 - Unmap local port.
4000 * 1 - Lane 0 is used.
4001 * 2 - Lanes 0 and 1 are used.
4002 * 4 - Lanes 0, 1, 2 and 3 are used.
4003 * 8 - Lanes 0-7 are used.
4006 MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
4012 MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
4015 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
4018 MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
4021 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
4025 MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
4027 static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
4029 MLXSW_REG_ZERO(pmlp, payload);
4030 mlxsw_reg_pmlp_local_port_set(payload, local_port);
4033 /* PMTU - Port MTU Register
4034 * ------------------------
4035 * Configures and reports the port MTU.
4037 #define MLXSW_REG_PMTU_ID 0x5003
4038 #define MLXSW_REG_PMTU_LEN 0x10
4040 MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
4042 /* reg_pmtu_local_port
4043 * Local port number.
4046 MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
4050 * When port type (e.g. Ethernet) is configured, the relevant MTU is
4051 * reported, otherwise the minimum between the max_mtu of the different
4052 * types is reported.
4055 MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
4057 /* reg_pmtu_admin_mtu
4058 * MTU value to set port to. Must be smaller or equal to max_mtu.
4059 * Note: If port type is Infiniband, then port must be disabled, when its
4063 MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
4065 /* reg_pmtu_oper_mtu
4066 * The actual MTU configured on the port. Packets exceeding this size
4068 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
4069 * oper_mtu might be smaller than admin_mtu.
4072 MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
4074 static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
4077 MLXSW_REG_ZERO(pmtu, payload);
4078 mlxsw_reg_pmtu_local_port_set(payload, local_port);
4079 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
4080 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
4081 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
4084 /* PTYS - Port Type and Speed Register
4085 * -----------------------------------
4086 * Configures and reports the port speed type.
4088 * Note: When set while the link is up, the changes will not take effect
4089 * until the port transitions from down to up state.
4091 #define MLXSW_REG_PTYS_ID 0x5004
4092 #define MLXSW_REG_PTYS_LEN 0x40
4094 MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
4097 * Auto negotiation disable administrative configuration
4098 * 0 - Device doesn't support AN disable.
4099 * 1 - Device supports AN disable.
4102 MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
4104 /* reg_ptys_local_port
4105 * Local port number.
4108 MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
4110 #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
4111 #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
4113 /* reg_ptys_proto_mask
4114 * Protocol mask. Indicates which protocol is used.
4116 * 1 - Fibre Channel.
4120 MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
4123 MLXSW_REG_PTYS_AN_STATUS_NA,
4124 MLXSW_REG_PTYS_AN_STATUS_OK,
4125 MLXSW_REG_PTYS_AN_STATUS_FAIL,
4128 /* reg_ptys_an_status
4129 * Autonegotiation status.
4132 MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
4134 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
4135 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
4136 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_2_5GBASE_X_2_5GMII BIT(2)
4137 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
4138 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
4139 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
4140 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
4141 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
4142 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
4143 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
4144 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
4145 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
4146 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
4148 /* reg_ptys_ext_eth_proto_cap
4149 * Extended Ethernet port supported speeds and protocols.
4152 MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
4154 #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
4155 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
4156 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
4157 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
4158 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
4159 #define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
4160 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
4161 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
4162 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
4163 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
4164 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
4165 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
4166 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
4167 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
4168 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
4169 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
4170 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
4171 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
4172 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
4173 #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
4174 #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
4175 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
4176 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
4177 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
4178 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
4179 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
4180 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
4182 /* reg_ptys_eth_proto_cap
4183 * Ethernet port supported speeds and protocols.
4186 MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
4188 /* reg_ptys_ib_link_width_cap
4189 * IB port supported widths.
4192 MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
4194 #define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
4195 #define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
4196 #define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
4197 #define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
4198 #define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
4199 #define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
4201 /* reg_ptys_ib_proto_cap
4202 * IB port supported speeds and protocols.
4205 MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
4207 /* reg_ptys_ext_eth_proto_admin
4208 * Extended speed and protocol to set port to.
4211 MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
4213 /* reg_ptys_eth_proto_admin
4214 * Speed and protocol to set port to.
4217 MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
4219 /* reg_ptys_ib_link_width_admin
4220 * IB width to set port to.
4223 MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
4225 /* reg_ptys_ib_proto_admin
4226 * IB speeds and protocols to set port to.
4229 MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
4231 /* reg_ptys_ext_eth_proto_oper
4232 * The extended current speed and protocol configured for the port.
4235 MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
4237 /* reg_ptys_eth_proto_oper
4238 * The current speed and protocol configured for the port.
4241 MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
4243 /* reg_ptys_ib_link_width_oper
4244 * The current IB width to set port to.
4247 MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
4249 /* reg_ptys_ib_proto_oper
4250 * The current IB speed and protocol.
4253 MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
4255 enum mlxsw_reg_ptys_connector_type {
4256 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
4257 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
4258 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
4259 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
4260 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
4261 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
4262 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
4263 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
4264 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
4267 /* reg_ptys_connector_type
4268 * Connector type indication.
4271 MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
4273 static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
4274 u32 proto_admin, bool autoneg)
4276 MLXSW_REG_ZERO(ptys, payload);
4277 mlxsw_reg_ptys_local_port_set(payload, local_port);
4278 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4279 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
4280 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4283 static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u8 local_port,
4284 u32 proto_admin, bool autoneg)
4286 MLXSW_REG_ZERO(ptys, payload);
4287 mlxsw_reg_ptys_local_port_set(payload, local_port);
4288 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4289 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
4290 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4293 static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
4294 u32 *p_eth_proto_cap,
4295 u32 *p_eth_proto_admin,
4296 u32 *p_eth_proto_oper)
4298 if (p_eth_proto_cap)
4300 mlxsw_reg_ptys_eth_proto_cap_get(payload);
4301 if (p_eth_proto_admin)
4302 *p_eth_proto_admin =
4303 mlxsw_reg_ptys_eth_proto_admin_get(payload);
4304 if (p_eth_proto_oper)
4306 mlxsw_reg_ptys_eth_proto_oper_get(payload);
4309 static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
4310 u32 *p_eth_proto_cap,
4311 u32 *p_eth_proto_admin,
4312 u32 *p_eth_proto_oper)
4314 if (p_eth_proto_cap)
4316 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
4317 if (p_eth_proto_admin)
4318 *p_eth_proto_admin =
4319 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
4320 if (p_eth_proto_oper)
4322 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
4325 static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
4326 u16 proto_admin, u16 link_width)
4328 MLXSW_REG_ZERO(ptys, payload);
4329 mlxsw_reg_ptys_local_port_set(payload, local_port);
4330 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
4331 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
4332 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
4335 static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
4336 u16 *p_ib_link_width_cap,
4337 u16 *p_ib_proto_oper,
4338 u16 *p_ib_link_width_oper)
4341 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
4342 if (p_ib_link_width_cap)
4343 *p_ib_link_width_cap =
4344 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
4345 if (p_ib_proto_oper)
4346 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
4347 if (p_ib_link_width_oper)
4348 *p_ib_link_width_oper =
4349 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
4352 /* PPAD - Port Physical Address Register
4353 * -------------------------------------
4354 * The PPAD register configures the per port physical MAC address.
4356 #define MLXSW_REG_PPAD_ID 0x5005
4357 #define MLXSW_REG_PPAD_LEN 0x10
4359 MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
4361 /* reg_ppad_single_base_mac
4362 * 0: base_mac, local port should be 0 and mac[7:0] is
4363 * reserved. HW will set incremental
4364 * 1: single_mac - mac of the local_port
4367 MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
4369 /* reg_ppad_local_port
4370 * port number, if single_base_mac = 0 then local_port is reserved
4373 MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
4376 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
4377 * If single_base_mac = 1 - the per port MAC address
4380 MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
4382 static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
4385 MLXSW_REG_ZERO(ppad, payload);
4386 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
4387 mlxsw_reg_ppad_local_port_set(payload, local_port);
4390 /* PAOS - Ports Administrative and Operational Status Register
4391 * -----------------------------------------------------------
4392 * Configures and retrieves per port administrative and operational status.
4394 #define MLXSW_REG_PAOS_ID 0x5006
4395 #define MLXSW_REG_PAOS_LEN 0x10
4397 MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
4400 * Switch partition ID with which to associate the port.
4401 * Note: while external ports uses unique local port numbers (and thus swid is
4402 * redundant), router ports use the same local port number where swid is the
4403 * only indication for the relevant port.
4406 MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
4408 /* reg_paos_local_port
4409 * Local port number.
4412 MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
4414 /* reg_paos_admin_status
4415 * Port administrative state (the desired state of the port):
4418 * 3 - Up once. This means that in case of link failure, the port won't go
4419 * into polling mode, but will wait to be re-enabled by software.
4420 * 4 - Disabled by system. Can only be set by hardware.
4423 MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
4425 /* reg_paos_oper_status
4426 * Port operational state (the current state):
4429 * 3 - Down by port failure. This means that the device will not let the
4430 * port up again until explicitly specified by software.
4433 MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
4436 * Admin state update enabled.
4439 MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
4442 * Event update enable. If this bit is set, event generation will be
4443 * updated based on the e field.
4446 MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
4449 * Event generation on operational state change:
4450 * 0 - Do not generate event.
4451 * 1 - Generate Event.
4452 * 2 - Generate Single Event.
4455 MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
4457 static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
4458 enum mlxsw_port_admin_status status)
4460 MLXSW_REG_ZERO(paos, payload);
4461 mlxsw_reg_paos_swid_set(payload, 0);
4462 mlxsw_reg_paos_local_port_set(payload, local_port);
4463 mlxsw_reg_paos_admin_status_set(payload, status);
4464 mlxsw_reg_paos_oper_status_set(payload, 0);
4465 mlxsw_reg_paos_ase_set(payload, 1);
4466 mlxsw_reg_paos_ee_set(payload, 1);
4467 mlxsw_reg_paos_e_set(payload, 1);
4470 /* PFCC - Ports Flow Control Configuration Register
4471 * ------------------------------------------------
4472 * Configures and retrieves the per port flow control configuration.
4474 #define MLXSW_REG_PFCC_ID 0x5007
4475 #define MLXSW_REG_PFCC_LEN 0x20
4477 MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
4479 /* reg_pfcc_local_port
4480 * Local port number.
4483 MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
4486 * Port number access type. Determines the way local_port is interpreted:
4487 * 0 - Local port number.
4488 * 1 - IB / label port number.
4491 MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
4494 * Send to higher layers capabilities:
4495 * 0 - No capability of sending Pause and PFC frames to higher layers.
4496 * 1 - Device has capability of sending Pause and PFC frames to higher
4500 MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4503 * Send to higher layers operation:
4504 * 0 - Pause and PFC frames are handled by the port (default).
4505 * 1 - Pause and PFC frames are handled by the port and also sent to
4506 * higher layers. Only valid if shl_cap = 1.
4509 MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4512 * Pause policy auto negotiation.
4513 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
4514 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
4515 * based on the auto-negotiation resolution.
4518 * Note: The auto-negotiation advertisement is set according to pptx and
4519 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
4521 MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4523 /* reg_pfcc_prio_mask_tx
4524 * Bit per priority indicating if Tx flow control policy should be
4525 * updated based on bit pfctx.
4528 MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4530 /* reg_pfcc_prio_mask_rx
4531 * Bit per priority indicating if Rx flow control policy should be
4532 * updated based on bit pfcrx.
4535 MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4538 * Admin Pause policy on Tx.
4539 * 0 - Never generate Pause frames (default).
4540 * 1 - Generate Pause frames according to Rx buffer threshold.
4543 MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4546 * Active (operational) Pause policy on Tx.
4547 * 0 - Never generate Pause frames.
4548 * 1 - Generate Pause frames according to Rx buffer threshold.
4551 MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4554 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
4555 * 0 - Never generate priority Pause frames on the specified priority
4557 * 1 - Generate priority Pause frames according to Rx buffer threshold on
4558 * the specified priority.
4561 * Note: pfctx and pptx must be mutually exclusive.
4563 MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4566 * Admin Pause policy on Rx.
4567 * 0 - Ignore received Pause frames (default).
4568 * 1 - Respect received Pause frames.
4571 MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4574 * Active (operational) Pause policy on Rx.
4575 * 0 - Ignore received Pause frames.
4576 * 1 - Respect received Pause frames.
4579 MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4582 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
4583 * 0 - Ignore incoming priority Pause frames on the specified priority
4585 * 1 - Respect incoming priority Pause frames on the specified priority.
4588 MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4590 #define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4592 static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4594 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4595 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4596 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4597 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4600 static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
4602 MLXSW_REG_ZERO(pfcc, payload);
4603 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4606 /* PPCNT - Ports Performance Counters Register
4607 * -------------------------------------------
4608 * The PPCNT register retrieves per port performance counters.
4610 #define MLXSW_REG_PPCNT_ID 0x5008
4611 #define MLXSW_REG_PPCNT_LEN 0x100
4612 #define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
4614 MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
4617 * For HCA: must be always 0.
4618 * Switch partition ID to associate port with.
4619 * Switch partitions are numbered from 0 to 7 inclusively.
4620 * Switch partition 254 indicates stacking ports.
4621 * Switch partition 255 indicates all switch partitions.
4622 * Only valid on Set() operation with local_port=255.
4625 MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4627 /* reg_ppcnt_local_port
4628 * Local port number.
4629 * 255 indicates all ports on the device, and is only allowed
4630 * for Set() operation.
4633 MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
4636 * Port number access type:
4637 * 0 - Local port number
4638 * 1 - IB port number
4641 MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4643 enum mlxsw_reg_ppcnt_grp {
4644 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
4645 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
4646 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
4647 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
4648 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
4649 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
4650 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
4651 MLXSW_REG_PPCNT_TC_CNT = 0x11,
4652 MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
4656 * Performance counter group.
4657 * Group 63 indicates all groups. Only valid on Set() operation with
4659 * 0x0: IEEE 802.3 Counters
4660 * 0x1: RFC 2863 Counters
4661 * 0x2: RFC 2819 Counters
4662 * 0x3: RFC 3635 Counters
4663 * 0x5: Ethernet Extended Counters
4664 * 0x6: Ethernet Discard Counters
4665 * 0x8: Link Level Retransmission Counters
4666 * 0x10: Per Priority Counters
4667 * 0x11: Per Traffic Class Counters
4668 * 0x12: Physical Layer Counters
4669 * 0x13: Per Traffic Class Congestion Counters
4672 MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4675 * Clear counters. Setting the clr bit will reset the counter value
4676 * for all counters in the counter group. This bit can be set
4677 * for both Set() and Get() operation.
4680 MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4682 /* reg_ppcnt_prio_tc
4683 * Priority for counter set that support per priority, valid values: 0-7.
4684 * Traffic class for counter set that support per traffic class,
4685 * valid values: 0- cap_max_tclass-1 .
4686 * For HCA: cap_max_tclass is always 8.
4687 * Otherwise must be 0.
4690 MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
4692 /* Ethernet IEEE 802.3 Counter Group */
4694 /* reg_ppcnt_a_frames_transmitted_ok
4697 MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
4698 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4700 /* reg_ppcnt_a_frames_received_ok
4703 MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
4704 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4706 /* reg_ppcnt_a_frame_check_sequence_errors
4709 MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
4710 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
4712 /* reg_ppcnt_a_alignment_errors
4715 MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
4716 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
4718 /* reg_ppcnt_a_octets_transmitted_ok
4721 MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
4722 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
4724 /* reg_ppcnt_a_octets_received_ok
4727 MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
4728 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
4730 /* reg_ppcnt_a_multicast_frames_xmitted_ok
4733 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
4734 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
4736 /* reg_ppcnt_a_broadcast_frames_xmitted_ok
4739 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
4740 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
4742 /* reg_ppcnt_a_multicast_frames_received_ok
4745 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
4746 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4748 /* reg_ppcnt_a_broadcast_frames_received_ok
4751 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
4752 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
4754 /* reg_ppcnt_a_in_range_length_errors
4757 MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
4758 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
4760 /* reg_ppcnt_a_out_of_range_length_field
4763 MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
4764 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4766 /* reg_ppcnt_a_frame_too_long_errors
4769 MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
4770 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4772 /* reg_ppcnt_a_symbol_error_during_carrier
4775 MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
4776 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4778 /* reg_ppcnt_a_mac_control_frames_transmitted
4781 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
4782 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4784 /* reg_ppcnt_a_mac_control_frames_received
4787 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
4788 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4790 /* reg_ppcnt_a_unsupported_opcodes_received
4793 MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
4794 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4796 /* reg_ppcnt_a_pause_mac_ctrl_frames_received
4799 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
4800 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4802 /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
4805 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
4806 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4808 /* Ethernet RFC 2863 Counter Group */
4810 /* reg_ppcnt_if_in_discards
4813 MLXSW_ITEM64(reg, ppcnt, if_in_discards,
4814 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
4816 /* reg_ppcnt_if_out_discards
4819 MLXSW_ITEM64(reg, ppcnt, if_out_discards,
4820 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
4822 /* reg_ppcnt_if_out_errors
4825 MLXSW_ITEM64(reg, ppcnt, if_out_errors,
4826 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4828 /* Ethernet RFC 2819 Counter Group */
4830 /* reg_ppcnt_ether_stats_undersize_pkts
4833 MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
4834 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
4836 /* reg_ppcnt_ether_stats_oversize_pkts
4839 MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
4840 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
4842 /* reg_ppcnt_ether_stats_fragments
4845 MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
4846 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4848 /* reg_ppcnt_ether_stats_pkts64octets
4851 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
4852 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4854 /* reg_ppcnt_ether_stats_pkts65to127octets
4857 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
4858 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4860 /* reg_ppcnt_ether_stats_pkts128to255octets
4863 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
4864 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4866 /* reg_ppcnt_ether_stats_pkts256to511octets
4869 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
4870 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4872 /* reg_ppcnt_ether_stats_pkts512to1023octets
4875 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
4876 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4878 /* reg_ppcnt_ether_stats_pkts1024to1518octets
4881 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
4882 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4884 /* reg_ppcnt_ether_stats_pkts1519to2047octets
4887 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
4888 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4890 /* reg_ppcnt_ether_stats_pkts2048to4095octets
4893 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
4894 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4896 /* reg_ppcnt_ether_stats_pkts4096to8191octets
4899 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
4900 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
4902 /* reg_ppcnt_ether_stats_pkts8192to10239octets
4905 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
4906 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
4908 /* Ethernet RFC 3635 Counter Group */
4910 /* reg_ppcnt_dot3stats_fcs_errors
4913 MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
4914 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4916 /* reg_ppcnt_dot3stats_symbol_errors
4919 MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
4920 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4922 /* reg_ppcnt_dot3control_in_unknown_opcodes
4925 MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
4926 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4928 /* reg_ppcnt_dot3in_pause_frames
4931 MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
4932 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4934 /* Ethernet Extended Counter Group Counters */
4936 /* reg_ppcnt_ecn_marked
4939 MLXSW_ITEM64(reg, ppcnt, ecn_marked,
4940 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4942 /* Ethernet Discard Counter Group Counters */
4944 /* reg_ppcnt_ingress_general
4947 MLXSW_ITEM64(reg, ppcnt, ingress_general,
4948 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4950 /* reg_ppcnt_ingress_policy_engine
4953 MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
4954 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4956 /* reg_ppcnt_ingress_vlan_membership
4959 MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
4960 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
4962 /* reg_ppcnt_ingress_tag_frame_type
4965 MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
4966 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
4968 /* reg_ppcnt_egress_vlan_membership
4971 MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
4972 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
4974 /* reg_ppcnt_loopback_filter
4977 MLXSW_ITEM64(reg, ppcnt, loopback_filter,
4978 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
4980 /* reg_ppcnt_egress_general
4983 MLXSW_ITEM64(reg, ppcnt, egress_general,
4984 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
4986 /* reg_ppcnt_egress_hoq
4989 MLXSW_ITEM64(reg, ppcnt, egress_hoq,
4990 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4992 /* reg_ppcnt_egress_policy_engine
4995 MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
4996 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
4998 /* reg_ppcnt_ingress_tx_link_down
5001 MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
5002 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5004 /* reg_ppcnt_egress_stp_filter
5007 MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
5008 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5010 /* reg_ppcnt_egress_sll
5013 MLXSW_ITEM64(reg, ppcnt, egress_sll,
5014 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5016 /* Ethernet Per Priority Group Counters */
5018 /* reg_ppcnt_rx_octets
5021 MLXSW_ITEM64(reg, ppcnt, rx_octets,
5022 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5024 /* reg_ppcnt_rx_frames
5027 MLXSW_ITEM64(reg, ppcnt, rx_frames,
5028 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5030 /* reg_ppcnt_tx_octets
5033 MLXSW_ITEM64(reg, ppcnt, tx_octets,
5034 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5036 /* reg_ppcnt_tx_frames
5039 MLXSW_ITEM64(reg, ppcnt, tx_frames,
5040 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5042 /* reg_ppcnt_rx_pause
5045 MLXSW_ITEM64(reg, ppcnt, rx_pause,
5046 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5048 /* reg_ppcnt_rx_pause_duration
5051 MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
5052 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5054 /* reg_ppcnt_tx_pause
5057 MLXSW_ITEM64(reg, ppcnt, tx_pause,
5058 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5060 /* reg_ppcnt_tx_pause_duration
5063 MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
5064 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5066 /* reg_ppcnt_rx_pause_transition
5069 MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
5070 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5072 /* Ethernet Per Traffic Group Counters */
5074 /* reg_ppcnt_tc_transmit_queue
5075 * Contains the transmit queue depth in cells of traffic class
5076 * selected by prio_tc and the port selected by local_port.
5077 * The field cannot be cleared.
5080 MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
5081 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5083 /* reg_ppcnt_tc_no_buffer_discard_uc
5084 * The number of unicast packets dropped due to lack of shared
5088 MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
5089 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5091 /* Ethernet Per Traffic Class Congestion Group Counters */
5093 /* reg_ppcnt_wred_discard
5096 MLXSW_ITEM64(reg, ppcnt, wred_discard,
5097 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5099 static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
5100 enum mlxsw_reg_ppcnt_grp grp,
5103 MLXSW_REG_ZERO(ppcnt, payload);
5104 mlxsw_reg_ppcnt_swid_set(payload, 0);
5105 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
5106 mlxsw_reg_ppcnt_pnat_set(payload, 0);
5107 mlxsw_reg_ppcnt_grp_set(payload, grp);
5108 mlxsw_reg_ppcnt_clr_set(payload, 0);
5109 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
5112 /* PLIB - Port Local to InfiniBand Port
5113 * ------------------------------------
5114 * The PLIB register performs mapping from Local Port into InfiniBand Port.
5116 #define MLXSW_REG_PLIB_ID 0x500A
5117 #define MLXSW_REG_PLIB_LEN 0x10
5119 MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
5121 /* reg_plib_local_port
5122 * Local port number.
5125 MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
5128 * InfiniBand port remapping for local_port.
5131 MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
5133 /* PPTB - Port Prio To Buffer Register
5134 * -----------------------------------
5135 * Configures the switch priority to buffer table.
5137 #define MLXSW_REG_PPTB_ID 0x500B
5138 #define MLXSW_REG_PPTB_LEN 0x10
5140 MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
5143 MLXSW_REG_PPTB_MM_UM,
5144 MLXSW_REG_PPTB_MM_UNICAST,
5145 MLXSW_REG_PPTB_MM_MULTICAST,
5150 * 0 - Map both unicast and multicast packets to the same buffer.
5151 * 1 - Map only unicast packets.
5152 * 2 - Map only multicast packets.
5155 * Note: SwitchX-2 only supports the first option.
5157 MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
5159 /* reg_pptb_local_port
5160 * Local port number.
5163 MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
5166 * Enables the update of the untagged_buf field.
5169 MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
5172 * Enables the update of the prio_to_buff field.
5173 * Bit <i> is a flag for updating the mapping for switch priority <i>.
5176 MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
5178 /* reg_pptb_prio_to_buff
5179 * Mapping of switch priority <i> to one of the allocated receive port
5183 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
5186 * Enables the update of the prio_to_buff field.
5187 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
5190 MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
5192 /* reg_pptb_untagged_buff
5193 * Mapping of untagged frames to one of the allocated receive port buffers.
5196 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
5197 * Spectrum, as it maps untagged packets based on the default switch priority.
5199 MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
5201 /* reg_pptb_prio_to_buff_msb
5202 * Mapping of switch priority <i+8> to one of the allocated receive port
5206 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
5208 #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
5210 static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
5212 MLXSW_REG_ZERO(pptb, payload);
5213 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
5214 mlxsw_reg_pptb_local_port_set(payload, local_port);
5215 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5216 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5219 static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
5222 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
5223 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
5226 /* PBMC - Port Buffer Management Control Register
5227 * ----------------------------------------------
5228 * The PBMC register configures and retrieves the port packet buffer
5229 * allocation for different Prios, and the Pause threshold management.
5231 #define MLXSW_REG_PBMC_ID 0x500C
5232 #define MLXSW_REG_PBMC_LEN 0x6C
5234 MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
5236 /* reg_pbmc_local_port
5237 * Local port number.
5240 MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
5242 /* reg_pbmc_xoff_timer_value
5243 * When device generates a pause frame, it uses this value as the pause
5244 * timer (time for the peer port to pause in quota-512 bit time).
5247 MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
5249 /* reg_pbmc_xoff_refresh
5250 * The time before a new pause frame should be sent to refresh the pause RW
5251 * state. Using the same units as xoff_timer_value above (in quota-512 bit
5255 MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
5257 #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
5259 /* reg_pbmc_buf_lossy
5260 * The field indicates if the buffer is lossy.
5265 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
5267 /* reg_pbmc_buf_epsb
5268 * Eligible for Port Shared buffer.
5269 * If epsb is set, packets assigned to buffer are allowed to insert the port
5271 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
5274 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
5276 /* reg_pbmc_buf_size
5277 * The part of the packet buffer array is allocated for the specific buffer.
5278 * Units are represented in cells.
5281 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
5283 /* reg_pbmc_buf_xoff_threshold
5284 * Once the amount of data in the buffer goes above this value, device
5285 * starts sending PFC frames for all priorities associated with the
5286 * buffer. Units are represented in cells. Reserved in case of lossy
5290 * Note: In Spectrum, reserved for buffer[9].
5292 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
5295 /* reg_pbmc_buf_xon_threshold
5296 * When the amount of data in the buffer goes below this value, device
5297 * stops sending PFC frames for the priorities associated with the
5298 * buffer. Units are represented in cells. Reserved in case of lossy
5302 * Note: In Spectrum, reserved for buffer[9].
5304 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
5307 static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
5308 u16 xoff_timer_value, u16 xoff_refresh)
5310 MLXSW_REG_ZERO(pbmc, payload);
5311 mlxsw_reg_pbmc_local_port_set(payload, local_port);
5312 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
5313 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
5316 static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
5320 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
5321 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5322 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5325 static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
5326 int buf_index, u16 size,
5329 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
5330 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5331 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5332 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
5333 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
5336 /* PSPA - Port Switch Partition Allocation
5337 * ---------------------------------------
5338 * Controls the association of a port with a switch partition and enables
5339 * configuring ports as stacking ports.
5341 #define MLXSW_REG_PSPA_ID 0x500D
5342 #define MLXSW_REG_PSPA_LEN 0x8
5344 MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
5347 * Switch partition ID.
5350 MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
5352 /* reg_pspa_local_port
5353 * Local port number.
5356 MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
5358 /* reg_pspa_sub_port
5359 * Virtual port within the local port. Set to 0 when virtual ports are
5360 * disabled on the local port.
5363 MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
5365 static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
5367 MLXSW_REG_ZERO(pspa, payload);
5368 mlxsw_reg_pspa_swid_set(payload, swid);
5369 mlxsw_reg_pspa_local_port_set(payload, local_port);
5370 mlxsw_reg_pspa_sub_port_set(payload, 0);
5373 /* PPLR - Port Physical Loopback Register
5374 * --------------------------------------
5375 * This register allows configuration of the port's loopback mode.
5377 #define MLXSW_REG_PPLR_ID 0x5018
5378 #define MLXSW_REG_PPLR_LEN 0x8
5380 MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
5382 /* reg_pplr_local_port
5383 * Local port number.
5386 MLXSW_ITEM32(reg, pplr, local_port, 0x00, 16, 8);
5388 /* Phy local loopback. When set the port's egress traffic is looped back
5389 * to the receiver and the port transmitter is disabled.
5391 #define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
5397 MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
5399 static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port,
5402 MLXSW_REG_ZERO(pplr, payload);
5403 mlxsw_reg_pplr_local_port_set(payload, local_port);
5404 mlxsw_reg_pplr_lb_en_set(payload,
5406 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
5409 /* PMTM - Port Module Type Mapping Register
5410 * ----------------------------------------
5411 * The PMTM allows query or configuration of module types.
5413 #define MLXSW_REG_PMTM_ID 0x5067
5414 #define MLXSW_REG_PMTM_LEN 0x10
5416 MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
5422 MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
5424 enum mlxsw_reg_pmtm_module_type {
5425 /* Backplane with 4 lanes */
5426 MLXSW_REG_PMTM_MODULE_TYPE_BP_4X,
5428 MLXSW_REG_PMTM_MODULE_TYPE_BP_QSFP,
5430 MLXSW_REG_PMTM_MODULE_TYPE_BP_SFP,
5431 /* Backplane with single lane */
5432 MLXSW_REG_PMTM_MODULE_TYPE_BP_1X = 4,
5433 /* Backplane with two lane */
5434 MLXSW_REG_PMTM_MODULE_TYPE_BP_2X = 8,
5436 MLXSW_REG_PMTM_MODULE_TYPE_C2C = 10,
5439 /* reg_pmtm_module_type
5443 MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 4);
5445 static inline void mlxsw_reg_pmtm_pack(char *payload, u8 module)
5447 MLXSW_REG_ZERO(pmtm, payload);
5448 mlxsw_reg_pmtm_module_set(payload, module);
5452 mlxsw_reg_pmtm_unpack(char *payload,
5453 enum mlxsw_reg_pmtm_module_type *module_type)
5455 *module_type = mlxsw_reg_pmtm_module_type_get(payload);
5458 /* HTGT - Host Trap Group Table
5459 * ----------------------------
5460 * Configures the properties for forwarding to CPU.
5462 #define MLXSW_REG_HTGT_ID 0x7002
5463 #define MLXSW_REG_HTGT_LEN 0x20
5465 MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
5468 * Switch partition ID.
5471 MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
5473 #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
5479 MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
5481 enum mlxsw_reg_htgt_trap_group {
5482 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
5483 MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX,
5484 MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL,
5485 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
5486 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
5487 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
5488 MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP,
5489 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
5490 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
5491 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
5492 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
5493 MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP,
5494 MLXSW_REG_HTGT_TRAP_GROUP_SP_HOST_MISS,
5495 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
5496 MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
5497 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
5498 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
5499 MLXSW_REG_HTGT_TRAP_GROUP_SP_RPF,
5500 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
5501 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_MLD,
5502 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_ND,
5503 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
5504 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
5505 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
5506 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
5508 __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
5509 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
5512 enum mlxsw_reg_htgt_discard_trap_group {
5513 MLXSW_REG_HTGT_DISCARD_TRAP_GROUP_BASE = MLXSW_REG_HTGT_TRAP_GROUP_MAX,
5514 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
5515 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
5518 /* reg_htgt_trap_group
5519 * Trap group number. User defined number specifying which trap groups
5520 * should be forwarded to the CPU. The mapping between trap IDs and trap
5521 * groups is configured using HPKT register.
5524 MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
5527 MLXSW_REG_HTGT_POLICER_DISABLE,
5528 MLXSW_REG_HTGT_POLICER_ENABLE,
5532 * Enable policer ID specified using 'pid' field.
5535 MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
5537 #define MLXSW_REG_HTGT_INVALID_POLICER 0xff
5540 * Policer ID for the trap group.
5543 MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
5545 #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
5547 /* reg_htgt_mirror_action
5548 * Mirror action to use.
5550 * 1 - Trap to CPU and mirror to a mirroring agent.
5551 * 2 - Mirror to a mirroring agent and do not trap to CPU.
5554 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
5556 MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
5558 /* reg_htgt_mirroring_agent
5562 MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
5564 #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
5566 /* reg_htgt_priority
5567 * Trap group priority.
5568 * In case a packet matches multiple classification rules, the packet will
5569 * only be trapped once, based on the trap ID associated with the group (via
5570 * register HPKT) with the highest priority.
5571 * Supported values are 0-7, with 7 represnting the highest priority.
5574 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
5575 * by the 'trap_group' field.
5577 MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
5579 #define MLXSW_REG_HTGT_DEFAULT_TC 7
5581 /* reg_htgt_local_path_cpu_tclass
5582 * CPU ingress traffic class for the trap group.
5585 MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
5587 enum mlxsw_reg_htgt_local_path_rdq {
5588 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
5589 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
5590 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
5591 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
5593 /* reg_htgt_local_path_rdq
5594 * Receive descriptor queue (RDQ) to use for the trap group.
5597 MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
5599 static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
5602 MLXSW_REG_ZERO(htgt, payload);
5604 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
5605 mlxsw_reg_htgt_pide_set(payload,
5606 MLXSW_REG_HTGT_POLICER_DISABLE);
5608 mlxsw_reg_htgt_pide_set(payload,
5609 MLXSW_REG_HTGT_POLICER_ENABLE);
5610 mlxsw_reg_htgt_pid_set(payload, policer_id);
5613 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
5614 mlxsw_reg_htgt_trap_group_set(payload, group);
5615 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
5616 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
5617 mlxsw_reg_htgt_priority_set(payload, priority);
5618 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
5619 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
5622 /* HPKT - Host Packet Trap
5623 * -----------------------
5624 * Configures trap IDs inside trap groups.
5626 #define MLXSW_REG_HPKT_ID 0x7003
5627 #define MLXSW_REG_HPKT_LEN 0x10
5629 MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
5632 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
5633 MLXSW_REG_HPKT_ACK_REQUIRED,
5637 * Require acknowledgements from the host for events.
5638 * If set, then the device will wait for the event it sent to be acknowledged
5639 * by the host. This option is only relevant for event trap IDs.
5642 * Note: Currently not supported by firmware.
5644 MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
5646 enum mlxsw_reg_hpkt_action {
5647 MLXSW_REG_HPKT_ACTION_FORWARD,
5648 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
5649 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
5650 MLXSW_REG_HPKT_ACTION_DISCARD,
5651 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
5652 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
5653 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
5654 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
5658 * Action to perform on packet when trapped.
5659 * 0 - No action. Forward to CPU based on switching rules.
5660 * 1 - Trap to CPU (CPU receives sole copy).
5661 * 2 - Mirror to CPU (CPU receives a replica of the packet).
5663 * 4 - Soft discard (allow other traps to act on the packet).
5664 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
5665 * 6 - Trap to CPU (CPU receives sole copy) and count it as error.
5666 * 15 - Restore the firmware's default action.
5669 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
5670 * addressed to the CPU.
5672 MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
5674 /* reg_hpkt_trap_group
5675 * Trap group to associate the trap with.
5678 MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
5684 * Note: A trap ID can only be associated with a single trap group. The device
5685 * will associate the trap ID with the last trap group configured.
5687 MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
5690 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
5691 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
5692 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
5696 * Configure dedicated buffer resources for control packets.
5697 * Ignored by SwitchX-2.
5698 * 0 - Keep factory defaults.
5699 * 1 - Do not use control buffer for this trap ID.
5700 * 2 - Use control buffer for this trap ID.
5703 MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
5705 static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
5706 enum mlxsw_reg_htgt_trap_group trap_group,
5709 MLXSW_REG_ZERO(hpkt, payload);
5710 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
5711 mlxsw_reg_hpkt_action_set(payload, action);
5712 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
5713 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
5714 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
5715 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
5716 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
5719 /* RGCR - Router General Configuration Register
5720 * --------------------------------------------
5721 * The register is used for setting up the router configuration.
5723 #define MLXSW_REG_RGCR_ID 0x8001
5724 #define MLXSW_REG_RGCR_LEN 0x28
5726 MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
5729 * IPv4 router enable.
5732 MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
5735 * IPv6 router enable.
5738 MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
5740 /* reg_rgcr_max_router_interfaces
5741 * Defines the maximum number of active router interfaces for all virtual
5745 MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
5748 * Update switch priority and packet color.
5749 * 0 - Preserve the value of Switch Priority and packet color.
5750 * 1 - Recalculate the value of Switch Priority and packet color.
5753 * Note: Not supported by SwitchX and SwitchX-2.
5755 MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
5758 * Indicates how to handle the pcp_rewrite_en value:
5759 * 0 - Preserve the value of pcp_rewrite_en.
5760 * 2 - Disable PCP rewrite.
5761 * 3 - Enable PCP rewrite.
5764 * Note: Not supported by SwitchX and SwitchX-2.
5766 MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
5768 /* reg_rgcr_activity_dis
5770 * 0 - Activity will be set when an entry is hit (default).
5771 * 1 - Activity will not be set when an entry is hit.
5773 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
5775 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
5777 * Bits 2:7 are reserved.
5780 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
5782 MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
5784 static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
5787 MLXSW_REG_ZERO(rgcr, payload);
5788 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
5789 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
5792 /* RITR - Router Interface Table Register
5793 * --------------------------------------
5794 * The register is used to configure the router interface table.
5796 #define MLXSW_REG_RITR_ID 0x8002
5797 #define MLXSW_REG_RITR_LEN 0x40
5799 MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
5802 * Enables routing on the router interface.
5805 MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
5808 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
5812 MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
5815 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
5819 MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
5822 * IPv4 multicast routing enable.
5825 MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
5828 * IPv6 multicast routing enable.
5831 MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
5833 enum mlxsw_reg_ritr_if_type {
5834 /* VLAN interface. */
5835 MLXSW_REG_RITR_VLAN_IF,
5836 /* FID interface. */
5837 MLXSW_REG_RITR_FID_IF,
5838 /* Sub-port interface. */
5839 MLXSW_REG_RITR_SP_IF,
5840 /* Loopback Interface. */
5841 MLXSW_REG_RITR_LOOPBACK_IF,
5845 * Router interface type as per enum mlxsw_reg_ritr_if_type.
5848 MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
5851 MLXSW_REG_RITR_RIF_CREATE,
5852 MLXSW_REG_RITR_RIF_DEL,
5857 * 0 - Create or edit RIF.
5859 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
5860 * is not supported. An interface must be deleted and re-created in order
5861 * to update properties.
5864 MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
5867 * Router interface index. A pointer to the Router Interface Table.
5870 MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
5873 * IPv4 Forwarding Enable.
5874 * Enables routing of IPv4 traffic on the router interface. When disabled,
5875 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
5876 * Not supported in SwitchX-2.
5879 MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
5882 * IPv6 Forwarding Enable.
5883 * Enables routing of IPv6 traffic on the router interface. When disabled,
5884 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
5885 * Not supported in SwitchX-2.
5888 MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
5890 /* reg_ritr_ipv4_mc_fe
5891 * IPv4 Multicast Forwarding Enable.
5892 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
5896 MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
5898 /* reg_ritr_ipv6_mc_fe
5899 * IPv6 Multicast Forwarding Enable.
5900 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
5904 MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
5907 * Loop-back filter enable for unicast packets.
5908 * If the flag is set then loop-back filter for unicast packets is
5909 * implemented on the RIF. Multicast packets are always subject to
5910 * loop-back filtering.
5913 MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
5915 /* reg_ritr_virtual_router
5916 * Virtual router ID associated with the router interface.
5919 MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
5922 * Router interface MTU.
5925 MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
5928 * Switch partition ID.
5931 MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
5934 * Router interface MAC address.
5935 * In Spectrum, all MAC addresses must have the same 38 MSBits.
5938 MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
5940 /* reg_ritr_if_vrrp_id_ipv6
5942 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
5945 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
5947 /* reg_ritr_if_vrrp_id_ipv4
5949 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
5952 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
5954 /* VLAN Interface */
5956 /* reg_ritr_vlan_if_vid
5960 MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
5964 /* reg_ritr_fid_if_fid
5965 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
5966 * the vFID range are supported.
5969 MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
5971 static inline void mlxsw_reg_ritr_fid_set(char *payload,
5972 enum mlxsw_reg_ritr_if_type rif_type,
5975 if (rif_type == MLXSW_REG_RITR_FID_IF)
5976 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
5978 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
5981 /* Sub-port Interface */
5983 /* reg_ritr_sp_if_lag
5984 * LAG indication. When this bit is set the system_port field holds the
5988 MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
5990 /* reg_ritr_sp_system_port
5991 * Port unique indentifier. When lag bit is set, this field holds the
5992 * lag_id in bits 0:9.
5995 MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
5997 /* reg_ritr_sp_if_vid
6001 MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
6003 /* Loopback Interface */
6005 enum mlxsw_reg_ritr_loopback_protocol {
6006 /* IPinIP IPv4 underlay Unicast */
6007 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
6008 /* IPinIP IPv6 underlay Unicast */
6009 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
6010 /* IPinIP generic - used for Spectrum-2 underlay RIF */
6011 MLXSW_REG_RITR_LOOPBACK_GENERIC,
6014 /* reg_ritr_loopback_protocol
6017 MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
6019 enum mlxsw_reg_ritr_loopback_ipip_type {
6020 /* Tunnel is IPinIP. */
6021 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
6022 /* Tunnel is GRE, no key. */
6023 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
6024 /* Tunnel is GRE, with a key. */
6025 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
6028 /* reg_ritr_loopback_ipip_type
6029 * Encapsulation type.
6032 MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
6034 enum mlxsw_reg_ritr_loopback_ipip_options {
6035 /* The key is defined by gre_key. */
6036 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
6039 /* reg_ritr_loopback_ipip_options
6042 MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
6044 /* reg_ritr_loopback_ipip_uvr
6045 * Underlay Virtual Router ID.
6046 * Range is 0..cap_max_virtual_routers-1.
6047 * Reserved for Spectrum-2.
6050 MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
6052 /* reg_ritr_loopback_ipip_underlay_rif
6053 * Underlay ingress router interface.
6054 * Reserved for Spectrum.
6057 MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
6059 /* reg_ritr_loopback_ipip_usip*
6060 * Encapsulation Underlay source IP.
6063 MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
6064 MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
6066 /* reg_ritr_loopback_ipip_gre_key
6068 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
6071 MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
6073 /* Shared between ingress/egress */
6074 enum mlxsw_reg_ritr_counter_set_type {
6076 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
6077 /* Basic. Used for router interfaces, counting the following:
6078 * - Error and Discard counters.
6079 * - Unicast, Multicast and Broadcast counters. Sharing the
6080 * same set of counters for the different type of traffic
6081 * (IPv4, IPv6 and mpls).
6083 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
6086 /* reg_ritr_ingress_counter_index
6087 * Counter Index for flow counter.
6090 MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
6092 /* reg_ritr_ingress_counter_set_type
6093 * Igress Counter Set Type for router interface counter.
6096 MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
6098 /* reg_ritr_egress_counter_index
6099 * Counter Index for flow counter.
6102 MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
6104 /* reg_ritr_egress_counter_set_type
6105 * Egress Counter Set Type for router interface counter.
6108 MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
6110 static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
6111 bool enable, bool egress)
6113 enum mlxsw_reg_ritr_counter_set_type set_type;
6116 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
6118 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
6119 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
6122 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
6124 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
6127 static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
6129 MLXSW_REG_ZERO(ritr, payload);
6130 mlxsw_reg_ritr_rif_set(payload, rif);
6133 static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
6134 u16 system_port, u16 vid)
6136 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
6137 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
6138 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
6141 static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
6142 enum mlxsw_reg_ritr_if_type type,
6143 u16 rif, u16 vr_id, u16 mtu)
6145 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
6147 MLXSW_REG_ZERO(ritr, payload);
6148 mlxsw_reg_ritr_enable_set(payload, enable);
6149 mlxsw_reg_ritr_ipv4_set(payload, 1);
6150 mlxsw_reg_ritr_ipv6_set(payload, 1);
6151 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
6152 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
6153 mlxsw_reg_ritr_type_set(payload, type);
6154 mlxsw_reg_ritr_op_set(payload, op);
6155 mlxsw_reg_ritr_rif_set(payload, rif);
6156 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
6157 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
6158 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
6159 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
6160 mlxsw_reg_ritr_lb_en_set(payload, 1);
6161 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
6162 mlxsw_reg_ritr_mtu_set(payload, mtu);
6165 static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
6167 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
6171 mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
6172 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6173 enum mlxsw_reg_ritr_loopback_ipip_options options,
6174 u16 uvr_id, u16 underlay_rif, u32 gre_key)
6176 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
6177 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
6178 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
6179 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
6180 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
6184 mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
6185 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6186 enum mlxsw_reg_ritr_loopback_ipip_options options,
6187 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
6189 mlxsw_reg_ritr_loopback_protocol_set(payload,
6190 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
6191 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
6192 uvr_id, underlay_rif, gre_key);
6193 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
6196 /* RTAR - Router TCAM Allocation Register
6197 * --------------------------------------
6198 * This register is used for allocation of regions in the TCAM table.
6200 #define MLXSW_REG_RTAR_ID 0x8004
6201 #define MLXSW_REG_RTAR_LEN 0x20
6203 MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
6205 enum mlxsw_reg_rtar_op {
6206 MLXSW_REG_RTAR_OP_ALLOCATE,
6207 MLXSW_REG_RTAR_OP_RESIZE,
6208 MLXSW_REG_RTAR_OP_DEALLOCATE,
6214 MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
6216 enum mlxsw_reg_rtar_key_type {
6217 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
6218 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
6221 /* reg_rtar_key_type
6222 * TCAM key type for the region.
6225 MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
6227 /* reg_rtar_region_size
6228 * TCAM region size. When allocating/resizing this is the requested
6229 * size, the response is the actual size.
6230 * Note: Actual size may be larger than requested.
6231 * Reserved for op = Deallocate
6234 MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
6236 static inline void mlxsw_reg_rtar_pack(char *payload,
6237 enum mlxsw_reg_rtar_op op,
6238 enum mlxsw_reg_rtar_key_type key_type,
6241 MLXSW_REG_ZERO(rtar, payload);
6242 mlxsw_reg_rtar_op_set(payload, op);
6243 mlxsw_reg_rtar_key_type_set(payload, key_type);
6244 mlxsw_reg_rtar_region_size_set(payload, region_size);
6247 /* RATR - Router Adjacency Table Register
6248 * --------------------------------------
6249 * The RATR register is used to configure the Router Adjacency (next-hop)
6252 #define MLXSW_REG_RATR_ID 0x8008
6253 #define MLXSW_REG_RATR_LEN 0x2C
6255 MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
6257 enum mlxsw_reg_ratr_op {
6259 MLXSW_REG_RATR_OP_QUERY_READ = 0,
6260 /* Read and clear activity */
6261 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
6262 /* Write Adjacency entry */
6263 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
6264 /* Write Adjacency entry only if the activity is cleared.
6265 * The write may not succeed if the activity is set. There is not
6266 * direct feedback if the write has succeeded or not, however
6267 * the get will reveal the actual entry (SW can compare the get
6268 * response to the set command).
6270 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
6274 * Note that Write operation may also be used for updating
6275 * counter_set_type and counter_index. In this case all other
6276 * fields must not be updated.
6279 MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
6282 * Valid bit. Indicates if the adjacency entry is valid.
6283 * Note: the device may need some time before reusing an invalidated
6284 * entry. During this time the entry can not be reused. It is
6285 * recommended to use another entry before reusing an invalidated
6286 * entry (e.g. software can put it at the end of the list for
6287 * reusing). Trying to access an invalidated entry not yet cleared
6288 * by the device results with failure indicating "Try Again" status.
6289 * When valid is '0' then egress_router_interface,trap_action,
6290 * adjacency_parameters and counters are reserved
6293 MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
6296 * Activity. Set for new entries. Set if a packet lookup has hit on
6297 * the specific entry. To clear the a bit, use "clear activity".
6300 MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
6302 enum mlxsw_reg_ratr_type {
6304 MLXSW_REG_RATR_TYPE_ETHERNET,
6305 /* IPoIB Unicast without GRH.
6306 * Reserved for Spectrum.
6308 MLXSW_REG_RATR_TYPE_IPOIB_UC,
6309 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
6311 * Reserved for Spectrum.
6313 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
6315 * Reserved for Spectrum.
6317 MLXSW_REG_RATR_TYPE_IPOIB_MC,
6319 * Reserved for SwitchX/-2.
6321 MLXSW_REG_RATR_TYPE_MPLS,
6323 * Reserved for SwitchX/-2.
6325 MLXSW_REG_RATR_TYPE_IPIP,
6329 * Adjacency entry type.
6332 MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
6334 /* reg_ratr_adjacency_index_low
6335 * Bits 15:0 of index into the adjacency table.
6336 * For SwitchX and SwitchX-2, the adjacency table is linear and
6337 * used for adjacency entries only.
6338 * For Spectrum, the index is to the KVD linear.
6341 MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
6343 /* reg_ratr_egress_router_interface
6344 * Range is 0 .. cap_max_router_interfaces - 1
6347 MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
6349 enum mlxsw_reg_ratr_trap_action {
6350 MLXSW_REG_RATR_TRAP_ACTION_NOP,
6351 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
6352 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
6353 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
6354 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
6357 /* reg_ratr_trap_action
6358 * see mlxsw_reg_ratr_trap_action
6361 MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
6363 /* reg_ratr_adjacency_index_high
6364 * Bits 23:16 of the adjacency_index.
6367 MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
6369 enum mlxsw_reg_ratr_trap_id {
6370 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
6371 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
6375 * Trap ID to be reported to CPU.
6376 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
6377 * For trap_action of NOP, MIRROR and DISCARD_ERROR
6380 MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
6382 /* reg_ratr_eth_destination_mac
6383 * MAC address of the destination next-hop.
6386 MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
6388 enum mlxsw_reg_ratr_ipip_type {
6389 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
6390 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
6391 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
6392 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
6395 /* reg_ratr_ipip_type
6396 * Underlay destination ip type.
6397 * Note: the type field must match the protocol of the router interface.
6400 MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
6402 /* reg_ratr_ipip_ipv4_udip
6403 * Underlay ipv4 dip.
6404 * Reserved when ipip_type is IPv6.
6407 MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
6409 /* reg_ratr_ipip_ipv6_ptr
6410 * Pointer to IPv6 underlay destination ip address.
6411 * For Spectrum: Pointer to KVD linear space.
6414 MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
6416 enum mlxsw_reg_flow_counter_set_type {
6418 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
6419 /* Count packets and bytes */
6420 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
6421 /* Count only packets */
6422 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
6425 /* reg_ratr_counter_set_type
6426 * Counter set type for flow counters
6429 MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
6431 /* reg_ratr_counter_index
6432 * Counter index for flow counters
6435 MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
6438 mlxsw_reg_ratr_pack(char *payload,
6439 enum mlxsw_reg_ratr_op op, bool valid,
6440 enum mlxsw_reg_ratr_type type,
6441 u32 adjacency_index, u16 egress_rif)
6443 MLXSW_REG_ZERO(ratr, payload);
6444 mlxsw_reg_ratr_op_set(payload, op);
6445 mlxsw_reg_ratr_v_set(payload, valid);
6446 mlxsw_reg_ratr_type_set(payload, type);
6447 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
6448 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
6449 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
6452 static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
6453 const char *dest_mac)
6455 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
6458 static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
6460 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
6461 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
6464 static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
6465 bool counter_enable)
6467 enum mlxsw_reg_flow_counter_set_type set_type;
6470 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
6472 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
6474 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
6475 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
6478 /* RDPM - Router DSCP to Priority Mapping
6479 * --------------------------------------
6480 * Controls the mapping from DSCP field to switch priority on routed packets
6482 #define MLXSW_REG_RDPM_ID 0x8009
6483 #define MLXSW_REG_RDPM_BASE_LEN 0x00
6484 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
6485 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
6486 #define MLXSW_REG_RDPM_LEN 0x40
6487 #define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
6488 MLXSW_REG_RDPM_LEN - \
6489 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
6491 MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
6494 * Enable update of the specific entry
6497 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
6498 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
6500 /* reg_dscp_entry_prio
6504 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
6505 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
6507 static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
6510 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
6511 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
6514 /* RICNT - Router Interface Counter Register
6515 * -----------------------------------------
6516 * The RICNT register retrieves per port performance counters
6518 #define MLXSW_REG_RICNT_ID 0x800B
6519 #define MLXSW_REG_RICNT_LEN 0x100
6521 MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
6523 /* reg_ricnt_counter_index
6527 MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
6529 enum mlxsw_reg_ricnt_counter_set_type {
6531 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
6532 /* Basic. Used for router interfaces, counting the following:
6533 * - Error and Discard counters.
6534 * - Unicast, Multicast and Broadcast counters. Sharing the
6535 * same set of counters for the different type of traffic
6536 * (IPv4, IPv6 and mpls).
6538 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
6541 /* reg_ricnt_counter_set_type
6542 * Counter Set Type for router interface counter
6545 MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
6547 enum mlxsw_reg_ricnt_opcode {
6548 /* Nop. Supported only for read access*/
6549 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
6550 /* Clear. Setting the clr bit will reset the counter value for
6551 * all counters of the specified Router Interface.
6553 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
6560 MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
6562 /* reg_ricnt_good_unicast_packets
6563 * good unicast packets.
6566 MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
6568 /* reg_ricnt_good_multicast_packets
6569 * good multicast packets.
6572 MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
6574 /* reg_ricnt_good_broadcast_packets
6575 * good broadcast packets
6578 MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
6580 /* reg_ricnt_good_unicast_bytes
6581 * A count of L3 data and padding octets not including L2 headers
6582 * for good unicast frames.
6585 MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
6587 /* reg_ricnt_good_multicast_bytes
6588 * A count of L3 data and padding octets not including L2 headers
6589 * for good multicast frames.
6592 MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
6594 /* reg_ritr_good_broadcast_bytes
6595 * A count of L3 data and padding octets not including L2 headers
6596 * for good broadcast frames.
6599 MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
6601 /* reg_ricnt_error_packets
6602 * A count of errored frames that do not pass the router checks.
6605 MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
6607 /* reg_ricnt_discrad_packets
6608 * A count of non-errored frames that do not pass the router checks.
6611 MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
6613 /* reg_ricnt_error_bytes
6614 * A count of L3 data and padding octets not including L2 headers
6615 * for errored frames.
6618 MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
6620 /* reg_ricnt_discard_bytes
6621 * A count of L3 data and padding octets not including L2 headers
6622 * for non-errored frames that do not pass the router checks.
6625 MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
6627 static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
6628 enum mlxsw_reg_ricnt_opcode op)
6630 MLXSW_REG_ZERO(ricnt, payload);
6631 mlxsw_reg_ricnt_op_set(payload, op);
6632 mlxsw_reg_ricnt_counter_index_set(payload, index);
6633 mlxsw_reg_ricnt_counter_set_type_set(payload,
6634 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
6637 /* RRCR - Router Rules Copy Register Layout
6638 * ----------------------------------------
6639 * This register is used for moving and copying route entry rules.
6641 #define MLXSW_REG_RRCR_ID 0x800F
6642 #define MLXSW_REG_RRCR_LEN 0x24
6644 MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
6646 enum mlxsw_reg_rrcr_op {
6648 MLXSW_REG_RRCR_OP_MOVE,
6650 MLXSW_REG_RRCR_OP_COPY,
6656 MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
6659 * Offset within the region from which to copy/move.
6662 MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
6665 * The number of rules to copy/move.
6668 MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
6670 /* reg_rrcr_table_id
6671 * Identifier of the table on which to perform the operation. Encoding is the
6672 * same as in RTAR.key_type
6675 MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
6677 /* reg_rrcr_dest_offset
6678 * Offset within the region to which to copy/move
6681 MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
6683 static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
6684 u16 offset, u16 size,
6685 enum mlxsw_reg_rtar_key_type table_id,
6688 MLXSW_REG_ZERO(rrcr, payload);
6689 mlxsw_reg_rrcr_op_set(payload, op);
6690 mlxsw_reg_rrcr_offset_set(payload, offset);
6691 mlxsw_reg_rrcr_size_set(payload, size);
6692 mlxsw_reg_rrcr_table_id_set(payload, table_id);
6693 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
6696 /* RALTA - Router Algorithmic LPM Tree Allocation Register
6697 * -------------------------------------------------------
6698 * RALTA is used to allocate the LPM trees of the SHSPM method.
6700 #define MLXSW_REG_RALTA_ID 0x8010
6701 #define MLXSW_REG_RALTA_LEN 0x04
6703 MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
6706 * opcode (valid for Write, must be 0 on Read)
6707 * 0 - allocate a tree
6708 * 1 - deallocate a tree
6711 MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
6713 enum mlxsw_reg_ralxx_protocol {
6714 MLXSW_REG_RALXX_PROTOCOL_IPV4,
6715 MLXSW_REG_RALXX_PROTOCOL_IPV6,
6718 /* reg_ralta_protocol
6720 * Deallocation opcode: Reserved.
6723 MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
6725 /* reg_ralta_tree_id
6726 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
6727 * the tree identifier (managed by software).
6728 * Note that tree_id 0 is allocated for a default-route tree.
6731 MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
6733 static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
6734 enum mlxsw_reg_ralxx_protocol protocol,
6737 MLXSW_REG_ZERO(ralta, payload);
6738 mlxsw_reg_ralta_op_set(payload, !alloc);
6739 mlxsw_reg_ralta_protocol_set(payload, protocol);
6740 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
6743 /* RALST - Router Algorithmic LPM Structure Tree Register
6744 * ------------------------------------------------------
6745 * RALST is used to set and query the structure of an LPM tree.
6746 * The structure of the tree must be sorted as a sorted binary tree, while
6747 * each node is a bin that is tagged as the length of the prefixes the lookup
6748 * will refer to. Therefore, bin X refers to a set of entries with prefixes
6749 * of X bits to match with the destination address. The bin 0 indicates
6750 * the default action, when there is no match of any prefix.
6752 #define MLXSW_REG_RALST_ID 0x8011
6753 #define MLXSW_REG_RALST_LEN 0x104
6755 MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
6757 /* reg_ralst_root_bin
6758 * The bin number of the root bin.
6759 * 0<root_bin=<(length of IP address)
6760 * For a default-route tree configure 0xff
6763 MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
6765 /* reg_ralst_tree_id
6766 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
6769 MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
6771 #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
6772 #define MLXSW_REG_RALST_BIN_OFFSET 0x04
6773 #define MLXSW_REG_RALST_BIN_COUNT 128
6775 /* reg_ralst_left_child_bin
6776 * Holding the children of the bin according to the stored tree's structure.
6777 * For trees composed of less than 4 blocks, the bins in excess are reserved.
6778 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
6781 MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
6783 /* reg_ralst_right_child_bin
6784 * Holding the children of the bin according to the stored tree's structure.
6785 * For trees composed of less than 4 blocks, the bins in excess are reserved.
6786 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
6789 MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
6792 static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
6794 MLXSW_REG_ZERO(ralst, payload);
6796 /* Initialize all bins to have no left or right child */
6797 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
6798 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
6800 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
6801 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
6804 static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
6808 int bin_index = bin_number - 1;
6810 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
6811 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
6815 /* RALTB - Router Algorithmic LPM Tree Binding Register
6816 * ----------------------------------------------------
6817 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
6819 #define MLXSW_REG_RALTB_ID 0x8012
6820 #define MLXSW_REG_RALTB_LEN 0x04
6822 MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
6824 /* reg_raltb_virtual_router
6826 * Range is 0..cap_max_virtual_routers-1
6829 MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
6831 /* reg_raltb_protocol
6835 MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
6837 /* reg_raltb_tree_id
6838 * Tree to be used for the {virtual_router, protocol}
6839 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
6840 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
6843 MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
6845 static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
6846 enum mlxsw_reg_ralxx_protocol protocol,
6849 MLXSW_REG_ZERO(raltb, payload);
6850 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
6851 mlxsw_reg_raltb_protocol_set(payload, protocol);
6852 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
6855 /* RALUE - Router Algorithmic LPM Unicast Entry Register
6856 * -----------------------------------------------------
6857 * RALUE is used to configure and query LPM entries that serve
6858 * the Unicast protocols.
6860 #define MLXSW_REG_RALUE_ID 0x8013
6861 #define MLXSW_REG_RALUE_LEN 0x38
6863 MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
6865 /* reg_ralue_protocol
6869 MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
6871 enum mlxsw_reg_ralue_op {
6872 /* Read operation. If entry doesn't exist, the operation fails. */
6873 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
6874 /* Clear on read operation. Used to read entry and
6875 * clear Activity bit.
6877 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
6878 /* Write operation. Used to write a new entry to the table. All RW
6879 * fields are written for new entry. Activity bit is set
6882 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
6883 /* Update operation. Used to update an existing route entry and
6884 * only update the RW fields that are detailed in the field
6885 * op_u_mask. If entry doesn't exist, the operation fails.
6887 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
6888 /* Clear activity. The Activity bit (the field a) is cleared
6891 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
6892 /* Delete operation. Used to delete an existing entry. If entry
6893 * doesn't exist, the operation fails.
6895 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
6902 MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
6905 * Activity. Set for new entries. Set if a packet lookup has hit on the
6906 * specific entry, only if the entry is a route. To clear the a bit, use
6907 * "clear activity" op.
6908 * Enabled by activity_dis in RGCR
6911 MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
6913 /* reg_ralue_virtual_router
6915 * Range is 0..cap_max_virtual_routers-1
6918 MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
6920 #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
6921 #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
6922 #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
6924 /* reg_ralue_op_u_mask
6925 * opcode update mask.
6926 * On read operation, this field is reserved.
6927 * This field is valid for update opcode, otherwise - reserved.
6928 * This field is a bitmask of the fields that should be updated.
6931 MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
6933 /* reg_ralue_prefix_len
6934 * Number of bits in the prefix of the LPM route.
6935 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
6936 * two entries in the physical HW table.
6939 MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
6942 * The prefix of the route or of the marker that the object of the LPM
6943 * is compared with. The most significant bits of the dip are the prefix.
6944 * The least significant bits must be '0' if the prefix_len is smaller
6945 * than 128 for IPv6 or smaller than 32 for IPv4.
6946 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
6949 MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
6950 MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
6952 enum mlxsw_reg_ralue_entry_type {
6953 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
6954 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
6955 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
6958 /* reg_ralue_entry_type
6960 * Note - for Marker entries, the action_type and action fields are reserved.
6963 MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
6965 /* reg_ralue_bmp_len
6966 * The best match prefix length in the case that there is no match for
6968 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
6969 * Note for any update operation with entry_type modification this
6970 * field must be set.
6973 MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
6975 enum mlxsw_reg_ralue_action_type {
6976 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
6977 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
6978 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
6981 /* reg_ralue_action_type
6983 * Indicates how the IP address is connected.
6984 * It can be connected to a local subnet through local_erif or can be
6985 * on a remote subnet connected through a next-hop router,
6986 * or transmitted to the CPU.
6987 * Reserved when entry_type = MARKER_ENTRY
6990 MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
6992 enum mlxsw_reg_ralue_trap_action {
6993 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
6994 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
6995 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
6996 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
6997 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
7000 /* reg_ralue_trap_action
7002 * For IP2ME action, only NOP and MIRROR are possible.
7005 MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
7007 /* reg_ralue_trap_id
7008 * Trap ID to be reported to CPU.
7009 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
7010 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
7013 MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
7015 /* reg_ralue_adjacency_index
7016 * Points to the first entry of the group-based ECMP.
7017 * Only relevant in case of REMOTE action.
7020 MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
7022 /* reg_ralue_ecmp_size
7023 * Amount of sequential entries starting
7024 * from the adjacency_index (the number of ECMPs).
7025 * The valid range is 1-64, 512, 1024, 2048 and 4096.
7026 * Reserved when trap_action is TRAP or DISCARD_ERROR.
7027 * Only relevant in case of REMOTE action.
7030 MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
7032 /* reg_ralue_local_erif
7033 * Egress Router Interface.
7034 * Only relevant in case of LOCAL action.
7037 MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
7039 /* reg_ralue_ip2me_v
7040 * Valid bit for the tunnel_ptr field.
7041 * If valid = 0 then trap to CPU as IP2ME trap ID.
7042 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
7043 * decapsulation then tunnel decapsulation is done.
7044 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
7045 * decapsulation then trap as IP2ME trap ID.
7046 * Only relevant in case of IP2ME action.
7049 MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
7051 /* reg_ralue_ip2me_tunnel_ptr
7052 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
7053 * For Spectrum, pointer to KVD Linear.
7054 * Only relevant in case of IP2ME action.
7057 MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
7059 static inline void mlxsw_reg_ralue_pack(char *payload,
7060 enum mlxsw_reg_ralxx_protocol protocol,
7061 enum mlxsw_reg_ralue_op op,
7062 u16 virtual_router, u8 prefix_len)
7064 MLXSW_REG_ZERO(ralue, payload);
7065 mlxsw_reg_ralue_protocol_set(payload, protocol);
7066 mlxsw_reg_ralue_op_set(payload, op);
7067 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
7068 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
7069 mlxsw_reg_ralue_entry_type_set(payload,
7070 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
7071 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
7074 static inline void mlxsw_reg_ralue_pack4(char *payload,
7075 enum mlxsw_reg_ralxx_protocol protocol,
7076 enum mlxsw_reg_ralue_op op,
7077 u16 virtual_router, u8 prefix_len,
7080 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7081 mlxsw_reg_ralue_dip4_set(payload, dip);
7084 static inline void mlxsw_reg_ralue_pack6(char *payload,
7085 enum mlxsw_reg_ralxx_protocol protocol,
7086 enum mlxsw_reg_ralue_op op,
7087 u16 virtual_router, u8 prefix_len,
7090 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7091 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
7095 mlxsw_reg_ralue_act_remote_pack(char *payload,
7096 enum mlxsw_reg_ralue_trap_action trap_action,
7097 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
7099 mlxsw_reg_ralue_action_type_set(payload,
7100 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
7101 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7102 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7103 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
7104 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
7108 mlxsw_reg_ralue_act_local_pack(char *payload,
7109 enum mlxsw_reg_ralue_trap_action trap_action,
7110 u16 trap_id, u16 local_erif)
7112 mlxsw_reg_ralue_action_type_set(payload,
7113 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
7114 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7115 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7116 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
7120 mlxsw_reg_ralue_act_ip2me_pack(char *payload)
7122 mlxsw_reg_ralue_action_type_set(payload,
7123 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7127 mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
7129 mlxsw_reg_ralue_action_type_set(payload,
7130 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7131 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
7132 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
7135 /* RAUHT - Router Algorithmic LPM Unicast Host Table Register
7136 * ----------------------------------------------------------
7137 * The RAUHT register is used to configure and query the Unicast Host table in
7138 * devices that implement the Algorithmic LPM.
7140 #define MLXSW_REG_RAUHT_ID 0x8014
7141 #define MLXSW_REG_RAUHT_LEN 0x74
7143 MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
7145 enum mlxsw_reg_rauht_type {
7146 MLXSW_REG_RAUHT_TYPE_IPV4,
7147 MLXSW_REG_RAUHT_TYPE_IPV6,
7153 MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
7155 enum mlxsw_reg_rauht_op {
7156 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
7157 /* Read operation */
7158 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
7159 /* Clear on read operation. Used to read entry and clear
7162 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
7163 /* Add. Used to write a new entry to the table. All R/W fields are
7164 * relevant for new entry. Activity bit is set for new entries.
7166 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
7167 /* Update action. Used to update an existing route entry and
7168 * only update the following fields:
7169 * trap_action, trap_id, mac, counter_set_type, counter_index
7171 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
7172 /* Clear activity. A bit is cleared for the entry. */
7173 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
7175 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
7176 /* Delete all host entries on a RIF. In this command, dip
7177 * field is reserved.
7184 MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
7187 * Activity. Set for new entries. Set if a packet lookup has hit on
7188 * the specific entry.
7189 * To clear the a bit, use "clear activity" op.
7190 * Enabled by activity_dis in RGCR
7193 MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
7199 MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
7202 * Destination address.
7205 MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
7206 MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
7208 enum mlxsw_reg_rauht_trap_action {
7209 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
7210 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
7211 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
7212 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
7213 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
7216 /* reg_rauht_trap_action
7219 MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
7221 enum mlxsw_reg_rauht_trap_id {
7222 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
7223 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
7226 /* reg_rauht_trap_id
7227 * Trap ID to be reported to CPU.
7228 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
7229 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
7230 * trap_id is reserved.
7233 MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
7235 /* reg_rauht_counter_set_type
7236 * Counter set type for flow counters
7239 MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
7241 /* reg_rauht_counter_index
7242 * Counter index for flow counters
7245 MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
7251 MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
7253 static inline void mlxsw_reg_rauht_pack(char *payload,
7254 enum mlxsw_reg_rauht_op op, u16 rif,
7257 MLXSW_REG_ZERO(rauht, payload);
7258 mlxsw_reg_rauht_op_set(payload, op);
7259 mlxsw_reg_rauht_rif_set(payload, rif);
7260 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
7263 static inline void mlxsw_reg_rauht_pack4(char *payload,
7264 enum mlxsw_reg_rauht_op op, u16 rif,
7265 const char *mac, u32 dip)
7267 mlxsw_reg_rauht_pack(payload, op, rif, mac);
7268 mlxsw_reg_rauht_dip4_set(payload, dip);
7271 static inline void mlxsw_reg_rauht_pack6(char *payload,
7272 enum mlxsw_reg_rauht_op op, u16 rif,
7273 const char *mac, const char *dip)
7275 mlxsw_reg_rauht_pack(payload, op, rif, mac);
7276 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
7277 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
7280 static inline void mlxsw_reg_rauht_pack_counter(char *payload,
7283 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
7284 mlxsw_reg_rauht_counter_set_type_set(payload,
7285 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
7288 /* RALEU - Router Algorithmic LPM ECMP Update Register
7289 * ---------------------------------------------------
7290 * The register enables updating the ECMP section in the action for multiple
7291 * LPM Unicast entries in a single operation. The update is executed to
7292 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
7294 #define MLXSW_REG_RALEU_ID 0x8015
7295 #define MLXSW_REG_RALEU_LEN 0x28
7297 MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
7299 /* reg_raleu_protocol
7303 MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
7305 /* reg_raleu_virtual_router
7307 * Range is 0..cap_max_virtual_routers-1
7310 MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
7312 /* reg_raleu_adjacency_index
7313 * Adjacency Index used for matching on the existing entries.
7316 MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
7318 /* reg_raleu_ecmp_size
7319 * ECMP Size used for matching on the existing entries.
7322 MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
7324 /* reg_raleu_new_adjacency_index
7325 * New Adjacency Index.
7328 MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
7330 /* reg_raleu_new_ecmp_size
7334 MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
7336 static inline void mlxsw_reg_raleu_pack(char *payload,
7337 enum mlxsw_reg_ralxx_protocol protocol,
7339 u32 adjacency_index, u16 ecmp_size,
7340 u32 new_adjacency_index,
7343 MLXSW_REG_ZERO(raleu, payload);
7344 mlxsw_reg_raleu_protocol_set(payload, protocol);
7345 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
7346 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
7347 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
7348 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
7349 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
7352 /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
7353 * ----------------------------------------------------------------
7354 * The RAUHTD register allows dumping entries from the Router Unicast Host
7355 * Table. For a given session an entry is dumped no more than one time. The
7356 * first RAUHTD access after reset is a new session. A session ends when the
7357 * num_rec response is smaller than num_rec request or for IPv4 when the
7358 * num_entries is smaller than 4. The clear activity affect the current session
7359 * or the last session if a new session has not started.
7361 #define MLXSW_REG_RAUHTD_ID 0x8018
7362 #define MLXSW_REG_RAUHTD_BASE_LEN 0x20
7363 #define MLXSW_REG_RAUHTD_REC_LEN 0x20
7364 #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
7365 #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
7366 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
7367 #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
7369 MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
7371 #define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
7372 #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
7374 /* reg_rauhtd_filter_fields
7375 * if a bit is '0' then the relevant field is ignored and dump is done
7376 * regardless of the field value
7377 * Bit0 - filter by activity: entry_a
7378 * Bit3 - filter by entry rip: entry_rif
7381 MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
7383 enum mlxsw_reg_rauhtd_op {
7384 MLXSW_REG_RAUHTD_OP_DUMP,
7385 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
7391 MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
7393 /* reg_rauhtd_num_rec
7394 * At request: number of records requested
7395 * At response: number of records dumped
7396 * For IPv4, each record has 4 entries at request and up to 4 entries
7398 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
7401 MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
7403 /* reg_rauhtd_entry_a
7404 * Dump only if activity has value of entry_a
7405 * Reserved if filter_fields bit0 is '0'
7408 MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
7410 enum mlxsw_reg_rauhtd_type {
7411 MLXSW_REG_RAUHTD_TYPE_IPV4,
7412 MLXSW_REG_RAUHTD_TYPE_IPV6,
7416 * Dump only if record type is:
7421 MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
7423 /* reg_rauhtd_entry_rif
7424 * Dump only if RIF has value of entry_rif
7425 * Reserved if filter_fields bit3 is '0'
7428 MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
7430 static inline void mlxsw_reg_rauhtd_pack(char *payload,
7431 enum mlxsw_reg_rauhtd_type type)
7433 MLXSW_REG_ZERO(rauhtd, payload);
7434 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
7435 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
7436 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
7437 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
7438 mlxsw_reg_rauhtd_type_set(payload, type);
7441 /* reg_rauhtd_ipv4_rec_num_entries
7442 * Number of valid entries in this record:
7444 * 1 - 2 valid entries
7445 * 2 - 3 valid entries
7446 * 3 - 4 valid entries
7449 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
7450 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
7451 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
7453 /* reg_rauhtd_rec_type
7459 MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
7460 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
7462 #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
7464 /* reg_rauhtd_ipv4_ent_a
7465 * Activity. Set for new entries. Set if a packet lookup has hit on the
7469 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
7470 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
7472 /* reg_rauhtd_ipv4_ent_rif
7476 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7477 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
7479 /* reg_rauhtd_ipv4_ent_dip
7480 * Destination IPv4 address.
7483 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7484 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
7486 #define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
7488 /* reg_rauhtd_ipv6_ent_a
7489 * Activity. Set for new entries. Set if a packet lookup has hit on the
7493 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
7494 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
7496 /* reg_rauhtd_ipv6_ent_rif
7500 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7501 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
7503 /* reg_rauhtd_ipv6_ent_dip
7504 * Destination IPv6 address.
7507 MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
7508 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
7510 static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
7511 int ent_index, u16 *p_rif,
7514 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
7515 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
7518 static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
7519 int rec_index, u16 *p_rif,
7522 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
7523 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
7526 /* RTDP - Routing Tunnel Decap Properties Register
7527 * -----------------------------------------------
7528 * The RTDP register is used for configuring the tunnel decap properties of NVE
7531 #define MLXSW_REG_RTDP_ID 0x8020
7532 #define MLXSW_REG_RTDP_LEN 0x44
7534 MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
7536 enum mlxsw_reg_rtdp_type {
7537 MLXSW_REG_RTDP_TYPE_NVE,
7538 MLXSW_REG_RTDP_TYPE_IPIP,
7542 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
7545 MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
7547 /* reg_rtdp_tunnel_index
7548 * Index to the Decap entry.
7549 * For Spectrum, Index to KVD Linear.
7552 MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
7554 /* reg_rtdp_egress_router_interface
7555 * Underlay egress router interface.
7556 * Valid range is from 0 to cap_max_router_interfaces - 1
7559 MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
7563 /* reg_rtdp_ipip_irif
7564 * Ingress Router Interface for the overlay router
7567 MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
7569 enum mlxsw_reg_rtdp_ipip_sip_check {
7570 /* No sip checks. */
7571 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
7572 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
7575 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
7576 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
7579 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
7582 /* reg_rtdp_ipip_sip_check
7583 * SIP check to perform. If decapsulation failed due to these configurations
7584 * then trap_id is IPIP_DECAP_ERROR.
7587 MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
7589 /* If set, allow decapsulation of IPinIP (without GRE). */
7590 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
7591 /* If set, allow decapsulation of IPinGREinIP without a key. */
7592 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
7593 /* If set, allow decapsulation of IPinGREinIP with a key. */
7594 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
7596 /* reg_rtdp_ipip_type_check
7597 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
7598 * these configurations then trap_id is IPIP_DECAP_ERROR.
7601 MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
7603 /* reg_rtdp_ipip_gre_key_check
7604 * Whether GRE key should be checked. When check is enabled:
7605 * - A packet received as IPinIP (without GRE) will always pass.
7606 * - A packet received as IPinGREinIP without a key will not pass the check.
7607 * - A packet received as IPinGREinIP with a key will pass the check only if the
7608 * key in the packet is equal to expected_gre_key.
7609 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
7612 MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
7614 /* reg_rtdp_ipip_ipv4_usip
7615 * Underlay IPv4 address for ipv4 source address check.
7616 * Reserved when sip_check is not '1'.
7619 MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
7621 /* reg_rtdp_ipip_ipv6_usip_ptr
7622 * This field is valid when sip_check is "sipv6 check explicitly". This is a
7623 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
7624 * is to the KVD linear.
7625 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
7628 MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
7630 /* reg_rtdp_ipip_expected_gre_key
7631 * GRE key for checking.
7632 * Reserved when gre_key_check is '0'.
7635 MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
7637 static inline void mlxsw_reg_rtdp_pack(char *payload,
7638 enum mlxsw_reg_rtdp_type type,
7641 MLXSW_REG_ZERO(rtdp, payload);
7642 mlxsw_reg_rtdp_type_set(payload, type);
7643 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
7647 mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
7648 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
7649 unsigned int type_check, bool gre_key_check,
7650 u32 ipv4_usip, u32 expected_gre_key)
7652 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
7653 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
7654 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
7655 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
7656 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
7657 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
7660 /* RIGR-V2 - Router Interface Group Register Version 2
7661 * ---------------------------------------------------
7662 * The RIGR_V2 register is used to add, remove and query egress interface list
7663 * of a multicast forwarding entry.
7665 #define MLXSW_REG_RIGR2_ID 0x8023
7666 #define MLXSW_REG_RIGR2_LEN 0xB0
7668 #define MLXSW_REG_RIGR2_MAX_ERIFS 32
7670 MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
7672 /* reg_rigr2_rigr_index
7676 MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
7679 * Next RIGR Index is valid.
7682 MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
7684 /* reg_rigr2_next_rigr_index
7685 * Next RIGR Index. The index is to the KVD linear.
7686 * Reserved when vnxet = '0'.
7689 MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
7692 * RMID Index is valid.
7695 MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
7697 /* reg_rigr2_rmid_index
7699 * Range 0 .. max_mid - 1
7700 * Reserved when vrmid = '0'.
7701 * The index is to the Port Group Table (PGT)
7704 MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
7706 /* reg_rigr2_erif_entry_v
7707 * Egress Router Interface is valid.
7708 * Note that low-entries must be set if high-entries are set. For
7709 * example: if erif_entry[2].v is set then erif_entry[1].v and
7710 * erif_entry[0].v must be set.
7711 * Index can be from 0 to cap_mc_erif_list_entries-1
7714 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
7716 /* reg_rigr2_erif_entry_erif
7717 * Egress Router Interface.
7718 * Valid range is from 0 to cap_max_router_interfaces - 1
7719 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
7722 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
7724 static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
7725 bool vnext, u32 next_rigr_index)
7727 MLXSW_REG_ZERO(rigr2, payload);
7728 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
7729 mlxsw_reg_rigr2_vnext_set(payload, vnext);
7730 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
7731 mlxsw_reg_rigr2_vrmid_set(payload, 0);
7732 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
7735 static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
7738 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
7739 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
7742 /* RECR-V2 - Router ECMP Configuration Version 2 Register
7743 * ------------------------------------------------------
7745 #define MLXSW_REG_RECR2_ID 0x8025
7746 #define MLXSW_REG_RECR2_LEN 0x38
7748 MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
7751 * Per-port configuration
7754 MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
7760 MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
7766 MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
7769 /* Enable IPv4 fields if packet is not TCP and not UDP */
7770 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
7771 /* Enable IPv4 fields if packet is TCP or UDP */
7772 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
7773 /* Enable IPv6 fields if packet is not TCP and not UDP */
7774 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
7775 /* Enable IPv6 fields if packet is TCP or UDP */
7776 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
7777 /* Enable TCP/UDP header fields if packet is IPv4 */
7778 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
7779 /* Enable TCP/UDP header fields if packet is IPv6 */
7780 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
7783 /* reg_recr2_outer_header_enables
7784 * Bit mask where each bit enables a specific layer to be included in
7785 * the hash calculation.
7788 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
7791 /* IPv4 Source IP */
7792 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
7793 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
7794 /* IPv4 Destination IP */
7795 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
7796 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
7798 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
7799 /* IPv6 Source IP */
7800 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
7801 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
7802 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
7803 /* IPv6 Destination IP */
7804 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
7805 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
7806 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
7807 /* IPv6 Next Header */
7808 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
7809 /* IPv6 Flow Label */
7810 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
7811 /* TCP/UDP Source Port */
7812 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
7813 /* TCP/UDP Destination Port */
7814 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
7817 /* reg_recr2_outer_header_fields_enable
7818 * Packet fields to enable for ECMP hash subject to outer_header_enable.
7821 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
7823 static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
7827 for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
7828 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7832 static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
7836 for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
7837 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7841 static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
7843 int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
7845 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7847 i = MLXSW_REG_RECR2_IPV6_SIP8;
7848 for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
7849 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7853 static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
7855 int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
7857 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7859 i = MLXSW_REG_RECR2_IPV6_DIP8;
7860 for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
7861 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7865 static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
7867 MLXSW_REG_ZERO(recr2, payload);
7868 mlxsw_reg_recr2_pp_set(payload, false);
7869 mlxsw_reg_recr2_sh_set(payload, true);
7870 mlxsw_reg_recr2_seed_set(payload, seed);
7873 /* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
7874 * --------------------------------------------------------------
7875 * The RMFT_V2 register is used to configure and query the multicast table.
7877 #define MLXSW_REG_RMFT2_ID 0x8027
7878 #define MLXSW_REG_RMFT2_LEN 0x174
7880 MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
7886 MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
7888 enum mlxsw_reg_rmft2_type {
7889 MLXSW_REG_RMFT2_TYPE_IPV4,
7890 MLXSW_REG_RMFT2_TYPE_IPV6
7896 MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
7898 enum mlxsw_sp_reg_rmft2_op {
7900 * Write operation. Used to write a new entry to the table. All RW
7901 * fields are relevant for new entry. Activity bit is set for new
7902 * entries - Note write with v (Valid) 0 will delete the entry.
7906 MLXSW_REG_RMFT2_OP_READ_WRITE,
7913 MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
7916 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
7920 MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
7923 * Offset within the multicast forwarding table to write to.
7926 MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
7928 /* reg_rmft2_virtual_router
7929 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
7932 MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
7934 enum mlxsw_reg_rmft2_irif_mask {
7935 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
7936 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
7939 /* reg_rmft2_irif_mask
7943 MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
7946 * Ingress RIF index.
7949 MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
7951 /* reg_rmft2_dip{4,6}
7952 * Destination IPv4/6 address
7955 MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
7956 MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
7958 /* reg_rmft2_dip{4,6}_mask
7959 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
7960 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
7963 MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
7964 MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
7966 /* reg_rmft2_sip{4,6}
7967 * Source IPv4/6 address
7970 MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
7971 MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
7973 /* reg_rmft2_sip{4,6}_mask
7974 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
7975 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
7978 MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
7979 MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
7981 /* reg_rmft2_flexible_action_set
7982 * ACL action set. The only supported action types in this field and in any
7983 * action-set pointed from here are as follows:
7985 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
7988 * 08h: ACTION_POLICING_MONITORING
7989 * 10h: ACTION_ROUTER_MC
7992 MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
7993 MLXSW_REG_FLEX_ACTION_SET_LEN);
7996 mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
7998 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7999 const char *flex_action_set)
8001 MLXSW_REG_ZERO(rmft2, payload);
8002 mlxsw_reg_rmft2_v_set(payload, v);
8003 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
8004 mlxsw_reg_rmft2_offset_set(payload, offset);
8005 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
8006 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
8007 mlxsw_reg_rmft2_irif_set(payload, irif);
8008 if (flex_action_set)
8009 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
8014 mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8015 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8016 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
8017 const char *flexible_action_set)
8019 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8020 irif_mask, irif, flexible_action_set);
8021 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
8022 mlxsw_reg_rmft2_dip4_set(payload, dip4);
8023 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
8024 mlxsw_reg_rmft2_sip4_set(payload, sip4);
8025 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
8029 mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8030 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8031 struct in6_addr dip6, struct in6_addr dip6_mask,
8032 struct in6_addr sip6, struct in6_addr sip6_mask,
8033 const char *flexible_action_set)
8035 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8036 irif_mask, irif, flexible_action_set);
8037 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
8038 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
8039 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
8040 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
8041 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
8044 /* MFCR - Management Fan Control Register
8045 * --------------------------------------
8046 * This register controls the settings of the Fan Speed PWM mechanism.
8048 #define MLXSW_REG_MFCR_ID 0x9001
8049 #define MLXSW_REG_MFCR_LEN 0x08
8051 MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
8053 enum mlxsw_reg_mfcr_pwm_frequency {
8054 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
8055 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
8056 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
8057 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
8058 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
8059 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
8060 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
8061 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
8064 /* reg_mfcr_pwm_frequency
8065 * Controls the frequency of the PWM signal.
8068 MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
8070 #define MLXSW_MFCR_TACHOS_MAX 10
8072 /* reg_mfcr_tacho_active
8073 * Indicates which of the tachometer is active (bit per tachometer).
8076 MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
8078 #define MLXSW_MFCR_PWMS_MAX 5
8080 /* reg_mfcr_pwm_active
8081 * Indicates which of the PWM control is active (bit per PWM).
8084 MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
8087 mlxsw_reg_mfcr_pack(char *payload,
8088 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
8090 MLXSW_REG_ZERO(mfcr, payload);
8091 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
8095 mlxsw_reg_mfcr_unpack(char *payload,
8096 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
8097 u16 *p_tacho_active, u8 *p_pwm_active)
8099 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
8100 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
8101 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
8104 /* MFSC - Management Fan Speed Control Register
8105 * --------------------------------------------
8106 * This register controls the settings of the Fan Speed PWM mechanism.
8108 #define MLXSW_REG_MFSC_ID 0x9002
8109 #define MLXSW_REG_MFSC_LEN 0x08
8111 MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
8114 * Fan pwm to control / monitor.
8117 MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
8119 /* reg_mfsc_pwm_duty_cycle
8120 * Controls the duty cycle of the PWM. Value range from 0..255 to
8121 * represent duty cycle of 0%...100%.
8124 MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
8126 static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
8129 MLXSW_REG_ZERO(mfsc, payload);
8130 mlxsw_reg_mfsc_pwm_set(payload, pwm);
8131 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
8134 /* MFSM - Management Fan Speed Measurement
8135 * ---------------------------------------
8136 * This register controls the settings of the Tacho measurements and
8137 * enables reading the Tachometer measurements.
8139 #define MLXSW_REG_MFSM_ID 0x9003
8140 #define MLXSW_REG_MFSM_LEN 0x08
8142 MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
8145 * Fan tachometer index.
8148 MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
8151 * Fan speed (round per minute).
8154 MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
8156 static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
8158 MLXSW_REG_ZERO(mfsm, payload);
8159 mlxsw_reg_mfsm_tacho_set(payload, tacho);
8162 /* MFSL - Management Fan Speed Limit Register
8163 * ------------------------------------------
8164 * The Fan Speed Limit register is used to configure the fan speed
8165 * event / interrupt notification mechanism. Fan speed threshold are
8166 * defined for both under-speed and over-speed.
8168 #define MLXSW_REG_MFSL_ID 0x9004
8169 #define MLXSW_REG_MFSL_LEN 0x0C
8171 MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
8174 * Fan tachometer index.
8177 MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
8179 /* reg_mfsl_tach_min
8180 * Tachometer minimum value (minimum RPM).
8183 MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
8185 /* reg_mfsl_tach_max
8186 * Tachometer maximum value (maximum RPM).
8189 MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
8191 static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
8192 u16 tach_min, u16 tach_max)
8194 MLXSW_REG_ZERO(mfsl, payload);
8195 mlxsw_reg_mfsl_tacho_set(payload, tacho);
8196 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
8197 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
8200 static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
8201 u16 *p_tach_min, u16 *p_tach_max)
8204 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
8207 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
8210 /* FORE - Fan Out of Range Event Register
8211 * --------------------------------------
8212 * This register reports the status of the controlled fans compared to the
8213 * range defined by the MFSL register.
8215 #define MLXSW_REG_FORE_ID 0x9007
8216 #define MLXSW_REG_FORE_LEN 0x0C
8218 MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
8221 * Fan speed is below the low limit defined in MFSL register. Each bit relates
8222 * to a single tachometer and indicates the specific tachometer reading is
8223 * below the threshold.
8226 MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
8228 static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
8234 limit = mlxsw_reg_fore_fan_under_limit_get(payload);
8235 *fault = limit & BIT(tacho);
8239 /* MTCAP - Management Temperature Capabilities
8240 * -------------------------------------------
8241 * This register exposes the capabilities of the device and
8242 * system temperature sensing.
8244 #define MLXSW_REG_MTCAP_ID 0x9009
8245 #define MLXSW_REG_MTCAP_LEN 0x08
8247 MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
8249 /* reg_mtcap_sensor_count
8250 * Number of sensors supported by the device.
8251 * This includes the QSFP module sensors (if exists in the QSFP module).
8254 MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
8256 /* MTMP - Management Temperature
8257 * -----------------------------
8258 * This register controls the settings of the temperature measurements
8259 * and enables reading the temperature measurements. Note that temperature
8260 * is in 0.125 degrees Celsius.
8262 #define MLXSW_REG_MTMP_ID 0x900A
8263 #define MLXSW_REG_MTMP_LEN 0x20
8265 MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
8267 #define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
8268 #define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
8269 /* reg_mtmp_sensor_index
8270 * Sensors index to access.
8271 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
8272 * (module 0 is mapped to sensor_index 64).
8275 MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
8277 /* Convert to milli degrees Celsius */
8278 #define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
8279 ((v_) >= 0) ? ((v_) * 125) : \
8280 ((s16)((GENMASK(15, 0) + (v_) + 1) \
8283 /* reg_mtmp_temperature
8284 * Temperature reading from the sensor. Reading is in 0.125 Celsius
8288 MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
8291 * Max Temperature Enable - enables measuring the max temperature on a sensor.
8294 MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
8297 * Max Temperature Reset - clears the value of the max temperature register.
8300 MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
8302 /* reg_mtmp_max_temperature
8303 * The highest measured temperature from the sensor.
8304 * When the bit mte is cleared, the field max_temperature is reserved.
8307 MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
8310 * Temperature Event Enable.
8311 * 0 - Do not generate event
8312 * 1 - Generate event
8313 * 2 - Generate single event
8316 MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
8318 #define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
8320 /* reg_mtmp_temperature_threshold_hi
8321 * High threshold for Temperature Warning Event. In 0.125 Celsius.
8324 MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
8326 /* reg_mtmp_temperature_threshold_lo
8327 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
8330 MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
8332 #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
8334 /* reg_mtmp_sensor_name
8338 MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
8340 static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index,
8341 bool max_temp_enable,
8342 bool max_temp_reset)
8344 MLXSW_REG_ZERO(mtmp, payload);
8345 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
8346 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
8347 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
8348 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
8349 MLXSW_REG_MTMP_THRESH_HI);
8352 static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
8353 int *p_max_temp, char *sensor_name)
8358 temp = mlxsw_reg_mtmp_temperature_get(payload);
8359 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
8362 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
8363 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
8366 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
8369 /* MTBR - Management Temperature Bulk Register
8370 * -------------------------------------------
8371 * This register is used for bulk temperature reading.
8373 #define MLXSW_REG_MTBR_ID 0x900F
8374 #define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */
8375 #define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */
8376 #define MLXSW_REG_MTBR_REC_MAX_COUNT 47 /* firmware limitation */
8377 #define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
8378 MLXSW_REG_MTBR_REC_LEN * \
8379 MLXSW_REG_MTBR_REC_MAX_COUNT)
8381 MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
8383 /* reg_mtbr_base_sensor_index
8384 * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
8385 * 64-127 are mapped to the SFP+/QSFP modules sequentially).
8388 MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
8391 * Request: Number of records to read
8392 * Response: Number of records read
8393 * See above description for more details.
8397 MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
8399 /* reg_mtbr_rec_max_temp
8400 * The highest measured temperature from the sensor.
8401 * When the bit mte is cleared, the field max_temperature is reserved.
8404 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
8405 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
8407 /* reg_mtbr_rec_temp
8408 * Temperature reading from the sensor. Reading is in 0..125 Celsius
8412 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
8413 MLXSW_REG_MTBR_REC_LEN, 0x00, false);
8415 static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index,
8418 MLXSW_REG_ZERO(mtbr, payload);
8419 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
8420 mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
8423 /* Error codes from temperatute reading */
8424 enum mlxsw_reg_mtbr_temp_status {
8425 MLXSW_REG_MTBR_NO_CONN = 0x8000,
8426 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
8427 MLXSW_REG_MTBR_INDEX_NA = 0x8002,
8428 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
8431 /* Base index for reading modules temperature */
8432 #define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
8434 static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
8435 u16 *p_temp, u16 *p_max_temp)
8438 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
8440 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
8443 /* MCIA - Management Cable Info Access
8444 * -----------------------------------
8445 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
8448 #define MLXSW_REG_MCIA_ID 0x9014
8449 #define MLXSW_REG_MCIA_LEN 0x40
8451 MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
8454 * Lock bit. Setting this bit will lock the access to the specific
8455 * cable. Used for updating a full page in a cable EPROM. Any access
8456 * other then subsequence writes will fail while the port is locked.
8459 MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
8465 MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
8471 MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
8473 /* reg_mcia_i2c_device_address
8474 * I2C device address.
8477 MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
8479 /* reg_mcia_page_number
8483 MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
8485 /* reg_mcia_device_address
8489 MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
8492 * Number of bytes to read/write (up to 48 bytes).
8495 MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
8497 #define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
8498 #define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
8499 #define MLXSW_REG_MCIA_EEPROM_SIZE 48
8500 #define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
8501 #define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
8502 #define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
8503 #define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
8504 #define MLXSW_REG_MCIA_TH_PAGE_NUM 3
8505 #define MLXSW_REG_MCIA_PAGE0_LO 0
8506 #define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
8508 enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
8509 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
8510 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
8511 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
8514 enum mlxsw_reg_mcia_eeprom_module_info_id {
8515 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
8516 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
8517 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
8518 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
8519 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
8522 enum mlxsw_reg_mcia_eeprom_module_info {
8523 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
8524 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
8525 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
8529 * Bytes to read/write.
8532 MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
8534 /* This is used to access the optional upper pages (1-3) in the QSFP+
8535 * memory map. Page 1 is available on offset 256 through 383, page 2 -
8536 * on offset 384 through 511, page 3 - on offset 512 through 639.
8538 #define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
8539 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
8540 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
8542 static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
8543 u8 page_number, u16 device_addr,
8544 u8 size, u8 i2c_device_addr)
8546 MLXSW_REG_ZERO(mcia, payload);
8547 mlxsw_reg_mcia_module_set(payload, module);
8548 mlxsw_reg_mcia_l_set(payload, lock);
8549 mlxsw_reg_mcia_page_number_set(payload, page_number);
8550 mlxsw_reg_mcia_device_address_set(payload, device_addr);
8551 mlxsw_reg_mcia_size_set(payload, size);
8552 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
8555 /* MPAT - Monitoring Port Analyzer Table
8556 * -------------------------------------
8557 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
8558 * For an enabled analyzer, all fields except e (enable) cannot be modified.
8560 #define MLXSW_REG_MPAT_ID 0x901A
8561 #define MLXSW_REG_MPAT_LEN 0x78
8563 MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
8569 MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
8571 /* reg_mpat_system_port
8572 * A unique port identifier for the final destination of the packet.
8575 MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
8578 * Enable. Indicating the Port Analyzer is enabled.
8581 MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
8584 * Quality Of Service Mode.
8585 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
8586 * PCP, DEI, DSCP or VL) are configured.
8587 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
8588 * same as in the original packet that has triggered the mirroring. For
8589 * SPAN also the pcp,dei are maintained.
8592 MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
8595 * Best effort mode. Indicates mirroring traffic should not cause packet
8596 * drop or back pressure, but will discard the mirrored packets. Mirrored
8597 * packets will be forwarded on a best effort manner.
8598 * 0: Do not discard mirrored packets
8599 * 1: Discard mirrored packets if causing congestion
8602 MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
8604 enum mlxsw_reg_mpat_span_type {
8605 /* Local SPAN Ethernet.
8606 * The original packet is not encapsulated.
8608 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
8610 /* Remote SPAN Ethernet VLAN.
8611 * The packet is forwarded to the monitoring port on the monitoring
8614 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
8616 /* Encapsulated Remote SPAN Ethernet L3 GRE.
8617 * The packet is encapsulated with GRE header.
8619 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
8622 /* reg_mpat_span_type
8626 MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
8628 /* Remote SPAN - Ethernet VLAN
8629 * - - - - - - - - - - - - - -
8632 /* reg_mpat_eth_rspan_vid
8633 * Encapsulation header VLAN ID.
8636 MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
8638 /* Encapsulated Remote SPAN - Ethernet L2
8639 * - - - - - - - - - - - - - - - - - - -
8642 enum mlxsw_reg_mpat_eth_rspan_version {
8643 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
8646 /* reg_mpat_eth_rspan_version
8647 * RSPAN mirror header version.
8650 MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
8652 /* reg_mpat_eth_rspan_mac
8653 * Destination MAC address.
8656 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
8658 /* reg_mpat_eth_rspan_tp
8659 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
8662 MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
8664 /* Encapsulated Remote SPAN - Ethernet L3
8665 * - - - - - - - - - - - - - - - - - - -
8668 enum mlxsw_reg_mpat_eth_rspan_protocol {
8669 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
8670 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
8673 /* reg_mpat_eth_rspan_protocol
8674 * SPAN encapsulation protocol.
8677 MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
8679 /* reg_mpat_eth_rspan_ttl
8680 * Encapsulation header Time-to-Live/HopLimit.
8683 MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
8685 /* reg_mpat_eth_rspan_smac
8686 * Source MAC address
8689 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
8691 /* reg_mpat_eth_rspan_dip*
8692 * Destination IP address. The IP version is configured by protocol.
8695 MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
8696 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
8698 /* reg_mpat_eth_rspan_sip*
8699 * Source IP address. The IP version is configured by protocol.
8702 MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
8703 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
8705 static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
8706 u16 system_port, bool e,
8707 enum mlxsw_reg_mpat_span_type span_type)
8709 MLXSW_REG_ZERO(mpat, payload);
8710 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
8711 mlxsw_reg_mpat_system_port_set(payload, system_port);
8712 mlxsw_reg_mpat_e_set(payload, e);
8713 mlxsw_reg_mpat_qos_set(payload, 1);
8714 mlxsw_reg_mpat_be_set(payload, 1);
8715 mlxsw_reg_mpat_span_type_set(payload, span_type);
8718 static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
8720 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
8724 mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
8725 enum mlxsw_reg_mpat_eth_rspan_version version,
8729 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
8730 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
8731 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
8735 mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
8739 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
8740 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
8741 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
8742 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
8743 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
8744 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
8748 mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
8750 struct in6_addr sip, struct in6_addr dip)
8752 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
8753 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
8754 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
8755 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
8756 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
8757 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
8760 /* MPAR - Monitoring Port Analyzer Register
8761 * ----------------------------------------
8762 * MPAR register is used to query and configure the port analyzer port mirroring
8765 #define MLXSW_REG_MPAR_ID 0x901B
8766 #define MLXSW_REG_MPAR_LEN 0x0C
8768 MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
8770 /* reg_mpar_local_port
8771 * The local port to mirror the packets from.
8774 MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
8776 enum mlxsw_reg_mpar_i_e {
8777 MLXSW_REG_MPAR_TYPE_EGRESS,
8778 MLXSW_REG_MPAR_TYPE_INGRESS,
8785 MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
8789 * By default, port mirroring is disabled for all ports.
8792 MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
8798 MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
8800 static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
8801 enum mlxsw_reg_mpar_i_e i_e,
8802 bool enable, u8 pa_id)
8804 MLXSW_REG_ZERO(mpar, payload);
8805 mlxsw_reg_mpar_local_port_set(payload, local_port);
8806 mlxsw_reg_mpar_enable_set(payload, enable);
8807 mlxsw_reg_mpar_i_e_set(payload, i_e);
8808 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
8811 /* MGIR - Management General Information Register
8812 * ----------------------------------------------
8813 * MGIR register allows software to query the hardware and firmware general
8816 #define MLXSW_REG_MGIR_ID 0x9020
8817 #define MLXSW_REG_MGIR_LEN 0x9C
8819 MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
8821 /* reg_mgir_hw_info_device_hw_revision
8824 MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
8826 #define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
8828 /* reg_mgir_fw_info_psid
8829 * PSID (ASCII string).
8832 MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
8834 /* reg_mgir_fw_info_extended_major
8837 MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
8839 /* reg_mgir_fw_info_extended_minor
8842 MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
8844 /* reg_mgir_fw_info_extended_sub_minor
8847 MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
8849 static inline void mlxsw_reg_mgir_pack(char *payload)
8851 MLXSW_REG_ZERO(mgir, payload);
8855 mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
8856 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
8858 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
8859 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
8860 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
8861 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
8862 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
8865 /* MRSR - Management Reset and Shutdown Register
8866 * ---------------------------------------------
8867 * MRSR register is used to reset or shutdown the switch or
8868 * the entire system (when applicable).
8870 #define MLXSW_REG_MRSR_ID 0x9023
8871 #define MLXSW_REG_MRSR_LEN 0x08
8873 MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
8876 * Reset/shutdown command
8878 * 1 - software reset
8881 MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
8883 static inline void mlxsw_reg_mrsr_pack(char *payload)
8885 MLXSW_REG_ZERO(mrsr, payload);
8886 mlxsw_reg_mrsr_command_set(payload, 1);
8889 /* MLCR - Management LED Control Register
8890 * --------------------------------------
8891 * Controls the system LEDs.
8893 #define MLXSW_REG_MLCR_ID 0x902B
8894 #define MLXSW_REG_MLCR_LEN 0x0C
8896 MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
8898 /* reg_mlcr_local_port
8899 * Local port number.
8902 MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
8904 #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
8906 /* reg_mlcr_beacon_duration
8907 * Duration of the beacon to be active, in seconds.
8908 * 0x0 - Will turn off the beacon.
8909 * 0xFFFF - Will turn on the beacon until explicitly turned off.
8912 MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
8914 /* reg_mlcr_beacon_remain
8915 * Remaining duration of the beacon, in seconds.
8916 * 0xFFFF indicates an infinite amount of time.
8919 MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
8921 static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
8924 MLXSW_REG_ZERO(mlcr, payload);
8925 mlxsw_reg_mlcr_local_port_set(payload, local_port);
8926 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
8927 MLXSW_REG_MLCR_DURATION_MAX : 0);
8930 /* MTPPS - Management Pulse Per Second Register
8931 * --------------------------------------------
8932 * This register provides the device PPS capabilities, configure the PPS in and
8933 * out modules and holds the PPS in time stamp.
8935 #define MLXSW_REG_MTPPS_ID 0x9053
8936 #define MLXSW_REG_MTPPS_LEN 0x3C
8938 MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
8941 * Enables the PPS functionality the specific pin.
8942 * A boolean variable.
8945 MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
8947 enum mlxsw_reg_mtpps_pin_mode {
8948 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
8951 /* reg_mtpps_pin_mode
8952 * Pin mode to be used. The mode must comply with the supported modes of the
8956 MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
8958 #define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
8961 * Pin to be configured or queried out of the supported pins.
8964 MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
8966 /* reg_mtpps_time_stamp
8967 * When pin_mode = pps_in, the latched device time when it was triggered from
8968 * the external GPIO pin.
8969 * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target
8970 * time to generate next output signal.
8971 * Time is in units of device clock.
8974 MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
8977 mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
8979 MLXSW_REG_ZERO(mtpps, payload);
8980 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
8981 mlxsw_reg_mtpps_pin_mode_set(payload,
8982 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
8983 mlxsw_reg_mtpps_enable_set(payload, true);
8984 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
8987 /* MTUTC - Management UTC Register
8988 * -------------------------------
8989 * Configures the HW UTC counter.
8991 #define MLXSW_REG_MTUTC_ID 0x9055
8992 #define MLXSW_REG_MTUTC_LEN 0x1C
8994 MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
8996 enum mlxsw_reg_mtutc_operation {
8997 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
8998 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
9001 /* reg_mtutc_operation
9005 MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
9007 /* reg_mtutc_freq_adjustment
9008 * Frequency adjustment: Every PPS the HW frequency will be
9009 * adjusted by this value. Units of HW clock, where HW counts
9010 * 10^9 HW clocks for 1 HW second.
9013 MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
9015 /* reg_mtutc_utc_sec
9019 MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
9022 mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
9023 u32 freq_adj, u32 utc_sec)
9025 MLXSW_REG_ZERO(mtutc, payload);
9026 mlxsw_reg_mtutc_operation_set(payload, oper);
9027 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
9028 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
9031 /* MCQI - Management Component Query Information
9032 * ---------------------------------------------
9033 * This register allows querying information about firmware components.
9035 #define MLXSW_REG_MCQI_ID 0x9061
9036 #define MLXSW_REG_MCQI_BASE_LEN 0x18
9037 #define MLXSW_REG_MCQI_CAP_LEN 0x14
9038 #define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
9040 MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
9042 /* reg_mcqi_component_index
9043 * Index of the accessed component.
9046 MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
9048 enum mlxfw_reg_mcqi_info_type {
9049 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
9052 /* reg_mcqi_info_type
9053 * Component properties set.
9056 MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
9059 * The requested/returned data offset from the section start, given in bytes.
9060 * Must be DWORD aligned.
9063 MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
9065 /* reg_mcqi_data_size
9066 * The requested/returned data size, given in bytes. If data_size is not DWORD
9067 * aligned, the last bytes are zero padded.
9070 MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
9072 /* reg_mcqi_cap_max_component_size
9073 * Maximum size for this component, given in bytes.
9076 MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
9078 /* reg_mcqi_cap_log_mcda_word_size
9079 * Log 2 of the access word size in bytes. Read and write access must be aligned
9080 * to the word size. Write access must be done for an integer number of words.
9083 MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
9085 /* reg_mcqi_cap_mcda_max_write_size
9086 * Maximal write size for MCDA register
9089 MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
9091 static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
9093 MLXSW_REG_ZERO(mcqi, payload);
9094 mlxsw_reg_mcqi_component_index_set(payload, component_index);
9095 mlxsw_reg_mcqi_info_type_set(payload,
9096 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
9097 mlxsw_reg_mcqi_offset_set(payload, 0);
9098 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
9101 static inline void mlxsw_reg_mcqi_unpack(char *payload,
9102 u32 *p_cap_max_component_size,
9103 u8 *p_cap_log_mcda_word_size,
9104 u16 *p_cap_mcda_max_write_size)
9106 *p_cap_max_component_size =
9107 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
9108 *p_cap_log_mcda_word_size =
9109 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
9110 *p_cap_mcda_max_write_size =
9111 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
9114 /* MCC - Management Component Control
9115 * ----------------------------------
9116 * Controls the firmware component and updates the FSM.
9118 #define MLXSW_REG_MCC_ID 0x9062
9119 #define MLXSW_REG_MCC_LEN 0x1C
9121 MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
9123 enum mlxsw_reg_mcc_instruction {
9124 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
9125 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
9126 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
9127 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
9128 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
9129 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
9132 /* reg_mcc_instruction
9133 * Command to be executed by the FSM.
9134 * Applicable for write operation only.
9137 MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
9139 /* reg_mcc_component_index
9140 * Index of the accessed component. Applicable only for commands that
9141 * refer to components. Otherwise, this field is reserved.
9144 MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
9146 /* reg_mcc_update_handle
9147 * Token representing the current flow executed by the FSM.
9150 MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
9152 /* reg_mcc_error_code
9153 * Indicates the successful completion of the instruction, or the reason it
9157 MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
9159 /* reg_mcc_control_state
9163 MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
9165 /* reg_mcc_component_size
9166 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
9167 * the size may shorten the update time. Value 0x0 means that size is
9171 MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
9173 static inline void mlxsw_reg_mcc_pack(char *payload,
9174 enum mlxsw_reg_mcc_instruction instr,
9175 u16 component_index, u32 update_handle,
9178 MLXSW_REG_ZERO(mcc, payload);
9179 mlxsw_reg_mcc_instruction_set(payload, instr);
9180 mlxsw_reg_mcc_component_index_set(payload, component_index);
9181 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
9182 mlxsw_reg_mcc_component_size_set(payload, component_size);
9185 static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
9186 u8 *p_error_code, u8 *p_control_state)
9188 if (p_update_handle)
9189 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
9191 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
9192 if (p_control_state)
9193 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
9196 /* MCDA - Management Component Data Access
9197 * ---------------------------------------
9198 * This register allows reading and writing a firmware component.
9200 #define MLXSW_REG_MCDA_ID 0x9063
9201 #define MLXSW_REG_MCDA_BASE_LEN 0x10
9202 #define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
9203 #define MLXSW_REG_MCDA_LEN \
9204 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
9206 MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
9208 /* reg_mcda_update_handle
9209 * Token representing the current flow executed by the FSM.
9212 MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
9215 * Offset of accessed address relative to component start. Accesses must be in
9216 * accordance to log_mcda_word_size in MCQI reg.
9219 MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
9222 * Size of the data accessed, given in bytes.
9225 MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
9228 * Data block accessed.
9231 MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
9233 static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
9234 u32 offset, u16 size, u8 *data)
9238 MLXSW_REG_ZERO(mcda, payload);
9239 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
9240 mlxsw_reg_mcda_offset_set(payload, offset);
9241 mlxsw_reg_mcda_size_set(payload, size);
9243 for (i = 0; i < size / 4; i++)
9244 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
9247 /* MPSC - Monitoring Packet Sampling Configuration Register
9248 * --------------------------------------------------------
9249 * MPSC Register is used to configure the Packet Sampling mechanism.
9251 #define MLXSW_REG_MPSC_ID 0x9080
9252 #define MLXSW_REG_MPSC_LEN 0x1C
9254 MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
9256 /* reg_mpsc_local_port
9258 * Not supported for CPU port
9261 MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
9264 * Enable sampling on port local_port
9267 MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
9269 #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
9272 * Sampling rate = 1 out of rate packets (with randomization around
9273 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
9276 MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
9278 static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
9281 MLXSW_REG_ZERO(mpsc, payload);
9282 mlxsw_reg_mpsc_local_port_set(payload, local_port);
9283 mlxsw_reg_mpsc_e_set(payload, e);
9284 mlxsw_reg_mpsc_rate_set(payload, rate);
9287 /* MGPC - Monitoring General Purpose Counter Set Register
9288 * The MGPC register retrieves and sets the General Purpose Counter Set.
9290 #define MLXSW_REG_MGPC_ID 0x9081
9291 #define MLXSW_REG_MGPC_LEN 0x18
9293 MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
9295 /* reg_mgpc_counter_set_type
9299 MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
9301 /* reg_mgpc_counter_index
9305 MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
9307 enum mlxsw_reg_mgpc_opcode {
9309 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
9310 /* Clear counters */
9311 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
9318 MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
9320 /* reg_mgpc_byte_counter
9321 * Byte counter value.
9324 MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
9326 /* reg_mgpc_packet_counter
9327 * Packet counter value.
9330 MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
9332 static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
9333 enum mlxsw_reg_mgpc_opcode opcode,
9334 enum mlxsw_reg_flow_counter_set_type set_type)
9336 MLXSW_REG_ZERO(mgpc, payload);
9337 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
9338 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
9339 mlxsw_reg_mgpc_opcode_set(payload, opcode);
9342 /* MPRS - Monitoring Parsing State Register
9343 * ----------------------------------------
9344 * The MPRS register is used for setting up the parsing for hash,
9345 * policy-engine and routing.
9347 #define MLXSW_REG_MPRS_ID 0x9083
9348 #define MLXSW_REG_MPRS_LEN 0x14
9350 MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
9352 /* reg_mprs_parsing_depth
9353 * Minimum parsing depth.
9354 * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL
9355 * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2.
9358 MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
9360 /* reg_mprs_parsing_en
9362 * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and
9363 * NVGRE. Default is enabled. Reserved when SwitchX-2.
9366 MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
9368 /* reg_mprs_vxlan_udp_dport
9369 * VxLAN UDP destination port.
9370 * Used for identifying VxLAN packets and for dport field in
9371 * encapsulation. Default is 4789.
9374 MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
9376 static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
9377 u16 vxlan_udp_dport)
9379 MLXSW_REG_ZERO(mprs, payload);
9380 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
9381 mlxsw_reg_mprs_parsing_en_set(payload, true);
9382 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
9385 /* MOGCR - Monitoring Global Configuration Register
9386 * ------------------------------------------------
9388 #define MLXSW_REG_MOGCR_ID 0x9086
9389 #define MLXSW_REG_MOGCR_LEN 0x20
9391 MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
9393 /* reg_mogcr_ptp_iftc
9394 * PTP Ingress FIFO Trap Clear
9395 * The PTP_ING_FIFO trap provides MTPPTR with clr according
9396 * to this value. Default 0.
9397 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
9400 MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
9402 /* reg_mogcr_ptp_eftc
9403 * PTP Egress FIFO Trap Clear
9404 * The PTP_EGR_FIFO trap provides MTPPTR with clr according
9405 * to this value. Default 0.
9406 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
9409 MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
9411 /* MTPPPC - Time Precision Packet Port Configuration
9412 * -------------------------------------------------
9413 * This register serves for configuration of which PTP messages should be
9414 * timestamped. This is a global configuration, despite the register name.
9416 * Reserved when Spectrum-2.
9418 #define MLXSW_REG_MTPPPC_ID 0x9090
9419 #define MLXSW_REG_MTPPPC_LEN 0x28
9421 MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
9423 /* reg_mtpppc_ing_timestamp_message_type
9424 * Bitwise vector of PTP message types to timestamp at ingress.
9425 * MessageType field as defined by IEEE 1588
9426 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
9430 MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
9432 /* reg_mtpppc_egr_timestamp_message_type
9433 * Bitwise vector of PTP message types to timestamp at egress.
9434 * MessageType field as defined by IEEE 1588
9435 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
9439 MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
9441 static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
9443 MLXSW_REG_ZERO(mtpppc, payload);
9444 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
9445 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
9448 /* MTPPTR - Time Precision Packet Timestamping Reading
9449 * ---------------------------------------------------
9450 * The MTPPTR is used for reading the per port PTP timestamp FIFO.
9451 * There is a trap for packets which are latched to the timestamp FIFO, thus the
9452 * SW knows which FIFO to read. Note that packets enter the FIFO before been
9453 * trapped. The sequence number is used to synchronize the timestamp FIFO
9454 * entries and the trapped packets.
9455 * Reserved when Spectrum-2.
9458 #define MLXSW_REG_MTPPTR_ID 0x9091
9459 #define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */
9460 #define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */
9461 #define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
9462 #define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
9463 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
9465 MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
9467 /* reg_mtpptr_local_port
9468 * Not supported for CPU port.
9471 MLXSW_ITEM32(reg, mtpptr, local_port, 0x00, 16, 8);
9473 enum mlxsw_reg_mtpptr_dir {
9474 MLXSW_REG_MTPPTR_DIR_INGRESS,
9475 MLXSW_REG_MTPPTR_DIR_EGRESS,
9482 MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
9485 * Clear the records.
9488 MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
9490 /* reg_mtpptr_num_rec
9491 * Number of valid records in the response
9492 * Range 0.. cap_ptp_timestamp_fifo
9495 MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
9497 /* reg_mtpptr_rec_message_type
9498 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
9499 * (e.g. Bit0: Sync, Bit1: Delay_Req)
9502 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
9503 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
9504 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
9506 /* reg_mtpptr_rec_domain_number
9507 * DomainNumber field as defined by IEEE 1588
9510 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
9511 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
9512 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
9514 /* reg_mtpptr_rec_sequence_id
9515 * SequenceId field as defined by IEEE 1588
9518 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
9519 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
9520 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
9522 /* reg_mtpptr_rec_timestamp_high
9523 * Timestamp of when the PTP packet has passed through the port Units of PLL
9525 * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec.
9528 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
9529 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
9530 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
9532 /* reg_mtpptr_rec_timestamp_low
9533 * See rec_timestamp_high.
9536 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
9537 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
9538 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
9540 static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
9543 u8 *p_domain_number,
9547 u32 timestamp_high, timestamp_low;
9549 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
9550 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
9551 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
9552 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
9553 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
9554 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
9557 /* MTPTPT - Monitoring Precision Time Protocol Trap Register
9558 * ---------------------------------------------------------
9559 * This register is used for configuring under which trap to deliver PTP
9560 * packets depending on type of the packet.
9562 #define MLXSW_REG_MTPTPT_ID 0x9092
9563 #define MLXSW_REG_MTPTPT_LEN 0x08
9565 MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
9567 enum mlxsw_reg_mtptpt_trap_id {
9568 MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
9569 MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
9572 /* reg_mtptpt_trap_id
9576 MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
9578 /* reg_mtptpt_message_type
9579 * Bitwise vector of PTP message types to trap. This is a necessary but
9580 * non-sufficient condition since need to enable also per port. See MTPPPC.
9581 * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g.
9582 * Bit0: Sync, Bit1: Delay_Req)
9584 MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
9586 static inline void mlxsw_reg_mtptptp_pack(char *payload,
9587 enum mlxsw_reg_mtptpt_trap_id trap_id,
9590 MLXSW_REG_ZERO(mtptpt, payload);
9591 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
9592 mlxsw_reg_mtptpt_message_type_set(payload, message_type);
9595 /* MGPIR - Management General Peripheral Information Register
9596 * ----------------------------------------------------------
9597 * MGPIR register allows software to query the hardware and
9598 * firmware general information of peripheral entities.
9600 #define MLXSW_REG_MGPIR_ID 0x9100
9601 #define MLXSW_REG_MGPIR_LEN 0xA0
9603 MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
9605 enum mlxsw_reg_mgpir_device_type {
9606 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
9607 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
9613 MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
9615 /* devices_per_flash
9616 * Number of devices of device_type per flash (can be shared by few devices).
9619 MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
9622 * Number of devices of device_type.
9625 MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
9628 * Number of modules.
9631 MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
9633 static inline void mlxsw_reg_mgpir_pack(char *payload)
9635 MLXSW_REG_ZERO(mgpir, payload);
9639 mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
9640 enum mlxsw_reg_mgpir_device_type *device_type,
9641 u8 *devices_per_flash, u8 *num_of_modules)
9644 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
9646 *device_type = mlxsw_reg_mgpir_device_type_get(payload);
9647 if (devices_per_flash)
9648 *devices_per_flash =
9649 mlxsw_reg_mgpir_devices_per_flash_get(payload);
9651 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
9654 /* TNGCR - Tunneling NVE General Configuration Register
9655 * ----------------------------------------------------
9656 * The TNGCR register is used for setting up the NVE Tunneling configuration.
9658 #define MLXSW_REG_TNGCR_ID 0xA001
9659 #define MLXSW_REG_TNGCR_LEN 0x44
9661 MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
9663 enum mlxsw_reg_tngcr_type {
9664 MLXSW_REG_TNGCR_TYPE_VXLAN,
9665 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
9666 MLXSW_REG_TNGCR_TYPE_GENEVE,
9667 MLXSW_REG_TNGCR_TYPE_NVGRE,
9671 * Tunnel type for encapsulation and decapsulation. The types are mutually
9673 * Note: For Spectrum the NVE parsing must be enabled in MPRS.
9676 MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
9678 /* reg_tngcr_nve_valid
9679 * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation.
9682 MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
9684 /* reg_tngcr_nve_ttl_uc
9685 * The TTL for NVE tunnel encapsulation underlay unicast packets.
9688 MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
9690 /* reg_tngcr_nve_ttl_mc
9691 * The TTL for NVE tunnel encapsulation underlay multicast packets.
9694 MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
9697 /* Do not copy flow label. Calculate flow label using nve_flh. */
9698 MLXSW_REG_TNGCR_FL_NO_COPY,
9699 /* Copy flow label from inner packet if packet is IPv6 and
9700 * encapsulation is by IPv6. Otherwise, calculate flow label using
9703 MLXSW_REG_TNGCR_FL_COPY,
9706 /* reg_tngcr_nve_flc
9707 * For NVE tunnel encapsulation: Flow label copy from inner packet.
9710 MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
9713 /* Flow label is static. In Spectrum this means '0'. Spectrum-2
9714 * uses {nve_fl_prefix, nve_fl_suffix}.
9716 MLXSW_REG_TNGCR_FL_NO_HASH,
9717 /* 8 LSBs of the flow label are calculated from ECMP hash of the
9718 * inner packet. 12 MSBs are configured by nve_fl_prefix.
9720 MLXSW_REG_TNGCR_FL_HASH,
9723 /* reg_tngcr_nve_flh
9724 * NVE flow label hash.
9727 MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
9729 /* reg_tngcr_nve_fl_prefix
9730 * NVE flow label prefix. Constant 12 MSBs of the flow label.
9733 MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
9735 /* reg_tngcr_nve_fl_suffix
9736 * NVE flow label suffix. Constant 8 LSBs of the flow label.
9737 * Reserved when nve_flh=1 and for Spectrum.
9740 MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
9743 /* Source UDP port is fixed (default '0') */
9744 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
9745 /* Source UDP port is calculated based on hash */
9746 MLXSW_REG_TNGCR_UDP_SPORT_HASH,
9749 /* reg_tngcr_nve_udp_sport_type
9750 * NVE UDP source port type.
9751 * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2).
9752 * When the source UDP port is calculated based on hash, then the 8 LSBs
9753 * are calculated from hash the 8 MSBs are configured by
9754 * nve_udp_sport_prefix.
9757 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
9759 /* reg_tngcr_nve_udp_sport_prefix
9760 * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port.
9761 * Reserved when NVE type is NVGRE.
9764 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
9766 /* reg_tngcr_nve_group_size_mc
9767 * The amount of sequential linked lists of MC entries. The first linked
9768 * list is configured by SFD.underlay_mc_ptr.
9769 * Valid values: 1, 2, 4, 8, 16, 32, 64
9770 * The linked list are configured by TNUMT.
9771 * The hash is set by LAG hash.
9774 MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
9776 /* reg_tngcr_nve_group_size_flood
9777 * The amount of sequential linked lists of flooding entries. The first
9778 * linked list is configured by SFMR.nve_tunnel_flood_ptr
9779 * Valid values: 1, 2, 4, 8, 16, 32, 64
9780 * The linked list are configured by TNUMT.
9781 * The hash is set by LAG hash.
9784 MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
9786 /* reg_tngcr_learn_enable
9787 * During decapsulation, whether to learn from NVE port.
9788 * Reserved when Spectrum-2. See TNPC.
9791 MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
9793 /* reg_tngcr_underlay_virtual_router
9794 * Underlay virtual router.
9795 * Reserved when Spectrum-2.
9798 MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
9800 /* reg_tngcr_underlay_rif
9801 * Underlay ingress router interface. RIF type should be loopback generic.
9802 * Reserved when Spectrum.
9805 MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
9808 * Underlay source IPv4 address of the NVE.
9811 MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
9814 * Underlay source IPv6 address of the NVE. For Spectrum, must not be
9815 * modified under traffic of NVE tunneling encapsulation.
9818 MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
9820 static inline void mlxsw_reg_tngcr_pack(char *payload,
9821 enum mlxsw_reg_tngcr_type type,
9824 MLXSW_REG_ZERO(tngcr, payload);
9825 mlxsw_reg_tngcr_type_set(payload, type);
9826 mlxsw_reg_tngcr_nve_valid_set(payload, valid);
9827 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
9828 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
9829 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
9830 mlxsw_reg_tngcr_nve_flh_set(payload, 0);
9831 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
9832 MLXSW_REG_TNGCR_UDP_SPORT_HASH);
9833 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
9834 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
9835 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
9838 /* TNUMT - Tunneling NVE Underlay Multicast Table Register
9839 * -------------------------------------------------------
9840 * The TNUMT register is for building the underlay MC table. It is used
9841 * for MC, flooding and BC traffic into the NVE tunnel.
9843 #define MLXSW_REG_TNUMT_ID 0xA003
9844 #define MLXSW_REG_TNUMT_LEN 0x20
9846 MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
9848 enum mlxsw_reg_tnumt_record_type {
9849 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
9850 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
9851 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
9854 /* reg_tnumt_record_type
9858 MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
9860 enum mlxsw_reg_tnumt_tunnel_port {
9861 MLXSW_REG_TNUMT_TUNNEL_PORT_NVE,
9862 MLXSW_REG_TNUMT_TUNNEL_PORT_VPLS,
9863 MLXSW_REG_TNUMT_TUNNEL_FLEX_TUNNEL0,
9864 MLXSW_REG_TNUMT_TUNNEL_FLEX_TUNNEL1,
9867 /* reg_tnumt_tunnel_port
9871 MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
9873 /* reg_tnumt_underlay_mc_ptr
9874 * Index to the underlay multicast table.
9875 * For Spectrum the index is to the KVD linear.
9878 MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
9881 * The next_underlay_mc_ptr is valid.
9884 MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
9886 /* reg_tnumt_next_underlay_mc_ptr
9887 * The next index to the underlay multicast table.
9890 MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
9892 /* reg_tnumt_record_size
9893 * Number of IP addresses in the record.
9894 * Range is 1..cap_max_nve_mc_entries_ipv{4,6}
9897 MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
9900 * The underlay IPv4 addresses. udip[i] is reserved if i >= size
9903 MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
9905 /* reg_tnumt_udip_ptr
9906 * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if
9907 * i >= size. The IPv6 addresses are configured by RIPS.
9910 MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
9912 static inline void mlxsw_reg_tnumt_pack(char *payload,
9913 enum mlxsw_reg_tnumt_record_type type,
9914 enum mlxsw_reg_tnumt_tunnel_port tport,
9915 u32 underlay_mc_ptr, bool vnext,
9916 u32 next_underlay_mc_ptr,
9919 MLXSW_REG_ZERO(tnumt, payload);
9920 mlxsw_reg_tnumt_record_type_set(payload, type);
9921 mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
9922 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
9923 mlxsw_reg_tnumt_vnext_set(payload, vnext);
9924 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
9925 mlxsw_reg_tnumt_record_size_set(payload, record_size);
9928 /* TNQCR - Tunneling NVE QoS Configuration Register
9929 * ------------------------------------------------
9930 * The TNQCR register configures how QoS is set in encapsulation into the
9933 #define MLXSW_REG_TNQCR_ID 0xA010
9934 #define MLXSW_REG_TNQCR_LEN 0x0C
9936 MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
9938 /* reg_tnqcr_enc_set_dscp
9939 * For encapsulation: How to set DSCP field:
9940 * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay
9941 * (outer) IP header. If there is no IP header, use TNQDR.dscp
9942 * 1 - Set the DSCP field as TNQDR.dscp
9945 MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
9947 static inline void mlxsw_reg_tnqcr_pack(char *payload)
9949 MLXSW_REG_ZERO(tnqcr, payload);
9950 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
9953 /* TNQDR - Tunneling NVE QoS Default Register
9954 * ------------------------------------------
9955 * The TNQDR register configures the default QoS settings for NVE
9958 #define MLXSW_REG_TNQDR_ID 0xA011
9959 #define MLXSW_REG_TNQDR_LEN 0x08
9961 MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
9963 /* reg_tnqdr_local_port
9964 * Local port number (receive port). CPU port is supported.
9967 MLXSW_ITEM32(reg, tnqdr, local_port, 0x00, 16, 8);
9970 * For encapsulation, the default DSCP.
9973 MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
9975 static inline void mlxsw_reg_tnqdr_pack(char *payload, u8 local_port)
9977 MLXSW_REG_ZERO(tnqdr, payload);
9978 mlxsw_reg_tnqdr_local_port_set(payload, local_port);
9979 mlxsw_reg_tnqdr_dscp_set(payload, 0);
9982 /* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register
9983 * --------------------------------------------------------
9984 * The TNEEM register maps ECN of the IP header at the ingress to the
9985 * encapsulation to the ECN of the underlay network.
9987 #define MLXSW_REG_TNEEM_ID 0xA012
9988 #define MLXSW_REG_TNEEM_LEN 0x0C
9990 MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
9992 /* reg_tneem_overlay_ecn
9993 * ECN of the IP header in the overlay network.
9996 MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
9998 /* reg_tneem_underlay_ecn
9999 * ECN of the IP header in the underlay network.
10002 MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
10004 static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
10007 MLXSW_REG_ZERO(tneem, payload);
10008 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
10009 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
10012 /* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register
10013 * --------------------------------------------------------
10014 * The TNDEM register configures the actions that are done in the
10017 #define MLXSW_REG_TNDEM_ID 0xA013
10018 #define MLXSW_REG_TNDEM_LEN 0x0C
10020 MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
10022 /* reg_tndem_underlay_ecn
10023 * ECN field of the IP header in the underlay network.
10026 MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
10028 /* reg_tndem_overlay_ecn
10029 * ECN field of the IP header in the overlay network.
10032 MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
10034 /* reg_tndem_eip_ecn
10035 * Egress IP ECN. ECN field of the IP header of the packet which goes out
10036 * from the decapsulation.
10039 MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
10041 /* reg_tndem_trap_en
10043 * 0 - No trap due to decap ECN
10044 * 1 - Trap enable with trap_id
10047 MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
10049 /* reg_tndem_trap_id
10050 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
10051 * Reserved when trap_en is '0'.
10054 MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
10056 static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
10057 u8 overlay_ecn, u8 ecn, bool trap_en,
10060 MLXSW_REG_ZERO(tndem, payload);
10061 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
10062 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
10063 mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
10064 mlxsw_reg_tndem_trap_en_set(payload, trap_en);
10065 mlxsw_reg_tndem_trap_id_set(payload, trap_id);
10068 /* TNPC - Tunnel Port Configuration Register
10069 * -----------------------------------------
10070 * The TNPC register is used for tunnel port configuration.
10071 * Reserved when Spectrum.
10073 #define MLXSW_REG_TNPC_ID 0xA020
10074 #define MLXSW_REG_TNPC_LEN 0x18
10076 MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
10078 enum mlxsw_reg_tnpc_tunnel_port {
10079 MLXSW_REG_TNPC_TUNNEL_PORT_NVE,
10080 MLXSW_REG_TNPC_TUNNEL_PORT_VPLS,
10081 MLXSW_REG_TNPC_TUNNEL_FLEX_TUNNEL0,
10082 MLXSW_REG_TNPC_TUNNEL_FLEX_TUNNEL1,
10085 /* reg_tnpc_tunnel_port
10089 MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
10091 /* reg_tnpc_learn_enable_v6
10092 * During IPv6 underlay decapsulation, whether to learn from tunnel port.
10095 MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
10097 /* reg_tnpc_learn_enable_v4
10098 * During IPv4 underlay decapsulation, whether to learn from tunnel port.
10101 MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
10103 static inline void mlxsw_reg_tnpc_pack(char *payload,
10104 enum mlxsw_reg_tnpc_tunnel_port tport,
10107 MLXSW_REG_ZERO(tnpc, payload);
10108 mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
10109 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
10110 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
10113 /* TIGCR - Tunneling IPinIP General Configuration Register
10114 * -------------------------------------------------------
10115 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
10117 #define MLXSW_REG_TIGCR_ID 0xA801
10118 #define MLXSW_REG_TIGCR_LEN 0x10
10120 MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
10122 /* reg_tigcr_ipip_ttlc
10123 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
10127 MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
10129 /* reg_tigcr_ipip_ttl_uc
10130 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
10131 * reg_tigcr_ipip_ttlc is unset.
10134 MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
10136 static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
10138 MLXSW_REG_ZERO(tigcr, payload);
10139 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
10140 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
10143 /* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register
10144 * -----------------------------------------------------------
10145 * The TIEEM register maps ECN of the IP header at the ingress to the
10146 * encapsulation to the ECN of the underlay network.
10148 #define MLXSW_REG_TIEEM_ID 0xA812
10149 #define MLXSW_REG_TIEEM_LEN 0x0C
10151 MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
10153 /* reg_tieem_overlay_ecn
10154 * ECN of the IP header in the overlay network.
10157 MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
10159 /* reg_tineem_underlay_ecn
10160 * ECN of the IP header in the underlay network.
10163 MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
10165 static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
10168 MLXSW_REG_ZERO(tieem, payload);
10169 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
10170 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
10173 /* SBPR - Shared Buffer Pools Register
10174 * -----------------------------------
10175 * The SBPR configures and retrieves the shared buffer pools and configuration.
10177 #define MLXSW_REG_SBPR_ID 0xB001
10178 #define MLXSW_REG_SBPR_LEN 0x14
10180 MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
10182 /* shared direstion enum for SBPR, SBCM, SBPM */
10183 enum mlxsw_reg_sbxx_dir {
10184 MLXSW_REG_SBXX_DIR_INGRESS,
10185 MLXSW_REG_SBXX_DIR_EGRESS,
10192 MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
10198 MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
10200 /* reg_sbpr_infi_size
10201 * Size is infinite.
10204 MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
10207 * Pool size in buffer cells.
10208 * Reserved when infi_size = 1.
10211 MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
10213 enum mlxsw_reg_sbpr_mode {
10214 MLXSW_REG_SBPR_MODE_STATIC,
10215 MLXSW_REG_SBPR_MODE_DYNAMIC,
10219 * Pool quota calculation mode.
10222 MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
10224 static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
10225 enum mlxsw_reg_sbxx_dir dir,
10226 enum mlxsw_reg_sbpr_mode mode, u32 size,
10229 MLXSW_REG_ZERO(sbpr, payload);
10230 mlxsw_reg_sbpr_pool_set(payload, pool);
10231 mlxsw_reg_sbpr_dir_set(payload, dir);
10232 mlxsw_reg_sbpr_mode_set(payload, mode);
10233 mlxsw_reg_sbpr_size_set(payload, size);
10234 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
10237 /* SBCM - Shared Buffer Class Management Register
10238 * ----------------------------------------------
10239 * The SBCM register configures and retrieves the shared buffer allocation
10240 * and configuration according to Port-PG, including the binding to pool
10241 * and definition of the associated quota.
10243 #define MLXSW_REG_SBCM_ID 0xB002
10244 #define MLXSW_REG_SBCM_LEN 0x28
10246 MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
10248 /* reg_sbcm_local_port
10249 * Local port number.
10250 * For Ingress: excludes CPU port and Router port
10251 * For Egress: excludes IP Router
10254 MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
10256 /* reg_sbcm_pg_buff
10257 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
10258 * For PG buffer: range is 0..cap_max_pg_buffers - 1
10259 * For traffic class: range is 0..cap_max_tclass - 1
10260 * Note that when traffic class is in MC aware mode then the traffic
10261 * classes which are MC aware cannot be configured.
10264 MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
10270 MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
10272 /* reg_sbcm_min_buff
10273 * Minimum buffer size for the limiter, in cells.
10276 MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
10278 /* shared max_buff limits for dynamic threshold for SBCM, SBPM */
10279 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
10280 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
10282 /* reg_sbcm_infi_max
10283 * Max buffer is infinite.
10286 MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
10288 /* reg_sbcm_max_buff
10289 * When the pool associated to the port-pg/tclass is configured to
10290 * static, Maximum buffer size for the limiter configured in cells.
10291 * When the pool associated to the port-pg/tclass is configured to
10292 * dynamic, the max_buff holds the "alpha" parameter, supporting
10293 * the following values:
10295 * i: (1/128)*2^(i-1), for i=1..14
10297 * Reserved when infi_max = 1.
10300 MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
10303 * Association of the port-priority to a pool.
10306 MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
10308 static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
10309 enum mlxsw_reg_sbxx_dir dir,
10310 u32 min_buff, u32 max_buff,
10311 bool infi_max, u8 pool)
10313 MLXSW_REG_ZERO(sbcm, payload);
10314 mlxsw_reg_sbcm_local_port_set(payload, local_port);
10315 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
10316 mlxsw_reg_sbcm_dir_set(payload, dir);
10317 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
10318 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
10319 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
10320 mlxsw_reg_sbcm_pool_set(payload, pool);
10323 /* SBPM - Shared Buffer Port Management Register
10324 * ---------------------------------------------
10325 * The SBPM register configures and retrieves the shared buffer allocation
10326 * and configuration according to Port-Pool, including the definition
10327 * of the associated quota.
10329 #define MLXSW_REG_SBPM_ID 0xB003
10330 #define MLXSW_REG_SBPM_LEN 0x28
10332 MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
10334 /* reg_sbpm_local_port
10335 * Local port number.
10336 * For Ingress: excludes CPU port and Router port
10337 * For Egress: excludes IP Router
10340 MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
10343 * The pool associated to quota counting on the local_port.
10346 MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
10352 MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
10354 /* reg_sbpm_buff_occupancy
10355 * Current buffer occupancy in cells.
10358 MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
10361 * Clear Max Buffer Occupancy
10362 * When this bit is set, max_buff_occupancy field is cleared (and a
10363 * new max value is tracked from the time the clear was performed).
10366 MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
10368 /* reg_sbpm_max_buff_occupancy
10369 * Maximum value of buffer occupancy in cells monitored. Cleared by
10370 * writing to the clr field.
10373 MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
10375 /* reg_sbpm_min_buff
10376 * Minimum buffer size for the limiter, in cells.
10379 MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
10381 /* reg_sbpm_max_buff
10382 * When the pool associated to the port-pg/tclass is configured to
10383 * static, Maximum buffer size for the limiter configured in cells.
10384 * When the pool associated to the port-pg/tclass is configured to
10385 * dynamic, the max_buff holds the "alpha" parameter, supporting
10386 * the following values:
10388 * i: (1/128)*2^(i-1), for i=1..14
10392 MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
10394 static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
10395 enum mlxsw_reg_sbxx_dir dir, bool clr,
10396 u32 min_buff, u32 max_buff)
10398 MLXSW_REG_ZERO(sbpm, payload);
10399 mlxsw_reg_sbpm_local_port_set(payload, local_port);
10400 mlxsw_reg_sbpm_pool_set(payload, pool);
10401 mlxsw_reg_sbpm_dir_set(payload, dir);
10402 mlxsw_reg_sbpm_clr_set(payload, clr);
10403 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
10404 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
10407 static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
10408 u32 *p_max_buff_occupancy)
10410 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
10411 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
10414 /* SBMM - Shared Buffer Multicast Management Register
10415 * --------------------------------------------------
10416 * The SBMM register configures and retrieves the shared buffer allocation
10417 * and configuration for MC packets according to Switch-Priority, including
10418 * the binding to pool and definition of the associated quota.
10420 #define MLXSW_REG_SBMM_ID 0xB004
10421 #define MLXSW_REG_SBMM_LEN 0x28
10423 MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
10429 MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
10431 /* reg_sbmm_min_buff
10432 * Minimum buffer size for the limiter, in cells.
10435 MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
10437 /* reg_sbmm_max_buff
10438 * When the pool associated to the port-pg/tclass is configured to
10439 * static, Maximum buffer size for the limiter configured in cells.
10440 * When the pool associated to the port-pg/tclass is configured to
10441 * dynamic, the max_buff holds the "alpha" parameter, supporting
10442 * the following values:
10444 * i: (1/128)*2^(i-1), for i=1..14
10448 MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
10451 * Association of the port-priority to a pool.
10454 MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
10456 static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
10457 u32 max_buff, u8 pool)
10459 MLXSW_REG_ZERO(sbmm, payload);
10460 mlxsw_reg_sbmm_prio_set(payload, prio);
10461 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
10462 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
10463 mlxsw_reg_sbmm_pool_set(payload, pool);
10466 /* SBSR - Shared Buffer Status Register
10467 * ------------------------------------
10468 * The SBSR register retrieves the shared buffer occupancy according to
10469 * Port-Pool. Note that this register enables reading a large amount of data.
10470 * It is the user's responsibility to limit the amount of data to ensure the
10471 * response can match the maximum transfer unit. In case the response exceeds
10472 * the maximum transport unit, it will be truncated with no special notice.
10474 #define MLXSW_REG_SBSR_ID 0xB005
10475 #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
10476 #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
10477 #define MLXSW_REG_SBSR_REC_MAX_COUNT 120
10478 #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
10479 MLXSW_REG_SBSR_REC_LEN * \
10480 MLXSW_REG_SBSR_REC_MAX_COUNT)
10482 MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
10485 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
10486 * field is cleared (and a new max value is tracked from the time the clear
10490 MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
10492 /* reg_sbsr_ingress_port_mask
10493 * Bit vector for all ingress network ports.
10494 * Indicates which of the ports (for which the relevant bit is set)
10495 * are affected by the set operation. Configuration of any other port
10499 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
10501 /* reg_sbsr_pg_buff_mask
10502 * Bit vector for all switch priority groups.
10503 * Indicates which of the priorities (for which the relevant bit is set)
10504 * are affected by the set operation. Configuration of any other priority
10506 * Range is 0..cap_max_pg_buffers - 1
10509 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
10511 /* reg_sbsr_egress_port_mask
10512 * Bit vector for all egress network ports.
10513 * Indicates which of the ports (for which the relevant bit is set)
10514 * are affected by the set operation. Configuration of any other port
10518 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
10520 /* reg_sbsr_tclass_mask
10521 * Bit vector for all traffic classes.
10522 * Indicates which of the traffic classes (for which the relevant bit is
10523 * set) are affected by the set operation. Configuration of any other
10524 * traffic class does not change.
10525 * Range is 0..cap_max_tclass - 1
10528 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
10530 static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
10532 MLXSW_REG_ZERO(sbsr, payload);
10533 mlxsw_reg_sbsr_clr_set(payload, clr);
10536 /* reg_sbsr_rec_buff_occupancy
10537 * Current buffer occupancy in cells.
10540 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
10541 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
10543 /* reg_sbsr_rec_max_buff_occupancy
10544 * Maximum value of buffer occupancy in cells monitored. Cleared by
10545 * writing to the clr field.
10548 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
10549 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
10551 static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
10552 u32 *p_buff_occupancy,
10553 u32 *p_max_buff_occupancy)
10555 *p_buff_occupancy =
10556 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
10557 *p_max_buff_occupancy =
10558 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
10561 /* SBIB - Shared Buffer Internal Buffer Register
10562 * ---------------------------------------------
10563 * The SBIB register configures per port buffers for internal use. The internal
10564 * buffers consume memory on the port buffers (note that the port buffers are
10565 * used also by PBMC).
10567 * For Spectrum this is used for egress mirroring.
10569 #define MLXSW_REG_SBIB_ID 0xB006
10570 #define MLXSW_REG_SBIB_LEN 0x10
10572 MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
10574 /* reg_sbib_local_port
10575 * Local port number
10576 * Not supported for CPU port and router port
10579 MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
10581 /* reg_sbib_buff_size
10582 * Units represented in cells
10583 * Allowed range is 0 to (cap_max_headroom_size - 1)
10587 MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
10589 static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
10592 MLXSW_REG_ZERO(sbib, payload);
10593 mlxsw_reg_sbib_local_port_set(payload, local_port);
10594 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
10597 static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
10726 static inline const char *mlxsw_reg_id_str(u16 reg_id)
10728 const struct mlxsw_reg_info *reg_info;
10731 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
10732 reg_info = mlxsw_reg_infos[i];
10733 if (reg_info->id == reg_id)
10734 return reg_info->name;
10736 return "*UNKNOWN*";
10739 /* PUDE - Port Up / Down Event
10740 * ---------------------------
10741 * Reports the operational state change of a port.
10743 #define MLXSW_REG_PUDE_LEN 0x10
10746 * Switch partition ID with which to associate the port.
10749 MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
10751 /* reg_pude_local_port
10752 * Local port number.
10755 MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
10757 /* reg_pude_admin_status
10758 * Port administrative state (the desired state).
10761 * 3 - Up once. This means that in case of link failure, the port won't go
10762 * into polling mode, but will wait to be re-enabled by software.
10763 * 4 - Disabled by system. Can only be set by hardware.
10766 MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
10768 /* reg_pude_oper_status
10769 * Port operatioanl state.
10772 * 3 - Down by port failure. This means that the device will not let the
10773 * port up again until explicitly specified by software.
10776 MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);