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);
41 /* reg_sgcr_lag_lookup_pgt_base
42 * Base address used for lookup in PGT table
43 * Supported when CONFIG_PROFILE.lag_mode = 1
44 * Note: when IGCR.ddd_lag_mode=0, the address shall be aligned to 8 entries.
47 MLXSW_ITEM32(reg, sgcr, lag_lookup_pgt_base, 0x0C, 0, 16);
49 static inline void mlxsw_reg_sgcr_pack(char *payload, u16 lag_lookup_pgt_base)
51 MLXSW_REG_ZERO(sgcr, payload);
52 mlxsw_reg_sgcr_lag_lookup_pgt_base_set(payload, lag_lookup_pgt_base);
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 /* SSPR - Switch System Port Record Register
73 * -----------------------------------------
74 * Configures the system port to local port mapping.
76 #define MLXSW_REG_SSPR_ID 0x2008
77 #define MLXSW_REG_SSPR_LEN 0x8
79 MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
82 * Master - if set, then the record describes the master system port.
83 * This is needed in case a local port is mapped into several system ports
84 * (for multipathing). That number will be reported as the source system
85 * port when packets are forwarded to the CPU. Only one master port is allowed
88 * Note: Must be set for Spectrum.
91 MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
93 /* reg_sspr_local_port
98 MLXSW_ITEM32_LP(reg, sspr, 0x00, 16, 0x00, 12);
100 /* reg_sspr_system_port
101 * Unique identifier within the stacking domain that represents all the ports
102 * that are available in the system (external ports).
104 * Currently, only single-ASIC configurations are supported, so we default to
105 * 1:1 mapping between system ports and local ports.
108 MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
110 static inline void mlxsw_reg_sspr_pack(char *payload, u16 local_port)
112 MLXSW_REG_ZERO(sspr, payload);
113 mlxsw_reg_sspr_m_set(payload, 1);
114 mlxsw_reg_sspr_local_port_set(payload, local_port);
115 mlxsw_reg_sspr_system_port_set(payload, local_port);
118 /* SFDAT - Switch Filtering Database Aging Time
119 * --------------------------------------------
120 * Controls the Switch aging time. Aging time is able to be set per Switch
123 #define MLXSW_REG_SFDAT_ID 0x2009
124 #define MLXSW_REG_SFDAT_LEN 0x8
126 MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
129 * Switch partition ID.
132 MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
134 /* reg_sfdat_age_time
135 * Aging time in seconds
137 * Max - 1,000,000 seconds
138 * Default is 300 seconds.
141 MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
143 static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
145 MLXSW_REG_ZERO(sfdat, payload);
146 mlxsw_reg_sfdat_swid_set(payload, 0);
147 mlxsw_reg_sfdat_age_time_set(payload, age_time);
150 /* SFD - Switch Filtering Database
151 * -------------------------------
152 * The following register defines the access to the filtering database.
153 * The register supports querying, adding, removing and modifying the database.
154 * The access is optimized for bulk updates in which case more than one
155 * FDB record is present in the same command.
157 #define MLXSW_REG_SFD_ID 0x200A
158 #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
159 #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
160 #define MLXSW_REG_SFD_REC_MAX_COUNT 64
161 #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
162 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
164 MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
167 * Switch partition ID for queries. Reserved on Write.
170 MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
172 enum mlxsw_reg_sfd_op {
173 /* Dump entire FDB a (process according to record_locator) */
174 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
175 /* Query records by {MAC, VID/FID} value */
176 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
177 /* Query and clear activity. Query records by {MAC, VID/FID} value */
178 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
179 /* Test. Response indicates if each of the records could be
182 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
183 /* Add/modify. Aged-out records cannot be added. This command removes
184 * the learning notification of the {MAC, VID/FID}. Response includes
185 * the entries that were added to the FDB.
187 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
188 /* Remove record by {MAC, VID/FID}. This command also removes
189 * the learning notification and aged-out notifications
190 * of the {MAC, VID/FID}. The response provides current (pre-removal)
191 * entries as non-aged-out.
193 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
194 /* Remove learned notification by {MAC, VID/FID}. The response provides
195 * the removed learning notification.
197 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
204 MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
206 /* reg_sfd_record_locator
207 * Used for querying the FDB. Use record_locator=0 to initiate the
208 * query. When a record is returned, a new record_locator is
209 * returned to be used in the subsequent query.
210 * Reserved for database update.
213 MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
216 * Request: Number of records to read/add/modify/remove
217 * Response: Number of records read/added/replaced/removed
218 * See above description for more details.
222 MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
224 static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
227 MLXSW_REG_ZERO(sfd, payload);
228 mlxsw_reg_sfd_op_set(payload, op);
229 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
233 * Switch partition ID.
236 MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
237 MLXSW_REG_SFD_REC_LEN, 0x00, false);
239 enum mlxsw_reg_sfd_rec_type {
240 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
241 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
242 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
243 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC,
250 MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
251 MLXSW_REG_SFD_REC_LEN, 0x00, false);
253 enum mlxsw_reg_sfd_rec_policy {
254 /* Replacement disabled, aging disabled. */
255 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
256 /* (mlag remote): Replacement enabled, aging disabled,
257 * learning notification enabled on this port.
259 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
260 /* (ingress device): Replacement enabled, aging enabled. */
261 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
264 /* reg_sfd_rec_policy
268 MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
269 MLXSW_REG_SFD_REC_LEN, 0x00, false);
272 * Activity. Set for new static entries. Set for static entries if a frame SMAC
273 * lookup hits on the entry.
274 * To clear the a bit, use "query and clear activity" op.
277 MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
278 MLXSW_REG_SFD_REC_LEN, 0x00, false);
284 MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
285 MLXSW_REG_SFD_REC_LEN, 0x02);
287 enum mlxsw_reg_sfd_rec_action {
289 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
290 /* forward and trap, trap_id is FDB_TRAP */
291 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
292 /* trap and do not forward, trap_id is FDB_TRAP */
293 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
294 /* forward to IP router */
295 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
296 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
299 /* reg_sfd_rec_action
300 * Action to apply on the packet.
301 * Note: Dynamic entries can only be configured with NOP action.
304 MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
305 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
307 /* reg_sfd_uc_sub_port
308 * VEPA channel on local port.
309 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
310 * VEPA is not enabled.
313 MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
314 MLXSW_REG_SFD_REC_LEN, 0x08, false);
316 /* reg_sfd_uc_set_vid
318 * 0 - Do not update VID.
320 * For Spectrum-2 when set_vid=0 and smpe_valid=1, the smpe will modify the vid.
323 * Note: Reserved when legacy bridge model is used.
325 MLXSW_ITEM32_INDEXED(reg, sfd, uc_set_vid, MLXSW_REG_SFD_BASE_LEN, 31, 1,
326 MLXSW_REG_SFD_REC_LEN, 0x08, false);
328 /* reg_sfd_uc_fid_vid
329 * Filtering ID or VLAN ID
330 * For SwitchX and SwitchX-2:
331 * - Dynamic entries (policy 2,3) use FID
332 * - Static entries (policy 0) use VID
333 * - When independent learning is configured, VID=FID
334 * For Spectrum: use FID for both Dynamic and Static entries.
335 * VID should not be used.
338 MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
339 MLXSW_REG_SFD_REC_LEN, 0x08, false);
342 * New VID when set_vid=1.
345 * Note: Reserved when legacy bridge model is used and when set_vid=0.
347 MLXSW_ITEM32_INDEXED(reg, sfd, uc_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
348 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
350 /* reg_sfd_uc_system_port
351 * Unique port identifier for the final destination of the packet.
354 MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
355 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
357 static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
358 enum mlxsw_reg_sfd_rec_type rec_type,
360 enum mlxsw_reg_sfd_rec_action action)
362 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
364 if (rec_index >= num_rec)
365 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
366 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
367 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
368 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
369 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
372 static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
373 enum mlxsw_reg_sfd_rec_policy policy,
374 const char *mac, u16 fid_vid, u16 vid,
375 enum mlxsw_reg_sfd_rec_action action,
378 mlxsw_reg_sfd_rec_pack(payload, rec_index,
379 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
380 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
381 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
382 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
383 mlxsw_reg_sfd_uc_set_vid_set(payload, rec_index, vid ? true : false);
384 mlxsw_reg_sfd_uc_vid_set(payload, rec_index, vid);
385 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
388 /* reg_sfd_uc_lag_sub_port
390 * Must be 0 if multichannel VEPA is not enabled.
393 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
394 MLXSW_REG_SFD_REC_LEN, 0x08, false);
396 /* reg_sfd_uc_lag_set_vid
398 * 0 - Do not update VID.
400 * For Spectrum-2 when set_vid=0 and smpe_valid=1, the smpe will modify the vid.
403 * Note: Reserved when legacy bridge model is used.
405 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_set_vid, MLXSW_REG_SFD_BASE_LEN, 31, 1,
406 MLXSW_REG_SFD_REC_LEN, 0x08, false);
408 /* reg_sfd_uc_lag_fid_vid
409 * Filtering ID or VLAN ID
410 * For SwitchX and SwitchX-2:
411 * - Dynamic entries (policy 2,3) use FID
412 * - Static entries (policy 0) use VID
413 * - When independent learning is configured, VID=FID
414 * For Spectrum: use FID for both Dynamic and Static entries.
415 * VID should not be used.
418 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
419 MLXSW_REG_SFD_REC_LEN, 0x08, false);
421 /* reg_sfd_uc_lag_lag_vid
425 * Note: Reserved when legacy bridge model is used and set_vid=0.
427 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
428 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
430 /* reg_sfd_uc_lag_lag_id
431 * LAG Identifier - pointer into the LAG descriptor table.
434 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
435 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
438 mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
439 enum mlxsw_reg_sfd_rec_policy policy,
440 const char *mac, u16 fid_vid,
441 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
444 mlxsw_reg_sfd_rec_pack(payload, rec_index,
445 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
447 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
448 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
449 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
450 mlxsw_reg_sfd_uc_lag_set_vid_set(payload, rec_index, true);
451 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
452 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
457 * Multicast port group index - index into the port group table.
458 * Value 0x1FFF indicates the pgi should point to the MID entry.
459 * For Spectrum this value must be set to 0x1FFF
462 MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
463 MLXSW_REG_SFD_REC_LEN, 0x08, false);
465 /* reg_sfd_mc_fid_vid
467 * Filtering ID or VLAN ID
470 MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
471 MLXSW_REG_SFD_REC_LEN, 0x08, false);
475 * Multicast identifier - global identifier that represents the multicast
476 * group across all devices.
479 MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
480 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
483 mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
484 const char *mac, u16 fid_vid,
485 enum mlxsw_reg_sfd_rec_action action, u16 mid)
487 mlxsw_reg_sfd_rec_pack(payload, rec_index,
488 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
489 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
490 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
491 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
494 /* reg_sfd_uc_tunnel_uip_msb
495 * When protocol is IPv4, the most significant byte of the underlay IPv4
497 * When protocol is IPv6, reserved.
500 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24,
501 8, MLXSW_REG_SFD_REC_LEN, 0x08, false);
503 /* reg_sfd_uc_tunnel_fid
507 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
508 MLXSW_REG_SFD_REC_LEN, 0x08, false);
510 enum mlxsw_reg_sfd_uc_tunnel_protocol {
511 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4,
512 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6,
515 /* reg_sfd_uc_tunnel_protocol
519 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27,
520 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
522 /* reg_sfd_uc_tunnel_uip_lsb
523 * When protocol is IPv4, the least significant bytes of the underlay
524 * IPv4 destination IP.
525 * When protocol is IPv6, pointer to the underlay IPv6 destination IP
526 * which is configured by RIPS.
529 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0,
530 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
533 mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
534 enum mlxsw_reg_sfd_rec_policy policy,
535 const char *mac, u16 fid,
536 enum mlxsw_reg_sfd_rec_action action,
537 enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
539 mlxsw_reg_sfd_rec_pack(payload, rec_index,
540 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
542 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
543 mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
544 mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
548 mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index,
549 enum mlxsw_reg_sfd_rec_policy policy,
550 const char *mac, u16 fid,
551 enum mlxsw_reg_sfd_rec_action action, u32 uip)
553 mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
554 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
555 mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, policy, mac, fid,
557 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4);
561 mlxsw_reg_sfd_uc_tunnel_pack6(char *payload, int rec_index, const char *mac,
562 u16 fid, enum mlxsw_reg_sfd_rec_action action,
565 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip_ptr);
566 /* Only static policy is supported for IPv6 unicast tunnel entry. */
567 mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index,
568 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY,
570 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6);
573 enum mlxsw_reg_tunnel_port {
574 MLXSW_REG_TUNNEL_PORT_NVE,
575 MLXSW_REG_TUNNEL_PORT_VPLS,
576 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL0,
577 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL1,
580 /* SFN - Switch FDB Notification Register
581 * -------------------------------------------
582 * The switch provides notifications on newly learned FDB entries and
583 * aged out entries. The notifications can be polled by software.
585 #define MLXSW_REG_SFN_ID 0x200B
586 #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
587 #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
588 #define MLXSW_REG_SFN_REC_MAX_COUNT 64
589 #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
590 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
592 MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
595 * Switch partition ID.
598 MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
601 * Forces the current session to end.
604 MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
607 * Request: Number of learned notifications and aged-out notification
609 * Response: Number of notification records returned (must be smaller
610 * than or equal to the value requested)
614 MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
616 static inline void mlxsw_reg_sfn_pack(char *payload)
618 MLXSW_REG_ZERO(sfn, payload);
619 mlxsw_reg_sfn_swid_set(payload, 0);
620 mlxsw_reg_sfn_end_set(payload, 0);
621 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
625 * Switch partition ID.
628 MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
629 MLXSW_REG_SFN_REC_LEN, 0x00, false);
631 enum mlxsw_reg_sfn_rec_type {
632 /* MAC addresses learned on a regular port. */
633 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
634 /* MAC addresses learned on a LAG port. */
635 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
636 /* Aged-out MAC address on a regular port. */
637 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
638 /* Aged-out MAC address on a LAG port. */
639 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
640 /* Learned unicast tunnel record. */
641 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
642 /* Aged-out unicast tunnel record. */
643 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
647 * Notification record type.
650 MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
651 MLXSW_REG_SFN_REC_LEN, 0x00, false);
657 MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
658 MLXSW_REG_SFN_REC_LEN, 0x02);
660 /* reg_sfn_mac_sub_port
661 * VEPA channel on the local port.
662 * 0 if multichannel VEPA is not enabled.
665 MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
666 MLXSW_REG_SFN_REC_LEN, 0x08, false);
669 * Filtering identifier.
672 MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
673 MLXSW_REG_SFN_REC_LEN, 0x08, false);
675 /* reg_sfn_mac_system_port
676 * Unique port identifier for the final destination of the packet.
679 MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
680 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
682 static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
683 char *mac, u16 *p_vid,
686 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
687 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
688 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
691 /* reg_sfn_mac_lag_lag_id
692 * LAG ID (pointer into the LAG descriptor table).
695 MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
696 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
698 static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
699 char *mac, u16 *p_vid,
702 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
703 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
704 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
707 /* reg_sfn_uc_tunnel_uip_msb
708 * When protocol is IPv4, the most significant byte of the underlay IPv4
709 * address of the remote VTEP.
710 * When protocol is IPv6, reserved.
713 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
714 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
716 enum mlxsw_reg_sfn_uc_tunnel_protocol {
717 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
718 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
721 /* reg_sfn_uc_tunnel_protocol
725 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
726 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
728 /* reg_sfn_uc_tunnel_uip_lsb
729 * When protocol is IPv4, the least significant bytes of the underlay
730 * IPv4 address of the remote VTEP.
731 * When protocol is IPv6, ipv6_id to be queried from TNIPSD.
734 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
735 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
737 /* reg_sfn_uc_tunnel_port
739 * Reserved on Spectrum.
742 MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4,
743 MLXSW_REG_SFN_REC_LEN, 0x10, false);
746 mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac,
747 u16 *p_fid, u32 *p_uip,
748 enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto)
750 u32 uip_msb, uip_lsb;
752 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
753 *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
754 uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index);
755 uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index);
756 *p_uip = uip_msb << 24 | uip_lsb;
757 *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index);
760 /* SPMS - Switch Port MSTP/RSTP State Register
761 * -------------------------------------------
762 * Configures the spanning tree state of a physical port.
764 #define MLXSW_REG_SPMS_ID 0x200D
765 #define MLXSW_REG_SPMS_LEN 0x404
767 MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
769 /* reg_spms_local_port
773 MLXSW_ITEM32_LP(reg, spms, 0x00, 16, 0x00, 12);
775 enum mlxsw_reg_spms_state {
776 MLXSW_REG_SPMS_STATE_NO_CHANGE,
777 MLXSW_REG_SPMS_STATE_DISCARDING,
778 MLXSW_REG_SPMS_STATE_LEARNING,
779 MLXSW_REG_SPMS_STATE_FORWARDING,
783 * Spanning tree state of each VLAN ID (VID) of the local port.
784 * 0 - Do not change spanning tree state (used only when writing).
785 * 1 - Discarding. No learning or forwarding to/from this port (default).
786 * 2 - Learning. Port is learning, but not forwarding.
787 * 3 - Forwarding. Port is learning and forwarding.
790 MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
792 static inline void mlxsw_reg_spms_pack(char *payload, u16 local_port)
794 MLXSW_REG_ZERO(spms, payload);
795 mlxsw_reg_spms_local_port_set(payload, local_port);
798 static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
799 enum mlxsw_reg_spms_state state)
801 mlxsw_reg_spms_state_set(payload, vid, state);
804 /* SPVID - Switch Port VID
805 * -----------------------
806 * The switch port VID configures the default VID for a port.
808 #define MLXSW_REG_SPVID_ID 0x200E
809 #define MLXSW_REG_SPVID_LEN 0x08
811 MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
814 * Port is tunnel port.
815 * Reserved when SwitchX/-2 or Spectrum-1.
818 MLXSW_ITEM32(reg, spvid, tport, 0x00, 24, 1);
820 /* reg_spvid_local_port
821 * When tport = 0: Local port number. Not supported for CPU port.
822 * When tport = 1: Tunnel port.
825 MLXSW_ITEM32_LP(reg, spvid, 0x00, 16, 0x00, 12);
827 /* reg_spvid_sub_port
828 * Virtual port within the physical port.
829 * Should be set to 0 when virtual ports are not enabled on the port.
832 MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
834 /* reg_spvid_egr_et_set
835 * When VLAN is pushed at ingress (for untagged packets or for
836 * QinQ push mode) then the EtherType is decided at the egress port.
837 * Reserved when Spectrum-1.
840 MLXSW_ITEM32(reg, spvid, egr_et_set, 0x04, 24, 1);
843 * EtherType used for when VLAN is pushed at ingress (for untagged
844 * packets or for QinQ push mode).
845 * 0: ether_type0 - (default)
847 * 2: ether_type2 - Reserved when Spectrum-1, supported by Spectrum-2
848 * Ethertype IDs are configured by SVER.
849 * Reserved when egr_et_set = 1.
852 MLXSW_ITEM32(reg, spvid, et_vlan, 0x04, 16, 2);
858 MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
860 static inline void mlxsw_reg_spvid_pack(char *payload, u16 local_port, u16 pvid,
863 MLXSW_REG_ZERO(spvid, payload);
864 mlxsw_reg_spvid_local_port_set(payload, local_port);
865 mlxsw_reg_spvid_pvid_set(payload, pvid);
866 mlxsw_reg_spvid_et_vlan_set(payload, et_vlan);
869 /* SPVM - Switch Port VLAN Membership
870 * ----------------------------------
871 * The Switch Port VLAN Membership register configures the VLAN membership
872 * of a port in a VLAN denoted by VID. VLAN membership is managed per
873 * virtual port. The register can be used to add and remove VID(s) from a port.
875 #define MLXSW_REG_SPVM_ID 0x200F
876 #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
877 #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
878 #define MLXSW_REG_SPVM_REC_MAX_COUNT 255
879 #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
880 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
882 MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
885 * Priority tagged. If this bit is set, packets forwarded to the port with
886 * untagged VLAN membership (u bit is set) will be tagged with priority tag
890 MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
893 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
894 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
897 MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
899 /* reg_spvm_local_port
903 MLXSW_ITEM32_LP(reg, spvm, 0x00, 16, 0x00, 12);
906 * Virtual port within the physical port.
907 * Should be set to 0 when virtual ports are not enabled on the port.
910 MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
913 * Number of records to update. Each record contains: i, e, u, vid.
916 MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
919 * Ingress membership in VLAN ID.
922 MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
923 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
924 MLXSW_REG_SPVM_REC_LEN, 0, false);
927 * Egress membership in VLAN ID.
930 MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
931 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
932 MLXSW_REG_SPVM_REC_LEN, 0, false);
935 * Untagged - port is an untagged member - egress transmission uses untagged
939 MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
940 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
941 MLXSW_REG_SPVM_REC_LEN, 0, false);
944 * Egress membership in VLAN ID.
947 MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
948 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
949 MLXSW_REG_SPVM_REC_LEN, 0, false);
951 static inline void mlxsw_reg_spvm_pack(char *payload, u16 local_port,
952 u16 vid_begin, u16 vid_end,
953 bool is_member, bool untagged)
955 int size = vid_end - vid_begin + 1;
958 MLXSW_REG_ZERO(spvm, payload);
959 mlxsw_reg_spvm_local_port_set(payload, local_port);
960 mlxsw_reg_spvm_num_rec_set(payload, size);
962 for (i = 0; i < size; i++) {
963 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
964 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
965 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
966 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
970 /* SPAFT - Switch Port Acceptable Frame Types
971 * ------------------------------------------
972 * The Switch Port Acceptable Frame Types register configures the frame
973 * admittance of the port.
975 #define MLXSW_REG_SPAFT_ID 0x2010
976 #define MLXSW_REG_SPAFT_LEN 0x08
978 MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
980 /* reg_spaft_local_port
984 * Note: CPU port is not supported (all tag types are allowed).
986 MLXSW_ITEM32_LP(reg, spaft, 0x00, 16, 0x00, 12);
988 /* reg_spaft_sub_port
989 * Virtual port within the physical port.
990 * Should be set to 0 when virtual ports are not enabled on the port.
993 MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
995 /* reg_spaft_allow_untagged
996 * When set, untagged frames on the ingress are allowed (default).
999 MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
1001 /* reg_spaft_allow_prio_tagged
1002 * When set, priority tagged frames on the ingress are allowed (default).
1005 MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
1007 /* reg_spaft_allow_tagged
1008 * When set, tagged frames on the ingress are allowed (default).
1011 MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
1013 static inline void mlxsw_reg_spaft_pack(char *payload, u16 local_port,
1014 bool allow_untagged)
1016 MLXSW_REG_ZERO(spaft, payload);
1017 mlxsw_reg_spaft_local_port_set(payload, local_port);
1018 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
1019 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
1020 mlxsw_reg_spaft_allow_tagged_set(payload, true);
1023 /* SFGC - Switch Flooding Group Configuration
1024 * ------------------------------------------
1025 * The following register controls the association of flooding tables and MIDs
1026 * to packet types used for flooding.
1028 * Reserved when CONFIG_PROFILE.flood_mode = CFF.
1030 #define MLXSW_REG_SFGC_ID 0x2011
1031 #define MLXSW_REG_SFGC_LEN 0x14
1033 MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
1035 enum mlxsw_reg_sfgc_type {
1036 MLXSW_REG_SFGC_TYPE_BROADCAST,
1037 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
1038 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
1039 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
1040 MLXSW_REG_SFGC_TYPE_RESERVED,
1041 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
1042 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
1043 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
1044 MLXSW_REG_SFGC_TYPE_MAX,
1048 * The traffic type to reach the flooding table.
1051 MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
1053 /* bridge_type is used in SFGC and SFMR. */
1054 enum mlxsw_reg_bridge_type {
1055 MLXSW_REG_BRIDGE_TYPE_0 = 0, /* Used for .1q FIDs. */
1056 MLXSW_REG_BRIDGE_TYPE_1 = 1, /* Used for .1d FIDs. */
1059 /* reg_sfgc_bridge_type
1062 * Note: SwitchX-2 only supports 802.1Q mode.
1064 MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
1066 enum mlxsw_flood_table_type {
1067 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
1068 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
1069 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
1070 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
1071 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
1074 /* reg_sfgc_table_type
1075 * See mlxsw_flood_table_type
1078 * Note: FID offset and FID types are not supported in SwitchX-2.
1080 MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
1082 /* reg_sfgc_flood_table
1083 * Flooding table index to associate with the specific type on the specific
1087 MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
1089 /* reg_sfgc_counter_set_type
1090 * Counter Set Type for flow counters.
1093 MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
1095 /* reg_sfgc_counter_index
1096 * Counter Index for flow counters.
1099 MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
1101 /* reg_sfgc_mid_base
1105 * Note: Reserved when legacy bridge model is used.
1107 MLXSW_ITEM32(reg, sfgc, mid_base, 0x10, 0, 16);
1110 mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1111 enum mlxsw_reg_bridge_type bridge_type,
1112 enum mlxsw_flood_table_type table_type,
1113 unsigned int flood_table, u16 mid_base)
1115 MLXSW_REG_ZERO(sfgc, payload);
1116 mlxsw_reg_sfgc_type_set(payload, type);
1117 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1118 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1119 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1120 mlxsw_reg_sfgc_mid_base_set(payload, mid_base);
1123 /* SFDF - Switch Filtering DB Flush
1124 * --------------------------------
1125 * The switch filtering DB flush register is used to flush the FDB.
1126 * Note that FDB notifications are flushed as well.
1128 #define MLXSW_REG_SFDF_ID 0x2013
1129 #define MLXSW_REG_SFDF_LEN 0x14
1131 MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
1134 * Switch partition ID.
1137 MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1139 enum mlxsw_reg_sfdf_flush_type {
1140 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1141 MLXSW_REG_SFDF_FLUSH_PER_FID,
1142 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1143 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1144 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1145 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1146 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1147 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
1150 /* reg_sfdf_flush_type
1152 * 0 - All SWID dynamic entries are flushed.
1153 * 1 - All FID dynamic entries are flushed.
1154 * 2 - All dynamic entries pointing to port are flushed.
1155 * 3 - All FID dynamic entries pointing to port are flushed.
1156 * 4 - All dynamic entries pointing to LAG are flushed.
1157 * 5 - All FID dynamic entries pointing to LAG are flushed.
1158 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1160 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1164 MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1166 /* reg_sfdf_flush_static
1168 * 0 - Flush only dynamic entries.
1169 * 1 - Flush both dynamic and static entries.
1172 MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1174 static inline void mlxsw_reg_sfdf_pack(char *payload,
1175 enum mlxsw_reg_sfdf_flush_type type)
1177 MLXSW_REG_ZERO(sfdf, payload);
1178 mlxsw_reg_sfdf_flush_type_set(payload, type);
1179 mlxsw_reg_sfdf_flush_static_set(payload, true);
1186 MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1188 /* reg_sfdf_system_port
1192 MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1194 /* reg_sfdf_port_fid_system_port
1195 * Port to flush, pointed to by FID.
1198 MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1204 MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1206 /* reg_sfdf_lag_fid_lag_id
1207 * LAG ID to flush, pointed to by FID.
1210 MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1212 /* SLDR - Switch LAG Descriptor Register
1213 * -----------------------------------------
1214 * The switch LAG descriptor register is populated by LAG descriptors.
1215 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1218 #define MLXSW_REG_SLDR_ID 0x2014
1219 #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1221 MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
1223 enum mlxsw_reg_sldr_op {
1224 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1225 MLXSW_REG_SLDR_OP_LAG_CREATE,
1226 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1227 /* Ports that appear in the list have the Distributor enabled */
1228 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1229 /* Removes ports from the disributor list */
1230 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1237 MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1240 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1243 MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1245 static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1247 MLXSW_REG_ZERO(sldr, payload);
1248 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1249 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1252 static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1254 MLXSW_REG_ZERO(sldr, payload);
1255 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1256 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1259 /* reg_sldr_num_ports
1260 * The number of member ports of the LAG.
1261 * Reserved for Create / Destroy operations
1262 * For Add / Remove operations - indicates the number of ports in the list.
1265 MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1267 /* reg_sldr_system_port
1271 MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1273 static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1276 MLXSW_REG_ZERO(sldr, payload);
1277 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1278 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1279 mlxsw_reg_sldr_num_ports_set(payload, 1);
1280 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1283 static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1286 MLXSW_REG_ZERO(sldr, payload);
1287 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1288 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1289 mlxsw_reg_sldr_num_ports_set(payload, 1);
1290 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1293 /* SLCR - Switch LAG Configuration 2 Register
1294 * -------------------------------------------
1295 * The Switch LAG Configuration register is used for configuring the
1296 * LAG properties of the switch.
1298 #define MLXSW_REG_SLCR_ID 0x2015
1299 #define MLXSW_REG_SLCR_LEN 0x10
1301 MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
1303 enum mlxsw_reg_slcr_pp {
1304 /* Global Configuration (for all ports) */
1305 MLXSW_REG_SLCR_PP_GLOBAL,
1306 /* Per port configuration, based on local_port field */
1307 MLXSW_REG_SLCR_PP_PER_PORT,
1311 * Per Port Configuration
1312 * Note: Reading at Global mode results in reading port 1 configuration.
1315 MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1317 /* reg_slcr_local_port
1319 * Supported from CPU port
1320 * Not supported from router port
1321 * Reserved when pp = Global Configuration
1324 MLXSW_ITEM32_LP(reg, slcr, 0x00, 16, 0x00, 12);
1326 enum mlxsw_reg_slcr_type {
1327 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1328 MLXSW_REG_SLCR_TYPE_XOR,
1329 MLXSW_REG_SLCR_TYPE_RANDOM,
1336 MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1339 #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1340 /* SMAC - for IPv4 and IPv6 packets */
1341 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1342 /* SMAC - for non-IP packets */
1343 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1344 #define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1345 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1346 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1347 /* DMAC - for IPv4 and IPv6 packets */
1348 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1349 /* DMAC - for non-IP packets */
1350 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1351 #define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1352 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1353 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1354 /* Ethertype - for IPv4 and IPv6 packets */
1355 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1356 /* Ethertype - for non-IP packets */
1357 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1358 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1359 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1360 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1361 /* VLAN ID - for IPv4 and IPv6 packets */
1362 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1363 /* VLAN ID - for non-IP packets */
1364 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1365 #define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1366 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1367 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1368 /* Source IP address (can be IPv4 or IPv6) */
1369 #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1370 /* Destination IP address (can be IPv4 or IPv6) */
1371 #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1372 /* TCP/UDP source port */
1373 #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1374 /* TCP/UDP destination port*/
1375 #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1376 /* IPv4 Protocol/IPv6 Next Header */
1377 #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1378 /* IPv6 Flow label */
1379 #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1380 /* SID - FCoE source ID */
1381 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1382 /* DID - FCoE destination ID */
1383 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1384 /* OXID - FCoE originator exchange ID */
1385 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1386 /* Destination QP number - for RoCE packets */
1387 #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1389 /* reg_slcr_lag_hash
1390 * LAG hashing configuration. This is a bitmask, in which each set
1391 * bit includes the corresponding item in the LAG hash calculation.
1392 * The default lag_hash contains SMAC, DMAC, VLANID and
1393 * Ethertype (for all packet types).
1396 MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1399 * LAG seed value. The seed is the same for all ports.
1402 MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1404 static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
1406 MLXSW_REG_ZERO(slcr, payload);
1407 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
1408 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
1409 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1410 mlxsw_reg_slcr_seed_set(payload, seed);
1413 /* SLCOR - Switch LAG Collector Register
1414 * -------------------------------------
1415 * The Switch LAG Collector register controls the Local Port membership
1416 * in a LAG and enablement of the collector.
1418 #define MLXSW_REG_SLCOR_ID 0x2016
1419 #define MLXSW_REG_SLCOR_LEN 0x10
1421 MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
1423 enum mlxsw_reg_slcor_col {
1424 /* Port is added with collector disabled */
1425 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1426 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1427 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1428 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1432 * Collector configuration
1435 MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1437 /* reg_slcor_local_port
1439 * Not supported for CPU port
1442 MLXSW_ITEM32_LP(reg, slcor, 0x00, 16, 0x00, 12);
1445 * LAG Identifier. Index into the LAG descriptor table.
1448 MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1450 /* reg_slcor_port_index
1451 * Port index in the LAG list. Only valid on Add Port to LAG col.
1452 * Valid range is from 0 to cap_max_lag_members-1
1455 MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1457 static inline void mlxsw_reg_slcor_pack(char *payload,
1458 u16 local_port, u16 lag_id,
1459 enum mlxsw_reg_slcor_col col)
1461 MLXSW_REG_ZERO(slcor, payload);
1462 mlxsw_reg_slcor_col_set(payload, col);
1463 mlxsw_reg_slcor_local_port_set(payload, local_port);
1464 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1467 static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1468 u16 local_port, u16 lag_id,
1471 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1472 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1473 mlxsw_reg_slcor_port_index_set(payload, port_index);
1476 static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1477 u16 local_port, u16 lag_id)
1479 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1480 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1483 static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1484 u16 local_port, u16 lag_id)
1486 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1487 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1490 static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1491 u16 local_port, u16 lag_id)
1493 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1494 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1497 /* SPMLR - Switch Port MAC Learning Register
1498 * -----------------------------------------
1499 * Controls the Switch MAC learning policy per port.
1501 #define MLXSW_REG_SPMLR_ID 0x2018
1502 #define MLXSW_REG_SPMLR_LEN 0x8
1504 MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
1506 /* reg_spmlr_local_port
1507 * Local port number.
1510 MLXSW_ITEM32_LP(reg, spmlr, 0x00, 16, 0x00, 12);
1512 /* reg_spmlr_sub_port
1513 * Virtual port within the physical port.
1514 * Should be set to 0 when virtual ports are not enabled on the port.
1517 MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1519 enum mlxsw_reg_spmlr_learn_mode {
1520 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1521 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1522 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1525 /* reg_spmlr_learn_mode
1526 * Learning mode on the port.
1527 * 0 - Learning disabled.
1528 * 2 - Learning enabled.
1529 * 3 - Security mode.
1531 * In security mode the switch does not learn MACs on the port, but uses the
1532 * SMAC to see if it exists on another ingress port. If so, the packet is
1533 * classified as a bad packet and is discarded unless the software registers
1534 * to receive port security error packets usign HPKT.
1536 MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1538 static inline void mlxsw_reg_spmlr_pack(char *payload, u16 local_port,
1539 enum mlxsw_reg_spmlr_learn_mode mode)
1541 MLXSW_REG_ZERO(spmlr, payload);
1542 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1543 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1544 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1547 /* SVFA - Switch VID to FID Allocation Register
1548 * --------------------------------------------
1549 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1550 * virtualized ports.
1552 #define MLXSW_REG_SVFA_ID 0x201C
1553 #define MLXSW_REG_SVFA_LEN 0x18
1555 MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
1558 * Switch partition ID.
1561 MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1563 /* reg_svfa_local_port
1564 * Local port number.
1567 * Note: Reserved for 802.1Q FIDs.
1569 MLXSW_ITEM32_LP(reg, svfa, 0x00, 16, 0x00, 12);
1571 enum mlxsw_reg_svfa_mt {
1572 MLXSW_REG_SVFA_MT_VID_TO_FID,
1573 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1574 MLXSW_REG_SVFA_MT_VNI_TO_FID,
1577 /* reg_svfa_mapping_table
1580 * 1 - {Port, VID} to FID
1583 * Note: Reserved for SwitchX-2.
1585 MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1592 * Note: Reserved for SwitchX-2.
1594 MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1600 MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1606 MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1608 /* reg_svfa_counter_set_type
1609 * Counter set type for flow counters.
1612 * Note: Reserved for SwitchX-2.
1614 MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1616 /* reg_svfa_counter_index
1617 * Counter index for flow counters.
1620 * Note: Reserved for SwitchX-2.
1622 MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1625 * Virtual Network Identifier.
1628 * Note: Reserved when mapping_table is not 2 (VNI mapping table).
1630 MLXSW_ITEM32(reg, svfa, vni, 0x10, 0, 24);
1633 * Ingress RIF valid.
1634 * 0 - Ingress RIF is not valid, no ingress RIF assigned.
1635 * 1 - Ingress RIF valid.
1636 * Must not be set for a non enabled RIF.
1639 * Note: Reserved when legacy bridge model is used.
1641 MLXSW_ITEM32(reg, svfa, irif_v, 0x14, 24, 1);
1644 * Ingress RIF (Router Interface).
1645 * Range is 0..cap_max_router_interfaces-1.
1648 * Note: Reserved when legacy bridge model is used and when irif_v=0.
1650 MLXSW_ITEM32(reg, svfa, irif, 0x14, 0, 16);
1652 static inline void __mlxsw_reg_svfa_pack(char *payload,
1653 enum mlxsw_reg_svfa_mt mt, bool valid,
1654 u16 fid, bool irif_v, u16 irif)
1656 MLXSW_REG_ZERO(svfa, payload);
1657 mlxsw_reg_svfa_swid_set(payload, 0);
1658 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1659 mlxsw_reg_svfa_v_set(payload, valid);
1660 mlxsw_reg_svfa_fid_set(payload, fid);
1661 mlxsw_reg_svfa_irif_v_set(payload, irif_v);
1662 mlxsw_reg_svfa_irif_set(payload, irif_v ? irif : 0);
1665 static inline void mlxsw_reg_svfa_port_vid_pack(char *payload, u16 local_port,
1666 bool valid, u16 fid, u16 vid,
1667 bool irif_v, u16 irif)
1669 enum mlxsw_reg_svfa_mt mt = MLXSW_REG_SVFA_MT_PORT_VID_TO_FID;
1671 __mlxsw_reg_svfa_pack(payload, mt, valid, fid, irif_v, irif);
1672 mlxsw_reg_svfa_local_port_set(payload, local_port);
1673 mlxsw_reg_svfa_vid_set(payload, vid);
1676 static inline void mlxsw_reg_svfa_vid_pack(char *payload, bool valid, u16 fid,
1677 u16 vid, bool irif_v, u16 irif)
1679 enum mlxsw_reg_svfa_mt mt = MLXSW_REG_SVFA_MT_VID_TO_FID;
1681 __mlxsw_reg_svfa_pack(payload, mt, valid, fid, irif_v, irif);
1682 mlxsw_reg_svfa_vid_set(payload, vid);
1685 static inline void mlxsw_reg_svfa_vni_pack(char *payload, bool valid, u16 fid,
1686 u32 vni, bool irif_v, u16 irif)
1688 enum mlxsw_reg_svfa_mt mt = MLXSW_REG_SVFA_MT_VNI_TO_FID;
1690 __mlxsw_reg_svfa_pack(payload, mt, valid, fid, irif_v, irif);
1691 mlxsw_reg_svfa_vni_set(payload, vni);
1694 /* SPVTR - Switch Port VLAN Stacking Register
1695 * ------------------------------------------
1696 * The Switch Port VLAN Stacking register configures the VLAN mode of the port
1697 * to enable VLAN stacking.
1699 #define MLXSW_REG_SPVTR_ID 0x201D
1700 #define MLXSW_REG_SPVTR_LEN 0x10
1702 MLXSW_REG_DEFINE(spvtr, MLXSW_REG_SPVTR_ID, MLXSW_REG_SPVTR_LEN);
1705 * Port is tunnel port.
1708 * Note: Reserved when SwitchX/-2 or Spectrum-1.
1710 MLXSW_ITEM32(reg, spvtr, tport, 0x00, 24, 1);
1712 /* reg_spvtr_local_port
1713 * When tport = 0: local port number (Not supported from/to CPU).
1714 * When tport = 1: tunnel port.
1717 MLXSW_ITEM32_LP(reg, spvtr, 0x00, 16, 0x00, 12);
1720 * Ingress Port Prio Mode Update Enable.
1721 * When set, the Port Prio Mode is updated with the provided ipprio_mode field.
1722 * Reserved on Get operations.
1725 MLXSW_ITEM32(reg, spvtr, ippe, 0x04, 31, 1);
1728 * Ingress Port VID Mode Update Enable.
1729 * When set, the Ingress Port VID Mode is updated with the provided ipvid_mode
1731 * Reserved on Get operations.
1734 MLXSW_ITEM32(reg, spvtr, ipve, 0x04, 30, 1);
1737 * Egress Port VID Mode Update Enable.
1738 * When set, the Egress Port VID Mode is updated with the provided epvid_mode
1742 MLXSW_ITEM32(reg, spvtr, epve, 0x04, 29, 1);
1744 /* reg_spvtr_ipprio_mode
1745 * Ingress Port Priority Mode.
1746 * This controls the PCP and DEI of the new outer VLAN
1747 * Note: for SwitchX/-2 the DEI is not affected.
1748 * 0: use port default PCP and DEI (configured by QPDPC).
1749 * 1: use C-VLAN PCP and DEI.
1750 * Has no effect when ipvid_mode = 0.
1751 * Reserved when tport = 1.
1754 MLXSW_ITEM32(reg, spvtr, ipprio_mode, 0x04, 20, 4);
1756 enum mlxsw_reg_spvtr_ipvid_mode {
1757 /* IEEE Compliant PVID (default) */
1758 MLXSW_REG_SPVTR_IPVID_MODE_IEEE_COMPLIANT_PVID,
1759 /* Push VLAN (for VLAN stacking, except prio tagged packets) */
1760 MLXSW_REG_SPVTR_IPVID_MODE_PUSH_VLAN_FOR_UNTAGGED_PACKET,
1761 /* Always push VLAN (also for prio tagged packets) */
1762 MLXSW_REG_SPVTR_IPVID_MODE_ALWAYS_PUSH_VLAN,
1765 /* reg_spvtr_ipvid_mode
1766 * Ingress Port VLAN-ID Mode.
1767 * For Spectrum family, this affects the values of SPVM.i
1770 MLXSW_ITEM32(reg, spvtr, ipvid_mode, 0x04, 16, 4);
1772 enum mlxsw_reg_spvtr_epvid_mode {
1773 /* IEEE Compliant VLAN membership */
1774 MLXSW_REG_SPVTR_EPVID_MODE_IEEE_COMPLIANT_VLAN_MEMBERSHIP,
1775 /* Pop VLAN (for VLAN stacking) */
1776 MLXSW_REG_SPVTR_EPVID_MODE_POP_VLAN,
1779 /* reg_spvtr_epvid_mode
1780 * Egress Port VLAN-ID Mode.
1781 * For Spectrum family, this affects the values of SPVM.e,u,pt.
1784 MLXSW_ITEM32(reg, spvtr, epvid_mode, 0x04, 0, 4);
1786 static inline void mlxsw_reg_spvtr_pack(char *payload, bool tport,
1788 enum mlxsw_reg_spvtr_ipvid_mode ipvid_mode)
1790 MLXSW_REG_ZERO(spvtr, payload);
1791 mlxsw_reg_spvtr_tport_set(payload, tport);
1792 mlxsw_reg_spvtr_local_port_set(payload, local_port);
1793 mlxsw_reg_spvtr_ipvid_mode_set(payload, ipvid_mode);
1794 mlxsw_reg_spvtr_ipve_set(payload, true);
1797 /* SVPE - Switch Virtual-Port Enabling Register
1798 * --------------------------------------------
1799 * Enables port virtualization.
1801 #define MLXSW_REG_SVPE_ID 0x201E
1802 #define MLXSW_REG_SVPE_LEN 0x4
1804 MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
1806 /* reg_svpe_local_port
1810 * Note: CPU port is not supported (uses VLAN mode only).
1812 MLXSW_ITEM32_LP(reg, svpe, 0x00, 16, 0x00, 12);
1815 * Virtual port enable.
1816 * 0 - Disable, VLAN mode (VID to FID).
1817 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1820 MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1822 static inline void mlxsw_reg_svpe_pack(char *payload, u16 local_port,
1825 MLXSW_REG_ZERO(svpe, payload);
1826 mlxsw_reg_svpe_local_port_set(payload, local_port);
1827 mlxsw_reg_svpe_vp_en_set(payload, enable);
1830 /* SFMR - Switch FID Management Register
1831 * -------------------------------------
1832 * Creates and configures FIDs.
1834 #define MLXSW_REG_SFMR_ID 0x201F
1835 #define MLXSW_REG_SFMR_LEN 0x30
1837 MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
1839 enum mlxsw_reg_sfmr_op {
1840 MLXSW_REG_SFMR_OP_CREATE_FID,
1841 MLXSW_REG_SFMR_OP_DESTROY_FID,
1846 * 0 - Create or edit FID.
1850 MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1856 MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1858 /* reg_sfmr_flood_rsp
1859 * Router sub-port flooding table.
1860 * 0 - Regular flooding table.
1861 * 1 - Router sub-port flooding table. For this FID the flooding is per
1862 * router-sub-port local_port. Must not be set for a FID which is not a
1863 * router-sub-port and must be set prior to enabling the relevant RIF.
1866 * Note: Reserved when legacy bridge model is used.
1867 * Reserved when CONFIG_PROFILE.flood_mode = CFF.
1869 MLXSW_ITEM32(reg, sfmr, flood_rsp, 0x08, 31, 1);
1871 /* reg_sfmr_flood_bridge_type
1872 * Flood bridge type (see SFGC.bridge_type).
1877 * Note: Reserved when legacy bridge model is used and when flood_rsp=1.
1878 * Reserved when CONFIG_PROFILE.flood_mode = CFF
1880 MLXSW_ITEM32(reg, sfmr, flood_bridge_type, 0x08, 28, 1);
1882 /* reg_sfmr_fid_offset
1884 * Used to point into the flooding table selected by SFGC register if
1885 * the table is of type FID-Offset. Otherwise, this field is reserved.
1888 * Note: Reserved when CONFIG_PROFILE.flood_mode = CFF
1890 MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1893 * Valid Tunnel Flood Pointer.
1894 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1897 * Note: Reserved for 802.1Q FIDs.
1899 MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1901 /* reg_sfmr_nve_tunnel_flood_ptr
1902 * Underlay Flooding and BC Pointer.
1903 * Used as a pointer to the first entry of the group based link lists of
1904 * flooding or BC entries (for NVE tunnels).
1907 MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1911 * If not set, then vni is reserved.
1914 * Note: Reserved for 802.1Q FIDs.
1916 MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1919 * Virtual Network Identifier.
1920 * When legacy bridge model is used, a given VNI can only be assigned to one
1921 * FID. When unified bridge model is used, it configures only the FID->VNI,
1922 * the VNI->FID is done by SVFA.
1925 MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1928 * Ingress RIF valid.
1929 * 0 - Ingress RIF is not valid, no ingress RIF assigned.
1930 * 1 - Ingress RIF valid.
1931 * Must not be set for a non valid RIF.
1934 * Note: Reserved when legacy bridge model is used.
1936 MLXSW_ITEM32(reg, sfmr, irif_v, 0x14, 24, 1);
1939 * Ingress RIF (Router Interface).
1940 * Range is 0..cap_max_router_interfaces-1.
1943 * Note: Reserved when legacy bridge model is used and when irif_v=0.
1945 MLXSW_ITEM32(reg, sfmr, irif, 0x14, 0, 16);
1947 /* reg_sfmr_cff_mid_base
1948 * Pointer to PGT table.
1949 * Range: 0..(cap_max_pgt-1)
1952 * Note: Reserved when SwitchX/-2 and Spectrum-1.
1953 * Supported when CONFIG_PROFILE.flood_mode = CFF.
1955 MLXSW_ITEM32(reg, sfmr, cff_mid_base, 0x20, 0, 16);
1957 /* reg_sfmr_nve_flood_prf_id
1958 * FID flooding profile_id for NVE Encap
1959 * Range 0..(max_cap_nve_flood_prf-1)
1962 * Note: Reserved when SwitchX/-2 and Spectrum-1
1964 MLXSW_ITEM32(reg, sfmr, nve_flood_prf_id, 0x24, 8, 2);
1966 /* reg_sfmr_cff_prf_id
1967 * Compressed Fid Flooding profile_id
1968 * Range 0..(max_cap_nve_flood_prf-1)
1971 * Note: Reserved when SwitchX/-2 and Spectrum-1
1972 * Supported only when CONFIG_PROFLE.flood_mode = CFF.
1974 MLXSW_ITEM32(reg, sfmr, cff_prf_id, 0x24, 0, 2);
1976 /* reg_sfmr_smpe_valid
1980 * Note: Reserved when legacy bridge model is used, when flood_rsp=1 and on
1983 MLXSW_ITEM32(reg, sfmr, smpe_valid, 0x28, 20, 1);
1986 * Switch multicast port to egress VID.
1987 * Range is 0..cap_max_rmpe-1
1990 * Note: Reserved when legacy bridge model is used, when flood_rsp=1 and on
1993 MLXSW_ITEM32(reg, sfmr, smpe, 0x28, 0, 16);
1995 static inline void mlxsw_reg_sfmr_pack(char *payload,
1996 enum mlxsw_reg_sfmr_op op, u16 fid,
1997 bool smpe_valid, u16 smpe)
1999 MLXSW_REG_ZERO(sfmr, payload);
2000 mlxsw_reg_sfmr_op_set(payload, op);
2001 mlxsw_reg_sfmr_fid_set(payload, fid);
2002 mlxsw_reg_sfmr_smpe_valid_set(payload, smpe_valid);
2003 mlxsw_reg_sfmr_smpe_set(payload, smpe);
2006 /* SPVMLR - Switch Port VLAN MAC Learning Register
2007 * -----------------------------------------------
2008 * Controls the switch MAC learning policy per {Port, VID}.
2010 #define MLXSW_REG_SPVMLR_ID 0x2020
2011 #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
2012 #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
2013 #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
2014 #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
2015 MLXSW_REG_SPVMLR_REC_LEN * \
2016 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
2018 MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
2020 /* reg_spvmlr_local_port
2021 * Local ingress port.
2024 * Note: CPU port is not supported.
2026 MLXSW_ITEM32_LP(reg, spvmlr, 0x00, 16, 0x00, 12);
2028 /* reg_spvmlr_num_rec
2029 * Number of records to update.
2032 MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
2034 /* reg_spvmlr_rec_learn_enable
2035 * 0 - Disable learning for {Port, VID}.
2036 * 1 - Enable learning for {Port, VID}.
2039 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
2040 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
2042 /* reg_spvmlr_rec_vid
2043 * VLAN ID to be added/removed from port or for querying.
2046 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
2047 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
2049 static inline void mlxsw_reg_spvmlr_pack(char *payload, u16 local_port,
2050 u16 vid_begin, u16 vid_end,
2053 int num_rec = vid_end - vid_begin + 1;
2056 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
2058 MLXSW_REG_ZERO(spvmlr, payload);
2059 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
2060 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
2062 for (i = 0; i < num_rec; i++) {
2063 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
2064 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
2068 /* SPFSR - Switch Port FDB Security Register
2069 * -----------------------------------------
2070 * Configures the security mode per port.
2072 #define MLXSW_REG_SPFSR_ID 0x2023
2073 #define MLXSW_REG_SPFSR_LEN 0x08
2075 MLXSW_REG_DEFINE(spfsr, MLXSW_REG_SPFSR_ID, MLXSW_REG_SPFSR_LEN);
2077 /* reg_spfsr_local_port
2081 * Note: not supported for CPU port.
2083 MLXSW_ITEM32_LP(reg, spfsr, 0x00, 16, 0x00, 12);
2085 /* reg_spfsr_security
2087 * 0: disabled (default)
2091 MLXSW_ITEM32(reg, spfsr, security, 0x04, 31, 1);
2093 static inline void mlxsw_reg_spfsr_pack(char *payload, u16 local_port,
2096 MLXSW_REG_ZERO(spfsr, payload);
2097 mlxsw_reg_spfsr_local_port_set(payload, local_port);
2098 mlxsw_reg_spfsr_security_set(payload, security);
2101 /* SPVC - Switch Port VLAN Classification Register
2102 * -----------------------------------------------
2103 * Configures the port to identify packets as untagged / single tagged /
2104 * double packets based on the packet EtherTypes.
2105 * Ethertype IDs are configured by SVER.
2107 #define MLXSW_REG_SPVC_ID 0x2026
2108 #define MLXSW_REG_SPVC_LEN 0x0C
2110 MLXSW_REG_DEFINE(spvc, MLXSW_REG_SPVC_ID, MLXSW_REG_SPVC_LEN);
2112 /* reg_spvc_local_port
2116 * Note: applies both to Rx port and Tx port, so if a packet traverses
2117 * through Rx port i and a Tx port j then port i and port j must have the
2118 * same configuration.
2120 MLXSW_ITEM32_LP(reg, spvc, 0x00, 16, 0x00, 12);
2122 /* reg_spvc_inner_et2
2123 * Vlan Tag1 EtherType2 enable.
2124 * Packet is initially classified as double VLAN Tag if in addition to
2125 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
2126 * equal to ether_type2.
2127 * 0: disable (default)
2131 MLXSW_ITEM32(reg, spvc, inner_et2, 0x08, 17, 1);
2134 * Vlan Tag0 EtherType2 enable.
2135 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
2136 * equal to ether_type2.
2137 * 0: disable (default)
2141 MLXSW_ITEM32(reg, spvc, et2, 0x08, 16, 1);
2143 /* reg_spvc_inner_et1
2144 * Vlan Tag1 EtherType1 enable.
2145 * Packet is initially classified as double VLAN Tag if in addition to
2146 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
2147 * equal to ether_type1.
2149 * 1: enable (default)
2152 MLXSW_ITEM32(reg, spvc, inner_et1, 0x08, 9, 1);
2155 * Vlan Tag0 EtherType1 enable.
2156 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
2157 * equal to ether_type1.
2159 * 1: enable (default)
2162 MLXSW_ITEM32(reg, spvc, et1, 0x08, 8, 1);
2165 * Vlan Tag1 EtherType0 enable.
2166 * Packet is initially classified as double VLAN Tag if in addition to
2167 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
2168 * equal to ether_type0.
2170 * 1: enable (default)
2173 MLXSW_ITEM32(reg, spvc, inner_et0, 0x08, 1, 1);
2176 * Vlan Tag0 EtherType0 enable.
2177 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
2178 * equal to ether_type0.
2180 * 1: enable (default)
2183 MLXSW_ITEM32(reg, spvc, et0, 0x08, 0, 1);
2185 static inline void mlxsw_reg_spvc_pack(char *payload, u16 local_port, bool et1,
2188 MLXSW_REG_ZERO(spvc, payload);
2189 mlxsw_reg_spvc_local_port_set(payload, local_port);
2190 /* Enable inner_et1 and inner_et0 to enable identification of double
2193 mlxsw_reg_spvc_inner_et1_set(payload, 1);
2194 mlxsw_reg_spvc_inner_et0_set(payload, 1);
2195 mlxsw_reg_spvc_et1_set(payload, et1);
2196 mlxsw_reg_spvc_et0_set(payload, et0);
2199 /* SFFP - Switch FID Flooding Profiles Register
2200 * --------------------------------------------
2201 * The SFFP register populates the fid flooding profile tables used for the NVE
2202 * flooding and Compressed-FID Flooding (CFF).
2204 * Reserved on Spectrum-1.
2206 #define MLXSW_REG_SFFP_ID 0x2029
2207 #define MLXSW_REG_SFFP_LEN 0x0C
2209 MLXSW_REG_DEFINE(sffp, MLXSW_REG_SFFP_ID, MLXSW_REG_SFFP_LEN);
2211 /* reg_sffp_profile_id
2212 * Profile ID a.k.a. SFMR.nve_flood_prf_id or SFMR.cff_prf_id
2213 * Range 0..max_cap_nve_flood_prf-1
2216 MLXSW_ITEM32(reg, sffp, profile_id, 0x00, 16, 2);
2219 * The traffic type to reach the flooding table.
2223 MLXSW_ITEM32(reg, sffp, type, 0x00, 0, 4);
2225 /* reg_sffp_flood_offset
2226 * Flood offset. Offset to add to SFMR.cff_mid_base to get the final PGT address
2227 * for FID flood; or offset to add to SFMR.nve_tunnel_flood_ptr to get KVD
2228 * pointer for NVE underlay.
2231 MLXSW_ITEM32(reg, sffp, flood_offset, 0x04, 0, 3);
2233 static inline void mlxsw_reg_sffp_pack(char *payload, u8 profile_id,
2234 enum mlxsw_reg_sfgc_type type,
2237 MLXSW_REG_ZERO(sffp, payload);
2238 mlxsw_reg_sffp_profile_id_set(payload, profile_id);
2239 mlxsw_reg_sffp_type_set(payload, type);
2240 mlxsw_reg_sffp_flood_offset_set(payload, flood_offset);
2243 /* SPEVET - Switch Port Egress VLAN EtherType
2244 * ------------------------------------------
2245 * The switch port egress VLAN EtherType configures which EtherType to push at
2246 * egress for packets incoming through a local port for which 'SPVID.egr_et_set'
2249 #define MLXSW_REG_SPEVET_ID 0x202A
2250 #define MLXSW_REG_SPEVET_LEN 0x08
2252 MLXSW_REG_DEFINE(spevet, MLXSW_REG_SPEVET_ID, MLXSW_REG_SPEVET_LEN);
2254 /* reg_spevet_local_port
2255 * Egress Local port number.
2256 * Not supported to CPU port.
2259 MLXSW_ITEM32_LP(reg, spevet, 0x00, 16, 0x00, 12);
2261 /* reg_spevet_et_vlan
2262 * Egress EtherType VLAN to push when SPVID.egr_et_set field set for the packet:
2263 * 0: ether_type0 - (default)
2268 MLXSW_ITEM32(reg, spevet, et_vlan, 0x04, 16, 2);
2270 static inline void mlxsw_reg_spevet_pack(char *payload, u16 local_port,
2273 MLXSW_REG_ZERO(spevet, payload);
2274 mlxsw_reg_spevet_local_port_set(payload, local_port);
2275 mlxsw_reg_spevet_et_vlan_set(payload, et_vlan);
2278 /* SMPE - Switch Multicast Port to Egress VID
2279 * ------------------------------------------
2280 * The switch multicast port to egress VID maps
2281 * {egress_port, SMPE index} -> {VID}.
2283 #define MLXSW_REG_SMPE_ID 0x202B
2284 #define MLXSW_REG_SMPE_LEN 0x0C
2286 MLXSW_REG_DEFINE(smpe, MLXSW_REG_SMPE_ID, MLXSW_REG_SMPE_LEN);
2288 /* reg_smpe_local_port
2289 * Local port number.
2290 * CPU port is not supported.
2293 MLXSW_ITEM32_LP(reg, smpe, 0x00, 16, 0x00, 12);
2295 /* reg_smpe_smpe_index
2296 * Switch multicast port to egress VID.
2297 * Range is 0..cap_max_rmpe-1.
2300 MLXSW_ITEM32(reg, smpe, smpe_index, 0x04, 0, 16);
2306 MLXSW_ITEM32(reg, smpe, evid, 0x08, 0, 12);
2308 static inline void mlxsw_reg_smpe_pack(char *payload, u16 local_port,
2309 u16 smpe_index, u16 evid)
2311 MLXSW_REG_ZERO(smpe, payload);
2312 mlxsw_reg_smpe_local_port_set(payload, local_port);
2313 mlxsw_reg_smpe_smpe_index_set(payload, smpe_index);
2314 mlxsw_reg_smpe_evid_set(payload, evid);
2317 /* SMID-V2 - Switch Multicast ID Version 2 Register
2318 * ------------------------------------------------
2319 * The MID record maps from a MID (Multicast ID), which is a unique identifier
2320 * of the multicast group within the stacking domain, into a list of local
2321 * ports into which the packet is replicated.
2323 #define MLXSW_REG_SMID2_ID 0x2034
2324 #define MLXSW_REG_SMID2_LEN 0x120
2326 MLXSW_REG_DEFINE(smid2, MLXSW_REG_SMID2_ID, MLXSW_REG_SMID2_LEN);
2329 * Switch partition ID.
2332 MLXSW_ITEM32(reg, smid2, swid, 0x00, 24, 8);
2335 * Multicast identifier - global identifier that represents the multicast group
2336 * across all devices.
2339 MLXSW_ITEM32(reg, smid2, mid, 0x00, 0, 16);
2341 /* reg_smid2_smpe_valid
2343 * When not valid, the egress VID will not be modified by the SMPE table.
2346 * Note: Reserved when legacy bridge model is used and on Spectrum-2.
2348 MLXSW_ITEM32(reg, smid2, smpe_valid, 0x08, 20, 1);
2351 * Switch multicast port to egress VID.
2354 * Note: Reserved when legacy bridge model is used and on Spectrum-2.
2356 MLXSW_ITEM32(reg, smid2, smpe, 0x08, 0, 16);
2359 * Local port memebership (1 bit per port).
2362 MLXSW_ITEM_BIT_ARRAY(reg, smid2, port, 0x20, 0x80, 1);
2364 /* reg_smid2_port_mask
2365 * Local port mask (1 bit per port).
2368 MLXSW_ITEM_BIT_ARRAY(reg, smid2, port_mask, 0xA0, 0x80, 1);
2370 static inline void mlxsw_reg_smid2_pack(char *payload, u16 mid, u16 port,
2371 bool set, bool smpe_valid, u16 smpe)
2373 MLXSW_REG_ZERO(smid2, payload);
2374 mlxsw_reg_smid2_swid_set(payload, 0);
2375 mlxsw_reg_smid2_mid_set(payload, mid);
2376 mlxsw_reg_smid2_port_set(payload, port, set);
2377 mlxsw_reg_smid2_port_mask_set(payload, port, 1);
2378 mlxsw_reg_smid2_smpe_valid_set(payload, smpe_valid);
2379 mlxsw_reg_smid2_smpe_set(payload, smpe_valid ? smpe : 0);
2382 /* CWTP - Congetion WRED ECN TClass Profile
2383 * ----------------------------------------
2384 * Configures the profiles for queues of egress port and traffic class
2386 #define MLXSW_REG_CWTP_ID 0x2802
2387 #define MLXSW_REG_CWTP_BASE_LEN 0x28
2388 #define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
2389 #define MLXSW_REG_CWTP_LEN 0x40
2391 MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
2393 /* reg_cwtp_local_port
2395 * Not supported for CPU port
2398 MLXSW_ITEM32_LP(reg, cwtp, 0x00, 16, 0x00, 12);
2400 /* reg_cwtp_traffic_class
2401 * Traffic Class to configure
2404 MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
2406 /* reg_cwtp_profile_min
2407 * Minimum Average Queue Size of the profile in cells.
2410 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
2411 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
2413 /* reg_cwtp_profile_percent
2414 * Percentage of WRED and ECN marking for maximum Average Queue size
2415 * Range is 0 to 100, units of integer percentage
2418 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
2419 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2421 /* reg_cwtp_profile_max
2422 * Maximum Average Queue size of the profile in cells
2425 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
2426 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2428 #define MLXSW_REG_CWTP_MIN_VALUE 64
2429 #define MLXSW_REG_CWTP_MAX_PROFILE 2
2430 #define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
2432 static inline void mlxsw_reg_cwtp_pack(char *payload, u16 local_port,
2437 MLXSW_REG_ZERO(cwtp, payload);
2438 mlxsw_reg_cwtp_local_port_set(payload, local_port);
2439 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
2441 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
2442 mlxsw_reg_cwtp_profile_min_set(payload, i,
2443 MLXSW_REG_CWTP_MIN_VALUE);
2444 mlxsw_reg_cwtp_profile_max_set(payload, i,
2445 MLXSW_REG_CWTP_MIN_VALUE);
2449 #define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
2452 mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
2455 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
2457 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
2458 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
2459 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
2462 /* CWTPM - Congestion WRED ECN TClass and Pool Mapping
2463 * ---------------------------------------------------
2464 * The CWTPM register maps each egress port and traffic class to profile num.
2466 #define MLXSW_REG_CWTPM_ID 0x2803
2467 #define MLXSW_REG_CWTPM_LEN 0x44
2469 MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
2471 /* reg_cwtpm_local_port
2473 * Not supported for CPU port
2476 MLXSW_ITEM32_LP(reg, cwtpm, 0x00, 16, 0x00, 12);
2478 /* reg_cwtpm_traffic_class
2479 * Traffic Class to configure
2482 MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
2485 * Control enablement of WRED for traffic class:
2490 MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
2493 * Control enablement of ECN for traffic class:
2498 MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
2501 * TCP Green Profile.
2502 * Index of the profile within {port, traffic class} to use.
2503 * 0 for disabling both WRED and ECN for this type of traffic.
2506 MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
2509 * TCP Yellow Profile.
2510 * Index of the profile within {port, traffic class} to use.
2511 * 0 for disabling both WRED and ECN for this type of traffic.
2514 MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
2518 * Index of the profile within {port, traffic class} to use.
2519 * 0 for disabling both WRED and ECN for this type of traffic.
2522 MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
2525 * Non-TCP Green Profile.
2526 * Index of the profile within {port, traffic class} to use.
2527 * 0 for disabling both WRED and ECN for this type of traffic.
2530 MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
2533 * Non-TCP Yellow Profile.
2534 * Index of the profile within {port, traffic class} to use.
2535 * 0 for disabling both WRED and ECN for this type of traffic.
2538 MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
2541 * Non-TCP Red Profile.
2542 * Index of the profile within {port, traffic class} to use.
2543 * 0 for disabling both WRED and ECN for this type of traffic.
2546 MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
2548 #define MLXSW_REG_CWTPM_RESET_PROFILE 0
2550 static inline void mlxsw_reg_cwtpm_pack(char *payload, u16 local_port,
2551 u8 traffic_class, u8 profile,
2552 bool wred, bool ecn)
2554 MLXSW_REG_ZERO(cwtpm, payload);
2555 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
2556 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
2557 mlxsw_reg_cwtpm_ew_set(payload, wred);
2558 mlxsw_reg_cwtpm_ee_set(payload, ecn);
2559 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
2560 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
2561 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
2562 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
2563 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
2564 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
2567 /* PGCR - Policy-Engine General Configuration Register
2568 * ---------------------------------------------------
2569 * This register configures general Policy-Engine settings.
2571 #define MLXSW_REG_PGCR_ID 0x3001
2572 #define MLXSW_REG_PGCR_LEN 0x20
2574 MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
2576 /* reg_pgcr_default_action_pointer_base
2577 * Default action pointer base. Each region has a default action pointer
2578 * which is equal to default_action_pointer_base + region_id.
2581 MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
2583 static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
2585 MLXSW_REG_ZERO(pgcr, payload);
2586 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
2589 /* PPBT - Policy-Engine Port Binding Table
2590 * ---------------------------------------
2591 * This register is used for configuration of the Port Binding Table.
2593 #define MLXSW_REG_PPBT_ID 0x3002
2594 #define MLXSW_REG_PPBT_LEN 0x14
2596 MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
2598 enum mlxsw_reg_pxbt_e {
2599 MLXSW_REG_PXBT_E_IACL,
2600 MLXSW_REG_PXBT_E_EACL,
2606 MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
2608 enum mlxsw_reg_pxbt_op {
2609 MLXSW_REG_PXBT_OP_BIND,
2610 MLXSW_REG_PXBT_OP_UNBIND,
2616 MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
2618 /* reg_ppbt_local_port
2619 * Local port. Not including CPU port.
2622 MLXSW_ITEM32_LP(reg, ppbt, 0x00, 16, 0x00, 12);
2625 * group - When set, the binding is of an ACL group. When cleared,
2626 * the binding is of an ACL.
2627 * Must be set to 1 for Spectrum.
2630 MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2632 /* reg_ppbt_acl_info
2633 * ACL/ACL group identifier. If the g bit is set, this field should hold
2634 * the acl_group_id, else it should hold the acl_id.
2637 MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2639 static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2640 enum mlxsw_reg_pxbt_op op,
2641 u16 local_port, u16 acl_info)
2643 MLXSW_REG_ZERO(ppbt, payload);
2644 mlxsw_reg_ppbt_e_set(payload, e);
2645 mlxsw_reg_ppbt_op_set(payload, op);
2646 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2647 mlxsw_reg_ppbt_g_set(payload, true);
2648 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2651 /* PACL - Policy-Engine ACL Register
2652 * ---------------------------------
2653 * This register is used for configuration of the ACL.
2655 #define MLXSW_REG_PACL_ID 0x3004
2656 #define MLXSW_REG_PACL_LEN 0x70
2658 MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2661 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2662 * while the ACL is bounded to either a port, VLAN or ACL rule.
2665 MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2668 * An identifier representing the ACL (managed by software)
2669 * Range 0 .. cap_max_acl_regions - 1
2672 MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2674 #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2676 /* reg_pacl_tcam_region_info
2677 * Opaque object that represents a TCAM region.
2678 * Obtained through PTAR register.
2681 MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2682 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2684 static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2685 bool valid, const char *tcam_region_info)
2687 MLXSW_REG_ZERO(pacl, payload);
2688 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2689 mlxsw_reg_pacl_v_set(payload, valid);
2690 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2693 /* PAGT - Policy-Engine ACL Group Table
2694 * ------------------------------------
2695 * This register is used for configuration of the ACL Group Table.
2697 #define MLXSW_REG_PAGT_ID 0x3005
2698 #define MLXSW_REG_PAGT_BASE_LEN 0x30
2699 #define MLXSW_REG_PAGT_ACL_LEN 4
2700 #define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2701 #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2702 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2704 MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2707 * Number of ACLs in the group.
2708 * Size 0 invalidates a group.
2709 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2710 * Total number of ACLs in all groups must be lower or equal
2711 * to cap_max_acl_tot_groups
2712 * Note: a group which is binded must not be invalidated
2715 MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2717 /* reg_pagt_acl_group_id
2718 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2719 * the ACL Group identifier (managed by software).
2722 MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2726 * 0 - This ACL is the last ACL in the multi-ACL
2727 * 1 - This ACL is part of a multi-ACL
2730 MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
2736 MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2738 static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2740 MLXSW_REG_ZERO(pagt, payload);
2741 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2744 static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2745 u16 acl_id, bool multi)
2747 u8 size = mlxsw_reg_pagt_size_get(payload);
2750 mlxsw_reg_pagt_size_set(payload, index + 1);
2751 mlxsw_reg_pagt_multi_set(payload, index, multi);
2752 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2755 /* PTAR - Policy-Engine TCAM Allocation Register
2756 * ---------------------------------------------
2757 * This register is used for allocation of regions in the TCAM.
2758 * Note: Query method is not supported on this register.
2760 #define MLXSW_REG_PTAR_ID 0x3006
2761 #define MLXSW_REG_PTAR_BASE_LEN 0x20
2762 #define MLXSW_REG_PTAR_KEY_ID_LEN 1
2763 #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2764 #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2765 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2767 MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2769 enum mlxsw_reg_ptar_op {
2770 /* allocate a TCAM region */
2771 MLXSW_REG_PTAR_OP_ALLOC,
2772 /* resize a TCAM region */
2773 MLXSW_REG_PTAR_OP_RESIZE,
2774 /* deallocate TCAM region */
2775 MLXSW_REG_PTAR_OP_FREE,
2776 /* test allocation */
2777 MLXSW_REG_PTAR_OP_TEST,
2783 MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2785 /* reg_ptar_action_set_type
2786 * Type of action set to be used on this region.
2787 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
2790 MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2792 enum mlxsw_reg_ptar_key_type {
2793 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2794 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2797 /* reg_ptar_key_type
2798 * TCAM key type for the region.
2801 MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2803 /* reg_ptar_region_size
2804 * TCAM region size. When allocating/resizing this is the requested size,
2805 * the response is the actual size. Note that actual size may be
2806 * larger than requested.
2807 * Allowed range 1 .. cap_max_rules-1
2808 * Reserved during op deallocate.
2811 MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2813 /* reg_ptar_region_id
2815 * Range 0 .. cap_max_regions-1
2818 MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2820 /* reg_ptar_tcam_region_info
2821 * Opaque object that represents the TCAM region.
2822 * Returned when allocating a region.
2823 * Provided by software for ACL generation and region deallocation and resize.
2826 MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2827 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2829 /* reg_ptar_flexible_key_id
2830 * Identifier of the Flexible Key.
2831 * Only valid if key_type == "FLEX_KEY"
2832 * The key size will be rounded up to one of the following values:
2833 * 9B, 18B, 36B, 54B.
2834 * This field is reserved for in resize operation.
2837 MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2838 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2840 static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
2841 enum mlxsw_reg_ptar_key_type key_type,
2842 u16 region_size, u16 region_id,
2843 const char *tcam_region_info)
2845 MLXSW_REG_ZERO(ptar, payload);
2846 mlxsw_reg_ptar_op_set(payload, op);
2847 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
2848 mlxsw_reg_ptar_key_type_set(payload, key_type);
2849 mlxsw_reg_ptar_region_size_set(payload, region_size);
2850 mlxsw_reg_ptar_region_id_set(payload, region_id);
2851 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2854 static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2857 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2860 static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2862 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2865 /* PPRR - Policy-Engine Port Range Register
2866 * ----------------------------------------
2867 * This register is used for configuring port range identification.
2869 #define MLXSW_REG_PPRR_ID 0x3008
2870 #define MLXSW_REG_PPRR_LEN 0x14
2872 MLXSW_REG_DEFINE(pprr, MLXSW_REG_PPRR_ID, MLXSW_REG_PPRR_LEN);
2875 * Apply port range register to IPv4 packets.
2878 MLXSW_ITEM32(reg, pprr, ipv4, 0x00, 31, 1);
2881 * Apply port range register to IPv6 packets.
2884 MLXSW_ITEM32(reg, pprr, ipv6, 0x00, 30, 1);
2887 * Apply port range register to source L4 ports.
2890 MLXSW_ITEM32(reg, pprr, src, 0x00, 29, 1);
2893 * Apply port range register to destination L4 ports.
2896 MLXSW_ITEM32(reg, pprr, dst, 0x00, 28, 1);
2899 * Apply port range register to TCP packets.
2902 MLXSW_ITEM32(reg, pprr, tcp, 0x00, 27, 1);
2905 * Apply port range register to UDP packets.
2908 MLXSW_ITEM32(reg, pprr, udp, 0x00, 26, 1);
2910 /* reg_pprr_register_index
2911 * Index of Port Range Register being accessed.
2912 * Range is 0..cap_max_acl_l4_port_range-1.
2915 MLXSW_ITEM32(reg, pprr, register_index, 0x00, 0, 8);
2917 /* reg_prrr_port_range_min
2918 * Minimum port range for comparison.
2919 * Match is defined as:
2920 * port_range_min <= packet_port <= port_range_max.
2923 MLXSW_ITEM32(reg, pprr, port_range_min, 0x04, 16, 16);
2925 /* reg_prrr_port_range_max
2926 * Maximum port range for comparison.
2929 MLXSW_ITEM32(reg, pprr, port_range_max, 0x04, 0, 16);
2931 static inline void mlxsw_reg_pprr_pack(char *payload, u8 register_index)
2933 MLXSW_REG_ZERO(pprr, payload);
2934 mlxsw_reg_pprr_register_index_set(payload, register_index);
2937 /* PPBS - Policy-Engine Policy Based Switching Register
2938 * ----------------------------------------------------
2939 * This register retrieves and sets Policy Based Switching Table entries.
2941 #define MLXSW_REG_PPBS_ID 0x300C
2942 #define MLXSW_REG_PPBS_LEN 0x14
2944 MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2947 * Index into the PBS table.
2948 * For Spectrum, the index points to the KVD Linear.
2951 MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2953 /* reg_ppbs_system_port
2954 * Unique port identifier for the final destination of the packet.
2957 MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2959 static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2962 MLXSW_REG_ZERO(ppbs, payload);
2963 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2964 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2967 /* PRCR - Policy-Engine Rules Copy Register
2968 * ----------------------------------------
2969 * This register is used for accessing rules within a TCAM region.
2971 #define MLXSW_REG_PRCR_ID 0x300D
2972 #define MLXSW_REG_PRCR_LEN 0x40
2974 MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2976 enum mlxsw_reg_prcr_op {
2977 /* Move rules. Moves the rules from "tcam_region_info" starting
2978 * at offset "offset" to "dest_tcam_region_info"
2979 * at offset "dest_offset."
2981 MLXSW_REG_PRCR_OP_MOVE,
2982 /* Copy rules. Copies the rules from "tcam_region_info" starting
2983 * at offset "offset" to "dest_tcam_region_info"
2984 * at offset "dest_offset."
2986 MLXSW_REG_PRCR_OP_COPY,
2992 MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2995 * Offset within the source region to copy/move from.
2998 MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
3001 * The number of rules to copy/move.
3004 MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
3006 /* reg_prcr_tcam_region_info
3007 * Opaque object that represents the source TCAM region.
3010 MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
3011 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3013 /* reg_prcr_dest_offset
3014 * Offset within the source region to copy/move to.
3017 MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
3019 /* reg_prcr_dest_tcam_region_info
3020 * Opaque object that represents the destination TCAM region.
3023 MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
3024 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3026 static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
3027 const char *src_tcam_region_info,
3029 const char *dest_tcam_region_info,
3030 u16 dest_offset, u16 size)
3032 MLXSW_REG_ZERO(prcr, payload);
3033 mlxsw_reg_prcr_op_set(payload, op);
3034 mlxsw_reg_prcr_offset_set(payload, src_offset);
3035 mlxsw_reg_prcr_size_set(payload, size);
3036 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
3037 src_tcam_region_info);
3038 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
3039 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
3040 dest_tcam_region_info);
3043 /* PEFA - Policy-Engine Extended Flexible Action Register
3044 * ------------------------------------------------------
3045 * This register is used for accessing an extended flexible action entry
3046 * in the central KVD Linear Database.
3048 #define MLXSW_REG_PEFA_ID 0x300F
3049 #define MLXSW_REG_PEFA_LEN 0xB0
3051 MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
3054 * Index in the KVD Linear Centralized Database.
3057 MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
3060 * Index in the KVD Linear Centralized Database.
3062 * For a new entry: set if ca=0, clear if ca=1
3063 * Set if a packet lookup has hit on the specific entry
3066 MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
3070 * When write: activity is according to this field
3071 * When read: after reading the activity is cleared according to ca
3074 MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
3076 #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
3078 /* reg_pefa_flex_action_set
3079 * Action-set to perform when rule is matched.
3080 * Must be zero padded if action set is shorter.
3083 MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
3085 static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
3086 const char *flex_action_set)
3088 MLXSW_REG_ZERO(pefa, payload);
3089 mlxsw_reg_pefa_index_set(payload, index);
3090 mlxsw_reg_pefa_ca_set(payload, ca);
3091 if (flex_action_set)
3092 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
3096 static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
3098 *p_a = mlxsw_reg_pefa_a_get(payload);
3101 /* PEMRBT - Policy-Engine Multicast Router Binding Table Register
3102 * --------------------------------------------------------------
3103 * This register is used for binding Multicast router to an ACL group
3104 * that serves the MC router.
3105 * This register is not supported by SwitchX/-2 and Spectrum.
3107 #define MLXSW_REG_PEMRBT_ID 0x3014
3108 #define MLXSW_REG_PEMRBT_LEN 0x14
3110 MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
3112 enum mlxsw_reg_pemrbt_protocol {
3113 MLXSW_REG_PEMRBT_PROTO_IPV4,
3114 MLXSW_REG_PEMRBT_PROTO_IPV6,
3117 /* reg_pemrbt_protocol
3120 MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
3122 /* reg_pemrbt_group_id
3123 * ACL group identifier.
3124 * Range 0..cap_max_acl_groups-1
3127 MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
3130 mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
3133 MLXSW_REG_ZERO(pemrbt, payload);
3134 mlxsw_reg_pemrbt_protocol_set(payload, protocol);
3135 mlxsw_reg_pemrbt_group_id_set(payload, group_id);
3138 /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
3139 * -----------------------------------------------------
3140 * This register is used for accessing rules within a TCAM region.
3141 * It is a new version of PTCE in order to support wider key,
3142 * mask and action within a TCAM region. This register is not supported
3143 * by SwitchX and SwitchX-2.
3145 #define MLXSW_REG_PTCE2_ID 0x3017
3146 #define MLXSW_REG_PTCE2_LEN 0x1D8
3148 MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
3154 MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
3157 * Activity. Set if a packet lookup has hit on the specific entry.
3158 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
3161 MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
3163 enum mlxsw_reg_ptce2_op {
3164 /* Read operation. */
3165 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
3166 /* clear on read operation. Used to read entry
3167 * and clear Activity bit.
3169 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
3170 /* Write operation. Used to write a new entry to the table.
3171 * All R/W fields are relevant for new entry. Activity bit is set
3172 * for new entries - Note write with v = 0 will delete the entry.
3174 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
3175 /* Update action. Only action set will be updated. */
3176 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
3177 /* Clear activity. A bit is cleared for the entry. */
3178 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
3184 MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
3189 MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
3191 /* reg_ptce2_priority
3192 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
3193 * Note: priority does not have to be unique per rule.
3194 * Within a region, higher priority should have lower offset (no limitation
3195 * between regions in a multi-region).
3198 MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
3200 /* reg_ptce2_tcam_region_info
3201 * Opaque object that represents the TCAM region.
3204 MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
3205 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3207 #define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
3209 /* reg_ptce2_flex_key_blocks
3213 MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
3214 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3217 * mask- in the same size as key. A bit that is set directs the TCAM
3218 * to compare the corresponding bit in key. A bit that is clear directs
3219 * the TCAM to ignore the corresponding bit in key.
3222 MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
3223 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3225 /* reg_ptce2_flex_action_set
3229 MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
3230 MLXSW_REG_FLEX_ACTION_SET_LEN);
3232 static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
3233 enum mlxsw_reg_ptce2_op op,
3234 const char *tcam_region_info,
3235 u16 offset, u32 priority)
3237 MLXSW_REG_ZERO(ptce2, payload);
3238 mlxsw_reg_ptce2_v_set(payload, valid);
3239 mlxsw_reg_ptce2_op_set(payload, op);
3240 mlxsw_reg_ptce2_offset_set(payload, offset);
3241 mlxsw_reg_ptce2_priority_set(payload, priority);
3242 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
3245 /* PERPT - Policy-Engine ERP Table Register
3246 * ----------------------------------------
3247 * This register adds and removes eRPs from the eRP table.
3249 #define MLXSW_REG_PERPT_ID 0x3021
3250 #define MLXSW_REG_PERPT_LEN 0x80
3252 MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
3254 /* reg_perpt_erpt_bank
3256 * Range 0 .. cap_max_erp_table_banks - 1
3259 MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
3261 /* reg_perpt_erpt_index
3262 * Index to eRP table within the eRP bank.
3263 * Range is 0 .. cap_max_erp_table_bank_size - 1
3266 MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
3268 enum mlxsw_reg_perpt_key_size {
3269 MLXSW_REG_PERPT_KEY_SIZE_2KB,
3270 MLXSW_REG_PERPT_KEY_SIZE_4KB,
3271 MLXSW_REG_PERPT_KEY_SIZE_8KB,
3272 MLXSW_REG_PERPT_KEY_SIZE_12KB,
3275 /* reg_perpt_key_size
3278 MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
3280 /* reg_perpt_bf_bypass
3281 * 0 - The eRP is used only if bloom filter state is set for the given
3283 * 1 - The eRP is used regardless of bloom filter state.
3284 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
3287 MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
3290 * eRP ID for use by the rules.
3293 MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
3295 /* reg_perpt_erpt_base_bank
3296 * Base eRP table bank, points to head of erp_vector
3297 * Range is 0 .. cap_max_erp_table_banks - 1
3300 MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
3302 /* reg_perpt_erpt_base_index
3303 * Base index to eRP table within the eRP bank
3304 * Range is 0 .. cap_max_erp_table_bank_size - 1
3307 MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
3309 /* reg_perpt_erp_index_in_vector
3310 * eRP index in the vector.
3313 MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
3315 /* reg_perpt_erp_vector
3319 MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
3323 * 0 - A-TCAM will ignore the bit in key
3324 * 1 - A-TCAM will compare the bit in key
3327 MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3329 static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
3330 unsigned long *erp_vector,
3335 for_each_set_bit(bit, erp_vector, size)
3336 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
3340 mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
3341 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
3342 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
3345 MLXSW_REG_ZERO(perpt, payload);
3346 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
3347 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
3348 mlxsw_reg_perpt_key_size_set(payload, key_size);
3349 mlxsw_reg_perpt_bf_bypass_set(payload, false);
3350 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
3351 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
3352 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
3353 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
3354 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
3357 /* PERAR - Policy-Engine Region Association Register
3358 * -------------------------------------------------
3359 * This register associates a hw region for region_id's. Changing on the fly
3360 * is supported by the device.
3362 #define MLXSW_REG_PERAR_ID 0x3026
3363 #define MLXSW_REG_PERAR_LEN 0x08
3365 MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
3367 /* reg_perar_region_id
3369 * Range 0 .. cap_max_regions-1
3372 MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
3374 static inline unsigned int
3375 mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
3377 return DIV_ROUND_UP(block_num, 4);
3380 /* reg_perar_hw_region
3382 * Range 0 .. cap_max_regions-1
3383 * Default: hw_region = region_id
3384 * For a 8 key block region, 2 consecutive regions are used
3385 * For a 12 key block region, 3 consecutive regions are used
3388 MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
3390 static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
3393 MLXSW_REG_ZERO(perar, payload);
3394 mlxsw_reg_perar_region_id_set(payload, region_id);
3395 mlxsw_reg_perar_hw_region_set(payload, hw_region);
3398 /* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
3399 * -----------------------------------------------------
3400 * This register is a new version of PTCE-V2 in order to support the
3401 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
3403 #define MLXSW_REG_PTCE3_ID 0x3027
3404 #define MLXSW_REG_PTCE3_LEN 0xF0
3406 MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
3412 MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
3414 enum mlxsw_reg_ptce3_op {
3415 /* Write operation. Used to write a new entry to the table.
3416 * All R/W fields are relevant for new entry. Activity bit is set
3417 * for new entries. Write with v = 0 will delete the entry. Must
3418 * not be used if an entry exists.
3420 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
3421 /* Update operation */
3422 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
3423 /* Read operation */
3424 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
3430 MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
3432 /* reg_ptce3_priority
3433 * Priority of the rule. Higher values win.
3434 * For Spectrum-2 range is 1..cap_kvd_size - 1
3435 * Note: Priority does not have to be unique per rule.
3438 MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
3440 /* reg_ptce3_tcam_region_info
3441 * Opaque object that represents the TCAM region.
3444 MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
3445 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3447 /* reg_ptce3_flex2_key_blocks
3448 * ACL key. The key must be masked according to eRP (if exists) or
3449 * according to master mask.
3452 MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
3453 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3459 MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
3461 /* reg_ptce3_delta_start
3462 * Start point of delta_value and delta_mask, in bits. Must not exceed
3463 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
3466 MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
3468 /* reg_ptce3_delta_mask
3470 * 0 - Ignore relevant bit in delta_value
3471 * 1 - Compare relevant bit in delta_value
3472 * Delta mask must not be set for reserved fields in the key blocks.
3473 * Note: No delta when no eRPs. Thus, for regions with
3474 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
3477 MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
3479 /* reg_ptce3_delta_value
3481 * Bits which are masked by delta_mask must be 0.
3484 MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
3486 /* reg_ptce3_prune_vector
3487 * Pruning vector relative to the PERPT.erp_id.
3488 * Used for reducing lookups.
3489 * 0 - NEED: Do a lookup using the eRP.
3490 * 1 - PRUNE: Do not perform a lookup using the eRP.
3491 * Maybe be modified by PEAPBL and PEAPBM.
3492 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
3493 * all 1's or all 0's.
3496 MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
3498 /* reg_ptce3_prune_ctcam
3499 * Pruning on C-TCAM. Used for reducing lookups.
3500 * 0 - NEED: Do a lookup in the C-TCAM.
3501 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
3504 MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
3506 /* reg_ptce3_large_exists
3507 * Large entry key ID exists.
3508 * Within the region:
3509 * 0 - SINGLE: The large_entry_key_id is not currently in use.
3510 * For rule insert: The MSB of the key (blocks 6..11) will be added.
3511 * For rule delete: The MSB of the key will be removed.
3512 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
3513 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
3514 * For rule delete: The MSB of the key will not be removed.
3517 MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
3519 /* reg_ptce3_large_entry_key_id
3520 * Large entry key ID.
3521 * A key for 12 key blocks rules. Reserved when region has less than 12 key
3522 * blocks. Must be different for different keys which have the same common
3523 * 6 key blocks (MSB, blocks 6..11) key within a region.
3524 * Range is 0..cap_max_pe_large_key_id - 1
3527 MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
3529 /* reg_ptce3_action_pointer
3530 * Pointer to action.
3531 * Range is 0..cap_max_kvd_action_sets - 1
3534 MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
3536 static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
3537 enum mlxsw_reg_ptce3_op op,
3539 const char *tcam_region_info,
3540 const char *key, u8 erp_id,
3541 u16 delta_start, u8 delta_mask,
3542 u8 delta_value, bool large_exists,
3543 u32 lkey_id, u32 action_pointer)
3545 MLXSW_REG_ZERO(ptce3, payload);
3546 mlxsw_reg_ptce3_v_set(payload, valid);
3547 mlxsw_reg_ptce3_op_set(payload, op);
3548 mlxsw_reg_ptce3_priority_set(payload, priority);
3549 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
3550 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
3551 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
3552 mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
3553 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
3554 mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
3555 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
3556 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
3557 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
3560 /* PERCR - Policy-Engine Region Configuration Register
3561 * ---------------------------------------------------
3562 * This register configures the region parameters. The region_id must be
3565 #define MLXSW_REG_PERCR_ID 0x302A
3566 #define MLXSW_REG_PERCR_LEN 0x80
3568 MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
3570 /* reg_percr_region_id
3571 * Region identifier.
3572 * Range 0..cap_max_regions-1
3575 MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
3577 /* reg_percr_atcam_ignore_prune
3578 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
3581 MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
3583 /* reg_percr_ctcam_ignore_prune
3584 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
3587 MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
3589 /* reg_percr_bf_bypass
3590 * Bloom filter bypass.
3591 * 0 - Bloom filter is used (default)
3592 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
3593 * region_id or eRP. See PERPT.bf_bypass
3596 MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
3598 /* reg_percr_master_mask
3599 * Master mask. Logical OR mask of all masks of all rules of a region
3600 * (both A-TCAM and C-TCAM). When there are no eRPs
3601 * (erpt_pointer_valid = 0), then this provides the mask.
3604 MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
3606 static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
3608 MLXSW_REG_ZERO(percr, payload);
3609 mlxsw_reg_percr_region_id_set(payload, region_id);
3610 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
3611 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
3612 mlxsw_reg_percr_bf_bypass_set(payload, false);
3615 /* PERERP - Policy-Engine Region eRP Register
3616 * ------------------------------------------
3617 * This register configures the region eRP. The region_id must be
3620 #define MLXSW_REG_PERERP_ID 0x302B
3621 #define MLXSW_REG_PERERP_LEN 0x1C
3623 MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
3625 /* reg_pererp_region_id
3626 * Region identifier.
3627 * Range 0..cap_max_regions-1
3630 MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
3632 /* reg_pererp_ctcam_le
3633 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
3636 MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
3638 /* reg_pererp_erpt_pointer_valid
3639 * erpt_pointer is valid.
3642 MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
3644 /* reg_pererp_erpt_bank_pointer
3645 * Pointer to eRP table bank. May be modified at any time.
3646 * Range 0..cap_max_erp_table_banks-1
3647 * Reserved when erpt_pointer_valid = 0
3649 MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
3651 /* reg_pererp_erpt_pointer
3652 * Pointer to eRP table within the eRP bank. Can be changed for an
3654 * Range 0..cap_max_erp_table_size-1
3655 * Reserved when erpt_pointer_valid = 0
3658 MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
3660 /* reg_pererp_erpt_vector
3661 * Vector of allowed eRP indexes starting from erpt_pointer within the
3662 * erpt_bank_pointer. Next entries will be in next bank.
3663 * Note that eRP index is used and not eRP ID.
3664 * Reserved when erpt_pointer_valid = 0
3667 MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
3669 /* reg_pererp_master_rp_id
3670 * Master RP ID. When there are no eRPs, then this provides the eRP ID
3671 * for the lookup. Can be changed for an existing region.
3672 * Reserved when erpt_pointer_valid = 1
3675 MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
3677 static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
3678 unsigned long *erp_vector,
3683 for_each_set_bit(bit, erp_vector, size)
3684 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
3687 static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
3688 bool ctcam_le, bool erpt_pointer_valid,
3689 u8 erpt_bank_pointer, u8 erpt_pointer,
3692 MLXSW_REG_ZERO(pererp, payload);
3693 mlxsw_reg_pererp_region_id_set(payload, region_id);
3694 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
3695 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
3696 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
3697 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
3698 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
3701 /* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
3702 * ----------------------------------------------------------------
3703 * This register configures the Bloom filter entries.
3705 #define MLXSW_REG_PEABFE_ID 0x3022
3706 #define MLXSW_REG_PEABFE_BASE_LEN 0x10
3707 #define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3708 #define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3709 #define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3710 MLXSW_REG_PEABFE_BF_REC_LEN * \
3711 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3713 MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3716 * Number of BF entries to be updated.
3720 MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3722 /* reg_peabfe_bf_entry_state
3723 * Bloom filter state
3728 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3729 MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3730 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3732 /* reg_peabfe_bf_entry_bank
3733 * Bloom filter bank ID
3734 * Range 0..cap_max_erp_table_banks-1
3737 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3738 MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3739 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3741 /* reg_peabfe_bf_entry_index
3742 * Bloom filter entry index
3743 * Range 0..2^cap_max_bf_log-1
3746 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3747 MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3748 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3750 static inline void mlxsw_reg_peabfe_pack(char *payload)
3752 MLXSW_REG_ZERO(peabfe, payload);
3755 static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3756 u8 state, u8 bank, u32 bf_index)
3758 u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3760 if (rec_index >= num_rec)
3761 mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3762 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3763 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3764 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3767 /* IEDR - Infrastructure Entry Delete Register
3768 * ----------------------------------------------------
3769 * This register is used for deleting entries from the entry tables.
3770 * It is legitimate to attempt to delete a nonexisting entry (the device will
3771 * respond as a good flow).
3773 #define MLXSW_REG_IEDR_ID 0x3804
3774 #define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
3775 #define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
3776 #define MLXSW_REG_IEDR_REC_MAX_COUNT 64
3777 #define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
3778 MLXSW_REG_IEDR_REC_LEN * \
3779 MLXSW_REG_IEDR_REC_MAX_COUNT)
3781 MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
3784 * Number of records.
3787 MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
3789 /* reg_iedr_rec_type
3793 MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
3794 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3796 /* reg_iedr_rec_size
3797 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
3800 MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13,
3801 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3803 /* reg_iedr_rec_index_start
3804 * Resource index start.
3807 MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3808 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3810 static inline void mlxsw_reg_iedr_pack(char *payload)
3812 MLXSW_REG_ZERO(iedr, payload);
3815 static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3816 u8 rec_type, u16 rec_size,
3817 u32 rec_index_start)
3819 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3821 if (rec_index >= num_rec)
3822 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3823 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3824 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3825 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3828 /* QPTS - QoS Priority Trust State Register
3829 * ----------------------------------------
3830 * This register controls the port policy to calculate the switch priority and
3831 * packet color based on incoming packet fields.
3833 #define MLXSW_REG_QPTS_ID 0x4002
3834 #define MLXSW_REG_QPTS_LEN 0x8
3836 MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3838 /* reg_qpts_local_port
3839 * Local port number.
3842 * Note: CPU port is supported.
3844 MLXSW_ITEM32_LP(reg, qpts, 0x00, 16, 0x00, 12);
3846 enum mlxsw_reg_qpts_trust_state {
3847 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3848 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3851 /* reg_qpts_trust_state
3852 * Trust state for a given port.
3855 MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3857 static inline void mlxsw_reg_qpts_pack(char *payload, u16 local_port,
3858 enum mlxsw_reg_qpts_trust_state ts)
3860 MLXSW_REG_ZERO(qpts, payload);
3862 mlxsw_reg_qpts_local_port_set(payload, local_port);
3863 mlxsw_reg_qpts_trust_state_set(payload, ts);
3866 /* QPCR - QoS Policer Configuration Register
3867 * -----------------------------------------
3868 * The QPCR register is used to create policers - that limit
3869 * the rate of bytes or packets via some trap group.
3871 #define MLXSW_REG_QPCR_ID 0x4004
3872 #define MLXSW_REG_QPCR_LEN 0x28
3874 MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3876 enum mlxsw_reg_qpcr_g {
3877 MLXSW_REG_QPCR_G_GLOBAL = 2,
3878 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3885 MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3891 MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3893 /* reg_qpcr_clear_counter
3897 MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1);
3899 /* reg_qpcr_color_aware
3900 * Is the policer aware of colors.
3901 * Must be 0 (unaware) for cpu port.
3902 * Access: RW for unbounded policer. RO for bounded policer.
3904 MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3907 * Is policer limit is for bytes per sec or packets per sec.
3910 * Access: RW for unbounded policer. RO for bounded policer.
3912 MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3914 enum mlxsw_reg_qpcr_ir_units {
3915 MLXSW_REG_QPCR_IR_UNITS_M,
3916 MLXSW_REG_QPCR_IR_UNITS_K,
3919 /* reg_qpcr_ir_units
3920 * Policer's units for cir and eir fields (for bytes limits only)
3925 MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3927 enum mlxsw_reg_qpcr_rate_type {
3928 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3929 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3932 /* reg_qpcr_rate_type
3933 * Policer can have one limit (single rate) or 2 limits with specific operation
3934 * for packets that exceed the lower rate but not the upper one.
3935 * (For cpu port must be single rate)
3936 * Access: RW for unbounded policer. RO for bounded policer.
3938 MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3941 * Policer's committed burst size.
3942 * The policer is working with time slices of 50 nano sec. By default every
3943 * slice is granted the proportionate share of the committed rate. If we want to
3944 * allow a slice to exceed that share (while still keeping the rate per sec) we
3945 * can allow burst. The burst size is between the default proportionate share
3946 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3947 * committed rate will result in exceeding the rate). The burst size must be a
3948 * log of 2 and will be determined by 2^cbs.
3951 MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3954 * Policer's committed rate.
3955 * The rate used for sungle rate, the lower rate for double rate.
3956 * For bytes limits, the rate will be this value * the unit from ir_units.
3957 * (Resolution error is up to 1%).
3960 MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3963 * Policer's exceed rate.
3964 * The higher rate for double rate, reserved for single rate.
3965 * Lower rate for double rate policer.
3966 * For bytes limits, the rate will be this value * the unit from ir_units.
3967 * (Resolution error is up to 1%).
3970 MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3972 #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3974 /* reg_qpcr_exceed_action.
3975 * What to do with packets between the 2 limits for double rate.
3976 * Access: RW for unbounded policer. RO for bounded policer.
3978 MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3980 enum mlxsw_reg_qpcr_action {
3982 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3983 /* Forward and set color to red.
3984 * If the packet is intended to cpu port, it will be dropped.
3986 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3989 /* reg_qpcr_violate_action
3990 * What to do with packets that cross the cir limit (for single rate) or the eir
3991 * limit (for double rate).
3992 * Access: RW for unbounded policer. RO for bounded policer.
3994 MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3996 /* reg_qpcr_violate_count
3997 * Counts the number of times violate_action happened on this PID.
4000 MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64);
4003 #define MLXSW_REG_QPCR_LOWEST_CIR 1
4004 #define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000) /* 2Gpps */
4005 #define MLXSW_REG_QPCR_LOWEST_CBS 4
4006 #define MLXSW_REG_QPCR_HIGHEST_CBS 24
4009 #define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024 /* bps */
4010 #define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL /* 2Tbps */
4011 #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4
4012 #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4
4013 #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25
4014 #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31
4016 static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
4017 enum mlxsw_reg_qpcr_ir_units ir_units,
4018 bool bytes, u32 cir, u16 cbs)
4020 MLXSW_REG_ZERO(qpcr, payload);
4021 mlxsw_reg_qpcr_pid_set(payload, pid);
4022 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
4023 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
4024 mlxsw_reg_qpcr_violate_action_set(payload,
4025 MLXSW_REG_QPCR_ACTION_DISCARD);
4026 mlxsw_reg_qpcr_cir_set(payload, cir);
4027 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
4028 mlxsw_reg_qpcr_bytes_set(payload, bytes);
4029 mlxsw_reg_qpcr_cbs_set(payload, cbs);
4032 /* QTCT - QoS Switch Traffic Class Table
4033 * -------------------------------------
4034 * Configures the mapping between the packet switch priority and the
4035 * traffic class on the transmit port.
4037 #define MLXSW_REG_QTCT_ID 0x400A
4038 #define MLXSW_REG_QTCT_LEN 0x08
4040 MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
4042 /* reg_qtct_local_port
4043 * Local port number.
4046 * Note: CPU port is not supported.
4048 MLXSW_ITEM32_LP(reg, qtct, 0x00, 16, 0x00, 12);
4050 /* reg_qtct_sub_port
4051 * Virtual port within the physical port.
4052 * Should be set to 0 when virtual ports are not enabled on the port.
4055 MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
4057 /* reg_qtct_switch_prio
4061 MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
4066 * switch_prio 0 : tclass 1
4067 * switch_prio 1 : tclass 0
4068 * switch_prio i : tclass i, for i > 1
4071 MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
4073 static inline void mlxsw_reg_qtct_pack(char *payload, u16 local_port,
4074 u8 switch_prio, u8 tclass)
4076 MLXSW_REG_ZERO(qtct, payload);
4077 mlxsw_reg_qtct_local_port_set(payload, local_port);
4078 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
4079 mlxsw_reg_qtct_tclass_set(payload, tclass);
4082 /* QEEC - QoS ETS Element Configuration Register
4083 * ---------------------------------------------
4084 * Configures the ETS elements.
4086 #define MLXSW_REG_QEEC_ID 0x400D
4087 #define MLXSW_REG_QEEC_LEN 0x20
4089 MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
4091 /* reg_qeec_local_port
4092 * Local port number.
4095 * Note: CPU port is supported.
4097 MLXSW_ITEM32_LP(reg, qeec, 0x00, 16, 0x00, 12);
4099 enum mlxsw_reg_qeec_hr {
4100 MLXSW_REG_QEEC_HR_PORT,
4101 MLXSW_REG_QEEC_HR_GROUP,
4102 MLXSW_REG_QEEC_HR_SUBGROUP,
4103 MLXSW_REG_QEEC_HR_TC,
4106 /* reg_qeec_element_hierarchy
4113 MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
4115 /* reg_qeec_element_index
4116 * The index of the element in the hierarchy.
4119 MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
4121 /* reg_qeec_next_element_index
4122 * The index of the next (lower) element in the hierarchy.
4125 * Note: Reserved for element_hierarchy 0.
4127 MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
4130 * Min shaper configuration enable. Enables configuration of the min
4131 * shaper on this ETS element
4136 MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
4140 * 0: regular shaper mode
4141 * 1: PTP oriented shaper
4142 * Allowed only for hierarchy 0
4143 * Not supported for CPU port
4144 * Note that ptps mode may affect the shaper rates of all hierarchies
4145 * Supported only on Spectrum-1
4148 MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
4151 MLXSW_REG_QEEC_BYTES_MODE,
4152 MLXSW_REG_QEEC_PACKETS_MODE,
4156 * Packets or bytes mode.
4161 * Note: Used for max shaper configuration. For Spectrum, packets mode
4162 * is supported only for traffic classes of CPU port.
4164 MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
4166 /* The smallest permitted min shaper rate. */
4167 #define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
4169 /* reg_qeec_min_shaper_rate
4170 * Min shaper information rate.
4171 * For CPU port, can only be configured for port hierarchy.
4172 * When in bytes mode, value is specified in units of 1000bps.
4175 MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
4178 * Max shaper configuration enable. Enables configuration of the max
4179 * shaper on this ETS element.
4184 MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
4186 /* The largest max shaper value possible to disable the shaper. */
4187 #define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1) /* Kbps */
4189 /* reg_qeec_max_shaper_rate
4190 * Max shaper information rate.
4191 * For CPU port, can only be configured for port hierarchy.
4192 * When in bytes mode, value is specified in units of 1000bps.
4195 MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31);
4198 * DWRR configuration enable. Enables configuration of the dwrr and
4204 MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
4207 * Transmission selection algorithm to use on the link going down from
4209 * 0 - Strict priority
4213 MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
4215 /* reg_qeec_dwrr_weight
4216 * DWRR weight on the link going down from the ETS element. The
4217 * percentage of bandwidth guaranteed to an ETS element within
4218 * its hierarchy. The sum of all weights across all ETS elements
4219 * within one hierarchy should be equal to 100. Reserved when
4220 * transmission selection algorithm is strict priority.
4223 MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
4225 /* reg_qeec_max_shaper_bs
4226 * Max shaper burst size
4227 * Burst size is 2^max_shaper_bs * 512 bits
4228 * For Spectrum-1: Range is: 5..25
4229 * For Spectrum-2: Range is: 11..25
4230 * Reserved when ptps = 1
4233 MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
4235 #define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25
4236 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
4237 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
4238 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11
4239 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4 11
4241 static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
4242 enum mlxsw_reg_qeec_hr hr, u8 index,
4245 MLXSW_REG_ZERO(qeec, payload);
4246 mlxsw_reg_qeec_local_port_set(payload, local_port);
4247 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
4248 mlxsw_reg_qeec_element_index_set(payload, index);
4249 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
4252 static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u16 local_port,
4255 MLXSW_REG_ZERO(qeec, payload);
4256 mlxsw_reg_qeec_local_port_set(payload, local_port);
4257 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
4258 mlxsw_reg_qeec_ptps_set(payload, ptps);
4261 /* QRWE - QoS ReWrite Enable
4262 * -------------------------
4263 * This register configures the rewrite enable per receive port.
4265 #define MLXSW_REG_QRWE_ID 0x400F
4266 #define MLXSW_REG_QRWE_LEN 0x08
4268 MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
4270 /* reg_qrwe_local_port
4271 * Local port number.
4274 * Note: CPU port is supported. No support for router port.
4276 MLXSW_ITEM32_LP(reg, qrwe, 0x00, 16, 0x00, 12);
4279 * Whether to enable DSCP rewrite (default is 0, don't rewrite).
4282 MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
4285 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
4288 MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
4290 static inline void mlxsw_reg_qrwe_pack(char *payload, u16 local_port,
4291 bool rewrite_pcp, bool rewrite_dscp)
4293 MLXSW_REG_ZERO(qrwe, payload);
4294 mlxsw_reg_qrwe_local_port_set(payload, local_port);
4295 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
4296 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
4299 /* QPDSM - QoS Priority to DSCP Mapping
4300 * ------------------------------------
4301 * QoS Priority to DSCP Mapping Register
4303 #define MLXSW_REG_QPDSM_ID 0x4011
4304 #define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
4305 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
4306 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
4307 #define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
4308 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
4309 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
4311 MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
4313 /* reg_qpdsm_local_port
4314 * Local Port. Supported for data packets from CPU port.
4317 MLXSW_ITEM32_LP(reg, qpdsm, 0x00, 16, 0x00, 12);
4319 /* reg_qpdsm_prio_entry_color0_e
4320 * Enable update of the entry for color 0 and a given port.
4323 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
4324 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
4325 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4327 /* reg_qpdsm_prio_entry_color0_dscp
4328 * DSCP field in the outer label of the packet for color 0 and a given port.
4329 * Reserved when e=0.
4332 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
4333 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
4334 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4336 /* reg_qpdsm_prio_entry_color1_e
4337 * Enable update of the entry for color 1 and a given port.
4340 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
4341 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
4342 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4344 /* reg_qpdsm_prio_entry_color1_dscp
4345 * DSCP field in the outer label of the packet for color 1 and a given port.
4346 * Reserved when e=0.
4349 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
4350 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
4351 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4353 /* reg_qpdsm_prio_entry_color2_e
4354 * Enable update of the entry for color 2 and a given port.
4357 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
4358 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
4359 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4361 /* reg_qpdsm_prio_entry_color2_dscp
4362 * DSCP field in the outer label of the packet for color 2 and a given port.
4363 * Reserved when e=0.
4366 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
4367 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
4368 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4370 static inline void mlxsw_reg_qpdsm_pack(char *payload, u16 local_port)
4372 MLXSW_REG_ZERO(qpdsm, payload);
4373 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
4377 mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
4379 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
4380 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
4381 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
4382 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
4383 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
4384 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
4387 /* QPDP - QoS Port DSCP to Priority Mapping Register
4388 * -------------------------------------------------
4389 * This register controls the port default Switch Priority and Color. The
4390 * default Switch Priority and Color are used for frames where the trust state
4391 * uses default values. All member ports of a LAG should be configured with the
4392 * same default values.
4394 #define MLXSW_REG_QPDP_ID 0x4007
4395 #define MLXSW_REG_QPDP_LEN 0x8
4397 MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
4399 /* reg_qpdp_local_port
4400 * Local Port. Supported for data packets from CPU port.
4403 MLXSW_ITEM32_LP(reg, qpdp, 0x00, 16, 0x00, 12);
4405 /* reg_qpdp_switch_prio
4406 * Default port Switch Priority (default 0)
4409 MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
4411 static inline void mlxsw_reg_qpdp_pack(char *payload, u16 local_port,
4414 MLXSW_REG_ZERO(qpdp, payload);
4415 mlxsw_reg_qpdp_local_port_set(payload, local_port);
4416 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
4419 /* QPDPM - QoS Port DSCP to Priority Mapping Register
4420 * --------------------------------------------------
4421 * This register controls the mapping from DSCP field to
4422 * Switch Priority for IP packets.
4424 #define MLXSW_REG_QPDPM_ID 0x4013
4425 #define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
4426 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
4427 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
4428 #define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
4429 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
4430 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
4432 MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
4434 /* reg_qpdpm_local_port
4435 * Local Port. Supported for data packets from CPU port.
4438 MLXSW_ITEM32_LP(reg, qpdpm, 0x00, 16, 0x00, 12);
4441 * Enable update of the specific entry. When cleared, the switch_prio and color
4442 * fields are ignored and the previous switch_prio and color values are
4446 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
4447 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4449 /* reg_qpdpm_dscp_prio
4450 * The new Switch Priority value for the relevant DSCP value.
4453 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
4454 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
4455 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4457 static inline void mlxsw_reg_qpdpm_pack(char *payload, u16 local_port)
4459 MLXSW_REG_ZERO(qpdpm, payload);
4460 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
4464 mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
4466 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
4467 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
4470 /* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
4471 * ------------------------------------------------------------------
4472 * This register configures if the Switch Priority to Traffic Class mapping is
4473 * based on Multicast packet indication. If so, then multicast packets will get
4474 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
4476 * By default, Switch Priority to Traffic Class mapping is not based on
4477 * Multicast packet indication.
4479 #define MLXSW_REG_QTCTM_ID 0x401A
4480 #define MLXSW_REG_QTCTM_LEN 0x08
4482 MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
4484 /* reg_qtctm_local_port
4485 * Local port number.
4486 * No support for CPU port.
4489 MLXSW_ITEM32_LP(reg, qtctm, 0x00, 16, 0x00, 12);
4493 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
4494 * indication (default is 0, not based on Multicast packet indication).
4496 MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
4499 mlxsw_reg_qtctm_pack(char *payload, u16 local_port, bool mc)
4501 MLXSW_REG_ZERO(qtctm, payload);
4502 mlxsw_reg_qtctm_local_port_set(payload, local_port);
4503 mlxsw_reg_qtctm_mc_set(payload, mc);
4506 /* QPSC - QoS PTP Shaper Configuration Register
4507 * --------------------------------------------
4508 * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1.
4509 * Supported only on Spectrum-1.
4511 #define MLXSW_REG_QPSC_ID 0x401B
4512 #define MLXSW_REG_QPSC_LEN 0x28
4514 MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
4516 enum mlxsw_reg_qpsc_port_speed {
4517 MLXSW_REG_QPSC_PORT_SPEED_100M,
4518 MLXSW_REG_QPSC_PORT_SPEED_1G,
4519 MLXSW_REG_QPSC_PORT_SPEED_10G,
4520 MLXSW_REG_QPSC_PORT_SPEED_25G,
4523 /* reg_qpsc_port_speed
4527 MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
4529 /* reg_qpsc_shaper_time_exp
4530 * The base-time-interval for updating the shapers tokens (for all hierarchies).
4531 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
4532 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
4535 MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
4537 /* reg_qpsc_shaper_time_mantissa
4538 * The base-time-interval for updating the shapers tokens (for all hierarchies).
4539 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
4540 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
4543 MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
4545 /* reg_qpsc_shaper_inc
4546 * Number of tokens added to shaper on each update.
4550 MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
4552 /* reg_qpsc_shaper_bs
4553 * Max shaper Burst size.
4554 * Burst size is 2 ^ max_shaper_bs * 512 [bits]
4555 * Range is: 5..25 (from 2KB..2GB)
4558 MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
4561 * Write enable to port_to_shaper_credits.
4564 MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
4566 /* reg_qpsc_port_to_shaper_credits
4567 * For split ports: range 1..57
4568 * For non-split ports: range 1..112
4569 * Written only when ptsc_we is set.
4572 MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
4574 /* reg_qpsc_ing_timestamp_inc
4575 * Ingress timestamp increment.
4577 * The timestamp of MTPPTR at ingress will be incremented by this value. Global
4578 * value for all ports.
4579 * Same units as used by MTPPTR.
4582 MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
4584 /* reg_qpsc_egr_timestamp_inc
4585 * Egress timestamp increment.
4587 * The timestamp of MTPPTR at egress will be incremented by this value. Global
4588 * value for all ports.
4589 * Same units as used by MTPPTR.
4592 MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
4595 mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
4596 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
4597 u8 shaper_bs, u8 port_to_shaper_credits,
4598 int ing_timestamp_inc, int egr_timestamp_inc)
4600 MLXSW_REG_ZERO(qpsc, payload);
4601 mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
4602 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
4603 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
4604 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
4605 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
4606 mlxsw_reg_qpsc_ptsc_we_set(payload, true);
4607 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
4608 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
4609 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
4612 /* PMLP - Ports Module to Local Port Register
4613 * ------------------------------------------
4614 * Configures the assignment of modules to local ports.
4616 #define MLXSW_REG_PMLP_ID 0x5002
4617 #define MLXSW_REG_PMLP_LEN 0x40
4619 MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
4622 * 0 - Tx value is used for both Tx and Rx.
4623 * 1 - Rx value is taken from a separte field.
4626 MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
4628 /* reg_pmlp_local_port
4629 * Local port number.
4632 MLXSW_ITEM32_LP(reg, pmlp, 0x00, 16, 0x00, 12);
4635 * 0 - Unmap local port.
4636 * 1 - Lane 0 is used.
4637 * 2 - Lanes 0 and 1 are used.
4638 * 4 - Lanes 0, 1, 2 and 3 are used.
4639 * 8 - Lanes 0-7 are used.
4642 MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
4648 MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
4650 /* reg_pmlp_slot_index
4653 * Slot_index = 0 represent the onboard (motherboard).
4654 * In case of non-modular system only slot_index = 0 is available.
4657 MLXSW_ITEM32_INDEXED(reg, pmlp, slot_index, 0x04, 8, 4, 0x04, 0x00, false);
4660 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
4663 MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
4666 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
4670 MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
4672 static inline void mlxsw_reg_pmlp_pack(char *payload, u16 local_port)
4674 MLXSW_REG_ZERO(pmlp, payload);
4675 mlxsw_reg_pmlp_local_port_set(payload, local_port);
4678 /* PMTU - Port MTU Register
4679 * ------------------------
4680 * Configures and reports the port MTU.
4682 #define MLXSW_REG_PMTU_ID 0x5003
4683 #define MLXSW_REG_PMTU_LEN 0x10
4685 MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
4687 /* reg_pmtu_local_port
4688 * Local port number.
4691 MLXSW_ITEM32_LP(reg, pmtu, 0x00, 16, 0x00, 12);
4695 * When port type (e.g. Ethernet) is configured, the relevant MTU is
4696 * reported, otherwise the minimum between the max_mtu of the different
4697 * types is reported.
4700 MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
4702 /* reg_pmtu_admin_mtu
4703 * MTU value to set port to. Must be smaller or equal to max_mtu.
4704 * Note: If port type is Infiniband, then port must be disabled, when its
4708 MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
4710 /* reg_pmtu_oper_mtu
4711 * The actual MTU configured on the port. Packets exceeding this size
4713 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
4714 * oper_mtu might be smaller than admin_mtu.
4717 MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
4719 static inline void mlxsw_reg_pmtu_pack(char *payload, u16 local_port,
4722 MLXSW_REG_ZERO(pmtu, payload);
4723 mlxsw_reg_pmtu_local_port_set(payload, local_port);
4724 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
4725 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
4726 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
4729 /* PTYS - Port Type and Speed Register
4730 * -----------------------------------
4731 * Configures and reports the port speed type.
4733 * Note: When set while the link is up, the changes will not take effect
4734 * until the port transitions from down to up state.
4736 #define MLXSW_REG_PTYS_ID 0x5004
4737 #define MLXSW_REG_PTYS_LEN 0x40
4739 MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
4742 * Auto negotiation disable administrative configuration
4743 * 0 - Device doesn't support AN disable.
4744 * 1 - Device supports AN disable.
4747 MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
4749 /* reg_ptys_local_port
4750 * Local port number.
4753 MLXSW_ITEM32_LP(reg, ptys, 0x00, 16, 0x00, 12);
4755 #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
4756 #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
4758 /* reg_ptys_proto_mask
4759 * Protocol mask. Indicates which protocol is used.
4761 * 1 - Fibre Channel.
4765 MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
4768 MLXSW_REG_PTYS_AN_STATUS_NA,
4769 MLXSW_REG_PTYS_AN_STATUS_OK,
4770 MLXSW_REG_PTYS_AN_STATUS_FAIL,
4773 /* reg_ptys_an_status
4774 * Autonegotiation status.
4777 MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
4779 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
4780 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
4781 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
4782 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
4783 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
4784 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
4785 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
4786 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
4787 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
4788 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
4789 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
4790 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
4791 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_800GAUI_8 BIT(19)
4793 /* reg_ptys_ext_eth_proto_cap
4794 * Extended Ethernet port supported speeds and protocols.
4797 MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
4799 #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
4800 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
4801 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
4802 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
4803 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
4804 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
4805 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
4806 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
4807 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
4808 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
4809 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
4810 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
4811 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
4812 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
4813 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
4814 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
4815 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
4816 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
4817 #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(24)
4818 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_T BIT(25)
4819 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
4820 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
4821 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
4822 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
4823 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
4825 /* reg_ptys_eth_proto_cap
4826 * Ethernet port supported speeds and protocols.
4829 MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
4831 /* reg_ptys_ext_eth_proto_admin
4832 * Extended speed and protocol to set port to.
4835 MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
4837 /* reg_ptys_eth_proto_admin
4838 * Speed and protocol to set port to.
4841 MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
4843 /* reg_ptys_ext_eth_proto_oper
4844 * The extended current speed and protocol configured for the port.
4847 MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
4849 /* reg_ptys_eth_proto_oper
4850 * The current speed and protocol configured for the port.
4853 MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
4855 enum mlxsw_reg_ptys_connector_type {
4856 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
4857 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
4858 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
4859 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
4860 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
4861 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
4862 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
4863 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
4864 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
4867 /* reg_ptys_connector_type
4868 * Connector type indication.
4871 MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
4873 static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port,
4874 u32 proto_admin, bool autoneg)
4876 MLXSW_REG_ZERO(ptys, payload);
4877 mlxsw_reg_ptys_local_port_set(payload, local_port);
4878 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4879 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
4880 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4883 static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u16 local_port,
4884 u32 proto_admin, bool autoneg)
4886 MLXSW_REG_ZERO(ptys, payload);
4887 mlxsw_reg_ptys_local_port_set(payload, local_port);
4888 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4889 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
4890 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4893 static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
4894 u32 *p_eth_proto_cap,
4895 u32 *p_eth_proto_admin,
4896 u32 *p_eth_proto_oper)
4898 if (p_eth_proto_cap)
4900 mlxsw_reg_ptys_eth_proto_cap_get(payload);
4901 if (p_eth_proto_admin)
4902 *p_eth_proto_admin =
4903 mlxsw_reg_ptys_eth_proto_admin_get(payload);
4904 if (p_eth_proto_oper)
4906 mlxsw_reg_ptys_eth_proto_oper_get(payload);
4909 static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
4910 u32 *p_eth_proto_cap,
4911 u32 *p_eth_proto_admin,
4912 u32 *p_eth_proto_oper)
4914 if (p_eth_proto_cap)
4916 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
4917 if (p_eth_proto_admin)
4918 *p_eth_proto_admin =
4919 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
4920 if (p_eth_proto_oper)
4922 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
4925 /* PPAD - Port Physical Address Register
4926 * -------------------------------------
4927 * The PPAD register configures the per port physical MAC address.
4929 #define MLXSW_REG_PPAD_ID 0x5005
4930 #define MLXSW_REG_PPAD_LEN 0x10
4932 MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
4934 /* reg_ppad_single_base_mac
4935 * 0: base_mac, local port should be 0 and mac[7:0] is
4936 * reserved. HW will set incremental
4937 * 1: single_mac - mac of the local_port
4940 MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
4942 /* reg_ppad_local_port
4943 * port number, if single_base_mac = 0 then local_port is reserved
4946 MLXSW_ITEM32_LP(reg, ppad, 0x00, 16, 0x00, 24);
4949 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
4950 * If single_base_mac = 1 - the per port MAC address
4953 MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
4955 static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
4958 MLXSW_REG_ZERO(ppad, payload);
4959 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
4960 mlxsw_reg_ppad_local_port_set(payload, local_port);
4963 /* PAOS - Ports Administrative and Operational Status Register
4964 * -----------------------------------------------------------
4965 * Configures and retrieves per port administrative and operational status.
4967 #define MLXSW_REG_PAOS_ID 0x5006
4968 #define MLXSW_REG_PAOS_LEN 0x10
4970 MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
4973 * Switch partition ID with which to associate the port.
4974 * Note: while external ports uses unique local port numbers (and thus swid is
4975 * redundant), router ports use the same local port number where swid is the
4976 * only indication for the relevant port.
4979 MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
4981 /* reg_paos_local_port
4982 * Local port number.
4985 MLXSW_ITEM32_LP(reg, paos, 0x00, 16, 0x00, 12);
4987 /* reg_paos_admin_status
4988 * Port administrative state (the desired state of the port):
4991 * 3 - Up once. This means that in case of link failure, the port won't go
4992 * into polling mode, but will wait to be re-enabled by software.
4993 * 4 - Disabled by system. Can only be set by hardware.
4996 MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
4998 /* reg_paos_oper_status
4999 * Port operational state (the current state):
5002 * 3 - Down by port failure. This means that the device will not let the
5003 * port up again until explicitly specified by software.
5006 MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
5009 * Admin state update enabled.
5012 MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
5015 * Event update enable. If this bit is set, event generation will be
5016 * updated based on the e field.
5019 MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
5022 * Event generation on operational state change:
5023 * 0 - Do not generate event.
5024 * 1 - Generate Event.
5025 * 2 - Generate Single Event.
5028 MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
5030 static inline void mlxsw_reg_paos_pack(char *payload, u16 local_port,
5031 enum mlxsw_port_admin_status status)
5033 MLXSW_REG_ZERO(paos, payload);
5034 mlxsw_reg_paos_swid_set(payload, 0);
5035 mlxsw_reg_paos_local_port_set(payload, local_port);
5036 mlxsw_reg_paos_admin_status_set(payload, status);
5037 mlxsw_reg_paos_oper_status_set(payload, 0);
5038 mlxsw_reg_paos_ase_set(payload, 1);
5039 mlxsw_reg_paos_ee_set(payload, 1);
5040 mlxsw_reg_paos_e_set(payload, 1);
5043 /* PFCC - Ports Flow Control Configuration Register
5044 * ------------------------------------------------
5045 * Configures and retrieves the per port flow control configuration.
5047 #define MLXSW_REG_PFCC_ID 0x5007
5048 #define MLXSW_REG_PFCC_LEN 0x20
5050 MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
5052 /* reg_pfcc_local_port
5053 * Local port number.
5056 MLXSW_ITEM32_LP(reg, pfcc, 0x00, 16, 0x00, 12);
5059 * Port number access type. Determines the way local_port is interpreted:
5060 * 0 - Local port number.
5061 * 1 - IB / label port number.
5064 MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
5067 * Send to higher layers capabilities:
5068 * 0 - No capability of sending Pause and PFC frames to higher layers.
5069 * 1 - Device has capability of sending Pause and PFC frames to higher
5073 MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
5076 * Send to higher layers operation:
5077 * 0 - Pause and PFC frames are handled by the port (default).
5078 * 1 - Pause and PFC frames are handled by the port and also sent to
5079 * higher layers. Only valid if shl_cap = 1.
5082 MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
5085 * Pause policy auto negotiation.
5086 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
5087 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
5088 * based on the auto-negotiation resolution.
5091 * Note: The auto-negotiation advertisement is set according to pptx and
5092 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
5094 MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
5096 /* reg_pfcc_prio_mask_tx
5097 * Bit per priority indicating if Tx flow control policy should be
5098 * updated based on bit pfctx.
5101 MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
5103 /* reg_pfcc_prio_mask_rx
5104 * Bit per priority indicating if Rx flow control policy should be
5105 * updated based on bit pfcrx.
5108 MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
5111 * Admin Pause policy on Tx.
5112 * 0 - Never generate Pause frames (default).
5113 * 1 - Generate Pause frames according to Rx buffer threshold.
5116 MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
5119 * Active (operational) Pause policy on Tx.
5120 * 0 - Never generate Pause frames.
5121 * 1 - Generate Pause frames according to Rx buffer threshold.
5124 MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
5127 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
5128 * 0 - Never generate priority Pause frames on the specified priority
5130 * 1 - Generate priority Pause frames according to Rx buffer threshold on
5131 * the specified priority.
5134 * Note: pfctx and pptx must be mutually exclusive.
5136 MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
5139 * Admin Pause policy on Rx.
5140 * 0 - Ignore received Pause frames (default).
5141 * 1 - Respect received Pause frames.
5144 MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
5147 * Active (operational) Pause policy on Rx.
5148 * 0 - Ignore received Pause frames.
5149 * 1 - Respect received Pause frames.
5152 MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
5155 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
5156 * 0 - Ignore incoming priority Pause frames on the specified priority
5158 * 1 - Respect incoming priority Pause frames on the specified priority.
5161 MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
5163 #define MLXSW_REG_PFCC_ALL_PRIO 0xFF
5165 static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
5167 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
5168 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
5169 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
5170 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
5173 static inline void mlxsw_reg_pfcc_pack(char *payload, u16 local_port)
5175 MLXSW_REG_ZERO(pfcc, payload);
5176 mlxsw_reg_pfcc_local_port_set(payload, local_port);
5179 /* PPCNT - Ports Performance Counters Register
5180 * -------------------------------------------
5181 * The PPCNT register retrieves per port performance counters.
5183 #define MLXSW_REG_PPCNT_ID 0x5008
5184 #define MLXSW_REG_PPCNT_LEN 0x100
5185 #define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
5187 MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
5190 * For HCA: must be always 0.
5191 * Switch partition ID to associate port with.
5192 * Switch partitions are numbered from 0 to 7 inclusively.
5193 * Switch partition 254 indicates stacking ports.
5194 * Switch partition 255 indicates all switch partitions.
5195 * Only valid on Set() operation with local_port=255.
5198 MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
5200 /* reg_ppcnt_local_port
5201 * Local port number.
5204 MLXSW_ITEM32_LP(reg, ppcnt, 0x00, 16, 0x00, 12);
5207 * Port number access type:
5208 * 0 - Local port number
5209 * 1 - IB port number
5212 MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
5214 enum mlxsw_reg_ppcnt_grp {
5215 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
5216 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
5217 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
5218 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
5219 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
5220 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
5221 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
5222 MLXSW_REG_PPCNT_TC_CNT = 0x11,
5223 MLXSW_REG_PPCNT_TC_CONG_CNT = 0x13,
5227 * Performance counter group.
5228 * Group 63 indicates all groups. Only valid on Set() operation with
5230 * 0x0: IEEE 802.3 Counters
5231 * 0x1: RFC 2863 Counters
5232 * 0x2: RFC 2819 Counters
5233 * 0x3: RFC 3635 Counters
5234 * 0x5: Ethernet Extended Counters
5235 * 0x6: Ethernet Discard Counters
5236 * 0x8: Link Level Retransmission Counters
5237 * 0x10: Per Priority Counters
5238 * 0x11: Per Traffic Class Counters
5239 * 0x12: Physical Layer Counters
5240 * 0x13: Per Traffic Class Congestion Counters
5243 MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
5246 * Clear counters. Setting the clr bit will reset the counter value
5247 * for all counters in the counter group. This bit can be set
5248 * for both Set() and Get() operation.
5251 MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
5254 * Local port global variable.
5255 * 0: local_port 255 = all ports of the device.
5256 * 1: local_port indicates local port number for all ports.
5259 MLXSW_ITEM32(reg, ppcnt, lp_gl, 0x04, 30, 1);
5261 /* reg_ppcnt_prio_tc
5262 * Priority for counter set that support per priority, valid values: 0-7.
5263 * Traffic class for counter set that support per traffic class,
5264 * valid values: 0- cap_max_tclass-1 .
5265 * For HCA: cap_max_tclass is always 8.
5266 * Otherwise must be 0.
5269 MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
5271 /* Ethernet IEEE 802.3 Counter Group */
5273 /* reg_ppcnt_a_frames_transmitted_ok
5276 MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
5277 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5279 /* reg_ppcnt_a_frames_received_ok
5282 MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
5283 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5285 /* reg_ppcnt_a_frame_check_sequence_errors
5288 MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
5289 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5291 /* reg_ppcnt_a_alignment_errors
5294 MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
5295 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5297 /* reg_ppcnt_a_octets_transmitted_ok
5300 MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
5301 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5303 /* reg_ppcnt_a_octets_received_ok
5306 MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
5307 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5309 /* reg_ppcnt_a_multicast_frames_xmitted_ok
5312 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
5313 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5315 /* reg_ppcnt_a_broadcast_frames_xmitted_ok
5318 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
5319 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5321 /* reg_ppcnt_a_multicast_frames_received_ok
5324 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
5325 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5327 /* reg_ppcnt_a_broadcast_frames_received_ok
5330 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
5331 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5333 /* reg_ppcnt_a_in_range_length_errors
5336 MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
5337 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5339 /* reg_ppcnt_a_out_of_range_length_field
5342 MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
5343 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5345 /* reg_ppcnt_a_frame_too_long_errors
5348 MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
5349 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5351 /* reg_ppcnt_a_symbol_error_during_carrier
5354 MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
5355 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5357 /* reg_ppcnt_a_mac_control_frames_transmitted
5360 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
5361 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5363 /* reg_ppcnt_a_mac_control_frames_received
5366 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
5367 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5369 /* reg_ppcnt_a_unsupported_opcodes_received
5372 MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
5373 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5375 /* reg_ppcnt_a_pause_mac_ctrl_frames_received
5378 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
5379 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5381 /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
5384 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
5385 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5387 /* Ethernet RFC 2863 Counter Group */
5389 /* reg_ppcnt_if_in_discards
5392 MLXSW_ITEM64(reg, ppcnt, if_in_discards,
5393 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5395 /* reg_ppcnt_if_out_discards
5398 MLXSW_ITEM64(reg, ppcnt, if_out_discards,
5399 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5401 /* reg_ppcnt_if_out_errors
5404 MLXSW_ITEM64(reg, ppcnt, if_out_errors,
5405 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5407 /* Ethernet RFC 2819 Counter Group */
5409 /* reg_ppcnt_ether_stats_undersize_pkts
5412 MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
5413 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5415 /* reg_ppcnt_ether_stats_oversize_pkts
5418 MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
5419 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5421 /* reg_ppcnt_ether_stats_fragments
5424 MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
5425 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5427 /* reg_ppcnt_ether_stats_pkts64octets
5430 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
5431 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5433 /* reg_ppcnt_ether_stats_pkts65to127octets
5436 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
5437 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5439 /* reg_ppcnt_ether_stats_pkts128to255octets
5442 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
5443 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5445 /* reg_ppcnt_ether_stats_pkts256to511octets
5448 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
5449 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5451 /* reg_ppcnt_ether_stats_pkts512to1023octets
5454 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
5455 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5457 /* reg_ppcnt_ether_stats_pkts1024to1518octets
5460 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
5461 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5463 /* reg_ppcnt_ether_stats_pkts1519to2047octets
5466 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
5467 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5469 /* reg_ppcnt_ether_stats_pkts2048to4095octets
5472 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
5473 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5475 /* reg_ppcnt_ether_stats_pkts4096to8191octets
5478 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
5479 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
5481 /* reg_ppcnt_ether_stats_pkts8192to10239octets
5484 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
5485 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
5487 /* Ethernet RFC 3635 Counter Group */
5489 /* reg_ppcnt_dot3stats_fcs_errors
5492 MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
5493 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5495 /* reg_ppcnt_dot3stats_symbol_errors
5498 MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
5499 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5501 /* reg_ppcnt_dot3control_in_unknown_opcodes
5504 MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
5505 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5507 /* reg_ppcnt_dot3in_pause_frames
5510 MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
5511 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5513 /* Ethernet Extended Counter Group Counters */
5515 /* reg_ppcnt_ecn_marked
5518 MLXSW_ITEM64(reg, ppcnt, ecn_marked,
5519 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5521 /* Ethernet Discard Counter Group Counters */
5523 /* reg_ppcnt_ingress_general
5526 MLXSW_ITEM64(reg, ppcnt, ingress_general,
5527 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5529 /* reg_ppcnt_ingress_policy_engine
5532 MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
5533 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5535 /* reg_ppcnt_ingress_vlan_membership
5538 MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
5539 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5541 /* reg_ppcnt_ingress_tag_frame_type
5544 MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
5545 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5547 /* reg_ppcnt_egress_vlan_membership
5550 MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
5551 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5553 /* reg_ppcnt_loopback_filter
5556 MLXSW_ITEM64(reg, ppcnt, loopback_filter,
5557 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5559 /* reg_ppcnt_egress_general
5562 MLXSW_ITEM64(reg, ppcnt, egress_general,
5563 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5565 /* reg_ppcnt_egress_hoq
5568 MLXSW_ITEM64(reg, ppcnt, egress_hoq,
5569 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5571 /* reg_ppcnt_egress_policy_engine
5574 MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
5575 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5577 /* reg_ppcnt_ingress_tx_link_down
5580 MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
5581 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5583 /* reg_ppcnt_egress_stp_filter
5586 MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
5587 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5589 /* reg_ppcnt_egress_sll
5592 MLXSW_ITEM64(reg, ppcnt, egress_sll,
5593 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5595 /* Ethernet Per Priority Group Counters */
5597 /* reg_ppcnt_rx_octets
5600 MLXSW_ITEM64(reg, ppcnt, rx_octets,
5601 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5603 /* reg_ppcnt_rx_frames
5606 MLXSW_ITEM64(reg, ppcnt, rx_frames,
5607 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5609 /* reg_ppcnt_tx_octets
5612 MLXSW_ITEM64(reg, ppcnt, tx_octets,
5613 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5615 /* reg_ppcnt_tx_frames
5618 MLXSW_ITEM64(reg, ppcnt, tx_frames,
5619 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5621 /* reg_ppcnt_rx_pause
5624 MLXSW_ITEM64(reg, ppcnt, rx_pause,
5625 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5627 /* reg_ppcnt_rx_pause_duration
5630 MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
5631 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5633 /* reg_ppcnt_tx_pause
5636 MLXSW_ITEM64(reg, ppcnt, tx_pause,
5637 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5639 /* reg_ppcnt_tx_pause_duration
5642 MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
5643 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5645 /* reg_ppcnt_rx_pause_transition
5648 MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
5649 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5651 /* Ethernet Per Traffic Class Counters */
5653 /* reg_ppcnt_tc_transmit_queue
5654 * Contains the transmit queue depth in cells of traffic class
5655 * selected by prio_tc and the port selected by local_port.
5656 * The field cannot be cleared.
5659 MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
5660 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5662 /* reg_ppcnt_tc_no_buffer_discard_uc
5663 * The number of unicast packets dropped due to lack of shared
5667 MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
5668 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5670 /* Ethernet Per Traffic Class Congestion Group Counters */
5672 /* reg_ppcnt_wred_discard
5675 MLXSW_ITEM64(reg, ppcnt, wred_discard,
5676 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5678 /* reg_ppcnt_ecn_marked_tc
5681 MLXSW_ITEM64(reg, ppcnt, ecn_marked_tc,
5682 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5684 static inline void mlxsw_reg_ppcnt_pack(char *payload, u16 local_port,
5685 enum mlxsw_reg_ppcnt_grp grp,
5688 MLXSW_REG_ZERO(ppcnt, payload);
5689 mlxsw_reg_ppcnt_swid_set(payload, 0);
5690 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
5691 mlxsw_reg_ppcnt_pnat_set(payload, 0);
5692 mlxsw_reg_ppcnt_grp_set(payload, grp);
5693 mlxsw_reg_ppcnt_clr_set(payload, 0);
5694 mlxsw_reg_ppcnt_lp_gl_set(payload, 1);
5695 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
5698 /* PPTB - Port Prio To Buffer Register
5699 * -----------------------------------
5700 * Configures the switch priority to buffer table.
5702 #define MLXSW_REG_PPTB_ID 0x500B
5703 #define MLXSW_REG_PPTB_LEN 0x10
5705 MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
5708 MLXSW_REG_PPTB_MM_UM,
5709 MLXSW_REG_PPTB_MM_UNICAST,
5710 MLXSW_REG_PPTB_MM_MULTICAST,
5715 * 0 - Map both unicast and multicast packets to the same buffer.
5716 * 1 - Map only unicast packets.
5717 * 2 - Map only multicast packets.
5720 * Note: SwitchX-2 only supports the first option.
5722 MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
5724 /* reg_pptb_local_port
5725 * Local port number.
5728 MLXSW_ITEM32_LP(reg, pptb, 0x00, 16, 0x00, 12);
5731 * Enables the update of the untagged_buf field.
5734 MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
5737 * Enables the update of the prio_to_buff field.
5738 * Bit <i> is a flag for updating the mapping for switch priority <i>.
5741 MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
5743 /* reg_pptb_prio_to_buff
5744 * Mapping of switch priority <i> to one of the allocated receive port
5748 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
5751 * Enables the update of the prio_to_buff field.
5752 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
5755 MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
5757 /* reg_pptb_untagged_buff
5758 * Mapping of untagged frames to one of the allocated receive port buffers.
5761 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
5762 * Spectrum, as it maps untagged packets based on the default switch priority.
5764 MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
5766 /* reg_pptb_prio_to_buff_msb
5767 * Mapping of switch priority <i+8> to one of the allocated receive port
5771 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
5773 #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
5775 static inline void mlxsw_reg_pptb_pack(char *payload, u16 local_port)
5777 MLXSW_REG_ZERO(pptb, payload);
5778 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
5779 mlxsw_reg_pptb_local_port_set(payload, local_port);
5780 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5781 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5784 static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
5787 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
5788 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
5791 /* PBMC - Port Buffer Management Control Register
5792 * ----------------------------------------------
5793 * The PBMC register configures and retrieves the port packet buffer
5794 * allocation for different Prios, and the Pause threshold management.
5796 #define MLXSW_REG_PBMC_ID 0x500C
5797 #define MLXSW_REG_PBMC_LEN 0x6C
5799 MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
5801 /* reg_pbmc_local_port
5802 * Local port number.
5805 MLXSW_ITEM32_LP(reg, pbmc, 0x00, 16, 0x00, 12);
5807 /* reg_pbmc_xoff_timer_value
5808 * When device generates a pause frame, it uses this value as the pause
5809 * timer (time for the peer port to pause in quota-512 bit time).
5812 MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
5814 /* reg_pbmc_xoff_refresh
5815 * The time before a new pause frame should be sent to refresh the pause RW
5816 * state. Using the same units as xoff_timer_value above (in quota-512 bit
5820 MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
5822 #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
5824 /* reg_pbmc_buf_lossy
5825 * The field indicates if the buffer is lossy.
5830 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
5832 /* reg_pbmc_buf_epsb
5833 * Eligible for Port Shared buffer.
5834 * If epsb is set, packets assigned to buffer are allowed to insert the port
5836 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
5839 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
5841 /* reg_pbmc_buf_size
5842 * The part of the packet buffer array is allocated for the specific buffer.
5843 * Units are represented in cells.
5846 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
5848 /* reg_pbmc_buf_xoff_threshold
5849 * Once the amount of data in the buffer goes above this value, device
5850 * starts sending PFC frames for all priorities associated with the
5851 * buffer. Units are represented in cells. Reserved in case of lossy
5855 * Note: In Spectrum, reserved for buffer[9].
5857 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
5860 /* reg_pbmc_buf_xon_threshold
5861 * When the amount of data in the buffer goes below this value, device
5862 * stops sending PFC frames for the priorities associated with the
5863 * buffer. Units are represented in cells. Reserved in case of lossy
5867 * Note: In Spectrum, reserved for buffer[9].
5869 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
5872 static inline void mlxsw_reg_pbmc_pack(char *payload, u16 local_port,
5873 u16 xoff_timer_value, u16 xoff_refresh)
5875 MLXSW_REG_ZERO(pbmc, payload);
5876 mlxsw_reg_pbmc_local_port_set(payload, local_port);
5877 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
5878 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
5881 static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
5885 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
5886 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5887 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5890 static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
5891 int buf_index, u16 size,
5894 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
5895 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5896 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5897 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
5898 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
5901 /* PSPA - Port Switch Partition Allocation
5902 * ---------------------------------------
5903 * Controls the association of a port with a switch partition and enables
5904 * configuring ports as stacking ports.
5906 #define MLXSW_REG_PSPA_ID 0x500D
5907 #define MLXSW_REG_PSPA_LEN 0x8
5909 MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
5912 * Switch partition ID.
5915 MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
5917 /* reg_pspa_local_port
5918 * Local port number.
5921 MLXSW_ITEM32_LP(reg, pspa, 0x00, 16, 0x00, 0);
5923 /* reg_pspa_sub_port
5924 * Virtual port within the local port. Set to 0 when virtual ports are
5925 * disabled on the local port.
5928 MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
5930 static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u16 local_port)
5932 MLXSW_REG_ZERO(pspa, payload);
5933 mlxsw_reg_pspa_swid_set(payload, swid);
5934 mlxsw_reg_pspa_local_port_set(payload, local_port);
5935 mlxsw_reg_pspa_sub_port_set(payload, 0);
5938 /* PMAOS - Ports Module Administrative and Operational Status
5939 * ----------------------------------------------------------
5940 * This register configures and retrieves the per module status.
5942 #define MLXSW_REG_PMAOS_ID 0x5012
5943 #define MLXSW_REG_PMAOS_LEN 0x10
5945 MLXSW_REG_DEFINE(pmaos, MLXSW_REG_PMAOS_ID, MLXSW_REG_PMAOS_LEN);
5948 * Module reset toggle.
5949 * Note: Setting reset while module is plugged-in will result in transition to
5950 * "initializing" operational state.
5953 MLXSW_ITEM32(reg, pmaos, rst, 0x00, 31, 1);
5955 /* reg_pmaos_slot_index
5959 MLXSW_ITEM32(reg, pmaos, slot_index, 0x00, 24, 4);
5965 MLXSW_ITEM32(reg, pmaos, module, 0x00, 16, 8);
5967 enum mlxsw_reg_pmaos_admin_status {
5968 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED = 1,
5969 MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED = 2,
5970 /* If the module is active and then unplugged, or experienced an error
5971 * event, the operational status should go to "disabled" and can only
5972 * be enabled upon explicit enable command.
5974 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED_ONCE = 3,
5977 /* reg_pmaos_admin_status
5978 * Module administrative state (the desired state of the module).
5979 * Note: To disable a module, all ports associated with the port must be
5980 * administatively down first.
5983 MLXSW_ITEM32(reg, pmaos, admin_status, 0x00, 8, 4);
5986 * Admin state update enable.
5987 * If this bit is set, admin state will be updated based on admin_state field.
5988 * Only relevant on Set() operations.
5991 MLXSW_ITEM32(reg, pmaos, ase, 0x04, 31, 1);
5994 * Event update enable.
5995 * If this bit is set, event generation will be updated based on the e field.
5996 * Only relevant on Set operations.
5999 MLXSW_ITEM32(reg, pmaos, ee, 0x04, 30, 1);
6001 enum mlxsw_reg_pmaos_e {
6002 MLXSW_REG_PMAOS_E_DO_NOT_GENERATE_EVENT,
6003 MLXSW_REG_PMAOS_E_GENERATE_EVENT,
6004 MLXSW_REG_PMAOS_E_GENERATE_SINGLE_EVENT,
6008 * Event Generation on operational state change.
6011 MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2);
6013 static inline void mlxsw_reg_pmaos_pack(char *payload, u8 slot_index, u8 module)
6015 MLXSW_REG_ZERO(pmaos, payload);
6016 mlxsw_reg_pmaos_slot_index_set(payload, slot_index);
6017 mlxsw_reg_pmaos_module_set(payload, module);
6020 /* PPLR - Port Physical Loopback Register
6021 * --------------------------------------
6022 * This register allows configuration of the port's loopback mode.
6024 #define MLXSW_REG_PPLR_ID 0x5018
6025 #define MLXSW_REG_PPLR_LEN 0x8
6027 MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
6029 /* reg_pplr_local_port
6030 * Local port number.
6033 MLXSW_ITEM32_LP(reg, pplr, 0x00, 16, 0x00, 12);
6035 /* Phy local loopback. When set the port's egress traffic is looped back
6036 * to the receiver and the port transmitter is disabled.
6038 #define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
6044 MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
6046 static inline void mlxsw_reg_pplr_pack(char *payload, u16 local_port,
6049 MLXSW_REG_ZERO(pplr, payload);
6050 mlxsw_reg_pplr_local_port_set(payload, local_port);
6051 mlxsw_reg_pplr_lb_en_set(payload,
6053 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
6056 /* PMTDB - Port Module To local DataBase Register
6057 * ----------------------------------------------
6058 * The PMTDB register allows to query the possible module<->local port
6059 * mapping than can be used in PMLP. It does not represent the actual/current
6060 * mapping of the local to module. Actual mapping is only defined by PMLP.
6062 #define MLXSW_REG_PMTDB_ID 0x501A
6063 #define MLXSW_REG_PMTDB_LEN 0x40
6065 MLXSW_REG_DEFINE(pmtdb, MLXSW_REG_PMTDB_ID, MLXSW_REG_PMTDB_LEN);
6067 /* reg_pmtdb_slot_index
6068 * Slot index (0: Main board).
6071 MLXSW_ITEM32(reg, pmtdb, slot_index, 0x00, 24, 4);
6077 MLXSW_ITEM32(reg, pmtdb, module, 0x00, 16, 8);
6079 /* reg_pmtdb_ports_width
6083 MLXSW_ITEM32(reg, pmtdb, ports_width, 0x00, 12, 4);
6085 /* reg_pmtdb_num_ports
6086 * Number of ports in a single module (split/breakout)
6089 MLXSW_ITEM32(reg, pmtdb, num_ports, 0x00, 8, 4);
6091 enum mlxsw_reg_pmtdb_status {
6092 MLXSW_REG_PMTDB_STATUS_SUCCESS,
6099 MLXSW_ITEM32(reg, pmtdb, status, 0x00, 0, 4);
6101 /* reg_pmtdb_port_num
6102 * The local_port value which can be assigned to the module.
6103 * In case of more than one port, port<x> represent the /<x> port of
6107 MLXSW_ITEM16_INDEXED(reg, pmtdb, port_num, 0x04, 0, 10, 0x02, 0x00, false);
6109 static inline void mlxsw_reg_pmtdb_pack(char *payload, u8 slot_index, u8 module,
6110 u8 ports_width, u8 num_ports)
6112 MLXSW_REG_ZERO(pmtdb, payload);
6113 mlxsw_reg_pmtdb_slot_index_set(payload, slot_index);
6114 mlxsw_reg_pmtdb_module_set(payload, module);
6115 mlxsw_reg_pmtdb_ports_width_set(payload, ports_width);
6116 mlxsw_reg_pmtdb_num_ports_set(payload, num_ports);
6119 /* PMECR - Ports Mapping Event Configuration Register
6120 * --------------------------------------------------
6121 * The PMECR register is used to enable/disable event triggering
6122 * in case of local port mapping change.
6124 #define MLXSW_REG_PMECR_ID 0x501B
6125 #define MLXSW_REG_PMECR_LEN 0x20
6127 MLXSW_REG_DEFINE(pmecr, MLXSW_REG_PMECR_ID, MLXSW_REG_PMECR_LEN);
6129 /* reg_pmecr_local_port
6130 * Local port number.
6133 MLXSW_ITEM32_LP(reg, pmecr, 0x00, 16, 0x00, 12);
6136 * Event update enable. If this bit is set, event generation will be updated
6137 * based on the e field. Only relevant on Set operations.
6140 MLXSW_ITEM32(reg, pmecr, ee, 0x04, 30, 1);
6143 * Software ignore enable bit. If this bit is set, the value of swi is used.
6144 * If this bit is clear, the value of swi is ignored.
6145 * Only relevant on Set operations.
6148 MLXSW_ITEM32(reg, pmecr, eswi, 0x04, 24, 1);
6151 * Software ignore. If this bit is set, the device shouldn't generate events
6152 * in case of PMLP SET operation but only upon self local port mapping change
6153 * (if applicable according to e configuration). This is supplementary
6154 * configuration on top of e value.
6157 MLXSW_ITEM32(reg, pmecr, swi, 0x04, 8, 1);
6159 enum mlxsw_reg_pmecr_e {
6160 MLXSW_REG_PMECR_E_DO_NOT_GENERATE_EVENT,
6161 MLXSW_REG_PMECR_E_GENERATE_EVENT,
6162 MLXSW_REG_PMECR_E_GENERATE_SINGLE_EVENT,
6166 * Event generation on local port mapping change.
6169 MLXSW_ITEM32(reg, pmecr, e, 0x04, 0, 2);
6171 static inline void mlxsw_reg_pmecr_pack(char *payload, u16 local_port,
6172 enum mlxsw_reg_pmecr_e e)
6174 MLXSW_REG_ZERO(pmecr, payload);
6175 mlxsw_reg_pmecr_local_port_set(payload, local_port);
6176 mlxsw_reg_pmecr_e_set(payload, e);
6177 mlxsw_reg_pmecr_ee_set(payload, true);
6178 mlxsw_reg_pmecr_swi_set(payload, true);
6179 mlxsw_reg_pmecr_eswi_set(payload, true);
6182 /* PMPE - Port Module Plug/Unplug Event Register
6183 * ---------------------------------------------
6184 * This register reports any operational status change of a module.
6185 * A change in the module’s state will generate an event only if the change
6186 * happens after arming the event mechanism. Any changes to the module state
6187 * while the event mechanism is not armed will not be reported. Software can
6188 * query the PMPE register for module status.
6190 #define MLXSW_REG_PMPE_ID 0x5024
6191 #define MLXSW_REG_PMPE_LEN 0x10
6193 MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN);
6195 /* reg_pmpe_slot_index
6199 MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4);
6205 MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8);
6207 enum mlxsw_reg_pmpe_module_status {
6208 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1,
6209 MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED,
6210 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR,
6211 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED,
6214 /* reg_pmpe_module_status
6218 MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4);
6220 /* reg_pmpe_error_type
6221 * Module error details.
6224 MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4);
6226 /* PDDR - Port Diagnostics Database Register
6227 * -----------------------------------------
6228 * The PDDR enables to read the Phy debug database
6230 #define MLXSW_REG_PDDR_ID 0x5031
6231 #define MLXSW_REG_PDDR_LEN 0x100
6233 MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN);
6235 /* reg_pddr_local_port
6236 * Local port number.
6239 MLXSW_ITEM32_LP(reg, pddr, 0x00, 16, 0x00, 12);
6241 enum mlxsw_reg_pddr_page_select {
6242 MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1,
6245 /* reg_pddr_page_select
6246 * Page select index.
6249 MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8);
6251 enum mlxsw_reg_pddr_trblsh_group_opcode {
6252 /* Monitor opcodes */
6253 MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR,
6256 /* reg_pddr_group_opcode
6260 MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
6262 /* reg_pddr_status_opcode
6266 MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
6268 static inline void mlxsw_reg_pddr_pack(char *payload, u16 local_port,
6271 MLXSW_REG_ZERO(pddr, payload);
6272 mlxsw_reg_pddr_local_port_set(payload, local_port);
6273 mlxsw_reg_pddr_page_select_set(payload, page_select);
6276 /* PMMP - Port Module Memory Map Properties Register
6277 * -------------------------------------------------
6278 * The PMMP register allows to override the module memory map advertisement.
6279 * The register can only be set when the module is disabled by PMAOS register.
6281 #define MLXSW_REG_PMMP_ID 0x5044
6282 #define MLXSW_REG_PMMP_LEN 0x2C
6284 MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN);
6290 MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8);
6292 /* reg_pmmp_slot_index
6296 MLXSW_ITEM32(reg, pmmp, slot_index, 0x00, 24, 4);
6299 * When set, will keep eeprom_override values after plug-out event.
6302 MLXSW_ITEM32(reg, pmmp, sticky, 0x00, 0, 1);
6304 /* reg_pmmp_eeprom_override_mask
6305 * Write mask bit (negative polarity).
6308 * On write, indicates which of the bits from eeprom_override field are
6312 MLXSW_ITEM32(reg, pmmp, eeprom_override_mask, 0x04, 16, 16);
6315 /* Set module to low power mode */
6316 MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK = BIT(8),
6319 /* reg_pmmp_eeprom_override
6320 * Override / ignore EEPROM advertisement properties bitmask
6323 MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16);
6325 static inline void mlxsw_reg_pmmp_pack(char *payload, u8 slot_index, u8 module)
6327 MLXSW_REG_ZERO(pmmp, payload);
6328 mlxsw_reg_pmmp_slot_index_set(payload, slot_index);
6329 mlxsw_reg_pmmp_module_set(payload, module);
6332 /* PLLP - Port Local port to Label Port mapping Register
6333 * -----------------------------------------------------
6334 * The PLLP register returns the mapping from Local Port into Label Port.
6336 #define MLXSW_REG_PLLP_ID 0x504A
6337 #define MLXSW_REG_PLLP_LEN 0x10
6339 MLXSW_REG_DEFINE(pllp, MLXSW_REG_PLLP_ID, MLXSW_REG_PLLP_LEN);
6341 /* reg_pllp_local_port
6342 * Local port number.
6345 MLXSW_ITEM32_LP(reg, pllp, 0x00, 16, 0x00, 12);
6347 /* reg_pllp_label_port
6348 * Front panel label of the port.
6351 MLXSW_ITEM32(reg, pllp, label_port, 0x00, 0, 8);
6353 /* reg_pllp_split_num
6354 * Label split mapping for local_port.
6357 MLXSW_ITEM32(reg, pllp, split_num, 0x04, 0, 4);
6359 /* reg_pllp_slot_index
6360 * Slot index (0: Main board).
6363 MLXSW_ITEM32(reg, pllp, slot_index, 0x08, 0, 4);
6365 static inline void mlxsw_reg_pllp_pack(char *payload, u16 local_port)
6367 MLXSW_REG_ZERO(pllp, payload);
6368 mlxsw_reg_pllp_local_port_set(payload, local_port);
6371 static inline void mlxsw_reg_pllp_unpack(char *payload, u8 *label_port,
6372 u8 *split_num, u8 *slot_index)
6374 *label_port = mlxsw_reg_pllp_label_port_get(payload);
6375 *split_num = mlxsw_reg_pllp_split_num_get(payload);
6376 *slot_index = mlxsw_reg_pllp_slot_index_get(payload);
6379 /* PMTM - Port Module Type Mapping Register
6380 * ----------------------------------------
6381 * The PMTM register allows query or configuration of module types.
6382 * The register can only be set when the module is disabled by PMAOS register
6384 #define MLXSW_REG_PMTM_ID 0x5067
6385 #define MLXSW_REG_PMTM_LEN 0x10
6387 MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
6389 /* reg_pmtm_slot_index
6393 MLXSW_ITEM32(reg, pmtm, slot_index, 0x00, 24, 4);
6399 MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
6401 enum mlxsw_reg_pmtm_module_type {
6402 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_4_LANES = 0,
6403 MLXSW_REG_PMTM_MODULE_TYPE_QSFP = 1,
6404 MLXSW_REG_PMTM_MODULE_TYPE_SFP = 2,
6405 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_SINGLE_LANE = 4,
6406 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_2_LANES = 8,
6407 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP4X = 10,
6408 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP2X = 11,
6409 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP1X = 12,
6410 MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD = 14,
6411 MLXSW_REG_PMTM_MODULE_TYPE_OSFP = 15,
6412 MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD = 16,
6413 MLXSW_REG_PMTM_MODULE_TYPE_DSFP = 17,
6414 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP8X = 18,
6415 MLXSW_REG_PMTM_MODULE_TYPE_TWISTED_PAIR = 19,
6418 /* reg_pmtm_module_type
6422 MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 5);
6424 static inline void mlxsw_reg_pmtm_pack(char *payload, u8 slot_index, u8 module)
6426 MLXSW_REG_ZERO(pmtm, payload);
6427 mlxsw_reg_pmtm_slot_index_set(payload, slot_index);
6428 mlxsw_reg_pmtm_module_set(payload, module);
6431 /* HTGT - Host Trap Group Table
6432 * ----------------------------
6433 * Configures the properties for forwarding to CPU.
6435 #define MLXSW_REG_HTGT_ID 0x7002
6436 #define MLXSW_REG_HTGT_LEN 0x20
6438 MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
6441 * Switch partition ID.
6444 MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
6446 #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
6452 MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
6454 enum mlxsw_reg_htgt_trap_group {
6455 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
6456 MLXSW_REG_HTGT_TRAP_GROUP_CORE_EVENT,
6457 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
6458 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
6459 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
6460 MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
6461 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
6462 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
6463 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
6464 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
6465 MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
6466 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
6467 MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE,
6468 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
6469 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
6470 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
6471 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
6472 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
6473 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
6474 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
6475 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
6476 MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
6477 MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
6478 MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS,
6479 MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
6480 MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
6481 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
6482 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
6483 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
6484 MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
6485 MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
6486 MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
6487 MLXSW_REG_HTGT_TRAP_GROUP_SP_EAPOL,
6489 __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
6490 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
6493 /* reg_htgt_trap_group
6494 * Trap group number. User defined number specifying which trap groups
6495 * should be forwarded to the CPU. The mapping between trap IDs and trap
6496 * groups is configured using HPKT register.
6499 MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
6502 MLXSW_REG_HTGT_POLICER_DISABLE,
6503 MLXSW_REG_HTGT_POLICER_ENABLE,
6507 * Enable policer ID specified using 'pid' field.
6510 MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
6512 #define MLXSW_REG_HTGT_INVALID_POLICER 0xff
6515 * Policer ID for the trap group.
6518 MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
6520 #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
6522 /* reg_htgt_mirror_action
6523 * Mirror action to use.
6525 * 1 - Trap to CPU and mirror to a mirroring agent.
6526 * 2 - Mirror to a mirroring agent and do not trap to CPU.
6529 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
6531 MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
6533 /* reg_htgt_mirroring_agent
6537 MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
6539 #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
6541 /* reg_htgt_priority
6542 * Trap group priority.
6543 * In case a packet matches multiple classification rules, the packet will
6544 * only be trapped once, based on the trap ID associated with the group (via
6545 * register HPKT) with the highest priority.
6546 * Supported values are 0-7, with 7 represnting the highest priority.
6549 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
6550 * by the 'trap_group' field.
6552 MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
6554 #define MLXSW_REG_HTGT_DEFAULT_TC 7
6556 /* reg_htgt_local_path_cpu_tclass
6557 * CPU ingress traffic class for the trap group.
6560 MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
6562 enum mlxsw_reg_htgt_local_path_rdq {
6563 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
6564 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
6565 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
6566 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
6568 /* reg_htgt_local_path_rdq
6569 * Receive descriptor queue (RDQ) to use for the trap group.
6572 MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
6574 static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
6577 MLXSW_REG_ZERO(htgt, payload);
6579 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
6580 mlxsw_reg_htgt_pide_set(payload,
6581 MLXSW_REG_HTGT_POLICER_DISABLE);
6583 mlxsw_reg_htgt_pide_set(payload,
6584 MLXSW_REG_HTGT_POLICER_ENABLE);
6585 mlxsw_reg_htgt_pid_set(payload, policer_id);
6588 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
6589 mlxsw_reg_htgt_trap_group_set(payload, group);
6590 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
6591 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
6592 mlxsw_reg_htgt_priority_set(payload, priority);
6593 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
6594 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
6597 /* HPKT - Host Packet Trap
6598 * -----------------------
6599 * Configures trap IDs inside trap groups.
6601 #define MLXSW_REG_HPKT_ID 0x7003
6602 #define MLXSW_REG_HPKT_LEN 0x10
6604 MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
6607 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
6608 MLXSW_REG_HPKT_ACK_REQUIRED,
6612 * Require acknowledgements from the host for events.
6613 * If set, then the device will wait for the event it sent to be acknowledged
6614 * by the host. This option is only relevant for event trap IDs.
6617 * Note: Currently not supported by firmware.
6619 MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
6621 enum mlxsw_reg_hpkt_action {
6622 MLXSW_REG_HPKT_ACTION_FORWARD,
6623 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
6624 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
6625 MLXSW_REG_HPKT_ACTION_DISCARD,
6626 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
6627 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
6628 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
6629 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
6633 * Action to perform on packet when trapped.
6634 * 0 - No action. Forward to CPU based on switching rules.
6635 * 1 - Trap to CPU (CPU receives sole copy).
6636 * 2 - Mirror to CPU (CPU receives a replica of the packet).
6638 * 4 - Soft discard (allow other traps to act on the packet).
6639 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
6640 * 6 - Trap to CPU (CPU receives sole copy) and count it as error.
6641 * 15 - Restore the firmware's default action.
6644 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
6645 * addressed to the CPU.
6647 MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
6649 /* reg_hpkt_trap_group
6650 * Trap group to associate the trap with.
6653 MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
6659 * Note: A trap ID can only be associated with a single trap group. The device
6660 * will associate the trap ID with the last trap group configured.
6662 MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10);
6665 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
6666 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
6667 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
6671 * Configure dedicated buffer resources for control packets.
6672 * Ignored by SwitchX-2.
6673 * 0 - Keep factory defaults.
6674 * 1 - Do not use control buffer for this trap ID.
6675 * 2 - Use control buffer for this trap ID.
6678 MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
6680 static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
6681 enum mlxsw_reg_htgt_trap_group trap_group,
6684 MLXSW_REG_ZERO(hpkt, payload);
6685 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
6686 mlxsw_reg_hpkt_action_set(payload, action);
6687 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
6688 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
6689 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
6690 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
6691 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
6694 /* RGCR - Router General Configuration Register
6695 * --------------------------------------------
6696 * The register is used for setting up the router configuration.
6698 #define MLXSW_REG_RGCR_ID 0x8001
6699 #define MLXSW_REG_RGCR_LEN 0x28
6701 MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
6704 * IPv4 router enable.
6707 MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
6710 * IPv6 router enable.
6713 MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
6715 /* reg_rgcr_max_router_interfaces
6716 * Defines the maximum number of active router interfaces for all virtual
6720 MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
6723 * Update switch priority and packet color.
6724 * 0 - Preserve the value of Switch Priority and packet color.
6725 * 1 - Recalculate the value of Switch Priority and packet color.
6728 * Note: Not supported by SwitchX and SwitchX-2.
6730 MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
6733 * Indicates how to handle the pcp_rewrite_en value:
6734 * 0 - Preserve the value of pcp_rewrite_en.
6735 * 2 - Disable PCP rewrite.
6736 * 3 - Enable PCP rewrite.
6739 * Note: Not supported by SwitchX and SwitchX-2.
6741 MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
6743 /* reg_rgcr_activity_dis
6745 * 0 - Activity will be set when an entry is hit (default).
6746 * 1 - Activity will not be set when an entry is hit.
6748 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
6750 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
6752 * Bits 2:7 are reserved.
6755 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
6757 MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
6759 static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
6762 MLXSW_REG_ZERO(rgcr, payload);
6763 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
6764 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
6767 /* RITR - Router Interface Table Register
6768 * --------------------------------------
6769 * The register is used to configure the router interface table.
6771 #define MLXSW_REG_RITR_ID 0x8002
6772 #define MLXSW_REG_RITR_LEN 0x40
6774 MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
6777 * Enables routing on the router interface.
6780 MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
6783 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
6787 MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
6790 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
6794 MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
6797 * IPv4 multicast routing enable.
6800 MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
6803 * IPv6 multicast routing enable.
6806 MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
6808 enum mlxsw_reg_ritr_if_type {
6809 /* VLAN interface. */
6810 MLXSW_REG_RITR_VLAN_IF,
6811 /* FID interface. */
6812 MLXSW_REG_RITR_FID_IF,
6813 /* Sub-port interface. */
6814 MLXSW_REG_RITR_SP_IF,
6815 /* Loopback Interface. */
6816 MLXSW_REG_RITR_LOOPBACK_IF,
6820 * Router interface type as per enum mlxsw_reg_ritr_if_type.
6823 MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
6826 MLXSW_REG_RITR_RIF_CREATE,
6827 MLXSW_REG_RITR_RIF_DEL,
6832 * 0 - Create or edit RIF.
6834 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
6835 * is not supported. An interface must be deleted and re-created in order
6836 * to update properties.
6839 MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
6842 * Router interface index. A pointer to the Router Interface Table.
6845 MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
6848 * IPv4 Forwarding Enable.
6849 * Enables routing of IPv4 traffic on the router interface. When disabled,
6850 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6851 * Not supported in SwitchX-2.
6854 MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
6857 * IPv6 Forwarding Enable.
6858 * Enables routing of IPv6 traffic on the router interface. When disabled,
6859 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6860 * Not supported in SwitchX-2.
6863 MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
6865 /* reg_ritr_ipv4_mc_fe
6866 * IPv4 Multicast Forwarding Enable.
6867 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6871 MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
6873 /* reg_ritr_ipv6_mc_fe
6874 * IPv6 Multicast Forwarding Enable.
6875 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6879 MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
6882 * Loop-back filter enable for unicast packets.
6883 * If the flag is set then loop-back filter for unicast packets is
6884 * implemented on the RIF. Multicast packets are always subject to
6885 * loop-back filtering.
6888 MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
6890 /* reg_ritr_virtual_router
6891 * Virtual router ID associated with the router interface.
6894 MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
6897 * Router interface MTU.
6900 MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
6903 * Switch partition ID.
6906 MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
6908 /* reg_ritr_if_mac_profile_id
6909 * MAC msb profile ID.
6912 MLXSW_ITEM32(reg, ritr, if_mac_profile_id, 0x10, 16, 4);
6915 * Router interface MAC address.
6916 * In Spectrum, all MAC addresses must have the same 38 MSBits.
6919 MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
6921 /* reg_ritr_if_vrrp_id_ipv6
6923 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6926 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
6928 /* reg_ritr_if_vrrp_id_ipv4
6930 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6933 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
6935 /* VLAN Interface */
6937 /* reg_ritr_vlan_if_vlan_id
6941 MLXSW_ITEM32(reg, ritr, vlan_if_vlan_id, 0x08, 0, 12);
6943 /* reg_ritr_vlan_if_efid
6945 * Used to connect the RIF to a bridge.
6948 * Note: Reserved when legacy bridge model is used and on Spectrum-1.
6950 MLXSW_ITEM32(reg, ritr, vlan_if_efid, 0x0C, 0, 16);
6954 /* reg_ritr_fid_if_fid
6955 * Filtering ID. Used to connect a bridge to the router.
6956 * When legacy bridge model is used, only FIDs from the vFID range are
6957 * supported. When unified bridge model is used, this is the egress FID for
6961 MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
6963 /* Sub-port Interface */
6965 /* reg_ritr_sp_if_lag
6966 * LAG indication. When this bit is set the system_port field holds the
6970 MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
6972 /* reg_ritr_sp_system_port
6973 * Port unique indentifier. When lag bit is set, this field holds the
6974 * lag_id in bits 0:9.
6977 MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
6979 /* reg_ritr_sp_if_efid
6980 * Egress filtering ID.
6981 * Used to connect the eRIF to a bridge if eRIF-ACL has modified the DMAC or
6985 * Note: Reserved when legacy bridge model is used.
6987 MLXSW_ITEM32(reg, ritr, sp_if_efid, 0x0C, 0, 16);
6989 /* reg_ritr_sp_if_vid
6993 MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
6995 /* Loopback Interface */
6997 enum mlxsw_reg_ritr_loopback_protocol {
6998 /* IPinIP IPv4 underlay Unicast */
6999 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
7000 /* IPinIP IPv6 underlay Unicast */
7001 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
7002 /* IPinIP generic - used for Spectrum-2 underlay RIF */
7003 MLXSW_REG_RITR_LOOPBACK_GENERIC,
7006 /* reg_ritr_loopback_protocol
7009 MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
7011 enum mlxsw_reg_ritr_loopback_ipip_type {
7012 /* Tunnel is IPinIP. */
7013 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
7014 /* Tunnel is GRE, no key. */
7015 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
7016 /* Tunnel is GRE, with a key. */
7017 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
7020 /* reg_ritr_loopback_ipip_type
7021 * Encapsulation type.
7024 MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
7026 enum mlxsw_reg_ritr_loopback_ipip_options {
7027 /* The key is defined by gre_key. */
7028 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
7031 /* reg_ritr_loopback_ipip_options
7034 MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
7036 /* reg_ritr_loopback_ipip_uvr
7037 * Underlay Virtual Router ID.
7038 * Range is 0..cap_max_virtual_routers-1.
7039 * Reserved for Spectrum-2.
7042 MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
7044 /* reg_ritr_loopback_ipip_underlay_rif
7045 * Underlay ingress router interface.
7046 * Reserved for Spectrum.
7049 MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
7051 /* reg_ritr_loopback_ipip_usip*
7052 * Encapsulation Underlay source IP.
7055 MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
7056 MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
7058 /* reg_ritr_loopback_ipip_gre_key
7060 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
7063 MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
7065 /* Shared between ingress/egress */
7066 enum mlxsw_reg_ritr_counter_set_type {
7068 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
7069 /* Basic. Used for router interfaces, counting the following:
7070 * - Error and Discard counters.
7071 * - Unicast, Multicast and Broadcast counters. Sharing the
7072 * same set of counters for the different type of traffic
7073 * (IPv4, IPv6 and mpls).
7075 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
7078 /* reg_ritr_ingress_counter_index
7079 * Counter Index for flow counter.
7082 MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
7084 /* reg_ritr_ingress_counter_set_type
7085 * Igress Counter Set Type for router interface counter.
7088 MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
7090 /* reg_ritr_egress_counter_index
7091 * Counter Index for flow counter.
7094 MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
7096 /* reg_ritr_egress_counter_set_type
7097 * Egress Counter Set Type for router interface counter.
7100 MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
7102 static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
7103 bool enable, bool egress)
7105 enum mlxsw_reg_ritr_counter_set_type set_type;
7108 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
7110 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
7113 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
7114 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
7116 mlxsw_reg_ritr_ingress_counter_set_type_set(payload, set_type);
7117 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
7121 static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
7123 MLXSW_REG_ZERO(ritr, payload);
7124 mlxsw_reg_ritr_rif_set(payload, rif);
7127 static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
7128 u16 system_port, u16 efid, u16 vid)
7130 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
7131 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
7132 mlxsw_reg_ritr_sp_if_efid_set(payload, efid);
7133 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
7136 static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
7137 enum mlxsw_reg_ritr_if_type type,
7138 u16 rif, u16 vr_id, u16 mtu)
7140 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
7142 MLXSW_REG_ZERO(ritr, payload);
7143 mlxsw_reg_ritr_enable_set(payload, enable);
7144 mlxsw_reg_ritr_ipv4_set(payload, 1);
7145 mlxsw_reg_ritr_ipv6_set(payload, 1);
7146 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
7147 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
7148 mlxsw_reg_ritr_type_set(payload, type);
7149 mlxsw_reg_ritr_op_set(payload, op);
7150 mlxsw_reg_ritr_rif_set(payload, rif);
7151 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
7152 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
7153 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
7154 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
7155 mlxsw_reg_ritr_lb_en_set(payload, 1);
7156 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
7157 mlxsw_reg_ritr_mtu_set(payload, mtu);
7160 static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
7162 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
7166 mlxsw_reg_ritr_vlan_if_pack(char *payload, bool enable, u16 rif, u16 vr_id,
7167 u16 mtu, const char *mac, u8 mac_profile_id,
7168 u16 vlan_id, u16 efid)
7170 enum mlxsw_reg_ritr_if_type type = MLXSW_REG_RITR_VLAN_IF;
7172 mlxsw_reg_ritr_pack(payload, enable, type, rif, vr_id, mtu);
7173 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
7174 mlxsw_reg_ritr_if_mac_profile_id_set(payload, mac_profile_id);
7175 mlxsw_reg_ritr_vlan_if_vlan_id_set(payload, vlan_id);
7176 mlxsw_reg_ritr_vlan_if_efid_set(payload, efid);
7180 mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
7181 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
7182 enum mlxsw_reg_ritr_loopback_ipip_options options,
7183 u16 uvr_id, u16 underlay_rif, u32 gre_key)
7185 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
7186 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
7187 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
7188 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
7189 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
7193 mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
7194 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
7195 enum mlxsw_reg_ritr_loopback_ipip_options options,
7196 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
7198 mlxsw_reg_ritr_loopback_protocol_set(payload,
7199 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
7200 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
7201 uvr_id, underlay_rif, gre_key);
7202 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
7206 mlxsw_reg_ritr_loopback_ipip6_pack(char *payload,
7207 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
7208 enum mlxsw_reg_ritr_loopback_ipip_options options,
7209 u16 uvr_id, u16 underlay_rif,
7210 const struct in6_addr *usip, u32 gre_key)
7212 enum mlxsw_reg_ritr_loopback_protocol protocol =
7213 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6;
7215 mlxsw_reg_ritr_loopback_protocol_set(payload, protocol);
7216 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
7217 uvr_id, underlay_rif, gre_key);
7218 mlxsw_reg_ritr_loopback_ipip_usip6_memcpy_to(payload,
7219 (const char *)usip);
7222 /* RTAR - Router TCAM Allocation Register
7223 * --------------------------------------
7224 * This register is used for allocation of regions in the TCAM table.
7226 #define MLXSW_REG_RTAR_ID 0x8004
7227 #define MLXSW_REG_RTAR_LEN 0x20
7229 MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
7231 enum mlxsw_reg_rtar_op {
7232 MLXSW_REG_RTAR_OP_ALLOCATE,
7233 MLXSW_REG_RTAR_OP_RESIZE,
7234 MLXSW_REG_RTAR_OP_DEALLOCATE,
7240 MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
7242 enum mlxsw_reg_rtar_key_type {
7243 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
7244 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
7247 /* reg_rtar_key_type
7248 * TCAM key type for the region.
7251 MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
7253 /* reg_rtar_region_size
7254 * TCAM region size. When allocating/resizing this is the requested
7255 * size, the response is the actual size.
7256 * Note: Actual size may be larger than requested.
7257 * Reserved for op = Deallocate
7260 MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
7262 static inline void mlxsw_reg_rtar_pack(char *payload,
7263 enum mlxsw_reg_rtar_op op,
7264 enum mlxsw_reg_rtar_key_type key_type,
7267 MLXSW_REG_ZERO(rtar, payload);
7268 mlxsw_reg_rtar_op_set(payload, op);
7269 mlxsw_reg_rtar_key_type_set(payload, key_type);
7270 mlxsw_reg_rtar_region_size_set(payload, region_size);
7273 /* RATR - Router Adjacency Table Register
7274 * --------------------------------------
7275 * The RATR register is used to configure the Router Adjacency (next-hop)
7278 #define MLXSW_REG_RATR_ID 0x8008
7279 #define MLXSW_REG_RATR_LEN 0x2C
7281 MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
7283 enum mlxsw_reg_ratr_op {
7285 MLXSW_REG_RATR_OP_QUERY_READ = 0,
7286 /* Read and clear activity */
7287 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
7288 /* Write Adjacency entry */
7289 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
7290 /* Write Adjacency entry only if the activity is cleared.
7291 * The write may not succeed if the activity is set. There is not
7292 * direct feedback if the write has succeeded or not, however
7293 * the get will reveal the actual entry (SW can compare the get
7294 * response to the set command).
7296 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
7300 * Note that Write operation may also be used for updating
7301 * counter_set_type and counter_index. In this case all other
7302 * fields must not be updated.
7305 MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
7308 * Valid bit. Indicates if the adjacency entry is valid.
7309 * Note: the device may need some time before reusing an invalidated
7310 * entry. During this time the entry can not be reused. It is
7311 * recommended to use another entry before reusing an invalidated
7312 * entry (e.g. software can put it at the end of the list for
7313 * reusing). Trying to access an invalidated entry not yet cleared
7314 * by the device results with failure indicating "Try Again" status.
7315 * When valid is '0' then egress_router_interface,trap_action,
7316 * adjacency_parameters and counters are reserved
7319 MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
7322 * Activity. Set for new entries. Set if a packet lookup has hit on
7323 * the specific entry. To clear the a bit, use "clear activity".
7326 MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
7328 enum mlxsw_reg_ratr_type {
7330 MLXSW_REG_RATR_TYPE_ETHERNET,
7331 /* IPoIB Unicast without GRH.
7332 * Reserved for Spectrum.
7334 MLXSW_REG_RATR_TYPE_IPOIB_UC,
7335 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
7337 * Reserved for Spectrum.
7339 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
7341 * Reserved for Spectrum.
7343 MLXSW_REG_RATR_TYPE_IPOIB_MC,
7345 * Reserved for SwitchX/-2.
7347 MLXSW_REG_RATR_TYPE_MPLS,
7349 * Reserved for SwitchX/-2.
7351 MLXSW_REG_RATR_TYPE_IPIP,
7355 * Adjacency entry type.
7358 MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
7360 /* reg_ratr_adjacency_index_low
7361 * Bits 15:0 of index into the adjacency table.
7362 * For SwitchX and SwitchX-2, the adjacency table is linear and
7363 * used for adjacency entries only.
7364 * For Spectrum, the index is to the KVD linear.
7367 MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
7369 /* reg_ratr_egress_router_interface
7370 * Range is 0 .. cap_max_router_interfaces - 1
7373 MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
7375 enum mlxsw_reg_ratr_trap_action {
7376 MLXSW_REG_RATR_TRAP_ACTION_NOP,
7377 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
7378 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
7379 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
7380 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
7383 /* reg_ratr_trap_action
7384 * see mlxsw_reg_ratr_trap_action
7387 MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
7389 /* reg_ratr_adjacency_index_high
7390 * Bits 23:16 of the adjacency_index.
7393 MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
7395 enum mlxsw_reg_ratr_trap_id {
7396 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
7397 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
7401 * Trap ID to be reported to CPU.
7402 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
7403 * For trap_action of NOP, MIRROR and DISCARD_ERROR
7406 MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
7408 /* reg_ratr_eth_destination_mac
7409 * MAC address of the destination next-hop.
7412 MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
7414 enum mlxsw_reg_ratr_ipip_type {
7415 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
7416 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
7417 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
7418 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
7421 /* reg_ratr_ipip_type
7422 * Underlay destination ip type.
7423 * Note: the type field must match the protocol of the router interface.
7426 MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
7428 /* reg_ratr_ipip_ipv4_udip
7429 * Underlay ipv4 dip.
7430 * Reserved when ipip_type is IPv6.
7433 MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
7435 /* reg_ratr_ipip_ipv6_ptr
7436 * Pointer to IPv6 underlay destination ip address.
7437 * For Spectrum: Pointer to KVD linear space.
7440 MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
7442 enum mlxsw_reg_flow_counter_set_type {
7444 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
7445 /* Count packets and bytes */
7446 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
7447 /* Count only packets */
7448 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
7451 /* reg_ratr_counter_set_type
7452 * Counter set type for flow counters
7455 MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
7457 /* reg_ratr_counter_index
7458 * Counter index for flow counters
7461 MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
7464 mlxsw_reg_ratr_pack(char *payload,
7465 enum mlxsw_reg_ratr_op op, bool valid,
7466 enum mlxsw_reg_ratr_type type,
7467 u32 adjacency_index, u16 egress_rif)
7469 MLXSW_REG_ZERO(ratr, payload);
7470 mlxsw_reg_ratr_op_set(payload, op);
7471 mlxsw_reg_ratr_v_set(payload, valid);
7472 mlxsw_reg_ratr_type_set(payload, type);
7473 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
7474 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
7475 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
7478 static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
7479 const char *dest_mac)
7481 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
7484 static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
7486 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
7487 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
7490 static inline void mlxsw_reg_ratr_ipip6_entry_pack(char *payload, u32 ipv6_ptr)
7492 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV6);
7493 mlxsw_reg_ratr_ipip_ipv6_ptr_set(payload, ipv6_ptr);
7496 static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
7497 bool counter_enable)
7499 enum mlxsw_reg_flow_counter_set_type set_type;
7502 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
7504 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
7506 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
7507 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
7510 /* RDPM - Router DSCP to Priority Mapping
7511 * --------------------------------------
7512 * Controls the mapping from DSCP field to switch priority on routed packets
7514 #define MLXSW_REG_RDPM_ID 0x8009
7515 #define MLXSW_REG_RDPM_BASE_LEN 0x00
7516 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
7517 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
7518 #define MLXSW_REG_RDPM_LEN 0x40
7519 #define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
7520 MLXSW_REG_RDPM_LEN - \
7521 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
7523 MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
7526 * Enable update of the specific entry
7529 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
7530 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
7532 /* reg_dscp_entry_prio
7536 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
7537 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
7539 static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
7542 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
7543 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
7546 /* RICNT - Router Interface Counter Register
7547 * -----------------------------------------
7548 * The RICNT register retrieves per port performance counters
7550 #define MLXSW_REG_RICNT_ID 0x800B
7551 #define MLXSW_REG_RICNT_LEN 0x100
7553 MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
7555 /* reg_ricnt_counter_index
7559 MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
7561 enum mlxsw_reg_ricnt_counter_set_type {
7563 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
7564 /* Basic. Used for router interfaces, counting the following:
7565 * - Error and Discard counters.
7566 * - Unicast, Multicast and Broadcast counters. Sharing the
7567 * same set of counters for the different type of traffic
7568 * (IPv4, IPv6 and mpls).
7570 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
7573 /* reg_ricnt_counter_set_type
7574 * Counter Set Type for router interface counter
7577 MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
7579 enum mlxsw_reg_ricnt_opcode {
7580 /* Nop. Supported only for read access*/
7581 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
7582 /* Clear. Setting the clr bit will reset the counter value for
7583 * all counters of the specified Router Interface.
7585 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
7592 MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
7594 /* reg_ricnt_good_unicast_packets
7595 * good unicast packets.
7598 MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
7600 /* reg_ricnt_good_multicast_packets
7601 * good multicast packets.
7604 MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
7606 /* reg_ricnt_good_broadcast_packets
7607 * good broadcast packets
7610 MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
7612 /* reg_ricnt_good_unicast_bytes
7613 * A count of L3 data and padding octets not including L2 headers
7614 * for good unicast frames.
7617 MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
7619 /* reg_ricnt_good_multicast_bytes
7620 * A count of L3 data and padding octets not including L2 headers
7621 * for good multicast frames.
7624 MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
7626 /* reg_ritr_good_broadcast_bytes
7627 * A count of L3 data and padding octets not including L2 headers
7628 * for good broadcast frames.
7631 MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
7633 /* reg_ricnt_error_packets
7634 * A count of errored frames that do not pass the router checks.
7637 MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
7639 /* reg_ricnt_discrad_packets
7640 * A count of non-errored frames that do not pass the router checks.
7643 MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
7645 /* reg_ricnt_error_bytes
7646 * A count of L3 data and padding octets not including L2 headers
7647 * for errored frames.
7650 MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
7652 /* reg_ricnt_discard_bytes
7653 * A count of L3 data and padding octets not including L2 headers
7654 * for non-errored frames that do not pass the router checks.
7657 MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
7659 static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
7660 enum mlxsw_reg_ricnt_opcode op)
7662 MLXSW_REG_ZERO(ricnt, payload);
7663 mlxsw_reg_ricnt_op_set(payload, op);
7664 mlxsw_reg_ricnt_counter_index_set(payload, index);
7665 mlxsw_reg_ricnt_counter_set_type_set(payload,
7666 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
7669 /* RRCR - Router Rules Copy Register Layout
7670 * ----------------------------------------
7671 * This register is used for moving and copying route entry rules.
7673 #define MLXSW_REG_RRCR_ID 0x800F
7674 #define MLXSW_REG_RRCR_LEN 0x24
7676 MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
7678 enum mlxsw_reg_rrcr_op {
7680 MLXSW_REG_RRCR_OP_MOVE,
7682 MLXSW_REG_RRCR_OP_COPY,
7688 MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
7691 * Offset within the region from which to copy/move.
7694 MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
7697 * The number of rules to copy/move.
7700 MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
7702 /* reg_rrcr_table_id
7703 * Identifier of the table on which to perform the operation. Encoding is the
7704 * same as in RTAR.key_type
7707 MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
7709 /* reg_rrcr_dest_offset
7710 * Offset within the region to which to copy/move
7713 MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
7715 static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
7716 u16 offset, u16 size,
7717 enum mlxsw_reg_rtar_key_type table_id,
7720 MLXSW_REG_ZERO(rrcr, payload);
7721 mlxsw_reg_rrcr_op_set(payload, op);
7722 mlxsw_reg_rrcr_offset_set(payload, offset);
7723 mlxsw_reg_rrcr_size_set(payload, size);
7724 mlxsw_reg_rrcr_table_id_set(payload, table_id);
7725 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
7728 /* RALTA - Router Algorithmic LPM Tree Allocation Register
7729 * -------------------------------------------------------
7730 * RALTA is used to allocate the LPM trees of the SHSPM method.
7732 #define MLXSW_REG_RALTA_ID 0x8010
7733 #define MLXSW_REG_RALTA_LEN 0x04
7735 MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
7738 * opcode (valid for Write, must be 0 on Read)
7739 * 0 - allocate a tree
7740 * 1 - deallocate a tree
7743 MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
7745 enum mlxsw_reg_ralxx_protocol {
7746 MLXSW_REG_RALXX_PROTOCOL_IPV4,
7747 MLXSW_REG_RALXX_PROTOCOL_IPV6,
7750 /* reg_ralta_protocol
7752 * Deallocation opcode: Reserved.
7755 MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
7757 /* reg_ralta_tree_id
7758 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
7759 * the tree identifier (managed by software).
7760 * Note that tree_id 0 is allocated for a default-route tree.
7763 MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
7765 static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
7766 enum mlxsw_reg_ralxx_protocol protocol,
7769 MLXSW_REG_ZERO(ralta, payload);
7770 mlxsw_reg_ralta_op_set(payload, !alloc);
7771 mlxsw_reg_ralta_protocol_set(payload, protocol);
7772 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
7775 /* RALST - Router Algorithmic LPM Structure Tree Register
7776 * ------------------------------------------------------
7777 * RALST is used to set and query the structure of an LPM tree.
7778 * The structure of the tree must be sorted as a sorted binary tree, while
7779 * each node is a bin that is tagged as the length of the prefixes the lookup
7780 * will refer to. Therefore, bin X refers to a set of entries with prefixes
7781 * of X bits to match with the destination address. The bin 0 indicates
7782 * the default action, when there is no match of any prefix.
7784 #define MLXSW_REG_RALST_ID 0x8011
7785 #define MLXSW_REG_RALST_LEN 0x104
7787 MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
7789 /* reg_ralst_root_bin
7790 * The bin number of the root bin.
7791 * 0<root_bin=<(length of IP address)
7792 * For a default-route tree configure 0xff
7795 MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
7797 /* reg_ralst_tree_id
7798 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
7801 MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
7803 #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
7804 #define MLXSW_REG_RALST_BIN_OFFSET 0x04
7805 #define MLXSW_REG_RALST_BIN_COUNT 128
7807 /* reg_ralst_left_child_bin
7808 * Holding the children of the bin according to the stored tree's structure.
7809 * For trees composed of less than 4 blocks, the bins in excess are reserved.
7810 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
7813 MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
7815 /* reg_ralst_right_child_bin
7816 * Holding the children of the bin according to the stored tree's structure.
7817 * For trees composed of less than 4 blocks, the bins in excess are reserved.
7818 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
7821 MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
7824 static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
7826 MLXSW_REG_ZERO(ralst, payload);
7828 /* Initialize all bins to have no left or right child */
7829 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
7830 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
7832 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
7833 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
7836 static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
7840 int bin_index = bin_number - 1;
7842 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
7843 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
7847 /* RALTB - Router Algorithmic LPM Tree Binding Register
7848 * ----------------------------------------------------
7849 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
7851 #define MLXSW_REG_RALTB_ID 0x8012
7852 #define MLXSW_REG_RALTB_LEN 0x04
7854 MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
7856 /* reg_raltb_virtual_router
7858 * Range is 0..cap_max_virtual_routers-1
7861 MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
7863 /* reg_raltb_protocol
7867 MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
7869 /* reg_raltb_tree_id
7870 * Tree to be used for the {virtual_router, protocol}
7871 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
7872 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
7875 MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
7877 static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
7878 enum mlxsw_reg_ralxx_protocol protocol,
7881 MLXSW_REG_ZERO(raltb, payload);
7882 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
7883 mlxsw_reg_raltb_protocol_set(payload, protocol);
7884 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
7887 /* RALUE - Router Algorithmic LPM Unicast Entry Register
7888 * -----------------------------------------------------
7889 * RALUE is used to configure and query LPM entries that serve
7890 * the Unicast protocols.
7892 #define MLXSW_REG_RALUE_ID 0x8013
7893 #define MLXSW_REG_RALUE_LEN 0x38
7895 MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
7897 /* reg_ralue_protocol
7901 MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
7903 enum mlxsw_reg_ralue_op {
7904 /* Read operation. If entry doesn't exist, the operation fails. */
7905 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
7906 /* Clear on read operation. Used to read entry and
7907 * clear Activity bit.
7909 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
7910 /* Write operation. Used to write a new entry to the table. All RW
7911 * fields are written for new entry. Activity bit is set
7914 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
7915 /* Update operation. Used to update an existing route entry and
7916 * only update the RW fields that are detailed in the field
7917 * op_u_mask. If entry doesn't exist, the operation fails.
7919 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
7920 /* Clear activity. The Activity bit (the field a) is cleared
7923 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
7924 /* Delete operation. Used to delete an existing entry. If entry
7925 * doesn't exist, the operation fails.
7927 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
7934 MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
7937 * Activity. Set for new entries. Set if a packet lookup has hit on the
7938 * specific entry, only if the entry is a route. To clear the a bit, use
7939 * "clear activity" op.
7940 * Enabled by activity_dis in RGCR
7943 MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
7945 /* reg_ralue_virtual_router
7947 * Range is 0..cap_max_virtual_routers-1
7950 MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
7952 #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
7953 #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
7954 #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
7956 /* reg_ralue_op_u_mask
7957 * opcode update mask.
7958 * On read operation, this field is reserved.
7959 * This field is valid for update opcode, otherwise - reserved.
7960 * This field is a bitmask of the fields that should be updated.
7963 MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
7965 /* reg_ralue_prefix_len
7966 * Number of bits in the prefix of the LPM route.
7967 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
7968 * two entries in the physical HW table.
7971 MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
7974 * The prefix of the route or of the marker that the object of the LPM
7975 * is compared with. The most significant bits of the dip are the prefix.
7976 * The least significant bits must be '0' if the prefix_len is smaller
7977 * than 128 for IPv6 or smaller than 32 for IPv4.
7978 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
7981 MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
7982 MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
7984 enum mlxsw_reg_ralue_entry_type {
7985 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
7986 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
7987 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
7990 /* reg_ralue_entry_type
7992 * Note - for Marker entries, the action_type and action fields are reserved.
7995 MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
7997 /* reg_ralue_bmp_len
7998 * The best match prefix length in the case that there is no match for
8000 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
8001 * Note for any update operation with entry_type modification this
8002 * field must be set.
8005 MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
8007 enum mlxsw_reg_ralue_action_type {
8008 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
8009 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
8010 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
8013 /* reg_ralue_action_type
8015 * Indicates how the IP address is connected.
8016 * It can be connected to a local subnet through local_erif or can be
8017 * on a remote subnet connected through a next-hop router,
8018 * or transmitted to the CPU.
8019 * Reserved when entry_type = MARKER_ENTRY
8022 MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
8024 enum mlxsw_reg_ralue_trap_action {
8025 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
8026 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
8027 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
8028 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
8029 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
8032 /* reg_ralue_trap_action
8034 * For IP2ME action, only NOP and MIRROR are possible.
8037 MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
8039 /* reg_ralue_trap_id
8040 * Trap ID to be reported to CPU.
8041 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
8042 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
8045 MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
8047 /* reg_ralue_adjacency_index
8048 * Points to the first entry of the group-based ECMP.
8049 * Only relevant in case of REMOTE action.
8052 MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
8054 /* reg_ralue_ecmp_size
8055 * Amount of sequential entries starting
8056 * from the adjacency_index (the number of ECMPs).
8057 * The valid range is 1-64, 512, 1024, 2048 and 4096.
8058 * Reserved when trap_action is TRAP or DISCARD_ERROR.
8059 * Only relevant in case of REMOTE action.
8062 MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
8064 /* reg_ralue_local_erif
8065 * Egress Router Interface.
8066 * Only relevant in case of LOCAL action.
8069 MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
8071 /* reg_ralue_ip2me_v
8072 * Valid bit for the tunnel_ptr field.
8073 * If valid = 0 then trap to CPU as IP2ME trap ID.
8074 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
8075 * decapsulation then tunnel decapsulation is done.
8076 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
8077 * decapsulation then trap as IP2ME trap ID.
8078 * Only relevant in case of IP2ME action.
8081 MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
8083 /* reg_ralue_ip2me_tunnel_ptr
8084 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
8085 * For Spectrum, pointer to KVD Linear.
8086 * Only relevant in case of IP2ME action.
8089 MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
8091 static inline void mlxsw_reg_ralue_pack(char *payload,
8092 enum mlxsw_reg_ralxx_protocol protocol,
8093 enum mlxsw_reg_ralue_op op,
8094 u16 virtual_router, u8 prefix_len)
8096 MLXSW_REG_ZERO(ralue, payload);
8097 mlxsw_reg_ralue_protocol_set(payload, protocol);
8098 mlxsw_reg_ralue_op_set(payload, op);
8099 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
8100 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
8101 mlxsw_reg_ralue_entry_type_set(payload,
8102 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
8103 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
8106 static inline void mlxsw_reg_ralue_pack4(char *payload,
8107 enum mlxsw_reg_ralxx_protocol protocol,
8108 enum mlxsw_reg_ralue_op op,
8109 u16 virtual_router, u8 prefix_len,
8112 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
8113 mlxsw_reg_ralue_dip4_set(payload, dip);
8116 static inline void mlxsw_reg_ralue_pack6(char *payload,
8117 enum mlxsw_reg_ralxx_protocol protocol,
8118 enum mlxsw_reg_ralue_op op,
8119 u16 virtual_router, u8 prefix_len,
8122 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
8123 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
8127 mlxsw_reg_ralue_act_remote_pack(char *payload,
8128 enum mlxsw_reg_ralue_trap_action trap_action,
8129 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
8131 mlxsw_reg_ralue_action_type_set(payload,
8132 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
8133 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
8134 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
8135 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
8136 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
8140 mlxsw_reg_ralue_act_local_pack(char *payload,
8141 enum mlxsw_reg_ralue_trap_action trap_action,
8142 u16 trap_id, u16 local_erif)
8144 mlxsw_reg_ralue_action_type_set(payload,
8145 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
8146 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
8147 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
8148 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
8152 mlxsw_reg_ralue_act_ip2me_pack(char *payload)
8154 mlxsw_reg_ralue_action_type_set(payload,
8155 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
8159 mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
8161 mlxsw_reg_ralue_action_type_set(payload,
8162 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
8163 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
8164 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
8167 /* RAUHT - Router Algorithmic LPM Unicast Host Table Register
8168 * ----------------------------------------------------------
8169 * The RAUHT register is used to configure and query the Unicast Host table in
8170 * devices that implement the Algorithmic LPM.
8172 #define MLXSW_REG_RAUHT_ID 0x8014
8173 #define MLXSW_REG_RAUHT_LEN 0x74
8175 MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
8177 enum mlxsw_reg_rauht_type {
8178 MLXSW_REG_RAUHT_TYPE_IPV4,
8179 MLXSW_REG_RAUHT_TYPE_IPV6,
8185 MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
8187 enum mlxsw_reg_rauht_op {
8188 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
8189 /* Read operation */
8190 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
8191 /* Clear on read operation. Used to read entry and clear
8194 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
8195 /* Add. Used to write a new entry to the table. All R/W fields are
8196 * relevant for new entry. Activity bit is set for new entries.
8198 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
8199 /* Update action. Used to update an existing route entry and
8200 * only update the following fields:
8201 * trap_action, trap_id, mac, counter_set_type, counter_index
8203 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
8204 /* Clear activity. A bit is cleared for the entry. */
8205 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
8207 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
8208 /* Delete all host entries on a RIF. In this command, dip
8209 * field is reserved.
8216 MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
8219 * Activity. Set for new entries. Set if a packet lookup has hit on
8220 * the specific entry.
8221 * To clear the a bit, use "clear activity" op.
8222 * Enabled by activity_dis in RGCR
8225 MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
8231 MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
8234 * Destination address.
8237 MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
8238 MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
8240 enum mlxsw_reg_rauht_trap_action {
8241 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
8242 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
8243 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
8244 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
8245 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
8248 /* reg_rauht_trap_action
8251 MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
8253 enum mlxsw_reg_rauht_trap_id {
8254 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
8255 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
8258 /* reg_rauht_trap_id
8259 * Trap ID to be reported to CPU.
8260 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
8261 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
8262 * trap_id is reserved.
8265 MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
8267 /* reg_rauht_counter_set_type
8268 * Counter set type for flow counters
8271 MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
8273 /* reg_rauht_counter_index
8274 * Counter index for flow counters
8277 MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
8283 MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
8285 static inline void mlxsw_reg_rauht_pack(char *payload,
8286 enum mlxsw_reg_rauht_op op, u16 rif,
8289 MLXSW_REG_ZERO(rauht, payload);
8290 mlxsw_reg_rauht_op_set(payload, op);
8291 mlxsw_reg_rauht_rif_set(payload, rif);
8292 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
8295 static inline void mlxsw_reg_rauht_pack4(char *payload,
8296 enum mlxsw_reg_rauht_op op, u16 rif,
8297 const char *mac, u32 dip)
8299 mlxsw_reg_rauht_pack(payload, op, rif, mac);
8300 mlxsw_reg_rauht_dip4_set(payload, dip);
8303 static inline void mlxsw_reg_rauht_pack6(char *payload,
8304 enum mlxsw_reg_rauht_op op, u16 rif,
8305 const char *mac, const char *dip)
8307 mlxsw_reg_rauht_pack(payload, op, rif, mac);
8308 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
8309 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
8312 static inline void mlxsw_reg_rauht_pack_counter(char *payload,
8315 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
8316 mlxsw_reg_rauht_counter_set_type_set(payload,
8317 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
8320 /* RALEU - Router Algorithmic LPM ECMP Update Register
8321 * ---------------------------------------------------
8322 * The register enables updating the ECMP section in the action for multiple
8323 * LPM Unicast entries in a single operation. The update is executed to
8324 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
8326 #define MLXSW_REG_RALEU_ID 0x8015
8327 #define MLXSW_REG_RALEU_LEN 0x28
8329 MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
8331 /* reg_raleu_protocol
8335 MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
8337 /* reg_raleu_virtual_router
8339 * Range is 0..cap_max_virtual_routers-1
8342 MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
8344 /* reg_raleu_adjacency_index
8345 * Adjacency Index used for matching on the existing entries.
8348 MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
8350 /* reg_raleu_ecmp_size
8351 * ECMP Size used for matching on the existing entries.
8354 MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
8356 /* reg_raleu_new_adjacency_index
8357 * New Adjacency Index.
8360 MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
8362 /* reg_raleu_new_ecmp_size
8366 MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
8368 static inline void mlxsw_reg_raleu_pack(char *payload,
8369 enum mlxsw_reg_ralxx_protocol protocol,
8371 u32 adjacency_index, u16 ecmp_size,
8372 u32 new_adjacency_index,
8375 MLXSW_REG_ZERO(raleu, payload);
8376 mlxsw_reg_raleu_protocol_set(payload, protocol);
8377 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
8378 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
8379 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
8380 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
8381 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
8384 /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
8385 * ----------------------------------------------------------------
8386 * The RAUHTD register allows dumping entries from the Router Unicast Host
8387 * Table. For a given session an entry is dumped no more than one time. The
8388 * first RAUHTD access after reset is a new session. A session ends when the
8389 * num_rec response is smaller than num_rec request or for IPv4 when the
8390 * num_entries is smaller than 4. The clear activity affect the current session
8391 * or the last session if a new session has not started.
8393 #define MLXSW_REG_RAUHTD_ID 0x8018
8394 #define MLXSW_REG_RAUHTD_BASE_LEN 0x20
8395 #define MLXSW_REG_RAUHTD_REC_LEN 0x20
8396 #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
8397 #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
8398 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
8399 #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
8401 MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
8403 #define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
8404 #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
8406 /* reg_rauhtd_filter_fields
8407 * if a bit is '0' then the relevant field is ignored and dump is done
8408 * regardless of the field value
8409 * Bit0 - filter by activity: entry_a
8410 * Bit3 - filter by entry rip: entry_rif
8413 MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
8415 enum mlxsw_reg_rauhtd_op {
8416 MLXSW_REG_RAUHTD_OP_DUMP,
8417 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
8423 MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
8425 /* reg_rauhtd_num_rec
8426 * At request: number of records requested
8427 * At response: number of records dumped
8428 * For IPv4, each record has 4 entries at request and up to 4 entries
8430 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
8433 MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
8435 /* reg_rauhtd_entry_a
8436 * Dump only if activity has value of entry_a
8437 * Reserved if filter_fields bit0 is '0'
8440 MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
8442 enum mlxsw_reg_rauhtd_type {
8443 MLXSW_REG_RAUHTD_TYPE_IPV4,
8444 MLXSW_REG_RAUHTD_TYPE_IPV6,
8448 * Dump only if record type is:
8453 MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
8455 /* reg_rauhtd_entry_rif
8456 * Dump only if RIF has value of entry_rif
8457 * Reserved if filter_fields bit3 is '0'
8460 MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
8462 static inline void mlxsw_reg_rauhtd_pack(char *payload,
8463 enum mlxsw_reg_rauhtd_type type)
8465 MLXSW_REG_ZERO(rauhtd, payload);
8466 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
8467 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
8468 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
8469 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
8470 mlxsw_reg_rauhtd_type_set(payload, type);
8473 /* reg_rauhtd_ipv4_rec_num_entries
8474 * Number of valid entries in this record:
8476 * 1 - 2 valid entries
8477 * 2 - 3 valid entries
8478 * 3 - 4 valid entries
8481 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
8482 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
8483 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
8485 /* reg_rauhtd_rec_type
8491 MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
8492 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
8494 #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
8496 /* reg_rauhtd_ipv4_ent_a
8497 * Activity. Set for new entries. Set if a packet lookup has hit on the
8501 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
8502 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
8504 /* reg_rauhtd_ipv4_ent_rif
8508 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8509 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
8511 /* reg_rauhtd_ipv4_ent_dip
8512 * Destination IPv4 address.
8515 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8516 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
8518 #define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
8520 /* reg_rauhtd_ipv6_ent_a
8521 * Activity. Set for new entries. Set if a packet lookup has hit on the
8525 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
8526 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
8528 /* reg_rauhtd_ipv6_ent_rif
8532 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8533 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
8535 /* reg_rauhtd_ipv6_ent_dip
8536 * Destination IPv6 address.
8539 MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
8540 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
8542 static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
8543 int ent_index, u16 *p_rif,
8546 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
8547 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
8550 static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
8551 int rec_index, u16 *p_rif,
8554 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
8555 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
8558 /* RTDP - Routing Tunnel Decap Properties Register
8559 * -----------------------------------------------
8560 * The RTDP register is used for configuring the tunnel decap properties of NVE
8563 #define MLXSW_REG_RTDP_ID 0x8020
8564 #define MLXSW_REG_RTDP_LEN 0x44
8566 MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
8568 enum mlxsw_reg_rtdp_type {
8569 MLXSW_REG_RTDP_TYPE_NVE,
8570 MLXSW_REG_RTDP_TYPE_IPIP,
8574 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
8577 MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
8579 /* reg_rtdp_tunnel_index
8580 * Index to the Decap entry.
8581 * For Spectrum, Index to KVD Linear.
8584 MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
8586 /* reg_rtdp_egress_router_interface
8587 * Underlay egress router interface.
8588 * Valid range is from 0 to cap_max_router_interfaces - 1
8591 MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
8595 /* reg_rtdp_ipip_irif
8596 * Ingress Router Interface for the overlay router
8599 MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
8601 enum mlxsw_reg_rtdp_ipip_sip_check {
8602 /* No sip checks. */
8603 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
8604 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
8607 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
8608 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
8611 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
8614 /* reg_rtdp_ipip_sip_check
8615 * SIP check to perform. If decapsulation failed due to these configurations
8616 * then trap_id is IPIP_DECAP_ERROR.
8619 MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
8621 /* If set, allow decapsulation of IPinIP (without GRE). */
8622 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
8623 /* If set, allow decapsulation of IPinGREinIP without a key. */
8624 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
8625 /* If set, allow decapsulation of IPinGREinIP with a key. */
8626 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
8628 /* reg_rtdp_ipip_type_check
8629 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
8630 * these configurations then trap_id is IPIP_DECAP_ERROR.
8633 MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
8635 /* reg_rtdp_ipip_gre_key_check
8636 * Whether GRE key should be checked. When check is enabled:
8637 * - A packet received as IPinIP (without GRE) will always pass.
8638 * - A packet received as IPinGREinIP without a key will not pass the check.
8639 * - A packet received as IPinGREinIP with a key will pass the check only if the
8640 * key in the packet is equal to expected_gre_key.
8641 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
8644 MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
8646 /* reg_rtdp_ipip_ipv4_usip
8647 * Underlay IPv4 address for ipv4 source address check.
8648 * Reserved when sip_check is not '1'.
8651 MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
8653 /* reg_rtdp_ipip_ipv6_usip_ptr
8654 * This field is valid when sip_check is "sipv6 check explicitly". This is a
8655 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
8656 * is to the KVD linear.
8657 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
8660 MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
8662 /* reg_rtdp_ipip_expected_gre_key
8663 * GRE key for checking.
8664 * Reserved when gre_key_check is '0'.
8667 MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
8669 static inline void mlxsw_reg_rtdp_pack(char *payload,
8670 enum mlxsw_reg_rtdp_type type,
8673 MLXSW_REG_ZERO(rtdp, payload);
8674 mlxsw_reg_rtdp_type_set(payload, type);
8675 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
8679 mlxsw_reg_rtdp_ipip_pack(char *payload, u16 irif,
8680 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8681 unsigned int type_check, bool gre_key_check,
8682 u32 expected_gre_key)
8684 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
8685 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
8686 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
8687 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
8688 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
8692 mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
8693 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8694 unsigned int type_check, bool gre_key_check,
8695 u32 ipv4_usip, u32 expected_gre_key)
8697 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
8698 gre_key_check, expected_gre_key);
8699 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
8703 mlxsw_reg_rtdp_ipip6_pack(char *payload, u16 irif,
8704 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8705 unsigned int type_check, bool gre_key_check,
8706 u32 ipv6_usip_ptr, u32 expected_gre_key)
8708 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
8709 gre_key_check, expected_gre_key);
8710 mlxsw_reg_rtdp_ipip_ipv6_usip_ptr_set(payload, ipv6_usip_ptr);
8713 /* RIPS - Router IP version Six Register
8714 * -------------------------------------
8715 * The RIPS register is used to store IPv6 addresses for use by the NVE and
8718 #define MLXSW_REG_RIPS_ID 0x8021
8719 #define MLXSW_REG_RIPS_LEN 0x14
8721 MLXSW_REG_DEFINE(rips, MLXSW_REG_RIPS_ID, MLXSW_REG_RIPS_LEN);
8724 * Index to IPv6 address.
8725 * For Spectrum, the index is to the KVD linear.
8728 MLXSW_ITEM32(reg, rips, index, 0x00, 0, 24);
8734 MLXSW_ITEM_BUF(reg, rips, ipv6, 0x04, 16);
8736 static inline void mlxsw_reg_rips_pack(char *payload, u32 index,
8737 const struct in6_addr *ipv6)
8739 MLXSW_REG_ZERO(rips, payload);
8740 mlxsw_reg_rips_index_set(payload, index);
8741 mlxsw_reg_rips_ipv6_memcpy_to(payload, (const char *)ipv6);
8744 /* RATRAD - Router Adjacency Table Activity Dump Register
8745 * ------------------------------------------------------
8746 * The RATRAD register is used to dump and optionally clear activity bits of
8747 * router adjacency table entries.
8749 #define MLXSW_REG_RATRAD_ID 0x8022
8750 #define MLXSW_REG_RATRAD_LEN 0x210
8752 MLXSW_REG_DEFINE(ratrad, MLXSW_REG_RATRAD_ID, MLXSW_REG_RATRAD_LEN);
8756 MLXSW_REG_RATRAD_OP_READ_ACTIVITY,
8757 /* Read and clear activity */
8758 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY,
8764 MLXSW_ITEM32(reg, ratrad, op, 0x00, 30, 2);
8766 /* reg_ratrad_ecmp_size
8767 * ecmp_size is the amount of sequential entries from adjacency_index. Valid
8769 * Spectrum-1: 32-64, 512, 1024, 2048, 4096
8770 * Spectrum-2/3: 32-128, 256, 512, 1024, 2048, 4096
8773 MLXSW_ITEM32(reg, ratrad, ecmp_size, 0x00, 0, 13);
8775 /* reg_ratrad_adjacency_index
8776 * Index into the adjacency table.
8779 MLXSW_ITEM32(reg, ratrad, adjacency_index, 0x04, 0, 24);
8781 /* reg_ratrad_activity_vector
8782 * Activity bit per adjacency index.
8783 * Bits higher than ecmp_size are reserved.
8786 MLXSW_ITEM_BIT_ARRAY(reg, ratrad, activity_vector, 0x10, 0x200, 1);
8788 static inline void mlxsw_reg_ratrad_pack(char *payload, u32 adjacency_index,
8791 MLXSW_REG_ZERO(ratrad, payload);
8792 mlxsw_reg_ratrad_op_set(payload,
8793 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY);
8794 mlxsw_reg_ratrad_ecmp_size_set(payload, ecmp_size);
8795 mlxsw_reg_ratrad_adjacency_index_set(payload, adjacency_index);
8798 /* RIGR-V2 - Router Interface Group Register Version 2
8799 * ---------------------------------------------------
8800 * The RIGR_V2 register is used to add, remove and query egress interface list
8801 * of a multicast forwarding entry.
8803 #define MLXSW_REG_RIGR2_ID 0x8023
8804 #define MLXSW_REG_RIGR2_LEN 0xB0
8806 #define MLXSW_REG_RIGR2_MAX_ERIFS 32
8808 MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
8810 /* reg_rigr2_rigr_index
8814 MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
8817 * Next RIGR Index is valid.
8820 MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
8822 /* reg_rigr2_next_rigr_index
8823 * Next RIGR Index. The index is to the KVD linear.
8824 * Reserved when vnxet = '0'.
8827 MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
8830 * RMID Index is valid.
8833 MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
8835 /* reg_rigr2_rmid_index
8837 * Range 0 .. max_mid - 1
8838 * Reserved when vrmid = '0'.
8839 * The index is to the Port Group Table (PGT)
8842 MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
8844 /* reg_rigr2_erif_entry_v
8845 * Egress Router Interface is valid.
8846 * Note that low-entries must be set if high-entries are set. For
8847 * example: if erif_entry[2].v is set then erif_entry[1].v and
8848 * erif_entry[0].v must be set.
8849 * Index can be from 0 to cap_mc_erif_list_entries-1
8852 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
8854 /* reg_rigr2_erif_entry_erif
8855 * Egress Router Interface.
8856 * Valid range is from 0 to cap_max_router_interfaces - 1
8857 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
8860 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
8862 static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
8863 bool vnext, u32 next_rigr_index)
8865 MLXSW_REG_ZERO(rigr2, payload);
8866 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
8867 mlxsw_reg_rigr2_vnext_set(payload, vnext);
8868 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
8869 mlxsw_reg_rigr2_vrmid_set(payload, 0);
8870 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
8873 static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
8876 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
8877 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
8880 /* RECR-V2 - Router ECMP Configuration Version 2 Register
8881 * ------------------------------------------------------
8883 #define MLXSW_REG_RECR2_ID 0x8025
8884 #define MLXSW_REG_RECR2_LEN 0x38
8886 MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
8889 * Per-port configuration
8892 MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
8898 MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
8904 MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
8907 /* Enable IPv4 fields if packet is not TCP and not UDP */
8908 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
8909 /* Enable IPv4 fields if packet is TCP or UDP */
8910 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
8911 /* Enable IPv6 fields if packet is not TCP and not UDP */
8912 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
8913 /* Enable IPv6 fields if packet is TCP or UDP */
8914 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
8915 /* Enable TCP/UDP header fields if packet is IPv4 */
8916 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
8917 /* Enable TCP/UDP header fields if packet is IPv6 */
8918 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
8920 __MLXSW_REG_RECR2_HEADER_CNT,
8923 /* reg_recr2_outer_header_enables
8924 * Bit mask where each bit enables a specific layer to be included in
8925 * the hash calculation.
8928 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
8931 /* IPv4 Source IP */
8932 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
8933 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
8934 /* IPv4 Destination IP */
8935 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
8936 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
8938 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
8939 /* IPv6 Source IP */
8940 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
8941 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
8942 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
8943 /* IPv6 Destination IP */
8944 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
8945 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
8946 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
8947 /* IPv6 Next Header */
8948 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
8949 /* IPv6 Flow Label */
8950 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
8951 /* TCP/UDP Source Port */
8952 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
8953 /* TCP/UDP Destination Port */
8954 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
8956 __MLXSW_REG_RECR2_FIELD_CNT,
8959 /* reg_recr2_outer_header_fields_enable
8960 * Packet fields to enable for ECMP hash subject to outer_header_enable.
8963 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
8965 /* reg_recr2_inner_header_enables
8966 * Bit mask where each bit enables a specific inner layer to be included in the
8967 * hash calculation. Same values as reg_recr2_outer_header_enables.
8970 MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_enables, 0x2C, 0x04, 1);
8973 /* Inner IPv4 Source IP */
8974 MLXSW_REG_RECR2_INNER_IPV4_SIP0 = 3,
8975 MLXSW_REG_RECR2_INNER_IPV4_SIP3 = 6,
8976 /* Inner IPv4 Destination IP */
8977 MLXSW_REG_RECR2_INNER_IPV4_DIP0 = 7,
8978 MLXSW_REG_RECR2_INNER_IPV4_DIP3 = 10,
8979 /* Inner IP Protocol */
8980 MLXSW_REG_RECR2_INNER_IPV4_PROTOCOL = 11,
8981 /* Inner IPv6 Source IP */
8982 MLXSW_REG_RECR2_INNER_IPV6_SIP0_7 = 12,
8983 MLXSW_REG_RECR2_INNER_IPV6_SIP8 = 20,
8984 MLXSW_REG_RECR2_INNER_IPV6_SIP15 = 27,
8985 /* Inner IPv6 Destination IP */
8986 MLXSW_REG_RECR2_INNER_IPV6_DIP0_7 = 28,
8987 MLXSW_REG_RECR2_INNER_IPV6_DIP8 = 36,
8988 MLXSW_REG_RECR2_INNER_IPV6_DIP15 = 43,
8989 /* Inner IPv6 Next Header */
8990 MLXSW_REG_RECR2_INNER_IPV6_NEXT_HEADER = 44,
8991 /* Inner IPv6 Flow Label */
8992 MLXSW_REG_RECR2_INNER_IPV6_FLOW_LABEL = 45,
8993 /* Inner TCP/UDP Source Port */
8994 MLXSW_REG_RECR2_INNER_TCP_UDP_SPORT = 46,
8995 /* Inner TCP/UDP Destination Port */
8996 MLXSW_REG_RECR2_INNER_TCP_UDP_DPORT = 47,
8998 __MLXSW_REG_RECR2_INNER_FIELD_CNT,
9001 /* reg_recr2_inner_header_fields_enable
9002 * Inner packet fields to enable for ECMP hash subject to inner_header_enables.
9005 MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_fields_enable, 0x30, 0x08, 1);
9007 static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
9009 MLXSW_REG_ZERO(recr2, payload);
9010 mlxsw_reg_recr2_pp_set(payload, false);
9011 mlxsw_reg_recr2_sh_set(payload, true);
9012 mlxsw_reg_recr2_seed_set(payload, seed);
9015 /* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
9016 * --------------------------------------------------------------
9017 * The RMFT_V2 register is used to configure and query the multicast table.
9019 #define MLXSW_REG_RMFT2_ID 0x8027
9020 #define MLXSW_REG_RMFT2_LEN 0x174
9022 MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
9028 MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
9030 enum mlxsw_reg_rmft2_type {
9031 MLXSW_REG_RMFT2_TYPE_IPV4,
9032 MLXSW_REG_RMFT2_TYPE_IPV6
9038 MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
9040 enum mlxsw_sp_reg_rmft2_op {
9042 * Write operation. Used to write a new entry to the table. All RW
9043 * fields are relevant for new entry. Activity bit is set for new
9044 * entries - Note write with v (Valid) 0 will delete the entry.
9048 MLXSW_REG_RMFT2_OP_READ_WRITE,
9055 MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
9058 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
9062 MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
9065 * Offset within the multicast forwarding table to write to.
9068 MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
9070 /* reg_rmft2_virtual_router
9071 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
9074 MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
9076 enum mlxsw_reg_rmft2_irif_mask {
9077 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
9078 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
9081 /* reg_rmft2_irif_mask
9085 MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
9088 * Ingress RIF index.
9091 MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
9093 /* reg_rmft2_dip{4,6}
9094 * Destination IPv4/6 address
9097 MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
9098 MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
9100 /* reg_rmft2_dip{4,6}_mask
9101 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
9102 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
9105 MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
9106 MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
9108 /* reg_rmft2_sip{4,6}
9109 * Source IPv4/6 address
9112 MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
9113 MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
9115 /* reg_rmft2_sip{4,6}_mask
9116 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
9117 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
9120 MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
9121 MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
9123 /* reg_rmft2_flexible_action_set
9124 * ACL action set. The only supported action types in this field and in any
9125 * action-set pointed from here are as follows:
9127 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
9130 * 08h: ACTION_POLICING_MONITORING
9131 * 10h: ACTION_ROUTER_MC
9134 MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
9135 MLXSW_REG_FLEX_ACTION_SET_LEN);
9138 mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
9140 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
9141 const char *flex_action_set)
9143 MLXSW_REG_ZERO(rmft2, payload);
9144 mlxsw_reg_rmft2_v_set(payload, v);
9145 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
9146 mlxsw_reg_rmft2_offset_set(payload, offset);
9147 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
9148 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
9149 mlxsw_reg_rmft2_irif_set(payload, irif);
9150 if (flex_action_set)
9151 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
9156 mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
9157 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
9158 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
9159 const char *flexible_action_set)
9161 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
9162 irif_mask, irif, flexible_action_set);
9163 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
9164 mlxsw_reg_rmft2_dip4_set(payload, dip4);
9165 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
9166 mlxsw_reg_rmft2_sip4_set(payload, sip4);
9167 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
9171 mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
9172 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
9173 struct in6_addr dip6, struct in6_addr dip6_mask,
9174 struct in6_addr sip6, struct in6_addr sip6_mask,
9175 const char *flexible_action_set)
9177 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
9178 irif_mask, irif, flexible_action_set);
9179 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
9180 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
9181 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
9182 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
9183 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
9186 /* REIV - Router Egress Interface to VID Register
9187 * ----------------------------------------------
9188 * The REIV register maps {eRIF, egress_port} -> VID.
9189 * This mapping is done at the egress, after the ACLs.
9190 * This mapping always takes effect after router, regardless of cast
9191 * (for unicast/multicast/port-base multicast), regardless of eRIF type and
9192 * regardless of bridge decisions (e.g. SFD for unicast or SMPE).
9193 * Reserved when the RIF is a loopback RIF.
9195 * Note: Reserved when legacy bridge model is used.
9197 #define MLXSW_REG_REIV_ID 0x8034
9198 #define MLXSW_REG_REIV_BASE_LEN 0x20 /* base length, without records */
9199 #define MLXSW_REG_REIV_REC_LEN 0x04 /* record length */
9200 #define MLXSW_REG_REIV_REC_MAX_COUNT 256 /* firmware limitation */
9201 #define MLXSW_REG_REIV_LEN (MLXSW_REG_REIV_BASE_LEN + \
9202 MLXSW_REG_REIV_REC_LEN * \
9203 MLXSW_REG_REIV_REC_MAX_COUNT)
9205 MLXSW_REG_DEFINE(reiv, MLXSW_REG_REIV_ID, MLXSW_REG_REIV_LEN);
9207 /* reg_reiv_port_page
9208 * Port page - elport_record[0] is 256*port_page.
9211 MLXSW_ITEM32(reg, reiv, port_page, 0x00, 0, 4);
9215 * Range is 0..cap_max_router_interfaces-1.
9218 MLXSW_ITEM32(reg, reiv, erif, 0x04, 0, 16);
9220 /* reg_reiv_rec_update
9221 * Update enable (when write):
9222 * 0 - Do not update the entry.
9223 * 1 - Update the entry.
9226 MLXSW_ITEM32_INDEXED(reg, reiv, rec_update, MLXSW_REG_REIV_BASE_LEN, 31, 1,
9227 MLXSW_REG_REIV_REC_LEN, 0x00, false);
9229 /* reg_reiv_rec_evid
9234 MLXSW_ITEM32_INDEXED(reg, reiv, rec_evid, MLXSW_REG_REIV_BASE_LEN, 0, 12,
9235 MLXSW_REG_REIV_REC_LEN, 0x00, false);
9237 static inline void mlxsw_reg_reiv_pack(char *payload, u8 port_page, u16 erif)
9239 MLXSW_REG_ZERO(reiv, payload);
9240 mlxsw_reg_reiv_port_page_set(payload, port_page);
9241 mlxsw_reg_reiv_erif_set(payload, erif);
9244 /* MFCR - Management Fan Control Register
9245 * --------------------------------------
9246 * This register controls the settings of the Fan Speed PWM mechanism.
9248 #define MLXSW_REG_MFCR_ID 0x9001
9249 #define MLXSW_REG_MFCR_LEN 0x08
9251 MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
9253 enum mlxsw_reg_mfcr_pwm_frequency {
9254 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
9255 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
9256 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
9257 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
9258 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
9259 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
9260 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
9261 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
9264 /* reg_mfcr_pwm_frequency
9265 * Controls the frequency of the PWM signal.
9268 MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
9270 #define MLXSW_MFCR_TACHOS_MAX 10
9272 /* reg_mfcr_tacho_active
9273 * Indicates which of the tachometer is active (bit per tachometer).
9276 MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
9278 #define MLXSW_MFCR_PWMS_MAX 5
9280 /* reg_mfcr_pwm_active
9281 * Indicates which of the PWM control is active (bit per PWM).
9284 MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
9287 mlxsw_reg_mfcr_pack(char *payload,
9288 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
9290 MLXSW_REG_ZERO(mfcr, payload);
9291 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
9295 mlxsw_reg_mfcr_unpack(char *payload,
9296 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
9297 u16 *p_tacho_active, u8 *p_pwm_active)
9299 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
9300 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
9301 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
9304 /* MFSC - Management Fan Speed Control Register
9305 * --------------------------------------------
9306 * This register controls the settings of the Fan Speed PWM mechanism.
9308 #define MLXSW_REG_MFSC_ID 0x9002
9309 #define MLXSW_REG_MFSC_LEN 0x08
9311 MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
9314 * Fan pwm to control / monitor.
9317 MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
9319 /* reg_mfsc_pwm_duty_cycle
9320 * Controls the duty cycle of the PWM. Value range from 0..255 to
9321 * represent duty cycle of 0%...100%.
9324 MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
9326 static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
9329 MLXSW_REG_ZERO(mfsc, payload);
9330 mlxsw_reg_mfsc_pwm_set(payload, pwm);
9331 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
9334 /* MFSM - Management Fan Speed Measurement
9335 * ---------------------------------------
9336 * This register controls the settings of the Tacho measurements and
9337 * enables reading the Tachometer measurements.
9339 #define MLXSW_REG_MFSM_ID 0x9003
9340 #define MLXSW_REG_MFSM_LEN 0x08
9342 MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
9345 * Fan tachometer index.
9348 MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
9351 * Fan speed (round per minute).
9354 MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
9356 static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
9358 MLXSW_REG_ZERO(mfsm, payload);
9359 mlxsw_reg_mfsm_tacho_set(payload, tacho);
9362 /* MFSL - Management Fan Speed Limit Register
9363 * ------------------------------------------
9364 * The Fan Speed Limit register is used to configure the fan speed
9365 * event / interrupt notification mechanism. Fan speed threshold are
9366 * defined for both under-speed and over-speed.
9368 #define MLXSW_REG_MFSL_ID 0x9004
9369 #define MLXSW_REG_MFSL_LEN 0x0C
9371 MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
9374 * Fan tachometer index.
9377 MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
9379 /* reg_mfsl_tach_min
9380 * Tachometer minimum value (minimum RPM).
9383 MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
9385 /* reg_mfsl_tach_max
9386 * Tachometer maximum value (maximum RPM).
9389 MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
9391 static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
9392 u16 tach_min, u16 tach_max)
9394 MLXSW_REG_ZERO(mfsl, payload);
9395 mlxsw_reg_mfsl_tacho_set(payload, tacho);
9396 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
9397 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
9400 static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
9401 u16 *p_tach_min, u16 *p_tach_max)
9404 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
9407 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
9410 /* FORE - Fan Out of Range Event Register
9411 * --------------------------------------
9412 * This register reports the status of the controlled fans compared to the
9413 * range defined by the MFSL register.
9415 #define MLXSW_REG_FORE_ID 0x9007
9416 #define MLXSW_REG_FORE_LEN 0x0C
9418 MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
9421 * Fan speed is below the low limit defined in MFSL register. Each bit relates
9422 * to a single tachometer and indicates the specific tachometer reading is
9423 * below the threshold.
9426 MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
9428 static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
9434 limit = mlxsw_reg_fore_fan_under_limit_get(payload);
9435 *fault = limit & BIT(tacho);
9439 /* MTCAP - Management Temperature Capabilities
9440 * -------------------------------------------
9441 * This register exposes the capabilities of the device and
9442 * system temperature sensing.
9444 #define MLXSW_REG_MTCAP_ID 0x9009
9445 #define MLXSW_REG_MTCAP_LEN 0x08
9447 MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
9449 /* reg_mtcap_sensor_count
9450 * Number of sensors supported by the device.
9451 * This includes the QSFP module sensors (if exists in the QSFP module).
9454 MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
9456 /* MTMP - Management Temperature
9457 * -----------------------------
9458 * This register controls the settings of the temperature measurements
9459 * and enables reading the temperature measurements. Note that temperature
9460 * is in 0.125 degrees Celsius.
9462 #define MLXSW_REG_MTMP_ID 0x900A
9463 #define MLXSW_REG_MTMP_LEN 0x20
9465 MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
9467 /* reg_mtmp_slot_index
9468 * Slot index (0: Main board).
9471 MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4);
9473 #define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
9474 #define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
9475 /* reg_mtmp_sensor_index
9476 * Sensors index to access.
9477 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
9478 * (module 0 is mapped to sensor_index 64).
9481 MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
9483 /* Convert to milli degrees Celsius */
9484 #define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
9485 ((v_) >= 0) ? ((v_) * 125) : \
9486 ((s16)((GENMASK(15, 0) + (v_) + 1) \
9489 /* reg_mtmp_max_operational_temperature
9490 * The highest temperature in the nominal operational range. Reading is in
9491 * 0.125 Celsius degrees units.
9492 * In case of module this is SFF critical temperature threshold.
9495 MLXSW_ITEM32(reg, mtmp, max_operational_temperature, 0x04, 16, 16);
9497 /* reg_mtmp_temperature
9498 * Temperature reading from the sensor. Reading is in 0.125 Celsius
9502 MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
9505 * Max Temperature Enable - enables measuring the max temperature on a sensor.
9508 MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
9511 * Max Temperature Reset - clears the value of the max temperature register.
9514 MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
9516 /* reg_mtmp_max_temperature
9517 * The highest measured temperature from the sensor.
9518 * When the bit mte is cleared, the field max_temperature is reserved.
9521 MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
9524 * Temperature Event Enable.
9525 * 0 - Do not generate event
9526 * 1 - Generate event
9527 * 2 - Generate single event
9531 enum mlxsw_reg_mtmp_tee {
9532 MLXSW_REG_MTMP_TEE_NO_EVENT,
9533 MLXSW_REG_MTMP_TEE_GENERATE_EVENT,
9534 MLXSW_REG_MTMP_TEE_GENERATE_SINGLE_EVENT,
9537 MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
9539 #define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
9541 /* reg_mtmp_temperature_threshold_hi
9542 * High threshold for Temperature Warning Event. In 0.125 Celsius.
9545 MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
9547 #define MLXSW_REG_MTMP_HYSTERESIS_TEMP 0x28 /* 5 Celsius */
9548 /* reg_mtmp_temperature_threshold_lo
9549 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
9552 MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
9554 #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
9556 /* reg_mtmp_sensor_name
9560 MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
9562 static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index,
9563 u16 sensor_index, bool max_temp_enable,
9564 bool max_temp_reset)
9566 MLXSW_REG_ZERO(mtmp, payload);
9567 mlxsw_reg_mtmp_slot_index_set(payload, slot_index);
9568 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
9569 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
9570 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
9571 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
9572 MLXSW_REG_MTMP_THRESH_HI);
9575 static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
9576 int *p_max_temp, int *p_temp_hi,
9577 int *p_max_oper_temp,
9583 temp = mlxsw_reg_mtmp_temperature_get(payload);
9584 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9587 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
9588 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9591 temp = mlxsw_reg_mtmp_temperature_threshold_hi_get(payload);
9592 *p_temp_hi = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9594 if (p_max_oper_temp) {
9595 temp = mlxsw_reg_mtmp_max_operational_temperature_get(payload);
9596 *p_max_oper_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9599 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
9602 /* MTWE - Management Temperature Warning Event
9603 * -------------------------------------------
9604 * This register is used for over temperature warning.
9606 #define MLXSW_REG_MTWE_ID 0x900B
9607 #define MLXSW_REG_MTWE_LEN 0x10
9609 MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN);
9611 /* reg_mtwe_sensor_warning
9612 * Bit vector indicating which of the sensor reading is above threshold.
9613 * Address 00h bit31 is sensor_warning[127].
9614 * Address 0Ch bit0 is sensor_warning[0].
9617 MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
9619 /* MTBR - Management Temperature Bulk Register
9620 * -------------------------------------------
9621 * This register is used for bulk temperature reading.
9623 #define MLXSW_REG_MTBR_ID 0x900F
9624 #define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */
9625 #define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */
9626 #define MLXSW_REG_MTBR_REC_MAX_COUNT 1
9627 #define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
9628 MLXSW_REG_MTBR_REC_LEN * \
9629 MLXSW_REG_MTBR_REC_MAX_COUNT)
9631 MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
9633 /* reg_mtbr_slot_index
9634 * Slot index (0: Main board).
9637 MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4);
9639 /* reg_mtbr_base_sensor_index
9640 * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
9641 * 64-127 are mapped to the SFP+/QSFP modules sequentially).
9644 MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
9647 * Request: Number of records to read
9648 * Response: Number of records read
9649 * See above description for more details.
9653 MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
9655 /* reg_mtbr_rec_max_temp
9656 * The highest measured temperature from the sensor.
9657 * When the bit mte is cleared, the field max_temperature is reserved.
9660 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
9661 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
9663 /* reg_mtbr_rec_temp
9664 * Temperature reading from the sensor. Reading is in 0..125 Celsius
9668 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
9669 MLXSW_REG_MTBR_REC_LEN, 0x00, false);
9671 static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index,
9672 u16 base_sensor_index)
9674 MLXSW_REG_ZERO(mtbr, payload);
9675 mlxsw_reg_mtbr_slot_index_set(payload, slot_index);
9676 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
9677 mlxsw_reg_mtbr_num_rec_set(payload, 1);
9680 /* Error codes from temperatute reading */
9681 enum mlxsw_reg_mtbr_temp_status {
9682 MLXSW_REG_MTBR_NO_CONN = 0x8000,
9683 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
9684 MLXSW_REG_MTBR_INDEX_NA = 0x8002,
9685 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
9688 /* Base index for reading modules temperature */
9689 #define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
9691 static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
9692 u16 *p_temp, u16 *p_max_temp)
9695 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
9697 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
9700 /* MCIA - Management Cable Info Access
9701 * -----------------------------------
9702 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
9705 #define MLXSW_REG_MCIA_ID 0x9014
9706 #define MLXSW_REG_MCIA_LEN 0x94
9708 MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
9714 MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
9716 /* reg_mcia_slot_index
9717 * Slot index (0: Main board)
9720 MLXSW_ITEM32(reg, mcia, slot, 0x00, 12, 4);
9723 MLXSW_REG_MCIA_STATUS_GOOD = 0,
9724 /* No response from module's EEPROM. */
9725 MLXSW_REG_MCIA_STATUS_NO_EEPROM_MODULE = 1,
9726 /* Module type not supported by the device. */
9727 MLXSW_REG_MCIA_STATUS_MODULE_NOT_SUPPORTED = 2,
9728 /* No module present indication. */
9729 MLXSW_REG_MCIA_STATUS_MODULE_NOT_CONNECTED = 3,
9730 /* Error occurred while trying to access module's EEPROM using I2C. */
9731 MLXSW_REG_MCIA_STATUS_I2C_ERROR = 9,
9732 /* Module is disabled. */
9733 MLXSW_REG_MCIA_STATUS_MODULE_DISABLED = 16,
9740 MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
9742 /* reg_mcia_i2c_device_address
9743 * I2C device address.
9746 MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
9748 /* reg_mcia_page_number
9752 MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
9754 /* reg_mcia_device_address
9758 MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
9760 /* reg_mcia_bank_number
9764 MLXSW_ITEM32(reg, mcia, bank_number, 0x08, 16, 8);
9767 * Number of bytes to read/write (up to 48 bytes).
9770 MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
9772 #define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
9773 #define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
9774 #define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
9775 #define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
9776 #define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
9777 #define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
9778 #define MLXSW_REG_MCIA_TH_PAGE_NUM 3
9779 #define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
9780 #define MLXSW_REG_MCIA_PAGE0_LO 0
9781 #define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
9782 #define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
9784 enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
9785 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
9786 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
9787 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
9790 enum mlxsw_reg_mcia_eeprom_module_info_id {
9791 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
9792 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
9793 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
9794 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
9795 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
9796 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP = 0x19,
9799 enum mlxsw_reg_mcia_eeprom_module_info {
9800 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
9801 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
9802 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
9803 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
9807 * Bytes to read/write.
9810 MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, 128);
9812 /* This is used to access the optional upper pages (1-3) in the QSFP+
9813 * memory map. Page 1 is available on offset 256 through 383, page 2 -
9814 * on offset 384 through 511, page 3 - on offset 512 through 639.
9816 #define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
9817 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
9818 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
9820 static inline void mlxsw_reg_mcia_pack(char *payload, u8 slot_index, u8 module,
9821 u8 page_number, u16 device_addr, u8 size,
9824 MLXSW_REG_ZERO(mcia, payload);
9825 mlxsw_reg_mcia_slot_set(payload, slot_index);
9826 mlxsw_reg_mcia_module_set(payload, module);
9827 mlxsw_reg_mcia_page_number_set(payload, page_number);
9828 mlxsw_reg_mcia_device_address_set(payload, device_addr);
9829 mlxsw_reg_mcia_size_set(payload, size);
9830 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
9833 /* MPAT - Monitoring Port Analyzer Table
9834 * -------------------------------------
9835 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
9836 * For an enabled analyzer, all fields except e (enable) cannot be modified.
9838 #define MLXSW_REG_MPAT_ID 0x901A
9839 #define MLXSW_REG_MPAT_LEN 0x78
9841 MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
9847 MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
9849 /* reg_mpat_session_id
9850 * Mirror Session ID.
9851 * Used for MIRROR_SESSION<i> trap.
9854 MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4);
9856 /* reg_mpat_system_port
9857 * A unique port identifier for the final destination of the packet.
9860 MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
9863 * Enable. Indicating the Port Analyzer is enabled.
9866 MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
9869 * Quality Of Service Mode.
9870 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
9871 * PCP, DEI, DSCP or VL) are configured.
9872 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
9873 * same as in the original packet that has triggered the mirroring. For
9874 * SPAN also the pcp,dei are maintained.
9877 MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
9880 * Best effort mode. Indicates mirroring traffic should not cause packet
9881 * drop or back pressure, but will discard the mirrored packets. Mirrored
9882 * packets will be forwarded on a best effort manner.
9883 * 0: Do not discard mirrored packets
9884 * 1: Discard mirrored packets if causing congestion
9887 MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
9889 enum mlxsw_reg_mpat_span_type {
9890 /* Local SPAN Ethernet.
9891 * The original packet is not encapsulated.
9893 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
9895 /* Remote SPAN Ethernet VLAN.
9896 * The packet is forwarded to the monitoring port on the monitoring
9899 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
9901 /* Encapsulated Remote SPAN Ethernet L3 GRE.
9902 * The packet is encapsulated with GRE header.
9904 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
9907 /* reg_mpat_span_type
9911 MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
9917 MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1);
9923 MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14);
9925 /* Remote SPAN - Ethernet VLAN
9926 * - - - - - - - - - - - - - -
9929 /* reg_mpat_eth_rspan_vid
9930 * Encapsulation header VLAN ID.
9933 MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
9935 /* Encapsulated Remote SPAN - Ethernet L2
9936 * - - - - - - - - - - - - - - - - - - -
9939 enum mlxsw_reg_mpat_eth_rspan_version {
9940 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
9943 /* reg_mpat_eth_rspan_version
9944 * RSPAN mirror header version.
9947 MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
9949 /* reg_mpat_eth_rspan_mac
9950 * Destination MAC address.
9953 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
9955 /* reg_mpat_eth_rspan_tp
9956 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
9959 MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
9961 /* Encapsulated Remote SPAN - Ethernet L3
9962 * - - - - - - - - - - - - - - - - - - -
9965 enum mlxsw_reg_mpat_eth_rspan_protocol {
9966 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
9967 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
9970 /* reg_mpat_eth_rspan_protocol
9971 * SPAN encapsulation protocol.
9974 MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
9976 /* reg_mpat_eth_rspan_ttl
9977 * Encapsulation header Time-to-Live/HopLimit.
9980 MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
9982 /* reg_mpat_eth_rspan_smac
9983 * Source MAC address
9986 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
9988 /* reg_mpat_eth_rspan_dip*
9989 * Destination IP address. The IP version is configured by protocol.
9992 MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
9993 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
9995 /* reg_mpat_eth_rspan_sip*
9996 * Source IP address. The IP version is configured by protocol.
9999 MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
10000 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
10002 static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
10003 u16 system_port, bool e,
10004 enum mlxsw_reg_mpat_span_type span_type)
10006 MLXSW_REG_ZERO(mpat, payload);
10007 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
10008 mlxsw_reg_mpat_system_port_set(payload, system_port);
10009 mlxsw_reg_mpat_e_set(payload, e);
10010 mlxsw_reg_mpat_qos_set(payload, 1);
10011 mlxsw_reg_mpat_be_set(payload, 1);
10012 mlxsw_reg_mpat_span_type_set(payload, span_type);
10015 static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
10017 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
10021 mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
10022 enum mlxsw_reg_mpat_eth_rspan_version version,
10026 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
10027 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
10028 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
10032 mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
10036 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
10037 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
10038 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
10039 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
10040 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
10041 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
10045 mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
10047 struct in6_addr sip, struct in6_addr dip)
10049 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
10050 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
10051 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
10052 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
10053 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
10054 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
10057 /* MPAR - Monitoring Port Analyzer Register
10058 * ----------------------------------------
10059 * MPAR register is used to query and configure the port analyzer port mirroring
10062 #define MLXSW_REG_MPAR_ID 0x901B
10063 #define MLXSW_REG_MPAR_LEN 0x0C
10065 MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
10067 /* reg_mpar_local_port
10068 * The local port to mirror the packets from.
10071 MLXSW_ITEM32_LP(reg, mpar, 0x00, 16, 0x00, 4);
10073 enum mlxsw_reg_mpar_i_e {
10074 MLXSW_REG_MPAR_TYPE_EGRESS,
10075 MLXSW_REG_MPAR_TYPE_INGRESS,
10082 MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
10086 * By default, port mirroring is disabled for all ports.
10089 MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
10092 * Port Analyzer ID.
10095 MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
10097 #define MLXSW_REG_MPAR_RATE_MAX 3500000000UL
10099 /* reg_mpar_probability_rate
10101 * Valid values are: 1 to 3.5*10^9
10102 * Value of 1 means "sample all". Default is 1.
10103 * Reserved when Spectrum-1.
10106 MLXSW_ITEM32(reg, mpar, probability_rate, 0x08, 0, 32);
10108 static inline void mlxsw_reg_mpar_pack(char *payload, u16 local_port,
10109 enum mlxsw_reg_mpar_i_e i_e,
10110 bool enable, u8 pa_id,
10111 u32 probability_rate)
10113 MLXSW_REG_ZERO(mpar, payload);
10114 mlxsw_reg_mpar_local_port_set(payload, local_port);
10115 mlxsw_reg_mpar_enable_set(payload, enable);
10116 mlxsw_reg_mpar_i_e_set(payload, i_e);
10117 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
10118 mlxsw_reg_mpar_probability_rate_set(payload, probability_rate);
10121 /* MGIR - Management General Information Register
10122 * ----------------------------------------------
10123 * MGIR register allows software to query the hardware and firmware general
10126 #define MLXSW_REG_MGIR_ID 0x9020
10127 #define MLXSW_REG_MGIR_LEN 0x9C
10129 MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
10131 /* reg_mgir_hw_info_device_hw_revision
10134 MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
10136 /* reg_mgir_fw_info_latency_tlv
10137 * When set, latency-TLV is supported.
10140 MLXSW_ITEM32(reg, mgir, fw_info_latency_tlv, 0x20, 29, 1);
10142 /* reg_mgir_fw_info_string_tlv
10143 * When set, string-TLV is supported.
10146 MLXSW_ITEM32(reg, mgir, fw_info_string_tlv, 0x20, 28, 1);
10148 #define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
10150 /* reg_mgir_fw_info_psid
10151 * PSID (ASCII string).
10154 MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
10156 /* reg_mgir_fw_info_extended_major
10159 MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
10161 /* reg_mgir_fw_info_extended_minor
10164 MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
10166 /* reg_mgir_fw_info_extended_sub_minor
10169 MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
10171 static inline void mlxsw_reg_mgir_pack(char *payload)
10173 MLXSW_REG_ZERO(mgir, payload);
10177 mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
10178 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
10180 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
10181 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
10182 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
10183 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
10184 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
10187 /* MRSR - Management Reset and Shutdown Register
10188 * ---------------------------------------------
10189 * MRSR register is used to reset or shutdown the switch or
10190 * the entire system (when applicable).
10192 #define MLXSW_REG_MRSR_ID 0x9023
10193 #define MLXSW_REG_MRSR_LEN 0x08
10195 MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
10197 enum mlxsw_reg_mrsr_command {
10198 /* Switch soft reset, does not reset PCI firmware. */
10199 MLXSW_REG_MRSR_COMMAND_SOFTWARE_RESET = 1,
10200 /* Reset will be done when PCI link will be disabled.
10201 * This command will reset PCI firmware also.
10203 MLXSW_REG_MRSR_COMMAND_RESET_AT_PCI_DISABLE = 6,
10206 /* reg_mrsr_command
10207 * Reset/shutdown command
10209 * 1 - software reset
10212 MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
10214 static inline void mlxsw_reg_mrsr_pack(char *payload,
10215 enum mlxsw_reg_mrsr_command command)
10217 MLXSW_REG_ZERO(mrsr, payload);
10218 mlxsw_reg_mrsr_command_set(payload, command);
10221 /* MLCR - Management LED Control Register
10222 * --------------------------------------
10223 * Controls the system LEDs.
10225 #define MLXSW_REG_MLCR_ID 0x902B
10226 #define MLXSW_REG_MLCR_LEN 0x0C
10228 MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
10230 /* reg_mlcr_local_port
10231 * Local port number.
10234 MLXSW_ITEM32_LP(reg, mlcr, 0x00, 16, 0x00, 24);
10236 #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
10238 /* reg_mlcr_beacon_duration
10239 * Duration of the beacon to be active, in seconds.
10240 * 0x0 - Will turn off the beacon.
10241 * 0xFFFF - Will turn on the beacon until explicitly turned off.
10244 MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
10246 /* reg_mlcr_beacon_remain
10247 * Remaining duration of the beacon, in seconds.
10248 * 0xFFFF indicates an infinite amount of time.
10251 MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
10253 static inline void mlxsw_reg_mlcr_pack(char *payload, u16 local_port,
10256 MLXSW_REG_ZERO(mlcr, payload);
10257 mlxsw_reg_mlcr_local_port_set(payload, local_port);
10258 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
10259 MLXSW_REG_MLCR_DURATION_MAX : 0);
10262 /* MCION - Management Cable IO and Notifications Register
10263 * ------------------------------------------------------
10264 * The MCION register is used to query transceiver modules' IO pins and other
10267 #define MLXSW_REG_MCION_ID 0x9052
10268 #define MLXSW_REG_MCION_LEN 0x18
10270 MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN);
10272 /* reg_mcion_module
10276 MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8);
10278 /* reg_mcion_slot_index
10282 MLXSW_ITEM32(reg, mcion, slot_index, 0x00, 12, 4);
10285 MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0),
10286 MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8),
10289 /* reg_mcion_module_status_bits
10290 * Module IO status as defined by SFF.
10293 MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16);
10295 static inline void mlxsw_reg_mcion_pack(char *payload, u8 slot_index, u8 module)
10297 MLXSW_REG_ZERO(mcion, payload);
10298 mlxsw_reg_mcion_slot_index_set(payload, slot_index);
10299 mlxsw_reg_mcion_module_set(payload, module);
10302 /* MTPPS - Management Pulse Per Second Register
10303 * --------------------------------------------
10304 * This register provides the device PPS capabilities, configure the PPS in and
10305 * out modules and holds the PPS in time stamp.
10307 #define MLXSW_REG_MTPPS_ID 0x9053
10308 #define MLXSW_REG_MTPPS_LEN 0x3C
10310 MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
10312 /* reg_mtpps_enable
10313 * Enables the PPS functionality the specific pin.
10314 * A boolean variable.
10317 MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
10319 enum mlxsw_reg_mtpps_pin_mode {
10320 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
10323 /* reg_mtpps_pin_mode
10324 * Pin mode to be used. The mode must comply with the supported modes of the
10328 MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
10330 #define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
10333 * Pin to be configured or queried out of the supported pins.
10336 MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
10338 /* reg_mtpps_time_stamp
10339 * When pin_mode = pps_in, the latched device time when it was triggered from
10340 * the external GPIO pin.
10341 * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target
10342 * time to generate next output signal.
10343 * Time is in units of device clock.
10346 MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
10349 mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
10351 MLXSW_REG_ZERO(mtpps, payload);
10352 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
10353 mlxsw_reg_mtpps_pin_mode_set(payload,
10354 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
10355 mlxsw_reg_mtpps_enable_set(payload, true);
10356 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
10359 /* MTUTC - Management UTC Register
10360 * -------------------------------
10361 * Configures the HW UTC counter.
10363 #define MLXSW_REG_MTUTC_ID 0x9055
10364 #define MLXSW_REG_MTUTC_LEN 0x1C
10366 MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
10368 enum mlxsw_reg_mtutc_operation {
10369 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
10370 MLXSW_REG_MTUTC_OPERATION_SET_TIME_IMMEDIATE = 1,
10371 MLXSW_REG_MTUTC_OPERATION_ADJUST_TIME = 2,
10372 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
10375 /* reg_mtutc_operation
10379 MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
10381 /* reg_mtutc_freq_adjustment
10382 * Frequency adjustment: Every PPS the HW frequency will be
10383 * adjusted by this value. Units of HW clock, where HW counts
10384 * 10^9 HW clocks for 1 HW second. Range is from -50,000,000 to +50,000,000.
10385 * In Spectrum-2, the field is reversed, positive values mean to decrease the
10389 MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
10391 #define MLXSW_REG_MTUTC_MAX_FREQ_ADJ (50 * 1000 * 1000)
10393 /* reg_mtutc_utc_sec
10397 MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
10399 /* reg_mtutc_utc_nsec
10401 * Range 0..(10^9-1)
10402 * Updated when operation is SET_TIME_IMMEDIATE.
10403 * Reserved on Spectrum-1.
10406 MLXSW_ITEM32(reg, mtutc, utc_nsec, 0x14, 0, 30);
10408 /* reg_mtutc_time_adjustment
10411 * Range is from -32768 to +32767.
10412 * Updated when operation is ADJUST_TIME.
10413 * Reserved on Spectrum-1.
10416 MLXSW_ITEM32(reg, mtutc, time_adjustment, 0x18, 0, 32);
10419 mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
10420 u32 freq_adj, u32 utc_sec, u32 utc_nsec, u32 time_adj)
10422 MLXSW_REG_ZERO(mtutc, payload);
10423 mlxsw_reg_mtutc_operation_set(payload, oper);
10424 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
10425 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
10426 mlxsw_reg_mtutc_utc_nsec_set(payload, utc_nsec);
10427 mlxsw_reg_mtutc_time_adjustment_set(payload, time_adj);
10430 /* MCQI - Management Component Query Information
10431 * ---------------------------------------------
10432 * This register allows querying information about firmware components.
10434 #define MLXSW_REG_MCQI_ID 0x9061
10435 #define MLXSW_REG_MCQI_BASE_LEN 0x18
10436 #define MLXSW_REG_MCQI_CAP_LEN 0x14
10437 #define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
10439 MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
10441 /* reg_mcqi_component_index
10442 * Index of the accessed component.
10445 MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
10447 enum mlxfw_reg_mcqi_info_type {
10448 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
10451 /* reg_mcqi_info_type
10452 * Component properties set.
10455 MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
10458 * The requested/returned data offset from the section start, given in bytes.
10459 * Must be DWORD aligned.
10462 MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
10464 /* reg_mcqi_data_size
10465 * The requested/returned data size, given in bytes. If data_size is not DWORD
10466 * aligned, the last bytes are zero padded.
10469 MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
10471 /* reg_mcqi_cap_max_component_size
10472 * Maximum size for this component, given in bytes.
10475 MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
10477 /* reg_mcqi_cap_log_mcda_word_size
10478 * Log 2 of the access word size in bytes. Read and write access must be aligned
10479 * to the word size. Write access must be done for an integer number of words.
10482 MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
10484 /* reg_mcqi_cap_mcda_max_write_size
10485 * Maximal write size for MCDA register
10488 MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
10490 static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
10492 MLXSW_REG_ZERO(mcqi, payload);
10493 mlxsw_reg_mcqi_component_index_set(payload, component_index);
10494 mlxsw_reg_mcqi_info_type_set(payload,
10495 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
10496 mlxsw_reg_mcqi_offset_set(payload, 0);
10497 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
10500 static inline void mlxsw_reg_mcqi_unpack(char *payload,
10501 u32 *p_cap_max_component_size,
10502 u8 *p_cap_log_mcda_word_size,
10503 u16 *p_cap_mcda_max_write_size)
10505 *p_cap_max_component_size =
10506 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
10507 *p_cap_log_mcda_word_size =
10508 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
10509 *p_cap_mcda_max_write_size =
10510 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
10513 /* MCC - Management Component Control
10514 * ----------------------------------
10515 * Controls the firmware component and updates the FSM.
10517 #define MLXSW_REG_MCC_ID 0x9062
10518 #define MLXSW_REG_MCC_LEN 0x1C
10520 MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
10522 enum mlxsw_reg_mcc_instruction {
10523 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
10524 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
10525 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
10526 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
10527 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
10528 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
10531 /* reg_mcc_instruction
10532 * Command to be executed by the FSM.
10533 * Applicable for write operation only.
10536 MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
10538 /* reg_mcc_component_index
10539 * Index of the accessed component. Applicable only for commands that
10540 * refer to components. Otherwise, this field is reserved.
10543 MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
10545 /* reg_mcc_update_handle
10546 * Token representing the current flow executed by the FSM.
10549 MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
10551 /* reg_mcc_error_code
10552 * Indicates the successful completion of the instruction, or the reason it
10556 MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
10558 /* reg_mcc_control_state
10559 * Current FSM state
10562 MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
10564 /* reg_mcc_component_size
10565 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
10566 * the size may shorten the update time. Value 0x0 means that size is
10570 MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
10572 static inline void mlxsw_reg_mcc_pack(char *payload,
10573 enum mlxsw_reg_mcc_instruction instr,
10574 u16 component_index, u32 update_handle,
10575 u32 component_size)
10577 MLXSW_REG_ZERO(mcc, payload);
10578 mlxsw_reg_mcc_instruction_set(payload, instr);
10579 mlxsw_reg_mcc_component_index_set(payload, component_index);
10580 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
10581 mlxsw_reg_mcc_component_size_set(payload, component_size);
10584 static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
10585 u8 *p_error_code, u8 *p_control_state)
10587 if (p_update_handle)
10588 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
10590 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
10591 if (p_control_state)
10592 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
10595 /* MCDA - Management Component Data Access
10596 * ---------------------------------------
10597 * This register allows reading and writing a firmware component.
10599 #define MLXSW_REG_MCDA_ID 0x9063
10600 #define MLXSW_REG_MCDA_BASE_LEN 0x10
10601 #define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
10602 #define MLXSW_REG_MCDA_LEN \
10603 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
10605 MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
10607 /* reg_mcda_update_handle
10608 * Token representing the current flow executed by the FSM.
10611 MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
10614 * Offset of accessed address relative to component start. Accesses must be in
10615 * accordance to log_mcda_word_size in MCQI reg.
10618 MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
10621 * Size of the data accessed, given in bytes.
10624 MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
10627 * Data block accessed.
10630 MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
10632 static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
10633 u32 offset, u16 size, u8 *data)
10637 MLXSW_REG_ZERO(mcda, payload);
10638 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
10639 mlxsw_reg_mcda_offset_set(payload, offset);
10640 mlxsw_reg_mcda_size_set(payload, size);
10642 for (i = 0; i < size / 4; i++)
10643 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
10646 /* MCAM - Management Capabilities Mask Register
10647 * --------------------------------------------
10648 * Reports the device supported management features.
10650 #define MLXSW_REG_MCAM_ID 0x907F
10651 #define MLXSW_REG_MCAM_LEN 0x48
10653 MLXSW_REG_DEFINE(mcam, MLXSW_REG_MCAM_ID, MLXSW_REG_MCAM_LEN);
10655 enum mlxsw_reg_mcam_feature_group {
10656 /* Enhanced features. */
10657 MLXSW_REG_MCAM_FEATURE_GROUP_ENHANCED_FEATURES,
10660 /* reg_mcam_feature_group
10661 * Feature list mask index.
10664 MLXSW_ITEM32(reg, mcam, feature_group, 0x00, 16, 8);
10666 enum mlxsw_reg_mcam_mng_feature_cap_mask_bits {
10667 /* If set, MCIA supports 128 bytes payloads. Otherwise, 48 bytes. */
10668 MLXSW_REG_MCAM_MCIA_128B = 34,
10669 /* If set, MRSR.command=6 is supported. */
10670 MLXSW_REG_MCAM_PCI_RESET = 48,
10673 #define MLXSW_REG_BYTES_PER_DWORD 0x4
10675 /* reg_mcam_mng_feature_cap_mask
10676 * Supported port's enhanced features.
10677 * Based on feature_group index.
10678 * When bit is set, the feature is supported in the device.
10681 #define MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(_dw_num, _offset) \
10682 MLXSW_ITEM_BIT_ARRAY(reg, mcam, mng_feature_cap_mask_dw##_dw_num, \
10683 _offset, MLXSW_REG_BYTES_PER_DWORD, 1)
10685 /* The access to the bits in the field 'mng_feature_cap_mask' is not same to
10686 * other mask fields in other registers. In most of the cases bit #0 is the
10687 * first one in the last dword. In MCAM register, the first dword contains bits
10688 * #0-#31 and so on, so the access to the bits is simpler using bit array per
10689 * dword. Declare each dword of 'mng_feature_cap_mask' field separately.
10691 MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(0, 0x28);
10692 MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(1, 0x2C);
10693 MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(2, 0x30);
10694 MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(3, 0x34);
10697 mlxsw_reg_mcam_pack(char *payload, enum mlxsw_reg_mcam_feature_group feat_group)
10699 MLXSW_REG_ZERO(mcam, payload);
10700 mlxsw_reg_mcam_feature_group_set(payload, feat_group);
10704 mlxsw_reg_mcam_unpack(char *payload,
10705 enum mlxsw_reg_mcam_mng_feature_cap_mask_bits bit,
10706 bool *p_mng_feature_cap_val)
10708 int offset = bit % (MLXSW_REG_BYTES_PER_DWORD * BITS_PER_BYTE);
10709 int dword = bit / (MLXSW_REG_BYTES_PER_DWORD * BITS_PER_BYTE);
10710 u8 (*getters[])(const char *, u16) = {
10711 mlxsw_reg_mcam_mng_feature_cap_mask_dw0_get,
10712 mlxsw_reg_mcam_mng_feature_cap_mask_dw1_get,
10713 mlxsw_reg_mcam_mng_feature_cap_mask_dw2_get,
10714 mlxsw_reg_mcam_mng_feature_cap_mask_dw3_get,
10717 if (!WARN_ON_ONCE(dword >= ARRAY_SIZE(getters)))
10718 *p_mng_feature_cap_val = getters[dword](payload, offset);
10721 /* MPSC - Monitoring Packet Sampling Configuration Register
10722 * --------------------------------------------------------
10723 * MPSC Register is used to configure the Packet Sampling mechanism.
10725 #define MLXSW_REG_MPSC_ID 0x9080
10726 #define MLXSW_REG_MPSC_LEN 0x1C
10728 MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
10730 /* reg_mpsc_local_port
10731 * Local port number
10732 * Not supported for CPU port
10735 MLXSW_ITEM32_LP(reg, mpsc, 0x00, 16, 0x00, 12);
10738 * Enable sampling on port local_port
10741 MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
10743 #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
10746 * Sampling rate = 1 out of rate packets (with randomization around
10747 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
10750 MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
10752 static inline void mlxsw_reg_mpsc_pack(char *payload, u16 local_port, bool e,
10755 MLXSW_REG_ZERO(mpsc, payload);
10756 mlxsw_reg_mpsc_local_port_set(payload, local_port);
10757 mlxsw_reg_mpsc_e_set(payload, e);
10758 mlxsw_reg_mpsc_rate_set(payload, rate);
10761 /* MGPC - Monitoring General Purpose Counter Set Register
10762 * The MGPC register retrieves and sets the General Purpose Counter Set.
10764 #define MLXSW_REG_MGPC_ID 0x9081
10765 #define MLXSW_REG_MGPC_LEN 0x18
10767 MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
10769 /* reg_mgpc_counter_set_type
10770 * Counter set type.
10773 MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
10775 /* reg_mgpc_counter_index
10779 MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
10781 enum mlxsw_reg_mgpc_opcode {
10783 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
10784 /* Clear counters */
10785 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
10792 MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
10794 /* reg_mgpc_byte_counter
10795 * Byte counter value.
10798 MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
10800 /* reg_mgpc_packet_counter
10801 * Packet counter value.
10804 MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
10806 static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
10807 enum mlxsw_reg_mgpc_opcode opcode,
10808 enum mlxsw_reg_flow_counter_set_type set_type)
10810 MLXSW_REG_ZERO(mgpc, payload);
10811 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
10812 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
10813 mlxsw_reg_mgpc_opcode_set(payload, opcode);
10816 /* MPRS - Monitoring Parsing State Register
10817 * ----------------------------------------
10818 * The MPRS register is used for setting up the parsing for hash,
10819 * policy-engine and routing.
10821 #define MLXSW_REG_MPRS_ID 0x9083
10822 #define MLXSW_REG_MPRS_LEN 0x14
10824 MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
10826 /* reg_mprs_parsing_depth
10827 * Minimum parsing depth.
10828 * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL
10829 * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2.
10832 MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
10834 /* reg_mprs_parsing_en
10836 * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and
10837 * NVGRE. Default is enabled. Reserved when SwitchX-2.
10840 MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
10842 /* reg_mprs_vxlan_udp_dport
10843 * VxLAN UDP destination port.
10844 * Used for identifying VxLAN packets and for dport field in
10845 * encapsulation. Default is 4789.
10848 MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
10850 static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
10851 u16 vxlan_udp_dport)
10853 MLXSW_REG_ZERO(mprs, payload);
10854 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
10855 mlxsw_reg_mprs_parsing_en_set(payload, true);
10856 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
10859 /* MOGCR - Monitoring Global Configuration Register
10860 * ------------------------------------------------
10862 #define MLXSW_REG_MOGCR_ID 0x9086
10863 #define MLXSW_REG_MOGCR_LEN 0x20
10865 MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
10867 /* reg_mogcr_ptp_iftc
10868 * PTP Ingress FIFO Trap Clear
10869 * The PTP_ING_FIFO trap provides MTPPTR with clr according
10870 * to this value. Default 0.
10871 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
10874 MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
10876 /* reg_mogcr_ptp_eftc
10877 * PTP Egress FIFO Trap Clear
10878 * The PTP_EGR_FIFO trap provides MTPPTR with clr according
10879 * to this value. Default 0.
10880 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
10883 MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
10885 /* reg_mogcr_mirroring_pid_base
10886 * Base policer id for mirroring policers.
10887 * Must have an even value (e.g. 1000, not 1001).
10888 * Reserved when SwitchX/-2, Switch-IB/2, Spectrum-1 and Quantum.
10891 MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14);
10893 /* MPAGR - Monitoring Port Analyzer Global Register
10894 * ------------------------------------------------
10895 * This register is used for global port analyzer configurations.
10896 * Note: This register is not supported by current FW versions for Spectrum-1.
10898 #define MLXSW_REG_MPAGR_ID 0x9089
10899 #define MLXSW_REG_MPAGR_LEN 0x0C
10901 MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN);
10903 enum mlxsw_reg_mpagr_trigger {
10904 MLXSW_REG_MPAGR_TRIGGER_EGRESS,
10905 MLXSW_REG_MPAGR_TRIGGER_INGRESS,
10906 MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED,
10907 MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER,
10908 MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG,
10909 MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG,
10910 MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN,
10911 MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY,
10914 /* reg_mpagr_trigger
10918 MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4);
10921 * Port analyzer ID.
10924 MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4);
10926 #define MLXSW_REG_MPAGR_RATE_MAX 3500000000UL
10928 /* reg_mpagr_probability_rate
10930 * Valid values are: 1 to 3.5*10^9
10931 * Value of 1 means "sample all". Default is 1.
10934 MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32);
10936 static inline void mlxsw_reg_mpagr_pack(char *payload,
10937 enum mlxsw_reg_mpagr_trigger trigger,
10938 u8 pa_id, u32 probability_rate)
10940 MLXSW_REG_ZERO(mpagr, payload);
10941 mlxsw_reg_mpagr_trigger_set(payload, trigger);
10942 mlxsw_reg_mpagr_pa_id_set(payload, pa_id);
10943 mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate);
10946 /* MOMTE - Monitoring Mirror Trigger Enable Register
10947 * -------------------------------------------------
10948 * This register is used to configure the mirror enable for different mirror
10951 #define MLXSW_REG_MOMTE_ID 0x908D
10952 #define MLXSW_REG_MOMTE_LEN 0x10
10954 MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN);
10956 /* reg_momte_local_port
10957 * Local port number.
10960 MLXSW_ITEM32_LP(reg, momte, 0x00, 16, 0x00, 12);
10962 enum mlxsw_reg_momte_type {
10963 MLXSW_REG_MOMTE_TYPE_WRED = 0x20,
10964 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31,
10965 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32,
10966 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33,
10967 MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40,
10968 MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50,
10969 MLXSW_REG_MOMTE_TYPE_ECN = 0x60,
10970 MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70,
10974 * Type of mirroring.
10977 MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
10979 /* reg_momte_tclass_en
10980 * TClass/PG mirror enable. Each bit represents corresponding tclass.
10981 * 0: disable (default)
10985 MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
10987 static inline void mlxsw_reg_momte_pack(char *payload, u16 local_port,
10988 enum mlxsw_reg_momte_type type)
10990 MLXSW_REG_ZERO(momte, payload);
10991 mlxsw_reg_momte_local_port_set(payload, local_port);
10992 mlxsw_reg_momte_type_set(payload, type);
10995 /* MTPPPC - Time Precision Packet Port Configuration
10996 * -------------------------------------------------
10997 * This register serves for configuration of which PTP messages should be
10998 * timestamped. This is a global configuration, despite the register name.
11000 * Reserved when Spectrum-2.
11002 #define MLXSW_REG_MTPPPC_ID 0x9090
11003 #define MLXSW_REG_MTPPPC_LEN 0x28
11005 MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
11007 /* reg_mtpppc_ing_timestamp_message_type
11008 * Bitwise vector of PTP message types to timestamp at ingress.
11009 * MessageType field as defined by IEEE 1588
11010 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
11014 MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
11016 /* reg_mtpppc_egr_timestamp_message_type
11017 * Bitwise vector of PTP message types to timestamp at egress.
11018 * MessageType field as defined by IEEE 1588
11019 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
11023 MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
11025 static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
11027 MLXSW_REG_ZERO(mtpppc, payload);
11028 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
11029 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
11032 /* MTPPTR - Time Precision Packet Timestamping Reading
11033 * ---------------------------------------------------
11034 * The MTPPTR is used for reading the per port PTP timestamp FIFO.
11035 * There is a trap for packets which are latched to the timestamp FIFO, thus the
11036 * SW knows which FIFO to read. Note that packets enter the FIFO before been
11037 * trapped. The sequence number is used to synchronize the timestamp FIFO
11038 * entries and the trapped packets.
11039 * Reserved when Spectrum-2.
11042 #define MLXSW_REG_MTPPTR_ID 0x9091
11043 #define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */
11044 #define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */
11045 #define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
11046 #define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
11047 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
11049 MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
11051 /* reg_mtpptr_local_port
11052 * Not supported for CPU port.
11055 MLXSW_ITEM32_LP(reg, mtpptr, 0x00, 16, 0x00, 12);
11057 enum mlxsw_reg_mtpptr_dir {
11058 MLXSW_REG_MTPPTR_DIR_INGRESS,
11059 MLXSW_REG_MTPPTR_DIR_EGRESS,
11066 MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
11069 * Clear the records.
11072 MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
11074 /* reg_mtpptr_num_rec
11075 * Number of valid records in the response
11076 * Range 0.. cap_ptp_timestamp_fifo
11079 MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
11081 /* reg_mtpptr_rec_message_type
11082 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
11083 * (e.g. Bit0: Sync, Bit1: Delay_Req)
11086 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
11087 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
11088 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
11090 /* reg_mtpptr_rec_domain_number
11091 * DomainNumber field as defined by IEEE 1588
11094 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
11095 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
11096 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
11098 /* reg_mtpptr_rec_sequence_id
11099 * SequenceId field as defined by IEEE 1588
11102 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
11103 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
11104 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
11106 /* reg_mtpptr_rec_timestamp_high
11107 * Timestamp of when the PTP packet has passed through the port Units of PLL
11109 * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec.
11112 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
11113 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
11114 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
11116 /* reg_mtpptr_rec_timestamp_low
11117 * See rec_timestamp_high.
11120 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
11121 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
11122 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
11124 static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
11126 u8 *p_message_type,
11127 u8 *p_domain_number,
11128 u16 *p_sequence_id,
11131 u32 timestamp_high, timestamp_low;
11133 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
11134 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
11135 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
11136 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
11137 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
11138 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
11141 /* MTPTPT - Monitoring Precision Time Protocol Trap Register
11142 * ---------------------------------------------------------
11143 * This register is used for configuring under which trap to deliver PTP
11144 * packets depending on type of the packet.
11146 #define MLXSW_REG_MTPTPT_ID 0x9092
11147 #define MLXSW_REG_MTPTPT_LEN 0x08
11149 MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
11151 enum mlxsw_reg_mtptpt_trap_id {
11152 MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
11153 MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
11156 /* reg_mtptpt_trap_id
11160 MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
11162 /* reg_mtptpt_message_type
11163 * Bitwise vector of PTP message types to trap. This is a necessary but
11164 * non-sufficient condition since need to enable also per port. See MTPPPC.
11165 * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g.
11166 * Bit0: Sync, Bit1: Delay_Req)
11168 MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
11170 static inline void mlxsw_reg_mtptpt_pack(char *payload,
11171 enum mlxsw_reg_mtptpt_trap_id trap_id,
11174 MLXSW_REG_ZERO(mtptpt, payload);
11175 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
11176 mlxsw_reg_mtptpt_message_type_set(payload, message_type);
11179 /* MTPCPC - Monitoring Time Precision Correction Port Configuration Register
11180 * -------------------------------------------------------------------------
11182 #define MLXSW_REG_MTPCPC_ID 0x9093
11183 #define MLXSW_REG_MTPCPC_LEN 0x2C
11185 MLXSW_REG_DEFINE(mtpcpc, MLXSW_REG_MTPCPC_ID, MLXSW_REG_MTPCPC_LEN);
11187 /* reg_mtpcpc_pport
11189 * 0: config is global. When reading - the local_port is 1.
11190 * 1: config is per port.
11193 MLXSW_ITEM32(reg, mtpcpc, pport, 0x00, 31, 1);
11195 /* reg_mtpcpc_local_port
11196 * Local port number.
11197 * Supported to/from CPU port.
11198 * Reserved when pport = 0.
11201 MLXSW_ITEM32_LP(reg, mtpcpc, 0x00, 16, 0x00, 12);
11203 /* reg_mtpcpc_ptp_trap_en
11204 * Enable PTP traps.
11205 * The trap_id is configured by MTPTPT.
11208 MLXSW_ITEM32(reg, mtpcpc, ptp_trap_en, 0x04, 0, 1);
11210 /* reg_mtpcpc_ing_correction_message_type
11211 * Bitwise vector of PTP message types to update correction-field at ingress.
11212 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
11213 * (e.g. Bit0: Sync, Bit1: Delay_Req). Supported also from CPU port.
11217 MLXSW_ITEM32(reg, mtpcpc, ing_correction_message_type, 0x10, 0, 16);
11219 /* reg_mtpcpc_egr_correction_message_type
11220 * Bitwise vector of PTP message types to update correction-field at egress.
11221 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
11222 * (e.g. Bit0: Sync, Bit1: Delay_Req). Supported also from CPU port.
11226 MLXSW_ITEM32(reg, mtpcpc, egr_correction_message_type, 0x14, 0, 16);
11228 static inline void mlxsw_reg_mtpcpc_pack(char *payload, bool pport,
11229 u16 local_port, bool ptp_trap_en,
11232 MLXSW_REG_ZERO(mtpcpc, payload);
11233 mlxsw_reg_mtpcpc_pport_set(payload, pport);
11234 mlxsw_reg_mtpcpc_local_port_set(payload, pport ? local_port : 0);
11235 mlxsw_reg_mtpcpc_ptp_trap_en_set(payload, ptp_trap_en);
11236 mlxsw_reg_mtpcpc_ing_correction_message_type_set(payload, ing);
11237 mlxsw_reg_mtpcpc_egr_correction_message_type_set(payload, egr);
11240 /* MFGD - Monitoring FW General Debug Register
11241 * -------------------------------------------
11243 #define MLXSW_REG_MFGD_ID 0x90F0
11244 #define MLXSW_REG_MFGD_LEN 0x0C
11246 MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN);
11248 /* reg_mfgd_fw_fatal_event_mode
11249 * 0 - don't check FW fatal (default)
11250 * 1 - check FW fatal - enable MFDE trap
11253 MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2);
11255 /* reg_mfgd_trigger_test
11258 MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1);
11260 /* MGPIR - Management General Peripheral Information Register
11261 * ----------------------------------------------------------
11262 * MGPIR register allows software to query the hardware and
11263 * firmware general information of peripheral entities.
11265 #define MLXSW_REG_MGPIR_ID 0x9100
11266 #define MLXSW_REG_MGPIR_LEN 0xA0
11268 MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
11270 enum mlxsw_reg_mgpir_device_type {
11271 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
11272 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
11275 /* mgpir_slot_index
11276 * Slot index (0: Main board).
11279 MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
11281 /* mgpir_device_type
11284 MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
11286 /* mgpir_devices_per_flash
11287 * Number of devices of device_type per flash (can be shared by few devices).
11290 MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
11292 /* mgpir_num_of_devices
11293 * Number of devices of device_type.
11296 MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
11298 /* max_modules_per_slot
11299 * Maximum number of modules that can be connected per slot.
11302 MLXSW_ITEM32(reg, mgpir, max_modules_per_slot, 0x04, 16, 8);
11304 /* mgpir_num_of_slots
11305 * Number of slots in the system.
11308 MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
11310 /* mgpir_num_of_modules
11311 * Number of modules.
11314 MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
11316 static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
11318 MLXSW_REG_ZERO(mgpir, payload);
11319 mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
11323 mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
11324 enum mlxsw_reg_mgpir_device_type *device_type,
11325 u8 *devices_per_flash, u8 *num_of_modules,
11328 if (num_of_devices)
11329 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
11331 *device_type = mlxsw_reg_mgpir_device_type_get(payload);
11332 if (devices_per_flash)
11333 *devices_per_flash =
11334 mlxsw_reg_mgpir_devices_per_flash_get(payload);
11335 if (num_of_modules)
11336 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
11338 *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
11341 /* MBCT - Management Binary Code Transfer Register
11342 * -----------------------------------------------
11343 * This register allows to transfer binary codes from the host to
11344 * the management FW by transferring it by chunks of maximum 1KB.
11346 #define MLXSW_REG_MBCT_ID 0x9120
11347 #define MLXSW_REG_MBCT_LEN 0x420
11349 MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN);
11351 /* reg_mbct_slot_index
11352 * Slot index. 0 is reserved.
11355 MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4);
11357 /* reg_mbct_data_size
11358 * Actual data field size in bytes for the current data transfer.
11361 MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11);
11363 enum mlxsw_reg_mbct_op {
11364 MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1,
11365 MLXSW_REG_MBCT_OP_DATA_TRANSFER, /* Download */
11366 MLXSW_REG_MBCT_OP_ACTIVATE,
11367 MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6,
11368 MLXSW_REG_MBCT_OP_QUERY_STATUS,
11374 MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4);
11377 * Indicates that the current data field is the last chunk of the INI.
11380 MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1);
11383 * Opcode Event Enable. When set a BCTOE event will be sent once the opcode
11384 * was executed and the fsm_state has changed.
11387 MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1);
11389 enum mlxsw_reg_mbct_status {
11390 /* Partial data transfer completed successfully and ready for next
11393 MLXSW_REG_MBCT_STATUS_PART_DATA = 2,
11394 MLXSW_REG_MBCT_STATUS_LAST_DATA,
11395 MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE,
11396 /* Error - trying to erase INI while it being used. */
11397 MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE,
11398 /* Last data transfer completed, applying magic pattern. */
11399 MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7,
11400 MLXSW_REG_MBCT_STATUS_INI_ERROR,
11401 MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED,
11402 MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11,
11409 MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5);
11411 enum mlxsw_reg_mbct_fsm_state {
11412 MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5,
11413 MLXSW_REG_MBCT_FSM_STATE_ERROR,
11416 /* reg_mbct_fsm_state
11420 MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4);
11422 #define MLXSW_REG_MBCT_DATA_LEN 1024
11425 * Up to 1KB of data.
11428 MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN);
11430 static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index,
11431 enum mlxsw_reg_mbct_op op, bool oee)
11433 MLXSW_REG_ZERO(mbct, payload);
11434 mlxsw_reg_mbct_slot_index_set(payload, slot_index);
11435 mlxsw_reg_mbct_op_set(payload, op);
11436 mlxsw_reg_mbct_oee_set(payload, oee);
11439 static inline void mlxsw_reg_mbct_dt_pack(char *payload,
11440 u16 data_size, bool last,
11443 if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN))
11445 mlxsw_reg_mbct_data_size_set(payload, data_size);
11446 mlxsw_reg_mbct_last_set(payload, last);
11447 mlxsw_reg_mbct_data_memcpy_to(payload, data);
11451 mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
11452 enum mlxsw_reg_mbct_status *p_status,
11453 enum mlxsw_reg_mbct_fsm_state *p_fsm_state)
11456 *p_slot_index = mlxsw_reg_mbct_slot_index_get(payload);
11457 *p_status = mlxsw_reg_mbct_status_get(payload);
11459 *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
11462 /* MDDT - Management DownStream Device Tunneling Register
11463 * ------------------------------------------------------
11464 * This register allows to deliver query and request messages (PRM registers,
11465 * commands) to a DownStream device.
11467 #define MLXSW_REG_MDDT_ID 0x9160
11468 #define MLXSW_REG_MDDT_LEN 0x110
11470 MLXSW_REG_DEFINE(mddt, MLXSW_REG_MDDT_ID, MLXSW_REG_MDDT_LEN);
11472 /* reg_mddt_slot_index
11476 MLXSW_ITEM32(reg, mddt, slot_index, 0x00, 8, 4);
11478 /* reg_mddt_device_index
11482 MLXSW_ITEM32(reg, mddt, device_index, 0x00, 0, 8);
11484 /* reg_mddt_read_size
11485 * Read size in D-Words.
11488 MLXSW_ITEM32(reg, mddt, read_size, 0x04, 24, 8);
11490 /* reg_mddt_write_size
11491 * Write size in D-Words.
11494 MLXSW_ITEM32(reg, mddt, write_size, 0x04, 16, 8);
11496 enum mlxsw_reg_mddt_status {
11497 MLXSW_REG_MDDT_STATUS_OK,
11501 * Return code of the Downstream Device to the register that was sent.
11504 MLXSW_ITEM32(reg, mddt, status, 0x0C, 24, 8);
11506 enum mlxsw_reg_mddt_method {
11507 MLXSW_REG_MDDT_METHOD_QUERY,
11508 MLXSW_REG_MDDT_METHOD_WRITE,
11514 MLXSW_ITEM32(reg, mddt, method, 0x0C, 22, 2);
11516 /* reg_mddt_register_id
11519 MLXSW_ITEM32(reg, mddt, register_id, 0x0C, 0, 16);
11521 #define MLXSW_REG_MDDT_PAYLOAD_OFFSET 0x0C
11522 #define MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN 4
11524 static inline char *mlxsw_reg_mddt_inner_payload(char *payload)
11526 return payload + MLXSW_REG_MDDT_PAYLOAD_OFFSET +
11527 MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN;
11530 static inline void mlxsw_reg_mddt_pack(char *payload, u8 slot_index,
11532 enum mlxsw_reg_mddt_method method,
11533 const struct mlxsw_reg_info *reg,
11534 char **inner_payload)
11536 int len = reg->len + MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN;
11538 if (WARN_ON(len + MLXSW_REG_MDDT_PAYLOAD_OFFSET > MLXSW_REG_MDDT_LEN))
11539 len = MLXSW_REG_MDDT_LEN - MLXSW_REG_MDDT_PAYLOAD_OFFSET;
11541 MLXSW_REG_ZERO(mddt, payload);
11542 mlxsw_reg_mddt_slot_index_set(payload, slot_index);
11543 mlxsw_reg_mddt_device_index_set(payload, device_index);
11544 mlxsw_reg_mddt_method_set(payload, method);
11545 mlxsw_reg_mddt_register_id_set(payload, reg->id);
11546 mlxsw_reg_mddt_read_size_set(payload, len / 4);
11547 mlxsw_reg_mddt_write_size_set(payload, len / 4);
11548 *inner_payload = mlxsw_reg_mddt_inner_payload(payload);
11551 /* MDDQ - Management DownStream Device Query Register
11552 * --------------------------------------------------
11553 * This register allows to query the DownStream device properties. The desired
11554 * information is chosen upon the query_type field and is delivered by 32B
11557 #define MLXSW_REG_MDDQ_ID 0x9161
11558 #define MLXSW_REG_MDDQ_LEN 0x30
11560 MLXSW_REG_DEFINE(mddq, MLXSW_REG_MDDQ_ID, MLXSW_REG_MDDQ_LEN);
11563 * Slot info event enable.
11564 * When set to '1', each change in the slot_info.provisioned / sr_valid /
11565 * active / ready will generate a DSDSC event.
11568 MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1);
11570 enum mlxsw_reg_mddq_query_type {
11571 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1,
11572 MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO, /* If there are no devices
11573 * on the slot, data_valid
11576 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME,
11579 /* reg_mddq_query_type
11582 MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8);
11584 /* reg_mddq_slot_index
11585 * Slot index. 0 is reserved.
11588 MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4);
11590 /* reg_mddq_response_msg_seq
11591 * Response message sequential number. For a specific request, the response
11592 * message sequential number is the following one. In addition, the last
11593 * message should be 0.
11596 MLXSW_ITEM32(reg, mddq, response_msg_seq, 0x04, 16, 8);
11598 /* reg_mddq_request_msg_seq
11599 * Request message sequential number.
11600 * The first message number should be 0.
11603 MLXSW_ITEM32(reg, mddq, request_msg_seq, 0x04, 0, 8);
11605 /* reg_mddq_data_valid
11606 * If set, the data in the data field is valid and contain the information
11607 * for the queried index.
11610 MLXSW_ITEM32(reg, mddq, data_valid, 0x08, 31, 1);
11612 /* reg_mddq_slot_info_provisioned
11613 * If set, the INI file is applied and the card is provisioned.
11616 MLXSW_ITEM32(reg, mddq, slot_info_provisioned, 0x10, 31, 1);
11618 /* reg_mddq_slot_info_sr_valid
11619 * If set, Shift Register is valid (after being provisioned) and data
11620 * can be sent from the switch ASIC to the line-card CPLD over Shift-Register.
11623 MLXSW_ITEM32(reg, mddq, slot_info_sr_valid, 0x10, 30, 1);
11625 enum mlxsw_reg_mddq_slot_info_ready {
11626 MLXSW_REG_MDDQ_SLOT_INFO_READY_NOT_READY,
11627 MLXSW_REG_MDDQ_SLOT_INFO_READY_READY,
11628 MLXSW_REG_MDDQ_SLOT_INFO_READY_ERROR,
11631 /* reg_mddq_slot_info_lc_ready
11632 * If set, the LC is powered on, matching the INI version and a new FW
11633 * version can be burnt (if necessary).
11636 MLXSW_ITEM32(reg, mddq, slot_info_lc_ready, 0x10, 28, 2);
11638 /* reg_mddq_slot_info_active
11639 * If set, the FW has completed the MDDC.device_enable command.
11642 MLXSW_ITEM32(reg, mddq, slot_info_active, 0x10, 27, 1);
11644 /* reg_mddq_slot_info_hw_revision
11645 * Major user-configured version number of the current INI file.
11646 * Valid only when active or ready are '1'.
11649 MLXSW_ITEM32(reg, mddq, slot_info_hw_revision, 0x14, 16, 16);
11651 /* reg_mddq_slot_info_ini_file_version
11652 * User-configured version number of the current INI file.
11653 * Valid only when active or lc_ready are '1'.
11656 MLXSW_ITEM32(reg, mddq, slot_info_ini_file_version, 0x14, 0, 16);
11658 /* reg_mddq_slot_info_card_type
11661 MLXSW_ITEM32(reg, mddq, slot_info_card_type, 0x18, 0, 8);
11664 __mlxsw_reg_mddq_pack(char *payload, u8 slot_index,
11665 enum mlxsw_reg_mddq_query_type query_type)
11667 MLXSW_REG_ZERO(mddq, payload);
11668 mlxsw_reg_mddq_slot_index_set(payload, slot_index);
11669 mlxsw_reg_mddq_query_type_set(payload, query_type);
11673 mlxsw_reg_mddq_slot_info_pack(char *payload, u8 slot_index, bool sie)
11675 __mlxsw_reg_mddq_pack(payload, slot_index,
11676 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO);
11677 mlxsw_reg_mddq_sie_set(payload, sie);
11681 mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index,
11682 bool *p_provisioned, bool *p_sr_valid,
11683 enum mlxsw_reg_mddq_slot_info_ready *p_lc_ready,
11684 bool *p_active, u16 *p_hw_revision,
11685 u16 *p_ini_file_version,
11688 *p_slot_index = mlxsw_reg_mddq_slot_index_get(payload);
11689 *p_provisioned = mlxsw_reg_mddq_slot_info_provisioned_get(payload);
11690 *p_sr_valid = mlxsw_reg_mddq_slot_info_sr_valid_get(payload);
11691 *p_lc_ready = mlxsw_reg_mddq_slot_info_lc_ready_get(payload);
11692 *p_active = mlxsw_reg_mddq_slot_info_active_get(payload);
11693 *p_hw_revision = mlxsw_reg_mddq_slot_info_hw_revision_get(payload);
11694 *p_ini_file_version = mlxsw_reg_mddq_slot_info_ini_file_version_get(payload);
11695 *p_card_type = mlxsw_reg_mddq_slot_info_card_type_get(payload);
11698 /* reg_mddq_device_info_flash_owner
11699 * If set, the device is the flash owner. Otherwise, a shared flash
11700 * is used by this device (another device is the flash owner).
11703 MLXSW_ITEM32(reg, mddq, device_info_flash_owner, 0x10, 30, 1);
11705 /* reg_mddq_device_info_device_index
11706 * Device index. The first device should number 0.
11709 MLXSW_ITEM32(reg, mddq, device_info_device_index, 0x10, 0, 8);
11711 /* reg_mddq_device_info_fw_major
11712 * Major FW version number.
11715 MLXSW_ITEM32(reg, mddq, device_info_fw_major, 0x14, 16, 16);
11717 /* reg_mddq_device_info_fw_minor
11718 * Minor FW version number.
11721 MLXSW_ITEM32(reg, mddq, device_info_fw_minor, 0x18, 16, 16);
11723 /* reg_mddq_device_info_fw_sub_minor
11724 * Sub-minor FW version number.
11727 MLXSW_ITEM32(reg, mddq, device_info_fw_sub_minor, 0x18, 0, 16);
11730 mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index,
11731 u8 request_msg_seq)
11733 __mlxsw_reg_mddq_pack(payload, slot_index,
11734 MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO);
11735 mlxsw_reg_mddq_request_msg_seq_set(payload, request_msg_seq);
11739 mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq,
11740 bool *p_data_valid, bool *p_flash_owner,
11741 u8 *p_device_index, u16 *p_fw_major,
11742 u16 *p_fw_minor, u16 *p_fw_sub_minor)
11744 *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload);
11745 *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload);
11746 *p_flash_owner = mlxsw_reg_mddq_device_info_flash_owner_get(payload);
11747 *p_device_index = mlxsw_reg_mddq_device_info_device_index_get(payload);
11748 *p_fw_major = mlxsw_reg_mddq_device_info_fw_major_get(payload);
11749 *p_fw_minor = mlxsw_reg_mddq_device_info_fw_minor_get(payload);
11750 *p_fw_sub_minor = mlxsw_reg_mddq_device_info_fw_sub_minor_get(payload);
11753 #define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20
11755 /* reg_mddq_slot_ascii_name
11756 * Slot's ASCII name.
11759 MLXSW_ITEM_BUF(reg, mddq, slot_ascii_name, 0x10,
11760 MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN);
11763 mlxsw_reg_mddq_slot_name_pack(char *payload, u8 slot_index)
11765 __mlxsw_reg_mddq_pack(payload, slot_index,
11766 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME);
11770 mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name)
11772 mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name);
11775 /* MDDC - Management DownStream Device Control Register
11776 * ----------------------------------------------------
11777 * This register allows to control downstream devices and line cards.
11779 #define MLXSW_REG_MDDC_ID 0x9163
11780 #define MLXSW_REG_MDDC_LEN 0x30
11782 MLXSW_REG_DEFINE(mddc, MLXSW_REG_MDDC_ID, MLXSW_REG_MDDC_LEN);
11784 /* reg_mddc_slot_index
11785 * Slot index. 0 is reserved.
11788 MLXSW_ITEM32(reg, mddc, slot_index, 0x00, 0, 4);
11794 MLXSW_ITEM32(reg, mddc, rst, 0x04, 29, 1);
11796 /* reg_mddc_device_enable
11797 * When set, FW is the manager and allowed to program the downstream device.
11800 MLXSW_ITEM32(reg, mddc, device_enable, 0x04, 28, 1);
11802 static inline void mlxsw_reg_mddc_pack(char *payload, u8 slot_index, bool rst,
11803 bool device_enable)
11805 MLXSW_REG_ZERO(mddc, payload);
11806 mlxsw_reg_mddc_slot_index_set(payload, slot_index);
11807 mlxsw_reg_mddc_rst_set(payload, rst);
11808 mlxsw_reg_mddc_device_enable_set(payload, device_enable);
11811 /* MFDE - Monitoring FW Debug Register
11812 * -----------------------------------
11814 #define MLXSW_REG_MFDE_ID 0x9200
11815 #define MLXSW_REG_MFDE_LEN 0x30
11817 MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN);
11819 /* reg_mfde_irisc_id
11820 * Which irisc triggered the event
11823 MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 24, 8);
11825 enum mlxsw_reg_mfde_severity {
11826 /* Unrecoverable switch behavior */
11827 MLXSW_REG_MFDE_SEVERITY_FATL = 2,
11828 /* Unexpected state with possible systemic failure */
11829 MLXSW_REG_MFDE_SEVERITY_NRML = 3,
11830 /* Unexpected state without systemic failure */
11831 MLXSW_REG_MFDE_SEVERITY_INTR = 5,
11834 /* reg_mfde_severity
11835 * The severity of the event.
11838 MLXSW_ITEM32(reg, mfde, severity, 0x00, 16, 8);
11840 enum mlxsw_reg_mfde_event_id {
11841 /* CRspace timeout */
11842 MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1,
11843 /* KVD insertion machine stopped */
11844 MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP,
11845 /* Triggered by MFGD.trigger_test */
11846 MLXSW_REG_MFDE_EVENT_ID_TEST,
11847 /* Triggered when firmware hits an assert */
11848 MLXSW_REG_MFDE_EVENT_ID_FW_ASSERT,
11849 /* Fatal error interrupt from hardware */
11850 MLXSW_REG_MFDE_EVENT_ID_FATAL_CAUSE,
11853 /* reg_mfde_event_id
11856 MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 16);
11858 enum mlxsw_reg_mfde_method {
11859 MLXSW_REG_MFDE_METHOD_QUERY,
11860 MLXSW_REG_MFDE_METHOD_WRITE,
11866 MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1);
11868 /* reg_mfde_long_process
11869 * Indicates if the command is in long_process mode.
11872 MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1);
11874 enum mlxsw_reg_mfde_command_type {
11875 MLXSW_REG_MFDE_COMMAND_TYPE_MAD,
11876 MLXSW_REG_MFDE_COMMAND_TYPE_EMAD,
11877 MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF,
11880 /* reg_mfde_command_type
11883 MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2);
11885 /* reg_mfde_reg_attr_id
11886 * EMAD - register id, MAD - attibute id
11889 MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16);
11891 /* reg_mfde_crspace_to_log_address
11892 * crspace address accessed, which resulted in timeout.
11895 MLXSW_ITEM32(reg, mfde, crspace_to_log_address, 0x10, 0, 32);
11897 /* reg_mfde_crspace_to_oe
11899 * 1 - Old event, occurred before MFGD activation.
11902 MLXSW_ITEM32(reg, mfde, crspace_to_oe, 0x14, 24, 1);
11904 /* reg_mfde_crspace_to_log_id
11905 * Which irisc triggered the timeout.
11908 MLXSW_ITEM32(reg, mfde, crspace_to_log_id, 0x14, 0, 4);
11910 /* reg_mfde_crspace_to_log_ip
11911 * IP (instruction pointer) that triggered the timeout.
11914 MLXSW_ITEM64(reg, mfde, crspace_to_log_ip, 0x18, 0, 64);
11916 /* reg_mfde_kvd_im_stop_oe
11918 * 1 - Old event, occurred before MFGD activation.
11921 MLXSW_ITEM32(reg, mfde, kvd_im_stop_oe, 0x10, 24, 1);
11923 /* reg_mfde_kvd_im_stop_pipes_mask
11924 * Bit per kvh pipe.
11927 MLXSW_ITEM32(reg, mfde, kvd_im_stop_pipes_mask, 0x10, 0, 16);
11929 /* reg_mfde_fw_assert_var0-4
11930 * Variables passed to assert.
11933 MLXSW_ITEM32(reg, mfde, fw_assert_var0, 0x10, 0, 32);
11934 MLXSW_ITEM32(reg, mfde, fw_assert_var1, 0x14, 0, 32);
11935 MLXSW_ITEM32(reg, mfde, fw_assert_var2, 0x18, 0, 32);
11936 MLXSW_ITEM32(reg, mfde, fw_assert_var3, 0x1C, 0, 32);
11937 MLXSW_ITEM32(reg, mfde, fw_assert_var4, 0x20, 0, 32);
11939 /* reg_mfde_fw_assert_existptr
11940 * The instruction pointer when assert was triggered.
11943 MLXSW_ITEM32(reg, mfde, fw_assert_existptr, 0x24, 0, 32);
11945 /* reg_mfde_fw_assert_callra
11946 * The return address after triggering assert.
11949 MLXSW_ITEM32(reg, mfde, fw_assert_callra, 0x28, 0, 32);
11951 /* reg_mfde_fw_assert_oe
11953 * 1 - Old event, occurred before MFGD activation.
11956 MLXSW_ITEM32(reg, mfde, fw_assert_oe, 0x2C, 24, 1);
11958 /* reg_mfde_fw_assert_tile_v
11959 * 0: The assert was from main
11960 * 1: The assert was from a tile
11963 MLXSW_ITEM32(reg, mfde, fw_assert_tile_v, 0x2C, 23, 1);
11965 /* reg_mfde_fw_assert_tile_index
11966 * When tile_v=1, the tile_index that caused the assert.
11969 MLXSW_ITEM32(reg, mfde, fw_assert_tile_index, 0x2C, 16, 6);
11971 /* reg_mfde_fw_assert_ext_synd
11972 * A generated one-to-one identifier which is specific per-assert.
11975 MLXSW_ITEM32(reg, mfde, fw_assert_ext_synd, 0x2C, 0, 16);
11977 /* reg_mfde_fatal_cause_id
11978 * HW interrupt cause id.
11981 MLXSW_ITEM32(reg, mfde, fatal_cause_id, 0x10, 0, 18);
11983 /* reg_mfde_fatal_cause_tile_v
11984 * 0: The assert was from main
11985 * 1: The assert was from a tile
11988 MLXSW_ITEM32(reg, mfde, fatal_cause_tile_v, 0x14, 23, 1);
11990 /* reg_mfde_fatal_cause_tile_index
11991 * When tile_v=1, the tile_index that caused the assert.
11994 MLXSW_ITEM32(reg, mfde, fatal_cause_tile_index, 0x14, 16, 6);
11996 /* TNGCR - Tunneling NVE General Configuration Register
11997 * ----------------------------------------------------
11998 * The TNGCR register is used for setting up the NVE Tunneling configuration.
12000 #define MLXSW_REG_TNGCR_ID 0xA001
12001 #define MLXSW_REG_TNGCR_LEN 0x44
12003 MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
12005 enum mlxsw_reg_tngcr_type {
12006 MLXSW_REG_TNGCR_TYPE_VXLAN,
12007 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
12008 MLXSW_REG_TNGCR_TYPE_GENEVE,
12009 MLXSW_REG_TNGCR_TYPE_NVGRE,
12013 * Tunnel type for encapsulation and decapsulation. The types are mutually
12015 * Note: For Spectrum the NVE parsing must be enabled in MPRS.
12018 MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
12020 /* reg_tngcr_nve_valid
12021 * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation.
12024 MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
12026 /* reg_tngcr_nve_ttl_uc
12027 * The TTL for NVE tunnel encapsulation underlay unicast packets.
12030 MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
12032 /* reg_tngcr_nve_ttl_mc
12033 * The TTL for NVE tunnel encapsulation underlay multicast packets.
12036 MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
12039 /* Do not copy flow label. Calculate flow label using nve_flh. */
12040 MLXSW_REG_TNGCR_FL_NO_COPY,
12041 /* Copy flow label from inner packet if packet is IPv6 and
12042 * encapsulation is by IPv6. Otherwise, calculate flow label using
12045 MLXSW_REG_TNGCR_FL_COPY,
12048 /* reg_tngcr_nve_flc
12049 * For NVE tunnel encapsulation: Flow label copy from inner packet.
12052 MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
12055 /* Flow label is static. In Spectrum this means '0'. Spectrum-2
12056 * uses {nve_fl_prefix, nve_fl_suffix}.
12058 MLXSW_REG_TNGCR_FL_NO_HASH,
12059 /* 8 LSBs of the flow label are calculated from ECMP hash of the
12060 * inner packet. 12 MSBs are configured by nve_fl_prefix.
12062 MLXSW_REG_TNGCR_FL_HASH,
12065 /* reg_tngcr_nve_flh
12066 * NVE flow label hash.
12069 MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
12071 /* reg_tngcr_nve_fl_prefix
12072 * NVE flow label prefix. Constant 12 MSBs of the flow label.
12075 MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
12077 /* reg_tngcr_nve_fl_suffix
12078 * NVE flow label suffix. Constant 8 LSBs of the flow label.
12079 * Reserved when nve_flh=1 and for Spectrum.
12082 MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
12085 /* Source UDP port is fixed (default '0') */
12086 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
12087 /* Source UDP port is calculated based on hash */
12088 MLXSW_REG_TNGCR_UDP_SPORT_HASH,
12091 /* reg_tngcr_nve_udp_sport_type
12092 * NVE UDP source port type.
12093 * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2).
12094 * When the source UDP port is calculated based on hash, then the 8 LSBs
12095 * are calculated from hash the 8 MSBs are configured by
12096 * nve_udp_sport_prefix.
12099 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
12101 /* reg_tngcr_nve_udp_sport_prefix
12102 * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port.
12103 * Reserved when NVE type is NVGRE.
12106 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
12108 /* reg_tngcr_nve_group_size_mc
12109 * The amount of sequential linked lists of MC entries. The first linked
12110 * list is configured by SFD.underlay_mc_ptr.
12111 * Valid values: 1, 2, 4, 8, 16, 32, 64
12112 * The linked list are configured by TNUMT.
12113 * The hash is set by LAG hash.
12116 MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
12118 /* reg_tngcr_nve_group_size_flood
12119 * The amount of sequential linked lists of flooding entries. The first
12120 * linked list is configured by SFMR.nve_tunnel_flood_ptr
12121 * Valid values: 1, 2, 4, 8, 16, 32, 64
12122 * The linked list are configured by TNUMT.
12123 * The hash is set by LAG hash.
12126 MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
12128 /* reg_tngcr_learn_enable
12129 * During decapsulation, whether to learn from NVE port.
12130 * Reserved when Spectrum-2. See TNPC.
12133 MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
12135 /* reg_tngcr_underlay_virtual_router
12136 * Underlay virtual router.
12137 * Reserved when Spectrum-2.
12140 MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
12142 /* reg_tngcr_underlay_rif
12143 * Underlay ingress router interface. RIF type should be loopback generic.
12144 * Reserved when Spectrum.
12147 MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
12149 /* reg_tngcr_usipv4
12150 * Underlay source IPv4 address of the NVE.
12153 MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
12155 /* reg_tngcr_usipv6
12156 * Underlay source IPv6 address of the NVE. For Spectrum, must not be
12157 * modified under traffic of NVE tunneling encapsulation.
12160 MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
12162 static inline void mlxsw_reg_tngcr_pack(char *payload,
12163 enum mlxsw_reg_tngcr_type type,
12164 bool valid, u8 ttl)
12166 MLXSW_REG_ZERO(tngcr, payload);
12167 mlxsw_reg_tngcr_type_set(payload, type);
12168 mlxsw_reg_tngcr_nve_valid_set(payload, valid);
12169 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
12170 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
12171 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
12172 mlxsw_reg_tngcr_nve_flh_set(payload, 0);
12173 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
12174 MLXSW_REG_TNGCR_UDP_SPORT_HASH);
12175 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
12176 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
12177 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
12180 /* TNUMT - Tunneling NVE Underlay Multicast Table Register
12181 * -------------------------------------------------------
12182 * The TNUMT register is for building the underlay MC table. It is used
12183 * for MC, flooding and BC traffic into the NVE tunnel.
12185 #define MLXSW_REG_TNUMT_ID 0xA003
12186 #define MLXSW_REG_TNUMT_LEN 0x20
12188 MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
12190 enum mlxsw_reg_tnumt_record_type {
12191 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
12192 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
12193 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
12196 /* reg_tnumt_record_type
12200 MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
12202 /* reg_tnumt_tunnel_port
12206 MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
12208 /* reg_tnumt_underlay_mc_ptr
12209 * Index to the underlay multicast table.
12210 * For Spectrum the index is to the KVD linear.
12213 MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
12216 * The next_underlay_mc_ptr is valid.
12219 MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
12221 /* reg_tnumt_next_underlay_mc_ptr
12222 * The next index to the underlay multicast table.
12225 MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
12227 /* reg_tnumt_record_size
12228 * Number of IP addresses in the record.
12229 * Range is 1..cap_max_nve_mc_entries_ipv{4,6}
12232 MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
12235 * The underlay IPv4 addresses. udip[i] is reserved if i >= size
12238 MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
12240 /* reg_tnumt_udip_ptr
12241 * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if
12242 * i >= size. The IPv6 addresses are configured by RIPS.
12245 MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
12247 static inline void mlxsw_reg_tnumt_pack(char *payload,
12248 enum mlxsw_reg_tnumt_record_type type,
12249 enum mlxsw_reg_tunnel_port tport,
12250 u32 underlay_mc_ptr, bool vnext,
12251 u32 next_underlay_mc_ptr,
12254 MLXSW_REG_ZERO(tnumt, payload);
12255 mlxsw_reg_tnumt_record_type_set(payload, type);
12256 mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
12257 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
12258 mlxsw_reg_tnumt_vnext_set(payload, vnext);
12259 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
12260 mlxsw_reg_tnumt_record_size_set(payload, record_size);
12263 /* TNQCR - Tunneling NVE QoS Configuration Register
12264 * ------------------------------------------------
12265 * The TNQCR register configures how QoS is set in encapsulation into the
12266 * underlay network.
12268 #define MLXSW_REG_TNQCR_ID 0xA010
12269 #define MLXSW_REG_TNQCR_LEN 0x0C
12271 MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
12273 /* reg_tnqcr_enc_set_dscp
12274 * For encapsulation: How to set DSCP field:
12275 * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay
12276 * (outer) IP header. If there is no IP header, use TNQDR.dscp
12277 * 1 - Set the DSCP field as TNQDR.dscp
12280 MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
12282 static inline void mlxsw_reg_tnqcr_pack(char *payload)
12284 MLXSW_REG_ZERO(tnqcr, payload);
12285 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
12288 /* TNQDR - Tunneling NVE QoS Default Register
12289 * ------------------------------------------
12290 * The TNQDR register configures the default QoS settings for NVE
12293 #define MLXSW_REG_TNQDR_ID 0xA011
12294 #define MLXSW_REG_TNQDR_LEN 0x08
12296 MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
12298 /* reg_tnqdr_local_port
12299 * Local port number (receive port). CPU port is supported.
12302 MLXSW_ITEM32_LP(reg, tnqdr, 0x00, 16, 0x00, 12);
12305 * For encapsulation, the default DSCP.
12308 MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
12310 static inline void mlxsw_reg_tnqdr_pack(char *payload, u16 local_port)
12312 MLXSW_REG_ZERO(tnqdr, payload);
12313 mlxsw_reg_tnqdr_local_port_set(payload, local_port);
12314 mlxsw_reg_tnqdr_dscp_set(payload, 0);
12317 /* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register
12318 * --------------------------------------------------------
12319 * The TNEEM register maps ECN of the IP header at the ingress to the
12320 * encapsulation to the ECN of the underlay network.
12322 #define MLXSW_REG_TNEEM_ID 0xA012
12323 #define MLXSW_REG_TNEEM_LEN 0x0C
12325 MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
12327 /* reg_tneem_overlay_ecn
12328 * ECN of the IP header in the overlay network.
12331 MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
12333 /* reg_tneem_underlay_ecn
12334 * ECN of the IP header in the underlay network.
12337 MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
12339 static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
12342 MLXSW_REG_ZERO(tneem, payload);
12343 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
12344 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
12347 /* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register
12348 * --------------------------------------------------------
12349 * The TNDEM register configures the actions that are done in the
12352 #define MLXSW_REG_TNDEM_ID 0xA013
12353 #define MLXSW_REG_TNDEM_LEN 0x0C
12355 MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
12357 /* reg_tndem_underlay_ecn
12358 * ECN field of the IP header in the underlay network.
12361 MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
12363 /* reg_tndem_overlay_ecn
12364 * ECN field of the IP header in the overlay network.
12367 MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
12369 /* reg_tndem_eip_ecn
12370 * Egress IP ECN. ECN field of the IP header of the packet which goes out
12371 * from the decapsulation.
12374 MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
12376 /* reg_tndem_trap_en
12378 * 0 - No trap due to decap ECN
12379 * 1 - Trap enable with trap_id
12382 MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
12384 /* reg_tndem_trap_id
12385 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
12386 * Reserved when trap_en is '0'.
12389 MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
12391 static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
12392 u8 overlay_ecn, u8 ecn, bool trap_en,
12395 MLXSW_REG_ZERO(tndem, payload);
12396 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
12397 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
12398 mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
12399 mlxsw_reg_tndem_trap_en_set(payload, trap_en);
12400 mlxsw_reg_tndem_trap_id_set(payload, trap_id);
12403 /* TNPC - Tunnel Port Configuration Register
12404 * -----------------------------------------
12405 * The TNPC register is used for tunnel port configuration.
12406 * Reserved when Spectrum.
12408 #define MLXSW_REG_TNPC_ID 0xA020
12409 #define MLXSW_REG_TNPC_LEN 0x18
12411 MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
12413 /* reg_tnpc_tunnel_port
12417 MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
12419 /* reg_tnpc_learn_enable_v6
12420 * During IPv6 underlay decapsulation, whether to learn from tunnel port.
12423 MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
12425 /* reg_tnpc_learn_enable_v4
12426 * During IPv4 underlay decapsulation, whether to learn from tunnel port.
12429 MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
12431 static inline void mlxsw_reg_tnpc_pack(char *payload,
12432 enum mlxsw_reg_tunnel_port tport,
12435 MLXSW_REG_ZERO(tnpc, payload);
12436 mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
12437 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
12438 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
12441 /* TIGCR - Tunneling IPinIP General Configuration Register
12442 * -------------------------------------------------------
12443 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
12445 #define MLXSW_REG_TIGCR_ID 0xA801
12446 #define MLXSW_REG_TIGCR_LEN 0x10
12448 MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
12450 /* reg_tigcr_ipip_ttlc
12451 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
12455 MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
12457 /* reg_tigcr_ipip_ttl_uc
12458 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
12459 * reg_tigcr_ipip_ttlc is unset.
12462 MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
12464 static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
12466 MLXSW_REG_ZERO(tigcr, payload);
12467 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
12468 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
12471 /* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register
12472 * -----------------------------------------------------------
12473 * The TIEEM register maps ECN of the IP header at the ingress to the
12474 * encapsulation to the ECN of the underlay network.
12476 #define MLXSW_REG_TIEEM_ID 0xA812
12477 #define MLXSW_REG_TIEEM_LEN 0x0C
12479 MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
12481 /* reg_tieem_overlay_ecn
12482 * ECN of the IP header in the overlay network.
12485 MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
12487 /* reg_tineem_underlay_ecn
12488 * ECN of the IP header in the underlay network.
12491 MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
12493 static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
12496 MLXSW_REG_ZERO(tieem, payload);
12497 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
12498 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
12501 /* TIDEM - Tunneling IPinIP Decapsulation ECN Mapping Register
12502 * -----------------------------------------------------------
12503 * The TIDEM register configures the actions that are done in the
12506 #define MLXSW_REG_TIDEM_ID 0xA813
12507 #define MLXSW_REG_TIDEM_LEN 0x0C
12509 MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN);
12511 /* reg_tidem_underlay_ecn
12512 * ECN field of the IP header in the underlay network.
12515 MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2);
12517 /* reg_tidem_overlay_ecn
12518 * ECN field of the IP header in the overlay network.
12521 MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2);
12523 /* reg_tidem_eip_ecn
12524 * Egress IP ECN. ECN field of the IP header of the packet which goes out
12525 * from the decapsulation.
12528 MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2);
12530 /* reg_tidem_trap_en
12532 * 0 - No trap due to decap ECN
12533 * 1 - Trap enable with trap_id
12536 MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4);
12538 /* reg_tidem_trap_id
12539 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
12540 * Reserved when trap_en is '0'.
12543 MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9);
12545 static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn,
12546 u8 overlay_ecn, u8 eip_ecn,
12547 bool trap_en, u16 trap_id)
12549 MLXSW_REG_ZERO(tidem, payload);
12550 mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn);
12551 mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn);
12552 mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn);
12553 mlxsw_reg_tidem_trap_en_set(payload, trap_en);
12554 mlxsw_reg_tidem_trap_id_set(payload, trap_id);
12557 /* SBPR - Shared Buffer Pools Register
12558 * -----------------------------------
12559 * The SBPR configures and retrieves the shared buffer pools and configuration.
12561 #define MLXSW_REG_SBPR_ID 0xB001
12562 #define MLXSW_REG_SBPR_LEN 0x14
12564 MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
12567 * When set, configures descriptor buffer.
12570 MLXSW_ITEM32(reg, sbpr, desc, 0x00, 31, 1);
12572 /* shared direstion enum for SBPR, SBCM, SBPM */
12573 enum mlxsw_reg_sbxx_dir {
12574 MLXSW_REG_SBXX_DIR_INGRESS,
12575 MLXSW_REG_SBXX_DIR_EGRESS,
12582 MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
12588 MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
12590 /* reg_sbpr_infi_size
12591 * Size is infinite.
12594 MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
12597 * Pool size in buffer cells.
12598 * Reserved when infi_size = 1.
12601 MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
12603 enum mlxsw_reg_sbpr_mode {
12604 MLXSW_REG_SBPR_MODE_STATIC,
12605 MLXSW_REG_SBPR_MODE_DYNAMIC,
12609 * Pool quota calculation mode.
12612 MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
12614 static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
12615 enum mlxsw_reg_sbxx_dir dir,
12616 enum mlxsw_reg_sbpr_mode mode, u32 size,
12619 MLXSW_REG_ZERO(sbpr, payload);
12620 mlxsw_reg_sbpr_pool_set(payload, pool);
12621 mlxsw_reg_sbpr_dir_set(payload, dir);
12622 mlxsw_reg_sbpr_mode_set(payload, mode);
12623 mlxsw_reg_sbpr_size_set(payload, size);
12624 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
12627 /* SBCM - Shared Buffer Class Management Register
12628 * ----------------------------------------------
12629 * The SBCM register configures and retrieves the shared buffer allocation
12630 * and configuration according to Port-PG, including the binding to pool
12631 * and definition of the associated quota.
12633 #define MLXSW_REG_SBCM_ID 0xB002
12634 #define MLXSW_REG_SBCM_LEN 0x28
12636 MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
12638 /* reg_sbcm_local_port
12639 * Local port number.
12640 * For Ingress: excludes CPU port and Router port
12641 * For Egress: excludes IP Router
12644 MLXSW_ITEM32_LP(reg, sbcm, 0x00, 16, 0x00, 4);
12646 /* reg_sbcm_pg_buff
12647 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
12648 * For PG buffer: range is 0..cap_max_pg_buffers - 1
12649 * For traffic class: range is 0..cap_max_tclass - 1
12650 * Note that when traffic class is in MC aware mode then the traffic
12651 * classes which are MC aware cannot be configured.
12654 MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
12660 MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
12662 /* reg_sbcm_min_buff
12663 * Minimum buffer size for the limiter, in cells.
12666 MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
12668 /* shared max_buff limits for dynamic threshold for SBCM, SBPM */
12669 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
12670 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
12672 /* reg_sbcm_infi_max
12673 * Max buffer is infinite.
12676 MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
12678 /* reg_sbcm_max_buff
12679 * When the pool associated to the port-pg/tclass is configured to
12680 * static, Maximum buffer size for the limiter configured in cells.
12681 * When the pool associated to the port-pg/tclass is configured to
12682 * dynamic, the max_buff holds the "alpha" parameter, supporting
12683 * the following values:
12685 * i: (1/128)*2^(i-1), for i=1..14
12687 * Reserved when infi_max = 1.
12690 MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
12693 * Association of the port-priority to a pool.
12696 MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
12698 static inline void mlxsw_reg_sbcm_pack(char *payload, u16 local_port, u8 pg_buff,
12699 enum mlxsw_reg_sbxx_dir dir,
12700 u32 min_buff, u32 max_buff,
12701 bool infi_max, u8 pool)
12703 MLXSW_REG_ZERO(sbcm, payload);
12704 mlxsw_reg_sbcm_local_port_set(payload, local_port);
12705 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
12706 mlxsw_reg_sbcm_dir_set(payload, dir);
12707 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
12708 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
12709 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
12710 mlxsw_reg_sbcm_pool_set(payload, pool);
12713 /* SBPM - Shared Buffer Port Management Register
12714 * ---------------------------------------------
12715 * The SBPM register configures and retrieves the shared buffer allocation
12716 * and configuration according to Port-Pool, including the definition
12717 * of the associated quota.
12719 #define MLXSW_REG_SBPM_ID 0xB003
12720 #define MLXSW_REG_SBPM_LEN 0x28
12722 MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
12724 /* reg_sbpm_local_port
12725 * Local port number.
12726 * For Ingress: excludes CPU port and Router port
12727 * For Egress: excludes IP Router
12730 MLXSW_ITEM32_LP(reg, sbpm, 0x00, 16, 0x00, 12);
12733 * The pool associated to quota counting on the local_port.
12736 MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
12742 MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
12744 /* reg_sbpm_buff_occupancy
12745 * Current buffer occupancy in cells.
12748 MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
12751 * Clear Max Buffer Occupancy
12752 * When this bit is set, max_buff_occupancy field is cleared (and a
12753 * new max value is tracked from the time the clear was performed).
12756 MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
12758 /* reg_sbpm_max_buff_occupancy
12759 * Maximum value of buffer occupancy in cells monitored. Cleared by
12760 * writing to the clr field.
12763 MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
12765 /* reg_sbpm_min_buff
12766 * Minimum buffer size for the limiter, in cells.
12769 MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
12771 /* reg_sbpm_max_buff
12772 * When the pool associated to the port-pg/tclass is configured to
12773 * static, Maximum buffer size for the limiter configured in cells.
12774 * When the pool associated to the port-pg/tclass is configured to
12775 * dynamic, the max_buff holds the "alpha" parameter, supporting
12776 * the following values:
12778 * i: (1/128)*2^(i-1), for i=1..14
12782 MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
12784 static inline void mlxsw_reg_sbpm_pack(char *payload, u16 local_port, u8 pool,
12785 enum mlxsw_reg_sbxx_dir dir, bool clr,
12786 u32 min_buff, u32 max_buff)
12788 MLXSW_REG_ZERO(sbpm, payload);
12789 mlxsw_reg_sbpm_local_port_set(payload, local_port);
12790 mlxsw_reg_sbpm_pool_set(payload, pool);
12791 mlxsw_reg_sbpm_dir_set(payload, dir);
12792 mlxsw_reg_sbpm_clr_set(payload, clr);
12793 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
12794 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
12797 static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
12798 u32 *p_max_buff_occupancy)
12800 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
12801 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
12804 /* SBMM - Shared Buffer Multicast Management Register
12805 * --------------------------------------------------
12806 * The SBMM register configures and retrieves the shared buffer allocation
12807 * and configuration for MC packets according to Switch-Priority, including
12808 * the binding to pool and definition of the associated quota.
12810 #define MLXSW_REG_SBMM_ID 0xB004
12811 #define MLXSW_REG_SBMM_LEN 0x28
12813 MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
12819 MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
12821 /* reg_sbmm_min_buff
12822 * Minimum buffer size for the limiter, in cells.
12825 MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
12827 /* reg_sbmm_max_buff
12828 * When the pool associated to the port-pg/tclass is configured to
12829 * static, Maximum buffer size for the limiter configured in cells.
12830 * When the pool associated to the port-pg/tclass is configured to
12831 * dynamic, the max_buff holds the "alpha" parameter, supporting
12832 * the following values:
12834 * i: (1/128)*2^(i-1), for i=1..14
12838 MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
12841 * Association of the port-priority to a pool.
12844 MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
12846 static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
12847 u32 max_buff, u8 pool)
12849 MLXSW_REG_ZERO(sbmm, payload);
12850 mlxsw_reg_sbmm_prio_set(payload, prio);
12851 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
12852 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
12853 mlxsw_reg_sbmm_pool_set(payload, pool);
12856 /* SBSR - Shared Buffer Status Register
12857 * ------------------------------------
12858 * The SBSR register retrieves the shared buffer occupancy according to
12859 * Port-Pool. Note that this register enables reading a large amount of data.
12860 * It is the user's responsibility to limit the amount of data to ensure the
12861 * response can match the maximum transfer unit. In case the response exceeds
12862 * the maximum transport unit, it will be truncated with no special notice.
12864 #define MLXSW_REG_SBSR_ID 0xB005
12865 #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
12866 #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
12867 #define MLXSW_REG_SBSR_REC_MAX_COUNT 120
12868 #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
12869 MLXSW_REG_SBSR_REC_LEN * \
12870 MLXSW_REG_SBSR_REC_MAX_COUNT)
12872 MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
12875 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
12876 * field is cleared (and a new max value is tracked from the time the clear
12880 MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
12882 #define MLXSW_REG_SBSR_NUM_PORTS_IN_PAGE 256
12884 /* reg_sbsr_port_page
12885 * Determines the range of the ports specified in the 'ingress_port_mask'
12886 * and 'egress_port_mask' bit masks.
12887 * {ingress,egress}_port_mask[x] is (256 * port_page) + x
12890 MLXSW_ITEM32(reg, sbsr, port_page, 0x04, 0, 4);
12892 /* reg_sbsr_ingress_port_mask
12893 * Bit vector for all ingress network ports.
12894 * Indicates which of the ports (for which the relevant bit is set)
12895 * are affected by the set operation. Configuration of any other port
12899 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
12901 /* reg_sbsr_pg_buff_mask
12902 * Bit vector for all switch priority groups.
12903 * Indicates which of the priorities (for which the relevant bit is set)
12904 * are affected by the set operation. Configuration of any other priority
12906 * Range is 0..cap_max_pg_buffers - 1
12909 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
12911 /* reg_sbsr_egress_port_mask
12912 * Bit vector for all egress network ports.
12913 * Indicates which of the ports (for which the relevant bit is set)
12914 * are affected by the set operation. Configuration of any other port
12918 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
12920 /* reg_sbsr_tclass_mask
12921 * Bit vector for all traffic classes.
12922 * Indicates which of the traffic classes (for which the relevant bit is
12923 * set) are affected by the set operation. Configuration of any other
12924 * traffic class does not change.
12925 * Range is 0..cap_max_tclass - 1
12928 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
12930 static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
12932 MLXSW_REG_ZERO(sbsr, payload);
12933 mlxsw_reg_sbsr_clr_set(payload, clr);
12936 /* reg_sbsr_rec_buff_occupancy
12937 * Current buffer occupancy in cells.
12940 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
12941 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
12943 /* reg_sbsr_rec_max_buff_occupancy
12944 * Maximum value of buffer occupancy in cells monitored. Cleared by
12945 * writing to the clr field.
12948 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
12949 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
12951 static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
12952 u32 *p_buff_occupancy,
12953 u32 *p_max_buff_occupancy)
12955 *p_buff_occupancy =
12956 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
12957 *p_max_buff_occupancy =
12958 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
12961 /* SBIB - Shared Buffer Internal Buffer Register
12962 * ---------------------------------------------
12963 * The SBIB register configures per port buffers for internal use. The internal
12964 * buffers consume memory on the port buffers (note that the port buffers are
12965 * used also by PBMC).
12967 * For Spectrum this is used for egress mirroring.
12969 #define MLXSW_REG_SBIB_ID 0xB006
12970 #define MLXSW_REG_SBIB_LEN 0x10
12972 MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
12974 /* reg_sbib_local_port
12975 * Local port number
12976 * Not supported for CPU port and router port
12979 MLXSW_ITEM32_LP(reg, sbib, 0x00, 16, 0x00, 12);
12981 /* reg_sbib_buff_size
12982 * Units represented in cells
12983 * Allowed range is 0 to (cap_max_headroom_size - 1)
12987 MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
12989 static inline void mlxsw_reg_sbib_pack(char *payload, u16 local_port,
12992 MLXSW_REG_ZERO(sbib, payload);
12993 mlxsw_reg_sbib_local_port_set(payload, local_port);
12994 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
12997 static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
13154 static inline const char *mlxsw_reg_id_str(u16 reg_id)
13156 const struct mlxsw_reg_info *reg_info;
13159 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
13160 reg_info = mlxsw_reg_infos[i];
13161 if (reg_info->id == reg_id)
13162 return reg_info->name;
13164 return "*UNKNOWN*";
13167 /* PUDE - Port Up / Down Event
13168 * ---------------------------
13169 * Reports the operational state change of a port.
13171 #define MLXSW_REG_PUDE_LEN 0x10
13174 * Switch partition ID with which to associate the port.
13177 MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
13179 /* reg_pude_local_port
13180 * Local port number.
13183 MLXSW_ITEM32_LP(reg, pude, 0x00, 16, 0x00, 12);
13185 /* reg_pude_admin_status
13186 * Port administrative state (the desired state).
13189 * 3 - Up once. This means that in case of link failure, the port won't go
13190 * into polling mode, but will wait to be re-enabled by software.
13191 * 4 - Disabled by system. Can only be set by hardware.
13194 MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
13196 /* reg_pude_oper_status
13197 * Port operatioanl state.
13200 * 3 - Down by port failure. This means that the device will not let the
13201 * port up again until explicitly specified by software.
13204 MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);