blob: ad6798c2169d22b1e763665f8d3b0fa2e5170159 [file] [log] [blame]
Jiri Pirko9948a062018-08-09 11:59:11 +03001/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2/* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003
4#ifndef _MLXSW_REG_H
5#define _MLXSW_REG_H
6
Jiri Pirko33907872018-07-18 11:14:37 +03007#include <linux/kernel.h>
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008#include <linux/string.h>
9#include <linux/bitops.h>
10#include <linux/if_vlan.h>
11
12#include "item.h"
13#include "port.h"
14
15struct mlxsw_reg_info {
16 u16 id;
17 u16 len; /* In u8 */
Jiri Pirko8e9658d2016-10-21 16:07:21 +020018 const char *name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +020019};
20
Jiri Pirko21978dc2016-10-21 16:07:20 +020021#define MLXSW_REG_DEFINE(_name, _id, _len) \
22static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
23 .id = _id, \
24 .len = _len, \
Jiri Pirko8e9658d2016-10-21 16:07:21 +020025 .name = #_name, \
Jiri Pirko21978dc2016-10-21 16:07:20 +020026}
27
Ido Schimmel4ec14b72015-07-29 23:33:48 +020028#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)
31
32/* SGCR - Switch General Configuration Register
33 * --------------------------------------------
34 * This register is used for configuration of the switch capabilities.
35 */
36#define MLXSW_REG_SGCR_ID 0x2000
37#define MLXSW_REG_SGCR_LEN 0x10
38
Jiri Pirko21978dc2016-10-21 16:07:20 +020039MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +020040
41/* reg_sgcr_llb
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.
45 * Access: RW
46 */
47MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
48
49static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
50{
51 MLXSW_REG_ZERO(sgcr, payload);
52 mlxsw_reg_sgcr_llb_set(payload, !!llb);
53}
54
55/* SPAD - Switch Physical Address Register
56 * ---------------------------------------
57 * The SPAD register configures the switch physical MAC address.
58 */
59#define MLXSW_REG_SPAD_ID 0x2002
60#define MLXSW_REG_SPAD_LEN 0x10
61
Jiri Pirko21978dc2016-10-21 16:07:20 +020062MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +020063
64/* reg_spad_base_mac
65 * Base MAC address for the switch partitions.
66 * Per switch partition MAC address is equal to:
67 * base_mac + swid
68 * Access: RW
69 */
70MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
71
Elad Razfabe5482016-01-10 21:06:25 +010072/* SMID - Switch Multicast ID
73 * --------------------------
74 * The MID record maps from a MID (Multicast ID), which is a unique identifier
75 * of the multicast group within the stacking domain, into a list of local
76 * ports into which the packet is replicated.
77 */
78#define MLXSW_REG_SMID_ID 0x2007
79#define MLXSW_REG_SMID_LEN 0x240
80
Jiri Pirko21978dc2016-10-21 16:07:20 +020081MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
Elad Razfabe5482016-01-10 21:06:25 +010082
83/* reg_smid_swid
84 * Switch partition ID.
85 * Access: Index
86 */
87MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
88
89/* reg_smid_mid
90 * Multicast identifier - global identifier that represents the multicast group
91 * across all devices.
92 * Access: Index
93 */
94MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
95
96/* reg_smid_port
97 * Local port memebership (1 bit per port).
98 * Access: RW
99 */
100MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
101
102/* reg_smid_port_mask
103 * Local port mask (1 bit per port).
104 * Access: W
105 */
106MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
107
108static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
109 u8 port, bool set)
110{
111 MLXSW_REG_ZERO(smid, payload);
112 mlxsw_reg_smid_swid_set(payload, 0);
113 mlxsw_reg_smid_mid_set(payload, mid);
114 mlxsw_reg_smid_port_set(payload, port, set);
115 mlxsw_reg_smid_port_mask_set(payload, port, 1);
116}
117
Ido Schimmele61011b2015-08-06 16:41:53 +0200118/* SSPR - Switch System Port Record Register
119 * -----------------------------------------
120 * Configures the system port to local port mapping.
121 */
122#define MLXSW_REG_SSPR_ID 0x2008
123#define MLXSW_REG_SSPR_LEN 0x8
124
Jiri Pirko21978dc2016-10-21 16:07:20 +0200125MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
Ido Schimmele61011b2015-08-06 16:41:53 +0200126
127/* reg_sspr_m
128 * Master - if set, then the record describes the master system port.
129 * This is needed in case a local port is mapped into several system ports
130 * (for multipathing). That number will be reported as the source system
131 * port when packets are forwarded to the CPU. Only one master port is allowed
132 * per local port.
133 *
134 * Note: Must be set for Spectrum.
135 * Access: RW
136 */
137MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
138
139/* reg_sspr_local_port
140 * Local port number.
141 *
142 * Access: RW
143 */
144MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
145
146/* reg_sspr_sub_port
147 * Virtual port within the physical port.
148 * Should be set to 0 when virtual ports are not enabled on the port.
149 *
150 * Access: RW
151 */
152MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
153
154/* reg_sspr_system_port
155 * Unique identifier within the stacking domain that represents all the ports
156 * that are available in the system (external ports).
157 *
158 * Currently, only single-ASIC configurations are supported, so we default to
159 * 1:1 mapping between system ports and local ports.
160 * Access: Index
161 */
162MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
163
164static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
165{
166 MLXSW_REG_ZERO(sspr, payload);
167 mlxsw_reg_sspr_m_set(payload, 1);
168 mlxsw_reg_sspr_local_port_set(payload, local_port);
169 mlxsw_reg_sspr_sub_port_set(payload, 0);
170 mlxsw_reg_sspr_system_port_set(payload, local_port);
171}
172
Jiri Pirkoe534a56a2015-10-16 14:01:35 +0200173/* SFDAT - Switch Filtering Database Aging Time
174 * --------------------------------------------
175 * Controls the Switch aging time. Aging time is able to be set per Switch
176 * Partition.
177 */
178#define MLXSW_REG_SFDAT_ID 0x2009
179#define MLXSW_REG_SFDAT_LEN 0x8
180
Jiri Pirko21978dc2016-10-21 16:07:20 +0200181MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
Jiri Pirkoe534a56a2015-10-16 14:01:35 +0200182
183/* reg_sfdat_swid
184 * Switch partition ID.
185 * Access: Index
186 */
187MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
188
189/* reg_sfdat_age_time
190 * Aging time in seconds
191 * Min - 10 seconds
192 * Max - 1,000,000 seconds
193 * Default is 300 seconds.
194 * Access: RW
195 */
196MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
197
198static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
199{
200 MLXSW_REG_ZERO(sfdat, payload);
201 mlxsw_reg_sfdat_swid_set(payload, 0);
202 mlxsw_reg_sfdat_age_time_set(payload, age_time);
203}
204
Jiri Pirko236033b2015-10-16 14:01:28 +0200205/* SFD - Switch Filtering Database
206 * -------------------------------
207 * The following register defines the access to the filtering database.
208 * The register supports querying, adding, removing and modifying the database.
209 * The access is optimized for bulk updates in which case more than one
210 * FDB record is present in the same command.
211 */
212#define MLXSW_REG_SFD_ID 0x200A
213#define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
214#define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
215#define MLXSW_REG_SFD_REC_MAX_COUNT 64
216#define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
217 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
218
Jiri Pirko21978dc2016-10-21 16:07:20 +0200219MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
Jiri Pirko236033b2015-10-16 14:01:28 +0200220
221/* reg_sfd_swid
222 * Switch partition ID for queries. Reserved on Write.
223 * Access: Index
224 */
225MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
226
227enum mlxsw_reg_sfd_op {
228 /* Dump entire FDB a (process according to record_locator) */
229 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
230 /* Query records by {MAC, VID/FID} value */
231 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
232 /* Query and clear activity. Query records by {MAC, VID/FID} value */
233 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
234 /* Test. Response indicates if each of the records could be
235 * added to the FDB.
236 */
237 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
238 /* Add/modify. Aged-out records cannot be added. This command removes
239 * the learning notification of the {MAC, VID/FID}. Response includes
240 * the entries that were added to the FDB.
241 */
242 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
243 /* Remove record by {MAC, VID/FID}. This command also removes
244 * the learning notification and aged-out notifications
245 * of the {MAC, VID/FID}. The response provides current (pre-removal)
246 * entries as non-aged-out.
247 */
248 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
249 /* Remove learned notification by {MAC, VID/FID}. The response provides
250 * the removed learning notification.
251 */
252 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
253};
254
255/* reg_sfd_op
256 * Operation.
257 * Access: OP
258 */
259MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
260
261/* reg_sfd_record_locator
262 * Used for querying the FDB. Use record_locator=0 to initiate the
263 * query. When a record is returned, a new record_locator is
264 * returned to be used in the subsequent query.
265 * Reserved for database update.
266 * Access: Index
267 */
268MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
269
270/* reg_sfd_num_rec
271 * Request: Number of records to read/add/modify/remove
272 * Response: Number of records read/added/replaced/removed
273 * See above description for more details.
274 * Ranges 0..64
275 * Access: RW
276 */
277MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
278
279static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
280 u32 record_locator)
281{
282 MLXSW_REG_ZERO(sfd, payload);
283 mlxsw_reg_sfd_op_set(payload, op);
284 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
285}
286
287/* reg_sfd_rec_swid
288 * Switch partition ID.
289 * Access: Index
290 */
291MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
292 MLXSW_REG_SFD_REC_LEN, 0x00, false);
293
294enum mlxsw_reg_sfd_rec_type {
295 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100296 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
Elad Raz5230b252016-01-10 21:06:24 +0100297 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
Ido Schimmel09337812018-10-11 07:48:07 +0000298 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC,
Jiri Pirko236033b2015-10-16 14:01:28 +0200299};
300
301/* reg_sfd_rec_type
302 * FDB record type.
303 * Access: RW
304 */
305MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
306 MLXSW_REG_SFD_REC_LEN, 0x00, false);
307
308enum mlxsw_reg_sfd_rec_policy {
309 /* Replacement disabled, aging disabled. */
310 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
311 /* (mlag remote): Replacement enabled, aging disabled,
312 * learning notification enabled on this port.
313 */
314 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
315 /* (ingress device): Replacement enabled, aging enabled. */
316 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
317};
318
319/* reg_sfd_rec_policy
320 * Policy.
321 * Access: RW
322 */
323MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
324 MLXSW_REG_SFD_REC_LEN, 0x00, false);
325
326/* reg_sfd_rec_a
327 * Activity. Set for new static entries. Set for static entries if a frame SMAC
328 * lookup hits on the entry.
329 * To clear the a bit, use "query and clear activity" op.
330 * Access: RO
331 */
332MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
333 MLXSW_REG_SFD_REC_LEN, 0x00, false);
334
335/* reg_sfd_rec_mac
336 * MAC address.
337 * Access: Index
338 */
339MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
340 MLXSW_REG_SFD_REC_LEN, 0x02);
341
342enum mlxsw_reg_sfd_rec_action {
343 /* forward */
344 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
345 /* forward and trap, trap_id is FDB_TRAP */
346 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
347 /* trap and do not forward, trap_id is FDB_TRAP */
Ido Schimmeld82d8c02016-07-02 11:00:17 +0200348 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
349 /* forward to IP router */
350 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
Jiri Pirko236033b2015-10-16 14:01:28 +0200351 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
352};
353
354/* reg_sfd_rec_action
355 * Action to apply on the packet.
356 * Note: Dynamic entries can only be configured with NOP action.
357 * Access: RW
358 */
359MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
360 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
361
362/* reg_sfd_uc_sub_port
Jiri Pirko4e9ec082015-10-28 10:16:59 +0100363 * VEPA channel on local port.
364 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
365 * VEPA is not enabled.
Jiri Pirko236033b2015-10-16 14:01:28 +0200366 * Access: RW
367 */
368MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
369 MLXSW_REG_SFD_REC_LEN, 0x08, false);
370
371/* reg_sfd_uc_fid_vid
372 * Filtering ID or VLAN ID
373 * For SwitchX and SwitchX-2:
374 * - Dynamic entries (policy 2,3) use FID
375 * - Static entries (policy 0) use VID
376 * - When independent learning is configured, VID=FID
377 * For Spectrum: use FID for both Dynamic and Static entries.
378 * VID should not be used.
379 * Access: Index
380 */
381MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
382 MLXSW_REG_SFD_REC_LEN, 0x08, false);
383
384/* reg_sfd_uc_system_port
385 * Unique port identifier for the final destination of the packet.
386 * Access: RW
387 */
388MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
389 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
390
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100391static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
392 enum mlxsw_reg_sfd_rec_type rec_type,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100393 const char *mac,
394 enum mlxsw_reg_sfd_rec_action action)
Jiri Pirko236033b2015-10-16 14:01:28 +0200395{
396 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
397
398 if (rec_index >= num_rec)
399 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
400 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100401 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
Jiri Pirko236033b2015-10-16 14:01:28 +0200402 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100403 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
404}
405
406static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
407 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100408 const char *mac, u16 fid_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100409 enum mlxsw_reg_sfd_rec_action action,
410 u8 local_port)
411{
412 mlxsw_reg_sfd_rec_pack(payload, rec_index,
Elad Raz5230b252016-01-10 21:06:24 +0100413 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
414 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirko236033b2015-10-16 14:01:28 +0200415 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100416 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
Jiri Pirko236033b2015-10-16 14:01:28 +0200417 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
418}
419
Jiri Pirko75c09282015-10-28 10:17:01 +0100420static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100421 char *mac, u16 *p_fid_vid,
Jiri Pirko75c09282015-10-28 10:17:01 +0100422 u8 *p_local_port)
Jiri Pirko236033b2015-10-16 14:01:28 +0200423{
424 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100425 *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
Jiri Pirko236033b2015-10-16 14:01:28 +0200426 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
427}
428
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100429/* reg_sfd_uc_lag_sub_port
430 * LAG sub port.
431 * Must be 0 if multichannel VEPA is not enabled.
432 * Access: RW
433 */
434MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
435 MLXSW_REG_SFD_REC_LEN, 0x08, false);
436
437/* reg_sfd_uc_lag_fid_vid
438 * Filtering ID or VLAN ID
439 * For SwitchX and SwitchX-2:
440 * - Dynamic entries (policy 2,3) use FID
441 * - Static entries (policy 0) use VID
442 * - When independent learning is configured, VID=FID
443 * For Spectrum: use FID for both Dynamic and Static entries.
444 * VID should not be used.
445 * Access: Index
446 */
447MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
448 MLXSW_REG_SFD_REC_LEN, 0x08, false);
449
Ido Schimmelafd7f972015-12-15 16:03:45 +0100450/* reg_sfd_uc_lag_lag_vid
451 * Indicates VID in case of vFIDs. Reserved for FIDs.
452 * Access: RW
453 */
454MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
455 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
456
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100457/* reg_sfd_uc_lag_lag_id
458 * LAG Identifier - pointer into the LAG descriptor table.
459 * Access: RW
460 */
461MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
462 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
463
464static inline void
465mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
466 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100467 const char *mac, u16 fid_vid,
Ido Schimmelafd7f972015-12-15 16:03:45 +0100468 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100469 u16 lag_id)
470{
471 mlxsw_reg_sfd_rec_pack(payload, rec_index,
472 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
Elad Raz5230b252016-01-10 21:06:24 +0100473 mac, action);
474 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100475 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100476 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
Ido Schimmelafd7f972015-12-15 16:03:45 +0100477 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100478 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
479}
480
481static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
482 char *mac, u16 *p_vid,
483 u16 *p_lag_id)
484{
485 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
486 *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
487 *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
488}
489
Elad Raz5230b252016-01-10 21:06:24 +0100490/* reg_sfd_mc_pgi
491 *
492 * Multicast port group index - index into the port group table.
493 * Value 0x1FFF indicates the pgi should point to the MID entry.
494 * For Spectrum this value must be set to 0x1FFF
495 * Access: RW
496 */
497MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
498 MLXSW_REG_SFD_REC_LEN, 0x08, false);
499
500/* reg_sfd_mc_fid_vid
501 *
502 * Filtering ID or VLAN ID
503 * Access: Index
504 */
505MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
506 MLXSW_REG_SFD_REC_LEN, 0x08, false);
507
508/* reg_sfd_mc_mid
509 *
510 * Multicast identifier - global identifier that represents the multicast
511 * group across all devices.
512 * Access: RW
513 */
514MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
515 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
516
517static inline void
518mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
519 const char *mac, u16 fid_vid,
520 enum mlxsw_reg_sfd_rec_action action, u16 mid)
521{
522 mlxsw_reg_sfd_rec_pack(payload, rec_index,
523 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
524 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
525 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
526 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
527}
528
Ido Schimmel09337812018-10-11 07:48:07 +0000529/* reg_sfd_uc_tunnel_uip_msb
530 * When protocol is IPv4, the most significant byte of the underlay IPv4
531 * destination IP.
532 * When protocol is IPv6, reserved.
533 * Access: RW
534 */
535MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24,
536 8, MLXSW_REG_SFD_REC_LEN, 0x08, false);
537
538/* reg_sfd_uc_tunnel_fid
539 * Filtering ID.
540 * Access: Index
541 */
542MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
543 MLXSW_REG_SFD_REC_LEN, 0x08, false);
544
545enum mlxsw_reg_sfd_uc_tunnel_protocol {
546 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4,
547 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6,
548};
549
550/* reg_sfd_uc_tunnel_protocol
551 * IP protocol.
552 * Access: RW
553 */
554MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27,
555 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
556
557/* reg_sfd_uc_tunnel_uip_lsb
558 * When protocol is IPv4, the least significant bytes of the underlay
559 * IPv4 destination IP.
560 * When protocol is IPv6, pointer to the underlay IPv6 destination IP
561 * which is configured by RIPS.
562 * Access: RW
563 */
564MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0,
565 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
566
567static inline void
568mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
569 enum mlxsw_reg_sfd_rec_policy policy,
570 const char *mac, u16 fid,
571 enum mlxsw_reg_sfd_rec_action action, u32 uip,
572 enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
573{
574 mlxsw_reg_sfd_rec_pack(payload, rec_index,
575 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
576 action);
577 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
578 mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
579 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
580 mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
581 mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
582}
583
Amit Cohen02c3b5c2020-12-08 11:22:41 +0200584enum mlxsw_reg_tunnel_port {
585 MLXSW_REG_TUNNEL_PORT_NVE,
586 MLXSW_REG_TUNNEL_PORT_VPLS,
587 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL0,
588 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL1,
589};
590
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200591/* SFN - Switch FDB Notification Register
592 * -------------------------------------------
593 * The switch provides notifications on newly learned FDB entries and
594 * aged out entries. The notifications can be polled by software.
595 */
596#define MLXSW_REG_SFN_ID 0x200B
597#define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
598#define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
599#define MLXSW_REG_SFN_REC_MAX_COUNT 64
600#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
601 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
602
Jiri Pirko21978dc2016-10-21 16:07:20 +0200603MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200604
605/* reg_sfn_swid
606 * Switch partition ID.
607 * Access: Index
608 */
609MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
610
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200611/* reg_sfn_end
612 * Forces the current session to end.
613 * Access: OP
614 */
615MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
616
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200617/* reg_sfn_num_rec
618 * Request: Number of learned notifications and aged-out notification
619 * records requested.
620 * Response: Number of notification records returned (must be smaller
621 * than or equal to the value requested)
622 * Ranges 0..64
623 * Access: OP
624 */
625MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
626
627static inline void mlxsw_reg_sfn_pack(char *payload)
628{
629 MLXSW_REG_ZERO(sfn, payload);
630 mlxsw_reg_sfn_swid_set(payload, 0);
Jiri Pirko648e53c2020-02-26 09:39:17 +0100631 mlxsw_reg_sfn_end_set(payload, 0);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200632 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
633}
634
635/* reg_sfn_rec_swid
636 * Switch partition ID.
637 * Access: RO
638 */
639MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
640 MLXSW_REG_SFN_REC_LEN, 0x00, false);
641
642enum mlxsw_reg_sfn_rec_type {
643 /* MAC addresses learned on a regular port. */
644 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
Jiri Pirko3b715712015-12-03 12:12:27 +0100645 /* MAC addresses learned on a LAG port. */
646 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
647 /* Aged-out MAC address on a regular port. */
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200648 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
Jiri Pirko3b715712015-12-03 12:12:27 +0100649 /* Aged-out MAC address on a LAG port. */
650 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
Ido Schimmel933b1ec2018-11-21 08:02:42 +0000651 /* Learned unicast tunnel record. */
652 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
653 /* Aged-out unicast tunnel record. */
654 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200655};
656
657/* reg_sfn_rec_type
658 * Notification record type.
659 * Access: RO
660 */
661MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
662 MLXSW_REG_SFN_REC_LEN, 0x00, false);
663
664/* reg_sfn_rec_mac
665 * MAC address.
666 * Access: RO
667 */
668MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
669 MLXSW_REG_SFN_REC_LEN, 0x02);
670
Jiri Pirko8316f082015-10-28 10:17:00 +0100671/* reg_sfn_mac_sub_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200672 * VEPA channel on the local port.
673 * 0 if multichannel VEPA is not enabled.
674 * Access: RO
675 */
676MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
677 MLXSW_REG_SFN_REC_LEN, 0x08, false);
678
Jiri Pirko8316f082015-10-28 10:17:00 +0100679/* reg_sfn_mac_fid
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200680 * Filtering identifier.
681 * Access: RO
682 */
683MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
684 MLXSW_REG_SFN_REC_LEN, 0x08, false);
685
Jiri Pirko8316f082015-10-28 10:17:00 +0100686/* reg_sfn_mac_system_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200687 * Unique port identifier for the final destination of the packet.
688 * Access: RO
689 */
690MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
691 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
692
693static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
694 char *mac, u16 *p_vid,
695 u8 *p_local_port)
696{
697 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
698 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
699 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
700}
701
Jiri Pirko3b715712015-12-03 12:12:27 +0100702/* reg_sfn_mac_lag_lag_id
703 * LAG ID (pointer into the LAG descriptor table).
704 * Access: RO
705 */
706MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
707 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
708
709static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
710 char *mac, u16 *p_vid,
711 u16 *p_lag_id)
712{
713 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
714 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
715 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
716}
717
Ido Schimmel933b1ec2018-11-21 08:02:42 +0000718/* reg_sfn_uc_tunnel_uip_msb
719 * When protocol is IPv4, the most significant byte of the underlay IPv4
720 * address of the remote VTEP.
721 * When protocol is IPv6, reserved.
722 * Access: RO
723 */
724MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
725 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
726
727enum mlxsw_reg_sfn_uc_tunnel_protocol {
728 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
729 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
730};
731
732/* reg_sfn_uc_tunnel_protocol
733 * IP protocol.
734 * Access: RO
735 */
736MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
737 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
738
739/* reg_sfn_uc_tunnel_uip_lsb
740 * When protocol is IPv4, the least significant bytes of the underlay
741 * IPv4 address of the remote VTEP.
742 * When protocol is IPv6, ipv6_id to be queried from TNIPSD.
743 * Access: RO
744 */
745MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
746 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
747
Ido Schimmel933b1ec2018-11-21 08:02:42 +0000748/* reg_sfn_uc_tunnel_port
749 * Tunnel port.
750 * Reserved on Spectrum.
751 * Access: RO
752 */
753MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4,
754 MLXSW_REG_SFN_REC_LEN, 0x10, false);
755
756static inline void
757mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac,
758 u16 *p_fid, u32 *p_uip,
759 enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto)
760{
761 u32 uip_msb, uip_lsb;
762
763 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
764 *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
765 uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index);
766 uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index);
767 *p_uip = uip_msb << 24 | uip_lsb;
768 *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index);
769}
770
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200771/* SPMS - Switch Port MSTP/RSTP State Register
772 * -------------------------------------------
773 * Configures the spanning tree state of a physical port.
774 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +0200775#define MLXSW_REG_SPMS_ID 0x200D
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200776#define MLXSW_REG_SPMS_LEN 0x404
777
Jiri Pirko21978dc2016-10-21 16:07:20 +0200778MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200779
780/* reg_spms_local_port
781 * Local port number.
782 * Access: Index
783 */
784MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
785
786enum mlxsw_reg_spms_state {
787 MLXSW_REG_SPMS_STATE_NO_CHANGE,
788 MLXSW_REG_SPMS_STATE_DISCARDING,
789 MLXSW_REG_SPMS_STATE_LEARNING,
790 MLXSW_REG_SPMS_STATE_FORWARDING,
791};
792
793/* reg_spms_state
794 * Spanning tree state of each VLAN ID (VID) of the local port.
795 * 0 - Do not change spanning tree state (used only when writing).
796 * 1 - Discarding. No learning or forwarding to/from this port (default).
797 * 2 - Learning. Port is learning, but not forwarding.
798 * 3 - Forwarding. Port is learning and forwarding.
799 * Access: RW
800 */
801MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
802
Jiri Pirkoebb79632015-10-15 17:43:26 +0200803static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200804{
805 MLXSW_REG_ZERO(spms, payload);
806 mlxsw_reg_spms_local_port_set(payload, local_port);
Jiri Pirkoebb79632015-10-15 17:43:26 +0200807}
808
809static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
810 enum mlxsw_reg_spms_state state)
811{
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200812 mlxsw_reg_spms_state_set(payload, vid, state);
813}
814
Elad Razb2e345f2015-10-16 14:01:30 +0200815/* SPVID - Switch Port VID
816 * -----------------------
817 * The switch port VID configures the default VID for a port.
818 */
819#define MLXSW_REG_SPVID_ID 0x200E
820#define MLXSW_REG_SPVID_LEN 0x08
821
Jiri Pirko21978dc2016-10-21 16:07:20 +0200822MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200823
824/* reg_spvid_local_port
825 * Local port number.
826 * Access: Index
827 */
828MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
829
830/* reg_spvid_sub_port
831 * Virtual port within the physical port.
832 * Should be set to 0 when virtual ports are not enabled on the port.
833 * Access: Index
834 */
835MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
836
Amit Cohen2a5a2902020-11-29 14:54:00 +0200837/* reg_spvid_et_vlan
838 * EtherType used for when VLAN is pushed at ingress (for untagged
839 * packets or for QinQ push mode).
840 * 0: ether_type0 - (default)
841 * 1: ether_type1
842 * 2: ether_type2 - Reserved when Spectrum-1, supported by Spectrum-2
843 * Ethertype IDs are configured by SVER.
844 * Access: RW
845 */
846MLXSW_ITEM32(reg, spvid, et_vlan, 0x04, 16, 2);
847
Elad Razb2e345f2015-10-16 14:01:30 +0200848/* reg_spvid_pvid
849 * Port default VID
850 * Access: RW
851 */
852MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
853
Amit Cohen3ae7a652020-11-29 14:54:02 +0200854static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid,
855 u8 et_vlan)
Elad Razb2e345f2015-10-16 14:01:30 +0200856{
857 MLXSW_REG_ZERO(spvid, payload);
858 mlxsw_reg_spvid_local_port_set(payload, local_port);
859 mlxsw_reg_spvid_pvid_set(payload, pvid);
Amit Cohen3ae7a652020-11-29 14:54:02 +0200860 mlxsw_reg_spvid_et_vlan_set(payload, et_vlan);
Elad Razb2e345f2015-10-16 14:01:30 +0200861}
862
863/* SPVM - Switch Port VLAN Membership
864 * ----------------------------------
865 * The Switch Port VLAN Membership register configures the VLAN membership
866 * of a port in a VLAN denoted by VID. VLAN membership is managed per
867 * virtual port. The register can be used to add and remove VID(s) from a port.
868 */
869#define MLXSW_REG_SPVM_ID 0x200F
870#define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
871#define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
Jiri Pirkof004ec02017-03-14 14:00:00 +0100872#define MLXSW_REG_SPVM_REC_MAX_COUNT 255
Elad Razb2e345f2015-10-16 14:01:30 +0200873#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
874 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
875
Jiri Pirko21978dc2016-10-21 16:07:20 +0200876MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200877
878/* reg_spvm_pt
879 * Priority tagged. If this bit is set, packets forwarded to the port with
880 * untagged VLAN membership (u bit is set) will be tagged with priority tag
881 * (VID=0)
882 * Access: RW
883 */
884MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
885
886/* reg_spvm_pte
887 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
888 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
889 * Access: WO
890 */
891MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
892
893/* reg_spvm_local_port
894 * Local port number.
895 * Access: Index
896 */
897MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
898
899/* reg_spvm_sub_port
900 * Virtual port within the physical port.
901 * Should be set to 0 when virtual ports are not enabled on the port.
902 * Access: Index
903 */
904MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
905
906/* reg_spvm_num_rec
907 * Number of records to update. Each record contains: i, e, u, vid.
908 * Access: OP
909 */
910MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
911
912/* reg_spvm_rec_i
913 * Ingress membership in VLAN ID.
914 * Access: Index
915 */
916MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
917 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
918 MLXSW_REG_SPVM_REC_LEN, 0, false);
919
920/* reg_spvm_rec_e
921 * Egress membership in VLAN ID.
922 * Access: Index
923 */
924MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
925 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
926 MLXSW_REG_SPVM_REC_LEN, 0, false);
927
928/* reg_spvm_rec_u
929 * Untagged - port is an untagged member - egress transmission uses untagged
930 * frames on VID<n>
931 * Access: Index
932 */
933MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
934 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
935 MLXSW_REG_SPVM_REC_LEN, 0, false);
936
937/* reg_spvm_rec_vid
938 * Egress membership in VLAN ID.
939 * Access: Index
940 */
941MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
942 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
943 MLXSW_REG_SPVM_REC_LEN, 0, false);
944
945static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
946 u16 vid_begin, u16 vid_end,
947 bool is_member, bool untagged)
948{
949 int size = vid_end - vid_begin + 1;
950 int i;
951
952 MLXSW_REG_ZERO(spvm, payload);
953 mlxsw_reg_spvm_local_port_set(payload, local_port);
954 mlxsw_reg_spvm_num_rec_set(payload, size);
955
956 for (i = 0; i < size; i++) {
957 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
958 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
959 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
960 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
961 }
962}
963
Ido Schimmel148f4722016-02-18 11:30:01 +0100964/* SPAFT - Switch Port Acceptable Frame Types
965 * ------------------------------------------
966 * The Switch Port Acceptable Frame Types register configures the frame
967 * admittance of the port.
968 */
969#define MLXSW_REG_SPAFT_ID 0x2010
970#define MLXSW_REG_SPAFT_LEN 0x08
971
Jiri Pirko21978dc2016-10-21 16:07:20 +0200972MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
Ido Schimmel148f4722016-02-18 11:30:01 +0100973
974/* reg_spaft_local_port
975 * Local port number.
976 * Access: Index
977 *
978 * Note: CPU port is not supported (all tag types are allowed).
979 */
980MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
981
982/* reg_spaft_sub_port
983 * Virtual port within the physical port.
984 * Should be set to 0 when virtual ports are not enabled on the port.
985 * Access: RW
986 */
987MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
988
989/* reg_spaft_allow_untagged
990 * When set, untagged frames on the ingress are allowed (default).
991 * Access: RW
992 */
993MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
994
995/* reg_spaft_allow_prio_tagged
996 * When set, priority tagged frames on the ingress are allowed (default).
997 * Access: RW
998 */
999MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
1000
1001/* reg_spaft_allow_tagged
1002 * When set, tagged frames on the ingress are allowed (default).
1003 * Access: RW
1004 */
1005MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
1006
1007static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
1008 bool allow_untagged)
1009{
1010 MLXSW_REG_ZERO(spaft, payload);
1011 mlxsw_reg_spaft_local_port_set(payload, local_port);
1012 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
Ido Schimmel4b14cc32019-06-11 10:19:46 +03001013 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
Ido Schimmel148f4722016-02-18 11:30:01 +01001014 mlxsw_reg_spaft_allow_tagged_set(payload, true);
1015}
1016
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001017/* SFGC - Switch Flooding Group Configuration
1018 * ------------------------------------------
1019 * The following register controls the association of flooding tables and MIDs
1020 * to packet types used for flooding.
1021 */
Jiri Pirko36b78e82015-10-15 17:43:24 +02001022#define MLXSW_REG_SFGC_ID 0x2011
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001023#define MLXSW_REG_SFGC_LEN 0x10
1024
Jiri Pirko21978dc2016-10-21 16:07:20 +02001025MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001026
1027enum mlxsw_reg_sfgc_type {
Ido Schimmelfa6ad052015-10-15 17:43:25 +02001028 MLXSW_REG_SFGC_TYPE_BROADCAST,
1029 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
1030 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
1031 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
1032 MLXSW_REG_SFGC_TYPE_RESERVED,
1033 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
1034 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
1035 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
1036 MLXSW_REG_SFGC_TYPE_MAX,
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001037};
1038
1039/* reg_sfgc_type
1040 * The traffic type to reach the flooding table.
1041 * Access: Index
1042 */
1043MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
1044
1045enum mlxsw_reg_sfgc_bridge_type {
1046 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
1047 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
1048};
1049
1050/* reg_sfgc_bridge_type
1051 * Access: Index
1052 *
1053 * Note: SwitchX-2 only supports 802.1Q mode.
1054 */
1055MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
1056
1057enum mlxsw_flood_table_type {
1058 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
1059 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
1060 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
Ido Schimmelda0abcf2017-06-04 16:53:39 +02001061 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001062 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
1063};
1064
1065/* reg_sfgc_table_type
1066 * See mlxsw_flood_table_type
1067 * Access: RW
1068 *
1069 * Note: FID offset and FID types are not supported in SwitchX-2.
1070 */
1071MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
1072
1073/* reg_sfgc_flood_table
1074 * Flooding table index to associate with the specific type on the specific
1075 * switch partition.
1076 * Access: RW
1077 */
1078MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
1079
1080/* reg_sfgc_mid
1081 * The multicast ID for the swid. Not supported for Spectrum
1082 * Access: RW
1083 */
1084MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
1085
1086/* reg_sfgc_counter_set_type
1087 * Counter Set Type for flow counters.
1088 * Access: RW
1089 */
1090MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
1091
1092/* reg_sfgc_counter_index
1093 * Counter Index for flow counters.
1094 * Access: RW
1095 */
1096MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
1097
1098static inline void
1099mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1100 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1101 enum mlxsw_flood_table_type table_type,
1102 unsigned int flood_table)
1103{
1104 MLXSW_REG_ZERO(sfgc, payload);
1105 mlxsw_reg_sfgc_type_set(payload, type);
1106 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1107 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1108 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1109 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1110}
1111
1112/* SFTR - Switch Flooding Table Register
1113 * -------------------------------------
1114 * The switch flooding table is used for flooding packet replication. The table
1115 * defines a bit mask of ports for packet replication.
1116 */
1117#define MLXSW_REG_SFTR_ID 0x2012
1118#define MLXSW_REG_SFTR_LEN 0x420
1119
Jiri Pirko21978dc2016-10-21 16:07:20 +02001120MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001121
1122/* reg_sftr_swid
1123 * Switch partition ID with which to associate the port.
1124 * Access: Index
1125 */
1126MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
1127
1128/* reg_sftr_flood_table
1129 * Flooding table index to associate with the specific type on the specific
1130 * switch partition.
1131 * Access: Index
1132 */
1133MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1134
1135/* reg_sftr_index
1136 * Index. Used as an index into the Flooding Table in case the table is
1137 * configured to use VID / FID or FID Offset.
1138 * Access: Index
1139 */
1140MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1141
1142/* reg_sftr_table_type
1143 * See mlxsw_flood_table_type
1144 * Access: RW
1145 */
1146MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1147
1148/* reg_sftr_range
1149 * Range of entries to update
1150 * Access: Index
1151 */
1152MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1153
1154/* reg_sftr_port
1155 * Local port membership (1 bit per port).
1156 * Access: RW
1157 */
1158MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1159
1160/* reg_sftr_cpu_port_mask
1161 * CPU port mask (1 bit per port).
1162 * Access: W
1163 */
1164MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1165
1166static inline void mlxsw_reg_sftr_pack(char *payload,
1167 unsigned int flood_table,
1168 unsigned int index,
1169 enum mlxsw_flood_table_type table_type,
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001170 unsigned int range, u8 port, bool set)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001171{
1172 MLXSW_REG_ZERO(sftr, payload);
1173 mlxsw_reg_sftr_swid_set(payload, 0);
1174 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1175 mlxsw_reg_sftr_index_set(payload, index);
1176 mlxsw_reg_sftr_table_type_set(payload, table_type);
1177 mlxsw_reg_sftr_range_set(payload, range);
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001178 mlxsw_reg_sftr_port_set(payload, port, set);
1179 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001180}
1181
Ido Schimmel41933272016-01-27 15:20:17 +01001182/* SFDF - Switch Filtering DB Flush
1183 * --------------------------------
1184 * The switch filtering DB flush register is used to flush the FDB.
1185 * Note that FDB notifications are flushed as well.
1186 */
1187#define MLXSW_REG_SFDF_ID 0x2013
1188#define MLXSW_REG_SFDF_LEN 0x14
1189
Jiri Pirko21978dc2016-10-21 16:07:20 +02001190MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
Ido Schimmel41933272016-01-27 15:20:17 +01001191
1192/* reg_sfdf_swid
1193 * Switch partition ID.
1194 * Access: Index
1195 */
1196MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1197
1198enum mlxsw_reg_sfdf_flush_type {
1199 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1200 MLXSW_REG_SFDF_FLUSH_PER_FID,
1201 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1202 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1203 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1204 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
Ido Schimmela682a302018-10-11 07:47:56 +00001205 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1206 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
Ido Schimmel41933272016-01-27 15:20:17 +01001207};
1208
1209/* reg_sfdf_flush_type
1210 * Flush type.
1211 * 0 - All SWID dynamic entries are flushed.
1212 * 1 - All FID dynamic entries are flushed.
1213 * 2 - All dynamic entries pointing to port are flushed.
1214 * 3 - All FID dynamic entries pointing to port are flushed.
1215 * 4 - All dynamic entries pointing to LAG are flushed.
1216 * 5 - All FID dynamic entries pointing to LAG are flushed.
Ido Schimmela682a302018-10-11 07:47:56 +00001217 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1218 * flushed.
1219 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1220 * flushed, per FID.
Ido Schimmel41933272016-01-27 15:20:17 +01001221 * Access: RW
1222 */
1223MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1224
1225/* reg_sfdf_flush_static
1226 * Static.
1227 * 0 - Flush only dynamic entries.
1228 * 1 - Flush both dynamic and static entries.
1229 * Access: RW
1230 */
1231MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1232
1233static inline void mlxsw_reg_sfdf_pack(char *payload,
1234 enum mlxsw_reg_sfdf_flush_type type)
1235{
1236 MLXSW_REG_ZERO(sfdf, payload);
1237 mlxsw_reg_sfdf_flush_type_set(payload, type);
1238 mlxsw_reg_sfdf_flush_static_set(payload, true);
1239}
1240
1241/* reg_sfdf_fid
1242 * FID to flush.
1243 * Access: RW
1244 */
1245MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1246
1247/* reg_sfdf_system_port
1248 * Port to flush.
1249 * Access: RW
1250 */
1251MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1252
1253/* reg_sfdf_port_fid_system_port
1254 * Port to flush, pointed to by FID.
1255 * Access: RW
1256 */
1257MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1258
1259/* reg_sfdf_lag_id
1260 * LAG ID to flush.
1261 * Access: RW
1262 */
1263MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1264
1265/* reg_sfdf_lag_fid_lag_id
1266 * LAG ID to flush, pointed to by FID.
1267 * Access: RW
1268 */
1269MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1270
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001271/* SLDR - Switch LAG Descriptor Register
1272 * -----------------------------------------
1273 * The switch LAG descriptor register is populated by LAG descriptors.
1274 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1275 * max_lag-1.
1276 */
1277#define MLXSW_REG_SLDR_ID 0x2014
1278#define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1279
Jiri Pirko21978dc2016-10-21 16:07:20 +02001280MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001281
1282enum mlxsw_reg_sldr_op {
1283 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1284 MLXSW_REG_SLDR_OP_LAG_CREATE,
1285 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1286 /* Ports that appear in the list have the Distributor enabled */
1287 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1288 /* Removes ports from the disributor list */
1289 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1290};
1291
1292/* reg_sldr_op
1293 * Operation.
1294 * Access: RW
1295 */
1296MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1297
1298/* reg_sldr_lag_id
1299 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1300 * Access: Index
1301 */
1302MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1303
1304static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1305{
1306 MLXSW_REG_ZERO(sldr, payload);
1307 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1308 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1309}
1310
1311static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1312{
1313 MLXSW_REG_ZERO(sldr, payload);
1314 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1315 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1316}
1317
1318/* reg_sldr_num_ports
1319 * The number of member ports of the LAG.
1320 * Reserved for Create / Destroy operations
1321 * For Add / Remove operations - indicates the number of ports in the list.
1322 * Access: RW
1323 */
1324MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1325
1326/* reg_sldr_system_port
1327 * System port.
1328 * Access: RW
1329 */
1330MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1331
1332static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1333 u8 local_port)
1334{
1335 MLXSW_REG_ZERO(sldr, payload);
1336 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1337 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1338 mlxsw_reg_sldr_num_ports_set(payload, 1);
1339 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1340}
1341
1342static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1343 u8 local_port)
1344{
1345 MLXSW_REG_ZERO(sldr, payload);
1346 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1347 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1348 mlxsw_reg_sldr_num_ports_set(payload, 1);
1349 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1350}
1351
1352/* SLCR - Switch LAG Configuration 2 Register
1353 * -------------------------------------------
1354 * The Switch LAG Configuration register is used for configuring the
1355 * LAG properties of the switch.
1356 */
1357#define MLXSW_REG_SLCR_ID 0x2015
1358#define MLXSW_REG_SLCR_LEN 0x10
1359
Jiri Pirko21978dc2016-10-21 16:07:20 +02001360MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001361
1362enum mlxsw_reg_slcr_pp {
1363 /* Global Configuration (for all ports) */
1364 MLXSW_REG_SLCR_PP_GLOBAL,
1365 /* Per port configuration, based on local_port field */
1366 MLXSW_REG_SLCR_PP_PER_PORT,
1367};
1368
1369/* reg_slcr_pp
1370 * Per Port Configuration
1371 * Note: Reading at Global mode results in reading port 1 configuration.
1372 * Access: Index
1373 */
1374MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1375
1376/* reg_slcr_local_port
1377 * Local port number
1378 * Supported from CPU port
1379 * Not supported from router port
1380 * Reserved when pp = Global Configuration
1381 * Access: Index
1382 */
1383MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1384
1385enum mlxsw_reg_slcr_type {
1386 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1387 MLXSW_REG_SLCR_TYPE_XOR,
1388 MLXSW_REG_SLCR_TYPE_RANDOM,
1389};
1390
1391/* reg_slcr_type
1392 * Hash type
1393 * Access: RW
1394 */
1395MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1396
1397/* Ingress port */
1398#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1399/* SMAC - for IPv4 and IPv6 packets */
1400#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1401/* SMAC - for non-IP packets */
1402#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1403#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1404 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1405 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1406/* DMAC - for IPv4 and IPv6 packets */
1407#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1408/* DMAC - for non-IP packets */
1409#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1410#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1411 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1412 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1413/* Ethertype - for IPv4 and IPv6 packets */
1414#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1415/* Ethertype - for non-IP packets */
1416#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1417#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1418 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1419 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1420/* VLAN ID - for IPv4 and IPv6 packets */
1421#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1422/* VLAN ID - for non-IP packets */
1423#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1424#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1425 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1426 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1427/* Source IP address (can be IPv4 or IPv6) */
1428#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1429/* Destination IP address (can be IPv4 or IPv6) */
1430#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1431/* TCP/UDP source port */
1432#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1433/* TCP/UDP destination port*/
1434#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1435/* IPv4 Protocol/IPv6 Next Header */
1436#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1437/* IPv6 Flow label */
1438#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1439/* SID - FCoE source ID */
1440#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1441/* DID - FCoE destination ID */
1442#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1443/* OXID - FCoE originator exchange ID */
1444#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1445/* Destination QP number - for RoCE packets */
1446#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1447
1448/* reg_slcr_lag_hash
1449 * LAG hashing configuration. This is a bitmask, in which each set
1450 * bit includes the corresponding item in the LAG hash calculation.
1451 * The default lag_hash contains SMAC, DMAC, VLANID and
1452 * Ethertype (for all packet types).
1453 * Access: RW
1454 */
1455MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1456
Ido Schimmelbeda7f72018-10-11 07:47:57 +00001457/* reg_slcr_seed
1458 * LAG seed value. The seed is the same for all ports.
1459 * Access: RW
1460 */
1461MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1462
1463static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001464{
1465 MLXSW_REG_ZERO(slcr, payload);
1466 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
Elad Raz18c2d2c2016-09-19 08:28:24 +02001467 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001468 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
Ido Schimmelbeda7f72018-10-11 07:47:57 +00001469 mlxsw_reg_slcr_seed_set(payload, seed);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001470}
1471
1472/* SLCOR - Switch LAG Collector Register
1473 * -------------------------------------
1474 * The Switch LAG Collector register controls the Local Port membership
1475 * in a LAG and enablement of the collector.
1476 */
1477#define MLXSW_REG_SLCOR_ID 0x2016
1478#define MLXSW_REG_SLCOR_LEN 0x10
1479
Jiri Pirko21978dc2016-10-21 16:07:20 +02001480MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001481
1482enum mlxsw_reg_slcor_col {
1483 /* Port is added with collector disabled */
1484 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1485 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1486 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1487 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1488};
1489
1490/* reg_slcor_col
1491 * Collector configuration
1492 * Access: RW
1493 */
1494MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1495
1496/* reg_slcor_local_port
1497 * Local port number
1498 * Not supported for CPU port
1499 * Access: Index
1500 */
1501MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1502
1503/* reg_slcor_lag_id
1504 * LAG Identifier. Index into the LAG descriptor table.
1505 * Access: Index
1506 */
1507MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1508
1509/* reg_slcor_port_index
1510 * Port index in the LAG list. Only valid on Add Port to LAG col.
1511 * Valid range is from 0 to cap_max_lag_members-1
1512 * Access: RW
1513 */
1514MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1515
1516static inline void mlxsw_reg_slcor_pack(char *payload,
1517 u8 local_port, u16 lag_id,
1518 enum mlxsw_reg_slcor_col col)
1519{
1520 MLXSW_REG_ZERO(slcor, payload);
1521 mlxsw_reg_slcor_col_set(payload, col);
1522 mlxsw_reg_slcor_local_port_set(payload, local_port);
1523 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1524}
1525
1526static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1527 u8 local_port, u16 lag_id,
1528 u8 port_index)
1529{
1530 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1531 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1532 mlxsw_reg_slcor_port_index_set(payload, port_index);
1533}
1534
1535static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1536 u8 local_port, u16 lag_id)
1537{
1538 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1539 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1540}
1541
1542static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1543 u8 local_port, u16 lag_id)
1544{
1545 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1546 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1547}
1548
1549static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1550 u8 local_port, u16 lag_id)
1551{
1552 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1553 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1554}
1555
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001556/* SPMLR - Switch Port MAC Learning Register
1557 * -----------------------------------------
1558 * Controls the Switch MAC learning policy per port.
1559 */
1560#define MLXSW_REG_SPMLR_ID 0x2018
1561#define MLXSW_REG_SPMLR_LEN 0x8
1562
Jiri Pirko21978dc2016-10-21 16:07:20 +02001563MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001564
1565/* reg_spmlr_local_port
1566 * Local port number.
1567 * Access: Index
1568 */
1569MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1570
1571/* reg_spmlr_sub_port
1572 * Virtual port within the physical port.
1573 * Should be set to 0 when virtual ports are not enabled on the port.
1574 * Access: Index
1575 */
1576MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1577
1578enum mlxsw_reg_spmlr_learn_mode {
1579 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1580 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1581 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1582};
1583
1584/* reg_spmlr_learn_mode
1585 * Learning mode on the port.
1586 * 0 - Learning disabled.
1587 * 2 - Learning enabled.
1588 * 3 - Security mode.
1589 *
1590 * In security mode the switch does not learn MACs on the port, but uses the
1591 * SMAC to see if it exists on another ingress port. If so, the packet is
1592 * classified as a bad packet and is discarded unless the software registers
1593 * to receive port security error packets usign HPKT.
1594 */
1595MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1596
1597static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1598 enum mlxsw_reg_spmlr_learn_mode mode)
1599{
1600 MLXSW_REG_ZERO(spmlr, payload);
1601 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1602 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1603 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1604}
1605
Ido Schimmel64790232015-10-16 14:01:33 +02001606/* SVFA - Switch VID to FID Allocation Register
1607 * --------------------------------------------
1608 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1609 * virtualized ports.
1610 */
1611#define MLXSW_REG_SVFA_ID 0x201C
1612#define MLXSW_REG_SVFA_LEN 0x10
1613
Jiri Pirko21978dc2016-10-21 16:07:20 +02001614MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
Ido Schimmel64790232015-10-16 14:01:33 +02001615
1616/* reg_svfa_swid
1617 * Switch partition ID.
1618 * Access: Index
1619 */
1620MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1621
1622/* reg_svfa_local_port
1623 * Local port number.
1624 * Access: Index
1625 *
1626 * Note: Reserved for 802.1Q FIDs.
1627 */
1628MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1629
1630enum mlxsw_reg_svfa_mt {
1631 MLXSW_REG_SVFA_MT_VID_TO_FID,
1632 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1633};
1634
1635/* reg_svfa_mapping_table
1636 * Mapping table:
1637 * 0 - VID to FID
1638 * 1 - {Port, VID} to FID
1639 * Access: Index
1640 *
1641 * Note: Reserved for SwitchX-2.
1642 */
1643MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1644
1645/* reg_svfa_v
1646 * Valid.
1647 * Valid if set.
1648 * Access: RW
1649 *
1650 * Note: Reserved for SwitchX-2.
1651 */
1652MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1653
1654/* reg_svfa_fid
1655 * Filtering ID.
1656 * Access: RW
1657 */
1658MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1659
1660/* reg_svfa_vid
1661 * VLAN ID.
1662 * Access: Index
1663 */
1664MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1665
1666/* reg_svfa_counter_set_type
1667 * Counter set type for flow counters.
1668 * Access: RW
1669 *
1670 * Note: Reserved for SwitchX-2.
1671 */
1672MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1673
1674/* reg_svfa_counter_index
1675 * Counter index for flow counters.
1676 * Access: RW
1677 *
1678 * Note: Reserved for SwitchX-2.
1679 */
1680MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1681
1682static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1683 enum mlxsw_reg_svfa_mt mt, bool valid,
1684 u16 fid, u16 vid)
1685{
1686 MLXSW_REG_ZERO(svfa, payload);
1687 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1688 mlxsw_reg_svfa_swid_set(payload, 0);
1689 mlxsw_reg_svfa_local_port_set(payload, local_port);
1690 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1691 mlxsw_reg_svfa_v_set(payload, valid);
1692 mlxsw_reg_svfa_fid_set(payload, fid);
1693 mlxsw_reg_svfa_vid_set(payload, vid);
1694}
1695
Amit Cohenc1c32a72020-12-08 11:22:42 +02001696/* SPVTR - Switch Port VLAN Stacking Register
1697 * ------------------------------------------
1698 * The Switch Port VLAN Stacking register configures the VLAN mode of the port
1699 * to enable VLAN stacking.
1700 */
1701#define MLXSW_REG_SPVTR_ID 0x201D
1702#define MLXSW_REG_SPVTR_LEN 0x10
1703
1704MLXSW_REG_DEFINE(spvtr, MLXSW_REG_SPVTR_ID, MLXSW_REG_SPVTR_LEN);
1705
1706/* reg_spvtr_tport
1707 * Port is tunnel port.
1708 * Access: Index
1709 *
1710 * Note: Reserved when SwitchX/-2 or Spectrum-1.
1711 */
1712MLXSW_ITEM32(reg, spvtr, tport, 0x00, 24, 1);
1713
1714/* reg_spvtr_local_port
1715 * When tport = 0: local port number (Not supported from/to CPU).
1716 * When tport = 1: tunnel port.
1717 * Access: Index
1718 */
1719MLXSW_ITEM32(reg, spvtr, local_port, 0x00, 16, 8);
1720
1721/* reg_spvtr_ippe
1722 * Ingress Port Prio Mode Update Enable.
1723 * When set, the Port Prio Mode is updated with the provided ipprio_mode field.
1724 * Reserved on Get operations.
1725 * Access: OP
1726 */
1727MLXSW_ITEM32(reg, spvtr, ippe, 0x04, 31, 1);
1728
1729/* reg_spvtr_ipve
1730 * Ingress Port VID Mode Update Enable.
1731 * When set, the Ingress Port VID Mode is updated with the provided ipvid_mode
1732 * field.
1733 * Reserved on Get operations.
1734 * Access: OP
1735 */
1736MLXSW_ITEM32(reg, spvtr, ipve, 0x04, 30, 1);
1737
1738/* reg_spvtr_epve
1739 * Egress Port VID Mode Update Enable.
1740 * When set, the Egress Port VID Mode is updated with the provided epvid_mode
1741 * field.
1742 * Access: OP
1743 */
1744MLXSW_ITEM32(reg, spvtr, epve, 0x04, 29, 1);
1745
1746/* reg_spvtr_ipprio_mode
1747 * Ingress Port Priority Mode.
1748 * This controls the PCP and DEI of the new outer VLAN
1749 * Note: for SwitchX/-2 the DEI is not affected.
1750 * 0: use port default PCP and DEI (configured by QPDPC).
1751 * 1: use C-VLAN PCP and DEI.
1752 * Has no effect when ipvid_mode = 0.
1753 * Reserved when tport = 1.
1754 * Access: RW
1755 */
1756MLXSW_ITEM32(reg, spvtr, ipprio_mode, 0x04, 20, 4);
1757
1758enum mlxsw_reg_spvtr_ipvid_mode {
1759 /* IEEE Compliant PVID (default) */
1760 MLXSW_REG_SPVTR_IPVID_MODE_IEEE_COMPLIANT_PVID,
1761 /* Push VLAN (for VLAN stacking, except prio tagged packets) */
1762 MLXSW_REG_SPVTR_IPVID_MODE_PUSH_VLAN_FOR_UNTAGGED_PACKET,
1763 /* Always push VLAN (also for prio tagged packets) */
1764 MLXSW_REG_SPVTR_IPVID_MODE_ALWAYS_PUSH_VLAN,
1765};
1766
1767/* reg_spvtr_ipvid_mode
1768 * Ingress Port VLAN-ID Mode.
1769 * For Spectrum family, this affects the values of SPVM.i
1770 * Access: RW
1771 */
1772MLXSW_ITEM32(reg, spvtr, ipvid_mode, 0x04, 16, 4);
1773
1774enum mlxsw_reg_spvtr_epvid_mode {
1775 /* IEEE Compliant VLAN membership */
1776 MLXSW_REG_SPVTR_EPVID_MODE_IEEE_COMPLIANT_VLAN_MEMBERSHIP,
1777 /* Pop VLAN (for VLAN stacking) */
1778 MLXSW_REG_SPVTR_EPVID_MODE_POP_VLAN,
1779};
1780
1781/* reg_spvtr_epvid_mode
1782 * Egress Port VLAN-ID Mode.
1783 * For Spectrum family, this affects the values of SPVM.e,u,pt.
1784 * Access: WO
1785 */
1786MLXSW_ITEM32(reg, spvtr, epvid_mode, 0x04, 0, 4);
1787
1788static inline void mlxsw_reg_spvtr_pack(char *payload, bool tport,
1789 u8 local_port,
1790 enum mlxsw_reg_spvtr_ipvid_mode ipvid_mode)
1791{
1792 MLXSW_REG_ZERO(spvtr, payload);
1793 mlxsw_reg_spvtr_tport_set(payload, tport);
1794 mlxsw_reg_spvtr_local_port_set(payload, local_port);
1795 mlxsw_reg_spvtr_ipvid_mode_set(payload, ipvid_mode);
1796 mlxsw_reg_spvtr_ipve_set(payload, true);
1797}
1798
Ido Schimmel1f65da72015-10-16 14:01:34 +02001799/* SVPE - Switch Virtual-Port Enabling Register
1800 * --------------------------------------------
1801 * Enables port virtualization.
1802 */
1803#define MLXSW_REG_SVPE_ID 0x201E
1804#define MLXSW_REG_SVPE_LEN 0x4
1805
Jiri Pirko21978dc2016-10-21 16:07:20 +02001806MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
Ido Schimmel1f65da72015-10-16 14:01:34 +02001807
1808/* reg_svpe_local_port
1809 * Local port number
1810 * Access: Index
1811 *
1812 * Note: CPU port is not supported (uses VLAN mode only).
1813 */
1814MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1815
1816/* reg_svpe_vp_en
1817 * Virtual port enable.
1818 * 0 - Disable, VLAN mode (VID to FID).
1819 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1820 * Access: RW
1821 */
1822MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1823
1824static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1825 bool enable)
1826{
1827 MLXSW_REG_ZERO(svpe, payload);
1828 mlxsw_reg_svpe_local_port_set(payload, local_port);
1829 mlxsw_reg_svpe_vp_en_set(payload, enable);
1830}
1831
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001832/* SFMR - Switch FID Management Register
1833 * -------------------------------------
1834 * Creates and configures FIDs.
1835 */
1836#define MLXSW_REG_SFMR_ID 0x201F
1837#define MLXSW_REG_SFMR_LEN 0x18
1838
Jiri Pirko21978dc2016-10-21 16:07:20 +02001839MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001840
1841enum mlxsw_reg_sfmr_op {
1842 MLXSW_REG_SFMR_OP_CREATE_FID,
1843 MLXSW_REG_SFMR_OP_DESTROY_FID,
1844};
1845
1846/* reg_sfmr_op
1847 * Operation.
1848 * 0 - Create or edit FID.
1849 * 1 - Destroy FID.
1850 * Access: WO
1851 */
1852MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1853
1854/* reg_sfmr_fid
1855 * Filtering ID.
1856 * Access: Index
1857 */
1858MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1859
1860/* reg_sfmr_fid_offset
1861 * FID offset.
1862 * Used to point into the flooding table selected by SFGC register if
1863 * the table is of type FID-Offset. Otherwise, this field is reserved.
1864 * Access: RW
1865 */
1866MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1867
1868/* reg_sfmr_vtfp
1869 * Valid Tunnel Flood Pointer.
1870 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1871 * Access: RW
1872 *
1873 * Note: Reserved for 802.1Q FIDs.
1874 */
1875MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1876
1877/* reg_sfmr_nve_tunnel_flood_ptr
1878 * Underlay Flooding and BC Pointer.
1879 * Used as a pointer to the first entry of the group based link lists of
1880 * flooding or BC entries (for NVE tunnels).
1881 * Access: RW
1882 */
1883MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1884
1885/* reg_sfmr_vv
1886 * VNI Valid.
1887 * If not set, then vni is reserved.
1888 * Access: RW
1889 *
1890 * Note: Reserved for 802.1Q FIDs.
1891 */
1892MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1893
1894/* reg_sfmr_vni
1895 * Virtual Network Identifier.
1896 * Access: RW
1897 *
1898 * Note: A given VNI can only be assigned to one FID.
1899 */
1900MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1901
1902static inline void mlxsw_reg_sfmr_pack(char *payload,
1903 enum mlxsw_reg_sfmr_op op, u16 fid,
1904 u16 fid_offset)
1905{
1906 MLXSW_REG_ZERO(sfmr, payload);
1907 mlxsw_reg_sfmr_op_set(payload, op);
1908 mlxsw_reg_sfmr_fid_set(payload, fid);
1909 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1910 mlxsw_reg_sfmr_vtfp_set(payload, false);
1911 mlxsw_reg_sfmr_vv_set(payload, false);
1912}
1913
Ido Schimmela4feea72015-10-16 14:01:36 +02001914/* SPVMLR - Switch Port VLAN MAC Learning Register
1915 * -----------------------------------------------
1916 * Controls the switch MAC learning policy per {Port, VID}.
1917 */
1918#define MLXSW_REG_SPVMLR_ID 0x2020
1919#define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1920#define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
Jiri Pirkoe9093b12017-03-14 14:00:01 +01001921#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
Ido Schimmela4feea72015-10-16 14:01:36 +02001922#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1923 MLXSW_REG_SPVMLR_REC_LEN * \
1924 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1925
Jiri Pirko21978dc2016-10-21 16:07:20 +02001926MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
Ido Schimmela4feea72015-10-16 14:01:36 +02001927
1928/* reg_spvmlr_local_port
1929 * Local ingress port.
1930 * Access: Index
1931 *
1932 * Note: CPU port is not supported.
1933 */
1934MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1935
1936/* reg_spvmlr_num_rec
1937 * Number of records to update.
1938 * Access: OP
1939 */
1940MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1941
1942/* reg_spvmlr_rec_learn_enable
1943 * 0 - Disable learning for {Port, VID}.
1944 * 1 - Enable learning for {Port, VID}.
1945 * Access: RW
1946 */
1947MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1948 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1949
1950/* reg_spvmlr_rec_vid
1951 * VLAN ID to be added/removed from port or for querying.
1952 * Access: Index
1953 */
1954MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1955 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1956
1957static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1958 u16 vid_begin, u16 vid_end,
1959 bool learn_enable)
1960{
1961 int num_rec = vid_end - vid_begin + 1;
1962 int i;
1963
1964 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1965
1966 MLXSW_REG_ZERO(spvmlr, payload);
1967 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1968 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1969
1970 for (i = 0; i < num_rec; i++) {
1971 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1972 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1973 }
1974}
1975
Amit Cohen7e9a6622020-11-29 14:53:59 +02001976/* SPVC - Switch Port VLAN Classification Register
1977 * -----------------------------------------------
1978 * Configures the port to identify packets as untagged / single tagged /
1979 * double packets based on the packet EtherTypes.
1980 * Ethertype IDs are configured by SVER.
1981 */
1982#define MLXSW_REG_SPVC_ID 0x2026
1983#define MLXSW_REG_SPVC_LEN 0x0C
1984
1985MLXSW_REG_DEFINE(spvc, MLXSW_REG_SPVC_ID, MLXSW_REG_SPVC_LEN);
1986
1987/* reg_spvc_local_port
1988 * Local port.
1989 * Access: Index
1990 *
1991 * Note: applies both to Rx port and Tx port, so if a packet traverses
1992 * through Rx port i and a Tx port j then port i and port j must have the
1993 * same configuration.
1994 */
1995MLXSW_ITEM32(reg, spvc, local_port, 0x00, 16, 8);
1996
1997/* reg_spvc_inner_et2
1998 * Vlan Tag1 EtherType2 enable.
1999 * Packet is initially classified as double VLAN Tag if in addition to
2000 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
2001 * equal to ether_type2.
2002 * 0: disable (default)
2003 * 1: enable
2004 * Access: RW
2005 */
2006MLXSW_ITEM32(reg, spvc, inner_et2, 0x08, 17, 1);
2007
2008/* reg_spvc_et2
2009 * Vlan Tag0 EtherType2 enable.
2010 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
2011 * equal to ether_type2.
2012 * 0: disable (default)
2013 * 1: enable
2014 * Access: RW
2015 */
2016MLXSW_ITEM32(reg, spvc, et2, 0x08, 16, 1);
2017
2018/* reg_spvc_inner_et1
2019 * Vlan Tag1 EtherType1 enable.
2020 * Packet is initially classified as double VLAN Tag if in addition to
2021 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
2022 * equal to ether_type1.
2023 * 0: disable
2024 * 1: enable (default)
2025 * Access: RW
2026 */
2027MLXSW_ITEM32(reg, spvc, inner_et1, 0x08, 9, 1);
2028
2029/* reg_spvc_et1
2030 * Vlan Tag0 EtherType1 enable.
2031 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
2032 * equal to ether_type1.
2033 * 0: disable
2034 * 1: enable (default)
2035 * Access: RW
2036 */
2037MLXSW_ITEM32(reg, spvc, et1, 0x08, 8, 1);
2038
2039/* reg_inner_et0
2040 * Vlan Tag1 EtherType0 enable.
2041 * Packet is initially classified as double VLAN Tag if in addition to
2042 * being classified with a tag0 VLAN Tag its tag1 EtherType value is
2043 * equal to ether_type0.
2044 * 0: disable
2045 * 1: enable (default)
2046 * Access: RW
2047 */
2048MLXSW_ITEM32(reg, spvc, inner_et0, 0x08, 1, 1);
2049
2050/* reg_et0
2051 * Vlan Tag0 EtherType0 enable.
2052 * Packet is initially classified as VLAN Tag if its tag0 EtherType is
2053 * equal to ether_type0.
2054 * 0: disable
2055 * 1: enable (default)
2056 * Access: RW
2057 */
2058MLXSW_ITEM32(reg, spvc, et0, 0x08, 0, 1);
2059
2060static inline void mlxsw_reg_spvc_pack(char *payload, u8 local_port, bool et1,
2061 bool et0)
2062{
2063 MLXSW_REG_ZERO(spvc, payload);
2064 mlxsw_reg_spvc_local_port_set(payload, local_port);
2065 /* Enable inner_et1 and inner_et0 to enable identification of double
2066 * tagged packets.
2067 */
2068 mlxsw_reg_spvc_inner_et1_set(payload, 1);
2069 mlxsw_reg_spvc_inner_et0_set(payload, 1);
2070 mlxsw_reg_spvc_et1_set(payload, et1);
2071 mlxsw_reg_spvc_et0_set(payload, et0);
2072}
2073
Nogah Frankelad53fa02017-11-06 07:23:44 +01002074/* CWTP - Congetion WRED ECN TClass Profile
2075 * ----------------------------------------
2076 * Configures the profiles for queues of egress port and traffic class
2077 */
2078#define MLXSW_REG_CWTP_ID 0x2802
2079#define MLXSW_REG_CWTP_BASE_LEN 0x28
2080#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
2081#define MLXSW_REG_CWTP_LEN 0x40
2082
2083MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
2084
2085/* reg_cwtp_local_port
2086 * Local port number
2087 * Not supported for CPU port
2088 * Access: Index
2089 */
2090MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
2091
2092/* reg_cwtp_traffic_class
2093 * Traffic Class to configure
2094 * Access: Index
2095 */
2096MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
2097
2098/* reg_cwtp_profile_min
2099 * Minimum Average Queue Size of the profile in cells.
2100 * Access: RW
2101 */
2102MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
2103 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
2104
2105/* reg_cwtp_profile_percent
2106 * Percentage of WRED and ECN marking for maximum Average Queue size
2107 * Range is 0 to 100, units of integer percentage
2108 * Access: RW
2109 */
2110MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
2111 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2112
2113/* reg_cwtp_profile_max
2114 * Maximum Average Queue size of the profile in cells
2115 * Access: RW
2116 */
2117MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
2118 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2119
2120#define MLXSW_REG_CWTP_MIN_VALUE 64
2121#define MLXSW_REG_CWTP_MAX_PROFILE 2
2122#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
2123
2124static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
2125 u8 traffic_class)
2126{
2127 int i;
2128
2129 MLXSW_REG_ZERO(cwtp, payload);
2130 mlxsw_reg_cwtp_local_port_set(payload, local_port);
2131 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
2132
2133 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
2134 mlxsw_reg_cwtp_profile_min_set(payload, i,
2135 MLXSW_REG_CWTP_MIN_VALUE);
2136 mlxsw_reg_cwtp_profile_max_set(payload, i,
2137 MLXSW_REG_CWTP_MIN_VALUE);
2138 }
2139}
2140
2141#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
2142
2143static inline void
2144mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
2145 u32 probability)
2146{
2147 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
2148
2149 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
2150 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
2151 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
2152}
2153
2154/* CWTPM - Congestion WRED ECN TClass and Pool Mapping
2155 * ---------------------------------------------------
2156 * The CWTPM register maps each egress port and traffic class to profile num.
2157 */
2158#define MLXSW_REG_CWTPM_ID 0x2803
2159#define MLXSW_REG_CWTPM_LEN 0x44
2160
2161MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
2162
2163/* reg_cwtpm_local_port
2164 * Local port number
2165 * Not supported for CPU port
2166 * Access: Index
2167 */
2168MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
2169
2170/* reg_cwtpm_traffic_class
2171 * Traffic Class to configure
2172 * Access: Index
2173 */
2174MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
2175
2176/* reg_cwtpm_ew
2177 * Control enablement of WRED for traffic class:
2178 * 0 - Disable
2179 * 1 - Enable
2180 * Access: RW
2181 */
2182MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
2183
2184/* reg_cwtpm_ee
2185 * Control enablement of ECN for traffic class:
2186 * 0 - Disable
2187 * 1 - Enable
2188 * Access: RW
2189 */
2190MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
2191
2192/* reg_cwtpm_tcp_g
2193 * TCP Green Profile.
2194 * Index of the profile within {port, traffic class} to use.
2195 * 0 for disabling both WRED and ECN for this type of traffic.
2196 * Access: RW
2197 */
2198MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
2199
2200/* reg_cwtpm_tcp_y
2201 * TCP Yellow Profile.
2202 * Index of the profile within {port, traffic class} to use.
2203 * 0 for disabling both WRED and ECN for this type of traffic.
2204 * Access: RW
2205 */
2206MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
2207
2208/* reg_cwtpm_tcp_r
2209 * TCP Red Profile.
2210 * Index of the profile within {port, traffic class} to use.
2211 * 0 for disabling both WRED and ECN for this type of traffic.
2212 * Access: RW
2213 */
2214MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
2215
2216/* reg_cwtpm_ntcp_g
2217 * Non-TCP Green Profile.
2218 * Index of the profile within {port, traffic class} to use.
2219 * 0 for disabling both WRED and ECN for this type of traffic.
2220 * Access: RW
2221 */
2222MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
2223
2224/* reg_cwtpm_ntcp_y
2225 * Non-TCP Yellow Profile.
2226 * Index of the profile within {port, traffic class} to use.
2227 * 0 for disabling both WRED and ECN for this type of traffic.
2228 * Access: RW
2229 */
2230MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
2231
2232/* reg_cwtpm_ntcp_r
2233 * Non-TCP Red Profile.
2234 * Index of the profile within {port, traffic class} to use.
2235 * 0 for disabling both WRED and ECN for this type of traffic.
2236 * Access: RW
2237 */
2238MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
2239
2240#define MLXSW_REG_CWTPM_RESET_PROFILE 0
2241
2242static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
2243 u8 traffic_class, u8 profile,
2244 bool wred, bool ecn)
2245{
2246 MLXSW_REG_ZERO(cwtpm, payload);
2247 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
2248 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
2249 mlxsw_reg_cwtpm_ew_set(payload, wred);
2250 mlxsw_reg_cwtpm_ee_set(payload, ecn);
2251 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
2252 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
2253 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
2254 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
2255 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
2256 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
2257}
2258
Ido Schimmel7050f432018-07-18 11:14:40 +03002259/* PGCR - Policy-Engine General Configuration Register
2260 * ---------------------------------------------------
2261 * This register configures general Policy-Engine settings.
2262 */
2263#define MLXSW_REG_PGCR_ID 0x3001
2264#define MLXSW_REG_PGCR_LEN 0x20
2265
2266MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
2267
2268/* reg_pgcr_default_action_pointer_base
2269 * Default action pointer base. Each region has a default action pointer
2270 * which is equal to default_action_pointer_base + region_id.
2271 * Access: RW
2272 */
2273MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
2274
2275static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
2276{
2277 MLXSW_REG_ZERO(pgcr, payload);
2278 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
2279}
2280
Jiri Pirkoaf7170e2017-02-03 10:28:57 +01002281/* PPBT - Policy-Engine Port Binding Table
2282 * ---------------------------------------
2283 * This register is used for configuration of the Port Binding Table.
2284 */
2285#define MLXSW_REG_PPBT_ID 0x3002
2286#define MLXSW_REG_PPBT_LEN 0x14
2287
2288MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
2289
2290enum mlxsw_reg_pxbt_e {
2291 MLXSW_REG_PXBT_E_IACL,
2292 MLXSW_REG_PXBT_E_EACL,
2293};
2294
2295/* reg_ppbt_e
2296 * Access: Index
2297 */
2298MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
2299
2300enum mlxsw_reg_pxbt_op {
2301 MLXSW_REG_PXBT_OP_BIND,
2302 MLXSW_REG_PXBT_OP_UNBIND,
2303};
2304
2305/* reg_ppbt_op
2306 * Access: RW
2307 */
2308MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
2309
2310/* reg_ppbt_local_port
2311 * Local port. Not including CPU port.
2312 * Access: Index
2313 */
2314MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
2315
2316/* reg_ppbt_g
2317 * group - When set, the binding is of an ACL group. When cleared,
2318 * the binding is of an ACL.
2319 * Must be set to 1 for Spectrum.
2320 * Access: RW
2321 */
2322MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2323
2324/* reg_ppbt_acl_info
2325 * ACL/ACL group identifier. If the g bit is set, this field should hold
2326 * the acl_group_id, else it should hold the acl_id.
2327 * Access: RW
2328 */
2329MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2330
2331static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2332 enum mlxsw_reg_pxbt_op op,
2333 u8 local_port, u16 acl_info)
2334{
2335 MLXSW_REG_ZERO(ppbt, payload);
2336 mlxsw_reg_ppbt_e_set(payload, e);
2337 mlxsw_reg_ppbt_op_set(payload, op);
2338 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2339 mlxsw_reg_ppbt_g_set(payload, true);
2340 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2341}
2342
Jiri Pirko3279da42017-02-03 10:28:53 +01002343/* PACL - Policy-Engine ACL Register
2344 * ---------------------------------
2345 * This register is used for configuration of the ACL.
2346 */
2347#define MLXSW_REG_PACL_ID 0x3004
2348#define MLXSW_REG_PACL_LEN 0x70
2349
2350MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2351
2352/* reg_pacl_v
2353 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2354 * while the ACL is bounded to either a port, VLAN or ACL rule.
2355 * Access: RW
2356 */
2357MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2358
2359/* reg_pacl_acl_id
2360 * An identifier representing the ACL (managed by software)
2361 * Range 0 .. cap_max_acl_regions - 1
2362 * Access: Index
2363 */
2364MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2365
2366#define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2367
2368/* reg_pacl_tcam_region_info
2369 * Opaque object that represents a TCAM region.
2370 * Obtained through PTAR register.
2371 * Access: RW
2372 */
2373MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2374 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2375
2376static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2377 bool valid, const char *tcam_region_info)
2378{
2379 MLXSW_REG_ZERO(pacl, payload);
2380 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2381 mlxsw_reg_pacl_v_set(payload, valid);
2382 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2383}
2384
Jiri Pirko10fabef2017-02-03 10:28:54 +01002385/* PAGT - Policy-Engine ACL Group Table
2386 * ------------------------------------
2387 * This register is used for configuration of the ACL Group Table.
2388 */
2389#define MLXSW_REG_PAGT_ID 0x3005
2390#define MLXSW_REG_PAGT_BASE_LEN 0x30
2391#define MLXSW_REG_PAGT_ACL_LEN 4
2392#define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2393#define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2394 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2395
2396MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2397
2398/* reg_pagt_size
2399 * Number of ACLs in the group.
2400 * Size 0 invalidates a group.
2401 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2402 * Total number of ACLs in all groups must be lower or equal
2403 * to cap_max_acl_tot_groups
2404 * Note: a group which is binded must not be invalidated
2405 * Access: Index
2406 */
2407MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2408
2409/* reg_pagt_acl_group_id
2410 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2411 * the ACL Group identifier (managed by software).
2412 * Access: Index
2413 */
2414MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2415
Jiri Pirko5c661f12019-02-07 11:22:53 +00002416/* reg_pagt_multi
2417 * Multi-ACL
2418 * 0 - This ACL is the last ACL in the multi-ACL
2419 * 1 - This ACL is part of a multi-ACL
2420 * Access: RW
2421 */
2422MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
2423
Jiri Pirko10fabef2017-02-03 10:28:54 +01002424/* reg_pagt_acl_id
2425 * ACL identifier
2426 * Access: RW
2427 */
2428MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2429
2430static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2431{
2432 MLXSW_REG_ZERO(pagt, payload);
2433 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2434}
2435
2436static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
Jiri Pirko5c661f12019-02-07 11:22:53 +00002437 u16 acl_id, bool multi)
Jiri Pirko10fabef2017-02-03 10:28:54 +01002438{
2439 u8 size = mlxsw_reg_pagt_size_get(payload);
2440
2441 if (index >= size)
2442 mlxsw_reg_pagt_size_set(payload, index + 1);
Jiri Pirko5c661f12019-02-07 11:22:53 +00002443 mlxsw_reg_pagt_multi_set(payload, index, multi);
Jiri Pirko10fabef2017-02-03 10:28:54 +01002444 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2445}
2446
Jiri Pirkod9c26612017-02-03 10:28:55 +01002447/* PTAR - Policy-Engine TCAM Allocation Register
2448 * ---------------------------------------------
2449 * This register is used for allocation of regions in the TCAM.
2450 * Note: Query method is not supported on this register.
2451 */
2452#define MLXSW_REG_PTAR_ID 0x3006
2453#define MLXSW_REG_PTAR_BASE_LEN 0x20
2454#define MLXSW_REG_PTAR_KEY_ID_LEN 1
2455#define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2456#define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2457 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2458
2459MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2460
2461enum mlxsw_reg_ptar_op {
2462 /* allocate a TCAM region */
2463 MLXSW_REG_PTAR_OP_ALLOC,
2464 /* resize a TCAM region */
2465 MLXSW_REG_PTAR_OP_RESIZE,
2466 /* deallocate TCAM region */
2467 MLXSW_REG_PTAR_OP_FREE,
2468 /* test allocation */
2469 MLXSW_REG_PTAR_OP_TEST,
2470};
2471
2472/* reg_ptar_op
2473 * Access: OP
2474 */
2475MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2476
2477/* reg_ptar_action_set_type
2478 * Type of action set to be used on this region.
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002479 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
Jiri Pirkod9c26612017-02-03 10:28:55 +01002480 * Access: WO
2481 */
2482MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2483
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002484enum mlxsw_reg_ptar_key_type {
2485 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2486 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2487};
2488
Jiri Pirkod9c26612017-02-03 10:28:55 +01002489/* reg_ptar_key_type
2490 * TCAM key type for the region.
Jiri Pirkod9c26612017-02-03 10:28:55 +01002491 * Access: WO
2492 */
2493MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2494
2495/* reg_ptar_region_size
2496 * TCAM region size. When allocating/resizing this is the requested size,
2497 * the response is the actual size. Note that actual size may be
2498 * larger than requested.
2499 * Allowed range 1 .. cap_max_rules-1
2500 * Reserved during op deallocate.
2501 * Access: WO
2502 */
2503MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2504
2505/* reg_ptar_region_id
2506 * Region identifier
2507 * Range 0 .. cap_max_regions-1
2508 * Access: Index
2509 */
2510MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2511
2512/* reg_ptar_tcam_region_info
2513 * Opaque object that represents the TCAM region.
2514 * Returned when allocating a region.
2515 * Provided by software for ACL generation and region deallocation and resize.
2516 * Access: RW
2517 */
2518MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2519 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2520
2521/* reg_ptar_flexible_key_id
2522 * Identifier of the Flexible Key.
2523 * Only valid if key_type == "FLEX_KEY"
2524 * The key size will be rounded up to one of the following values:
2525 * 9B, 18B, 36B, 54B.
2526 * This field is reserved for in resize operation.
2527 * Access: WO
2528 */
2529MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2530 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2531
2532static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002533 enum mlxsw_reg_ptar_key_type key_type,
Jiri Pirkod9c26612017-02-03 10:28:55 +01002534 u16 region_size, u16 region_id,
2535 const char *tcam_region_info)
2536{
2537 MLXSW_REG_ZERO(ptar, payload);
2538 mlxsw_reg_ptar_op_set(payload, op);
2539 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002540 mlxsw_reg_ptar_key_type_set(payload, key_type);
Jiri Pirkod9c26612017-02-03 10:28:55 +01002541 mlxsw_reg_ptar_region_size_set(payload, region_size);
2542 mlxsw_reg_ptar_region_id_set(payload, region_id);
2543 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2544}
2545
2546static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2547 u16 key_id)
2548{
2549 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2550}
2551
2552static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2553{
2554 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2555}
2556
Jiri Pirkod1206492017-02-03 10:28:59 +01002557/* PPBS - Policy-Engine Policy Based Switching Register
2558 * ----------------------------------------------------
2559 * This register retrieves and sets Policy Based Switching Table entries.
2560 */
2561#define MLXSW_REG_PPBS_ID 0x300C
2562#define MLXSW_REG_PPBS_LEN 0x14
2563
2564MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2565
2566/* reg_ppbs_pbs_ptr
2567 * Index into the PBS table.
2568 * For Spectrum, the index points to the KVD Linear.
2569 * Access: Index
2570 */
2571MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2572
2573/* reg_ppbs_system_port
2574 * Unique port identifier for the final destination of the packet.
2575 * Access: RW
2576 */
2577MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2578
2579static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2580 u16 system_port)
2581{
2582 MLXSW_REG_ZERO(ppbs, payload);
2583 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2584 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2585}
2586
Jiri Pirko937b6822017-02-03 10:28:58 +01002587/* PRCR - Policy-Engine Rules Copy Register
2588 * ----------------------------------------
2589 * This register is used for accessing rules within a TCAM region.
2590 */
2591#define MLXSW_REG_PRCR_ID 0x300D
2592#define MLXSW_REG_PRCR_LEN 0x40
2593
2594MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2595
2596enum mlxsw_reg_prcr_op {
2597 /* Move rules. Moves the rules from "tcam_region_info" starting
2598 * at offset "offset" to "dest_tcam_region_info"
2599 * at offset "dest_offset."
2600 */
2601 MLXSW_REG_PRCR_OP_MOVE,
2602 /* Copy rules. Copies the rules from "tcam_region_info" starting
2603 * at offset "offset" to "dest_tcam_region_info"
2604 * at offset "dest_offset."
2605 */
2606 MLXSW_REG_PRCR_OP_COPY,
2607};
2608
2609/* reg_prcr_op
2610 * Access: OP
2611 */
2612MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2613
2614/* reg_prcr_offset
2615 * Offset within the source region to copy/move from.
2616 * Access: Index
2617 */
2618MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2619
2620/* reg_prcr_size
2621 * The number of rules to copy/move.
2622 * Access: WO
2623 */
2624MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2625
2626/* reg_prcr_tcam_region_info
2627 * Opaque object that represents the source TCAM region.
2628 * Access: Index
2629 */
2630MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2631 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2632
2633/* reg_prcr_dest_offset
2634 * Offset within the source region to copy/move to.
2635 * Access: Index
2636 */
2637MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2638
2639/* reg_prcr_dest_tcam_region_info
2640 * Opaque object that represents the destination TCAM region.
2641 * Access: Index
2642 */
2643MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2644 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2645
2646static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2647 const char *src_tcam_region_info,
2648 u16 src_offset,
2649 const char *dest_tcam_region_info,
2650 u16 dest_offset, u16 size)
2651{
2652 MLXSW_REG_ZERO(prcr, payload);
2653 mlxsw_reg_prcr_op_set(payload, op);
2654 mlxsw_reg_prcr_offset_set(payload, src_offset);
2655 mlxsw_reg_prcr_size_set(payload, size);
2656 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2657 src_tcam_region_info);
2658 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2659 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2660 dest_tcam_region_info);
2661}
2662
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002663/* PEFA - Policy-Engine Extended Flexible Action Register
2664 * ------------------------------------------------------
2665 * This register is used for accessing an extended flexible action entry
2666 * in the central KVD Linear Database.
2667 */
2668#define MLXSW_REG_PEFA_ID 0x300F
2669#define MLXSW_REG_PEFA_LEN 0xB0
2670
2671MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2672
2673/* reg_pefa_index
2674 * Index in the KVD Linear Centralized Database.
2675 * Access: Index
2676 */
2677MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2678
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002679/* reg_pefa_a
2680 * Index in the KVD Linear Centralized Database.
2681 * Activity
2682 * For a new entry: set if ca=0, clear if ca=1
2683 * Set if a packet lookup has hit on the specific entry
2684 * Access: RO
2685 */
2686MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2687
2688/* reg_pefa_ca
2689 * Clear activity
2690 * When write: activity is according to this field
2691 * When read: after reading the activity is cleared according to ca
2692 * Access: OP
2693 */
2694MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2695
Yotam Gigi58726562017-09-19 10:00:12 +02002696#define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002697
2698/* reg_pefa_flex_action_set
2699 * Action-set to perform when rule is matched.
2700 * Must be zero padded if action set is shorter.
2701 * Access: RW
2702 */
Yotam Gigi58726562017-09-19 10:00:12 +02002703MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002704
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002705static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002706 const char *flex_action_set)
2707{
2708 MLXSW_REG_ZERO(pefa, payload);
2709 mlxsw_reg_pefa_index_set(payload, index);
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002710 mlxsw_reg_pefa_ca_set(payload, ca);
2711 if (flex_action_set)
2712 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2713 flex_action_set);
2714}
2715
2716static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2717{
2718 *p_a = mlxsw_reg_pefa_a_get(payload);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002719}
2720
Nir Dotana75e41d2018-12-10 07:11:33 +00002721/* PEMRBT - Policy-Engine Multicast Router Binding Table Register
2722 * --------------------------------------------------------------
2723 * This register is used for binding Multicast router to an ACL group
2724 * that serves the MC router.
2725 * This register is not supported by SwitchX/-2 and Spectrum.
2726 */
2727#define MLXSW_REG_PEMRBT_ID 0x3014
2728#define MLXSW_REG_PEMRBT_LEN 0x14
2729
2730MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
2731
2732enum mlxsw_reg_pemrbt_protocol {
2733 MLXSW_REG_PEMRBT_PROTO_IPV4,
2734 MLXSW_REG_PEMRBT_PROTO_IPV6,
2735};
2736
2737/* reg_pemrbt_protocol
2738 * Access: Index
2739 */
2740MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
2741
2742/* reg_pemrbt_group_id
2743 * ACL group identifier.
2744 * Range 0..cap_max_acl_groups-1
2745 * Access: RW
2746 */
2747MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
2748
2749static inline void
2750mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
2751 u16 group_id)
2752{
2753 MLXSW_REG_ZERO(pemrbt, payload);
2754 mlxsw_reg_pemrbt_protocol_set(payload, protocol);
2755 mlxsw_reg_pemrbt_group_id_set(payload, group_id);
2756}
2757
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002758/* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
2759 * -----------------------------------------------------
2760 * This register is used for accessing rules within a TCAM region.
2761 * It is a new version of PTCE in order to support wider key,
2762 * mask and action within a TCAM region. This register is not supported
2763 * by SwitchX and SwitchX-2.
2764 */
2765#define MLXSW_REG_PTCE2_ID 0x3017
2766#define MLXSW_REG_PTCE2_LEN 0x1D8
2767
2768MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2769
2770/* reg_ptce2_v
2771 * Valid.
2772 * Access: RW
2773 */
2774MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2775
2776/* reg_ptce2_a
2777 * Activity. Set if a packet lookup has hit on the specific entry.
2778 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
2779 * Access: RO
2780 */
2781MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2782
2783enum mlxsw_reg_ptce2_op {
2784 /* Read operation. */
2785 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2786 /* clear on read operation. Used to read entry
2787 * and clear Activity bit.
2788 */
2789 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2790 /* Write operation. Used to write a new entry to the table.
2791 * All R/W fields are relevant for new entry. Activity bit is set
2792 * for new entries - Note write with v = 0 will delete the entry.
2793 */
2794 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2795 /* Update action. Only action set will be updated. */
2796 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2797 /* Clear activity. A bit is cleared for the entry. */
2798 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2799};
2800
2801/* reg_ptce2_op
2802 * Access: OP
2803 */
2804MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2805
2806/* reg_ptce2_offset
2807 * Access: Index
2808 */
2809MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2810
Jiri Pirko42df8352018-07-08 23:51:24 +03002811/* reg_ptce2_priority
2812 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
2813 * Note: priority does not have to be unique per rule.
2814 * Within a region, higher priority should have lower offset (no limitation
2815 * between regions in a multi-region).
2816 * Access: RW
2817 */
2818MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2819
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002820/* reg_ptce2_tcam_region_info
2821 * Opaque object that represents the TCAM region.
2822 * Access: Index
2823 */
2824MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2825 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2826
Ido Schimmelaecefac2018-07-25 09:23:51 +03002827#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002828
2829/* reg_ptce2_flex_key_blocks
2830 * ACL Key.
2831 * Access: RW
2832 */
2833MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002834 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002835
2836/* reg_ptce2_mask
2837 * mask- in the same size as key. A bit that is set directs the TCAM
2838 * to compare the corresponding bit in key. A bit that is clear directs
2839 * the TCAM to ignore the corresponding bit in key.
2840 * Access: RW
2841 */
2842MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002843 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002844
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002845/* reg_ptce2_flex_action_set
2846 * ACL action set.
2847 * Access: RW
2848 */
2849MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
Yotam Gigi58726562017-09-19 10:00:12 +02002850 MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002851
2852static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2853 enum mlxsw_reg_ptce2_op op,
2854 const char *tcam_region_info,
Jiri Pirko42df8352018-07-08 23:51:24 +03002855 u16 offset, u32 priority)
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002856{
2857 MLXSW_REG_ZERO(ptce2, payload);
2858 mlxsw_reg_ptce2_v_set(payload, valid);
2859 mlxsw_reg_ptce2_op_set(payload, op);
2860 mlxsw_reg_ptce2_offset_set(payload, offset);
Jiri Pirko42df8352018-07-08 23:51:24 +03002861 mlxsw_reg_ptce2_priority_set(payload, priority);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002862 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2863}
2864
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03002865/* PERPT - Policy-Engine ERP Table Register
2866 * ----------------------------------------
2867 * This register adds and removes eRPs from the eRP table.
2868 */
2869#define MLXSW_REG_PERPT_ID 0x3021
2870#define MLXSW_REG_PERPT_LEN 0x80
2871
2872MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2873
2874/* reg_perpt_erpt_bank
2875 * eRP table bank.
2876 * Range 0 .. cap_max_erp_table_banks - 1
2877 * Access: Index
2878 */
2879MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2880
2881/* reg_perpt_erpt_index
2882 * Index to eRP table within the eRP bank.
2883 * Range is 0 .. cap_max_erp_table_bank_size - 1
2884 * Access: Index
2885 */
2886MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2887
2888enum mlxsw_reg_perpt_key_size {
2889 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2890 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2891 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2892 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2893};
2894
2895/* reg_perpt_key_size
2896 * Access: OP
2897 */
2898MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2899
2900/* reg_perpt_bf_bypass
2901 * 0 - The eRP is used only if bloom filter state is set for the given
2902 * rule.
2903 * 1 - The eRP is used regardless of bloom filter state.
2904 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
2905 * Access: RW
2906 */
2907MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2908
2909/* reg_perpt_erp_id
2910 * eRP ID for use by the rules.
2911 * Access: RW
2912 */
2913MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2914
2915/* reg_perpt_erpt_base_bank
2916 * Base eRP table bank, points to head of erp_vector
2917 * Range is 0 .. cap_max_erp_table_banks - 1
2918 * Access: OP
2919 */
2920MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2921
2922/* reg_perpt_erpt_base_index
2923 * Base index to eRP table within the eRP bank
2924 * Range is 0 .. cap_max_erp_table_bank_size - 1
2925 * Access: OP
2926 */
2927MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2928
2929/* reg_perpt_erp_index_in_vector
2930 * eRP index in the vector.
2931 * Access: OP
2932 */
2933MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2934
2935/* reg_perpt_erp_vector
2936 * eRP vector.
2937 * Access: OP
2938 */
2939MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2940
2941/* reg_perpt_mask
2942 * Mask
2943 * 0 - A-TCAM will ignore the bit in key
2944 * 1 - A-TCAM will compare the bit in key
2945 * Access: RW
2946 */
2947MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2948
2949static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
2950 unsigned long *erp_vector,
2951 unsigned long size)
2952{
2953 unsigned long bit;
2954
2955 for_each_set_bit(bit, erp_vector, size)
2956 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
2957}
2958
2959static inline void
2960mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
2961 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
2962 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
2963 char *mask)
2964{
2965 MLXSW_REG_ZERO(perpt, payload);
2966 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
2967 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
2968 mlxsw_reg_perpt_key_size_set(payload, key_size);
Nir Dotan03ce5bd2018-12-16 08:49:34 +00002969 mlxsw_reg_perpt_bf_bypass_set(payload, false);
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03002970 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
2971 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
2972 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
2973 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
2974 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
2975}
2976
Jiri Pirko33907872018-07-18 11:14:37 +03002977/* PERAR - Policy-Engine Region Association Register
2978 * -------------------------------------------------
2979 * This register associates a hw region for region_id's. Changing on the fly
2980 * is supported by the device.
2981 */
2982#define MLXSW_REG_PERAR_ID 0x3026
2983#define MLXSW_REG_PERAR_LEN 0x08
2984
2985MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
2986
2987/* reg_perar_region_id
2988 * Region identifier
2989 * Range 0 .. cap_max_regions-1
2990 * Access: Index
2991 */
2992MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
2993
2994static inline unsigned int
2995mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
2996{
2997 return DIV_ROUND_UP(block_num, 4);
2998}
2999
3000/* reg_perar_hw_region
3001 * HW Region
3002 * Range 0 .. cap_max_regions-1
3003 * Default: hw_region = region_id
3004 * For a 8 key block region, 2 consecutive regions are used
3005 * For a 12 key block region, 3 consecutive regions are used
3006 * Access: RW
3007 */
3008MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
3009
3010static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
3011 u16 hw_region)
3012{
3013 MLXSW_REG_ZERO(perar, payload);
3014 mlxsw_reg_perar_region_id_set(payload, region_id);
3015 mlxsw_reg_perar_hw_region_set(payload, hw_region);
3016}
3017
Ido Schimmelaecefac2018-07-25 09:23:51 +03003018/* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
3019 * -----------------------------------------------------
3020 * This register is a new version of PTCE-V2 in order to support the
3021 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
3022 */
3023#define MLXSW_REG_PTCE3_ID 0x3027
3024#define MLXSW_REG_PTCE3_LEN 0xF0
3025
3026MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
3027
3028/* reg_ptce3_v
3029 * Valid.
3030 * Access: RW
3031 */
3032MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
3033
3034enum mlxsw_reg_ptce3_op {
3035 /* Write operation. Used to write a new entry to the table.
3036 * All R/W fields are relevant for new entry. Activity bit is set
3037 * for new entries. Write with v = 0 will delete the entry. Must
3038 * not be used if an entry exists.
3039 */
3040 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
3041 /* Update operation */
3042 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
3043 /* Read operation */
3044 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
3045};
3046
3047/* reg_ptce3_op
3048 * Access: OP
3049 */
3050MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
3051
3052/* reg_ptce3_priority
3053 * Priority of the rule. Higher values win.
3054 * For Spectrum-2 range is 1..cap_kvd_size - 1
3055 * Note: Priority does not have to be unique per rule.
3056 * Access: RW
3057 */
3058MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
3059
3060/* reg_ptce3_tcam_region_info
3061 * Opaque object that represents the TCAM region.
3062 * Access: Index
3063 */
3064MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
3065 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3066
3067/* reg_ptce3_flex2_key_blocks
3068 * ACL key. The key must be masked according to eRP (if exists) or
3069 * according to master mask.
3070 * Access: Index
3071 */
3072MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
3073 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3074
3075/* reg_ptce3_erp_id
3076 * eRP ID.
3077 * Access: Index
3078 */
3079MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
3080
3081/* reg_ptce3_delta_start
3082 * Start point of delta_value and delta_mask, in bits. Must not exceed
3083 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
3084 * Access: Index
3085 */
3086MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
3087
3088/* reg_ptce3_delta_mask
3089 * Delta mask.
3090 * 0 - Ignore relevant bit in delta_value
3091 * 1 - Compare relevant bit in delta_value
3092 * Delta mask must not be set for reserved fields in the key blocks.
3093 * Note: No delta when no eRPs. Thus, for regions with
3094 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
3095 * Access: Index
3096 */
3097MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
3098
3099/* reg_ptce3_delta_value
3100 * Delta value.
3101 * Bits which are masked by delta_mask must be 0.
3102 * Access: Index
3103 */
3104MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
3105
3106/* reg_ptce3_prune_vector
3107 * Pruning vector relative to the PERPT.erp_id.
3108 * Used for reducing lookups.
3109 * 0 - NEED: Do a lookup using the eRP.
3110 * 1 - PRUNE: Do not perform a lookup using the eRP.
3111 * Maybe be modified by PEAPBL and PEAPBM.
3112 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
3113 * all 1's or all 0's.
3114 * Access: RW
3115 */
3116MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
3117
3118/* reg_ptce3_prune_ctcam
3119 * Pruning on C-TCAM. Used for reducing lookups.
3120 * 0 - NEED: Do a lookup in the C-TCAM.
3121 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
3122 * Access: RW
3123 */
3124MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
3125
3126/* reg_ptce3_large_exists
3127 * Large entry key ID exists.
3128 * Within the region:
3129 * 0 - SINGLE: The large_entry_key_id is not currently in use.
3130 * For rule insert: The MSB of the key (blocks 6..11) will be added.
3131 * For rule delete: The MSB of the key will be removed.
3132 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
3133 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
3134 * For rule delete: The MSB of the key will not be removed.
3135 * Access: WO
3136 */
3137MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
3138
3139/* reg_ptce3_large_entry_key_id
3140 * Large entry key ID.
3141 * A key for 12 key blocks rules. Reserved when region has less than 12 key
3142 * blocks. Must be different for different keys which have the same common
3143 * 6 key blocks (MSB, blocks 6..11) key within a region.
3144 * Range is 0..cap_max_pe_large_key_id - 1
3145 * Access: RW
3146 */
3147MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
3148
3149/* reg_ptce3_action_pointer
3150 * Pointer to action.
3151 * Range is 0..cap_max_kvd_action_sets - 1
3152 * Access: RW
3153 */
3154MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
3155
3156static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
3157 enum mlxsw_reg_ptce3_op op,
3158 u32 priority,
3159 const char *tcam_region_info,
3160 const char *key, u8 erp_id,
Jiri Pirkoc22291f2018-11-14 08:22:35 +00003161 u16 delta_start, u8 delta_mask,
3162 u8 delta_value, bool large_exists,
3163 u32 lkey_id, u32 action_pointer)
Ido Schimmelaecefac2018-07-25 09:23:51 +03003164{
3165 MLXSW_REG_ZERO(ptce3, payload);
3166 mlxsw_reg_ptce3_v_set(payload, valid);
3167 mlxsw_reg_ptce3_op_set(payload, op);
3168 mlxsw_reg_ptce3_priority_set(payload, priority);
3169 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
3170 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
3171 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
Jiri Pirkoc22291f2018-11-14 08:22:35 +00003172 mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
3173 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
3174 mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
Ido Schimmelaecefac2018-07-25 09:23:51 +03003175 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
3176 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
3177 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
3178}
3179
Ido Schimmel481662a2018-07-18 11:14:38 +03003180/* PERCR - Policy-Engine Region Configuration Register
3181 * ---------------------------------------------------
3182 * This register configures the region parameters. The region_id must be
3183 * allocated.
3184 */
3185#define MLXSW_REG_PERCR_ID 0x302A
3186#define MLXSW_REG_PERCR_LEN 0x80
3187
3188MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
3189
3190/* reg_percr_region_id
3191 * Region identifier.
3192 * Range 0..cap_max_regions-1
3193 * Access: Index
3194 */
3195MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
3196
3197/* reg_percr_atcam_ignore_prune
3198 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
3199 * Access: RW
3200 */
3201MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
3202
3203/* reg_percr_ctcam_ignore_prune
3204 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
3205 * Access: RW
3206 */
3207MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
3208
3209/* reg_percr_bf_bypass
3210 * Bloom filter bypass.
3211 * 0 - Bloom filter is used (default)
3212 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
3213 * region_id or eRP. See PERPT.bf_bypass
3214 * Access: RW
3215 */
3216MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
3217
3218/* reg_percr_master_mask
3219 * Master mask. Logical OR mask of all masks of all rules of a region
3220 * (both A-TCAM and C-TCAM). When there are no eRPs
3221 * (erpt_pointer_valid = 0), then this provides the mask.
3222 * Access: RW
3223 */
3224MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
3225
3226static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
3227{
3228 MLXSW_REG_ZERO(percr, payload);
3229 mlxsw_reg_percr_region_id_set(payload, region_id);
3230 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
3231 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
Nir Dotan03ce5bd2018-12-16 08:49:34 +00003232 mlxsw_reg_percr_bf_bypass_set(payload, false);
Ido Schimmel481662a2018-07-18 11:14:38 +03003233}
3234
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03003235/* PERERP - Policy-Engine Region eRP Register
3236 * ------------------------------------------
3237 * This register configures the region eRP. The region_id must be
3238 * allocated.
3239 */
3240#define MLXSW_REG_PERERP_ID 0x302B
3241#define MLXSW_REG_PERERP_LEN 0x1C
3242
3243MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
3244
3245/* reg_pererp_region_id
3246 * Region identifier.
3247 * Range 0..cap_max_regions-1
3248 * Access: Index
3249 */
3250MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
3251
3252/* reg_pererp_ctcam_le
3253 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
3254 * Access: RW
3255 */
3256MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
3257
3258/* reg_pererp_erpt_pointer_valid
3259 * erpt_pointer is valid.
3260 * Access: RW
3261 */
3262MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
3263
3264/* reg_pererp_erpt_bank_pointer
3265 * Pointer to eRP table bank. May be modified at any time.
3266 * Range 0..cap_max_erp_table_banks-1
3267 * Reserved when erpt_pointer_valid = 0
3268 */
3269MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
3270
3271/* reg_pererp_erpt_pointer
3272 * Pointer to eRP table within the eRP bank. Can be changed for an
3273 * existing region.
3274 * Range 0..cap_max_erp_table_size-1
3275 * Reserved when erpt_pointer_valid = 0
3276 * Access: RW
3277 */
3278MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
3279
3280/* reg_pererp_erpt_vector
3281 * Vector of allowed eRP indexes starting from erpt_pointer within the
3282 * erpt_bank_pointer. Next entries will be in next bank.
3283 * Note that eRP index is used and not eRP ID.
3284 * Reserved when erpt_pointer_valid = 0
3285 * Access: RW
3286 */
3287MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
3288
3289/* reg_pererp_master_rp_id
3290 * Master RP ID. When there are no eRPs, then this provides the eRP ID
3291 * for the lookup. Can be changed for an existing region.
3292 * Reserved when erpt_pointer_valid = 1
3293 * Access: RW
3294 */
3295MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
3296
Ido Schimmel91329e22018-07-25 09:23:50 +03003297static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
3298 unsigned long *erp_vector,
3299 unsigned long size)
3300{
3301 unsigned long bit;
3302
3303 for_each_set_bit(bit, erp_vector, size)
3304 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
3305}
3306
3307static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
3308 bool ctcam_le, bool erpt_pointer_valid,
3309 u8 erpt_bank_pointer, u8 erpt_pointer,
3310 u8 master_rp_id)
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03003311{
3312 MLXSW_REG_ZERO(pererp, payload);
3313 mlxsw_reg_pererp_region_id_set(payload, region_id);
Ido Schimmel91329e22018-07-25 09:23:50 +03003314 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
3315 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
3316 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
3317 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
3318 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03003319}
3320
Nir Dotan418089a2018-12-16 08:49:24 +00003321/* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
3322 * ----------------------------------------------------------------
3323 * This register configures the Bloom filter entries.
3324 */
3325#define MLXSW_REG_PEABFE_ID 0x3022
3326#define MLXSW_REG_PEABFE_BASE_LEN 0x10
3327#define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3328#define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3329#define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3330 MLXSW_REG_PEABFE_BF_REC_LEN * \
3331 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3332
3333MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3334
3335/* reg_peabfe_size
3336 * Number of BF entries to be updated.
3337 * Range 1..256
3338 * Access: Op
3339 */
3340MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3341
3342/* reg_peabfe_bf_entry_state
3343 * Bloom filter state
3344 * 0 - Clear
3345 * 1 - Set
3346 * Access: RW
3347 */
3348MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3349 MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3350 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3351
3352/* reg_peabfe_bf_entry_bank
3353 * Bloom filter bank ID
3354 * Range 0..cap_max_erp_table_banks-1
3355 * Access: Index
3356 */
3357MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3358 MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3359 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3360
3361/* reg_peabfe_bf_entry_index
3362 * Bloom filter entry index
3363 * Range 0..2^cap_max_bf_log-1
3364 * Access: Index
3365 */
3366MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3367 MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3368 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3369
3370static inline void mlxsw_reg_peabfe_pack(char *payload)
3371{
3372 MLXSW_REG_ZERO(peabfe, payload);
3373}
3374
3375static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3376 u8 state, u8 bank, u32 bf_index)
3377{
3378 u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3379
3380 if (rec_index >= num_rec)
3381 mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3382 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3383 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3384 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3385}
3386
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03003387/* IEDR - Infrastructure Entry Delete Register
3388 * ----------------------------------------------------
3389 * This register is used for deleting entries from the entry tables.
3390 * It is legitimate to attempt to delete a nonexisting entry (the device will
3391 * respond as a good flow).
3392 */
3393#define MLXSW_REG_IEDR_ID 0x3804
3394#define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
3395#define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
3396#define MLXSW_REG_IEDR_REC_MAX_COUNT 64
3397#define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
3398 MLXSW_REG_IEDR_REC_LEN * \
3399 MLXSW_REG_IEDR_REC_MAX_COUNT)
3400
3401MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
3402
3403/* reg_iedr_num_rec
3404 * Number of records.
3405 * Access: OP
3406 */
3407MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
3408
3409/* reg_iedr_rec_type
3410 * Resource type.
3411 * Access: OP
3412 */
3413MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
3414 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3415
3416/* reg_iedr_rec_size
3417 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
3418 * Access: OP
3419 */
Ido Schimmelb7f03b02020-04-19 10:01:06 +03003420MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13,
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03003421 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3422
3423/* reg_iedr_rec_index_start
3424 * Resource index start.
3425 * Access: OP
3426 */
3427MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3428 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3429
3430static inline void mlxsw_reg_iedr_pack(char *payload)
3431{
3432 MLXSW_REG_ZERO(iedr, payload);
3433}
3434
3435static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3436 u8 rec_type, u16 rec_size,
3437 u32 rec_index_start)
3438{
3439 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3440
3441 if (rec_index >= num_rec)
3442 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3443 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3444 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3445 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3446}
3447
Petr Machata746da422018-07-27 15:26:58 +03003448/* QPTS - QoS Priority Trust State Register
3449 * ----------------------------------------
3450 * This register controls the port policy to calculate the switch priority and
3451 * packet color based on incoming packet fields.
3452 */
3453#define MLXSW_REG_QPTS_ID 0x4002
3454#define MLXSW_REG_QPTS_LEN 0x8
3455
3456MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3457
3458/* reg_qpts_local_port
3459 * Local port number.
3460 * Access: Index
3461 *
3462 * Note: CPU port is supported.
3463 */
3464MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
3465
3466enum mlxsw_reg_qpts_trust_state {
3467 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3468 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3469};
3470
3471/* reg_qpts_trust_state
3472 * Trust state for a given port.
3473 * Access: RW
3474 */
3475MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3476
3477static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
3478 enum mlxsw_reg_qpts_trust_state ts)
3479{
3480 MLXSW_REG_ZERO(qpts, payload);
3481
3482 mlxsw_reg_qpts_local_port_set(payload, local_port);
3483 mlxsw_reg_qpts_trust_state_set(payload, ts);
3484}
3485
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003486/* QPCR - QoS Policer Configuration Register
3487 * -----------------------------------------
3488 * The QPCR register is used to create policers - that limit
3489 * the rate of bytes or packets via some trap group.
3490 */
3491#define MLXSW_REG_QPCR_ID 0x4004
3492#define MLXSW_REG_QPCR_LEN 0x28
3493
3494MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3495
3496enum mlxsw_reg_qpcr_g {
3497 MLXSW_REG_QPCR_G_GLOBAL = 2,
3498 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3499};
3500
3501/* reg_qpcr_g
3502 * The policer type.
3503 * Access: Index
3504 */
3505MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3506
3507/* reg_qpcr_pid
3508 * Policer ID.
3509 * Access: Index
3510 */
3511MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3512
Ido Schimmel2b84d7c2020-03-30 22:38:25 +03003513/* reg_qpcr_clear_counter
3514 * Clear counters.
3515 * Access: OP
3516 */
3517MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1);
3518
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003519/* reg_qpcr_color_aware
3520 * Is the policer aware of colors.
3521 * Must be 0 (unaware) for cpu port.
3522 * Access: RW for unbounded policer. RO for bounded policer.
3523 */
3524MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3525
3526/* reg_qpcr_bytes
3527 * Is policer limit is for bytes per sec or packets per sec.
3528 * 0 - packets
3529 * 1 - bytes
3530 * Access: RW for unbounded policer. RO for bounded policer.
3531 */
3532MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3533
3534enum mlxsw_reg_qpcr_ir_units {
3535 MLXSW_REG_QPCR_IR_UNITS_M,
3536 MLXSW_REG_QPCR_IR_UNITS_K,
3537};
3538
3539/* reg_qpcr_ir_units
3540 * Policer's units for cir and eir fields (for bytes limits only)
3541 * 1 - 10^3
3542 * 0 - 10^6
3543 * Access: OP
3544 */
3545MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3546
3547enum mlxsw_reg_qpcr_rate_type {
3548 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3549 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3550};
3551
3552/* reg_qpcr_rate_type
3553 * Policer can have one limit (single rate) or 2 limits with specific operation
3554 * for packets that exceed the lower rate but not the upper one.
3555 * (For cpu port must be single rate)
3556 * Access: RW for unbounded policer. RO for bounded policer.
3557 */
3558MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3559
3560/* reg_qpc_cbs
3561 * Policer's committed burst size.
3562 * The policer is working with time slices of 50 nano sec. By default every
3563 * slice is granted the proportionate share of the committed rate. If we want to
3564 * allow a slice to exceed that share (while still keeping the rate per sec) we
3565 * can allow burst. The burst size is between the default proportionate share
3566 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3567 * committed rate will result in exceeding the rate). The burst size must be a
3568 * log of 2 and will be determined by 2^cbs.
3569 * Access: RW
3570 */
3571MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3572
3573/* reg_qpcr_cir
3574 * Policer's committed rate.
3575 * The rate used for sungle rate, the lower rate for double rate.
3576 * For bytes limits, the rate will be this value * the unit from ir_units.
3577 * (Resolution error is up to 1%).
3578 * Access: RW
3579 */
3580MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3581
3582/* reg_qpcr_eir
3583 * Policer's exceed rate.
3584 * The higher rate for double rate, reserved for single rate.
3585 * Lower rate for double rate policer.
3586 * For bytes limits, the rate will be this value * the unit from ir_units.
3587 * (Resolution error is up to 1%).
3588 * Access: RW
3589 */
3590MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3591
3592#define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3593
3594/* reg_qpcr_exceed_action.
3595 * What to do with packets between the 2 limits for double rate.
3596 * Access: RW for unbounded policer. RO for bounded policer.
3597 */
3598MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3599
3600enum mlxsw_reg_qpcr_action {
3601 /* Discard */
3602 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3603 /* Forward and set color to red.
3604 * If the packet is intended to cpu port, it will be dropped.
3605 */
3606 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3607};
3608
3609/* reg_qpcr_violate_action
3610 * What to do with packets that cross the cir limit (for single rate) or the eir
3611 * limit (for double rate).
3612 * Access: RW for unbounded policer. RO for bounded policer.
3613 */
3614MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3615
Ido Schimmel2b84d7c2020-03-30 22:38:25 +03003616/* reg_qpcr_violate_count
3617 * Counts the number of times violate_action happened on this PID.
3618 * Access: RW
3619 */
3620MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64);
3621
Ido Schimmelfbf0f5d2020-07-15 11:27:23 +03003622/* Packets */
Ido Schimmel2b84d7c2020-03-30 22:38:25 +03003623#define MLXSW_REG_QPCR_LOWEST_CIR 1
3624#define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000) /* 2Gpps */
3625#define MLXSW_REG_QPCR_LOWEST_CBS 4
3626#define MLXSW_REG_QPCR_HIGHEST_CBS 24
3627
Ido Schimmelfbf0f5d2020-07-15 11:27:23 +03003628/* Bandwidth */
3629#define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024 /* bps */
3630#define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL /* 2Tbps */
3631#define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4
3632#define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4
3633#define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25
3634#define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31
3635
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003636static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3637 enum mlxsw_reg_qpcr_ir_units ir_units,
3638 bool bytes, u32 cir, u16 cbs)
3639{
3640 MLXSW_REG_ZERO(qpcr, payload);
3641 mlxsw_reg_qpcr_pid_set(payload, pid);
3642 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3643 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3644 mlxsw_reg_qpcr_violate_action_set(payload,
3645 MLXSW_REG_QPCR_ACTION_DISCARD);
3646 mlxsw_reg_qpcr_cir_set(payload, cir);
3647 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3648 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3649 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3650}
3651
Ido Schimmel2c63a552016-04-06 17:10:07 +02003652/* QTCT - QoS Switch Traffic Class Table
3653 * -------------------------------------
3654 * Configures the mapping between the packet switch priority and the
3655 * traffic class on the transmit port.
3656 */
3657#define MLXSW_REG_QTCT_ID 0x400A
3658#define MLXSW_REG_QTCT_LEN 0x08
3659
Jiri Pirko21978dc2016-10-21 16:07:20 +02003660MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
Ido Schimmel2c63a552016-04-06 17:10:07 +02003661
3662/* reg_qtct_local_port
3663 * Local port number.
3664 * Access: Index
3665 *
3666 * Note: CPU port is not supported.
3667 */
3668MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
3669
3670/* reg_qtct_sub_port
3671 * Virtual port within the physical port.
3672 * Should be set to 0 when virtual ports are not enabled on the port.
3673 * Access: Index
3674 */
3675MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3676
3677/* reg_qtct_switch_prio
3678 * Switch priority.
3679 * Access: Index
3680 */
3681MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3682
3683/* reg_qtct_tclass
3684 * Traffic class.
3685 * Default values:
3686 * switch_prio 0 : tclass 1
3687 * switch_prio 1 : tclass 0
3688 * switch_prio i : tclass i, for i > 1
3689 * Access: RW
3690 */
3691MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3692
3693static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3694 u8 switch_prio, u8 tclass)
3695{
3696 MLXSW_REG_ZERO(qtct, payload);
3697 mlxsw_reg_qtct_local_port_set(payload, local_port);
3698 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3699 mlxsw_reg_qtct_tclass_set(payload, tclass);
3700}
3701
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003702/* QEEC - QoS ETS Element Configuration Register
3703 * ---------------------------------------------
3704 * Configures the ETS elements.
3705 */
3706#define MLXSW_REG_QEEC_ID 0x400D
Petr Machata8b931822018-10-31 09:56:42 +00003707#define MLXSW_REG_QEEC_LEN 0x20
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003708
Jiri Pirko21978dc2016-10-21 16:07:20 +02003709MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003710
3711/* reg_qeec_local_port
3712 * Local port number.
3713 * Access: Index
3714 *
3715 * Note: CPU port is supported.
3716 */
3717MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
3718
3719enum mlxsw_reg_qeec_hr {
Petr Machata9cf9b922019-12-18 14:55:11 +00003720 MLXSW_REG_QEEC_HR_PORT,
3721 MLXSW_REG_QEEC_HR_GROUP,
3722 MLXSW_REG_QEEC_HR_SUBGROUP,
3723 MLXSW_REG_QEEC_HR_TC,
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003724};
3725
3726/* reg_qeec_element_hierarchy
3727 * 0 - Port
3728 * 1 - Group
3729 * 2 - Subgroup
3730 * 3 - Traffic Class
3731 * Access: Index
3732 */
3733MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3734
3735/* reg_qeec_element_index
3736 * The index of the element in the hierarchy.
3737 * Access: Index
3738 */
3739MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3740
3741/* reg_qeec_next_element_index
3742 * The index of the next (lower) element in the hierarchy.
3743 * Access: RW
3744 *
3745 * Note: Reserved for element_hierarchy 0.
3746 */
3747MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3748
Petr Machata8b931822018-10-31 09:56:42 +00003749/* reg_qeec_mise
3750 * Min shaper configuration enable. Enables configuration of the min
3751 * shaper on this ETS element
3752 * 0 - Disable
3753 * 1 - Enable
3754 * Access: RW
3755 */
3756MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3757
Shalom Toledo12f0e2e2019-07-04 10:07:33 +03003758/* reg_qeec_ptps
3759 * PTP shaper
3760 * 0: regular shaper mode
3761 * 1: PTP oriented shaper
3762 * Allowed only for hierarchy 0
3763 * Not supported for CPU port
3764 * Note that ptps mode may affect the shaper rates of all hierarchies
3765 * Supported only on Spectrum-1
3766 * Access: RW
3767 */
3768MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
3769
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003770enum {
3771 MLXSW_REG_QEEC_BYTES_MODE,
3772 MLXSW_REG_QEEC_PACKETS_MODE,
3773};
3774
3775/* reg_qeec_pb
3776 * Packets or bytes mode.
3777 * 0 - Bytes mode
3778 * 1 - Packets mode
3779 * Access: RW
3780 *
3781 * Note: Used for max shaper configuration. For Spectrum, packets mode
3782 * is supported only for traffic classes of CPU port.
3783 */
3784MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3785
Petr Machata8b931822018-10-31 09:56:42 +00003786/* The smallest permitted min shaper rate. */
3787#define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
3788
3789/* reg_qeec_min_shaper_rate
3790 * Min shaper information rate.
3791 * For CPU port, can only be configured for port hierarchy.
3792 * When in bytes mode, value is specified in units of 1000bps.
3793 * Access: RW
3794 */
3795MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3796
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003797/* reg_qeec_mase
3798 * Max shaper configuration enable. Enables configuration of the max
3799 * shaper on this ETS element.
3800 * 0 - Disable
3801 * 1 - Enable
3802 * Access: RW
3803 */
3804MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3805
Petr Machata92afbfe2020-01-24 15:23:11 +02003806/* The largest max shaper value possible to disable the shaper. */
3807#define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1) /* Kbps */
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003808
3809/* reg_qeec_max_shaper_rate
3810 * Max shaper information rate.
3811 * For CPU port, can only be configured for port hierarchy.
3812 * When in bytes mode, value is specified in units of 1000bps.
3813 * Access: RW
3814 */
Ido Schimmelcb851c02020-03-15 10:07:35 +02003815MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003816
3817/* reg_qeec_de
3818 * DWRR configuration enable. Enables configuration of the dwrr and
3819 * dwrr_weight.
3820 * 0 - Disable
3821 * 1 - Enable
3822 * Access: RW
3823 */
3824MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3825
3826/* reg_qeec_dwrr
3827 * Transmission selection algorithm to use on the link going down from
3828 * the ETS element.
3829 * 0 - Strict priority
3830 * 1 - DWRR
3831 * Access: RW
3832 */
3833MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3834
3835/* reg_qeec_dwrr_weight
3836 * DWRR weight on the link going down from the ETS element. The
3837 * percentage of bandwidth guaranteed to an ETS element within
3838 * its hierarchy. The sum of all weights across all ETS elements
3839 * within one hierarchy should be equal to 100. Reserved when
3840 * transmission selection algorithm is strict priority.
3841 * Access: RW
3842 */
3843MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3844
Petr Machata23effa22020-01-24 15:23:10 +02003845/* reg_qeec_max_shaper_bs
3846 * Max shaper burst size
3847 * Burst size is 2^max_shaper_bs * 512 bits
3848 * For Spectrum-1: Range is: 5..25
3849 * For Spectrum-2: Range is: 11..25
3850 * Reserved when ptps = 1
3851 * Access: RW
3852 */
3853MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
3854
3855#define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25
3856#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
3857#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
3858#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 5
3859
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003860static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
3861 enum mlxsw_reg_qeec_hr hr, u8 index,
3862 u8 next_index)
3863{
3864 MLXSW_REG_ZERO(qeec, payload);
3865 mlxsw_reg_qeec_local_port_set(payload, local_port);
3866 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3867 mlxsw_reg_qeec_element_index_set(payload, index);
3868 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3869}
3870
Shalom Toledo12f0e2e2019-07-04 10:07:33 +03003871static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u8 local_port,
3872 bool ptps)
3873{
3874 MLXSW_REG_ZERO(qeec, payload);
3875 mlxsw_reg_qeec_local_port_set(payload, local_port);
Petr Machata9cf9b922019-12-18 14:55:11 +00003876 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
Shalom Toledo12f0e2e2019-07-04 10:07:33 +03003877 mlxsw_reg_qeec_ptps_set(payload, ptps);
3878}
3879
Petr Machatae67131d2018-07-27 15:26:59 +03003880/* QRWE - QoS ReWrite Enable
3881 * -------------------------
3882 * This register configures the rewrite enable per receive port.
3883 */
3884#define MLXSW_REG_QRWE_ID 0x400F
3885#define MLXSW_REG_QRWE_LEN 0x08
3886
3887MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3888
3889/* reg_qrwe_local_port
3890 * Local port number.
3891 * Access: Index
3892 *
3893 * Note: CPU port is supported. No support for router port.
3894 */
3895MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
3896
3897/* reg_qrwe_dscp
3898 * Whether to enable DSCP rewrite (default is 0, don't rewrite).
3899 * Access: RW
3900 */
3901MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3902
3903/* reg_qrwe_pcp
3904 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
3905 * Access: RW
3906 */
3907MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3908
3909static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
3910 bool rewrite_pcp, bool rewrite_dscp)
3911{
3912 MLXSW_REG_ZERO(qrwe, payload);
3913 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3914 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3915 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3916}
3917
Petr Machata55fb71f2018-07-27 15:27:00 +03003918/* QPDSM - QoS Priority to DSCP Mapping
3919 * ------------------------------------
3920 * QoS Priority to DSCP Mapping Register
3921 */
3922#define MLXSW_REG_QPDSM_ID 0x4011
3923#define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
3924#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
3925#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3926#define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3927 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3928 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3929
3930MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3931
3932/* reg_qpdsm_local_port
3933 * Local Port. Supported for data packets from CPU port.
3934 * Access: Index
3935 */
3936MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
3937
3938/* reg_qpdsm_prio_entry_color0_e
3939 * Enable update of the entry for color 0 and a given port.
3940 * Access: WO
3941 */
3942MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
3943 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
3944 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3945
3946/* reg_qpdsm_prio_entry_color0_dscp
3947 * DSCP field in the outer label of the packet for color 0 and a given port.
3948 * Reserved when e=0.
3949 * Access: RW
3950 */
3951MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
3952 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
3953 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3954
3955/* reg_qpdsm_prio_entry_color1_e
3956 * Enable update of the entry for color 1 and a given port.
3957 * Access: WO
3958 */
3959MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
3960 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
3961 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3962
3963/* reg_qpdsm_prio_entry_color1_dscp
3964 * DSCP field in the outer label of the packet for color 1 and a given port.
3965 * Reserved when e=0.
3966 * Access: RW
3967 */
3968MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
3969 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
3970 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3971
3972/* reg_qpdsm_prio_entry_color2_e
3973 * Enable update of the entry for color 2 and a given port.
3974 * Access: WO
3975 */
3976MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
3977 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
3978 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3979
3980/* reg_qpdsm_prio_entry_color2_dscp
3981 * DSCP field in the outer label of the packet for color 2 and a given port.
3982 * Reserved when e=0.
3983 * Access: RW
3984 */
3985MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
3986 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
3987 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3988
3989static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
3990{
3991 MLXSW_REG_ZERO(qpdsm, payload);
3992 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
3993}
3994
3995static inline void
3996mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
3997{
3998 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
3999 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
4000 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
4001 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
4002 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
4003 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
4004}
4005
Petr Machatad8446882019-12-29 13:48:27 +02004006/* QPDP - QoS Port DSCP to Priority Mapping Register
4007 * -------------------------------------------------
4008 * This register controls the port default Switch Priority and Color. The
4009 * default Switch Priority and Color are used for frames where the trust state
4010 * uses default values. All member ports of a LAG should be configured with the
4011 * same default values.
4012 */
4013#define MLXSW_REG_QPDP_ID 0x4007
4014#define MLXSW_REG_QPDP_LEN 0x8
4015
4016MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
4017
4018/* reg_qpdp_local_port
4019 * Local Port. Supported for data packets from CPU port.
4020 * Access: Index
4021 */
4022MLXSW_ITEM32(reg, qpdp, local_port, 0x00, 16, 8);
4023
4024/* reg_qpdp_switch_prio
4025 * Default port Switch Priority (default 0)
4026 * Access: RW
4027 */
4028MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
4029
4030static inline void mlxsw_reg_qpdp_pack(char *payload, u8 local_port,
4031 u8 switch_prio)
4032{
4033 MLXSW_REG_ZERO(qpdp, payload);
4034 mlxsw_reg_qpdp_local_port_set(payload, local_port);
4035 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
4036}
4037
Petr Machata02837d72018-07-27 15:26:57 +03004038/* QPDPM - QoS Port DSCP to Priority Mapping Register
4039 * --------------------------------------------------
4040 * This register controls the mapping from DSCP field to
4041 * Switch Priority for IP packets.
4042 */
4043#define MLXSW_REG_QPDPM_ID 0x4013
4044#define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
4045#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
4046#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
4047#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
4048 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
4049 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
4050
4051MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
4052
4053/* reg_qpdpm_local_port
4054 * Local Port. Supported for data packets from CPU port.
4055 * Access: Index
4056 */
4057MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
4058
4059/* reg_qpdpm_dscp_e
4060 * Enable update of the specific entry. When cleared, the switch_prio and color
4061 * fields are ignored and the previous switch_prio and color values are
4062 * preserved.
4063 * Access: WO
4064 */
4065MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
4066 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4067
4068/* reg_qpdpm_dscp_prio
4069 * The new Switch Priority value for the relevant DSCP value.
4070 * Access: RW
4071 */
4072MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
4073 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
4074 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4075
4076static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
4077{
4078 MLXSW_REG_ZERO(qpdpm, payload);
4079 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
4080}
4081
4082static inline void
4083mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
4084{
4085 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
4086 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
4087}
4088
Petr Machata671ae8a2018-08-05 09:03:06 +03004089/* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
4090 * ------------------------------------------------------------------
4091 * This register configures if the Switch Priority to Traffic Class mapping is
4092 * based on Multicast packet indication. If so, then multicast packets will get
4093 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
4094 * QTCT.
4095 * By default, Switch Priority to Traffic Class mapping is not based on
4096 * Multicast packet indication.
4097 */
4098#define MLXSW_REG_QTCTM_ID 0x401A
4099#define MLXSW_REG_QTCTM_LEN 0x08
4100
4101MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
4102
4103/* reg_qtctm_local_port
4104 * Local port number.
4105 * No support for CPU port.
4106 * Access: Index
4107 */
4108MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
4109
4110/* reg_qtctm_mc
4111 * Multicast Mode
4112 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
4113 * indication (default is 0, not based on Multicast packet indication).
4114 */
4115MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
4116
4117static inline void
4118mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
4119{
4120 MLXSW_REG_ZERO(qtctm, payload);
4121 mlxsw_reg_qtctm_local_port_set(payload, local_port);
4122 mlxsw_reg_qtctm_mc_set(payload, mc);
4123}
4124
Shalom Toledo71147502019-07-04 10:07:35 +03004125/* QPSC - QoS PTP Shaper Configuration Register
4126 * --------------------------------------------
4127 * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1.
4128 * Supported only on Spectrum-1.
4129 */
4130#define MLXSW_REG_QPSC_ID 0x401B
4131#define MLXSW_REG_QPSC_LEN 0x28
4132
4133MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
4134
4135enum mlxsw_reg_qpsc_port_speed {
4136 MLXSW_REG_QPSC_PORT_SPEED_100M,
4137 MLXSW_REG_QPSC_PORT_SPEED_1G,
4138 MLXSW_REG_QPSC_PORT_SPEED_10G,
4139 MLXSW_REG_QPSC_PORT_SPEED_25G,
4140};
4141
4142/* reg_qpsc_port_speed
4143 * Port speed.
4144 * Access: Index
4145 */
4146MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
4147
4148/* reg_qpsc_shaper_time_exp
4149 * The base-time-interval for updating the shapers tokens (for all hierarchies).
4150 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
4151 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
4152 * Access: RW
4153 */
4154MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
4155
4156/* reg_qpsc_shaper_time_mantissa
4157 * The base-time-interval for updating the shapers tokens (for all hierarchies).
4158 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
4159 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
4160 * Access: RW
4161 */
4162MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
4163
4164/* reg_qpsc_shaper_inc
4165 * Number of tokens added to shaper on each update.
4166 * Units of 8B.
4167 * Access: RW
4168 */
4169MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
4170
4171/* reg_qpsc_shaper_bs
4172 * Max shaper Burst size.
4173 * Burst size is 2 ^ max_shaper_bs * 512 [bits]
4174 * Range is: 5..25 (from 2KB..2GB)
4175 * Access: RW
4176 */
4177MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
4178
4179/* reg_qpsc_ptsc_we
4180 * Write enable to port_to_shaper_credits.
4181 * Access: WO
4182 */
4183MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
4184
4185/* reg_qpsc_port_to_shaper_credits
4186 * For split ports: range 1..57
4187 * For non-split ports: range 1..112
4188 * Written only when ptsc_we is set.
4189 * Access: RW
4190 */
4191MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
4192
4193/* reg_qpsc_ing_timestamp_inc
4194 * Ingress timestamp increment.
4195 * 2's complement.
4196 * The timestamp of MTPPTR at ingress will be incremented by this value. Global
4197 * value for all ports.
4198 * Same units as used by MTPPTR.
4199 * Access: RW
4200 */
4201MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
4202
4203/* reg_qpsc_egr_timestamp_inc
4204 * Egress timestamp increment.
4205 * 2's complement.
4206 * The timestamp of MTPPTR at egress will be incremented by this value. Global
4207 * value for all ports.
4208 * Same units as used by MTPPTR.
4209 * Access: RW
4210 */
4211MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
4212
4213static inline void
4214mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
4215 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
4216 u8 shaper_bs, u8 port_to_shaper_credits,
4217 int ing_timestamp_inc, int egr_timestamp_inc)
4218{
4219 MLXSW_REG_ZERO(qpsc, payload);
4220 mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
4221 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
4222 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
4223 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
4224 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
4225 mlxsw_reg_qpsc_ptsc_we_set(payload, true);
4226 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
4227 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
4228 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
4229}
4230
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004231/* PMLP - Ports Module to Local Port Register
4232 * ------------------------------------------
4233 * Configures the assignment of modules to local ports.
4234 */
4235#define MLXSW_REG_PMLP_ID 0x5002
4236#define MLXSW_REG_PMLP_LEN 0x40
4237
Jiri Pirko21978dc2016-10-21 16:07:20 +02004238MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004239
4240/* reg_pmlp_rxtx
4241 * 0 - Tx value is used for both Tx and Rx.
4242 * 1 - Rx value is taken from a separte field.
4243 * Access: RW
4244 */
4245MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
4246
4247/* reg_pmlp_local_port
4248 * Local port number.
4249 * Access: Index
4250 */
4251MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
4252
4253/* reg_pmlp_width
4254 * 0 - Unmap local port.
4255 * 1 - Lane 0 is used.
4256 * 2 - Lanes 0 and 1 are used.
4257 * 4 - Lanes 0, 1, 2 and 3 are used.
Jiri Pirko94e76832019-10-31 11:42:06 +02004258 * 8 - Lanes 0-7 are used.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004259 * Access: RW
4260 */
4261MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
4262
4263/* reg_pmlp_module
4264 * Module number.
4265 * Access: RW
4266 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01004267MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004268
4269/* reg_pmlp_tx_lane
4270 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
4271 * Access: RW
4272 */
Jiri Pirko94e76832019-10-31 11:42:06 +02004273MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004274
4275/* reg_pmlp_rx_lane
4276 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
4277 * equal to Tx lane.
4278 * Access: RW
4279 */
Jiri Pirko94e76832019-10-31 11:42:06 +02004280MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004281
4282static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
4283{
4284 MLXSW_REG_ZERO(pmlp, payload);
4285 mlxsw_reg_pmlp_local_port_set(payload, local_port);
4286}
4287
4288/* PMTU - Port MTU Register
4289 * ------------------------
4290 * Configures and reports the port MTU.
4291 */
4292#define MLXSW_REG_PMTU_ID 0x5003
4293#define MLXSW_REG_PMTU_LEN 0x10
4294
Jiri Pirko21978dc2016-10-21 16:07:20 +02004295MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004296
4297/* reg_pmtu_local_port
4298 * Local port number.
4299 * Access: Index
4300 */
4301MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
4302
4303/* reg_pmtu_max_mtu
4304 * Maximum MTU.
4305 * When port type (e.g. Ethernet) is configured, the relevant MTU is
4306 * reported, otherwise the minimum between the max_mtu of the different
4307 * types is reported.
4308 * Access: RO
4309 */
4310MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
4311
4312/* reg_pmtu_admin_mtu
4313 * MTU value to set port to. Must be smaller or equal to max_mtu.
4314 * Note: If port type is Infiniband, then port must be disabled, when its
4315 * MTU is set.
4316 * Access: RW
4317 */
4318MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
4319
4320/* reg_pmtu_oper_mtu
4321 * The actual MTU configured on the port. Packets exceeding this size
4322 * will be dropped.
4323 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
4324 * oper_mtu might be smaller than admin_mtu.
4325 * Access: RO
4326 */
4327MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
4328
4329static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
4330 u16 new_mtu)
4331{
4332 MLXSW_REG_ZERO(pmtu, payload);
4333 mlxsw_reg_pmtu_local_port_set(payload, local_port);
4334 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
4335 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
4336 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
4337}
4338
4339/* PTYS - Port Type and Speed Register
4340 * -----------------------------------
4341 * Configures and reports the port speed type.
4342 *
4343 * Note: When set while the link is up, the changes will not take effect
4344 * until the port transitions from down to up state.
4345 */
4346#define MLXSW_REG_PTYS_ID 0x5004
4347#define MLXSW_REG_PTYS_LEN 0x40
4348
Jiri Pirko21978dc2016-10-21 16:07:20 +02004349MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004350
Tal Bar8e1ed732018-03-21 09:34:06 +02004351/* an_disable_admin
4352 * Auto negotiation disable administrative configuration
4353 * 0 - Device doesn't support AN disable.
4354 * 1 - Device supports AN disable.
4355 * Access: RW
4356 */
4357MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
4358
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004359/* reg_ptys_local_port
4360 * Local port number.
4361 * Access: Index
4362 */
4363MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
4364
Elad Raz79417702016-10-28 21:35:53 +02004365#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004366#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
4367
4368/* reg_ptys_proto_mask
4369 * Protocol mask. Indicates which protocol is used.
4370 * 0 - Infiniband.
4371 * 1 - Fibre Channel.
4372 * 2 - Ethernet.
4373 * Access: Index
4374 */
4375MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
4376
Ido Schimmel4149b972016-09-12 13:26:24 +02004377enum {
4378 MLXSW_REG_PTYS_AN_STATUS_NA,
4379 MLXSW_REG_PTYS_AN_STATUS_OK,
4380 MLXSW_REG_PTYS_AN_STATUS_FAIL,
4381};
4382
4383/* reg_ptys_an_status
4384 * Autonegotiation status.
4385 * Access: RO
4386 */
4387MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
4388
Shalom Toledo9ce84392019-02-22 13:56:44 +00004389#define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
4390#define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
Shalom Toledo9ce84392019-02-22 13:56:44 +00004391#define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
4392#define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
4393#define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
4394#define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
4395#define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
4396#define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
4397#define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
4398#define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
4399#define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
Jiri Pirko5bd29b92019-10-12 18:27:58 +02004400#define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
Shalom Toledo9ce84392019-02-22 13:56:44 +00004401
4402/* reg_ptys_ext_eth_proto_cap
4403 * Extended Ethernet port supported speeds and protocols.
4404 * Access: RO
4405 */
4406MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
4407
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004408#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
4409#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
4410#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
4411#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
4412#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004413#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
4414#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004415#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
4416#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
4417#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
4418#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
4419#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
Ido Schimmelb9d66a32016-09-12 13:26:27 +02004420#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004421#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
4422#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
4423#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
4424#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004425#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
4426#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
4427#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
4428#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
4429#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
4430
4431/* reg_ptys_eth_proto_cap
4432 * Ethernet port supported speeds and protocols.
4433 * Access: RO
4434 */
4435MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
4436
Elad Raz79417702016-10-28 21:35:53 +02004437/* reg_ptys_ib_link_width_cap
4438 * IB port supported widths.
4439 * Access: RO
4440 */
4441MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
4442
4443#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
4444#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
4445#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
4446#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
4447#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
4448#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
4449
4450/* reg_ptys_ib_proto_cap
4451 * IB port supported speeds and protocols.
4452 * Access: RO
4453 */
4454MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
4455
Shalom Toledo9ce84392019-02-22 13:56:44 +00004456/* reg_ptys_ext_eth_proto_admin
4457 * Extended speed and protocol to set port to.
4458 * Access: RW
4459 */
4460MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
4461
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004462/* reg_ptys_eth_proto_admin
4463 * Speed and protocol to set port to.
4464 * Access: RW
4465 */
4466MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
4467
Elad Raz79417702016-10-28 21:35:53 +02004468/* reg_ptys_ib_link_width_admin
4469 * IB width to set port to.
4470 * Access: RW
4471 */
4472MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
4473
4474/* reg_ptys_ib_proto_admin
4475 * IB speeds and protocols to set port to.
4476 * Access: RW
4477 */
4478MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
4479
Shalom Toledo9ce84392019-02-22 13:56:44 +00004480/* reg_ptys_ext_eth_proto_oper
4481 * The extended current speed and protocol configured for the port.
4482 * Access: RO
4483 */
4484MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
4485
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004486/* reg_ptys_eth_proto_oper
4487 * The current speed and protocol configured for the port.
4488 * Access: RO
4489 */
4490MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
4491
Elad Raz79417702016-10-28 21:35:53 +02004492/* reg_ptys_ib_link_width_oper
4493 * The current IB width to set port to.
4494 * Access: RO
4495 */
4496MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
4497
4498/* reg_ptys_ib_proto_oper
4499 * The current IB speed and protocol.
4500 * Access: RO
4501 */
4502MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
4503
Shalom Toledo1e2f66e2019-02-22 13:56:38 +00004504enum mlxsw_reg_ptys_connector_type {
4505 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
4506 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
4507 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
4508 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
4509 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
4510 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
4511 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
4512 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
4513 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
4514};
4515
4516/* reg_ptys_connector_type
4517 * Connector type indication.
4518 * Access: RO
4519 */
4520MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
4521
Elad Raz401c8b42016-10-28 21:35:52 +02004522static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
Tal Bar8e1ed732018-03-21 09:34:06 +02004523 u32 proto_admin, bool autoneg)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004524{
4525 MLXSW_REG_ZERO(ptys, payload);
4526 mlxsw_reg_ptys_local_port_set(payload, local_port);
4527 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4528 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
Tal Bar8e1ed732018-03-21 09:34:06 +02004529 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004530}
4531
Shalom Toledo9ce84392019-02-22 13:56:44 +00004532static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u8 local_port,
4533 u32 proto_admin, bool autoneg)
4534{
4535 MLXSW_REG_ZERO(ptys, payload);
4536 mlxsw_reg_ptys_local_port_set(payload, local_port);
4537 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4538 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
4539 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4540}
4541
Elad Raz401c8b42016-10-28 21:35:52 +02004542static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
4543 u32 *p_eth_proto_cap,
Shalom Toledoe6f66f52019-02-22 13:56:41 +00004544 u32 *p_eth_proto_admin,
Elad Raz401c8b42016-10-28 21:35:52 +02004545 u32 *p_eth_proto_oper)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004546{
4547 if (p_eth_proto_cap)
Shalom Toledo1dc3c0a2019-02-22 13:56:42 +00004548 *p_eth_proto_cap =
4549 mlxsw_reg_ptys_eth_proto_cap_get(payload);
Shalom Toledoe6f66f52019-02-22 13:56:41 +00004550 if (p_eth_proto_admin)
Shalom Toledo1dc3c0a2019-02-22 13:56:42 +00004551 *p_eth_proto_admin =
4552 mlxsw_reg_ptys_eth_proto_admin_get(payload);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004553 if (p_eth_proto_oper)
Shalom Toledo1dc3c0a2019-02-22 13:56:42 +00004554 *p_eth_proto_oper =
4555 mlxsw_reg_ptys_eth_proto_oper_get(payload);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004556}
4557
Shalom Toledo9ce84392019-02-22 13:56:44 +00004558static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
4559 u32 *p_eth_proto_cap,
4560 u32 *p_eth_proto_admin,
4561 u32 *p_eth_proto_oper)
4562{
4563 if (p_eth_proto_cap)
4564 *p_eth_proto_cap =
4565 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
4566 if (p_eth_proto_admin)
4567 *p_eth_proto_admin =
4568 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
4569 if (p_eth_proto_oper)
4570 *p_eth_proto_oper =
4571 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
4572}
4573
Elad Raz79417702016-10-28 21:35:53 +02004574static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
4575 u16 proto_admin, u16 link_width)
4576{
4577 MLXSW_REG_ZERO(ptys, payload);
4578 mlxsw_reg_ptys_local_port_set(payload, local_port);
4579 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
4580 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
4581 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
4582}
4583
4584static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
4585 u16 *p_ib_link_width_cap,
4586 u16 *p_ib_proto_oper,
4587 u16 *p_ib_link_width_oper)
4588{
4589 if (p_ib_proto_cap)
4590 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
4591 if (p_ib_link_width_cap)
4592 *p_ib_link_width_cap =
4593 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
4594 if (p_ib_proto_oper)
4595 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
4596 if (p_ib_link_width_oper)
4597 *p_ib_link_width_oper =
4598 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
4599}
4600
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004601/* PPAD - Port Physical Address Register
4602 * -------------------------------------
4603 * The PPAD register configures the per port physical MAC address.
4604 */
4605#define MLXSW_REG_PPAD_ID 0x5005
4606#define MLXSW_REG_PPAD_LEN 0x10
4607
Jiri Pirko21978dc2016-10-21 16:07:20 +02004608MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004609
4610/* reg_ppad_single_base_mac
4611 * 0: base_mac, local port should be 0 and mac[7:0] is
4612 * reserved. HW will set incremental
4613 * 1: single_mac - mac of the local_port
4614 * Access: RW
4615 */
4616MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
4617
4618/* reg_ppad_local_port
4619 * port number, if single_base_mac = 0 then local_port is reserved
4620 * Access: RW
4621 */
4622MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
4623
4624/* reg_ppad_mac
4625 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
4626 * If single_base_mac = 1 - the per port MAC address
4627 * Access: RW
4628 */
4629MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
4630
4631static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
4632 u8 local_port)
4633{
4634 MLXSW_REG_ZERO(ppad, payload);
4635 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
4636 mlxsw_reg_ppad_local_port_set(payload, local_port);
4637}
4638
4639/* PAOS - Ports Administrative and Operational Status Register
4640 * -----------------------------------------------------------
4641 * Configures and retrieves per port administrative and operational status.
4642 */
4643#define MLXSW_REG_PAOS_ID 0x5006
4644#define MLXSW_REG_PAOS_LEN 0x10
4645
Jiri Pirko21978dc2016-10-21 16:07:20 +02004646MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004647
4648/* reg_paos_swid
4649 * Switch partition ID with which to associate the port.
4650 * Note: while external ports uses unique local port numbers (and thus swid is
4651 * redundant), router ports use the same local port number where swid is the
4652 * only indication for the relevant port.
4653 * Access: Index
4654 */
4655MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
4656
4657/* reg_paos_local_port
4658 * Local port number.
4659 * Access: Index
4660 */
4661MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
4662
4663/* reg_paos_admin_status
4664 * Port administrative state (the desired state of the port):
4665 * 1 - Up.
4666 * 2 - Down.
4667 * 3 - Up once. This means that in case of link failure, the port won't go
4668 * into polling mode, but will wait to be re-enabled by software.
4669 * 4 - Disabled by system. Can only be set by hardware.
4670 * Access: RW
4671 */
4672MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
4673
4674/* reg_paos_oper_status
4675 * Port operational state (the current state):
4676 * 1 - Up.
4677 * 2 - Down.
4678 * 3 - Down by port failure. This means that the device will not let the
4679 * port up again until explicitly specified by software.
4680 * Access: RO
4681 */
4682MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
4683
4684/* reg_paos_ase
4685 * Admin state update enabled.
4686 * Access: WO
4687 */
4688MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
4689
4690/* reg_paos_ee
4691 * Event update enable. If this bit is set, event generation will be
4692 * updated based on the e field.
4693 * Access: WO
4694 */
4695MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
4696
4697/* reg_paos_e
4698 * Event generation on operational state change:
4699 * 0 - Do not generate event.
4700 * 1 - Generate Event.
4701 * 2 - Generate Single Event.
4702 * Access: RW
4703 */
4704MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
4705
4706static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
4707 enum mlxsw_port_admin_status status)
4708{
4709 MLXSW_REG_ZERO(paos, payload);
4710 mlxsw_reg_paos_swid_set(payload, 0);
4711 mlxsw_reg_paos_local_port_set(payload, local_port);
4712 mlxsw_reg_paos_admin_status_set(payload, status);
4713 mlxsw_reg_paos_oper_status_set(payload, 0);
4714 mlxsw_reg_paos_ase_set(payload, 1);
4715 mlxsw_reg_paos_ee_set(payload, 1);
4716 mlxsw_reg_paos_e_set(payload, 1);
4717}
4718
Ido Schimmel6f253d82016-04-06 17:10:12 +02004719/* PFCC - Ports Flow Control Configuration Register
4720 * ------------------------------------------------
4721 * Configures and retrieves the per port flow control configuration.
4722 */
4723#define MLXSW_REG_PFCC_ID 0x5007
4724#define MLXSW_REG_PFCC_LEN 0x20
4725
Jiri Pirko21978dc2016-10-21 16:07:20 +02004726MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
Ido Schimmel6f253d82016-04-06 17:10:12 +02004727
4728/* reg_pfcc_local_port
4729 * Local port number.
4730 * Access: Index
4731 */
4732MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
4733
4734/* reg_pfcc_pnat
4735 * Port number access type. Determines the way local_port is interpreted:
4736 * 0 - Local port number.
4737 * 1 - IB / label port number.
4738 * Access: Index
4739 */
4740MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
4741
4742/* reg_pfcc_shl_cap
4743 * Send to higher layers capabilities:
4744 * 0 - No capability of sending Pause and PFC frames to higher layers.
4745 * 1 - Device has capability of sending Pause and PFC frames to higher
4746 * layers.
4747 * Access: RO
4748 */
4749MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4750
4751/* reg_pfcc_shl_opr
4752 * Send to higher layers operation:
4753 * 0 - Pause and PFC frames are handled by the port (default).
4754 * 1 - Pause and PFC frames are handled by the port and also sent to
4755 * higher layers. Only valid if shl_cap = 1.
4756 * Access: RW
4757 */
4758MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4759
4760/* reg_pfcc_ppan
4761 * Pause policy auto negotiation.
4762 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
4763 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
4764 * based on the auto-negotiation resolution.
4765 * Access: RW
4766 *
4767 * Note: The auto-negotiation advertisement is set according to pptx and
4768 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
4769 */
4770MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4771
4772/* reg_pfcc_prio_mask_tx
4773 * Bit per priority indicating if Tx flow control policy should be
4774 * updated based on bit pfctx.
4775 * Access: WO
4776 */
4777MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4778
4779/* reg_pfcc_prio_mask_rx
4780 * Bit per priority indicating if Rx flow control policy should be
4781 * updated based on bit pfcrx.
4782 * Access: WO
4783 */
4784MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4785
4786/* reg_pfcc_pptx
4787 * Admin Pause policy on Tx.
4788 * 0 - Never generate Pause frames (default).
4789 * 1 - Generate Pause frames according to Rx buffer threshold.
4790 * Access: RW
4791 */
4792MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4793
4794/* reg_pfcc_aptx
4795 * Active (operational) Pause policy on Tx.
4796 * 0 - Never generate Pause frames.
4797 * 1 - Generate Pause frames according to Rx buffer threshold.
4798 * Access: RO
4799 */
4800MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4801
4802/* reg_pfcc_pfctx
4803 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
4804 * 0 - Never generate priority Pause frames on the specified priority
4805 * (default).
4806 * 1 - Generate priority Pause frames according to Rx buffer threshold on
4807 * the specified priority.
4808 * Access: RW
4809 *
4810 * Note: pfctx and pptx must be mutually exclusive.
4811 */
4812MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4813
4814/* reg_pfcc_pprx
4815 * Admin Pause policy on Rx.
4816 * 0 - Ignore received Pause frames (default).
4817 * 1 - Respect received Pause frames.
4818 * Access: RW
4819 */
4820MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4821
4822/* reg_pfcc_aprx
4823 * Active (operational) Pause policy on Rx.
4824 * 0 - Ignore received Pause frames.
4825 * 1 - Respect received Pause frames.
4826 * Access: RO
4827 */
4828MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4829
4830/* reg_pfcc_pfcrx
4831 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
4832 * 0 - Ignore incoming priority Pause frames on the specified priority
4833 * (default).
4834 * 1 - Respect incoming priority Pause frames on the specified priority.
4835 * Access: RW
4836 */
4837MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4838
Ido Schimmeld81a6bd2016-04-06 17:10:16 +02004839#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4840
4841static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4842{
4843 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4844 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4845 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4846 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4847}
4848
Ido Schimmel6f253d82016-04-06 17:10:12 +02004849static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
4850{
4851 MLXSW_REG_ZERO(pfcc, payload);
4852 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4853}
4854
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004855/* PPCNT - Ports Performance Counters Register
4856 * -------------------------------------------
4857 * The PPCNT register retrieves per port performance counters.
4858 */
4859#define MLXSW_REG_PPCNT_ID 0x5008
4860#define MLXSW_REG_PPCNT_LEN 0x100
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004861#define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004862
Jiri Pirko21978dc2016-10-21 16:07:20 +02004863MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004864
4865/* reg_ppcnt_swid
4866 * For HCA: must be always 0.
4867 * Switch partition ID to associate port with.
4868 * Switch partitions are numbered from 0 to 7 inclusively.
4869 * Switch partition 254 indicates stacking ports.
4870 * Switch partition 255 indicates all switch partitions.
4871 * Only valid on Set() operation with local_port=255.
4872 * Access: Index
4873 */
4874MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4875
4876/* reg_ppcnt_local_port
4877 * Local port number.
4878 * 255 indicates all ports on the device, and is only allowed
4879 * for Set() operation.
4880 * Access: Index
4881 */
4882MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
4883
4884/* reg_ppcnt_pnat
4885 * Port number access type:
4886 * 0 - Local port number
4887 * 1 - IB port number
4888 * Access: Index
4889 */
4890MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4891
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004892enum mlxsw_reg_ppcnt_grp {
4893 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
Shalom Toledobae4e102018-11-18 16:43:03 +00004894 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
Jiri Pirko1222d152018-07-15 10:45:42 +03004895 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
Shalom Toledobae4e102018-11-18 16:43:03 +00004896 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004897 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
Shalom Toledobae4e102018-11-18 16:43:03 +00004898 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004899 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004900 MLXSW_REG_PPCNT_TC_CNT = 0x11,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004901 MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004902};
4903
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004904/* reg_ppcnt_grp
4905 * Performance counter group.
4906 * Group 63 indicates all groups. Only valid on Set() operation with
4907 * clr bit set.
4908 * 0x0: IEEE 802.3 Counters
4909 * 0x1: RFC 2863 Counters
4910 * 0x2: RFC 2819 Counters
4911 * 0x3: RFC 3635 Counters
4912 * 0x5: Ethernet Extended Counters
Shalom Toledobae4e102018-11-18 16:43:03 +00004913 * 0x6: Ethernet Discard Counters
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004914 * 0x8: Link Level Retransmission Counters
4915 * 0x10: Per Priority Counters
4916 * 0x11: Per Traffic Class Counters
4917 * 0x12: Physical Layer Counters
Yuval Mintz0afc1222017-11-06 07:23:46 +01004918 * 0x13: Per Traffic Class Congestion Counters
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004919 * Access: Index
4920 */
4921MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4922
4923/* reg_ppcnt_clr
4924 * Clear counters. Setting the clr bit will reset the counter value
4925 * for all counters in the counter group. This bit can be set
4926 * for both Set() and Get() operation.
4927 * Access: OP
4928 */
4929MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4930
4931/* reg_ppcnt_prio_tc
4932 * Priority for counter set that support per priority, valid values: 0-7.
4933 * Traffic class for counter set that support per traffic class,
4934 * valid values: 0- cap_max_tclass-1 .
4935 * For HCA: cap_max_tclass is always 8.
4936 * Otherwise must be 0.
4937 * Access: Index
4938 */
4939MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
4940
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004941/* Ethernet IEEE 802.3 Counter Group */
4942
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004943/* reg_ppcnt_a_frames_transmitted_ok
4944 * Access: RO
4945 */
4946MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004947 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004948
4949/* reg_ppcnt_a_frames_received_ok
4950 * Access: RO
4951 */
4952MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004953 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004954
4955/* reg_ppcnt_a_frame_check_sequence_errors
4956 * Access: RO
4957 */
4958MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004959 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004960
4961/* reg_ppcnt_a_alignment_errors
4962 * Access: RO
4963 */
4964MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004965 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004966
4967/* reg_ppcnt_a_octets_transmitted_ok
4968 * Access: RO
4969 */
4970MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004971 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004972
4973/* reg_ppcnt_a_octets_received_ok
4974 * Access: RO
4975 */
4976MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004977 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004978
4979/* reg_ppcnt_a_multicast_frames_xmitted_ok
4980 * Access: RO
4981 */
4982MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004983 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004984
4985/* reg_ppcnt_a_broadcast_frames_xmitted_ok
4986 * Access: RO
4987 */
4988MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004989 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004990
4991/* reg_ppcnt_a_multicast_frames_received_ok
4992 * Access: RO
4993 */
4994MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004995 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004996
4997/* reg_ppcnt_a_broadcast_frames_received_ok
4998 * Access: RO
4999 */
5000MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005001 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005002
5003/* reg_ppcnt_a_in_range_length_errors
5004 * Access: RO
5005 */
5006MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005007 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005008
5009/* reg_ppcnt_a_out_of_range_length_field
5010 * Access: RO
5011 */
5012MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005013 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005014
5015/* reg_ppcnt_a_frame_too_long_errors
5016 * Access: RO
5017 */
5018MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005019 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005020
5021/* reg_ppcnt_a_symbol_error_during_carrier
5022 * Access: RO
5023 */
5024MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005025 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005026
5027/* reg_ppcnt_a_mac_control_frames_transmitted
5028 * Access: RO
5029 */
5030MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005031 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005032
5033/* reg_ppcnt_a_mac_control_frames_received
5034 * Access: RO
5035 */
5036MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005037 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005038
5039/* reg_ppcnt_a_unsupported_opcodes_received
5040 * Access: RO
5041 */
5042MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005043 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005044
5045/* reg_ppcnt_a_pause_mac_ctrl_frames_received
5046 * Access: RO
5047 */
5048MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005049 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005050
5051/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
5052 * Access: RO
5053 */
5054MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005055 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005056
Shalom Toledobae4e102018-11-18 16:43:03 +00005057/* Ethernet RFC 2863 Counter Group */
5058
5059/* reg_ppcnt_if_in_discards
5060 * Access: RO
5061 */
5062MLXSW_ITEM64(reg, ppcnt, if_in_discards,
5063 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5064
5065/* reg_ppcnt_if_out_discards
5066 * Access: RO
5067 */
5068MLXSW_ITEM64(reg, ppcnt, if_out_discards,
5069 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5070
5071/* reg_ppcnt_if_out_errors
5072 * Access: RO
5073 */
5074MLXSW_ITEM64(reg, ppcnt, if_out_errors,
5075 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5076
Jiri Pirko1222d152018-07-15 10:45:42 +03005077/* Ethernet RFC 2819 Counter Group */
5078
Shalom Toledobae4e102018-11-18 16:43:03 +00005079/* reg_ppcnt_ether_stats_undersize_pkts
5080 * Access: RO
5081 */
5082MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
5083 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5084
5085/* reg_ppcnt_ether_stats_oversize_pkts
5086 * Access: RO
5087 */
5088MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
5089 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5090
5091/* reg_ppcnt_ether_stats_fragments
5092 * Access: RO
5093 */
5094MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
5095 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5096
Jiri Pirko1222d152018-07-15 10:45:42 +03005097/* reg_ppcnt_ether_stats_pkts64octets
5098 * Access: RO
5099 */
5100MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
5101 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5102
5103/* reg_ppcnt_ether_stats_pkts65to127octets
5104 * Access: RO
5105 */
5106MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
5107 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5108
5109/* reg_ppcnt_ether_stats_pkts128to255octets
5110 * Access: RO
5111 */
5112MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
5113 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5114
5115/* reg_ppcnt_ether_stats_pkts256to511octets
5116 * Access: RO
5117 */
5118MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
5119 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5120
5121/* reg_ppcnt_ether_stats_pkts512to1023octets
5122 * Access: RO
5123 */
5124MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
5125 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5126
5127/* reg_ppcnt_ether_stats_pkts1024to1518octets
5128 * Access: RO
5129 */
5130MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
5131 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5132
5133/* reg_ppcnt_ether_stats_pkts1519to2047octets
5134 * Access: RO
5135 */
5136MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
5137 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5138
5139/* reg_ppcnt_ether_stats_pkts2048to4095octets
5140 * Access: RO
5141 */
5142MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
5143 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5144
5145/* reg_ppcnt_ether_stats_pkts4096to8191octets
5146 * Access: RO
5147 */
5148MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
5149 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
5150
5151/* reg_ppcnt_ether_stats_pkts8192to10239octets
5152 * Access: RO
5153 */
5154MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
5155 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
5156
Shalom Toledobae4e102018-11-18 16:43:03 +00005157/* Ethernet RFC 3635 Counter Group */
5158
5159/* reg_ppcnt_dot3stats_fcs_errors
5160 * Access: RO
5161 */
5162MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
5163 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5164
5165/* reg_ppcnt_dot3stats_symbol_errors
5166 * Access: RO
5167 */
5168MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
5169 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5170
5171/* reg_ppcnt_dot3control_in_unknown_opcodes
5172 * Access: RO
5173 */
5174MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
5175 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5176
5177/* reg_ppcnt_dot3in_pause_frames
5178 * Access: RO
5179 */
5180MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
5181 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5182
Yuval Mintz0afc1222017-11-06 07:23:46 +01005183/* Ethernet Extended Counter Group Counters */
5184
5185/* reg_ppcnt_ecn_marked
5186 * Access: RO
5187 */
5188MLXSW_ITEM64(reg, ppcnt, ecn_marked,
5189 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5190
Shalom Toledobae4e102018-11-18 16:43:03 +00005191/* Ethernet Discard Counter Group Counters */
5192
5193/* reg_ppcnt_ingress_general
5194 * Access: RO
5195 */
5196MLXSW_ITEM64(reg, ppcnt, ingress_general,
5197 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5198
5199/* reg_ppcnt_ingress_policy_engine
5200 * Access: RO
5201 */
5202MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
5203 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5204
5205/* reg_ppcnt_ingress_vlan_membership
5206 * Access: RO
5207 */
5208MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
5209 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5210
5211/* reg_ppcnt_ingress_tag_frame_type
5212 * Access: RO
5213 */
5214MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
5215 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5216
5217/* reg_ppcnt_egress_vlan_membership
5218 * Access: RO
5219 */
5220MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
5221 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5222
5223/* reg_ppcnt_loopback_filter
5224 * Access: RO
5225 */
5226MLXSW_ITEM64(reg, ppcnt, loopback_filter,
5227 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5228
5229/* reg_ppcnt_egress_general
5230 * Access: RO
5231 */
5232MLXSW_ITEM64(reg, ppcnt, egress_general,
5233 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5234
5235/* reg_ppcnt_egress_hoq
5236 * Access: RO
5237 */
5238MLXSW_ITEM64(reg, ppcnt, egress_hoq,
5239 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5240
5241/* reg_ppcnt_egress_policy_engine
5242 * Access: RO
5243 */
5244MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
5245 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5246
5247/* reg_ppcnt_ingress_tx_link_down
5248 * Access: RO
5249 */
5250MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
5251 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5252
5253/* reg_ppcnt_egress_stp_filter
5254 * Access: RO
5255 */
5256MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
5257 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5258
5259/* reg_ppcnt_egress_sll
5260 * Access: RO
5261 */
5262MLXSW_ITEM64(reg, ppcnt, egress_sll,
5263 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5264
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005265/* Ethernet Per Priority Group Counters */
5266
5267/* reg_ppcnt_rx_octets
5268 * Access: RO
5269 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005270MLXSW_ITEM64(reg, ppcnt, rx_octets,
5271 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005272
5273/* reg_ppcnt_rx_frames
5274 * Access: RO
5275 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005276MLXSW_ITEM64(reg, ppcnt, rx_frames,
5277 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005278
5279/* reg_ppcnt_tx_octets
5280 * Access: RO
5281 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005282MLXSW_ITEM64(reg, ppcnt, tx_octets,
5283 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005284
5285/* reg_ppcnt_tx_frames
5286 * Access: RO
5287 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005288MLXSW_ITEM64(reg, ppcnt, tx_frames,
5289 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005290
5291/* reg_ppcnt_rx_pause
5292 * Access: RO
5293 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005294MLXSW_ITEM64(reg, ppcnt, rx_pause,
5295 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005296
5297/* reg_ppcnt_rx_pause_duration
5298 * Access: RO
5299 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005300MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
5301 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005302
5303/* reg_ppcnt_tx_pause
5304 * Access: RO
5305 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005306MLXSW_ITEM64(reg, ppcnt, tx_pause,
5307 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005308
5309/* reg_ppcnt_tx_pause_duration
5310 * Access: RO
5311 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005312MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
5313 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005314
5315/* reg_ppcnt_rx_pause_transition
5316 * Access: RO
5317 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005318MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
5319 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005320
Ido Schimmeldf4750e2016-07-19 15:35:54 +02005321/* Ethernet Per Traffic Group Counters */
5322
5323/* reg_ppcnt_tc_transmit_queue
5324 * Contains the transmit queue depth in cells of traffic class
5325 * selected by prio_tc and the port selected by local_port.
5326 * The field cannot be cleared.
5327 * Access: RO
5328 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005329MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
5330 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02005331
5332/* reg_ppcnt_tc_no_buffer_discard_uc
5333 * The number of unicast packets dropped due to lack of shared
5334 * buffer resources.
5335 * Access: RO
5336 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005337MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
5338 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02005339
Yuval Mintz0afc1222017-11-06 07:23:46 +01005340/* Ethernet Per Traffic Class Congestion Group Counters */
5341
5342/* reg_ppcnt_wred_discard
5343 * Access: RO
5344 */
5345MLXSW_ITEM64(reg, ppcnt, wred_discard,
5346 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5347
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005348static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
5349 enum mlxsw_reg_ppcnt_grp grp,
5350 u8 prio_tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005351{
5352 MLXSW_REG_ZERO(ppcnt, payload);
5353 mlxsw_reg_ppcnt_swid_set(payload, 0);
5354 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
5355 mlxsw_reg_ppcnt_pnat_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005356 mlxsw_reg_ppcnt_grp_set(payload, grp);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005357 mlxsw_reg_ppcnt_clr_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005358 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005359}
5360
Elad Raz71367932016-10-28 21:35:54 +02005361/* PLIB - Port Local to InfiniBand Port
5362 * ------------------------------------
5363 * The PLIB register performs mapping from Local Port into InfiniBand Port.
5364 */
5365#define MLXSW_REG_PLIB_ID 0x500A
5366#define MLXSW_REG_PLIB_LEN 0x10
5367
5368MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
5369
5370/* reg_plib_local_port
5371 * Local port number.
5372 * Access: Index
5373 */
5374MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
5375
5376/* reg_plib_ib_port
5377 * InfiniBand port remapping for local_port.
5378 * Access: RW
5379 */
5380MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
5381
Ido Schimmelb98ff152016-04-06 17:10:00 +02005382/* PPTB - Port Prio To Buffer Register
5383 * -----------------------------------
5384 * Configures the switch priority to buffer table.
5385 */
5386#define MLXSW_REG_PPTB_ID 0x500B
Ido Schimmel11719a52016-07-15 11:15:02 +02005387#define MLXSW_REG_PPTB_LEN 0x10
Ido Schimmelb98ff152016-04-06 17:10:00 +02005388
Jiri Pirko21978dc2016-10-21 16:07:20 +02005389MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
Ido Schimmelb98ff152016-04-06 17:10:00 +02005390
5391enum {
5392 MLXSW_REG_PPTB_MM_UM,
5393 MLXSW_REG_PPTB_MM_UNICAST,
5394 MLXSW_REG_PPTB_MM_MULTICAST,
5395};
5396
5397/* reg_pptb_mm
5398 * Mapping mode.
5399 * 0 - Map both unicast and multicast packets to the same buffer.
5400 * 1 - Map only unicast packets.
5401 * 2 - Map only multicast packets.
5402 * Access: Index
5403 *
5404 * Note: SwitchX-2 only supports the first option.
5405 */
5406MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
5407
5408/* reg_pptb_local_port
5409 * Local port number.
5410 * Access: Index
5411 */
5412MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
5413
5414/* reg_pptb_um
5415 * Enables the update of the untagged_buf field.
5416 * Access: RW
5417 */
5418MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
5419
5420/* reg_pptb_pm
5421 * Enables the update of the prio_to_buff field.
5422 * Bit <i> is a flag for updating the mapping for switch priority <i>.
5423 * Access: RW
5424 */
5425MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
5426
5427/* reg_pptb_prio_to_buff
5428 * Mapping of switch priority <i> to one of the allocated receive port
5429 * buffers.
5430 * Access: RW
5431 */
5432MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
5433
5434/* reg_pptb_pm_msb
5435 * Enables the update of the prio_to_buff field.
5436 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
5437 * Access: RW
5438 */
5439MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
5440
5441/* reg_pptb_untagged_buff
5442 * Mapping of untagged frames to one of the allocated receive port buffers.
5443 * Access: RW
5444 *
5445 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
5446 * Spectrum, as it maps untagged packets based on the default switch priority.
5447 */
5448MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
5449
Ido Schimmel11719a52016-07-15 11:15:02 +02005450/* reg_pptb_prio_to_buff_msb
5451 * Mapping of switch priority <i+8> to one of the allocated receive port
5452 * buffers.
5453 * Access: RW
5454 */
5455MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
5456
Ido Schimmelb98ff152016-04-06 17:10:00 +02005457#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
5458
5459static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
5460{
5461 MLXSW_REG_ZERO(pptb, payload);
5462 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
5463 mlxsw_reg_pptb_local_port_set(payload, local_port);
5464 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
Ido Schimmel11719a52016-07-15 11:15:02 +02005465 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5466}
5467
5468static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
5469 u8 buff)
5470{
5471 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
5472 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
Ido Schimmelb98ff152016-04-06 17:10:00 +02005473}
5474
Jiri Pirkoe0594362015-10-16 14:01:31 +02005475/* PBMC - Port Buffer Management Control Register
5476 * ----------------------------------------------
5477 * The PBMC register configures and retrieves the port packet buffer
5478 * allocation for different Prios, and the Pause threshold management.
5479 */
5480#define MLXSW_REG_PBMC_ID 0x500C
Ido Schimmel7ad7cd62016-04-06 17:10:04 +02005481#define MLXSW_REG_PBMC_LEN 0x6C
Jiri Pirkoe0594362015-10-16 14:01:31 +02005482
Jiri Pirko21978dc2016-10-21 16:07:20 +02005483MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02005484
5485/* reg_pbmc_local_port
5486 * Local port number.
5487 * Access: Index
5488 */
5489MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
5490
5491/* reg_pbmc_xoff_timer_value
5492 * When device generates a pause frame, it uses this value as the pause
5493 * timer (time for the peer port to pause in quota-512 bit time).
5494 * Access: RW
5495 */
5496MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
5497
5498/* reg_pbmc_xoff_refresh
5499 * The time before a new pause frame should be sent to refresh the pause RW
5500 * state. Using the same units as xoff_timer_value above (in quota-512 bit
5501 * time).
5502 * Access: RW
5503 */
5504MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
5505
Ido Schimmeld6b7c132016-04-06 17:10:05 +02005506#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
5507
Jiri Pirkoe0594362015-10-16 14:01:31 +02005508/* reg_pbmc_buf_lossy
5509 * The field indicates if the buffer is lossy.
5510 * 0 - Lossless
5511 * 1 - Lossy
5512 * Access: RW
5513 */
5514MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
5515
5516/* reg_pbmc_buf_epsb
5517 * Eligible for Port Shared buffer.
5518 * If epsb is set, packets assigned to buffer are allowed to insert the port
5519 * shared buffer.
5520 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
5521 * Access: RW
5522 */
5523MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
5524
5525/* reg_pbmc_buf_size
5526 * The part of the packet buffer array is allocated for the specific buffer.
5527 * Units are represented in cells.
5528 * Access: RW
5529 */
5530MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
5531
Ido Schimmel155f9de2016-04-06 17:10:13 +02005532/* reg_pbmc_buf_xoff_threshold
5533 * Once the amount of data in the buffer goes above this value, device
5534 * starts sending PFC frames for all priorities associated with the
5535 * buffer. Units are represented in cells. Reserved in case of lossy
5536 * buffer.
5537 * Access: RW
5538 *
5539 * Note: In Spectrum, reserved for buffer[9].
5540 */
5541MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
5542 0x08, 0x04, false);
5543
5544/* reg_pbmc_buf_xon_threshold
5545 * When the amount of data in the buffer goes below this value, device
5546 * stops sending PFC frames for the priorities associated with the
5547 * buffer. Units are represented in cells. Reserved in case of lossy
5548 * buffer.
5549 * Access: RW
5550 *
5551 * Note: In Spectrum, reserved for buffer[9].
5552 */
5553MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
5554 0x08, 0x04, false);
5555
Jiri Pirkoe0594362015-10-16 14:01:31 +02005556static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
5557 u16 xoff_timer_value, u16 xoff_refresh)
5558{
5559 MLXSW_REG_ZERO(pbmc, payload);
5560 mlxsw_reg_pbmc_local_port_set(payload, local_port);
5561 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
5562 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
5563}
5564
5565static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
5566 int buf_index,
5567 u16 size)
5568{
5569 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
5570 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5571 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5572}
5573
Ido Schimmel155f9de2016-04-06 17:10:13 +02005574static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
5575 int buf_index, u16 size,
5576 u16 threshold)
5577{
5578 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
5579 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5580 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5581 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
5582 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
5583}
5584
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005585/* PSPA - Port Switch Partition Allocation
5586 * ---------------------------------------
5587 * Controls the association of a port with a switch partition and enables
5588 * configuring ports as stacking ports.
5589 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +02005590#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005591#define MLXSW_REG_PSPA_LEN 0x8
5592
Jiri Pirko21978dc2016-10-21 16:07:20 +02005593MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005594
5595/* reg_pspa_swid
5596 * Switch partition ID.
5597 * Access: RW
5598 */
5599MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
5600
5601/* reg_pspa_local_port
5602 * Local port number.
5603 * Access: Index
5604 */
5605MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
5606
5607/* reg_pspa_sub_port
5608 * Virtual port within the local port. Set to 0 when virtual ports are
5609 * disabled on the local port.
5610 * Access: Index
5611 */
5612MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
5613
5614static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
5615{
5616 MLXSW_REG_ZERO(pspa, payload);
5617 mlxsw_reg_pspa_swid_set(payload, swid);
5618 mlxsw_reg_pspa_local_port_set(payload, local_port);
5619 mlxsw_reg_pspa_sub_port_set(payload, 0);
5620}
5621
Amit Cohen02d33b42020-09-27 10:50:08 +03005622/* PMAOS - Ports Module Administrative and Operational Status
5623 * ----------------------------------------------------------
5624 * This register configures and retrieves the per module status.
5625 */
5626#define MLXSW_REG_PMAOS_ID 0x5012
5627#define MLXSW_REG_PMAOS_LEN 0x10
5628
5629MLXSW_REG_DEFINE(pmaos, MLXSW_REG_PMAOS_ID, MLXSW_REG_PMAOS_LEN);
5630
5631/* reg_slot_index
5632 * Slot index.
5633 * Access: Index
5634 */
5635MLXSW_ITEM32(reg, pmaos, slot_index, 0x00, 24, 4);
5636
5637/* reg_pmaos_module
5638 * Module number.
5639 * Access: Index
5640 */
5641MLXSW_ITEM32(reg, pmaos, module, 0x00, 16, 8);
5642
5643/* reg_pmaos_ase
5644 * Admin state update enable.
5645 * If this bit is set, admin state will be updated based on admin_state field.
5646 * Only relevant on Set() operations.
5647 * Access: WO
5648 */
5649MLXSW_ITEM32(reg, pmaos, ase, 0x04, 31, 1);
5650
5651/* reg_pmaos_ee
5652 * Event update enable.
5653 * If this bit is set, event generation will be updated based on the e field.
5654 * Only relevant on Set operations.
5655 * Access: WO
5656 */
5657MLXSW_ITEM32(reg, pmaos, ee, 0x04, 30, 1);
5658
5659enum mlxsw_reg_pmaos_e {
5660 MLXSW_REG_PMAOS_E_DO_NOT_GENERATE_EVENT,
5661 MLXSW_REG_PMAOS_E_GENERATE_EVENT,
5662 MLXSW_REG_PMAOS_E_GENERATE_SINGLE_EVENT,
5663};
5664
5665/* reg_pmaos_e
5666 * Event Generation on operational state change.
5667 * Access: RW
5668 */
5669MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2);
5670
5671static inline void mlxsw_reg_pmaos_pack(char *payload, u8 module,
5672 enum mlxsw_reg_pmaos_e e)
5673{
5674 MLXSW_REG_ZERO(pmaos, payload);
5675 mlxsw_reg_pmaos_module_set(payload, module);
5676 mlxsw_reg_pmaos_e_set(payload, e);
5677 mlxsw_reg_pmaos_ee_set(payload, true);
5678}
5679
Jiri Pirkoa0c25382019-05-05 09:48:05 +03005680/* PPLR - Port Physical Loopback Register
5681 * --------------------------------------
5682 * This register allows configuration of the port's loopback mode.
5683 */
5684#define MLXSW_REG_PPLR_ID 0x5018
5685#define MLXSW_REG_PPLR_LEN 0x8
5686
5687MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
5688
5689/* reg_pplr_local_port
5690 * Local port number.
5691 * Access: Index
5692 */
5693MLXSW_ITEM32(reg, pplr, local_port, 0x00, 16, 8);
5694
5695/* Phy local loopback. When set the port's egress traffic is looped back
5696 * to the receiver and the port transmitter is disabled.
5697 */
5698#define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
5699
5700/* reg_pplr_lb_en
5701 * Loopback enable.
5702 * Access: RW
5703 */
5704MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
5705
5706static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port,
5707 bool phy_local)
5708{
5709 MLXSW_REG_ZERO(pplr, payload);
5710 mlxsw_reg_pplr_local_port_set(payload, local_port);
5711 mlxsw_reg_pplr_lb_en_set(payload,
5712 phy_local ?
5713 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
5714}
5715
Amit Cohene7d62a32020-09-27 10:50:07 +03005716/* PMPE - Port Module Plug/Unplug Event Register
5717 * ---------------------------------------------
5718 * This register reports any operational status change of a module.
5719 * A change in the module’s state will generate an event only if the change
5720 * happens after arming the event mechanism. Any changes to the module state
5721 * while the event mechanism is not armed will not be reported. Software can
5722 * query the PMPE register for module status.
5723 */
5724#define MLXSW_REG_PMPE_ID 0x5024
5725#define MLXSW_REG_PMPE_LEN 0x10
5726
5727MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN);
5728
5729/* reg_pmpe_slot_index
5730 * Slot index.
5731 * Access: Index
5732 */
5733MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4);
5734
5735/* reg_pmpe_module
5736 * Module number.
5737 * Access: Index
5738 */
5739MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8);
5740
5741enum mlxsw_reg_pmpe_module_status {
5742 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1,
5743 MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED,
5744 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR,
5745 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED,
5746};
5747
5748/* reg_pmpe_module_status
5749 * Module status.
5750 * Access: RO
5751 */
5752MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4);
5753
5754/* reg_pmpe_error_type
5755 * Module error details.
5756 * Access: RO
5757 */
5758MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4);
5759
Amit Cohen1bd06932020-06-29 23:46:17 +03005760/* PDDR - Port Diagnostics Database Register
5761 * -----------------------------------------
5762 * The PDDR enables to read the Phy debug database
5763 */
5764#define MLXSW_REG_PDDR_ID 0x5031
5765#define MLXSW_REG_PDDR_LEN 0x100
5766
5767MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN);
5768
5769/* reg_pddr_local_port
5770 * Local port number.
5771 * Access: Index
5772 */
5773MLXSW_ITEM32(reg, pddr, local_port, 0x00, 16, 8);
5774
5775enum mlxsw_reg_pddr_page_select {
5776 MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1,
5777};
5778
5779/* reg_pddr_page_select
5780 * Page select index.
5781 * Access: Index
5782 */
5783MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8);
5784
5785enum mlxsw_reg_pddr_trblsh_group_opcode {
5786 /* Monitor opcodes */
5787 MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR,
5788};
5789
5790/* reg_pddr_group_opcode
5791 * Group selector.
5792 * Access: Index
5793 */
5794MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
5795
5796/* reg_pddr_status_opcode
5797 * Group selector.
5798 * Access: RO
5799 */
5800MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
5801
5802static inline void mlxsw_reg_pddr_pack(char *payload, u8 local_port,
5803 u8 page_select)
5804{
5805 MLXSW_REG_ZERO(pddr, payload);
5806 mlxsw_reg_pddr_local_port_set(payload, local_port);
5807 mlxsw_reg_pddr_page_select_set(payload, page_select);
5808}
5809
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005810/* PMTM - Port Module Type Mapping Register
5811 * ----------------------------------------
5812 * The PMTM allows query or configuration of module types.
5813 */
5814#define MLXSW_REG_PMTM_ID 0x5067
5815#define MLXSW_REG_PMTM_LEN 0x10
5816
5817MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
5818
5819/* reg_pmtm_module
5820 * Module number.
5821 * Access: Index
5822 */
5823MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
5824
5825enum mlxsw_reg_pmtm_module_type {
5826 /* Backplane with 4 lanes */
5827 MLXSW_REG_PMTM_MODULE_TYPE_BP_4X,
5828 /* QSFP */
Jiri Pirkoec4a5142020-02-27 20:59:26 +01005829 MLXSW_REG_PMTM_MODULE_TYPE_QSFP,
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005830 /* SFP */
Jiri Pirkoec4a5142020-02-27 20:59:26 +01005831 MLXSW_REG_PMTM_MODULE_TYPE_SFP,
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005832 /* Backplane with single lane */
5833 MLXSW_REG_PMTM_MODULE_TYPE_BP_1X = 4,
5834 /* Backplane with two lane */
5835 MLXSW_REG_PMTM_MODULE_TYPE_BP_2X = 8,
Jiri Pirkoec4a5142020-02-27 20:59:26 +01005836 /* Chip2Chip4x */
5837 MLXSW_REG_PMTM_MODULE_TYPE_C2C4X = 10,
5838 /* Chip2Chip2x */
5839 MLXSW_REG_PMTM_MODULE_TYPE_C2C2X,
5840 /* Chip2Chip1x */
5841 MLXSW_REG_PMTM_MODULE_TYPE_C2C1X,
5842 /* QSFP-DD */
5843 MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD = 14,
5844 /* OSFP */
5845 MLXSW_REG_PMTM_MODULE_TYPE_OSFP,
5846 /* SFP-DD */
5847 MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD,
5848 /* DSFP */
5849 MLXSW_REG_PMTM_MODULE_TYPE_DSFP,
5850 /* Chip2Chip8x */
5851 MLXSW_REG_PMTM_MODULE_TYPE_C2C8X,
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005852};
5853
5854/* reg_pmtm_module_type
5855 * Module type.
5856 * Access: RW
5857 */
5858MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 4);
5859
5860static inline void mlxsw_reg_pmtm_pack(char *payload, u8 module)
5861{
5862 MLXSW_REG_ZERO(pmtm, payload);
5863 mlxsw_reg_pmtm_module_set(payload, module);
5864}
5865
5866static inline void
5867mlxsw_reg_pmtm_unpack(char *payload,
5868 enum mlxsw_reg_pmtm_module_type *module_type)
5869{
5870 *module_type = mlxsw_reg_pmtm_module_type_get(payload);
5871}
5872
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005873/* HTGT - Host Trap Group Table
5874 * ----------------------------
5875 * Configures the properties for forwarding to CPU.
5876 */
5877#define MLXSW_REG_HTGT_ID 0x7002
Elad Raze158e5e2017-02-06 13:56:27 +01005878#define MLXSW_REG_HTGT_LEN 0x20
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005879
Jiri Pirko21978dc2016-10-21 16:07:20 +02005880MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005881
5882/* reg_htgt_swid
5883 * Switch partition ID.
5884 * Access: Index
5885 */
5886MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
5887
5888#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
5889
5890/* reg_htgt_type
5891 * CPU path type.
5892 * Access: RW
5893 */
5894MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
5895
Ido Schimmel801bd3d2015-10-15 17:43:28 +02005896enum mlxsw_reg_htgt_trap_group {
5897 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
Jiri Pirko7d83ee12020-09-15 11:40:58 +03005898 MLXSW_REG_HTGT_TRAP_GROUP_MFDE,
Amit Cohen943585c2020-09-27 10:50:11 +03005899 MLXSW_REG_HTGT_TRAP_GROUP_MTWE,
Amit Cohen05cf5822020-09-27 10:50:14 +03005900 MLXSW_REG_HTGT_TRAP_GROUP_PMPE,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005901 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
5902 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
5903 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
Ido Schimmeldebb7af2020-05-25 00:50:57 +03005904 MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02005905 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005906 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
Yotam Gigib48cfc82017-09-19 10:00:20 +02005907 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
5908 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
Ido Schimmel32446432020-05-25 00:51:04 +03005909 MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005910 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
Ido Schimmelec4f5b32020-07-29 12:26:44 +03005911 MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005912 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
5913 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
5914 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
Ido Schimmel412df3d2020-05-26 02:05:45 +03005915 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
Ido Schimmel2f4f4492018-12-04 08:15:12 +00005916 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
Petr Machataaed4b572019-06-30 09:04:51 +03005917 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
5918 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
Ido Schimmelacca7892019-12-29 13:40:23 +02005919 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
Ido Schimmelce3c3bf2020-05-25 00:51:06 +03005920 MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
Ido Schimmel3c2d8a042020-05-26 02:05:43 +03005921 MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
Ido Schimmeld3223092020-05-26 02:05:47 +03005922 MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS,
Ido Schimmel9785b922020-05-26 02:05:55 +03005923 MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
Jiri Pirkoe6125232020-02-24 08:35:54 +01005924 MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
Ido Schimmel9e6290c2019-08-21 10:19:34 +03005925 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
Amit Cohendbc684f2019-11-07 18:42:10 +02005926 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
Ido Schimmel1e292f52020-05-29 21:36:37 +03005927 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
Amit Cohena318bf62020-01-19 15:00:55 +02005928 MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
Jiri Pirko45dbee02020-02-24 08:35:55 +01005929 MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
Ido Schimmel6687e952020-08-03 19:11:39 +03005930 MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
Ido Schimmel500769b2020-05-26 02:05:52 +03005931
5932 __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
5933 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
Ido Schimmel801bd3d2015-10-15 17:43:28 +02005934};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005935
5936/* reg_htgt_trap_group
5937 * Trap group number. User defined number specifying which trap groups
5938 * should be forwarded to the CPU. The mapping between trap IDs and trap
5939 * groups is configured using HPKT register.
5940 * Access: Index
5941 */
5942MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
5943
5944enum {
5945 MLXSW_REG_HTGT_POLICER_DISABLE,
5946 MLXSW_REG_HTGT_POLICER_ENABLE,
5947};
5948
5949/* reg_htgt_pide
5950 * Enable policer ID specified using 'pid' field.
5951 * Access: RW
5952 */
5953MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
5954
Nogah Frankel579c82e2016-11-25 10:33:42 +01005955#define MLXSW_REG_HTGT_INVALID_POLICER 0xff
5956
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005957/* reg_htgt_pid
5958 * Policer ID for the trap group.
5959 * Access: RW
5960 */
5961MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
5962
5963#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
5964
5965/* reg_htgt_mirror_action
5966 * Mirror action to use.
5967 * 0 - Trap to CPU.
5968 * 1 - Trap to CPU and mirror to a mirroring agent.
5969 * 2 - Mirror to a mirroring agent and do not trap to CPU.
5970 * Access: RW
5971 *
5972 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
5973 */
5974MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
5975
5976/* reg_htgt_mirroring_agent
5977 * Mirroring agent.
5978 * Access: RW
5979 */
5980MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
5981
Nogah Frankel579c82e2016-11-25 10:33:42 +01005982#define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
5983
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005984/* reg_htgt_priority
5985 * Trap group priority.
5986 * In case a packet matches multiple classification rules, the packet will
5987 * only be trapped once, based on the trap ID associated with the group (via
5988 * register HPKT) with the highest priority.
5989 * Supported values are 0-7, with 7 represnting the highest priority.
5990 * Access: RW
5991 *
5992 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
5993 * by the 'trap_group' field.
5994 */
5995MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
5996
Nogah Frankel579c82e2016-11-25 10:33:42 +01005997#define MLXSW_REG_HTGT_DEFAULT_TC 7
5998
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005999/* reg_htgt_local_path_cpu_tclass
6000 * CPU ingress traffic class for the trap group.
6001 * Access: RW
6002 */
6003MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
6004
Nogah Frankel579c82e2016-11-25 10:33:42 +01006005enum mlxsw_reg_htgt_local_path_rdq {
6006 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
6007 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
6008 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
6009 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
6010};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006011/* reg_htgt_local_path_rdq
6012 * Receive descriptor queue (RDQ) to use for the trap group.
6013 * Access: RW
6014 */
6015MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
6016
Nogah Frankel579c82e2016-11-25 10:33:42 +01006017static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
6018 u8 priority, u8 tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006019{
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006020 MLXSW_REG_ZERO(htgt, payload);
Nogah Frankel579c82e2016-11-25 10:33:42 +01006021
6022 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
6023 mlxsw_reg_htgt_pide_set(payload,
6024 MLXSW_REG_HTGT_POLICER_DISABLE);
6025 } else {
6026 mlxsw_reg_htgt_pide_set(payload,
6027 MLXSW_REG_HTGT_POLICER_ENABLE);
6028 mlxsw_reg_htgt_pid_set(payload, policer_id);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006029 }
Nogah Frankel579c82e2016-11-25 10:33:42 +01006030
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006031 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02006032 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006033 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
6034 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
Nogah Frankel579c82e2016-11-25 10:33:42 +01006035 mlxsw_reg_htgt_priority_set(payload, priority);
6036 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
6037 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006038}
6039
6040/* HPKT - Host Packet Trap
6041 * -----------------------
6042 * Configures trap IDs inside trap groups.
6043 */
6044#define MLXSW_REG_HPKT_ID 0x7003
6045#define MLXSW_REG_HPKT_LEN 0x10
6046
Jiri Pirko21978dc2016-10-21 16:07:20 +02006047MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006048
6049enum {
6050 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
6051 MLXSW_REG_HPKT_ACK_REQUIRED,
6052};
6053
6054/* reg_hpkt_ack
6055 * Require acknowledgements from the host for events.
6056 * If set, then the device will wait for the event it sent to be acknowledged
6057 * by the host. This option is only relevant for event trap IDs.
6058 * Access: RW
6059 *
6060 * Note: Currently not supported by firmware.
6061 */
6062MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
6063
6064enum mlxsw_reg_hpkt_action {
6065 MLXSW_REG_HPKT_ACTION_FORWARD,
6066 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
6067 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
6068 MLXSW_REG_HPKT_ACTION_DISCARD,
6069 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
6070 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
Ido Schimmel6a44bae2019-08-21 10:19:32 +03006071 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
6072 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006073};
6074
6075/* reg_hpkt_action
6076 * Action to perform on packet when trapped.
6077 * 0 - No action. Forward to CPU based on switching rules.
6078 * 1 - Trap to CPU (CPU receives sole copy).
6079 * 2 - Mirror to CPU (CPU receives a replica of the packet).
6080 * 3 - Discard.
6081 * 4 - Soft discard (allow other traps to act on the packet).
6082 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
Ido Schimmel6a44bae2019-08-21 10:19:32 +03006083 * 6 - Trap to CPU (CPU receives sole copy) and count it as error.
6084 * 15 - Restore the firmware's default action.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006085 * Access: RW
6086 *
6087 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
6088 * addressed to the CPU.
6089 */
6090MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
6091
6092/* reg_hpkt_trap_group
6093 * Trap group to associate the trap with.
6094 * Access: RW
6095 */
6096MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
6097
6098/* reg_hpkt_trap_id
6099 * Trap ID.
6100 * Access: Index
6101 *
6102 * Note: A trap ID can only be associated with a single trap group. The device
6103 * will associate the trap ID with the last trap group configured.
6104 */
Amit Cohen47e4b162020-07-14 17:21:02 +03006105MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006106
6107enum {
6108 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
6109 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
6110 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
6111};
6112
6113/* reg_hpkt_ctrl
6114 * Configure dedicated buffer resources for control packets.
Nogah Frankeld570b7e2016-11-25 10:33:38 +01006115 * Ignored by SwitchX-2.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006116 * 0 - Keep factory defaults.
6117 * 1 - Do not use control buffer for this trap ID.
6118 * 2 - Use control buffer for this trap ID.
6119 * Access: RW
6120 */
6121MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
6122
Nogah Frankeld570b7e2016-11-25 10:33:38 +01006123static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
6124 enum mlxsw_reg_htgt_trap_group trap_group,
6125 bool is_ctrl)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006126{
6127 MLXSW_REG_ZERO(hpkt, payload);
6128 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
6129 mlxsw_reg_hpkt_action_set(payload, action);
6130 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
6131 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
Nogah Frankeld570b7e2016-11-25 10:33:38 +01006132 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
6133 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
6134 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02006135}
6136
Ido Schimmel69c407a2016-07-02 11:00:13 +02006137/* RGCR - Router General Configuration Register
6138 * --------------------------------------------
6139 * The register is used for setting up the router configuration.
6140 */
6141#define MLXSW_REG_RGCR_ID 0x8001
6142#define MLXSW_REG_RGCR_LEN 0x28
6143
Jiri Pirko21978dc2016-10-21 16:07:20 +02006144MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
Ido Schimmel69c407a2016-07-02 11:00:13 +02006145
6146/* reg_rgcr_ipv4_en
6147 * IPv4 router enable.
6148 * Access: RW
6149 */
6150MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
6151
6152/* reg_rgcr_ipv6_en
6153 * IPv6 router enable.
6154 * Access: RW
6155 */
6156MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
6157
6158/* reg_rgcr_max_router_interfaces
6159 * Defines the maximum number of active router interfaces for all virtual
6160 * routers.
6161 * Access: RW
6162 */
6163MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
6164
6165/* reg_rgcr_usp
6166 * Update switch priority and packet color.
6167 * 0 - Preserve the value of Switch Priority and packet color.
6168 * 1 - Recalculate the value of Switch Priority and packet color.
6169 * Access: RW
6170 *
6171 * Note: Not supported by SwitchX and SwitchX-2.
6172 */
6173MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
6174
6175/* reg_rgcr_pcp_rw
6176 * Indicates how to handle the pcp_rewrite_en value:
6177 * 0 - Preserve the value of pcp_rewrite_en.
6178 * 2 - Disable PCP rewrite.
6179 * 3 - Enable PCP rewrite.
6180 * Access: RW
6181 *
6182 * Note: Not supported by SwitchX and SwitchX-2.
6183 */
6184MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
6185
6186/* reg_rgcr_activity_dis
6187 * Activity disable:
6188 * 0 - Activity will be set when an entry is hit (default).
6189 * 1 - Activity will not be set when an entry is hit.
6190 *
6191 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
6192 * (RALUE).
6193 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
6194 * Entry (RAUHT).
6195 * Bits 2:7 are reserved.
6196 * Access: RW
6197 *
6198 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
6199 */
6200MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
6201
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02006202static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
6203 bool ipv6_en)
Ido Schimmel69c407a2016-07-02 11:00:13 +02006204{
6205 MLXSW_REG_ZERO(rgcr, payload);
6206 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02006207 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
Ido Schimmel69c407a2016-07-02 11:00:13 +02006208}
6209
Ido Schimmel3dc26682016-07-02 11:00:18 +02006210/* RITR - Router Interface Table Register
6211 * --------------------------------------
6212 * The register is used to configure the router interface table.
6213 */
6214#define MLXSW_REG_RITR_ID 0x8002
6215#define MLXSW_REG_RITR_LEN 0x40
6216
Jiri Pirko21978dc2016-10-21 16:07:20 +02006217MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
Ido Schimmel3dc26682016-07-02 11:00:18 +02006218
6219/* reg_ritr_enable
6220 * Enables routing on the router interface.
6221 * Access: RW
6222 */
6223MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
6224
6225/* reg_ritr_ipv4
6226 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
6227 * interface.
6228 * Access: RW
6229 */
6230MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
6231
6232/* reg_ritr_ipv6
6233 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
6234 * interface.
6235 * Access: RW
6236 */
6237MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
6238
Yotam Gigi4af59642017-09-19 10:00:18 +02006239/* reg_ritr_ipv4_mc
6240 * IPv4 multicast routing enable.
6241 * Access: RW
6242 */
6243MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
6244
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006245/* reg_ritr_ipv6_mc
6246 * IPv6 multicast routing enable.
6247 * Access: RW
6248 */
6249MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
6250
Ido Schimmel3dc26682016-07-02 11:00:18 +02006251enum mlxsw_reg_ritr_if_type {
Petr Machata78676ad2017-07-31 09:27:26 +02006252 /* VLAN interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02006253 MLXSW_REG_RITR_VLAN_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02006254 /* FID interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02006255 MLXSW_REG_RITR_FID_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02006256 /* Sub-port interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02006257 MLXSW_REG_RITR_SP_IF,
Petr Machata99ae8e32017-09-02 23:49:09 +02006258 /* Loopback Interface. */
6259 MLXSW_REG_RITR_LOOPBACK_IF,
Ido Schimmel3dc26682016-07-02 11:00:18 +02006260};
6261
6262/* reg_ritr_type
Petr Machata78676ad2017-07-31 09:27:26 +02006263 * Router interface type as per enum mlxsw_reg_ritr_if_type.
Ido Schimmel3dc26682016-07-02 11:00:18 +02006264 * Access: RW
6265 */
6266MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
6267
6268enum {
6269 MLXSW_REG_RITR_RIF_CREATE,
6270 MLXSW_REG_RITR_RIF_DEL,
6271};
6272
6273/* reg_ritr_op
6274 * Opcode:
6275 * 0 - Create or edit RIF.
6276 * 1 - Delete RIF.
6277 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
6278 * is not supported. An interface must be deleted and re-created in order
6279 * to update properties.
6280 * Access: WO
6281 */
6282MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
6283
6284/* reg_ritr_rif
6285 * Router interface index. A pointer to the Router Interface Table.
6286 * Access: Index
6287 */
6288MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
6289
6290/* reg_ritr_ipv4_fe
6291 * IPv4 Forwarding Enable.
6292 * Enables routing of IPv4 traffic on the router interface. When disabled,
6293 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6294 * Not supported in SwitchX-2.
6295 * Access: RW
6296 */
6297MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
6298
6299/* reg_ritr_ipv6_fe
6300 * IPv6 Forwarding Enable.
6301 * Enables routing of IPv6 traffic on the router interface. When disabled,
6302 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6303 * Not supported in SwitchX-2.
6304 * Access: RW
6305 */
6306MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
6307
Yotam Gigi4af59642017-09-19 10:00:18 +02006308/* reg_ritr_ipv4_mc_fe
6309 * IPv4 Multicast Forwarding Enable.
6310 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6311 * will be enabled.
6312 * Access: RW
6313 */
6314MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
6315
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006316/* reg_ritr_ipv6_mc_fe
6317 * IPv6 Multicast Forwarding Enable.
6318 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6319 * will be enabled.
6320 * Access: RW
6321 */
6322MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
6323
Ido Schimmela94a6142016-08-17 16:39:33 +02006324/* reg_ritr_lb_en
6325 * Loop-back filter enable for unicast packets.
6326 * If the flag is set then loop-back filter for unicast packets is
6327 * implemented on the RIF. Multicast packets are always subject to
6328 * loop-back filtering.
6329 * Access: RW
6330 */
6331MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
6332
Ido Schimmel3dc26682016-07-02 11:00:18 +02006333/* reg_ritr_virtual_router
6334 * Virtual router ID associated with the router interface.
6335 * Access: RW
6336 */
6337MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
6338
6339/* reg_ritr_mtu
6340 * Router interface MTU.
6341 * Access: RW
6342 */
6343MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
6344
6345/* reg_ritr_if_swid
6346 * Switch partition ID.
6347 * Access: RW
6348 */
6349MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
6350
6351/* reg_ritr_if_mac
6352 * Router interface MAC address.
6353 * In Spectrum, all MAC addresses must have the same 38 MSBits.
6354 * Access: RW
6355 */
6356MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
6357
Ido Schimmelc3a49542018-07-14 11:39:54 +03006358/* reg_ritr_if_vrrp_id_ipv6
6359 * VRRP ID for IPv6
6360 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6361 * Access: RW
6362 */
6363MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
6364
6365/* reg_ritr_if_vrrp_id_ipv4
6366 * VRRP ID for IPv4
6367 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6368 * Access: RW
6369 */
6370MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
6371
Ido Schimmel3dc26682016-07-02 11:00:18 +02006372/* VLAN Interface */
6373
6374/* reg_ritr_vlan_if_vid
6375 * VLAN ID.
6376 * Access: RW
6377 */
6378MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
6379
6380/* FID Interface */
6381
6382/* reg_ritr_fid_if_fid
6383 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
6384 * the vFID range are supported.
6385 * Access: RW
6386 */
6387MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
6388
6389static inline void mlxsw_reg_ritr_fid_set(char *payload,
6390 enum mlxsw_reg_ritr_if_type rif_type,
6391 u16 fid)
6392{
6393 if (rif_type == MLXSW_REG_RITR_FID_IF)
6394 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
6395 else
6396 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
6397}
6398
6399/* Sub-port Interface */
6400
6401/* reg_ritr_sp_if_lag
6402 * LAG indication. When this bit is set the system_port field holds the
6403 * LAG identifier.
6404 * Access: RW
6405 */
6406MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
6407
6408/* reg_ritr_sp_system_port
6409 * Port unique indentifier. When lag bit is set, this field holds the
6410 * lag_id in bits 0:9.
6411 * Access: RW
6412 */
6413MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
6414
6415/* reg_ritr_sp_if_vid
6416 * VLAN ID.
6417 * Access: RW
6418 */
6419MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
6420
Petr Machata99ae8e32017-09-02 23:49:09 +02006421/* Loopback Interface */
6422
6423enum mlxsw_reg_ritr_loopback_protocol {
6424 /* IPinIP IPv4 underlay Unicast */
6425 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
6426 /* IPinIP IPv6 underlay Unicast */
6427 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
Nir Dotanafba3e12019-01-20 06:50:39 +00006428 /* IPinIP generic - used for Spectrum-2 underlay RIF */
6429 MLXSW_REG_RITR_LOOPBACK_GENERIC,
Petr Machata99ae8e32017-09-02 23:49:09 +02006430};
6431
6432/* reg_ritr_loopback_protocol
6433 * Access: RW
6434 */
6435MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
6436
6437enum mlxsw_reg_ritr_loopback_ipip_type {
6438 /* Tunnel is IPinIP. */
6439 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
6440 /* Tunnel is GRE, no key. */
6441 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
6442 /* Tunnel is GRE, with a key. */
6443 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
6444};
6445
6446/* reg_ritr_loopback_ipip_type
6447 * Encapsulation type.
6448 * Access: RW
6449 */
6450MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
6451
6452enum mlxsw_reg_ritr_loopback_ipip_options {
6453 /* The key is defined by gre_key. */
6454 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
6455};
6456
6457/* reg_ritr_loopback_ipip_options
6458 * Access: RW
6459 */
6460MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
6461
6462/* reg_ritr_loopback_ipip_uvr
6463 * Underlay Virtual Router ID.
6464 * Range is 0..cap_max_virtual_routers-1.
6465 * Reserved for Spectrum-2.
6466 * Access: RW
6467 */
6468MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
6469
Nir Dotanafba3e12019-01-20 06:50:39 +00006470/* reg_ritr_loopback_ipip_underlay_rif
6471 * Underlay ingress router interface.
6472 * Reserved for Spectrum.
6473 * Access: RW
6474 */
6475MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
6476
Petr Machata99ae8e32017-09-02 23:49:09 +02006477/* reg_ritr_loopback_ipip_usip*
6478 * Encapsulation Underlay source IP.
6479 * Access: RW
6480 */
6481MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
6482MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
6483
6484/* reg_ritr_loopback_ipip_gre_key
6485 * GRE Key.
6486 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
6487 * Access: RW
6488 */
6489MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
6490
Arkadi Sharshevsky0f630fc2017-03-28 17:24:11 +02006491/* Shared between ingress/egress */
6492enum mlxsw_reg_ritr_counter_set_type {
6493 /* No Count. */
6494 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
6495 /* Basic. Used for router interfaces, counting the following:
6496 * - Error and Discard counters.
6497 * - Unicast, Multicast and Broadcast counters. Sharing the
6498 * same set of counters for the different type of traffic
6499 * (IPv4, IPv6 and mpls).
6500 */
6501 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
6502};
6503
6504/* reg_ritr_ingress_counter_index
6505 * Counter Index for flow counter.
6506 * Access: RW
6507 */
6508MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
6509
6510/* reg_ritr_ingress_counter_set_type
6511 * Igress Counter Set Type for router interface counter.
6512 * Access: RW
6513 */
6514MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
6515
6516/* reg_ritr_egress_counter_index
6517 * Counter Index for flow counter.
6518 * Access: RW
6519 */
6520MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
6521
6522/* reg_ritr_egress_counter_set_type
6523 * Egress Counter Set Type for router interface counter.
6524 * Access: RW
6525 */
6526MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
6527
6528static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
6529 bool enable, bool egress)
6530{
6531 enum mlxsw_reg_ritr_counter_set_type set_type;
6532
6533 if (enable)
6534 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
6535 else
6536 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
6537 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
6538
6539 if (egress)
6540 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
6541 else
6542 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
6543}
6544
Ido Schimmel3dc26682016-07-02 11:00:18 +02006545static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
6546{
6547 MLXSW_REG_ZERO(ritr, payload);
6548 mlxsw_reg_ritr_rif_set(payload, rif);
6549}
6550
6551static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
6552 u16 system_port, u16 vid)
6553{
6554 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
6555 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
6556 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
6557}
6558
6559static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
6560 enum mlxsw_reg_ritr_if_type type,
Petr Machata9571e822017-09-02 23:49:14 +02006561 u16 rif, u16 vr_id, u16 mtu)
Ido Schimmel3dc26682016-07-02 11:00:18 +02006562{
6563 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
6564
6565 MLXSW_REG_ZERO(ritr, payload);
6566 mlxsw_reg_ritr_enable_set(payload, enable);
6567 mlxsw_reg_ritr_ipv4_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02006568 mlxsw_reg_ritr_ipv6_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02006569 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006570 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
Ido Schimmel3dc26682016-07-02 11:00:18 +02006571 mlxsw_reg_ritr_type_set(payload, type);
6572 mlxsw_reg_ritr_op_set(payload, op);
6573 mlxsw_reg_ritr_rif_set(payload, rif);
6574 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02006575 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02006576 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006577 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
Ido Schimmela94a6142016-08-17 16:39:33 +02006578 mlxsw_reg_ritr_lb_en_set(payload, 1);
Ido Schimmel69132292017-03-10 08:53:42 +01006579 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
Ido Schimmel3dc26682016-07-02 11:00:18 +02006580 mlxsw_reg_ritr_mtu_set(payload, mtu);
Petr Machata9571e822017-09-02 23:49:14 +02006581}
6582
6583static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
6584{
Ido Schimmel3dc26682016-07-02 11:00:18 +02006585 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
6586}
6587
Petr Machata99ae8e32017-09-02 23:49:09 +02006588static inline void
6589mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
6590 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6591 enum mlxsw_reg_ritr_loopback_ipip_options options,
Nir Dotanafba3e12019-01-20 06:50:39 +00006592 u16 uvr_id, u16 underlay_rif, u32 gre_key)
Petr Machata99ae8e32017-09-02 23:49:09 +02006593{
6594 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
6595 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
6596 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
Nir Dotanafba3e12019-01-20 06:50:39 +00006597 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
Petr Machata99ae8e32017-09-02 23:49:09 +02006598 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
6599}
6600
6601static inline void
6602mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
6603 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6604 enum mlxsw_reg_ritr_loopback_ipip_options options,
Nir Dotanafba3e12019-01-20 06:50:39 +00006605 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
Petr Machata99ae8e32017-09-02 23:49:09 +02006606{
6607 mlxsw_reg_ritr_loopback_protocol_set(payload,
6608 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
6609 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
Nir Dotanafba3e12019-01-20 06:50:39 +00006610 uvr_id, underlay_rif, gre_key);
Petr Machata99ae8e32017-09-02 23:49:09 +02006611 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
6612}
6613
Yotam Gigi46a70542017-09-19 10:00:13 +02006614/* RTAR - Router TCAM Allocation Register
6615 * --------------------------------------
6616 * This register is used for allocation of regions in the TCAM table.
6617 */
6618#define MLXSW_REG_RTAR_ID 0x8004
6619#define MLXSW_REG_RTAR_LEN 0x20
6620
6621MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
6622
6623enum mlxsw_reg_rtar_op {
6624 MLXSW_REG_RTAR_OP_ALLOCATE,
6625 MLXSW_REG_RTAR_OP_RESIZE,
6626 MLXSW_REG_RTAR_OP_DEALLOCATE,
6627};
6628
6629/* reg_rtar_op
6630 * Access: WO
6631 */
6632MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
6633
6634enum mlxsw_reg_rtar_key_type {
6635 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
6636 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
6637};
6638
6639/* reg_rtar_key_type
6640 * TCAM key type for the region.
6641 * Access: WO
6642 */
6643MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
6644
6645/* reg_rtar_region_size
6646 * TCAM region size. When allocating/resizing this is the requested
6647 * size, the response is the actual size.
6648 * Note: Actual size may be larger than requested.
6649 * Reserved for op = Deallocate
6650 * Access: WO
6651 */
6652MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
6653
6654static inline void mlxsw_reg_rtar_pack(char *payload,
6655 enum mlxsw_reg_rtar_op op,
6656 enum mlxsw_reg_rtar_key_type key_type,
6657 u16 region_size)
6658{
6659 MLXSW_REG_ZERO(rtar, payload);
6660 mlxsw_reg_rtar_op_set(payload, op);
6661 mlxsw_reg_rtar_key_type_set(payload, key_type);
6662 mlxsw_reg_rtar_region_size_set(payload, region_size);
6663}
6664
Yotam Gigi089f9812016-07-05 11:27:48 +02006665/* RATR - Router Adjacency Table Register
6666 * --------------------------------------
6667 * The RATR register is used to configure the Router Adjacency (next-hop)
6668 * Table.
6669 */
6670#define MLXSW_REG_RATR_ID 0x8008
6671#define MLXSW_REG_RATR_LEN 0x2C
6672
Jiri Pirko21978dc2016-10-21 16:07:20 +02006673MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
Yotam Gigi089f9812016-07-05 11:27:48 +02006674
6675enum mlxsw_reg_ratr_op {
6676 /* Read */
6677 MLXSW_REG_RATR_OP_QUERY_READ = 0,
6678 /* Read and clear activity */
6679 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
6680 /* Write Adjacency entry */
6681 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
6682 /* Write Adjacency entry only if the activity is cleared.
6683 * The write may not succeed if the activity is set. There is not
6684 * direct feedback if the write has succeeded or not, however
6685 * the get will reveal the actual entry (SW can compare the get
6686 * response to the set command).
6687 */
6688 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
6689};
6690
6691/* reg_ratr_op
6692 * Note that Write operation may also be used for updating
6693 * counter_set_type and counter_index. In this case all other
6694 * fields must not be updated.
6695 * Access: OP
6696 */
6697MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
6698
6699/* reg_ratr_v
6700 * Valid bit. Indicates if the adjacency entry is valid.
6701 * Note: the device may need some time before reusing an invalidated
6702 * entry. During this time the entry can not be reused. It is
6703 * recommended to use another entry before reusing an invalidated
6704 * entry (e.g. software can put it at the end of the list for
6705 * reusing). Trying to access an invalidated entry not yet cleared
6706 * by the device results with failure indicating "Try Again" status.
6707 * When valid is '0' then egress_router_interface,trap_action,
6708 * adjacency_parameters and counters are reserved
6709 * Access: RW
6710 */
6711MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
6712
6713/* reg_ratr_a
6714 * Activity. Set for new entries. Set if a packet lookup has hit on
6715 * the specific entry. To clear the a bit, use "clear activity".
6716 * Access: RO
6717 */
6718MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
6719
Petr Machata7c819de2017-09-02 23:49:10 +02006720enum mlxsw_reg_ratr_type {
6721 /* Ethernet */
6722 MLXSW_REG_RATR_TYPE_ETHERNET,
6723 /* IPoIB Unicast without GRH.
6724 * Reserved for Spectrum.
6725 */
6726 MLXSW_REG_RATR_TYPE_IPOIB_UC,
6727 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
6728 * adjacency).
6729 * Reserved for Spectrum.
6730 */
6731 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
6732 /* IPoIB Multicast.
6733 * Reserved for Spectrum.
6734 */
6735 MLXSW_REG_RATR_TYPE_IPOIB_MC,
6736 /* MPLS.
6737 * Reserved for SwitchX/-2.
6738 */
6739 MLXSW_REG_RATR_TYPE_MPLS,
6740 /* IPinIP Encap.
6741 * Reserved for SwitchX/-2.
6742 */
6743 MLXSW_REG_RATR_TYPE_IPIP,
6744};
6745
6746/* reg_ratr_type
6747 * Adjacency entry type.
6748 * Access: RW
6749 */
6750MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
6751
Yotam Gigi089f9812016-07-05 11:27:48 +02006752/* reg_ratr_adjacency_index_low
6753 * Bits 15:0 of index into the adjacency table.
6754 * For SwitchX and SwitchX-2, the adjacency table is linear and
6755 * used for adjacency entries only.
6756 * For Spectrum, the index is to the KVD linear.
6757 * Access: Index
6758 */
6759MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
6760
6761/* reg_ratr_egress_router_interface
6762 * Range is 0 .. cap_max_router_interfaces - 1
6763 * Access: RW
6764 */
6765MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
6766
6767enum mlxsw_reg_ratr_trap_action {
6768 MLXSW_REG_RATR_TRAP_ACTION_NOP,
6769 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
6770 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
6771 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
6772 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
6773};
6774
6775/* reg_ratr_trap_action
6776 * see mlxsw_reg_ratr_trap_action
6777 * Access: RW
6778 */
6779MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
6780
Yotam Gigi089f9812016-07-05 11:27:48 +02006781/* reg_ratr_adjacency_index_high
6782 * Bits 23:16 of the adjacency_index.
6783 * Access: Index
6784 */
6785MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
6786
Petr Machata6c4153b2017-09-02 23:49:11 +02006787enum mlxsw_reg_ratr_trap_id {
6788 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
6789 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
6790};
6791
Yotam Gigi089f9812016-07-05 11:27:48 +02006792/* reg_ratr_trap_id
6793 * Trap ID to be reported to CPU.
6794 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
6795 * For trap_action of NOP, MIRROR and DISCARD_ERROR
6796 * Access: RW
6797 */
6798MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
6799
6800/* reg_ratr_eth_destination_mac
6801 * MAC address of the destination next-hop.
6802 * Access: RW
6803 */
6804MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
6805
Petr Machata7c819de2017-09-02 23:49:10 +02006806enum mlxsw_reg_ratr_ipip_type {
6807 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
6808 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
6809 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
6810 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
6811};
6812
6813/* reg_ratr_ipip_type
6814 * Underlay destination ip type.
6815 * Note: the type field must match the protocol of the router interface.
6816 * Access: RW
6817 */
6818MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
6819
6820/* reg_ratr_ipip_ipv4_udip
6821 * Underlay ipv4 dip.
6822 * Reserved when ipip_type is IPv6.
6823 * Access: RW
6824 */
6825MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
6826
6827/* reg_ratr_ipip_ipv6_ptr
6828 * Pointer to IPv6 underlay destination ip address.
6829 * For Spectrum: Pointer to KVD linear space.
6830 * Access: RW
6831 */
6832MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
6833
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02006834enum mlxsw_reg_flow_counter_set_type {
6835 /* No count */
6836 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
6837 /* Count packets and bytes */
6838 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
6839 /* Count only packets */
6840 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
6841};
6842
6843/* reg_ratr_counter_set_type
6844 * Counter set type for flow counters
6845 * Access: RW
6846 */
6847MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
6848
6849/* reg_ratr_counter_index
6850 * Counter index for flow counters
6851 * Access: RW
6852 */
6853MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
6854
Yotam Gigi089f9812016-07-05 11:27:48 +02006855static inline void
6856mlxsw_reg_ratr_pack(char *payload,
6857 enum mlxsw_reg_ratr_op op, bool valid,
Petr Machata89e41982017-09-02 23:49:15 +02006858 enum mlxsw_reg_ratr_type type,
Yotam Gigi089f9812016-07-05 11:27:48 +02006859 u32 adjacency_index, u16 egress_rif)
6860{
6861 MLXSW_REG_ZERO(ratr, payload);
6862 mlxsw_reg_ratr_op_set(payload, op);
6863 mlxsw_reg_ratr_v_set(payload, valid);
Petr Machata89e41982017-09-02 23:49:15 +02006864 mlxsw_reg_ratr_type_set(payload, type);
Yotam Gigi089f9812016-07-05 11:27:48 +02006865 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
6866 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
6867 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
6868}
6869
6870static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
6871 const char *dest_mac)
6872{
6873 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
6874}
6875
Petr Machata7c819de2017-09-02 23:49:10 +02006876static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
6877{
6878 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
6879 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
6880}
6881
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02006882static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
6883 bool counter_enable)
6884{
6885 enum mlxsw_reg_flow_counter_set_type set_type;
6886
6887 if (counter_enable)
6888 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
6889 else
6890 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
6891
6892 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
6893 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
6894}
6895
Yuval Mintzddb362c2018-01-14 12:33:13 +01006896/* RDPM - Router DSCP to Priority Mapping
6897 * --------------------------------------
6898 * Controls the mapping from DSCP field to switch priority on routed packets
6899 */
6900#define MLXSW_REG_RDPM_ID 0x8009
6901#define MLXSW_REG_RDPM_BASE_LEN 0x00
6902#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
6903#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
6904#define MLXSW_REG_RDPM_LEN 0x40
6905#define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
6906 MLXSW_REG_RDPM_LEN - \
6907 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
6908
6909MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
6910
6911/* reg_dscp_entry_e
6912 * Enable update of the specific entry
6913 * Access: Index
6914 */
6915MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
6916 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
6917
6918/* reg_dscp_entry_prio
6919 * Switch Priority
6920 * Access: RW
6921 */
6922MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
6923 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
6924
6925static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
6926 u8 prio)
6927{
6928 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
6929 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
6930}
6931
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +02006932/* RICNT - Router Interface Counter Register
6933 * -----------------------------------------
6934 * The RICNT register retrieves per port performance counters
6935 */
6936#define MLXSW_REG_RICNT_ID 0x800B
6937#define MLXSW_REG_RICNT_LEN 0x100
6938
6939MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
6940
6941/* reg_ricnt_counter_index
6942 * Counter index
6943 * Access: RW
6944 */
6945MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
6946
6947enum mlxsw_reg_ricnt_counter_set_type {
6948 /* No Count. */
6949 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
6950 /* Basic. Used for router interfaces, counting the following:
6951 * - Error and Discard counters.
6952 * - Unicast, Multicast and Broadcast counters. Sharing the
6953 * same set of counters for the different type of traffic
6954 * (IPv4, IPv6 and mpls).
6955 */
6956 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
6957};
6958
6959/* reg_ricnt_counter_set_type
6960 * Counter Set Type for router interface counter
6961 * Access: RW
6962 */
6963MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
6964
6965enum mlxsw_reg_ricnt_opcode {
6966 /* Nop. Supported only for read access*/
6967 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
6968 /* Clear. Setting the clr bit will reset the counter value for
6969 * all counters of the specified Router Interface.
6970 */
6971 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
6972};
6973
6974/* reg_ricnt_opcode
6975 * Opcode
6976 * Access: RW
6977 */
6978MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
6979
6980/* reg_ricnt_good_unicast_packets
6981 * good unicast packets.
6982 * Access: RW
6983 */
6984MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
6985
6986/* reg_ricnt_good_multicast_packets
6987 * good multicast packets.
6988 * Access: RW
6989 */
6990MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
6991
6992/* reg_ricnt_good_broadcast_packets
6993 * good broadcast packets
6994 * Access: RW
6995 */
6996MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
6997
6998/* reg_ricnt_good_unicast_bytes
6999 * A count of L3 data and padding octets not including L2 headers
7000 * for good unicast frames.
7001 * Access: RW
7002 */
7003MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
7004
7005/* reg_ricnt_good_multicast_bytes
7006 * A count of L3 data and padding octets not including L2 headers
7007 * for good multicast frames.
7008 * Access: RW
7009 */
7010MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
7011
7012/* reg_ritr_good_broadcast_bytes
7013 * A count of L3 data and padding octets not including L2 headers
7014 * for good broadcast frames.
7015 * Access: RW
7016 */
7017MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
7018
7019/* reg_ricnt_error_packets
7020 * A count of errored frames that do not pass the router checks.
7021 * Access: RW
7022 */
7023MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
7024
7025/* reg_ricnt_discrad_packets
7026 * A count of non-errored frames that do not pass the router checks.
7027 * Access: RW
7028 */
7029MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
7030
7031/* reg_ricnt_error_bytes
7032 * A count of L3 data and padding octets not including L2 headers
7033 * for errored frames.
7034 * Access: RW
7035 */
7036MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
7037
7038/* reg_ricnt_discard_bytes
7039 * A count of L3 data and padding octets not including L2 headers
7040 * for non-errored frames that do not pass the router checks.
7041 * Access: RW
7042 */
7043MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
7044
7045static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
7046 enum mlxsw_reg_ricnt_opcode op)
7047{
7048 MLXSW_REG_ZERO(ricnt, payload);
7049 mlxsw_reg_ricnt_op_set(payload, op);
7050 mlxsw_reg_ricnt_counter_index_set(payload, index);
7051 mlxsw_reg_ricnt_counter_set_type_set(payload,
7052 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
7053}
7054
Yotam Gigi4fc92842017-09-19 10:00:17 +02007055/* RRCR - Router Rules Copy Register Layout
7056 * ----------------------------------------
7057 * This register is used for moving and copying route entry rules.
7058 */
7059#define MLXSW_REG_RRCR_ID 0x800F
7060#define MLXSW_REG_RRCR_LEN 0x24
7061
7062MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
7063
7064enum mlxsw_reg_rrcr_op {
7065 /* Move rules */
7066 MLXSW_REG_RRCR_OP_MOVE,
7067 /* Copy rules */
7068 MLXSW_REG_RRCR_OP_COPY,
7069};
7070
7071/* reg_rrcr_op
7072 * Access: WO
7073 */
7074MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
7075
7076/* reg_rrcr_offset
7077 * Offset within the region from which to copy/move.
7078 * Access: Index
7079 */
7080MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
7081
7082/* reg_rrcr_size
7083 * The number of rules to copy/move.
7084 * Access: WO
7085 */
7086MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
7087
7088/* reg_rrcr_table_id
7089 * Identifier of the table on which to perform the operation. Encoding is the
7090 * same as in RTAR.key_type
7091 * Access: Index
7092 */
7093MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
7094
7095/* reg_rrcr_dest_offset
7096 * Offset within the region to which to copy/move
7097 * Access: Index
7098 */
7099MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
7100
7101static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
7102 u16 offset, u16 size,
7103 enum mlxsw_reg_rtar_key_type table_id,
7104 u16 dest_offset)
7105{
7106 MLXSW_REG_ZERO(rrcr, payload);
7107 mlxsw_reg_rrcr_op_set(payload, op);
7108 mlxsw_reg_rrcr_offset_set(payload, offset);
7109 mlxsw_reg_rrcr_size_set(payload, size);
7110 mlxsw_reg_rrcr_table_id_set(payload, table_id);
7111 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
7112}
7113
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02007114/* RALTA - Router Algorithmic LPM Tree Allocation Register
7115 * -------------------------------------------------------
7116 * RALTA is used to allocate the LPM trees of the SHSPM method.
7117 */
7118#define MLXSW_REG_RALTA_ID 0x8010
7119#define MLXSW_REG_RALTA_LEN 0x04
7120
Jiri Pirko21978dc2016-10-21 16:07:20 +02007121MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02007122
7123/* reg_ralta_op
7124 * opcode (valid for Write, must be 0 on Read)
7125 * 0 - allocate a tree
7126 * 1 - deallocate a tree
7127 * Access: OP
7128 */
7129MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
7130
7131enum mlxsw_reg_ralxx_protocol {
7132 MLXSW_REG_RALXX_PROTOCOL_IPV4,
7133 MLXSW_REG_RALXX_PROTOCOL_IPV6,
7134};
7135
7136/* reg_ralta_protocol
7137 * Protocol.
7138 * Deallocation opcode: Reserved.
7139 * Access: RW
7140 */
7141MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
7142
7143/* reg_ralta_tree_id
7144 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
7145 * the tree identifier (managed by software).
7146 * Note that tree_id 0 is allocated for a default-route tree.
7147 * Access: Index
7148 */
7149MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
7150
7151static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
7152 enum mlxsw_reg_ralxx_protocol protocol,
7153 u8 tree_id)
7154{
7155 MLXSW_REG_ZERO(ralta, payload);
7156 mlxsw_reg_ralta_op_set(payload, !alloc);
7157 mlxsw_reg_ralta_protocol_set(payload, protocol);
7158 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
7159}
7160
Jiri Pirkoa9823352016-07-04 08:23:06 +02007161/* RALST - Router Algorithmic LPM Structure Tree Register
7162 * ------------------------------------------------------
7163 * RALST is used to set and query the structure of an LPM tree.
7164 * The structure of the tree must be sorted as a sorted binary tree, while
7165 * each node is a bin that is tagged as the length of the prefixes the lookup
7166 * will refer to. Therefore, bin X refers to a set of entries with prefixes
7167 * of X bits to match with the destination address. The bin 0 indicates
7168 * the default action, when there is no match of any prefix.
7169 */
7170#define MLXSW_REG_RALST_ID 0x8011
7171#define MLXSW_REG_RALST_LEN 0x104
7172
Jiri Pirko21978dc2016-10-21 16:07:20 +02007173MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
Jiri Pirkoa9823352016-07-04 08:23:06 +02007174
7175/* reg_ralst_root_bin
7176 * The bin number of the root bin.
7177 * 0<root_bin=<(length of IP address)
7178 * For a default-route tree configure 0xff
7179 * Access: RW
7180 */
7181MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
7182
7183/* reg_ralst_tree_id
7184 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
7185 * Access: Index
7186 */
7187MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
7188
7189#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
7190#define MLXSW_REG_RALST_BIN_OFFSET 0x04
7191#define MLXSW_REG_RALST_BIN_COUNT 128
7192
7193/* reg_ralst_left_child_bin
7194 * Holding the children of the bin according to the stored tree's structure.
7195 * For trees composed of less than 4 blocks, the bins in excess are reserved.
7196 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
7197 * Access: RW
7198 */
7199MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
7200
7201/* reg_ralst_right_child_bin
7202 * Holding the children of the bin according to the stored tree's structure.
7203 * For trees composed of less than 4 blocks, the bins in excess are reserved.
7204 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
7205 * Access: RW
7206 */
7207MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
7208 false);
7209
7210static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
7211{
7212 MLXSW_REG_ZERO(ralst, payload);
7213
7214 /* Initialize all bins to have no left or right child */
7215 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
7216 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
7217
7218 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
7219 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
7220}
7221
7222static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
7223 u8 left_child_bin,
7224 u8 right_child_bin)
7225{
7226 int bin_index = bin_number - 1;
7227
7228 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
7229 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
7230 right_child_bin);
7231}
7232
Jiri Pirko20ae4052016-07-04 08:23:07 +02007233/* RALTB - Router Algorithmic LPM Tree Binding Register
7234 * ----------------------------------------------------
7235 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
7236 */
7237#define MLXSW_REG_RALTB_ID 0x8012
7238#define MLXSW_REG_RALTB_LEN 0x04
7239
Jiri Pirko21978dc2016-10-21 16:07:20 +02007240MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
Jiri Pirko20ae4052016-07-04 08:23:07 +02007241
7242/* reg_raltb_virtual_router
7243 * Virtual Router ID
7244 * Range is 0..cap_max_virtual_routers-1
7245 * Access: Index
7246 */
7247MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
7248
7249/* reg_raltb_protocol
7250 * Protocol.
7251 * Access: Index
7252 */
7253MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
7254
7255/* reg_raltb_tree_id
7256 * Tree to be used for the {virtual_router, protocol}
7257 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
7258 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
7259 * Access: RW
7260 */
7261MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
7262
7263static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
7264 enum mlxsw_reg_ralxx_protocol protocol,
7265 u8 tree_id)
7266{
7267 MLXSW_REG_ZERO(raltb, payload);
7268 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
7269 mlxsw_reg_raltb_protocol_set(payload, protocol);
7270 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
7271}
7272
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007273/* RALUE - Router Algorithmic LPM Unicast Entry Register
7274 * -----------------------------------------------------
7275 * RALUE is used to configure and query LPM entries that serve
7276 * the Unicast protocols.
7277 */
7278#define MLXSW_REG_RALUE_ID 0x8013
7279#define MLXSW_REG_RALUE_LEN 0x38
7280
Jiri Pirko21978dc2016-10-21 16:07:20 +02007281MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007282
7283/* reg_ralue_protocol
7284 * Protocol.
7285 * Access: Index
7286 */
7287MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
7288
7289enum mlxsw_reg_ralue_op {
7290 /* Read operation. If entry doesn't exist, the operation fails. */
7291 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
7292 /* Clear on read operation. Used to read entry and
7293 * clear Activity bit.
7294 */
7295 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
7296 /* Write operation. Used to write a new entry to the table. All RW
7297 * fields are written for new entry. Activity bit is set
7298 * for new entries.
7299 */
7300 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
7301 /* Update operation. Used to update an existing route entry and
7302 * only update the RW fields that are detailed in the field
7303 * op_u_mask. If entry doesn't exist, the operation fails.
7304 */
7305 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
7306 /* Clear activity. The Activity bit (the field a) is cleared
7307 * for the entry.
7308 */
7309 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
7310 /* Delete operation. Used to delete an existing entry. If entry
7311 * doesn't exist, the operation fails.
7312 */
7313 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
7314};
7315
7316/* reg_ralue_op
7317 * Operation.
7318 * Access: OP
7319 */
7320MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
7321
7322/* reg_ralue_a
7323 * Activity. Set for new entries. Set if a packet lookup has hit on the
7324 * specific entry, only if the entry is a route. To clear the a bit, use
7325 * "clear activity" op.
7326 * Enabled by activity_dis in RGCR
7327 * Access: RO
7328 */
7329MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
7330
7331/* reg_ralue_virtual_router
7332 * Virtual Router ID
7333 * Range is 0..cap_max_virtual_routers-1
7334 * Access: Index
7335 */
7336MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
7337
7338#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
7339#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
7340#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
7341
7342/* reg_ralue_op_u_mask
7343 * opcode update mask.
7344 * On read operation, this field is reserved.
7345 * This field is valid for update opcode, otherwise - reserved.
7346 * This field is a bitmask of the fields that should be updated.
7347 * Access: WO
7348 */
7349MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
7350
7351/* reg_ralue_prefix_len
7352 * Number of bits in the prefix of the LPM route.
7353 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
7354 * two entries in the physical HW table.
7355 * Access: Index
7356 */
7357MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
7358
7359/* reg_ralue_dip*
7360 * The prefix of the route or of the marker that the object of the LPM
7361 * is compared with. The most significant bits of the dip are the prefix.
Petr Machata806a1c1a2017-07-31 09:27:24 +02007362 * The least significant bits must be '0' if the prefix_len is smaller
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007363 * than 128 for IPv6 or smaller than 32 for IPv4.
7364 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
7365 * Access: Index
7366 */
7367MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
Ido Schimmel62547f42017-07-18 10:10:23 +02007368MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007369
7370enum mlxsw_reg_ralue_entry_type {
7371 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
7372 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
7373 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
7374};
7375
7376/* reg_ralue_entry_type
7377 * Entry type.
7378 * Note - for Marker entries, the action_type and action fields are reserved.
7379 * Access: RW
7380 */
7381MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
7382
7383/* reg_ralue_bmp_len
7384 * The best match prefix length in the case that there is no match for
7385 * longer prefixes.
7386 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
7387 * Note for any update operation with entry_type modification this
7388 * field must be set.
7389 * Access: RW
7390 */
7391MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
7392
7393enum mlxsw_reg_ralue_action_type {
7394 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
7395 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
7396 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
7397};
7398
7399/* reg_ralue_action_type
7400 * Action Type
7401 * Indicates how the IP address is connected.
7402 * It can be connected to a local subnet through local_erif or can be
7403 * on a remote subnet connected through a next-hop router,
7404 * or transmitted to the CPU.
7405 * Reserved when entry_type = MARKER_ENTRY
7406 * Access: RW
7407 */
7408MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
7409
7410enum mlxsw_reg_ralue_trap_action {
7411 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
7412 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
7413 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
7414 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
7415 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
7416};
7417
7418/* reg_ralue_trap_action
7419 * Trap action.
7420 * For IP2ME action, only NOP and MIRROR are possible.
7421 * Access: RW
7422 */
7423MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
7424
7425/* reg_ralue_trap_id
7426 * Trap ID to be reported to CPU.
7427 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
7428 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
7429 * Access: RW
7430 */
7431MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
7432
7433/* reg_ralue_adjacency_index
7434 * Points to the first entry of the group-based ECMP.
7435 * Only relevant in case of REMOTE action.
7436 * Access: RW
7437 */
7438MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
7439
7440/* reg_ralue_ecmp_size
7441 * Amount of sequential entries starting
7442 * from the adjacency_index (the number of ECMPs).
7443 * The valid range is 1-64, 512, 1024, 2048 and 4096.
7444 * Reserved when trap_action is TRAP or DISCARD_ERROR.
7445 * Only relevant in case of REMOTE action.
7446 * Access: RW
7447 */
7448MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
7449
7450/* reg_ralue_local_erif
7451 * Egress Router Interface.
7452 * Only relevant in case of LOCAL action.
7453 * Access: RW
7454 */
7455MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
7456
Petr Machata83930cd2017-07-31 09:27:27 +02007457/* reg_ralue_ip2me_v
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007458 * Valid bit for the tunnel_ptr field.
7459 * If valid = 0 then trap to CPU as IP2ME trap ID.
7460 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
7461 * decapsulation then tunnel decapsulation is done.
7462 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
7463 * decapsulation then trap as IP2ME trap ID.
7464 * Only relevant in case of IP2ME action.
7465 * Access: RW
7466 */
Petr Machata83930cd2017-07-31 09:27:27 +02007467MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007468
Petr Machata83930cd2017-07-31 09:27:27 +02007469/* reg_ralue_ip2me_tunnel_ptr
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007470 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
7471 * For Spectrum, pointer to KVD Linear.
7472 * Only relevant in case of IP2ME action.
7473 * Access: RW
7474 */
Petr Machata83930cd2017-07-31 09:27:27 +02007475MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007476
7477static inline void mlxsw_reg_ralue_pack(char *payload,
7478 enum mlxsw_reg_ralxx_protocol protocol,
7479 enum mlxsw_reg_ralue_op op,
7480 u16 virtual_router, u8 prefix_len)
7481{
7482 MLXSW_REG_ZERO(ralue, payload);
7483 mlxsw_reg_ralue_protocol_set(payload, protocol);
Jiri Pirko0e7df1a2016-08-17 16:39:34 +02007484 mlxsw_reg_ralue_op_set(payload, op);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007485 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
7486 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
7487 mlxsw_reg_ralue_entry_type_set(payload,
7488 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
7489 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
7490}
7491
7492static inline void mlxsw_reg_ralue_pack4(char *payload,
7493 enum mlxsw_reg_ralxx_protocol protocol,
7494 enum mlxsw_reg_ralue_op op,
7495 u16 virtual_router, u8 prefix_len,
Jiri Pirko0c1d6b22020-11-10 11:48:52 +02007496 u32 *dip)
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007497{
7498 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
Jiri Pirko1a7fcdf72020-11-10 11:48:53 +02007499 if (dip)
7500 mlxsw_reg_ralue_dip4_set(payload, *dip);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007501}
7502
Ido Schimmel62547f42017-07-18 10:10:23 +02007503static inline void mlxsw_reg_ralue_pack6(char *payload,
7504 enum mlxsw_reg_ralxx_protocol protocol,
7505 enum mlxsw_reg_ralue_op op,
7506 u16 virtual_router, u8 prefix_len,
7507 const void *dip)
7508{
7509 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
Jiri Pirko1a7fcdf72020-11-10 11:48:53 +02007510 if (dip)
7511 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
Ido Schimmel62547f42017-07-18 10:10:23 +02007512}
7513
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007514static inline void
7515mlxsw_reg_ralue_act_remote_pack(char *payload,
7516 enum mlxsw_reg_ralue_trap_action trap_action,
7517 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
7518{
7519 mlxsw_reg_ralue_action_type_set(payload,
7520 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
7521 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7522 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7523 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
7524 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
7525}
7526
7527static inline void
7528mlxsw_reg_ralue_act_local_pack(char *payload,
7529 enum mlxsw_reg_ralue_trap_action trap_action,
7530 u16 trap_id, u16 local_erif)
7531{
7532 mlxsw_reg_ralue_action_type_set(payload,
7533 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
7534 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7535 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7536 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
7537}
7538
7539static inline void
7540mlxsw_reg_ralue_act_ip2me_pack(char *payload)
7541{
7542 mlxsw_reg_ralue_action_type_set(payload,
7543 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7544}
7545
Petr Machataa43da822017-09-02 23:49:12 +02007546static inline void
7547mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
7548{
7549 mlxsw_reg_ralue_action_type_set(payload,
7550 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7551 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
7552 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
7553}
7554
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007555/* RAUHT - Router Algorithmic LPM Unicast Host Table Register
7556 * ----------------------------------------------------------
7557 * The RAUHT register is used to configure and query the Unicast Host table in
7558 * devices that implement the Algorithmic LPM.
7559 */
7560#define MLXSW_REG_RAUHT_ID 0x8014
7561#define MLXSW_REG_RAUHT_LEN 0x74
7562
Jiri Pirko21978dc2016-10-21 16:07:20 +02007563MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007564
7565enum mlxsw_reg_rauht_type {
7566 MLXSW_REG_RAUHT_TYPE_IPV4,
7567 MLXSW_REG_RAUHT_TYPE_IPV6,
7568};
7569
7570/* reg_rauht_type
7571 * Access: Index
7572 */
7573MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
7574
7575enum mlxsw_reg_rauht_op {
7576 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
7577 /* Read operation */
7578 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
7579 /* Clear on read operation. Used to read entry and clear
7580 * activity bit.
7581 */
7582 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
7583 /* Add. Used to write a new entry to the table. All R/W fields are
7584 * relevant for new entry. Activity bit is set for new entries.
7585 */
7586 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
7587 /* Update action. Used to update an existing route entry and
7588 * only update the following fields:
7589 * trap_action, trap_id, mac, counter_set_type, counter_index
7590 */
7591 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
7592 /* Clear activity. A bit is cleared for the entry. */
7593 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
7594 /* Delete entry */
7595 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
7596 /* Delete all host entries on a RIF. In this command, dip
7597 * field is reserved.
7598 */
7599};
7600
7601/* reg_rauht_op
7602 * Access: OP
7603 */
7604MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
7605
7606/* reg_rauht_a
7607 * Activity. Set for new entries. Set if a packet lookup has hit on
7608 * the specific entry.
7609 * To clear the a bit, use "clear activity" op.
7610 * Enabled by activity_dis in RGCR
7611 * Access: RO
7612 */
7613MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
7614
7615/* reg_rauht_rif
7616 * Router Interface
7617 * Access: Index
7618 */
7619MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
7620
7621/* reg_rauht_dip*
7622 * Destination address.
7623 * Access: Index
7624 */
7625MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02007626MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007627
7628enum mlxsw_reg_rauht_trap_action {
7629 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
7630 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
7631 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
7632 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
7633 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
7634};
7635
7636/* reg_rauht_trap_action
7637 * Access: RW
7638 */
7639MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
7640
7641enum mlxsw_reg_rauht_trap_id {
7642 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
7643 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
7644};
7645
7646/* reg_rauht_trap_id
7647 * Trap ID to be reported to CPU.
7648 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
7649 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
7650 * trap_id is reserved.
7651 * Access: RW
7652 */
7653MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
7654
7655/* reg_rauht_counter_set_type
7656 * Counter set type for flow counters
7657 * Access: RW
7658 */
7659MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
7660
7661/* reg_rauht_counter_index
7662 * Counter index for flow counters
7663 * Access: RW
7664 */
7665MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
7666
7667/* reg_rauht_mac
7668 * MAC address.
7669 * Access: RW
7670 */
7671MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
7672
7673static inline void mlxsw_reg_rauht_pack(char *payload,
7674 enum mlxsw_reg_rauht_op op, u16 rif,
7675 const char *mac)
7676{
7677 MLXSW_REG_ZERO(rauht, payload);
7678 mlxsw_reg_rauht_op_set(payload, op);
7679 mlxsw_reg_rauht_rif_set(payload, rif);
7680 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
7681}
7682
7683static inline void mlxsw_reg_rauht_pack4(char *payload,
7684 enum mlxsw_reg_rauht_op op, u16 rif,
7685 const char *mac, u32 dip)
7686{
7687 mlxsw_reg_rauht_pack(payload, op, rif, mac);
7688 mlxsw_reg_rauht_dip4_set(payload, dip);
7689}
7690
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02007691static inline void mlxsw_reg_rauht_pack6(char *payload,
7692 enum mlxsw_reg_rauht_op op, u16 rif,
7693 const char *mac, const char *dip)
7694{
7695 mlxsw_reg_rauht_pack(payload, op, rif, mac);
7696 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
7697 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
7698}
7699
Arkadi Sharshevsky7cfcbc72017-08-24 08:40:08 +02007700static inline void mlxsw_reg_rauht_pack_counter(char *payload,
7701 u64 counter_index)
7702{
7703 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
7704 mlxsw_reg_rauht_counter_set_type_set(payload,
7705 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
7706}
7707
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02007708/* RALEU - Router Algorithmic LPM ECMP Update Register
7709 * ---------------------------------------------------
7710 * The register enables updating the ECMP section in the action for multiple
7711 * LPM Unicast entries in a single operation. The update is executed to
7712 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
7713 */
7714#define MLXSW_REG_RALEU_ID 0x8015
7715#define MLXSW_REG_RALEU_LEN 0x28
7716
Jiri Pirko21978dc2016-10-21 16:07:20 +02007717MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02007718
7719/* reg_raleu_protocol
7720 * Protocol.
7721 * Access: Index
7722 */
7723MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
7724
7725/* reg_raleu_virtual_router
7726 * Virtual Router ID
7727 * Range is 0..cap_max_virtual_routers-1
7728 * Access: Index
7729 */
7730MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
7731
7732/* reg_raleu_adjacency_index
7733 * Adjacency Index used for matching on the existing entries.
7734 * Access: Index
7735 */
7736MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
7737
7738/* reg_raleu_ecmp_size
7739 * ECMP Size used for matching on the existing entries.
7740 * Access: Index
7741 */
7742MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
7743
7744/* reg_raleu_new_adjacency_index
7745 * New Adjacency Index.
7746 * Access: WO
7747 */
7748MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
7749
7750/* reg_raleu_new_ecmp_size
7751 * New ECMP Size.
7752 * Access: WO
7753 */
7754MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
7755
7756static inline void mlxsw_reg_raleu_pack(char *payload,
7757 enum mlxsw_reg_ralxx_protocol protocol,
7758 u16 virtual_router,
7759 u32 adjacency_index, u16 ecmp_size,
7760 u32 new_adjacency_index,
7761 u16 new_ecmp_size)
7762{
7763 MLXSW_REG_ZERO(raleu, payload);
7764 mlxsw_reg_raleu_protocol_set(payload, protocol);
7765 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
7766 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
7767 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
7768 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
7769 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
7770}
7771
Yotam Gigi7cf2c202016-07-05 11:27:41 +02007772/* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
7773 * ----------------------------------------------------------------
7774 * The RAUHTD register allows dumping entries from the Router Unicast Host
7775 * Table. For a given session an entry is dumped no more than one time. The
7776 * first RAUHTD access after reset is a new session. A session ends when the
7777 * num_rec response is smaller than num_rec request or for IPv4 when the
7778 * num_entries is smaller than 4. The clear activity affect the current session
7779 * or the last session if a new session has not started.
7780 */
7781#define MLXSW_REG_RAUHTD_ID 0x8018
7782#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
7783#define MLXSW_REG_RAUHTD_REC_LEN 0x20
7784#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
7785#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
7786 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
7787#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
7788
Jiri Pirko21978dc2016-10-21 16:07:20 +02007789MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
Yotam Gigi7cf2c202016-07-05 11:27:41 +02007790
7791#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
7792#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
7793
7794/* reg_rauhtd_filter_fields
7795 * if a bit is '0' then the relevant field is ignored and dump is done
7796 * regardless of the field value
7797 * Bit0 - filter by activity: entry_a
7798 * Bit3 - filter by entry rip: entry_rif
7799 * Access: Index
7800 */
7801MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
7802
7803enum mlxsw_reg_rauhtd_op {
7804 MLXSW_REG_RAUHTD_OP_DUMP,
7805 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
7806};
7807
7808/* reg_rauhtd_op
7809 * Access: OP
7810 */
7811MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
7812
7813/* reg_rauhtd_num_rec
7814 * At request: number of records requested
7815 * At response: number of records dumped
7816 * For IPv4, each record has 4 entries at request and up to 4 entries
7817 * at response
7818 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
7819 * Access: Index
7820 */
7821MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
7822
7823/* reg_rauhtd_entry_a
7824 * Dump only if activity has value of entry_a
7825 * Reserved if filter_fields bit0 is '0'
7826 * Access: Index
7827 */
7828MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
7829
7830enum mlxsw_reg_rauhtd_type {
7831 MLXSW_REG_RAUHTD_TYPE_IPV4,
7832 MLXSW_REG_RAUHTD_TYPE_IPV6,
7833};
7834
7835/* reg_rauhtd_type
7836 * Dump only if record type is:
7837 * 0 - IPv4
7838 * 1 - IPv6
7839 * Access: Index
7840 */
7841MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
7842
7843/* reg_rauhtd_entry_rif
7844 * Dump only if RIF has value of entry_rif
7845 * Reserved if filter_fields bit3 is '0'
7846 * Access: Index
7847 */
7848MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
7849
7850static inline void mlxsw_reg_rauhtd_pack(char *payload,
7851 enum mlxsw_reg_rauhtd_type type)
7852{
7853 MLXSW_REG_ZERO(rauhtd, payload);
7854 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
7855 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
7856 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
7857 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
7858 mlxsw_reg_rauhtd_type_set(payload, type);
7859}
7860
7861/* reg_rauhtd_ipv4_rec_num_entries
7862 * Number of valid entries in this record:
7863 * 0 - 1 valid entry
7864 * 1 - 2 valid entries
7865 * 2 - 3 valid entries
7866 * 3 - 4 valid entries
7867 * Access: RO
7868 */
7869MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
7870 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
7871 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
7872
7873/* reg_rauhtd_rec_type
7874 * Record type.
7875 * 0 - IPv4
7876 * 1 - IPv6
7877 * Access: RO
7878 */
7879MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
7880 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
7881
7882#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
7883
7884/* reg_rauhtd_ipv4_ent_a
7885 * Activity. Set for new entries. Set if a packet lookup has hit on the
7886 * specific entry.
7887 * Access: RO
7888 */
7889MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
7890 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
7891
7892/* reg_rauhtd_ipv4_ent_rif
7893 * Router interface.
7894 * Access: RO
7895 */
7896MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7897 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
7898
7899/* reg_rauhtd_ipv4_ent_dip
7900 * Destination IPv4 address.
7901 * Access: RO
7902 */
7903MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7904 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
7905
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02007906#define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
7907
7908/* reg_rauhtd_ipv6_ent_a
7909 * Activity. Set for new entries. Set if a packet lookup has hit on the
7910 * specific entry.
7911 * Access: RO
7912 */
7913MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
7914 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
7915
7916/* reg_rauhtd_ipv6_ent_rif
7917 * Router interface.
7918 * Access: RO
7919 */
7920MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7921 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
7922
7923/* reg_rauhtd_ipv6_ent_dip
7924 * Destination IPv6 address.
7925 * Access: RO
7926 */
7927MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
7928 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
7929
Yotam Gigi7cf2c202016-07-05 11:27:41 +02007930static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
7931 int ent_index, u16 *p_rif,
7932 u32 *p_dip)
7933{
7934 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
7935 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
7936}
7937
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02007938static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
7939 int rec_index, u16 *p_rif,
7940 char *p_dip)
7941{
7942 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
7943 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
7944}
7945
Petr Machata1e659eb2017-09-02 23:49:13 +02007946/* RTDP - Routing Tunnel Decap Properties Register
7947 * -----------------------------------------------
7948 * The RTDP register is used for configuring the tunnel decap properties of NVE
7949 * and IPinIP.
7950 */
7951#define MLXSW_REG_RTDP_ID 0x8020
7952#define MLXSW_REG_RTDP_LEN 0x44
7953
7954MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
7955
7956enum mlxsw_reg_rtdp_type {
7957 MLXSW_REG_RTDP_TYPE_NVE,
7958 MLXSW_REG_RTDP_TYPE_IPIP,
7959};
7960
7961/* reg_rtdp_type
7962 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
7963 * Access: RW
7964 */
7965MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
7966
7967/* reg_rtdp_tunnel_index
7968 * Index to the Decap entry.
7969 * For Spectrum, Index to KVD Linear.
7970 * Access: Index
7971 */
7972MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
7973
Ido Schimmelc9417492019-01-20 06:50:39 +00007974/* reg_rtdp_egress_router_interface
7975 * Underlay egress router interface.
7976 * Valid range is from 0 to cap_max_router_interfaces - 1
7977 * Access: RW
7978 */
7979MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
7980
Petr Machata1e659eb2017-09-02 23:49:13 +02007981/* IPinIP */
7982
7983/* reg_rtdp_ipip_irif
7984 * Ingress Router Interface for the overlay router
7985 * Access: RW
7986 */
7987MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
7988
7989enum mlxsw_reg_rtdp_ipip_sip_check {
7990 /* No sip checks. */
7991 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
7992 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
7993 * equal ipv4_usip.
7994 */
7995 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
7996 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
7997 * equal ipv6_usip.
7998 */
7999 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
8000};
8001
8002/* reg_rtdp_ipip_sip_check
8003 * SIP check to perform. If decapsulation failed due to these configurations
8004 * then trap_id is IPIP_DECAP_ERROR.
8005 * Access: RW
8006 */
8007MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
8008
8009/* If set, allow decapsulation of IPinIP (without GRE). */
8010#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
8011/* If set, allow decapsulation of IPinGREinIP without a key. */
8012#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
8013/* If set, allow decapsulation of IPinGREinIP with a key. */
8014#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
8015
8016/* reg_rtdp_ipip_type_check
8017 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
8018 * these configurations then trap_id is IPIP_DECAP_ERROR.
8019 * Access: RW
8020 */
8021MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
8022
8023/* reg_rtdp_ipip_gre_key_check
8024 * Whether GRE key should be checked. When check is enabled:
8025 * - A packet received as IPinIP (without GRE) will always pass.
8026 * - A packet received as IPinGREinIP without a key will not pass the check.
8027 * - A packet received as IPinGREinIP with a key will pass the check only if the
8028 * key in the packet is equal to expected_gre_key.
8029 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
8030 * Access: RW
8031 */
8032MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
8033
8034/* reg_rtdp_ipip_ipv4_usip
8035 * Underlay IPv4 address for ipv4 source address check.
8036 * Reserved when sip_check is not '1'.
8037 * Access: RW
8038 */
8039MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
8040
8041/* reg_rtdp_ipip_ipv6_usip_ptr
8042 * This field is valid when sip_check is "sipv6 check explicitly". This is a
8043 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
8044 * is to the KVD linear.
8045 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
8046 * Access: RW
8047 */
8048MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
8049
8050/* reg_rtdp_ipip_expected_gre_key
8051 * GRE key for checking.
8052 * Reserved when gre_key_check is '0'.
8053 * Access: RW
8054 */
8055MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
8056
8057static inline void mlxsw_reg_rtdp_pack(char *payload,
8058 enum mlxsw_reg_rtdp_type type,
8059 u32 tunnel_index)
8060{
8061 MLXSW_REG_ZERO(rtdp, payload);
8062 mlxsw_reg_rtdp_type_set(payload, type);
8063 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
8064}
8065
8066static inline void
8067mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
8068 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8069 unsigned int type_check, bool gre_key_check,
8070 u32 ipv4_usip, u32 expected_gre_key)
8071{
8072 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
8073 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
8074 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
8075 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
8076 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
8077 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
8078}
8079
Yotam Gigi5080c7e2017-09-19 10:00:14 +02008080/* RIGR-V2 - Router Interface Group Register Version 2
8081 * ---------------------------------------------------
8082 * The RIGR_V2 register is used to add, remove and query egress interface list
8083 * of a multicast forwarding entry.
8084 */
8085#define MLXSW_REG_RIGR2_ID 0x8023
8086#define MLXSW_REG_RIGR2_LEN 0xB0
8087
8088#define MLXSW_REG_RIGR2_MAX_ERIFS 32
8089
8090MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
8091
8092/* reg_rigr2_rigr_index
8093 * KVD Linear index.
8094 * Access: Index
8095 */
8096MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
8097
8098/* reg_rigr2_vnext
8099 * Next RIGR Index is valid.
8100 * Access: RW
8101 */
8102MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
8103
8104/* reg_rigr2_next_rigr_index
8105 * Next RIGR Index. The index is to the KVD linear.
8106 * Reserved when vnxet = '0'.
8107 * Access: RW
8108 */
8109MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
8110
8111/* reg_rigr2_vrmid
8112 * RMID Index is valid.
8113 * Access: RW
8114 */
8115MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
8116
8117/* reg_rigr2_rmid_index
8118 * RMID Index.
8119 * Range 0 .. max_mid - 1
8120 * Reserved when vrmid = '0'.
8121 * The index is to the Port Group Table (PGT)
8122 * Access: RW
8123 */
8124MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
8125
8126/* reg_rigr2_erif_entry_v
8127 * Egress Router Interface is valid.
8128 * Note that low-entries must be set if high-entries are set. For
8129 * example: if erif_entry[2].v is set then erif_entry[1].v and
8130 * erif_entry[0].v must be set.
8131 * Index can be from 0 to cap_mc_erif_list_entries-1
8132 * Access: RW
8133 */
8134MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
8135
8136/* reg_rigr2_erif_entry_erif
8137 * Egress Router Interface.
8138 * Valid range is from 0 to cap_max_router_interfaces - 1
8139 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
8140 * Access: RW
8141 */
8142MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
8143
8144static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
8145 bool vnext, u32 next_rigr_index)
8146{
8147 MLXSW_REG_ZERO(rigr2, payload);
8148 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
8149 mlxsw_reg_rigr2_vnext_set(payload, vnext);
8150 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
8151 mlxsw_reg_rigr2_vrmid_set(payload, 0);
8152 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
8153}
8154
8155static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
8156 bool v, u16 erif)
8157{
8158 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
8159 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
8160}
8161
Ido Schimmele4718592017-11-02 17:14:08 +01008162/* RECR-V2 - Router ECMP Configuration Version 2 Register
8163 * ------------------------------------------------------
8164 */
8165#define MLXSW_REG_RECR2_ID 0x8025
8166#define MLXSW_REG_RECR2_LEN 0x38
8167
8168MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
8169
8170/* reg_recr2_pp
8171 * Per-port configuration
8172 * Access: Index
8173 */
8174MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
8175
8176/* reg_recr2_sh
8177 * Symmetric hash
8178 * Access: RW
8179 */
8180MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
8181
8182/* reg_recr2_seed
8183 * Seed
8184 * Access: RW
8185 */
8186MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
8187
8188enum {
8189 /* Enable IPv4 fields if packet is not TCP and not UDP */
8190 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
8191 /* Enable IPv4 fields if packet is TCP or UDP */
8192 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
8193 /* Enable IPv6 fields if packet is not TCP and not UDP */
8194 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
8195 /* Enable IPv6 fields if packet is TCP or UDP */
8196 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
8197 /* Enable TCP/UDP header fields if packet is IPv4 */
8198 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
8199 /* Enable TCP/UDP header fields if packet is IPv6 */
8200 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
8201};
8202
8203/* reg_recr2_outer_header_enables
8204 * Bit mask where each bit enables a specific layer to be included in
8205 * the hash calculation.
8206 * Access: RW
8207 */
8208MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
8209
8210enum {
8211 /* IPv4 Source IP */
8212 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
8213 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
8214 /* IPv4 Destination IP */
8215 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
8216 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
8217 /* IP Protocol */
8218 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
8219 /* IPv6 Source IP */
8220 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
8221 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
8222 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
8223 /* IPv6 Destination IP */
8224 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
8225 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
8226 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
8227 /* IPv6 Next Header */
8228 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
8229 /* IPv6 Flow Label */
8230 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
8231 /* TCP/UDP Source Port */
8232 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
8233 /* TCP/UDP Destination Port */
8234 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
8235};
8236
8237/* reg_recr2_outer_header_fields_enable
8238 * Packet fields to enable for ECMP hash subject to outer_header_enable.
8239 * Access: RW
8240 */
8241MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
8242
8243static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
8244{
8245 int i;
8246
8247 for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
8248 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
8249 true);
8250}
8251
8252static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
8253{
8254 int i;
8255
8256 for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
8257 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
8258 true);
8259}
8260
8261static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
8262{
8263 int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
8264
8265 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
8266
8267 i = MLXSW_REG_RECR2_IPV6_SIP8;
8268 for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
8269 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
8270 true);
8271}
8272
8273static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
8274{
8275 int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
8276
8277 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
8278
8279 i = MLXSW_REG_RECR2_IPV6_DIP8;
8280 for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
8281 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
8282 true);
8283}
8284
8285static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
8286{
8287 MLXSW_REG_ZERO(recr2, payload);
8288 mlxsw_reg_recr2_pp_set(payload, false);
8289 mlxsw_reg_recr2_sh_set(payload, true);
8290 mlxsw_reg_recr2_seed_set(payload, seed);
8291}
8292
Yotam Gigi2e654e32017-09-19 10:00:16 +02008293/* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
8294 * --------------------------------------------------------------
8295 * The RMFT_V2 register is used to configure and query the multicast table.
8296 */
8297#define MLXSW_REG_RMFT2_ID 0x8027
8298#define MLXSW_REG_RMFT2_LEN 0x174
8299
8300MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
8301
8302/* reg_rmft2_v
8303 * Valid
8304 * Access: RW
8305 */
8306MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
8307
8308enum mlxsw_reg_rmft2_type {
8309 MLXSW_REG_RMFT2_TYPE_IPV4,
8310 MLXSW_REG_RMFT2_TYPE_IPV6
8311};
8312
8313/* reg_rmft2_type
8314 * Access: Index
8315 */
8316MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
8317
8318enum mlxsw_sp_reg_rmft2_op {
8319 /* For Write:
8320 * Write operation. Used to write a new entry to the table. All RW
8321 * fields are relevant for new entry. Activity bit is set for new
8322 * entries - Note write with v (Valid) 0 will delete the entry.
8323 * For Query:
8324 * Read operation
8325 */
8326 MLXSW_REG_RMFT2_OP_READ_WRITE,
8327};
8328
8329/* reg_rmft2_op
8330 * Operation.
8331 * Access: OP
8332 */
8333MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
8334
8335/* reg_rmft2_a
8336 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
8337 * entry.
8338 * Access: RO
8339 */
8340MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
8341
8342/* reg_rmft2_offset
8343 * Offset within the multicast forwarding table to write to.
8344 * Access: Index
8345 */
8346MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
8347
8348/* reg_rmft2_virtual_router
8349 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
8350 * Access: RW
8351 */
8352MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
8353
8354enum mlxsw_reg_rmft2_irif_mask {
8355 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
8356 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
8357};
8358
8359/* reg_rmft2_irif_mask
8360 * Ingress RIF mask.
8361 * Access: RW
8362 */
8363MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
8364
8365/* reg_rmft2_irif
8366 * Ingress RIF index.
8367 * Access: RW
8368 */
8369MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
8370
Yuval Mintza82b1b82018-03-26 15:01:38 +03008371/* reg_rmft2_dip{4,6}
8372 * Destination IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02008373 * Access: RW
8374 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008375MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008376MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
8377
Yuval Mintza82b1b82018-03-26 15:01:38 +03008378/* reg_rmft2_dip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02008379 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
8380 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
8381 * Access: RW
8382 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008383MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008384MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
8385
Yuval Mintza82b1b82018-03-26 15:01:38 +03008386/* reg_rmft2_sip{4,6}
8387 * Source IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02008388 * Access: RW
8389 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008390MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008391MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
8392
Yuval Mintza82b1b82018-03-26 15:01:38 +03008393/* reg_rmft2_sip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02008394 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
8395 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
8396 * Access: RW
8397 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008398MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008399MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
8400
8401/* reg_rmft2_flexible_action_set
8402 * ACL action set. The only supported action types in this field and in any
8403 * action-set pointed from here are as follows:
8404 * 00h: ACTION_NULL
8405 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
8406 * 03h: ACTION_TRAP
8407 * 06h: ACTION_QOS
8408 * 08h: ACTION_POLICING_MONITORING
8409 * 10h: ACTION_ROUTER_MC
8410 * Access: RW
8411 */
8412MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
8413 MLXSW_REG_FLEX_ACTION_SET_LEN);
8414
8415static inline void
Yuval Mintza82b1b82018-03-26 15:01:38 +03008416mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
8417 u16 virtual_router,
8418 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8419 const char *flex_action_set)
Yotam Gigi2e654e32017-09-19 10:00:16 +02008420{
8421 MLXSW_REG_ZERO(rmft2, payload);
8422 mlxsw_reg_rmft2_v_set(payload, v);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008423 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
8424 mlxsw_reg_rmft2_offset_set(payload, offset);
8425 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
8426 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
8427 mlxsw_reg_rmft2_irif_set(payload, irif);
Yuval Mintza82b1b82018-03-26 15:01:38 +03008428 if (flex_action_set)
8429 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
8430 flex_action_set);
8431}
8432
8433static inline void
8434mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8435 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8436 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
8437 const char *flexible_action_set)
8438{
8439 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8440 irif_mask, irif, flexible_action_set);
8441 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008442 mlxsw_reg_rmft2_dip4_set(payload, dip4);
8443 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
8444 mlxsw_reg_rmft2_sip4_set(payload, sip4);
8445 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
Yuval Mintza82b1b82018-03-26 15:01:38 +03008446}
8447
8448static inline void
8449mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8450 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8451 struct in6_addr dip6, struct in6_addr dip6_mask,
8452 struct in6_addr sip6, struct in6_addr sip6_mask,
8453 const char *flexible_action_set)
8454{
8455 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8456 irif_mask, irif, flexible_action_set);
8457 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
8458 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
8459 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
8460 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
8461 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008462}
8463
Jiri Pirkofb281f22020-11-01 15:42:14 +02008464/* Note that XRALXX register position violates the rule of ordering register
8465 * definition by the ID. However, XRALXX pack helpers are using RALXX pack
8466 * helpers, RALXX registers have higher IDs.
8467 */
8468
8469/* XRALTA - XM Router Algorithmic LPM Tree Allocation Register
8470 * -----------------------------------------------------------
8471 * The XRALTA is used to allocate the XLT LPM trees.
8472 *
8473 * This register embeds original RALTA register.
8474 */
8475#define MLXSW_REG_XRALTA_ID 0x7811
8476#define MLXSW_REG_XRALTA_LEN 0x08
8477#define MLXSW_REG_XRALTA_RALTA_OFFSET 0x04
8478
8479MLXSW_REG_DEFINE(xralta, MLXSW_REG_XRALTA_ID, MLXSW_REG_XRALTA_LEN);
8480
8481static inline void mlxsw_reg_xralta_pack(char *payload, bool alloc,
8482 enum mlxsw_reg_ralxx_protocol protocol,
8483 u8 tree_id)
8484{
8485 char *ralta_payload = payload + MLXSW_REG_XRALTA_RALTA_OFFSET;
8486
8487 MLXSW_REG_ZERO(xralta, payload);
8488 mlxsw_reg_ralta_pack(ralta_payload, alloc, protocol, tree_id);
8489}
8490
8491/* XRALST - XM Router Algorithmic LPM Structure Tree Register
8492 * ----------------------------------------------------------
8493 * The XRALST is used to set and query the structure of an XLT LPM tree.
8494 *
8495 * This register embeds original RALST register.
8496 */
8497#define MLXSW_REG_XRALST_ID 0x7812
8498#define MLXSW_REG_XRALST_LEN 0x108
8499#define MLXSW_REG_XRALST_RALST_OFFSET 0x04
8500
8501MLXSW_REG_DEFINE(xralst, MLXSW_REG_XRALST_ID, MLXSW_REG_XRALST_LEN);
8502
8503static inline void mlxsw_reg_xralst_pack(char *payload, u8 root_bin, u8 tree_id)
8504{
8505 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET;
8506
8507 MLXSW_REG_ZERO(xralst, payload);
8508 mlxsw_reg_ralst_pack(ralst_payload, root_bin, tree_id);
8509}
8510
8511static inline void mlxsw_reg_xralst_bin_pack(char *payload, u8 bin_number,
8512 u8 left_child_bin,
8513 u8 right_child_bin)
8514{
8515 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET;
8516
8517 mlxsw_reg_ralst_bin_pack(ralst_payload, bin_number, left_child_bin,
8518 right_child_bin);
8519}
8520
8521/* XRALTB - XM Router Algorithmic LPM Tree Binding Register
8522 * --------------------------------------------------------
8523 * The XRALTB register is used to bind virtual router and protocol
8524 * to an allocated LPM tree.
8525 *
8526 * This register embeds original RALTB register.
8527 */
8528#define MLXSW_REG_XRALTB_ID 0x7813
8529#define MLXSW_REG_XRALTB_LEN 0x08
8530#define MLXSW_REG_XRALTB_RALTB_OFFSET 0x04
8531
8532MLXSW_REG_DEFINE(xraltb, MLXSW_REG_XRALTB_ID, MLXSW_REG_XRALTB_LEN);
8533
8534static inline void mlxsw_reg_xraltb_pack(char *payload, u16 virtual_router,
8535 enum mlxsw_reg_ralxx_protocol protocol,
8536 u8 tree_id)
8537{
8538 char *raltb_payload = payload + MLXSW_REG_XRALTB_RALTB_OFFSET;
8539
8540 MLXSW_REG_ZERO(xraltb, payload);
8541 mlxsw_reg_raltb_pack(raltb_payload, virtual_router, protocol, tree_id);
8542}
8543
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008544/* MFCR - Management Fan Control Register
8545 * --------------------------------------
8546 * This register controls the settings of the Fan Speed PWM mechanism.
8547 */
8548#define MLXSW_REG_MFCR_ID 0x9001
8549#define MLXSW_REG_MFCR_LEN 0x08
8550
Jiri Pirko21978dc2016-10-21 16:07:20 +02008551MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008552
8553enum mlxsw_reg_mfcr_pwm_frequency {
8554 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
8555 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
8556 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
8557 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
8558 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
8559 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
8560 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
8561 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
8562};
8563
8564/* reg_mfcr_pwm_frequency
8565 * Controls the frequency of the PWM signal.
8566 * Access: RW
8567 */
Jiri Pirkof7ad3d42016-11-11 11:22:53 +01008568MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008569
8570#define MLXSW_MFCR_TACHOS_MAX 10
8571
8572/* reg_mfcr_tacho_active
8573 * Indicates which of the tachometer is active (bit per tachometer).
8574 * Access: RO
8575 */
8576MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
8577
8578#define MLXSW_MFCR_PWMS_MAX 5
8579
8580/* reg_mfcr_pwm_active
8581 * Indicates which of the PWM control is active (bit per PWM).
8582 * Access: RO
8583 */
8584MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
8585
8586static inline void
8587mlxsw_reg_mfcr_pack(char *payload,
8588 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
8589{
8590 MLXSW_REG_ZERO(mfcr, payload);
8591 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
8592}
8593
8594static inline void
8595mlxsw_reg_mfcr_unpack(char *payload,
8596 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
8597 u16 *p_tacho_active, u8 *p_pwm_active)
8598{
8599 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
8600 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
8601 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
8602}
8603
8604/* MFSC - Management Fan Speed Control Register
8605 * --------------------------------------------
8606 * This register controls the settings of the Fan Speed PWM mechanism.
8607 */
8608#define MLXSW_REG_MFSC_ID 0x9002
8609#define MLXSW_REG_MFSC_LEN 0x08
8610
Jiri Pirko21978dc2016-10-21 16:07:20 +02008611MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008612
8613/* reg_mfsc_pwm
8614 * Fan pwm to control / monitor.
8615 * Access: Index
8616 */
8617MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
8618
8619/* reg_mfsc_pwm_duty_cycle
8620 * Controls the duty cycle of the PWM. Value range from 0..255 to
8621 * represent duty cycle of 0%...100%.
8622 * Access: RW
8623 */
8624MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
8625
8626static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
8627 u8 pwm_duty_cycle)
8628{
8629 MLXSW_REG_ZERO(mfsc, payload);
8630 mlxsw_reg_mfsc_pwm_set(payload, pwm);
8631 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
8632}
8633
8634/* MFSM - Management Fan Speed Measurement
8635 * ---------------------------------------
8636 * This register controls the settings of the Tacho measurements and
8637 * enables reading the Tachometer measurements.
8638 */
8639#define MLXSW_REG_MFSM_ID 0x9003
8640#define MLXSW_REG_MFSM_LEN 0x08
8641
Jiri Pirko21978dc2016-10-21 16:07:20 +02008642MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008643
8644/* reg_mfsm_tacho
8645 * Fan tachometer index.
8646 * Access: Index
8647 */
8648MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
8649
8650/* reg_mfsm_rpm
8651 * Fan speed (round per minute).
8652 * Access: RO
8653 */
8654MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
8655
8656static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
8657{
8658 MLXSW_REG_ZERO(mfsm, payload);
8659 mlxsw_reg_mfsm_tacho_set(payload, tacho);
8660}
8661
Jiri Pirko55c63aa2016-11-22 11:24:12 +01008662/* MFSL - Management Fan Speed Limit Register
8663 * ------------------------------------------
8664 * The Fan Speed Limit register is used to configure the fan speed
8665 * event / interrupt notification mechanism. Fan speed threshold are
8666 * defined for both under-speed and over-speed.
8667 */
8668#define MLXSW_REG_MFSL_ID 0x9004
8669#define MLXSW_REG_MFSL_LEN 0x0C
8670
8671MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
8672
8673/* reg_mfsl_tacho
8674 * Fan tachometer index.
8675 * Access: Index
8676 */
8677MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
8678
8679/* reg_mfsl_tach_min
8680 * Tachometer minimum value (minimum RPM).
8681 * Access: RW
8682 */
8683MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
8684
8685/* reg_mfsl_tach_max
8686 * Tachometer maximum value (maximum RPM).
8687 * Access: RW
8688 */
8689MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
8690
8691static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
8692 u16 tach_min, u16 tach_max)
8693{
8694 MLXSW_REG_ZERO(mfsl, payload);
8695 mlxsw_reg_mfsl_tacho_set(payload, tacho);
8696 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
8697 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
8698}
8699
8700static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
8701 u16 *p_tach_min, u16 *p_tach_max)
8702{
8703 if (p_tach_min)
8704 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
8705
8706 if (p_tach_max)
8707 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
8708}
8709
Vadim Pasternak3760c2b2019-02-13 11:28:46 +00008710/* FORE - Fan Out of Range Event Register
8711 * --------------------------------------
8712 * This register reports the status of the controlled fans compared to the
8713 * range defined by the MFSL register.
8714 */
8715#define MLXSW_REG_FORE_ID 0x9007
8716#define MLXSW_REG_FORE_LEN 0x0C
8717
8718MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
8719
8720/* fan_under_limit
8721 * Fan speed is below the low limit defined in MFSL register. Each bit relates
8722 * to a single tachometer and indicates the specific tachometer reading is
8723 * below the threshold.
8724 * Access: RO
8725 */
8726MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
8727
8728static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
8729 bool *fault)
8730{
8731 u16 limit;
8732
8733 if (fault) {
8734 limit = mlxsw_reg_fore_fan_under_limit_get(payload);
8735 *fault = limit & BIT(tacho);
8736 }
8737}
8738
Jiri Pirko85926f82015-11-27 13:45:56 +01008739/* MTCAP - Management Temperature Capabilities
8740 * -------------------------------------------
8741 * This register exposes the capabilities of the device and
8742 * system temperature sensing.
8743 */
8744#define MLXSW_REG_MTCAP_ID 0x9009
8745#define MLXSW_REG_MTCAP_LEN 0x08
8746
Jiri Pirko21978dc2016-10-21 16:07:20 +02008747MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01008748
8749/* reg_mtcap_sensor_count
8750 * Number of sensors supported by the device.
8751 * This includes the QSFP module sensors (if exists in the QSFP module).
8752 * Access: RO
8753 */
8754MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
8755
8756/* MTMP - Management Temperature
8757 * -----------------------------
8758 * This register controls the settings of the temperature measurements
8759 * and enables reading the temperature measurements. Note that temperature
8760 * is in 0.125 degrees Celsius.
8761 */
8762#define MLXSW_REG_MTMP_ID 0x900A
8763#define MLXSW_REG_MTMP_LEN 0x20
8764
Jiri Pirko21978dc2016-10-21 16:07:20 +02008765MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01008766
Vadim Pasternak984aec72019-05-29 11:47:21 +03008767#define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
Vadim Pasternakae574672019-05-29 11:47:18 +03008768#define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
Jiri Pirko85926f82015-11-27 13:45:56 +01008769/* reg_mtmp_sensor_index
8770 * Sensors index to access.
8771 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
8772 * (module 0 is mapped to sensor_index 64).
8773 * Access: Index
8774 */
Vadim Pasternak984aec72019-05-29 11:47:21 +03008775MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
Jiri Pirko85926f82015-11-27 13:45:56 +01008776
8777/* Convert to milli degrees Celsius */
Vadim Pasternakf485cc32019-06-24 13:32:03 +03008778#define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
8779 ((v_) >= 0) ? ((v_) * 125) : \
8780 ((s16)((GENMASK(15, 0) + (v_) + 1) \
8781 * 125)); })
Jiri Pirko85926f82015-11-27 13:45:56 +01008782
8783/* reg_mtmp_temperature
8784 * Temperature reading from the sensor. Reading is in 0.125 Celsius
8785 * degrees units.
8786 * Access: RO
8787 */
8788MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
8789
8790/* reg_mtmp_mte
8791 * Max Temperature Enable - enables measuring the max temperature on a sensor.
8792 * Access: RW
8793 */
8794MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
8795
8796/* reg_mtmp_mtr
8797 * Max Temperature Reset - clears the value of the max temperature register.
8798 * Access: WO
8799 */
8800MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
8801
8802/* reg_mtmp_max_temperature
8803 * The highest measured temperature from the sensor.
8804 * When the bit mte is cleared, the field max_temperature is reserved.
8805 * Access: RO
8806 */
8807MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
8808
Ido Schimmel62b0e922017-10-30 10:51:18 +01008809/* reg_mtmp_tee
8810 * Temperature Event Enable.
8811 * 0 - Do not generate event
8812 * 1 - Generate event
8813 * 2 - Generate single event
8814 * Access: RW
8815 */
Amit Cohenf21b1a62020-09-27 10:50:12 +03008816
8817enum mlxsw_reg_mtmp_tee {
8818 MLXSW_REG_MTMP_TEE_NO_EVENT,
8819 MLXSW_REG_MTMP_TEE_GENERATE_EVENT,
8820 MLXSW_REG_MTMP_TEE_GENERATE_SINGLE_EVENT,
8821};
8822
Ido Schimmel62b0e922017-10-30 10:51:18 +01008823MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
8824
8825#define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
8826
8827/* reg_mtmp_temperature_threshold_hi
8828 * High threshold for Temperature Warning Event. In 0.125 Celsius.
8829 * Access: RW
8830 */
8831MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
8832
Amit Cohenf21b1a62020-09-27 10:50:12 +03008833#define MLXSW_REG_MTMP_HYSTERESIS_TEMP 0x28 /* 5 Celsius */
Ido Schimmel62b0e922017-10-30 10:51:18 +01008834/* reg_mtmp_temperature_threshold_lo
8835 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
8836 * Access: RW
8837 */
8838MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
8839
Jiri Pirko85926f82015-11-27 13:45:56 +01008840#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
8841
8842/* reg_mtmp_sensor_name
8843 * Sensor Name
8844 * Access: RO
8845 */
8846MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
8847
Vadim Pasternakae574672019-05-29 11:47:18 +03008848static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index,
Jiri Pirko85926f82015-11-27 13:45:56 +01008849 bool max_temp_enable,
8850 bool max_temp_reset)
8851{
8852 MLXSW_REG_ZERO(mtmp, payload);
8853 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
8854 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
8855 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
Ido Schimmel62b0e922017-10-30 10:51:18 +01008856 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
8857 MLXSW_REG_MTMP_THRESH_HI);
Jiri Pirko85926f82015-11-27 13:45:56 +01008858}
8859
Vadim Pasternakf485cc32019-06-24 13:32:03 +03008860static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
8861 int *p_max_temp, char *sensor_name)
Jiri Pirko85926f82015-11-27 13:45:56 +01008862{
Vadim Pasternakf485cc32019-06-24 13:32:03 +03008863 s16 temp;
Jiri Pirko85926f82015-11-27 13:45:56 +01008864
8865 if (p_temp) {
8866 temp = mlxsw_reg_mtmp_temperature_get(payload);
8867 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
8868 }
8869 if (p_max_temp) {
Jiri Pirkoacf35a42015-12-11 16:10:39 +01008870 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
Jiri Pirko85926f82015-11-27 13:45:56 +01008871 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
8872 }
8873 if (sensor_name)
8874 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
8875}
8876
Amit Cohen946bd432020-09-27 10:50:06 +03008877/* MTWE - Management Temperature Warning Event
8878 * -------------------------------------------
8879 * This register is used for over temperature warning.
8880 */
8881#define MLXSW_REG_MTWE_ID 0x900B
8882#define MLXSW_REG_MTWE_LEN 0x10
8883
8884MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN);
8885
8886/* reg_mtwe_sensor_warning
8887 * Bit vector indicating which of the sensor reading is above threshold.
8888 * Address 00h bit31 is sensor_warning[127].
8889 * Address 0Ch bit0 is sensor_warning[0].
8890 * Access: RO
8891 */
8892MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
8893
Vadim Pasternak5f28ef72019-02-13 11:28:45 +00008894/* MTBR - Management Temperature Bulk Register
8895 * -------------------------------------------
8896 * This register is used for bulk temperature reading.
8897 */
8898#define MLXSW_REG_MTBR_ID 0x900F
8899#define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */
8900#define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */
8901#define MLXSW_REG_MTBR_REC_MAX_COUNT 47 /* firmware limitation */
8902#define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
8903 MLXSW_REG_MTBR_REC_LEN * \
8904 MLXSW_REG_MTBR_REC_MAX_COUNT)
8905
8906MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
8907
8908/* reg_mtbr_base_sensor_index
8909 * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
8910 * 64-127 are mapped to the SFP+/QSFP modules sequentially).
8911 * Access: Index
8912 */
Vadim Pasternak984aec72019-05-29 11:47:21 +03008913MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
Vadim Pasternak5f28ef72019-02-13 11:28:45 +00008914
8915/* reg_mtbr_num_rec
8916 * Request: Number of records to read
8917 * Response: Number of records read
8918 * See above description for more details.
8919 * Range 1..255
8920 * Access: RW
8921 */
8922MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
8923
8924/* reg_mtbr_rec_max_temp
8925 * The highest measured temperature from the sensor.
8926 * When the bit mte is cleared, the field max_temperature is reserved.
8927 * Access: RO
8928 */
8929MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
8930 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
8931
8932/* reg_mtbr_rec_temp
8933 * Temperature reading from the sensor. Reading is in 0..125 Celsius
8934 * degrees units.
8935 * Access: RO
8936 */
8937MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
8938 MLXSW_REG_MTBR_REC_LEN, 0x00, false);
8939
Vadim Pasternak984aec72019-05-29 11:47:21 +03008940static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index,
Vadim Pasternak5f28ef72019-02-13 11:28:45 +00008941 u8 num_rec)
8942{
8943 MLXSW_REG_ZERO(mtbr, payload);
8944 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
8945 mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
8946}
8947
8948/* Error codes from temperatute reading */
8949enum mlxsw_reg_mtbr_temp_status {
8950 MLXSW_REG_MTBR_NO_CONN = 0x8000,
8951 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
8952 MLXSW_REG_MTBR_INDEX_NA = 0x8002,
8953 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
8954};
8955
8956/* Base index for reading modules temperature */
8957#define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
8958
8959static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
8960 u16 *p_temp, u16 *p_max_temp)
8961{
8962 if (p_temp)
8963 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
8964 if (p_max_temp)
8965 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
8966}
8967
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008968/* MCIA - Management Cable Info Access
8969 * -----------------------------------
8970 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
8971 */
8972
8973#define MLXSW_REG_MCIA_ID 0x9014
8974#define MLXSW_REG_MCIA_LEN 0x40
8975
8976MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
8977
8978/* reg_mcia_l
8979 * Lock bit. Setting this bit will lock the access to the specific
8980 * cable. Used for updating a full page in a cable EPROM. Any access
8981 * other then subsequence writes will fail while the port is locked.
8982 * Access: RW
8983 */
8984MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
8985
8986/* reg_mcia_module
8987 * Module number.
8988 * Access: Index
8989 */
8990MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
8991
8992/* reg_mcia_status
8993 * Module status.
8994 * Access: RO
8995 */
8996MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
8997
8998/* reg_mcia_i2c_device_address
8999 * I2C device address.
9000 * Access: RW
9001 */
9002MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
9003
9004/* reg_mcia_page_number
9005 * Page number.
9006 * Access: RW
9007 */
9008MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
9009
9010/* reg_mcia_device_address
9011 * Device address.
9012 * Access: RW
9013 */
9014MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
9015
9016/* reg_mcia_size
9017 * Number of bytes to read/write (up to 48 bytes).
9018 * Access: RW
9019 */
9020MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
9021
Vadim Pasternakd517ee72019-02-13 11:28:44 +00009022#define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
Vadim Pasternakf366cd2a2019-10-21 13:30:30 +03009023#define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
Vadim Pasternakd517ee72019-02-13 11:28:44 +00009024#define MLXSW_REG_MCIA_EEPROM_SIZE 48
9025#define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
9026#define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
9027#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
9028#define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
9029#define MLXSW_REG_MCIA_TH_PAGE_NUM 3
Vadim Pasternakf152b412020-07-28 13:20:16 +03009030#define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
Vadim Pasternakd517ee72019-02-13 11:28:44 +00009031#define MLXSW_REG_MCIA_PAGE0_LO 0
9032#define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
Vadim Pasternak6af496a2020-07-28 13:20:15 +03009033#define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
Vadim Pasternakd517ee72019-02-13 11:28:44 +00009034
9035enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
9036 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
9037 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
9038 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
9039};
9040
9041enum mlxsw_reg_mcia_eeprom_module_info_id {
9042 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
9043 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
9044 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
9045 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
9046 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
9047};
9048
9049enum mlxsw_reg_mcia_eeprom_module_info {
9050 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
9051 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
Vadim Pasternak6af496a2020-07-28 13:20:15 +03009052 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
Vadim Pasternakd517ee72019-02-13 11:28:44 +00009053 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
9054};
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02009055
9056/* reg_mcia_eeprom
9057 * Bytes to read/write.
9058 * Access: RW
9059 */
Vadim Pasternakd517ee72019-02-13 11:28:44 +00009060MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02009061
Vadim Pasternakf366cd2a2019-10-21 13:30:30 +03009062/* This is used to access the optional upper pages (1-3) in the QSFP+
9063 * memory map. Page 1 is available on offset 256 through 383, page 2 -
9064 * on offset 384 through 511, page 3 - on offset 512 through 639.
9065 */
9066#define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
9067 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
9068 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
9069
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02009070static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
9071 u8 page_number, u16 device_addr,
9072 u8 size, u8 i2c_device_addr)
9073{
9074 MLXSW_REG_ZERO(mcia, payload);
9075 mlxsw_reg_mcia_module_set(payload, module);
9076 mlxsw_reg_mcia_l_set(payload, lock);
9077 mlxsw_reg_mcia_page_number_set(payload, page_number);
9078 mlxsw_reg_mcia_device_address_set(payload, device_addr);
9079 mlxsw_reg_mcia_size_set(payload, size);
9080 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
9081}
9082
Yotam Gigi43a46852016-07-21 12:03:14 +02009083/* MPAT - Monitoring Port Analyzer Table
9084 * -------------------------------------
9085 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
9086 * For an enabled analyzer, all fields except e (enable) cannot be modified.
9087 */
9088#define MLXSW_REG_MPAT_ID 0x901A
9089#define MLXSW_REG_MPAT_LEN 0x78
9090
Jiri Pirko21978dc2016-10-21 16:07:20 +02009091MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
Yotam Gigi43a46852016-07-21 12:03:14 +02009092
9093/* reg_mpat_pa_id
9094 * Port Analyzer ID.
9095 * Access: Index
9096 */
9097MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
9098
Amit Cohenef8d57e2020-07-14 17:20:54 +03009099/* reg_mpat_session_id
9100 * Mirror Session ID.
9101 * Used for MIRROR_SESSION<i> trap.
9102 * Access: RW
9103 */
9104MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4);
9105
Yotam Gigi43a46852016-07-21 12:03:14 +02009106/* reg_mpat_system_port
9107 * A unique port identifier for the final destination of the packet.
9108 * Access: RW
9109 */
9110MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
9111
9112/* reg_mpat_e
9113 * Enable. Indicating the Port Analyzer is enabled.
9114 * Access: RW
9115 */
9116MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
9117
9118/* reg_mpat_qos
9119 * Quality Of Service Mode.
9120 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
9121 * PCP, DEI, DSCP or VL) are configured.
9122 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
9123 * same as in the original packet that has triggered the mirroring. For
9124 * SPAN also the pcp,dei are maintained.
9125 * Access: RW
9126 */
9127MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
9128
Yotam Gigi23019052016-07-21 12:03:15 +02009129/* reg_mpat_be
9130 * Best effort mode. Indicates mirroring traffic should not cause packet
9131 * drop or back pressure, but will discard the mirrored packets. Mirrored
9132 * packets will be forwarded on a best effort manner.
9133 * 0: Do not discard mirrored packets
9134 * 1: Discard mirrored packets if causing congestion
9135 * Access: RW
9136 */
9137MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
9138
Petr Machata0d6cd3f2018-02-27 14:53:39 +01009139enum mlxsw_reg_mpat_span_type {
9140 /* Local SPAN Ethernet.
9141 * The original packet is not encapsulated.
9142 */
9143 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
9144
Petr Machata41947662018-05-10 13:13:04 +03009145 /* Remote SPAN Ethernet VLAN.
9146 * The packet is forwarded to the monitoring port on the monitoring
9147 * VLAN.
9148 */
9149 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
9150
Petr Machata0d6cd3f2018-02-27 14:53:39 +01009151 /* Encapsulated Remote SPAN Ethernet L3 GRE.
9152 * The packet is encapsulated with GRE header.
9153 */
9154 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
9155};
9156
9157/* reg_mpat_span_type
9158 * SPAN type.
9159 * Access: RW
9160 */
9161MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
9162
Amit Cohenef8d57e2020-07-14 17:20:54 +03009163/* reg_mpat_pide
9164 * Policer enable.
9165 * Access: RW
9166 */
9167MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1);
9168
9169/* reg_mpat_pid
9170 * Policer ID.
9171 * Access: RW
9172 */
9173MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14);
9174
Petr Machata0d6cd3f2018-02-27 14:53:39 +01009175/* Remote SPAN - Ethernet VLAN
9176 * - - - - - - - - - - - - - -
9177 */
9178
9179/* reg_mpat_eth_rspan_vid
9180 * Encapsulation header VLAN ID.
9181 * Access: RW
9182 */
9183MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
9184
9185/* Encapsulated Remote SPAN - Ethernet L2
9186 * - - - - - - - - - - - - - - - - - - -
9187 */
9188
9189enum mlxsw_reg_mpat_eth_rspan_version {
9190 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
9191};
9192
9193/* reg_mpat_eth_rspan_version
9194 * RSPAN mirror header version.
9195 * Access: RW
9196 */
9197MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
9198
9199/* reg_mpat_eth_rspan_mac
9200 * Destination MAC address.
9201 * Access: RW
9202 */
9203MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
9204
9205/* reg_mpat_eth_rspan_tp
9206 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
9207 * Access: RW
9208 */
9209MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
9210
9211/* Encapsulated Remote SPAN - Ethernet L3
9212 * - - - - - - - - - - - - - - - - - - -
9213 */
9214
9215enum mlxsw_reg_mpat_eth_rspan_protocol {
9216 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
9217 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
9218};
9219
9220/* reg_mpat_eth_rspan_protocol
9221 * SPAN encapsulation protocol.
9222 * Access: RW
9223 */
9224MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
9225
9226/* reg_mpat_eth_rspan_ttl
9227 * Encapsulation header Time-to-Live/HopLimit.
9228 * Access: RW
9229 */
9230MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
9231
9232/* reg_mpat_eth_rspan_smac
9233 * Source MAC address
9234 * Access: RW
9235 */
9236MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
9237
9238/* reg_mpat_eth_rspan_dip*
9239 * Destination IP address. The IP version is configured by protocol.
9240 * Access: RW
9241 */
9242MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
9243MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
9244
9245/* reg_mpat_eth_rspan_sip*
9246 * Source IP address. The IP version is configured by protocol.
9247 * Access: RW
9248 */
9249MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
9250MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
9251
Yotam Gigi43a46852016-07-21 12:03:14 +02009252static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
Petr Machata1da93eb2018-02-27 14:53:40 +01009253 u16 system_port, bool e,
9254 enum mlxsw_reg_mpat_span_type span_type)
Yotam Gigi43a46852016-07-21 12:03:14 +02009255{
9256 MLXSW_REG_ZERO(mpat, payload);
9257 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
9258 mlxsw_reg_mpat_system_port_set(payload, system_port);
9259 mlxsw_reg_mpat_e_set(payload, e);
9260 mlxsw_reg_mpat_qos_set(payload, 1);
Yotam Gigi23019052016-07-21 12:03:15 +02009261 mlxsw_reg_mpat_be_set(payload, 1);
Petr Machata1da93eb2018-02-27 14:53:40 +01009262 mlxsw_reg_mpat_span_type_set(payload, span_type);
Yotam Gigi23019052016-07-21 12:03:15 +02009263}
9264
Petr Machata0d6cd3f2018-02-27 14:53:39 +01009265static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
9266{
9267 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
9268}
9269
9270static inline void
9271mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
9272 enum mlxsw_reg_mpat_eth_rspan_version version,
9273 const char *mac,
9274 bool tp)
9275{
9276 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
9277 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
9278 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
9279}
9280
9281static inline void
9282mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
9283 const char *smac,
9284 u32 sip, u32 dip)
9285{
9286 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
9287 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
9288 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
9289 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
9290 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
9291 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
9292}
9293
9294static inline void
9295mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
9296 const char *smac,
9297 struct in6_addr sip, struct in6_addr dip)
9298{
9299 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
9300 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
9301 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
9302 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
9303 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
9304 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
9305}
9306
Yotam Gigi23019052016-07-21 12:03:15 +02009307/* MPAR - Monitoring Port Analyzer Register
9308 * ----------------------------------------
9309 * MPAR register is used to query and configure the port analyzer port mirroring
9310 * properties.
9311 */
9312#define MLXSW_REG_MPAR_ID 0x901B
Ido Schimmel50750662019-10-30 11:34:48 +02009313#define MLXSW_REG_MPAR_LEN 0x0C
Yotam Gigi23019052016-07-21 12:03:15 +02009314
Jiri Pirko21978dc2016-10-21 16:07:20 +02009315MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
Yotam Gigi23019052016-07-21 12:03:15 +02009316
9317/* reg_mpar_local_port
9318 * The local port to mirror the packets from.
9319 * Access: Index
9320 */
9321MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
9322
9323enum mlxsw_reg_mpar_i_e {
9324 MLXSW_REG_MPAR_TYPE_EGRESS,
9325 MLXSW_REG_MPAR_TYPE_INGRESS,
9326};
9327
9328/* reg_mpar_i_e
9329 * Ingress/Egress
9330 * Access: Index
9331 */
9332MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
9333
9334/* reg_mpar_enable
9335 * Enable mirroring
9336 * By default, port mirroring is disabled for all ports.
9337 * Access: RW
9338 */
9339MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
9340
9341/* reg_mpar_pa_id
9342 * Port Analyzer ID.
9343 * Access: RW
9344 */
9345MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
9346
9347static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
9348 enum mlxsw_reg_mpar_i_e i_e,
9349 bool enable, u8 pa_id)
9350{
9351 MLXSW_REG_ZERO(mpar, payload);
9352 mlxsw_reg_mpar_local_port_set(payload, local_port);
9353 mlxsw_reg_mpar_enable_set(payload, enable);
9354 mlxsw_reg_mpar_i_e_set(payload, i_e);
9355 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
Yotam Gigi43a46852016-07-21 12:03:14 +02009356}
9357
Shalom Toledo8d77d4b2019-04-08 06:59:34 +00009358/* MGIR - Management General Information Register
9359 * ----------------------------------------------
9360 * MGIR register allows software to query the hardware and firmware general
9361 * information.
9362 */
9363#define MLXSW_REG_MGIR_ID 0x9020
9364#define MLXSW_REG_MGIR_LEN 0x9C
9365
9366MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
9367
9368/* reg_mgir_hw_info_device_hw_revision
9369 * Access: RO
9370 */
9371MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
9372
9373#define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
9374
9375/* reg_mgir_fw_info_psid
9376 * PSID (ASCII string).
9377 * Access: RO
9378 */
9379MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
9380
9381/* reg_mgir_fw_info_extended_major
9382 * Access: RO
9383 */
9384MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
9385
9386/* reg_mgir_fw_info_extended_minor
9387 * Access: RO
9388 */
9389MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
9390
9391/* reg_mgir_fw_info_extended_sub_minor
9392 * Access: RO
9393 */
9394MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
9395
9396static inline void mlxsw_reg_mgir_pack(char *payload)
9397{
9398 MLXSW_REG_ZERO(mgir, payload);
9399}
9400
9401static inline void
9402mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
9403 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
9404{
9405 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
9406 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
9407 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
9408 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
9409 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
9410}
9411
Jiri Pirko12b003b2018-05-27 09:56:13 +03009412/* MRSR - Management Reset and Shutdown Register
9413 * ---------------------------------------------
9414 * MRSR register is used to reset or shutdown the switch or
9415 * the entire system (when applicable).
9416 */
9417#define MLXSW_REG_MRSR_ID 0x9023
9418#define MLXSW_REG_MRSR_LEN 0x08
9419
9420MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
9421
9422/* reg_mrsr_command
9423 * Reset/shutdown command
9424 * 0 - do nothing
9425 * 1 - software reset
9426 * Access: WO
9427 */
9428MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
9429
9430static inline void mlxsw_reg_mrsr_pack(char *payload)
9431{
9432 MLXSW_REG_ZERO(mrsr, payload);
9433 mlxsw_reg_mrsr_command_set(payload, 1);
9434}
9435
Ido Schimmel3161c152015-11-27 13:45:54 +01009436/* MLCR - Management LED Control Register
9437 * --------------------------------------
9438 * Controls the system LEDs.
9439 */
9440#define MLXSW_REG_MLCR_ID 0x902B
9441#define MLXSW_REG_MLCR_LEN 0x0C
9442
Jiri Pirko21978dc2016-10-21 16:07:20 +02009443MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
Ido Schimmel3161c152015-11-27 13:45:54 +01009444
9445/* reg_mlcr_local_port
9446 * Local port number.
9447 * Access: RW
9448 */
9449MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
9450
9451#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
9452
9453/* reg_mlcr_beacon_duration
9454 * Duration of the beacon to be active, in seconds.
9455 * 0x0 - Will turn off the beacon.
9456 * 0xFFFF - Will turn on the beacon until explicitly turned off.
9457 * Access: RW
9458 */
9459MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
9460
9461/* reg_mlcr_beacon_remain
9462 * Remaining duration of the beacon, in seconds.
9463 * 0xFFFF indicates an infinite amount of time.
9464 * Access: RO
9465 */
9466MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
9467
9468static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
9469 bool active)
9470{
9471 MLXSW_REG_ZERO(mlcr, payload);
9472 mlxsw_reg_mlcr_local_port_set(payload, local_port);
9473 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
9474 MLXSW_REG_MLCR_DURATION_MAX : 0);
9475}
9476
Shalom Toledo10786452019-06-11 18:45:08 +03009477/* MTPPS - Management Pulse Per Second Register
9478 * --------------------------------------------
9479 * This register provides the device PPS capabilities, configure the PPS in and
9480 * out modules and holds the PPS in time stamp.
9481 */
9482#define MLXSW_REG_MTPPS_ID 0x9053
9483#define MLXSW_REG_MTPPS_LEN 0x3C
9484
9485MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
9486
9487/* reg_mtpps_enable
9488 * Enables the PPS functionality the specific pin.
9489 * A boolean variable.
9490 * Access: RW
9491 */
9492MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
9493
9494enum mlxsw_reg_mtpps_pin_mode {
9495 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
9496};
9497
9498/* reg_mtpps_pin_mode
9499 * Pin mode to be used. The mode must comply with the supported modes of the
9500 * requested pin.
9501 * Access: RW
9502 */
9503MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
9504
9505#define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
9506
9507/* reg_mtpps_pin
9508 * Pin to be configured or queried out of the supported pins.
9509 * Access: Index
9510 */
9511MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
9512
9513/* reg_mtpps_time_stamp
9514 * When pin_mode = pps_in, the latched device time when it was triggered from
9515 * the external GPIO pin.
9516 * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target
9517 * time to generate next output signal.
9518 * Time is in units of device clock.
9519 * Access: RW
9520 */
9521MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
9522
9523static inline void
9524mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
9525{
9526 MLXSW_REG_ZERO(mtpps, payload);
9527 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
9528 mlxsw_reg_mtpps_pin_mode_set(payload,
9529 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
9530 mlxsw_reg_mtpps_enable_set(payload, true);
9531 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
9532}
9533
Shalom Toledo55a8b002019-06-11 18:45:07 +03009534/* MTUTC - Management UTC Register
9535 * -------------------------------
9536 * Configures the HW UTC counter.
9537 */
9538#define MLXSW_REG_MTUTC_ID 0x9055
9539#define MLXSW_REG_MTUTC_LEN 0x1C
9540
9541MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
9542
9543enum mlxsw_reg_mtutc_operation {
9544 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
9545 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
9546};
9547
9548/* reg_mtutc_operation
9549 * Operation.
9550 * Access: OP
9551 */
9552MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
9553
9554/* reg_mtutc_freq_adjustment
9555 * Frequency adjustment: Every PPS the HW frequency will be
9556 * adjusted by this value. Units of HW clock, where HW counts
9557 * 10^9 HW clocks for 1 HW second.
9558 * Access: RW
9559 */
9560MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
9561
9562/* reg_mtutc_utc_sec
9563 * UTC seconds.
9564 * Access: WO
9565 */
9566MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
9567
9568static inline void
9569mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
9570 u32 freq_adj, u32 utc_sec)
9571{
9572 MLXSW_REG_ZERO(mtutc, payload);
9573 mlxsw_reg_mtutc_operation_set(payload, oper);
9574 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
9575 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
9576}
9577
Yotam Gigi4f2402d2017-05-23 21:56:24 +02009578/* MCQI - Management Component Query Information
9579 * ---------------------------------------------
9580 * This register allows querying information about firmware components.
9581 */
9582#define MLXSW_REG_MCQI_ID 0x9061
9583#define MLXSW_REG_MCQI_BASE_LEN 0x18
9584#define MLXSW_REG_MCQI_CAP_LEN 0x14
9585#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
9586
9587MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
9588
9589/* reg_mcqi_component_index
9590 * Index of the accessed component.
9591 * Access: Index
9592 */
9593MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
9594
9595enum mlxfw_reg_mcqi_info_type {
9596 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
9597};
9598
9599/* reg_mcqi_info_type
9600 * Component properties set.
9601 * Access: RW
9602 */
9603MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
9604
9605/* reg_mcqi_offset
9606 * The requested/returned data offset from the section start, given in bytes.
9607 * Must be DWORD aligned.
9608 * Access: RW
9609 */
9610MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
9611
9612/* reg_mcqi_data_size
9613 * The requested/returned data size, given in bytes. If data_size is not DWORD
9614 * aligned, the last bytes are zero padded.
9615 * Access: RW
9616 */
9617MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
9618
9619/* reg_mcqi_cap_max_component_size
9620 * Maximum size for this component, given in bytes.
9621 * Access: RO
9622 */
9623MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
9624
9625/* reg_mcqi_cap_log_mcda_word_size
9626 * Log 2 of the access word size in bytes. Read and write access must be aligned
9627 * to the word size. Write access must be done for an integer number of words.
9628 * Access: RO
9629 */
9630MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
9631
9632/* reg_mcqi_cap_mcda_max_write_size
9633 * Maximal write size for MCDA register
9634 * Access: RO
9635 */
9636MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
9637
9638static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
9639{
9640 MLXSW_REG_ZERO(mcqi, payload);
9641 mlxsw_reg_mcqi_component_index_set(payload, component_index);
9642 mlxsw_reg_mcqi_info_type_set(payload,
9643 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
9644 mlxsw_reg_mcqi_offset_set(payload, 0);
9645 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
9646}
9647
9648static inline void mlxsw_reg_mcqi_unpack(char *payload,
9649 u32 *p_cap_max_component_size,
9650 u8 *p_cap_log_mcda_word_size,
9651 u16 *p_cap_mcda_max_write_size)
9652{
9653 *p_cap_max_component_size =
9654 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
9655 *p_cap_log_mcda_word_size =
9656 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
9657 *p_cap_mcda_max_write_size =
9658 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
9659}
9660
Yotam Gigi191839d2017-05-23 21:56:25 +02009661/* MCC - Management Component Control
9662 * ----------------------------------
9663 * Controls the firmware component and updates the FSM.
9664 */
9665#define MLXSW_REG_MCC_ID 0x9062
9666#define MLXSW_REG_MCC_LEN 0x1C
9667
9668MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
9669
9670enum mlxsw_reg_mcc_instruction {
9671 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
9672 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
9673 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
9674 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
9675 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
9676 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
9677};
9678
9679/* reg_mcc_instruction
9680 * Command to be executed by the FSM.
9681 * Applicable for write operation only.
9682 * Access: RW
9683 */
9684MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
9685
9686/* reg_mcc_component_index
9687 * Index of the accessed component. Applicable only for commands that
9688 * refer to components. Otherwise, this field is reserved.
9689 * Access: Index
9690 */
9691MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
9692
9693/* reg_mcc_update_handle
9694 * Token representing the current flow executed by the FSM.
9695 * Access: WO
9696 */
9697MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
9698
9699/* reg_mcc_error_code
9700 * Indicates the successful completion of the instruction, or the reason it
9701 * failed
9702 * Access: RO
9703 */
9704MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
9705
9706/* reg_mcc_control_state
9707 * Current FSM state
9708 * Access: RO
9709 */
9710MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
9711
9712/* reg_mcc_component_size
9713 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
9714 * the size may shorten the update time. Value 0x0 means that size is
9715 * unspecified.
9716 * Access: WO
9717 */
9718MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
9719
9720static inline void mlxsw_reg_mcc_pack(char *payload,
9721 enum mlxsw_reg_mcc_instruction instr,
9722 u16 component_index, u32 update_handle,
9723 u32 component_size)
9724{
9725 MLXSW_REG_ZERO(mcc, payload);
9726 mlxsw_reg_mcc_instruction_set(payload, instr);
9727 mlxsw_reg_mcc_component_index_set(payload, component_index);
9728 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
9729 mlxsw_reg_mcc_component_size_set(payload, component_size);
9730}
9731
9732static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
9733 u8 *p_error_code, u8 *p_control_state)
9734{
9735 if (p_update_handle)
9736 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
9737 if (p_error_code)
9738 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
9739 if (p_control_state)
9740 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
9741}
9742
Yotam Gigi4625d592017-05-23 21:56:26 +02009743/* MCDA - Management Component Data Access
9744 * ---------------------------------------
9745 * This register allows reading and writing a firmware component.
9746 */
9747#define MLXSW_REG_MCDA_ID 0x9063
9748#define MLXSW_REG_MCDA_BASE_LEN 0x10
9749#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
9750#define MLXSW_REG_MCDA_LEN \
9751 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
9752
9753MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
9754
9755/* reg_mcda_update_handle
9756 * Token representing the current flow executed by the FSM.
9757 * Access: RW
9758 */
9759MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
9760
9761/* reg_mcda_offset
9762 * Offset of accessed address relative to component start. Accesses must be in
9763 * accordance to log_mcda_word_size in MCQI reg.
9764 * Access: RW
9765 */
9766MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
9767
9768/* reg_mcda_size
9769 * Size of the data accessed, given in bytes.
9770 * Access: RW
9771 */
9772MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
9773
9774/* reg_mcda_data
9775 * Data block accessed.
9776 * Access: RW
9777 */
9778MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
9779
9780static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
9781 u32 offset, u16 size, u8 *data)
9782{
9783 int i;
9784
9785 MLXSW_REG_ZERO(mcda, payload);
9786 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
9787 mlxsw_reg_mcda_offset_set(payload, offset);
9788 mlxsw_reg_mcda_size_set(payload, size);
9789
9790 for (i = 0; i < size / 4; i++)
9791 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
9792}
9793
Yotam Gigi0677d682017-01-23 11:07:10 +01009794/* MPSC - Monitoring Packet Sampling Configuration Register
9795 * --------------------------------------------------------
9796 * MPSC Register is used to configure the Packet Sampling mechanism.
9797 */
9798#define MLXSW_REG_MPSC_ID 0x9080
9799#define MLXSW_REG_MPSC_LEN 0x1C
9800
9801MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
9802
9803/* reg_mpsc_local_port
9804 * Local port number
9805 * Not supported for CPU port
9806 * Access: Index
9807 */
9808MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
9809
9810/* reg_mpsc_e
9811 * Enable sampling on port local_port
9812 * Access: RW
9813 */
9814MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
9815
9816#define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
9817
9818/* reg_mpsc_rate
9819 * Sampling rate = 1 out of rate packets (with randomization around
9820 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
9821 * Access: RW
9822 */
9823MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
9824
9825static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
9826 u32 rate)
9827{
9828 MLXSW_REG_ZERO(mpsc, payload);
9829 mlxsw_reg_mpsc_local_port_set(payload, local_port);
9830 mlxsw_reg_mpsc_e_set(payload, e);
9831 mlxsw_reg_mpsc_rate_set(payload, rate);
9832}
9833
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01009834/* MGPC - Monitoring General Purpose Counter Set Register
9835 * The MGPC register retrieves and sets the General Purpose Counter Set.
9836 */
9837#define MLXSW_REG_MGPC_ID 0x9081
9838#define MLXSW_REG_MGPC_LEN 0x18
9839
9840MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
9841
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01009842/* reg_mgpc_counter_set_type
9843 * Counter set type.
9844 * Access: OP
9845 */
9846MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
9847
9848/* reg_mgpc_counter_index
9849 * Counter index.
9850 * Access: Index
9851 */
9852MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
9853
9854enum mlxsw_reg_mgpc_opcode {
9855 /* Nop */
9856 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
9857 /* Clear counters */
9858 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
9859};
9860
9861/* reg_mgpc_opcode
9862 * Opcode.
9863 * Access: OP
9864 */
9865MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
9866
9867/* reg_mgpc_byte_counter
9868 * Byte counter value.
9869 * Access: RW
9870 */
9871MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
9872
9873/* reg_mgpc_packet_counter
9874 * Packet counter value.
9875 * Access: RW
9876 */
9877MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
9878
9879static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
9880 enum mlxsw_reg_mgpc_opcode opcode,
Arkadi Sharshevsky6bba7e22017-08-24 08:40:07 +02009881 enum mlxsw_reg_flow_counter_set_type set_type)
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01009882{
9883 MLXSW_REG_ZERO(mgpc, payload);
9884 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
9885 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
9886 mlxsw_reg_mgpc_opcode_set(payload, opcode);
9887}
9888
Ido Schimmel27f68c02018-10-11 07:48:08 +00009889/* MPRS - Monitoring Parsing State Register
9890 * ----------------------------------------
9891 * The MPRS register is used for setting up the parsing for hash,
9892 * policy-engine and routing.
9893 */
9894#define MLXSW_REG_MPRS_ID 0x9083
9895#define MLXSW_REG_MPRS_LEN 0x14
9896
9897MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
9898
9899/* reg_mprs_parsing_depth
9900 * Minimum parsing depth.
9901 * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL
9902 * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2.
9903 * Access: RW
9904 */
9905MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
9906
9907/* reg_mprs_parsing_en
9908 * Parsing enable.
9909 * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and
9910 * NVGRE. Default is enabled. Reserved when SwitchX-2.
9911 * Access: RW
9912 */
9913MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
9914
9915/* reg_mprs_vxlan_udp_dport
9916 * VxLAN UDP destination port.
9917 * Used for identifying VxLAN packets and for dport field in
9918 * encapsulation. Default is 4789.
9919 * Access: RW
9920 */
9921MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
9922
9923static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
9924 u16 vxlan_udp_dport)
9925{
9926 MLXSW_REG_ZERO(mprs, payload);
9927 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
9928 mlxsw_reg_mprs_parsing_en_set(payload, true);
9929 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
9930}
9931
Petr Machata41ce78b2019-06-30 09:04:48 +03009932/* MOGCR - Monitoring Global Configuration Register
9933 * ------------------------------------------------
9934 */
9935#define MLXSW_REG_MOGCR_ID 0x9086
9936#define MLXSW_REG_MOGCR_LEN 0x20
9937
9938MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
9939
9940/* reg_mogcr_ptp_iftc
9941 * PTP Ingress FIFO Trap Clear
9942 * The PTP_ING_FIFO trap provides MTPPTR with clr according
9943 * to this value. Default 0.
9944 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
9945 * Access: RW
9946 */
9947MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
9948
9949/* reg_mogcr_ptp_eftc
9950 * PTP Egress FIFO Trap Clear
9951 * The PTP_EGR_FIFO trap provides MTPPTR with clr according
9952 * to this value. Default 0.
9953 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
9954 * Access: RW
9955 */
9956MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
9957
Amit Cohen95c68832020-07-14 17:20:55 +03009958/* reg_mogcr_mirroring_pid_base
9959 * Base policer id for mirroring policers.
9960 * Must have an even value (e.g. 1000, not 1001).
9961 * Reserved when SwitchX/-2, Switch-IB/2, Spectrum-1 and Quantum.
9962 * Access: RW
9963 */
9964MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14);
9965
Amit Cohenc0e39692020-07-11 00:55:05 +03009966/* MPAGR - Monitoring Port Analyzer Global Register
9967 * ------------------------------------------------
9968 * This register is used for global port analyzer configurations.
9969 * Note: This register is not supported by current FW versions for Spectrum-1.
9970 */
9971#define MLXSW_REG_MPAGR_ID 0x9089
9972#define MLXSW_REG_MPAGR_LEN 0x0C
9973
9974MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN);
9975
9976enum mlxsw_reg_mpagr_trigger {
9977 MLXSW_REG_MPAGR_TRIGGER_EGRESS,
9978 MLXSW_REG_MPAGR_TRIGGER_INGRESS,
9979 MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED,
9980 MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER,
9981 MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG,
9982 MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG,
9983 MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN,
9984 MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY,
9985};
9986
9987/* reg_mpagr_trigger
9988 * Mirror trigger.
9989 * Access: Index
9990 */
9991MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4);
9992
9993/* reg_mpagr_pa_id
9994 * Port analyzer ID.
9995 * Access: RW
9996 */
9997MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4);
9998
9999/* reg_mpagr_probability_rate
10000 * Sampling rate.
10001 * Valid values are: 1 to 3.5*10^9
10002 * Value of 1 means "sample all". Default is 1.
10003 * Access: RW
10004 */
10005MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32);
10006
10007static inline void mlxsw_reg_mpagr_pack(char *payload,
10008 enum mlxsw_reg_mpagr_trigger trigger,
10009 u8 pa_id, u32 probability_rate)
10010{
10011 MLXSW_REG_ZERO(mpagr, payload);
10012 mlxsw_reg_mpagr_trigger_set(payload, trigger);
10013 mlxsw_reg_mpagr_pa_id_set(payload, pa_id);
10014 mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate);
10015}
10016
Amit Cohen951b84d2020-07-11 00:55:04 +030010017/* MOMTE - Monitoring Mirror Trigger Enable Register
10018 * -------------------------------------------------
10019 * This register is used to configure the mirror enable for different mirror
10020 * reasons.
10021 */
10022#define MLXSW_REG_MOMTE_ID 0x908D
10023#define MLXSW_REG_MOMTE_LEN 0x10
10024
10025MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN);
10026
10027/* reg_momte_local_port
10028 * Local port number.
10029 * Access: Index
10030 */
10031MLXSW_ITEM32(reg, momte, local_port, 0x00, 16, 8);
10032
10033enum mlxsw_reg_momte_type {
10034 MLXSW_REG_MOMTE_TYPE_WRED = 0x20,
10035 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31,
10036 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32,
10037 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33,
10038 MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40,
10039 MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50,
10040 MLXSW_REG_MOMTE_TYPE_ECN = 0x60,
10041 MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70,
10042};
10043
10044/* reg_momte_type
10045 * Type of mirroring.
10046 * Access: Index
10047 */
10048MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
10049
10050/* reg_momte_tclass_en
10051 * TClass/PG mirror enable. Each bit represents corresponding tclass.
10052 * 0: disable (default)
10053 * 1: enable
10054 * Access: RW
10055 */
10056MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
10057
10058static inline void mlxsw_reg_momte_pack(char *payload, u8 local_port,
10059 enum mlxsw_reg_momte_type type)
10060{
10061 MLXSW_REG_ZERO(momte, payload);
10062 mlxsw_reg_momte_local_port_set(payload, local_port);
10063 mlxsw_reg_momte_type_set(payload, type);
10064}
10065
Petr Machatada28e872019-06-30 09:04:45 +030010066/* MTPPPC - Time Precision Packet Port Configuration
10067 * -------------------------------------------------
10068 * This register serves for configuration of which PTP messages should be
10069 * timestamped. This is a global configuration, despite the register name.
10070 *
10071 * Reserved when Spectrum-2.
10072 */
10073#define MLXSW_REG_MTPPPC_ID 0x9090
10074#define MLXSW_REG_MTPPPC_LEN 0x28
10075
10076MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
10077
10078/* reg_mtpppc_ing_timestamp_message_type
10079 * Bitwise vector of PTP message types to timestamp at ingress.
10080 * MessageType field as defined by IEEE 1588
10081 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
10082 * Default all 0
10083 * Access: RW
10084 */
10085MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
10086
10087/* reg_mtpppc_egr_timestamp_message_type
10088 * Bitwise vector of PTP message types to timestamp at egress.
10089 * MessageType field as defined by IEEE 1588
10090 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
10091 * Default all 0
10092 * Access: RW
10093 */
10094MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
10095
10096static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
10097{
10098 MLXSW_REG_ZERO(mtpppc, payload);
10099 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
10100 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
10101}
10102
Petr Machata98b90282019-06-30 09:04:47 +030010103/* MTPPTR - Time Precision Packet Timestamping Reading
10104 * ---------------------------------------------------
10105 * The MTPPTR is used for reading the per port PTP timestamp FIFO.
10106 * There is a trap for packets which are latched to the timestamp FIFO, thus the
10107 * SW knows which FIFO to read. Note that packets enter the FIFO before been
10108 * trapped. The sequence number is used to synchronize the timestamp FIFO
10109 * entries and the trapped packets.
10110 * Reserved when Spectrum-2.
10111 */
10112
10113#define MLXSW_REG_MTPPTR_ID 0x9091
10114#define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */
10115#define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */
10116#define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
10117#define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
10118 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
10119
10120MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
10121
10122/* reg_mtpptr_local_port
10123 * Not supported for CPU port.
10124 * Access: Index
10125 */
10126MLXSW_ITEM32(reg, mtpptr, local_port, 0x00, 16, 8);
10127
10128enum mlxsw_reg_mtpptr_dir {
10129 MLXSW_REG_MTPPTR_DIR_INGRESS,
10130 MLXSW_REG_MTPPTR_DIR_EGRESS,
10131};
10132
10133/* reg_mtpptr_dir
10134 * Direction.
10135 * Access: Index
10136 */
10137MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
10138
10139/* reg_mtpptr_clr
10140 * Clear the records.
10141 * Access: OP
10142 */
10143MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
10144
10145/* reg_mtpptr_num_rec
10146 * Number of valid records in the response
10147 * Range 0.. cap_ptp_timestamp_fifo
10148 * Access: RO
10149 */
10150MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
10151
10152/* reg_mtpptr_rec_message_type
10153 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
10154 * (e.g. Bit0: Sync, Bit1: Delay_Req)
10155 * Access: RO
10156 */
10157MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
10158 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
10159 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
10160
10161/* reg_mtpptr_rec_domain_number
10162 * DomainNumber field as defined by IEEE 1588
10163 * Access: RO
10164 */
10165MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
10166 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
10167 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
10168
10169/* reg_mtpptr_rec_sequence_id
10170 * SequenceId field as defined by IEEE 1588
10171 * Access: RO
10172 */
10173MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
10174 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
10175 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
10176
10177/* reg_mtpptr_rec_timestamp_high
10178 * Timestamp of when the PTP packet has passed through the port Units of PLL
10179 * clock time.
10180 * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec.
10181 * Access: RO
10182 */
10183MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
10184 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
10185 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
10186
10187/* reg_mtpptr_rec_timestamp_low
10188 * See rec_timestamp_high.
10189 * Access: RO
10190 */
10191MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
10192 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
10193 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
10194
10195static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
10196 unsigned int rec,
10197 u8 *p_message_type,
10198 u8 *p_domain_number,
10199 u16 *p_sequence_id,
10200 u64 *p_timestamp)
10201{
10202 u32 timestamp_high, timestamp_low;
10203
10204 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
10205 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
10206 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
10207 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
10208 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
10209 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
10210}
10211
Petr Machata4dfecb62019-06-30 09:04:46 +030010212/* MTPTPT - Monitoring Precision Time Protocol Trap Register
10213 * ---------------------------------------------------------
10214 * This register is used for configuring under which trap to deliver PTP
10215 * packets depending on type of the packet.
10216 */
10217#define MLXSW_REG_MTPTPT_ID 0x9092
10218#define MLXSW_REG_MTPTPT_LEN 0x08
10219
10220MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
10221
10222enum mlxsw_reg_mtptpt_trap_id {
10223 MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
10224 MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
10225};
10226
10227/* reg_mtptpt_trap_id
10228 * Trap id.
10229 * Access: Index
10230 */
10231MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
10232
10233/* reg_mtptpt_message_type
10234 * Bitwise vector of PTP message types to trap. This is a necessary but
10235 * non-sufficient condition since need to enable also per port. See MTPPPC.
10236 * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g.
10237 * Bit0: Sync, Bit1: Delay_Req)
10238 */
10239MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
10240
10241static inline void mlxsw_reg_mtptptp_pack(char *payload,
10242 enum mlxsw_reg_mtptpt_trap_id trap_id,
10243 u16 message_type)
10244{
10245 MLXSW_REG_ZERO(mtptpt, payload);
10246 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
10247 mlxsw_reg_mtptpt_message_type_set(payload, message_type);
10248}
10249
Jiri Pirko191c0c22020-09-15 11:40:56 +030010250/* MFGD - Monitoring FW General Debug Register
10251 * -------------------------------------------
10252 */
10253#define MLXSW_REG_MFGD_ID 0x90F0
10254#define MLXSW_REG_MFGD_LEN 0x0C
10255
10256MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN);
10257
10258/* reg_mfgd_fw_fatal_event_mode
10259 * 0 - don't check FW fatal (default)
10260 * 1 - check FW fatal - enable MFDE trap
10261 * Access: RW
10262 */
10263MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2);
10264
10265/* reg_mfgd_trigger_test
10266 * Access: WO
10267 */
10268MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1);
10269
Vadim Pasternak7e9561e2019-05-29 11:47:19 +030010270/* MGPIR - Management General Peripheral Information Register
10271 * ----------------------------------------------------------
10272 * MGPIR register allows software to query the hardware and
10273 * firmware general information of peripheral entities.
10274 */
10275#define MLXSW_REG_MGPIR_ID 0x9100
10276#define MLXSW_REG_MGPIR_LEN 0xA0
10277
10278MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
10279
10280enum mlxsw_reg_mgpir_device_type {
10281 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
10282 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
10283};
10284
10285/* device_type
10286 * Access: RO
10287 */
10288MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
10289
10290/* devices_per_flash
10291 * Number of devices of device_type per flash (can be shared by few devices).
10292 * Access: RO
10293 */
10294MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
10295
10296/* num_of_devices
10297 * Number of devices of device_type.
10298 * Access: RO
10299 */
10300MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
10301
Vadim Pasternak5cfa0302019-10-06 09:34:48 +030010302/* num_of_modules
10303 * Number of modules.
10304 * Access: RO
10305 */
10306MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
10307
Vadim Pasternak7e9561e2019-05-29 11:47:19 +030010308static inline void mlxsw_reg_mgpir_pack(char *payload)
10309{
10310 MLXSW_REG_ZERO(mgpir, payload);
10311}
10312
10313static inline void
10314mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
10315 enum mlxsw_reg_mgpir_device_type *device_type,
Vadim Pasternak5cfa0302019-10-06 09:34:48 +030010316 u8 *devices_per_flash, u8 *num_of_modules)
Vadim Pasternak7e9561e2019-05-29 11:47:19 +030010317{
10318 if (num_of_devices)
10319 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
10320 if (device_type)
10321 *device_type = mlxsw_reg_mgpir_device_type_get(payload);
10322 if (devices_per_flash)
10323 *devices_per_flash =
10324 mlxsw_reg_mgpir_devices_per_flash_get(payload);
Vadim Pasternak5cfa0302019-10-06 09:34:48 +030010325 if (num_of_modules)
10326 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
Vadim Pasternak7e9561e2019-05-29 11:47:19 +030010327}
10328
Jiri Pirko6ddac9d2020-09-15 11:40:55 +030010329/* MFDE - Monitoring FW Debug Register
10330 * -----------------------------------
10331 */
10332#define MLXSW_REG_MFDE_ID 0x9200
10333#define MLXSW_REG_MFDE_LEN 0x18
10334
10335MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN);
10336
10337/* reg_mfde_irisc_id
10338 * Which irisc triggered the event
10339 * Access: RO
10340 */
10341MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 8, 4);
10342
10343enum mlxsw_reg_mfde_event_id {
10344 MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1,
10345 /* KVD insertion machine stopped */
10346 MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP,
10347};
10348
10349/* reg_mfde_event_id
10350 * Access: RO
10351 */
10352MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 8);
10353
10354enum mlxsw_reg_mfde_method {
10355 MLXSW_REG_MFDE_METHOD_QUERY,
10356 MLXSW_REG_MFDE_METHOD_WRITE,
10357};
10358
10359/* reg_mfde_method
10360 * Access: RO
10361 */
10362MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1);
10363
10364/* reg_mfde_long_process
10365 * Indicates if the command is in long_process mode.
10366 * Access: RO
10367 */
10368MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1);
10369
10370enum mlxsw_reg_mfde_command_type {
10371 MLXSW_REG_MFDE_COMMAND_TYPE_MAD,
10372 MLXSW_REG_MFDE_COMMAND_TYPE_EMAD,
10373 MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF,
10374};
10375
10376/* reg_mfde_command_type
10377 * Access: RO
10378 */
10379MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2);
10380
10381/* reg_mfde_reg_attr_id
10382 * EMAD - register id, MAD - attibute id
10383 * Access: RO
10384 */
10385MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16);
10386
10387/* reg_mfde_log_address
10388 * crspace address accessed, which resulted in timeout.
10389 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO
10390 * Access: RO
10391 */
10392MLXSW_ITEM32(reg, mfde, log_address, 0x10, 0, 32);
10393
10394/* reg_mfde_log_id
10395 * Which irisc triggered the timeout.
10396 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO
10397 * Access: RO
10398 */
10399MLXSW_ITEM32(reg, mfde, log_id, 0x14, 0, 4);
10400
10401/* reg_mfde_pipes_mask
10402 * Bit per kvh pipe.
10403 * Access: RO
10404 */
10405MLXSW_ITEM32(reg, mfde, pipes_mask, 0x10, 0, 16);
10406
Ido Schimmel710dd1a2018-10-11 07:47:59 +000010407/* TNGCR - Tunneling NVE General Configuration Register
10408 * ----------------------------------------------------
10409 * The TNGCR register is used for setting up the NVE Tunneling configuration.
10410 */
10411#define MLXSW_REG_TNGCR_ID 0xA001
10412#define MLXSW_REG_TNGCR_LEN 0x44
10413
10414MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
10415
10416enum mlxsw_reg_tngcr_type {
10417 MLXSW_REG_TNGCR_TYPE_VXLAN,
10418 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
10419 MLXSW_REG_TNGCR_TYPE_GENEVE,
10420 MLXSW_REG_TNGCR_TYPE_NVGRE,
10421};
10422
10423/* reg_tngcr_type
10424 * Tunnel type for encapsulation and decapsulation. The types are mutually
10425 * exclusive.
10426 * Note: For Spectrum the NVE parsing must be enabled in MPRS.
10427 * Access: RW
10428 */
10429MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
10430
10431/* reg_tngcr_nve_valid
10432 * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation.
10433 * Access: RW
10434 */
10435MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
10436
10437/* reg_tngcr_nve_ttl_uc
10438 * The TTL for NVE tunnel encapsulation underlay unicast packets.
10439 * Access: RW
10440 */
10441MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
10442
10443/* reg_tngcr_nve_ttl_mc
10444 * The TTL for NVE tunnel encapsulation underlay multicast packets.
10445 * Access: RW
10446 */
10447MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
10448
10449enum {
10450 /* Do not copy flow label. Calculate flow label using nve_flh. */
10451 MLXSW_REG_TNGCR_FL_NO_COPY,
10452 /* Copy flow label from inner packet if packet is IPv6 and
10453 * encapsulation is by IPv6. Otherwise, calculate flow label using
10454 * nve_flh.
10455 */
10456 MLXSW_REG_TNGCR_FL_COPY,
10457};
10458
10459/* reg_tngcr_nve_flc
10460 * For NVE tunnel encapsulation: Flow label copy from inner packet.
10461 * Access: RW
10462 */
10463MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
10464
10465enum {
10466 /* Flow label is static. In Spectrum this means '0'. Spectrum-2
10467 * uses {nve_fl_prefix, nve_fl_suffix}.
10468 */
10469 MLXSW_REG_TNGCR_FL_NO_HASH,
10470 /* 8 LSBs of the flow label are calculated from ECMP hash of the
10471 * inner packet. 12 MSBs are configured by nve_fl_prefix.
10472 */
10473 MLXSW_REG_TNGCR_FL_HASH,
10474};
10475
10476/* reg_tngcr_nve_flh
10477 * NVE flow label hash.
10478 * Access: RW
10479 */
10480MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
10481
10482/* reg_tngcr_nve_fl_prefix
10483 * NVE flow label prefix. Constant 12 MSBs of the flow label.
10484 * Access: RW
10485 */
10486MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
10487
10488/* reg_tngcr_nve_fl_suffix
10489 * NVE flow label suffix. Constant 8 LSBs of the flow label.
10490 * Reserved when nve_flh=1 and for Spectrum.
10491 * Access: RW
10492 */
10493MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
10494
10495enum {
10496 /* Source UDP port is fixed (default '0') */
10497 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
10498 /* Source UDP port is calculated based on hash */
10499 MLXSW_REG_TNGCR_UDP_SPORT_HASH,
10500};
10501
10502/* reg_tngcr_nve_udp_sport_type
10503 * NVE UDP source port type.
10504 * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2).
10505 * When the source UDP port is calculated based on hash, then the 8 LSBs
10506 * are calculated from hash the 8 MSBs are configured by
10507 * nve_udp_sport_prefix.
10508 * Access: RW
10509 */
10510MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
10511
10512/* reg_tngcr_nve_udp_sport_prefix
10513 * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port.
10514 * Reserved when NVE type is NVGRE.
10515 * Access: RW
10516 */
10517MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
10518
10519/* reg_tngcr_nve_group_size_mc
10520 * The amount of sequential linked lists of MC entries. The first linked
10521 * list is configured by SFD.underlay_mc_ptr.
10522 * Valid values: 1, 2, 4, 8, 16, 32, 64
10523 * The linked list are configured by TNUMT.
10524 * The hash is set by LAG hash.
10525 * Access: RW
10526 */
10527MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
10528
10529/* reg_tngcr_nve_group_size_flood
10530 * The amount of sequential linked lists of flooding entries. The first
10531 * linked list is configured by SFMR.nve_tunnel_flood_ptr
10532 * Valid values: 1, 2, 4, 8, 16, 32, 64
10533 * The linked list are configured by TNUMT.
10534 * The hash is set by LAG hash.
10535 * Access: RW
10536 */
10537MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
10538
10539/* reg_tngcr_learn_enable
10540 * During decapsulation, whether to learn from NVE port.
10541 * Reserved when Spectrum-2. See TNPC.
10542 * Access: RW
10543 */
10544MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
10545
10546/* reg_tngcr_underlay_virtual_router
10547 * Underlay virtual router.
10548 * Reserved when Spectrum-2.
10549 * Access: RW
10550 */
10551MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
10552
10553/* reg_tngcr_underlay_rif
10554 * Underlay ingress router interface. RIF type should be loopback generic.
10555 * Reserved when Spectrum.
10556 * Access: RW
10557 */
10558MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
10559
10560/* reg_tngcr_usipv4
10561 * Underlay source IPv4 address of the NVE.
10562 * Access: RW
10563 */
10564MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
10565
10566/* reg_tngcr_usipv6
10567 * Underlay source IPv6 address of the NVE. For Spectrum, must not be
10568 * modified under traffic of NVE tunneling encapsulation.
10569 * Access: RW
10570 */
10571MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
10572
10573static inline void mlxsw_reg_tngcr_pack(char *payload,
10574 enum mlxsw_reg_tngcr_type type,
10575 bool valid, u8 ttl)
10576{
10577 MLXSW_REG_ZERO(tngcr, payload);
10578 mlxsw_reg_tngcr_type_set(payload, type);
10579 mlxsw_reg_tngcr_nve_valid_set(payload, valid);
10580 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
10581 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
10582 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
10583 mlxsw_reg_tngcr_nve_flh_set(payload, 0);
10584 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
10585 MLXSW_REG_TNGCR_UDP_SPORT_HASH);
10586 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
10587 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
10588 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
10589}
10590
Ido Schimmelc723d192018-10-11 07:48:01 +000010591/* TNUMT - Tunneling NVE Underlay Multicast Table Register
10592 * -------------------------------------------------------
10593 * The TNUMT register is for building the underlay MC table. It is used
10594 * for MC, flooding and BC traffic into the NVE tunnel.
10595 */
10596#define MLXSW_REG_TNUMT_ID 0xA003
10597#define MLXSW_REG_TNUMT_LEN 0x20
10598
10599MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
10600
10601enum mlxsw_reg_tnumt_record_type {
10602 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
10603 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
10604 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
10605};
10606
10607/* reg_tnumt_record_type
10608 * Record type.
10609 * Access: RW
10610 */
10611MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
10612
Ido Schimmelc723d192018-10-11 07:48:01 +000010613/* reg_tnumt_tunnel_port
10614 * Tunnel port.
10615 * Access: RW
10616 */
10617MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
10618
10619/* reg_tnumt_underlay_mc_ptr
10620 * Index to the underlay multicast table.
10621 * For Spectrum the index is to the KVD linear.
10622 * Access: Index
10623 */
10624MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
10625
10626/* reg_tnumt_vnext
10627 * The next_underlay_mc_ptr is valid.
10628 * Access: RW
10629 */
10630MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
10631
10632/* reg_tnumt_next_underlay_mc_ptr
10633 * The next index to the underlay multicast table.
10634 * Access: RW
10635 */
10636MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
10637
10638/* reg_tnumt_record_size
10639 * Number of IP addresses in the record.
10640 * Range is 1..cap_max_nve_mc_entries_ipv{4,6}
10641 * Access: RW
10642 */
10643MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
10644
10645/* reg_tnumt_udip
10646 * The underlay IPv4 addresses. udip[i] is reserved if i >= size
10647 * Access: RW
10648 */
10649MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
10650
10651/* reg_tnumt_udip_ptr
10652 * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if
10653 * i >= size. The IPv6 addresses are configured by RIPS.
10654 * Access: RW
10655 */
10656MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
10657
10658static inline void mlxsw_reg_tnumt_pack(char *payload,
10659 enum mlxsw_reg_tnumt_record_type type,
Amit Cohen02c3b5c2020-12-08 11:22:41 +020010660 enum mlxsw_reg_tunnel_port tport,
Ido Schimmelc723d192018-10-11 07:48:01 +000010661 u32 underlay_mc_ptr, bool vnext,
10662 u32 next_underlay_mc_ptr,
10663 u8 record_size)
10664{
10665 MLXSW_REG_ZERO(tnumt, payload);
10666 mlxsw_reg_tnumt_record_type_set(payload, type);
10667 mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
10668 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
10669 mlxsw_reg_tnumt_vnext_set(payload, vnext);
10670 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
10671 mlxsw_reg_tnumt_record_size_set(payload, record_size);
10672}
10673
Ido Schimmelfd6db272018-10-11 07:48:04 +000010674/* TNQCR - Tunneling NVE QoS Configuration Register
10675 * ------------------------------------------------
10676 * The TNQCR register configures how QoS is set in encapsulation into the
10677 * underlay network.
10678 */
10679#define MLXSW_REG_TNQCR_ID 0xA010
10680#define MLXSW_REG_TNQCR_LEN 0x0C
10681
10682MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
10683
10684/* reg_tnqcr_enc_set_dscp
10685 * For encapsulation: How to set DSCP field:
10686 * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay
10687 * (outer) IP header. If there is no IP header, use TNQDR.dscp
10688 * 1 - Set the DSCP field as TNQDR.dscp
10689 * Access: RW
10690 */
10691MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
10692
10693static inline void mlxsw_reg_tnqcr_pack(char *payload)
10694{
10695 MLXSW_REG_ZERO(tnqcr, payload);
10696 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
10697}
10698
Ido Schimmel8efcf6b2018-10-11 07:48:06 +000010699/* TNQDR - Tunneling NVE QoS Default Register
10700 * ------------------------------------------
10701 * The TNQDR register configures the default QoS settings for NVE
10702 * encapsulation.
10703 */
10704#define MLXSW_REG_TNQDR_ID 0xA011
10705#define MLXSW_REG_TNQDR_LEN 0x08
10706
10707MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
10708
10709/* reg_tnqdr_local_port
10710 * Local port number (receive port). CPU port is supported.
10711 * Access: Index
10712 */
10713MLXSW_ITEM32(reg, tnqdr, local_port, 0x00, 16, 8);
10714
10715/* reg_tnqdr_dscp
10716 * For encapsulation, the default DSCP.
10717 * Access: RW
10718 */
10719MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
10720
10721static inline void mlxsw_reg_tnqdr_pack(char *payload, u8 local_port)
10722{
10723 MLXSW_REG_ZERO(tnqdr, payload);
10724 mlxsw_reg_tnqdr_local_port_set(payload, local_port);
10725 mlxsw_reg_tnqdr_dscp_set(payload, 0);
10726}
10727
Ido Schimmel4a8d1862018-10-11 07:48:02 +000010728/* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register
10729 * --------------------------------------------------------
10730 * The TNEEM register maps ECN of the IP header at the ingress to the
10731 * encapsulation to the ECN of the underlay network.
10732 */
10733#define MLXSW_REG_TNEEM_ID 0xA012
10734#define MLXSW_REG_TNEEM_LEN 0x0C
10735
10736MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
10737
10738/* reg_tneem_overlay_ecn
10739 * ECN of the IP header in the overlay network.
10740 * Access: Index
10741 */
10742MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
10743
10744/* reg_tneem_underlay_ecn
10745 * ECN of the IP header in the underlay network.
10746 * Access: RW
10747 */
10748MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
10749
10750static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
10751 u8 underlay_ecn)
10752{
10753 MLXSW_REG_ZERO(tneem, payload);
10754 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
10755 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
10756}
10757
Ido Schimmela77d5f02018-10-11 07:48:03 +000010758/* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register
10759 * --------------------------------------------------------
10760 * The TNDEM register configures the actions that are done in the
10761 * decapsulation.
10762 */
10763#define MLXSW_REG_TNDEM_ID 0xA013
10764#define MLXSW_REG_TNDEM_LEN 0x0C
10765
10766MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
10767
10768/* reg_tndem_underlay_ecn
10769 * ECN field of the IP header in the underlay network.
10770 * Access: Index
10771 */
10772MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
10773
10774/* reg_tndem_overlay_ecn
10775 * ECN field of the IP header in the overlay network.
10776 * Access: Index
10777 */
10778MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
10779
10780/* reg_tndem_eip_ecn
10781 * Egress IP ECN. ECN field of the IP header of the packet which goes out
10782 * from the decapsulation.
10783 * Access: RW
10784 */
10785MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
10786
10787/* reg_tndem_trap_en
10788 * Trap enable:
10789 * 0 - No trap due to decap ECN
10790 * 1 - Trap enable with trap_id
10791 * Access: RW
10792 */
10793MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
10794
10795/* reg_tndem_trap_id
10796 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
10797 * Reserved when trap_en is '0'.
10798 * Access: RW
10799 */
10800MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
10801
10802static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
10803 u8 overlay_ecn, u8 ecn, bool trap_en,
10804 u16 trap_id)
10805{
10806 MLXSW_REG_ZERO(tndem, payload);
10807 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
10808 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
10809 mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
10810 mlxsw_reg_tndem_trap_en_set(payload, trap_en);
10811 mlxsw_reg_tndem_trap_id_set(payload, trap_id);
10812}
10813
Ido Schimmel50e6eb22018-10-11 07:48:00 +000010814/* TNPC - Tunnel Port Configuration Register
10815 * -----------------------------------------
10816 * The TNPC register is used for tunnel port configuration.
10817 * Reserved when Spectrum.
10818 */
10819#define MLXSW_REG_TNPC_ID 0xA020
10820#define MLXSW_REG_TNPC_LEN 0x18
10821
10822MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
10823
Ido Schimmel50e6eb22018-10-11 07:48:00 +000010824/* reg_tnpc_tunnel_port
10825 * Tunnel port.
10826 * Access: Index
10827 */
10828MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
10829
10830/* reg_tnpc_learn_enable_v6
10831 * During IPv6 underlay decapsulation, whether to learn from tunnel port.
10832 * Access: RW
10833 */
10834MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
10835
10836/* reg_tnpc_learn_enable_v4
10837 * During IPv4 underlay decapsulation, whether to learn from tunnel port.
10838 * Access: RW
10839 */
10840MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
10841
10842static inline void mlxsw_reg_tnpc_pack(char *payload,
Amit Cohen02c3b5c2020-12-08 11:22:41 +020010843 enum mlxsw_reg_tunnel_port tport,
Ido Schimmel50e6eb22018-10-11 07:48:00 +000010844 bool learn_enable)
10845{
10846 MLXSW_REG_ZERO(tnpc, payload);
10847 mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
10848 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
10849 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
10850}
10851
Petr Machata14aefd92017-10-20 09:16:15 +020010852/* TIGCR - Tunneling IPinIP General Configuration Register
10853 * -------------------------------------------------------
10854 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
10855 */
10856#define MLXSW_REG_TIGCR_ID 0xA801
10857#define MLXSW_REG_TIGCR_LEN 0x10
10858
10859MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
10860
10861/* reg_tigcr_ipip_ttlc
10862 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
10863 * header.
10864 * Access: RW
10865 */
10866MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
10867
10868/* reg_tigcr_ipip_ttl_uc
10869 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
10870 * reg_tigcr_ipip_ttlc is unset.
10871 * Access: RW
10872 */
10873MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
10874
10875static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
10876{
10877 MLXSW_REG_ZERO(tigcr, payload);
10878 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
10879 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
10880}
10881
Amit Cohen20174902020-01-19 15:00:50 +020010882/* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register
10883 * -----------------------------------------------------------
10884 * The TIEEM register maps ECN of the IP header at the ingress to the
10885 * encapsulation to the ECN of the underlay network.
10886 */
10887#define MLXSW_REG_TIEEM_ID 0xA812
10888#define MLXSW_REG_TIEEM_LEN 0x0C
10889
10890MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
10891
10892/* reg_tieem_overlay_ecn
10893 * ECN of the IP header in the overlay network.
10894 * Access: Index
10895 */
10896MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
10897
10898/* reg_tineem_underlay_ecn
10899 * ECN of the IP header in the underlay network.
10900 * Access: RW
10901 */
10902MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
10903
10904static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
10905 u8 underlay_ecn)
10906{
10907 MLXSW_REG_ZERO(tieem, payload);
10908 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
10909 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
10910}
10911
Amit Cohen839607e2020-01-19 15:00:51 +020010912/* TIDEM - Tunneling IPinIP Decapsulation ECN Mapping Register
10913 * -----------------------------------------------------------
10914 * The TIDEM register configures the actions that are done in the
10915 * decapsulation.
10916 */
10917#define MLXSW_REG_TIDEM_ID 0xA813
10918#define MLXSW_REG_TIDEM_LEN 0x0C
10919
10920MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN);
10921
10922/* reg_tidem_underlay_ecn
10923 * ECN field of the IP header in the underlay network.
10924 * Access: Index
10925 */
10926MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2);
10927
10928/* reg_tidem_overlay_ecn
10929 * ECN field of the IP header in the overlay network.
10930 * Access: Index
10931 */
10932MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2);
10933
10934/* reg_tidem_eip_ecn
10935 * Egress IP ECN. ECN field of the IP header of the packet which goes out
10936 * from the decapsulation.
10937 * Access: RW
10938 */
10939MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2);
10940
10941/* reg_tidem_trap_en
10942 * Trap enable:
10943 * 0 - No trap due to decap ECN
10944 * 1 - Trap enable with trap_id
10945 * Access: RW
10946 */
10947MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4);
10948
10949/* reg_tidem_trap_id
10950 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
10951 * Reserved when trap_en is '0'.
10952 * Access: RW
10953 */
10954MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9);
10955
10956static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn,
10957 u8 overlay_ecn, u8 eip_ecn,
10958 bool trap_en, u16 trap_id)
10959{
10960 MLXSW_REG_ZERO(tidem, payload);
10961 mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn);
10962 mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn);
10963 mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn);
10964 mlxsw_reg_tidem_trap_en_set(payload, trap_en);
10965 mlxsw_reg_tidem_trap_id_set(payload, trap_id);
10966}
10967
Jiri Pirkoe0594362015-10-16 14:01:31 +020010968/* SBPR - Shared Buffer Pools Register
10969 * -----------------------------------
10970 * The SBPR configures and retrieves the shared buffer pools and configuration.
10971 */
10972#define MLXSW_REG_SBPR_ID 0xB001
10973#define MLXSW_REG_SBPR_LEN 0x14
10974
Jiri Pirko21978dc2016-10-21 16:07:20 +020010975MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010976
Jiri Pirko497e8592016-04-08 19:11:24 +020010977/* shared direstion enum for SBPR, SBCM, SBPM */
10978enum mlxsw_reg_sbxx_dir {
10979 MLXSW_REG_SBXX_DIR_INGRESS,
10980 MLXSW_REG_SBXX_DIR_EGRESS,
Jiri Pirkoe0594362015-10-16 14:01:31 +020010981};
10982
10983/* reg_sbpr_dir
10984 * Direction.
10985 * Access: Index
10986 */
10987MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
10988
10989/* reg_sbpr_pool
10990 * Pool index.
10991 * Access: Index
10992 */
10993MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
10994
Petr Machataf0024f02018-09-20 09:21:28 +030010995/* reg_sbpr_infi_size
10996 * Size is infinite.
10997 * Access: RW
10998 */
10999MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
11000
Jiri Pirkoe0594362015-10-16 14:01:31 +020011001/* reg_sbpr_size
11002 * Pool size in buffer cells.
Petr Machataf0024f02018-09-20 09:21:28 +030011003 * Reserved when infi_size = 1.
Jiri Pirkoe0594362015-10-16 14:01:31 +020011004 * Access: RW
11005 */
11006MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
11007
11008enum mlxsw_reg_sbpr_mode {
11009 MLXSW_REG_SBPR_MODE_STATIC,
11010 MLXSW_REG_SBPR_MODE_DYNAMIC,
11011};
11012
11013/* reg_sbpr_mode
11014 * Pool quota calculation mode.
11015 * Access: RW
11016 */
11017MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
11018
11019static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
Jiri Pirko497e8592016-04-08 19:11:24 +020011020 enum mlxsw_reg_sbxx_dir dir,
Petr Machataf0024f02018-09-20 09:21:28 +030011021 enum mlxsw_reg_sbpr_mode mode, u32 size,
11022 bool infi_size)
Jiri Pirkoe0594362015-10-16 14:01:31 +020011023{
11024 MLXSW_REG_ZERO(sbpr, payload);
11025 mlxsw_reg_sbpr_pool_set(payload, pool);
11026 mlxsw_reg_sbpr_dir_set(payload, dir);
11027 mlxsw_reg_sbpr_mode_set(payload, mode);
11028 mlxsw_reg_sbpr_size_set(payload, size);
Petr Machataf0024f02018-09-20 09:21:28 +030011029 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
Jiri Pirkoe0594362015-10-16 14:01:31 +020011030}
11031
11032/* SBCM - Shared Buffer Class Management Register
11033 * ----------------------------------------------
11034 * The SBCM register configures and retrieves the shared buffer allocation
11035 * and configuration according to Port-PG, including the binding to pool
11036 * and definition of the associated quota.
11037 */
11038#define MLXSW_REG_SBCM_ID 0xB002
11039#define MLXSW_REG_SBCM_LEN 0x28
11040
Jiri Pirko21978dc2016-10-21 16:07:20 +020011041MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020011042
11043/* reg_sbcm_local_port
11044 * Local port number.
11045 * For Ingress: excludes CPU port and Router port
11046 * For Egress: excludes IP Router
11047 * Access: Index
11048 */
11049MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
11050
11051/* reg_sbcm_pg_buff
11052 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
11053 * For PG buffer: range is 0..cap_max_pg_buffers - 1
11054 * For traffic class: range is 0..cap_max_tclass - 1
11055 * Note that when traffic class is in MC aware mode then the traffic
11056 * classes which are MC aware cannot be configured.
11057 * Access: Index
11058 */
11059MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
11060
Jiri Pirkoe0594362015-10-16 14:01:31 +020011061/* reg_sbcm_dir
11062 * Direction.
11063 * Access: Index
11064 */
11065MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
11066
11067/* reg_sbcm_min_buff
11068 * Minimum buffer size for the limiter, in cells.
11069 * Access: RW
11070 */
11071MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
11072
Jiri Pirkoc30a53c2016-04-14 18:19:22 +020011073/* shared max_buff limits for dynamic threshold for SBCM, SBPM */
11074#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
11075#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
11076
Petr Machatad144e3a2018-09-20 09:21:29 +030011077/* reg_sbcm_infi_max
11078 * Max buffer is infinite.
11079 * Access: RW
11080 */
11081MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
11082
Jiri Pirkoe0594362015-10-16 14:01:31 +020011083/* reg_sbcm_max_buff
11084 * When the pool associated to the port-pg/tclass is configured to
11085 * static, Maximum buffer size for the limiter configured in cells.
11086 * When the pool associated to the port-pg/tclass is configured to
11087 * dynamic, the max_buff holds the "alpha" parameter, supporting
11088 * the following values:
11089 * 0: 0
11090 * i: (1/128)*2^(i-1), for i=1..14
11091 * 0xFF: Infinity
Petr Machatad144e3a2018-09-20 09:21:29 +030011092 * Reserved when infi_max = 1.
Jiri Pirkoe0594362015-10-16 14:01:31 +020011093 * Access: RW
11094 */
11095MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
11096
11097/* reg_sbcm_pool
11098 * Association of the port-priority to a pool.
11099 * Access: RW
11100 */
11101MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
11102
11103static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
Jiri Pirko497e8592016-04-08 19:11:24 +020011104 enum mlxsw_reg_sbxx_dir dir,
Petr Machatad144e3a2018-09-20 09:21:29 +030011105 u32 min_buff, u32 max_buff,
11106 bool infi_max, u8 pool)
Jiri Pirkoe0594362015-10-16 14:01:31 +020011107{
11108 MLXSW_REG_ZERO(sbcm, payload);
11109 mlxsw_reg_sbcm_local_port_set(payload, local_port);
11110 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
11111 mlxsw_reg_sbcm_dir_set(payload, dir);
11112 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
11113 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
Petr Machatad144e3a2018-09-20 09:21:29 +030011114 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
Jiri Pirkoe0594362015-10-16 14:01:31 +020011115 mlxsw_reg_sbcm_pool_set(payload, pool);
11116}
11117
Jiri Pirko9efc8f62016-04-08 19:11:25 +020011118/* SBPM - Shared Buffer Port Management Register
11119 * ---------------------------------------------
Jiri Pirkoe0594362015-10-16 14:01:31 +020011120 * The SBPM register configures and retrieves the shared buffer allocation
11121 * and configuration according to Port-Pool, including the definition
11122 * of the associated quota.
11123 */
11124#define MLXSW_REG_SBPM_ID 0xB003
11125#define MLXSW_REG_SBPM_LEN 0x28
11126
Jiri Pirko21978dc2016-10-21 16:07:20 +020011127MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020011128
11129/* reg_sbpm_local_port
11130 * Local port number.
11131 * For Ingress: excludes CPU port and Router port
11132 * For Egress: excludes IP Router
11133 * Access: Index
11134 */
11135MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
11136
11137/* reg_sbpm_pool
11138 * The pool associated to quota counting on the local_port.
11139 * Access: Index
11140 */
11141MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
11142
Jiri Pirkoe0594362015-10-16 14:01:31 +020011143/* reg_sbpm_dir
11144 * Direction.
11145 * Access: Index
11146 */
11147MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
11148
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020011149/* reg_sbpm_buff_occupancy
11150 * Current buffer occupancy in cells.
11151 * Access: RO
11152 */
11153MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
11154
11155/* reg_sbpm_clr
11156 * Clear Max Buffer Occupancy
11157 * When this bit is set, max_buff_occupancy field is cleared (and a
11158 * new max value is tracked from the time the clear was performed).
11159 * Access: OP
11160 */
11161MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
11162
11163/* reg_sbpm_max_buff_occupancy
11164 * Maximum value of buffer occupancy in cells monitored. Cleared by
11165 * writing to the clr field.
11166 * Access: RO
11167 */
11168MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
11169
Jiri Pirkoe0594362015-10-16 14:01:31 +020011170/* reg_sbpm_min_buff
11171 * Minimum buffer size for the limiter, in cells.
11172 * Access: RW
11173 */
11174MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
11175
11176/* reg_sbpm_max_buff
11177 * When the pool associated to the port-pg/tclass is configured to
11178 * static, Maximum buffer size for the limiter configured in cells.
11179 * When the pool associated to the port-pg/tclass is configured to
11180 * dynamic, the max_buff holds the "alpha" parameter, supporting
11181 * the following values:
11182 * 0: 0
11183 * i: (1/128)*2^(i-1), for i=1..14
11184 * 0xFF: Infinity
11185 * Access: RW
11186 */
11187MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
11188
11189static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020011190 enum mlxsw_reg_sbxx_dir dir, bool clr,
Jiri Pirkoe0594362015-10-16 14:01:31 +020011191 u32 min_buff, u32 max_buff)
11192{
11193 MLXSW_REG_ZERO(sbpm, payload);
11194 mlxsw_reg_sbpm_local_port_set(payload, local_port);
11195 mlxsw_reg_sbpm_pool_set(payload, pool);
11196 mlxsw_reg_sbpm_dir_set(payload, dir);
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020011197 mlxsw_reg_sbpm_clr_set(payload, clr);
Jiri Pirkoe0594362015-10-16 14:01:31 +020011198 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
11199 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
11200}
11201
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020011202static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
11203 u32 *p_max_buff_occupancy)
11204{
11205 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
11206 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
11207}
11208
Jiri Pirkoe0594362015-10-16 14:01:31 +020011209/* SBMM - Shared Buffer Multicast Management Register
11210 * --------------------------------------------------
11211 * The SBMM register configures and retrieves the shared buffer allocation
11212 * and configuration for MC packets according to Switch-Priority, including
11213 * the binding to pool and definition of the associated quota.
11214 */
11215#define MLXSW_REG_SBMM_ID 0xB004
11216#define MLXSW_REG_SBMM_LEN 0x28
11217
Jiri Pirko21978dc2016-10-21 16:07:20 +020011218MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020011219
11220/* reg_sbmm_prio
11221 * Switch Priority.
11222 * Access: Index
11223 */
11224MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
11225
11226/* reg_sbmm_min_buff
11227 * Minimum buffer size for the limiter, in cells.
11228 * Access: RW
11229 */
11230MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
11231
11232/* reg_sbmm_max_buff
11233 * When the pool associated to the port-pg/tclass is configured to
11234 * static, Maximum buffer size for the limiter configured in cells.
11235 * When the pool associated to the port-pg/tclass is configured to
11236 * dynamic, the max_buff holds the "alpha" parameter, supporting
11237 * the following values:
11238 * 0: 0
11239 * i: (1/128)*2^(i-1), for i=1..14
11240 * 0xFF: Infinity
11241 * Access: RW
11242 */
11243MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
11244
11245/* reg_sbmm_pool
11246 * Association of the port-priority to a pool.
11247 * Access: RW
11248 */
11249MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
11250
11251static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
11252 u32 max_buff, u8 pool)
11253{
11254 MLXSW_REG_ZERO(sbmm, payload);
11255 mlxsw_reg_sbmm_prio_set(payload, prio);
11256 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
11257 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
11258 mlxsw_reg_sbmm_pool_set(payload, pool);
11259}
11260
Jiri Pirko26176de2016-04-14 18:19:26 +020011261/* SBSR - Shared Buffer Status Register
11262 * ------------------------------------
11263 * The SBSR register retrieves the shared buffer occupancy according to
11264 * Port-Pool. Note that this register enables reading a large amount of data.
11265 * It is the user's responsibility to limit the amount of data to ensure the
11266 * response can match the maximum transfer unit. In case the response exceeds
11267 * the maximum transport unit, it will be truncated with no special notice.
11268 */
11269#define MLXSW_REG_SBSR_ID 0xB005
11270#define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
11271#define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
11272#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
11273#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
11274 MLXSW_REG_SBSR_REC_LEN * \
11275 MLXSW_REG_SBSR_REC_MAX_COUNT)
11276
Jiri Pirko21978dc2016-10-21 16:07:20 +020011277MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
Jiri Pirko26176de2016-04-14 18:19:26 +020011278
11279/* reg_sbsr_clr
11280 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
11281 * field is cleared (and a new max value is tracked from the time the clear
11282 * was performed).
11283 * Access: OP
11284 */
11285MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
11286
11287/* reg_sbsr_ingress_port_mask
11288 * Bit vector for all ingress network ports.
11289 * Indicates which of the ports (for which the relevant bit is set)
11290 * are affected by the set operation. Configuration of any other port
11291 * does not change.
11292 * Access: Index
11293 */
11294MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
11295
11296/* reg_sbsr_pg_buff_mask
11297 * Bit vector for all switch priority groups.
11298 * Indicates which of the priorities (for which the relevant bit is set)
11299 * are affected by the set operation. Configuration of any other priority
11300 * does not change.
11301 * Range is 0..cap_max_pg_buffers - 1
11302 * Access: Index
11303 */
11304MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
11305
11306/* reg_sbsr_egress_port_mask
11307 * Bit vector for all egress network ports.
11308 * Indicates which of the ports (for which the relevant bit is set)
11309 * are affected by the set operation. Configuration of any other port
11310 * does not change.
11311 * Access: Index
11312 */
11313MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
11314
11315/* reg_sbsr_tclass_mask
11316 * Bit vector for all traffic classes.
11317 * Indicates which of the traffic classes (for which the relevant bit is
11318 * set) are affected by the set operation. Configuration of any other
11319 * traffic class does not change.
11320 * Range is 0..cap_max_tclass - 1
11321 * Access: Index
11322 */
11323MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
11324
11325static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
11326{
11327 MLXSW_REG_ZERO(sbsr, payload);
11328 mlxsw_reg_sbsr_clr_set(payload, clr);
11329}
11330
11331/* reg_sbsr_rec_buff_occupancy
11332 * Current buffer occupancy in cells.
11333 * Access: RO
11334 */
11335MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
11336 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
11337
11338/* reg_sbsr_rec_max_buff_occupancy
11339 * Maximum value of buffer occupancy in cells monitored. Cleared by
11340 * writing to the clr field.
11341 * Access: RO
11342 */
11343MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
11344 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
11345
11346static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
11347 u32 *p_buff_occupancy,
11348 u32 *p_max_buff_occupancy)
11349{
11350 *p_buff_occupancy =
11351 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
11352 *p_max_buff_occupancy =
11353 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
11354}
11355
Yotam Gigi51ae8cc2016-07-21 12:03:13 +020011356/* SBIB - Shared Buffer Internal Buffer Register
11357 * ---------------------------------------------
11358 * The SBIB register configures per port buffers for internal use. The internal
11359 * buffers consume memory on the port buffers (note that the port buffers are
11360 * used also by PBMC).
11361 *
11362 * For Spectrum this is used for egress mirroring.
11363 */
11364#define MLXSW_REG_SBIB_ID 0xB006
11365#define MLXSW_REG_SBIB_LEN 0x10
11366
Jiri Pirko21978dc2016-10-21 16:07:20 +020011367MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
Yotam Gigi51ae8cc2016-07-21 12:03:13 +020011368
11369/* reg_sbib_local_port
11370 * Local port number
11371 * Not supported for CPU port and router port
11372 * Access: Index
11373 */
11374MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
11375
11376/* reg_sbib_buff_size
11377 * Units represented in cells
11378 * Allowed range is 0 to (cap_max_headroom_size - 1)
11379 * Default is 0
11380 * Access: RW
11381 */
11382MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
11383
11384static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
11385 u32 buff_size)
11386{
11387 MLXSW_REG_ZERO(sbib, payload);
11388 mlxsw_reg_sbib_local_port_set(payload, local_port);
11389 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
11390}
11391
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011392static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
11393 MLXSW_REG(sgcr),
11394 MLXSW_REG(spad),
11395 MLXSW_REG(smid),
11396 MLXSW_REG(sspr),
11397 MLXSW_REG(sfdat),
11398 MLXSW_REG(sfd),
11399 MLXSW_REG(sfn),
11400 MLXSW_REG(spms),
11401 MLXSW_REG(spvid),
11402 MLXSW_REG(spvm),
11403 MLXSW_REG(spaft),
11404 MLXSW_REG(sfgc),
11405 MLXSW_REG(sftr),
11406 MLXSW_REG(sfdf),
11407 MLXSW_REG(sldr),
11408 MLXSW_REG(slcr),
11409 MLXSW_REG(slcor),
11410 MLXSW_REG(spmlr),
11411 MLXSW_REG(svfa),
Amit Cohenc1c32a72020-12-08 11:22:42 +020011412 MLXSW_REG(spvtr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011413 MLXSW_REG(svpe),
11414 MLXSW_REG(sfmr),
11415 MLXSW_REG(spvmlr),
Amit Cohen7e9a6622020-11-29 14:53:59 +020011416 MLXSW_REG(spvc),
Nogah Frankelad53fa02017-11-06 07:23:44 +010011417 MLXSW_REG(cwtp),
11418 MLXSW_REG(cwtpm),
Ido Schimmel7050f432018-07-18 11:14:40 +030011419 MLXSW_REG(pgcr),
Jiri Pirkoaf7170e2017-02-03 10:28:57 +010011420 MLXSW_REG(ppbt),
Jiri Pirko3279da42017-02-03 10:28:53 +010011421 MLXSW_REG(pacl),
Jiri Pirko10fabef2017-02-03 10:28:54 +010011422 MLXSW_REG(pagt),
Jiri Pirkod9c26612017-02-03 10:28:55 +010011423 MLXSW_REG(ptar),
Jiri Pirkod1206492017-02-03 10:28:59 +010011424 MLXSW_REG(ppbs),
Jiri Pirko937b6822017-02-03 10:28:58 +010011425 MLXSW_REG(prcr),
Jiri Pirkoe3426e12017-02-03 10:29:00 +010011426 MLXSW_REG(pefa),
Nir Dotana75e41d2018-12-10 07:11:33 +000011427 MLXSW_REG(pemrbt),
Jiri Pirko0171cdec2017-02-03 10:28:56 +010011428 MLXSW_REG(ptce2),
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +030011429 MLXSW_REG(perpt),
Nir Dotan418089a2018-12-16 08:49:24 +000011430 MLXSW_REG(peabfe),
Jiri Pirko33907872018-07-18 11:14:37 +030011431 MLXSW_REG(perar),
Ido Schimmelaecefac2018-07-25 09:23:51 +030011432 MLXSW_REG(ptce3),
Ido Schimmel481662a2018-07-18 11:14:38 +030011433 MLXSW_REG(percr),
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +030011434 MLXSW_REG(pererp),
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +030011435 MLXSW_REG(iedr),
Petr Machata746da422018-07-27 15:26:58 +030011436 MLXSW_REG(qpts),
Nogah Frankel76a4c7d2016-11-25 10:33:46 +010011437 MLXSW_REG(qpcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011438 MLXSW_REG(qtct),
11439 MLXSW_REG(qeec),
Petr Machatae67131d2018-07-27 15:26:59 +030011440 MLXSW_REG(qrwe),
Petr Machata55fb71f2018-07-27 15:27:00 +030011441 MLXSW_REG(qpdsm),
Petr Machatad8446882019-12-29 13:48:27 +020011442 MLXSW_REG(qpdp),
Petr Machata02837d72018-07-27 15:26:57 +030011443 MLXSW_REG(qpdpm),
Petr Machata671ae8a2018-08-05 09:03:06 +030011444 MLXSW_REG(qtctm),
Shalom Toledo71147502019-07-04 10:07:35 +030011445 MLXSW_REG(qpsc),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011446 MLXSW_REG(pmlp),
11447 MLXSW_REG(pmtu),
11448 MLXSW_REG(ptys),
11449 MLXSW_REG(ppad),
11450 MLXSW_REG(paos),
11451 MLXSW_REG(pfcc),
11452 MLXSW_REG(ppcnt),
Elad Raz71367932016-10-28 21:35:54 +020011453 MLXSW_REG(plib),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011454 MLXSW_REG(pptb),
11455 MLXSW_REG(pbmc),
11456 MLXSW_REG(pspa),
Amit Cohen02d33b42020-09-27 10:50:08 +030011457 MLXSW_REG(pmaos),
Jiri Pirkoa0c25382019-05-05 09:48:05 +030011458 MLXSW_REG(pplr),
Amit Cohene7d62a32020-09-27 10:50:07 +030011459 MLXSW_REG(pmpe),
Amit Cohen1bd06932020-06-29 23:46:17 +030011460 MLXSW_REG(pddr),
Jiri Pirkoa513b1a2019-10-31 11:42:07 +020011461 MLXSW_REG(pmtm),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011462 MLXSW_REG(htgt),
11463 MLXSW_REG(hpkt),
11464 MLXSW_REG(rgcr),
11465 MLXSW_REG(ritr),
Yotam Gigi46a70542017-09-19 10:00:13 +020011466 MLXSW_REG(rtar),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011467 MLXSW_REG(ratr),
Petr Machata1e659eb2017-09-02 23:49:13 +020011468 MLXSW_REG(rtdp),
Yuval Mintzddb362c2018-01-14 12:33:13 +010011469 MLXSW_REG(rdpm),
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +020011470 MLXSW_REG(ricnt),
Yotam Gigi4fc92842017-09-19 10:00:17 +020011471 MLXSW_REG(rrcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011472 MLXSW_REG(ralta),
11473 MLXSW_REG(ralst),
11474 MLXSW_REG(raltb),
11475 MLXSW_REG(ralue),
11476 MLXSW_REG(rauht),
11477 MLXSW_REG(raleu),
11478 MLXSW_REG(rauhtd),
Yotam Gigi5080c7e2017-09-19 10:00:14 +020011479 MLXSW_REG(rigr2),
Ido Schimmele4718592017-11-02 17:14:08 +010011480 MLXSW_REG(recr2),
Yotam Gigi2e654e32017-09-19 10:00:16 +020011481 MLXSW_REG(rmft2),
Jiri Pirkofb281f22020-11-01 15:42:14 +020011482 MLXSW_REG(xralta),
11483 MLXSW_REG(xralst),
11484 MLXSW_REG(xraltb),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011485 MLXSW_REG(mfcr),
11486 MLXSW_REG(mfsc),
11487 MLXSW_REG(mfsm),
Jiri Pirko55c63aa2016-11-22 11:24:12 +010011488 MLXSW_REG(mfsl),
Vadim Pasternak3760c2b2019-02-13 11:28:46 +000011489 MLXSW_REG(fore),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011490 MLXSW_REG(mtcap),
11491 MLXSW_REG(mtmp),
Amit Cohen946bd432020-09-27 10:50:06 +030011492 MLXSW_REG(mtwe),
Vadim Pasternak5f28ef72019-02-13 11:28:45 +000011493 MLXSW_REG(mtbr),
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +020011494 MLXSW_REG(mcia),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011495 MLXSW_REG(mpat),
11496 MLXSW_REG(mpar),
Shalom Toledo8d77d4b2019-04-08 06:59:34 +000011497 MLXSW_REG(mgir),
Jiri Pirko12b003b2018-05-27 09:56:13 +030011498 MLXSW_REG(mrsr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011499 MLXSW_REG(mlcr),
Shalom Toledo10786452019-06-11 18:45:08 +030011500 MLXSW_REG(mtpps),
Shalom Toledo55a8b002019-06-11 18:45:07 +030011501 MLXSW_REG(mtutc),
Yotam Gigi0677d682017-01-23 11:07:10 +010011502 MLXSW_REG(mpsc),
Yotam Gigi4f2402d2017-05-23 21:56:24 +020011503 MLXSW_REG(mcqi),
Yotam Gigi191839d2017-05-23 21:56:25 +020011504 MLXSW_REG(mcc),
Yotam Gigi4625d592017-05-23 21:56:26 +020011505 MLXSW_REG(mcda),
Arkadi Sharshevsky57665322017-03-11 09:42:52 +010011506 MLXSW_REG(mgpc),
Ido Schimmel27f68c02018-10-11 07:48:08 +000011507 MLXSW_REG(mprs),
Petr Machata41ce78b2019-06-30 09:04:48 +030011508 MLXSW_REG(mogcr),
Amit Cohenc0e39692020-07-11 00:55:05 +030011509 MLXSW_REG(mpagr),
Amit Cohen951b84d2020-07-11 00:55:04 +030011510 MLXSW_REG(momte),
Petr Machatada28e872019-06-30 09:04:45 +030011511 MLXSW_REG(mtpppc),
Petr Machata98b90282019-06-30 09:04:47 +030011512 MLXSW_REG(mtpptr),
Petr Machata4dfecb62019-06-30 09:04:46 +030011513 MLXSW_REG(mtptpt),
Jiri Pirko191c0c22020-09-15 11:40:56 +030011514 MLXSW_REG(mfgd),
Vadim Pasternak7e9561e2019-05-29 11:47:19 +030011515 MLXSW_REG(mgpir),
Jiri Pirko6ddac9d2020-09-15 11:40:55 +030011516 MLXSW_REG(mfde),
Ido Schimmel710dd1a2018-10-11 07:47:59 +000011517 MLXSW_REG(tngcr),
Ido Schimmelc723d192018-10-11 07:48:01 +000011518 MLXSW_REG(tnumt),
Ido Schimmelfd6db272018-10-11 07:48:04 +000011519 MLXSW_REG(tnqcr),
Ido Schimmel8efcf6b2018-10-11 07:48:06 +000011520 MLXSW_REG(tnqdr),
Ido Schimmel4a8d1862018-10-11 07:48:02 +000011521 MLXSW_REG(tneem),
Ido Schimmela77d5f02018-10-11 07:48:03 +000011522 MLXSW_REG(tndem),
Ido Schimmel50e6eb22018-10-11 07:48:00 +000011523 MLXSW_REG(tnpc),
Petr Machata14aefd92017-10-20 09:16:15 +020011524 MLXSW_REG(tigcr),
Amit Cohen20174902020-01-19 15:00:50 +020011525 MLXSW_REG(tieem),
Amit Cohen839607e2020-01-19 15:00:51 +020011526 MLXSW_REG(tidem),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011527 MLXSW_REG(sbpr),
11528 MLXSW_REG(sbcm),
11529 MLXSW_REG(sbpm),
11530 MLXSW_REG(sbmm),
11531 MLXSW_REG(sbsr),
11532 MLXSW_REG(sbib),
11533};
11534
Ido Schimmel4ec14b72015-07-29 23:33:48 +020011535static inline const char *mlxsw_reg_id_str(u16 reg_id)
11536{
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011537 const struct mlxsw_reg_info *reg_info;
11538 int i;
11539
11540 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
11541 reg_info = mlxsw_reg_infos[i];
11542 if (reg_info->id == reg_id)
11543 return reg_info->name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +020011544 }
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011545 return "*UNKNOWN*";
Ido Schimmel4ec14b72015-07-29 23:33:48 +020011546}
11547
11548/* PUDE - Port Up / Down Event
11549 * ---------------------------
11550 * Reports the operational state change of a port.
11551 */
11552#define MLXSW_REG_PUDE_LEN 0x10
11553
11554/* reg_pude_swid
11555 * Switch partition ID with which to associate the port.
11556 * Access: Index
11557 */
11558MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
11559
11560/* reg_pude_local_port
11561 * Local port number.
11562 * Access: Index
11563 */
11564MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
11565
11566/* reg_pude_admin_status
11567 * Port administrative state (the desired state).
11568 * 1 - Up.
11569 * 2 - Down.
11570 * 3 - Up once. This means that in case of link failure, the port won't go
11571 * into polling mode, but will wait to be re-enabled by software.
11572 * 4 - Disabled by system. Can only be set by hardware.
11573 * Access: RO
11574 */
11575MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
11576
11577/* reg_pude_oper_status
11578 * Port operatioanl state.
11579 * 1 - Up.
11580 * 2 - Down.
11581 * 3 - Down by port failure. This means that the device will not let the
11582 * port up again until explicitly specified by software.
11583 * Access: RO
11584 */
11585MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
11586
11587#endif