blob: 5878f14a65387e1b799a88595884c5007e38fcb2 [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
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200584/* SFN - Switch FDB Notification Register
585 * -------------------------------------------
586 * The switch provides notifications on newly learned FDB entries and
587 * aged out entries. The notifications can be polled by software.
588 */
589#define MLXSW_REG_SFN_ID 0x200B
590#define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
591#define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
592#define MLXSW_REG_SFN_REC_MAX_COUNT 64
593#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
594 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
595
Jiri Pirko21978dc2016-10-21 16:07:20 +0200596MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200597
598/* reg_sfn_swid
599 * Switch partition ID.
600 * Access: Index
601 */
602MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
603
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200604/* reg_sfn_end
605 * Forces the current session to end.
606 * Access: OP
607 */
608MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
609
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200610/* reg_sfn_num_rec
611 * Request: Number of learned notifications and aged-out notification
612 * records requested.
613 * Response: Number of notification records returned (must be smaller
614 * than or equal to the value requested)
615 * Ranges 0..64
616 * Access: OP
617 */
618MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
619
620static inline void mlxsw_reg_sfn_pack(char *payload)
621{
622 MLXSW_REG_ZERO(sfn, payload);
623 mlxsw_reg_sfn_swid_set(payload, 0);
Jiri Pirko648e53c2020-02-26 09:39:17 +0100624 mlxsw_reg_sfn_end_set(payload, 0);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200625 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
626}
627
628/* reg_sfn_rec_swid
629 * Switch partition ID.
630 * Access: RO
631 */
632MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
633 MLXSW_REG_SFN_REC_LEN, 0x00, false);
634
635enum mlxsw_reg_sfn_rec_type {
636 /* MAC addresses learned on a regular port. */
637 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
Jiri Pirko3b715712015-12-03 12:12:27 +0100638 /* MAC addresses learned on a LAG port. */
639 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
640 /* Aged-out MAC address on a regular port. */
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200641 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
Jiri Pirko3b715712015-12-03 12:12:27 +0100642 /* Aged-out MAC address on a LAG port. */
643 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
Ido Schimmel933b1ec2018-11-21 08:02:42 +0000644 /* Learned unicast tunnel record. */
645 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
646 /* Aged-out unicast tunnel record. */
647 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200648};
649
650/* reg_sfn_rec_type
651 * Notification record type.
652 * Access: RO
653 */
654MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
655 MLXSW_REG_SFN_REC_LEN, 0x00, false);
656
657/* reg_sfn_rec_mac
658 * MAC address.
659 * Access: RO
660 */
661MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
662 MLXSW_REG_SFN_REC_LEN, 0x02);
663
Jiri Pirko8316f082015-10-28 10:17:00 +0100664/* reg_sfn_mac_sub_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200665 * VEPA channel on the local port.
666 * 0 if multichannel VEPA is not enabled.
667 * Access: RO
668 */
669MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
670 MLXSW_REG_SFN_REC_LEN, 0x08, false);
671
Jiri Pirko8316f082015-10-28 10:17:00 +0100672/* reg_sfn_mac_fid
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200673 * Filtering identifier.
674 * Access: RO
675 */
676MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
677 MLXSW_REG_SFN_REC_LEN, 0x08, false);
678
Jiri Pirko8316f082015-10-28 10:17:00 +0100679/* reg_sfn_mac_system_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200680 * Unique port identifier for the final destination of the packet.
681 * Access: RO
682 */
683MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
684 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
685
686static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
687 char *mac, u16 *p_vid,
688 u8 *p_local_port)
689{
690 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
691 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
692 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
693}
694
Jiri Pirko3b715712015-12-03 12:12:27 +0100695/* reg_sfn_mac_lag_lag_id
696 * LAG ID (pointer into the LAG descriptor table).
697 * Access: RO
698 */
699MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
700 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
701
702static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
703 char *mac, u16 *p_vid,
704 u16 *p_lag_id)
705{
706 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
707 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
708 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
709}
710
Ido Schimmel933b1ec2018-11-21 08:02:42 +0000711/* reg_sfn_uc_tunnel_uip_msb
712 * When protocol is IPv4, the most significant byte of the underlay IPv4
713 * address of the remote VTEP.
714 * When protocol is IPv6, reserved.
715 * Access: RO
716 */
717MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
718 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
719
720enum mlxsw_reg_sfn_uc_tunnel_protocol {
721 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
722 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
723};
724
725/* reg_sfn_uc_tunnel_protocol
726 * IP protocol.
727 * Access: RO
728 */
729MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
730 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
731
732/* reg_sfn_uc_tunnel_uip_lsb
733 * When protocol is IPv4, the least significant bytes of the underlay
734 * IPv4 address of the remote VTEP.
735 * When protocol is IPv6, ipv6_id to be queried from TNIPSD.
736 * Access: RO
737 */
738MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
739 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
740
741enum mlxsw_reg_sfn_tunnel_port {
742 MLXSW_REG_SFN_TUNNEL_PORT_NVE,
743 MLXSW_REG_SFN_TUNNEL_PORT_VPLS,
744 MLXSW_REG_SFN_TUNNEL_FLEX_TUNNEL0,
745 MLXSW_REG_SFN_TUNNEL_FLEX_TUNNEL1,
746};
747
748/* 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
837/* reg_spvid_pvid
838 * Port default VID
839 * Access: RW
840 */
841MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
842
843static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
844{
845 MLXSW_REG_ZERO(spvid, payload);
846 mlxsw_reg_spvid_local_port_set(payload, local_port);
847 mlxsw_reg_spvid_pvid_set(payload, pvid);
848}
849
850/* SPVM - Switch Port VLAN Membership
851 * ----------------------------------
852 * The Switch Port VLAN Membership register configures the VLAN membership
853 * of a port in a VLAN denoted by VID. VLAN membership is managed per
854 * virtual port. The register can be used to add and remove VID(s) from a port.
855 */
856#define MLXSW_REG_SPVM_ID 0x200F
857#define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
858#define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
Jiri Pirkof004ec02017-03-14 14:00:00 +0100859#define MLXSW_REG_SPVM_REC_MAX_COUNT 255
Elad Razb2e345f2015-10-16 14:01:30 +0200860#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
861 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
862
Jiri Pirko21978dc2016-10-21 16:07:20 +0200863MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200864
865/* reg_spvm_pt
866 * Priority tagged. If this bit is set, packets forwarded to the port with
867 * untagged VLAN membership (u bit is set) will be tagged with priority tag
868 * (VID=0)
869 * Access: RW
870 */
871MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
872
873/* reg_spvm_pte
874 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
875 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
876 * Access: WO
877 */
878MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
879
880/* reg_spvm_local_port
881 * Local port number.
882 * Access: Index
883 */
884MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
885
886/* reg_spvm_sub_port
887 * Virtual port within the physical port.
888 * Should be set to 0 when virtual ports are not enabled on the port.
889 * Access: Index
890 */
891MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
892
893/* reg_spvm_num_rec
894 * Number of records to update. Each record contains: i, e, u, vid.
895 * Access: OP
896 */
897MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
898
899/* reg_spvm_rec_i
900 * Ingress membership in VLAN ID.
901 * Access: Index
902 */
903MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
904 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
905 MLXSW_REG_SPVM_REC_LEN, 0, false);
906
907/* reg_spvm_rec_e
908 * Egress membership in VLAN ID.
909 * Access: Index
910 */
911MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
912 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
913 MLXSW_REG_SPVM_REC_LEN, 0, false);
914
915/* reg_spvm_rec_u
916 * Untagged - port is an untagged member - egress transmission uses untagged
917 * frames on VID<n>
918 * Access: Index
919 */
920MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
921 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
922 MLXSW_REG_SPVM_REC_LEN, 0, false);
923
924/* reg_spvm_rec_vid
925 * Egress membership in VLAN ID.
926 * Access: Index
927 */
928MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
929 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
930 MLXSW_REG_SPVM_REC_LEN, 0, false);
931
932static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
933 u16 vid_begin, u16 vid_end,
934 bool is_member, bool untagged)
935{
936 int size = vid_end - vid_begin + 1;
937 int i;
938
939 MLXSW_REG_ZERO(spvm, payload);
940 mlxsw_reg_spvm_local_port_set(payload, local_port);
941 mlxsw_reg_spvm_num_rec_set(payload, size);
942
943 for (i = 0; i < size; i++) {
944 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
945 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
946 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
947 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
948 }
949}
950
Ido Schimmel148f4722016-02-18 11:30:01 +0100951/* SPAFT - Switch Port Acceptable Frame Types
952 * ------------------------------------------
953 * The Switch Port Acceptable Frame Types register configures the frame
954 * admittance of the port.
955 */
956#define MLXSW_REG_SPAFT_ID 0x2010
957#define MLXSW_REG_SPAFT_LEN 0x08
958
Jiri Pirko21978dc2016-10-21 16:07:20 +0200959MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
Ido Schimmel148f4722016-02-18 11:30:01 +0100960
961/* reg_spaft_local_port
962 * Local port number.
963 * Access: Index
964 *
965 * Note: CPU port is not supported (all tag types are allowed).
966 */
967MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
968
969/* reg_spaft_sub_port
970 * Virtual port within the physical port.
971 * Should be set to 0 when virtual ports are not enabled on the port.
972 * Access: RW
973 */
974MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
975
976/* reg_spaft_allow_untagged
977 * When set, untagged frames on the ingress are allowed (default).
978 * Access: RW
979 */
980MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
981
982/* reg_spaft_allow_prio_tagged
983 * When set, priority tagged frames on the ingress are allowed (default).
984 * Access: RW
985 */
986MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
987
988/* reg_spaft_allow_tagged
989 * When set, tagged frames on the ingress are allowed (default).
990 * Access: RW
991 */
992MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
993
994static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
995 bool allow_untagged)
996{
997 MLXSW_REG_ZERO(spaft, payload);
998 mlxsw_reg_spaft_local_port_set(payload, local_port);
999 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
Ido Schimmel4b14cc32019-06-11 10:19:46 +03001000 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
Ido Schimmel148f4722016-02-18 11:30:01 +01001001 mlxsw_reg_spaft_allow_tagged_set(payload, true);
1002}
1003
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001004/* SFGC - Switch Flooding Group Configuration
1005 * ------------------------------------------
1006 * The following register controls the association of flooding tables and MIDs
1007 * to packet types used for flooding.
1008 */
Jiri Pirko36b78e82015-10-15 17:43:24 +02001009#define MLXSW_REG_SFGC_ID 0x2011
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001010#define MLXSW_REG_SFGC_LEN 0x10
1011
Jiri Pirko21978dc2016-10-21 16:07:20 +02001012MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001013
1014enum mlxsw_reg_sfgc_type {
Ido Schimmelfa6ad052015-10-15 17:43:25 +02001015 MLXSW_REG_SFGC_TYPE_BROADCAST,
1016 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
1017 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
1018 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
1019 MLXSW_REG_SFGC_TYPE_RESERVED,
1020 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
1021 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
1022 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
1023 MLXSW_REG_SFGC_TYPE_MAX,
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001024};
1025
1026/* reg_sfgc_type
1027 * The traffic type to reach the flooding table.
1028 * Access: Index
1029 */
1030MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
1031
1032enum mlxsw_reg_sfgc_bridge_type {
1033 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
1034 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
1035};
1036
1037/* reg_sfgc_bridge_type
1038 * Access: Index
1039 *
1040 * Note: SwitchX-2 only supports 802.1Q mode.
1041 */
1042MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
1043
1044enum mlxsw_flood_table_type {
1045 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
1046 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
1047 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
Ido Schimmelda0abcf2017-06-04 16:53:39 +02001048 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001049 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
1050};
1051
1052/* reg_sfgc_table_type
1053 * See mlxsw_flood_table_type
1054 * Access: RW
1055 *
1056 * Note: FID offset and FID types are not supported in SwitchX-2.
1057 */
1058MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
1059
1060/* reg_sfgc_flood_table
1061 * Flooding table index to associate with the specific type on the specific
1062 * switch partition.
1063 * Access: RW
1064 */
1065MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
1066
1067/* reg_sfgc_mid
1068 * The multicast ID for the swid. Not supported for Spectrum
1069 * Access: RW
1070 */
1071MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
1072
1073/* reg_sfgc_counter_set_type
1074 * Counter Set Type for flow counters.
1075 * Access: RW
1076 */
1077MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
1078
1079/* reg_sfgc_counter_index
1080 * Counter Index for flow counters.
1081 * Access: RW
1082 */
1083MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
1084
1085static inline void
1086mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1087 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1088 enum mlxsw_flood_table_type table_type,
1089 unsigned int flood_table)
1090{
1091 MLXSW_REG_ZERO(sfgc, payload);
1092 mlxsw_reg_sfgc_type_set(payload, type);
1093 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1094 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1095 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1096 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1097}
1098
1099/* SFTR - Switch Flooding Table Register
1100 * -------------------------------------
1101 * The switch flooding table is used for flooding packet replication. The table
1102 * defines a bit mask of ports for packet replication.
1103 */
1104#define MLXSW_REG_SFTR_ID 0x2012
1105#define MLXSW_REG_SFTR_LEN 0x420
1106
Jiri Pirko21978dc2016-10-21 16:07:20 +02001107MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001108
1109/* reg_sftr_swid
1110 * Switch partition ID with which to associate the port.
1111 * Access: Index
1112 */
1113MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
1114
1115/* reg_sftr_flood_table
1116 * Flooding table index to associate with the specific type on the specific
1117 * switch partition.
1118 * Access: Index
1119 */
1120MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1121
1122/* reg_sftr_index
1123 * Index. Used as an index into the Flooding Table in case the table is
1124 * configured to use VID / FID or FID Offset.
1125 * Access: Index
1126 */
1127MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1128
1129/* reg_sftr_table_type
1130 * See mlxsw_flood_table_type
1131 * Access: RW
1132 */
1133MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1134
1135/* reg_sftr_range
1136 * Range of entries to update
1137 * Access: Index
1138 */
1139MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1140
1141/* reg_sftr_port
1142 * Local port membership (1 bit per port).
1143 * Access: RW
1144 */
1145MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1146
1147/* reg_sftr_cpu_port_mask
1148 * CPU port mask (1 bit per port).
1149 * Access: W
1150 */
1151MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1152
1153static inline void mlxsw_reg_sftr_pack(char *payload,
1154 unsigned int flood_table,
1155 unsigned int index,
1156 enum mlxsw_flood_table_type table_type,
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001157 unsigned int range, u8 port, bool set)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001158{
1159 MLXSW_REG_ZERO(sftr, payload);
1160 mlxsw_reg_sftr_swid_set(payload, 0);
1161 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1162 mlxsw_reg_sftr_index_set(payload, index);
1163 mlxsw_reg_sftr_table_type_set(payload, table_type);
1164 mlxsw_reg_sftr_range_set(payload, range);
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001165 mlxsw_reg_sftr_port_set(payload, port, set);
1166 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001167}
1168
Ido Schimmel41933272016-01-27 15:20:17 +01001169/* SFDF - Switch Filtering DB Flush
1170 * --------------------------------
1171 * The switch filtering DB flush register is used to flush the FDB.
1172 * Note that FDB notifications are flushed as well.
1173 */
1174#define MLXSW_REG_SFDF_ID 0x2013
1175#define MLXSW_REG_SFDF_LEN 0x14
1176
Jiri Pirko21978dc2016-10-21 16:07:20 +02001177MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
Ido Schimmel41933272016-01-27 15:20:17 +01001178
1179/* reg_sfdf_swid
1180 * Switch partition ID.
1181 * Access: Index
1182 */
1183MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1184
1185enum mlxsw_reg_sfdf_flush_type {
1186 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1187 MLXSW_REG_SFDF_FLUSH_PER_FID,
1188 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1189 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1190 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1191 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
Ido Schimmela682a302018-10-11 07:47:56 +00001192 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1193 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
Ido Schimmel41933272016-01-27 15:20:17 +01001194};
1195
1196/* reg_sfdf_flush_type
1197 * Flush type.
1198 * 0 - All SWID dynamic entries are flushed.
1199 * 1 - All FID dynamic entries are flushed.
1200 * 2 - All dynamic entries pointing to port are flushed.
1201 * 3 - All FID dynamic entries pointing to port are flushed.
1202 * 4 - All dynamic entries pointing to LAG are flushed.
1203 * 5 - All FID dynamic entries pointing to LAG are flushed.
Ido Schimmela682a302018-10-11 07:47:56 +00001204 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1205 * flushed.
1206 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1207 * flushed, per FID.
Ido Schimmel41933272016-01-27 15:20:17 +01001208 * Access: RW
1209 */
1210MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1211
1212/* reg_sfdf_flush_static
1213 * Static.
1214 * 0 - Flush only dynamic entries.
1215 * 1 - Flush both dynamic and static entries.
1216 * Access: RW
1217 */
1218MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1219
1220static inline void mlxsw_reg_sfdf_pack(char *payload,
1221 enum mlxsw_reg_sfdf_flush_type type)
1222{
1223 MLXSW_REG_ZERO(sfdf, payload);
1224 mlxsw_reg_sfdf_flush_type_set(payload, type);
1225 mlxsw_reg_sfdf_flush_static_set(payload, true);
1226}
1227
1228/* reg_sfdf_fid
1229 * FID to flush.
1230 * Access: RW
1231 */
1232MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1233
1234/* reg_sfdf_system_port
1235 * Port to flush.
1236 * Access: RW
1237 */
1238MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1239
1240/* reg_sfdf_port_fid_system_port
1241 * Port to flush, pointed to by FID.
1242 * Access: RW
1243 */
1244MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1245
1246/* reg_sfdf_lag_id
1247 * LAG ID to flush.
1248 * Access: RW
1249 */
1250MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1251
1252/* reg_sfdf_lag_fid_lag_id
1253 * LAG ID to flush, pointed to by FID.
1254 * Access: RW
1255 */
1256MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1257
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001258/* SLDR - Switch LAG Descriptor Register
1259 * -----------------------------------------
1260 * The switch LAG descriptor register is populated by LAG descriptors.
1261 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1262 * max_lag-1.
1263 */
1264#define MLXSW_REG_SLDR_ID 0x2014
1265#define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1266
Jiri Pirko21978dc2016-10-21 16:07:20 +02001267MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001268
1269enum mlxsw_reg_sldr_op {
1270 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1271 MLXSW_REG_SLDR_OP_LAG_CREATE,
1272 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1273 /* Ports that appear in the list have the Distributor enabled */
1274 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1275 /* Removes ports from the disributor list */
1276 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1277};
1278
1279/* reg_sldr_op
1280 * Operation.
1281 * Access: RW
1282 */
1283MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1284
1285/* reg_sldr_lag_id
1286 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1287 * Access: Index
1288 */
1289MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1290
1291static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1292{
1293 MLXSW_REG_ZERO(sldr, payload);
1294 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1295 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1296}
1297
1298static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1299{
1300 MLXSW_REG_ZERO(sldr, payload);
1301 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1302 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1303}
1304
1305/* reg_sldr_num_ports
1306 * The number of member ports of the LAG.
1307 * Reserved for Create / Destroy operations
1308 * For Add / Remove operations - indicates the number of ports in the list.
1309 * Access: RW
1310 */
1311MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1312
1313/* reg_sldr_system_port
1314 * System port.
1315 * Access: RW
1316 */
1317MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1318
1319static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1320 u8 local_port)
1321{
1322 MLXSW_REG_ZERO(sldr, payload);
1323 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1324 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1325 mlxsw_reg_sldr_num_ports_set(payload, 1);
1326 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1327}
1328
1329static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1330 u8 local_port)
1331{
1332 MLXSW_REG_ZERO(sldr, payload);
1333 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1334 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1335 mlxsw_reg_sldr_num_ports_set(payload, 1);
1336 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1337}
1338
1339/* SLCR - Switch LAG Configuration 2 Register
1340 * -------------------------------------------
1341 * The Switch LAG Configuration register is used for configuring the
1342 * LAG properties of the switch.
1343 */
1344#define MLXSW_REG_SLCR_ID 0x2015
1345#define MLXSW_REG_SLCR_LEN 0x10
1346
Jiri Pirko21978dc2016-10-21 16:07:20 +02001347MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001348
1349enum mlxsw_reg_slcr_pp {
1350 /* Global Configuration (for all ports) */
1351 MLXSW_REG_SLCR_PP_GLOBAL,
1352 /* Per port configuration, based on local_port field */
1353 MLXSW_REG_SLCR_PP_PER_PORT,
1354};
1355
1356/* reg_slcr_pp
1357 * Per Port Configuration
1358 * Note: Reading at Global mode results in reading port 1 configuration.
1359 * Access: Index
1360 */
1361MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1362
1363/* reg_slcr_local_port
1364 * Local port number
1365 * Supported from CPU port
1366 * Not supported from router port
1367 * Reserved when pp = Global Configuration
1368 * Access: Index
1369 */
1370MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1371
1372enum mlxsw_reg_slcr_type {
1373 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1374 MLXSW_REG_SLCR_TYPE_XOR,
1375 MLXSW_REG_SLCR_TYPE_RANDOM,
1376};
1377
1378/* reg_slcr_type
1379 * Hash type
1380 * Access: RW
1381 */
1382MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1383
1384/* Ingress port */
1385#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1386/* SMAC - for IPv4 and IPv6 packets */
1387#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1388/* SMAC - for non-IP packets */
1389#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1390#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1391 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1392 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1393/* DMAC - for IPv4 and IPv6 packets */
1394#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1395/* DMAC - for non-IP packets */
1396#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1397#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1398 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1399 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1400/* Ethertype - for IPv4 and IPv6 packets */
1401#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1402/* Ethertype - for non-IP packets */
1403#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1404#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1405 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1406 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1407/* VLAN ID - for IPv4 and IPv6 packets */
1408#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1409/* VLAN ID - for non-IP packets */
1410#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1411#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1412 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1413 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1414/* Source IP address (can be IPv4 or IPv6) */
1415#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1416/* Destination IP address (can be IPv4 or IPv6) */
1417#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1418/* TCP/UDP source port */
1419#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1420/* TCP/UDP destination port*/
1421#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1422/* IPv4 Protocol/IPv6 Next Header */
1423#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1424/* IPv6 Flow label */
1425#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1426/* SID - FCoE source ID */
1427#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1428/* DID - FCoE destination ID */
1429#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1430/* OXID - FCoE originator exchange ID */
1431#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1432/* Destination QP number - for RoCE packets */
1433#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1434
1435/* reg_slcr_lag_hash
1436 * LAG hashing configuration. This is a bitmask, in which each set
1437 * bit includes the corresponding item in the LAG hash calculation.
1438 * The default lag_hash contains SMAC, DMAC, VLANID and
1439 * Ethertype (for all packet types).
1440 * Access: RW
1441 */
1442MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1443
Ido Schimmelbeda7f72018-10-11 07:47:57 +00001444/* reg_slcr_seed
1445 * LAG seed value. The seed is the same for all ports.
1446 * Access: RW
1447 */
1448MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1449
1450static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001451{
1452 MLXSW_REG_ZERO(slcr, payload);
1453 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
Elad Raz18c2d2c2016-09-19 08:28:24 +02001454 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001455 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
Ido Schimmelbeda7f72018-10-11 07:47:57 +00001456 mlxsw_reg_slcr_seed_set(payload, seed);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001457}
1458
1459/* SLCOR - Switch LAG Collector Register
1460 * -------------------------------------
1461 * The Switch LAG Collector register controls the Local Port membership
1462 * in a LAG and enablement of the collector.
1463 */
1464#define MLXSW_REG_SLCOR_ID 0x2016
1465#define MLXSW_REG_SLCOR_LEN 0x10
1466
Jiri Pirko21978dc2016-10-21 16:07:20 +02001467MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001468
1469enum mlxsw_reg_slcor_col {
1470 /* Port is added with collector disabled */
1471 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1472 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1473 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1474 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1475};
1476
1477/* reg_slcor_col
1478 * Collector configuration
1479 * Access: RW
1480 */
1481MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1482
1483/* reg_slcor_local_port
1484 * Local port number
1485 * Not supported for CPU port
1486 * Access: Index
1487 */
1488MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1489
1490/* reg_slcor_lag_id
1491 * LAG Identifier. Index into the LAG descriptor table.
1492 * Access: Index
1493 */
1494MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1495
1496/* reg_slcor_port_index
1497 * Port index in the LAG list. Only valid on Add Port to LAG col.
1498 * Valid range is from 0 to cap_max_lag_members-1
1499 * Access: RW
1500 */
1501MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1502
1503static inline void mlxsw_reg_slcor_pack(char *payload,
1504 u8 local_port, u16 lag_id,
1505 enum mlxsw_reg_slcor_col col)
1506{
1507 MLXSW_REG_ZERO(slcor, payload);
1508 mlxsw_reg_slcor_col_set(payload, col);
1509 mlxsw_reg_slcor_local_port_set(payload, local_port);
1510 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1511}
1512
1513static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1514 u8 local_port, u16 lag_id,
1515 u8 port_index)
1516{
1517 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1518 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1519 mlxsw_reg_slcor_port_index_set(payload, port_index);
1520}
1521
1522static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1523 u8 local_port, u16 lag_id)
1524{
1525 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1526 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1527}
1528
1529static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1530 u8 local_port, u16 lag_id)
1531{
1532 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1533 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1534}
1535
1536static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1537 u8 local_port, u16 lag_id)
1538{
1539 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1540 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1541}
1542
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001543/* SPMLR - Switch Port MAC Learning Register
1544 * -----------------------------------------
1545 * Controls the Switch MAC learning policy per port.
1546 */
1547#define MLXSW_REG_SPMLR_ID 0x2018
1548#define MLXSW_REG_SPMLR_LEN 0x8
1549
Jiri Pirko21978dc2016-10-21 16:07:20 +02001550MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001551
1552/* reg_spmlr_local_port
1553 * Local port number.
1554 * Access: Index
1555 */
1556MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1557
1558/* reg_spmlr_sub_port
1559 * Virtual port within the physical port.
1560 * Should be set to 0 when virtual ports are not enabled on the port.
1561 * Access: Index
1562 */
1563MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1564
1565enum mlxsw_reg_spmlr_learn_mode {
1566 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1567 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1568 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1569};
1570
1571/* reg_spmlr_learn_mode
1572 * Learning mode on the port.
1573 * 0 - Learning disabled.
1574 * 2 - Learning enabled.
1575 * 3 - Security mode.
1576 *
1577 * In security mode the switch does not learn MACs on the port, but uses the
1578 * SMAC to see if it exists on another ingress port. If so, the packet is
1579 * classified as a bad packet and is discarded unless the software registers
1580 * to receive port security error packets usign HPKT.
1581 */
1582MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1583
1584static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1585 enum mlxsw_reg_spmlr_learn_mode mode)
1586{
1587 MLXSW_REG_ZERO(spmlr, payload);
1588 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1589 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1590 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1591}
1592
Ido Schimmel64790232015-10-16 14:01:33 +02001593/* SVFA - Switch VID to FID Allocation Register
1594 * --------------------------------------------
1595 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1596 * virtualized ports.
1597 */
1598#define MLXSW_REG_SVFA_ID 0x201C
1599#define MLXSW_REG_SVFA_LEN 0x10
1600
Jiri Pirko21978dc2016-10-21 16:07:20 +02001601MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
Ido Schimmel64790232015-10-16 14:01:33 +02001602
1603/* reg_svfa_swid
1604 * Switch partition ID.
1605 * Access: Index
1606 */
1607MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1608
1609/* reg_svfa_local_port
1610 * Local port number.
1611 * Access: Index
1612 *
1613 * Note: Reserved for 802.1Q FIDs.
1614 */
1615MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1616
1617enum mlxsw_reg_svfa_mt {
1618 MLXSW_REG_SVFA_MT_VID_TO_FID,
1619 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1620};
1621
1622/* reg_svfa_mapping_table
1623 * Mapping table:
1624 * 0 - VID to FID
1625 * 1 - {Port, VID} to FID
1626 * Access: Index
1627 *
1628 * Note: Reserved for SwitchX-2.
1629 */
1630MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1631
1632/* reg_svfa_v
1633 * Valid.
1634 * Valid if set.
1635 * Access: RW
1636 *
1637 * Note: Reserved for SwitchX-2.
1638 */
1639MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1640
1641/* reg_svfa_fid
1642 * Filtering ID.
1643 * Access: RW
1644 */
1645MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1646
1647/* reg_svfa_vid
1648 * VLAN ID.
1649 * Access: Index
1650 */
1651MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1652
1653/* reg_svfa_counter_set_type
1654 * Counter set type for flow counters.
1655 * Access: RW
1656 *
1657 * Note: Reserved for SwitchX-2.
1658 */
1659MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1660
1661/* reg_svfa_counter_index
1662 * Counter index for flow counters.
1663 * Access: RW
1664 *
1665 * Note: Reserved for SwitchX-2.
1666 */
1667MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1668
1669static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1670 enum mlxsw_reg_svfa_mt mt, bool valid,
1671 u16 fid, u16 vid)
1672{
1673 MLXSW_REG_ZERO(svfa, payload);
1674 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1675 mlxsw_reg_svfa_swid_set(payload, 0);
1676 mlxsw_reg_svfa_local_port_set(payload, local_port);
1677 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1678 mlxsw_reg_svfa_v_set(payload, valid);
1679 mlxsw_reg_svfa_fid_set(payload, fid);
1680 mlxsw_reg_svfa_vid_set(payload, vid);
1681}
1682
Ido Schimmel1f65da72015-10-16 14:01:34 +02001683/* SVPE - Switch Virtual-Port Enabling Register
1684 * --------------------------------------------
1685 * Enables port virtualization.
1686 */
1687#define MLXSW_REG_SVPE_ID 0x201E
1688#define MLXSW_REG_SVPE_LEN 0x4
1689
Jiri Pirko21978dc2016-10-21 16:07:20 +02001690MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
Ido Schimmel1f65da72015-10-16 14:01:34 +02001691
1692/* reg_svpe_local_port
1693 * Local port number
1694 * Access: Index
1695 *
1696 * Note: CPU port is not supported (uses VLAN mode only).
1697 */
1698MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1699
1700/* reg_svpe_vp_en
1701 * Virtual port enable.
1702 * 0 - Disable, VLAN mode (VID to FID).
1703 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1704 * Access: RW
1705 */
1706MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1707
1708static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1709 bool enable)
1710{
1711 MLXSW_REG_ZERO(svpe, payload);
1712 mlxsw_reg_svpe_local_port_set(payload, local_port);
1713 mlxsw_reg_svpe_vp_en_set(payload, enable);
1714}
1715
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001716/* SFMR - Switch FID Management Register
1717 * -------------------------------------
1718 * Creates and configures FIDs.
1719 */
1720#define MLXSW_REG_SFMR_ID 0x201F
1721#define MLXSW_REG_SFMR_LEN 0x18
1722
Jiri Pirko21978dc2016-10-21 16:07:20 +02001723MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001724
1725enum mlxsw_reg_sfmr_op {
1726 MLXSW_REG_SFMR_OP_CREATE_FID,
1727 MLXSW_REG_SFMR_OP_DESTROY_FID,
1728};
1729
1730/* reg_sfmr_op
1731 * Operation.
1732 * 0 - Create or edit FID.
1733 * 1 - Destroy FID.
1734 * Access: WO
1735 */
1736MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1737
1738/* reg_sfmr_fid
1739 * Filtering ID.
1740 * Access: Index
1741 */
1742MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1743
1744/* reg_sfmr_fid_offset
1745 * FID offset.
1746 * Used to point into the flooding table selected by SFGC register if
1747 * the table is of type FID-Offset. Otherwise, this field is reserved.
1748 * Access: RW
1749 */
1750MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1751
1752/* reg_sfmr_vtfp
1753 * Valid Tunnel Flood Pointer.
1754 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1755 * Access: RW
1756 *
1757 * Note: Reserved for 802.1Q FIDs.
1758 */
1759MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1760
1761/* reg_sfmr_nve_tunnel_flood_ptr
1762 * Underlay Flooding and BC Pointer.
1763 * Used as a pointer to the first entry of the group based link lists of
1764 * flooding or BC entries (for NVE tunnels).
1765 * Access: RW
1766 */
1767MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1768
1769/* reg_sfmr_vv
1770 * VNI Valid.
1771 * If not set, then vni is reserved.
1772 * Access: RW
1773 *
1774 * Note: Reserved for 802.1Q FIDs.
1775 */
1776MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1777
1778/* reg_sfmr_vni
1779 * Virtual Network Identifier.
1780 * Access: RW
1781 *
1782 * Note: A given VNI can only be assigned to one FID.
1783 */
1784MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1785
1786static inline void mlxsw_reg_sfmr_pack(char *payload,
1787 enum mlxsw_reg_sfmr_op op, u16 fid,
1788 u16 fid_offset)
1789{
1790 MLXSW_REG_ZERO(sfmr, payload);
1791 mlxsw_reg_sfmr_op_set(payload, op);
1792 mlxsw_reg_sfmr_fid_set(payload, fid);
1793 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1794 mlxsw_reg_sfmr_vtfp_set(payload, false);
1795 mlxsw_reg_sfmr_vv_set(payload, false);
1796}
1797
Ido Schimmela4feea72015-10-16 14:01:36 +02001798/* SPVMLR - Switch Port VLAN MAC Learning Register
1799 * -----------------------------------------------
1800 * Controls the switch MAC learning policy per {Port, VID}.
1801 */
1802#define MLXSW_REG_SPVMLR_ID 0x2020
1803#define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1804#define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
Jiri Pirkoe9093b12017-03-14 14:00:01 +01001805#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
Ido Schimmela4feea72015-10-16 14:01:36 +02001806#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1807 MLXSW_REG_SPVMLR_REC_LEN * \
1808 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1809
Jiri Pirko21978dc2016-10-21 16:07:20 +02001810MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
Ido Schimmela4feea72015-10-16 14:01:36 +02001811
1812/* reg_spvmlr_local_port
1813 * Local ingress port.
1814 * Access: Index
1815 *
1816 * Note: CPU port is not supported.
1817 */
1818MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1819
1820/* reg_spvmlr_num_rec
1821 * Number of records to update.
1822 * Access: OP
1823 */
1824MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1825
1826/* reg_spvmlr_rec_learn_enable
1827 * 0 - Disable learning for {Port, VID}.
1828 * 1 - Enable learning for {Port, VID}.
1829 * Access: RW
1830 */
1831MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1832 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1833
1834/* reg_spvmlr_rec_vid
1835 * VLAN ID to be added/removed from port or for querying.
1836 * Access: Index
1837 */
1838MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1839 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1840
1841static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1842 u16 vid_begin, u16 vid_end,
1843 bool learn_enable)
1844{
1845 int num_rec = vid_end - vid_begin + 1;
1846 int i;
1847
1848 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1849
1850 MLXSW_REG_ZERO(spvmlr, payload);
1851 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1852 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1853
1854 for (i = 0; i < num_rec; i++) {
1855 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1856 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1857 }
1858}
1859
Nogah Frankelad53fa02017-11-06 07:23:44 +01001860/* CWTP - Congetion WRED ECN TClass Profile
1861 * ----------------------------------------
1862 * Configures the profiles for queues of egress port and traffic class
1863 */
1864#define MLXSW_REG_CWTP_ID 0x2802
1865#define MLXSW_REG_CWTP_BASE_LEN 0x28
1866#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
1867#define MLXSW_REG_CWTP_LEN 0x40
1868
1869MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
1870
1871/* reg_cwtp_local_port
1872 * Local port number
1873 * Not supported for CPU port
1874 * Access: Index
1875 */
1876MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
1877
1878/* reg_cwtp_traffic_class
1879 * Traffic Class to configure
1880 * Access: Index
1881 */
1882MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
1883
1884/* reg_cwtp_profile_min
1885 * Minimum Average Queue Size of the profile in cells.
1886 * Access: RW
1887 */
1888MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
1889 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
1890
1891/* reg_cwtp_profile_percent
1892 * Percentage of WRED and ECN marking for maximum Average Queue size
1893 * Range is 0 to 100, units of integer percentage
1894 * Access: RW
1895 */
1896MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
1897 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1898
1899/* reg_cwtp_profile_max
1900 * Maximum Average Queue size of the profile in cells
1901 * Access: RW
1902 */
1903MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
1904 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1905
1906#define MLXSW_REG_CWTP_MIN_VALUE 64
1907#define MLXSW_REG_CWTP_MAX_PROFILE 2
1908#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
1909
1910static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
1911 u8 traffic_class)
1912{
1913 int i;
1914
1915 MLXSW_REG_ZERO(cwtp, payload);
1916 mlxsw_reg_cwtp_local_port_set(payload, local_port);
1917 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
1918
1919 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
1920 mlxsw_reg_cwtp_profile_min_set(payload, i,
1921 MLXSW_REG_CWTP_MIN_VALUE);
1922 mlxsw_reg_cwtp_profile_max_set(payload, i,
1923 MLXSW_REG_CWTP_MIN_VALUE);
1924 }
1925}
1926
1927#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
1928
1929static inline void
1930mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
1931 u32 probability)
1932{
1933 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
1934
1935 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
1936 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
1937 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
1938}
1939
1940/* CWTPM - Congestion WRED ECN TClass and Pool Mapping
1941 * ---------------------------------------------------
1942 * The CWTPM register maps each egress port and traffic class to profile num.
1943 */
1944#define MLXSW_REG_CWTPM_ID 0x2803
1945#define MLXSW_REG_CWTPM_LEN 0x44
1946
1947MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
1948
1949/* reg_cwtpm_local_port
1950 * Local port number
1951 * Not supported for CPU port
1952 * Access: Index
1953 */
1954MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
1955
1956/* reg_cwtpm_traffic_class
1957 * Traffic Class to configure
1958 * Access: Index
1959 */
1960MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
1961
1962/* reg_cwtpm_ew
1963 * Control enablement of WRED for traffic class:
1964 * 0 - Disable
1965 * 1 - Enable
1966 * Access: RW
1967 */
1968MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
1969
1970/* reg_cwtpm_ee
1971 * Control enablement of ECN for traffic class:
1972 * 0 - Disable
1973 * 1 - Enable
1974 * Access: RW
1975 */
1976MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
1977
1978/* reg_cwtpm_tcp_g
1979 * TCP Green Profile.
1980 * Index of the profile within {port, traffic class} to use.
1981 * 0 for disabling both WRED and ECN for this type of traffic.
1982 * Access: RW
1983 */
1984MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
1985
1986/* reg_cwtpm_tcp_y
1987 * TCP Yellow Profile.
1988 * Index of the profile within {port, traffic class} to use.
1989 * 0 for disabling both WRED and ECN for this type of traffic.
1990 * Access: RW
1991 */
1992MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
1993
1994/* reg_cwtpm_tcp_r
1995 * TCP Red Profile.
1996 * Index of the profile within {port, traffic class} to use.
1997 * 0 for disabling both WRED and ECN for this type of traffic.
1998 * Access: RW
1999 */
2000MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
2001
2002/* reg_cwtpm_ntcp_g
2003 * Non-TCP Green Profile.
2004 * Index of the profile within {port, traffic class} to use.
2005 * 0 for disabling both WRED and ECN for this type of traffic.
2006 * Access: RW
2007 */
2008MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
2009
2010/* reg_cwtpm_ntcp_y
2011 * Non-TCP Yellow Profile.
2012 * Index of the profile within {port, traffic class} to use.
2013 * 0 for disabling both WRED and ECN for this type of traffic.
2014 * Access: RW
2015 */
2016MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
2017
2018/* reg_cwtpm_ntcp_r
2019 * Non-TCP Red Profile.
2020 * Index of the profile within {port, traffic class} to use.
2021 * 0 for disabling both WRED and ECN for this type of traffic.
2022 * Access: RW
2023 */
2024MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
2025
2026#define MLXSW_REG_CWTPM_RESET_PROFILE 0
2027
2028static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
2029 u8 traffic_class, u8 profile,
2030 bool wred, bool ecn)
2031{
2032 MLXSW_REG_ZERO(cwtpm, payload);
2033 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
2034 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
2035 mlxsw_reg_cwtpm_ew_set(payload, wred);
2036 mlxsw_reg_cwtpm_ee_set(payload, ecn);
2037 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
2038 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
2039 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
2040 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
2041 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
2042 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
2043}
2044
Ido Schimmel7050f432018-07-18 11:14:40 +03002045/* PGCR - Policy-Engine General Configuration Register
2046 * ---------------------------------------------------
2047 * This register configures general Policy-Engine settings.
2048 */
2049#define MLXSW_REG_PGCR_ID 0x3001
2050#define MLXSW_REG_PGCR_LEN 0x20
2051
2052MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
2053
2054/* reg_pgcr_default_action_pointer_base
2055 * Default action pointer base. Each region has a default action pointer
2056 * which is equal to default_action_pointer_base + region_id.
2057 * Access: RW
2058 */
2059MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
2060
2061static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
2062{
2063 MLXSW_REG_ZERO(pgcr, payload);
2064 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
2065}
2066
Jiri Pirkoaf7170e2017-02-03 10:28:57 +01002067/* PPBT - Policy-Engine Port Binding Table
2068 * ---------------------------------------
2069 * This register is used for configuration of the Port Binding Table.
2070 */
2071#define MLXSW_REG_PPBT_ID 0x3002
2072#define MLXSW_REG_PPBT_LEN 0x14
2073
2074MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
2075
2076enum mlxsw_reg_pxbt_e {
2077 MLXSW_REG_PXBT_E_IACL,
2078 MLXSW_REG_PXBT_E_EACL,
2079};
2080
2081/* reg_ppbt_e
2082 * Access: Index
2083 */
2084MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
2085
2086enum mlxsw_reg_pxbt_op {
2087 MLXSW_REG_PXBT_OP_BIND,
2088 MLXSW_REG_PXBT_OP_UNBIND,
2089};
2090
2091/* reg_ppbt_op
2092 * Access: RW
2093 */
2094MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
2095
2096/* reg_ppbt_local_port
2097 * Local port. Not including CPU port.
2098 * Access: Index
2099 */
2100MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
2101
2102/* reg_ppbt_g
2103 * group - When set, the binding is of an ACL group. When cleared,
2104 * the binding is of an ACL.
2105 * Must be set to 1 for Spectrum.
2106 * Access: RW
2107 */
2108MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2109
2110/* reg_ppbt_acl_info
2111 * ACL/ACL group identifier. If the g bit is set, this field should hold
2112 * the acl_group_id, else it should hold the acl_id.
2113 * Access: RW
2114 */
2115MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2116
2117static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2118 enum mlxsw_reg_pxbt_op op,
2119 u8 local_port, u16 acl_info)
2120{
2121 MLXSW_REG_ZERO(ppbt, payload);
2122 mlxsw_reg_ppbt_e_set(payload, e);
2123 mlxsw_reg_ppbt_op_set(payload, op);
2124 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2125 mlxsw_reg_ppbt_g_set(payload, true);
2126 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2127}
2128
Jiri Pirko3279da42017-02-03 10:28:53 +01002129/* PACL - Policy-Engine ACL Register
2130 * ---------------------------------
2131 * This register is used for configuration of the ACL.
2132 */
2133#define MLXSW_REG_PACL_ID 0x3004
2134#define MLXSW_REG_PACL_LEN 0x70
2135
2136MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2137
2138/* reg_pacl_v
2139 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2140 * while the ACL is bounded to either a port, VLAN or ACL rule.
2141 * Access: RW
2142 */
2143MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2144
2145/* reg_pacl_acl_id
2146 * An identifier representing the ACL (managed by software)
2147 * Range 0 .. cap_max_acl_regions - 1
2148 * Access: Index
2149 */
2150MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2151
2152#define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2153
2154/* reg_pacl_tcam_region_info
2155 * Opaque object that represents a TCAM region.
2156 * Obtained through PTAR register.
2157 * Access: RW
2158 */
2159MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2160 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2161
2162static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2163 bool valid, const char *tcam_region_info)
2164{
2165 MLXSW_REG_ZERO(pacl, payload);
2166 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2167 mlxsw_reg_pacl_v_set(payload, valid);
2168 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2169}
2170
Jiri Pirko10fabef2017-02-03 10:28:54 +01002171/* PAGT - Policy-Engine ACL Group Table
2172 * ------------------------------------
2173 * This register is used for configuration of the ACL Group Table.
2174 */
2175#define MLXSW_REG_PAGT_ID 0x3005
2176#define MLXSW_REG_PAGT_BASE_LEN 0x30
2177#define MLXSW_REG_PAGT_ACL_LEN 4
2178#define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2179#define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2180 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2181
2182MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2183
2184/* reg_pagt_size
2185 * Number of ACLs in the group.
2186 * Size 0 invalidates a group.
2187 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2188 * Total number of ACLs in all groups must be lower or equal
2189 * to cap_max_acl_tot_groups
2190 * Note: a group which is binded must not be invalidated
2191 * Access: Index
2192 */
2193MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2194
2195/* reg_pagt_acl_group_id
2196 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2197 * the ACL Group identifier (managed by software).
2198 * Access: Index
2199 */
2200MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2201
Jiri Pirko5c661f12019-02-07 11:22:53 +00002202/* reg_pagt_multi
2203 * Multi-ACL
2204 * 0 - This ACL is the last ACL in the multi-ACL
2205 * 1 - This ACL is part of a multi-ACL
2206 * Access: RW
2207 */
2208MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
2209
Jiri Pirko10fabef2017-02-03 10:28:54 +01002210/* reg_pagt_acl_id
2211 * ACL identifier
2212 * Access: RW
2213 */
2214MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2215
2216static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2217{
2218 MLXSW_REG_ZERO(pagt, payload);
2219 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2220}
2221
2222static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
Jiri Pirko5c661f12019-02-07 11:22:53 +00002223 u16 acl_id, bool multi)
Jiri Pirko10fabef2017-02-03 10:28:54 +01002224{
2225 u8 size = mlxsw_reg_pagt_size_get(payload);
2226
2227 if (index >= size)
2228 mlxsw_reg_pagt_size_set(payload, index + 1);
Jiri Pirko5c661f12019-02-07 11:22:53 +00002229 mlxsw_reg_pagt_multi_set(payload, index, multi);
Jiri Pirko10fabef2017-02-03 10:28:54 +01002230 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2231}
2232
Jiri Pirkod9c26612017-02-03 10:28:55 +01002233/* PTAR - Policy-Engine TCAM Allocation Register
2234 * ---------------------------------------------
2235 * This register is used for allocation of regions in the TCAM.
2236 * Note: Query method is not supported on this register.
2237 */
2238#define MLXSW_REG_PTAR_ID 0x3006
2239#define MLXSW_REG_PTAR_BASE_LEN 0x20
2240#define MLXSW_REG_PTAR_KEY_ID_LEN 1
2241#define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2242#define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2243 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2244
2245MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2246
2247enum mlxsw_reg_ptar_op {
2248 /* allocate a TCAM region */
2249 MLXSW_REG_PTAR_OP_ALLOC,
2250 /* resize a TCAM region */
2251 MLXSW_REG_PTAR_OP_RESIZE,
2252 /* deallocate TCAM region */
2253 MLXSW_REG_PTAR_OP_FREE,
2254 /* test allocation */
2255 MLXSW_REG_PTAR_OP_TEST,
2256};
2257
2258/* reg_ptar_op
2259 * Access: OP
2260 */
2261MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2262
2263/* reg_ptar_action_set_type
2264 * Type of action set to be used on this region.
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002265 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
Jiri Pirkod9c26612017-02-03 10:28:55 +01002266 * Access: WO
2267 */
2268MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2269
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002270enum mlxsw_reg_ptar_key_type {
2271 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2272 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2273};
2274
Jiri Pirkod9c26612017-02-03 10:28:55 +01002275/* reg_ptar_key_type
2276 * TCAM key type for the region.
Jiri Pirkod9c26612017-02-03 10:28:55 +01002277 * Access: WO
2278 */
2279MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2280
2281/* reg_ptar_region_size
2282 * TCAM region size. When allocating/resizing this is the requested size,
2283 * the response is the actual size. Note that actual size may be
2284 * larger than requested.
2285 * Allowed range 1 .. cap_max_rules-1
2286 * Reserved during op deallocate.
2287 * Access: WO
2288 */
2289MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2290
2291/* reg_ptar_region_id
2292 * Region identifier
2293 * Range 0 .. cap_max_regions-1
2294 * Access: Index
2295 */
2296MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2297
2298/* reg_ptar_tcam_region_info
2299 * Opaque object that represents the TCAM region.
2300 * Returned when allocating a region.
2301 * Provided by software for ACL generation and region deallocation and resize.
2302 * Access: RW
2303 */
2304MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2305 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2306
2307/* reg_ptar_flexible_key_id
2308 * Identifier of the Flexible Key.
2309 * Only valid if key_type == "FLEX_KEY"
2310 * The key size will be rounded up to one of the following values:
2311 * 9B, 18B, 36B, 54B.
2312 * This field is reserved for in resize operation.
2313 * Access: WO
2314 */
2315MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2316 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2317
2318static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002319 enum mlxsw_reg_ptar_key_type key_type,
Jiri Pirkod9c26612017-02-03 10:28:55 +01002320 u16 region_size, u16 region_id,
2321 const char *tcam_region_info)
2322{
2323 MLXSW_REG_ZERO(ptar, payload);
2324 mlxsw_reg_ptar_op_set(payload, op);
2325 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002326 mlxsw_reg_ptar_key_type_set(payload, key_type);
Jiri Pirkod9c26612017-02-03 10:28:55 +01002327 mlxsw_reg_ptar_region_size_set(payload, region_size);
2328 mlxsw_reg_ptar_region_id_set(payload, region_id);
2329 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2330}
2331
2332static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2333 u16 key_id)
2334{
2335 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2336}
2337
2338static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2339{
2340 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2341}
2342
Jiri Pirkod1206492017-02-03 10:28:59 +01002343/* PPBS - Policy-Engine Policy Based Switching Register
2344 * ----------------------------------------------------
2345 * This register retrieves and sets Policy Based Switching Table entries.
2346 */
2347#define MLXSW_REG_PPBS_ID 0x300C
2348#define MLXSW_REG_PPBS_LEN 0x14
2349
2350MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2351
2352/* reg_ppbs_pbs_ptr
2353 * Index into the PBS table.
2354 * For Spectrum, the index points to the KVD Linear.
2355 * Access: Index
2356 */
2357MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2358
2359/* reg_ppbs_system_port
2360 * Unique port identifier for the final destination of the packet.
2361 * Access: RW
2362 */
2363MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2364
2365static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2366 u16 system_port)
2367{
2368 MLXSW_REG_ZERO(ppbs, payload);
2369 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2370 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2371}
2372
Jiri Pirko937b6822017-02-03 10:28:58 +01002373/* PRCR - Policy-Engine Rules Copy Register
2374 * ----------------------------------------
2375 * This register is used for accessing rules within a TCAM region.
2376 */
2377#define MLXSW_REG_PRCR_ID 0x300D
2378#define MLXSW_REG_PRCR_LEN 0x40
2379
2380MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2381
2382enum mlxsw_reg_prcr_op {
2383 /* Move rules. Moves the rules from "tcam_region_info" starting
2384 * at offset "offset" to "dest_tcam_region_info"
2385 * at offset "dest_offset."
2386 */
2387 MLXSW_REG_PRCR_OP_MOVE,
2388 /* Copy rules. Copies the rules from "tcam_region_info" starting
2389 * at offset "offset" to "dest_tcam_region_info"
2390 * at offset "dest_offset."
2391 */
2392 MLXSW_REG_PRCR_OP_COPY,
2393};
2394
2395/* reg_prcr_op
2396 * Access: OP
2397 */
2398MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2399
2400/* reg_prcr_offset
2401 * Offset within the source region to copy/move from.
2402 * Access: Index
2403 */
2404MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2405
2406/* reg_prcr_size
2407 * The number of rules to copy/move.
2408 * Access: WO
2409 */
2410MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2411
2412/* reg_prcr_tcam_region_info
2413 * Opaque object that represents the source TCAM region.
2414 * Access: Index
2415 */
2416MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2417 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2418
2419/* reg_prcr_dest_offset
2420 * Offset within the source region to copy/move to.
2421 * Access: Index
2422 */
2423MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2424
2425/* reg_prcr_dest_tcam_region_info
2426 * Opaque object that represents the destination TCAM region.
2427 * Access: Index
2428 */
2429MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2430 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2431
2432static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2433 const char *src_tcam_region_info,
2434 u16 src_offset,
2435 const char *dest_tcam_region_info,
2436 u16 dest_offset, u16 size)
2437{
2438 MLXSW_REG_ZERO(prcr, payload);
2439 mlxsw_reg_prcr_op_set(payload, op);
2440 mlxsw_reg_prcr_offset_set(payload, src_offset);
2441 mlxsw_reg_prcr_size_set(payload, size);
2442 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2443 src_tcam_region_info);
2444 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2445 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2446 dest_tcam_region_info);
2447}
2448
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002449/* PEFA - Policy-Engine Extended Flexible Action Register
2450 * ------------------------------------------------------
2451 * This register is used for accessing an extended flexible action entry
2452 * in the central KVD Linear Database.
2453 */
2454#define MLXSW_REG_PEFA_ID 0x300F
2455#define MLXSW_REG_PEFA_LEN 0xB0
2456
2457MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2458
2459/* reg_pefa_index
2460 * Index in the KVD Linear Centralized Database.
2461 * Access: Index
2462 */
2463MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2464
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002465/* reg_pefa_a
2466 * Index in the KVD Linear Centralized Database.
2467 * Activity
2468 * For a new entry: set if ca=0, clear if ca=1
2469 * Set if a packet lookup has hit on the specific entry
2470 * Access: RO
2471 */
2472MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2473
2474/* reg_pefa_ca
2475 * Clear activity
2476 * When write: activity is according to this field
2477 * When read: after reading the activity is cleared according to ca
2478 * Access: OP
2479 */
2480MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2481
Yotam Gigi58726562017-09-19 10:00:12 +02002482#define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002483
2484/* reg_pefa_flex_action_set
2485 * Action-set to perform when rule is matched.
2486 * Must be zero padded if action set is shorter.
2487 * Access: RW
2488 */
Yotam Gigi58726562017-09-19 10:00:12 +02002489MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002490
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002491static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002492 const char *flex_action_set)
2493{
2494 MLXSW_REG_ZERO(pefa, payload);
2495 mlxsw_reg_pefa_index_set(payload, index);
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002496 mlxsw_reg_pefa_ca_set(payload, ca);
2497 if (flex_action_set)
2498 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2499 flex_action_set);
2500}
2501
2502static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2503{
2504 *p_a = mlxsw_reg_pefa_a_get(payload);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002505}
2506
Nir Dotana75e41d2018-12-10 07:11:33 +00002507/* PEMRBT - Policy-Engine Multicast Router Binding Table Register
2508 * --------------------------------------------------------------
2509 * This register is used for binding Multicast router to an ACL group
2510 * that serves the MC router.
2511 * This register is not supported by SwitchX/-2 and Spectrum.
2512 */
2513#define MLXSW_REG_PEMRBT_ID 0x3014
2514#define MLXSW_REG_PEMRBT_LEN 0x14
2515
2516MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
2517
2518enum mlxsw_reg_pemrbt_protocol {
2519 MLXSW_REG_PEMRBT_PROTO_IPV4,
2520 MLXSW_REG_PEMRBT_PROTO_IPV6,
2521};
2522
2523/* reg_pemrbt_protocol
2524 * Access: Index
2525 */
2526MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
2527
2528/* reg_pemrbt_group_id
2529 * ACL group identifier.
2530 * Range 0..cap_max_acl_groups-1
2531 * Access: RW
2532 */
2533MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
2534
2535static inline void
2536mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
2537 u16 group_id)
2538{
2539 MLXSW_REG_ZERO(pemrbt, payload);
2540 mlxsw_reg_pemrbt_protocol_set(payload, protocol);
2541 mlxsw_reg_pemrbt_group_id_set(payload, group_id);
2542}
2543
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002544/* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
2545 * -----------------------------------------------------
2546 * This register is used for accessing rules within a TCAM region.
2547 * It is a new version of PTCE in order to support wider key,
2548 * mask and action within a TCAM region. This register is not supported
2549 * by SwitchX and SwitchX-2.
2550 */
2551#define MLXSW_REG_PTCE2_ID 0x3017
2552#define MLXSW_REG_PTCE2_LEN 0x1D8
2553
2554MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2555
2556/* reg_ptce2_v
2557 * Valid.
2558 * Access: RW
2559 */
2560MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2561
2562/* reg_ptce2_a
2563 * Activity. Set if a packet lookup has hit on the specific entry.
2564 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
2565 * Access: RO
2566 */
2567MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2568
2569enum mlxsw_reg_ptce2_op {
2570 /* Read operation. */
2571 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2572 /* clear on read operation. Used to read entry
2573 * and clear Activity bit.
2574 */
2575 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2576 /* Write operation. Used to write a new entry to the table.
2577 * All R/W fields are relevant for new entry. Activity bit is set
2578 * for new entries - Note write with v = 0 will delete the entry.
2579 */
2580 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2581 /* Update action. Only action set will be updated. */
2582 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2583 /* Clear activity. A bit is cleared for the entry. */
2584 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2585};
2586
2587/* reg_ptce2_op
2588 * Access: OP
2589 */
2590MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2591
2592/* reg_ptce2_offset
2593 * Access: Index
2594 */
2595MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2596
Jiri Pirko42df8352018-07-08 23:51:24 +03002597/* reg_ptce2_priority
2598 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
2599 * Note: priority does not have to be unique per rule.
2600 * Within a region, higher priority should have lower offset (no limitation
2601 * between regions in a multi-region).
2602 * Access: RW
2603 */
2604MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2605
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002606/* reg_ptce2_tcam_region_info
2607 * Opaque object that represents the TCAM region.
2608 * Access: Index
2609 */
2610MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2611 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2612
Ido Schimmelaecefac2018-07-25 09:23:51 +03002613#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002614
2615/* reg_ptce2_flex_key_blocks
2616 * ACL Key.
2617 * Access: RW
2618 */
2619MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002620 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002621
2622/* reg_ptce2_mask
2623 * mask- in the same size as key. A bit that is set directs the TCAM
2624 * to compare the corresponding bit in key. A bit that is clear directs
2625 * the TCAM to ignore the corresponding bit in key.
2626 * Access: RW
2627 */
2628MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002629 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002630
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002631/* reg_ptce2_flex_action_set
2632 * ACL action set.
2633 * Access: RW
2634 */
2635MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
Yotam Gigi58726562017-09-19 10:00:12 +02002636 MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002637
2638static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2639 enum mlxsw_reg_ptce2_op op,
2640 const char *tcam_region_info,
Jiri Pirko42df8352018-07-08 23:51:24 +03002641 u16 offset, u32 priority)
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002642{
2643 MLXSW_REG_ZERO(ptce2, payload);
2644 mlxsw_reg_ptce2_v_set(payload, valid);
2645 mlxsw_reg_ptce2_op_set(payload, op);
2646 mlxsw_reg_ptce2_offset_set(payload, offset);
Jiri Pirko42df8352018-07-08 23:51:24 +03002647 mlxsw_reg_ptce2_priority_set(payload, priority);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002648 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2649}
2650
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03002651/* PERPT - Policy-Engine ERP Table Register
2652 * ----------------------------------------
2653 * This register adds and removes eRPs from the eRP table.
2654 */
2655#define MLXSW_REG_PERPT_ID 0x3021
2656#define MLXSW_REG_PERPT_LEN 0x80
2657
2658MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2659
2660/* reg_perpt_erpt_bank
2661 * eRP table bank.
2662 * Range 0 .. cap_max_erp_table_banks - 1
2663 * Access: Index
2664 */
2665MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2666
2667/* reg_perpt_erpt_index
2668 * Index to eRP table within the eRP bank.
2669 * Range is 0 .. cap_max_erp_table_bank_size - 1
2670 * Access: Index
2671 */
2672MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2673
2674enum mlxsw_reg_perpt_key_size {
2675 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2676 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2677 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2678 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2679};
2680
2681/* reg_perpt_key_size
2682 * Access: OP
2683 */
2684MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2685
2686/* reg_perpt_bf_bypass
2687 * 0 - The eRP is used only if bloom filter state is set for the given
2688 * rule.
2689 * 1 - The eRP is used regardless of bloom filter state.
2690 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
2691 * Access: RW
2692 */
2693MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2694
2695/* reg_perpt_erp_id
2696 * eRP ID for use by the rules.
2697 * Access: RW
2698 */
2699MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2700
2701/* reg_perpt_erpt_base_bank
2702 * Base eRP table bank, points to head of erp_vector
2703 * Range is 0 .. cap_max_erp_table_banks - 1
2704 * Access: OP
2705 */
2706MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2707
2708/* reg_perpt_erpt_base_index
2709 * Base index to eRP table within the eRP bank
2710 * Range is 0 .. cap_max_erp_table_bank_size - 1
2711 * Access: OP
2712 */
2713MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2714
2715/* reg_perpt_erp_index_in_vector
2716 * eRP index in the vector.
2717 * Access: OP
2718 */
2719MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2720
2721/* reg_perpt_erp_vector
2722 * eRP vector.
2723 * Access: OP
2724 */
2725MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2726
2727/* reg_perpt_mask
2728 * Mask
2729 * 0 - A-TCAM will ignore the bit in key
2730 * 1 - A-TCAM will compare the bit in key
2731 * Access: RW
2732 */
2733MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2734
2735static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
2736 unsigned long *erp_vector,
2737 unsigned long size)
2738{
2739 unsigned long bit;
2740
2741 for_each_set_bit(bit, erp_vector, size)
2742 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
2743}
2744
2745static inline void
2746mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
2747 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
2748 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
2749 char *mask)
2750{
2751 MLXSW_REG_ZERO(perpt, payload);
2752 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
2753 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
2754 mlxsw_reg_perpt_key_size_set(payload, key_size);
Nir Dotan03ce5bd2018-12-16 08:49:34 +00002755 mlxsw_reg_perpt_bf_bypass_set(payload, false);
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03002756 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
2757 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
2758 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
2759 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
2760 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
2761}
2762
Jiri Pirko33907872018-07-18 11:14:37 +03002763/* PERAR - Policy-Engine Region Association Register
2764 * -------------------------------------------------
2765 * This register associates a hw region for region_id's. Changing on the fly
2766 * is supported by the device.
2767 */
2768#define MLXSW_REG_PERAR_ID 0x3026
2769#define MLXSW_REG_PERAR_LEN 0x08
2770
2771MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
2772
2773/* reg_perar_region_id
2774 * Region identifier
2775 * Range 0 .. cap_max_regions-1
2776 * Access: Index
2777 */
2778MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
2779
2780static inline unsigned int
2781mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
2782{
2783 return DIV_ROUND_UP(block_num, 4);
2784}
2785
2786/* reg_perar_hw_region
2787 * HW Region
2788 * Range 0 .. cap_max_regions-1
2789 * Default: hw_region = region_id
2790 * For a 8 key block region, 2 consecutive regions are used
2791 * For a 12 key block region, 3 consecutive regions are used
2792 * Access: RW
2793 */
2794MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
2795
2796static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
2797 u16 hw_region)
2798{
2799 MLXSW_REG_ZERO(perar, payload);
2800 mlxsw_reg_perar_region_id_set(payload, region_id);
2801 mlxsw_reg_perar_hw_region_set(payload, hw_region);
2802}
2803
Ido Schimmelaecefac2018-07-25 09:23:51 +03002804/* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
2805 * -----------------------------------------------------
2806 * This register is a new version of PTCE-V2 in order to support the
2807 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
2808 */
2809#define MLXSW_REG_PTCE3_ID 0x3027
2810#define MLXSW_REG_PTCE3_LEN 0xF0
2811
2812MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
2813
2814/* reg_ptce3_v
2815 * Valid.
2816 * Access: RW
2817 */
2818MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
2819
2820enum mlxsw_reg_ptce3_op {
2821 /* Write operation. Used to write a new entry to the table.
2822 * All R/W fields are relevant for new entry. Activity bit is set
2823 * for new entries. Write with v = 0 will delete the entry. Must
2824 * not be used if an entry exists.
2825 */
2826 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
2827 /* Update operation */
2828 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
2829 /* Read operation */
2830 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
2831};
2832
2833/* reg_ptce3_op
2834 * Access: OP
2835 */
2836MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
2837
2838/* reg_ptce3_priority
2839 * Priority of the rule. Higher values win.
2840 * For Spectrum-2 range is 1..cap_kvd_size - 1
2841 * Note: Priority does not have to be unique per rule.
2842 * Access: RW
2843 */
2844MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
2845
2846/* reg_ptce3_tcam_region_info
2847 * Opaque object that represents the TCAM region.
2848 * Access: Index
2849 */
2850MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
2851 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2852
2853/* reg_ptce3_flex2_key_blocks
2854 * ACL key. The key must be masked according to eRP (if exists) or
2855 * according to master mask.
2856 * Access: Index
2857 */
2858MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
2859 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2860
2861/* reg_ptce3_erp_id
2862 * eRP ID.
2863 * Access: Index
2864 */
2865MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
2866
2867/* reg_ptce3_delta_start
2868 * Start point of delta_value and delta_mask, in bits. Must not exceed
2869 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
2870 * Access: Index
2871 */
2872MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
2873
2874/* reg_ptce3_delta_mask
2875 * Delta mask.
2876 * 0 - Ignore relevant bit in delta_value
2877 * 1 - Compare relevant bit in delta_value
2878 * Delta mask must not be set for reserved fields in the key blocks.
2879 * Note: No delta when no eRPs. Thus, for regions with
2880 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
2881 * Access: Index
2882 */
2883MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
2884
2885/* reg_ptce3_delta_value
2886 * Delta value.
2887 * Bits which are masked by delta_mask must be 0.
2888 * Access: Index
2889 */
2890MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
2891
2892/* reg_ptce3_prune_vector
2893 * Pruning vector relative to the PERPT.erp_id.
2894 * Used for reducing lookups.
2895 * 0 - NEED: Do a lookup using the eRP.
2896 * 1 - PRUNE: Do not perform a lookup using the eRP.
2897 * Maybe be modified by PEAPBL and PEAPBM.
2898 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
2899 * all 1's or all 0's.
2900 * Access: RW
2901 */
2902MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
2903
2904/* reg_ptce3_prune_ctcam
2905 * Pruning on C-TCAM. Used for reducing lookups.
2906 * 0 - NEED: Do a lookup in the C-TCAM.
2907 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
2908 * Access: RW
2909 */
2910MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
2911
2912/* reg_ptce3_large_exists
2913 * Large entry key ID exists.
2914 * Within the region:
2915 * 0 - SINGLE: The large_entry_key_id is not currently in use.
2916 * For rule insert: The MSB of the key (blocks 6..11) will be added.
2917 * For rule delete: The MSB of the key will be removed.
2918 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
2919 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
2920 * For rule delete: The MSB of the key will not be removed.
2921 * Access: WO
2922 */
2923MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
2924
2925/* reg_ptce3_large_entry_key_id
2926 * Large entry key ID.
2927 * A key for 12 key blocks rules. Reserved when region has less than 12 key
2928 * blocks. Must be different for different keys which have the same common
2929 * 6 key blocks (MSB, blocks 6..11) key within a region.
2930 * Range is 0..cap_max_pe_large_key_id - 1
2931 * Access: RW
2932 */
2933MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
2934
2935/* reg_ptce3_action_pointer
2936 * Pointer to action.
2937 * Range is 0..cap_max_kvd_action_sets - 1
2938 * Access: RW
2939 */
2940MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
2941
2942static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
2943 enum mlxsw_reg_ptce3_op op,
2944 u32 priority,
2945 const char *tcam_region_info,
2946 const char *key, u8 erp_id,
Jiri Pirkoc22291f2018-11-14 08:22:35 +00002947 u16 delta_start, u8 delta_mask,
2948 u8 delta_value, bool large_exists,
2949 u32 lkey_id, u32 action_pointer)
Ido Schimmelaecefac2018-07-25 09:23:51 +03002950{
2951 MLXSW_REG_ZERO(ptce3, payload);
2952 mlxsw_reg_ptce3_v_set(payload, valid);
2953 mlxsw_reg_ptce3_op_set(payload, op);
2954 mlxsw_reg_ptce3_priority_set(payload, priority);
2955 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
2956 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
2957 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
Jiri Pirkoc22291f2018-11-14 08:22:35 +00002958 mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
2959 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
2960 mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
Ido Schimmelaecefac2018-07-25 09:23:51 +03002961 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
2962 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
2963 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
2964}
2965
Ido Schimmel481662a2018-07-18 11:14:38 +03002966/* PERCR - Policy-Engine Region Configuration Register
2967 * ---------------------------------------------------
2968 * This register configures the region parameters. The region_id must be
2969 * allocated.
2970 */
2971#define MLXSW_REG_PERCR_ID 0x302A
2972#define MLXSW_REG_PERCR_LEN 0x80
2973
2974MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
2975
2976/* reg_percr_region_id
2977 * Region identifier.
2978 * Range 0..cap_max_regions-1
2979 * Access: Index
2980 */
2981MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
2982
2983/* reg_percr_atcam_ignore_prune
2984 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
2985 * Access: RW
2986 */
2987MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
2988
2989/* reg_percr_ctcam_ignore_prune
2990 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
2991 * Access: RW
2992 */
2993MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
2994
2995/* reg_percr_bf_bypass
2996 * Bloom filter bypass.
2997 * 0 - Bloom filter is used (default)
2998 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
2999 * region_id or eRP. See PERPT.bf_bypass
3000 * Access: RW
3001 */
3002MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
3003
3004/* reg_percr_master_mask
3005 * Master mask. Logical OR mask of all masks of all rules of a region
3006 * (both A-TCAM and C-TCAM). When there are no eRPs
3007 * (erpt_pointer_valid = 0), then this provides the mask.
3008 * Access: RW
3009 */
3010MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
3011
3012static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
3013{
3014 MLXSW_REG_ZERO(percr, payload);
3015 mlxsw_reg_percr_region_id_set(payload, region_id);
3016 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
3017 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
Nir Dotan03ce5bd2018-12-16 08:49:34 +00003018 mlxsw_reg_percr_bf_bypass_set(payload, false);
Ido Schimmel481662a2018-07-18 11:14:38 +03003019}
3020
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03003021/* PERERP - Policy-Engine Region eRP Register
3022 * ------------------------------------------
3023 * This register configures the region eRP. The region_id must be
3024 * allocated.
3025 */
3026#define MLXSW_REG_PERERP_ID 0x302B
3027#define MLXSW_REG_PERERP_LEN 0x1C
3028
3029MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
3030
3031/* reg_pererp_region_id
3032 * Region identifier.
3033 * Range 0..cap_max_regions-1
3034 * Access: Index
3035 */
3036MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
3037
3038/* reg_pererp_ctcam_le
3039 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
3040 * Access: RW
3041 */
3042MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
3043
3044/* reg_pererp_erpt_pointer_valid
3045 * erpt_pointer is valid.
3046 * Access: RW
3047 */
3048MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
3049
3050/* reg_pererp_erpt_bank_pointer
3051 * Pointer to eRP table bank. May be modified at any time.
3052 * Range 0..cap_max_erp_table_banks-1
3053 * Reserved when erpt_pointer_valid = 0
3054 */
3055MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
3056
3057/* reg_pererp_erpt_pointer
3058 * Pointer to eRP table within the eRP bank. Can be changed for an
3059 * existing region.
3060 * Range 0..cap_max_erp_table_size-1
3061 * Reserved when erpt_pointer_valid = 0
3062 * Access: RW
3063 */
3064MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
3065
3066/* reg_pererp_erpt_vector
3067 * Vector of allowed eRP indexes starting from erpt_pointer within the
3068 * erpt_bank_pointer. Next entries will be in next bank.
3069 * Note that eRP index is used and not eRP ID.
3070 * Reserved when erpt_pointer_valid = 0
3071 * Access: RW
3072 */
3073MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
3074
3075/* reg_pererp_master_rp_id
3076 * Master RP ID. When there are no eRPs, then this provides the eRP ID
3077 * for the lookup. Can be changed for an existing region.
3078 * Reserved when erpt_pointer_valid = 1
3079 * Access: RW
3080 */
3081MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
3082
Ido Schimmel91329e22018-07-25 09:23:50 +03003083static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
3084 unsigned long *erp_vector,
3085 unsigned long size)
3086{
3087 unsigned long bit;
3088
3089 for_each_set_bit(bit, erp_vector, size)
3090 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
3091}
3092
3093static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
3094 bool ctcam_le, bool erpt_pointer_valid,
3095 u8 erpt_bank_pointer, u8 erpt_pointer,
3096 u8 master_rp_id)
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03003097{
3098 MLXSW_REG_ZERO(pererp, payload);
3099 mlxsw_reg_pererp_region_id_set(payload, region_id);
Ido Schimmel91329e22018-07-25 09:23:50 +03003100 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
3101 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
3102 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
3103 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
3104 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03003105}
3106
Nir Dotan418089a2018-12-16 08:49:24 +00003107/* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
3108 * ----------------------------------------------------------------
3109 * This register configures the Bloom filter entries.
3110 */
3111#define MLXSW_REG_PEABFE_ID 0x3022
3112#define MLXSW_REG_PEABFE_BASE_LEN 0x10
3113#define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3114#define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3115#define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3116 MLXSW_REG_PEABFE_BF_REC_LEN * \
3117 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3118
3119MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3120
3121/* reg_peabfe_size
3122 * Number of BF entries to be updated.
3123 * Range 1..256
3124 * Access: Op
3125 */
3126MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3127
3128/* reg_peabfe_bf_entry_state
3129 * Bloom filter state
3130 * 0 - Clear
3131 * 1 - Set
3132 * Access: RW
3133 */
3134MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3135 MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3136 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3137
3138/* reg_peabfe_bf_entry_bank
3139 * Bloom filter bank ID
3140 * Range 0..cap_max_erp_table_banks-1
3141 * Access: Index
3142 */
3143MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3144 MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3145 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3146
3147/* reg_peabfe_bf_entry_index
3148 * Bloom filter entry index
3149 * Range 0..2^cap_max_bf_log-1
3150 * Access: Index
3151 */
3152MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3153 MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3154 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3155
3156static inline void mlxsw_reg_peabfe_pack(char *payload)
3157{
3158 MLXSW_REG_ZERO(peabfe, payload);
3159}
3160
3161static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3162 u8 state, u8 bank, u32 bf_index)
3163{
3164 u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3165
3166 if (rec_index >= num_rec)
3167 mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3168 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3169 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3170 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3171}
3172
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03003173/* IEDR - Infrastructure Entry Delete Register
3174 * ----------------------------------------------------
3175 * This register is used for deleting entries from the entry tables.
3176 * It is legitimate to attempt to delete a nonexisting entry (the device will
3177 * respond as a good flow).
3178 */
3179#define MLXSW_REG_IEDR_ID 0x3804
3180#define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
3181#define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
3182#define MLXSW_REG_IEDR_REC_MAX_COUNT 64
3183#define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
3184 MLXSW_REG_IEDR_REC_LEN * \
3185 MLXSW_REG_IEDR_REC_MAX_COUNT)
3186
3187MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
3188
3189/* reg_iedr_num_rec
3190 * Number of records.
3191 * Access: OP
3192 */
3193MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
3194
3195/* reg_iedr_rec_type
3196 * Resource type.
3197 * Access: OP
3198 */
3199MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
3200 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3201
3202/* reg_iedr_rec_size
3203 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
3204 * Access: OP
3205 */
Ido Schimmelb7f03b02020-04-19 10:01:06 +03003206MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13,
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03003207 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3208
3209/* reg_iedr_rec_index_start
3210 * Resource index start.
3211 * Access: OP
3212 */
3213MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3214 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3215
3216static inline void mlxsw_reg_iedr_pack(char *payload)
3217{
3218 MLXSW_REG_ZERO(iedr, payload);
3219}
3220
3221static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3222 u8 rec_type, u16 rec_size,
3223 u32 rec_index_start)
3224{
3225 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3226
3227 if (rec_index >= num_rec)
3228 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3229 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3230 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3231 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3232}
3233
Petr Machata746da422018-07-27 15:26:58 +03003234/* QPTS - QoS Priority Trust State Register
3235 * ----------------------------------------
3236 * This register controls the port policy to calculate the switch priority and
3237 * packet color based on incoming packet fields.
3238 */
3239#define MLXSW_REG_QPTS_ID 0x4002
3240#define MLXSW_REG_QPTS_LEN 0x8
3241
3242MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3243
3244/* reg_qpts_local_port
3245 * Local port number.
3246 * Access: Index
3247 *
3248 * Note: CPU port is supported.
3249 */
3250MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
3251
3252enum mlxsw_reg_qpts_trust_state {
3253 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3254 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3255};
3256
3257/* reg_qpts_trust_state
3258 * Trust state for a given port.
3259 * Access: RW
3260 */
3261MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3262
3263static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
3264 enum mlxsw_reg_qpts_trust_state ts)
3265{
3266 MLXSW_REG_ZERO(qpts, payload);
3267
3268 mlxsw_reg_qpts_local_port_set(payload, local_port);
3269 mlxsw_reg_qpts_trust_state_set(payload, ts);
3270}
3271
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003272/* QPCR - QoS Policer Configuration Register
3273 * -----------------------------------------
3274 * The QPCR register is used to create policers - that limit
3275 * the rate of bytes or packets via some trap group.
3276 */
3277#define MLXSW_REG_QPCR_ID 0x4004
3278#define MLXSW_REG_QPCR_LEN 0x28
3279
3280MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3281
3282enum mlxsw_reg_qpcr_g {
3283 MLXSW_REG_QPCR_G_GLOBAL = 2,
3284 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3285};
3286
3287/* reg_qpcr_g
3288 * The policer type.
3289 * Access: Index
3290 */
3291MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3292
3293/* reg_qpcr_pid
3294 * Policer ID.
3295 * Access: Index
3296 */
3297MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3298
Ido Schimmel2b84d7c2020-03-30 22:38:25 +03003299/* reg_qpcr_clear_counter
3300 * Clear counters.
3301 * Access: OP
3302 */
3303MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1);
3304
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003305/* reg_qpcr_color_aware
3306 * Is the policer aware of colors.
3307 * Must be 0 (unaware) for cpu port.
3308 * Access: RW for unbounded policer. RO for bounded policer.
3309 */
3310MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3311
3312/* reg_qpcr_bytes
3313 * Is policer limit is for bytes per sec or packets per sec.
3314 * 0 - packets
3315 * 1 - bytes
3316 * Access: RW for unbounded policer. RO for bounded policer.
3317 */
3318MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3319
3320enum mlxsw_reg_qpcr_ir_units {
3321 MLXSW_REG_QPCR_IR_UNITS_M,
3322 MLXSW_REG_QPCR_IR_UNITS_K,
3323};
3324
3325/* reg_qpcr_ir_units
3326 * Policer's units for cir and eir fields (for bytes limits only)
3327 * 1 - 10^3
3328 * 0 - 10^6
3329 * Access: OP
3330 */
3331MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3332
3333enum mlxsw_reg_qpcr_rate_type {
3334 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3335 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3336};
3337
3338/* reg_qpcr_rate_type
3339 * Policer can have one limit (single rate) or 2 limits with specific operation
3340 * for packets that exceed the lower rate but not the upper one.
3341 * (For cpu port must be single rate)
3342 * Access: RW for unbounded policer. RO for bounded policer.
3343 */
3344MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3345
3346/* reg_qpc_cbs
3347 * Policer's committed burst size.
3348 * The policer is working with time slices of 50 nano sec. By default every
3349 * slice is granted the proportionate share of the committed rate. If we want to
3350 * allow a slice to exceed that share (while still keeping the rate per sec) we
3351 * can allow burst. The burst size is between the default proportionate share
3352 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3353 * committed rate will result in exceeding the rate). The burst size must be a
3354 * log of 2 and will be determined by 2^cbs.
3355 * Access: RW
3356 */
3357MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3358
3359/* reg_qpcr_cir
3360 * Policer's committed rate.
3361 * The rate used for sungle rate, the lower rate for double rate.
3362 * For bytes limits, the rate will be this value * the unit from ir_units.
3363 * (Resolution error is up to 1%).
3364 * Access: RW
3365 */
3366MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3367
3368/* reg_qpcr_eir
3369 * Policer's exceed rate.
3370 * The higher rate for double rate, reserved for single rate.
3371 * Lower rate for double rate policer.
3372 * For bytes limits, the rate will be this value * the unit from ir_units.
3373 * (Resolution error is up to 1%).
3374 * Access: RW
3375 */
3376MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3377
3378#define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3379
3380/* reg_qpcr_exceed_action.
3381 * What to do with packets between the 2 limits for double rate.
3382 * Access: RW for unbounded policer. RO for bounded policer.
3383 */
3384MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3385
3386enum mlxsw_reg_qpcr_action {
3387 /* Discard */
3388 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3389 /* Forward and set color to red.
3390 * If the packet is intended to cpu port, it will be dropped.
3391 */
3392 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3393};
3394
3395/* reg_qpcr_violate_action
3396 * What to do with packets that cross the cir limit (for single rate) or the eir
3397 * limit (for double rate).
3398 * Access: RW for unbounded policer. RO for bounded policer.
3399 */
3400MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3401
Ido Schimmel2b84d7c2020-03-30 22:38:25 +03003402/* reg_qpcr_violate_count
3403 * Counts the number of times violate_action happened on this PID.
3404 * Access: RW
3405 */
3406MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64);
3407
Ido Schimmelfbf0f5d2020-07-15 11:27:23 +03003408/* Packets */
Ido Schimmel2b84d7c2020-03-30 22:38:25 +03003409#define MLXSW_REG_QPCR_LOWEST_CIR 1
3410#define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000) /* 2Gpps */
3411#define MLXSW_REG_QPCR_LOWEST_CBS 4
3412#define MLXSW_REG_QPCR_HIGHEST_CBS 24
3413
Ido Schimmelfbf0f5d2020-07-15 11:27:23 +03003414/* Bandwidth */
3415#define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024 /* bps */
3416#define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL /* 2Tbps */
3417#define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4
3418#define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4
3419#define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25
3420#define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31
3421
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003422static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3423 enum mlxsw_reg_qpcr_ir_units ir_units,
3424 bool bytes, u32 cir, u16 cbs)
3425{
3426 MLXSW_REG_ZERO(qpcr, payload);
3427 mlxsw_reg_qpcr_pid_set(payload, pid);
3428 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3429 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3430 mlxsw_reg_qpcr_violate_action_set(payload,
3431 MLXSW_REG_QPCR_ACTION_DISCARD);
3432 mlxsw_reg_qpcr_cir_set(payload, cir);
3433 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3434 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3435 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3436}
3437
Ido Schimmel2c63a552016-04-06 17:10:07 +02003438/* QTCT - QoS Switch Traffic Class Table
3439 * -------------------------------------
3440 * Configures the mapping between the packet switch priority and the
3441 * traffic class on the transmit port.
3442 */
3443#define MLXSW_REG_QTCT_ID 0x400A
3444#define MLXSW_REG_QTCT_LEN 0x08
3445
Jiri Pirko21978dc2016-10-21 16:07:20 +02003446MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
Ido Schimmel2c63a552016-04-06 17:10:07 +02003447
3448/* reg_qtct_local_port
3449 * Local port number.
3450 * Access: Index
3451 *
3452 * Note: CPU port is not supported.
3453 */
3454MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
3455
3456/* reg_qtct_sub_port
3457 * Virtual port within the physical port.
3458 * Should be set to 0 when virtual ports are not enabled on the port.
3459 * Access: Index
3460 */
3461MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3462
3463/* reg_qtct_switch_prio
3464 * Switch priority.
3465 * Access: Index
3466 */
3467MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3468
3469/* reg_qtct_tclass
3470 * Traffic class.
3471 * Default values:
3472 * switch_prio 0 : tclass 1
3473 * switch_prio 1 : tclass 0
3474 * switch_prio i : tclass i, for i > 1
3475 * Access: RW
3476 */
3477MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3478
3479static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3480 u8 switch_prio, u8 tclass)
3481{
3482 MLXSW_REG_ZERO(qtct, payload);
3483 mlxsw_reg_qtct_local_port_set(payload, local_port);
3484 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3485 mlxsw_reg_qtct_tclass_set(payload, tclass);
3486}
3487
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003488/* QEEC - QoS ETS Element Configuration Register
3489 * ---------------------------------------------
3490 * Configures the ETS elements.
3491 */
3492#define MLXSW_REG_QEEC_ID 0x400D
Petr Machata8b931822018-10-31 09:56:42 +00003493#define MLXSW_REG_QEEC_LEN 0x20
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003494
Jiri Pirko21978dc2016-10-21 16:07:20 +02003495MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003496
3497/* reg_qeec_local_port
3498 * Local port number.
3499 * Access: Index
3500 *
3501 * Note: CPU port is supported.
3502 */
3503MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
3504
3505enum mlxsw_reg_qeec_hr {
Petr Machata9cf9b922019-12-18 14:55:11 +00003506 MLXSW_REG_QEEC_HR_PORT,
3507 MLXSW_REG_QEEC_HR_GROUP,
3508 MLXSW_REG_QEEC_HR_SUBGROUP,
3509 MLXSW_REG_QEEC_HR_TC,
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003510};
3511
3512/* reg_qeec_element_hierarchy
3513 * 0 - Port
3514 * 1 - Group
3515 * 2 - Subgroup
3516 * 3 - Traffic Class
3517 * Access: Index
3518 */
3519MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3520
3521/* reg_qeec_element_index
3522 * The index of the element in the hierarchy.
3523 * Access: Index
3524 */
3525MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3526
3527/* reg_qeec_next_element_index
3528 * The index of the next (lower) element in the hierarchy.
3529 * Access: RW
3530 *
3531 * Note: Reserved for element_hierarchy 0.
3532 */
3533MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3534
Petr Machata8b931822018-10-31 09:56:42 +00003535/* reg_qeec_mise
3536 * Min shaper configuration enable. Enables configuration of the min
3537 * shaper on this ETS element
3538 * 0 - Disable
3539 * 1 - Enable
3540 * Access: RW
3541 */
3542MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3543
Shalom Toledo12f0e2e2019-07-04 10:07:33 +03003544/* reg_qeec_ptps
3545 * PTP shaper
3546 * 0: regular shaper mode
3547 * 1: PTP oriented shaper
3548 * Allowed only for hierarchy 0
3549 * Not supported for CPU port
3550 * Note that ptps mode may affect the shaper rates of all hierarchies
3551 * Supported only on Spectrum-1
3552 * Access: RW
3553 */
3554MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
3555
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003556enum {
3557 MLXSW_REG_QEEC_BYTES_MODE,
3558 MLXSW_REG_QEEC_PACKETS_MODE,
3559};
3560
3561/* reg_qeec_pb
3562 * Packets or bytes mode.
3563 * 0 - Bytes mode
3564 * 1 - Packets mode
3565 * Access: RW
3566 *
3567 * Note: Used for max shaper configuration. For Spectrum, packets mode
3568 * is supported only for traffic classes of CPU port.
3569 */
3570MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3571
Petr Machata8b931822018-10-31 09:56:42 +00003572/* The smallest permitted min shaper rate. */
3573#define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
3574
3575/* reg_qeec_min_shaper_rate
3576 * Min shaper information rate.
3577 * For CPU port, can only be configured for port hierarchy.
3578 * When in bytes mode, value is specified in units of 1000bps.
3579 * Access: RW
3580 */
3581MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3582
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003583/* reg_qeec_mase
3584 * Max shaper configuration enable. Enables configuration of the max
3585 * shaper on this ETS element.
3586 * 0 - Disable
3587 * 1 - Enable
3588 * Access: RW
3589 */
3590MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3591
Petr Machata92afbfe2020-01-24 15:23:11 +02003592/* The largest max shaper value possible to disable the shaper. */
3593#define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1) /* Kbps */
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003594
3595/* reg_qeec_max_shaper_rate
3596 * Max shaper information rate.
3597 * For CPU port, can only be configured for port hierarchy.
3598 * When in bytes mode, value is specified in units of 1000bps.
3599 * Access: RW
3600 */
Ido Schimmelcb851c02020-03-15 10:07:35 +02003601MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003602
3603/* reg_qeec_de
3604 * DWRR configuration enable. Enables configuration of the dwrr and
3605 * dwrr_weight.
3606 * 0 - Disable
3607 * 1 - Enable
3608 * Access: RW
3609 */
3610MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3611
3612/* reg_qeec_dwrr
3613 * Transmission selection algorithm to use on the link going down from
3614 * the ETS element.
3615 * 0 - Strict priority
3616 * 1 - DWRR
3617 * Access: RW
3618 */
3619MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3620
3621/* reg_qeec_dwrr_weight
3622 * DWRR weight on the link going down from the ETS element. The
3623 * percentage of bandwidth guaranteed to an ETS element within
3624 * its hierarchy. The sum of all weights across all ETS elements
3625 * within one hierarchy should be equal to 100. Reserved when
3626 * transmission selection algorithm is strict priority.
3627 * Access: RW
3628 */
3629MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3630
Petr Machata23effa22020-01-24 15:23:10 +02003631/* reg_qeec_max_shaper_bs
3632 * Max shaper burst size
3633 * Burst size is 2^max_shaper_bs * 512 bits
3634 * For Spectrum-1: Range is: 5..25
3635 * For Spectrum-2: Range is: 11..25
3636 * Reserved when ptps = 1
3637 * Access: RW
3638 */
3639MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
3640
3641#define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25
3642#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
3643#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
3644#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 5
3645
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003646static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
3647 enum mlxsw_reg_qeec_hr hr, u8 index,
3648 u8 next_index)
3649{
3650 MLXSW_REG_ZERO(qeec, payload);
3651 mlxsw_reg_qeec_local_port_set(payload, local_port);
3652 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3653 mlxsw_reg_qeec_element_index_set(payload, index);
3654 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3655}
3656
Shalom Toledo12f0e2e2019-07-04 10:07:33 +03003657static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u8 local_port,
3658 bool ptps)
3659{
3660 MLXSW_REG_ZERO(qeec, payload);
3661 mlxsw_reg_qeec_local_port_set(payload, local_port);
Petr Machata9cf9b922019-12-18 14:55:11 +00003662 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
Shalom Toledo12f0e2e2019-07-04 10:07:33 +03003663 mlxsw_reg_qeec_ptps_set(payload, ptps);
3664}
3665
Petr Machatae67131d2018-07-27 15:26:59 +03003666/* QRWE - QoS ReWrite Enable
3667 * -------------------------
3668 * This register configures the rewrite enable per receive port.
3669 */
3670#define MLXSW_REG_QRWE_ID 0x400F
3671#define MLXSW_REG_QRWE_LEN 0x08
3672
3673MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3674
3675/* reg_qrwe_local_port
3676 * Local port number.
3677 * Access: Index
3678 *
3679 * Note: CPU port is supported. No support for router port.
3680 */
3681MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
3682
3683/* reg_qrwe_dscp
3684 * Whether to enable DSCP rewrite (default is 0, don't rewrite).
3685 * Access: RW
3686 */
3687MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3688
3689/* reg_qrwe_pcp
3690 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
3691 * Access: RW
3692 */
3693MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3694
3695static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
3696 bool rewrite_pcp, bool rewrite_dscp)
3697{
3698 MLXSW_REG_ZERO(qrwe, payload);
3699 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3700 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3701 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3702}
3703
Petr Machata55fb71f2018-07-27 15:27:00 +03003704/* QPDSM - QoS Priority to DSCP Mapping
3705 * ------------------------------------
3706 * QoS Priority to DSCP Mapping Register
3707 */
3708#define MLXSW_REG_QPDSM_ID 0x4011
3709#define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
3710#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
3711#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3712#define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3713 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3714 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3715
3716MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3717
3718/* reg_qpdsm_local_port
3719 * Local Port. Supported for data packets from CPU port.
3720 * Access: Index
3721 */
3722MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
3723
3724/* reg_qpdsm_prio_entry_color0_e
3725 * Enable update of the entry for color 0 and a given port.
3726 * Access: WO
3727 */
3728MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
3729 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
3730 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3731
3732/* reg_qpdsm_prio_entry_color0_dscp
3733 * DSCP field in the outer label of the packet for color 0 and a given port.
3734 * Reserved when e=0.
3735 * Access: RW
3736 */
3737MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
3738 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
3739 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3740
3741/* reg_qpdsm_prio_entry_color1_e
3742 * Enable update of the entry for color 1 and a given port.
3743 * Access: WO
3744 */
3745MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
3746 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
3747 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3748
3749/* reg_qpdsm_prio_entry_color1_dscp
3750 * DSCP field in the outer label of the packet for color 1 and a given port.
3751 * Reserved when e=0.
3752 * Access: RW
3753 */
3754MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
3755 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
3756 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3757
3758/* reg_qpdsm_prio_entry_color2_e
3759 * Enable update of the entry for color 2 and a given port.
3760 * Access: WO
3761 */
3762MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
3763 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
3764 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3765
3766/* reg_qpdsm_prio_entry_color2_dscp
3767 * DSCP field in the outer label of the packet for color 2 and a given port.
3768 * Reserved when e=0.
3769 * Access: RW
3770 */
3771MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
3772 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
3773 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3774
3775static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
3776{
3777 MLXSW_REG_ZERO(qpdsm, payload);
3778 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
3779}
3780
3781static inline void
3782mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
3783{
3784 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
3785 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
3786 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
3787 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
3788 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
3789 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
3790}
3791
Petr Machatad8446882019-12-29 13:48:27 +02003792/* QPDP - QoS Port DSCP to Priority Mapping Register
3793 * -------------------------------------------------
3794 * This register controls the port default Switch Priority and Color. The
3795 * default Switch Priority and Color are used for frames where the trust state
3796 * uses default values. All member ports of a LAG should be configured with the
3797 * same default values.
3798 */
3799#define MLXSW_REG_QPDP_ID 0x4007
3800#define MLXSW_REG_QPDP_LEN 0x8
3801
3802MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
3803
3804/* reg_qpdp_local_port
3805 * Local Port. Supported for data packets from CPU port.
3806 * Access: Index
3807 */
3808MLXSW_ITEM32(reg, qpdp, local_port, 0x00, 16, 8);
3809
3810/* reg_qpdp_switch_prio
3811 * Default port Switch Priority (default 0)
3812 * Access: RW
3813 */
3814MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
3815
3816static inline void mlxsw_reg_qpdp_pack(char *payload, u8 local_port,
3817 u8 switch_prio)
3818{
3819 MLXSW_REG_ZERO(qpdp, payload);
3820 mlxsw_reg_qpdp_local_port_set(payload, local_port);
3821 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
3822}
3823
Petr Machata02837d72018-07-27 15:26:57 +03003824/* QPDPM - QoS Port DSCP to Priority Mapping Register
3825 * --------------------------------------------------
3826 * This register controls the mapping from DSCP field to
3827 * Switch Priority for IP packets.
3828 */
3829#define MLXSW_REG_QPDPM_ID 0x4013
3830#define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
3831#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
3832#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
3833#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
3834 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
3835 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
3836
3837MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
3838
3839/* reg_qpdpm_local_port
3840 * Local Port. Supported for data packets from CPU port.
3841 * Access: Index
3842 */
3843MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
3844
3845/* reg_qpdpm_dscp_e
3846 * Enable update of the specific entry. When cleared, the switch_prio and color
3847 * fields are ignored and the previous switch_prio and color values are
3848 * preserved.
3849 * Access: WO
3850 */
3851MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
3852 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3853
3854/* reg_qpdpm_dscp_prio
3855 * The new Switch Priority value for the relevant DSCP value.
3856 * Access: RW
3857 */
3858MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
3859 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
3860 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3861
3862static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
3863{
3864 MLXSW_REG_ZERO(qpdpm, payload);
3865 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
3866}
3867
3868static inline void
3869mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
3870{
3871 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
3872 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
3873}
3874
Petr Machata671ae8a2018-08-05 09:03:06 +03003875/* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
3876 * ------------------------------------------------------------------
3877 * This register configures if the Switch Priority to Traffic Class mapping is
3878 * based on Multicast packet indication. If so, then multicast packets will get
3879 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
3880 * QTCT.
3881 * By default, Switch Priority to Traffic Class mapping is not based on
3882 * Multicast packet indication.
3883 */
3884#define MLXSW_REG_QTCTM_ID 0x401A
3885#define MLXSW_REG_QTCTM_LEN 0x08
3886
3887MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
3888
3889/* reg_qtctm_local_port
3890 * Local port number.
3891 * No support for CPU port.
3892 * Access: Index
3893 */
3894MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
3895
3896/* reg_qtctm_mc
3897 * Multicast Mode
3898 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
3899 * indication (default is 0, not based on Multicast packet indication).
3900 */
3901MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
3902
3903static inline void
3904mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
3905{
3906 MLXSW_REG_ZERO(qtctm, payload);
3907 mlxsw_reg_qtctm_local_port_set(payload, local_port);
3908 mlxsw_reg_qtctm_mc_set(payload, mc);
3909}
3910
Shalom Toledo71147502019-07-04 10:07:35 +03003911/* QPSC - QoS PTP Shaper Configuration Register
3912 * --------------------------------------------
3913 * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1.
3914 * Supported only on Spectrum-1.
3915 */
3916#define MLXSW_REG_QPSC_ID 0x401B
3917#define MLXSW_REG_QPSC_LEN 0x28
3918
3919MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
3920
3921enum mlxsw_reg_qpsc_port_speed {
3922 MLXSW_REG_QPSC_PORT_SPEED_100M,
3923 MLXSW_REG_QPSC_PORT_SPEED_1G,
3924 MLXSW_REG_QPSC_PORT_SPEED_10G,
3925 MLXSW_REG_QPSC_PORT_SPEED_25G,
3926};
3927
3928/* reg_qpsc_port_speed
3929 * Port speed.
3930 * Access: Index
3931 */
3932MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
3933
3934/* reg_qpsc_shaper_time_exp
3935 * The base-time-interval for updating the shapers tokens (for all hierarchies).
3936 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
3937 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
3938 * Access: RW
3939 */
3940MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
3941
3942/* reg_qpsc_shaper_time_mantissa
3943 * The base-time-interval for updating the shapers tokens (for all hierarchies).
3944 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
3945 * shaper_rate = 64bit * shaper_inc / shaper_update_rate
3946 * Access: RW
3947 */
3948MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
3949
3950/* reg_qpsc_shaper_inc
3951 * Number of tokens added to shaper on each update.
3952 * Units of 8B.
3953 * Access: RW
3954 */
3955MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
3956
3957/* reg_qpsc_shaper_bs
3958 * Max shaper Burst size.
3959 * Burst size is 2 ^ max_shaper_bs * 512 [bits]
3960 * Range is: 5..25 (from 2KB..2GB)
3961 * Access: RW
3962 */
3963MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
3964
3965/* reg_qpsc_ptsc_we
3966 * Write enable to port_to_shaper_credits.
3967 * Access: WO
3968 */
3969MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
3970
3971/* reg_qpsc_port_to_shaper_credits
3972 * For split ports: range 1..57
3973 * For non-split ports: range 1..112
3974 * Written only when ptsc_we is set.
3975 * Access: RW
3976 */
3977MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
3978
3979/* reg_qpsc_ing_timestamp_inc
3980 * Ingress timestamp increment.
3981 * 2's complement.
3982 * The timestamp of MTPPTR at ingress will be incremented by this value. Global
3983 * value for all ports.
3984 * Same units as used by MTPPTR.
3985 * Access: RW
3986 */
3987MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
3988
3989/* reg_qpsc_egr_timestamp_inc
3990 * Egress timestamp increment.
3991 * 2's complement.
3992 * The timestamp of MTPPTR at egress will be incremented by this value. Global
3993 * value for all ports.
3994 * Same units as used by MTPPTR.
3995 * Access: RW
3996 */
3997MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
3998
3999static inline void
4000mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
4001 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
4002 u8 shaper_bs, u8 port_to_shaper_credits,
4003 int ing_timestamp_inc, int egr_timestamp_inc)
4004{
4005 MLXSW_REG_ZERO(qpsc, payload);
4006 mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
4007 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
4008 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
4009 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
4010 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
4011 mlxsw_reg_qpsc_ptsc_we_set(payload, true);
4012 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
4013 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
4014 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
4015}
4016
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004017/* PMLP - Ports Module to Local Port Register
4018 * ------------------------------------------
4019 * Configures the assignment of modules to local ports.
4020 */
4021#define MLXSW_REG_PMLP_ID 0x5002
4022#define MLXSW_REG_PMLP_LEN 0x40
4023
Jiri Pirko21978dc2016-10-21 16:07:20 +02004024MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004025
4026/* reg_pmlp_rxtx
4027 * 0 - Tx value is used for both Tx and Rx.
4028 * 1 - Rx value is taken from a separte field.
4029 * Access: RW
4030 */
4031MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
4032
4033/* reg_pmlp_local_port
4034 * Local port number.
4035 * Access: Index
4036 */
4037MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
4038
4039/* reg_pmlp_width
4040 * 0 - Unmap local port.
4041 * 1 - Lane 0 is used.
4042 * 2 - Lanes 0 and 1 are used.
4043 * 4 - Lanes 0, 1, 2 and 3 are used.
Jiri Pirko94e76832019-10-31 11:42:06 +02004044 * 8 - Lanes 0-7 are used.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004045 * Access: RW
4046 */
4047MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
4048
4049/* reg_pmlp_module
4050 * Module number.
4051 * Access: RW
4052 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01004053MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004054
4055/* reg_pmlp_tx_lane
4056 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
4057 * Access: RW
4058 */
Jiri Pirko94e76832019-10-31 11:42:06 +02004059MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004060
4061/* reg_pmlp_rx_lane
4062 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
4063 * equal to Tx lane.
4064 * Access: RW
4065 */
Jiri Pirko94e76832019-10-31 11:42:06 +02004066MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004067
4068static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
4069{
4070 MLXSW_REG_ZERO(pmlp, payload);
4071 mlxsw_reg_pmlp_local_port_set(payload, local_port);
4072}
4073
4074/* PMTU - Port MTU Register
4075 * ------------------------
4076 * Configures and reports the port MTU.
4077 */
4078#define MLXSW_REG_PMTU_ID 0x5003
4079#define MLXSW_REG_PMTU_LEN 0x10
4080
Jiri Pirko21978dc2016-10-21 16:07:20 +02004081MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004082
4083/* reg_pmtu_local_port
4084 * Local port number.
4085 * Access: Index
4086 */
4087MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
4088
4089/* reg_pmtu_max_mtu
4090 * Maximum MTU.
4091 * When port type (e.g. Ethernet) is configured, the relevant MTU is
4092 * reported, otherwise the minimum between the max_mtu of the different
4093 * types is reported.
4094 * Access: RO
4095 */
4096MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
4097
4098/* reg_pmtu_admin_mtu
4099 * MTU value to set port to. Must be smaller or equal to max_mtu.
4100 * Note: If port type is Infiniband, then port must be disabled, when its
4101 * MTU is set.
4102 * Access: RW
4103 */
4104MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
4105
4106/* reg_pmtu_oper_mtu
4107 * The actual MTU configured on the port. Packets exceeding this size
4108 * will be dropped.
4109 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
4110 * oper_mtu might be smaller than admin_mtu.
4111 * Access: RO
4112 */
4113MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
4114
4115static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
4116 u16 new_mtu)
4117{
4118 MLXSW_REG_ZERO(pmtu, payload);
4119 mlxsw_reg_pmtu_local_port_set(payload, local_port);
4120 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
4121 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
4122 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
4123}
4124
4125/* PTYS - Port Type and Speed Register
4126 * -----------------------------------
4127 * Configures and reports the port speed type.
4128 *
4129 * Note: When set while the link is up, the changes will not take effect
4130 * until the port transitions from down to up state.
4131 */
4132#define MLXSW_REG_PTYS_ID 0x5004
4133#define MLXSW_REG_PTYS_LEN 0x40
4134
Jiri Pirko21978dc2016-10-21 16:07:20 +02004135MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004136
Tal Bar8e1ed732018-03-21 09:34:06 +02004137/* an_disable_admin
4138 * Auto negotiation disable administrative configuration
4139 * 0 - Device doesn't support AN disable.
4140 * 1 - Device supports AN disable.
4141 * Access: RW
4142 */
4143MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
4144
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004145/* reg_ptys_local_port
4146 * Local port number.
4147 * Access: Index
4148 */
4149MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
4150
Elad Raz79417702016-10-28 21:35:53 +02004151#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004152#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
4153
4154/* reg_ptys_proto_mask
4155 * Protocol mask. Indicates which protocol is used.
4156 * 0 - Infiniband.
4157 * 1 - Fibre Channel.
4158 * 2 - Ethernet.
4159 * Access: Index
4160 */
4161MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
4162
Ido Schimmel4149b972016-09-12 13:26:24 +02004163enum {
4164 MLXSW_REG_PTYS_AN_STATUS_NA,
4165 MLXSW_REG_PTYS_AN_STATUS_OK,
4166 MLXSW_REG_PTYS_AN_STATUS_FAIL,
4167};
4168
4169/* reg_ptys_an_status
4170 * Autonegotiation status.
4171 * Access: RO
4172 */
4173MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
4174
Shalom Toledo9ce84392019-02-22 13:56:44 +00004175#define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
4176#define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
Shalom Toledo9ce84392019-02-22 13:56:44 +00004177#define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
4178#define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
4179#define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
4180#define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
4181#define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
4182#define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
4183#define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
4184#define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
4185#define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
Jiri Pirko5bd29b92019-10-12 18:27:58 +02004186#define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
Shalom Toledo9ce84392019-02-22 13:56:44 +00004187
4188/* reg_ptys_ext_eth_proto_cap
4189 * Extended Ethernet port supported speeds and protocols.
4190 * Access: RO
4191 */
4192MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
4193
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004194#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
4195#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
4196#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
4197#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
4198#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004199#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
4200#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004201#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
4202#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
4203#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
4204#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
4205#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
Ido Schimmelb9d66a32016-09-12 13:26:27 +02004206#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004207#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
4208#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
4209#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
4210#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004211#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
4212#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
4213#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
4214#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
4215#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
4216
4217/* reg_ptys_eth_proto_cap
4218 * Ethernet port supported speeds and protocols.
4219 * Access: RO
4220 */
4221MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
4222
Elad Raz79417702016-10-28 21:35:53 +02004223/* reg_ptys_ib_link_width_cap
4224 * IB port supported widths.
4225 * Access: RO
4226 */
4227MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
4228
4229#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
4230#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
4231#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
4232#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
4233#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
4234#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
4235
4236/* reg_ptys_ib_proto_cap
4237 * IB port supported speeds and protocols.
4238 * Access: RO
4239 */
4240MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
4241
Shalom Toledo9ce84392019-02-22 13:56:44 +00004242/* reg_ptys_ext_eth_proto_admin
4243 * Extended speed and protocol to set port to.
4244 * Access: RW
4245 */
4246MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
4247
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004248/* reg_ptys_eth_proto_admin
4249 * Speed and protocol to set port to.
4250 * Access: RW
4251 */
4252MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
4253
Elad Raz79417702016-10-28 21:35:53 +02004254/* reg_ptys_ib_link_width_admin
4255 * IB width to set port to.
4256 * Access: RW
4257 */
4258MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
4259
4260/* reg_ptys_ib_proto_admin
4261 * IB speeds and protocols to set port to.
4262 * Access: RW
4263 */
4264MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
4265
Shalom Toledo9ce84392019-02-22 13:56:44 +00004266/* reg_ptys_ext_eth_proto_oper
4267 * The extended current speed and protocol configured for the port.
4268 * Access: RO
4269 */
4270MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
4271
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004272/* reg_ptys_eth_proto_oper
4273 * The current speed and protocol configured for the port.
4274 * Access: RO
4275 */
4276MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
4277
Elad Raz79417702016-10-28 21:35:53 +02004278/* reg_ptys_ib_link_width_oper
4279 * The current IB width to set port to.
4280 * Access: RO
4281 */
4282MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
4283
4284/* reg_ptys_ib_proto_oper
4285 * The current IB speed and protocol.
4286 * Access: RO
4287 */
4288MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
4289
Shalom Toledo1e2f66e2019-02-22 13:56:38 +00004290enum mlxsw_reg_ptys_connector_type {
4291 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
4292 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
4293 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
4294 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
4295 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
4296 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
4297 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
4298 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
4299 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
4300};
4301
4302/* reg_ptys_connector_type
4303 * Connector type indication.
4304 * Access: RO
4305 */
4306MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
4307
Elad Raz401c8b42016-10-28 21:35:52 +02004308static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
Tal Bar8e1ed732018-03-21 09:34:06 +02004309 u32 proto_admin, bool autoneg)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004310{
4311 MLXSW_REG_ZERO(ptys, payload);
4312 mlxsw_reg_ptys_local_port_set(payload, local_port);
4313 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4314 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
Tal Bar8e1ed732018-03-21 09:34:06 +02004315 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004316}
4317
Shalom Toledo9ce84392019-02-22 13:56:44 +00004318static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u8 local_port,
4319 u32 proto_admin, bool autoneg)
4320{
4321 MLXSW_REG_ZERO(ptys, payload);
4322 mlxsw_reg_ptys_local_port_set(payload, local_port);
4323 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4324 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
4325 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4326}
4327
Elad Raz401c8b42016-10-28 21:35:52 +02004328static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
4329 u32 *p_eth_proto_cap,
Shalom Toledoe6f66f52019-02-22 13:56:41 +00004330 u32 *p_eth_proto_admin,
Elad Raz401c8b42016-10-28 21:35:52 +02004331 u32 *p_eth_proto_oper)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004332{
4333 if (p_eth_proto_cap)
Shalom Toledo1dc3c0a2019-02-22 13:56:42 +00004334 *p_eth_proto_cap =
4335 mlxsw_reg_ptys_eth_proto_cap_get(payload);
Shalom Toledoe6f66f52019-02-22 13:56:41 +00004336 if (p_eth_proto_admin)
Shalom Toledo1dc3c0a2019-02-22 13:56:42 +00004337 *p_eth_proto_admin =
4338 mlxsw_reg_ptys_eth_proto_admin_get(payload);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004339 if (p_eth_proto_oper)
Shalom Toledo1dc3c0a2019-02-22 13:56:42 +00004340 *p_eth_proto_oper =
4341 mlxsw_reg_ptys_eth_proto_oper_get(payload);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004342}
4343
Shalom Toledo9ce84392019-02-22 13:56:44 +00004344static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
4345 u32 *p_eth_proto_cap,
4346 u32 *p_eth_proto_admin,
4347 u32 *p_eth_proto_oper)
4348{
4349 if (p_eth_proto_cap)
4350 *p_eth_proto_cap =
4351 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
4352 if (p_eth_proto_admin)
4353 *p_eth_proto_admin =
4354 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
4355 if (p_eth_proto_oper)
4356 *p_eth_proto_oper =
4357 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
4358}
4359
Elad Raz79417702016-10-28 21:35:53 +02004360static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
4361 u16 proto_admin, u16 link_width)
4362{
4363 MLXSW_REG_ZERO(ptys, payload);
4364 mlxsw_reg_ptys_local_port_set(payload, local_port);
4365 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
4366 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
4367 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
4368}
4369
4370static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
4371 u16 *p_ib_link_width_cap,
4372 u16 *p_ib_proto_oper,
4373 u16 *p_ib_link_width_oper)
4374{
4375 if (p_ib_proto_cap)
4376 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
4377 if (p_ib_link_width_cap)
4378 *p_ib_link_width_cap =
4379 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
4380 if (p_ib_proto_oper)
4381 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
4382 if (p_ib_link_width_oper)
4383 *p_ib_link_width_oper =
4384 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
4385}
4386
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004387/* PPAD - Port Physical Address Register
4388 * -------------------------------------
4389 * The PPAD register configures the per port physical MAC address.
4390 */
4391#define MLXSW_REG_PPAD_ID 0x5005
4392#define MLXSW_REG_PPAD_LEN 0x10
4393
Jiri Pirko21978dc2016-10-21 16:07:20 +02004394MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004395
4396/* reg_ppad_single_base_mac
4397 * 0: base_mac, local port should be 0 and mac[7:0] is
4398 * reserved. HW will set incremental
4399 * 1: single_mac - mac of the local_port
4400 * Access: RW
4401 */
4402MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
4403
4404/* reg_ppad_local_port
4405 * port number, if single_base_mac = 0 then local_port is reserved
4406 * Access: RW
4407 */
4408MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
4409
4410/* reg_ppad_mac
4411 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
4412 * If single_base_mac = 1 - the per port MAC address
4413 * Access: RW
4414 */
4415MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
4416
4417static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
4418 u8 local_port)
4419{
4420 MLXSW_REG_ZERO(ppad, payload);
4421 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
4422 mlxsw_reg_ppad_local_port_set(payload, local_port);
4423}
4424
4425/* PAOS - Ports Administrative and Operational Status Register
4426 * -----------------------------------------------------------
4427 * Configures and retrieves per port administrative and operational status.
4428 */
4429#define MLXSW_REG_PAOS_ID 0x5006
4430#define MLXSW_REG_PAOS_LEN 0x10
4431
Jiri Pirko21978dc2016-10-21 16:07:20 +02004432MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004433
4434/* reg_paos_swid
4435 * Switch partition ID with which to associate the port.
4436 * Note: while external ports uses unique local port numbers (and thus swid is
4437 * redundant), router ports use the same local port number where swid is the
4438 * only indication for the relevant port.
4439 * Access: Index
4440 */
4441MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
4442
4443/* reg_paos_local_port
4444 * Local port number.
4445 * Access: Index
4446 */
4447MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
4448
4449/* reg_paos_admin_status
4450 * Port administrative state (the desired state of the port):
4451 * 1 - Up.
4452 * 2 - Down.
4453 * 3 - Up once. This means that in case of link failure, the port won't go
4454 * into polling mode, but will wait to be re-enabled by software.
4455 * 4 - Disabled by system. Can only be set by hardware.
4456 * Access: RW
4457 */
4458MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
4459
4460/* reg_paos_oper_status
4461 * Port operational state (the current state):
4462 * 1 - Up.
4463 * 2 - Down.
4464 * 3 - Down by port failure. This means that the device will not let the
4465 * port up again until explicitly specified by software.
4466 * Access: RO
4467 */
4468MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
4469
4470/* reg_paos_ase
4471 * Admin state update enabled.
4472 * Access: WO
4473 */
4474MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
4475
4476/* reg_paos_ee
4477 * Event update enable. If this bit is set, event generation will be
4478 * updated based on the e field.
4479 * Access: WO
4480 */
4481MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
4482
4483/* reg_paos_e
4484 * Event generation on operational state change:
4485 * 0 - Do not generate event.
4486 * 1 - Generate Event.
4487 * 2 - Generate Single Event.
4488 * Access: RW
4489 */
4490MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
4491
4492static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
4493 enum mlxsw_port_admin_status status)
4494{
4495 MLXSW_REG_ZERO(paos, payload);
4496 mlxsw_reg_paos_swid_set(payload, 0);
4497 mlxsw_reg_paos_local_port_set(payload, local_port);
4498 mlxsw_reg_paos_admin_status_set(payload, status);
4499 mlxsw_reg_paos_oper_status_set(payload, 0);
4500 mlxsw_reg_paos_ase_set(payload, 1);
4501 mlxsw_reg_paos_ee_set(payload, 1);
4502 mlxsw_reg_paos_e_set(payload, 1);
4503}
4504
Ido Schimmel6f253d82016-04-06 17:10:12 +02004505/* PFCC - Ports Flow Control Configuration Register
4506 * ------------------------------------------------
4507 * Configures and retrieves the per port flow control configuration.
4508 */
4509#define MLXSW_REG_PFCC_ID 0x5007
4510#define MLXSW_REG_PFCC_LEN 0x20
4511
Jiri Pirko21978dc2016-10-21 16:07:20 +02004512MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
Ido Schimmel6f253d82016-04-06 17:10:12 +02004513
4514/* reg_pfcc_local_port
4515 * Local port number.
4516 * Access: Index
4517 */
4518MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
4519
4520/* reg_pfcc_pnat
4521 * Port number access type. Determines the way local_port is interpreted:
4522 * 0 - Local port number.
4523 * 1 - IB / label port number.
4524 * Access: Index
4525 */
4526MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
4527
4528/* reg_pfcc_shl_cap
4529 * Send to higher layers capabilities:
4530 * 0 - No capability of sending Pause and PFC frames to higher layers.
4531 * 1 - Device has capability of sending Pause and PFC frames to higher
4532 * layers.
4533 * Access: RO
4534 */
4535MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4536
4537/* reg_pfcc_shl_opr
4538 * Send to higher layers operation:
4539 * 0 - Pause and PFC frames are handled by the port (default).
4540 * 1 - Pause and PFC frames are handled by the port and also sent to
4541 * higher layers. Only valid if shl_cap = 1.
4542 * Access: RW
4543 */
4544MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4545
4546/* reg_pfcc_ppan
4547 * Pause policy auto negotiation.
4548 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
4549 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
4550 * based on the auto-negotiation resolution.
4551 * Access: RW
4552 *
4553 * Note: The auto-negotiation advertisement is set according to pptx and
4554 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
4555 */
4556MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4557
4558/* reg_pfcc_prio_mask_tx
4559 * Bit per priority indicating if Tx flow control policy should be
4560 * updated based on bit pfctx.
4561 * Access: WO
4562 */
4563MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4564
4565/* reg_pfcc_prio_mask_rx
4566 * Bit per priority indicating if Rx flow control policy should be
4567 * updated based on bit pfcrx.
4568 * Access: WO
4569 */
4570MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4571
4572/* reg_pfcc_pptx
4573 * Admin Pause policy on Tx.
4574 * 0 - Never generate Pause frames (default).
4575 * 1 - Generate Pause frames according to Rx buffer threshold.
4576 * Access: RW
4577 */
4578MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4579
4580/* reg_pfcc_aptx
4581 * Active (operational) Pause policy on Tx.
4582 * 0 - Never generate Pause frames.
4583 * 1 - Generate Pause frames according to Rx buffer threshold.
4584 * Access: RO
4585 */
4586MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4587
4588/* reg_pfcc_pfctx
4589 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
4590 * 0 - Never generate priority Pause frames on the specified priority
4591 * (default).
4592 * 1 - Generate priority Pause frames according to Rx buffer threshold on
4593 * the specified priority.
4594 * Access: RW
4595 *
4596 * Note: pfctx and pptx must be mutually exclusive.
4597 */
4598MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4599
4600/* reg_pfcc_pprx
4601 * Admin Pause policy on Rx.
4602 * 0 - Ignore received Pause frames (default).
4603 * 1 - Respect received Pause frames.
4604 * Access: RW
4605 */
4606MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4607
4608/* reg_pfcc_aprx
4609 * Active (operational) Pause policy on Rx.
4610 * 0 - Ignore received Pause frames.
4611 * 1 - Respect received Pause frames.
4612 * Access: RO
4613 */
4614MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4615
4616/* reg_pfcc_pfcrx
4617 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
4618 * 0 - Ignore incoming priority Pause frames on the specified priority
4619 * (default).
4620 * 1 - Respect incoming priority Pause frames on the specified priority.
4621 * Access: RW
4622 */
4623MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4624
Ido Schimmeld81a6bd2016-04-06 17:10:16 +02004625#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4626
4627static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4628{
4629 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4630 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4631 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4632 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4633}
4634
Ido Schimmel6f253d82016-04-06 17:10:12 +02004635static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
4636{
4637 MLXSW_REG_ZERO(pfcc, payload);
4638 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4639}
4640
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004641/* PPCNT - Ports Performance Counters Register
4642 * -------------------------------------------
4643 * The PPCNT register retrieves per port performance counters.
4644 */
4645#define MLXSW_REG_PPCNT_ID 0x5008
4646#define MLXSW_REG_PPCNT_LEN 0x100
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004647#define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004648
Jiri Pirko21978dc2016-10-21 16:07:20 +02004649MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004650
4651/* reg_ppcnt_swid
4652 * For HCA: must be always 0.
4653 * Switch partition ID to associate port with.
4654 * Switch partitions are numbered from 0 to 7 inclusively.
4655 * Switch partition 254 indicates stacking ports.
4656 * Switch partition 255 indicates all switch partitions.
4657 * Only valid on Set() operation with local_port=255.
4658 * Access: Index
4659 */
4660MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4661
4662/* reg_ppcnt_local_port
4663 * Local port number.
4664 * 255 indicates all ports on the device, and is only allowed
4665 * for Set() operation.
4666 * Access: Index
4667 */
4668MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
4669
4670/* reg_ppcnt_pnat
4671 * Port number access type:
4672 * 0 - Local port number
4673 * 1 - IB port number
4674 * Access: Index
4675 */
4676MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4677
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004678enum mlxsw_reg_ppcnt_grp {
4679 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
Shalom Toledobae4e102018-11-18 16:43:03 +00004680 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
Jiri Pirko1222d152018-07-15 10:45:42 +03004681 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
Shalom Toledobae4e102018-11-18 16:43:03 +00004682 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004683 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
Shalom Toledobae4e102018-11-18 16:43:03 +00004684 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004685 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004686 MLXSW_REG_PPCNT_TC_CNT = 0x11,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004687 MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004688};
4689
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004690/* reg_ppcnt_grp
4691 * Performance counter group.
4692 * Group 63 indicates all groups. Only valid on Set() operation with
4693 * clr bit set.
4694 * 0x0: IEEE 802.3 Counters
4695 * 0x1: RFC 2863 Counters
4696 * 0x2: RFC 2819 Counters
4697 * 0x3: RFC 3635 Counters
4698 * 0x5: Ethernet Extended Counters
Shalom Toledobae4e102018-11-18 16:43:03 +00004699 * 0x6: Ethernet Discard Counters
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004700 * 0x8: Link Level Retransmission Counters
4701 * 0x10: Per Priority Counters
4702 * 0x11: Per Traffic Class Counters
4703 * 0x12: Physical Layer Counters
Yuval Mintz0afc1222017-11-06 07:23:46 +01004704 * 0x13: Per Traffic Class Congestion Counters
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004705 * Access: Index
4706 */
4707MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4708
4709/* reg_ppcnt_clr
4710 * Clear counters. Setting the clr bit will reset the counter value
4711 * for all counters in the counter group. This bit can be set
4712 * for both Set() and Get() operation.
4713 * Access: OP
4714 */
4715MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4716
4717/* reg_ppcnt_prio_tc
4718 * Priority for counter set that support per priority, valid values: 0-7.
4719 * Traffic class for counter set that support per traffic class,
4720 * valid values: 0- cap_max_tclass-1 .
4721 * For HCA: cap_max_tclass is always 8.
4722 * Otherwise must be 0.
4723 * Access: Index
4724 */
4725MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
4726
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004727/* Ethernet IEEE 802.3 Counter Group */
4728
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004729/* reg_ppcnt_a_frames_transmitted_ok
4730 * Access: RO
4731 */
4732MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004733 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004734
4735/* reg_ppcnt_a_frames_received_ok
4736 * Access: RO
4737 */
4738MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004739 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004740
4741/* reg_ppcnt_a_frame_check_sequence_errors
4742 * Access: RO
4743 */
4744MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004745 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004746
4747/* reg_ppcnt_a_alignment_errors
4748 * Access: RO
4749 */
4750MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004751 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004752
4753/* reg_ppcnt_a_octets_transmitted_ok
4754 * Access: RO
4755 */
4756MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004757 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004758
4759/* reg_ppcnt_a_octets_received_ok
4760 * Access: RO
4761 */
4762MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004763 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004764
4765/* reg_ppcnt_a_multicast_frames_xmitted_ok
4766 * Access: RO
4767 */
4768MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004769 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004770
4771/* reg_ppcnt_a_broadcast_frames_xmitted_ok
4772 * Access: RO
4773 */
4774MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004775 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004776
4777/* reg_ppcnt_a_multicast_frames_received_ok
4778 * Access: RO
4779 */
4780MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004781 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004782
4783/* reg_ppcnt_a_broadcast_frames_received_ok
4784 * Access: RO
4785 */
4786MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004787 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004788
4789/* reg_ppcnt_a_in_range_length_errors
4790 * Access: RO
4791 */
4792MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004793 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004794
4795/* reg_ppcnt_a_out_of_range_length_field
4796 * Access: RO
4797 */
4798MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004799 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004800
4801/* reg_ppcnt_a_frame_too_long_errors
4802 * Access: RO
4803 */
4804MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004805 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004806
4807/* reg_ppcnt_a_symbol_error_during_carrier
4808 * Access: RO
4809 */
4810MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004811 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004812
4813/* reg_ppcnt_a_mac_control_frames_transmitted
4814 * Access: RO
4815 */
4816MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004817 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004818
4819/* reg_ppcnt_a_mac_control_frames_received
4820 * Access: RO
4821 */
4822MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004823 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004824
4825/* reg_ppcnt_a_unsupported_opcodes_received
4826 * Access: RO
4827 */
4828MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004829 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004830
4831/* reg_ppcnt_a_pause_mac_ctrl_frames_received
4832 * Access: RO
4833 */
4834MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004835 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004836
4837/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
4838 * Access: RO
4839 */
4840MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004841 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004842
Shalom Toledobae4e102018-11-18 16:43:03 +00004843/* Ethernet RFC 2863 Counter Group */
4844
4845/* reg_ppcnt_if_in_discards
4846 * Access: RO
4847 */
4848MLXSW_ITEM64(reg, ppcnt, if_in_discards,
4849 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
4850
4851/* reg_ppcnt_if_out_discards
4852 * Access: RO
4853 */
4854MLXSW_ITEM64(reg, ppcnt, if_out_discards,
4855 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
4856
4857/* reg_ppcnt_if_out_errors
4858 * Access: RO
4859 */
4860MLXSW_ITEM64(reg, ppcnt, if_out_errors,
4861 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4862
Jiri Pirko1222d152018-07-15 10:45:42 +03004863/* Ethernet RFC 2819 Counter Group */
4864
Shalom Toledobae4e102018-11-18 16:43:03 +00004865/* reg_ppcnt_ether_stats_undersize_pkts
4866 * Access: RO
4867 */
4868MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
4869 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
4870
4871/* reg_ppcnt_ether_stats_oversize_pkts
4872 * Access: RO
4873 */
4874MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
4875 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
4876
4877/* reg_ppcnt_ether_stats_fragments
4878 * Access: RO
4879 */
4880MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
4881 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4882
Jiri Pirko1222d152018-07-15 10:45:42 +03004883/* reg_ppcnt_ether_stats_pkts64octets
4884 * Access: RO
4885 */
4886MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
4887 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4888
4889/* reg_ppcnt_ether_stats_pkts65to127octets
4890 * Access: RO
4891 */
4892MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
4893 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4894
4895/* reg_ppcnt_ether_stats_pkts128to255octets
4896 * Access: RO
4897 */
4898MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
4899 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4900
4901/* reg_ppcnt_ether_stats_pkts256to511octets
4902 * Access: RO
4903 */
4904MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
4905 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4906
4907/* reg_ppcnt_ether_stats_pkts512to1023octets
4908 * Access: RO
4909 */
4910MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
4911 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4912
4913/* reg_ppcnt_ether_stats_pkts1024to1518octets
4914 * Access: RO
4915 */
4916MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
4917 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4918
4919/* reg_ppcnt_ether_stats_pkts1519to2047octets
4920 * Access: RO
4921 */
4922MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
4923 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4924
4925/* reg_ppcnt_ether_stats_pkts2048to4095octets
4926 * Access: RO
4927 */
4928MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
4929 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4930
4931/* reg_ppcnt_ether_stats_pkts4096to8191octets
4932 * Access: RO
4933 */
4934MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
4935 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
4936
4937/* reg_ppcnt_ether_stats_pkts8192to10239octets
4938 * Access: RO
4939 */
4940MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
4941 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
4942
Shalom Toledobae4e102018-11-18 16:43:03 +00004943/* Ethernet RFC 3635 Counter Group */
4944
4945/* reg_ppcnt_dot3stats_fcs_errors
4946 * Access: RO
4947 */
4948MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
4949 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4950
4951/* reg_ppcnt_dot3stats_symbol_errors
4952 * Access: RO
4953 */
4954MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
4955 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4956
4957/* reg_ppcnt_dot3control_in_unknown_opcodes
4958 * Access: RO
4959 */
4960MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
4961 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4962
4963/* reg_ppcnt_dot3in_pause_frames
4964 * Access: RO
4965 */
4966MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
4967 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4968
Yuval Mintz0afc1222017-11-06 07:23:46 +01004969/* Ethernet Extended Counter Group Counters */
4970
4971/* reg_ppcnt_ecn_marked
4972 * Access: RO
4973 */
4974MLXSW_ITEM64(reg, ppcnt, ecn_marked,
4975 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4976
Shalom Toledobae4e102018-11-18 16:43:03 +00004977/* Ethernet Discard Counter Group Counters */
4978
4979/* reg_ppcnt_ingress_general
4980 * Access: RO
4981 */
4982MLXSW_ITEM64(reg, ppcnt, ingress_general,
4983 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4984
4985/* reg_ppcnt_ingress_policy_engine
4986 * Access: RO
4987 */
4988MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
4989 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4990
4991/* reg_ppcnt_ingress_vlan_membership
4992 * Access: RO
4993 */
4994MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
4995 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
4996
4997/* reg_ppcnt_ingress_tag_frame_type
4998 * Access: RO
4999 */
5000MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
5001 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5002
5003/* reg_ppcnt_egress_vlan_membership
5004 * Access: RO
5005 */
5006MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
5007 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5008
5009/* reg_ppcnt_loopback_filter
5010 * Access: RO
5011 */
5012MLXSW_ITEM64(reg, ppcnt, loopback_filter,
5013 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5014
5015/* reg_ppcnt_egress_general
5016 * Access: RO
5017 */
5018MLXSW_ITEM64(reg, ppcnt, egress_general,
5019 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5020
5021/* reg_ppcnt_egress_hoq
5022 * Access: RO
5023 */
5024MLXSW_ITEM64(reg, ppcnt, egress_hoq,
5025 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5026
5027/* reg_ppcnt_egress_policy_engine
5028 * Access: RO
5029 */
5030MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
5031 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5032
5033/* reg_ppcnt_ingress_tx_link_down
5034 * Access: RO
5035 */
5036MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
5037 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5038
5039/* reg_ppcnt_egress_stp_filter
5040 * Access: RO
5041 */
5042MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
5043 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5044
5045/* reg_ppcnt_egress_sll
5046 * Access: RO
5047 */
5048MLXSW_ITEM64(reg, ppcnt, egress_sll,
5049 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5050
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005051/* Ethernet Per Priority Group Counters */
5052
5053/* reg_ppcnt_rx_octets
5054 * Access: RO
5055 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005056MLXSW_ITEM64(reg, ppcnt, rx_octets,
5057 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005058
5059/* reg_ppcnt_rx_frames
5060 * Access: RO
5061 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005062MLXSW_ITEM64(reg, ppcnt, rx_frames,
5063 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005064
5065/* reg_ppcnt_tx_octets
5066 * Access: RO
5067 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005068MLXSW_ITEM64(reg, ppcnt, tx_octets,
5069 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005070
5071/* reg_ppcnt_tx_frames
5072 * Access: RO
5073 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005074MLXSW_ITEM64(reg, ppcnt, tx_frames,
5075 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005076
5077/* reg_ppcnt_rx_pause
5078 * Access: RO
5079 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005080MLXSW_ITEM64(reg, ppcnt, rx_pause,
5081 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005082
5083/* reg_ppcnt_rx_pause_duration
5084 * Access: RO
5085 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005086MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
5087 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005088
5089/* reg_ppcnt_tx_pause
5090 * Access: RO
5091 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005092MLXSW_ITEM64(reg, ppcnt, tx_pause,
5093 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005094
5095/* reg_ppcnt_tx_pause_duration
5096 * Access: RO
5097 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005098MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
5099 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005100
5101/* reg_ppcnt_rx_pause_transition
5102 * Access: RO
5103 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005104MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
5105 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005106
Ido Schimmeldf4750e2016-07-19 15:35:54 +02005107/* Ethernet Per Traffic Group Counters */
5108
5109/* reg_ppcnt_tc_transmit_queue
5110 * Contains the transmit queue depth in cells of traffic class
5111 * selected by prio_tc and the port selected by local_port.
5112 * The field cannot be cleared.
5113 * Access: RO
5114 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005115MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
5116 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02005117
5118/* reg_ppcnt_tc_no_buffer_discard_uc
5119 * The number of unicast packets dropped due to lack of shared
5120 * buffer resources.
5121 * Access: RO
5122 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02005123MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
5124 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02005125
Yuval Mintz0afc1222017-11-06 07:23:46 +01005126/* Ethernet Per Traffic Class Congestion Group Counters */
5127
5128/* reg_ppcnt_wred_discard
5129 * Access: RO
5130 */
5131MLXSW_ITEM64(reg, ppcnt, wred_discard,
5132 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5133
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005134static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
5135 enum mlxsw_reg_ppcnt_grp grp,
5136 u8 prio_tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005137{
5138 MLXSW_REG_ZERO(ppcnt, payload);
5139 mlxsw_reg_ppcnt_swid_set(payload, 0);
5140 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
5141 mlxsw_reg_ppcnt_pnat_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005142 mlxsw_reg_ppcnt_grp_set(payload, grp);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005143 mlxsw_reg_ppcnt_clr_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02005144 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005145}
5146
Elad Raz71367932016-10-28 21:35:54 +02005147/* PLIB - Port Local to InfiniBand Port
5148 * ------------------------------------
5149 * The PLIB register performs mapping from Local Port into InfiniBand Port.
5150 */
5151#define MLXSW_REG_PLIB_ID 0x500A
5152#define MLXSW_REG_PLIB_LEN 0x10
5153
5154MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
5155
5156/* reg_plib_local_port
5157 * Local port number.
5158 * Access: Index
5159 */
5160MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
5161
5162/* reg_plib_ib_port
5163 * InfiniBand port remapping for local_port.
5164 * Access: RW
5165 */
5166MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
5167
Ido Schimmelb98ff152016-04-06 17:10:00 +02005168/* PPTB - Port Prio To Buffer Register
5169 * -----------------------------------
5170 * Configures the switch priority to buffer table.
5171 */
5172#define MLXSW_REG_PPTB_ID 0x500B
Ido Schimmel11719a52016-07-15 11:15:02 +02005173#define MLXSW_REG_PPTB_LEN 0x10
Ido Schimmelb98ff152016-04-06 17:10:00 +02005174
Jiri Pirko21978dc2016-10-21 16:07:20 +02005175MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
Ido Schimmelb98ff152016-04-06 17:10:00 +02005176
5177enum {
5178 MLXSW_REG_PPTB_MM_UM,
5179 MLXSW_REG_PPTB_MM_UNICAST,
5180 MLXSW_REG_PPTB_MM_MULTICAST,
5181};
5182
5183/* reg_pptb_mm
5184 * Mapping mode.
5185 * 0 - Map both unicast and multicast packets to the same buffer.
5186 * 1 - Map only unicast packets.
5187 * 2 - Map only multicast packets.
5188 * Access: Index
5189 *
5190 * Note: SwitchX-2 only supports the first option.
5191 */
5192MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
5193
5194/* reg_pptb_local_port
5195 * Local port number.
5196 * Access: Index
5197 */
5198MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
5199
5200/* reg_pptb_um
5201 * Enables the update of the untagged_buf field.
5202 * Access: RW
5203 */
5204MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
5205
5206/* reg_pptb_pm
5207 * Enables the update of the prio_to_buff field.
5208 * Bit <i> is a flag for updating the mapping for switch priority <i>.
5209 * Access: RW
5210 */
5211MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
5212
5213/* reg_pptb_prio_to_buff
5214 * Mapping of switch priority <i> to one of the allocated receive port
5215 * buffers.
5216 * Access: RW
5217 */
5218MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
5219
5220/* reg_pptb_pm_msb
5221 * Enables the update of the prio_to_buff field.
5222 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
5223 * Access: RW
5224 */
5225MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
5226
5227/* reg_pptb_untagged_buff
5228 * Mapping of untagged frames to one of the allocated receive port buffers.
5229 * Access: RW
5230 *
5231 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
5232 * Spectrum, as it maps untagged packets based on the default switch priority.
5233 */
5234MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
5235
Ido Schimmel11719a52016-07-15 11:15:02 +02005236/* reg_pptb_prio_to_buff_msb
5237 * Mapping of switch priority <i+8> to one of the allocated receive port
5238 * buffers.
5239 * Access: RW
5240 */
5241MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
5242
Ido Schimmelb98ff152016-04-06 17:10:00 +02005243#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
5244
5245static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
5246{
5247 MLXSW_REG_ZERO(pptb, payload);
5248 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
5249 mlxsw_reg_pptb_local_port_set(payload, local_port);
5250 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
Ido Schimmel11719a52016-07-15 11:15:02 +02005251 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5252}
5253
5254static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
5255 u8 buff)
5256{
5257 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
5258 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
Ido Schimmelb98ff152016-04-06 17:10:00 +02005259}
5260
Jiri Pirkoe0594362015-10-16 14:01:31 +02005261/* PBMC - Port Buffer Management Control Register
5262 * ----------------------------------------------
5263 * The PBMC register configures and retrieves the port packet buffer
5264 * allocation for different Prios, and the Pause threshold management.
5265 */
5266#define MLXSW_REG_PBMC_ID 0x500C
Ido Schimmel7ad7cd62016-04-06 17:10:04 +02005267#define MLXSW_REG_PBMC_LEN 0x6C
Jiri Pirkoe0594362015-10-16 14:01:31 +02005268
Jiri Pirko21978dc2016-10-21 16:07:20 +02005269MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02005270
5271/* reg_pbmc_local_port
5272 * Local port number.
5273 * Access: Index
5274 */
5275MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
5276
5277/* reg_pbmc_xoff_timer_value
5278 * When device generates a pause frame, it uses this value as the pause
5279 * timer (time for the peer port to pause in quota-512 bit time).
5280 * Access: RW
5281 */
5282MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
5283
5284/* reg_pbmc_xoff_refresh
5285 * The time before a new pause frame should be sent to refresh the pause RW
5286 * state. Using the same units as xoff_timer_value above (in quota-512 bit
5287 * time).
5288 * Access: RW
5289 */
5290MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
5291
Ido Schimmeld6b7c132016-04-06 17:10:05 +02005292#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
5293
Jiri Pirkoe0594362015-10-16 14:01:31 +02005294/* reg_pbmc_buf_lossy
5295 * The field indicates if the buffer is lossy.
5296 * 0 - Lossless
5297 * 1 - Lossy
5298 * Access: RW
5299 */
5300MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
5301
5302/* reg_pbmc_buf_epsb
5303 * Eligible for Port Shared buffer.
5304 * If epsb is set, packets assigned to buffer are allowed to insert the port
5305 * shared buffer.
5306 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
5307 * Access: RW
5308 */
5309MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
5310
5311/* reg_pbmc_buf_size
5312 * The part of the packet buffer array is allocated for the specific buffer.
5313 * Units are represented in cells.
5314 * Access: RW
5315 */
5316MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
5317
Ido Schimmel155f9de2016-04-06 17:10:13 +02005318/* reg_pbmc_buf_xoff_threshold
5319 * Once the amount of data in the buffer goes above this value, device
5320 * starts sending PFC frames for all priorities associated with the
5321 * buffer. Units are represented in cells. Reserved in case of lossy
5322 * buffer.
5323 * Access: RW
5324 *
5325 * Note: In Spectrum, reserved for buffer[9].
5326 */
5327MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
5328 0x08, 0x04, false);
5329
5330/* reg_pbmc_buf_xon_threshold
5331 * When the amount of data in the buffer goes below this value, device
5332 * stops sending PFC frames for the priorities associated with the
5333 * buffer. Units are represented in cells. Reserved in case of lossy
5334 * buffer.
5335 * Access: RW
5336 *
5337 * Note: In Spectrum, reserved for buffer[9].
5338 */
5339MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
5340 0x08, 0x04, false);
5341
Jiri Pirkoe0594362015-10-16 14:01:31 +02005342static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
5343 u16 xoff_timer_value, u16 xoff_refresh)
5344{
5345 MLXSW_REG_ZERO(pbmc, payload);
5346 mlxsw_reg_pbmc_local_port_set(payload, local_port);
5347 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
5348 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
5349}
5350
5351static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
5352 int buf_index,
5353 u16 size)
5354{
5355 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
5356 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5357 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5358}
5359
Ido Schimmel155f9de2016-04-06 17:10:13 +02005360static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
5361 int buf_index, u16 size,
5362 u16 threshold)
5363{
5364 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
5365 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5366 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5367 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
5368 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
5369}
5370
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005371/* PSPA - Port Switch Partition Allocation
5372 * ---------------------------------------
5373 * Controls the association of a port with a switch partition and enables
5374 * configuring ports as stacking ports.
5375 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +02005376#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005377#define MLXSW_REG_PSPA_LEN 0x8
5378
Jiri Pirko21978dc2016-10-21 16:07:20 +02005379MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005380
5381/* reg_pspa_swid
5382 * Switch partition ID.
5383 * Access: RW
5384 */
5385MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
5386
5387/* reg_pspa_local_port
5388 * Local port number.
5389 * Access: Index
5390 */
5391MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
5392
5393/* reg_pspa_sub_port
5394 * Virtual port within the local port. Set to 0 when virtual ports are
5395 * disabled on the local port.
5396 * Access: Index
5397 */
5398MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
5399
5400static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
5401{
5402 MLXSW_REG_ZERO(pspa, payload);
5403 mlxsw_reg_pspa_swid_set(payload, swid);
5404 mlxsw_reg_pspa_local_port_set(payload, local_port);
5405 mlxsw_reg_pspa_sub_port_set(payload, 0);
5406}
5407
Jiri Pirkoa0c25382019-05-05 09:48:05 +03005408/* PPLR - Port Physical Loopback Register
5409 * --------------------------------------
5410 * This register allows configuration of the port's loopback mode.
5411 */
5412#define MLXSW_REG_PPLR_ID 0x5018
5413#define MLXSW_REG_PPLR_LEN 0x8
5414
5415MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
5416
5417/* reg_pplr_local_port
5418 * Local port number.
5419 * Access: Index
5420 */
5421MLXSW_ITEM32(reg, pplr, local_port, 0x00, 16, 8);
5422
5423/* Phy local loopback. When set the port's egress traffic is looped back
5424 * to the receiver and the port transmitter is disabled.
5425 */
5426#define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
5427
5428/* reg_pplr_lb_en
5429 * Loopback enable.
5430 * Access: RW
5431 */
5432MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
5433
5434static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port,
5435 bool phy_local)
5436{
5437 MLXSW_REG_ZERO(pplr, payload);
5438 mlxsw_reg_pplr_local_port_set(payload, local_port);
5439 mlxsw_reg_pplr_lb_en_set(payload,
5440 phy_local ?
5441 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
5442}
5443
Amit Cohene7d62a32020-09-27 10:50:07 +03005444/* PMPE - Port Module Plug/Unplug Event Register
5445 * ---------------------------------------------
5446 * This register reports any operational status change of a module.
5447 * A change in the module’s state will generate an event only if the change
5448 * happens after arming the event mechanism. Any changes to the module state
5449 * while the event mechanism is not armed will not be reported. Software can
5450 * query the PMPE register for module status.
5451 */
5452#define MLXSW_REG_PMPE_ID 0x5024
5453#define MLXSW_REG_PMPE_LEN 0x10
5454
5455MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN);
5456
5457/* reg_pmpe_slot_index
5458 * Slot index.
5459 * Access: Index
5460 */
5461MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4);
5462
5463/* reg_pmpe_module
5464 * Module number.
5465 * Access: Index
5466 */
5467MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8);
5468
5469enum mlxsw_reg_pmpe_module_status {
5470 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1,
5471 MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED,
5472 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR,
5473 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED,
5474};
5475
5476/* reg_pmpe_module_status
5477 * Module status.
5478 * Access: RO
5479 */
5480MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4);
5481
5482/* reg_pmpe_error_type
5483 * Module error details.
5484 * Access: RO
5485 */
5486MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4);
5487
Amit Cohen1bd06932020-06-29 23:46:17 +03005488/* PDDR - Port Diagnostics Database Register
5489 * -----------------------------------------
5490 * The PDDR enables to read the Phy debug database
5491 */
5492#define MLXSW_REG_PDDR_ID 0x5031
5493#define MLXSW_REG_PDDR_LEN 0x100
5494
5495MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN);
5496
5497/* reg_pddr_local_port
5498 * Local port number.
5499 * Access: Index
5500 */
5501MLXSW_ITEM32(reg, pddr, local_port, 0x00, 16, 8);
5502
5503enum mlxsw_reg_pddr_page_select {
5504 MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1,
5505};
5506
5507/* reg_pddr_page_select
5508 * Page select index.
5509 * Access: Index
5510 */
5511MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8);
5512
5513enum mlxsw_reg_pddr_trblsh_group_opcode {
5514 /* Monitor opcodes */
5515 MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR,
5516};
5517
5518/* reg_pddr_group_opcode
5519 * Group selector.
5520 * Access: Index
5521 */
5522MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
5523
5524/* reg_pddr_status_opcode
5525 * Group selector.
5526 * Access: RO
5527 */
5528MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
5529
5530static inline void mlxsw_reg_pddr_pack(char *payload, u8 local_port,
5531 u8 page_select)
5532{
5533 MLXSW_REG_ZERO(pddr, payload);
5534 mlxsw_reg_pddr_local_port_set(payload, local_port);
5535 mlxsw_reg_pddr_page_select_set(payload, page_select);
5536}
5537
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005538/* PMTM - Port Module Type Mapping Register
5539 * ----------------------------------------
5540 * The PMTM allows query or configuration of module types.
5541 */
5542#define MLXSW_REG_PMTM_ID 0x5067
5543#define MLXSW_REG_PMTM_LEN 0x10
5544
5545MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
5546
5547/* reg_pmtm_module
5548 * Module number.
5549 * Access: Index
5550 */
5551MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
5552
5553enum mlxsw_reg_pmtm_module_type {
5554 /* Backplane with 4 lanes */
5555 MLXSW_REG_PMTM_MODULE_TYPE_BP_4X,
5556 /* QSFP */
Jiri Pirkoec4a5142020-02-27 20:59:26 +01005557 MLXSW_REG_PMTM_MODULE_TYPE_QSFP,
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005558 /* SFP */
Jiri Pirkoec4a5142020-02-27 20:59:26 +01005559 MLXSW_REG_PMTM_MODULE_TYPE_SFP,
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005560 /* Backplane with single lane */
5561 MLXSW_REG_PMTM_MODULE_TYPE_BP_1X = 4,
5562 /* Backplane with two lane */
5563 MLXSW_REG_PMTM_MODULE_TYPE_BP_2X = 8,
Jiri Pirkoec4a5142020-02-27 20:59:26 +01005564 /* Chip2Chip4x */
5565 MLXSW_REG_PMTM_MODULE_TYPE_C2C4X = 10,
5566 /* Chip2Chip2x */
5567 MLXSW_REG_PMTM_MODULE_TYPE_C2C2X,
5568 /* Chip2Chip1x */
5569 MLXSW_REG_PMTM_MODULE_TYPE_C2C1X,
5570 /* QSFP-DD */
5571 MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD = 14,
5572 /* OSFP */
5573 MLXSW_REG_PMTM_MODULE_TYPE_OSFP,
5574 /* SFP-DD */
5575 MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD,
5576 /* DSFP */
5577 MLXSW_REG_PMTM_MODULE_TYPE_DSFP,
5578 /* Chip2Chip8x */
5579 MLXSW_REG_PMTM_MODULE_TYPE_C2C8X,
Jiri Pirkoa513b1a2019-10-31 11:42:07 +02005580};
5581
5582/* reg_pmtm_module_type
5583 * Module type.
5584 * Access: RW
5585 */
5586MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 4);
5587
5588static inline void mlxsw_reg_pmtm_pack(char *payload, u8 module)
5589{
5590 MLXSW_REG_ZERO(pmtm, payload);
5591 mlxsw_reg_pmtm_module_set(payload, module);
5592}
5593
5594static inline void
5595mlxsw_reg_pmtm_unpack(char *payload,
5596 enum mlxsw_reg_pmtm_module_type *module_type)
5597{
5598 *module_type = mlxsw_reg_pmtm_module_type_get(payload);
5599}
5600
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005601/* HTGT - Host Trap Group Table
5602 * ----------------------------
5603 * Configures the properties for forwarding to CPU.
5604 */
5605#define MLXSW_REG_HTGT_ID 0x7002
Elad Raze158e5e2017-02-06 13:56:27 +01005606#define MLXSW_REG_HTGT_LEN 0x20
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005607
Jiri Pirko21978dc2016-10-21 16:07:20 +02005608MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005609
5610/* reg_htgt_swid
5611 * Switch partition ID.
5612 * Access: Index
5613 */
5614MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
5615
5616#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
5617
5618/* reg_htgt_type
5619 * CPU path type.
5620 * Access: RW
5621 */
5622MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
5623
Ido Schimmel801bd3d2015-10-15 17:43:28 +02005624enum mlxsw_reg_htgt_trap_group {
5625 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
Jiri Pirko7d83ee12020-09-15 11:40:58 +03005626 MLXSW_REG_HTGT_TRAP_GROUP_MFDE,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005627 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
5628 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
5629 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
Ido Schimmeldebb7af2020-05-25 00:50:57 +03005630 MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02005631 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005632 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
Yotam Gigib48cfc82017-09-19 10:00:20 +02005633 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
5634 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
Ido Schimmel32446432020-05-25 00:51:04 +03005635 MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005636 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
Ido Schimmelec4f5b32020-07-29 12:26:44 +03005637 MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE,
Nogah Frankel117b0da2016-11-25 10:33:44 +01005638 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
5639 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
5640 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
Ido Schimmel412df3d2020-05-26 02:05:45 +03005641 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
Ido Schimmel2f4f4492018-12-04 08:15:12 +00005642 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
Petr Machataaed4b572019-06-30 09:04:51 +03005643 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
5644 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
Ido Schimmelacca7892019-12-29 13:40:23 +02005645 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
Ido Schimmelce3c3bf2020-05-25 00:51:06 +03005646 MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
Ido Schimmel3c2d8a042020-05-26 02:05:43 +03005647 MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
Ido Schimmeld3223092020-05-26 02:05:47 +03005648 MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS,
Ido Schimmel9785b922020-05-26 02:05:55 +03005649 MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
Jiri Pirkoe6125232020-02-24 08:35:54 +01005650 MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
Ido Schimmel9e6290c2019-08-21 10:19:34 +03005651 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
Amit Cohendbc684f2019-11-07 18:42:10 +02005652 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
Ido Schimmel1e292f52020-05-29 21:36:37 +03005653 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
Amit Cohena318bf62020-01-19 15:00:55 +02005654 MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
Jiri Pirko45dbee02020-02-24 08:35:55 +01005655 MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
Ido Schimmel6687e952020-08-03 19:11:39 +03005656 MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
Ido Schimmel500769b2020-05-26 02:05:52 +03005657
5658 __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
5659 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
Ido Schimmel801bd3d2015-10-15 17:43:28 +02005660};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005661
5662/* reg_htgt_trap_group
5663 * Trap group number. User defined number specifying which trap groups
5664 * should be forwarded to the CPU. The mapping between trap IDs and trap
5665 * groups is configured using HPKT register.
5666 * Access: Index
5667 */
5668MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
5669
5670enum {
5671 MLXSW_REG_HTGT_POLICER_DISABLE,
5672 MLXSW_REG_HTGT_POLICER_ENABLE,
5673};
5674
5675/* reg_htgt_pide
5676 * Enable policer ID specified using 'pid' field.
5677 * Access: RW
5678 */
5679MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
5680
Nogah Frankel579c82e2016-11-25 10:33:42 +01005681#define MLXSW_REG_HTGT_INVALID_POLICER 0xff
5682
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005683/* reg_htgt_pid
5684 * Policer ID for the trap group.
5685 * Access: RW
5686 */
5687MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
5688
5689#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
5690
5691/* reg_htgt_mirror_action
5692 * Mirror action to use.
5693 * 0 - Trap to CPU.
5694 * 1 - Trap to CPU and mirror to a mirroring agent.
5695 * 2 - Mirror to a mirroring agent and do not trap to CPU.
5696 * Access: RW
5697 *
5698 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
5699 */
5700MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
5701
5702/* reg_htgt_mirroring_agent
5703 * Mirroring agent.
5704 * Access: RW
5705 */
5706MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
5707
Nogah Frankel579c82e2016-11-25 10:33:42 +01005708#define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
5709
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005710/* reg_htgt_priority
5711 * Trap group priority.
5712 * In case a packet matches multiple classification rules, the packet will
5713 * only be trapped once, based on the trap ID associated with the group (via
5714 * register HPKT) with the highest priority.
5715 * Supported values are 0-7, with 7 represnting the highest priority.
5716 * Access: RW
5717 *
5718 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
5719 * by the 'trap_group' field.
5720 */
5721MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
5722
Nogah Frankel579c82e2016-11-25 10:33:42 +01005723#define MLXSW_REG_HTGT_DEFAULT_TC 7
5724
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005725/* reg_htgt_local_path_cpu_tclass
5726 * CPU ingress traffic class for the trap group.
5727 * Access: RW
5728 */
5729MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
5730
Nogah Frankel579c82e2016-11-25 10:33:42 +01005731enum mlxsw_reg_htgt_local_path_rdq {
5732 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
5733 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
5734 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
5735 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
5736};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005737/* reg_htgt_local_path_rdq
5738 * Receive descriptor queue (RDQ) to use for the trap group.
5739 * Access: RW
5740 */
5741MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
5742
Nogah Frankel579c82e2016-11-25 10:33:42 +01005743static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
5744 u8 priority, u8 tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005745{
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005746 MLXSW_REG_ZERO(htgt, payload);
Nogah Frankel579c82e2016-11-25 10:33:42 +01005747
5748 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
5749 mlxsw_reg_htgt_pide_set(payload,
5750 MLXSW_REG_HTGT_POLICER_DISABLE);
5751 } else {
5752 mlxsw_reg_htgt_pide_set(payload,
5753 MLXSW_REG_HTGT_POLICER_ENABLE);
5754 mlxsw_reg_htgt_pid_set(payload, policer_id);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005755 }
Nogah Frankel579c82e2016-11-25 10:33:42 +01005756
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005757 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02005758 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005759 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
5760 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
Nogah Frankel579c82e2016-11-25 10:33:42 +01005761 mlxsw_reg_htgt_priority_set(payload, priority);
5762 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
5763 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005764}
5765
5766/* HPKT - Host Packet Trap
5767 * -----------------------
5768 * Configures trap IDs inside trap groups.
5769 */
5770#define MLXSW_REG_HPKT_ID 0x7003
5771#define MLXSW_REG_HPKT_LEN 0x10
5772
Jiri Pirko21978dc2016-10-21 16:07:20 +02005773MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005774
5775enum {
5776 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
5777 MLXSW_REG_HPKT_ACK_REQUIRED,
5778};
5779
5780/* reg_hpkt_ack
5781 * Require acknowledgements from the host for events.
5782 * If set, then the device will wait for the event it sent to be acknowledged
5783 * by the host. This option is only relevant for event trap IDs.
5784 * Access: RW
5785 *
5786 * Note: Currently not supported by firmware.
5787 */
5788MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
5789
5790enum mlxsw_reg_hpkt_action {
5791 MLXSW_REG_HPKT_ACTION_FORWARD,
5792 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
5793 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
5794 MLXSW_REG_HPKT_ACTION_DISCARD,
5795 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
5796 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
Ido Schimmel6a44bae2019-08-21 10:19:32 +03005797 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
5798 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005799};
5800
5801/* reg_hpkt_action
5802 * Action to perform on packet when trapped.
5803 * 0 - No action. Forward to CPU based on switching rules.
5804 * 1 - Trap to CPU (CPU receives sole copy).
5805 * 2 - Mirror to CPU (CPU receives a replica of the packet).
5806 * 3 - Discard.
5807 * 4 - Soft discard (allow other traps to act on the packet).
5808 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
Ido Schimmel6a44bae2019-08-21 10:19:32 +03005809 * 6 - Trap to CPU (CPU receives sole copy) and count it as error.
5810 * 15 - Restore the firmware's default action.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005811 * Access: RW
5812 *
5813 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
5814 * addressed to the CPU.
5815 */
5816MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
5817
5818/* reg_hpkt_trap_group
5819 * Trap group to associate the trap with.
5820 * Access: RW
5821 */
5822MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
5823
5824/* reg_hpkt_trap_id
5825 * Trap ID.
5826 * Access: Index
5827 *
5828 * Note: A trap ID can only be associated with a single trap group. The device
5829 * will associate the trap ID with the last trap group configured.
5830 */
Amit Cohen47e4b162020-07-14 17:21:02 +03005831MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005832
5833enum {
5834 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
5835 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
5836 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
5837};
5838
5839/* reg_hpkt_ctrl
5840 * Configure dedicated buffer resources for control packets.
Nogah Frankeld570b7e2016-11-25 10:33:38 +01005841 * Ignored by SwitchX-2.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005842 * 0 - Keep factory defaults.
5843 * 1 - Do not use control buffer for this trap ID.
5844 * 2 - Use control buffer for this trap ID.
5845 * Access: RW
5846 */
5847MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
5848
Nogah Frankeld570b7e2016-11-25 10:33:38 +01005849static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
5850 enum mlxsw_reg_htgt_trap_group trap_group,
5851 bool is_ctrl)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005852{
5853 MLXSW_REG_ZERO(hpkt, payload);
5854 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
5855 mlxsw_reg_hpkt_action_set(payload, action);
5856 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
5857 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
Nogah Frankeld570b7e2016-11-25 10:33:38 +01005858 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
5859 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
5860 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005861}
5862
Ido Schimmel69c407a2016-07-02 11:00:13 +02005863/* RGCR - Router General Configuration Register
5864 * --------------------------------------------
5865 * The register is used for setting up the router configuration.
5866 */
5867#define MLXSW_REG_RGCR_ID 0x8001
5868#define MLXSW_REG_RGCR_LEN 0x28
5869
Jiri Pirko21978dc2016-10-21 16:07:20 +02005870MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
Ido Schimmel69c407a2016-07-02 11:00:13 +02005871
5872/* reg_rgcr_ipv4_en
5873 * IPv4 router enable.
5874 * Access: RW
5875 */
5876MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
5877
5878/* reg_rgcr_ipv6_en
5879 * IPv6 router enable.
5880 * Access: RW
5881 */
5882MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
5883
5884/* reg_rgcr_max_router_interfaces
5885 * Defines the maximum number of active router interfaces for all virtual
5886 * routers.
5887 * Access: RW
5888 */
5889MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
5890
5891/* reg_rgcr_usp
5892 * Update switch priority and packet color.
5893 * 0 - Preserve the value of Switch Priority and packet color.
5894 * 1 - Recalculate the value of Switch Priority and packet color.
5895 * Access: RW
5896 *
5897 * Note: Not supported by SwitchX and SwitchX-2.
5898 */
5899MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
5900
5901/* reg_rgcr_pcp_rw
5902 * Indicates how to handle the pcp_rewrite_en value:
5903 * 0 - Preserve the value of pcp_rewrite_en.
5904 * 2 - Disable PCP rewrite.
5905 * 3 - Enable PCP rewrite.
5906 * Access: RW
5907 *
5908 * Note: Not supported by SwitchX and SwitchX-2.
5909 */
5910MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
5911
5912/* reg_rgcr_activity_dis
5913 * Activity disable:
5914 * 0 - Activity will be set when an entry is hit (default).
5915 * 1 - Activity will not be set when an entry is hit.
5916 *
5917 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
5918 * (RALUE).
5919 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
5920 * Entry (RAUHT).
5921 * Bits 2:7 are reserved.
5922 * Access: RW
5923 *
5924 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
5925 */
5926MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
5927
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02005928static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
5929 bool ipv6_en)
Ido Schimmel69c407a2016-07-02 11:00:13 +02005930{
5931 MLXSW_REG_ZERO(rgcr, payload);
5932 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02005933 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
Ido Schimmel69c407a2016-07-02 11:00:13 +02005934}
5935
Ido Schimmel3dc26682016-07-02 11:00:18 +02005936/* RITR - Router Interface Table Register
5937 * --------------------------------------
5938 * The register is used to configure the router interface table.
5939 */
5940#define MLXSW_REG_RITR_ID 0x8002
5941#define MLXSW_REG_RITR_LEN 0x40
5942
Jiri Pirko21978dc2016-10-21 16:07:20 +02005943MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
Ido Schimmel3dc26682016-07-02 11:00:18 +02005944
5945/* reg_ritr_enable
5946 * Enables routing on the router interface.
5947 * Access: RW
5948 */
5949MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
5950
5951/* reg_ritr_ipv4
5952 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
5953 * interface.
5954 * Access: RW
5955 */
5956MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
5957
5958/* reg_ritr_ipv6
5959 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
5960 * interface.
5961 * Access: RW
5962 */
5963MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
5964
Yotam Gigi4af59642017-09-19 10:00:18 +02005965/* reg_ritr_ipv4_mc
5966 * IPv4 multicast routing enable.
5967 * Access: RW
5968 */
5969MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
5970
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005971/* reg_ritr_ipv6_mc
5972 * IPv6 multicast routing enable.
5973 * Access: RW
5974 */
5975MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
5976
Ido Schimmel3dc26682016-07-02 11:00:18 +02005977enum mlxsw_reg_ritr_if_type {
Petr Machata78676ad2017-07-31 09:27:26 +02005978 /* VLAN interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02005979 MLXSW_REG_RITR_VLAN_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02005980 /* FID interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02005981 MLXSW_REG_RITR_FID_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02005982 /* Sub-port interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02005983 MLXSW_REG_RITR_SP_IF,
Petr Machata99ae8e32017-09-02 23:49:09 +02005984 /* Loopback Interface. */
5985 MLXSW_REG_RITR_LOOPBACK_IF,
Ido Schimmel3dc26682016-07-02 11:00:18 +02005986};
5987
5988/* reg_ritr_type
Petr Machata78676ad2017-07-31 09:27:26 +02005989 * Router interface type as per enum mlxsw_reg_ritr_if_type.
Ido Schimmel3dc26682016-07-02 11:00:18 +02005990 * Access: RW
5991 */
5992MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
5993
5994enum {
5995 MLXSW_REG_RITR_RIF_CREATE,
5996 MLXSW_REG_RITR_RIF_DEL,
5997};
5998
5999/* reg_ritr_op
6000 * Opcode:
6001 * 0 - Create or edit RIF.
6002 * 1 - Delete RIF.
6003 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
6004 * is not supported. An interface must be deleted and re-created in order
6005 * to update properties.
6006 * Access: WO
6007 */
6008MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
6009
6010/* reg_ritr_rif
6011 * Router interface index. A pointer to the Router Interface Table.
6012 * Access: Index
6013 */
6014MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
6015
6016/* reg_ritr_ipv4_fe
6017 * IPv4 Forwarding Enable.
6018 * Enables routing of IPv4 traffic on the router interface. When disabled,
6019 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6020 * Not supported in SwitchX-2.
6021 * Access: RW
6022 */
6023MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
6024
6025/* reg_ritr_ipv6_fe
6026 * IPv6 Forwarding Enable.
6027 * Enables routing of IPv6 traffic on the router interface. When disabled,
6028 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
6029 * Not supported in SwitchX-2.
6030 * Access: RW
6031 */
6032MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
6033
Yotam Gigi4af59642017-09-19 10:00:18 +02006034/* reg_ritr_ipv4_mc_fe
6035 * IPv4 Multicast Forwarding Enable.
6036 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6037 * will be enabled.
6038 * Access: RW
6039 */
6040MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
6041
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006042/* reg_ritr_ipv6_mc_fe
6043 * IPv6 Multicast Forwarding Enable.
6044 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
6045 * will be enabled.
6046 * Access: RW
6047 */
6048MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
6049
Ido Schimmela94a6142016-08-17 16:39:33 +02006050/* reg_ritr_lb_en
6051 * Loop-back filter enable for unicast packets.
6052 * If the flag is set then loop-back filter for unicast packets is
6053 * implemented on the RIF. Multicast packets are always subject to
6054 * loop-back filtering.
6055 * Access: RW
6056 */
6057MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
6058
Ido Schimmel3dc26682016-07-02 11:00:18 +02006059/* reg_ritr_virtual_router
6060 * Virtual router ID associated with the router interface.
6061 * Access: RW
6062 */
6063MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
6064
6065/* reg_ritr_mtu
6066 * Router interface MTU.
6067 * Access: RW
6068 */
6069MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
6070
6071/* reg_ritr_if_swid
6072 * Switch partition ID.
6073 * Access: RW
6074 */
6075MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
6076
6077/* reg_ritr_if_mac
6078 * Router interface MAC address.
6079 * In Spectrum, all MAC addresses must have the same 38 MSBits.
6080 * Access: RW
6081 */
6082MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
6083
Ido Schimmelc3a49542018-07-14 11:39:54 +03006084/* reg_ritr_if_vrrp_id_ipv6
6085 * VRRP ID for IPv6
6086 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6087 * Access: RW
6088 */
6089MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
6090
6091/* reg_ritr_if_vrrp_id_ipv4
6092 * VRRP ID for IPv4
6093 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
6094 * Access: RW
6095 */
6096MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
6097
Ido Schimmel3dc26682016-07-02 11:00:18 +02006098/* VLAN Interface */
6099
6100/* reg_ritr_vlan_if_vid
6101 * VLAN ID.
6102 * Access: RW
6103 */
6104MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
6105
6106/* FID Interface */
6107
6108/* reg_ritr_fid_if_fid
6109 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
6110 * the vFID range are supported.
6111 * Access: RW
6112 */
6113MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
6114
6115static inline void mlxsw_reg_ritr_fid_set(char *payload,
6116 enum mlxsw_reg_ritr_if_type rif_type,
6117 u16 fid)
6118{
6119 if (rif_type == MLXSW_REG_RITR_FID_IF)
6120 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
6121 else
6122 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
6123}
6124
6125/* Sub-port Interface */
6126
6127/* reg_ritr_sp_if_lag
6128 * LAG indication. When this bit is set the system_port field holds the
6129 * LAG identifier.
6130 * Access: RW
6131 */
6132MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
6133
6134/* reg_ritr_sp_system_port
6135 * Port unique indentifier. When lag bit is set, this field holds the
6136 * lag_id in bits 0:9.
6137 * Access: RW
6138 */
6139MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
6140
6141/* reg_ritr_sp_if_vid
6142 * VLAN ID.
6143 * Access: RW
6144 */
6145MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
6146
Petr Machata99ae8e32017-09-02 23:49:09 +02006147/* Loopback Interface */
6148
6149enum mlxsw_reg_ritr_loopback_protocol {
6150 /* IPinIP IPv4 underlay Unicast */
6151 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
6152 /* IPinIP IPv6 underlay Unicast */
6153 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
Nir Dotanafba3e12019-01-20 06:50:39 +00006154 /* IPinIP generic - used for Spectrum-2 underlay RIF */
6155 MLXSW_REG_RITR_LOOPBACK_GENERIC,
Petr Machata99ae8e32017-09-02 23:49:09 +02006156};
6157
6158/* reg_ritr_loopback_protocol
6159 * Access: RW
6160 */
6161MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
6162
6163enum mlxsw_reg_ritr_loopback_ipip_type {
6164 /* Tunnel is IPinIP. */
6165 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
6166 /* Tunnel is GRE, no key. */
6167 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
6168 /* Tunnel is GRE, with a key. */
6169 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
6170};
6171
6172/* reg_ritr_loopback_ipip_type
6173 * Encapsulation type.
6174 * Access: RW
6175 */
6176MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
6177
6178enum mlxsw_reg_ritr_loopback_ipip_options {
6179 /* The key is defined by gre_key. */
6180 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
6181};
6182
6183/* reg_ritr_loopback_ipip_options
6184 * Access: RW
6185 */
6186MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
6187
6188/* reg_ritr_loopback_ipip_uvr
6189 * Underlay Virtual Router ID.
6190 * Range is 0..cap_max_virtual_routers-1.
6191 * Reserved for Spectrum-2.
6192 * Access: RW
6193 */
6194MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
6195
Nir Dotanafba3e12019-01-20 06:50:39 +00006196/* reg_ritr_loopback_ipip_underlay_rif
6197 * Underlay ingress router interface.
6198 * Reserved for Spectrum.
6199 * Access: RW
6200 */
6201MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
6202
Petr Machata99ae8e32017-09-02 23:49:09 +02006203/* reg_ritr_loopback_ipip_usip*
6204 * Encapsulation Underlay source IP.
6205 * Access: RW
6206 */
6207MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
6208MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
6209
6210/* reg_ritr_loopback_ipip_gre_key
6211 * GRE Key.
6212 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
6213 * Access: RW
6214 */
6215MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
6216
Arkadi Sharshevsky0f630fc2017-03-28 17:24:11 +02006217/* Shared between ingress/egress */
6218enum mlxsw_reg_ritr_counter_set_type {
6219 /* No Count. */
6220 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
6221 /* Basic. Used for router interfaces, counting the following:
6222 * - Error and Discard counters.
6223 * - Unicast, Multicast and Broadcast counters. Sharing the
6224 * same set of counters for the different type of traffic
6225 * (IPv4, IPv6 and mpls).
6226 */
6227 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
6228};
6229
6230/* reg_ritr_ingress_counter_index
6231 * Counter Index for flow counter.
6232 * Access: RW
6233 */
6234MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
6235
6236/* reg_ritr_ingress_counter_set_type
6237 * Igress Counter Set Type for router interface counter.
6238 * Access: RW
6239 */
6240MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
6241
6242/* reg_ritr_egress_counter_index
6243 * Counter Index for flow counter.
6244 * Access: RW
6245 */
6246MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
6247
6248/* reg_ritr_egress_counter_set_type
6249 * Egress Counter Set Type for router interface counter.
6250 * Access: RW
6251 */
6252MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
6253
6254static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
6255 bool enable, bool egress)
6256{
6257 enum mlxsw_reg_ritr_counter_set_type set_type;
6258
6259 if (enable)
6260 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
6261 else
6262 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
6263 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
6264
6265 if (egress)
6266 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
6267 else
6268 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
6269}
6270
Ido Schimmel3dc26682016-07-02 11:00:18 +02006271static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
6272{
6273 MLXSW_REG_ZERO(ritr, payload);
6274 mlxsw_reg_ritr_rif_set(payload, rif);
6275}
6276
6277static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
6278 u16 system_port, u16 vid)
6279{
6280 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
6281 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
6282 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
6283}
6284
6285static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
6286 enum mlxsw_reg_ritr_if_type type,
Petr Machata9571e822017-09-02 23:49:14 +02006287 u16 rif, u16 vr_id, u16 mtu)
Ido Schimmel3dc26682016-07-02 11:00:18 +02006288{
6289 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
6290
6291 MLXSW_REG_ZERO(ritr, payload);
6292 mlxsw_reg_ritr_enable_set(payload, enable);
6293 mlxsw_reg_ritr_ipv4_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02006294 mlxsw_reg_ritr_ipv6_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02006295 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006296 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
Ido Schimmel3dc26682016-07-02 11:00:18 +02006297 mlxsw_reg_ritr_type_set(payload, type);
6298 mlxsw_reg_ritr_op_set(payload, op);
6299 mlxsw_reg_ritr_rif_set(payload, rif);
6300 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02006301 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02006302 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03006303 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
Ido Schimmela94a6142016-08-17 16:39:33 +02006304 mlxsw_reg_ritr_lb_en_set(payload, 1);
Ido Schimmel69132292017-03-10 08:53:42 +01006305 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
Ido Schimmel3dc26682016-07-02 11:00:18 +02006306 mlxsw_reg_ritr_mtu_set(payload, mtu);
Petr Machata9571e822017-09-02 23:49:14 +02006307}
6308
6309static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
6310{
Ido Schimmel3dc26682016-07-02 11:00:18 +02006311 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
6312}
6313
Petr Machata99ae8e32017-09-02 23:49:09 +02006314static inline void
6315mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
6316 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6317 enum mlxsw_reg_ritr_loopback_ipip_options options,
Nir Dotanafba3e12019-01-20 06:50:39 +00006318 u16 uvr_id, u16 underlay_rif, u32 gre_key)
Petr Machata99ae8e32017-09-02 23:49:09 +02006319{
6320 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
6321 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
6322 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
Nir Dotanafba3e12019-01-20 06:50:39 +00006323 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
Petr Machata99ae8e32017-09-02 23:49:09 +02006324 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
6325}
6326
6327static inline void
6328mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
6329 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6330 enum mlxsw_reg_ritr_loopback_ipip_options options,
Nir Dotanafba3e12019-01-20 06:50:39 +00006331 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
Petr Machata99ae8e32017-09-02 23:49:09 +02006332{
6333 mlxsw_reg_ritr_loopback_protocol_set(payload,
6334 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
6335 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
Nir Dotanafba3e12019-01-20 06:50:39 +00006336 uvr_id, underlay_rif, gre_key);
Petr Machata99ae8e32017-09-02 23:49:09 +02006337 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
6338}
6339
Yotam Gigi46a70542017-09-19 10:00:13 +02006340/* RTAR - Router TCAM Allocation Register
6341 * --------------------------------------
6342 * This register is used for allocation of regions in the TCAM table.
6343 */
6344#define MLXSW_REG_RTAR_ID 0x8004
6345#define MLXSW_REG_RTAR_LEN 0x20
6346
6347MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
6348
6349enum mlxsw_reg_rtar_op {
6350 MLXSW_REG_RTAR_OP_ALLOCATE,
6351 MLXSW_REG_RTAR_OP_RESIZE,
6352 MLXSW_REG_RTAR_OP_DEALLOCATE,
6353};
6354
6355/* reg_rtar_op
6356 * Access: WO
6357 */
6358MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
6359
6360enum mlxsw_reg_rtar_key_type {
6361 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
6362 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
6363};
6364
6365/* reg_rtar_key_type
6366 * TCAM key type for the region.
6367 * Access: WO
6368 */
6369MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
6370
6371/* reg_rtar_region_size
6372 * TCAM region size. When allocating/resizing this is the requested
6373 * size, the response is the actual size.
6374 * Note: Actual size may be larger than requested.
6375 * Reserved for op = Deallocate
6376 * Access: WO
6377 */
6378MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
6379
6380static inline void mlxsw_reg_rtar_pack(char *payload,
6381 enum mlxsw_reg_rtar_op op,
6382 enum mlxsw_reg_rtar_key_type key_type,
6383 u16 region_size)
6384{
6385 MLXSW_REG_ZERO(rtar, payload);
6386 mlxsw_reg_rtar_op_set(payload, op);
6387 mlxsw_reg_rtar_key_type_set(payload, key_type);
6388 mlxsw_reg_rtar_region_size_set(payload, region_size);
6389}
6390
Yotam Gigi089f9812016-07-05 11:27:48 +02006391/* RATR - Router Adjacency Table Register
6392 * --------------------------------------
6393 * The RATR register is used to configure the Router Adjacency (next-hop)
6394 * Table.
6395 */
6396#define MLXSW_REG_RATR_ID 0x8008
6397#define MLXSW_REG_RATR_LEN 0x2C
6398
Jiri Pirko21978dc2016-10-21 16:07:20 +02006399MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
Yotam Gigi089f9812016-07-05 11:27:48 +02006400
6401enum mlxsw_reg_ratr_op {
6402 /* Read */
6403 MLXSW_REG_RATR_OP_QUERY_READ = 0,
6404 /* Read and clear activity */
6405 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
6406 /* Write Adjacency entry */
6407 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
6408 /* Write Adjacency entry only if the activity is cleared.
6409 * The write may not succeed if the activity is set. There is not
6410 * direct feedback if the write has succeeded or not, however
6411 * the get will reveal the actual entry (SW can compare the get
6412 * response to the set command).
6413 */
6414 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
6415};
6416
6417/* reg_ratr_op
6418 * Note that Write operation may also be used for updating
6419 * counter_set_type and counter_index. In this case all other
6420 * fields must not be updated.
6421 * Access: OP
6422 */
6423MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
6424
6425/* reg_ratr_v
6426 * Valid bit. Indicates if the adjacency entry is valid.
6427 * Note: the device may need some time before reusing an invalidated
6428 * entry. During this time the entry can not be reused. It is
6429 * recommended to use another entry before reusing an invalidated
6430 * entry (e.g. software can put it at the end of the list for
6431 * reusing). Trying to access an invalidated entry not yet cleared
6432 * by the device results with failure indicating "Try Again" status.
6433 * When valid is '0' then egress_router_interface,trap_action,
6434 * adjacency_parameters and counters are reserved
6435 * Access: RW
6436 */
6437MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
6438
6439/* reg_ratr_a
6440 * Activity. Set for new entries. Set if a packet lookup has hit on
6441 * the specific entry. To clear the a bit, use "clear activity".
6442 * Access: RO
6443 */
6444MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
6445
Petr Machata7c819de2017-09-02 23:49:10 +02006446enum mlxsw_reg_ratr_type {
6447 /* Ethernet */
6448 MLXSW_REG_RATR_TYPE_ETHERNET,
6449 /* IPoIB Unicast without GRH.
6450 * Reserved for Spectrum.
6451 */
6452 MLXSW_REG_RATR_TYPE_IPOIB_UC,
6453 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
6454 * adjacency).
6455 * Reserved for Spectrum.
6456 */
6457 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
6458 /* IPoIB Multicast.
6459 * Reserved for Spectrum.
6460 */
6461 MLXSW_REG_RATR_TYPE_IPOIB_MC,
6462 /* MPLS.
6463 * Reserved for SwitchX/-2.
6464 */
6465 MLXSW_REG_RATR_TYPE_MPLS,
6466 /* IPinIP Encap.
6467 * Reserved for SwitchX/-2.
6468 */
6469 MLXSW_REG_RATR_TYPE_IPIP,
6470};
6471
6472/* reg_ratr_type
6473 * Adjacency entry type.
6474 * Access: RW
6475 */
6476MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
6477
Yotam Gigi089f9812016-07-05 11:27:48 +02006478/* reg_ratr_adjacency_index_low
6479 * Bits 15:0 of index into the adjacency table.
6480 * For SwitchX and SwitchX-2, the adjacency table is linear and
6481 * used for adjacency entries only.
6482 * For Spectrum, the index is to the KVD linear.
6483 * Access: Index
6484 */
6485MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
6486
6487/* reg_ratr_egress_router_interface
6488 * Range is 0 .. cap_max_router_interfaces - 1
6489 * Access: RW
6490 */
6491MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
6492
6493enum mlxsw_reg_ratr_trap_action {
6494 MLXSW_REG_RATR_TRAP_ACTION_NOP,
6495 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
6496 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
6497 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
6498 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
6499};
6500
6501/* reg_ratr_trap_action
6502 * see mlxsw_reg_ratr_trap_action
6503 * Access: RW
6504 */
6505MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
6506
Yotam Gigi089f9812016-07-05 11:27:48 +02006507/* reg_ratr_adjacency_index_high
6508 * Bits 23:16 of the adjacency_index.
6509 * Access: Index
6510 */
6511MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
6512
Petr Machata6c4153b2017-09-02 23:49:11 +02006513enum mlxsw_reg_ratr_trap_id {
6514 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
6515 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
6516};
6517
Yotam Gigi089f9812016-07-05 11:27:48 +02006518/* reg_ratr_trap_id
6519 * Trap ID to be reported to CPU.
6520 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
6521 * For trap_action of NOP, MIRROR and DISCARD_ERROR
6522 * Access: RW
6523 */
6524MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
6525
6526/* reg_ratr_eth_destination_mac
6527 * MAC address of the destination next-hop.
6528 * Access: RW
6529 */
6530MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
6531
Petr Machata7c819de2017-09-02 23:49:10 +02006532enum mlxsw_reg_ratr_ipip_type {
6533 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
6534 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
6535 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
6536 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
6537};
6538
6539/* reg_ratr_ipip_type
6540 * Underlay destination ip type.
6541 * Note: the type field must match the protocol of the router interface.
6542 * Access: RW
6543 */
6544MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
6545
6546/* reg_ratr_ipip_ipv4_udip
6547 * Underlay ipv4 dip.
6548 * Reserved when ipip_type is IPv6.
6549 * Access: RW
6550 */
6551MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
6552
6553/* reg_ratr_ipip_ipv6_ptr
6554 * Pointer to IPv6 underlay destination ip address.
6555 * For Spectrum: Pointer to KVD linear space.
6556 * Access: RW
6557 */
6558MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
6559
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02006560enum mlxsw_reg_flow_counter_set_type {
6561 /* No count */
6562 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
6563 /* Count packets and bytes */
6564 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
6565 /* Count only packets */
6566 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
6567};
6568
6569/* reg_ratr_counter_set_type
6570 * Counter set type for flow counters
6571 * Access: RW
6572 */
6573MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
6574
6575/* reg_ratr_counter_index
6576 * Counter index for flow counters
6577 * Access: RW
6578 */
6579MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
6580
Yotam Gigi089f9812016-07-05 11:27:48 +02006581static inline void
6582mlxsw_reg_ratr_pack(char *payload,
6583 enum mlxsw_reg_ratr_op op, bool valid,
Petr Machata89e41982017-09-02 23:49:15 +02006584 enum mlxsw_reg_ratr_type type,
Yotam Gigi089f9812016-07-05 11:27:48 +02006585 u32 adjacency_index, u16 egress_rif)
6586{
6587 MLXSW_REG_ZERO(ratr, payload);
6588 mlxsw_reg_ratr_op_set(payload, op);
6589 mlxsw_reg_ratr_v_set(payload, valid);
Petr Machata89e41982017-09-02 23:49:15 +02006590 mlxsw_reg_ratr_type_set(payload, type);
Yotam Gigi089f9812016-07-05 11:27:48 +02006591 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
6592 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
6593 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
6594}
6595
6596static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
6597 const char *dest_mac)
6598{
6599 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
6600}
6601
Petr Machata7c819de2017-09-02 23:49:10 +02006602static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
6603{
6604 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
6605 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
6606}
6607
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02006608static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
6609 bool counter_enable)
6610{
6611 enum mlxsw_reg_flow_counter_set_type set_type;
6612
6613 if (counter_enable)
6614 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
6615 else
6616 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
6617
6618 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
6619 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
6620}
6621
Yuval Mintzddb362c2018-01-14 12:33:13 +01006622/* RDPM - Router DSCP to Priority Mapping
6623 * --------------------------------------
6624 * Controls the mapping from DSCP field to switch priority on routed packets
6625 */
6626#define MLXSW_REG_RDPM_ID 0x8009
6627#define MLXSW_REG_RDPM_BASE_LEN 0x00
6628#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
6629#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
6630#define MLXSW_REG_RDPM_LEN 0x40
6631#define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
6632 MLXSW_REG_RDPM_LEN - \
6633 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
6634
6635MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
6636
6637/* reg_dscp_entry_e
6638 * Enable update of the specific entry
6639 * Access: Index
6640 */
6641MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
6642 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
6643
6644/* reg_dscp_entry_prio
6645 * Switch Priority
6646 * Access: RW
6647 */
6648MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
6649 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
6650
6651static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
6652 u8 prio)
6653{
6654 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
6655 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
6656}
6657
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +02006658/* RICNT - Router Interface Counter Register
6659 * -----------------------------------------
6660 * The RICNT register retrieves per port performance counters
6661 */
6662#define MLXSW_REG_RICNT_ID 0x800B
6663#define MLXSW_REG_RICNT_LEN 0x100
6664
6665MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
6666
6667/* reg_ricnt_counter_index
6668 * Counter index
6669 * Access: RW
6670 */
6671MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
6672
6673enum mlxsw_reg_ricnt_counter_set_type {
6674 /* No Count. */
6675 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
6676 /* Basic. Used for router interfaces, counting the following:
6677 * - Error and Discard counters.
6678 * - Unicast, Multicast and Broadcast counters. Sharing the
6679 * same set of counters for the different type of traffic
6680 * (IPv4, IPv6 and mpls).
6681 */
6682 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
6683};
6684
6685/* reg_ricnt_counter_set_type
6686 * Counter Set Type for router interface counter
6687 * Access: RW
6688 */
6689MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
6690
6691enum mlxsw_reg_ricnt_opcode {
6692 /* Nop. Supported only for read access*/
6693 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
6694 /* Clear. Setting the clr bit will reset the counter value for
6695 * all counters of the specified Router Interface.
6696 */
6697 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
6698};
6699
6700/* reg_ricnt_opcode
6701 * Opcode
6702 * Access: RW
6703 */
6704MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
6705
6706/* reg_ricnt_good_unicast_packets
6707 * good unicast packets.
6708 * Access: RW
6709 */
6710MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
6711
6712/* reg_ricnt_good_multicast_packets
6713 * good multicast packets.
6714 * Access: RW
6715 */
6716MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
6717
6718/* reg_ricnt_good_broadcast_packets
6719 * good broadcast packets
6720 * Access: RW
6721 */
6722MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
6723
6724/* reg_ricnt_good_unicast_bytes
6725 * A count of L3 data and padding octets not including L2 headers
6726 * for good unicast frames.
6727 * Access: RW
6728 */
6729MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
6730
6731/* reg_ricnt_good_multicast_bytes
6732 * A count of L3 data and padding octets not including L2 headers
6733 * for good multicast frames.
6734 * Access: RW
6735 */
6736MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
6737
6738/* reg_ritr_good_broadcast_bytes
6739 * A count of L3 data and padding octets not including L2 headers
6740 * for good broadcast frames.
6741 * Access: RW
6742 */
6743MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
6744
6745/* reg_ricnt_error_packets
6746 * A count of errored frames that do not pass the router checks.
6747 * Access: RW
6748 */
6749MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
6750
6751/* reg_ricnt_discrad_packets
6752 * A count of non-errored frames that do not pass the router checks.
6753 * Access: RW
6754 */
6755MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
6756
6757/* reg_ricnt_error_bytes
6758 * A count of L3 data and padding octets not including L2 headers
6759 * for errored frames.
6760 * Access: RW
6761 */
6762MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
6763
6764/* reg_ricnt_discard_bytes
6765 * A count of L3 data and padding octets not including L2 headers
6766 * for non-errored frames that do not pass the router checks.
6767 * Access: RW
6768 */
6769MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
6770
6771static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
6772 enum mlxsw_reg_ricnt_opcode op)
6773{
6774 MLXSW_REG_ZERO(ricnt, payload);
6775 mlxsw_reg_ricnt_op_set(payload, op);
6776 mlxsw_reg_ricnt_counter_index_set(payload, index);
6777 mlxsw_reg_ricnt_counter_set_type_set(payload,
6778 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
6779}
6780
Yotam Gigi4fc92842017-09-19 10:00:17 +02006781/* RRCR - Router Rules Copy Register Layout
6782 * ----------------------------------------
6783 * This register is used for moving and copying route entry rules.
6784 */
6785#define MLXSW_REG_RRCR_ID 0x800F
6786#define MLXSW_REG_RRCR_LEN 0x24
6787
6788MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
6789
6790enum mlxsw_reg_rrcr_op {
6791 /* Move rules */
6792 MLXSW_REG_RRCR_OP_MOVE,
6793 /* Copy rules */
6794 MLXSW_REG_RRCR_OP_COPY,
6795};
6796
6797/* reg_rrcr_op
6798 * Access: WO
6799 */
6800MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
6801
6802/* reg_rrcr_offset
6803 * Offset within the region from which to copy/move.
6804 * Access: Index
6805 */
6806MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
6807
6808/* reg_rrcr_size
6809 * The number of rules to copy/move.
6810 * Access: WO
6811 */
6812MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
6813
6814/* reg_rrcr_table_id
6815 * Identifier of the table on which to perform the operation. Encoding is the
6816 * same as in RTAR.key_type
6817 * Access: Index
6818 */
6819MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
6820
6821/* reg_rrcr_dest_offset
6822 * Offset within the region to which to copy/move
6823 * Access: Index
6824 */
6825MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
6826
6827static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
6828 u16 offset, u16 size,
6829 enum mlxsw_reg_rtar_key_type table_id,
6830 u16 dest_offset)
6831{
6832 MLXSW_REG_ZERO(rrcr, payload);
6833 mlxsw_reg_rrcr_op_set(payload, op);
6834 mlxsw_reg_rrcr_offset_set(payload, offset);
6835 mlxsw_reg_rrcr_size_set(payload, size);
6836 mlxsw_reg_rrcr_table_id_set(payload, table_id);
6837 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
6838}
6839
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02006840/* RALTA - Router Algorithmic LPM Tree Allocation Register
6841 * -------------------------------------------------------
6842 * RALTA is used to allocate the LPM trees of the SHSPM method.
6843 */
6844#define MLXSW_REG_RALTA_ID 0x8010
6845#define MLXSW_REG_RALTA_LEN 0x04
6846
Jiri Pirko21978dc2016-10-21 16:07:20 +02006847MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02006848
6849/* reg_ralta_op
6850 * opcode (valid for Write, must be 0 on Read)
6851 * 0 - allocate a tree
6852 * 1 - deallocate a tree
6853 * Access: OP
6854 */
6855MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
6856
6857enum mlxsw_reg_ralxx_protocol {
6858 MLXSW_REG_RALXX_PROTOCOL_IPV4,
6859 MLXSW_REG_RALXX_PROTOCOL_IPV6,
6860};
6861
6862/* reg_ralta_protocol
6863 * Protocol.
6864 * Deallocation opcode: Reserved.
6865 * Access: RW
6866 */
6867MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
6868
6869/* reg_ralta_tree_id
6870 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
6871 * the tree identifier (managed by software).
6872 * Note that tree_id 0 is allocated for a default-route tree.
6873 * Access: Index
6874 */
6875MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
6876
6877static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
6878 enum mlxsw_reg_ralxx_protocol protocol,
6879 u8 tree_id)
6880{
6881 MLXSW_REG_ZERO(ralta, payload);
6882 mlxsw_reg_ralta_op_set(payload, !alloc);
6883 mlxsw_reg_ralta_protocol_set(payload, protocol);
6884 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
6885}
6886
Jiri Pirkoa9823352016-07-04 08:23:06 +02006887/* RALST - Router Algorithmic LPM Structure Tree Register
6888 * ------------------------------------------------------
6889 * RALST is used to set and query the structure of an LPM tree.
6890 * The structure of the tree must be sorted as a sorted binary tree, while
6891 * each node is a bin that is tagged as the length of the prefixes the lookup
6892 * will refer to. Therefore, bin X refers to a set of entries with prefixes
6893 * of X bits to match with the destination address. The bin 0 indicates
6894 * the default action, when there is no match of any prefix.
6895 */
6896#define MLXSW_REG_RALST_ID 0x8011
6897#define MLXSW_REG_RALST_LEN 0x104
6898
Jiri Pirko21978dc2016-10-21 16:07:20 +02006899MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
Jiri Pirkoa9823352016-07-04 08:23:06 +02006900
6901/* reg_ralst_root_bin
6902 * The bin number of the root bin.
6903 * 0<root_bin=<(length of IP address)
6904 * For a default-route tree configure 0xff
6905 * Access: RW
6906 */
6907MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
6908
6909/* reg_ralst_tree_id
6910 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
6911 * Access: Index
6912 */
6913MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
6914
6915#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
6916#define MLXSW_REG_RALST_BIN_OFFSET 0x04
6917#define MLXSW_REG_RALST_BIN_COUNT 128
6918
6919/* reg_ralst_left_child_bin
6920 * Holding the children of the bin according to the stored tree's structure.
6921 * For trees composed of less than 4 blocks, the bins in excess are reserved.
6922 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
6923 * Access: RW
6924 */
6925MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
6926
6927/* reg_ralst_right_child_bin
6928 * Holding the children of the bin according to the stored tree's structure.
6929 * For trees composed of less than 4 blocks, the bins in excess are reserved.
6930 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
6931 * Access: RW
6932 */
6933MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
6934 false);
6935
6936static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
6937{
6938 MLXSW_REG_ZERO(ralst, payload);
6939
6940 /* Initialize all bins to have no left or right child */
6941 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
6942 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
6943
6944 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
6945 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
6946}
6947
6948static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
6949 u8 left_child_bin,
6950 u8 right_child_bin)
6951{
6952 int bin_index = bin_number - 1;
6953
6954 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
6955 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
6956 right_child_bin);
6957}
6958
Jiri Pirko20ae4052016-07-04 08:23:07 +02006959/* RALTB - Router Algorithmic LPM Tree Binding Register
6960 * ----------------------------------------------------
6961 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
6962 */
6963#define MLXSW_REG_RALTB_ID 0x8012
6964#define MLXSW_REG_RALTB_LEN 0x04
6965
Jiri Pirko21978dc2016-10-21 16:07:20 +02006966MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
Jiri Pirko20ae4052016-07-04 08:23:07 +02006967
6968/* reg_raltb_virtual_router
6969 * Virtual Router ID
6970 * Range is 0..cap_max_virtual_routers-1
6971 * Access: Index
6972 */
6973MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
6974
6975/* reg_raltb_protocol
6976 * Protocol.
6977 * Access: Index
6978 */
6979MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
6980
6981/* reg_raltb_tree_id
6982 * Tree to be used for the {virtual_router, protocol}
6983 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
6984 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
6985 * Access: RW
6986 */
6987MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
6988
6989static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
6990 enum mlxsw_reg_ralxx_protocol protocol,
6991 u8 tree_id)
6992{
6993 MLXSW_REG_ZERO(raltb, payload);
6994 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
6995 mlxsw_reg_raltb_protocol_set(payload, protocol);
6996 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
6997}
6998
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006999/* RALUE - Router Algorithmic LPM Unicast Entry Register
7000 * -----------------------------------------------------
7001 * RALUE is used to configure and query LPM entries that serve
7002 * the Unicast protocols.
7003 */
7004#define MLXSW_REG_RALUE_ID 0x8013
7005#define MLXSW_REG_RALUE_LEN 0x38
7006
Jiri Pirko21978dc2016-10-21 16:07:20 +02007007MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007008
7009/* reg_ralue_protocol
7010 * Protocol.
7011 * Access: Index
7012 */
7013MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
7014
7015enum mlxsw_reg_ralue_op {
7016 /* Read operation. If entry doesn't exist, the operation fails. */
7017 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
7018 /* Clear on read operation. Used to read entry and
7019 * clear Activity bit.
7020 */
7021 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
7022 /* Write operation. Used to write a new entry to the table. All RW
7023 * fields are written for new entry. Activity bit is set
7024 * for new entries.
7025 */
7026 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
7027 /* Update operation. Used to update an existing route entry and
7028 * only update the RW fields that are detailed in the field
7029 * op_u_mask. If entry doesn't exist, the operation fails.
7030 */
7031 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
7032 /* Clear activity. The Activity bit (the field a) is cleared
7033 * for the entry.
7034 */
7035 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
7036 /* Delete operation. Used to delete an existing entry. If entry
7037 * doesn't exist, the operation fails.
7038 */
7039 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
7040};
7041
7042/* reg_ralue_op
7043 * Operation.
7044 * Access: OP
7045 */
7046MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
7047
7048/* reg_ralue_a
7049 * Activity. Set for new entries. Set if a packet lookup has hit on the
7050 * specific entry, only if the entry is a route. To clear the a bit, use
7051 * "clear activity" op.
7052 * Enabled by activity_dis in RGCR
7053 * Access: RO
7054 */
7055MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
7056
7057/* reg_ralue_virtual_router
7058 * Virtual Router ID
7059 * Range is 0..cap_max_virtual_routers-1
7060 * Access: Index
7061 */
7062MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
7063
7064#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
7065#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
7066#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
7067
7068/* reg_ralue_op_u_mask
7069 * opcode update mask.
7070 * On read operation, this field is reserved.
7071 * This field is valid for update opcode, otherwise - reserved.
7072 * This field is a bitmask of the fields that should be updated.
7073 * Access: WO
7074 */
7075MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
7076
7077/* reg_ralue_prefix_len
7078 * Number of bits in the prefix of the LPM route.
7079 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
7080 * two entries in the physical HW table.
7081 * Access: Index
7082 */
7083MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
7084
7085/* reg_ralue_dip*
7086 * The prefix of the route or of the marker that the object of the LPM
7087 * is compared with. The most significant bits of the dip are the prefix.
Petr Machata806a1c1a2017-07-31 09:27:24 +02007088 * The least significant bits must be '0' if the prefix_len is smaller
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007089 * than 128 for IPv6 or smaller than 32 for IPv4.
7090 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
7091 * Access: Index
7092 */
7093MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
Ido Schimmel62547f42017-07-18 10:10:23 +02007094MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007095
7096enum mlxsw_reg_ralue_entry_type {
7097 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
7098 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
7099 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
7100};
7101
7102/* reg_ralue_entry_type
7103 * Entry type.
7104 * Note - for Marker entries, the action_type and action fields are reserved.
7105 * Access: RW
7106 */
7107MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
7108
7109/* reg_ralue_bmp_len
7110 * The best match prefix length in the case that there is no match for
7111 * longer prefixes.
7112 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
7113 * Note for any update operation with entry_type modification this
7114 * field must be set.
7115 * Access: RW
7116 */
7117MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
7118
7119enum mlxsw_reg_ralue_action_type {
7120 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
7121 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
7122 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
7123};
7124
7125/* reg_ralue_action_type
7126 * Action Type
7127 * Indicates how the IP address is connected.
7128 * It can be connected to a local subnet through local_erif or can be
7129 * on a remote subnet connected through a next-hop router,
7130 * or transmitted to the CPU.
7131 * Reserved when entry_type = MARKER_ENTRY
7132 * Access: RW
7133 */
7134MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
7135
7136enum mlxsw_reg_ralue_trap_action {
7137 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
7138 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
7139 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
7140 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
7141 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
7142};
7143
7144/* reg_ralue_trap_action
7145 * Trap action.
7146 * For IP2ME action, only NOP and MIRROR are possible.
7147 * Access: RW
7148 */
7149MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
7150
7151/* reg_ralue_trap_id
7152 * Trap ID to be reported to CPU.
7153 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
7154 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
7155 * Access: RW
7156 */
7157MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
7158
7159/* reg_ralue_adjacency_index
7160 * Points to the first entry of the group-based ECMP.
7161 * Only relevant in case of REMOTE action.
7162 * Access: RW
7163 */
7164MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
7165
7166/* reg_ralue_ecmp_size
7167 * Amount of sequential entries starting
7168 * from the adjacency_index (the number of ECMPs).
7169 * The valid range is 1-64, 512, 1024, 2048 and 4096.
7170 * Reserved when trap_action is TRAP or DISCARD_ERROR.
7171 * Only relevant in case of REMOTE action.
7172 * Access: RW
7173 */
7174MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
7175
7176/* reg_ralue_local_erif
7177 * Egress Router Interface.
7178 * Only relevant in case of LOCAL action.
7179 * Access: RW
7180 */
7181MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
7182
Petr Machata83930cd2017-07-31 09:27:27 +02007183/* reg_ralue_ip2me_v
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007184 * Valid bit for the tunnel_ptr field.
7185 * If valid = 0 then trap to CPU as IP2ME trap ID.
7186 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
7187 * decapsulation then tunnel decapsulation is done.
7188 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
7189 * decapsulation then trap as IP2ME trap ID.
7190 * Only relevant in case of IP2ME action.
7191 * Access: RW
7192 */
Petr Machata83930cd2017-07-31 09:27:27 +02007193MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007194
Petr Machata83930cd2017-07-31 09:27:27 +02007195/* reg_ralue_ip2me_tunnel_ptr
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007196 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
7197 * For Spectrum, pointer to KVD Linear.
7198 * Only relevant in case of IP2ME action.
7199 * Access: RW
7200 */
Petr Machata83930cd2017-07-31 09:27:27 +02007201MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007202
7203static inline void mlxsw_reg_ralue_pack(char *payload,
7204 enum mlxsw_reg_ralxx_protocol protocol,
7205 enum mlxsw_reg_ralue_op op,
7206 u16 virtual_router, u8 prefix_len)
7207{
7208 MLXSW_REG_ZERO(ralue, payload);
7209 mlxsw_reg_ralue_protocol_set(payload, protocol);
Jiri Pirko0e7df1a2016-08-17 16:39:34 +02007210 mlxsw_reg_ralue_op_set(payload, op);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007211 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
7212 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
7213 mlxsw_reg_ralue_entry_type_set(payload,
7214 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
7215 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
7216}
7217
7218static inline void mlxsw_reg_ralue_pack4(char *payload,
7219 enum mlxsw_reg_ralxx_protocol protocol,
7220 enum mlxsw_reg_ralue_op op,
7221 u16 virtual_router, u8 prefix_len,
7222 u32 dip)
7223{
7224 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7225 mlxsw_reg_ralue_dip4_set(payload, dip);
7226}
7227
Ido Schimmel62547f42017-07-18 10:10:23 +02007228static inline void mlxsw_reg_ralue_pack6(char *payload,
7229 enum mlxsw_reg_ralxx_protocol protocol,
7230 enum mlxsw_reg_ralue_op op,
7231 u16 virtual_router, u8 prefix_len,
7232 const void *dip)
7233{
7234 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7235 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
7236}
7237
Jiri Pirkod5a1c742016-07-04 08:23:10 +02007238static inline void
7239mlxsw_reg_ralue_act_remote_pack(char *payload,
7240 enum mlxsw_reg_ralue_trap_action trap_action,
7241 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
7242{
7243 mlxsw_reg_ralue_action_type_set(payload,
7244 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
7245 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7246 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7247 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
7248 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
7249}
7250
7251static inline void
7252mlxsw_reg_ralue_act_local_pack(char *payload,
7253 enum mlxsw_reg_ralue_trap_action trap_action,
7254 u16 trap_id, u16 local_erif)
7255{
7256 mlxsw_reg_ralue_action_type_set(payload,
7257 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
7258 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7259 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7260 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
7261}
7262
7263static inline void
7264mlxsw_reg_ralue_act_ip2me_pack(char *payload)
7265{
7266 mlxsw_reg_ralue_action_type_set(payload,
7267 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7268}
7269
Petr Machataa43da822017-09-02 23:49:12 +02007270static inline void
7271mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
7272{
7273 mlxsw_reg_ralue_action_type_set(payload,
7274 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7275 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
7276 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
7277}
7278
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007279/* RAUHT - Router Algorithmic LPM Unicast Host Table Register
7280 * ----------------------------------------------------------
7281 * The RAUHT register is used to configure and query the Unicast Host table in
7282 * devices that implement the Algorithmic LPM.
7283 */
7284#define MLXSW_REG_RAUHT_ID 0x8014
7285#define MLXSW_REG_RAUHT_LEN 0x74
7286
Jiri Pirko21978dc2016-10-21 16:07:20 +02007287MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007288
7289enum mlxsw_reg_rauht_type {
7290 MLXSW_REG_RAUHT_TYPE_IPV4,
7291 MLXSW_REG_RAUHT_TYPE_IPV6,
7292};
7293
7294/* reg_rauht_type
7295 * Access: Index
7296 */
7297MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
7298
7299enum mlxsw_reg_rauht_op {
7300 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
7301 /* Read operation */
7302 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
7303 /* Clear on read operation. Used to read entry and clear
7304 * activity bit.
7305 */
7306 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
7307 /* Add. Used to write a new entry to the table. All R/W fields are
7308 * relevant for new entry. Activity bit is set for new entries.
7309 */
7310 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
7311 /* Update action. Used to update an existing route entry and
7312 * only update the following fields:
7313 * trap_action, trap_id, mac, counter_set_type, counter_index
7314 */
7315 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
7316 /* Clear activity. A bit is cleared for the entry. */
7317 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
7318 /* Delete entry */
7319 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
7320 /* Delete all host entries on a RIF. In this command, dip
7321 * field is reserved.
7322 */
7323};
7324
7325/* reg_rauht_op
7326 * Access: OP
7327 */
7328MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
7329
7330/* reg_rauht_a
7331 * Activity. Set for new entries. Set if a packet lookup has hit on
7332 * the specific entry.
7333 * To clear the a bit, use "clear activity" op.
7334 * Enabled by activity_dis in RGCR
7335 * Access: RO
7336 */
7337MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
7338
7339/* reg_rauht_rif
7340 * Router Interface
7341 * Access: Index
7342 */
7343MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
7344
7345/* reg_rauht_dip*
7346 * Destination address.
7347 * Access: Index
7348 */
7349MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02007350MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007351
7352enum mlxsw_reg_rauht_trap_action {
7353 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
7354 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
7355 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
7356 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
7357 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
7358};
7359
7360/* reg_rauht_trap_action
7361 * Access: RW
7362 */
7363MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
7364
7365enum mlxsw_reg_rauht_trap_id {
7366 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
7367 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
7368};
7369
7370/* reg_rauht_trap_id
7371 * Trap ID to be reported to CPU.
7372 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
7373 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
7374 * trap_id is reserved.
7375 * Access: RW
7376 */
7377MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
7378
7379/* reg_rauht_counter_set_type
7380 * Counter set type for flow counters
7381 * Access: RW
7382 */
7383MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
7384
7385/* reg_rauht_counter_index
7386 * Counter index for flow counters
7387 * Access: RW
7388 */
7389MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
7390
7391/* reg_rauht_mac
7392 * MAC address.
7393 * Access: RW
7394 */
7395MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
7396
7397static inline void mlxsw_reg_rauht_pack(char *payload,
7398 enum mlxsw_reg_rauht_op op, u16 rif,
7399 const char *mac)
7400{
7401 MLXSW_REG_ZERO(rauht, payload);
7402 mlxsw_reg_rauht_op_set(payload, op);
7403 mlxsw_reg_rauht_rif_set(payload, rif);
7404 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
7405}
7406
7407static inline void mlxsw_reg_rauht_pack4(char *payload,
7408 enum mlxsw_reg_rauht_op op, u16 rif,
7409 const char *mac, u32 dip)
7410{
7411 mlxsw_reg_rauht_pack(payload, op, rif, mac);
7412 mlxsw_reg_rauht_dip4_set(payload, dip);
7413}
7414
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02007415static inline void mlxsw_reg_rauht_pack6(char *payload,
7416 enum mlxsw_reg_rauht_op op, u16 rif,
7417 const char *mac, const char *dip)
7418{
7419 mlxsw_reg_rauht_pack(payload, op, rif, mac);
7420 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
7421 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
7422}
7423
Arkadi Sharshevsky7cfcbc72017-08-24 08:40:08 +02007424static inline void mlxsw_reg_rauht_pack_counter(char *payload,
7425 u64 counter_index)
7426{
7427 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
7428 mlxsw_reg_rauht_counter_set_type_set(payload,
7429 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
7430}
7431
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02007432/* RALEU - Router Algorithmic LPM ECMP Update Register
7433 * ---------------------------------------------------
7434 * The register enables updating the ECMP section in the action for multiple
7435 * LPM Unicast entries in a single operation. The update is executed to
7436 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
7437 */
7438#define MLXSW_REG_RALEU_ID 0x8015
7439#define MLXSW_REG_RALEU_LEN 0x28
7440
Jiri Pirko21978dc2016-10-21 16:07:20 +02007441MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02007442
7443/* reg_raleu_protocol
7444 * Protocol.
7445 * Access: Index
7446 */
7447MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
7448
7449/* reg_raleu_virtual_router
7450 * Virtual Router ID
7451 * Range is 0..cap_max_virtual_routers-1
7452 * Access: Index
7453 */
7454MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
7455
7456/* reg_raleu_adjacency_index
7457 * Adjacency Index used for matching on the existing entries.
7458 * Access: Index
7459 */
7460MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
7461
7462/* reg_raleu_ecmp_size
7463 * ECMP Size used for matching on the existing entries.
7464 * Access: Index
7465 */
7466MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
7467
7468/* reg_raleu_new_adjacency_index
7469 * New Adjacency Index.
7470 * Access: WO
7471 */
7472MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
7473
7474/* reg_raleu_new_ecmp_size
7475 * New ECMP Size.
7476 * Access: WO
7477 */
7478MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
7479
7480static inline void mlxsw_reg_raleu_pack(char *payload,
7481 enum mlxsw_reg_ralxx_protocol protocol,
7482 u16 virtual_router,
7483 u32 adjacency_index, u16 ecmp_size,
7484 u32 new_adjacency_index,
7485 u16 new_ecmp_size)
7486{
7487 MLXSW_REG_ZERO(raleu, payload);
7488 mlxsw_reg_raleu_protocol_set(payload, protocol);
7489 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
7490 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
7491 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
7492 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
7493 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
7494}
7495
Yotam Gigi7cf2c202016-07-05 11:27:41 +02007496/* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
7497 * ----------------------------------------------------------------
7498 * The RAUHTD register allows dumping entries from the Router Unicast Host
7499 * Table. For a given session an entry is dumped no more than one time. The
7500 * first RAUHTD access after reset is a new session. A session ends when the
7501 * num_rec response is smaller than num_rec request or for IPv4 when the
7502 * num_entries is smaller than 4. The clear activity affect the current session
7503 * or the last session if a new session has not started.
7504 */
7505#define MLXSW_REG_RAUHTD_ID 0x8018
7506#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
7507#define MLXSW_REG_RAUHTD_REC_LEN 0x20
7508#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
7509#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
7510 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
7511#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
7512
Jiri Pirko21978dc2016-10-21 16:07:20 +02007513MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
Yotam Gigi7cf2c202016-07-05 11:27:41 +02007514
7515#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
7516#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
7517
7518/* reg_rauhtd_filter_fields
7519 * if a bit is '0' then the relevant field is ignored and dump is done
7520 * regardless of the field value
7521 * Bit0 - filter by activity: entry_a
7522 * Bit3 - filter by entry rip: entry_rif
7523 * Access: Index
7524 */
7525MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
7526
7527enum mlxsw_reg_rauhtd_op {
7528 MLXSW_REG_RAUHTD_OP_DUMP,
7529 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
7530};
7531
7532/* reg_rauhtd_op
7533 * Access: OP
7534 */
7535MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
7536
7537/* reg_rauhtd_num_rec
7538 * At request: number of records requested
7539 * At response: number of records dumped
7540 * For IPv4, each record has 4 entries at request and up to 4 entries
7541 * at response
7542 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
7543 * Access: Index
7544 */
7545MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
7546
7547/* reg_rauhtd_entry_a
7548 * Dump only if activity has value of entry_a
7549 * Reserved if filter_fields bit0 is '0'
7550 * Access: Index
7551 */
7552MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
7553
7554enum mlxsw_reg_rauhtd_type {
7555 MLXSW_REG_RAUHTD_TYPE_IPV4,
7556 MLXSW_REG_RAUHTD_TYPE_IPV6,
7557};
7558
7559/* reg_rauhtd_type
7560 * Dump only if record type is:
7561 * 0 - IPv4
7562 * 1 - IPv6
7563 * Access: Index
7564 */
7565MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
7566
7567/* reg_rauhtd_entry_rif
7568 * Dump only if RIF has value of entry_rif
7569 * Reserved if filter_fields bit3 is '0'
7570 * Access: Index
7571 */
7572MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
7573
7574static inline void mlxsw_reg_rauhtd_pack(char *payload,
7575 enum mlxsw_reg_rauhtd_type type)
7576{
7577 MLXSW_REG_ZERO(rauhtd, payload);
7578 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
7579 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
7580 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
7581 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
7582 mlxsw_reg_rauhtd_type_set(payload, type);
7583}
7584
7585/* reg_rauhtd_ipv4_rec_num_entries
7586 * Number of valid entries in this record:
7587 * 0 - 1 valid entry
7588 * 1 - 2 valid entries
7589 * 2 - 3 valid entries
7590 * 3 - 4 valid entries
7591 * Access: RO
7592 */
7593MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
7594 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
7595 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
7596
7597/* reg_rauhtd_rec_type
7598 * Record type.
7599 * 0 - IPv4
7600 * 1 - IPv6
7601 * Access: RO
7602 */
7603MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
7604 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
7605
7606#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
7607
7608/* reg_rauhtd_ipv4_ent_a
7609 * Activity. Set for new entries. Set if a packet lookup has hit on the
7610 * specific entry.
7611 * Access: RO
7612 */
7613MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
7614 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
7615
7616/* reg_rauhtd_ipv4_ent_rif
7617 * Router interface.
7618 * Access: RO
7619 */
7620MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7621 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
7622
7623/* reg_rauhtd_ipv4_ent_dip
7624 * Destination IPv4 address.
7625 * Access: RO
7626 */
7627MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7628 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
7629
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02007630#define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
7631
7632/* reg_rauhtd_ipv6_ent_a
7633 * Activity. Set for new entries. Set if a packet lookup has hit on the
7634 * specific entry.
7635 * Access: RO
7636 */
7637MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
7638 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
7639
7640/* reg_rauhtd_ipv6_ent_rif
7641 * Router interface.
7642 * Access: RO
7643 */
7644MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
7645 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
7646
7647/* reg_rauhtd_ipv6_ent_dip
7648 * Destination IPv6 address.
7649 * Access: RO
7650 */
7651MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
7652 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
7653
Yotam Gigi7cf2c202016-07-05 11:27:41 +02007654static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
7655 int ent_index, u16 *p_rif,
7656 u32 *p_dip)
7657{
7658 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
7659 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
7660}
7661
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02007662static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
7663 int rec_index, u16 *p_rif,
7664 char *p_dip)
7665{
7666 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
7667 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
7668}
7669
Petr Machata1e659eb2017-09-02 23:49:13 +02007670/* RTDP - Routing Tunnel Decap Properties Register
7671 * -----------------------------------------------
7672 * The RTDP register is used for configuring the tunnel decap properties of NVE
7673 * and IPinIP.
7674 */
7675#define MLXSW_REG_RTDP_ID 0x8020
7676#define MLXSW_REG_RTDP_LEN 0x44
7677
7678MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
7679
7680enum mlxsw_reg_rtdp_type {
7681 MLXSW_REG_RTDP_TYPE_NVE,
7682 MLXSW_REG_RTDP_TYPE_IPIP,
7683};
7684
7685/* reg_rtdp_type
7686 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
7687 * Access: RW
7688 */
7689MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
7690
7691/* reg_rtdp_tunnel_index
7692 * Index to the Decap entry.
7693 * For Spectrum, Index to KVD Linear.
7694 * Access: Index
7695 */
7696MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
7697
Ido Schimmelc9417492019-01-20 06:50:39 +00007698/* reg_rtdp_egress_router_interface
7699 * Underlay egress router interface.
7700 * Valid range is from 0 to cap_max_router_interfaces - 1
7701 * Access: RW
7702 */
7703MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
7704
Petr Machata1e659eb2017-09-02 23:49:13 +02007705/* IPinIP */
7706
7707/* reg_rtdp_ipip_irif
7708 * Ingress Router Interface for the overlay router
7709 * Access: RW
7710 */
7711MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
7712
7713enum mlxsw_reg_rtdp_ipip_sip_check {
7714 /* No sip checks. */
7715 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
7716 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
7717 * equal ipv4_usip.
7718 */
7719 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
7720 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
7721 * equal ipv6_usip.
7722 */
7723 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
7724};
7725
7726/* reg_rtdp_ipip_sip_check
7727 * SIP check to perform. If decapsulation failed due to these configurations
7728 * then trap_id is IPIP_DECAP_ERROR.
7729 * Access: RW
7730 */
7731MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
7732
7733/* If set, allow decapsulation of IPinIP (without GRE). */
7734#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
7735/* If set, allow decapsulation of IPinGREinIP without a key. */
7736#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
7737/* If set, allow decapsulation of IPinGREinIP with a key. */
7738#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
7739
7740/* reg_rtdp_ipip_type_check
7741 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
7742 * these configurations then trap_id is IPIP_DECAP_ERROR.
7743 * Access: RW
7744 */
7745MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
7746
7747/* reg_rtdp_ipip_gre_key_check
7748 * Whether GRE key should be checked. When check is enabled:
7749 * - A packet received as IPinIP (without GRE) will always pass.
7750 * - A packet received as IPinGREinIP without a key will not pass the check.
7751 * - A packet received as IPinGREinIP with a key will pass the check only if the
7752 * key in the packet is equal to expected_gre_key.
7753 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
7754 * Access: RW
7755 */
7756MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
7757
7758/* reg_rtdp_ipip_ipv4_usip
7759 * Underlay IPv4 address for ipv4 source address check.
7760 * Reserved when sip_check is not '1'.
7761 * Access: RW
7762 */
7763MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
7764
7765/* reg_rtdp_ipip_ipv6_usip_ptr
7766 * This field is valid when sip_check is "sipv6 check explicitly". This is a
7767 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
7768 * is to the KVD linear.
7769 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
7770 * Access: RW
7771 */
7772MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
7773
7774/* reg_rtdp_ipip_expected_gre_key
7775 * GRE key for checking.
7776 * Reserved when gre_key_check is '0'.
7777 * Access: RW
7778 */
7779MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
7780
7781static inline void mlxsw_reg_rtdp_pack(char *payload,
7782 enum mlxsw_reg_rtdp_type type,
7783 u32 tunnel_index)
7784{
7785 MLXSW_REG_ZERO(rtdp, payload);
7786 mlxsw_reg_rtdp_type_set(payload, type);
7787 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
7788}
7789
7790static inline void
7791mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
7792 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
7793 unsigned int type_check, bool gre_key_check,
7794 u32 ipv4_usip, u32 expected_gre_key)
7795{
7796 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
7797 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
7798 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
7799 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
7800 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
7801 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
7802}
7803
Yotam Gigi5080c7e2017-09-19 10:00:14 +02007804/* RIGR-V2 - Router Interface Group Register Version 2
7805 * ---------------------------------------------------
7806 * The RIGR_V2 register is used to add, remove and query egress interface list
7807 * of a multicast forwarding entry.
7808 */
7809#define MLXSW_REG_RIGR2_ID 0x8023
7810#define MLXSW_REG_RIGR2_LEN 0xB0
7811
7812#define MLXSW_REG_RIGR2_MAX_ERIFS 32
7813
7814MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
7815
7816/* reg_rigr2_rigr_index
7817 * KVD Linear index.
7818 * Access: Index
7819 */
7820MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
7821
7822/* reg_rigr2_vnext
7823 * Next RIGR Index is valid.
7824 * Access: RW
7825 */
7826MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
7827
7828/* reg_rigr2_next_rigr_index
7829 * Next RIGR Index. The index is to the KVD linear.
7830 * Reserved when vnxet = '0'.
7831 * Access: RW
7832 */
7833MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
7834
7835/* reg_rigr2_vrmid
7836 * RMID Index is valid.
7837 * Access: RW
7838 */
7839MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
7840
7841/* reg_rigr2_rmid_index
7842 * RMID Index.
7843 * Range 0 .. max_mid - 1
7844 * Reserved when vrmid = '0'.
7845 * The index is to the Port Group Table (PGT)
7846 * Access: RW
7847 */
7848MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
7849
7850/* reg_rigr2_erif_entry_v
7851 * Egress Router Interface is valid.
7852 * Note that low-entries must be set if high-entries are set. For
7853 * example: if erif_entry[2].v is set then erif_entry[1].v and
7854 * erif_entry[0].v must be set.
7855 * Index can be from 0 to cap_mc_erif_list_entries-1
7856 * Access: RW
7857 */
7858MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
7859
7860/* reg_rigr2_erif_entry_erif
7861 * Egress Router Interface.
7862 * Valid range is from 0 to cap_max_router_interfaces - 1
7863 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
7864 * Access: RW
7865 */
7866MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
7867
7868static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
7869 bool vnext, u32 next_rigr_index)
7870{
7871 MLXSW_REG_ZERO(rigr2, payload);
7872 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
7873 mlxsw_reg_rigr2_vnext_set(payload, vnext);
7874 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
7875 mlxsw_reg_rigr2_vrmid_set(payload, 0);
7876 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
7877}
7878
7879static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
7880 bool v, u16 erif)
7881{
7882 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
7883 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
7884}
7885
Ido Schimmele4718592017-11-02 17:14:08 +01007886/* RECR-V2 - Router ECMP Configuration Version 2 Register
7887 * ------------------------------------------------------
7888 */
7889#define MLXSW_REG_RECR2_ID 0x8025
7890#define MLXSW_REG_RECR2_LEN 0x38
7891
7892MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
7893
7894/* reg_recr2_pp
7895 * Per-port configuration
7896 * Access: Index
7897 */
7898MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
7899
7900/* reg_recr2_sh
7901 * Symmetric hash
7902 * Access: RW
7903 */
7904MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
7905
7906/* reg_recr2_seed
7907 * Seed
7908 * Access: RW
7909 */
7910MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
7911
7912enum {
7913 /* Enable IPv4 fields if packet is not TCP and not UDP */
7914 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
7915 /* Enable IPv4 fields if packet is TCP or UDP */
7916 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
7917 /* Enable IPv6 fields if packet is not TCP and not UDP */
7918 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
7919 /* Enable IPv6 fields if packet is TCP or UDP */
7920 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
7921 /* Enable TCP/UDP header fields if packet is IPv4 */
7922 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
7923 /* Enable TCP/UDP header fields if packet is IPv6 */
7924 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
7925};
7926
7927/* reg_recr2_outer_header_enables
7928 * Bit mask where each bit enables a specific layer to be included in
7929 * the hash calculation.
7930 * Access: RW
7931 */
7932MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
7933
7934enum {
7935 /* IPv4 Source IP */
7936 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
7937 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
7938 /* IPv4 Destination IP */
7939 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
7940 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
7941 /* IP Protocol */
7942 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
7943 /* IPv6 Source IP */
7944 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
7945 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
7946 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
7947 /* IPv6 Destination IP */
7948 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
7949 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
7950 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
7951 /* IPv6 Next Header */
7952 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
7953 /* IPv6 Flow Label */
7954 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
7955 /* TCP/UDP Source Port */
7956 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
7957 /* TCP/UDP Destination Port */
7958 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
7959};
7960
7961/* reg_recr2_outer_header_fields_enable
7962 * Packet fields to enable for ECMP hash subject to outer_header_enable.
7963 * Access: RW
7964 */
7965MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
7966
7967static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
7968{
7969 int i;
7970
7971 for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
7972 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7973 true);
7974}
7975
7976static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
7977{
7978 int i;
7979
7980 for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
7981 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7982 true);
7983}
7984
7985static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
7986{
7987 int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
7988
7989 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7990
7991 i = MLXSW_REG_RECR2_IPV6_SIP8;
7992 for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
7993 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7994 true);
7995}
7996
7997static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
7998{
7999 int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
8000
8001 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
8002
8003 i = MLXSW_REG_RECR2_IPV6_DIP8;
8004 for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
8005 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
8006 true);
8007}
8008
8009static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
8010{
8011 MLXSW_REG_ZERO(recr2, payload);
8012 mlxsw_reg_recr2_pp_set(payload, false);
8013 mlxsw_reg_recr2_sh_set(payload, true);
8014 mlxsw_reg_recr2_seed_set(payload, seed);
8015}
8016
Yotam Gigi2e654e32017-09-19 10:00:16 +02008017/* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
8018 * --------------------------------------------------------------
8019 * The RMFT_V2 register is used to configure and query the multicast table.
8020 */
8021#define MLXSW_REG_RMFT2_ID 0x8027
8022#define MLXSW_REG_RMFT2_LEN 0x174
8023
8024MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
8025
8026/* reg_rmft2_v
8027 * Valid
8028 * Access: RW
8029 */
8030MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
8031
8032enum mlxsw_reg_rmft2_type {
8033 MLXSW_REG_RMFT2_TYPE_IPV4,
8034 MLXSW_REG_RMFT2_TYPE_IPV6
8035};
8036
8037/* reg_rmft2_type
8038 * Access: Index
8039 */
8040MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
8041
8042enum mlxsw_sp_reg_rmft2_op {
8043 /* For Write:
8044 * Write operation. Used to write a new entry to the table. All RW
8045 * fields are relevant for new entry. Activity bit is set for new
8046 * entries - Note write with v (Valid) 0 will delete the entry.
8047 * For Query:
8048 * Read operation
8049 */
8050 MLXSW_REG_RMFT2_OP_READ_WRITE,
8051};
8052
8053/* reg_rmft2_op
8054 * Operation.
8055 * Access: OP
8056 */
8057MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
8058
8059/* reg_rmft2_a
8060 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
8061 * entry.
8062 * Access: RO
8063 */
8064MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
8065
8066/* reg_rmft2_offset
8067 * Offset within the multicast forwarding table to write to.
8068 * Access: Index
8069 */
8070MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
8071
8072/* reg_rmft2_virtual_router
8073 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
8074 * Access: RW
8075 */
8076MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
8077
8078enum mlxsw_reg_rmft2_irif_mask {
8079 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
8080 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
8081};
8082
8083/* reg_rmft2_irif_mask
8084 * Ingress RIF mask.
8085 * Access: RW
8086 */
8087MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
8088
8089/* reg_rmft2_irif
8090 * Ingress RIF index.
8091 * Access: RW
8092 */
8093MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
8094
Yuval Mintza82b1b82018-03-26 15:01:38 +03008095/* reg_rmft2_dip{4,6}
8096 * Destination IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02008097 * Access: RW
8098 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008099MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008100MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
8101
Yuval Mintza82b1b82018-03-26 15:01:38 +03008102/* reg_rmft2_dip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02008103 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
8104 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
8105 * Access: RW
8106 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008107MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008108MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
8109
Yuval Mintza82b1b82018-03-26 15:01:38 +03008110/* reg_rmft2_sip{4,6}
8111 * Source IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02008112 * Access: RW
8113 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008114MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008115MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
8116
Yuval Mintza82b1b82018-03-26 15:01:38 +03008117/* reg_rmft2_sip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02008118 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
8119 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
8120 * Access: RW
8121 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03008122MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008123MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
8124
8125/* reg_rmft2_flexible_action_set
8126 * ACL action set. The only supported action types in this field and in any
8127 * action-set pointed from here are as follows:
8128 * 00h: ACTION_NULL
8129 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
8130 * 03h: ACTION_TRAP
8131 * 06h: ACTION_QOS
8132 * 08h: ACTION_POLICING_MONITORING
8133 * 10h: ACTION_ROUTER_MC
8134 * Access: RW
8135 */
8136MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
8137 MLXSW_REG_FLEX_ACTION_SET_LEN);
8138
8139static inline void
Yuval Mintza82b1b82018-03-26 15:01:38 +03008140mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
8141 u16 virtual_router,
8142 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8143 const char *flex_action_set)
Yotam Gigi2e654e32017-09-19 10:00:16 +02008144{
8145 MLXSW_REG_ZERO(rmft2, payload);
8146 mlxsw_reg_rmft2_v_set(payload, v);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008147 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
8148 mlxsw_reg_rmft2_offset_set(payload, offset);
8149 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
8150 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
8151 mlxsw_reg_rmft2_irif_set(payload, irif);
Yuval Mintza82b1b82018-03-26 15:01:38 +03008152 if (flex_action_set)
8153 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
8154 flex_action_set);
8155}
8156
8157static inline void
8158mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8159 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8160 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
8161 const char *flexible_action_set)
8162{
8163 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8164 irif_mask, irif, flexible_action_set);
8165 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008166 mlxsw_reg_rmft2_dip4_set(payload, dip4);
8167 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
8168 mlxsw_reg_rmft2_sip4_set(payload, sip4);
8169 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
Yuval Mintza82b1b82018-03-26 15:01:38 +03008170}
8171
8172static inline void
8173mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8174 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8175 struct in6_addr dip6, struct in6_addr dip6_mask,
8176 struct in6_addr sip6, struct in6_addr sip6_mask,
8177 const char *flexible_action_set)
8178{
8179 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8180 irif_mask, irif, flexible_action_set);
8181 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
8182 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
8183 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
8184 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
8185 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
Yotam Gigi2e654e32017-09-19 10:00:16 +02008186}
8187
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008188/* MFCR - Management Fan Control Register
8189 * --------------------------------------
8190 * This register controls the settings of the Fan Speed PWM mechanism.
8191 */
8192#define MLXSW_REG_MFCR_ID 0x9001
8193#define MLXSW_REG_MFCR_LEN 0x08
8194
Jiri Pirko21978dc2016-10-21 16:07:20 +02008195MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008196
8197enum mlxsw_reg_mfcr_pwm_frequency {
8198 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
8199 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
8200 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
8201 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
8202 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
8203 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
8204 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
8205 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
8206};
8207
8208/* reg_mfcr_pwm_frequency
8209 * Controls the frequency of the PWM signal.
8210 * Access: RW
8211 */
Jiri Pirkof7ad3d42016-11-11 11:22:53 +01008212MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008213
8214#define MLXSW_MFCR_TACHOS_MAX 10
8215
8216/* reg_mfcr_tacho_active
8217 * Indicates which of the tachometer is active (bit per tachometer).
8218 * Access: RO
8219 */
8220MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
8221
8222#define MLXSW_MFCR_PWMS_MAX 5
8223
8224/* reg_mfcr_pwm_active
8225 * Indicates which of the PWM control is active (bit per PWM).
8226 * Access: RO
8227 */
8228MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
8229
8230static inline void
8231mlxsw_reg_mfcr_pack(char *payload,
8232 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
8233{
8234 MLXSW_REG_ZERO(mfcr, payload);
8235 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
8236}
8237
8238static inline void
8239mlxsw_reg_mfcr_unpack(char *payload,
8240 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
8241 u16 *p_tacho_active, u8 *p_pwm_active)
8242{
8243 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
8244 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
8245 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
8246}
8247
8248/* MFSC - Management Fan Speed Control Register
8249 * --------------------------------------------
8250 * This register controls the settings of the Fan Speed PWM mechanism.
8251 */
8252#define MLXSW_REG_MFSC_ID 0x9002
8253#define MLXSW_REG_MFSC_LEN 0x08
8254
Jiri Pirko21978dc2016-10-21 16:07:20 +02008255MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008256
8257/* reg_mfsc_pwm
8258 * Fan pwm to control / monitor.
8259 * Access: Index
8260 */
8261MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
8262
8263/* reg_mfsc_pwm_duty_cycle
8264 * Controls the duty cycle of the PWM. Value range from 0..255 to
8265 * represent duty cycle of 0%...100%.
8266 * Access: RW
8267 */
8268MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
8269
8270static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
8271 u8 pwm_duty_cycle)
8272{
8273 MLXSW_REG_ZERO(mfsc, payload);
8274 mlxsw_reg_mfsc_pwm_set(payload, pwm);
8275 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
8276}
8277
8278/* MFSM - Management Fan Speed Measurement
8279 * ---------------------------------------
8280 * This register controls the settings of the Tacho measurements and
8281 * enables reading the Tachometer measurements.
8282 */
8283#define MLXSW_REG_MFSM_ID 0x9003
8284#define MLXSW_REG_MFSM_LEN 0x08
8285
Jiri Pirko21978dc2016-10-21 16:07:20 +02008286MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01008287
8288/* reg_mfsm_tacho
8289 * Fan tachometer index.
8290 * Access: Index
8291 */
8292MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
8293
8294/* reg_mfsm_rpm
8295 * Fan speed (round per minute).
8296 * Access: RO
8297 */
8298MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
8299
8300static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
8301{
8302 MLXSW_REG_ZERO(mfsm, payload);
8303 mlxsw_reg_mfsm_tacho_set(payload, tacho);
8304}
8305
Jiri Pirko55c63aa2016-11-22 11:24:12 +01008306/* MFSL - Management Fan Speed Limit Register
8307 * ------------------------------------------
8308 * The Fan Speed Limit register is used to configure the fan speed
8309 * event / interrupt notification mechanism. Fan speed threshold are
8310 * defined for both under-speed and over-speed.
8311 */
8312#define MLXSW_REG_MFSL_ID 0x9004
8313#define MLXSW_REG_MFSL_LEN 0x0C
8314
8315MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
8316
8317/* reg_mfsl_tacho
8318 * Fan tachometer index.
8319 * Access: Index
8320 */
8321MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
8322
8323/* reg_mfsl_tach_min
8324 * Tachometer minimum value (minimum RPM).
8325 * Access: RW
8326 */
8327MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
8328
8329/* reg_mfsl_tach_max
8330 * Tachometer maximum value (maximum RPM).
8331 * Access: RW
8332 */
8333MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
8334
8335static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
8336 u16 tach_min, u16 tach_max)
8337{
8338 MLXSW_REG_ZERO(mfsl, payload);
8339 mlxsw_reg_mfsl_tacho_set(payload, tacho);
8340 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
8341 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
8342}
8343
8344static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
8345 u16 *p_tach_min, u16 *p_tach_max)
8346{
8347 if (p_tach_min)
8348 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
8349
8350 if (p_tach_max)
8351 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
8352}
8353
Vadim Pasternak3760c2b2019-02-13 11:28:46 +00008354/* FORE - Fan Out of Range Event Register
8355 * --------------------------------------
8356 * This register reports the status of the controlled fans compared to the
8357 * range defined by the MFSL register.
8358 */
8359#define MLXSW_REG_FORE_ID 0x9007
8360#define MLXSW_REG_FORE_LEN 0x0C
8361
8362MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
8363
8364/* fan_under_limit
8365 * Fan speed is below the low limit defined in MFSL register. Each bit relates
8366 * to a single tachometer and indicates the specific tachometer reading is
8367 * below the threshold.
8368 * Access: RO
8369 */
8370MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
8371
8372static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
8373 bool *fault)
8374{
8375 u16 limit;
8376
8377 if (fault) {
8378 limit = mlxsw_reg_fore_fan_under_limit_get(payload);
8379 *fault = limit & BIT(tacho);
8380 }
8381}
8382
Jiri Pirko85926f82015-11-27 13:45:56 +01008383/* MTCAP - Management Temperature Capabilities
8384 * -------------------------------------------
8385 * This register exposes the capabilities of the device and
8386 * system temperature sensing.
8387 */
8388#define MLXSW_REG_MTCAP_ID 0x9009
8389#define MLXSW_REG_MTCAP_LEN 0x08
8390
Jiri Pirko21978dc2016-10-21 16:07:20 +02008391MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01008392
8393/* reg_mtcap_sensor_count
8394 * Number of sensors supported by the device.
8395 * This includes the QSFP module sensors (if exists in the QSFP module).
8396 * Access: RO
8397 */
8398MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
8399
8400/* MTMP - Management Temperature
8401 * -----------------------------
8402 * This register controls the settings of the temperature measurements
8403 * and enables reading the temperature measurements. Note that temperature
8404 * is in 0.125 degrees Celsius.
8405 */
8406#define MLXSW_REG_MTMP_ID 0x900A
8407#define MLXSW_REG_MTMP_LEN 0x20
8408
Jiri Pirko21978dc2016-10-21 16:07:20 +02008409MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01008410
Vadim Pasternak984aec72019-05-29 11:47:21 +03008411#define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
Vadim Pasternakae574672019-05-29 11:47:18 +03008412#define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
Jiri Pirko85926f82015-11-27 13:45:56 +01008413/* reg_mtmp_sensor_index
8414 * Sensors index to access.
8415 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
8416 * (module 0 is mapped to sensor_index 64).
8417 * Access: Index
8418 */
Vadim Pasternak984aec72019-05-29 11:47:21 +03008419MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
Jiri Pirko85926f82015-11-27 13:45:56 +01008420
8421/* Convert to milli degrees Celsius */
Vadim Pasternakf485cc32019-06-24 13:32:03 +03008422#define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
8423 ((v_) >= 0) ? ((v_) * 125) : \
8424 ((s16)((GENMASK(15, 0) + (v_) + 1) \
8425 * 125)); })
Jiri Pirko85926f82015-11-27 13:45:56 +01008426
8427/* reg_mtmp_temperature
8428 * Temperature reading from the sensor. Reading is in 0.125 Celsius
8429 * degrees units.
8430 * Access: RO
8431 */
8432MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
8433
8434/* reg_mtmp_mte
8435 * Max Temperature Enable - enables measuring the max temperature on a sensor.
8436 * Access: RW
8437 */
8438MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
8439
8440/* reg_mtmp_mtr
8441 * Max Temperature Reset - clears the value of the max temperature register.
8442 * Access: WO
8443 */
8444MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
8445
8446/* reg_mtmp_max_temperature
8447 * The highest measured temperature from the sensor.
8448 * When the bit mte is cleared, the field max_temperature is reserved.
8449 * Access: RO
8450 */
8451MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
8452
Ido Schimmel62b0e922017-10-30 10:51:18 +01008453/* reg_mtmp_tee
8454 * Temperature Event Enable.
8455 * 0 - Do not generate event
8456 * 1 - Generate event
8457 * 2 - Generate single event
8458 * Access: RW
8459 */
8460MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
8461
8462#define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
8463
8464/* reg_mtmp_temperature_threshold_hi
8465 * High threshold for Temperature Warning Event. In 0.125 Celsius.
8466 * Access: RW
8467 */
8468MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
8469
8470/* reg_mtmp_temperature_threshold_lo
8471 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
8472 * Access: RW
8473 */
8474MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
8475
Jiri Pirko85926f82015-11-27 13:45:56 +01008476#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
8477
8478/* reg_mtmp_sensor_name
8479 * Sensor Name
8480 * Access: RO
8481 */
8482MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
8483
Vadim Pasternakae574672019-05-29 11:47:18 +03008484static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index,
Jiri Pirko85926f82015-11-27 13:45:56 +01008485 bool max_temp_enable,
8486 bool max_temp_reset)
8487{
8488 MLXSW_REG_ZERO(mtmp, payload);
8489 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
8490 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
8491 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
Ido Schimmel62b0e922017-10-30 10:51:18 +01008492 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
8493 MLXSW_REG_MTMP_THRESH_HI);
Jiri Pirko85926f82015-11-27 13:45:56 +01008494}
8495
Vadim Pasternakf485cc32019-06-24 13:32:03 +03008496static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
8497 int *p_max_temp, char *sensor_name)
Jiri Pirko85926f82015-11-27 13:45:56 +01008498{
Vadim Pasternakf485cc32019-06-24 13:32:03 +03008499 s16 temp;
Jiri Pirko85926f82015-11-27 13:45:56 +01008500
8501 if (p_temp) {
8502 temp = mlxsw_reg_mtmp_temperature_get(payload);
8503 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
8504 }
8505 if (p_max_temp) {
Jiri Pirkoacf35a42015-12-11 16:10:39 +01008506 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
Jiri Pirko85926f82015-11-27 13:45:56 +01008507 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
8508 }
8509 if (sensor_name)
8510 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
8511}
8512
Amit Cohen946bd432020-09-27 10:50:06 +03008513/* MTWE - Management Temperature Warning Event
8514 * -------------------------------------------
8515 * This register is used for over temperature warning.
8516 */
8517#define MLXSW_REG_MTWE_ID 0x900B
8518#define MLXSW_REG_MTWE_LEN 0x10
8519
8520MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN);
8521
8522/* reg_mtwe_sensor_warning
8523 * Bit vector indicating which of the sensor reading is above threshold.
8524 * Address 00h bit31 is sensor_warning[127].
8525 * Address 0Ch bit0 is sensor_warning[0].
8526 * Access: RO
8527 */
8528MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
8529
Vadim Pasternak5f28ef72019-02-13 11:28:45 +00008530/* MTBR - Management Temperature Bulk Register
8531 * -------------------------------------------
8532 * This register is used for bulk temperature reading.
8533 */
8534#define MLXSW_REG_MTBR_ID 0x900F
8535#define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */
8536#define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */
8537#define MLXSW_REG_MTBR_REC_MAX_COUNT 47 /* firmware limitation */
8538#define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
8539 MLXSW_REG_MTBR_REC_LEN * \
8540 MLXSW_REG_MTBR_REC_MAX_COUNT)
8541
8542MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
8543
8544/* reg_mtbr_base_sensor_index
8545 * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
8546 * 64-127 are mapped to the SFP+/QSFP modules sequentially).
8547 * Access: Index
8548 */
Vadim Pasternak984aec72019-05-29 11:47:21 +03008549MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
Vadim Pasternak5f28ef72019-02-13 11:28:45 +00008550
8551/* reg_mtbr_num_rec
8552 * Request: Number of records to read
8553 * Response: Number of records read
8554 * See above description for more details.
8555 * Range 1..255
8556 * Access: RW
8557 */
8558MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
8559
8560/* reg_mtbr_rec_max_temp
8561 * The highest measured temperature from the sensor.
8562 * When the bit mte is cleared, the field max_temperature is reserved.
8563 * Access: RO
8564 */
8565MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
8566 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
8567
8568/* reg_mtbr_rec_temp
8569 * Temperature reading from the sensor. Reading is in 0..125 Celsius
8570 * degrees units.
8571 * Access: RO
8572 */
8573MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
8574 MLXSW_REG_MTBR_REC_LEN, 0x00, false);
8575
Vadim Pasternak984aec72019-05-29 11:47:21 +03008576static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index,
Vadim Pasternak5f28ef72019-02-13 11:28:45 +00008577 u8 num_rec)
8578{
8579 MLXSW_REG_ZERO(mtbr, payload);
8580 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
8581 mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
8582}
8583
8584/* Error codes from temperatute reading */
8585enum mlxsw_reg_mtbr_temp_status {
8586 MLXSW_REG_MTBR_NO_CONN = 0x8000,
8587 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
8588 MLXSW_REG_MTBR_INDEX_NA = 0x8002,
8589 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
8590};
8591
8592/* Base index for reading modules temperature */
8593#define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
8594
8595static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
8596 u16 *p_temp, u16 *p_max_temp)
8597{
8598 if (p_temp)
8599 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
8600 if (p_max_temp)
8601 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
8602}
8603
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008604/* MCIA - Management Cable Info Access
8605 * -----------------------------------
8606 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
8607 */
8608
8609#define MLXSW_REG_MCIA_ID 0x9014
8610#define MLXSW_REG_MCIA_LEN 0x40
8611
8612MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
8613
8614/* reg_mcia_l
8615 * Lock bit. Setting this bit will lock the access to the specific
8616 * cable. Used for updating a full page in a cable EPROM. Any access
8617 * other then subsequence writes will fail while the port is locked.
8618 * Access: RW
8619 */
8620MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
8621
8622/* reg_mcia_module
8623 * Module number.
8624 * Access: Index
8625 */
8626MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
8627
8628/* reg_mcia_status
8629 * Module status.
8630 * Access: RO
8631 */
8632MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
8633
8634/* reg_mcia_i2c_device_address
8635 * I2C device address.
8636 * Access: RW
8637 */
8638MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
8639
8640/* reg_mcia_page_number
8641 * Page number.
8642 * Access: RW
8643 */
8644MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
8645
8646/* reg_mcia_device_address
8647 * Device address.
8648 * Access: RW
8649 */
8650MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
8651
8652/* reg_mcia_size
8653 * Number of bytes to read/write (up to 48 bytes).
8654 * Access: RW
8655 */
8656MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
8657
Vadim Pasternakd517ee72019-02-13 11:28:44 +00008658#define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
Vadim Pasternakf366cd2a2019-10-21 13:30:30 +03008659#define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
Vadim Pasternakd517ee72019-02-13 11:28:44 +00008660#define MLXSW_REG_MCIA_EEPROM_SIZE 48
8661#define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
8662#define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
8663#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
8664#define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
8665#define MLXSW_REG_MCIA_TH_PAGE_NUM 3
Vadim Pasternakf152b412020-07-28 13:20:16 +03008666#define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
Vadim Pasternakd517ee72019-02-13 11:28:44 +00008667#define MLXSW_REG_MCIA_PAGE0_LO 0
8668#define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
Vadim Pasternak6af496a2020-07-28 13:20:15 +03008669#define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
Vadim Pasternakd517ee72019-02-13 11:28:44 +00008670
8671enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
8672 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
8673 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
8674 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
8675};
8676
8677enum mlxsw_reg_mcia_eeprom_module_info_id {
8678 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
8679 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
8680 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
8681 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
8682 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
8683};
8684
8685enum mlxsw_reg_mcia_eeprom_module_info {
8686 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
8687 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
Vadim Pasternak6af496a2020-07-28 13:20:15 +03008688 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
Vadim Pasternakd517ee72019-02-13 11:28:44 +00008689 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
8690};
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008691
8692/* reg_mcia_eeprom
8693 * Bytes to read/write.
8694 * Access: RW
8695 */
Vadim Pasternakd517ee72019-02-13 11:28:44 +00008696MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008697
Vadim Pasternakf366cd2a2019-10-21 13:30:30 +03008698/* This is used to access the optional upper pages (1-3) in the QSFP+
8699 * memory map. Page 1 is available on offset 256 through 383, page 2 -
8700 * on offset 384 through 511, page 3 - on offset 512 through 639.
8701 */
8702#define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
8703 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
8704 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
8705
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008706static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
8707 u8 page_number, u16 device_addr,
8708 u8 size, u8 i2c_device_addr)
8709{
8710 MLXSW_REG_ZERO(mcia, payload);
8711 mlxsw_reg_mcia_module_set(payload, module);
8712 mlxsw_reg_mcia_l_set(payload, lock);
8713 mlxsw_reg_mcia_page_number_set(payload, page_number);
8714 mlxsw_reg_mcia_device_address_set(payload, device_addr);
8715 mlxsw_reg_mcia_size_set(payload, size);
8716 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
8717}
8718
Yotam Gigi43a46852016-07-21 12:03:14 +02008719/* MPAT - Monitoring Port Analyzer Table
8720 * -------------------------------------
8721 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
8722 * For an enabled analyzer, all fields except e (enable) cannot be modified.
8723 */
8724#define MLXSW_REG_MPAT_ID 0x901A
8725#define MLXSW_REG_MPAT_LEN 0x78
8726
Jiri Pirko21978dc2016-10-21 16:07:20 +02008727MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
Yotam Gigi43a46852016-07-21 12:03:14 +02008728
8729/* reg_mpat_pa_id
8730 * Port Analyzer ID.
8731 * Access: Index
8732 */
8733MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
8734
Amit Cohenef8d57e2020-07-14 17:20:54 +03008735/* reg_mpat_session_id
8736 * Mirror Session ID.
8737 * Used for MIRROR_SESSION<i> trap.
8738 * Access: RW
8739 */
8740MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4);
8741
Yotam Gigi43a46852016-07-21 12:03:14 +02008742/* reg_mpat_system_port
8743 * A unique port identifier for the final destination of the packet.
8744 * Access: RW
8745 */
8746MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
8747
8748/* reg_mpat_e
8749 * Enable. Indicating the Port Analyzer is enabled.
8750 * Access: RW
8751 */
8752MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
8753
8754/* reg_mpat_qos
8755 * Quality Of Service Mode.
8756 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
8757 * PCP, DEI, DSCP or VL) are configured.
8758 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
8759 * same as in the original packet that has triggered the mirroring. For
8760 * SPAN also the pcp,dei are maintained.
8761 * Access: RW
8762 */
8763MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
8764
Yotam Gigi23019052016-07-21 12:03:15 +02008765/* reg_mpat_be
8766 * Best effort mode. Indicates mirroring traffic should not cause packet
8767 * drop or back pressure, but will discard the mirrored packets. Mirrored
8768 * packets will be forwarded on a best effort manner.
8769 * 0: Do not discard mirrored packets
8770 * 1: Discard mirrored packets if causing congestion
8771 * Access: RW
8772 */
8773MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
8774
Petr Machata0d6cd3f2018-02-27 14:53:39 +01008775enum mlxsw_reg_mpat_span_type {
8776 /* Local SPAN Ethernet.
8777 * The original packet is not encapsulated.
8778 */
8779 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
8780
Petr Machata41947662018-05-10 13:13:04 +03008781 /* Remote SPAN Ethernet VLAN.
8782 * The packet is forwarded to the monitoring port on the monitoring
8783 * VLAN.
8784 */
8785 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
8786
Petr Machata0d6cd3f2018-02-27 14:53:39 +01008787 /* Encapsulated Remote SPAN Ethernet L3 GRE.
8788 * The packet is encapsulated with GRE header.
8789 */
8790 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
8791};
8792
8793/* reg_mpat_span_type
8794 * SPAN type.
8795 * Access: RW
8796 */
8797MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
8798
Amit Cohenef8d57e2020-07-14 17:20:54 +03008799/* reg_mpat_pide
8800 * Policer enable.
8801 * Access: RW
8802 */
8803MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1);
8804
8805/* reg_mpat_pid
8806 * Policer ID.
8807 * Access: RW
8808 */
8809MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14);
8810
Petr Machata0d6cd3f2018-02-27 14:53:39 +01008811/* Remote SPAN - Ethernet VLAN
8812 * - - - - - - - - - - - - - -
8813 */
8814
8815/* reg_mpat_eth_rspan_vid
8816 * Encapsulation header VLAN ID.
8817 * Access: RW
8818 */
8819MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
8820
8821/* Encapsulated Remote SPAN - Ethernet L2
8822 * - - - - - - - - - - - - - - - - - - -
8823 */
8824
8825enum mlxsw_reg_mpat_eth_rspan_version {
8826 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
8827};
8828
8829/* reg_mpat_eth_rspan_version
8830 * RSPAN mirror header version.
8831 * Access: RW
8832 */
8833MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
8834
8835/* reg_mpat_eth_rspan_mac
8836 * Destination MAC address.
8837 * Access: RW
8838 */
8839MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
8840
8841/* reg_mpat_eth_rspan_tp
8842 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
8843 * Access: RW
8844 */
8845MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
8846
8847/* Encapsulated Remote SPAN - Ethernet L3
8848 * - - - - - - - - - - - - - - - - - - -
8849 */
8850
8851enum mlxsw_reg_mpat_eth_rspan_protocol {
8852 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
8853 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
8854};
8855
8856/* reg_mpat_eth_rspan_protocol
8857 * SPAN encapsulation protocol.
8858 * Access: RW
8859 */
8860MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
8861
8862/* reg_mpat_eth_rspan_ttl
8863 * Encapsulation header Time-to-Live/HopLimit.
8864 * Access: RW
8865 */
8866MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
8867
8868/* reg_mpat_eth_rspan_smac
8869 * Source MAC address
8870 * Access: RW
8871 */
8872MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
8873
8874/* reg_mpat_eth_rspan_dip*
8875 * Destination IP address. The IP version is configured by protocol.
8876 * Access: RW
8877 */
8878MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
8879MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
8880
8881/* reg_mpat_eth_rspan_sip*
8882 * Source IP address. The IP version is configured by protocol.
8883 * Access: RW
8884 */
8885MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
8886MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
8887
Yotam Gigi43a46852016-07-21 12:03:14 +02008888static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
Petr Machata1da93eb2018-02-27 14:53:40 +01008889 u16 system_port, bool e,
8890 enum mlxsw_reg_mpat_span_type span_type)
Yotam Gigi43a46852016-07-21 12:03:14 +02008891{
8892 MLXSW_REG_ZERO(mpat, payload);
8893 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
8894 mlxsw_reg_mpat_system_port_set(payload, system_port);
8895 mlxsw_reg_mpat_e_set(payload, e);
8896 mlxsw_reg_mpat_qos_set(payload, 1);
Yotam Gigi23019052016-07-21 12:03:15 +02008897 mlxsw_reg_mpat_be_set(payload, 1);
Petr Machata1da93eb2018-02-27 14:53:40 +01008898 mlxsw_reg_mpat_span_type_set(payload, span_type);
Yotam Gigi23019052016-07-21 12:03:15 +02008899}
8900
Petr Machata0d6cd3f2018-02-27 14:53:39 +01008901static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
8902{
8903 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
8904}
8905
8906static inline void
8907mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
8908 enum mlxsw_reg_mpat_eth_rspan_version version,
8909 const char *mac,
8910 bool tp)
8911{
8912 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
8913 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
8914 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
8915}
8916
8917static inline void
8918mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
8919 const char *smac,
8920 u32 sip, u32 dip)
8921{
8922 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
8923 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
8924 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
8925 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
8926 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
8927 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
8928}
8929
8930static inline void
8931mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
8932 const char *smac,
8933 struct in6_addr sip, struct in6_addr dip)
8934{
8935 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
8936 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
8937 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
8938 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
8939 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
8940 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
8941}
8942
Yotam Gigi23019052016-07-21 12:03:15 +02008943/* MPAR - Monitoring Port Analyzer Register
8944 * ----------------------------------------
8945 * MPAR register is used to query and configure the port analyzer port mirroring
8946 * properties.
8947 */
8948#define MLXSW_REG_MPAR_ID 0x901B
Ido Schimmel50750662019-10-30 11:34:48 +02008949#define MLXSW_REG_MPAR_LEN 0x0C
Yotam Gigi23019052016-07-21 12:03:15 +02008950
Jiri Pirko21978dc2016-10-21 16:07:20 +02008951MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
Yotam Gigi23019052016-07-21 12:03:15 +02008952
8953/* reg_mpar_local_port
8954 * The local port to mirror the packets from.
8955 * Access: Index
8956 */
8957MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
8958
8959enum mlxsw_reg_mpar_i_e {
8960 MLXSW_REG_MPAR_TYPE_EGRESS,
8961 MLXSW_REG_MPAR_TYPE_INGRESS,
8962};
8963
8964/* reg_mpar_i_e
8965 * Ingress/Egress
8966 * Access: Index
8967 */
8968MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
8969
8970/* reg_mpar_enable
8971 * Enable mirroring
8972 * By default, port mirroring is disabled for all ports.
8973 * Access: RW
8974 */
8975MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
8976
8977/* reg_mpar_pa_id
8978 * Port Analyzer ID.
8979 * Access: RW
8980 */
8981MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
8982
8983static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
8984 enum mlxsw_reg_mpar_i_e i_e,
8985 bool enable, u8 pa_id)
8986{
8987 MLXSW_REG_ZERO(mpar, payload);
8988 mlxsw_reg_mpar_local_port_set(payload, local_port);
8989 mlxsw_reg_mpar_enable_set(payload, enable);
8990 mlxsw_reg_mpar_i_e_set(payload, i_e);
8991 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
Yotam Gigi43a46852016-07-21 12:03:14 +02008992}
8993
Shalom Toledo8d77d4b2019-04-08 06:59:34 +00008994/* MGIR - Management General Information Register
8995 * ----------------------------------------------
8996 * MGIR register allows software to query the hardware and firmware general
8997 * information.
8998 */
8999#define MLXSW_REG_MGIR_ID 0x9020
9000#define MLXSW_REG_MGIR_LEN 0x9C
9001
9002MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
9003
9004/* reg_mgir_hw_info_device_hw_revision
9005 * Access: RO
9006 */
9007MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
9008
9009#define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
9010
9011/* reg_mgir_fw_info_psid
9012 * PSID (ASCII string).
9013 * Access: RO
9014 */
9015MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
9016
9017/* reg_mgir_fw_info_extended_major
9018 * Access: RO
9019 */
9020MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
9021
9022/* reg_mgir_fw_info_extended_minor
9023 * Access: RO
9024 */
9025MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
9026
9027/* reg_mgir_fw_info_extended_sub_minor
9028 * Access: RO
9029 */
9030MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
9031
9032static inline void mlxsw_reg_mgir_pack(char *payload)
9033{
9034 MLXSW_REG_ZERO(mgir, payload);
9035}
9036
9037static inline void
9038mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
9039 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
9040{
9041 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
9042 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
9043 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
9044 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
9045 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
9046}
9047
Jiri Pirko12b003b2018-05-27 09:56:13 +03009048/* MRSR - Management Reset and Shutdown Register
9049 * ---------------------------------------------
9050 * MRSR register is used to reset or shutdown the switch or
9051 * the entire system (when applicable).
9052 */
9053#define MLXSW_REG_MRSR_ID 0x9023
9054#define MLXSW_REG_MRSR_LEN 0x08
9055
9056MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
9057
9058/* reg_mrsr_command
9059 * Reset/shutdown command
9060 * 0 - do nothing
9061 * 1 - software reset
9062 * Access: WO
9063 */
9064MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
9065
9066static inline void mlxsw_reg_mrsr_pack(char *payload)
9067{
9068 MLXSW_REG_ZERO(mrsr, payload);
9069 mlxsw_reg_mrsr_command_set(payload, 1);
9070}
9071
Ido Schimmel3161c152015-11-27 13:45:54 +01009072/* MLCR - Management LED Control Register
9073 * --------------------------------------
9074 * Controls the system LEDs.
9075 */
9076#define MLXSW_REG_MLCR_ID 0x902B
9077#define MLXSW_REG_MLCR_LEN 0x0C
9078
Jiri Pirko21978dc2016-10-21 16:07:20 +02009079MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
Ido Schimmel3161c152015-11-27 13:45:54 +01009080
9081/* reg_mlcr_local_port
9082 * Local port number.
9083 * Access: RW
9084 */
9085MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
9086
9087#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
9088
9089/* reg_mlcr_beacon_duration
9090 * Duration of the beacon to be active, in seconds.
9091 * 0x0 - Will turn off the beacon.
9092 * 0xFFFF - Will turn on the beacon until explicitly turned off.
9093 * Access: RW
9094 */
9095MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
9096
9097/* reg_mlcr_beacon_remain
9098 * Remaining duration of the beacon, in seconds.
9099 * 0xFFFF indicates an infinite amount of time.
9100 * Access: RO
9101 */
9102MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
9103
9104static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
9105 bool active)
9106{
9107 MLXSW_REG_ZERO(mlcr, payload);
9108 mlxsw_reg_mlcr_local_port_set(payload, local_port);
9109 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
9110 MLXSW_REG_MLCR_DURATION_MAX : 0);
9111}
9112
Shalom Toledo10786452019-06-11 18:45:08 +03009113/* MTPPS - Management Pulse Per Second Register
9114 * --------------------------------------------
9115 * This register provides the device PPS capabilities, configure the PPS in and
9116 * out modules and holds the PPS in time stamp.
9117 */
9118#define MLXSW_REG_MTPPS_ID 0x9053
9119#define MLXSW_REG_MTPPS_LEN 0x3C
9120
9121MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
9122
9123/* reg_mtpps_enable
9124 * Enables the PPS functionality the specific pin.
9125 * A boolean variable.
9126 * Access: RW
9127 */
9128MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
9129
9130enum mlxsw_reg_mtpps_pin_mode {
9131 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
9132};
9133
9134/* reg_mtpps_pin_mode
9135 * Pin mode to be used. The mode must comply with the supported modes of the
9136 * requested pin.
9137 * Access: RW
9138 */
9139MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
9140
9141#define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
9142
9143/* reg_mtpps_pin
9144 * Pin to be configured or queried out of the supported pins.
9145 * Access: Index
9146 */
9147MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
9148
9149/* reg_mtpps_time_stamp
9150 * When pin_mode = pps_in, the latched device time when it was triggered from
9151 * the external GPIO pin.
9152 * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target
9153 * time to generate next output signal.
9154 * Time is in units of device clock.
9155 * Access: RW
9156 */
9157MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
9158
9159static inline void
9160mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
9161{
9162 MLXSW_REG_ZERO(mtpps, payload);
9163 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
9164 mlxsw_reg_mtpps_pin_mode_set(payload,
9165 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
9166 mlxsw_reg_mtpps_enable_set(payload, true);
9167 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
9168}
9169
Shalom Toledo55a8b002019-06-11 18:45:07 +03009170/* MTUTC - Management UTC Register
9171 * -------------------------------
9172 * Configures the HW UTC counter.
9173 */
9174#define MLXSW_REG_MTUTC_ID 0x9055
9175#define MLXSW_REG_MTUTC_LEN 0x1C
9176
9177MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
9178
9179enum mlxsw_reg_mtutc_operation {
9180 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
9181 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
9182};
9183
9184/* reg_mtutc_operation
9185 * Operation.
9186 * Access: OP
9187 */
9188MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
9189
9190/* reg_mtutc_freq_adjustment
9191 * Frequency adjustment: Every PPS the HW frequency will be
9192 * adjusted by this value. Units of HW clock, where HW counts
9193 * 10^9 HW clocks for 1 HW second.
9194 * Access: RW
9195 */
9196MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
9197
9198/* reg_mtutc_utc_sec
9199 * UTC seconds.
9200 * Access: WO
9201 */
9202MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
9203
9204static inline void
9205mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
9206 u32 freq_adj, u32 utc_sec)
9207{
9208 MLXSW_REG_ZERO(mtutc, payload);
9209 mlxsw_reg_mtutc_operation_set(payload, oper);
9210 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
9211 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
9212}
9213
Yotam Gigi4f2402d2017-05-23 21:56:24 +02009214/* MCQI - Management Component Query Information
9215 * ---------------------------------------------
9216 * This register allows querying information about firmware components.
9217 */
9218#define MLXSW_REG_MCQI_ID 0x9061
9219#define MLXSW_REG_MCQI_BASE_LEN 0x18
9220#define MLXSW_REG_MCQI_CAP_LEN 0x14
9221#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
9222
9223MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
9224
9225/* reg_mcqi_component_index
9226 * Index of the accessed component.
9227 * Access: Index
9228 */
9229MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
9230
9231enum mlxfw_reg_mcqi_info_type {
9232 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
9233};
9234
9235/* reg_mcqi_info_type
9236 * Component properties set.
9237 * Access: RW
9238 */
9239MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
9240
9241/* reg_mcqi_offset
9242 * The requested/returned data offset from the section start, given in bytes.
9243 * Must be DWORD aligned.
9244 * Access: RW
9245 */
9246MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
9247
9248/* reg_mcqi_data_size
9249 * The requested/returned data size, given in bytes. If data_size is not DWORD
9250 * aligned, the last bytes are zero padded.
9251 * Access: RW
9252 */
9253MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
9254
9255/* reg_mcqi_cap_max_component_size
9256 * Maximum size for this component, given in bytes.
9257 * Access: RO
9258 */
9259MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
9260
9261/* reg_mcqi_cap_log_mcda_word_size
9262 * Log 2 of the access word size in bytes. Read and write access must be aligned
9263 * to the word size. Write access must be done for an integer number of words.
9264 * Access: RO
9265 */
9266MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
9267
9268/* reg_mcqi_cap_mcda_max_write_size
9269 * Maximal write size for MCDA register
9270 * Access: RO
9271 */
9272MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
9273
9274static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
9275{
9276 MLXSW_REG_ZERO(mcqi, payload);
9277 mlxsw_reg_mcqi_component_index_set(payload, component_index);
9278 mlxsw_reg_mcqi_info_type_set(payload,
9279 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
9280 mlxsw_reg_mcqi_offset_set(payload, 0);
9281 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
9282}
9283
9284static inline void mlxsw_reg_mcqi_unpack(char *payload,
9285 u32 *p_cap_max_component_size,
9286 u8 *p_cap_log_mcda_word_size,
9287 u16 *p_cap_mcda_max_write_size)
9288{
9289 *p_cap_max_component_size =
9290 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
9291 *p_cap_log_mcda_word_size =
9292 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
9293 *p_cap_mcda_max_write_size =
9294 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
9295}
9296
Yotam Gigi191839d2017-05-23 21:56:25 +02009297/* MCC - Management Component Control
9298 * ----------------------------------
9299 * Controls the firmware component and updates the FSM.
9300 */
9301#define MLXSW_REG_MCC_ID 0x9062
9302#define MLXSW_REG_MCC_LEN 0x1C
9303
9304MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
9305
9306enum mlxsw_reg_mcc_instruction {
9307 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
9308 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
9309 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
9310 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
9311 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
9312 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
9313};
9314
9315/* reg_mcc_instruction
9316 * Command to be executed by the FSM.
9317 * Applicable for write operation only.
9318 * Access: RW
9319 */
9320MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
9321
9322/* reg_mcc_component_index
9323 * Index of the accessed component. Applicable only for commands that
9324 * refer to components. Otherwise, this field is reserved.
9325 * Access: Index
9326 */
9327MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
9328
9329/* reg_mcc_update_handle
9330 * Token representing the current flow executed by the FSM.
9331 * Access: WO
9332 */
9333MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
9334
9335/* reg_mcc_error_code
9336 * Indicates the successful completion of the instruction, or the reason it
9337 * failed
9338 * Access: RO
9339 */
9340MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
9341
9342/* reg_mcc_control_state
9343 * Current FSM state
9344 * Access: RO
9345 */
9346MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
9347
9348/* reg_mcc_component_size
9349 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
9350 * the size may shorten the update time. Value 0x0 means that size is
9351 * unspecified.
9352 * Access: WO
9353 */
9354MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
9355
9356static inline void mlxsw_reg_mcc_pack(char *payload,
9357 enum mlxsw_reg_mcc_instruction instr,
9358 u16 component_index, u32 update_handle,
9359 u32 component_size)
9360{
9361 MLXSW_REG_ZERO(mcc, payload);
9362 mlxsw_reg_mcc_instruction_set(payload, instr);
9363 mlxsw_reg_mcc_component_index_set(payload, component_index);
9364 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
9365 mlxsw_reg_mcc_component_size_set(payload, component_size);
9366}
9367
9368static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
9369 u8 *p_error_code, u8 *p_control_state)
9370{
9371 if (p_update_handle)
9372 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
9373 if (p_error_code)
9374 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
9375 if (p_control_state)
9376 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
9377}
9378
Yotam Gigi4625d592017-05-23 21:56:26 +02009379/* MCDA - Management Component Data Access
9380 * ---------------------------------------
9381 * This register allows reading and writing a firmware component.
9382 */
9383#define MLXSW_REG_MCDA_ID 0x9063
9384#define MLXSW_REG_MCDA_BASE_LEN 0x10
9385#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
9386#define MLXSW_REG_MCDA_LEN \
9387 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
9388
9389MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
9390
9391/* reg_mcda_update_handle
9392 * Token representing the current flow executed by the FSM.
9393 * Access: RW
9394 */
9395MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
9396
9397/* reg_mcda_offset
9398 * Offset of accessed address relative to component start. Accesses must be in
9399 * accordance to log_mcda_word_size in MCQI reg.
9400 * Access: RW
9401 */
9402MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
9403
9404/* reg_mcda_size
9405 * Size of the data accessed, given in bytes.
9406 * Access: RW
9407 */
9408MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
9409
9410/* reg_mcda_data
9411 * Data block accessed.
9412 * Access: RW
9413 */
9414MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
9415
9416static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
9417 u32 offset, u16 size, u8 *data)
9418{
9419 int i;
9420
9421 MLXSW_REG_ZERO(mcda, payload);
9422 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
9423 mlxsw_reg_mcda_offset_set(payload, offset);
9424 mlxsw_reg_mcda_size_set(payload, size);
9425
9426 for (i = 0; i < size / 4; i++)
9427 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
9428}
9429
Yotam Gigi0677d682017-01-23 11:07:10 +01009430/* MPSC - Monitoring Packet Sampling Configuration Register
9431 * --------------------------------------------------------
9432 * MPSC Register is used to configure the Packet Sampling mechanism.
9433 */
9434#define MLXSW_REG_MPSC_ID 0x9080
9435#define MLXSW_REG_MPSC_LEN 0x1C
9436
9437MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
9438
9439/* reg_mpsc_local_port
9440 * Local port number
9441 * Not supported for CPU port
9442 * Access: Index
9443 */
9444MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
9445
9446/* reg_mpsc_e
9447 * Enable sampling on port local_port
9448 * Access: RW
9449 */
9450MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
9451
9452#define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
9453
9454/* reg_mpsc_rate
9455 * Sampling rate = 1 out of rate packets (with randomization around
9456 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
9457 * Access: RW
9458 */
9459MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
9460
9461static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
9462 u32 rate)
9463{
9464 MLXSW_REG_ZERO(mpsc, payload);
9465 mlxsw_reg_mpsc_local_port_set(payload, local_port);
9466 mlxsw_reg_mpsc_e_set(payload, e);
9467 mlxsw_reg_mpsc_rate_set(payload, rate);
9468}
9469
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01009470/* MGPC - Monitoring General Purpose Counter Set Register
9471 * The MGPC register retrieves and sets the General Purpose Counter Set.
9472 */
9473#define MLXSW_REG_MGPC_ID 0x9081
9474#define MLXSW_REG_MGPC_LEN 0x18
9475
9476MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
9477
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01009478/* reg_mgpc_counter_set_type
9479 * Counter set type.
9480 * Access: OP
9481 */
9482MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
9483
9484/* reg_mgpc_counter_index
9485 * Counter index.
9486 * Access: Index
9487 */
9488MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
9489
9490enum mlxsw_reg_mgpc_opcode {
9491 /* Nop */
9492 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
9493 /* Clear counters */
9494 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
9495};
9496
9497/* reg_mgpc_opcode
9498 * Opcode.
9499 * Access: OP
9500 */
9501MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
9502
9503/* reg_mgpc_byte_counter
9504 * Byte counter value.
9505 * Access: RW
9506 */
9507MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
9508
9509/* reg_mgpc_packet_counter
9510 * Packet counter value.
9511 * Access: RW
9512 */
9513MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
9514
9515static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
9516 enum mlxsw_reg_mgpc_opcode opcode,
Arkadi Sharshevsky6bba7e22017-08-24 08:40:07 +02009517 enum mlxsw_reg_flow_counter_set_type set_type)
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01009518{
9519 MLXSW_REG_ZERO(mgpc, payload);
9520 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
9521 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
9522 mlxsw_reg_mgpc_opcode_set(payload, opcode);
9523}
9524
Ido Schimmel27f68c02018-10-11 07:48:08 +00009525/* MPRS - Monitoring Parsing State Register
9526 * ----------------------------------------
9527 * The MPRS register is used for setting up the parsing for hash,
9528 * policy-engine and routing.
9529 */
9530#define MLXSW_REG_MPRS_ID 0x9083
9531#define MLXSW_REG_MPRS_LEN 0x14
9532
9533MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
9534
9535/* reg_mprs_parsing_depth
9536 * Minimum parsing depth.
9537 * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL
9538 * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2.
9539 * Access: RW
9540 */
9541MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
9542
9543/* reg_mprs_parsing_en
9544 * Parsing enable.
9545 * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and
9546 * NVGRE. Default is enabled. Reserved when SwitchX-2.
9547 * Access: RW
9548 */
9549MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
9550
9551/* reg_mprs_vxlan_udp_dport
9552 * VxLAN UDP destination port.
9553 * Used for identifying VxLAN packets and for dport field in
9554 * encapsulation. Default is 4789.
9555 * Access: RW
9556 */
9557MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
9558
9559static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
9560 u16 vxlan_udp_dport)
9561{
9562 MLXSW_REG_ZERO(mprs, payload);
9563 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
9564 mlxsw_reg_mprs_parsing_en_set(payload, true);
9565 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
9566}
9567
Petr Machata41ce78b2019-06-30 09:04:48 +03009568/* MOGCR - Monitoring Global Configuration Register
9569 * ------------------------------------------------
9570 */
9571#define MLXSW_REG_MOGCR_ID 0x9086
9572#define MLXSW_REG_MOGCR_LEN 0x20
9573
9574MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
9575
9576/* reg_mogcr_ptp_iftc
9577 * PTP Ingress FIFO Trap Clear
9578 * The PTP_ING_FIFO trap provides MTPPTR with clr according
9579 * to this value. Default 0.
9580 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
9581 * Access: RW
9582 */
9583MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
9584
9585/* reg_mogcr_ptp_eftc
9586 * PTP Egress FIFO Trap Clear
9587 * The PTP_EGR_FIFO trap provides MTPPTR with clr according
9588 * to this value. Default 0.
9589 * Reserved when IB switches and when SwitchX/-2, Spectrum-2
9590 * Access: RW
9591 */
9592MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
9593
Amit Cohen95c68832020-07-14 17:20:55 +03009594/* reg_mogcr_mirroring_pid_base
9595 * Base policer id for mirroring policers.
9596 * Must have an even value (e.g. 1000, not 1001).
9597 * Reserved when SwitchX/-2, Switch-IB/2, Spectrum-1 and Quantum.
9598 * Access: RW
9599 */
9600MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14);
9601
Amit Cohenc0e39692020-07-11 00:55:05 +03009602/* MPAGR - Monitoring Port Analyzer Global Register
9603 * ------------------------------------------------
9604 * This register is used for global port analyzer configurations.
9605 * Note: This register is not supported by current FW versions for Spectrum-1.
9606 */
9607#define MLXSW_REG_MPAGR_ID 0x9089
9608#define MLXSW_REG_MPAGR_LEN 0x0C
9609
9610MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN);
9611
9612enum mlxsw_reg_mpagr_trigger {
9613 MLXSW_REG_MPAGR_TRIGGER_EGRESS,
9614 MLXSW_REG_MPAGR_TRIGGER_INGRESS,
9615 MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED,
9616 MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER,
9617 MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG,
9618 MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG,
9619 MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN,
9620 MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY,
9621};
9622
9623/* reg_mpagr_trigger
9624 * Mirror trigger.
9625 * Access: Index
9626 */
9627MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4);
9628
9629/* reg_mpagr_pa_id
9630 * Port analyzer ID.
9631 * Access: RW
9632 */
9633MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4);
9634
9635/* reg_mpagr_probability_rate
9636 * Sampling rate.
9637 * Valid values are: 1 to 3.5*10^9
9638 * Value of 1 means "sample all". Default is 1.
9639 * Access: RW
9640 */
9641MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32);
9642
9643static inline void mlxsw_reg_mpagr_pack(char *payload,
9644 enum mlxsw_reg_mpagr_trigger trigger,
9645 u8 pa_id, u32 probability_rate)
9646{
9647 MLXSW_REG_ZERO(mpagr, payload);
9648 mlxsw_reg_mpagr_trigger_set(payload, trigger);
9649 mlxsw_reg_mpagr_pa_id_set(payload, pa_id);
9650 mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate);
9651}
9652
Amit Cohen951b84d2020-07-11 00:55:04 +03009653/* MOMTE - Monitoring Mirror Trigger Enable Register
9654 * -------------------------------------------------
9655 * This register is used to configure the mirror enable for different mirror
9656 * reasons.
9657 */
9658#define MLXSW_REG_MOMTE_ID 0x908D
9659#define MLXSW_REG_MOMTE_LEN 0x10
9660
9661MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN);
9662
9663/* reg_momte_local_port
9664 * Local port number.
9665 * Access: Index
9666 */
9667MLXSW_ITEM32(reg, momte, local_port, 0x00, 16, 8);
9668
9669enum mlxsw_reg_momte_type {
9670 MLXSW_REG_MOMTE_TYPE_WRED = 0x20,
9671 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31,
9672 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32,
9673 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33,
9674 MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40,
9675 MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50,
9676 MLXSW_REG_MOMTE_TYPE_ECN = 0x60,
9677 MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70,
9678};
9679
9680/* reg_momte_type
9681 * Type of mirroring.
9682 * Access: Index
9683 */
9684MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
9685
9686/* reg_momte_tclass_en
9687 * TClass/PG mirror enable. Each bit represents corresponding tclass.
9688 * 0: disable (default)
9689 * 1: enable
9690 * Access: RW
9691 */
9692MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
9693
9694static inline void mlxsw_reg_momte_pack(char *payload, u8 local_port,
9695 enum mlxsw_reg_momte_type type)
9696{
9697 MLXSW_REG_ZERO(momte, payload);
9698 mlxsw_reg_momte_local_port_set(payload, local_port);
9699 mlxsw_reg_momte_type_set(payload, type);
9700}
9701
Petr Machatada28e872019-06-30 09:04:45 +03009702/* MTPPPC - Time Precision Packet Port Configuration
9703 * -------------------------------------------------
9704 * This register serves for configuration of which PTP messages should be
9705 * timestamped. This is a global configuration, despite the register name.
9706 *
9707 * Reserved when Spectrum-2.
9708 */
9709#define MLXSW_REG_MTPPPC_ID 0x9090
9710#define MLXSW_REG_MTPPPC_LEN 0x28
9711
9712MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
9713
9714/* reg_mtpppc_ing_timestamp_message_type
9715 * Bitwise vector of PTP message types to timestamp at ingress.
9716 * MessageType field as defined by IEEE 1588
9717 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
9718 * Default all 0
9719 * Access: RW
9720 */
9721MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
9722
9723/* reg_mtpppc_egr_timestamp_message_type
9724 * Bitwise vector of PTP message types to timestamp at egress.
9725 * MessageType field as defined by IEEE 1588
9726 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
9727 * Default all 0
9728 * Access: RW
9729 */
9730MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
9731
9732static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
9733{
9734 MLXSW_REG_ZERO(mtpppc, payload);
9735 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
9736 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
9737}
9738
Petr Machata98b90282019-06-30 09:04:47 +03009739/* MTPPTR - Time Precision Packet Timestamping Reading
9740 * ---------------------------------------------------
9741 * The MTPPTR is used for reading the per port PTP timestamp FIFO.
9742 * There is a trap for packets which are latched to the timestamp FIFO, thus the
9743 * SW knows which FIFO to read. Note that packets enter the FIFO before been
9744 * trapped. The sequence number is used to synchronize the timestamp FIFO
9745 * entries and the trapped packets.
9746 * Reserved when Spectrum-2.
9747 */
9748
9749#define MLXSW_REG_MTPPTR_ID 0x9091
9750#define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */
9751#define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */
9752#define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
9753#define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
9754 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
9755
9756MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
9757
9758/* reg_mtpptr_local_port
9759 * Not supported for CPU port.
9760 * Access: Index
9761 */
9762MLXSW_ITEM32(reg, mtpptr, local_port, 0x00, 16, 8);
9763
9764enum mlxsw_reg_mtpptr_dir {
9765 MLXSW_REG_MTPPTR_DIR_INGRESS,
9766 MLXSW_REG_MTPPTR_DIR_EGRESS,
9767};
9768
9769/* reg_mtpptr_dir
9770 * Direction.
9771 * Access: Index
9772 */
9773MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
9774
9775/* reg_mtpptr_clr
9776 * Clear the records.
9777 * Access: OP
9778 */
9779MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
9780
9781/* reg_mtpptr_num_rec
9782 * Number of valid records in the response
9783 * Range 0.. cap_ptp_timestamp_fifo
9784 * Access: RO
9785 */
9786MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
9787
9788/* reg_mtpptr_rec_message_type
9789 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
9790 * (e.g. Bit0: Sync, Bit1: Delay_Req)
9791 * Access: RO
9792 */
9793MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
9794 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
9795 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
9796
9797/* reg_mtpptr_rec_domain_number
9798 * DomainNumber field as defined by IEEE 1588
9799 * Access: RO
9800 */
9801MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
9802 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
9803 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
9804
9805/* reg_mtpptr_rec_sequence_id
9806 * SequenceId field as defined by IEEE 1588
9807 * Access: RO
9808 */
9809MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
9810 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
9811 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
9812
9813/* reg_mtpptr_rec_timestamp_high
9814 * Timestamp of when the PTP packet has passed through the port Units of PLL
9815 * clock time.
9816 * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec.
9817 * Access: RO
9818 */
9819MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
9820 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
9821 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
9822
9823/* reg_mtpptr_rec_timestamp_low
9824 * See rec_timestamp_high.
9825 * Access: RO
9826 */
9827MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
9828 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
9829 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
9830
9831static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
9832 unsigned int rec,
9833 u8 *p_message_type,
9834 u8 *p_domain_number,
9835 u16 *p_sequence_id,
9836 u64 *p_timestamp)
9837{
9838 u32 timestamp_high, timestamp_low;
9839
9840 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
9841 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
9842 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
9843 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
9844 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
9845 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
9846}
9847
Petr Machata4dfecb62019-06-30 09:04:46 +03009848/* MTPTPT - Monitoring Precision Time Protocol Trap Register
9849 * ---------------------------------------------------------
9850 * This register is used for configuring under which trap to deliver PTP
9851 * packets depending on type of the packet.
9852 */
9853#define MLXSW_REG_MTPTPT_ID 0x9092
9854#define MLXSW_REG_MTPTPT_LEN 0x08
9855
9856MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
9857
9858enum mlxsw_reg_mtptpt_trap_id {
9859 MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
9860 MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
9861};
9862
9863/* reg_mtptpt_trap_id
9864 * Trap id.
9865 * Access: Index
9866 */
9867MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
9868
9869/* reg_mtptpt_message_type
9870 * Bitwise vector of PTP message types to trap. This is a necessary but
9871 * non-sufficient condition since need to enable also per port. See MTPPPC.
9872 * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g.
9873 * Bit0: Sync, Bit1: Delay_Req)
9874 */
9875MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
9876
9877static inline void mlxsw_reg_mtptptp_pack(char *payload,
9878 enum mlxsw_reg_mtptpt_trap_id trap_id,
9879 u16 message_type)
9880{
9881 MLXSW_REG_ZERO(mtptpt, payload);
9882 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
9883 mlxsw_reg_mtptpt_message_type_set(payload, message_type);
9884}
9885
Jiri Pirko191c0c22020-09-15 11:40:56 +03009886/* MFGD - Monitoring FW General Debug Register
9887 * -------------------------------------------
9888 */
9889#define MLXSW_REG_MFGD_ID 0x90F0
9890#define MLXSW_REG_MFGD_LEN 0x0C
9891
9892MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN);
9893
9894/* reg_mfgd_fw_fatal_event_mode
9895 * 0 - don't check FW fatal (default)
9896 * 1 - check FW fatal - enable MFDE trap
9897 * Access: RW
9898 */
9899MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2);
9900
9901/* reg_mfgd_trigger_test
9902 * Access: WO
9903 */
9904MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1);
9905
Vadim Pasternak7e9561e2019-05-29 11:47:19 +03009906/* MGPIR - Management General Peripheral Information Register
9907 * ----------------------------------------------------------
9908 * MGPIR register allows software to query the hardware and
9909 * firmware general information of peripheral entities.
9910 */
9911#define MLXSW_REG_MGPIR_ID 0x9100
9912#define MLXSW_REG_MGPIR_LEN 0xA0
9913
9914MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
9915
9916enum mlxsw_reg_mgpir_device_type {
9917 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
9918 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
9919};
9920
9921/* device_type
9922 * Access: RO
9923 */
9924MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
9925
9926/* devices_per_flash
9927 * Number of devices of device_type per flash (can be shared by few devices).
9928 * Access: RO
9929 */
9930MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
9931
9932/* num_of_devices
9933 * Number of devices of device_type.
9934 * Access: RO
9935 */
9936MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
9937
Vadim Pasternak5cfa0302019-10-06 09:34:48 +03009938/* num_of_modules
9939 * Number of modules.
9940 * Access: RO
9941 */
9942MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
9943
Vadim Pasternak7e9561e2019-05-29 11:47:19 +03009944static inline void mlxsw_reg_mgpir_pack(char *payload)
9945{
9946 MLXSW_REG_ZERO(mgpir, payload);
9947}
9948
9949static inline void
9950mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
9951 enum mlxsw_reg_mgpir_device_type *device_type,
Vadim Pasternak5cfa0302019-10-06 09:34:48 +03009952 u8 *devices_per_flash, u8 *num_of_modules)
Vadim Pasternak7e9561e2019-05-29 11:47:19 +03009953{
9954 if (num_of_devices)
9955 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
9956 if (device_type)
9957 *device_type = mlxsw_reg_mgpir_device_type_get(payload);
9958 if (devices_per_flash)
9959 *devices_per_flash =
9960 mlxsw_reg_mgpir_devices_per_flash_get(payload);
Vadim Pasternak5cfa0302019-10-06 09:34:48 +03009961 if (num_of_modules)
9962 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
Vadim Pasternak7e9561e2019-05-29 11:47:19 +03009963}
9964
Jiri Pirko6ddac9d2020-09-15 11:40:55 +03009965/* MFDE - Monitoring FW Debug Register
9966 * -----------------------------------
9967 */
9968#define MLXSW_REG_MFDE_ID 0x9200
9969#define MLXSW_REG_MFDE_LEN 0x18
9970
9971MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN);
9972
9973/* reg_mfde_irisc_id
9974 * Which irisc triggered the event
9975 * Access: RO
9976 */
9977MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 8, 4);
9978
9979enum mlxsw_reg_mfde_event_id {
9980 MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1,
9981 /* KVD insertion machine stopped */
9982 MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP,
9983};
9984
9985/* reg_mfde_event_id
9986 * Access: RO
9987 */
9988MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 8);
9989
9990enum mlxsw_reg_mfde_method {
9991 MLXSW_REG_MFDE_METHOD_QUERY,
9992 MLXSW_REG_MFDE_METHOD_WRITE,
9993};
9994
9995/* reg_mfde_method
9996 * Access: RO
9997 */
9998MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1);
9999
10000/* reg_mfde_long_process
10001 * Indicates if the command is in long_process mode.
10002 * Access: RO
10003 */
10004MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1);
10005
10006enum mlxsw_reg_mfde_command_type {
10007 MLXSW_REG_MFDE_COMMAND_TYPE_MAD,
10008 MLXSW_REG_MFDE_COMMAND_TYPE_EMAD,
10009 MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF,
10010};
10011
10012/* reg_mfde_command_type
10013 * Access: RO
10014 */
10015MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2);
10016
10017/* reg_mfde_reg_attr_id
10018 * EMAD - register id, MAD - attibute id
10019 * Access: RO
10020 */
10021MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16);
10022
10023/* reg_mfde_log_address
10024 * crspace address accessed, which resulted in timeout.
10025 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO
10026 * Access: RO
10027 */
10028MLXSW_ITEM32(reg, mfde, log_address, 0x10, 0, 32);
10029
10030/* reg_mfde_log_id
10031 * Which irisc triggered the timeout.
10032 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO
10033 * Access: RO
10034 */
10035MLXSW_ITEM32(reg, mfde, log_id, 0x14, 0, 4);
10036
10037/* reg_mfde_pipes_mask
10038 * Bit per kvh pipe.
10039 * Access: RO
10040 */
10041MLXSW_ITEM32(reg, mfde, pipes_mask, 0x10, 0, 16);
10042
Ido Schimmel710dd1a2018-10-11 07:47:59 +000010043/* TNGCR - Tunneling NVE General Configuration Register
10044 * ----------------------------------------------------
10045 * The TNGCR register is used for setting up the NVE Tunneling configuration.
10046 */
10047#define MLXSW_REG_TNGCR_ID 0xA001
10048#define MLXSW_REG_TNGCR_LEN 0x44
10049
10050MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
10051
10052enum mlxsw_reg_tngcr_type {
10053 MLXSW_REG_TNGCR_TYPE_VXLAN,
10054 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
10055 MLXSW_REG_TNGCR_TYPE_GENEVE,
10056 MLXSW_REG_TNGCR_TYPE_NVGRE,
10057};
10058
10059/* reg_tngcr_type
10060 * Tunnel type for encapsulation and decapsulation. The types are mutually
10061 * exclusive.
10062 * Note: For Spectrum the NVE parsing must be enabled in MPRS.
10063 * Access: RW
10064 */
10065MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
10066
10067/* reg_tngcr_nve_valid
10068 * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation.
10069 * Access: RW
10070 */
10071MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
10072
10073/* reg_tngcr_nve_ttl_uc
10074 * The TTL for NVE tunnel encapsulation underlay unicast packets.
10075 * Access: RW
10076 */
10077MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
10078
10079/* reg_tngcr_nve_ttl_mc
10080 * The TTL for NVE tunnel encapsulation underlay multicast packets.
10081 * Access: RW
10082 */
10083MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
10084
10085enum {
10086 /* Do not copy flow label. Calculate flow label using nve_flh. */
10087 MLXSW_REG_TNGCR_FL_NO_COPY,
10088 /* Copy flow label from inner packet if packet is IPv6 and
10089 * encapsulation is by IPv6. Otherwise, calculate flow label using
10090 * nve_flh.
10091 */
10092 MLXSW_REG_TNGCR_FL_COPY,
10093};
10094
10095/* reg_tngcr_nve_flc
10096 * For NVE tunnel encapsulation: Flow label copy from inner packet.
10097 * Access: RW
10098 */
10099MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
10100
10101enum {
10102 /* Flow label is static. In Spectrum this means '0'. Spectrum-2
10103 * uses {nve_fl_prefix, nve_fl_suffix}.
10104 */
10105 MLXSW_REG_TNGCR_FL_NO_HASH,
10106 /* 8 LSBs of the flow label are calculated from ECMP hash of the
10107 * inner packet. 12 MSBs are configured by nve_fl_prefix.
10108 */
10109 MLXSW_REG_TNGCR_FL_HASH,
10110};
10111
10112/* reg_tngcr_nve_flh
10113 * NVE flow label hash.
10114 * Access: RW
10115 */
10116MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
10117
10118/* reg_tngcr_nve_fl_prefix
10119 * NVE flow label prefix. Constant 12 MSBs of the flow label.
10120 * Access: RW
10121 */
10122MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
10123
10124/* reg_tngcr_nve_fl_suffix
10125 * NVE flow label suffix. Constant 8 LSBs of the flow label.
10126 * Reserved when nve_flh=1 and for Spectrum.
10127 * Access: RW
10128 */
10129MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
10130
10131enum {
10132 /* Source UDP port is fixed (default '0') */
10133 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
10134 /* Source UDP port is calculated based on hash */
10135 MLXSW_REG_TNGCR_UDP_SPORT_HASH,
10136};
10137
10138/* reg_tngcr_nve_udp_sport_type
10139 * NVE UDP source port type.
10140 * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2).
10141 * When the source UDP port is calculated based on hash, then the 8 LSBs
10142 * are calculated from hash the 8 MSBs are configured by
10143 * nve_udp_sport_prefix.
10144 * Access: RW
10145 */
10146MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
10147
10148/* reg_tngcr_nve_udp_sport_prefix
10149 * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port.
10150 * Reserved when NVE type is NVGRE.
10151 * Access: RW
10152 */
10153MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
10154
10155/* reg_tngcr_nve_group_size_mc
10156 * The amount of sequential linked lists of MC entries. The first linked
10157 * list is configured by SFD.underlay_mc_ptr.
10158 * Valid values: 1, 2, 4, 8, 16, 32, 64
10159 * The linked list are configured by TNUMT.
10160 * The hash is set by LAG hash.
10161 * Access: RW
10162 */
10163MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
10164
10165/* reg_tngcr_nve_group_size_flood
10166 * The amount of sequential linked lists of flooding entries. The first
10167 * linked list is configured by SFMR.nve_tunnel_flood_ptr
10168 * Valid values: 1, 2, 4, 8, 16, 32, 64
10169 * The linked list are configured by TNUMT.
10170 * The hash is set by LAG hash.
10171 * Access: RW
10172 */
10173MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
10174
10175/* reg_tngcr_learn_enable
10176 * During decapsulation, whether to learn from NVE port.
10177 * Reserved when Spectrum-2. See TNPC.
10178 * Access: RW
10179 */
10180MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
10181
10182/* reg_tngcr_underlay_virtual_router
10183 * Underlay virtual router.
10184 * Reserved when Spectrum-2.
10185 * Access: RW
10186 */
10187MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
10188
10189/* reg_tngcr_underlay_rif
10190 * Underlay ingress router interface. RIF type should be loopback generic.
10191 * Reserved when Spectrum.
10192 * Access: RW
10193 */
10194MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
10195
10196/* reg_tngcr_usipv4
10197 * Underlay source IPv4 address of the NVE.
10198 * Access: RW
10199 */
10200MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
10201
10202/* reg_tngcr_usipv6
10203 * Underlay source IPv6 address of the NVE. For Spectrum, must not be
10204 * modified under traffic of NVE tunneling encapsulation.
10205 * Access: RW
10206 */
10207MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
10208
10209static inline void mlxsw_reg_tngcr_pack(char *payload,
10210 enum mlxsw_reg_tngcr_type type,
10211 bool valid, u8 ttl)
10212{
10213 MLXSW_REG_ZERO(tngcr, payload);
10214 mlxsw_reg_tngcr_type_set(payload, type);
10215 mlxsw_reg_tngcr_nve_valid_set(payload, valid);
10216 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
10217 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
10218 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
10219 mlxsw_reg_tngcr_nve_flh_set(payload, 0);
10220 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
10221 MLXSW_REG_TNGCR_UDP_SPORT_HASH);
10222 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
10223 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
10224 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
10225}
10226
Ido Schimmelc723d192018-10-11 07:48:01 +000010227/* TNUMT - Tunneling NVE Underlay Multicast Table Register
10228 * -------------------------------------------------------
10229 * The TNUMT register is for building the underlay MC table. It is used
10230 * for MC, flooding and BC traffic into the NVE tunnel.
10231 */
10232#define MLXSW_REG_TNUMT_ID 0xA003
10233#define MLXSW_REG_TNUMT_LEN 0x20
10234
10235MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
10236
10237enum mlxsw_reg_tnumt_record_type {
10238 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
10239 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
10240 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
10241};
10242
10243/* reg_tnumt_record_type
10244 * Record type.
10245 * Access: RW
10246 */
10247MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
10248
10249enum mlxsw_reg_tnumt_tunnel_port {
10250 MLXSW_REG_TNUMT_TUNNEL_PORT_NVE,
10251 MLXSW_REG_TNUMT_TUNNEL_PORT_VPLS,
10252 MLXSW_REG_TNUMT_TUNNEL_FLEX_TUNNEL0,
10253 MLXSW_REG_TNUMT_TUNNEL_FLEX_TUNNEL1,
10254};
10255
10256/* reg_tnumt_tunnel_port
10257 * Tunnel port.
10258 * Access: RW
10259 */
10260MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
10261
10262/* reg_tnumt_underlay_mc_ptr
10263 * Index to the underlay multicast table.
10264 * For Spectrum the index is to the KVD linear.
10265 * Access: Index
10266 */
10267MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
10268
10269/* reg_tnumt_vnext
10270 * The next_underlay_mc_ptr is valid.
10271 * Access: RW
10272 */
10273MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
10274
10275/* reg_tnumt_next_underlay_mc_ptr
10276 * The next index to the underlay multicast table.
10277 * Access: RW
10278 */
10279MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
10280
10281/* reg_tnumt_record_size
10282 * Number of IP addresses in the record.
10283 * Range is 1..cap_max_nve_mc_entries_ipv{4,6}
10284 * Access: RW
10285 */
10286MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
10287
10288/* reg_tnumt_udip
10289 * The underlay IPv4 addresses. udip[i] is reserved if i >= size
10290 * Access: RW
10291 */
10292MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
10293
10294/* reg_tnumt_udip_ptr
10295 * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if
10296 * i >= size. The IPv6 addresses are configured by RIPS.
10297 * Access: RW
10298 */
10299MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
10300
10301static inline void mlxsw_reg_tnumt_pack(char *payload,
10302 enum mlxsw_reg_tnumt_record_type type,
10303 enum mlxsw_reg_tnumt_tunnel_port tport,
10304 u32 underlay_mc_ptr, bool vnext,
10305 u32 next_underlay_mc_ptr,
10306 u8 record_size)
10307{
10308 MLXSW_REG_ZERO(tnumt, payload);
10309 mlxsw_reg_tnumt_record_type_set(payload, type);
10310 mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
10311 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
10312 mlxsw_reg_tnumt_vnext_set(payload, vnext);
10313 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
10314 mlxsw_reg_tnumt_record_size_set(payload, record_size);
10315}
10316
Ido Schimmelfd6db272018-10-11 07:48:04 +000010317/* TNQCR - Tunneling NVE QoS Configuration Register
10318 * ------------------------------------------------
10319 * The TNQCR register configures how QoS is set in encapsulation into the
10320 * underlay network.
10321 */
10322#define MLXSW_REG_TNQCR_ID 0xA010
10323#define MLXSW_REG_TNQCR_LEN 0x0C
10324
10325MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
10326
10327/* reg_tnqcr_enc_set_dscp
10328 * For encapsulation: How to set DSCP field:
10329 * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay
10330 * (outer) IP header. If there is no IP header, use TNQDR.dscp
10331 * 1 - Set the DSCP field as TNQDR.dscp
10332 * Access: RW
10333 */
10334MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
10335
10336static inline void mlxsw_reg_tnqcr_pack(char *payload)
10337{
10338 MLXSW_REG_ZERO(tnqcr, payload);
10339 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
10340}
10341
Ido Schimmel8efcf6b2018-10-11 07:48:06 +000010342/* TNQDR - Tunneling NVE QoS Default Register
10343 * ------------------------------------------
10344 * The TNQDR register configures the default QoS settings for NVE
10345 * encapsulation.
10346 */
10347#define MLXSW_REG_TNQDR_ID 0xA011
10348#define MLXSW_REG_TNQDR_LEN 0x08
10349
10350MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
10351
10352/* reg_tnqdr_local_port
10353 * Local port number (receive port). CPU port is supported.
10354 * Access: Index
10355 */
10356MLXSW_ITEM32(reg, tnqdr, local_port, 0x00, 16, 8);
10357
10358/* reg_tnqdr_dscp
10359 * For encapsulation, the default DSCP.
10360 * Access: RW
10361 */
10362MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
10363
10364static inline void mlxsw_reg_tnqdr_pack(char *payload, u8 local_port)
10365{
10366 MLXSW_REG_ZERO(tnqdr, payload);
10367 mlxsw_reg_tnqdr_local_port_set(payload, local_port);
10368 mlxsw_reg_tnqdr_dscp_set(payload, 0);
10369}
10370
Ido Schimmel4a8d1862018-10-11 07:48:02 +000010371/* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register
10372 * --------------------------------------------------------
10373 * The TNEEM register maps ECN of the IP header at the ingress to the
10374 * encapsulation to the ECN of the underlay network.
10375 */
10376#define MLXSW_REG_TNEEM_ID 0xA012
10377#define MLXSW_REG_TNEEM_LEN 0x0C
10378
10379MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
10380
10381/* reg_tneem_overlay_ecn
10382 * ECN of the IP header in the overlay network.
10383 * Access: Index
10384 */
10385MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
10386
10387/* reg_tneem_underlay_ecn
10388 * ECN of the IP header in the underlay network.
10389 * Access: RW
10390 */
10391MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
10392
10393static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
10394 u8 underlay_ecn)
10395{
10396 MLXSW_REG_ZERO(tneem, payload);
10397 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
10398 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
10399}
10400
Ido Schimmela77d5f02018-10-11 07:48:03 +000010401/* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register
10402 * --------------------------------------------------------
10403 * The TNDEM register configures the actions that are done in the
10404 * decapsulation.
10405 */
10406#define MLXSW_REG_TNDEM_ID 0xA013
10407#define MLXSW_REG_TNDEM_LEN 0x0C
10408
10409MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
10410
10411/* reg_tndem_underlay_ecn
10412 * ECN field of the IP header in the underlay network.
10413 * Access: Index
10414 */
10415MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
10416
10417/* reg_tndem_overlay_ecn
10418 * ECN field of the IP header in the overlay network.
10419 * Access: Index
10420 */
10421MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
10422
10423/* reg_tndem_eip_ecn
10424 * Egress IP ECN. ECN field of the IP header of the packet which goes out
10425 * from the decapsulation.
10426 * Access: RW
10427 */
10428MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
10429
10430/* reg_tndem_trap_en
10431 * Trap enable:
10432 * 0 - No trap due to decap ECN
10433 * 1 - Trap enable with trap_id
10434 * Access: RW
10435 */
10436MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
10437
10438/* reg_tndem_trap_id
10439 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
10440 * Reserved when trap_en is '0'.
10441 * Access: RW
10442 */
10443MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
10444
10445static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
10446 u8 overlay_ecn, u8 ecn, bool trap_en,
10447 u16 trap_id)
10448{
10449 MLXSW_REG_ZERO(tndem, payload);
10450 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
10451 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
10452 mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
10453 mlxsw_reg_tndem_trap_en_set(payload, trap_en);
10454 mlxsw_reg_tndem_trap_id_set(payload, trap_id);
10455}
10456
Ido Schimmel50e6eb22018-10-11 07:48:00 +000010457/* TNPC - Tunnel Port Configuration Register
10458 * -----------------------------------------
10459 * The TNPC register is used for tunnel port configuration.
10460 * Reserved when Spectrum.
10461 */
10462#define MLXSW_REG_TNPC_ID 0xA020
10463#define MLXSW_REG_TNPC_LEN 0x18
10464
10465MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
10466
10467enum mlxsw_reg_tnpc_tunnel_port {
10468 MLXSW_REG_TNPC_TUNNEL_PORT_NVE,
10469 MLXSW_REG_TNPC_TUNNEL_PORT_VPLS,
10470 MLXSW_REG_TNPC_TUNNEL_FLEX_TUNNEL0,
10471 MLXSW_REG_TNPC_TUNNEL_FLEX_TUNNEL1,
10472};
10473
10474/* reg_tnpc_tunnel_port
10475 * Tunnel port.
10476 * Access: Index
10477 */
10478MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
10479
10480/* reg_tnpc_learn_enable_v6
10481 * During IPv6 underlay decapsulation, whether to learn from tunnel port.
10482 * Access: RW
10483 */
10484MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
10485
10486/* reg_tnpc_learn_enable_v4
10487 * During IPv4 underlay decapsulation, whether to learn from tunnel port.
10488 * Access: RW
10489 */
10490MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
10491
10492static inline void mlxsw_reg_tnpc_pack(char *payload,
10493 enum mlxsw_reg_tnpc_tunnel_port tport,
10494 bool learn_enable)
10495{
10496 MLXSW_REG_ZERO(tnpc, payload);
10497 mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
10498 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
10499 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
10500}
10501
Petr Machata14aefd92017-10-20 09:16:15 +020010502/* TIGCR - Tunneling IPinIP General Configuration Register
10503 * -------------------------------------------------------
10504 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
10505 */
10506#define MLXSW_REG_TIGCR_ID 0xA801
10507#define MLXSW_REG_TIGCR_LEN 0x10
10508
10509MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
10510
10511/* reg_tigcr_ipip_ttlc
10512 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
10513 * header.
10514 * Access: RW
10515 */
10516MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
10517
10518/* reg_tigcr_ipip_ttl_uc
10519 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
10520 * reg_tigcr_ipip_ttlc is unset.
10521 * Access: RW
10522 */
10523MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
10524
10525static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
10526{
10527 MLXSW_REG_ZERO(tigcr, payload);
10528 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
10529 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
10530}
10531
Amit Cohen20174902020-01-19 15:00:50 +020010532/* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register
10533 * -----------------------------------------------------------
10534 * The TIEEM register maps ECN of the IP header at the ingress to the
10535 * encapsulation to the ECN of the underlay network.
10536 */
10537#define MLXSW_REG_TIEEM_ID 0xA812
10538#define MLXSW_REG_TIEEM_LEN 0x0C
10539
10540MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
10541
10542/* reg_tieem_overlay_ecn
10543 * ECN of the IP header in the overlay network.
10544 * Access: Index
10545 */
10546MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
10547
10548/* reg_tineem_underlay_ecn
10549 * ECN of the IP header in the underlay network.
10550 * Access: RW
10551 */
10552MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
10553
10554static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
10555 u8 underlay_ecn)
10556{
10557 MLXSW_REG_ZERO(tieem, payload);
10558 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
10559 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
10560}
10561
Amit Cohen839607e2020-01-19 15:00:51 +020010562/* TIDEM - Tunneling IPinIP Decapsulation ECN Mapping Register
10563 * -----------------------------------------------------------
10564 * The TIDEM register configures the actions that are done in the
10565 * decapsulation.
10566 */
10567#define MLXSW_REG_TIDEM_ID 0xA813
10568#define MLXSW_REG_TIDEM_LEN 0x0C
10569
10570MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN);
10571
10572/* reg_tidem_underlay_ecn
10573 * ECN field of the IP header in the underlay network.
10574 * Access: Index
10575 */
10576MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2);
10577
10578/* reg_tidem_overlay_ecn
10579 * ECN field of the IP header in the overlay network.
10580 * Access: Index
10581 */
10582MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2);
10583
10584/* reg_tidem_eip_ecn
10585 * Egress IP ECN. ECN field of the IP header of the packet which goes out
10586 * from the decapsulation.
10587 * Access: RW
10588 */
10589MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2);
10590
10591/* reg_tidem_trap_en
10592 * Trap enable:
10593 * 0 - No trap due to decap ECN
10594 * 1 - Trap enable with trap_id
10595 * Access: RW
10596 */
10597MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4);
10598
10599/* reg_tidem_trap_id
10600 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
10601 * Reserved when trap_en is '0'.
10602 * Access: RW
10603 */
10604MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9);
10605
10606static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn,
10607 u8 overlay_ecn, u8 eip_ecn,
10608 bool trap_en, u16 trap_id)
10609{
10610 MLXSW_REG_ZERO(tidem, payload);
10611 mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn);
10612 mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn);
10613 mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn);
10614 mlxsw_reg_tidem_trap_en_set(payload, trap_en);
10615 mlxsw_reg_tidem_trap_id_set(payload, trap_id);
10616}
10617
Jiri Pirkoe0594362015-10-16 14:01:31 +020010618/* SBPR - Shared Buffer Pools Register
10619 * -----------------------------------
10620 * The SBPR configures and retrieves the shared buffer pools and configuration.
10621 */
10622#define MLXSW_REG_SBPR_ID 0xB001
10623#define MLXSW_REG_SBPR_LEN 0x14
10624
Jiri Pirko21978dc2016-10-21 16:07:20 +020010625MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010626
Jiri Pirko497e8592016-04-08 19:11:24 +020010627/* shared direstion enum for SBPR, SBCM, SBPM */
10628enum mlxsw_reg_sbxx_dir {
10629 MLXSW_REG_SBXX_DIR_INGRESS,
10630 MLXSW_REG_SBXX_DIR_EGRESS,
Jiri Pirkoe0594362015-10-16 14:01:31 +020010631};
10632
10633/* reg_sbpr_dir
10634 * Direction.
10635 * Access: Index
10636 */
10637MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
10638
10639/* reg_sbpr_pool
10640 * Pool index.
10641 * Access: Index
10642 */
10643MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
10644
Petr Machataf0024f02018-09-20 09:21:28 +030010645/* reg_sbpr_infi_size
10646 * Size is infinite.
10647 * Access: RW
10648 */
10649MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
10650
Jiri Pirkoe0594362015-10-16 14:01:31 +020010651/* reg_sbpr_size
10652 * Pool size in buffer cells.
Petr Machataf0024f02018-09-20 09:21:28 +030010653 * Reserved when infi_size = 1.
Jiri Pirkoe0594362015-10-16 14:01:31 +020010654 * Access: RW
10655 */
10656MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
10657
10658enum mlxsw_reg_sbpr_mode {
10659 MLXSW_REG_SBPR_MODE_STATIC,
10660 MLXSW_REG_SBPR_MODE_DYNAMIC,
10661};
10662
10663/* reg_sbpr_mode
10664 * Pool quota calculation mode.
10665 * Access: RW
10666 */
10667MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
10668
10669static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
Jiri Pirko497e8592016-04-08 19:11:24 +020010670 enum mlxsw_reg_sbxx_dir dir,
Petr Machataf0024f02018-09-20 09:21:28 +030010671 enum mlxsw_reg_sbpr_mode mode, u32 size,
10672 bool infi_size)
Jiri Pirkoe0594362015-10-16 14:01:31 +020010673{
10674 MLXSW_REG_ZERO(sbpr, payload);
10675 mlxsw_reg_sbpr_pool_set(payload, pool);
10676 mlxsw_reg_sbpr_dir_set(payload, dir);
10677 mlxsw_reg_sbpr_mode_set(payload, mode);
10678 mlxsw_reg_sbpr_size_set(payload, size);
Petr Machataf0024f02018-09-20 09:21:28 +030010679 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010680}
10681
10682/* SBCM - Shared Buffer Class Management Register
10683 * ----------------------------------------------
10684 * The SBCM register configures and retrieves the shared buffer allocation
10685 * and configuration according to Port-PG, including the binding to pool
10686 * and definition of the associated quota.
10687 */
10688#define MLXSW_REG_SBCM_ID 0xB002
10689#define MLXSW_REG_SBCM_LEN 0x28
10690
Jiri Pirko21978dc2016-10-21 16:07:20 +020010691MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010692
10693/* reg_sbcm_local_port
10694 * Local port number.
10695 * For Ingress: excludes CPU port and Router port
10696 * For Egress: excludes IP Router
10697 * Access: Index
10698 */
10699MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
10700
10701/* reg_sbcm_pg_buff
10702 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
10703 * For PG buffer: range is 0..cap_max_pg_buffers - 1
10704 * For traffic class: range is 0..cap_max_tclass - 1
10705 * Note that when traffic class is in MC aware mode then the traffic
10706 * classes which are MC aware cannot be configured.
10707 * Access: Index
10708 */
10709MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
10710
Jiri Pirkoe0594362015-10-16 14:01:31 +020010711/* reg_sbcm_dir
10712 * Direction.
10713 * Access: Index
10714 */
10715MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
10716
10717/* reg_sbcm_min_buff
10718 * Minimum buffer size for the limiter, in cells.
10719 * Access: RW
10720 */
10721MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
10722
Jiri Pirkoc30a53c2016-04-14 18:19:22 +020010723/* shared max_buff limits for dynamic threshold for SBCM, SBPM */
10724#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
10725#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
10726
Petr Machatad144e3a2018-09-20 09:21:29 +030010727/* reg_sbcm_infi_max
10728 * Max buffer is infinite.
10729 * Access: RW
10730 */
10731MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
10732
Jiri Pirkoe0594362015-10-16 14:01:31 +020010733/* reg_sbcm_max_buff
10734 * When the pool associated to the port-pg/tclass is configured to
10735 * static, Maximum buffer size for the limiter configured in cells.
10736 * When the pool associated to the port-pg/tclass is configured to
10737 * dynamic, the max_buff holds the "alpha" parameter, supporting
10738 * the following values:
10739 * 0: 0
10740 * i: (1/128)*2^(i-1), for i=1..14
10741 * 0xFF: Infinity
Petr Machatad144e3a2018-09-20 09:21:29 +030010742 * Reserved when infi_max = 1.
Jiri Pirkoe0594362015-10-16 14:01:31 +020010743 * Access: RW
10744 */
10745MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
10746
10747/* reg_sbcm_pool
10748 * Association of the port-priority to a pool.
10749 * Access: RW
10750 */
10751MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
10752
10753static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
Jiri Pirko497e8592016-04-08 19:11:24 +020010754 enum mlxsw_reg_sbxx_dir dir,
Petr Machatad144e3a2018-09-20 09:21:29 +030010755 u32 min_buff, u32 max_buff,
10756 bool infi_max, u8 pool)
Jiri Pirkoe0594362015-10-16 14:01:31 +020010757{
10758 MLXSW_REG_ZERO(sbcm, payload);
10759 mlxsw_reg_sbcm_local_port_set(payload, local_port);
10760 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
10761 mlxsw_reg_sbcm_dir_set(payload, dir);
10762 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
10763 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
Petr Machatad144e3a2018-09-20 09:21:29 +030010764 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010765 mlxsw_reg_sbcm_pool_set(payload, pool);
10766}
10767
Jiri Pirko9efc8f62016-04-08 19:11:25 +020010768/* SBPM - Shared Buffer Port Management Register
10769 * ---------------------------------------------
Jiri Pirkoe0594362015-10-16 14:01:31 +020010770 * The SBPM register configures and retrieves the shared buffer allocation
10771 * and configuration according to Port-Pool, including the definition
10772 * of the associated quota.
10773 */
10774#define MLXSW_REG_SBPM_ID 0xB003
10775#define MLXSW_REG_SBPM_LEN 0x28
10776
Jiri Pirko21978dc2016-10-21 16:07:20 +020010777MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010778
10779/* reg_sbpm_local_port
10780 * Local port number.
10781 * For Ingress: excludes CPU port and Router port
10782 * For Egress: excludes IP Router
10783 * Access: Index
10784 */
10785MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
10786
10787/* reg_sbpm_pool
10788 * The pool associated to quota counting on the local_port.
10789 * Access: Index
10790 */
10791MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
10792
Jiri Pirkoe0594362015-10-16 14:01:31 +020010793/* reg_sbpm_dir
10794 * Direction.
10795 * Access: Index
10796 */
10797MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
10798
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020010799/* reg_sbpm_buff_occupancy
10800 * Current buffer occupancy in cells.
10801 * Access: RO
10802 */
10803MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
10804
10805/* reg_sbpm_clr
10806 * Clear Max Buffer Occupancy
10807 * When this bit is set, max_buff_occupancy field is cleared (and a
10808 * new max value is tracked from the time the clear was performed).
10809 * Access: OP
10810 */
10811MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
10812
10813/* reg_sbpm_max_buff_occupancy
10814 * Maximum value of buffer occupancy in cells monitored. Cleared by
10815 * writing to the clr field.
10816 * Access: RO
10817 */
10818MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
10819
Jiri Pirkoe0594362015-10-16 14:01:31 +020010820/* reg_sbpm_min_buff
10821 * Minimum buffer size for the limiter, in cells.
10822 * Access: RW
10823 */
10824MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
10825
10826/* reg_sbpm_max_buff
10827 * When the pool associated to the port-pg/tclass is configured to
10828 * static, Maximum buffer size for the limiter configured in cells.
10829 * When the pool associated to the port-pg/tclass is configured to
10830 * dynamic, the max_buff holds the "alpha" parameter, supporting
10831 * the following values:
10832 * 0: 0
10833 * i: (1/128)*2^(i-1), for i=1..14
10834 * 0xFF: Infinity
10835 * Access: RW
10836 */
10837MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
10838
10839static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020010840 enum mlxsw_reg_sbxx_dir dir, bool clr,
Jiri Pirkoe0594362015-10-16 14:01:31 +020010841 u32 min_buff, u32 max_buff)
10842{
10843 MLXSW_REG_ZERO(sbpm, payload);
10844 mlxsw_reg_sbpm_local_port_set(payload, local_port);
10845 mlxsw_reg_sbpm_pool_set(payload, pool);
10846 mlxsw_reg_sbpm_dir_set(payload, dir);
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020010847 mlxsw_reg_sbpm_clr_set(payload, clr);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010848 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
10849 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
10850}
10851
Jiri Pirko42a7f1d2016-04-14 18:19:27 +020010852static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
10853 u32 *p_max_buff_occupancy)
10854{
10855 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
10856 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
10857}
10858
Jiri Pirkoe0594362015-10-16 14:01:31 +020010859/* SBMM - Shared Buffer Multicast Management Register
10860 * --------------------------------------------------
10861 * The SBMM register configures and retrieves the shared buffer allocation
10862 * and configuration for MC packets according to Switch-Priority, including
10863 * the binding to pool and definition of the associated quota.
10864 */
10865#define MLXSW_REG_SBMM_ID 0xB004
10866#define MLXSW_REG_SBMM_LEN 0x28
10867
Jiri Pirko21978dc2016-10-21 16:07:20 +020010868MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +020010869
10870/* reg_sbmm_prio
10871 * Switch Priority.
10872 * Access: Index
10873 */
10874MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
10875
10876/* reg_sbmm_min_buff
10877 * Minimum buffer size for the limiter, in cells.
10878 * Access: RW
10879 */
10880MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
10881
10882/* reg_sbmm_max_buff
10883 * When the pool associated to the port-pg/tclass is configured to
10884 * static, Maximum buffer size for the limiter configured in cells.
10885 * When the pool associated to the port-pg/tclass is configured to
10886 * dynamic, the max_buff holds the "alpha" parameter, supporting
10887 * the following values:
10888 * 0: 0
10889 * i: (1/128)*2^(i-1), for i=1..14
10890 * 0xFF: Infinity
10891 * Access: RW
10892 */
10893MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
10894
10895/* reg_sbmm_pool
10896 * Association of the port-priority to a pool.
10897 * Access: RW
10898 */
10899MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
10900
10901static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
10902 u32 max_buff, u8 pool)
10903{
10904 MLXSW_REG_ZERO(sbmm, payload);
10905 mlxsw_reg_sbmm_prio_set(payload, prio);
10906 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
10907 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
10908 mlxsw_reg_sbmm_pool_set(payload, pool);
10909}
10910
Jiri Pirko26176de2016-04-14 18:19:26 +020010911/* SBSR - Shared Buffer Status Register
10912 * ------------------------------------
10913 * The SBSR register retrieves the shared buffer occupancy according to
10914 * Port-Pool. Note that this register enables reading a large amount of data.
10915 * It is the user's responsibility to limit the amount of data to ensure the
10916 * response can match the maximum transfer unit. In case the response exceeds
10917 * the maximum transport unit, it will be truncated with no special notice.
10918 */
10919#define MLXSW_REG_SBSR_ID 0xB005
10920#define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
10921#define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
10922#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
10923#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
10924 MLXSW_REG_SBSR_REC_LEN * \
10925 MLXSW_REG_SBSR_REC_MAX_COUNT)
10926
Jiri Pirko21978dc2016-10-21 16:07:20 +020010927MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
Jiri Pirko26176de2016-04-14 18:19:26 +020010928
10929/* reg_sbsr_clr
10930 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
10931 * field is cleared (and a new max value is tracked from the time the clear
10932 * was performed).
10933 * Access: OP
10934 */
10935MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
10936
10937/* reg_sbsr_ingress_port_mask
10938 * Bit vector for all ingress network ports.
10939 * Indicates which of the ports (for which the relevant bit is set)
10940 * are affected by the set operation. Configuration of any other port
10941 * does not change.
10942 * Access: Index
10943 */
10944MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
10945
10946/* reg_sbsr_pg_buff_mask
10947 * Bit vector for all switch priority groups.
10948 * Indicates which of the priorities (for which the relevant bit is set)
10949 * are affected by the set operation. Configuration of any other priority
10950 * does not change.
10951 * Range is 0..cap_max_pg_buffers - 1
10952 * Access: Index
10953 */
10954MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
10955
10956/* reg_sbsr_egress_port_mask
10957 * Bit vector for all egress network ports.
10958 * Indicates which of the ports (for which the relevant bit is set)
10959 * are affected by the set operation. Configuration of any other port
10960 * does not change.
10961 * Access: Index
10962 */
10963MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
10964
10965/* reg_sbsr_tclass_mask
10966 * Bit vector for all traffic classes.
10967 * Indicates which of the traffic classes (for which the relevant bit is
10968 * set) are affected by the set operation. Configuration of any other
10969 * traffic class does not change.
10970 * Range is 0..cap_max_tclass - 1
10971 * Access: Index
10972 */
10973MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
10974
10975static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
10976{
10977 MLXSW_REG_ZERO(sbsr, payload);
10978 mlxsw_reg_sbsr_clr_set(payload, clr);
10979}
10980
10981/* reg_sbsr_rec_buff_occupancy
10982 * Current buffer occupancy in cells.
10983 * Access: RO
10984 */
10985MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
10986 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
10987
10988/* reg_sbsr_rec_max_buff_occupancy
10989 * Maximum value of buffer occupancy in cells monitored. Cleared by
10990 * writing to the clr field.
10991 * Access: RO
10992 */
10993MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
10994 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
10995
10996static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
10997 u32 *p_buff_occupancy,
10998 u32 *p_max_buff_occupancy)
10999{
11000 *p_buff_occupancy =
11001 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
11002 *p_max_buff_occupancy =
11003 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
11004}
11005
Yotam Gigi51ae8cc2016-07-21 12:03:13 +020011006/* SBIB - Shared Buffer Internal Buffer Register
11007 * ---------------------------------------------
11008 * The SBIB register configures per port buffers for internal use. The internal
11009 * buffers consume memory on the port buffers (note that the port buffers are
11010 * used also by PBMC).
11011 *
11012 * For Spectrum this is used for egress mirroring.
11013 */
11014#define MLXSW_REG_SBIB_ID 0xB006
11015#define MLXSW_REG_SBIB_LEN 0x10
11016
Jiri Pirko21978dc2016-10-21 16:07:20 +020011017MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
Yotam Gigi51ae8cc2016-07-21 12:03:13 +020011018
11019/* reg_sbib_local_port
11020 * Local port number
11021 * Not supported for CPU port and router port
11022 * Access: Index
11023 */
11024MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
11025
11026/* reg_sbib_buff_size
11027 * Units represented in cells
11028 * Allowed range is 0 to (cap_max_headroom_size - 1)
11029 * Default is 0
11030 * Access: RW
11031 */
11032MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
11033
11034static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
11035 u32 buff_size)
11036{
11037 MLXSW_REG_ZERO(sbib, payload);
11038 mlxsw_reg_sbib_local_port_set(payload, local_port);
11039 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
11040}
11041
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011042static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
11043 MLXSW_REG(sgcr),
11044 MLXSW_REG(spad),
11045 MLXSW_REG(smid),
11046 MLXSW_REG(sspr),
11047 MLXSW_REG(sfdat),
11048 MLXSW_REG(sfd),
11049 MLXSW_REG(sfn),
11050 MLXSW_REG(spms),
11051 MLXSW_REG(spvid),
11052 MLXSW_REG(spvm),
11053 MLXSW_REG(spaft),
11054 MLXSW_REG(sfgc),
11055 MLXSW_REG(sftr),
11056 MLXSW_REG(sfdf),
11057 MLXSW_REG(sldr),
11058 MLXSW_REG(slcr),
11059 MLXSW_REG(slcor),
11060 MLXSW_REG(spmlr),
11061 MLXSW_REG(svfa),
11062 MLXSW_REG(svpe),
11063 MLXSW_REG(sfmr),
11064 MLXSW_REG(spvmlr),
Nogah Frankelad53fa02017-11-06 07:23:44 +010011065 MLXSW_REG(cwtp),
11066 MLXSW_REG(cwtpm),
Ido Schimmel7050f432018-07-18 11:14:40 +030011067 MLXSW_REG(pgcr),
Jiri Pirkoaf7170e2017-02-03 10:28:57 +010011068 MLXSW_REG(ppbt),
Jiri Pirko3279da42017-02-03 10:28:53 +010011069 MLXSW_REG(pacl),
Jiri Pirko10fabef2017-02-03 10:28:54 +010011070 MLXSW_REG(pagt),
Jiri Pirkod9c26612017-02-03 10:28:55 +010011071 MLXSW_REG(ptar),
Jiri Pirkod1206492017-02-03 10:28:59 +010011072 MLXSW_REG(ppbs),
Jiri Pirko937b6822017-02-03 10:28:58 +010011073 MLXSW_REG(prcr),
Jiri Pirkoe3426e12017-02-03 10:29:00 +010011074 MLXSW_REG(pefa),
Nir Dotana75e41d2018-12-10 07:11:33 +000011075 MLXSW_REG(pemrbt),
Jiri Pirko0171cdec2017-02-03 10:28:56 +010011076 MLXSW_REG(ptce2),
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +030011077 MLXSW_REG(perpt),
Nir Dotan418089a2018-12-16 08:49:24 +000011078 MLXSW_REG(peabfe),
Jiri Pirko33907872018-07-18 11:14:37 +030011079 MLXSW_REG(perar),
Ido Schimmelaecefac2018-07-25 09:23:51 +030011080 MLXSW_REG(ptce3),
Ido Schimmel481662a2018-07-18 11:14:38 +030011081 MLXSW_REG(percr),
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +030011082 MLXSW_REG(pererp),
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +030011083 MLXSW_REG(iedr),
Petr Machata746da422018-07-27 15:26:58 +030011084 MLXSW_REG(qpts),
Nogah Frankel76a4c7d2016-11-25 10:33:46 +010011085 MLXSW_REG(qpcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011086 MLXSW_REG(qtct),
11087 MLXSW_REG(qeec),
Petr Machatae67131d2018-07-27 15:26:59 +030011088 MLXSW_REG(qrwe),
Petr Machata55fb71f2018-07-27 15:27:00 +030011089 MLXSW_REG(qpdsm),
Petr Machatad8446882019-12-29 13:48:27 +020011090 MLXSW_REG(qpdp),
Petr Machata02837d72018-07-27 15:26:57 +030011091 MLXSW_REG(qpdpm),
Petr Machata671ae8a2018-08-05 09:03:06 +030011092 MLXSW_REG(qtctm),
Shalom Toledo71147502019-07-04 10:07:35 +030011093 MLXSW_REG(qpsc),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011094 MLXSW_REG(pmlp),
11095 MLXSW_REG(pmtu),
11096 MLXSW_REG(ptys),
11097 MLXSW_REG(ppad),
11098 MLXSW_REG(paos),
11099 MLXSW_REG(pfcc),
11100 MLXSW_REG(ppcnt),
Elad Raz71367932016-10-28 21:35:54 +020011101 MLXSW_REG(plib),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011102 MLXSW_REG(pptb),
11103 MLXSW_REG(pbmc),
11104 MLXSW_REG(pspa),
Jiri Pirkoa0c25382019-05-05 09:48:05 +030011105 MLXSW_REG(pplr),
Amit Cohene7d62a32020-09-27 10:50:07 +030011106 MLXSW_REG(pmpe),
Amit Cohen1bd06932020-06-29 23:46:17 +030011107 MLXSW_REG(pddr),
Jiri Pirkoa513b1a2019-10-31 11:42:07 +020011108 MLXSW_REG(pmtm),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011109 MLXSW_REG(htgt),
11110 MLXSW_REG(hpkt),
11111 MLXSW_REG(rgcr),
11112 MLXSW_REG(ritr),
Yotam Gigi46a70542017-09-19 10:00:13 +020011113 MLXSW_REG(rtar),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011114 MLXSW_REG(ratr),
Petr Machata1e659eb2017-09-02 23:49:13 +020011115 MLXSW_REG(rtdp),
Yuval Mintzddb362c2018-01-14 12:33:13 +010011116 MLXSW_REG(rdpm),
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +020011117 MLXSW_REG(ricnt),
Yotam Gigi4fc92842017-09-19 10:00:17 +020011118 MLXSW_REG(rrcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011119 MLXSW_REG(ralta),
11120 MLXSW_REG(ralst),
11121 MLXSW_REG(raltb),
11122 MLXSW_REG(ralue),
11123 MLXSW_REG(rauht),
11124 MLXSW_REG(raleu),
11125 MLXSW_REG(rauhtd),
Yotam Gigi5080c7e2017-09-19 10:00:14 +020011126 MLXSW_REG(rigr2),
Ido Schimmele4718592017-11-02 17:14:08 +010011127 MLXSW_REG(recr2),
Yotam Gigi2e654e32017-09-19 10:00:16 +020011128 MLXSW_REG(rmft2),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011129 MLXSW_REG(mfcr),
11130 MLXSW_REG(mfsc),
11131 MLXSW_REG(mfsm),
Jiri Pirko55c63aa2016-11-22 11:24:12 +010011132 MLXSW_REG(mfsl),
Vadim Pasternak3760c2b2019-02-13 11:28:46 +000011133 MLXSW_REG(fore),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011134 MLXSW_REG(mtcap),
11135 MLXSW_REG(mtmp),
Amit Cohen946bd432020-09-27 10:50:06 +030011136 MLXSW_REG(mtwe),
Vadim Pasternak5f28ef72019-02-13 11:28:45 +000011137 MLXSW_REG(mtbr),
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +020011138 MLXSW_REG(mcia),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011139 MLXSW_REG(mpat),
11140 MLXSW_REG(mpar),
Shalom Toledo8d77d4b2019-04-08 06:59:34 +000011141 MLXSW_REG(mgir),
Jiri Pirko12b003b2018-05-27 09:56:13 +030011142 MLXSW_REG(mrsr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011143 MLXSW_REG(mlcr),
Shalom Toledo10786452019-06-11 18:45:08 +030011144 MLXSW_REG(mtpps),
Shalom Toledo55a8b002019-06-11 18:45:07 +030011145 MLXSW_REG(mtutc),
Yotam Gigi0677d682017-01-23 11:07:10 +010011146 MLXSW_REG(mpsc),
Yotam Gigi4f2402d2017-05-23 21:56:24 +020011147 MLXSW_REG(mcqi),
Yotam Gigi191839d2017-05-23 21:56:25 +020011148 MLXSW_REG(mcc),
Yotam Gigi4625d592017-05-23 21:56:26 +020011149 MLXSW_REG(mcda),
Arkadi Sharshevsky57665322017-03-11 09:42:52 +010011150 MLXSW_REG(mgpc),
Ido Schimmel27f68c02018-10-11 07:48:08 +000011151 MLXSW_REG(mprs),
Petr Machata41ce78b2019-06-30 09:04:48 +030011152 MLXSW_REG(mogcr),
Amit Cohenc0e39692020-07-11 00:55:05 +030011153 MLXSW_REG(mpagr),
Amit Cohen951b84d2020-07-11 00:55:04 +030011154 MLXSW_REG(momte),
Petr Machatada28e872019-06-30 09:04:45 +030011155 MLXSW_REG(mtpppc),
Petr Machata98b90282019-06-30 09:04:47 +030011156 MLXSW_REG(mtpptr),
Petr Machata4dfecb62019-06-30 09:04:46 +030011157 MLXSW_REG(mtptpt),
Jiri Pirko191c0c22020-09-15 11:40:56 +030011158 MLXSW_REG(mfgd),
Vadim Pasternak7e9561e2019-05-29 11:47:19 +030011159 MLXSW_REG(mgpir),
Jiri Pirko6ddac9d2020-09-15 11:40:55 +030011160 MLXSW_REG(mfde),
Ido Schimmel710dd1a2018-10-11 07:47:59 +000011161 MLXSW_REG(tngcr),
Ido Schimmelc723d192018-10-11 07:48:01 +000011162 MLXSW_REG(tnumt),
Ido Schimmelfd6db272018-10-11 07:48:04 +000011163 MLXSW_REG(tnqcr),
Ido Schimmel8efcf6b2018-10-11 07:48:06 +000011164 MLXSW_REG(tnqdr),
Ido Schimmel4a8d1862018-10-11 07:48:02 +000011165 MLXSW_REG(tneem),
Ido Schimmela77d5f02018-10-11 07:48:03 +000011166 MLXSW_REG(tndem),
Ido Schimmel50e6eb22018-10-11 07:48:00 +000011167 MLXSW_REG(tnpc),
Petr Machata14aefd92017-10-20 09:16:15 +020011168 MLXSW_REG(tigcr),
Amit Cohen20174902020-01-19 15:00:50 +020011169 MLXSW_REG(tieem),
Amit Cohen839607e2020-01-19 15:00:51 +020011170 MLXSW_REG(tidem),
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011171 MLXSW_REG(sbpr),
11172 MLXSW_REG(sbcm),
11173 MLXSW_REG(sbpm),
11174 MLXSW_REG(sbmm),
11175 MLXSW_REG(sbsr),
11176 MLXSW_REG(sbib),
11177};
11178
Ido Schimmel4ec14b72015-07-29 23:33:48 +020011179static inline const char *mlxsw_reg_id_str(u16 reg_id)
11180{
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011181 const struct mlxsw_reg_info *reg_info;
11182 int i;
11183
11184 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
11185 reg_info = mlxsw_reg_infos[i];
11186 if (reg_info->id == reg_id)
11187 return reg_info->name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +020011188 }
Jiri Pirko8e9658d2016-10-21 16:07:21 +020011189 return "*UNKNOWN*";
Ido Schimmel4ec14b72015-07-29 23:33:48 +020011190}
11191
11192/* PUDE - Port Up / Down Event
11193 * ---------------------------
11194 * Reports the operational state change of a port.
11195 */
11196#define MLXSW_REG_PUDE_LEN 0x10
11197
11198/* reg_pude_swid
11199 * Switch partition ID with which to associate the port.
11200 * Access: Index
11201 */
11202MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
11203
11204/* reg_pude_local_port
11205 * Local port number.
11206 * Access: Index
11207 */
11208MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
11209
11210/* reg_pude_admin_status
11211 * Port administrative state (the desired state).
11212 * 1 - Up.
11213 * 2 - Down.
11214 * 3 - Up once. This means that in case of link failure, the port won't go
11215 * into polling mode, but will wait to be re-enabled by software.
11216 * 4 - Disabled by system. Can only be set by hardware.
11217 * Access: RO
11218 */
11219MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
11220
11221/* reg_pude_oper_status
11222 * Port operatioanl state.
11223 * 1 - Up.
11224 * 2 - Down.
11225 * 3 - Down by port failure. This means that the device will not let the
11226 * port up again until explicitly specified by software.
11227 * Access: RO
11228 */
11229MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
11230
11231#endif