1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
7 #include <linux/kernel.h>
8 #include <linux/string.h>
9 #include <linux/bitops.h>
10 #include <linux/if_vlan.h>
15 struct mlxsw_reg_info {
21 #define MLXSW_REG_DEFINE(_name, _id, _len) \
22 static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
28 #define MLXSW_REG(type) (&mlxsw_reg_##type)
29 #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
30 #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
32 /* SGCR - Switch General Configuration Register
33 * --------------------------------------------
34 * This register is used for configuration of the switch capabilities.
36 #define MLXSW_REG_SGCR_ID 0x2000
37 #define MLXSW_REG_SGCR_LEN 0x10
39 MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
42 * Link Local Broadcast (Default=0)
43 * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
44 * packets and ignore the IGMP snooping entries.
47 MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
49 static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
51 MLXSW_REG_ZERO(sgcr, payload);
52 mlxsw_reg_sgcr_llb_set(payload, !!llb);
55 /* SPAD - Switch Physical Address Register
56 * ---------------------------------------
57 * The SPAD register configures the switch physical MAC address.
59 #define MLXSW_REG_SPAD_ID 0x2002
60 #define MLXSW_REG_SPAD_LEN 0x10
62 MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
65 * Base MAC address for the switch partitions.
66 * Per switch partition MAC address is equal to:
70 MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
72 /* 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);
101 * Virtual port within the physical port.
102 * Should be set to 0 when virtual ports are not enabled on the port.
106 MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
108 /* reg_sspr_system_port
109 * Unique identifier within the stacking domain that represents all the ports
110 * that are available in the system (external ports).
112 * Currently, only single-ASIC configurations are supported, so we default to
113 * 1:1 mapping between system ports and local ports.
116 MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
118 static inline void mlxsw_reg_sspr_pack(char *payload, u16 local_port)
120 MLXSW_REG_ZERO(sspr, payload);
121 mlxsw_reg_sspr_m_set(payload, 1);
122 mlxsw_reg_sspr_local_port_set(payload, local_port);
123 mlxsw_reg_sspr_sub_port_set(payload, 0);
124 mlxsw_reg_sspr_system_port_set(payload, local_port);
127 /* SFDAT - Switch Filtering Database Aging Time
128 * --------------------------------------------
129 * Controls the Switch aging time. Aging time is able to be set per Switch
132 #define MLXSW_REG_SFDAT_ID 0x2009
133 #define MLXSW_REG_SFDAT_LEN 0x8
135 MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
138 * Switch partition ID.
141 MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
143 /* reg_sfdat_age_time
144 * Aging time in seconds
146 * Max - 1,000,000 seconds
147 * Default is 300 seconds.
150 MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
152 static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
154 MLXSW_REG_ZERO(sfdat, payload);
155 mlxsw_reg_sfdat_swid_set(payload, 0);
156 mlxsw_reg_sfdat_age_time_set(payload, age_time);
159 /* SFD - Switch Filtering Database
160 * -------------------------------
161 * The following register defines the access to the filtering database.
162 * The register supports querying, adding, removing and modifying the database.
163 * The access is optimized for bulk updates in which case more than one
164 * FDB record is present in the same command.
166 #define MLXSW_REG_SFD_ID 0x200A
167 #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
168 #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
169 #define MLXSW_REG_SFD_REC_MAX_COUNT 64
170 #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
171 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
173 MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
176 * Switch partition ID for queries. Reserved on Write.
179 MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
181 enum mlxsw_reg_sfd_op {
182 /* Dump entire FDB a (process according to record_locator) */
183 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
184 /* Query records by {MAC, VID/FID} value */
185 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
186 /* Query and clear activity. Query records by {MAC, VID/FID} value */
187 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
188 /* Test. Response indicates if each of the records could be
191 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
192 /* Add/modify. Aged-out records cannot be added. This command removes
193 * the learning notification of the {MAC, VID/FID}. Response includes
194 * the entries that were added to the FDB.
196 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
197 /* Remove record by {MAC, VID/FID}. This command also removes
198 * the learning notification and aged-out notifications
199 * of the {MAC, VID/FID}. The response provides current (pre-removal)
200 * entries as non-aged-out.
202 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
203 /* Remove learned notification by {MAC, VID/FID}. The response provides
204 * the removed learning notification.
206 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
213 MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
215 /* reg_sfd_record_locator
216 * Used for querying the FDB. Use record_locator=0 to initiate the
217 * query. When a record is returned, a new record_locator is
218 * returned to be used in the subsequent query.
219 * Reserved for database update.
222 MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
225 * Request: Number of records to read/add/modify/remove
226 * Response: Number of records read/added/replaced/removed
227 * See above description for more details.
231 MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
233 static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
236 MLXSW_REG_ZERO(sfd, payload);
237 mlxsw_reg_sfd_op_set(payload, op);
238 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
242 * Switch partition ID.
245 MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
246 MLXSW_REG_SFD_REC_LEN, 0x00, false);
248 enum mlxsw_reg_sfd_rec_type {
249 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
250 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
251 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
252 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC,
259 MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
260 MLXSW_REG_SFD_REC_LEN, 0x00, false);
262 enum mlxsw_reg_sfd_rec_policy {
263 /* Replacement disabled, aging disabled. */
264 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
265 /* (mlag remote): Replacement enabled, aging disabled,
266 * learning notification enabled on this port.
268 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
269 /* (ingress device): Replacement enabled, aging enabled. */
270 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
273 /* reg_sfd_rec_policy
277 MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
278 MLXSW_REG_SFD_REC_LEN, 0x00, false);
281 * Activity. Set for new static entries. Set for static entries if a frame SMAC
282 * lookup hits on the entry.
283 * To clear the a bit, use "query and clear activity" op.
286 MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
287 MLXSW_REG_SFD_REC_LEN, 0x00, false);
293 MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
294 MLXSW_REG_SFD_REC_LEN, 0x02);
296 enum mlxsw_reg_sfd_rec_action {
298 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
299 /* forward and trap, trap_id is FDB_TRAP */
300 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
301 /* trap and do not forward, trap_id is FDB_TRAP */
302 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
303 /* forward to IP router */
304 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
305 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
308 /* reg_sfd_rec_action
309 * Action to apply on the packet.
310 * Note: Dynamic entries can only be configured with NOP action.
313 MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
314 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
316 /* reg_sfd_uc_sub_port
317 * VEPA channel on local port.
318 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
319 * VEPA is not enabled.
322 MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
323 MLXSW_REG_SFD_REC_LEN, 0x08, false);
325 /* reg_sfd_uc_fid_vid
326 * Filtering ID or VLAN ID
327 * For SwitchX and SwitchX-2:
328 * - Dynamic entries (policy 2,3) use FID
329 * - Static entries (policy 0) use VID
330 * - When independent learning is configured, VID=FID
331 * For Spectrum: use FID for both Dynamic and Static entries.
332 * VID should not be used.
335 MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
336 MLXSW_REG_SFD_REC_LEN, 0x08, false);
338 /* reg_sfd_uc_system_port
339 * Unique port identifier for the final destination of the packet.
342 MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
343 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
345 static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
346 enum mlxsw_reg_sfd_rec_type rec_type,
348 enum mlxsw_reg_sfd_rec_action action)
350 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
352 if (rec_index >= num_rec)
353 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
354 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
355 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
356 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
357 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
360 static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
361 enum mlxsw_reg_sfd_rec_policy policy,
362 const char *mac, u16 fid_vid,
363 enum mlxsw_reg_sfd_rec_action action,
366 mlxsw_reg_sfd_rec_pack(payload, rec_index,
367 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
368 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
369 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
370 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
371 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
374 /* reg_sfd_uc_lag_sub_port
376 * Must be 0 if multichannel VEPA is not enabled.
379 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
380 MLXSW_REG_SFD_REC_LEN, 0x08, false);
382 /* reg_sfd_uc_lag_fid_vid
383 * Filtering ID or VLAN ID
384 * For SwitchX and SwitchX-2:
385 * - Dynamic entries (policy 2,3) use FID
386 * - Static entries (policy 0) use VID
387 * - When independent learning is configured, VID=FID
388 * For Spectrum: use FID for both Dynamic and Static entries.
389 * VID should not be used.
392 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
393 MLXSW_REG_SFD_REC_LEN, 0x08, false);
395 /* reg_sfd_uc_lag_lag_vid
396 * Indicates VID in case of vFIDs. Reserved for FIDs.
399 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
400 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
402 /* reg_sfd_uc_lag_lag_id
403 * LAG Identifier - pointer into the LAG descriptor table.
406 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
407 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
410 mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
411 enum mlxsw_reg_sfd_rec_policy policy,
412 const char *mac, u16 fid_vid,
413 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
416 mlxsw_reg_sfd_rec_pack(payload, rec_index,
417 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
419 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
420 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
421 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
422 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
423 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
428 * Multicast port group index - index into the port group table.
429 * Value 0x1FFF indicates the pgi should point to the MID entry.
430 * For Spectrum this value must be set to 0x1FFF
433 MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
434 MLXSW_REG_SFD_REC_LEN, 0x08, false);
436 /* reg_sfd_mc_fid_vid
438 * Filtering ID or VLAN ID
441 MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
442 MLXSW_REG_SFD_REC_LEN, 0x08, false);
446 * Multicast identifier - global identifier that represents the multicast
447 * group across all devices.
450 MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
451 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
454 mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
455 const char *mac, u16 fid_vid,
456 enum mlxsw_reg_sfd_rec_action action, u16 mid)
458 mlxsw_reg_sfd_rec_pack(payload, rec_index,
459 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
460 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
461 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
462 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
465 /* reg_sfd_uc_tunnel_uip_msb
466 * When protocol is IPv4, the most significant byte of the underlay IPv4
468 * When protocol is IPv6, reserved.
471 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24,
472 8, MLXSW_REG_SFD_REC_LEN, 0x08, false);
474 /* reg_sfd_uc_tunnel_fid
478 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
479 MLXSW_REG_SFD_REC_LEN, 0x08, false);
481 enum mlxsw_reg_sfd_uc_tunnel_protocol {
482 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4,
483 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6,
486 /* reg_sfd_uc_tunnel_protocol
490 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27,
491 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
493 /* reg_sfd_uc_tunnel_uip_lsb
494 * When protocol is IPv4, the least significant bytes of the underlay
495 * IPv4 destination IP.
496 * When protocol is IPv6, pointer to the underlay IPv6 destination IP
497 * which is configured by RIPS.
500 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0,
501 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
504 mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
505 enum mlxsw_reg_sfd_rec_policy policy,
506 const char *mac, u16 fid,
507 enum mlxsw_reg_sfd_rec_action action,
508 enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
510 mlxsw_reg_sfd_rec_pack(payload, rec_index,
511 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
513 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
514 mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
515 mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
519 mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index,
520 enum mlxsw_reg_sfd_rec_policy policy,
521 const char *mac, u16 fid,
522 enum mlxsw_reg_sfd_rec_action action, u32 uip)
524 mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
525 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
526 mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, policy, mac, fid,
528 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4);
532 mlxsw_reg_sfd_uc_tunnel_pack6(char *payload, int rec_index, const char *mac,
533 u16 fid, enum mlxsw_reg_sfd_rec_action action,
536 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip_ptr);
537 /* Only static policy is supported for IPv6 unicast tunnel entry. */
538 mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index,
539 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY,
541 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6);
544 enum mlxsw_reg_tunnel_port {
545 MLXSW_REG_TUNNEL_PORT_NVE,
546 MLXSW_REG_TUNNEL_PORT_VPLS,
547 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL0,
548 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL1,
551 /* SFN - Switch FDB Notification Register
552 * -------------------------------------------
553 * The switch provides notifications on newly learned FDB entries and
554 * aged out entries. The notifications can be polled by software.
556 #define MLXSW_REG_SFN_ID 0x200B
557 #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
558 #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
559 #define MLXSW_REG_SFN_REC_MAX_COUNT 64
560 #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
561 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
563 MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
566 * Switch partition ID.
569 MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
572 * Forces the current session to end.
575 MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
578 * Request: Number of learned notifications and aged-out notification
580 * Response: Number of notification records returned (must be smaller
581 * than or equal to the value requested)
585 MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
587 static inline void mlxsw_reg_sfn_pack(char *payload)
589 MLXSW_REG_ZERO(sfn, payload);
590 mlxsw_reg_sfn_swid_set(payload, 0);
591 mlxsw_reg_sfn_end_set(payload, 0);
592 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
596 * Switch partition ID.
599 MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
600 MLXSW_REG_SFN_REC_LEN, 0x00, false);
602 enum mlxsw_reg_sfn_rec_type {
603 /* MAC addresses learned on a regular port. */
604 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
605 /* MAC addresses learned on a LAG port. */
606 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
607 /* Aged-out MAC address on a regular port. */
608 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
609 /* Aged-out MAC address on a LAG port. */
610 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
611 /* Learned unicast tunnel record. */
612 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
613 /* Aged-out unicast tunnel record. */
614 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
618 * Notification record type.
621 MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
622 MLXSW_REG_SFN_REC_LEN, 0x00, false);
628 MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
629 MLXSW_REG_SFN_REC_LEN, 0x02);
631 /* reg_sfn_mac_sub_port
632 * VEPA channel on the local port.
633 * 0 if multichannel VEPA is not enabled.
636 MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
637 MLXSW_REG_SFN_REC_LEN, 0x08, false);
640 * Filtering identifier.
643 MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
644 MLXSW_REG_SFN_REC_LEN, 0x08, false);
646 /* reg_sfn_mac_system_port
647 * Unique port identifier for the final destination of the packet.
650 MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
651 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
653 static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
654 char *mac, u16 *p_vid,
657 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
658 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
659 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
662 /* reg_sfn_mac_lag_lag_id
663 * LAG ID (pointer into the LAG descriptor table).
666 MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
667 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
669 static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
670 char *mac, u16 *p_vid,
673 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
674 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
675 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
678 /* reg_sfn_uc_tunnel_uip_msb
679 * When protocol is IPv4, the most significant byte of the underlay IPv4
680 * address of the remote VTEP.
681 * When protocol is IPv6, reserved.
684 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
685 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
687 enum mlxsw_reg_sfn_uc_tunnel_protocol {
688 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
689 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
692 /* reg_sfn_uc_tunnel_protocol
696 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
697 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
699 /* reg_sfn_uc_tunnel_uip_lsb
700 * When protocol is IPv4, the least significant bytes of the underlay
701 * IPv4 address of the remote VTEP.
702 * When protocol is IPv6, ipv6_id to be queried from TNIPSD.
705 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
706 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
708 /* reg_sfn_uc_tunnel_port
710 * Reserved on Spectrum.
713 MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4,
714 MLXSW_REG_SFN_REC_LEN, 0x10, false);
717 mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac,
718 u16 *p_fid, u32 *p_uip,
719 enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto)
721 u32 uip_msb, uip_lsb;
723 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
724 *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
725 uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index);
726 uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index);
727 *p_uip = uip_msb << 24 | uip_lsb;
728 *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index);
731 /* SPMS - Switch Port MSTP/RSTP State Register
732 * -------------------------------------------
733 * Configures the spanning tree state of a physical port.
735 #define MLXSW_REG_SPMS_ID 0x200D
736 #define MLXSW_REG_SPMS_LEN 0x404
738 MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
740 /* reg_spms_local_port
744 MLXSW_ITEM32_LP(reg, spms, 0x00, 16, 0x00, 12);
746 enum mlxsw_reg_spms_state {
747 MLXSW_REG_SPMS_STATE_NO_CHANGE,
748 MLXSW_REG_SPMS_STATE_DISCARDING,
749 MLXSW_REG_SPMS_STATE_LEARNING,
750 MLXSW_REG_SPMS_STATE_FORWARDING,
754 * Spanning tree state of each VLAN ID (VID) of the local port.
755 * 0 - Do not change spanning tree state (used only when writing).
756 * 1 - Discarding. No learning or forwarding to/from this port (default).
757 * 2 - Learning. Port is learning, but not forwarding.
758 * 3 - Forwarding. Port is learning and forwarding.
761 MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
763 static inline void mlxsw_reg_spms_pack(char *payload, u16 local_port)
765 MLXSW_REG_ZERO(spms, payload);
766 mlxsw_reg_spms_local_port_set(payload, local_port);
769 static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
770 enum mlxsw_reg_spms_state state)
772 mlxsw_reg_spms_state_set(payload, vid, state);
775 /* SPVID - Switch Port VID
776 * -----------------------
777 * The switch port VID configures the default VID for a port.
779 #define MLXSW_REG_SPVID_ID 0x200E
780 #define MLXSW_REG_SPVID_LEN 0x08
782 MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
785 * Port is tunnel port.
786 * Reserved when SwitchX/-2 or Spectrum-1.
789 MLXSW_ITEM32(reg, spvid, tport, 0x00, 24, 1);
791 /* reg_spvid_local_port
792 * When tport = 0: Local port number. Not supported for CPU port.
793 * When tport = 1: Tunnel port.
796 MLXSW_ITEM32_LP(reg, spvid, 0x00, 16, 0x00, 12);
798 /* reg_spvid_sub_port
799 * Virtual port within the physical port.
800 * Should be set to 0 when virtual ports are not enabled on the port.
803 MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
805 /* reg_spvid_egr_et_set
806 * When VLAN is pushed at ingress (for untagged packets or for
807 * QinQ push mode) then the EtherType is decided at the egress port.
808 * Reserved when Spectrum-1.
811 MLXSW_ITEM32(reg, spvid, egr_et_set, 0x04, 24, 1);
814 * EtherType used for when VLAN is pushed at ingress (for untagged
815 * packets or for QinQ push mode).
816 * 0: ether_type0 - (default)
818 * 2: ether_type2 - Reserved when Spectrum-1, supported by Spectrum-2
819 * Ethertype IDs are configured by SVER.
820 * Reserved when egr_et_set = 1.
823 MLXSW_ITEM32(reg, spvid, et_vlan, 0x04, 16, 2);
829 MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
831 static inline void mlxsw_reg_spvid_pack(char *payload, u16 local_port, u16 pvid,
834 MLXSW_REG_ZERO(spvid, payload);
835 mlxsw_reg_spvid_local_port_set(payload, local_port);
836 mlxsw_reg_spvid_pvid_set(payload, pvid);
837 mlxsw_reg_spvid_et_vlan_set(payload, et_vlan);
840 /* SPVM - Switch Port VLAN Membership
841 * ----------------------------------
842 * The Switch Port VLAN Membership register configures the VLAN membership
843 * of a port in a VLAN denoted by VID. VLAN membership is managed per
844 * virtual port. The register can be used to add and remove VID(s) from a port.
846 #define MLXSW_REG_SPVM_ID 0x200F
847 #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
848 #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
849 #define MLXSW_REG_SPVM_REC_MAX_COUNT 255
850 #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
851 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
853 MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
856 * Priority tagged. If this bit is set, packets forwarded to the port with
857 * untagged VLAN membership (u bit is set) will be tagged with priority tag
861 MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
864 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
865 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
868 MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
870 /* reg_spvm_local_port
874 MLXSW_ITEM32_LP(reg, spvm, 0x00, 16, 0x00, 12);
877 * Virtual port within the physical port.
878 * Should be set to 0 when virtual ports are not enabled on the port.
881 MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
884 * Number of records to update. Each record contains: i, e, u, vid.
887 MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
890 * Ingress membership in VLAN ID.
893 MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
894 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
895 MLXSW_REG_SPVM_REC_LEN, 0, false);
898 * Egress membership in VLAN ID.
901 MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
902 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
903 MLXSW_REG_SPVM_REC_LEN, 0, false);
906 * Untagged - port is an untagged member - egress transmission uses untagged
910 MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
911 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
912 MLXSW_REG_SPVM_REC_LEN, 0, false);
915 * Egress membership in VLAN ID.
918 MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
919 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
920 MLXSW_REG_SPVM_REC_LEN, 0, false);
922 static inline void mlxsw_reg_spvm_pack(char *payload, u16 local_port,
923 u16 vid_begin, u16 vid_end,
924 bool is_member, bool untagged)
926 int size = vid_end - vid_begin + 1;
929 MLXSW_REG_ZERO(spvm, payload);
930 mlxsw_reg_spvm_local_port_set(payload, local_port);
931 mlxsw_reg_spvm_num_rec_set(payload, size);
933 for (i = 0; i < size; i++) {
934 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
935 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
936 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
937 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
941 /* SPAFT - Switch Port Acceptable Frame Types
942 * ------------------------------------------
943 * The Switch Port Acceptable Frame Types register configures the frame
944 * admittance of the port.
946 #define MLXSW_REG_SPAFT_ID 0x2010
947 #define MLXSW_REG_SPAFT_LEN 0x08
949 MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
951 /* reg_spaft_local_port
955 * Note: CPU port is not supported (all tag types are allowed).
957 MLXSW_ITEM32_LP(reg, spaft, 0x00, 16, 0x00, 12);
959 /* reg_spaft_sub_port
960 * Virtual port within the physical port.
961 * Should be set to 0 when virtual ports are not enabled on the port.
964 MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
966 /* reg_spaft_allow_untagged
967 * When set, untagged frames on the ingress are allowed (default).
970 MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
972 /* reg_spaft_allow_prio_tagged
973 * When set, priority tagged frames on the ingress are allowed (default).
976 MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
978 /* reg_spaft_allow_tagged
979 * When set, tagged frames on the ingress are allowed (default).
982 MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
984 static inline void mlxsw_reg_spaft_pack(char *payload, u16 local_port,
987 MLXSW_REG_ZERO(spaft, payload);
988 mlxsw_reg_spaft_local_port_set(payload, local_port);
989 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
990 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
991 mlxsw_reg_spaft_allow_tagged_set(payload, true);
994 /* SFGC - Switch Flooding Group Configuration
995 * ------------------------------------------
996 * The following register controls the association of flooding tables and MIDs
997 * to packet types used for flooding.
999 #define MLXSW_REG_SFGC_ID 0x2011
1000 #define MLXSW_REG_SFGC_LEN 0x10
1002 MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
1004 enum mlxsw_reg_sfgc_type {
1005 MLXSW_REG_SFGC_TYPE_BROADCAST,
1006 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
1007 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
1008 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
1009 MLXSW_REG_SFGC_TYPE_RESERVED,
1010 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
1011 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
1012 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
1013 MLXSW_REG_SFGC_TYPE_MAX,
1017 * The traffic type to reach the flooding table.
1020 MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
1022 enum mlxsw_reg_sfgc_bridge_type {
1023 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
1024 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
1027 /* reg_sfgc_bridge_type
1030 * Note: SwitchX-2 only supports 802.1Q mode.
1032 MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
1034 enum mlxsw_flood_table_type {
1035 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
1036 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
1037 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
1038 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
1039 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
1042 /* reg_sfgc_table_type
1043 * See mlxsw_flood_table_type
1046 * Note: FID offset and FID types are not supported in SwitchX-2.
1048 MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
1050 /* reg_sfgc_flood_table
1051 * Flooding table index to associate with the specific type on the specific
1055 MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
1058 * The multicast ID for the swid. Not supported for Spectrum
1061 MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
1063 /* reg_sfgc_counter_set_type
1064 * Counter Set Type for flow counters.
1067 MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
1069 /* reg_sfgc_counter_index
1070 * Counter Index for flow counters.
1073 MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
1076 mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1077 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1078 enum mlxsw_flood_table_type table_type,
1079 unsigned int flood_table)
1081 MLXSW_REG_ZERO(sfgc, payload);
1082 mlxsw_reg_sfgc_type_set(payload, type);
1083 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1084 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1085 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1086 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1089 /* SFDF - Switch Filtering DB Flush
1090 * --------------------------------
1091 * The switch filtering DB flush register is used to flush the FDB.
1092 * Note that FDB notifications are flushed as well.
1094 #define MLXSW_REG_SFDF_ID 0x2013
1095 #define MLXSW_REG_SFDF_LEN 0x14
1097 MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
1100 * Switch partition ID.
1103 MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1105 enum mlxsw_reg_sfdf_flush_type {
1106 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1107 MLXSW_REG_SFDF_FLUSH_PER_FID,
1108 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1109 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1110 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1111 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1112 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1113 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
1116 /* reg_sfdf_flush_type
1118 * 0 - All SWID dynamic entries are flushed.
1119 * 1 - All FID dynamic entries are flushed.
1120 * 2 - All dynamic entries pointing to port are flushed.
1121 * 3 - All FID dynamic entries pointing to port are flushed.
1122 * 4 - All dynamic entries pointing to LAG are flushed.
1123 * 5 - All FID dynamic entries pointing to LAG are flushed.
1124 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1126 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1130 MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1132 /* reg_sfdf_flush_static
1134 * 0 - Flush only dynamic entries.
1135 * 1 - Flush both dynamic and static entries.
1138 MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1140 static inline void mlxsw_reg_sfdf_pack(char *payload,
1141 enum mlxsw_reg_sfdf_flush_type type)
1143 MLXSW_REG_ZERO(sfdf, payload);
1144 mlxsw_reg_sfdf_flush_type_set(payload, type);
1145 mlxsw_reg_sfdf_flush_static_set(payload, true);
1152 MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1154 /* reg_sfdf_system_port
1158 MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1160 /* reg_sfdf_port_fid_system_port
1161 * Port to flush, pointed to by FID.
1164 MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1170 MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1172 /* reg_sfdf_lag_fid_lag_id
1173 * LAG ID to flush, pointed to by FID.
1176 MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1178 /* SLDR - Switch LAG Descriptor Register
1179 * -----------------------------------------
1180 * The switch LAG descriptor register is populated by LAG descriptors.
1181 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1184 #define MLXSW_REG_SLDR_ID 0x2014
1185 #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1187 MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
1189 enum mlxsw_reg_sldr_op {
1190 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1191 MLXSW_REG_SLDR_OP_LAG_CREATE,
1192 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1193 /* Ports that appear in the list have the Distributor enabled */
1194 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1195 /* Removes ports from the disributor list */
1196 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1203 MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1206 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1209 MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1211 static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1213 MLXSW_REG_ZERO(sldr, payload);
1214 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1215 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1218 static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1220 MLXSW_REG_ZERO(sldr, payload);
1221 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1222 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1225 /* reg_sldr_num_ports
1226 * The number of member ports of the LAG.
1227 * Reserved for Create / Destroy operations
1228 * For Add / Remove operations - indicates the number of ports in the list.
1231 MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1233 /* reg_sldr_system_port
1237 MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1239 static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1242 MLXSW_REG_ZERO(sldr, payload);
1243 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1244 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1245 mlxsw_reg_sldr_num_ports_set(payload, 1);
1246 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1249 static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1252 MLXSW_REG_ZERO(sldr, payload);
1253 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1254 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1255 mlxsw_reg_sldr_num_ports_set(payload, 1);
1256 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1259 /* SLCR - Switch LAG Configuration 2 Register
1260 * -------------------------------------------
1261 * The Switch LAG Configuration register is used for configuring the
1262 * LAG properties of the switch.
1264 #define MLXSW_REG_SLCR_ID 0x2015
1265 #define MLXSW_REG_SLCR_LEN 0x10
1267 MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
1269 enum mlxsw_reg_slcr_pp {
1270 /* Global Configuration (for all ports) */
1271 MLXSW_REG_SLCR_PP_GLOBAL,
1272 /* Per port configuration, based on local_port field */
1273 MLXSW_REG_SLCR_PP_PER_PORT,
1277 * Per Port Configuration
1278 * Note: Reading at Global mode results in reading port 1 configuration.
1281 MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1283 /* reg_slcr_local_port
1285 * Supported from CPU port
1286 * Not supported from router port
1287 * Reserved when pp = Global Configuration
1290 MLXSW_ITEM32_LP(reg, slcr, 0x00, 16, 0x00, 12);
1292 enum mlxsw_reg_slcr_type {
1293 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1294 MLXSW_REG_SLCR_TYPE_XOR,
1295 MLXSW_REG_SLCR_TYPE_RANDOM,
1302 MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1305 #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1306 /* SMAC - for IPv4 and IPv6 packets */
1307 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1308 /* SMAC - for non-IP packets */
1309 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1310 #define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1311 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1312 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1313 /* DMAC - for IPv4 and IPv6 packets */
1314 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1315 /* DMAC - for non-IP packets */
1316 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1317 #define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1318 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1319 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1320 /* Ethertype - for IPv4 and IPv6 packets */
1321 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1322 /* Ethertype - for non-IP packets */
1323 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1324 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1325 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1326 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1327 /* VLAN ID - for IPv4 and IPv6 packets */
1328 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1329 /* VLAN ID - for non-IP packets */
1330 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1331 #define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1332 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1333 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1334 /* Source IP address (can be IPv4 or IPv6) */
1335 #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1336 /* Destination IP address (can be IPv4 or IPv6) */
1337 #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1338 /* TCP/UDP source port */
1339 #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1340 /* TCP/UDP destination port*/
1341 #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1342 /* IPv4 Protocol/IPv6 Next Header */
1343 #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1344 /* IPv6 Flow label */
1345 #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1346 /* SID - FCoE source ID */
1347 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1348 /* DID - FCoE destination ID */
1349 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1350 /* OXID - FCoE originator exchange ID */
1351 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1352 /* Destination QP number - for RoCE packets */
1353 #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1355 /* reg_slcr_lag_hash
1356 * LAG hashing configuration. This is a bitmask, in which each set
1357 * bit includes the corresponding item in the LAG hash calculation.
1358 * The default lag_hash contains SMAC, DMAC, VLANID and
1359 * Ethertype (for all packet types).
1362 MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1365 * LAG seed value. The seed is the same for all ports.
1368 MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1370 static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
1372 MLXSW_REG_ZERO(slcr, payload);
1373 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
1374 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
1375 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1376 mlxsw_reg_slcr_seed_set(payload, seed);
1379 /* SLCOR - Switch LAG Collector Register
1380 * -------------------------------------
1381 * The Switch LAG Collector register controls the Local Port membership
1382 * in a LAG and enablement of the collector.
1384 #define MLXSW_REG_SLCOR_ID 0x2016
1385 #define MLXSW_REG_SLCOR_LEN 0x10
1387 MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
1389 enum mlxsw_reg_slcor_col {
1390 /* Port is added with collector disabled */
1391 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1392 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1393 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1394 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1398 * Collector configuration
1401 MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1403 /* reg_slcor_local_port
1405 * Not supported for CPU port
1408 MLXSW_ITEM32_LP(reg, slcor, 0x00, 16, 0x00, 12);
1411 * LAG Identifier. Index into the LAG descriptor table.
1414 MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1416 /* reg_slcor_port_index
1417 * Port index in the LAG list. Only valid on Add Port to LAG col.
1418 * Valid range is from 0 to cap_max_lag_members-1
1421 MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1423 static inline void mlxsw_reg_slcor_pack(char *payload,
1424 u16 local_port, u16 lag_id,
1425 enum mlxsw_reg_slcor_col col)
1427 MLXSW_REG_ZERO(slcor, payload);
1428 mlxsw_reg_slcor_col_set(payload, col);
1429 mlxsw_reg_slcor_local_port_set(payload, local_port);
1430 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1433 static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1434 u16 local_port, u16 lag_id,
1437 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1438 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1439 mlxsw_reg_slcor_port_index_set(payload, port_index);
1442 static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1443 u16 local_port, u16 lag_id)
1445 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1446 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1449 static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1450 u16 local_port, u16 lag_id)
1452 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1453 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1456 static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1457 u16 local_port, u16 lag_id)
1459 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1460 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1463 /* SPMLR - Switch Port MAC Learning Register
1464 * -----------------------------------------
1465 * Controls the Switch MAC learning policy per port.
1467 #define MLXSW_REG_SPMLR_ID 0x2018
1468 #define MLXSW_REG_SPMLR_LEN 0x8
1470 MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
1472 /* reg_spmlr_local_port
1473 * Local port number.
1476 MLXSW_ITEM32_LP(reg, spmlr, 0x00, 16, 0x00, 12);
1478 /* reg_spmlr_sub_port
1479 * Virtual port within the physical port.
1480 * Should be set to 0 when virtual ports are not enabled on the port.
1483 MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1485 enum mlxsw_reg_spmlr_learn_mode {
1486 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1487 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1488 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1491 /* reg_spmlr_learn_mode
1492 * Learning mode on the port.
1493 * 0 - Learning disabled.
1494 * 2 - Learning enabled.
1495 * 3 - Security mode.
1497 * In security mode the switch does not learn MACs on the port, but uses the
1498 * SMAC to see if it exists on another ingress port. If so, the packet is
1499 * classified as a bad packet and is discarded unless the software registers
1500 * to receive port security error packets usign HPKT.
1502 MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1504 static inline void mlxsw_reg_spmlr_pack(char *payload, u16 local_port,
1505 enum mlxsw_reg_spmlr_learn_mode mode)
1507 MLXSW_REG_ZERO(spmlr, payload);
1508 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1509 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1510 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1513 /* SVFA - Switch VID to FID Allocation Register
1514 * --------------------------------------------
1515 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1516 * virtualized ports.
1518 #define MLXSW_REG_SVFA_ID 0x201C
1519 #define MLXSW_REG_SVFA_LEN 0x10
1521 MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
1524 * Switch partition ID.
1527 MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1529 /* reg_svfa_local_port
1530 * Local port number.
1533 * Note: Reserved for 802.1Q FIDs.
1535 MLXSW_ITEM32_LP(reg, svfa, 0x00, 16, 0x00, 12);
1537 enum mlxsw_reg_svfa_mt {
1538 MLXSW_REG_SVFA_MT_VID_TO_FID,
1539 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1542 /* reg_svfa_mapping_table
1545 * 1 - {Port, VID} to FID
1548 * Note: Reserved for SwitchX-2.
1550 MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1557 * Note: Reserved for SwitchX-2.
1559 MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1565 MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1571 MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1573 /* reg_svfa_counter_set_type
1574 * Counter set type for flow counters.
1577 * Note: Reserved for SwitchX-2.
1579 MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1581 /* reg_svfa_counter_index
1582 * Counter index for flow counters.
1585 * Note: Reserved for SwitchX-2.
1587 MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1589 static inline void mlxsw_reg_svfa_pack(char *payload, u16 local_port,
1590 enum mlxsw_reg_svfa_mt mt, bool valid,
1593 MLXSW_REG_ZERO(svfa, payload);
1594 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1595 mlxsw_reg_svfa_swid_set(payload, 0);
1596 mlxsw_reg_svfa_local_port_set(payload, local_port);
1597 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1598 mlxsw_reg_svfa_v_set(payload, valid);
1599 mlxsw_reg_svfa_fid_set(payload, fid);
1600 mlxsw_reg_svfa_vid_set(payload, vid);
1603 /* SPVTR - Switch Port VLAN Stacking Register
1604 * ------------------------------------------
1605 * The Switch Port VLAN Stacking register configures the VLAN mode of the port
1606 * to enable VLAN stacking.
1608 #define MLXSW_REG_SPVTR_ID 0x201D
1609 #define MLXSW_REG_SPVTR_LEN 0x10
1611 MLXSW_REG_DEFINE(spvtr, MLXSW_REG_SPVTR_ID, MLXSW_REG_SPVTR_LEN);
1614 * Port is tunnel port.
1617 * Note: Reserved when SwitchX/-2 or Spectrum-1.
1619 MLXSW_ITEM32(reg, spvtr, tport, 0x00, 24, 1);
1621 /* reg_spvtr_local_port
1622 * When tport = 0: local port number (Not supported from/to CPU).
1623 * When tport = 1: tunnel port.
1626 MLXSW_ITEM32_LP(reg, spvtr, 0x00, 16, 0x00, 12);
1629 * Ingress Port Prio Mode Update Enable.
1630 * When set, the Port Prio Mode is updated with the provided ipprio_mode field.
1631 * Reserved on Get operations.
1634 MLXSW_ITEM32(reg, spvtr, ippe, 0x04, 31, 1);
1637 * Ingress Port VID Mode Update Enable.
1638 * When set, the Ingress Port VID Mode is updated with the provided ipvid_mode
1640 * Reserved on Get operations.
1643 MLXSW_ITEM32(reg, spvtr, ipve, 0x04, 30, 1);
1646 * Egress Port VID Mode Update Enable.
1647 * When set, the Egress Port VID Mode is updated with the provided epvid_mode
1651 MLXSW_ITEM32(reg, spvtr, epve, 0x04, 29, 1);
1653 /* reg_spvtr_ipprio_mode
1654 * Ingress Port Priority Mode.
1655 * This controls the PCP and DEI of the new outer VLAN
1656 * Note: for SwitchX/-2 the DEI is not affected.
1657 * 0: use port default PCP and DEI (configured by QPDPC).
1658 * 1: use C-VLAN PCP and DEI.
1659 * Has no effect when ipvid_mode = 0.
1660 * Reserved when tport = 1.
1663 MLXSW_ITEM32(reg, spvtr, ipprio_mode, 0x04, 20, 4);
1665 enum mlxsw_reg_spvtr_ipvid_mode {
1666 /* IEEE Compliant PVID (default) */
1667 MLXSW_REG_SPVTR_IPVID_MODE_IEEE_COMPLIANT_PVID,
1668 /* Push VLAN (for VLAN stacking, except prio tagged packets) */
1669 MLXSW_REG_SPVTR_IPVID_MODE_PUSH_VLAN_FOR_UNTAGGED_PACKET,
1670 /* Always push VLAN (also for prio tagged packets) */
1671 MLXSW_REG_SPVTR_IPVID_MODE_ALWAYS_PUSH_VLAN,
1674 /* reg_spvtr_ipvid_mode
1675 * Ingress Port VLAN-ID Mode.
1676 * For Spectrum family, this affects the values of SPVM.i
1679 MLXSW_ITEM32(reg, spvtr, ipvid_mode, 0x04, 16, 4);
1681 enum mlxsw_reg_spvtr_epvid_mode {
1682 /* IEEE Compliant VLAN membership */
1683 MLXSW_REG_SPVTR_EPVID_MODE_IEEE_COMPLIANT_VLAN_MEMBERSHIP,
1684 /* Pop VLAN (for VLAN stacking) */
1685 MLXSW_REG_SPVTR_EPVID_MODE_POP_VLAN,
1688 /* reg_spvtr_epvid_mode
1689 * Egress Port VLAN-ID Mode.
1690 * For Spectrum family, this affects the values of SPVM.e,u,pt.
1693 MLXSW_ITEM32(reg, spvtr, epvid_mode, 0x04, 0, 4);
1695 static inline void mlxsw_reg_spvtr_pack(char *payload, bool tport,
1697 enum mlxsw_reg_spvtr_ipvid_mode ipvid_mode)
1699 MLXSW_REG_ZERO(spvtr, payload);
1700 mlxsw_reg_spvtr_tport_set(payload, tport);
1701 mlxsw_reg_spvtr_local_port_set(payload, local_port);
1702 mlxsw_reg_spvtr_ipvid_mode_set(payload, ipvid_mode);
1703 mlxsw_reg_spvtr_ipve_set(payload, true);
1706 /* SVPE - Switch Virtual-Port Enabling Register
1707 * --------------------------------------------
1708 * Enables port virtualization.
1710 #define MLXSW_REG_SVPE_ID 0x201E
1711 #define MLXSW_REG_SVPE_LEN 0x4
1713 MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
1715 /* reg_svpe_local_port
1719 * Note: CPU port is not supported (uses VLAN mode only).
1721 MLXSW_ITEM32_LP(reg, svpe, 0x00, 16, 0x00, 12);
1724 * Virtual port enable.
1725 * 0 - Disable, VLAN mode (VID to FID).
1726 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1729 MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1731 static inline void mlxsw_reg_svpe_pack(char *payload, u16 local_port,
1734 MLXSW_REG_ZERO(svpe, payload);
1735 mlxsw_reg_svpe_local_port_set(payload, local_port);
1736 mlxsw_reg_svpe_vp_en_set(payload, enable);
1739 /* SFMR - Switch FID Management Register
1740 * -------------------------------------
1741 * Creates and configures FIDs.
1743 #define MLXSW_REG_SFMR_ID 0x201F
1744 #define MLXSW_REG_SFMR_LEN 0x18
1746 MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
1748 enum mlxsw_reg_sfmr_op {
1749 MLXSW_REG_SFMR_OP_CREATE_FID,
1750 MLXSW_REG_SFMR_OP_DESTROY_FID,
1755 * 0 - Create or edit FID.
1759 MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1765 MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1767 /* reg_sfmr_fid_offset
1769 * Used to point into the flooding table selected by SFGC register if
1770 * the table is of type FID-Offset. Otherwise, this field is reserved.
1773 MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1776 * Valid Tunnel Flood Pointer.
1777 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1780 * Note: Reserved for 802.1Q FIDs.
1782 MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1784 /* reg_sfmr_nve_tunnel_flood_ptr
1785 * Underlay Flooding and BC Pointer.
1786 * Used as a pointer to the first entry of the group based link lists of
1787 * flooding or BC entries (for NVE tunnels).
1790 MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1794 * If not set, then vni is reserved.
1797 * Note: Reserved for 802.1Q FIDs.
1799 MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1802 * Virtual Network Identifier.
1805 * Note: A given VNI can only be assigned to one FID.
1807 MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1809 static inline void mlxsw_reg_sfmr_pack(char *payload,
1810 enum mlxsw_reg_sfmr_op op, u16 fid,
1813 MLXSW_REG_ZERO(sfmr, payload);
1814 mlxsw_reg_sfmr_op_set(payload, op);
1815 mlxsw_reg_sfmr_fid_set(payload, fid);
1816 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1817 mlxsw_reg_sfmr_vtfp_set(payload, false);
1818 mlxsw_reg_sfmr_vv_set(payload, false);
1821 /* SPVMLR - Switch Port VLAN MAC Learning Register
1822 * -----------------------------------------------
1823 * Controls the switch MAC learning policy per {Port, VID}.
1825 #define MLXSW_REG_SPVMLR_ID 0x2020
1826 #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1827 #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
1828 #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
1829 #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1830 MLXSW_REG_SPVMLR_REC_LEN * \
1831 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1833 MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
1835 /* reg_spvmlr_local_port
1836 * Local ingress port.
1839 * Note: CPU port is not supported.
1841 MLXSW_ITEM32_LP(reg, spvmlr, 0x00, 16, 0x00, 12);
1843 /* reg_spvmlr_num_rec
1844 * Number of records to update.
1847 MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1849 /* reg_spvmlr_rec_learn_enable
1850 * 0 - Disable learning for {Port, VID}.
1851 * 1 - Enable learning for {Port, VID}.
1854 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1855 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1857 /* reg_spvmlr_rec_vid
1858 * VLAN ID to be added/removed from port or for querying.
1861 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1862 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1864 static inline void mlxsw_reg_spvmlr_pack(char *payload, u16 local_port,
1865 u16 vid_begin, u16 vid_end,
1868 int num_rec = vid_end - vid_begin + 1;
1871 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1873 MLXSW_REG_ZERO(spvmlr, payload);
1874 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1875 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1877 for (i = 0; i < num_rec; i++) {
1878 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1879 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1883 /* SPVC - Switch Port VLAN Classification Register
1884 * -----------------------------------------------
1885 * Configures the port to identify packets as untagged / single tagged /
1886 * double packets based on the packet EtherTypes.
1887 * Ethertype IDs are configured by SVER.
1889 #define MLXSW_REG_SPVC_ID 0x2026
1890 #define MLXSW_REG_SPVC_LEN 0x0C
1892 MLXSW_REG_DEFINE(spvc, MLXSW_REG_SPVC_ID, MLXSW_REG_SPVC_LEN);
1894 /* reg_spvc_local_port
1898 * Note: applies both to Rx port and Tx port, so if a packet traverses
1899 * through Rx port i and a Tx port j then port i and port j must have the
1900 * same configuration.
1902 MLXSW_ITEM32_LP(reg, spvc, 0x00, 16, 0x00, 12);
1904 /* reg_spvc_inner_et2
1905 * Vlan Tag1 EtherType2 enable.
1906 * Packet is initially classified as double VLAN Tag if in addition to
1907 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
1908 * equal to ether_type2.
1909 * 0: disable (default)
1913 MLXSW_ITEM32(reg, spvc, inner_et2, 0x08, 17, 1);
1916 * Vlan Tag0 EtherType2 enable.
1917 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
1918 * equal to ether_type2.
1919 * 0: disable (default)
1923 MLXSW_ITEM32(reg, spvc, et2, 0x08, 16, 1);
1925 /* reg_spvc_inner_et1
1926 * Vlan Tag1 EtherType1 enable.
1927 * Packet is initially classified as double VLAN Tag if in addition to
1928 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
1929 * equal to ether_type1.
1931 * 1: enable (default)
1934 MLXSW_ITEM32(reg, spvc, inner_et1, 0x08, 9, 1);
1937 * Vlan Tag0 EtherType1 enable.
1938 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
1939 * equal to ether_type1.
1941 * 1: enable (default)
1944 MLXSW_ITEM32(reg, spvc, et1, 0x08, 8, 1);
1947 * Vlan Tag1 EtherType0 enable.
1948 * Packet is initially classified as double VLAN Tag if in addition to
1949 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
1950 * equal to ether_type0.
1952 * 1: enable (default)
1955 MLXSW_ITEM32(reg, spvc, inner_et0, 0x08, 1, 1);
1958 * Vlan Tag0 EtherType0 enable.
1959 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
1960 * equal to ether_type0.
1962 * 1: enable (default)
1965 MLXSW_ITEM32(reg, spvc, et0, 0x08, 0, 1);
1967 static inline void mlxsw_reg_spvc_pack(char *payload, u16 local_port, bool et1,
1970 MLXSW_REG_ZERO(spvc, payload);
1971 mlxsw_reg_spvc_local_port_set(payload, local_port);
1972 /* Enable inner_et1 and inner_et0 to enable identification of double
1975 mlxsw_reg_spvc_inner_et1_set(payload, 1);
1976 mlxsw_reg_spvc_inner_et0_set(payload, 1);
1977 mlxsw_reg_spvc_et1_set(payload, et1);
1978 mlxsw_reg_spvc_et0_set(payload, et0);
1981 /* SPEVET - Switch Port Egress VLAN EtherType
1982 * ------------------------------------------
1983 * The switch port egress VLAN EtherType configures which EtherType to push at
1984 * egress for packets incoming through a local port for which 'SPVID.egr_et_set'
1987 #define MLXSW_REG_SPEVET_ID 0x202A
1988 #define MLXSW_REG_SPEVET_LEN 0x08
1990 MLXSW_REG_DEFINE(spevet, MLXSW_REG_SPEVET_ID, MLXSW_REG_SPEVET_LEN);
1992 /* reg_spevet_local_port
1993 * Egress Local port number.
1994 * Not supported to CPU port.
1997 MLXSW_ITEM32_LP(reg, spevet, 0x00, 16, 0x00, 12);
1999 /* reg_spevet_et_vlan
2000 * Egress EtherType VLAN to push when SPVID.egr_et_set field set for the packet:
2001 * 0: ether_type0 - (default)
2006 MLXSW_ITEM32(reg, spevet, et_vlan, 0x04, 16, 2);
2008 static inline void mlxsw_reg_spevet_pack(char *payload, u16 local_port,
2011 MLXSW_REG_ZERO(spevet, payload);
2012 mlxsw_reg_spevet_local_port_set(payload, local_port);
2013 mlxsw_reg_spevet_et_vlan_set(payload, et_vlan);
2016 /* SFTR-V2 - Switch Flooding Table Version 2 Register
2017 * --------------------------------------------------
2018 * The switch flooding table is used for flooding packet replication. The table
2019 * defines a bit mask of ports for packet replication.
2021 #define MLXSW_REG_SFTR2_ID 0x202F
2022 #define MLXSW_REG_SFTR2_LEN 0x120
2024 MLXSW_REG_DEFINE(sftr2, MLXSW_REG_SFTR2_ID, MLXSW_REG_SFTR2_LEN);
2027 * Switch partition ID with which to associate the port.
2030 MLXSW_ITEM32(reg, sftr2, swid, 0x00, 24, 8);
2032 /* reg_sftr2_flood_table
2033 * Flooding table index to associate with the specific type on the specific
2037 MLXSW_ITEM32(reg, sftr2, flood_table, 0x00, 16, 6);
2040 * Index. Used as an index into the Flooding Table in case the table is
2041 * configured to use VID / FID or FID Offset.
2044 MLXSW_ITEM32(reg, sftr2, index, 0x00, 0, 16);
2046 /* reg_sftr2_table_type
2047 * See mlxsw_flood_table_type
2050 MLXSW_ITEM32(reg, sftr2, table_type, 0x04, 16, 3);
2053 * Range of entries to update
2056 MLXSW_ITEM32(reg, sftr2, range, 0x04, 0, 16);
2059 * Local port membership (1 bit per port).
2062 MLXSW_ITEM_BIT_ARRAY(reg, sftr2, port, 0x20, 0x80, 1);
2064 /* reg_sftr2_port_mask
2065 * Local port mask (1 bit per port).
2068 MLXSW_ITEM_BIT_ARRAY(reg, sftr2, port_mask, 0xA0, 0x80, 1);
2070 static inline void mlxsw_reg_sftr2_pack(char *payload,
2071 unsigned int flood_table,
2073 enum mlxsw_flood_table_type table_type,
2074 unsigned int range, u16 port, bool set)
2076 MLXSW_REG_ZERO(sftr2, payload);
2077 mlxsw_reg_sftr2_swid_set(payload, 0);
2078 mlxsw_reg_sftr2_flood_table_set(payload, flood_table);
2079 mlxsw_reg_sftr2_index_set(payload, index);
2080 mlxsw_reg_sftr2_table_type_set(payload, table_type);
2081 mlxsw_reg_sftr2_range_set(payload, range);
2082 mlxsw_reg_sftr2_port_set(payload, port, set);
2083 mlxsw_reg_sftr2_port_mask_set(payload, port, 1);
2086 /* SMID-V2 - Switch Multicast ID Version 2 Register
2087 * ------------------------------------------------
2088 * The MID record maps from a MID (Multicast ID), which is a unique identifier
2089 * of the multicast group within the stacking domain, into a list of local
2090 * ports into which the packet is replicated.
2092 #define MLXSW_REG_SMID2_ID 0x2034
2093 #define MLXSW_REG_SMID2_LEN 0x120
2095 MLXSW_REG_DEFINE(smid2, MLXSW_REG_SMID2_ID, MLXSW_REG_SMID2_LEN);
2098 * Switch partition ID.
2101 MLXSW_ITEM32(reg, smid2, swid, 0x00, 24, 8);
2104 * Multicast identifier - global identifier that represents the multicast group
2105 * across all devices.
2108 MLXSW_ITEM32(reg, smid2, mid, 0x00, 0, 16);
2111 * Local port memebership (1 bit per port).
2114 MLXSW_ITEM_BIT_ARRAY(reg, smid2, port, 0x20, 0x80, 1);
2116 /* reg_smid2_port_mask
2117 * Local port mask (1 bit per port).
2120 MLXSW_ITEM_BIT_ARRAY(reg, smid2, port_mask, 0xA0, 0x80, 1);
2122 static inline void mlxsw_reg_smid2_pack(char *payload, u16 mid, u16 port,
2125 MLXSW_REG_ZERO(smid2, payload);
2126 mlxsw_reg_smid2_swid_set(payload, 0);
2127 mlxsw_reg_smid2_mid_set(payload, mid);
2128 mlxsw_reg_smid2_port_set(payload, port, set);
2129 mlxsw_reg_smid2_port_mask_set(payload, port, 1);
2132 /* CWTP - Congetion WRED ECN TClass Profile
2133 * ----------------------------------------
2134 * Configures the profiles for queues of egress port and traffic class
2136 #define MLXSW_REG_CWTP_ID 0x2802
2137 #define MLXSW_REG_CWTP_BASE_LEN 0x28
2138 #define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
2139 #define MLXSW_REG_CWTP_LEN 0x40
2141 MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
2143 /* reg_cwtp_local_port
2145 * Not supported for CPU port
2148 MLXSW_ITEM32_LP(reg, cwtp, 0x00, 16, 0x00, 12);
2150 /* reg_cwtp_traffic_class
2151 * Traffic Class to configure
2154 MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
2156 /* reg_cwtp_profile_min
2157 * Minimum Average Queue Size of the profile in cells.
2160 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
2161 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
2163 /* reg_cwtp_profile_percent
2164 * Percentage of WRED and ECN marking for maximum Average Queue size
2165 * Range is 0 to 100, units of integer percentage
2168 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
2169 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2171 /* reg_cwtp_profile_max
2172 * Maximum Average Queue size of the profile in cells
2175 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
2176 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2178 #define MLXSW_REG_CWTP_MIN_VALUE 64
2179 #define MLXSW_REG_CWTP_MAX_PROFILE 2
2180 #define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
2182 static inline void mlxsw_reg_cwtp_pack(char *payload, u16 local_port,
2187 MLXSW_REG_ZERO(cwtp, payload);
2188 mlxsw_reg_cwtp_local_port_set(payload, local_port);
2189 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
2191 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
2192 mlxsw_reg_cwtp_profile_min_set(payload, i,
2193 MLXSW_REG_CWTP_MIN_VALUE);
2194 mlxsw_reg_cwtp_profile_max_set(payload, i,
2195 MLXSW_REG_CWTP_MIN_VALUE);
2199 #define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
2202 mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
2205 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
2207 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
2208 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
2209 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
2212 /* CWTPM - Congestion WRED ECN TClass and Pool Mapping
2213 * ---------------------------------------------------
2214 * The CWTPM register maps each egress port and traffic class to profile num.
2216 #define MLXSW_REG_CWTPM_ID 0x2803
2217 #define MLXSW_REG_CWTPM_LEN 0x44
2219 MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
2221 /* reg_cwtpm_local_port
2223 * Not supported for CPU port
2226 MLXSW_ITEM32_LP(reg, cwtpm, 0x00, 16, 0x00, 12);
2228 /* reg_cwtpm_traffic_class
2229 * Traffic Class to configure
2232 MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
2235 * Control enablement of WRED for traffic class:
2240 MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
2243 * Control enablement of ECN for traffic class:
2248 MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
2251 * TCP Green Profile.
2252 * Index of the profile within {port, traffic class} to use.
2253 * 0 for disabling both WRED and ECN for this type of traffic.
2256 MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
2259 * TCP Yellow Profile.
2260 * Index of the profile within {port, traffic class} to use.
2261 * 0 for disabling both WRED and ECN for this type of traffic.
2264 MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
2268 * Index of the profile within {port, traffic class} to use.
2269 * 0 for disabling both WRED and ECN for this type of traffic.
2272 MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
2275 * Non-TCP Green Profile.
2276 * Index of the profile within {port, traffic class} to use.
2277 * 0 for disabling both WRED and ECN for this type of traffic.
2280 MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
2283 * Non-TCP Yellow Profile.
2284 * Index of the profile within {port, traffic class} to use.
2285 * 0 for disabling both WRED and ECN for this type of traffic.
2288 MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
2291 * Non-TCP Red Profile.
2292 * Index of the profile within {port, traffic class} to use.
2293 * 0 for disabling both WRED and ECN for this type of traffic.
2296 MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
2298 #define MLXSW_REG_CWTPM_RESET_PROFILE 0
2300 static inline void mlxsw_reg_cwtpm_pack(char *payload, u16 local_port,
2301 u8 traffic_class, u8 profile,
2302 bool wred, bool ecn)
2304 MLXSW_REG_ZERO(cwtpm, payload);
2305 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
2306 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
2307 mlxsw_reg_cwtpm_ew_set(payload, wred);
2308 mlxsw_reg_cwtpm_ee_set(payload, ecn);
2309 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
2310 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
2311 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
2312 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
2313 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
2314 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
2317 /* PGCR - Policy-Engine General Configuration Register
2318 * ---------------------------------------------------
2319 * This register configures general Policy-Engine settings.
2321 #define MLXSW_REG_PGCR_ID 0x3001
2322 #define MLXSW_REG_PGCR_LEN 0x20
2324 MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
2326 /* reg_pgcr_default_action_pointer_base
2327 * Default action pointer base. Each region has a default action pointer
2328 * which is equal to default_action_pointer_base + region_id.
2331 MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
2333 static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
2335 MLXSW_REG_ZERO(pgcr, payload);
2336 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
2339 /* PPBT - Policy-Engine Port Binding Table
2340 * ---------------------------------------
2341 * This register is used for configuration of the Port Binding Table.
2343 #define MLXSW_REG_PPBT_ID 0x3002
2344 #define MLXSW_REG_PPBT_LEN 0x14
2346 MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
2348 enum mlxsw_reg_pxbt_e {
2349 MLXSW_REG_PXBT_E_IACL,
2350 MLXSW_REG_PXBT_E_EACL,
2356 MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
2358 enum mlxsw_reg_pxbt_op {
2359 MLXSW_REG_PXBT_OP_BIND,
2360 MLXSW_REG_PXBT_OP_UNBIND,
2366 MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
2368 /* reg_ppbt_local_port
2369 * Local port. Not including CPU port.
2372 MLXSW_ITEM32_LP(reg, ppbt, 0x00, 16, 0x00, 12);
2375 * group - When set, the binding is of an ACL group. When cleared,
2376 * the binding is of an ACL.
2377 * Must be set to 1 for Spectrum.
2380 MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2382 /* reg_ppbt_acl_info
2383 * ACL/ACL group identifier. If the g bit is set, this field should hold
2384 * the acl_group_id, else it should hold the acl_id.
2387 MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2389 static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2390 enum mlxsw_reg_pxbt_op op,
2391 u16 local_port, u16 acl_info)
2393 MLXSW_REG_ZERO(ppbt, payload);
2394 mlxsw_reg_ppbt_e_set(payload, e);
2395 mlxsw_reg_ppbt_op_set(payload, op);
2396 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2397 mlxsw_reg_ppbt_g_set(payload, true);
2398 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2401 /* PACL - Policy-Engine ACL Register
2402 * ---------------------------------
2403 * This register is used for configuration of the ACL.
2405 #define MLXSW_REG_PACL_ID 0x3004
2406 #define MLXSW_REG_PACL_LEN 0x70
2408 MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2411 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2412 * while the ACL is bounded to either a port, VLAN or ACL rule.
2415 MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2418 * An identifier representing the ACL (managed by software)
2419 * Range 0 .. cap_max_acl_regions - 1
2422 MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2424 #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2426 /* reg_pacl_tcam_region_info
2427 * Opaque object that represents a TCAM region.
2428 * Obtained through PTAR register.
2431 MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2432 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2434 static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2435 bool valid, const char *tcam_region_info)
2437 MLXSW_REG_ZERO(pacl, payload);
2438 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2439 mlxsw_reg_pacl_v_set(payload, valid);
2440 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2443 /* PAGT - Policy-Engine ACL Group Table
2444 * ------------------------------------
2445 * This register is used for configuration of the ACL Group Table.
2447 #define MLXSW_REG_PAGT_ID 0x3005
2448 #define MLXSW_REG_PAGT_BASE_LEN 0x30
2449 #define MLXSW_REG_PAGT_ACL_LEN 4
2450 #define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2451 #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2452 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2454 MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2457 * Number of ACLs in the group.
2458 * Size 0 invalidates a group.
2459 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2460 * Total number of ACLs in all groups must be lower or equal
2461 * to cap_max_acl_tot_groups
2462 * Note: a group which is binded must not be invalidated
2465 MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2467 /* reg_pagt_acl_group_id
2468 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2469 * the ACL Group identifier (managed by software).
2472 MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2476 * 0 - This ACL is the last ACL in the multi-ACL
2477 * 1 - This ACL is part of a multi-ACL
2480 MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
2486 MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2488 static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2490 MLXSW_REG_ZERO(pagt, payload);
2491 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2494 static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2495 u16 acl_id, bool multi)
2497 u8 size = mlxsw_reg_pagt_size_get(payload);
2500 mlxsw_reg_pagt_size_set(payload, index + 1);
2501 mlxsw_reg_pagt_multi_set(payload, index, multi);
2502 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2505 /* PTAR - Policy-Engine TCAM Allocation Register
2506 * ---------------------------------------------
2507 * This register is used for allocation of regions in the TCAM.
2508 * Note: Query method is not supported on this register.
2510 #define MLXSW_REG_PTAR_ID 0x3006
2511 #define MLXSW_REG_PTAR_BASE_LEN 0x20
2512 #define MLXSW_REG_PTAR_KEY_ID_LEN 1
2513 #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2514 #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2515 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2517 MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2519 enum mlxsw_reg_ptar_op {
2520 /* allocate a TCAM region */
2521 MLXSW_REG_PTAR_OP_ALLOC,
2522 /* resize a TCAM region */
2523 MLXSW_REG_PTAR_OP_RESIZE,
2524 /* deallocate TCAM region */
2525 MLXSW_REG_PTAR_OP_FREE,
2526 /* test allocation */
2527 MLXSW_REG_PTAR_OP_TEST,
2533 MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2535 /* reg_ptar_action_set_type
2536 * Type of action set to be used on this region.
2537 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
2540 MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2542 enum mlxsw_reg_ptar_key_type {
2543 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2544 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2547 /* reg_ptar_key_type
2548 * TCAM key type for the region.
2551 MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2553 /* reg_ptar_region_size
2554 * TCAM region size. When allocating/resizing this is the requested size,
2555 * the response is the actual size. Note that actual size may be
2556 * larger than requested.
2557 * Allowed range 1 .. cap_max_rules-1
2558 * Reserved during op deallocate.
2561 MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2563 /* reg_ptar_region_id
2565 * Range 0 .. cap_max_regions-1
2568 MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2570 /* reg_ptar_tcam_region_info
2571 * Opaque object that represents the TCAM region.
2572 * Returned when allocating a region.
2573 * Provided by software for ACL generation and region deallocation and resize.
2576 MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2577 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2579 /* reg_ptar_flexible_key_id
2580 * Identifier of the Flexible Key.
2581 * Only valid if key_type == "FLEX_KEY"
2582 * The key size will be rounded up to one of the following values:
2583 * 9B, 18B, 36B, 54B.
2584 * This field is reserved for in resize operation.
2587 MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2588 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2590 static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
2591 enum mlxsw_reg_ptar_key_type key_type,
2592 u16 region_size, u16 region_id,
2593 const char *tcam_region_info)
2595 MLXSW_REG_ZERO(ptar, payload);
2596 mlxsw_reg_ptar_op_set(payload, op);
2597 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
2598 mlxsw_reg_ptar_key_type_set(payload, key_type);
2599 mlxsw_reg_ptar_region_size_set(payload, region_size);
2600 mlxsw_reg_ptar_region_id_set(payload, region_id);
2601 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2604 static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2607 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2610 static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2612 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2615 /* PPBS - Policy-Engine Policy Based Switching Register
2616 * ----------------------------------------------------
2617 * This register retrieves and sets Policy Based Switching Table entries.
2619 #define MLXSW_REG_PPBS_ID 0x300C
2620 #define MLXSW_REG_PPBS_LEN 0x14
2622 MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2625 * Index into the PBS table.
2626 * For Spectrum, the index points to the KVD Linear.
2629 MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2631 /* reg_ppbs_system_port
2632 * Unique port identifier for the final destination of the packet.
2635 MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2637 static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2640 MLXSW_REG_ZERO(ppbs, payload);
2641 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2642 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2645 /* PRCR - Policy-Engine Rules Copy Register
2646 * ----------------------------------------
2647 * This register is used for accessing rules within a TCAM region.
2649 #define MLXSW_REG_PRCR_ID 0x300D
2650 #define MLXSW_REG_PRCR_LEN 0x40
2652 MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2654 enum mlxsw_reg_prcr_op {
2655 /* Move rules. Moves the rules from "tcam_region_info" starting
2656 * at offset "offset" to "dest_tcam_region_info"
2657 * at offset "dest_offset."
2659 MLXSW_REG_PRCR_OP_MOVE,
2660 /* Copy rules. Copies the rules from "tcam_region_info" starting
2661 * at offset "offset" to "dest_tcam_region_info"
2662 * at offset "dest_offset."
2664 MLXSW_REG_PRCR_OP_COPY,
2670 MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2673 * Offset within the source region to copy/move from.
2676 MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2679 * The number of rules to copy/move.
2682 MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2684 /* reg_prcr_tcam_region_info
2685 * Opaque object that represents the source TCAM region.
2688 MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2689 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2691 /* reg_prcr_dest_offset
2692 * Offset within the source region to copy/move to.
2695 MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2697 /* reg_prcr_dest_tcam_region_info
2698 * Opaque object that represents the destination TCAM region.
2701 MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2702 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2704 static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2705 const char *src_tcam_region_info,
2707 const char *dest_tcam_region_info,
2708 u16 dest_offset, u16 size)
2710 MLXSW_REG_ZERO(prcr, payload);
2711 mlxsw_reg_prcr_op_set(payload, op);
2712 mlxsw_reg_prcr_offset_set(payload, src_offset);
2713 mlxsw_reg_prcr_size_set(payload, size);
2714 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2715 src_tcam_region_info);
2716 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2717 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2718 dest_tcam_region_info);
2721 /* PEFA - Policy-Engine Extended Flexible Action Register
2722 * ------------------------------------------------------
2723 * This register is used for accessing an extended flexible action entry
2724 * in the central KVD Linear Database.
2726 #define MLXSW_REG_PEFA_ID 0x300F
2727 #define MLXSW_REG_PEFA_LEN 0xB0
2729 MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2732 * Index in the KVD Linear Centralized Database.
2735 MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2738 * Index in the KVD Linear Centralized Database.
2740 * For a new entry: set if ca=0, clear if ca=1
2741 * Set if a packet lookup has hit on the specific entry
2744 MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2748 * When write: activity is according to this field
2749 * When read: after reading the activity is cleared according to ca
2752 MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2754 #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
2756 /* reg_pefa_flex_action_set
2757 * Action-set to perform when rule is matched.
2758 * Must be zero padded if action set is shorter.
2761 MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
2763 static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
2764 const char *flex_action_set)
2766 MLXSW_REG_ZERO(pefa, payload);
2767 mlxsw_reg_pefa_index_set(payload, index);
2768 mlxsw_reg_pefa_ca_set(payload, ca);
2769 if (flex_action_set)
2770 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2774 static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2776 *p_a = mlxsw_reg_pefa_a_get(payload);
2779 /* PEMRBT - Policy-Engine Multicast Router Binding Table Register
2780 * --------------------------------------------------------------
2781 * This register is used for binding Multicast router to an ACL group
2782 * that serves the MC router.
2783 * This register is not supported by SwitchX/-2 and Spectrum.
2785 #define MLXSW_REG_PEMRBT_ID 0x3014
2786 #define MLXSW_REG_PEMRBT_LEN 0x14
2788 MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
2790 enum mlxsw_reg_pemrbt_protocol {
2791 MLXSW_REG_PEMRBT_PROTO_IPV4,
2792 MLXSW_REG_PEMRBT_PROTO_IPV6,
2795 /* reg_pemrbt_protocol
2798 MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
2800 /* reg_pemrbt_group_id
2801 * ACL group identifier.
2802 * Range 0..cap_max_acl_groups-1
2805 MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
2808 mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
2811 MLXSW_REG_ZERO(pemrbt, payload);
2812 mlxsw_reg_pemrbt_protocol_set(payload, protocol);
2813 mlxsw_reg_pemrbt_group_id_set(payload, group_id);
2816 /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
2817 * -----------------------------------------------------
2818 * This register is used for accessing rules within a TCAM region.
2819 * It is a new version of PTCE in order to support wider key,
2820 * mask and action within a TCAM region. This register is not supported
2821 * by SwitchX and SwitchX-2.
2823 #define MLXSW_REG_PTCE2_ID 0x3017
2824 #define MLXSW_REG_PTCE2_LEN 0x1D8
2826 MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2832 MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2835 * Activity. Set if a packet lookup has hit on the specific entry.
2836 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
2839 MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2841 enum mlxsw_reg_ptce2_op {
2842 /* Read operation. */
2843 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2844 /* clear on read operation. Used to read entry
2845 * and clear Activity bit.
2847 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2848 /* Write operation. Used to write a new entry to the table.
2849 * All R/W fields are relevant for new entry. Activity bit is set
2850 * for new entries - Note write with v = 0 will delete the entry.
2852 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2853 /* Update action. Only action set will be updated. */
2854 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2855 /* Clear activity. A bit is cleared for the entry. */
2856 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2862 MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2867 MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2869 /* reg_ptce2_priority
2870 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
2871 * Note: priority does not have to be unique per rule.
2872 * Within a region, higher priority should have lower offset (no limitation
2873 * between regions in a multi-region).
2876 MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2878 /* reg_ptce2_tcam_region_info
2879 * Opaque object that represents the TCAM region.
2882 MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2883 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2885 #define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
2887 /* reg_ptce2_flex_key_blocks
2891 MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
2892 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2895 * mask- in the same size as key. A bit that is set directs the TCAM
2896 * to compare the corresponding bit in key. A bit that is clear directs
2897 * the TCAM to ignore the corresponding bit in key.
2900 MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
2901 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2903 /* reg_ptce2_flex_action_set
2907 MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
2908 MLXSW_REG_FLEX_ACTION_SET_LEN);
2910 static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2911 enum mlxsw_reg_ptce2_op op,
2912 const char *tcam_region_info,
2913 u16 offset, u32 priority)
2915 MLXSW_REG_ZERO(ptce2, payload);
2916 mlxsw_reg_ptce2_v_set(payload, valid);
2917 mlxsw_reg_ptce2_op_set(payload, op);
2918 mlxsw_reg_ptce2_offset_set(payload, offset);
2919 mlxsw_reg_ptce2_priority_set(payload, priority);
2920 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2923 /* PERPT - Policy-Engine ERP Table Register
2924 * ----------------------------------------
2925 * This register adds and removes eRPs from the eRP table.
2927 #define MLXSW_REG_PERPT_ID 0x3021
2928 #define MLXSW_REG_PERPT_LEN 0x80
2930 MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2932 /* reg_perpt_erpt_bank
2934 * Range 0 .. cap_max_erp_table_banks - 1
2937 MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2939 /* reg_perpt_erpt_index
2940 * Index to eRP table within the eRP bank.
2941 * Range is 0 .. cap_max_erp_table_bank_size - 1
2944 MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2946 enum mlxsw_reg_perpt_key_size {
2947 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2948 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2949 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2950 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2953 /* reg_perpt_key_size
2956 MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2958 /* reg_perpt_bf_bypass
2959 * 0 - The eRP is used only if bloom filter state is set for the given
2961 * 1 - The eRP is used regardless of bloom filter state.
2962 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
2965 MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2968 * eRP ID for use by the rules.
2971 MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2973 /* reg_perpt_erpt_base_bank
2974 * Base eRP table bank, points to head of erp_vector
2975 * Range is 0 .. cap_max_erp_table_banks - 1
2978 MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2980 /* reg_perpt_erpt_base_index
2981 * Base index to eRP table within the eRP bank
2982 * Range is 0 .. cap_max_erp_table_bank_size - 1
2985 MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2987 /* reg_perpt_erp_index_in_vector
2988 * eRP index in the vector.
2991 MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2993 /* reg_perpt_erp_vector
2997 MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
3001 * 0 - A-TCAM will ignore the bit in key
3002 * 1 - A-TCAM will compare the bit in key
3005 MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3007 static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
3008 unsigned long *erp_vector,
3013 for_each_set_bit(bit, erp_vector, size)
3014 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
3018 mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
3019 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
3020 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
3023 MLXSW_REG_ZERO(perpt, payload);
3024 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
3025 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
3026 mlxsw_reg_perpt_key_size_set(payload, key_size);
3027 mlxsw_reg_perpt_bf_bypass_set(payload, false);
3028 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
3029 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
3030 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
3031 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
3032 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
3035 /* PERAR - Policy-Engine Region Association Register
3036 * -------------------------------------------------
3037 * This register associates a hw region for region_id's. Changing on the fly
3038 * is supported by the device.
3040 #define MLXSW_REG_PERAR_ID 0x3026
3041 #define MLXSW_REG_PERAR_LEN 0x08
3043 MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
3045 /* reg_perar_region_id
3047 * Range 0 .. cap_max_regions-1
3050 MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
3052 static inline unsigned int
3053 mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
3055 return DIV_ROUND_UP(block_num, 4);
3058 /* reg_perar_hw_region
3060 * Range 0 .. cap_max_regions-1
3061 * Default: hw_region = region_id
3062 * For a 8 key block region, 2 consecutive regions are used
3063 * For a 12 key block region, 3 consecutive regions are used
3066 MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
3068 static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
3071 MLXSW_REG_ZERO(perar, payload);
3072 mlxsw_reg_perar_region_id_set(payload, region_id);
3073 mlxsw_reg_perar_hw_region_set(payload, hw_region);
3076 /* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
3077 * -----------------------------------------------------
3078 * This register is a new version of PTCE-V2 in order to support the
3079 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
3081 #define MLXSW_REG_PTCE3_ID 0x3027
3082 #define MLXSW_REG_PTCE3_LEN 0xF0
3084 MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
3090 MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
3092 enum mlxsw_reg_ptce3_op {
3093 /* Write operation. Used to write a new entry to the table.
3094 * All R/W fields are relevant for new entry. Activity bit is set
3095 * for new entries. Write with v = 0 will delete the entry. Must
3096 * not be used if an entry exists.
3098 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
3099 /* Update operation */
3100 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
3101 /* Read operation */
3102 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
3108 MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
3110 /* reg_ptce3_priority
3111 * Priority of the rule. Higher values win.
3112 * For Spectrum-2 range is 1..cap_kvd_size - 1
3113 * Note: Priority does not have to be unique per rule.
3116 MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
3118 /* reg_ptce3_tcam_region_info
3119 * Opaque object that represents the TCAM region.
3122 MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
3123 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3125 /* reg_ptce3_flex2_key_blocks
3126 * ACL key. The key must be masked according to eRP (if exists) or
3127 * according to master mask.
3130 MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
3131 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3137 MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
3139 /* reg_ptce3_delta_start
3140 * Start point of delta_value and delta_mask, in bits. Must not exceed
3141 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
3144 MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
3146 /* reg_ptce3_delta_mask
3148 * 0 - Ignore relevant bit in delta_value
3149 * 1 - Compare relevant bit in delta_value
3150 * Delta mask must not be set for reserved fields in the key blocks.
3151 * Note: No delta when no eRPs. Thus, for regions with
3152 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
3155 MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
3157 /* reg_ptce3_delta_value
3159 * Bits which are masked by delta_mask must be 0.
3162 MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
3164 /* reg_ptce3_prune_vector
3165 * Pruning vector relative to the PERPT.erp_id.
3166 * Used for reducing lookups.
3167 * 0 - NEED: Do a lookup using the eRP.
3168 * 1 - PRUNE: Do not perform a lookup using the eRP.
3169 * Maybe be modified by PEAPBL and PEAPBM.
3170 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
3171 * all 1's or all 0's.
3174 MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
3176 /* reg_ptce3_prune_ctcam
3177 * Pruning on C-TCAM. Used for reducing lookups.
3178 * 0 - NEED: Do a lookup in the C-TCAM.
3179 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
3182 MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
3184 /* reg_ptce3_large_exists
3185 * Large entry key ID exists.
3186 * Within the region:
3187 * 0 - SINGLE: The large_entry_key_id is not currently in use.
3188 * For rule insert: The MSB of the key (blocks 6..11) will be added.
3189 * For rule delete: The MSB of the key will be removed.
3190 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
3191 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
3192 * For rule delete: The MSB of the key will not be removed.
3195 MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
3197 /* reg_ptce3_large_entry_key_id
3198 * Large entry key ID.
3199 * A key for 12 key blocks rules. Reserved when region has less than 12 key
3200 * blocks. Must be different for different keys which have the same common
3201 * 6 key blocks (MSB, blocks 6..11) key within a region.
3202 * Range is 0..cap_max_pe_large_key_id - 1
3205 MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
3207 /* reg_ptce3_action_pointer
3208 * Pointer to action.
3209 * Range is 0..cap_max_kvd_action_sets - 1
3212 MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
3214 static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
3215 enum mlxsw_reg_ptce3_op op,
3217 const char *tcam_region_info,
3218 const char *key, u8 erp_id,
3219 u16 delta_start, u8 delta_mask,
3220 u8 delta_value, bool large_exists,
3221 u32 lkey_id, u32 action_pointer)
3223 MLXSW_REG_ZERO(ptce3, payload);
3224 mlxsw_reg_ptce3_v_set(payload, valid);
3225 mlxsw_reg_ptce3_op_set(payload, op);
3226 mlxsw_reg_ptce3_priority_set(payload, priority);
3227 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
3228 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
3229 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
3230 mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
3231 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
3232 mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
3233 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
3234 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
3235 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
3238 /* PERCR - Policy-Engine Region Configuration Register
3239 * ---------------------------------------------------
3240 * This register configures the region parameters. The region_id must be
3243 #define MLXSW_REG_PERCR_ID 0x302A
3244 #define MLXSW_REG_PERCR_LEN 0x80
3246 MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
3248 /* reg_percr_region_id
3249 * Region identifier.
3250 * Range 0..cap_max_regions-1
3253 MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
3255 /* reg_percr_atcam_ignore_prune
3256 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
3259 MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
3261 /* reg_percr_ctcam_ignore_prune
3262 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
3265 MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
3267 /* reg_percr_bf_bypass
3268 * Bloom filter bypass.
3269 * 0 - Bloom filter is used (default)
3270 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
3271 * region_id or eRP. See PERPT.bf_bypass
3274 MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
3276 /* reg_percr_master_mask
3277 * Master mask. Logical OR mask of all masks of all rules of a region
3278 * (both A-TCAM and C-TCAM). When there are no eRPs
3279 * (erpt_pointer_valid = 0), then this provides the mask.
3282 MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
3284 static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
3286 MLXSW_REG_ZERO(percr, payload);
3287 mlxsw_reg_percr_region_id_set(payload, region_id);
3288 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
3289 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
3290 mlxsw_reg_percr_bf_bypass_set(payload, false);
3293 /* PERERP - Policy-Engine Region eRP Register
3294 * ------------------------------------------
3295 * This register configures the region eRP. The region_id must be
3298 #define MLXSW_REG_PERERP_ID 0x302B
3299 #define MLXSW_REG_PERERP_LEN 0x1C
3301 MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
3303 /* reg_pererp_region_id
3304 * Region identifier.
3305 * Range 0..cap_max_regions-1
3308 MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
3310 /* reg_pererp_ctcam_le
3311 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
3314 MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
3316 /* reg_pererp_erpt_pointer_valid
3317 * erpt_pointer is valid.
3320 MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
3322 /* reg_pererp_erpt_bank_pointer
3323 * Pointer to eRP table bank. May be modified at any time.
3324 * Range 0..cap_max_erp_table_banks-1
3325 * Reserved when erpt_pointer_valid = 0
3327 MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
3329 /* reg_pererp_erpt_pointer
3330 * Pointer to eRP table within the eRP bank. Can be changed for an
3332 * Range 0..cap_max_erp_table_size-1
3333 * Reserved when erpt_pointer_valid = 0
3336 MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
3338 /* reg_pererp_erpt_vector
3339 * Vector of allowed eRP indexes starting from erpt_pointer within the
3340 * erpt_bank_pointer. Next entries will be in next bank.
3341 * Note that eRP index is used and not eRP ID.
3342 * Reserved when erpt_pointer_valid = 0
3345 MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
3347 /* reg_pererp_master_rp_id
3348 * Master RP ID. When there are no eRPs, then this provides the eRP ID
3349 * for the lookup. Can be changed for an existing region.
3350 * Reserved when erpt_pointer_valid = 1
3353 MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
3355 static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
3356 unsigned long *erp_vector,
3361 for_each_set_bit(bit, erp_vector, size)
3362 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
3365 static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
3366 bool ctcam_le, bool erpt_pointer_valid,
3367 u8 erpt_bank_pointer, u8 erpt_pointer,
3370 MLXSW_REG_ZERO(pererp, payload);
3371 mlxsw_reg_pererp_region_id_set(payload, region_id);
3372 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
3373 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
3374 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
3375 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
3376 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
3379 /* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
3380 * ----------------------------------------------------------------
3381 * This register configures the Bloom filter entries.
3383 #define MLXSW_REG_PEABFE_ID 0x3022
3384 #define MLXSW_REG_PEABFE_BASE_LEN 0x10
3385 #define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3386 #define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3387 #define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3388 MLXSW_REG_PEABFE_BF_REC_LEN * \
3389 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3391 MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3394 * Number of BF entries to be updated.
3398 MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3400 /* reg_peabfe_bf_entry_state
3401 * Bloom filter state
3406 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3407 MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3408 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3410 /* reg_peabfe_bf_entry_bank
3411 * Bloom filter bank ID
3412 * Range 0..cap_max_erp_table_banks-1
3415 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3416 MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3417 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3419 /* reg_peabfe_bf_entry_index
3420 * Bloom filter entry index
3421 * Range 0..2^cap_max_bf_log-1
3424 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3425 MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3426 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3428 static inline void mlxsw_reg_peabfe_pack(char *payload)
3430 MLXSW_REG_ZERO(peabfe, payload);
3433 static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3434 u8 state, u8 bank, u32 bf_index)
3436 u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3438 if (rec_index >= num_rec)
3439 mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3440 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3441 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3442 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3445 /* IEDR - Infrastructure Entry Delete Register
3446 * ----------------------------------------------------
3447 * This register is used for deleting entries from the entry tables.
3448 * It is legitimate to attempt to delete a nonexisting entry (the device will
3449 * respond as a good flow).
3451 #define MLXSW_REG_IEDR_ID 0x3804
3452 #define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
3453 #define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
3454 #define MLXSW_REG_IEDR_REC_MAX_COUNT 64
3455 #define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
3456 MLXSW_REG_IEDR_REC_LEN * \
3457 MLXSW_REG_IEDR_REC_MAX_COUNT)
3459 MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
3462 * Number of records.
3465 MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
3467 /* reg_iedr_rec_type
3471 MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
3472 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3474 /* reg_iedr_rec_size
3475 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
3478 MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13,
3479 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3481 /* reg_iedr_rec_index_start
3482 * Resource index start.
3485 MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3486 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3488 static inline void mlxsw_reg_iedr_pack(char *payload)
3490 MLXSW_REG_ZERO(iedr, payload);
3493 static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3494 u8 rec_type, u16 rec_size,
3495 u32 rec_index_start)
3497 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3499 if (rec_index >= num_rec)
3500 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3501 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3502 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3503 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3506 /* QPTS - QoS Priority Trust State Register
3507 * ----------------------------------------
3508 * This register controls the port policy to calculate the switch priority and
3509 * packet color based on incoming packet fields.
3511 #define MLXSW_REG_QPTS_ID 0x4002
3512 #define MLXSW_REG_QPTS_LEN 0x8
3514 MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3516 /* reg_qpts_local_port
3517 * Local port number.
3520 * Note: CPU port is supported.
3522 MLXSW_ITEM32_LP(reg, qpts, 0x00, 16, 0x00, 12);
3524 enum mlxsw_reg_qpts_trust_state {
3525 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3526 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3529 /* reg_qpts_trust_state
3530 * Trust state for a given port.
3533 MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3535 static inline void mlxsw_reg_qpts_pack(char *payload, u16 local_port,
3536 enum mlxsw_reg_qpts_trust_state ts)
3538 MLXSW_REG_ZERO(qpts, payload);
3540 mlxsw_reg_qpts_local_port_set(payload, local_port);
3541 mlxsw_reg_qpts_trust_state_set(payload, ts);
3544 /* QPCR - QoS Policer Configuration Register
3545 * -----------------------------------------
3546 * The QPCR register is used to create policers - that limit
3547 * the rate of bytes or packets via some trap group.
3549 #define MLXSW_REG_QPCR_ID 0x4004
3550 #define MLXSW_REG_QPCR_LEN 0x28
3552 MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3554 enum mlxsw_reg_qpcr_g {
3555 MLXSW_REG_QPCR_G_GLOBAL = 2,
3556 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3563 MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3569 MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3571 /* reg_qpcr_clear_counter
3575 MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1);
3577 /* reg_qpcr_color_aware
3578 * Is the policer aware of colors.
3579 * Must be 0 (unaware) for cpu port.
3580 * Access: RW for unbounded policer. RO for bounded policer.
3582 MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3585 * Is policer limit is for bytes per sec or packets per sec.
3588 * Access: RW for unbounded policer. RO for bounded policer.
3590 MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3592 enum mlxsw_reg_qpcr_ir_units {
3593 MLXSW_REG_QPCR_IR_UNITS_M,
3594 MLXSW_REG_QPCR_IR_UNITS_K,
3597 /* reg_qpcr_ir_units
3598 * Policer's units for cir and eir fields (for bytes limits only)
3603 MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3605 enum mlxsw_reg_qpcr_rate_type {
3606 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3607 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3610 /* reg_qpcr_rate_type
3611 * Policer can have one limit (single rate) or 2 limits with specific operation
3612 * for packets that exceed the lower rate but not the upper one.
3613 * (For cpu port must be single rate)
3614 * Access: RW for unbounded policer. RO for bounded policer.
3616 MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3619 * Policer's committed burst size.
3620 * The policer is working with time slices of 50 nano sec. By default every
3621 * slice is granted the proportionate share of the committed rate. If we want to
3622 * allow a slice to exceed that share (while still keeping the rate per sec) we
3623 * can allow burst. The burst size is between the default proportionate share
3624 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3625 * committed rate will result in exceeding the rate). The burst size must be a
3626 * log of 2 and will be determined by 2^cbs.
3629 MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3632 * Policer's committed rate.
3633 * The rate used for sungle rate, the lower rate for double rate.
3634 * For bytes limits, the rate will be this value * the unit from ir_units.
3635 * (Resolution error is up to 1%).
3638 MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3641 * Policer's exceed rate.
3642 * The higher rate for double rate, reserved for single rate.
3643 * Lower rate for double rate policer.
3644 * For bytes limits, the rate will be this value * the unit from ir_units.
3645 * (Resolution error is up to 1%).
3648 MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3650 #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3652 /* reg_qpcr_exceed_action.
3653 * What to do with packets between the 2 limits for double rate.
3654 * Access: RW for unbounded policer. RO for bounded policer.
3656 MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3658 enum mlxsw_reg_qpcr_action {
3660 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3661 /* Forward and set color to red.
3662 * If the packet is intended to cpu port, it will be dropped.
3664 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3667 /* reg_qpcr_violate_action
3668 * What to do with packets that cross the cir limit (for single rate) or the eir
3669 * limit (for double rate).
3670 * Access: RW for unbounded policer. RO for bounded policer.
3672 MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3674 /* reg_qpcr_violate_count
3675 * Counts the number of times violate_action happened on this PID.
3678 MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64);
3681 #define MLXSW_REG_QPCR_LOWEST_CIR 1
3682 #define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000) /* 2Gpps */
3683 #define MLXSW_REG_QPCR_LOWEST_CBS 4
3684 #define MLXSW_REG_QPCR_HIGHEST_CBS 24
3687 #define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024 /* bps */
3688 #define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL /* 2Tbps */
3689 #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4
3690 #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4
3691 #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25
3692 #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31
3694 static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3695 enum mlxsw_reg_qpcr_ir_units ir_units,
3696 bool bytes, u32 cir, u16 cbs)
3698 MLXSW_REG_ZERO(qpcr, payload);
3699 mlxsw_reg_qpcr_pid_set(payload, pid);
3700 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3701 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3702 mlxsw_reg_qpcr_violate_action_set(payload,
3703 MLXSW_REG_QPCR_ACTION_DISCARD);
3704 mlxsw_reg_qpcr_cir_set(payload, cir);
3705 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3706 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3707 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3710 /* QTCT - QoS Switch Traffic Class Table
3711 * -------------------------------------
3712 * Configures the mapping between the packet switch priority and the
3713 * traffic class on the transmit port.
3715 #define MLXSW_REG_QTCT_ID 0x400A
3716 #define MLXSW_REG_QTCT_LEN 0x08
3718 MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
3720 /* reg_qtct_local_port
3721 * Local port number.
3724 * Note: CPU port is not supported.
3726 MLXSW_ITEM32_LP(reg, qtct, 0x00, 16, 0x00, 12);
3728 /* reg_qtct_sub_port
3729 * Virtual port within the physical port.
3730 * Should be set to 0 when virtual ports are not enabled on the port.
3733 MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3735 /* reg_qtct_switch_prio
3739 MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3744 * switch_prio 0 : tclass 1
3745 * switch_prio 1 : tclass 0
3746 * switch_prio i : tclass i, for i > 1
3749 MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3751 static inline void mlxsw_reg_qtct_pack(char *payload, u16 local_port,
3752 u8 switch_prio, u8 tclass)
3754 MLXSW_REG_ZERO(qtct, payload);
3755 mlxsw_reg_qtct_local_port_set(payload, local_port);
3756 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3757 mlxsw_reg_qtct_tclass_set(payload, tclass);
3760 /* QEEC - QoS ETS Element Configuration Register
3761 * ---------------------------------------------
3762 * Configures the ETS elements.
3764 #define MLXSW_REG_QEEC_ID 0x400D
3765 #define MLXSW_REG_QEEC_LEN 0x20
3767 MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
3769 /* reg_qeec_local_port
3770 * Local port number.
3773 * Note: CPU port is supported.
3775 MLXSW_ITEM32_LP(reg, qeec, 0x00, 16, 0x00, 12);
3777 enum mlxsw_reg_qeec_hr {
3778 MLXSW_REG_QEEC_HR_PORT,
3779 MLXSW_REG_QEEC_HR_GROUP,
3780 MLXSW_REG_QEEC_HR_SUBGROUP,
3781 MLXSW_REG_QEEC_HR_TC,
3784 /* reg_qeec_element_hierarchy
3791 MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3793 /* reg_qeec_element_index
3794 * The index of the element in the hierarchy.
3797 MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3799 /* reg_qeec_next_element_index
3800 * The index of the next (lower) element in the hierarchy.
3803 * Note: Reserved for element_hierarchy 0.
3805 MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3808 * Min shaper configuration enable. Enables configuration of the min
3809 * shaper on this ETS element
3814 MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3818 * 0: regular shaper mode
3819 * 1: PTP oriented shaper
3820 * Allowed only for hierarchy 0
3821 * Not supported for CPU port
3822 * Note that ptps mode may affect the shaper rates of all hierarchies
3823 * Supported only on Spectrum-1
3826 MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
3829 MLXSW_REG_QEEC_BYTES_MODE,
3830 MLXSW_REG_QEEC_PACKETS_MODE,
3834 * Packets or bytes mode.
3839 * Note: Used for max shaper configuration. For Spectrum, packets mode
3840 * is supported only for traffic classes of CPU port.
3842 MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3844 /* The smallest permitted min shaper rate. */
3845 #define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
3847 /* reg_qeec_min_shaper_rate
3848 * Min shaper information rate.
3849 * For CPU port, can only be configured for port hierarchy.
3850 * When in bytes mode, value is specified in units of 1000bps.
3853 MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3856 * Max shaper configuration enable. Enables configuration of the max
3857 * shaper on this ETS element.
3862 MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3864 /* The largest max shaper value possible to disable the shaper. */
3865 #define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1) /* Kbps */
3867 /* reg_qeec_max_shaper_rate
3868 * Max shaper information rate.
3869 * For CPU port, can only be configured for port hierarchy.
3870 * When in bytes mode, value is specified in units of 1000bps.
3873 MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31);
3876 * DWRR configuration enable. Enables configuration of the dwrr and
3882 MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3885 * Transmission selection algorithm to use on the link going down from
3887 * 0 - Strict priority
3891 MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3893 /* reg_qeec_dwrr_weight
3894 * DWRR weight on the link going down from the ETS element. The
3895 * percentage of bandwidth guaranteed to an ETS element within
3896 * its hierarchy. The sum of all weights across all ETS elements
3897 * within one hierarchy should be equal to 100. Reserved when
3898 * transmission selection algorithm is strict priority.
3901 MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3903 /* reg_qeec_max_shaper_bs
3904 * Max shaper burst size
3905 * Burst size is 2^max_shaper_bs * 512 bits
3906 * For Spectrum-1: Range is: 5..25
3907 * For Spectrum-2: Range is: 11..25
3908 * Reserved when ptps = 1
3911 MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
3913 #define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25
3914 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
3915 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
3916 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11
3917 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4 11
3919 static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
3920 enum mlxsw_reg_qeec_hr hr, u8 index,
3923 MLXSW_REG_ZERO(qeec, payload);
3924 mlxsw_reg_qeec_local_port_set(payload, local_port);
3925 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3926 mlxsw_reg_qeec_element_index_set(payload, index);
3927 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3930 static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u16 local_port,
3933 MLXSW_REG_ZERO(qeec, payload);
3934 mlxsw_reg_qeec_local_port_set(payload, local_port);
3935 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
3936 mlxsw_reg_qeec_ptps_set(payload, ptps);
3939 /* QRWE - QoS ReWrite Enable
3940 * -------------------------
3941 * This register configures the rewrite enable per receive port.
3943 #define MLXSW_REG_QRWE_ID 0x400F
3944 #define MLXSW_REG_QRWE_LEN 0x08
3946 MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3948 /* reg_qrwe_local_port
3949 * Local port number.
3952 * Note: CPU port is supported. No support for router port.
3954 MLXSW_ITEM32_LP(reg, qrwe, 0x00, 16, 0x00, 12);
3957 * Whether to enable DSCP rewrite (default is 0, don't rewrite).
3960 MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3963 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
3966 MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3968 static inline void mlxsw_reg_qrwe_pack(char *payload, u16 local_port,
3969 bool rewrite_pcp, bool rewrite_dscp)
3971 MLXSW_REG_ZERO(qrwe, payload);
3972 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3973 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3974 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3977 /* QPDSM - QoS Priority to DSCP Mapping
3978 * ------------------------------------
3979 * QoS Priority to DSCP Mapping Register
3981 #define MLXSW_REG_QPDSM_ID 0x4011
3982 #define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
3983 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
3984 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3985 #define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3986 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3987 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3989 MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3991 /* reg_qpdsm_local_port
3992 * Local Port. Supported for data packets from CPU port.
3995 MLXSW_ITEM32_LP(reg, qpdsm, 0x00, 16, 0x00, 12);
3997 /* reg_qpdsm_prio_entry_color0_e
3998 * Enable update of the entry for color 0 and a given port.
4001 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
4002 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
4003 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4005 /* reg_qpdsm_prio_entry_color0_dscp
4006 * DSCP field in the outer label of the packet for color 0 and a given port.
4007 * Reserved when e=0.
4010 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
4011 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
4012 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4014 /* reg_qpdsm_prio_entry_color1_e
4015 * Enable update of the entry for color 1 and a given port.
4018 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
4019 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
4020 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4022 /* reg_qpdsm_prio_entry_color1_dscp
4023 * DSCP field in the outer label of the packet for color 1 and a given port.
4024 * Reserved when e=0.
4027 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
4028 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
4029 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4031 /* reg_qpdsm_prio_entry_color2_e
4032 * Enable update of the entry for color 2 and a given port.
4035 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
4036 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
4037 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4039 /* reg_qpdsm_prio_entry_color2_dscp
4040 * DSCP field in the outer label of the packet for color 2 and a given port.
4041 * Reserved when e=0.
4044 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
4045 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
4046 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4048 static inline void mlxsw_reg_qpdsm_pack(char *payload, u16 local_port)
4050 MLXSW_REG_ZERO(qpdsm, payload);
4051 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
4055 mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
4057 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
4058 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
4059 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
4060 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
4061 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
4062 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
4065 /* QPDP - QoS Port DSCP to Priority Mapping Register
4066 * -------------------------------------------------
4067 * This register controls the port default Switch Priority and Color. The
4068 * default Switch Priority and Color are used for frames where the trust state
4069 * uses default values. All member ports of a LAG should be configured with the
4070 * same default values.
4072 #define MLXSW_REG_QPDP_ID 0x4007
4073 #define MLXSW_REG_QPDP_LEN 0x8
4075 MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
4077 /* reg_qpdp_local_port
4078 * Local Port. Supported for data packets from CPU port.
4081 MLXSW_ITEM32_LP(reg, qpdp, 0x00, 16, 0x00, 12);
4083 /* reg_qpdp_switch_prio
4084 * Default port Switch Priority (default 0)
4087 MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
4089 static inline void mlxsw_reg_qpdp_pack(char *payload, u16 local_port,
4092 MLXSW_REG_ZERO(qpdp, payload);
4093 mlxsw_reg_qpdp_local_port_set(payload, local_port);
4094 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
4097 /* QPDPM - QoS Port DSCP to Priority Mapping Register
4098 * --------------------------------------------------
4099 * This register controls the mapping from DSCP field to
4100 * Switch Priority for IP packets.
4102 #define MLXSW_REG_QPDPM_ID 0x4013
4103 #define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
4104 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
4105 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
4106 #define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
4107 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
4108 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
4110 MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
4112 /* reg_qpdpm_local_port
4113 * Local Port. Supported for data packets from CPU port.
4116 MLXSW_ITEM32_LP(reg, qpdpm, 0x00, 16, 0x00, 12);
4119 * Enable update of the specific entry. When cleared, the switch_prio and color
4120 * fields are ignored and the previous switch_prio and color values are
4124 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
4125 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4127 /* reg_qpdpm_dscp_prio
4128 * The new Switch Priority value for the relevant DSCP value.
4131 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
4132 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
4133 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4135 static inline void mlxsw_reg_qpdpm_pack(char *payload, u16 local_port)
4137 MLXSW_REG_ZERO(qpdpm, payload);
4138 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
4142 mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
4144 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
4145 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
4148 /* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
4149 * ------------------------------------------------------------------
4150 * This register configures if the Switch Priority to Traffic Class mapping is
4151 * based on Multicast packet indication. If so, then multicast packets will get
4152 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
4154 * By default, Switch Priority to Traffic Class mapping is not based on
4155 * Multicast packet indication.
4157 #define MLXSW_REG_QTCTM_ID 0x401A
4158 #define MLXSW_REG_QTCTM_LEN 0x08
4160 MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
4162 /* reg_qtctm_local_port
4163 * Local port number.
4164 * No support for CPU port.
4167 MLXSW_ITEM32_LP(reg, qtctm, 0x00, 16, 0x00, 12);
4171 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
4172 * indication (default is 0, not based on Multicast packet indication).
4174 MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
4177 mlxsw_reg_qtctm_pack(char *payload, u16 local_port, bool mc)
4179 MLXSW_REG_ZERO(qtctm, payload);
4180 mlxsw_reg_qtctm_local_port_set(payload, local_port);
4181 mlxsw_reg_qtctm_mc_set(payload, mc);
4184 /* QPSC - QoS PTP Shaper Configuration Register
4185 * --------------------------------------------
4186 * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1.
4187 * Supported only on Spectrum-1.
4189 #define MLXSW_REG_QPSC_ID 0x401B
4190 #define MLXSW_REG_QPSC_LEN 0x28
4192 MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
4194 enum mlxsw_reg_qpsc_port_speed {
4195 MLXSW_REG_QPSC_PORT_SPEED_100M,
4196 MLXSW_REG_QPSC_PORT_SPEED_1G,
4197 MLXSW_REG_QPSC_PORT_SPEED_10G,
4198 MLXSW_REG_QPSC_PORT_SPEED_25G,
4201 /* reg_qpsc_port_speed
4205 MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
4207 /* reg_qpsc_shaper_time_exp
4208 * The base-time-interval for updating the shapers tokens (for all hierarchies).
4209 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
4210 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
4213 MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
4215 /* reg_qpsc_shaper_time_mantissa
4216 * The base-time-interval for updating the shapers tokens (for all hierarchies).
4217 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
4218 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
4221 MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
4223 /* reg_qpsc_shaper_inc
4224 * Number of tokens added to shaper on each update.
4228 MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
4230 /* reg_qpsc_shaper_bs
4231 * Max shaper Burst size.
4232 * Burst size is 2 ^ max_shaper_bs * 512 [bits]
4233 * Range is: 5..25 (from 2KB..2GB)
4236 MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
4239 * Write enable to port_to_shaper_credits.
4242 MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
4244 /* reg_qpsc_port_to_shaper_credits
4245 * For split ports: range 1..57
4246 * For non-split ports: range 1..112
4247 * Written only when ptsc_we is set.
4250 MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
4252 /* reg_qpsc_ing_timestamp_inc
4253 * Ingress timestamp increment.
4255 * The timestamp of MTPPTR at ingress will be incremented by this value. Global
4256 * value for all ports.
4257 * Same units as used by MTPPTR.
4260 MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
4262 /* reg_qpsc_egr_timestamp_inc
4263 * Egress timestamp increment.
4265 * The timestamp of MTPPTR at egress will be incremented by this value. Global
4266 * value for all ports.
4267 * Same units as used by MTPPTR.
4270 MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
4273 mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
4274 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
4275 u8 shaper_bs, u8 port_to_shaper_credits,
4276 int ing_timestamp_inc, int egr_timestamp_inc)
4278 MLXSW_REG_ZERO(qpsc, payload);
4279 mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
4280 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
4281 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
4282 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
4283 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
4284 mlxsw_reg_qpsc_ptsc_we_set(payload, true);
4285 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
4286 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
4287 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
4290 /* PMLP - Ports Module to Local Port Register
4291 * ------------------------------------------
4292 * Configures the assignment of modules to local ports.
4294 #define MLXSW_REG_PMLP_ID 0x5002
4295 #define MLXSW_REG_PMLP_LEN 0x40
4297 MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
4300 * 0 - Tx value is used for both Tx and Rx.
4301 * 1 - Rx value is taken from a separte field.
4304 MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
4306 /* reg_pmlp_local_port
4307 * Local port number.
4310 MLXSW_ITEM32_LP(reg, pmlp, 0x00, 16, 0x00, 12);
4313 * 0 - Unmap local port.
4314 * 1 - Lane 0 is used.
4315 * 2 - Lanes 0 and 1 are used.
4316 * 4 - Lanes 0, 1, 2 and 3 are used.
4317 * 8 - Lanes 0-7 are used.
4320 MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
4326 MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
4328 /* reg_pmlp_slot_index
4331 * Slot_index = 0 represent the onboard (motherboard).
4332 * In case of non-modular system only slot_index = 0 is available.
4335 MLXSW_ITEM32_INDEXED(reg, pmlp, slot_index, 0x04, 8, 4, 0x04, 0x00, false);
4338 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
4341 MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
4344 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
4348 MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
4350 static inline void mlxsw_reg_pmlp_pack(char *payload, u16 local_port)
4352 MLXSW_REG_ZERO(pmlp, payload);
4353 mlxsw_reg_pmlp_local_port_set(payload, local_port);
4356 /* PMTU - Port MTU Register
4357 * ------------------------
4358 * Configures and reports the port MTU.
4360 #define MLXSW_REG_PMTU_ID 0x5003
4361 #define MLXSW_REG_PMTU_LEN 0x10
4363 MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
4365 /* reg_pmtu_local_port
4366 * Local port number.
4369 MLXSW_ITEM32_LP(reg, pmtu, 0x00, 16, 0x00, 12);
4373 * When port type (e.g. Ethernet) is configured, the relevant MTU is
4374 * reported, otherwise the minimum between the max_mtu of the different
4375 * types is reported.
4378 MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
4380 /* reg_pmtu_admin_mtu
4381 * MTU value to set port to. Must be smaller or equal to max_mtu.
4382 * Note: If port type is Infiniband, then port must be disabled, when its
4386 MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
4388 /* reg_pmtu_oper_mtu
4389 * The actual MTU configured on the port. Packets exceeding this size
4391 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
4392 * oper_mtu might be smaller than admin_mtu.
4395 MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
4397 static inline void mlxsw_reg_pmtu_pack(char *payload, u16 local_port,
4400 MLXSW_REG_ZERO(pmtu, payload);
4401 mlxsw_reg_pmtu_local_port_set(payload, local_port);
4402 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
4403 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
4404 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
4407 /* PTYS - Port Type and Speed Register
4408 * -----------------------------------
4409 * Configures and reports the port speed type.
4411 * Note: When set while the link is up, the changes will not take effect
4412 * until the port transitions from down to up state.
4414 #define MLXSW_REG_PTYS_ID 0x5004
4415 #define MLXSW_REG_PTYS_LEN 0x40
4417 MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
4420 * Auto negotiation disable administrative configuration
4421 * 0 - Device doesn't support AN disable.
4422 * 1 - Device supports AN disable.
4425 MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
4427 /* reg_ptys_local_port
4428 * Local port number.
4431 MLXSW_ITEM32_LP(reg, ptys, 0x00, 16, 0x00, 12);
4433 #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
4434 #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
4436 /* reg_ptys_proto_mask
4437 * Protocol mask. Indicates which protocol is used.
4439 * 1 - Fibre Channel.
4443 MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
4446 MLXSW_REG_PTYS_AN_STATUS_NA,
4447 MLXSW_REG_PTYS_AN_STATUS_OK,
4448 MLXSW_REG_PTYS_AN_STATUS_FAIL,
4451 /* reg_ptys_an_status
4452 * Autonegotiation status.
4455 MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
4457 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
4458 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
4459 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
4460 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
4461 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
4462 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
4463 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
4464 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
4465 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
4466 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
4467 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
4468 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
4470 /* reg_ptys_ext_eth_proto_cap
4471 * Extended Ethernet port supported speeds and protocols.
4474 MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
4476 #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
4477 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
4478 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
4479 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
4480 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
4481 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
4482 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
4483 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
4484 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
4485 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
4486 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
4487 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
4488 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
4489 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
4490 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
4491 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
4492 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
4493 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
4494 #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(24)
4495 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_T BIT(25)
4496 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
4497 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
4498 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
4499 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
4500 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
4502 /* reg_ptys_eth_proto_cap
4503 * Ethernet port supported speeds and protocols.
4506 MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
4508 /* reg_ptys_ib_link_width_cap
4509 * IB port supported widths.
4512 MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
4514 #define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
4515 #define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
4516 #define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
4517 #define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
4518 #define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
4519 #define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
4521 /* reg_ptys_ib_proto_cap
4522 * IB port supported speeds and protocols.
4525 MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
4527 /* reg_ptys_ext_eth_proto_admin
4528 * Extended speed and protocol to set port to.
4531 MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
4533 /* reg_ptys_eth_proto_admin
4534 * Speed and protocol to set port to.
4537 MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
4539 /* reg_ptys_ib_link_width_admin
4540 * IB width to set port to.
4543 MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
4545 /* reg_ptys_ib_proto_admin
4546 * IB speeds and protocols to set port to.
4549 MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
4551 /* reg_ptys_ext_eth_proto_oper
4552 * The extended current speed and protocol configured for the port.
4555 MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
4557 /* reg_ptys_eth_proto_oper
4558 * The current speed and protocol configured for the port.
4561 MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
4563 /* reg_ptys_ib_link_width_oper
4564 * The current IB width to set port to.
4567 MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
4569 /* reg_ptys_ib_proto_oper
4570 * The current IB speed and protocol.
4573 MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
4575 enum mlxsw_reg_ptys_connector_type {
4576 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
4577 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
4578 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
4579 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
4580 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
4581 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
4582 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
4583 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
4584 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
4587 /* reg_ptys_connector_type
4588 * Connector type indication.
4591 MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
4593 static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port,
4594 u32 proto_admin, bool autoneg)
4596 MLXSW_REG_ZERO(ptys, payload);
4597 mlxsw_reg_ptys_local_port_set(payload, local_port);
4598 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4599 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
4600 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4603 static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u16 local_port,
4604 u32 proto_admin, bool autoneg)
4606 MLXSW_REG_ZERO(ptys, payload);
4607 mlxsw_reg_ptys_local_port_set(payload, local_port);
4608 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4609 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
4610 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4613 static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
4614 u32 *p_eth_proto_cap,
4615 u32 *p_eth_proto_admin,
4616 u32 *p_eth_proto_oper)
4618 if (p_eth_proto_cap)
4620 mlxsw_reg_ptys_eth_proto_cap_get(payload);
4621 if (p_eth_proto_admin)
4622 *p_eth_proto_admin =
4623 mlxsw_reg_ptys_eth_proto_admin_get(payload);
4624 if (p_eth_proto_oper)
4626 mlxsw_reg_ptys_eth_proto_oper_get(payload);
4629 static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
4630 u32 *p_eth_proto_cap,
4631 u32 *p_eth_proto_admin,
4632 u32 *p_eth_proto_oper)
4634 if (p_eth_proto_cap)
4636 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
4637 if (p_eth_proto_admin)
4638 *p_eth_proto_admin =
4639 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
4640 if (p_eth_proto_oper)
4642 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
4645 static inline void mlxsw_reg_ptys_ib_pack(char *payload, u16 local_port,
4646 u16 proto_admin, u16 link_width)
4648 MLXSW_REG_ZERO(ptys, payload);
4649 mlxsw_reg_ptys_local_port_set(payload, local_port);
4650 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
4651 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
4652 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
4655 static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
4656 u16 *p_ib_link_width_cap,
4657 u16 *p_ib_proto_oper,
4658 u16 *p_ib_link_width_oper)
4661 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
4662 if (p_ib_link_width_cap)
4663 *p_ib_link_width_cap =
4664 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
4665 if (p_ib_proto_oper)
4666 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
4667 if (p_ib_link_width_oper)
4668 *p_ib_link_width_oper =
4669 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
4672 /* PPAD - Port Physical Address Register
4673 * -------------------------------------
4674 * The PPAD register configures the per port physical MAC address.
4676 #define MLXSW_REG_PPAD_ID 0x5005
4677 #define MLXSW_REG_PPAD_LEN 0x10
4679 MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
4681 /* reg_ppad_single_base_mac
4682 * 0: base_mac, local port should be 0 and mac[7:0] is
4683 * reserved. HW will set incremental
4684 * 1: single_mac - mac of the local_port
4687 MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
4689 /* reg_ppad_local_port
4690 * port number, if single_base_mac = 0 then local_port is reserved
4693 MLXSW_ITEM32_LP(reg, ppad, 0x00, 16, 0x00, 24);
4696 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
4697 * If single_base_mac = 1 - the per port MAC address
4700 MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
4702 static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
4705 MLXSW_REG_ZERO(ppad, payload);
4706 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
4707 mlxsw_reg_ppad_local_port_set(payload, local_port);
4710 /* PAOS - Ports Administrative and Operational Status Register
4711 * -----------------------------------------------------------
4712 * Configures and retrieves per port administrative and operational status.
4714 #define MLXSW_REG_PAOS_ID 0x5006
4715 #define MLXSW_REG_PAOS_LEN 0x10
4717 MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
4720 * Switch partition ID with which to associate the port.
4721 * Note: while external ports uses unique local port numbers (and thus swid is
4722 * redundant), router ports use the same local port number where swid is the
4723 * only indication for the relevant port.
4726 MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
4728 /* reg_paos_local_port
4729 * Local port number.
4732 MLXSW_ITEM32_LP(reg, paos, 0x00, 16, 0x00, 12);
4734 /* reg_paos_admin_status
4735 * Port administrative state (the desired state of the port):
4738 * 3 - Up once. This means that in case of link failure, the port won't go
4739 * into polling mode, but will wait to be re-enabled by software.
4740 * 4 - Disabled by system. Can only be set by hardware.
4743 MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
4745 /* reg_paos_oper_status
4746 * Port operational state (the current state):
4749 * 3 - Down by port failure. This means that the device will not let the
4750 * port up again until explicitly specified by software.
4753 MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
4756 * Admin state update enabled.
4759 MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
4762 * Event update enable. If this bit is set, event generation will be
4763 * updated based on the e field.
4766 MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
4769 * Event generation on operational state change:
4770 * 0 - Do not generate event.
4771 * 1 - Generate Event.
4772 * 2 - Generate Single Event.
4775 MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
4777 static inline void mlxsw_reg_paos_pack(char *payload, u16 local_port,
4778 enum mlxsw_port_admin_status status)
4780 MLXSW_REG_ZERO(paos, payload);
4781 mlxsw_reg_paos_swid_set(payload, 0);
4782 mlxsw_reg_paos_local_port_set(payload, local_port);
4783 mlxsw_reg_paos_admin_status_set(payload, status);
4784 mlxsw_reg_paos_oper_status_set(payload, 0);
4785 mlxsw_reg_paos_ase_set(payload, 1);
4786 mlxsw_reg_paos_ee_set(payload, 1);
4787 mlxsw_reg_paos_e_set(payload, 1);
4790 /* PFCC - Ports Flow Control Configuration Register
4791 * ------------------------------------------------
4792 * Configures and retrieves the per port flow control configuration.
4794 #define MLXSW_REG_PFCC_ID 0x5007
4795 #define MLXSW_REG_PFCC_LEN 0x20
4797 MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
4799 /* reg_pfcc_local_port
4800 * Local port number.
4803 MLXSW_ITEM32_LP(reg, pfcc, 0x00, 16, 0x00, 12);
4806 * Port number access type. Determines the way local_port is interpreted:
4807 * 0 - Local port number.
4808 * 1 - IB / label port number.
4811 MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
4814 * Send to higher layers capabilities:
4815 * 0 - No capability of sending Pause and PFC frames to higher layers.
4816 * 1 - Device has capability of sending Pause and PFC frames to higher
4820 MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4823 * Send to higher layers operation:
4824 * 0 - Pause and PFC frames are handled by the port (default).
4825 * 1 - Pause and PFC frames are handled by the port and also sent to
4826 * higher layers. Only valid if shl_cap = 1.
4829 MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4832 * Pause policy auto negotiation.
4833 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
4834 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
4835 * based on the auto-negotiation resolution.
4838 * Note: The auto-negotiation advertisement is set according to pptx and
4839 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
4841 MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4843 /* reg_pfcc_prio_mask_tx
4844 * Bit per priority indicating if Tx flow control policy should be
4845 * updated based on bit pfctx.
4848 MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4850 /* reg_pfcc_prio_mask_rx
4851 * Bit per priority indicating if Rx flow control policy should be
4852 * updated based on bit pfcrx.
4855 MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4858 * Admin Pause policy on Tx.
4859 * 0 - Never generate Pause frames (default).
4860 * 1 - Generate Pause frames according to Rx buffer threshold.
4863 MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4866 * Active (operational) Pause policy on Tx.
4867 * 0 - Never generate Pause frames.
4868 * 1 - Generate Pause frames according to Rx buffer threshold.
4871 MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4874 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
4875 * 0 - Never generate priority Pause frames on the specified priority
4877 * 1 - Generate priority Pause frames according to Rx buffer threshold on
4878 * the specified priority.
4881 * Note: pfctx and pptx must be mutually exclusive.
4883 MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4886 * Admin Pause policy on Rx.
4887 * 0 - Ignore received Pause frames (default).
4888 * 1 - Respect received Pause frames.
4891 MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4894 * Active (operational) Pause policy on Rx.
4895 * 0 - Ignore received Pause frames.
4896 * 1 - Respect received Pause frames.
4899 MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4902 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
4903 * 0 - Ignore incoming priority Pause frames on the specified priority
4905 * 1 - Respect incoming priority Pause frames on the specified priority.
4908 MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4910 #define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4912 static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4914 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4915 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4916 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4917 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4920 static inline void mlxsw_reg_pfcc_pack(char *payload, u16 local_port)
4922 MLXSW_REG_ZERO(pfcc, payload);
4923 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4926 /* PPCNT - Ports Performance Counters Register
4927 * -------------------------------------------
4928 * The PPCNT register retrieves per port performance counters.
4930 #define MLXSW_REG_PPCNT_ID 0x5008
4931 #define MLXSW_REG_PPCNT_LEN 0x100
4932 #define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
4934 MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
4937 * For HCA: must be always 0.
4938 * Switch partition ID to associate port with.
4939 * Switch partitions are numbered from 0 to 7 inclusively.
4940 * Switch partition 254 indicates stacking ports.
4941 * Switch partition 255 indicates all switch partitions.
4942 * Only valid on Set() operation with local_port=255.
4945 MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4947 /* reg_ppcnt_local_port
4948 * Local port number.
4951 MLXSW_ITEM32_LP(reg, ppcnt, 0x00, 16, 0x00, 12);
4954 * Port number access type:
4955 * 0 - Local port number
4956 * 1 - IB port number
4959 MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4961 enum mlxsw_reg_ppcnt_grp {
4962 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
4963 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
4964 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
4965 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
4966 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
4967 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
4968 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
4969 MLXSW_REG_PPCNT_TC_CNT = 0x11,
4970 MLXSW_REG_PPCNT_TC_CONG_CNT = 0x13,
4974 * Performance counter group.
4975 * Group 63 indicates all groups. Only valid on Set() operation with
4977 * 0x0: IEEE 802.3 Counters
4978 * 0x1: RFC 2863 Counters
4979 * 0x2: RFC 2819 Counters
4980 * 0x3: RFC 3635 Counters
4981 * 0x5: Ethernet Extended Counters
4982 * 0x6: Ethernet Discard Counters
4983 * 0x8: Link Level Retransmission Counters
4984 * 0x10: Per Priority Counters
4985 * 0x11: Per Traffic Class Counters
4986 * 0x12: Physical Layer Counters
4987 * 0x13: Per Traffic Class Congestion Counters
4990 MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4993 * Clear counters. Setting the clr bit will reset the counter value
4994 * for all counters in the counter group. This bit can be set
4995 * for both Set() and Get() operation.
4998 MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
5001 * Local port global variable.
5002 * 0: local_port 255 = all ports of the device.
5003 * 1: local_port indicates local port number for all ports.
5006 MLXSW_ITEM32(reg, ppcnt, lp_gl, 0x04, 30, 1);
5008 /* reg_ppcnt_prio_tc
5009 * Priority for counter set that support per priority, valid values: 0-7.
5010 * Traffic class for counter set that support per traffic class,
5011 * valid values: 0- cap_max_tclass-1 .
5012 * For HCA: cap_max_tclass is always 8.
5013 * Otherwise must be 0.
5016 MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
5018 /* Ethernet IEEE 802.3 Counter Group */
5020 /* reg_ppcnt_a_frames_transmitted_ok
5023 MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
5024 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5026 /* reg_ppcnt_a_frames_received_ok
5029 MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
5030 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5032 /* reg_ppcnt_a_frame_check_sequence_errors
5035 MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
5036 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5038 /* reg_ppcnt_a_alignment_errors
5041 MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
5042 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5044 /* reg_ppcnt_a_octets_transmitted_ok
5047 MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
5048 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5050 /* reg_ppcnt_a_octets_received_ok
5053 MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
5054 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5056 /* reg_ppcnt_a_multicast_frames_xmitted_ok
5059 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
5060 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5062 /* reg_ppcnt_a_broadcast_frames_xmitted_ok
5065 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
5066 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5068 /* reg_ppcnt_a_multicast_frames_received_ok
5071 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
5072 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5074 /* reg_ppcnt_a_broadcast_frames_received_ok
5077 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
5078 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5080 /* reg_ppcnt_a_in_range_length_errors
5083 MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
5084 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5086 /* reg_ppcnt_a_out_of_range_length_field
5089 MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
5090 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5092 /* reg_ppcnt_a_frame_too_long_errors
5095 MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
5096 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5098 /* reg_ppcnt_a_symbol_error_during_carrier
5101 MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
5102 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5104 /* reg_ppcnt_a_mac_control_frames_transmitted
5107 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
5108 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5110 /* reg_ppcnt_a_mac_control_frames_received
5113 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
5114 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5116 /* reg_ppcnt_a_unsupported_opcodes_received
5119 MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
5120 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5122 /* reg_ppcnt_a_pause_mac_ctrl_frames_received
5125 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
5126 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5128 /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
5131 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
5132 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5134 /* Ethernet RFC 2863 Counter Group */
5136 /* reg_ppcnt_if_in_discards
5139 MLXSW_ITEM64(reg, ppcnt, if_in_discards,
5140 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5142 /* reg_ppcnt_if_out_discards
5145 MLXSW_ITEM64(reg, ppcnt, if_out_discards,
5146 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5148 /* reg_ppcnt_if_out_errors
5151 MLXSW_ITEM64(reg, ppcnt, if_out_errors,
5152 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5154 /* Ethernet RFC 2819 Counter Group */
5156 /* reg_ppcnt_ether_stats_undersize_pkts
5159 MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
5160 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5162 /* reg_ppcnt_ether_stats_oversize_pkts
5165 MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
5166 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5168 /* reg_ppcnt_ether_stats_fragments
5171 MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
5172 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5174 /* reg_ppcnt_ether_stats_pkts64octets
5177 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
5178 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5180 /* reg_ppcnt_ether_stats_pkts65to127octets
5183 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
5184 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5186 /* reg_ppcnt_ether_stats_pkts128to255octets
5189 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
5190 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5192 /* reg_ppcnt_ether_stats_pkts256to511octets
5195 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
5196 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5198 /* reg_ppcnt_ether_stats_pkts512to1023octets
5201 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
5202 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5204 /* reg_ppcnt_ether_stats_pkts1024to1518octets
5207 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
5208 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5210 /* reg_ppcnt_ether_stats_pkts1519to2047octets
5213 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
5214 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5216 /* reg_ppcnt_ether_stats_pkts2048to4095octets
5219 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
5220 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5222 /* reg_ppcnt_ether_stats_pkts4096to8191octets
5225 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
5226 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
5228 /* reg_ppcnt_ether_stats_pkts8192to10239octets
5231 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
5232 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
5234 /* Ethernet RFC 3635 Counter Group */
5236 /* reg_ppcnt_dot3stats_fcs_errors
5239 MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
5240 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5242 /* reg_ppcnt_dot3stats_symbol_errors
5245 MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
5246 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5248 /* reg_ppcnt_dot3control_in_unknown_opcodes
5251 MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
5252 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5254 /* reg_ppcnt_dot3in_pause_frames
5257 MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
5258 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5260 /* Ethernet Extended Counter Group Counters */
5262 /* reg_ppcnt_ecn_marked
5265 MLXSW_ITEM64(reg, ppcnt, ecn_marked,
5266 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5268 /* Ethernet Discard Counter Group Counters */
5270 /* reg_ppcnt_ingress_general
5273 MLXSW_ITEM64(reg, ppcnt, ingress_general,
5274 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5276 /* reg_ppcnt_ingress_policy_engine
5279 MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
5280 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5282 /* reg_ppcnt_ingress_vlan_membership
5285 MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
5286 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5288 /* reg_ppcnt_ingress_tag_frame_type
5291 MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
5292 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5294 /* reg_ppcnt_egress_vlan_membership
5297 MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
5298 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5300 /* reg_ppcnt_loopback_filter
5303 MLXSW_ITEM64(reg, ppcnt, loopback_filter,
5304 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5306 /* reg_ppcnt_egress_general
5309 MLXSW_ITEM64(reg, ppcnt, egress_general,
5310 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5312 /* reg_ppcnt_egress_hoq
5315 MLXSW_ITEM64(reg, ppcnt, egress_hoq,
5316 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5318 /* reg_ppcnt_egress_policy_engine
5321 MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
5322 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5324 /* reg_ppcnt_ingress_tx_link_down
5327 MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
5328 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5330 /* reg_ppcnt_egress_stp_filter
5333 MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
5334 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5336 /* reg_ppcnt_egress_sll
5339 MLXSW_ITEM64(reg, ppcnt, egress_sll,
5340 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5342 /* Ethernet Per Priority Group Counters */
5344 /* reg_ppcnt_rx_octets
5347 MLXSW_ITEM64(reg, ppcnt, rx_octets,
5348 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5350 /* reg_ppcnt_rx_frames
5353 MLXSW_ITEM64(reg, ppcnt, rx_frames,
5354 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5356 /* reg_ppcnt_tx_octets
5359 MLXSW_ITEM64(reg, ppcnt, tx_octets,
5360 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5362 /* reg_ppcnt_tx_frames
5365 MLXSW_ITEM64(reg, ppcnt, tx_frames,
5366 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5368 /* reg_ppcnt_rx_pause
5371 MLXSW_ITEM64(reg, ppcnt, rx_pause,
5372 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5374 /* reg_ppcnt_rx_pause_duration
5377 MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
5378 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5380 /* reg_ppcnt_tx_pause
5383 MLXSW_ITEM64(reg, ppcnt, tx_pause,
5384 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5386 /* reg_ppcnt_tx_pause_duration
5389 MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
5390 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5392 /* reg_ppcnt_rx_pause_transition
5395 MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
5396 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5398 /* Ethernet Per Traffic Class Counters */
5400 /* reg_ppcnt_tc_transmit_queue
5401 * Contains the transmit queue depth in cells of traffic class
5402 * selected by prio_tc and the port selected by local_port.
5403 * The field cannot be cleared.
5406 MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
5407 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5409 /* reg_ppcnt_tc_no_buffer_discard_uc
5410 * The number of unicast packets dropped due to lack of shared
5414 MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
5415 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5417 /* Ethernet Per Traffic Class Congestion Group Counters */
5419 /* reg_ppcnt_wred_discard
5422 MLXSW_ITEM64(reg, ppcnt, wred_discard,
5423 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5425 /* reg_ppcnt_ecn_marked_tc
5428 MLXSW_ITEM64(reg, ppcnt, ecn_marked_tc,
5429 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5431 static inline void mlxsw_reg_ppcnt_pack(char *payload, u16 local_port,
5432 enum mlxsw_reg_ppcnt_grp grp,
5435 MLXSW_REG_ZERO(ppcnt, payload);
5436 mlxsw_reg_ppcnt_swid_set(payload, 0);
5437 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
5438 mlxsw_reg_ppcnt_pnat_set(payload, 0);
5439 mlxsw_reg_ppcnt_grp_set(payload, grp);
5440 mlxsw_reg_ppcnt_clr_set(payload, 0);
5441 mlxsw_reg_ppcnt_lp_gl_set(payload, 1);
5442 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
5445 /* PLIB - Port Local to InfiniBand Port
5446 * ------------------------------------
5447 * The PLIB register performs mapping from Local Port into InfiniBand Port.
5449 #define MLXSW_REG_PLIB_ID 0x500A
5450 #define MLXSW_REG_PLIB_LEN 0x10
5452 MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
5454 /* reg_plib_local_port
5455 * Local port number.
5458 MLXSW_ITEM32_LP(reg, plib, 0x00, 16, 0x00, 12);
5461 * InfiniBand port remapping for local_port.
5464 MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
5466 /* PPTB - Port Prio To Buffer Register
5467 * -----------------------------------
5468 * Configures the switch priority to buffer table.
5470 #define MLXSW_REG_PPTB_ID 0x500B
5471 #define MLXSW_REG_PPTB_LEN 0x10
5473 MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
5476 MLXSW_REG_PPTB_MM_UM,
5477 MLXSW_REG_PPTB_MM_UNICAST,
5478 MLXSW_REG_PPTB_MM_MULTICAST,
5483 * 0 - Map both unicast and multicast packets to the same buffer.
5484 * 1 - Map only unicast packets.
5485 * 2 - Map only multicast packets.
5488 * Note: SwitchX-2 only supports the first option.
5490 MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
5492 /* reg_pptb_local_port
5493 * Local port number.
5496 MLXSW_ITEM32_LP(reg, pptb, 0x00, 16, 0x00, 12);
5499 * Enables the update of the untagged_buf field.
5502 MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
5505 * Enables the update of the prio_to_buff field.
5506 * Bit <i> is a flag for updating the mapping for switch priority <i>.
5509 MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
5511 /* reg_pptb_prio_to_buff
5512 * Mapping of switch priority <i> to one of the allocated receive port
5516 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
5519 * Enables the update of the prio_to_buff field.
5520 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
5523 MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
5525 /* reg_pptb_untagged_buff
5526 * Mapping of untagged frames to one of the allocated receive port buffers.
5529 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
5530 * Spectrum, as it maps untagged packets based on the default switch priority.
5532 MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
5534 /* reg_pptb_prio_to_buff_msb
5535 * Mapping of switch priority <i+8> to one of the allocated receive port
5539 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
5541 #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
5543 static inline void mlxsw_reg_pptb_pack(char *payload, u16 local_port)
5545 MLXSW_REG_ZERO(pptb, payload);
5546 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
5547 mlxsw_reg_pptb_local_port_set(payload, local_port);
5548 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5549 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5552 static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
5555 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
5556 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
5559 /* PBMC - Port Buffer Management Control Register
5560 * ----------------------------------------------
5561 * The PBMC register configures and retrieves the port packet buffer
5562 * allocation for different Prios, and the Pause threshold management.
5564 #define MLXSW_REG_PBMC_ID 0x500C
5565 #define MLXSW_REG_PBMC_LEN 0x6C
5567 MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
5569 /* reg_pbmc_local_port
5570 * Local port number.
5573 MLXSW_ITEM32_LP(reg, pbmc, 0x00, 16, 0x00, 12);
5575 /* reg_pbmc_xoff_timer_value
5576 * When device generates a pause frame, it uses this value as the pause
5577 * timer (time for the peer port to pause in quota-512 bit time).
5580 MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
5582 /* reg_pbmc_xoff_refresh
5583 * The time before a new pause frame should be sent to refresh the pause RW
5584 * state. Using the same units as xoff_timer_value above (in quota-512 bit
5588 MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
5590 #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
5592 /* reg_pbmc_buf_lossy
5593 * The field indicates if the buffer is lossy.
5598 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
5600 /* reg_pbmc_buf_epsb
5601 * Eligible for Port Shared buffer.
5602 * If epsb is set, packets assigned to buffer are allowed to insert the port
5604 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
5607 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
5609 /* reg_pbmc_buf_size
5610 * The part of the packet buffer array is allocated for the specific buffer.
5611 * Units are represented in cells.
5614 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
5616 /* reg_pbmc_buf_xoff_threshold
5617 * Once the amount of data in the buffer goes above this value, device
5618 * starts sending PFC frames for all priorities associated with the
5619 * buffer. Units are represented in cells. Reserved in case of lossy
5623 * Note: In Spectrum, reserved for buffer[9].
5625 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
5628 /* reg_pbmc_buf_xon_threshold
5629 * When the amount of data in the buffer goes below this value, device
5630 * stops sending PFC frames for the priorities associated with the
5631 * buffer. Units are represented in cells. Reserved in case of lossy
5635 * Note: In Spectrum, reserved for buffer[9].
5637 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
5640 static inline void mlxsw_reg_pbmc_pack(char *payload, u16 local_port,
5641 u16 xoff_timer_value, u16 xoff_refresh)
5643 MLXSW_REG_ZERO(pbmc, payload);
5644 mlxsw_reg_pbmc_local_port_set(payload, local_port);
5645 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
5646 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
5649 static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
5653 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
5654 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5655 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5658 static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
5659 int buf_index, u16 size,
5662 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
5663 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5664 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5665 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
5666 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
5669 /* PSPA - Port Switch Partition Allocation
5670 * ---------------------------------------
5671 * Controls the association of a port with a switch partition and enables
5672 * configuring ports as stacking ports.
5674 #define MLXSW_REG_PSPA_ID 0x500D
5675 #define MLXSW_REG_PSPA_LEN 0x8
5677 MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
5680 * Switch partition ID.
5683 MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
5685 /* reg_pspa_local_port
5686 * Local port number.
5689 MLXSW_ITEM32_LP(reg, pspa, 0x00, 16, 0x00, 0);
5691 /* reg_pspa_sub_port
5692 * Virtual port within the local port. Set to 0 when virtual ports are
5693 * disabled on the local port.
5696 MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
5698 static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u16 local_port)
5700 MLXSW_REG_ZERO(pspa, payload);
5701 mlxsw_reg_pspa_swid_set(payload, swid);
5702 mlxsw_reg_pspa_local_port_set(payload, local_port);
5703 mlxsw_reg_pspa_sub_port_set(payload, 0);
5706 /* PMAOS - Ports Module Administrative and Operational Status
5707 * ----------------------------------------------------------
5708 * This register configures and retrieves the per module status.
5710 #define MLXSW_REG_PMAOS_ID 0x5012
5711 #define MLXSW_REG_PMAOS_LEN 0x10
5713 MLXSW_REG_DEFINE(pmaos, MLXSW_REG_PMAOS_ID, MLXSW_REG_PMAOS_LEN);
5716 * Module reset toggle.
5717 * Note: Setting reset while module is plugged-in will result in transition to
5718 * "initializing" operational state.
5721 MLXSW_ITEM32(reg, pmaos, rst, 0x00, 31, 1);
5723 /* reg_pmaos_slot_index
5727 MLXSW_ITEM32(reg, pmaos, slot_index, 0x00, 24, 4);
5733 MLXSW_ITEM32(reg, pmaos, module, 0x00, 16, 8);
5735 enum mlxsw_reg_pmaos_admin_status {
5736 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED = 1,
5737 MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED = 2,
5738 /* If the module is active and then unplugged, or experienced an error
5739 * event, the operational status should go to "disabled" and can only
5740 * be enabled upon explicit enable command.
5742 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED_ONCE = 3,
5745 /* reg_pmaos_admin_status
5746 * Module administrative state (the desired state of the module).
5747 * Note: To disable a module, all ports associated with the port must be
5748 * administatively down first.
5751 MLXSW_ITEM32(reg, pmaos, admin_status, 0x00, 8, 4);
5754 * Admin state update enable.
5755 * If this bit is set, admin state will be updated based on admin_state field.
5756 * Only relevant on Set() operations.
5759 MLXSW_ITEM32(reg, pmaos, ase, 0x04, 31, 1);
5762 * Event update enable.
5763 * If this bit is set, event generation will be updated based on the e field.
5764 * Only relevant on Set operations.
5767 MLXSW_ITEM32(reg, pmaos, ee, 0x04, 30, 1);
5769 enum mlxsw_reg_pmaos_e {
5770 MLXSW_REG_PMAOS_E_DO_NOT_GENERATE_EVENT,
5771 MLXSW_REG_PMAOS_E_GENERATE_EVENT,
5772 MLXSW_REG_PMAOS_E_GENERATE_SINGLE_EVENT,
5776 * Event Generation on operational state change.
5779 MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2);
5781 static inline void mlxsw_reg_pmaos_pack(char *payload, u8 slot_index, u8 module)
5783 MLXSW_REG_ZERO(pmaos, payload);
5784 mlxsw_reg_pmaos_slot_index_set(payload, slot_index);
5785 mlxsw_reg_pmaos_module_set(payload, module);
5788 /* PPLR - Port Physical Loopback Register
5789 * --------------------------------------
5790 * This register allows configuration of the port's loopback mode.
5792 #define MLXSW_REG_PPLR_ID 0x5018
5793 #define MLXSW_REG_PPLR_LEN 0x8
5795 MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
5797 /* reg_pplr_local_port
5798 * Local port number.
5801 MLXSW_ITEM32_LP(reg, pplr, 0x00, 16, 0x00, 12);
5803 /* Phy local loopback. When set the port's egress traffic is looped back
5804 * to the receiver and the port transmitter is disabled.
5806 #define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
5812 MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
5814 static inline void mlxsw_reg_pplr_pack(char *payload, u16 local_port,
5817 MLXSW_REG_ZERO(pplr, payload);
5818 mlxsw_reg_pplr_local_port_set(payload, local_port);
5819 mlxsw_reg_pplr_lb_en_set(payload,
5821 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
5824 /* PMTDB - Port Module To local DataBase Register
5825 * ----------------------------------------------
5826 * The PMTDB register allows to query the possible module<->local port
5827 * mapping than can be used in PMLP. It does not represent the actual/current
5828 * mapping of the local to module. Actual mapping is only defined by PMLP.
5830 #define MLXSW_REG_PMTDB_ID 0x501A
5831 #define MLXSW_REG_PMTDB_LEN 0x40
5833 MLXSW_REG_DEFINE(pmtdb, MLXSW_REG_PMTDB_ID, MLXSW_REG_PMTDB_LEN);
5835 /* reg_pmtdb_slot_index
5836 * Slot index (0: Main board).
5839 MLXSW_ITEM32(reg, pmtdb, slot_index, 0x00, 24, 4);
5845 MLXSW_ITEM32(reg, pmtdb, module, 0x00, 16, 8);
5847 /* reg_pmtdb_ports_width
5851 MLXSW_ITEM32(reg, pmtdb, ports_width, 0x00, 12, 4);
5853 /* reg_pmtdb_num_ports
5854 * Number of ports in a single module (split/breakout)
5857 MLXSW_ITEM32(reg, pmtdb, num_ports, 0x00, 8, 4);
5859 enum mlxsw_reg_pmtdb_status {
5860 MLXSW_REG_PMTDB_STATUS_SUCCESS,
5867 MLXSW_ITEM32(reg, pmtdb, status, 0x00, 0, 4);
5869 /* reg_pmtdb_port_num
5870 * The local_port value which can be assigned to the module.
5871 * In case of more than one port, port<x> represent the /<x> port of
5875 MLXSW_ITEM16_INDEXED(reg, pmtdb, port_num, 0x04, 0, 10, 0x02, 0x00, false);
5877 static inline void mlxsw_reg_pmtdb_pack(char *payload, u8 slot_index, u8 module,
5878 u8 ports_width, u8 num_ports)
5880 MLXSW_REG_ZERO(pmtdb, payload);
5881 mlxsw_reg_pmtdb_slot_index_set(payload, slot_index);
5882 mlxsw_reg_pmtdb_module_set(payload, module);
5883 mlxsw_reg_pmtdb_ports_width_set(payload, ports_width);
5884 mlxsw_reg_pmtdb_num_ports_set(payload, num_ports);
5887 /* PMECR - Ports Mapping Event Configuration Register
5888 * --------------------------------------------------
5889 * The PMECR register is used to enable/disable event triggering
5890 * in case of local port mapping change.
5892 #define MLXSW_REG_PMECR_ID 0x501B
5893 #define MLXSW_REG_PMECR_LEN 0x20
5895 MLXSW_REG_DEFINE(pmecr, MLXSW_REG_PMECR_ID, MLXSW_REG_PMECR_LEN);
5897 /* reg_pmecr_local_port
5898 * Local port number.
5901 MLXSW_ITEM32_LP(reg, pmecr, 0x00, 16, 0x00, 12);
5904 * Event update enable. If this bit is set, event generation will be updated
5905 * based on the e field. Only relevant on Set operations.
5908 MLXSW_ITEM32(reg, pmecr, ee, 0x04, 30, 1);
5911 * Software ignore enable bit. If this bit is set, the value of swi is used.
5912 * If this bit is clear, the value of swi is ignored.
5913 * Only relevant on Set operations.
5916 MLXSW_ITEM32(reg, pmecr, eswi, 0x04, 24, 1);
5919 * Software ignore. If this bit is set, the device shouldn't generate events
5920 * in case of PMLP SET operation but only upon self local port mapping change
5921 * (if applicable according to e configuration). This is supplementary
5922 * configuration on top of e value.
5925 MLXSW_ITEM32(reg, pmecr, swi, 0x04, 8, 1);
5927 enum mlxsw_reg_pmecr_e {
5928 MLXSW_REG_PMECR_E_DO_NOT_GENERATE_EVENT,
5929 MLXSW_REG_PMECR_E_GENERATE_EVENT,
5930 MLXSW_REG_PMECR_E_GENERATE_SINGLE_EVENT,
5934 * Event generation on local port mapping change.
5937 MLXSW_ITEM32(reg, pmecr, e, 0x04, 0, 2);
5939 static inline void mlxsw_reg_pmecr_pack(char *payload, u16 local_port,
5940 enum mlxsw_reg_pmecr_e e)
5942 MLXSW_REG_ZERO(pmecr, payload);
5943 mlxsw_reg_pmecr_local_port_set(payload, local_port);
5944 mlxsw_reg_pmecr_e_set(payload, e);
5945 mlxsw_reg_pmecr_ee_set(payload, true);
5946 mlxsw_reg_pmecr_swi_set(payload, true);
5947 mlxsw_reg_pmecr_eswi_set(payload, true);
5950 /* PMPE - Port Module Plug/Unplug Event Register
5951 * ---------------------------------------------
5952 * This register reports any operational status change of a module.
5953 * A change in the module’s state will generate an event only if the change
5954 * happens after arming the event mechanism. Any changes to the module state
5955 * while the event mechanism is not armed will not be reported. Software can
5956 * query the PMPE register for module status.
5958 #define MLXSW_REG_PMPE_ID 0x5024
5959 #define MLXSW_REG_PMPE_LEN 0x10
5961 MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN);
5963 /* reg_pmpe_slot_index
5967 MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4);
5973 MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8);
5975 enum mlxsw_reg_pmpe_module_status {
5976 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1,
5977 MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED,
5978 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR,
5979 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED,
5982 /* reg_pmpe_module_status
5986 MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4);
5988 /* reg_pmpe_error_type
5989 * Module error details.
5992 MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4);
5994 /* PDDR - Port Diagnostics Database Register
5995 * -----------------------------------------
5996 * The PDDR enables to read the Phy debug database
5998 #define MLXSW_REG_PDDR_ID 0x5031
5999 #define MLXSW_REG_PDDR_LEN 0x100
6001 MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN);
6003 /* reg_pddr_local_port
6004 * Local port number.
6007 MLXSW_ITEM32_LP(reg, pddr, 0x00, 16, 0x00, 12);
6009 enum mlxsw_reg_pddr_page_select {
6010 MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1,
6013 /* reg_pddr_page_select
6014 * Page select index.
6017 MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8);
6019 enum mlxsw_reg_pddr_trblsh_group_opcode {
6020 /* Monitor opcodes */
6021 MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR,
6024 /* reg_pddr_group_opcode
6028 MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
6030 /* reg_pddr_status_opcode
6034 MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
6036 static inline void mlxsw_reg_pddr_pack(char *payload, u16 local_port,
6039 MLXSW_REG_ZERO(pddr, payload);
6040 mlxsw_reg_pddr_local_port_set(payload, local_port);
6041 mlxsw_reg_pddr_page_select_set(payload, page_select);
6044 /* PMMP - Port Module Memory Map Properties Register
6045 * -------------------------------------------------
6046 * The PMMP register allows to override the module memory map advertisement.
6047 * The register can only be set when the module is disabled by PMAOS register.
6049 #define MLXSW_REG_PMMP_ID 0x5044
6050 #define MLXSW_REG_PMMP_LEN 0x2C
6052 MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN);
6058 MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8);
6060 /* reg_pmmp_slot_index
6064 MLXSW_ITEM32(reg, pmmp, slot_index, 0x00, 24, 4);
6067 * When set, will keep eeprom_override values after plug-out event.
6070 MLXSW_ITEM32(reg, pmmp, sticky, 0x00, 0, 1);
6072 /* reg_pmmp_eeprom_override_mask
6073 * Write mask bit (negative polarity).
6076 * On write, indicates which of the bits from eeprom_override field are
6080 MLXSW_ITEM32(reg, pmmp, eeprom_override_mask, 0x04, 16, 16);
6083 /* Set module to low power mode */
6084 MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK = BIT(8),
6087 /* reg_pmmp_eeprom_override
6088 * Override / ignore EEPROM advertisement properties bitmask
6091 MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16);
6093 static inline void mlxsw_reg_pmmp_pack(char *payload, u8 slot_index, u8 module)
6095 MLXSW_REG_ZERO(pmmp, payload);
6096 mlxsw_reg_pmmp_slot_index_set(payload, slot_index);
6097 mlxsw_reg_pmmp_module_set(payload, module);
6100 /* PLLP - Port Local port to Label Port mapping Register
6101 * -----------------------------------------------------
6102 * The PLLP register returns the mapping from Local Port into Label Port.
6104 #define MLXSW_REG_PLLP_ID 0x504A
6105 #define MLXSW_REG_PLLP_LEN 0x10
6107 MLXSW_REG_DEFINE(pllp, MLXSW_REG_PLLP_ID, MLXSW_REG_PLLP_LEN);
6109 /* reg_pllp_local_port
6110 * Local port number.
6113 MLXSW_ITEM32_LP(reg, pllp, 0x00, 16, 0x00, 12);
6115 /* reg_pllp_label_port
6116 * Front panel label of the port.
6119 MLXSW_ITEM32(reg, pllp, label_port, 0x00, 0, 8);
6121 /* reg_pllp_split_num
6122 * Label split mapping for local_port.
6125 MLXSW_ITEM32(reg, pllp, split_num, 0x04, 0, 4);
6127 /* reg_pllp_slot_index
6128 * Slot index (0: Main board).
6131 MLXSW_ITEM32(reg, pllp, slot_index, 0x08, 0, 4);
6133 static inline void mlxsw_reg_pllp_pack(char *payload, u16 local_port)
6135 MLXSW_REG_ZERO(pllp, payload);
6136 mlxsw_reg_pllp_local_port_set(payload, local_port);
6139 static inline void mlxsw_reg_pllp_unpack(char *payload, u8 *label_port,
6140 u8 *split_num, u8 *slot_index)
6142 *label_port = mlxsw_reg_pllp_label_port_get(payload);
6143 *split_num = mlxsw_reg_pllp_split_num_get(payload);
6144 *slot_index = mlxsw_reg_pllp_slot_index_get(payload);
6147 /* PMTM - Port Module Type Mapping Register
6148 * ----------------------------------------
6149 * The PMTM register allows query or configuration of module types.
6150 * The register can only be set when the module is disabled by PMAOS register
6152 #define MLXSW_REG_PMTM_ID 0x5067
6153 #define MLXSW_REG_PMTM_LEN 0x10
6155 MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
6157 /* reg_pmtm_slot_index
6161 MLXSW_ITEM32(reg, pmtm, slot_index, 0x00, 24, 4);
6167 MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
6169 enum mlxsw_reg_pmtm_module_type {
6170 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_4_LANES = 0,
6171 MLXSW_REG_PMTM_MODULE_TYPE_QSFP = 1,
6172 MLXSW_REG_PMTM_MODULE_TYPE_SFP = 2,
6173 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_SINGLE_LANE = 4,
6174 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_2_LANES = 8,
6175 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP4X = 10,
6176 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP2X = 11,
6177 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP1X = 12,
6178 MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD = 14,
6179 MLXSW_REG_PMTM_MODULE_TYPE_OSFP = 15,
6180 MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD = 16,
6181 MLXSW_REG_PMTM_MODULE_TYPE_DSFP = 17,
6182 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP8X = 18,
6183 MLXSW_REG_PMTM_MODULE_TYPE_TWISTED_PAIR = 19,
6186 /* reg_pmtm_module_type
6190 MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 5);
6192 static inline void mlxsw_reg_pmtm_pack(char *payload, u8 slot_index, u8 module)
6194 MLXSW_REG_ZERO(pmtm, payload);
6195 mlxsw_reg_pmtm_slot_index_set(payload, slot_index);
6196 mlxsw_reg_pmtm_module_set(payload, module);
6199 /* HTGT - Host Trap Group Table
6200 * ----------------------------
6201 * Configures the properties for forwarding to CPU.
6203 #define MLXSW_REG_HTGT_ID 0x7002
6204 #define MLXSW_REG_HTGT_LEN 0x20
6206 MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
6209 * Switch partition ID.
6212 MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
6214 #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
6220 MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
6222 enum mlxsw_reg_htgt_trap_group {
6223 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
6224 MLXSW_REG_HTGT_TRAP_GROUP_CORE_EVENT,
6225 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
6226 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
6227 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
6228 MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
6229 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
6230 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
6231 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
6232 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
6233 MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
6234 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
6235 MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE,
6236 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
6237 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
6238 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
6239 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
6240 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
6241 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
6242 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
6243 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
6244 MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
6245 MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
6246 MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS,
6247 MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
6248 MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
6249 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
6250 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
6251 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
6252 MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
6253 MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
6254 MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
6256 __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
6257 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
6260 /* reg_htgt_trap_group
6261 * Trap group number. User defined number specifying which trap groups
6262 * should be forwarded to the CPU. The mapping between trap IDs and trap
6263 * groups is configured using HPKT register.
6266 MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
6269 MLXSW_REG_HTGT_POLICER_DISABLE,
6270 MLXSW_REG_HTGT_POLICER_ENABLE,
6274 * Enable policer ID specified using 'pid' field.
6277 MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
6279 #define MLXSW_REG_HTGT_INVALID_POLICER 0xff
6282 * Policer ID for the trap group.
6285 MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
6287 #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
6289 /* reg_htgt_mirror_action
6290 * Mirror action to use.
6292 * 1 - Trap to CPU and mirror to a mirroring agent.
6293 * 2 - Mirror to a mirroring agent and do not trap to CPU.
6296 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
6298 MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
6300 /* reg_htgt_mirroring_agent
6304 MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
6306 #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
6308 /* reg_htgt_priority
6309 * Trap group priority.
6310 * In case a packet matches multiple classification rules, the packet will
6311 * only be trapped once, based on the trap ID associated with the group (via
6312 * register HPKT) with the highest priority.
6313 * Supported values are 0-7, with 7 represnting the highest priority.
6316 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
6317 * by the 'trap_group' field.
6319 MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
6321 #define MLXSW_REG_HTGT_DEFAULT_TC 7
6323 /* reg_htgt_local_path_cpu_tclass
6324 * CPU ingress traffic class for the trap group.
6327 MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
6329 enum mlxsw_reg_htgt_local_path_rdq {
6330 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
6331 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
6332 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
6333 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
6335 /* reg_htgt_local_path_rdq
6336 * Receive descriptor queue (RDQ) to use for the trap group.
6339 MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
6341 static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
6344 MLXSW_REG_ZERO(htgt, payload);
6346 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
6347 mlxsw_reg_htgt_pide_set(payload,
6348 MLXSW_REG_HTGT_POLICER_DISABLE);
6350 mlxsw_reg_htgt_pide_set(payload,
6351 MLXSW_REG_HTGT_POLICER_ENABLE);
6352 mlxsw_reg_htgt_pid_set(payload, policer_id);
6355 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
6356 mlxsw_reg_htgt_trap_group_set(payload, group);
6357 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
6358 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
6359 mlxsw_reg_htgt_priority_set(payload, priority);
6360 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
6361 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
6364 /* HPKT - Host Packet Trap
6365 * -----------------------
6366 * Configures trap IDs inside trap groups.
6368 #define MLXSW_REG_HPKT_ID 0x7003
6369 #define MLXSW_REG_HPKT_LEN 0x10
6371 MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
6374 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
6375 MLXSW_REG_HPKT_ACK_REQUIRED,
6379 * Require acknowledgements from the host for events.
6380 * If set, then the device will wait for the event it sent to be acknowledged
6381 * by the host. This option is only relevant for event trap IDs.
6384 * Note: Currently not supported by firmware.
6386 MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
6388 enum mlxsw_reg_hpkt_action {
6389 MLXSW_REG_HPKT_ACTION_FORWARD,
6390 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
6391 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
6392 MLXSW_REG_HPKT_ACTION_DISCARD,
6393 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
6394 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
6395 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
6396 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
6400 * Action to perform on packet when trapped.
6401 * 0 - No action. Forward to CPU based on switching rules.
6402 * 1 - Trap to CPU (CPU receives sole copy).
6403 * 2 - Mirror to CPU (CPU receives a replica of the packet).
6405 * 4 - Soft discard (allow other traps to act on the packet).
6406 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
6407 * 6 - Trap to CPU (CPU receives sole copy) and count it as error.
6408 * 15 - Restore the firmware's default action.
6411 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
6412 * addressed to the CPU.
6414 MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
6416 /* reg_hpkt_trap_group
6417 * Trap group to associate the trap with.
6420 MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
6426 * Note: A trap ID can only be associated with a single trap group. The device
6427 * will associate the trap ID with the last trap group configured.
6429 MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10);
6432 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
6433 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
6434 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
6438 * Configure dedicated buffer resources for control packets.
6439 * Ignored by SwitchX-2.
6440 * 0 - Keep factory defaults.
6441 * 1 - Do not use control buffer for this trap ID.
6442 * 2 - Use control buffer for this trap ID.
6445 MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
6447 static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
6448 enum mlxsw_reg_htgt_trap_group trap_group,
6451 MLXSW_REG_ZERO(hpkt, payload);
6452 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
6453 mlxsw_reg_hpkt_action_set(payload, action);
6454 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
6455 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
6456 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
6457 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
6458 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
6461 /* RGCR - Router General Configuration Register
6462 * --------------------------------------------
6463 * The register is used for setting up the router configuration.
6465 #define MLXSW_REG_RGCR_ID 0x8001
6466 #define MLXSW_REG_RGCR_LEN 0x28
6468 MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
6471 * IPv4 router enable.
6474 MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
6477 * IPv6 router enable.
6480 MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
6482 /* reg_rgcr_max_router_interfaces
6483 * Defines the maximum number of active router interfaces for all virtual
6487 MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
6490 * Update switch priority and packet color.
6491 * 0 - Preserve the value of Switch Priority and packet color.
6492 * 1 - Recalculate the value of Switch Priority and packet color.
6495 * Note: Not supported by SwitchX and SwitchX-2.
6497 MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
6500 * Indicates how to handle the pcp_rewrite_en value:
6501 * 0 - Preserve the value of pcp_rewrite_en.
6502 * 2 - Disable PCP rewrite.
6503 * 3 - Enable PCP rewrite.
6506 * Note: Not supported by SwitchX and SwitchX-2.
6508 MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
6510 /* reg_rgcr_activity_dis
6512 * 0 - Activity will be set when an entry is hit (default).
6513 * 1 - Activity will not be set when an entry is hit.
6515 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
6517 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
6519 * Bits 2:7 are reserved.
6522 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
6524 MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
6526 static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
6529 MLXSW_REG_ZERO(rgcr, payload);
6530 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
6531 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
6534 /* RITR - Router Interface Table Register
6535 * --------------------------------------
6536 * The register is used to configure the router interface table.
6538 #define MLXSW_REG_RITR_ID 0x8002
6539 #define MLXSW_REG_RITR_LEN 0x40
6541 MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
6544 * Enables routing on the router interface.
6547 MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
6550 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
6554 MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
6557 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
6561 MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
6564 * IPv4 multicast routing enable.
6567 MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
6570 * IPv6 multicast routing enable.
6573 MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
6575 enum mlxsw_reg_ritr_if_type {
6576 /* VLAN interface. */
6577 MLXSW_REG_RITR_VLAN_IF,
6578 /* FID interface. */
6579 MLXSW_REG_RITR_FID_IF,
6580 /* Sub-port interface. */
6581 MLXSW_REG_RITR_SP_IF,
6582 /* Loopback Interface. */
6583 MLXSW_REG_RITR_LOOPBACK_IF,
6587 * Router interface type as per enum mlxsw_reg_ritr_if_type.
6590 MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
6593 MLXSW_REG_RITR_RIF_CREATE,
6594 MLXSW_REG_RITR_RIF_DEL,
6599 * 0 - Create or edit RIF.
6601 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
6602 * is not supported. An interface must be deleted and re-created in order
6603 * to update properties.
6606 MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
6609 * Router interface index. A pointer to the Router Interface Table.
6612 MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
6615 * IPv4 Forwarding Enable.
6616 * Enables routing of IPv4 traffic on the router interface. When disabled,
6617 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6618 * Not supported in SwitchX-2.
6621 MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
6624 * IPv6 Forwarding Enable.
6625 * Enables routing of IPv6 traffic on the router interface. When disabled,
6626 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6627 * Not supported in SwitchX-2.
6630 MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
6632 /* reg_ritr_ipv4_mc_fe
6633 * IPv4 Multicast Forwarding Enable.
6634 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6638 MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
6640 /* reg_ritr_ipv6_mc_fe
6641 * IPv6 Multicast Forwarding Enable.
6642 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6646 MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
6649 * Loop-back filter enable for unicast packets.
6650 * If the flag is set then loop-back filter for unicast packets is
6651 * implemented on the RIF. Multicast packets are always subject to
6652 * loop-back filtering.
6655 MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
6657 /* reg_ritr_virtual_router
6658 * Virtual router ID associated with the router interface.
6661 MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
6664 * Router interface MTU.
6667 MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
6670 * Switch partition ID.
6673 MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
6675 /* reg_ritr_if_mac_profile_id
6676 * MAC msb profile ID.
6679 MLXSW_ITEM32(reg, ritr, if_mac_profile_id, 0x10, 16, 4);
6682 * Router interface MAC address.
6683 * In Spectrum, all MAC addresses must have the same 38 MSBits.
6686 MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
6688 /* reg_ritr_if_vrrp_id_ipv6
6690 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6693 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
6695 /* reg_ritr_if_vrrp_id_ipv4
6697 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6700 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
6702 /* VLAN Interface */
6704 /* reg_ritr_vlan_if_vid
6708 MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
6712 /* reg_ritr_fid_if_fid
6713 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
6714 * the vFID range are supported.
6717 MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
6719 static inline void mlxsw_reg_ritr_fid_set(char *payload,
6720 enum mlxsw_reg_ritr_if_type rif_type,
6723 if (rif_type == MLXSW_REG_RITR_FID_IF)
6724 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
6726 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
6729 /* Sub-port Interface */
6731 /* reg_ritr_sp_if_lag
6732 * LAG indication. When this bit is set the system_port field holds the
6736 MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
6738 /* reg_ritr_sp_system_port
6739 * Port unique indentifier. When lag bit is set, this field holds the
6740 * lag_id in bits 0:9.
6743 MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
6745 /* reg_ritr_sp_if_vid
6749 MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
6751 /* Loopback Interface */
6753 enum mlxsw_reg_ritr_loopback_protocol {
6754 /* IPinIP IPv4 underlay Unicast */
6755 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
6756 /* IPinIP IPv6 underlay Unicast */
6757 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
6758 /* IPinIP generic - used for Spectrum-2 underlay RIF */
6759 MLXSW_REG_RITR_LOOPBACK_GENERIC,
6762 /* reg_ritr_loopback_protocol
6765 MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
6767 enum mlxsw_reg_ritr_loopback_ipip_type {
6768 /* Tunnel is IPinIP. */
6769 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
6770 /* Tunnel is GRE, no key. */
6771 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
6772 /* Tunnel is GRE, with a key. */
6773 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
6776 /* reg_ritr_loopback_ipip_type
6777 * Encapsulation type.
6780 MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
6782 enum mlxsw_reg_ritr_loopback_ipip_options {
6783 /* The key is defined by gre_key. */
6784 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
6787 /* reg_ritr_loopback_ipip_options
6790 MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
6792 /* reg_ritr_loopback_ipip_uvr
6793 * Underlay Virtual Router ID.
6794 * Range is 0..cap_max_virtual_routers-1.
6795 * Reserved for Spectrum-2.
6798 MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
6800 /* reg_ritr_loopback_ipip_underlay_rif
6801 * Underlay ingress router interface.
6802 * Reserved for Spectrum.
6805 MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
6807 /* reg_ritr_loopback_ipip_usip*
6808 * Encapsulation Underlay source IP.
6811 MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
6812 MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
6814 /* reg_ritr_loopback_ipip_gre_key
6816 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
6819 MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
6821 /* Shared between ingress/egress */
6822 enum mlxsw_reg_ritr_counter_set_type {
6824 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
6825 /* Basic. Used for router interfaces, counting the following:
6826 * - Error and Discard counters.
6827 * - Unicast, Multicast and Broadcast counters. Sharing the
6828 * same set of counters for the different type of traffic
6829 * (IPv4, IPv6 and mpls).
6831 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
6834 /* reg_ritr_ingress_counter_index
6835 * Counter Index for flow counter.
6838 MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
6840 /* reg_ritr_ingress_counter_set_type
6841 * Igress Counter Set Type for router interface counter.
6844 MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
6846 /* reg_ritr_egress_counter_index
6847 * Counter Index for flow counter.
6850 MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
6852 /* reg_ritr_egress_counter_set_type
6853 * Egress Counter Set Type for router interface counter.
6856 MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
6858 static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
6859 bool enable, bool egress)
6861 enum mlxsw_reg_ritr_counter_set_type set_type;
6864 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
6866 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
6869 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
6870 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
6872 mlxsw_reg_ritr_ingress_counter_set_type_set(payload, set_type);
6873 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
6877 static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
6879 MLXSW_REG_ZERO(ritr, payload);
6880 mlxsw_reg_ritr_rif_set(payload, rif);
6883 static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
6884 u16 system_port, u16 vid)
6886 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
6887 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
6888 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
6891 static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
6892 enum mlxsw_reg_ritr_if_type type,
6893 u16 rif, u16 vr_id, u16 mtu)
6895 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
6897 MLXSW_REG_ZERO(ritr, payload);
6898 mlxsw_reg_ritr_enable_set(payload, enable);
6899 mlxsw_reg_ritr_ipv4_set(payload, 1);
6900 mlxsw_reg_ritr_ipv6_set(payload, 1);
6901 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
6902 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
6903 mlxsw_reg_ritr_type_set(payload, type);
6904 mlxsw_reg_ritr_op_set(payload, op);
6905 mlxsw_reg_ritr_rif_set(payload, rif);
6906 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
6907 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
6908 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
6909 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
6910 mlxsw_reg_ritr_lb_en_set(payload, 1);
6911 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
6912 mlxsw_reg_ritr_mtu_set(payload, mtu);
6915 static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
6917 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
6921 mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
6922 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6923 enum mlxsw_reg_ritr_loopback_ipip_options options,
6924 u16 uvr_id, u16 underlay_rif, u32 gre_key)
6926 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
6927 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
6928 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
6929 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
6930 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
6934 mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
6935 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6936 enum mlxsw_reg_ritr_loopback_ipip_options options,
6937 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
6939 mlxsw_reg_ritr_loopback_protocol_set(payload,
6940 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
6941 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
6942 uvr_id, underlay_rif, gre_key);
6943 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
6947 mlxsw_reg_ritr_loopback_ipip6_pack(char *payload,
6948 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6949 enum mlxsw_reg_ritr_loopback_ipip_options options,
6950 u16 uvr_id, u16 underlay_rif,
6951 const struct in6_addr *usip, u32 gre_key)
6953 enum mlxsw_reg_ritr_loopback_protocol protocol =
6954 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6;
6956 mlxsw_reg_ritr_loopback_protocol_set(payload, protocol);
6957 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
6958 uvr_id, underlay_rif, gre_key);
6959 mlxsw_reg_ritr_loopback_ipip_usip6_memcpy_to(payload,
6960 (const char *)usip);
6963 /* RTAR - Router TCAM Allocation Register
6964 * --------------------------------------
6965 * This register is used for allocation of regions in the TCAM table.
6967 #define MLXSW_REG_RTAR_ID 0x8004
6968 #define MLXSW_REG_RTAR_LEN 0x20
6970 MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
6972 enum mlxsw_reg_rtar_op {
6973 MLXSW_REG_RTAR_OP_ALLOCATE,
6974 MLXSW_REG_RTAR_OP_RESIZE,
6975 MLXSW_REG_RTAR_OP_DEALLOCATE,
6981 MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
6983 enum mlxsw_reg_rtar_key_type {
6984 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
6985 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
6988 /* reg_rtar_key_type
6989 * TCAM key type for the region.
6992 MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
6994 /* reg_rtar_region_size
6995 * TCAM region size. When allocating/resizing this is the requested
6996 * size, the response is the actual size.
6997 * Note: Actual size may be larger than requested.
6998 * Reserved for op = Deallocate
7001 MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
7003 static inline void mlxsw_reg_rtar_pack(char *payload,
7004 enum mlxsw_reg_rtar_op op,
7005 enum mlxsw_reg_rtar_key_type key_type,
7008 MLXSW_REG_ZERO(rtar, payload);
7009 mlxsw_reg_rtar_op_set(payload, op);
7010 mlxsw_reg_rtar_key_type_set(payload, key_type);
7011 mlxsw_reg_rtar_region_size_set(payload, region_size);
7014 /* RATR - Router Adjacency Table Register
7015 * --------------------------------------
7016 * The RATR register is used to configure the Router Adjacency (next-hop)
7019 #define MLXSW_REG_RATR_ID 0x8008
7020 #define MLXSW_REG_RATR_LEN 0x2C
7022 MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
7024 enum mlxsw_reg_ratr_op {
7026 MLXSW_REG_RATR_OP_QUERY_READ = 0,
7027 /* Read and clear activity */
7028 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
7029 /* Write Adjacency entry */
7030 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
7031 /* Write Adjacency entry only if the activity is cleared.
7032 * The write may not succeed if the activity is set. There is not
7033 * direct feedback if the write has succeeded or not, however
7034 * the get will reveal the actual entry (SW can compare the get
7035 * response to the set command).
7037 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
7041 * Note that Write operation may also be used for updating
7042 * counter_set_type and counter_index. In this case all other
7043 * fields must not be updated.
7046 MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
7049 * Valid bit. Indicates if the adjacency entry is valid.
7050 * Note: the device may need some time before reusing an invalidated
7051 * entry. During this time the entry can not be reused. It is
7052 * recommended to use another entry before reusing an invalidated
7053 * entry (e.g. software can put it at the end of the list for
7054 * reusing). Trying to access an invalidated entry not yet cleared
7055 * by the device results with failure indicating "Try Again" status.
7056 * When valid is '0' then egress_router_interface,trap_action,
7057 * adjacency_parameters and counters are reserved
7060 MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
7063 * Activity. Set for new entries. Set if a packet lookup has hit on
7064 * the specific entry. To clear the a bit, use "clear activity".
7067 MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
7069 enum mlxsw_reg_ratr_type {
7071 MLXSW_REG_RATR_TYPE_ETHERNET,
7072 /* IPoIB Unicast without GRH.
7073 * Reserved for Spectrum.
7075 MLXSW_REG_RATR_TYPE_IPOIB_UC,
7076 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
7078 * Reserved for Spectrum.
7080 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
7082 * Reserved for Spectrum.
7084 MLXSW_REG_RATR_TYPE_IPOIB_MC,
7086 * Reserved for SwitchX/-2.
7088 MLXSW_REG_RATR_TYPE_MPLS,
7090 * Reserved for SwitchX/-2.
7092 MLXSW_REG_RATR_TYPE_IPIP,
7096 * Adjacency entry type.
7099 MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
7101 /* reg_ratr_adjacency_index_low
7102 * Bits 15:0 of index into the adjacency table.
7103 * For SwitchX and SwitchX-2, the adjacency table is linear and
7104 * used for adjacency entries only.
7105 * For Spectrum, the index is to the KVD linear.
7108 MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
7110 /* reg_ratr_egress_router_interface
7111 * Range is 0 .. cap_max_router_interfaces - 1
7114 MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
7116 enum mlxsw_reg_ratr_trap_action {
7117 MLXSW_REG_RATR_TRAP_ACTION_NOP,
7118 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
7119 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
7120 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
7121 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
7124 /* reg_ratr_trap_action
7125 * see mlxsw_reg_ratr_trap_action
7128 MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
7130 /* reg_ratr_adjacency_index_high
7131 * Bits 23:16 of the adjacency_index.
7134 MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
7136 enum mlxsw_reg_ratr_trap_id {
7137 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
7138 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
7142 * Trap ID to be reported to CPU.
7143 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
7144 * For trap_action of NOP, MIRROR and DISCARD_ERROR
7147 MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
7149 /* reg_ratr_eth_destination_mac
7150 * MAC address of the destination next-hop.
7153 MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
7155 enum mlxsw_reg_ratr_ipip_type {
7156 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
7157 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
7158 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
7159 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
7162 /* reg_ratr_ipip_type
7163 * Underlay destination ip type.
7164 * Note: the type field must match the protocol of the router interface.
7167 MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
7169 /* reg_ratr_ipip_ipv4_udip
7170 * Underlay ipv4 dip.
7171 * Reserved when ipip_type is IPv6.
7174 MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
7176 /* reg_ratr_ipip_ipv6_ptr
7177 * Pointer to IPv6 underlay destination ip address.
7178 * For Spectrum: Pointer to KVD linear space.
7181 MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
7183 enum mlxsw_reg_flow_counter_set_type {
7185 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
7186 /* Count packets and bytes */
7187 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
7188 /* Count only packets */
7189 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
7192 /* reg_ratr_counter_set_type
7193 * Counter set type for flow counters
7196 MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
7198 /* reg_ratr_counter_index
7199 * Counter index for flow counters
7202 MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
7205 mlxsw_reg_ratr_pack(char *payload,
7206 enum mlxsw_reg_ratr_op op, bool valid,
7207 enum mlxsw_reg_ratr_type type,
7208 u32 adjacency_index, u16 egress_rif)
7210 MLXSW_REG_ZERO(ratr, payload);
7211 mlxsw_reg_ratr_op_set(payload, op);
7212 mlxsw_reg_ratr_v_set(payload, valid);
7213 mlxsw_reg_ratr_type_set(payload, type);
7214 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
7215 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
7216 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
7219 static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
7220 const char *dest_mac)
7222 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
7225 static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
7227 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
7228 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
7231 static inline void mlxsw_reg_ratr_ipip6_entry_pack(char *payload, u32 ipv6_ptr)
7233 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV6);
7234 mlxsw_reg_ratr_ipip_ipv6_ptr_set(payload, ipv6_ptr);
7237 static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
7238 bool counter_enable)
7240 enum mlxsw_reg_flow_counter_set_type set_type;
7243 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
7245 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
7247 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
7248 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
7251 /* RDPM - Router DSCP to Priority Mapping
7252 * --------------------------------------
7253 * Controls the mapping from DSCP field to switch priority on routed packets
7255 #define MLXSW_REG_RDPM_ID 0x8009
7256 #define MLXSW_REG_RDPM_BASE_LEN 0x00
7257 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
7258 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
7259 #define MLXSW_REG_RDPM_LEN 0x40
7260 #define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
7261 MLXSW_REG_RDPM_LEN - \
7262 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
7264 MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
7267 * Enable update of the specific entry
7270 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
7271 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
7273 /* reg_dscp_entry_prio
7277 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
7278 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
7280 static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
7283 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
7284 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
7287 /* RICNT - Router Interface Counter Register
7288 * -----------------------------------------
7289 * The RICNT register retrieves per port performance counters
7291 #define MLXSW_REG_RICNT_ID 0x800B
7292 #define MLXSW_REG_RICNT_LEN 0x100
7294 MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
7296 /* reg_ricnt_counter_index
7300 MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
7302 enum mlxsw_reg_ricnt_counter_set_type {
7304 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
7305 /* Basic. Used for router interfaces, counting the following:
7306 * - Error and Discard counters.
7307 * - Unicast, Multicast and Broadcast counters. Sharing the
7308 * same set of counters for the different type of traffic
7309 * (IPv4, IPv6 and mpls).
7311 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
7314 /* reg_ricnt_counter_set_type
7315 * Counter Set Type for router interface counter
7318 MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
7320 enum mlxsw_reg_ricnt_opcode {
7321 /* Nop. Supported only for read access*/
7322 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
7323 /* Clear. Setting the clr bit will reset the counter value for
7324 * all counters of the specified Router Interface.
7326 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
7333 MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
7335 /* reg_ricnt_good_unicast_packets
7336 * good unicast packets.
7339 MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
7341 /* reg_ricnt_good_multicast_packets
7342 * good multicast packets.
7345 MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
7347 /* reg_ricnt_good_broadcast_packets
7348 * good broadcast packets
7351 MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
7353 /* reg_ricnt_good_unicast_bytes
7354 * A count of L3 data and padding octets not including L2 headers
7355 * for good unicast frames.
7358 MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
7360 /* reg_ricnt_good_multicast_bytes
7361 * A count of L3 data and padding octets not including L2 headers
7362 * for good multicast frames.
7365 MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
7367 /* reg_ritr_good_broadcast_bytes
7368 * A count of L3 data and padding octets not including L2 headers
7369 * for good broadcast frames.
7372 MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
7374 /* reg_ricnt_error_packets
7375 * A count of errored frames that do not pass the router checks.
7378 MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
7380 /* reg_ricnt_discrad_packets
7381 * A count of non-errored frames that do not pass the router checks.
7384 MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
7386 /* reg_ricnt_error_bytes
7387 * A count of L3 data and padding octets not including L2 headers
7388 * for errored frames.
7391 MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
7393 /* reg_ricnt_discard_bytes
7394 * A count of L3 data and padding octets not including L2 headers
7395 * for non-errored frames that do not pass the router checks.
7398 MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
7400 static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
7401 enum mlxsw_reg_ricnt_opcode op)
7403 MLXSW_REG_ZERO(ricnt, payload);
7404 mlxsw_reg_ricnt_op_set(payload, op);
7405 mlxsw_reg_ricnt_counter_index_set(payload, index);
7406 mlxsw_reg_ricnt_counter_set_type_set(payload,
7407 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
7410 /* RRCR - Router Rules Copy Register Layout
7411 * ----------------------------------------
7412 * This register is used for moving and copying route entry rules.
7414 #define MLXSW_REG_RRCR_ID 0x800F
7415 #define MLXSW_REG_RRCR_LEN 0x24
7417 MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
7419 enum mlxsw_reg_rrcr_op {
7421 MLXSW_REG_RRCR_OP_MOVE,
7423 MLXSW_REG_RRCR_OP_COPY,
7429 MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
7432 * Offset within the region from which to copy/move.
7435 MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
7438 * The number of rules to copy/move.
7441 MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
7443 /* reg_rrcr_table_id
7444 * Identifier of the table on which to perform the operation. Encoding is the
7445 * same as in RTAR.key_type
7448 MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
7450 /* reg_rrcr_dest_offset
7451 * Offset within the region to which to copy/move
7454 MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
7456 static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
7457 u16 offset, u16 size,
7458 enum mlxsw_reg_rtar_key_type table_id,
7461 MLXSW_REG_ZERO(rrcr, payload);
7462 mlxsw_reg_rrcr_op_set(payload, op);
7463 mlxsw_reg_rrcr_offset_set(payload, offset);
7464 mlxsw_reg_rrcr_size_set(payload, size);
7465 mlxsw_reg_rrcr_table_id_set(payload, table_id);
7466 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
7469 /* RALTA - Router Algorithmic LPM Tree Allocation Register
7470 * -------------------------------------------------------
7471 * RALTA is used to allocate the LPM trees of the SHSPM method.
7473 #define MLXSW_REG_RALTA_ID 0x8010
7474 #define MLXSW_REG_RALTA_LEN 0x04
7476 MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
7479 * opcode (valid for Write, must be 0 on Read)
7480 * 0 - allocate a tree
7481 * 1 - deallocate a tree
7484 MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
7486 enum mlxsw_reg_ralxx_protocol {
7487 MLXSW_REG_RALXX_PROTOCOL_IPV4,
7488 MLXSW_REG_RALXX_PROTOCOL_IPV6,
7491 /* reg_ralta_protocol
7493 * Deallocation opcode: Reserved.
7496 MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
7498 /* reg_ralta_tree_id
7499 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
7500 * the tree identifier (managed by software).
7501 * Note that tree_id 0 is allocated for a default-route tree.
7504 MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
7506 static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
7507 enum mlxsw_reg_ralxx_protocol protocol,
7510 MLXSW_REG_ZERO(ralta, payload);
7511 mlxsw_reg_ralta_op_set(payload, !alloc);
7512 mlxsw_reg_ralta_protocol_set(payload, protocol);
7513 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
7516 /* RALST - Router Algorithmic LPM Structure Tree Register
7517 * ------------------------------------------------------
7518 * RALST is used to set and query the structure of an LPM tree.
7519 * The structure of the tree must be sorted as a sorted binary tree, while
7520 * each node is a bin that is tagged as the length of the prefixes the lookup
7521 * will refer to. Therefore, bin X refers to a set of entries with prefixes
7522 * of X bits to match with the destination address. The bin 0 indicates
7523 * the default action, when there is no match of any prefix.
7525 #define MLXSW_REG_RALST_ID 0x8011
7526 #define MLXSW_REG_RALST_LEN 0x104
7528 MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
7530 /* reg_ralst_root_bin
7531 * The bin number of the root bin.
7532 * 0<root_bin=<(length of IP address)
7533 * For a default-route tree configure 0xff
7536 MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
7538 /* reg_ralst_tree_id
7539 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
7542 MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
7544 #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
7545 #define MLXSW_REG_RALST_BIN_OFFSET 0x04
7546 #define MLXSW_REG_RALST_BIN_COUNT 128
7548 /* reg_ralst_left_child_bin
7549 * Holding the children of the bin according to the stored tree's structure.
7550 * For trees composed of less than 4 blocks, the bins in excess are reserved.
7551 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
7554 MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
7556 /* reg_ralst_right_child_bin
7557 * Holding the children of the bin according to the stored tree's structure.
7558 * For trees composed of less than 4 blocks, the bins in excess are reserved.
7559 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
7562 MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
7565 static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
7567 MLXSW_REG_ZERO(ralst, payload);
7569 /* Initialize all bins to have no left or right child */
7570 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
7571 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
7573 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
7574 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
7577 static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
7581 int bin_index = bin_number - 1;
7583 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
7584 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
7588 /* RALTB - Router Algorithmic LPM Tree Binding Register
7589 * ----------------------------------------------------
7590 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
7592 #define MLXSW_REG_RALTB_ID 0x8012
7593 #define MLXSW_REG_RALTB_LEN 0x04
7595 MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
7597 /* reg_raltb_virtual_router
7599 * Range is 0..cap_max_virtual_routers-1
7602 MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
7604 /* reg_raltb_protocol
7608 MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
7610 /* reg_raltb_tree_id
7611 * Tree to be used for the {virtual_router, protocol}
7612 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
7613 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
7616 MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
7618 static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
7619 enum mlxsw_reg_ralxx_protocol protocol,
7622 MLXSW_REG_ZERO(raltb, payload);
7623 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
7624 mlxsw_reg_raltb_protocol_set(payload, protocol);
7625 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
7628 /* RALUE - Router Algorithmic LPM Unicast Entry Register
7629 * -----------------------------------------------------
7630 * RALUE is used to configure and query LPM entries that serve
7631 * the Unicast protocols.
7633 #define MLXSW_REG_RALUE_ID 0x8013
7634 #define MLXSW_REG_RALUE_LEN 0x38
7636 MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
7638 /* reg_ralue_protocol
7642 MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
7644 enum mlxsw_reg_ralue_op {
7645 /* Read operation. If entry doesn't exist, the operation fails. */
7646 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
7647 /* Clear on read operation. Used to read entry and
7648 * clear Activity bit.
7650 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
7651 /* Write operation. Used to write a new entry to the table. All RW
7652 * fields are written for new entry. Activity bit is set
7655 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
7656 /* Update operation. Used to update an existing route entry and
7657 * only update the RW fields that are detailed in the field
7658 * op_u_mask. If entry doesn't exist, the operation fails.
7660 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
7661 /* Clear activity. The Activity bit (the field a) is cleared
7664 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
7665 /* Delete operation. Used to delete an existing entry. If entry
7666 * doesn't exist, the operation fails.
7668 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
7675 MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
7678 * Activity. Set for new entries. Set if a packet lookup has hit on the
7679 * specific entry, only if the entry is a route. To clear the a bit, use
7680 * "clear activity" op.
7681 * Enabled by activity_dis in RGCR
7684 MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
7686 /* reg_ralue_virtual_router
7688 * Range is 0..cap_max_virtual_routers-1
7691 MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
7693 #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
7694 #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
7695 #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
7697 /* reg_ralue_op_u_mask
7698 * opcode update mask.
7699 * On read operation, this field is reserved.
7700 * This field is valid for update opcode, otherwise - reserved.
7701 * This field is a bitmask of the fields that should be updated.
7704 MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
7706 /* reg_ralue_prefix_len
7707 * Number of bits in the prefix of the LPM route.
7708 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
7709 * two entries in the physical HW table.
7712 MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
7715 * The prefix of the route or of the marker that the object of the LPM
7716 * is compared with. The most significant bits of the dip are the prefix.
7717 * The least significant bits must be '0' if the prefix_len is smaller
7718 * than 128 for IPv6 or smaller than 32 for IPv4.
7719 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
7722 MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
7723 MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
7725 enum mlxsw_reg_ralue_entry_type {
7726 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
7727 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
7728 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
7731 /* reg_ralue_entry_type
7733 * Note - for Marker entries, the action_type and action fields are reserved.
7736 MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
7738 /* reg_ralue_bmp_len
7739 * The best match prefix length in the case that there is no match for
7741 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
7742 * Note for any update operation with entry_type modification this
7743 * field must be set.
7746 MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
7748 enum mlxsw_reg_ralue_action_type {
7749 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
7750 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
7751 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
7754 /* reg_ralue_action_type
7756 * Indicates how the IP address is connected.
7757 * It can be connected to a local subnet through local_erif or can be
7758 * on a remote subnet connected through a next-hop router,
7759 * or transmitted to the CPU.
7760 * Reserved when entry_type = MARKER_ENTRY
7763 MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
7765 enum mlxsw_reg_ralue_trap_action {
7766 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
7767 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
7768 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
7769 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
7770 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
7773 /* reg_ralue_trap_action
7775 * For IP2ME action, only NOP and MIRROR are possible.
7778 MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
7780 /* reg_ralue_trap_id
7781 * Trap ID to be reported to CPU.
7782 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
7783 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
7786 MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
7788 /* reg_ralue_adjacency_index
7789 * Points to the first entry of the group-based ECMP.
7790 * Only relevant in case of REMOTE action.
7793 MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
7795 /* reg_ralue_ecmp_size
7796 * Amount of sequential entries starting
7797 * from the adjacency_index (the number of ECMPs).
7798 * The valid range is 1-64, 512, 1024, 2048 and 4096.
7799 * Reserved when trap_action is TRAP or DISCARD_ERROR.
7800 * Only relevant in case of REMOTE action.
7803 MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
7805 /* reg_ralue_local_erif
7806 * Egress Router Interface.
7807 * Only relevant in case of LOCAL action.
7810 MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
7812 /* reg_ralue_ip2me_v
7813 * Valid bit for the tunnel_ptr field.
7814 * If valid = 0 then trap to CPU as IP2ME trap ID.
7815 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
7816 * decapsulation then tunnel decapsulation is done.
7817 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
7818 * decapsulation then trap as IP2ME trap ID.
7819 * Only relevant in case of IP2ME action.
7822 MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
7824 /* reg_ralue_ip2me_tunnel_ptr
7825 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
7826 * For Spectrum, pointer to KVD Linear.
7827 * Only relevant in case of IP2ME action.
7830 MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
7832 static inline void mlxsw_reg_ralue_pack(char *payload,
7833 enum mlxsw_reg_ralxx_protocol protocol,
7834 enum mlxsw_reg_ralue_op op,
7835 u16 virtual_router, u8 prefix_len)
7837 MLXSW_REG_ZERO(ralue, payload);
7838 mlxsw_reg_ralue_protocol_set(payload, protocol);
7839 mlxsw_reg_ralue_op_set(payload, op);
7840 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
7841 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
7842 mlxsw_reg_ralue_entry_type_set(payload,
7843 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
7844 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
7847 static inline void mlxsw_reg_ralue_pack4(char *payload,
7848 enum mlxsw_reg_ralxx_protocol protocol,
7849 enum mlxsw_reg_ralue_op op,
7850 u16 virtual_router, u8 prefix_len,
7853 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7855 mlxsw_reg_ralue_dip4_set(payload, *dip);
7858 static inline void mlxsw_reg_ralue_pack6(char *payload,
7859 enum mlxsw_reg_ralxx_protocol protocol,
7860 enum mlxsw_reg_ralue_op op,
7861 u16 virtual_router, u8 prefix_len,
7864 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7866 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
7870 mlxsw_reg_ralue_act_remote_pack(char *payload,
7871 enum mlxsw_reg_ralue_trap_action trap_action,
7872 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
7874 mlxsw_reg_ralue_action_type_set(payload,
7875 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
7876 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7877 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7878 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
7879 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
7883 mlxsw_reg_ralue_act_local_pack(char *payload,
7884 enum mlxsw_reg_ralue_trap_action trap_action,
7885 u16 trap_id, u16 local_erif)
7887 mlxsw_reg_ralue_action_type_set(payload,
7888 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
7889 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7890 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7891 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
7895 mlxsw_reg_ralue_act_ip2me_pack(char *payload)
7897 mlxsw_reg_ralue_action_type_set(payload,
7898 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7902 mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
7904 mlxsw_reg_ralue_action_type_set(payload,
7905 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7906 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
7907 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
7910 /* RAUHT - Router Algorithmic LPM Unicast Host Table Register
7911 * ----------------------------------------------------------
7912 * The RAUHT register is used to configure and query the Unicast Host table in
7913 * devices that implement the Algorithmic LPM.
7915 #define MLXSW_REG_RAUHT_ID 0x8014
7916 #define MLXSW_REG_RAUHT_LEN 0x74
7918 MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
7920 enum mlxsw_reg_rauht_type {
7921 MLXSW_REG_RAUHT_TYPE_IPV4,
7922 MLXSW_REG_RAUHT_TYPE_IPV6,
7928 MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
7930 enum mlxsw_reg_rauht_op {
7931 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
7932 /* Read operation */
7933 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
7934 /* Clear on read operation. Used to read entry and clear
7937 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
7938 /* Add. Used to write a new entry to the table. All R/W fields are
7939 * relevant for new entry. Activity bit is set for new entries.
7941 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
7942 /* Update action. Used to update an existing route entry and
7943 * only update the following fields:
7944 * trap_action, trap_id, mac, counter_set_type, counter_index
7946 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
7947 /* Clear activity. A bit is cleared for the entry. */
7948 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
7950 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
7951 /* Delete all host entries on a RIF. In this command, dip
7952 * field is reserved.
7959 MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
7962 * Activity. Set for new entries. Set if a packet lookup has hit on
7963 * the specific entry.
7964 * To clear the a bit, use "clear activity" op.
7965 * Enabled by activity_dis in RGCR
7968 MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
7974 MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
7977 * Destination address.
7980 MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
7981 MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
7983 enum mlxsw_reg_rauht_trap_action {
7984 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
7985 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
7986 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
7987 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
7988 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
7991 /* reg_rauht_trap_action
7994 MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
7996 enum mlxsw_reg_rauht_trap_id {
7997 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
7998 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
8001 /* reg_rauht_trap_id
8002 * Trap ID to be reported to CPU.
8003 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
8004 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
8005 * trap_id is reserved.
8008 MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
8010 /* reg_rauht_counter_set_type
8011 * Counter set type for flow counters
8014 MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
8016 /* reg_rauht_counter_index
8017 * Counter index for flow counters
8020 MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
8026 MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
8028 static inline void mlxsw_reg_rauht_pack(char *payload,
8029 enum mlxsw_reg_rauht_op op, u16 rif,
8032 MLXSW_REG_ZERO(rauht, payload);
8033 mlxsw_reg_rauht_op_set(payload, op);
8034 mlxsw_reg_rauht_rif_set(payload, rif);
8035 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
8038 static inline void mlxsw_reg_rauht_pack4(char *payload,
8039 enum mlxsw_reg_rauht_op op, u16 rif,
8040 const char *mac, u32 dip)
8042 mlxsw_reg_rauht_pack(payload, op, rif, mac);
8043 mlxsw_reg_rauht_dip4_set(payload, dip);
8046 static inline void mlxsw_reg_rauht_pack6(char *payload,
8047 enum mlxsw_reg_rauht_op op, u16 rif,
8048 const char *mac, const char *dip)
8050 mlxsw_reg_rauht_pack(payload, op, rif, mac);
8051 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
8052 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
8055 static inline void mlxsw_reg_rauht_pack_counter(char *payload,
8058 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
8059 mlxsw_reg_rauht_counter_set_type_set(payload,
8060 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
8063 /* RALEU - Router Algorithmic LPM ECMP Update Register
8064 * ---------------------------------------------------
8065 * The register enables updating the ECMP section in the action for multiple
8066 * LPM Unicast entries in a single operation. The update is executed to
8067 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
8069 #define MLXSW_REG_RALEU_ID 0x8015
8070 #define MLXSW_REG_RALEU_LEN 0x28
8072 MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
8074 /* reg_raleu_protocol
8078 MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
8080 /* reg_raleu_virtual_router
8082 * Range is 0..cap_max_virtual_routers-1
8085 MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
8087 /* reg_raleu_adjacency_index
8088 * Adjacency Index used for matching on the existing entries.
8091 MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
8093 /* reg_raleu_ecmp_size
8094 * ECMP Size used for matching on the existing entries.
8097 MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
8099 /* reg_raleu_new_adjacency_index
8100 * New Adjacency Index.
8103 MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
8105 /* reg_raleu_new_ecmp_size
8109 MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
8111 static inline void mlxsw_reg_raleu_pack(char *payload,
8112 enum mlxsw_reg_ralxx_protocol protocol,
8114 u32 adjacency_index, u16 ecmp_size,
8115 u32 new_adjacency_index,
8118 MLXSW_REG_ZERO(raleu, payload);
8119 mlxsw_reg_raleu_protocol_set(payload, protocol);
8120 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
8121 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
8122 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
8123 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
8124 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
8127 /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
8128 * ----------------------------------------------------------------
8129 * The RAUHTD register allows dumping entries from the Router Unicast Host
8130 * Table. For a given session an entry is dumped no more than one time. The
8131 * first RAUHTD access after reset is a new session. A session ends when the
8132 * num_rec response is smaller than num_rec request or for IPv4 when the
8133 * num_entries is smaller than 4. The clear activity affect the current session
8134 * or the last session if a new session has not started.
8136 #define MLXSW_REG_RAUHTD_ID 0x8018
8137 #define MLXSW_REG_RAUHTD_BASE_LEN 0x20
8138 #define MLXSW_REG_RAUHTD_REC_LEN 0x20
8139 #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
8140 #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
8141 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
8142 #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
8144 MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
8146 #define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
8147 #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
8149 /* reg_rauhtd_filter_fields
8150 * if a bit is '0' then the relevant field is ignored and dump is done
8151 * regardless of the field value
8152 * Bit0 - filter by activity: entry_a
8153 * Bit3 - filter by entry rip: entry_rif
8156 MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
8158 enum mlxsw_reg_rauhtd_op {
8159 MLXSW_REG_RAUHTD_OP_DUMP,
8160 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
8166 MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
8168 /* reg_rauhtd_num_rec
8169 * At request: number of records requested
8170 * At response: number of records dumped
8171 * For IPv4, each record has 4 entries at request and up to 4 entries
8173 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
8176 MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
8178 /* reg_rauhtd_entry_a
8179 * Dump only if activity has value of entry_a
8180 * Reserved if filter_fields bit0 is '0'
8183 MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
8185 enum mlxsw_reg_rauhtd_type {
8186 MLXSW_REG_RAUHTD_TYPE_IPV4,
8187 MLXSW_REG_RAUHTD_TYPE_IPV6,
8191 * Dump only if record type is:
8196 MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
8198 /* reg_rauhtd_entry_rif
8199 * Dump only if RIF has value of entry_rif
8200 * Reserved if filter_fields bit3 is '0'
8203 MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
8205 static inline void mlxsw_reg_rauhtd_pack(char *payload,
8206 enum mlxsw_reg_rauhtd_type type)
8208 MLXSW_REG_ZERO(rauhtd, payload);
8209 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
8210 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
8211 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
8212 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
8213 mlxsw_reg_rauhtd_type_set(payload, type);
8216 /* reg_rauhtd_ipv4_rec_num_entries
8217 * Number of valid entries in this record:
8219 * 1 - 2 valid entries
8220 * 2 - 3 valid entries
8221 * 3 - 4 valid entries
8224 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
8225 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
8226 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
8228 /* reg_rauhtd_rec_type
8234 MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
8235 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
8237 #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
8239 /* reg_rauhtd_ipv4_ent_a
8240 * Activity. Set for new entries. Set if a packet lookup has hit on the
8244 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
8245 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
8247 /* reg_rauhtd_ipv4_ent_rif
8251 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8252 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
8254 /* reg_rauhtd_ipv4_ent_dip
8255 * Destination IPv4 address.
8258 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8259 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
8261 #define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
8263 /* reg_rauhtd_ipv6_ent_a
8264 * Activity. Set for new entries. Set if a packet lookup has hit on the
8268 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
8269 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
8271 /* reg_rauhtd_ipv6_ent_rif
8275 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8276 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
8278 /* reg_rauhtd_ipv6_ent_dip
8279 * Destination IPv6 address.
8282 MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
8283 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
8285 static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
8286 int ent_index, u16 *p_rif,
8289 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
8290 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
8293 static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
8294 int rec_index, u16 *p_rif,
8297 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
8298 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
8301 /* RTDP - Routing Tunnel Decap Properties Register
8302 * -----------------------------------------------
8303 * The RTDP register is used for configuring the tunnel decap properties of NVE
8306 #define MLXSW_REG_RTDP_ID 0x8020
8307 #define MLXSW_REG_RTDP_LEN 0x44
8309 MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
8311 enum mlxsw_reg_rtdp_type {
8312 MLXSW_REG_RTDP_TYPE_NVE,
8313 MLXSW_REG_RTDP_TYPE_IPIP,
8317 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
8320 MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
8322 /* reg_rtdp_tunnel_index
8323 * Index to the Decap entry.
8324 * For Spectrum, Index to KVD Linear.
8327 MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
8329 /* reg_rtdp_egress_router_interface
8330 * Underlay egress router interface.
8331 * Valid range is from 0 to cap_max_router_interfaces - 1
8334 MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
8338 /* reg_rtdp_ipip_irif
8339 * Ingress Router Interface for the overlay router
8342 MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
8344 enum mlxsw_reg_rtdp_ipip_sip_check {
8345 /* No sip checks. */
8346 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
8347 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
8350 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
8351 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
8354 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
8357 /* reg_rtdp_ipip_sip_check
8358 * SIP check to perform. If decapsulation failed due to these configurations
8359 * then trap_id is IPIP_DECAP_ERROR.
8362 MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
8364 /* If set, allow decapsulation of IPinIP (without GRE). */
8365 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
8366 /* If set, allow decapsulation of IPinGREinIP without a key. */
8367 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
8368 /* If set, allow decapsulation of IPinGREinIP with a key. */
8369 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
8371 /* reg_rtdp_ipip_type_check
8372 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
8373 * these configurations then trap_id is IPIP_DECAP_ERROR.
8376 MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
8378 /* reg_rtdp_ipip_gre_key_check
8379 * Whether GRE key should be checked. When check is enabled:
8380 * - A packet received as IPinIP (without GRE) will always pass.
8381 * - A packet received as IPinGREinIP without a key will not pass the check.
8382 * - A packet received as IPinGREinIP with a key will pass the check only if the
8383 * key in the packet is equal to expected_gre_key.
8384 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
8387 MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
8389 /* reg_rtdp_ipip_ipv4_usip
8390 * Underlay IPv4 address for ipv4 source address check.
8391 * Reserved when sip_check is not '1'.
8394 MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
8396 /* reg_rtdp_ipip_ipv6_usip_ptr
8397 * This field is valid when sip_check is "sipv6 check explicitly". This is a
8398 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
8399 * is to the KVD linear.
8400 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
8403 MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
8405 /* reg_rtdp_ipip_expected_gre_key
8406 * GRE key for checking.
8407 * Reserved when gre_key_check is '0'.
8410 MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
8412 static inline void mlxsw_reg_rtdp_pack(char *payload,
8413 enum mlxsw_reg_rtdp_type type,
8416 MLXSW_REG_ZERO(rtdp, payload);
8417 mlxsw_reg_rtdp_type_set(payload, type);
8418 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
8422 mlxsw_reg_rtdp_ipip_pack(char *payload, u16 irif,
8423 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8424 unsigned int type_check, bool gre_key_check,
8425 u32 expected_gre_key)
8427 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
8428 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
8429 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
8430 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
8431 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
8435 mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
8436 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8437 unsigned int type_check, bool gre_key_check,
8438 u32 ipv4_usip, u32 expected_gre_key)
8440 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
8441 gre_key_check, expected_gre_key);
8442 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
8446 mlxsw_reg_rtdp_ipip6_pack(char *payload, u16 irif,
8447 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8448 unsigned int type_check, bool gre_key_check,
8449 u32 ipv6_usip_ptr, u32 expected_gre_key)
8451 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
8452 gre_key_check, expected_gre_key);
8453 mlxsw_reg_rtdp_ipip_ipv6_usip_ptr_set(payload, ipv6_usip_ptr);
8456 /* RIPS - Router IP version Six Register
8457 * -------------------------------------
8458 * The RIPS register is used to store IPv6 addresses for use by the NVE and
8461 #define MLXSW_REG_RIPS_ID 0x8021
8462 #define MLXSW_REG_RIPS_LEN 0x14
8464 MLXSW_REG_DEFINE(rips, MLXSW_REG_RIPS_ID, MLXSW_REG_RIPS_LEN);
8467 * Index to IPv6 address.
8468 * For Spectrum, the index is to the KVD linear.
8471 MLXSW_ITEM32(reg, rips, index, 0x00, 0, 24);
8477 MLXSW_ITEM_BUF(reg, rips, ipv6, 0x04, 16);
8479 static inline void mlxsw_reg_rips_pack(char *payload, u32 index,
8480 const struct in6_addr *ipv6)
8482 MLXSW_REG_ZERO(rips, payload);
8483 mlxsw_reg_rips_index_set(payload, index);
8484 mlxsw_reg_rips_ipv6_memcpy_to(payload, (const char *)ipv6);
8487 /* RATRAD - Router Adjacency Table Activity Dump Register
8488 * ------------------------------------------------------
8489 * The RATRAD register is used to dump and optionally clear activity bits of
8490 * router adjacency table entries.
8492 #define MLXSW_REG_RATRAD_ID 0x8022
8493 #define MLXSW_REG_RATRAD_LEN 0x210
8495 MLXSW_REG_DEFINE(ratrad, MLXSW_REG_RATRAD_ID, MLXSW_REG_RATRAD_LEN);
8499 MLXSW_REG_RATRAD_OP_READ_ACTIVITY,
8500 /* Read and clear activity */
8501 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY,
8507 MLXSW_ITEM32(reg, ratrad, op, 0x00, 30, 2);
8509 /* reg_ratrad_ecmp_size
8510 * ecmp_size is the amount of sequential entries from adjacency_index. Valid
8512 * Spectrum-1: 32-64, 512, 1024, 2048, 4096
8513 * Spectrum-2/3: 32-128, 256, 512, 1024, 2048, 4096
8516 MLXSW_ITEM32(reg, ratrad, ecmp_size, 0x00, 0, 13);
8518 /* reg_ratrad_adjacency_index
8519 * Index into the adjacency table.
8522 MLXSW_ITEM32(reg, ratrad, adjacency_index, 0x04, 0, 24);
8524 /* reg_ratrad_activity_vector
8525 * Activity bit per adjacency index.
8526 * Bits higher than ecmp_size are reserved.
8529 MLXSW_ITEM_BIT_ARRAY(reg, ratrad, activity_vector, 0x10, 0x200, 1);
8531 static inline void mlxsw_reg_ratrad_pack(char *payload, u32 adjacency_index,
8534 MLXSW_REG_ZERO(ratrad, payload);
8535 mlxsw_reg_ratrad_op_set(payload,
8536 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY);
8537 mlxsw_reg_ratrad_ecmp_size_set(payload, ecmp_size);
8538 mlxsw_reg_ratrad_adjacency_index_set(payload, adjacency_index);
8541 /* RIGR-V2 - Router Interface Group Register Version 2
8542 * ---------------------------------------------------
8543 * The RIGR_V2 register is used to add, remove and query egress interface list
8544 * of a multicast forwarding entry.
8546 #define MLXSW_REG_RIGR2_ID 0x8023
8547 #define MLXSW_REG_RIGR2_LEN 0xB0
8549 #define MLXSW_REG_RIGR2_MAX_ERIFS 32
8551 MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
8553 /* reg_rigr2_rigr_index
8557 MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
8560 * Next RIGR Index is valid.
8563 MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
8565 /* reg_rigr2_next_rigr_index
8566 * Next RIGR Index. The index is to the KVD linear.
8567 * Reserved when vnxet = '0'.
8570 MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
8573 * RMID Index is valid.
8576 MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
8578 /* reg_rigr2_rmid_index
8580 * Range 0 .. max_mid - 1
8581 * Reserved when vrmid = '0'.
8582 * The index is to the Port Group Table (PGT)
8585 MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
8587 /* reg_rigr2_erif_entry_v
8588 * Egress Router Interface is valid.
8589 * Note that low-entries must be set if high-entries are set. For
8590 * example: if erif_entry[2].v is set then erif_entry[1].v and
8591 * erif_entry[0].v must be set.
8592 * Index can be from 0 to cap_mc_erif_list_entries-1
8595 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
8597 /* reg_rigr2_erif_entry_erif
8598 * Egress Router Interface.
8599 * Valid range is from 0 to cap_max_router_interfaces - 1
8600 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
8603 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
8605 static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
8606 bool vnext, u32 next_rigr_index)
8608 MLXSW_REG_ZERO(rigr2, payload);
8609 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
8610 mlxsw_reg_rigr2_vnext_set(payload, vnext);
8611 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
8612 mlxsw_reg_rigr2_vrmid_set(payload, 0);
8613 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
8616 static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
8619 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
8620 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
8623 /* RECR-V2 - Router ECMP Configuration Version 2 Register
8624 * ------------------------------------------------------
8626 #define MLXSW_REG_RECR2_ID 0x8025
8627 #define MLXSW_REG_RECR2_LEN 0x38
8629 MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
8632 * Per-port configuration
8635 MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
8641 MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
8647 MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
8650 /* Enable IPv4 fields if packet is not TCP and not UDP */
8651 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
8652 /* Enable IPv4 fields if packet is TCP or UDP */
8653 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
8654 /* Enable IPv6 fields if packet is not TCP and not UDP */
8655 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
8656 /* Enable IPv6 fields if packet is TCP or UDP */
8657 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
8658 /* Enable TCP/UDP header fields if packet is IPv4 */
8659 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
8660 /* Enable TCP/UDP header fields if packet is IPv6 */
8661 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
8663 __MLXSW_REG_RECR2_HEADER_CNT,
8666 /* reg_recr2_outer_header_enables
8667 * Bit mask where each bit enables a specific layer to be included in
8668 * the hash calculation.
8671 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
8674 /* IPv4 Source IP */
8675 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
8676 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
8677 /* IPv4 Destination IP */
8678 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
8679 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
8681 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
8682 /* IPv6 Source IP */
8683 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
8684 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
8685 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
8686 /* IPv6 Destination IP */
8687 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
8688 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
8689 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
8690 /* IPv6 Next Header */
8691 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
8692 /* IPv6 Flow Label */
8693 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
8694 /* TCP/UDP Source Port */
8695 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
8696 /* TCP/UDP Destination Port */
8697 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
8699 __MLXSW_REG_RECR2_FIELD_CNT,
8702 /* reg_recr2_outer_header_fields_enable
8703 * Packet fields to enable for ECMP hash subject to outer_header_enable.
8706 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
8708 /* reg_recr2_inner_header_enables
8709 * Bit mask where each bit enables a specific inner layer to be included in the
8710 * hash calculation. Same values as reg_recr2_outer_header_enables.
8713 MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_enables, 0x2C, 0x04, 1);
8716 /* Inner IPv4 Source IP */
8717 MLXSW_REG_RECR2_INNER_IPV4_SIP0 = 3,
8718 MLXSW_REG_RECR2_INNER_IPV4_SIP3 = 6,
8719 /* Inner IPv4 Destination IP */
8720 MLXSW_REG_RECR2_INNER_IPV4_DIP0 = 7,
8721 MLXSW_REG_RECR2_INNER_IPV4_DIP3 = 10,
8722 /* Inner IP Protocol */
8723 MLXSW_REG_RECR2_INNER_IPV4_PROTOCOL = 11,
8724 /* Inner IPv6 Source IP */
8725 MLXSW_REG_RECR2_INNER_IPV6_SIP0_7 = 12,
8726 MLXSW_REG_RECR2_INNER_IPV6_SIP8 = 20,
8727 MLXSW_REG_RECR2_INNER_IPV6_SIP15 = 27,
8728 /* Inner IPv6 Destination IP */
8729 MLXSW_REG_RECR2_INNER_IPV6_DIP0_7 = 28,
8730 MLXSW_REG_RECR2_INNER_IPV6_DIP8 = 36,
8731 MLXSW_REG_RECR2_INNER_IPV6_DIP15 = 43,
8732 /* Inner IPv6 Next Header */
8733 MLXSW_REG_RECR2_INNER_IPV6_NEXT_HEADER = 44,
8734 /* Inner IPv6 Flow Label */
8735 MLXSW_REG_RECR2_INNER_IPV6_FLOW_LABEL = 45,
8736 /* Inner TCP/UDP Source Port */
8737 MLXSW_REG_RECR2_INNER_TCP_UDP_SPORT = 46,
8738 /* Inner TCP/UDP Destination Port */
8739 MLXSW_REG_RECR2_INNER_TCP_UDP_DPORT = 47,
8741 __MLXSW_REG_RECR2_INNER_FIELD_CNT,
8744 /* reg_recr2_inner_header_fields_enable
8745 * Inner packet fields to enable for ECMP hash subject to inner_header_enables.
8748 MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_fields_enable, 0x30, 0x08, 1);
8750 static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
8752 MLXSW_REG_ZERO(recr2, payload);
8753 mlxsw_reg_recr2_pp_set(payload, false);
8754 mlxsw_reg_recr2_sh_set(payload, true);
8755 mlxsw_reg_recr2_seed_set(payload, seed);
8758 /* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
8759 * --------------------------------------------------------------
8760 * The RMFT_V2 register is used to configure and query the multicast table.
8762 #define MLXSW_REG_RMFT2_ID 0x8027
8763 #define MLXSW_REG_RMFT2_LEN 0x174
8765 MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
8771 MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
8773 enum mlxsw_reg_rmft2_type {
8774 MLXSW_REG_RMFT2_TYPE_IPV4,
8775 MLXSW_REG_RMFT2_TYPE_IPV6
8781 MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
8783 enum mlxsw_sp_reg_rmft2_op {
8785 * Write operation. Used to write a new entry to the table. All RW
8786 * fields are relevant for new entry. Activity bit is set for new
8787 * entries - Note write with v (Valid) 0 will delete the entry.
8791 MLXSW_REG_RMFT2_OP_READ_WRITE,
8798 MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
8801 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
8805 MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
8808 * Offset within the multicast forwarding table to write to.
8811 MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
8813 /* reg_rmft2_virtual_router
8814 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
8817 MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
8819 enum mlxsw_reg_rmft2_irif_mask {
8820 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
8821 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
8824 /* reg_rmft2_irif_mask
8828 MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
8831 * Ingress RIF index.
8834 MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
8836 /* reg_rmft2_dip{4,6}
8837 * Destination IPv4/6 address
8840 MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
8841 MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
8843 /* reg_rmft2_dip{4,6}_mask
8844 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
8845 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
8848 MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
8849 MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
8851 /* reg_rmft2_sip{4,6}
8852 * Source IPv4/6 address
8855 MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
8856 MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
8858 /* reg_rmft2_sip{4,6}_mask
8859 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
8860 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
8863 MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
8864 MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
8866 /* reg_rmft2_flexible_action_set
8867 * ACL action set. The only supported action types in this field and in any
8868 * action-set pointed from here are as follows:
8870 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
8873 * 08h: ACTION_POLICING_MONITORING
8874 * 10h: ACTION_ROUTER_MC
8877 MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
8878 MLXSW_REG_FLEX_ACTION_SET_LEN);
8881 mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
8883 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8884 const char *flex_action_set)
8886 MLXSW_REG_ZERO(rmft2, payload);
8887 mlxsw_reg_rmft2_v_set(payload, v);
8888 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
8889 mlxsw_reg_rmft2_offset_set(payload, offset);
8890 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
8891 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
8892 mlxsw_reg_rmft2_irif_set(payload, irif);
8893 if (flex_action_set)
8894 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
8899 mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8900 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8901 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
8902 const char *flexible_action_set)
8904 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8905 irif_mask, irif, flexible_action_set);
8906 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
8907 mlxsw_reg_rmft2_dip4_set(payload, dip4);
8908 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
8909 mlxsw_reg_rmft2_sip4_set(payload, sip4);
8910 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
8914 mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8915 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8916 struct in6_addr dip6, struct in6_addr dip6_mask,
8917 struct in6_addr sip6, struct in6_addr sip6_mask,
8918 const char *flexible_action_set)
8920 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8921 irif_mask, irif, flexible_action_set);
8922 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
8923 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
8924 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
8925 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
8926 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
8929 /* RXLTE - Router XLT Enable Register
8930 * ----------------------------------
8931 * The RXLTE enables XLT (eXtended Lookup Table) LPM lookups if a capable
8932 * XM is present on the system.
8935 #define MLXSW_REG_RXLTE_ID 0x8050
8936 #define MLXSW_REG_RXLTE_LEN 0x0C
8938 MLXSW_REG_DEFINE(rxlte, MLXSW_REG_RXLTE_ID, MLXSW_REG_RXLTE_LEN);
8940 /* reg_rxlte_virtual_router
8941 * Virtual router ID associated with the router interface.
8942 * Range is 0..cap_max_virtual_routers-1
8945 MLXSW_ITEM32(reg, rxlte, virtual_router, 0x00, 0, 16);
8947 enum mlxsw_reg_rxlte_protocol {
8948 MLXSW_REG_RXLTE_PROTOCOL_IPV4,
8949 MLXSW_REG_RXLTE_PROTOCOL_IPV6,
8952 /* reg_rxlte_protocol
8955 MLXSW_ITEM32(reg, rxlte, protocol, 0x04, 0, 4);
8957 /* reg_rxlte_lpm_xlt_en
8960 MLXSW_ITEM32(reg, rxlte, lpm_xlt_en, 0x08, 0, 1);
8962 static inline void mlxsw_reg_rxlte_pack(char *payload, u16 virtual_router,
8963 enum mlxsw_reg_rxlte_protocol protocol,
8966 MLXSW_REG_ZERO(rxlte, payload);
8967 mlxsw_reg_rxlte_virtual_router_set(payload, virtual_router);
8968 mlxsw_reg_rxlte_protocol_set(payload, protocol);
8969 mlxsw_reg_rxlte_lpm_xlt_en_set(payload, lpm_xlt_en);
8972 /* RXLTM - Router XLT M select Register
8973 * ------------------------------------
8974 * The RXLTM configures and selects the M for the XM lookups.
8977 #define MLXSW_REG_RXLTM_ID 0x8051
8978 #define MLXSW_REG_RXLTM_LEN 0x14
8980 MLXSW_REG_DEFINE(rxltm, MLXSW_REG_RXLTM_ID, MLXSW_REG_RXLTM_LEN);
8982 /* reg_rxltm_m0_val_v6
8983 * Global M0 value For IPv6.
8987 MLXSW_ITEM32(reg, rxltm, m0_val_v6, 0x10, 16, 8);
8989 /* reg_rxltm_m0_val_v4
8990 * Global M0 value For IPv4.
8994 MLXSW_ITEM32(reg, rxltm, m0_val_v4, 0x10, 0, 6);
8996 static inline void mlxsw_reg_rxltm_pack(char *payload, u8 m0_val_v4, u8 m0_val_v6)
8998 MLXSW_REG_ZERO(rxltm, payload);
8999 mlxsw_reg_rxltm_m0_val_v6_set(payload, m0_val_v6);
9000 mlxsw_reg_rxltm_m0_val_v4_set(payload, m0_val_v4);
9003 /* RLCMLD - Router LPM Cache ML Delete Register
9004 * --------------------------------------------
9005 * The RLCMLD register is used to bulk delete the XLT-LPM cache ML entries.
9006 * This can be used by SW when L is increased or decreased, thus need to
9007 * remove entries with old ML values.
9010 #define MLXSW_REG_RLCMLD_ID 0x8055
9011 #define MLXSW_REG_RLCMLD_LEN 0x30
9013 MLXSW_REG_DEFINE(rlcmld, MLXSW_REG_RLCMLD_ID, MLXSW_REG_RLCMLD_LEN);
9015 enum mlxsw_reg_rlcmld_select {
9016 MLXSW_REG_RLCMLD_SELECT_ML_ENTRIES,
9017 MLXSW_REG_RLCMLD_SELECT_M_ENTRIES,
9018 MLXSW_REG_RLCMLD_SELECT_M_AND_ML_ENTRIES,
9021 /* reg_rlcmld_select
9022 * Which entries to delete.
9025 MLXSW_ITEM32(reg, rlcmld, select, 0x00, 16, 2);
9027 enum mlxsw_reg_rlcmld_filter_fields {
9028 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_PROTOCOL = 0x04,
9029 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_VIRTUAL_ROUTER = 0x08,
9030 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_DIP = 0x10,
9033 /* reg_rlcmld_filter_fields
9034 * If a bit is '0' then the relevant field is ignored.
9037 MLXSW_ITEM32(reg, rlcmld, filter_fields, 0x00, 0, 8);
9039 enum mlxsw_reg_rlcmld_protocol {
9040 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV4,
9041 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV6,
9044 /* reg_rlcmld_protocol
9047 MLXSW_ITEM32(reg, rlcmld, protocol, 0x08, 0, 4);
9049 /* reg_rlcmld_virtual_router
9050 * Virtual router ID.
9051 * Range is 0..cap_max_virtual_routers-1
9054 MLXSW_ITEM32(reg, rlcmld, virtual_router, 0x0C, 0, 16);
9057 * The prefix of the route or of the marker that the object of the LPM
9058 * is compared with. The most significant bits of the dip are the prefix.
9061 MLXSW_ITEM32(reg, rlcmld, dip4, 0x1C, 0, 32);
9062 MLXSW_ITEM_BUF(reg, rlcmld, dip6, 0x10, 16);
9064 /* reg_rlcmld_dip_mask
9070 MLXSW_ITEM32(reg, rlcmld, dip_mask4, 0x2C, 0, 32);
9071 MLXSW_ITEM_BUF(reg, rlcmld, dip_mask6, 0x20, 16);
9073 static inline void __mlxsw_reg_rlcmld_pack(char *payload,
9074 enum mlxsw_reg_rlcmld_select select,
9075 enum mlxsw_reg_rlcmld_protocol protocol,
9078 u8 filter_fields = MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_PROTOCOL |
9079 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_VIRTUAL_ROUTER |
9080 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_DIP;
9082 MLXSW_REG_ZERO(rlcmld, payload);
9083 mlxsw_reg_rlcmld_select_set(payload, select);
9084 mlxsw_reg_rlcmld_filter_fields_set(payload, filter_fields);
9085 mlxsw_reg_rlcmld_protocol_set(payload, protocol);
9086 mlxsw_reg_rlcmld_virtual_router_set(payload, virtual_router);
9089 static inline void mlxsw_reg_rlcmld_pack4(char *payload,
9090 enum mlxsw_reg_rlcmld_select select,
9092 u32 dip, u32 dip_mask)
9094 __mlxsw_reg_rlcmld_pack(payload, select,
9095 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV4,
9097 mlxsw_reg_rlcmld_dip4_set(payload, dip);
9098 mlxsw_reg_rlcmld_dip_mask4_set(payload, dip_mask);
9101 static inline void mlxsw_reg_rlcmld_pack6(char *payload,
9102 enum mlxsw_reg_rlcmld_select select,
9104 const void *dip, const void *dip_mask)
9106 __mlxsw_reg_rlcmld_pack(payload, select,
9107 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV6,
9109 mlxsw_reg_rlcmld_dip6_memcpy_to(payload, dip);
9110 mlxsw_reg_rlcmld_dip_mask6_memcpy_to(payload, dip_mask);
9113 /* RLPMCE - Router LPM Cache Enable Register
9114 * -----------------------------------------
9115 * Allows disabling the LPM cache. Can be changed on the fly.
9118 #define MLXSW_REG_RLPMCE_ID 0x8056
9119 #define MLXSW_REG_RLPMCE_LEN 0x4
9121 MLXSW_REG_DEFINE(rlpmce, MLXSW_REG_RLPMCE_ID, MLXSW_REG_RLPMCE_LEN);
9125 * 0: do not flush the cache (default)
9126 * 1: flush (clear) the cache
9129 MLXSW_ITEM32(reg, rlpmce, flush, 0x00, 4, 1);
9131 /* reg_rlpmce_disable
9133 * 0: enabled (default)
9137 MLXSW_ITEM32(reg, rlpmce, disable, 0x00, 0, 1);
9139 static inline void mlxsw_reg_rlpmce_pack(char *payload, bool flush,
9142 MLXSW_REG_ZERO(rlpmce, payload);
9143 mlxsw_reg_rlpmce_flush_set(payload, flush);
9144 mlxsw_reg_rlpmce_disable_set(payload, disable);
9147 /* Note that XLTQ, XMDR, XRMT and XRALXX register positions violate the rule
9148 * of ordering register definitions by the ID. However, XRALXX pack helpers are
9149 * using RALXX pack helpers, RALXX registers have higher IDs.
9150 * Also XMDR is using RALUE enums. XLRQ and XRMT are just put alongside with the
9151 * related registers.
9154 /* XLTQ - XM Lookup Table Query Register
9155 * -------------------------------------
9157 #define MLXSW_REG_XLTQ_ID 0x7802
9158 #define MLXSW_REG_XLTQ_LEN 0x2C
9160 MLXSW_REG_DEFINE(xltq, MLXSW_REG_XLTQ_ID, MLXSW_REG_XLTQ_LEN);
9162 enum mlxsw_reg_xltq_xm_device_id {
9163 MLXSW_REG_XLTQ_XM_DEVICE_ID_UNKNOWN,
9164 MLXSW_REG_XLTQ_XM_DEVICE_ID_XLT = 0xCF71,
9167 /* reg_xltq_xm_device_id
9171 MLXSW_ITEM32(reg, xltq, xm_device_id, 0x04, 0, 16);
9173 /* reg_xltq_xlt_cap_ipv4_lpm
9176 MLXSW_ITEM32(reg, xltq, xlt_cap_ipv4_lpm, 0x10, 0, 1);
9178 /* reg_xltq_xlt_cap_ipv6_lpm
9181 MLXSW_ITEM32(reg, xltq, xlt_cap_ipv6_lpm, 0x10, 1, 1);
9183 /* reg_xltq_cap_xlt_entries
9184 * Number of XLT entries
9185 * Note: SW must not fill more than 80% in order to avoid overflow
9188 MLXSW_ITEM32(reg, xltq, cap_xlt_entries, 0x20, 0, 32);
9190 /* reg_xltq_cap_xlt_mtable
9191 * XLT M-Table max size
9194 MLXSW_ITEM32(reg, xltq, cap_xlt_mtable, 0x24, 0, 32);
9196 static inline void mlxsw_reg_xltq_pack(char *payload)
9198 MLXSW_REG_ZERO(xltq, payload);
9201 static inline void mlxsw_reg_xltq_unpack(char *payload, u16 *xm_device_id, bool *xlt_cap_ipv4_lpm,
9202 bool *xlt_cap_ipv6_lpm, u32 *cap_xlt_entries,
9203 u32 *cap_xlt_mtable)
9205 *xm_device_id = mlxsw_reg_xltq_xm_device_id_get(payload);
9206 *xlt_cap_ipv4_lpm = mlxsw_reg_xltq_xlt_cap_ipv4_lpm_get(payload);
9207 *xlt_cap_ipv6_lpm = mlxsw_reg_xltq_xlt_cap_ipv6_lpm_get(payload);
9208 *cap_xlt_entries = mlxsw_reg_xltq_cap_xlt_entries_get(payload);
9209 *cap_xlt_mtable = mlxsw_reg_xltq_cap_xlt_mtable_get(payload);
9212 /* XMDR - XM Direct Register
9213 * -------------------------
9214 * The XMDR allows direct access to the XM device via the switch.
9215 * Working in synchronous mode. FW waits for response from the XLT
9216 * for each command. FW acks the XMDR accordingly.
9218 #define MLXSW_REG_XMDR_ID 0x7803
9219 #define MLXSW_REG_XMDR_BASE_LEN 0x20
9220 #define MLXSW_REG_XMDR_TRANS_LEN 0x80
9221 #define MLXSW_REG_XMDR_LEN (MLXSW_REG_XMDR_BASE_LEN + \
9222 MLXSW_REG_XMDR_TRANS_LEN)
9224 MLXSW_REG_DEFINE(xmdr, MLXSW_REG_XMDR_ID, MLXSW_REG_XMDR_LEN);
9226 /* reg_xmdr_bulk_entry
9228 * 0: Last entry - immediate flush of XRT-cache
9229 * 1: Bulk entry - do not flush the XRT-cache
9232 MLXSW_ITEM32(reg, xmdr, bulk_entry, 0x04, 8, 1);
9235 * Number of records for Direct access to XM
9236 * Supported: 0..4 commands (except NOP which is a filler)
9237 * 0 commands is reserved when bulk_entry = 1.
9238 * 0 commands is allowed when bulk_entry = 0 for immediate XRT-cache flush.
9241 MLXSW_ITEM32(reg, xmdr, num_rec, 0x04, 0, 4);
9243 /* reg_xmdr_reply_vect
9245 * Bit i for command index i+1
9249 * e.g. if commands 1, 2, 4 succeeded and command 3 failed then binary
9250 * value will be 0b1011
9253 MLXSW_ITEM_BIT_ARRAY(reg, xmdr, reply_vect, 0x08, 4, 1);
9255 static inline void mlxsw_reg_xmdr_pack(char *payload, bool bulk_entry)
9257 MLXSW_REG_ZERO(xmdr, payload);
9258 mlxsw_reg_xmdr_bulk_entry_set(payload, bulk_entry);
9261 enum mlxsw_reg_xmdr_c_cmd_id {
9262 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V4 = 0x30,
9263 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V6 = 0x31,
9266 #define MLXSW_REG_XMDR_C_LT_ROUTE_V4_LEN 32
9267 #define MLXSW_REG_XMDR_C_LT_ROUTE_V6_LEN 48
9269 /* reg_xmdr_c_cmd_id
9271 MLXSW_ITEM32(reg, xmdr_c, cmd_id, 0x00, 24, 8);
9273 /* reg_xmdr_c_seq_number
9275 MLXSW_ITEM32(reg, xmdr_c, seq_number, 0x00, 12, 12);
9277 enum mlxsw_reg_xmdr_c_ltr_op {
9278 /* Activity is set */
9279 MLXSW_REG_XMDR_C_LTR_OP_WRITE = 0,
9280 /* There is no update mask. All fields are updated. */
9281 MLXSW_REG_XMDR_C_LTR_OP_UPDATE = 1,
9282 MLXSW_REG_XMDR_C_LTR_OP_DELETE = 2,
9285 /* reg_xmdr_c_ltr_op
9288 MLXSW_ITEM32(reg, xmdr_c, ltr_op, 0x04, 24, 8);
9290 /* reg_xmdr_c_ltr_trap_action
9292 * Values are defined in enum mlxsw_reg_ralue_trap_action.
9294 MLXSW_ITEM32(reg, xmdr_c, ltr_trap_action, 0x04, 20, 4);
9296 enum mlxsw_reg_xmdr_c_ltr_trap_id_num {
9297 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS0,
9298 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS1,
9299 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS2,
9300 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS3,
9303 /* reg_xmdr_c_ltr_trap_id_num
9306 MLXSW_ITEM32(reg, xmdr_c, ltr_trap_id_num, 0x04, 16, 4);
9308 /* reg_xmdr_c_ltr_virtual_router
9309 * Virtual Router ID.
9310 * Range is 0..cap_max_virtual_routers-1
9312 MLXSW_ITEM32(reg, xmdr_c, ltr_virtual_router, 0x04, 0, 16);
9314 /* reg_xmdr_c_ltr_prefix_len
9315 * Number of bits in the prefix of the LPM route.
9317 MLXSW_ITEM32(reg, xmdr_c, ltr_prefix_len, 0x08, 24, 8);
9319 /* reg_xmdr_c_ltr_bmp_len
9320 * The best match prefix length in the case that there is no match for
9322 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
9324 MLXSW_ITEM32(reg, xmdr_c, ltr_bmp_len, 0x08, 16, 8);
9326 /* reg_xmdr_c_ltr_entry_type
9328 * Values are defined in enum mlxsw_reg_ralue_entry_type.
9330 MLXSW_ITEM32(reg, xmdr_c, ltr_entry_type, 0x08, 4, 4);
9332 enum mlxsw_reg_xmdr_c_ltr_action_type {
9333 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_LOCAL,
9334 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_REMOTE,
9335 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME,
9338 /* reg_xmdr_c_ltr_action_type
9341 MLXSW_ITEM32(reg, xmdr_c, ltr_action_type, 0x08, 0, 4);
9343 /* reg_xmdr_c_ltr_erif
9344 * Egress Router Interface.
9345 * Only relevant in case of LOCAL action.
9347 MLXSW_ITEM32(reg, xmdr_c, ltr_erif, 0x10, 0, 16);
9349 /* reg_xmdr_c_ltr_adjacency_index
9350 * Points to the first entry of the group-based ECMP.
9351 * Only relevant in case of REMOTE action.
9353 MLXSW_ITEM32(reg, xmdr_c, ltr_adjacency_index, 0x10, 0, 24);
9355 #define MLXSW_REG_XMDR_C_LTR_POINTER_TO_TUNNEL_DISABLED_MAGIC 0xFFFFFF
9357 /* reg_xmdr_c_ltr_pointer_to_tunnel
9358 * Only relevant in case of IP2ME action.
9360 MLXSW_ITEM32(reg, xmdr_c, ltr_pointer_to_tunnel, 0x10, 0, 24);
9362 /* reg_xmdr_c_ltr_ecmp_size
9363 * Amount of sequential entries starting
9364 * from the adjacency_index (the number of ECMPs).
9365 * The valid range is 1-64, 512, 1024, 2048 and 4096.
9366 * Only relevant in case of REMOTE action.
9368 MLXSW_ITEM32(reg, xmdr_c, ltr_ecmp_size, 0x14, 0, 32);
9370 /* reg_xmdr_c_ltr_dip*
9371 * The prefix of the route or of the marker that the object of the LPM
9372 * is compared with. The most significant bits of the dip are the prefix.
9373 * The least significant bits must be '0' if the prefix_len is smaller
9374 * than 128 for IPv6 or smaller than 32 for IPv4.
9376 MLXSW_ITEM32(reg, xmdr_c, ltr_dip4, 0x1C, 0, 32);
9377 MLXSW_ITEM_BUF(reg, xmdr_c, ltr_dip6, 0x1C, 16);
9380 mlxsw_reg_xmdr_c_ltr_pack(char *xmdr_payload, unsigned int trans_offset,
9381 enum mlxsw_reg_xmdr_c_cmd_id cmd_id, u16 seq_number,
9382 enum mlxsw_reg_xmdr_c_ltr_op op, u16 virtual_router,
9385 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9386 u8 num_rec = mlxsw_reg_xmdr_num_rec_get(xmdr_payload);
9388 mlxsw_reg_xmdr_num_rec_set(xmdr_payload, num_rec + 1);
9390 mlxsw_reg_xmdr_c_cmd_id_set(payload, cmd_id);
9391 mlxsw_reg_xmdr_c_seq_number_set(payload, seq_number);
9392 mlxsw_reg_xmdr_c_ltr_op_set(payload, op);
9393 mlxsw_reg_xmdr_c_ltr_virtual_router_set(payload, virtual_router);
9394 mlxsw_reg_xmdr_c_ltr_prefix_len_set(payload, prefix_len);
9395 mlxsw_reg_xmdr_c_ltr_entry_type_set(payload,
9396 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
9397 mlxsw_reg_xmdr_c_ltr_bmp_len_set(payload, prefix_len);
9400 static inline unsigned int
9401 mlxsw_reg_xmdr_c_ltr_pack4(char *xmdr_payload, unsigned int trans_offset,
9402 u16 seq_number, enum mlxsw_reg_xmdr_c_ltr_op op,
9403 u16 virtual_router, u8 prefix_len, u32 *dip)
9405 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9407 mlxsw_reg_xmdr_c_ltr_pack(xmdr_payload, trans_offset,
9408 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V4,
9409 seq_number, op, virtual_router, prefix_len);
9411 mlxsw_reg_xmdr_c_ltr_dip4_set(payload, *dip);
9412 return MLXSW_REG_XMDR_C_LT_ROUTE_V4_LEN;
9415 static inline unsigned int
9416 mlxsw_reg_xmdr_c_ltr_pack6(char *xmdr_payload, unsigned int trans_offset,
9417 u16 seq_number, enum mlxsw_reg_xmdr_c_ltr_op op,
9418 u16 virtual_router, u8 prefix_len, const void *dip)
9420 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9422 mlxsw_reg_xmdr_c_ltr_pack(xmdr_payload, trans_offset,
9423 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V6,
9424 seq_number, op, virtual_router, prefix_len);
9426 mlxsw_reg_xmdr_c_ltr_dip6_memcpy_to(payload, dip);
9427 return MLXSW_REG_XMDR_C_LT_ROUTE_V6_LEN;
9431 mlxsw_reg_xmdr_c_ltr_act_remote_pack(char *xmdr_payload, unsigned int trans_offset,
9432 enum mlxsw_reg_ralue_trap_action trap_action,
9433 enum mlxsw_reg_xmdr_c_ltr_trap_id_num trap_id_num,
9434 u32 adjacency_index, u16 ecmp_size)
9436 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9438 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_REMOTE);
9439 mlxsw_reg_xmdr_c_ltr_trap_action_set(payload, trap_action);
9440 mlxsw_reg_xmdr_c_ltr_trap_id_num_set(payload, trap_id_num);
9441 mlxsw_reg_xmdr_c_ltr_adjacency_index_set(payload, adjacency_index);
9442 mlxsw_reg_xmdr_c_ltr_ecmp_size_set(payload, ecmp_size);
9446 mlxsw_reg_xmdr_c_ltr_act_local_pack(char *xmdr_payload, unsigned int trans_offset,
9447 enum mlxsw_reg_ralue_trap_action trap_action,
9448 enum mlxsw_reg_xmdr_c_ltr_trap_id_num trap_id_num, u16 erif)
9450 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9452 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_LOCAL);
9453 mlxsw_reg_xmdr_c_ltr_trap_action_set(payload, trap_action);
9454 mlxsw_reg_xmdr_c_ltr_trap_id_num_set(payload, trap_id_num);
9455 mlxsw_reg_xmdr_c_ltr_erif_set(payload, erif);
9458 static inline void mlxsw_reg_xmdr_c_ltr_act_ip2me_pack(char *xmdr_payload,
9459 unsigned int trans_offset)
9461 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9463 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME);
9464 mlxsw_reg_xmdr_c_ltr_pointer_to_tunnel_set(payload,
9465 MLXSW_REG_XMDR_C_LTR_POINTER_TO_TUNNEL_DISABLED_MAGIC);
9468 static inline void mlxsw_reg_xmdr_c_ltr_act_ip2me_tun_pack(char *xmdr_payload,
9469 unsigned int trans_offset,
9470 u32 pointer_to_tunnel)
9472 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9474 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME);
9475 mlxsw_reg_xmdr_c_ltr_pointer_to_tunnel_set(payload, pointer_to_tunnel);
9478 /* XRMT - XM Router M Table Register
9479 * ---------------------------------
9480 * The XRMT configures the M-Table for the XLT-LPM.
9482 #define MLXSW_REG_XRMT_ID 0x7810
9483 #define MLXSW_REG_XRMT_LEN 0x14
9485 MLXSW_REG_DEFINE(xrmt, MLXSW_REG_XRMT_ID, MLXSW_REG_XRMT_LEN);
9489 * Range 0..cap_xlt_mtable-1
9492 MLXSW_ITEM32(reg, xrmt, index, 0x04, 0, 20);
9497 MLXSW_ITEM32(reg, xrmt, l0_val, 0x10, 24, 8);
9499 static inline void mlxsw_reg_xrmt_pack(char *payload, u32 index, u8 l0_val)
9501 MLXSW_REG_ZERO(xrmt, payload);
9502 mlxsw_reg_xrmt_index_set(payload, index);
9503 mlxsw_reg_xrmt_l0_val_set(payload, l0_val);
9506 /* XRALTA - XM Router Algorithmic LPM Tree Allocation Register
9507 * -----------------------------------------------------------
9508 * The XRALTA is used to allocate the XLT LPM trees.
9510 * This register embeds original RALTA register.
9512 #define MLXSW_REG_XRALTA_ID 0x7811
9513 #define MLXSW_REG_XRALTA_LEN 0x08
9514 #define MLXSW_REG_XRALTA_RALTA_OFFSET 0x04
9516 MLXSW_REG_DEFINE(xralta, MLXSW_REG_XRALTA_ID, MLXSW_REG_XRALTA_LEN);
9518 static inline void mlxsw_reg_xralta_pack(char *payload, bool alloc,
9519 enum mlxsw_reg_ralxx_protocol protocol,
9522 char *ralta_payload = payload + MLXSW_REG_XRALTA_RALTA_OFFSET;
9524 MLXSW_REG_ZERO(xralta, payload);
9525 mlxsw_reg_ralta_pack(ralta_payload, alloc, protocol, tree_id);
9528 /* XRALST - XM Router Algorithmic LPM Structure Tree Register
9529 * ----------------------------------------------------------
9530 * The XRALST is used to set and query the structure of an XLT LPM tree.
9532 * This register embeds original RALST register.
9534 #define MLXSW_REG_XRALST_ID 0x7812
9535 #define MLXSW_REG_XRALST_LEN 0x108
9536 #define MLXSW_REG_XRALST_RALST_OFFSET 0x04
9538 MLXSW_REG_DEFINE(xralst, MLXSW_REG_XRALST_ID, MLXSW_REG_XRALST_LEN);
9540 static inline void mlxsw_reg_xralst_pack(char *payload, u8 root_bin, u8 tree_id)
9542 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET;
9544 MLXSW_REG_ZERO(xralst, payload);
9545 mlxsw_reg_ralst_pack(ralst_payload, root_bin, tree_id);
9548 static inline void mlxsw_reg_xralst_bin_pack(char *payload, u8 bin_number,
9552 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET;
9554 mlxsw_reg_ralst_bin_pack(ralst_payload, bin_number, left_child_bin,
9558 /* XRALTB - XM Router Algorithmic LPM Tree Binding Register
9559 * --------------------------------------------------------
9560 * The XRALTB register is used to bind virtual router and protocol
9561 * to an allocated LPM tree.
9563 * This register embeds original RALTB register.
9565 #define MLXSW_REG_XRALTB_ID 0x7813
9566 #define MLXSW_REG_XRALTB_LEN 0x08
9567 #define MLXSW_REG_XRALTB_RALTB_OFFSET 0x04
9569 MLXSW_REG_DEFINE(xraltb, MLXSW_REG_XRALTB_ID, MLXSW_REG_XRALTB_LEN);
9571 static inline void mlxsw_reg_xraltb_pack(char *payload, u16 virtual_router,
9572 enum mlxsw_reg_ralxx_protocol protocol,
9575 char *raltb_payload = payload + MLXSW_REG_XRALTB_RALTB_OFFSET;
9577 MLXSW_REG_ZERO(xraltb, payload);
9578 mlxsw_reg_raltb_pack(raltb_payload, virtual_router, protocol, tree_id);
9581 /* MFCR - Management Fan Control Register
9582 * --------------------------------------
9583 * This register controls the settings of the Fan Speed PWM mechanism.
9585 #define MLXSW_REG_MFCR_ID 0x9001
9586 #define MLXSW_REG_MFCR_LEN 0x08
9588 MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
9590 enum mlxsw_reg_mfcr_pwm_frequency {
9591 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
9592 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
9593 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
9594 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
9595 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
9596 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
9597 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
9598 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
9601 /* reg_mfcr_pwm_frequency
9602 * Controls the frequency of the PWM signal.
9605 MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
9607 #define MLXSW_MFCR_TACHOS_MAX 10
9609 /* reg_mfcr_tacho_active
9610 * Indicates which of the tachometer is active (bit per tachometer).
9613 MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
9615 #define MLXSW_MFCR_PWMS_MAX 5
9617 /* reg_mfcr_pwm_active
9618 * Indicates which of the PWM control is active (bit per PWM).
9621 MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
9624 mlxsw_reg_mfcr_pack(char *payload,
9625 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
9627 MLXSW_REG_ZERO(mfcr, payload);
9628 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
9632 mlxsw_reg_mfcr_unpack(char *payload,
9633 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
9634 u16 *p_tacho_active, u8 *p_pwm_active)
9636 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
9637 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
9638 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
9641 /* MFSC - Management Fan Speed Control Register
9642 * --------------------------------------------
9643 * This register controls the settings of the Fan Speed PWM mechanism.
9645 #define MLXSW_REG_MFSC_ID 0x9002
9646 #define MLXSW_REG_MFSC_LEN 0x08
9648 MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
9651 * Fan pwm to control / monitor.
9654 MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
9656 /* reg_mfsc_pwm_duty_cycle
9657 * Controls the duty cycle of the PWM. Value range from 0..255 to
9658 * represent duty cycle of 0%...100%.
9661 MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
9663 static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
9666 MLXSW_REG_ZERO(mfsc, payload);
9667 mlxsw_reg_mfsc_pwm_set(payload, pwm);
9668 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
9671 /* MFSM - Management Fan Speed Measurement
9672 * ---------------------------------------
9673 * This register controls the settings of the Tacho measurements and
9674 * enables reading the Tachometer measurements.
9676 #define MLXSW_REG_MFSM_ID 0x9003
9677 #define MLXSW_REG_MFSM_LEN 0x08
9679 MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
9682 * Fan tachometer index.
9685 MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
9688 * Fan speed (round per minute).
9691 MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
9693 static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
9695 MLXSW_REG_ZERO(mfsm, payload);
9696 mlxsw_reg_mfsm_tacho_set(payload, tacho);
9699 /* MFSL - Management Fan Speed Limit Register
9700 * ------------------------------------------
9701 * The Fan Speed Limit register is used to configure the fan speed
9702 * event / interrupt notification mechanism. Fan speed threshold are
9703 * defined for both under-speed and over-speed.
9705 #define MLXSW_REG_MFSL_ID 0x9004
9706 #define MLXSW_REG_MFSL_LEN 0x0C
9708 MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
9711 * Fan tachometer index.
9714 MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
9716 /* reg_mfsl_tach_min
9717 * Tachometer minimum value (minimum RPM).
9720 MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
9722 /* reg_mfsl_tach_max
9723 * Tachometer maximum value (maximum RPM).
9726 MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
9728 static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
9729 u16 tach_min, u16 tach_max)
9731 MLXSW_REG_ZERO(mfsl, payload);
9732 mlxsw_reg_mfsl_tacho_set(payload, tacho);
9733 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
9734 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
9737 static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
9738 u16 *p_tach_min, u16 *p_tach_max)
9741 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
9744 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
9747 /* FORE - Fan Out of Range Event Register
9748 * --------------------------------------
9749 * This register reports the status of the controlled fans compared to the
9750 * range defined by the MFSL register.
9752 #define MLXSW_REG_FORE_ID 0x9007
9753 #define MLXSW_REG_FORE_LEN 0x0C
9755 MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
9758 * Fan speed is below the low limit defined in MFSL register. Each bit relates
9759 * to a single tachometer and indicates the specific tachometer reading is
9760 * below the threshold.
9763 MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
9765 static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
9771 limit = mlxsw_reg_fore_fan_under_limit_get(payload);
9772 *fault = limit & BIT(tacho);
9776 /* MTCAP - Management Temperature Capabilities
9777 * -------------------------------------------
9778 * This register exposes the capabilities of the device and
9779 * system temperature sensing.
9781 #define MLXSW_REG_MTCAP_ID 0x9009
9782 #define MLXSW_REG_MTCAP_LEN 0x08
9784 MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
9786 /* reg_mtcap_sensor_count
9787 * Number of sensors supported by the device.
9788 * This includes the QSFP module sensors (if exists in the QSFP module).
9791 MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
9793 /* MTMP - Management Temperature
9794 * -----------------------------
9795 * This register controls the settings of the temperature measurements
9796 * and enables reading the temperature measurements. Note that temperature
9797 * is in 0.125 degrees Celsius.
9799 #define MLXSW_REG_MTMP_ID 0x900A
9800 #define MLXSW_REG_MTMP_LEN 0x20
9802 MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
9804 /* reg_mtmp_slot_index
9805 * Slot index (0: Main board).
9808 MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4);
9810 #define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
9811 #define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
9812 /* reg_mtmp_sensor_index
9813 * Sensors index to access.
9814 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
9815 * (module 0 is mapped to sensor_index 64).
9818 MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
9820 /* Convert to milli degrees Celsius */
9821 #define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
9822 ((v_) >= 0) ? ((v_) * 125) : \
9823 ((s16)((GENMASK(15, 0) + (v_) + 1) \
9826 /* reg_mtmp_max_operational_temperature
9827 * The highest temperature in the nominal operational range. Reading is in
9828 * 0.125 Celsius degrees units.
9829 * In case of module this is SFF critical temperature threshold.
9832 MLXSW_ITEM32(reg, mtmp, max_operational_temperature, 0x04, 16, 16);
9834 /* reg_mtmp_temperature
9835 * Temperature reading from the sensor. Reading is in 0.125 Celsius
9839 MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
9842 * Max Temperature Enable - enables measuring the max temperature on a sensor.
9845 MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
9848 * Max Temperature Reset - clears the value of the max temperature register.
9851 MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
9853 /* reg_mtmp_max_temperature
9854 * The highest measured temperature from the sensor.
9855 * When the bit mte is cleared, the field max_temperature is reserved.
9858 MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
9861 * Temperature Event Enable.
9862 * 0 - Do not generate event
9863 * 1 - Generate event
9864 * 2 - Generate single event
9868 enum mlxsw_reg_mtmp_tee {
9869 MLXSW_REG_MTMP_TEE_NO_EVENT,
9870 MLXSW_REG_MTMP_TEE_GENERATE_EVENT,
9871 MLXSW_REG_MTMP_TEE_GENERATE_SINGLE_EVENT,
9874 MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
9876 #define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
9878 /* reg_mtmp_temperature_threshold_hi
9879 * High threshold for Temperature Warning Event. In 0.125 Celsius.
9882 MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
9884 #define MLXSW_REG_MTMP_HYSTERESIS_TEMP 0x28 /* 5 Celsius */
9885 /* reg_mtmp_temperature_threshold_lo
9886 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
9889 MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
9891 #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
9893 /* reg_mtmp_sensor_name
9897 MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
9899 static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index,
9900 u16 sensor_index, bool max_temp_enable,
9901 bool max_temp_reset)
9903 MLXSW_REG_ZERO(mtmp, payload);
9904 mlxsw_reg_mtmp_slot_index_set(payload, slot_index);
9905 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
9906 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
9907 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
9908 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
9909 MLXSW_REG_MTMP_THRESH_HI);
9912 static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
9913 int *p_max_temp, int *p_temp_hi,
9914 int *p_max_oper_temp,
9920 temp = mlxsw_reg_mtmp_temperature_get(payload);
9921 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9924 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
9925 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9928 temp = mlxsw_reg_mtmp_temperature_threshold_hi_get(payload);
9929 *p_temp_hi = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9931 if (p_max_oper_temp) {
9932 temp = mlxsw_reg_mtmp_max_operational_temperature_get(payload);
9933 *p_max_oper_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9936 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
9939 /* MTWE - Management Temperature Warning Event
9940 * -------------------------------------------
9941 * This register is used for over temperature warning.
9943 #define MLXSW_REG_MTWE_ID 0x900B
9944 #define MLXSW_REG_MTWE_LEN 0x10
9946 MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN);
9948 /* reg_mtwe_sensor_warning
9949 * Bit vector indicating which of the sensor reading is above threshold.
9950 * Address 00h bit31 is sensor_warning[127].
9951 * Address 0Ch bit0 is sensor_warning[0].
9954 MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
9956 /* MTBR - Management Temperature Bulk Register
9957 * -------------------------------------------
9958 * This register is used for bulk temperature reading.
9960 #define MLXSW_REG_MTBR_ID 0x900F
9961 #define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */
9962 #define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */
9963 #define MLXSW_REG_MTBR_REC_MAX_COUNT 47 /* firmware limitation */
9964 #define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
9965 MLXSW_REG_MTBR_REC_LEN * \
9966 MLXSW_REG_MTBR_REC_MAX_COUNT)
9968 MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
9970 /* reg_mtbr_slot_index
9971 * Slot index (0: Main board).
9974 MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4);
9976 /* reg_mtbr_base_sensor_index
9977 * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
9978 * 64-127 are mapped to the SFP+/QSFP modules sequentially).
9981 MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
9984 * Request: Number of records to read
9985 * Response: Number of records read
9986 * See above description for more details.
9990 MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
9992 /* reg_mtbr_rec_max_temp
9993 * The highest measured temperature from the sensor.
9994 * When the bit mte is cleared, the field max_temperature is reserved.
9997 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
9998 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
10000 /* reg_mtbr_rec_temp
10001 * Temperature reading from the sensor. Reading is in 0..125 Celsius
10005 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
10006 MLXSW_REG_MTBR_REC_LEN, 0x00, false);
10008 static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index,
10009 u16 base_sensor_index, u8 num_rec)
10011 MLXSW_REG_ZERO(mtbr, payload);
10012 mlxsw_reg_mtbr_slot_index_set(payload, slot_index);
10013 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
10014 mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
10017 /* Error codes from temperatute reading */
10018 enum mlxsw_reg_mtbr_temp_status {
10019 MLXSW_REG_MTBR_NO_CONN = 0x8000,
10020 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
10021 MLXSW_REG_MTBR_INDEX_NA = 0x8002,
10022 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
10025 /* Base index for reading modules temperature */
10026 #define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
10028 static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
10029 u16 *p_temp, u16 *p_max_temp)
10032 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
10034 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
10037 /* MCIA - Management Cable Info Access
10038 * -----------------------------------
10039 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
10042 #define MLXSW_REG_MCIA_ID 0x9014
10043 #define MLXSW_REG_MCIA_LEN 0x40
10045 MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
10048 * Lock bit. Setting this bit will lock the access to the specific
10049 * cable. Used for updating a full page in a cable EPROM. Any access
10050 * other then subsequence writes will fail while the port is locked.
10053 MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
10059 MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
10061 /* reg_mcia_slot_index
10062 * Slot index (0: Main board)
10065 MLXSW_ITEM32(reg, mcia, slot, 0x00, 12, 4);
10068 MLXSW_REG_MCIA_STATUS_GOOD = 0,
10069 /* No response from module's EEPROM. */
10070 MLXSW_REG_MCIA_STATUS_NO_EEPROM_MODULE = 1,
10071 /* Module type not supported by the device. */
10072 MLXSW_REG_MCIA_STATUS_MODULE_NOT_SUPPORTED = 2,
10073 /* No module present indication. */
10074 MLXSW_REG_MCIA_STATUS_MODULE_NOT_CONNECTED = 3,
10075 /* Error occurred while trying to access module's EEPROM using I2C. */
10076 MLXSW_REG_MCIA_STATUS_I2C_ERROR = 9,
10077 /* Module is disabled. */
10078 MLXSW_REG_MCIA_STATUS_MODULE_DISABLED = 16,
10085 MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
10087 /* reg_mcia_i2c_device_address
10088 * I2C device address.
10091 MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
10093 /* reg_mcia_page_number
10097 MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
10099 /* reg_mcia_device_address
10103 MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
10105 /* reg_mcia_bank_number
10109 MLXSW_ITEM32(reg, mcia, bank_number, 0x08, 16, 8);
10112 * Number of bytes to read/write (up to 48 bytes).
10115 MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
10117 #define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
10118 #define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
10119 #define MLXSW_REG_MCIA_EEPROM_SIZE 48
10120 #define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
10121 #define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
10122 #define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
10123 #define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
10124 #define MLXSW_REG_MCIA_TH_PAGE_NUM 3
10125 #define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
10126 #define MLXSW_REG_MCIA_PAGE0_LO 0
10127 #define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
10128 #define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
10130 enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
10131 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
10132 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
10133 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
10136 enum mlxsw_reg_mcia_eeprom_module_info_id {
10137 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
10138 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
10139 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
10140 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
10141 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
10142 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP = 0x19,
10145 enum mlxsw_reg_mcia_eeprom_module_info {
10146 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
10147 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
10148 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
10149 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
10153 * Bytes to read/write.
10156 MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
10158 /* This is used to access the optional upper pages (1-3) in the QSFP+
10159 * memory map. Page 1 is available on offset 256 through 383, page 2 -
10160 * on offset 384 through 511, page 3 - on offset 512 through 639.
10162 #define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
10163 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
10164 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
10166 static inline void mlxsw_reg_mcia_pack(char *payload, u8 slot_index, u8 module,
10167 u8 lock, u8 page_number,
10168 u16 device_addr, u8 size,
10169 u8 i2c_device_addr)
10171 MLXSW_REG_ZERO(mcia, payload);
10172 mlxsw_reg_mcia_slot_set(payload, slot_index);
10173 mlxsw_reg_mcia_module_set(payload, module);
10174 mlxsw_reg_mcia_l_set(payload, lock);
10175 mlxsw_reg_mcia_page_number_set(payload, page_number);
10176 mlxsw_reg_mcia_device_address_set(payload, device_addr);
10177 mlxsw_reg_mcia_size_set(payload, size);
10178 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
10181 /* MPAT - Monitoring Port Analyzer Table
10182 * -------------------------------------
10183 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
10184 * For an enabled analyzer, all fields except e (enable) cannot be modified.
10186 #define MLXSW_REG_MPAT_ID 0x901A
10187 #define MLXSW_REG_MPAT_LEN 0x78
10189 MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
10192 * Port Analyzer ID.
10195 MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
10197 /* reg_mpat_session_id
10198 * Mirror Session ID.
10199 * Used for MIRROR_SESSION<i> trap.
10202 MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4);
10204 /* reg_mpat_system_port
10205 * A unique port identifier for the final destination of the packet.
10208 MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
10211 * Enable. Indicating the Port Analyzer is enabled.
10214 MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
10217 * Quality Of Service Mode.
10218 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
10219 * PCP, DEI, DSCP or VL) are configured.
10220 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
10221 * same as in the original packet that has triggered the mirroring. For
10222 * SPAN also the pcp,dei are maintained.
10225 MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
10228 * Best effort mode. Indicates mirroring traffic should not cause packet
10229 * drop or back pressure, but will discard the mirrored packets. Mirrored
10230 * packets will be forwarded on a best effort manner.
10231 * 0: Do not discard mirrored packets
10232 * 1: Discard mirrored packets if causing congestion
10235 MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
10237 enum mlxsw_reg_mpat_span_type {
10238 /* Local SPAN Ethernet.
10239 * The original packet is not encapsulated.
10241 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
10243 /* Remote SPAN Ethernet VLAN.
10244 * The packet is forwarded to the monitoring port on the monitoring
10247 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
10249 /* Encapsulated Remote SPAN Ethernet L3 GRE.
10250 * The packet is encapsulated with GRE header.
10252 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
10255 /* reg_mpat_span_type
10259 MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
10265 MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1);
10271 MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14);
10273 /* Remote SPAN - Ethernet VLAN
10274 * - - - - - - - - - - - - - -
10277 /* reg_mpat_eth_rspan_vid
10278 * Encapsulation header VLAN ID.
10281 MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
10283 /* Encapsulated Remote SPAN - Ethernet L2
10284 * - - - - - - - - - - - - - - - - - - -
10287 enum mlxsw_reg_mpat_eth_rspan_version {
10288 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
10291 /* reg_mpat_eth_rspan_version
10292 * RSPAN mirror header version.
10295 MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
10297 /* reg_mpat_eth_rspan_mac
10298 * Destination MAC address.
10301 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
10303 /* reg_mpat_eth_rspan_tp
10304 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
10307 MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
10309 /* Encapsulated Remote SPAN - Ethernet L3
10310 * - - - - - - - - - - - - - - - - - - -
10313 enum mlxsw_reg_mpat_eth_rspan_protocol {
10314 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
10315 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
10318 /* reg_mpat_eth_rspan_protocol
10319 * SPAN encapsulation protocol.
10322 MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
10324 /* reg_mpat_eth_rspan_ttl
10325 * Encapsulation header Time-to-Live/HopLimit.
10328 MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
10330 /* reg_mpat_eth_rspan_smac
10331 * Source MAC address
10334 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
10336 /* reg_mpat_eth_rspan_dip*
10337 * Destination IP address. The IP version is configured by protocol.
10340 MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
10341 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
10343 /* reg_mpat_eth_rspan_sip*
10344 * Source IP address. The IP version is configured by protocol.
10347 MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
10348 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
10350 static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
10351 u16 system_port, bool e,
10352 enum mlxsw_reg_mpat_span_type span_type)
10354 MLXSW_REG_ZERO(mpat, payload);
10355 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
10356 mlxsw_reg_mpat_system_port_set(payload, system_port);
10357 mlxsw_reg_mpat_e_set(payload, e);
10358 mlxsw_reg_mpat_qos_set(payload, 1);
10359 mlxsw_reg_mpat_be_set(payload, 1);
10360 mlxsw_reg_mpat_span_type_set(payload, span_type);
10363 static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
10365 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
10369 mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
10370 enum mlxsw_reg_mpat_eth_rspan_version version,
10374 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
10375 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
10376 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
10380 mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
10384 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
10385 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
10386 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
10387 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
10388 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
10389 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
10393 mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
10395 struct in6_addr sip, struct in6_addr dip)
10397 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
10398 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
10399 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
10400 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
10401 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
10402 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
10405 /* MPAR - Monitoring Port Analyzer Register
10406 * ----------------------------------------
10407 * MPAR register is used to query and configure the port analyzer port mirroring
10410 #define MLXSW_REG_MPAR_ID 0x901B
10411 #define MLXSW_REG_MPAR_LEN 0x0C
10413 MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
10415 /* reg_mpar_local_port
10416 * The local port to mirror the packets from.
10419 MLXSW_ITEM32_LP(reg, mpar, 0x00, 16, 0x00, 4);
10421 enum mlxsw_reg_mpar_i_e {
10422 MLXSW_REG_MPAR_TYPE_EGRESS,
10423 MLXSW_REG_MPAR_TYPE_INGRESS,
10430 MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
10434 * By default, port mirroring is disabled for all ports.
10437 MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
10440 * Port Analyzer ID.
10443 MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
10445 #define MLXSW_REG_MPAR_RATE_MAX 3500000000UL
10447 /* reg_mpar_probability_rate
10449 * Valid values are: 1 to 3.5*10^9
10450 * Value of 1 means "sample all". Default is 1.
10451 * Reserved when Spectrum-1.
10454 MLXSW_ITEM32(reg, mpar, probability_rate, 0x08, 0, 32);
10456 static inline void mlxsw_reg_mpar_pack(char *payload, u16 local_port,
10457 enum mlxsw_reg_mpar_i_e i_e,
10458 bool enable, u8 pa_id,
10459 u32 probability_rate)
10461 MLXSW_REG_ZERO(mpar, payload);
10462 mlxsw_reg_mpar_local_port_set(payload, local_port);
10463 mlxsw_reg_mpar_enable_set(payload, enable);
10464 mlxsw_reg_mpar_i_e_set(payload, i_e);
10465 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
10466 mlxsw_reg_mpar_probability_rate_set(payload, probability_rate);
10469 /* MGIR - Management General Information Register
10470 * ----------------------------------------------
10471 * MGIR register allows software to query the hardware and firmware general
10474 #define MLXSW_REG_MGIR_ID 0x9020
10475 #define MLXSW_REG_MGIR_LEN 0x9C
10477 MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
10479 /* reg_mgir_hw_info_device_hw_revision
10482 MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
10484 #define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
10486 /* reg_mgir_fw_info_psid
10487 * PSID (ASCII string).
10490 MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
10492 /* reg_mgir_fw_info_extended_major
10495 MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
10497 /* reg_mgir_fw_info_extended_minor
10500 MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
10502 /* reg_mgir_fw_info_extended_sub_minor
10505 MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
10507 static inline void mlxsw_reg_mgir_pack(char *payload)
10509 MLXSW_REG_ZERO(mgir, payload);
10513 mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
10514 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
10516 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
10517 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
10518 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
10519 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
10520 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
10523 /* MRSR - Management Reset and Shutdown Register
10524 * ---------------------------------------------
10525 * MRSR register is used to reset or shutdown the switch or
10526 * the entire system (when applicable).
10528 #define MLXSW_REG_MRSR_ID 0x9023
10529 #define MLXSW_REG_MRSR_LEN 0x08
10531 MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
10533 /* reg_mrsr_command
10534 * Reset/shutdown command
10536 * 1 - software reset
10539 MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
10541 static inline void mlxsw_reg_mrsr_pack(char *payload)
10543 MLXSW_REG_ZERO(mrsr, payload);
10544 mlxsw_reg_mrsr_command_set(payload, 1);
10547 /* MLCR - Management LED Control Register
10548 * --------------------------------------
10549 * Controls the system LEDs.
10551 #define MLXSW_REG_MLCR_ID 0x902B
10552 #define MLXSW_REG_MLCR_LEN 0x0C
10554 MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
10556 /* reg_mlcr_local_port
10557 * Local port number.
10560 MLXSW_ITEM32_LP(reg, mlcr, 0x00, 16, 0x00, 24);
10562 #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
10564 /* reg_mlcr_beacon_duration
10565 * Duration of the beacon to be active, in seconds.
10566 * 0x0 - Will turn off the beacon.
10567 * 0xFFFF - Will turn on the beacon until explicitly turned off.
10570 MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
10572 /* reg_mlcr_beacon_remain
10573 * Remaining duration of the beacon, in seconds.
10574 * 0xFFFF indicates an infinite amount of time.
10577 MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
10579 static inline void mlxsw_reg_mlcr_pack(char *payload, u16 local_port,
10582 MLXSW_REG_ZERO(mlcr, payload);
10583 mlxsw_reg_mlcr_local_port_set(payload, local_port);
10584 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
10585 MLXSW_REG_MLCR_DURATION_MAX : 0);
10588 /* MCION - Management Cable IO and Notifications Register
10589 * ------------------------------------------------------
10590 * The MCION register is used to query transceiver modules' IO pins and other
10593 #define MLXSW_REG_MCION_ID 0x9052
10594 #define MLXSW_REG_MCION_LEN 0x18
10596 MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN);
10598 /* reg_mcion_module
10602 MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8);
10604 /* reg_mcion_slot_index
10608 MLXSW_ITEM32(reg, mcion, slot_index, 0x00, 12, 4);
10611 MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0),
10612 MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8),
10615 /* reg_mcion_module_status_bits
10616 * Module IO status as defined by SFF.
10619 MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16);
10621 static inline void mlxsw_reg_mcion_pack(char *payload, u8 slot_index, u8 module)
10623 MLXSW_REG_ZERO(mcion, payload);
10624 mlxsw_reg_mcion_slot_index_set(payload, slot_index);
10625 mlxsw_reg_mcion_module_set(payload, module);
10628 /* MTPPS - Management Pulse Per Second Register
10629 * --------------------------------------------
10630 * This register provides the device PPS capabilities, configure the PPS in and
10631 * out modules and holds the PPS in time stamp.
10633 #define MLXSW_REG_MTPPS_ID 0x9053
10634 #define MLXSW_REG_MTPPS_LEN 0x3C
10636 MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
10638 /* reg_mtpps_enable
10639 * Enables the PPS functionality the specific pin.
10640 * A boolean variable.
10643 MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
10645 enum mlxsw_reg_mtpps_pin_mode {
10646 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
10649 /* reg_mtpps_pin_mode
10650 * Pin mode to be used. The mode must comply with the supported modes of the
10654 MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
10656 #define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
10659 * Pin to be configured or queried out of the supported pins.
10662 MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
10664 /* reg_mtpps_time_stamp
10665 * When pin_mode = pps_in, the latched device time when it was triggered from
10666 * the external GPIO pin.
10667 * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target
10668 * time to generate next output signal.
10669 * Time is in units of device clock.
10672 MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
10675 mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
10677 MLXSW_REG_ZERO(mtpps, payload);
10678 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
10679 mlxsw_reg_mtpps_pin_mode_set(payload,
10680 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
10681 mlxsw_reg_mtpps_enable_set(payload, true);
10682 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
10685 /* MTUTC - Management UTC Register
10686 * -------------------------------
10687 * Configures the HW UTC counter.
10689 #define MLXSW_REG_MTUTC_ID 0x9055
10690 #define MLXSW_REG_MTUTC_LEN 0x1C
10692 MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
10694 enum mlxsw_reg_mtutc_operation {
10695 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
10696 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
10699 /* reg_mtutc_operation
10703 MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
10705 /* reg_mtutc_freq_adjustment
10706 * Frequency adjustment: Every PPS the HW frequency will be
10707 * adjusted by this value. Units of HW clock, where HW counts
10708 * 10^9 HW clocks for 1 HW second.
10711 MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
10713 /* reg_mtutc_utc_sec
10717 MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
10720 mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
10721 u32 freq_adj, u32 utc_sec)
10723 MLXSW_REG_ZERO(mtutc, payload);
10724 mlxsw_reg_mtutc_operation_set(payload, oper);
10725 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
10726 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
10729 /* MCQI - Management Component Query Information
10730 * ---------------------------------------------
10731 * This register allows querying information about firmware components.
10733 #define MLXSW_REG_MCQI_ID 0x9061
10734 #define MLXSW_REG_MCQI_BASE_LEN 0x18
10735 #define MLXSW_REG_MCQI_CAP_LEN 0x14
10736 #define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
10738 MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
10740 /* reg_mcqi_component_index
10741 * Index of the accessed component.
10744 MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
10746 enum mlxfw_reg_mcqi_info_type {
10747 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
10750 /* reg_mcqi_info_type
10751 * Component properties set.
10754 MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
10757 * The requested/returned data offset from the section start, given in bytes.
10758 * Must be DWORD aligned.
10761 MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
10763 /* reg_mcqi_data_size
10764 * The requested/returned data size, given in bytes. If data_size is not DWORD
10765 * aligned, the last bytes are zero padded.
10768 MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
10770 /* reg_mcqi_cap_max_component_size
10771 * Maximum size for this component, given in bytes.
10774 MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
10776 /* reg_mcqi_cap_log_mcda_word_size
10777 * Log 2 of the access word size in bytes. Read and write access must be aligned
10778 * to the word size. Write access must be done for an integer number of words.
10781 MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
10783 /* reg_mcqi_cap_mcda_max_write_size
10784 * Maximal write size for MCDA register
10787 MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
10789 static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
10791 MLXSW_REG_ZERO(mcqi, payload);
10792 mlxsw_reg_mcqi_component_index_set(payload, component_index);
10793 mlxsw_reg_mcqi_info_type_set(payload,
10794 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
10795 mlxsw_reg_mcqi_offset_set(payload, 0);
10796 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
10799 static inline void mlxsw_reg_mcqi_unpack(char *payload,
10800 u32 *p_cap_max_component_size,
10801 u8 *p_cap_log_mcda_word_size,
10802 u16 *p_cap_mcda_max_write_size)
10804 *p_cap_max_component_size =
10805 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
10806 *p_cap_log_mcda_word_size =
10807 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
10808 *p_cap_mcda_max_write_size =
10809 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
10812 /* MCC - Management Component Control
10813 * ----------------------------------
10814 * Controls the firmware component and updates the FSM.
10816 #define MLXSW_REG_MCC_ID 0x9062
10817 #define MLXSW_REG_MCC_LEN 0x1C
10819 MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
10821 enum mlxsw_reg_mcc_instruction {
10822 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
10823 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
10824 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
10825 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
10826 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
10827 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
10830 /* reg_mcc_instruction
10831 * Command to be executed by the FSM.
10832 * Applicable for write operation only.
10835 MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
10837 /* reg_mcc_component_index
10838 * Index of the accessed component. Applicable only for commands that
10839 * refer to components. Otherwise, this field is reserved.
10842 MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
10844 /* reg_mcc_update_handle
10845 * Token representing the current flow executed by the FSM.
10848 MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
10850 /* reg_mcc_error_code
10851 * Indicates the successful completion of the instruction, or the reason it
10855 MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
10857 /* reg_mcc_control_state
10858 * Current FSM state
10861 MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
10863 /* reg_mcc_component_size
10864 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
10865 * the size may shorten the update time. Value 0x0 means that size is
10869 MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
10871 static inline void mlxsw_reg_mcc_pack(char *payload,
10872 enum mlxsw_reg_mcc_instruction instr,
10873 u16 component_index, u32 update_handle,
10874 u32 component_size)
10876 MLXSW_REG_ZERO(mcc, payload);
10877 mlxsw_reg_mcc_instruction_set(payload, instr);
10878 mlxsw_reg_mcc_component_index_set(payload, component_index);
10879 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
10880 mlxsw_reg_mcc_component_size_set(payload, component_size);
10883 static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
10884 u8 *p_error_code, u8 *p_control_state)
10886 if (p_update_handle)
10887 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
10889 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
10890 if (p_control_state)
10891 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
10894 /* MCDA - Management Component Data Access
10895 * ---------------------------------------
10896 * This register allows reading and writing a firmware component.
10898 #define MLXSW_REG_MCDA_ID 0x9063
10899 #define MLXSW_REG_MCDA_BASE_LEN 0x10
10900 #define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
10901 #define MLXSW_REG_MCDA_LEN \
10902 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
10904 MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
10906 /* reg_mcda_update_handle
10907 * Token representing the current flow executed by the FSM.
10910 MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
10913 * Offset of accessed address relative to component start. Accesses must be in
10914 * accordance to log_mcda_word_size in MCQI reg.
10917 MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
10920 * Size of the data accessed, given in bytes.
10923 MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
10926 * Data block accessed.
10929 MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
10931 static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
10932 u32 offset, u16 size, u8 *data)
10936 MLXSW_REG_ZERO(mcda, payload);
10937 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
10938 mlxsw_reg_mcda_offset_set(payload, offset);
10939 mlxsw_reg_mcda_size_set(payload, size);
10941 for (i = 0; i < size / 4; i++)
10942 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
10945 /* MPSC - Monitoring Packet Sampling Configuration Register
10946 * --------------------------------------------------------
10947 * MPSC Register is used to configure the Packet Sampling mechanism.
10949 #define MLXSW_REG_MPSC_ID 0x9080
10950 #define MLXSW_REG_MPSC_LEN 0x1C
10952 MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
10954 /* reg_mpsc_local_port
10955 * Local port number
10956 * Not supported for CPU port
10959 MLXSW_ITEM32_LP(reg, mpsc, 0x00, 16, 0x00, 12);
10962 * Enable sampling on port local_port
10965 MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
10967 #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
10970 * Sampling rate = 1 out of rate packets (with randomization around
10971 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
10974 MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
10976 static inline void mlxsw_reg_mpsc_pack(char *payload, u16 local_port, bool e,
10979 MLXSW_REG_ZERO(mpsc, payload);
10980 mlxsw_reg_mpsc_local_port_set(payload, local_port);
10981 mlxsw_reg_mpsc_e_set(payload, e);
10982 mlxsw_reg_mpsc_rate_set(payload, rate);
10985 /* MGPC - Monitoring General Purpose Counter Set Register
10986 * The MGPC register retrieves and sets the General Purpose Counter Set.
10988 #define MLXSW_REG_MGPC_ID 0x9081
10989 #define MLXSW_REG_MGPC_LEN 0x18
10991 MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
10993 /* reg_mgpc_counter_set_type
10994 * Counter set type.
10997 MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
10999 /* reg_mgpc_counter_index
11003 MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
11005 enum mlxsw_reg_mgpc_opcode {
11007 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
11008 /* Clear counters */
11009 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
11016 MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
11018 /* reg_mgpc_byte_counter
11019 * Byte counter value.
11022 MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
11024 /* reg_mgpc_packet_counter
11025 * Packet counter value.
11028 MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
11030 static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
11031 enum mlxsw_reg_mgpc_opcode opcode,
11032 enum mlxsw_reg_flow_counter_set_type set_type)
11034 MLXSW_REG_ZERO(mgpc, payload);
11035 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
11036 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
11037 mlxsw_reg_mgpc_opcode_set(payload, opcode);
11040 /* MPRS - Monitoring Parsing State Register
11041 * ----------------------------------------
11042 * The MPRS register is used for setting up the parsing for hash,
11043 * policy-engine and routing.
11045 #define MLXSW_REG_MPRS_ID 0x9083
11046 #define MLXSW_REG_MPRS_LEN 0x14
11048 MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
11050 /* reg_mprs_parsing_depth
11051 * Minimum parsing depth.
11052 * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL
11053 * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2.
11056 MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
11058 /* reg_mprs_parsing_en
11060 * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and
11061 * NVGRE. Default is enabled. Reserved when SwitchX-2.
11064 MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
11066 /* reg_mprs_vxlan_udp_dport
11067 * VxLAN UDP destination port.
11068 * Used for identifying VxLAN packets and for dport field in
11069 * encapsulation. Default is 4789.
11072 MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
11074 static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
11075 u16 vxlan_udp_dport)
11077 MLXSW_REG_ZERO(mprs, payload);
11078 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
11079 mlxsw_reg_mprs_parsing_en_set(payload, true);
11080 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
11083 /* MOGCR - Monitoring Global Configuration Register
11084 * ------------------------------------------------
11086 #define MLXSW_REG_MOGCR_ID 0x9086
11087 #define MLXSW_REG_MOGCR_LEN 0x20
11089 MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
11091 /* reg_mogcr_ptp_iftc
11092 * PTP Ingress FIFO Trap Clear
11093 * The PTP_ING_FIFO trap provides MTPPTR with clr according
11094 * to this value. Default 0.
11095 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
11098 MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
11100 /* reg_mogcr_ptp_eftc
11101 * PTP Egress FIFO Trap Clear
11102 * The PTP_EGR_FIFO trap provides MTPPTR with clr according
11103 * to this value. Default 0.
11104 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
11107 MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
11109 /* reg_mogcr_mirroring_pid_base
11110 * Base policer id for mirroring policers.
11111 * Must have an even value (e.g. 1000, not 1001).
11112 * Reserved when SwitchX/-2, Switch-IB/2, Spectrum-1 and Quantum.
11115 MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14);
11117 /* MPAGR - Monitoring Port Analyzer Global Register
11118 * ------------------------------------------------
11119 * This register is used for global port analyzer configurations.
11120 * Note: This register is not supported by current FW versions for Spectrum-1.
11122 #define MLXSW_REG_MPAGR_ID 0x9089
11123 #define MLXSW_REG_MPAGR_LEN 0x0C
11125 MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN);
11127 enum mlxsw_reg_mpagr_trigger {
11128 MLXSW_REG_MPAGR_TRIGGER_EGRESS,
11129 MLXSW_REG_MPAGR_TRIGGER_INGRESS,
11130 MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED,
11131 MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER,
11132 MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG,
11133 MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG,
11134 MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN,
11135 MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY,
11138 /* reg_mpagr_trigger
11142 MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4);
11145 * Port analyzer ID.
11148 MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4);
11150 #define MLXSW_REG_MPAGR_RATE_MAX 3500000000UL
11152 /* reg_mpagr_probability_rate
11154 * Valid values are: 1 to 3.5*10^9
11155 * Value of 1 means "sample all". Default is 1.
11158 MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32);
11160 static inline void mlxsw_reg_mpagr_pack(char *payload,
11161 enum mlxsw_reg_mpagr_trigger trigger,
11162 u8 pa_id, u32 probability_rate)
11164 MLXSW_REG_ZERO(mpagr, payload);
11165 mlxsw_reg_mpagr_trigger_set(payload, trigger);
11166 mlxsw_reg_mpagr_pa_id_set(payload, pa_id);
11167 mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate);
11170 /* MOMTE - Monitoring Mirror Trigger Enable Register
11171 * -------------------------------------------------
11172 * This register is used to configure the mirror enable for different mirror
11175 #define MLXSW_REG_MOMTE_ID 0x908D
11176 #define MLXSW_REG_MOMTE_LEN 0x10
11178 MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN);
11180 /* reg_momte_local_port
11181 * Local port number.
11184 MLXSW_ITEM32_LP(reg, momte, 0x00, 16, 0x00, 12);
11186 enum mlxsw_reg_momte_type {
11187 MLXSW_REG_MOMTE_TYPE_WRED = 0x20,
11188 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31,
11189 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32,
11190 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33,
11191 MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40,
11192 MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50,
11193 MLXSW_REG_MOMTE_TYPE_ECN = 0x60,
11194 MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70,
11198 * Type of mirroring.
11201 MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
11203 /* reg_momte_tclass_en
11204 * TClass/PG mirror enable. Each bit represents corresponding tclass.
11205 * 0: disable (default)
11209 MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
11211 static inline void mlxsw_reg_momte_pack(char *payload, u16 local_port,
11212 enum mlxsw_reg_momte_type type)
11214 MLXSW_REG_ZERO(momte, payload);
11215 mlxsw_reg_momte_local_port_set(payload, local_port);
11216 mlxsw_reg_momte_type_set(payload, type);
11219 /* MTPPPC - Time Precision Packet Port Configuration
11220 * -------------------------------------------------
11221 * This register serves for configuration of which PTP messages should be
11222 * timestamped. This is a global configuration, despite the register name.
11224 * Reserved when Spectrum-2.
11226 #define MLXSW_REG_MTPPPC_ID 0x9090
11227 #define MLXSW_REG_MTPPPC_LEN 0x28
11229 MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
11231 /* reg_mtpppc_ing_timestamp_message_type
11232 * Bitwise vector of PTP message types to timestamp at ingress.
11233 * MessageType field as defined by IEEE 1588
11234 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
11238 MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
11240 /* reg_mtpppc_egr_timestamp_message_type
11241 * Bitwise vector of PTP message types to timestamp at egress.
11242 * MessageType field as defined by IEEE 1588
11243 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
11247 MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
11249 static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
11251 MLXSW_REG_ZERO(mtpppc, payload);
11252 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
11253 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
11256 /* MTPPTR - Time Precision Packet Timestamping Reading
11257 * ---------------------------------------------------
11258 * The MTPPTR is used for reading the per port PTP timestamp FIFO.
11259 * There is a trap for packets which are latched to the timestamp FIFO, thus the
11260 * SW knows which FIFO to read. Note that packets enter the FIFO before been
11261 * trapped. The sequence number is used to synchronize the timestamp FIFO
11262 * entries and the trapped packets.
11263 * Reserved when Spectrum-2.
11266 #define MLXSW_REG_MTPPTR_ID 0x9091
11267 #define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */
11268 #define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */
11269 #define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
11270 #define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
11271 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
11273 MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
11275 /* reg_mtpptr_local_port
11276 * Not supported for CPU port.
11279 MLXSW_ITEM32_LP(reg, mtpptr, 0x00, 16, 0x00, 12);
11281 enum mlxsw_reg_mtpptr_dir {
11282 MLXSW_REG_MTPPTR_DIR_INGRESS,
11283 MLXSW_REG_MTPPTR_DIR_EGRESS,
11290 MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
11293 * Clear the records.
11296 MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
11298 /* reg_mtpptr_num_rec
11299 * Number of valid records in the response
11300 * Range 0.. cap_ptp_timestamp_fifo
11303 MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
11305 /* reg_mtpptr_rec_message_type
11306 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
11307 * (e.g. Bit0: Sync, Bit1: Delay_Req)
11310 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
11311 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
11312 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
11314 /* reg_mtpptr_rec_domain_number
11315 * DomainNumber field as defined by IEEE 1588
11318 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
11319 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
11320 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
11322 /* reg_mtpptr_rec_sequence_id
11323 * SequenceId field as defined by IEEE 1588
11326 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
11327 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
11328 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
11330 /* reg_mtpptr_rec_timestamp_high
11331 * Timestamp of when the PTP packet has passed through the port Units of PLL
11333 * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec.
11336 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
11337 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
11338 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
11340 /* reg_mtpptr_rec_timestamp_low
11341 * See rec_timestamp_high.
11344 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
11345 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
11346 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
11348 static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
11350 u8 *p_message_type,
11351 u8 *p_domain_number,
11352 u16 *p_sequence_id,
11355 u32 timestamp_high, timestamp_low;
11357 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
11358 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
11359 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
11360 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
11361 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
11362 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
11365 /* MTPTPT - Monitoring Precision Time Protocol Trap Register
11366 * ---------------------------------------------------------
11367 * This register is used for configuring under which trap to deliver PTP
11368 * packets depending on type of the packet.
11370 #define MLXSW_REG_MTPTPT_ID 0x9092
11371 #define MLXSW_REG_MTPTPT_LEN 0x08
11373 MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
11375 enum mlxsw_reg_mtptpt_trap_id {
11376 MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
11377 MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
11380 /* reg_mtptpt_trap_id
11384 MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
11386 /* reg_mtptpt_message_type
11387 * Bitwise vector of PTP message types to trap. This is a necessary but
11388 * non-sufficient condition since need to enable also per port. See MTPPPC.
11389 * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g.
11390 * Bit0: Sync, Bit1: Delay_Req)
11392 MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
11394 static inline void mlxsw_reg_mtptptp_pack(char *payload,
11395 enum mlxsw_reg_mtptpt_trap_id trap_id,
11398 MLXSW_REG_ZERO(mtptpt, payload);
11399 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
11400 mlxsw_reg_mtptpt_message_type_set(payload, message_type);
11403 /* MFGD - Monitoring FW General Debug Register
11404 * -------------------------------------------
11406 #define MLXSW_REG_MFGD_ID 0x90F0
11407 #define MLXSW_REG_MFGD_LEN 0x0C
11409 MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN);
11411 /* reg_mfgd_fw_fatal_event_mode
11412 * 0 - don't check FW fatal (default)
11413 * 1 - check FW fatal - enable MFDE trap
11416 MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2);
11418 /* reg_mfgd_trigger_test
11421 MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1);
11423 /* MGPIR - Management General Peripheral Information Register
11424 * ----------------------------------------------------------
11425 * MGPIR register allows software to query the hardware and
11426 * firmware general information of peripheral entities.
11428 #define MLXSW_REG_MGPIR_ID 0x9100
11429 #define MLXSW_REG_MGPIR_LEN 0xA0
11431 MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
11433 enum mlxsw_reg_mgpir_device_type {
11434 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
11435 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
11438 /* mgpir_slot_index
11439 * Slot index (0: Main board).
11442 MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
11444 /* mgpir_device_type
11447 MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
11449 /* mgpir_devices_per_flash
11450 * Number of devices of device_type per flash (can be shared by few devices).
11453 MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
11455 /* mgpir_num_of_devices
11456 * Number of devices of device_type.
11459 MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
11461 /* max_modules_per_slot
11462 * Maximum number of modules that can be connected per slot.
11465 MLXSW_ITEM32(reg, mgpir, max_modules_per_slot, 0x04, 16, 8);
11467 /* mgpir_num_of_slots
11468 * Number of slots in the system.
11471 MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
11473 /* mgpir_num_of_modules
11474 * Number of modules.
11477 MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
11479 static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
11481 MLXSW_REG_ZERO(mgpir, payload);
11482 mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
11486 mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
11487 enum mlxsw_reg_mgpir_device_type *device_type,
11488 u8 *devices_per_flash, u8 *num_of_modules,
11491 if (num_of_devices)
11492 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
11494 *device_type = mlxsw_reg_mgpir_device_type_get(payload);
11495 if (devices_per_flash)
11496 *devices_per_flash =
11497 mlxsw_reg_mgpir_devices_per_flash_get(payload);
11498 if (num_of_modules)
11499 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
11501 *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
11504 /* MBCT - Management Binary Code Transfer Register
11505 * -----------------------------------------------
11506 * This register allows to transfer binary codes from the host to
11507 * the management FW by transferring it by chunks of maximum 1KB.
11509 #define MLXSW_REG_MBCT_ID 0x9120
11510 #define MLXSW_REG_MBCT_LEN 0x420
11512 MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN);
11514 /* reg_mbct_slot_index
11515 * Slot index. 0 is reserved.
11518 MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4);
11520 /* reg_mbct_data_size
11521 * Actual data field size in bytes for the current data transfer.
11524 MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11);
11526 enum mlxsw_reg_mbct_op {
11527 MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1,
11528 MLXSW_REG_MBCT_OP_DATA_TRANSFER, /* Download */
11529 MLXSW_REG_MBCT_OP_ACTIVATE,
11530 MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6,
11531 MLXSW_REG_MBCT_OP_QUERY_STATUS,
11537 MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4);
11540 * Indicates that the current data field is the last chunk of the INI.
11543 MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1);
11546 * Opcode Event Enable. When set a BCTOE event will be sent once the opcode
11547 * was executed and the fsm_state has changed.
11550 MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1);
11552 enum mlxsw_reg_mbct_status {
11553 /* Partial data transfer completed successfully and ready for next
11556 MLXSW_REG_MBCT_STATUS_PART_DATA = 2,
11557 MLXSW_REG_MBCT_STATUS_LAST_DATA,
11558 MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE,
11559 /* Error - trying to erase INI while it being used. */
11560 MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE,
11561 /* Last data transfer completed, applying magic pattern. */
11562 MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7,
11563 MLXSW_REG_MBCT_STATUS_INI_ERROR,
11564 MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED,
11565 MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11,
11572 MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5);
11574 enum mlxsw_reg_mbct_fsm_state {
11575 MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5,
11576 MLXSW_REG_MBCT_FSM_STATE_ERROR,
11579 /* reg_mbct_fsm_state
11583 MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4);
11585 #define MLXSW_REG_MBCT_DATA_LEN 1024
11588 * Up to 1KB of data.
11591 MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN);
11593 static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index,
11594 enum mlxsw_reg_mbct_op op, bool oee)
11596 MLXSW_REG_ZERO(mbct, payload);
11597 mlxsw_reg_mbct_slot_index_set(payload, slot_index);
11598 mlxsw_reg_mbct_op_set(payload, op);
11599 mlxsw_reg_mbct_oee_set(payload, oee);
11602 static inline void mlxsw_reg_mbct_dt_pack(char *payload,
11603 u16 data_size, bool last,
11606 if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN))
11608 mlxsw_reg_mbct_data_size_set(payload, data_size);
11609 mlxsw_reg_mbct_last_set(payload, last);
11610 mlxsw_reg_mbct_data_memcpy_to(payload, data);
11614 mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
11615 enum mlxsw_reg_mbct_status *p_status,
11616 enum mlxsw_reg_mbct_fsm_state *p_fsm_state)
11619 *p_slot_index = mlxsw_reg_mbct_slot_index_get(payload);
11620 *p_status = mlxsw_reg_mbct_status_get(payload);
11622 *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
11625 /* MDDQ - Management DownStream Device Query Register
11626 * --------------------------------------------------
11627 * This register allows to query the DownStream device properties. The desired
11628 * information is chosen upon the query_type field and is delivered by 32B
11631 #define MLXSW_REG_MDDQ_ID 0x9161
11632 #define MLXSW_REG_MDDQ_LEN 0x30
11634 MLXSW_REG_DEFINE(mddq, MLXSW_REG_MDDQ_ID, MLXSW_REG_MDDQ_LEN);
11637 * Slot info event enable.
11638 * When set to '1', each change in the slot_info.provisioned / sr_valid /
11639 * active / ready will generate a DSDSC event.
11642 MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1);
11644 enum mlxsw_reg_mddq_query_type {
11645 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1,
11646 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME = 3,
11649 /* reg_mddq_query_type
11652 MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8);
11654 /* reg_mddq_slot_index
11655 * Slot index. 0 is reserved.
11658 MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4);
11660 /* reg_mddq_slot_info_provisioned
11661 * If set, the INI file is applied and the card is provisioned.
11664 MLXSW_ITEM32(reg, mddq, slot_info_provisioned, 0x10, 31, 1);
11666 /* reg_mddq_slot_info_sr_valid
11667 * If set, Shift Register is valid (after being provisioned) and data
11668 * can be sent from the switch ASIC to the line-card CPLD over Shift-Register.
11671 MLXSW_ITEM32(reg, mddq, slot_info_sr_valid, 0x10, 30, 1);
11673 enum mlxsw_reg_mddq_slot_info_ready {
11674 MLXSW_REG_MDDQ_SLOT_INFO_READY_NOT_READY,
11675 MLXSW_REG_MDDQ_SLOT_INFO_READY_READY,
11676 MLXSW_REG_MDDQ_SLOT_INFO_READY_ERROR,
11679 /* reg_mddq_slot_info_lc_ready
11680 * If set, the LC is powered on, matching the INI version and a new FW
11681 * version can be burnt (if necessary).
11684 MLXSW_ITEM32(reg, mddq, slot_info_lc_ready, 0x10, 28, 2);
11686 /* reg_mddq_slot_info_active
11687 * If set, the FW has completed the MDDC.device_enable command.
11690 MLXSW_ITEM32(reg, mddq, slot_info_active, 0x10, 27, 1);
11692 /* reg_mddq_slot_info_hw_revision
11693 * Major user-configured version number of the current INI file.
11694 * Valid only when active or ready are '1'.
11697 MLXSW_ITEM32(reg, mddq, slot_info_hw_revision, 0x14, 16, 16);
11699 /* reg_mddq_slot_info_ini_file_version
11700 * User-configured version number of the current INI file.
11701 * Valid only when active or lc_ready are '1'.
11704 MLXSW_ITEM32(reg, mddq, slot_info_ini_file_version, 0x14, 0, 16);
11706 /* reg_mddq_slot_info_card_type
11709 MLXSW_ITEM32(reg, mddq, slot_info_card_type, 0x18, 0, 8);
11712 __mlxsw_reg_mddq_pack(char *payload, u8 slot_index,
11713 enum mlxsw_reg_mddq_query_type query_type)
11715 MLXSW_REG_ZERO(mddq, payload);
11716 mlxsw_reg_mddq_slot_index_set(payload, slot_index);
11717 mlxsw_reg_mddq_query_type_set(payload, query_type);
11721 mlxsw_reg_mddq_slot_info_pack(char *payload, u8 slot_index, bool sie)
11723 __mlxsw_reg_mddq_pack(payload, slot_index,
11724 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO);
11725 mlxsw_reg_mddq_sie_set(payload, sie);
11729 mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index,
11730 bool *p_provisioned, bool *p_sr_valid,
11731 enum mlxsw_reg_mddq_slot_info_ready *p_lc_ready,
11732 bool *p_active, u16 *p_hw_revision,
11733 u16 *p_ini_file_version,
11736 *p_slot_index = mlxsw_reg_mddq_slot_index_get(payload);
11737 *p_provisioned = mlxsw_reg_mddq_slot_info_provisioned_get(payload);
11738 *p_sr_valid = mlxsw_reg_mddq_slot_info_sr_valid_get(payload);
11739 *p_lc_ready = mlxsw_reg_mddq_slot_info_lc_ready_get(payload);
11740 *p_active = mlxsw_reg_mddq_slot_info_active_get(payload);
11741 *p_hw_revision = mlxsw_reg_mddq_slot_info_hw_revision_get(payload);
11742 *p_ini_file_version = mlxsw_reg_mddq_slot_info_ini_file_version_get(payload);
11743 *p_card_type = mlxsw_reg_mddq_slot_info_card_type_get(payload);
11746 #define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20
11748 /* reg_mddq_slot_ascii_name
11749 * Slot's ASCII name.
11752 MLXSW_ITEM_BUF(reg, mddq, slot_ascii_name, 0x10,
11753 MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN);
11756 mlxsw_reg_mddq_slot_name_pack(char *payload, u8 slot_index)
11758 __mlxsw_reg_mddq_pack(payload, slot_index,
11759 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME);
11763 mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name)
11765 mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name);
11768 /* MDDC - Management DownStream Device Control Register
11769 * ----------------------------------------------------
11770 * This register allows to control downstream devices and line cards.
11772 #define MLXSW_REG_MDDC_ID 0x9163
11773 #define MLXSW_REG_MDDC_LEN 0x30
11775 MLXSW_REG_DEFINE(mddc, MLXSW_REG_MDDC_ID, MLXSW_REG_MDDC_LEN);
11777 /* reg_mddc_slot_index
11778 * Slot index. 0 is reserved.
11781 MLXSW_ITEM32(reg, mddc, slot_index, 0x00, 0, 4);
11787 MLXSW_ITEM32(reg, mddc, rst, 0x04, 29, 1);
11789 /* reg_mddc_device_enable
11790 * When set, FW is the manager and allowed to program the downstream device.
11793 MLXSW_ITEM32(reg, mddc, device_enable, 0x04, 28, 1);
11795 static inline void mlxsw_reg_mddc_pack(char *payload, u8 slot_index, bool rst,
11796 bool device_enable)
11798 MLXSW_REG_ZERO(mddc, payload);
11799 mlxsw_reg_mddc_slot_index_set(payload, slot_index);
11800 mlxsw_reg_mddc_rst_set(payload, rst);
11801 mlxsw_reg_mddc_device_enable_set(payload, device_enable);
11804 /* MFDE - Monitoring FW Debug Register
11805 * -----------------------------------
11807 #define MLXSW_REG_MFDE_ID 0x9200
11808 #define MLXSW_REG_MFDE_LEN 0x30
11810 MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN);
11812 /* reg_mfde_irisc_id
11813 * Which irisc triggered the event
11816 MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 24, 8);
11818 enum mlxsw_reg_mfde_severity {
11819 /* Unrecoverable switch behavior */
11820 MLXSW_REG_MFDE_SEVERITY_FATL = 2,
11821 /* Unexpected state with possible systemic failure */
11822 MLXSW_REG_MFDE_SEVERITY_NRML = 3,
11823 /* Unexpected state without systemic failure */
11824 MLXSW_REG_MFDE_SEVERITY_INTR = 5,
11827 /* reg_mfde_severity
11828 * The severity of the event.
11831 MLXSW_ITEM32(reg, mfde, severity, 0x00, 16, 8);
11833 enum mlxsw_reg_mfde_event_id {
11834 /* CRspace timeout */
11835 MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1,
11836 /* KVD insertion machine stopped */
11837 MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP,
11838 /* Triggered by MFGD.trigger_test */
11839 MLXSW_REG_MFDE_EVENT_ID_TEST,
11840 /* Triggered when firmware hits an assert */
11841 MLXSW_REG_MFDE_EVENT_ID_FW_ASSERT,
11842 /* Fatal error interrupt from hardware */
11843 MLXSW_REG_MFDE_EVENT_ID_FATAL_CAUSE,
11846 /* reg_mfde_event_id
11849 MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 16);
11851 enum mlxsw_reg_mfde_method {
11852 MLXSW_REG_MFDE_METHOD_QUERY,
11853 MLXSW_REG_MFDE_METHOD_WRITE,
11859 MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1);
11861 /* reg_mfde_long_process
11862 * Indicates if the command is in long_process mode.
11865 MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1);
11867 enum mlxsw_reg_mfde_command_type {
11868 MLXSW_REG_MFDE_COMMAND_TYPE_MAD,
11869 MLXSW_REG_MFDE_COMMAND_TYPE_EMAD,
11870 MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF,
11873 /* reg_mfde_command_type
11876 MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2);
11878 /* reg_mfde_reg_attr_id
11879 * EMAD - register id, MAD - attibute id
11882 MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16);
11884 /* reg_mfde_crspace_to_log_address
11885 * crspace address accessed, which resulted in timeout.
11888 MLXSW_ITEM32(reg, mfde, crspace_to_log_address, 0x10, 0, 32);
11890 /* reg_mfde_crspace_to_oe
11892 * 1 - Old event, occurred before MFGD activation.
11895 MLXSW_ITEM32(reg, mfde, crspace_to_oe, 0x14, 24, 1);
11897 /* reg_mfde_crspace_to_log_id
11898 * Which irisc triggered the timeout.
11901 MLXSW_ITEM32(reg, mfde, crspace_to_log_id, 0x14, 0, 4);
11903 /* reg_mfde_crspace_to_log_ip
11904 * IP (instruction pointer) that triggered the timeout.
11907 MLXSW_ITEM64(reg, mfde, crspace_to_log_ip, 0x18, 0, 64);
11909 /* reg_mfde_kvd_im_stop_oe
11911 * 1 - Old event, occurred before MFGD activation.
11914 MLXSW_ITEM32(reg, mfde, kvd_im_stop_oe, 0x10, 24, 1);
11916 /* reg_mfde_kvd_im_stop_pipes_mask
11917 * Bit per kvh pipe.
11920 MLXSW_ITEM32(reg, mfde, kvd_im_stop_pipes_mask, 0x10, 0, 16);
11922 /* reg_mfde_fw_assert_var0-4
11923 * Variables passed to assert.
11926 MLXSW_ITEM32(reg, mfde, fw_assert_var0, 0x10, 0, 32);
11927 MLXSW_ITEM32(reg, mfde, fw_assert_var1, 0x14, 0, 32);
11928 MLXSW_ITEM32(reg, mfde, fw_assert_var2, 0x18, 0, 32);
11929 MLXSW_ITEM32(reg, mfde, fw_assert_var3, 0x1C, 0, 32);
11930 MLXSW_ITEM32(reg, mfde, fw_assert_var4, 0x20, 0, 32);
11932 /* reg_mfde_fw_assert_existptr
11933 * The instruction pointer when assert was triggered.
11936 MLXSW_ITEM32(reg, mfde, fw_assert_existptr, 0x24, 0, 32);
11938 /* reg_mfde_fw_assert_callra
11939 * The return address after triggering assert.
11942 MLXSW_ITEM32(reg, mfde, fw_assert_callra, 0x28, 0, 32);
11944 /* reg_mfde_fw_assert_oe
11946 * 1 - Old event, occurred before MFGD activation.
11949 MLXSW_ITEM32(reg, mfde, fw_assert_oe, 0x2C, 24, 1);
11951 /* reg_mfde_fw_assert_tile_v
11952 * 0: The assert was from main
11953 * 1: The assert was from a tile
11956 MLXSW_ITEM32(reg, mfde, fw_assert_tile_v, 0x2C, 23, 1);
11958 /* reg_mfde_fw_assert_tile_index
11959 * When tile_v=1, the tile_index that caused the assert.
11962 MLXSW_ITEM32(reg, mfde, fw_assert_tile_index, 0x2C, 16, 6);
11964 /* reg_mfde_fw_assert_ext_synd
11965 * A generated one-to-one identifier which is specific per-assert.
11968 MLXSW_ITEM32(reg, mfde, fw_assert_ext_synd, 0x2C, 0, 16);
11970 /* reg_mfde_fatal_cause_id
11971 * HW interrupt cause id.
11974 MLXSW_ITEM32(reg, mfde, fatal_cause_id, 0x10, 0, 18);
11976 /* reg_mfde_fatal_cause_tile_v
11977 * 0: The assert was from main
11978 * 1: The assert was from a tile
11981 MLXSW_ITEM32(reg, mfde, fatal_cause_tile_v, 0x14, 23, 1);
11983 /* reg_mfde_fatal_cause_tile_index
11984 * When tile_v=1, the tile_index that caused the assert.
11987 MLXSW_ITEM32(reg, mfde, fatal_cause_tile_index, 0x14, 16, 6);
11989 /* TNGCR - Tunneling NVE General Configuration Register
11990 * ----------------------------------------------------
11991 * The TNGCR register is used for setting up the NVE Tunneling configuration.
11993 #define MLXSW_REG_TNGCR_ID 0xA001
11994 #define MLXSW_REG_TNGCR_LEN 0x44
11996 MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
11998 enum mlxsw_reg_tngcr_type {
11999 MLXSW_REG_TNGCR_TYPE_VXLAN,
12000 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
12001 MLXSW_REG_TNGCR_TYPE_GENEVE,
12002 MLXSW_REG_TNGCR_TYPE_NVGRE,
12006 * Tunnel type for encapsulation and decapsulation. The types are mutually
12008 * Note: For Spectrum the NVE parsing must be enabled in MPRS.
12011 MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
12013 /* reg_tngcr_nve_valid
12014 * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation.
12017 MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
12019 /* reg_tngcr_nve_ttl_uc
12020 * The TTL for NVE tunnel encapsulation underlay unicast packets.
12023 MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
12025 /* reg_tngcr_nve_ttl_mc
12026 * The TTL for NVE tunnel encapsulation underlay multicast packets.
12029 MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
12032 /* Do not copy flow label. Calculate flow label using nve_flh. */
12033 MLXSW_REG_TNGCR_FL_NO_COPY,
12034 /* Copy flow label from inner packet if packet is IPv6 and
12035 * encapsulation is by IPv6. Otherwise, calculate flow label using
12038 MLXSW_REG_TNGCR_FL_COPY,
12041 /* reg_tngcr_nve_flc
12042 * For NVE tunnel encapsulation: Flow label copy from inner packet.
12045 MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
12048 /* Flow label is static. In Spectrum this means '0'. Spectrum-2
12049 * uses {nve_fl_prefix, nve_fl_suffix}.
12051 MLXSW_REG_TNGCR_FL_NO_HASH,
12052 /* 8 LSBs of the flow label are calculated from ECMP hash of the
12053 * inner packet. 12 MSBs are configured by nve_fl_prefix.
12055 MLXSW_REG_TNGCR_FL_HASH,
12058 /* reg_tngcr_nve_flh
12059 * NVE flow label hash.
12062 MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
12064 /* reg_tngcr_nve_fl_prefix
12065 * NVE flow label prefix. Constant 12 MSBs of the flow label.
12068 MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
12070 /* reg_tngcr_nve_fl_suffix
12071 * NVE flow label suffix. Constant 8 LSBs of the flow label.
12072 * Reserved when nve_flh=1 and for Spectrum.
12075 MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
12078 /* Source UDP port is fixed (default '0') */
12079 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
12080 /* Source UDP port is calculated based on hash */
12081 MLXSW_REG_TNGCR_UDP_SPORT_HASH,
12084 /* reg_tngcr_nve_udp_sport_type
12085 * NVE UDP source port type.
12086 * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2).
12087 * When the source UDP port is calculated based on hash, then the 8 LSBs
12088 * are calculated from hash the 8 MSBs are configured by
12089 * nve_udp_sport_prefix.
12092 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
12094 /* reg_tngcr_nve_udp_sport_prefix
12095 * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port.
12096 * Reserved when NVE type is NVGRE.
12099 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
12101 /* reg_tngcr_nve_group_size_mc
12102 * The amount of sequential linked lists of MC entries. The first linked
12103 * list is configured by SFD.underlay_mc_ptr.
12104 * Valid values: 1, 2, 4, 8, 16, 32, 64
12105 * The linked list are configured by TNUMT.
12106 * The hash is set by LAG hash.
12109 MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
12111 /* reg_tngcr_nve_group_size_flood
12112 * The amount of sequential linked lists of flooding entries. The first
12113 * linked list is configured by SFMR.nve_tunnel_flood_ptr
12114 * Valid values: 1, 2, 4, 8, 16, 32, 64
12115 * The linked list are configured by TNUMT.
12116 * The hash is set by LAG hash.
12119 MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
12121 /* reg_tngcr_learn_enable
12122 * During decapsulation, whether to learn from NVE port.
12123 * Reserved when Spectrum-2. See TNPC.
12126 MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
12128 /* reg_tngcr_underlay_virtual_router
12129 * Underlay virtual router.
12130 * Reserved when Spectrum-2.
12133 MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
12135 /* reg_tngcr_underlay_rif
12136 * Underlay ingress router interface. RIF type should be loopback generic.
12137 * Reserved when Spectrum.
12140 MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
12142 /* reg_tngcr_usipv4
12143 * Underlay source IPv4 address of the NVE.
12146 MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
12148 /* reg_tngcr_usipv6
12149 * Underlay source IPv6 address of the NVE. For Spectrum, must not be
12150 * modified under traffic of NVE tunneling encapsulation.
12153 MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
12155 static inline void mlxsw_reg_tngcr_pack(char *payload,
12156 enum mlxsw_reg_tngcr_type type,
12157 bool valid, u8 ttl)
12159 MLXSW_REG_ZERO(tngcr, payload);
12160 mlxsw_reg_tngcr_type_set(payload, type);
12161 mlxsw_reg_tngcr_nve_valid_set(payload, valid);
12162 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
12163 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
12164 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
12165 mlxsw_reg_tngcr_nve_flh_set(payload, 0);
12166 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
12167 MLXSW_REG_TNGCR_UDP_SPORT_HASH);
12168 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
12169 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
12170 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
12173 /* TNUMT - Tunneling NVE Underlay Multicast Table Register
12174 * -------------------------------------------------------
12175 * The TNUMT register is for building the underlay MC table. It is used
12176 * for MC, flooding and BC traffic into the NVE tunnel.
12178 #define MLXSW_REG_TNUMT_ID 0xA003
12179 #define MLXSW_REG_TNUMT_LEN 0x20
12181 MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
12183 enum mlxsw_reg_tnumt_record_type {
12184 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
12185 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
12186 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
12189 /* reg_tnumt_record_type
12193 MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
12195 /* reg_tnumt_tunnel_port
12199 MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
12201 /* reg_tnumt_underlay_mc_ptr
12202 * Index to the underlay multicast table.
12203 * For Spectrum the index is to the KVD linear.
12206 MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
12209 * The next_underlay_mc_ptr is valid.
12212 MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
12214 /* reg_tnumt_next_underlay_mc_ptr
12215 * The next index to the underlay multicast table.
12218 MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
12220 /* reg_tnumt_record_size
12221 * Number of IP addresses in the record.
12222 * Range is 1..cap_max_nve_mc_entries_ipv{4,6}
12225 MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
12228 * The underlay IPv4 addresses. udip[i] is reserved if i >= size
12231 MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
12233 /* reg_tnumt_udip_ptr
12234 * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if
12235 * i >= size. The IPv6 addresses are configured by RIPS.
12238 MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
12240 static inline void mlxsw_reg_tnumt_pack(char *payload,
12241 enum mlxsw_reg_tnumt_record_type type,
12242 enum mlxsw_reg_tunnel_port tport,
12243 u32 underlay_mc_ptr, bool vnext,
12244 u32 next_underlay_mc_ptr,
12247 MLXSW_REG_ZERO(tnumt, payload);
12248 mlxsw_reg_tnumt_record_type_set(payload, type);
12249 mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
12250 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
12251 mlxsw_reg_tnumt_vnext_set(payload, vnext);
12252 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
12253 mlxsw_reg_tnumt_record_size_set(payload, record_size);
12256 /* TNQCR - Tunneling NVE QoS Configuration Register
12257 * ------------------------------------------------
12258 * The TNQCR register configures how QoS is set in encapsulation into the
12259 * underlay network.
12261 #define MLXSW_REG_TNQCR_ID 0xA010
12262 #define MLXSW_REG_TNQCR_LEN 0x0C
12264 MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
12266 /* reg_tnqcr_enc_set_dscp
12267 * For encapsulation: How to set DSCP field:
12268 * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay
12269 * (outer) IP header. If there is no IP header, use TNQDR.dscp
12270 * 1 - Set the DSCP field as TNQDR.dscp
12273 MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
12275 static inline void mlxsw_reg_tnqcr_pack(char *payload)
12277 MLXSW_REG_ZERO(tnqcr, payload);
12278 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
12281 /* TNQDR - Tunneling NVE QoS Default Register
12282 * ------------------------------------------
12283 * The TNQDR register configures the default QoS settings for NVE
12286 #define MLXSW_REG_TNQDR_ID 0xA011
12287 #define MLXSW_REG_TNQDR_LEN 0x08
12289 MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
12291 /* reg_tnqdr_local_port
12292 * Local port number (receive port). CPU port is supported.
12295 MLXSW_ITEM32_LP(reg, tnqdr, 0x00, 16, 0x00, 12);
12298 * For encapsulation, the default DSCP.
12301 MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
12303 static inline void mlxsw_reg_tnqdr_pack(char *payload, u16 local_port)
12305 MLXSW_REG_ZERO(tnqdr, payload);
12306 mlxsw_reg_tnqdr_local_port_set(payload, local_port);
12307 mlxsw_reg_tnqdr_dscp_set(payload, 0);
12310 /* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register
12311 * --------------------------------------------------------
12312 * The TNEEM register maps ECN of the IP header at the ingress to the
12313 * encapsulation to the ECN of the underlay network.
12315 #define MLXSW_REG_TNEEM_ID 0xA012
12316 #define MLXSW_REG_TNEEM_LEN 0x0C
12318 MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
12320 /* reg_tneem_overlay_ecn
12321 * ECN of the IP header in the overlay network.
12324 MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
12326 /* reg_tneem_underlay_ecn
12327 * ECN of the IP header in the underlay network.
12330 MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
12332 static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
12335 MLXSW_REG_ZERO(tneem, payload);
12336 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
12337 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
12340 /* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register
12341 * --------------------------------------------------------
12342 * The TNDEM register configures the actions that are done in the
12345 #define MLXSW_REG_TNDEM_ID 0xA013
12346 #define MLXSW_REG_TNDEM_LEN 0x0C
12348 MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
12350 /* reg_tndem_underlay_ecn
12351 * ECN field of the IP header in the underlay network.
12354 MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
12356 /* reg_tndem_overlay_ecn
12357 * ECN field of the IP header in the overlay network.
12360 MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
12362 /* reg_tndem_eip_ecn
12363 * Egress IP ECN. ECN field of the IP header of the packet which goes out
12364 * from the decapsulation.
12367 MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
12369 /* reg_tndem_trap_en
12371 * 0 - No trap due to decap ECN
12372 * 1 - Trap enable with trap_id
12375 MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
12377 /* reg_tndem_trap_id
12378 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
12379 * Reserved when trap_en is '0'.
12382 MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
12384 static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
12385 u8 overlay_ecn, u8 ecn, bool trap_en,
12388 MLXSW_REG_ZERO(tndem, payload);
12389 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
12390 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
12391 mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
12392 mlxsw_reg_tndem_trap_en_set(payload, trap_en);
12393 mlxsw_reg_tndem_trap_id_set(payload, trap_id);
12396 /* TNPC - Tunnel Port Configuration Register
12397 * -----------------------------------------
12398 * The TNPC register is used for tunnel port configuration.
12399 * Reserved when Spectrum.
12401 #define MLXSW_REG_TNPC_ID 0xA020
12402 #define MLXSW_REG_TNPC_LEN 0x18
12404 MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
12406 /* reg_tnpc_tunnel_port
12410 MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
12412 /* reg_tnpc_learn_enable_v6
12413 * During IPv6 underlay decapsulation, whether to learn from tunnel port.
12416 MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
12418 /* reg_tnpc_learn_enable_v4
12419 * During IPv4 underlay decapsulation, whether to learn from tunnel port.
12422 MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
12424 static inline void mlxsw_reg_tnpc_pack(char *payload,
12425 enum mlxsw_reg_tunnel_port tport,
12428 MLXSW_REG_ZERO(tnpc, payload);
12429 mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
12430 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
12431 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
12434 /* TIGCR - Tunneling IPinIP General Configuration Register
12435 * -------------------------------------------------------
12436 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
12438 #define MLXSW_REG_TIGCR_ID 0xA801
12439 #define MLXSW_REG_TIGCR_LEN 0x10
12441 MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
12443 /* reg_tigcr_ipip_ttlc
12444 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
12448 MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
12450 /* reg_tigcr_ipip_ttl_uc
12451 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
12452 * reg_tigcr_ipip_ttlc is unset.
12455 MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
12457 static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
12459 MLXSW_REG_ZERO(tigcr, payload);
12460 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
12461 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
12464 /* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register
12465 * -----------------------------------------------------------
12466 * The TIEEM register maps ECN of the IP header at the ingress to the
12467 * encapsulation to the ECN of the underlay network.
12469 #define MLXSW_REG_TIEEM_ID 0xA812
12470 #define MLXSW_REG_TIEEM_LEN 0x0C
12472 MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
12474 /* reg_tieem_overlay_ecn
12475 * ECN of the IP header in the overlay network.
12478 MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
12480 /* reg_tineem_underlay_ecn
12481 * ECN of the IP header in the underlay network.
12484 MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
12486 static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
12489 MLXSW_REG_ZERO(tieem, payload);
12490 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
12491 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
12494 /* TIDEM - Tunneling IPinIP Decapsulation ECN Mapping Register
12495 * -----------------------------------------------------------
12496 * The TIDEM register configures the actions that are done in the
12499 #define MLXSW_REG_TIDEM_ID 0xA813
12500 #define MLXSW_REG_TIDEM_LEN 0x0C
12502 MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN);
12504 /* reg_tidem_underlay_ecn
12505 * ECN field of the IP header in the underlay network.
12508 MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2);
12510 /* reg_tidem_overlay_ecn
12511 * ECN field of the IP header in the overlay network.
12514 MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2);
12516 /* reg_tidem_eip_ecn
12517 * Egress IP ECN. ECN field of the IP header of the packet which goes out
12518 * from the decapsulation.
12521 MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2);
12523 /* reg_tidem_trap_en
12525 * 0 - No trap due to decap ECN
12526 * 1 - Trap enable with trap_id
12529 MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4);
12531 /* reg_tidem_trap_id
12532 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
12533 * Reserved when trap_en is '0'.
12536 MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9);
12538 static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn,
12539 u8 overlay_ecn, u8 eip_ecn,
12540 bool trap_en, u16 trap_id)
12542 MLXSW_REG_ZERO(tidem, payload);
12543 mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn);
12544 mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn);
12545 mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn);
12546 mlxsw_reg_tidem_trap_en_set(payload, trap_en);
12547 mlxsw_reg_tidem_trap_id_set(payload, trap_id);
12550 /* SBPR - Shared Buffer Pools Register
12551 * -----------------------------------
12552 * The SBPR configures and retrieves the shared buffer pools and configuration.
12554 #define MLXSW_REG_SBPR_ID 0xB001
12555 #define MLXSW_REG_SBPR_LEN 0x14
12557 MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
12560 * When set, configures descriptor buffer.
12563 MLXSW_ITEM32(reg, sbpr, desc, 0x00, 31, 1);
12565 /* shared direstion enum for SBPR, SBCM, SBPM */
12566 enum mlxsw_reg_sbxx_dir {
12567 MLXSW_REG_SBXX_DIR_INGRESS,
12568 MLXSW_REG_SBXX_DIR_EGRESS,
12575 MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
12581 MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
12583 /* reg_sbpr_infi_size
12584 * Size is infinite.
12587 MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
12590 * Pool size in buffer cells.
12591 * Reserved when infi_size = 1.
12594 MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
12596 enum mlxsw_reg_sbpr_mode {
12597 MLXSW_REG_SBPR_MODE_STATIC,
12598 MLXSW_REG_SBPR_MODE_DYNAMIC,
12602 * Pool quota calculation mode.
12605 MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
12607 static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
12608 enum mlxsw_reg_sbxx_dir dir,
12609 enum mlxsw_reg_sbpr_mode mode, u32 size,
12612 MLXSW_REG_ZERO(sbpr, payload);
12613 mlxsw_reg_sbpr_pool_set(payload, pool);
12614 mlxsw_reg_sbpr_dir_set(payload, dir);
12615 mlxsw_reg_sbpr_mode_set(payload, mode);
12616 mlxsw_reg_sbpr_size_set(payload, size);
12617 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
12620 /* SBCM - Shared Buffer Class Management Register
12621 * ----------------------------------------------
12622 * The SBCM register configures and retrieves the shared buffer allocation
12623 * and configuration according to Port-PG, including the binding to pool
12624 * and definition of the associated quota.
12626 #define MLXSW_REG_SBCM_ID 0xB002
12627 #define MLXSW_REG_SBCM_LEN 0x28
12629 MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
12631 /* reg_sbcm_local_port
12632 * Local port number.
12633 * For Ingress: excludes CPU port and Router port
12634 * For Egress: excludes IP Router
12637 MLXSW_ITEM32_LP(reg, sbcm, 0x00, 16, 0x00, 4);
12639 /* reg_sbcm_pg_buff
12640 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
12641 * For PG buffer: range is 0..cap_max_pg_buffers - 1
12642 * For traffic class: range is 0..cap_max_tclass - 1
12643 * Note that when traffic class is in MC aware mode then the traffic
12644 * classes which are MC aware cannot be configured.
12647 MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
12653 MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
12655 /* reg_sbcm_min_buff
12656 * Minimum buffer size for the limiter, in cells.
12659 MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
12661 /* shared max_buff limits for dynamic threshold for SBCM, SBPM */
12662 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
12663 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
12665 /* reg_sbcm_infi_max
12666 * Max buffer is infinite.
12669 MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
12671 /* reg_sbcm_max_buff
12672 * When the pool associated to the port-pg/tclass is configured to
12673 * static, Maximum buffer size for the limiter configured in cells.
12674 * When the pool associated to the port-pg/tclass is configured to
12675 * dynamic, the max_buff holds the "alpha" parameter, supporting
12676 * the following values:
12678 * i: (1/128)*2^(i-1), for i=1..14
12680 * Reserved when infi_max = 1.
12683 MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
12686 * Association of the port-priority to a pool.
12689 MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
12691 static inline void mlxsw_reg_sbcm_pack(char *payload, u16 local_port, u8 pg_buff,
12692 enum mlxsw_reg_sbxx_dir dir,
12693 u32 min_buff, u32 max_buff,
12694 bool infi_max, u8 pool)
12696 MLXSW_REG_ZERO(sbcm, payload);
12697 mlxsw_reg_sbcm_local_port_set(payload, local_port);
12698 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
12699 mlxsw_reg_sbcm_dir_set(payload, dir);
12700 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
12701 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
12702 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
12703 mlxsw_reg_sbcm_pool_set(payload, pool);
12706 /* SBPM - Shared Buffer Port Management Register
12707 * ---------------------------------------------
12708 * The SBPM register configures and retrieves the shared buffer allocation
12709 * and configuration according to Port-Pool, including the definition
12710 * of the associated quota.
12712 #define MLXSW_REG_SBPM_ID 0xB003
12713 #define MLXSW_REG_SBPM_LEN 0x28
12715 MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
12717 /* reg_sbpm_local_port
12718 * Local port number.
12719 * For Ingress: excludes CPU port and Router port
12720 * For Egress: excludes IP Router
12723 MLXSW_ITEM32_LP(reg, sbpm, 0x00, 16, 0x00, 12);
12726 * The pool associated to quota counting on the local_port.
12729 MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
12735 MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
12737 /* reg_sbpm_buff_occupancy
12738 * Current buffer occupancy in cells.
12741 MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
12744 * Clear Max Buffer Occupancy
12745 * When this bit is set, max_buff_occupancy field is cleared (and a
12746 * new max value is tracked from the time the clear was performed).
12749 MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
12751 /* reg_sbpm_max_buff_occupancy
12752 * Maximum value of buffer occupancy in cells monitored. Cleared by
12753 * writing to the clr field.
12756 MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
12758 /* reg_sbpm_min_buff
12759 * Minimum buffer size for the limiter, in cells.
12762 MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
12764 /* reg_sbpm_max_buff
12765 * When the pool associated to the port-pg/tclass is configured to
12766 * static, Maximum buffer size for the limiter configured in cells.
12767 * When the pool associated to the port-pg/tclass is configured to
12768 * dynamic, the max_buff holds the "alpha" parameter, supporting
12769 * the following values:
12771 * i: (1/128)*2^(i-1), for i=1..14
12775 MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
12777 static inline void mlxsw_reg_sbpm_pack(char *payload, u16 local_port, u8 pool,
12778 enum mlxsw_reg_sbxx_dir dir, bool clr,
12779 u32 min_buff, u32 max_buff)
12781 MLXSW_REG_ZERO(sbpm, payload);
12782 mlxsw_reg_sbpm_local_port_set(payload, local_port);
12783 mlxsw_reg_sbpm_pool_set(payload, pool);
12784 mlxsw_reg_sbpm_dir_set(payload, dir);
12785 mlxsw_reg_sbpm_clr_set(payload, clr);
12786 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
12787 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
12790 static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
12791 u32 *p_max_buff_occupancy)
12793 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
12794 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
12797 /* SBMM - Shared Buffer Multicast Management Register
12798 * --------------------------------------------------
12799 * The SBMM register configures and retrieves the shared buffer allocation
12800 * and configuration for MC packets according to Switch-Priority, including
12801 * the binding to pool and definition of the associated quota.
12803 #define MLXSW_REG_SBMM_ID 0xB004
12804 #define MLXSW_REG_SBMM_LEN 0x28
12806 MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
12812 MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
12814 /* reg_sbmm_min_buff
12815 * Minimum buffer size for the limiter, in cells.
12818 MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
12820 /* reg_sbmm_max_buff
12821 * When the pool associated to the port-pg/tclass is configured to
12822 * static, Maximum buffer size for the limiter configured in cells.
12823 * When the pool associated to the port-pg/tclass is configured to
12824 * dynamic, the max_buff holds the "alpha" parameter, supporting
12825 * the following values:
12827 * i: (1/128)*2^(i-1), for i=1..14
12831 MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
12834 * Association of the port-priority to a pool.
12837 MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
12839 static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
12840 u32 max_buff, u8 pool)
12842 MLXSW_REG_ZERO(sbmm, payload);
12843 mlxsw_reg_sbmm_prio_set(payload, prio);
12844 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
12845 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
12846 mlxsw_reg_sbmm_pool_set(payload, pool);
12849 /* SBSR - Shared Buffer Status Register
12850 * ------------------------------------
12851 * The SBSR register retrieves the shared buffer occupancy according to
12852 * Port-Pool. Note that this register enables reading a large amount of data.
12853 * It is the user's responsibility to limit the amount of data to ensure the
12854 * response can match the maximum transfer unit. In case the response exceeds
12855 * the maximum transport unit, it will be truncated with no special notice.
12857 #define MLXSW_REG_SBSR_ID 0xB005
12858 #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
12859 #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
12860 #define MLXSW_REG_SBSR_REC_MAX_COUNT 120
12861 #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
12862 MLXSW_REG_SBSR_REC_LEN * \
12863 MLXSW_REG_SBSR_REC_MAX_COUNT)
12865 MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
12868 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
12869 * field is cleared (and a new max value is tracked from the time the clear
12873 MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
12875 #define MLXSW_REG_SBSR_NUM_PORTS_IN_PAGE 256
12877 /* reg_sbsr_port_page
12878 * Determines the range of the ports specified in the 'ingress_port_mask'
12879 * and 'egress_port_mask' bit masks.
12880 * {ingress,egress}_port_mask[x] is (256 * port_page) + x
12883 MLXSW_ITEM32(reg, sbsr, port_page, 0x04, 0, 4);
12885 /* reg_sbsr_ingress_port_mask
12886 * Bit vector for all ingress network ports.
12887 * Indicates which of the ports (for which the relevant bit is set)
12888 * are affected by the set operation. Configuration of any other port
12892 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
12894 /* reg_sbsr_pg_buff_mask
12895 * Bit vector for all switch priority groups.
12896 * Indicates which of the priorities (for which the relevant bit is set)
12897 * are affected by the set operation. Configuration of any other priority
12899 * Range is 0..cap_max_pg_buffers - 1
12902 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
12904 /* reg_sbsr_egress_port_mask
12905 * Bit vector for all egress network ports.
12906 * Indicates which of the ports (for which the relevant bit is set)
12907 * are affected by the set operation. Configuration of any other port
12911 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
12913 /* reg_sbsr_tclass_mask
12914 * Bit vector for all traffic classes.
12915 * Indicates which of the traffic classes (for which the relevant bit is
12916 * set) are affected by the set operation. Configuration of any other
12917 * traffic class does not change.
12918 * Range is 0..cap_max_tclass - 1
12921 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
12923 static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
12925 MLXSW_REG_ZERO(sbsr, payload);
12926 mlxsw_reg_sbsr_clr_set(payload, clr);
12929 /* reg_sbsr_rec_buff_occupancy
12930 * Current buffer occupancy in cells.
12933 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
12934 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
12936 /* reg_sbsr_rec_max_buff_occupancy
12937 * Maximum value of buffer occupancy in cells monitored. Cleared by
12938 * writing to the clr field.
12941 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
12942 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
12944 static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
12945 u32 *p_buff_occupancy,
12946 u32 *p_max_buff_occupancy)
12948 *p_buff_occupancy =
12949 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
12950 *p_max_buff_occupancy =
12951 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
12954 /* SBIB - Shared Buffer Internal Buffer Register
12955 * ---------------------------------------------
12956 * The SBIB register configures per port buffers for internal use. The internal
12957 * buffers consume memory on the port buffers (note that the port buffers are
12958 * used also by PBMC).
12960 * For Spectrum this is used for egress mirroring.
12962 #define MLXSW_REG_SBIB_ID 0xB006
12963 #define MLXSW_REG_SBIB_LEN 0x10
12965 MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
12967 /* reg_sbib_local_port
12968 * Local port number
12969 * Not supported for CPU port and router port
12972 MLXSW_ITEM32_LP(reg, sbib, 0x00, 16, 0x00, 12);
12974 /* reg_sbib_buff_size
12975 * Units represented in cells
12976 * Allowed range is 0 to (cap_max_headroom_size - 1)
12980 MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
12982 static inline void mlxsw_reg_sbib_pack(char *payload, u16 local_port,
12985 MLXSW_REG_ZERO(sbib, payload);
12986 mlxsw_reg_sbib_local_port_set(payload, local_port);
12987 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
12990 static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
13151 static inline const char *mlxsw_reg_id_str(u16 reg_id)
13153 const struct mlxsw_reg_info *reg_info;
13156 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
13157 reg_info = mlxsw_reg_infos[i];
13158 if (reg_info->id == reg_id)
13159 return reg_info->name;
13161 return "*UNKNOWN*";
13164 /* PUDE - Port Up / Down Event
13165 * ---------------------------
13166 * Reports the operational state change of a port.
13168 #define MLXSW_REG_PUDE_LEN 0x10
13171 * Switch partition ID with which to associate the port.
13174 MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
13176 /* reg_pude_local_port
13177 * Local port number.
13180 MLXSW_ITEM32_LP(reg, pude, 0x00, 16, 0x00, 12);
13182 /* reg_pude_admin_status
13183 * Port administrative state (the desired state).
13186 * 3 - Up once. This means that in case of link failure, the port won't go
13187 * into polling mode, but will wait to be re-enabled by software.
13188 * 4 - Disabled by system. Can only be set by hardware.
13191 MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
13193 /* reg_pude_oper_status
13194 * Port operatioanl state.
13197 * 3 - Down by port failure. This means that the device will not let the
13198 * port up again until explicitly specified by software.
13201 MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);