blob: 4988d24a628c3c7de0719333763d70ada5d2221c [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,
Jiri Pirko236033b2015-10-16 14:01:28 +0200298};
299
300/* reg_sfd_rec_type
301 * FDB record type.
302 * Access: RW
303 */
304MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
305 MLXSW_REG_SFD_REC_LEN, 0x00, false);
306
307enum mlxsw_reg_sfd_rec_policy {
308 /* Replacement disabled, aging disabled. */
309 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
310 /* (mlag remote): Replacement enabled, aging disabled,
311 * learning notification enabled on this port.
312 */
313 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
314 /* (ingress device): Replacement enabled, aging enabled. */
315 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
316};
317
318/* reg_sfd_rec_policy
319 * Policy.
320 * Access: RW
321 */
322MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
323 MLXSW_REG_SFD_REC_LEN, 0x00, false);
324
325/* reg_sfd_rec_a
326 * Activity. Set for new static entries. Set for static entries if a frame SMAC
327 * lookup hits on the entry.
328 * To clear the a bit, use "query and clear activity" op.
329 * Access: RO
330 */
331MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
332 MLXSW_REG_SFD_REC_LEN, 0x00, false);
333
334/* reg_sfd_rec_mac
335 * MAC address.
336 * Access: Index
337 */
338MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
339 MLXSW_REG_SFD_REC_LEN, 0x02);
340
341enum mlxsw_reg_sfd_rec_action {
342 /* forward */
343 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
344 /* forward and trap, trap_id is FDB_TRAP */
345 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
346 /* trap and do not forward, trap_id is FDB_TRAP */
Ido Schimmeld82d8c02016-07-02 11:00:17 +0200347 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
348 /* forward to IP router */
349 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
Jiri Pirko236033b2015-10-16 14:01:28 +0200350 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
351};
352
353/* reg_sfd_rec_action
354 * Action to apply on the packet.
355 * Note: Dynamic entries can only be configured with NOP action.
356 * Access: RW
357 */
358MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
359 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
360
361/* reg_sfd_uc_sub_port
Jiri Pirko4e9ec082015-10-28 10:16:59 +0100362 * VEPA channel on local port.
363 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
364 * VEPA is not enabled.
Jiri Pirko236033b2015-10-16 14:01:28 +0200365 * Access: RW
366 */
367MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
368 MLXSW_REG_SFD_REC_LEN, 0x08, false);
369
370/* reg_sfd_uc_fid_vid
371 * Filtering ID or VLAN ID
372 * For SwitchX and SwitchX-2:
373 * - Dynamic entries (policy 2,3) use FID
374 * - Static entries (policy 0) use VID
375 * - When independent learning is configured, VID=FID
376 * For Spectrum: use FID for both Dynamic and Static entries.
377 * VID should not be used.
378 * Access: Index
379 */
380MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
381 MLXSW_REG_SFD_REC_LEN, 0x08, false);
382
383/* reg_sfd_uc_system_port
384 * Unique port identifier for the final destination of the packet.
385 * Access: RW
386 */
387MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
388 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
389
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100390static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
391 enum mlxsw_reg_sfd_rec_type rec_type,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100392 const char *mac,
393 enum mlxsw_reg_sfd_rec_action action)
Jiri Pirko236033b2015-10-16 14:01:28 +0200394{
395 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
396
397 if (rec_index >= num_rec)
398 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
399 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100400 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
Jiri Pirko236033b2015-10-16 14:01:28 +0200401 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100402 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
403}
404
405static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
406 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100407 const char *mac, u16 fid_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100408 enum mlxsw_reg_sfd_rec_action action,
409 u8 local_port)
410{
411 mlxsw_reg_sfd_rec_pack(payload, rec_index,
Elad Raz5230b252016-01-10 21:06:24 +0100412 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
413 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirko236033b2015-10-16 14:01:28 +0200414 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100415 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
Jiri Pirko236033b2015-10-16 14:01:28 +0200416 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
417}
418
Jiri Pirko75c09282015-10-28 10:17:01 +0100419static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100420 char *mac, u16 *p_fid_vid,
Jiri Pirko75c09282015-10-28 10:17:01 +0100421 u8 *p_local_port)
Jiri Pirko236033b2015-10-16 14:01:28 +0200422{
423 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100424 *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
Jiri Pirko236033b2015-10-16 14:01:28 +0200425 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
426}
427
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100428/* reg_sfd_uc_lag_sub_port
429 * LAG sub port.
430 * Must be 0 if multichannel VEPA is not enabled.
431 * Access: RW
432 */
433MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
434 MLXSW_REG_SFD_REC_LEN, 0x08, false);
435
436/* reg_sfd_uc_lag_fid_vid
437 * Filtering ID or VLAN ID
438 * For SwitchX and SwitchX-2:
439 * - Dynamic entries (policy 2,3) use FID
440 * - Static entries (policy 0) use VID
441 * - When independent learning is configured, VID=FID
442 * For Spectrum: use FID for both Dynamic and Static entries.
443 * VID should not be used.
444 * Access: Index
445 */
446MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
447 MLXSW_REG_SFD_REC_LEN, 0x08, false);
448
Ido Schimmelafd7f972015-12-15 16:03:45 +0100449/* reg_sfd_uc_lag_lag_vid
450 * Indicates VID in case of vFIDs. Reserved for FIDs.
451 * Access: RW
452 */
453MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
454 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
455
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100456/* reg_sfd_uc_lag_lag_id
457 * LAG Identifier - pointer into the LAG descriptor table.
458 * Access: RW
459 */
460MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
461 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
462
463static inline void
464mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
465 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100466 const char *mac, u16 fid_vid,
Ido Schimmelafd7f972015-12-15 16:03:45 +0100467 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100468 u16 lag_id)
469{
470 mlxsw_reg_sfd_rec_pack(payload, rec_index,
471 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
Elad Raz5230b252016-01-10 21:06:24 +0100472 mac, action);
473 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100474 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100475 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
Ido Schimmelafd7f972015-12-15 16:03:45 +0100476 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100477 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
478}
479
480static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
481 char *mac, u16 *p_vid,
482 u16 *p_lag_id)
483{
484 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
485 *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
486 *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
487}
488
Elad Raz5230b252016-01-10 21:06:24 +0100489/* reg_sfd_mc_pgi
490 *
491 * Multicast port group index - index into the port group table.
492 * Value 0x1FFF indicates the pgi should point to the MID entry.
493 * For Spectrum this value must be set to 0x1FFF
494 * Access: RW
495 */
496MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
497 MLXSW_REG_SFD_REC_LEN, 0x08, false);
498
499/* reg_sfd_mc_fid_vid
500 *
501 * Filtering ID or VLAN ID
502 * Access: Index
503 */
504MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
505 MLXSW_REG_SFD_REC_LEN, 0x08, false);
506
507/* reg_sfd_mc_mid
508 *
509 * Multicast identifier - global identifier that represents the multicast
510 * group across all devices.
511 * Access: RW
512 */
513MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
514 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
515
516static inline void
517mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
518 const char *mac, u16 fid_vid,
519 enum mlxsw_reg_sfd_rec_action action, u16 mid)
520{
521 mlxsw_reg_sfd_rec_pack(payload, rec_index,
522 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
523 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
524 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
525 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
526}
527
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200528/* SFN - Switch FDB Notification Register
529 * -------------------------------------------
530 * The switch provides notifications on newly learned FDB entries and
531 * aged out entries. The notifications can be polled by software.
532 */
533#define MLXSW_REG_SFN_ID 0x200B
534#define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
535#define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
536#define MLXSW_REG_SFN_REC_MAX_COUNT 64
537#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
538 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
539
Jiri Pirko21978dc2016-10-21 16:07:20 +0200540MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200541
542/* reg_sfn_swid
543 * Switch partition ID.
544 * Access: Index
545 */
546MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
547
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200548/* reg_sfn_end
549 * Forces the current session to end.
550 * Access: OP
551 */
552MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
553
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200554/* reg_sfn_num_rec
555 * Request: Number of learned notifications and aged-out notification
556 * records requested.
557 * Response: Number of notification records returned (must be smaller
558 * than or equal to the value requested)
559 * Ranges 0..64
560 * Access: OP
561 */
562MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
563
564static inline void mlxsw_reg_sfn_pack(char *payload)
565{
566 MLXSW_REG_ZERO(sfn, payload);
567 mlxsw_reg_sfn_swid_set(payload, 0);
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200568 mlxsw_reg_sfn_end_set(payload, 1);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200569 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
570}
571
572/* reg_sfn_rec_swid
573 * Switch partition ID.
574 * Access: RO
575 */
576MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
577 MLXSW_REG_SFN_REC_LEN, 0x00, false);
578
579enum mlxsw_reg_sfn_rec_type {
580 /* MAC addresses learned on a regular port. */
581 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
Jiri Pirko3b715712015-12-03 12:12:27 +0100582 /* MAC addresses learned on a LAG port. */
583 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
584 /* Aged-out MAC address on a regular port. */
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200585 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
Jiri Pirko3b715712015-12-03 12:12:27 +0100586 /* Aged-out MAC address on a LAG port. */
587 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200588};
589
590/* reg_sfn_rec_type
591 * Notification record type.
592 * Access: RO
593 */
594MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
595 MLXSW_REG_SFN_REC_LEN, 0x00, false);
596
597/* reg_sfn_rec_mac
598 * MAC address.
599 * Access: RO
600 */
601MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
602 MLXSW_REG_SFN_REC_LEN, 0x02);
603
Jiri Pirko8316f082015-10-28 10:17:00 +0100604/* reg_sfn_mac_sub_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200605 * VEPA channel on the local port.
606 * 0 if multichannel VEPA is not enabled.
607 * Access: RO
608 */
609MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
610 MLXSW_REG_SFN_REC_LEN, 0x08, false);
611
Jiri Pirko8316f082015-10-28 10:17:00 +0100612/* reg_sfn_mac_fid
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200613 * Filtering identifier.
614 * Access: RO
615 */
616MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
617 MLXSW_REG_SFN_REC_LEN, 0x08, false);
618
Jiri Pirko8316f082015-10-28 10:17:00 +0100619/* reg_sfn_mac_system_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200620 * Unique port identifier for the final destination of the packet.
621 * Access: RO
622 */
623MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
624 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
625
626static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
627 char *mac, u16 *p_vid,
628 u8 *p_local_port)
629{
630 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
631 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
632 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
633}
634
Jiri Pirko3b715712015-12-03 12:12:27 +0100635/* reg_sfn_mac_lag_lag_id
636 * LAG ID (pointer into the LAG descriptor table).
637 * Access: RO
638 */
639MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
640 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
641
642static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
643 char *mac, u16 *p_vid,
644 u16 *p_lag_id)
645{
646 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
647 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
648 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
649}
650
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200651/* SPMS - Switch Port MSTP/RSTP State Register
652 * -------------------------------------------
653 * Configures the spanning tree state of a physical port.
654 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +0200655#define MLXSW_REG_SPMS_ID 0x200D
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200656#define MLXSW_REG_SPMS_LEN 0x404
657
Jiri Pirko21978dc2016-10-21 16:07:20 +0200658MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200659
660/* reg_spms_local_port
661 * Local port number.
662 * Access: Index
663 */
664MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
665
666enum mlxsw_reg_spms_state {
667 MLXSW_REG_SPMS_STATE_NO_CHANGE,
668 MLXSW_REG_SPMS_STATE_DISCARDING,
669 MLXSW_REG_SPMS_STATE_LEARNING,
670 MLXSW_REG_SPMS_STATE_FORWARDING,
671};
672
673/* reg_spms_state
674 * Spanning tree state of each VLAN ID (VID) of the local port.
675 * 0 - Do not change spanning tree state (used only when writing).
676 * 1 - Discarding. No learning or forwarding to/from this port (default).
677 * 2 - Learning. Port is learning, but not forwarding.
678 * 3 - Forwarding. Port is learning and forwarding.
679 * Access: RW
680 */
681MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
682
Jiri Pirkoebb79632015-10-15 17:43:26 +0200683static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200684{
685 MLXSW_REG_ZERO(spms, payload);
686 mlxsw_reg_spms_local_port_set(payload, local_port);
Jiri Pirkoebb79632015-10-15 17:43:26 +0200687}
688
689static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
690 enum mlxsw_reg_spms_state state)
691{
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200692 mlxsw_reg_spms_state_set(payload, vid, state);
693}
694
Elad Razb2e345f2015-10-16 14:01:30 +0200695/* SPVID - Switch Port VID
696 * -----------------------
697 * The switch port VID configures the default VID for a port.
698 */
699#define MLXSW_REG_SPVID_ID 0x200E
700#define MLXSW_REG_SPVID_LEN 0x08
701
Jiri Pirko21978dc2016-10-21 16:07:20 +0200702MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200703
704/* reg_spvid_local_port
705 * Local port number.
706 * Access: Index
707 */
708MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
709
710/* reg_spvid_sub_port
711 * Virtual port within the physical port.
712 * Should be set to 0 when virtual ports are not enabled on the port.
713 * Access: Index
714 */
715MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
716
717/* reg_spvid_pvid
718 * Port default VID
719 * Access: RW
720 */
721MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
722
723static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
724{
725 MLXSW_REG_ZERO(spvid, payload);
726 mlxsw_reg_spvid_local_port_set(payload, local_port);
727 mlxsw_reg_spvid_pvid_set(payload, pvid);
728}
729
730/* SPVM - Switch Port VLAN Membership
731 * ----------------------------------
732 * The Switch Port VLAN Membership register configures the VLAN membership
733 * of a port in a VLAN denoted by VID. VLAN membership is managed per
734 * virtual port. The register can be used to add and remove VID(s) from a port.
735 */
736#define MLXSW_REG_SPVM_ID 0x200F
737#define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
738#define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
Jiri Pirkof004ec02017-03-14 14:00:00 +0100739#define MLXSW_REG_SPVM_REC_MAX_COUNT 255
Elad Razb2e345f2015-10-16 14:01:30 +0200740#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
741 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
742
Jiri Pirko21978dc2016-10-21 16:07:20 +0200743MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200744
745/* reg_spvm_pt
746 * Priority tagged. If this bit is set, packets forwarded to the port with
747 * untagged VLAN membership (u bit is set) will be tagged with priority tag
748 * (VID=0)
749 * Access: RW
750 */
751MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
752
753/* reg_spvm_pte
754 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
755 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
756 * Access: WO
757 */
758MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
759
760/* reg_spvm_local_port
761 * Local port number.
762 * Access: Index
763 */
764MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
765
766/* reg_spvm_sub_port
767 * Virtual port within the physical port.
768 * Should be set to 0 when virtual ports are not enabled on the port.
769 * Access: Index
770 */
771MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
772
773/* reg_spvm_num_rec
774 * Number of records to update. Each record contains: i, e, u, vid.
775 * Access: OP
776 */
777MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
778
779/* reg_spvm_rec_i
780 * Ingress membership in VLAN ID.
781 * Access: Index
782 */
783MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
784 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
785 MLXSW_REG_SPVM_REC_LEN, 0, false);
786
787/* reg_spvm_rec_e
788 * Egress membership in VLAN ID.
789 * Access: Index
790 */
791MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
792 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
793 MLXSW_REG_SPVM_REC_LEN, 0, false);
794
795/* reg_spvm_rec_u
796 * Untagged - port is an untagged member - egress transmission uses untagged
797 * frames on VID<n>
798 * Access: Index
799 */
800MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
801 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
802 MLXSW_REG_SPVM_REC_LEN, 0, false);
803
804/* reg_spvm_rec_vid
805 * Egress membership in VLAN ID.
806 * Access: Index
807 */
808MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
809 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
810 MLXSW_REG_SPVM_REC_LEN, 0, false);
811
812static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
813 u16 vid_begin, u16 vid_end,
814 bool is_member, bool untagged)
815{
816 int size = vid_end - vid_begin + 1;
817 int i;
818
819 MLXSW_REG_ZERO(spvm, payload);
820 mlxsw_reg_spvm_local_port_set(payload, local_port);
821 mlxsw_reg_spvm_num_rec_set(payload, size);
822
823 for (i = 0; i < size; i++) {
824 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
825 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
826 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
827 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
828 }
829}
830
Ido Schimmel148f4722016-02-18 11:30:01 +0100831/* SPAFT - Switch Port Acceptable Frame Types
832 * ------------------------------------------
833 * The Switch Port Acceptable Frame Types register configures the frame
834 * admittance of the port.
835 */
836#define MLXSW_REG_SPAFT_ID 0x2010
837#define MLXSW_REG_SPAFT_LEN 0x08
838
Jiri Pirko21978dc2016-10-21 16:07:20 +0200839MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
Ido Schimmel148f4722016-02-18 11:30:01 +0100840
841/* reg_spaft_local_port
842 * Local port number.
843 * Access: Index
844 *
845 * Note: CPU port is not supported (all tag types are allowed).
846 */
847MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
848
849/* reg_spaft_sub_port
850 * Virtual port within the physical port.
851 * Should be set to 0 when virtual ports are not enabled on the port.
852 * Access: RW
853 */
854MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
855
856/* reg_spaft_allow_untagged
857 * When set, untagged frames on the ingress are allowed (default).
858 * Access: RW
859 */
860MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
861
862/* reg_spaft_allow_prio_tagged
863 * When set, priority tagged frames on the ingress are allowed (default).
864 * Access: RW
865 */
866MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
867
868/* reg_spaft_allow_tagged
869 * When set, tagged frames on the ingress are allowed (default).
870 * Access: RW
871 */
872MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
873
874static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
875 bool allow_untagged)
876{
877 MLXSW_REG_ZERO(spaft, payload);
878 mlxsw_reg_spaft_local_port_set(payload, local_port);
879 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
880 mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
881 mlxsw_reg_spaft_allow_tagged_set(payload, true);
882}
883
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200884/* SFGC - Switch Flooding Group Configuration
885 * ------------------------------------------
886 * The following register controls the association of flooding tables and MIDs
887 * to packet types used for flooding.
888 */
Jiri Pirko36b78e82015-10-15 17:43:24 +0200889#define MLXSW_REG_SFGC_ID 0x2011
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200890#define MLXSW_REG_SFGC_LEN 0x10
891
Jiri Pirko21978dc2016-10-21 16:07:20 +0200892MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200893
894enum mlxsw_reg_sfgc_type {
Ido Schimmelfa6ad052015-10-15 17:43:25 +0200895 MLXSW_REG_SFGC_TYPE_BROADCAST,
896 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
897 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
898 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
899 MLXSW_REG_SFGC_TYPE_RESERVED,
900 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
901 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
902 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
903 MLXSW_REG_SFGC_TYPE_MAX,
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200904};
905
906/* reg_sfgc_type
907 * The traffic type to reach the flooding table.
908 * Access: Index
909 */
910MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
911
912enum mlxsw_reg_sfgc_bridge_type {
913 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
914 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
915};
916
917/* reg_sfgc_bridge_type
918 * Access: Index
919 *
920 * Note: SwitchX-2 only supports 802.1Q mode.
921 */
922MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
923
924enum mlxsw_flood_table_type {
925 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
926 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
927 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
Ido Schimmelda0abcf2017-06-04 16:53:39 +0200928 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200929 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
930};
931
932/* reg_sfgc_table_type
933 * See mlxsw_flood_table_type
934 * Access: RW
935 *
936 * Note: FID offset and FID types are not supported in SwitchX-2.
937 */
938MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
939
940/* reg_sfgc_flood_table
941 * Flooding table index to associate with the specific type on the specific
942 * switch partition.
943 * Access: RW
944 */
945MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
946
947/* reg_sfgc_mid
948 * The multicast ID for the swid. Not supported for Spectrum
949 * Access: RW
950 */
951MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
952
953/* reg_sfgc_counter_set_type
954 * Counter Set Type for flow counters.
955 * Access: RW
956 */
957MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
958
959/* reg_sfgc_counter_index
960 * Counter Index for flow counters.
961 * Access: RW
962 */
963MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
964
965static inline void
966mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
967 enum mlxsw_reg_sfgc_bridge_type bridge_type,
968 enum mlxsw_flood_table_type table_type,
969 unsigned int flood_table)
970{
971 MLXSW_REG_ZERO(sfgc, payload);
972 mlxsw_reg_sfgc_type_set(payload, type);
973 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
974 mlxsw_reg_sfgc_table_type_set(payload, table_type);
975 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
976 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
977}
978
979/* SFTR - Switch Flooding Table Register
980 * -------------------------------------
981 * The switch flooding table is used for flooding packet replication. The table
982 * defines a bit mask of ports for packet replication.
983 */
984#define MLXSW_REG_SFTR_ID 0x2012
985#define MLXSW_REG_SFTR_LEN 0x420
986
Jiri Pirko21978dc2016-10-21 16:07:20 +0200987MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200988
989/* reg_sftr_swid
990 * Switch partition ID with which to associate the port.
991 * Access: Index
992 */
993MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
994
995/* reg_sftr_flood_table
996 * Flooding table index to associate with the specific type on the specific
997 * switch partition.
998 * Access: Index
999 */
1000MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1001
1002/* reg_sftr_index
1003 * Index. Used as an index into the Flooding Table in case the table is
1004 * configured to use VID / FID or FID Offset.
1005 * Access: Index
1006 */
1007MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1008
1009/* reg_sftr_table_type
1010 * See mlxsw_flood_table_type
1011 * Access: RW
1012 */
1013MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1014
1015/* reg_sftr_range
1016 * Range of entries to update
1017 * Access: Index
1018 */
1019MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1020
1021/* reg_sftr_port
1022 * Local port membership (1 bit per port).
1023 * Access: RW
1024 */
1025MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1026
1027/* reg_sftr_cpu_port_mask
1028 * CPU port mask (1 bit per port).
1029 * Access: W
1030 */
1031MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1032
1033static inline void mlxsw_reg_sftr_pack(char *payload,
1034 unsigned int flood_table,
1035 unsigned int index,
1036 enum mlxsw_flood_table_type table_type,
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001037 unsigned int range, u8 port, bool set)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001038{
1039 MLXSW_REG_ZERO(sftr, payload);
1040 mlxsw_reg_sftr_swid_set(payload, 0);
1041 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1042 mlxsw_reg_sftr_index_set(payload, index);
1043 mlxsw_reg_sftr_table_type_set(payload, table_type);
1044 mlxsw_reg_sftr_range_set(payload, range);
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001045 mlxsw_reg_sftr_port_set(payload, port, set);
1046 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001047}
1048
Ido Schimmel41933272016-01-27 15:20:17 +01001049/* SFDF - Switch Filtering DB Flush
1050 * --------------------------------
1051 * The switch filtering DB flush register is used to flush the FDB.
1052 * Note that FDB notifications are flushed as well.
1053 */
1054#define MLXSW_REG_SFDF_ID 0x2013
1055#define MLXSW_REG_SFDF_LEN 0x14
1056
Jiri Pirko21978dc2016-10-21 16:07:20 +02001057MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
Ido Schimmel41933272016-01-27 15:20:17 +01001058
1059/* reg_sfdf_swid
1060 * Switch partition ID.
1061 * Access: Index
1062 */
1063MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1064
1065enum mlxsw_reg_sfdf_flush_type {
1066 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1067 MLXSW_REG_SFDF_FLUSH_PER_FID,
1068 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1069 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1070 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1071 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
Ido Schimmela682a302018-10-11 07:47:56 +00001072 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1073 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
Ido Schimmel41933272016-01-27 15:20:17 +01001074};
1075
1076/* reg_sfdf_flush_type
1077 * Flush type.
1078 * 0 - All SWID dynamic entries are flushed.
1079 * 1 - All FID dynamic entries are flushed.
1080 * 2 - All dynamic entries pointing to port are flushed.
1081 * 3 - All FID dynamic entries pointing to port are flushed.
1082 * 4 - All dynamic entries pointing to LAG are flushed.
1083 * 5 - All FID dynamic entries pointing to LAG are flushed.
Ido Schimmela682a302018-10-11 07:47:56 +00001084 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1085 * flushed.
1086 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
1087 * flushed, per FID.
Ido Schimmel41933272016-01-27 15:20:17 +01001088 * Access: RW
1089 */
1090MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1091
1092/* reg_sfdf_flush_static
1093 * Static.
1094 * 0 - Flush only dynamic entries.
1095 * 1 - Flush both dynamic and static entries.
1096 * Access: RW
1097 */
1098MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1099
1100static inline void mlxsw_reg_sfdf_pack(char *payload,
1101 enum mlxsw_reg_sfdf_flush_type type)
1102{
1103 MLXSW_REG_ZERO(sfdf, payload);
1104 mlxsw_reg_sfdf_flush_type_set(payload, type);
1105 mlxsw_reg_sfdf_flush_static_set(payload, true);
1106}
1107
1108/* reg_sfdf_fid
1109 * FID to flush.
1110 * Access: RW
1111 */
1112MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1113
1114/* reg_sfdf_system_port
1115 * Port to flush.
1116 * Access: RW
1117 */
1118MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1119
1120/* reg_sfdf_port_fid_system_port
1121 * Port to flush, pointed to by FID.
1122 * Access: RW
1123 */
1124MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1125
1126/* reg_sfdf_lag_id
1127 * LAG ID to flush.
1128 * Access: RW
1129 */
1130MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1131
1132/* reg_sfdf_lag_fid_lag_id
1133 * LAG ID to flush, pointed to by FID.
1134 * Access: RW
1135 */
1136MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1137
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001138/* SLDR - Switch LAG Descriptor Register
1139 * -----------------------------------------
1140 * The switch LAG descriptor register is populated by LAG descriptors.
1141 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1142 * max_lag-1.
1143 */
1144#define MLXSW_REG_SLDR_ID 0x2014
1145#define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1146
Jiri Pirko21978dc2016-10-21 16:07:20 +02001147MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001148
1149enum mlxsw_reg_sldr_op {
1150 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1151 MLXSW_REG_SLDR_OP_LAG_CREATE,
1152 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1153 /* Ports that appear in the list have the Distributor enabled */
1154 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1155 /* Removes ports from the disributor list */
1156 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1157};
1158
1159/* reg_sldr_op
1160 * Operation.
1161 * Access: RW
1162 */
1163MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1164
1165/* reg_sldr_lag_id
1166 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1167 * Access: Index
1168 */
1169MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1170
1171static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1172{
1173 MLXSW_REG_ZERO(sldr, payload);
1174 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1175 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1176}
1177
1178static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1179{
1180 MLXSW_REG_ZERO(sldr, payload);
1181 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1182 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1183}
1184
1185/* reg_sldr_num_ports
1186 * The number of member ports of the LAG.
1187 * Reserved for Create / Destroy operations
1188 * For Add / Remove operations - indicates the number of ports in the list.
1189 * Access: RW
1190 */
1191MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1192
1193/* reg_sldr_system_port
1194 * System port.
1195 * Access: RW
1196 */
1197MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1198
1199static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1200 u8 local_port)
1201{
1202 MLXSW_REG_ZERO(sldr, payload);
1203 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1204 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1205 mlxsw_reg_sldr_num_ports_set(payload, 1);
1206 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1207}
1208
1209static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1210 u8 local_port)
1211{
1212 MLXSW_REG_ZERO(sldr, payload);
1213 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1214 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1215 mlxsw_reg_sldr_num_ports_set(payload, 1);
1216 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1217}
1218
1219/* SLCR - Switch LAG Configuration 2 Register
1220 * -------------------------------------------
1221 * The Switch LAG Configuration register is used for configuring the
1222 * LAG properties of the switch.
1223 */
1224#define MLXSW_REG_SLCR_ID 0x2015
1225#define MLXSW_REG_SLCR_LEN 0x10
1226
Jiri Pirko21978dc2016-10-21 16:07:20 +02001227MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001228
1229enum mlxsw_reg_slcr_pp {
1230 /* Global Configuration (for all ports) */
1231 MLXSW_REG_SLCR_PP_GLOBAL,
1232 /* Per port configuration, based on local_port field */
1233 MLXSW_REG_SLCR_PP_PER_PORT,
1234};
1235
1236/* reg_slcr_pp
1237 * Per Port Configuration
1238 * Note: Reading at Global mode results in reading port 1 configuration.
1239 * Access: Index
1240 */
1241MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1242
1243/* reg_slcr_local_port
1244 * Local port number
1245 * Supported from CPU port
1246 * Not supported from router port
1247 * Reserved when pp = Global Configuration
1248 * Access: Index
1249 */
1250MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1251
1252enum mlxsw_reg_slcr_type {
1253 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1254 MLXSW_REG_SLCR_TYPE_XOR,
1255 MLXSW_REG_SLCR_TYPE_RANDOM,
1256};
1257
1258/* reg_slcr_type
1259 * Hash type
1260 * Access: RW
1261 */
1262MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1263
1264/* Ingress port */
1265#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1266/* SMAC - for IPv4 and IPv6 packets */
1267#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1268/* SMAC - for non-IP packets */
1269#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1270#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1271 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1272 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1273/* DMAC - for IPv4 and IPv6 packets */
1274#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1275/* DMAC - for non-IP packets */
1276#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1277#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1278 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1279 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1280/* Ethertype - for IPv4 and IPv6 packets */
1281#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1282/* Ethertype - for non-IP packets */
1283#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1284#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1285 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1286 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1287/* VLAN ID - for IPv4 and IPv6 packets */
1288#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1289/* VLAN ID - for non-IP packets */
1290#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1291#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1292 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1293 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1294/* Source IP address (can be IPv4 or IPv6) */
1295#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1296/* Destination IP address (can be IPv4 or IPv6) */
1297#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1298/* TCP/UDP source port */
1299#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1300/* TCP/UDP destination port*/
1301#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1302/* IPv4 Protocol/IPv6 Next Header */
1303#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1304/* IPv6 Flow label */
1305#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1306/* SID - FCoE source ID */
1307#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1308/* DID - FCoE destination ID */
1309#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1310/* OXID - FCoE originator exchange ID */
1311#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1312/* Destination QP number - for RoCE packets */
1313#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1314
1315/* reg_slcr_lag_hash
1316 * LAG hashing configuration. This is a bitmask, in which each set
1317 * bit includes the corresponding item in the LAG hash calculation.
1318 * The default lag_hash contains SMAC, DMAC, VLANID and
1319 * Ethertype (for all packet types).
1320 * Access: RW
1321 */
1322MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1323
Ido Schimmelbeda7f72018-10-11 07:47:57 +00001324/* reg_slcr_seed
1325 * LAG seed value. The seed is the same for all ports.
1326 * Access: RW
1327 */
1328MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1329
1330static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001331{
1332 MLXSW_REG_ZERO(slcr, payload);
1333 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
Elad Raz18c2d2c2016-09-19 08:28:24 +02001334 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001335 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
Ido Schimmelbeda7f72018-10-11 07:47:57 +00001336 mlxsw_reg_slcr_seed_set(payload, seed);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001337}
1338
1339/* SLCOR - Switch LAG Collector Register
1340 * -------------------------------------
1341 * The Switch LAG Collector register controls the Local Port membership
1342 * in a LAG and enablement of the collector.
1343 */
1344#define MLXSW_REG_SLCOR_ID 0x2016
1345#define MLXSW_REG_SLCOR_LEN 0x10
1346
Jiri Pirko21978dc2016-10-21 16:07:20 +02001347MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001348
1349enum mlxsw_reg_slcor_col {
1350 /* Port is added with collector disabled */
1351 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1352 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1353 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1354 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1355};
1356
1357/* reg_slcor_col
1358 * Collector configuration
1359 * Access: RW
1360 */
1361MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1362
1363/* reg_slcor_local_port
1364 * Local port number
1365 * Not supported for CPU port
1366 * Access: Index
1367 */
1368MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1369
1370/* reg_slcor_lag_id
1371 * LAG Identifier. Index into the LAG descriptor table.
1372 * Access: Index
1373 */
1374MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1375
1376/* reg_slcor_port_index
1377 * Port index in the LAG list. Only valid on Add Port to LAG col.
1378 * Valid range is from 0 to cap_max_lag_members-1
1379 * Access: RW
1380 */
1381MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1382
1383static inline void mlxsw_reg_slcor_pack(char *payload,
1384 u8 local_port, u16 lag_id,
1385 enum mlxsw_reg_slcor_col col)
1386{
1387 MLXSW_REG_ZERO(slcor, payload);
1388 mlxsw_reg_slcor_col_set(payload, col);
1389 mlxsw_reg_slcor_local_port_set(payload, local_port);
1390 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1391}
1392
1393static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1394 u8 local_port, u16 lag_id,
1395 u8 port_index)
1396{
1397 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1398 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1399 mlxsw_reg_slcor_port_index_set(payload, port_index);
1400}
1401
1402static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1403 u8 local_port, u16 lag_id)
1404{
1405 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1406 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1407}
1408
1409static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1410 u8 local_port, u16 lag_id)
1411{
1412 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1413 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1414}
1415
1416static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1417 u8 local_port, u16 lag_id)
1418{
1419 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1420 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1421}
1422
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001423/* SPMLR - Switch Port MAC Learning Register
1424 * -----------------------------------------
1425 * Controls the Switch MAC learning policy per port.
1426 */
1427#define MLXSW_REG_SPMLR_ID 0x2018
1428#define MLXSW_REG_SPMLR_LEN 0x8
1429
Jiri Pirko21978dc2016-10-21 16:07:20 +02001430MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001431
1432/* reg_spmlr_local_port
1433 * Local port number.
1434 * Access: Index
1435 */
1436MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1437
1438/* reg_spmlr_sub_port
1439 * Virtual port within the physical port.
1440 * Should be set to 0 when virtual ports are not enabled on the port.
1441 * Access: Index
1442 */
1443MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1444
1445enum mlxsw_reg_spmlr_learn_mode {
1446 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1447 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1448 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1449};
1450
1451/* reg_spmlr_learn_mode
1452 * Learning mode on the port.
1453 * 0 - Learning disabled.
1454 * 2 - Learning enabled.
1455 * 3 - Security mode.
1456 *
1457 * In security mode the switch does not learn MACs on the port, but uses the
1458 * SMAC to see if it exists on another ingress port. If so, the packet is
1459 * classified as a bad packet and is discarded unless the software registers
1460 * to receive port security error packets usign HPKT.
1461 */
1462MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1463
1464static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1465 enum mlxsw_reg_spmlr_learn_mode mode)
1466{
1467 MLXSW_REG_ZERO(spmlr, payload);
1468 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1469 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1470 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1471}
1472
Ido Schimmel64790232015-10-16 14:01:33 +02001473/* SVFA - Switch VID to FID Allocation Register
1474 * --------------------------------------------
1475 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1476 * virtualized ports.
1477 */
1478#define MLXSW_REG_SVFA_ID 0x201C
1479#define MLXSW_REG_SVFA_LEN 0x10
1480
Jiri Pirko21978dc2016-10-21 16:07:20 +02001481MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
Ido Schimmel64790232015-10-16 14:01:33 +02001482
1483/* reg_svfa_swid
1484 * Switch partition ID.
1485 * Access: Index
1486 */
1487MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1488
1489/* reg_svfa_local_port
1490 * Local port number.
1491 * Access: Index
1492 *
1493 * Note: Reserved for 802.1Q FIDs.
1494 */
1495MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1496
1497enum mlxsw_reg_svfa_mt {
1498 MLXSW_REG_SVFA_MT_VID_TO_FID,
1499 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1500};
1501
1502/* reg_svfa_mapping_table
1503 * Mapping table:
1504 * 0 - VID to FID
1505 * 1 - {Port, VID} to FID
1506 * Access: Index
1507 *
1508 * Note: Reserved for SwitchX-2.
1509 */
1510MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1511
1512/* reg_svfa_v
1513 * Valid.
1514 * Valid if set.
1515 * Access: RW
1516 *
1517 * Note: Reserved for SwitchX-2.
1518 */
1519MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1520
1521/* reg_svfa_fid
1522 * Filtering ID.
1523 * Access: RW
1524 */
1525MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1526
1527/* reg_svfa_vid
1528 * VLAN ID.
1529 * Access: Index
1530 */
1531MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1532
1533/* reg_svfa_counter_set_type
1534 * Counter set type for flow counters.
1535 * Access: RW
1536 *
1537 * Note: Reserved for SwitchX-2.
1538 */
1539MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1540
1541/* reg_svfa_counter_index
1542 * Counter index for flow counters.
1543 * Access: RW
1544 *
1545 * Note: Reserved for SwitchX-2.
1546 */
1547MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1548
1549static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1550 enum mlxsw_reg_svfa_mt mt, bool valid,
1551 u16 fid, u16 vid)
1552{
1553 MLXSW_REG_ZERO(svfa, payload);
1554 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1555 mlxsw_reg_svfa_swid_set(payload, 0);
1556 mlxsw_reg_svfa_local_port_set(payload, local_port);
1557 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1558 mlxsw_reg_svfa_v_set(payload, valid);
1559 mlxsw_reg_svfa_fid_set(payload, fid);
1560 mlxsw_reg_svfa_vid_set(payload, vid);
1561}
1562
Ido Schimmel1f65da72015-10-16 14:01:34 +02001563/* SVPE - Switch Virtual-Port Enabling Register
1564 * --------------------------------------------
1565 * Enables port virtualization.
1566 */
1567#define MLXSW_REG_SVPE_ID 0x201E
1568#define MLXSW_REG_SVPE_LEN 0x4
1569
Jiri Pirko21978dc2016-10-21 16:07:20 +02001570MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
Ido Schimmel1f65da72015-10-16 14:01:34 +02001571
1572/* reg_svpe_local_port
1573 * Local port number
1574 * Access: Index
1575 *
1576 * Note: CPU port is not supported (uses VLAN mode only).
1577 */
1578MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1579
1580/* reg_svpe_vp_en
1581 * Virtual port enable.
1582 * 0 - Disable, VLAN mode (VID to FID).
1583 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1584 * Access: RW
1585 */
1586MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1587
1588static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1589 bool enable)
1590{
1591 MLXSW_REG_ZERO(svpe, payload);
1592 mlxsw_reg_svpe_local_port_set(payload, local_port);
1593 mlxsw_reg_svpe_vp_en_set(payload, enable);
1594}
1595
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001596/* SFMR - Switch FID Management Register
1597 * -------------------------------------
1598 * Creates and configures FIDs.
1599 */
1600#define MLXSW_REG_SFMR_ID 0x201F
1601#define MLXSW_REG_SFMR_LEN 0x18
1602
Jiri Pirko21978dc2016-10-21 16:07:20 +02001603MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001604
1605enum mlxsw_reg_sfmr_op {
1606 MLXSW_REG_SFMR_OP_CREATE_FID,
1607 MLXSW_REG_SFMR_OP_DESTROY_FID,
1608};
1609
1610/* reg_sfmr_op
1611 * Operation.
1612 * 0 - Create or edit FID.
1613 * 1 - Destroy FID.
1614 * Access: WO
1615 */
1616MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1617
1618/* reg_sfmr_fid
1619 * Filtering ID.
1620 * Access: Index
1621 */
1622MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1623
1624/* reg_sfmr_fid_offset
1625 * FID offset.
1626 * Used to point into the flooding table selected by SFGC register if
1627 * the table is of type FID-Offset. Otherwise, this field is reserved.
1628 * Access: RW
1629 */
1630MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1631
1632/* reg_sfmr_vtfp
1633 * Valid Tunnel Flood Pointer.
1634 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1635 * Access: RW
1636 *
1637 * Note: Reserved for 802.1Q FIDs.
1638 */
1639MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1640
1641/* reg_sfmr_nve_tunnel_flood_ptr
1642 * Underlay Flooding and BC Pointer.
1643 * Used as a pointer to the first entry of the group based link lists of
1644 * flooding or BC entries (for NVE tunnels).
1645 * Access: RW
1646 */
1647MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1648
1649/* reg_sfmr_vv
1650 * VNI Valid.
1651 * If not set, then vni is reserved.
1652 * Access: RW
1653 *
1654 * Note: Reserved for 802.1Q FIDs.
1655 */
1656MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1657
1658/* reg_sfmr_vni
1659 * Virtual Network Identifier.
1660 * Access: RW
1661 *
1662 * Note: A given VNI can only be assigned to one FID.
1663 */
1664MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1665
1666static inline void mlxsw_reg_sfmr_pack(char *payload,
1667 enum mlxsw_reg_sfmr_op op, u16 fid,
1668 u16 fid_offset)
1669{
1670 MLXSW_REG_ZERO(sfmr, payload);
1671 mlxsw_reg_sfmr_op_set(payload, op);
1672 mlxsw_reg_sfmr_fid_set(payload, fid);
1673 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1674 mlxsw_reg_sfmr_vtfp_set(payload, false);
1675 mlxsw_reg_sfmr_vv_set(payload, false);
1676}
1677
Ido Schimmela4feea72015-10-16 14:01:36 +02001678/* SPVMLR - Switch Port VLAN MAC Learning Register
1679 * -----------------------------------------------
1680 * Controls the switch MAC learning policy per {Port, VID}.
1681 */
1682#define MLXSW_REG_SPVMLR_ID 0x2020
1683#define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1684#define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
Jiri Pirkoe9093b12017-03-14 14:00:01 +01001685#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
Ido Schimmela4feea72015-10-16 14:01:36 +02001686#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1687 MLXSW_REG_SPVMLR_REC_LEN * \
1688 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1689
Jiri Pirko21978dc2016-10-21 16:07:20 +02001690MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
Ido Schimmela4feea72015-10-16 14:01:36 +02001691
1692/* reg_spvmlr_local_port
1693 * Local ingress port.
1694 * Access: Index
1695 *
1696 * Note: CPU port is not supported.
1697 */
1698MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1699
1700/* reg_spvmlr_num_rec
1701 * Number of records to update.
1702 * Access: OP
1703 */
1704MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1705
1706/* reg_spvmlr_rec_learn_enable
1707 * 0 - Disable learning for {Port, VID}.
1708 * 1 - Enable learning for {Port, VID}.
1709 * Access: RW
1710 */
1711MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1712 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1713
1714/* reg_spvmlr_rec_vid
1715 * VLAN ID to be added/removed from port or for querying.
1716 * Access: Index
1717 */
1718MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1719 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1720
1721static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1722 u16 vid_begin, u16 vid_end,
1723 bool learn_enable)
1724{
1725 int num_rec = vid_end - vid_begin + 1;
1726 int i;
1727
1728 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1729
1730 MLXSW_REG_ZERO(spvmlr, payload);
1731 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1732 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1733
1734 for (i = 0; i < num_rec; i++) {
1735 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1736 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1737 }
1738}
1739
Nogah Frankelad53fa02017-11-06 07:23:44 +01001740/* CWTP - Congetion WRED ECN TClass Profile
1741 * ----------------------------------------
1742 * Configures the profiles for queues of egress port and traffic class
1743 */
1744#define MLXSW_REG_CWTP_ID 0x2802
1745#define MLXSW_REG_CWTP_BASE_LEN 0x28
1746#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
1747#define MLXSW_REG_CWTP_LEN 0x40
1748
1749MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
1750
1751/* reg_cwtp_local_port
1752 * Local port number
1753 * Not supported for CPU port
1754 * Access: Index
1755 */
1756MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
1757
1758/* reg_cwtp_traffic_class
1759 * Traffic Class to configure
1760 * Access: Index
1761 */
1762MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
1763
1764/* reg_cwtp_profile_min
1765 * Minimum Average Queue Size of the profile in cells.
1766 * Access: RW
1767 */
1768MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
1769 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
1770
1771/* reg_cwtp_profile_percent
1772 * Percentage of WRED and ECN marking for maximum Average Queue size
1773 * Range is 0 to 100, units of integer percentage
1774 * Access: RW
1775 */
1776MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
1777 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1778
1779/* reg_cwtp_profile_max
1780 * Maximum Average Queue size of the profile in cells
1781 * Access: RW
1782 */
1783MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
1784 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1785
1786#define MLXSW_REG_CWTP_MIN_VALUE 64
1787#define MLXSW_REG_CWTP_MAX_PROFILE 2
1788#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
1789
1790static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
1791 u8 traffic_class)
1792{
1793 int i;
1794
1795 MLXSW_REG_ZERO(cwtp, payload);
1796 mlxsw_reg_cwtp_local_port_set(payload, local_port);
1797 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
1798
1799 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
1800 mlxsw_reg_cwtp_profile_min_set(payload, i,
1801 MLXSW_REG_CWTP_MIN_VALUE);
1802 mlxsw_reg_cwtp_profile_max_set(payload, i,
1803 MLXSW_REG_CWTP_MIN_VALUE);
1804 }
1805}
1806
1807#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
1808
1809static inline void
1810mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
1811 u32 probability)
1812{
1813 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
1814
1815 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
1816 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
1817 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
1818}
1819
1820/* CWTPM - Congestion WRED ECN TClass and Pool Mapping
1821 * ---------------------------------------------------
1822 * The CWTPM register maps each egress port and traffic class to profile num.
1823 */
1824#define MLXSW_REG_CWTPM_ID 0x2803
1825#define MLXSW_REG_CWTPM_LEN 0x44
1826
1827MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
1828
1829/* reg_cwtpm_local_port
1830 * Local port number
1831 * Not supported for CPU port
1832 * Access: Index
1833 */
1834MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
1835
1836/* reg_cwtpm_traffic_class
1837 * Traffic Class to configure
1838 * Access: Index
1839 */
1840MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
1841
1842/* reg_cwtpm_ew
1843 * Control enablement of WRED for traffic class:
1844 * 0 - Disable
1845 * 1 - Enable
1846 * Access: RW
1847 */
1848MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
1849
1850/* reg_cwtpm_ee
1851 * Control enablement of ECN for traffic class:
1852 * 0 - Disable
1853 * 1 - Enable
1854 * Access: RW
1855 */
1856MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
1857
1858/* reg_cwtpm_tcp_g
1859 * TCP Green Profile.
1860 * Index of the profile within {port, traffic class} to use.
1861 * 0 for disabling both WRED and ECN for this type of traffic.
1862 * Access: RW
1863 */
1864MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
1865
1866/* reg_cwtpm_tcp_y
1867 * TCP Yellow Profile.
1868 * Index of the profile within {port, traffic class} to use.
1869 * 0 for disabling both WRED and ECN for this type of traffic.
1870 * Access: RW
1871 */
1872MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
1873
1874/* reg_cwtpm_tcp_r
1875 * TCP Red Profile.
1876 * Index of the profile within {port, traffic class} to use.
1877 * 0 for disabling both WRED and ECN for this type of traffic.
1878 * Access: RW
1879 */
1880MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
1881
1882/* reg_cwtpm_ntcp_g
1883 * Non-TCP Green Profile.
1884 * Index of the profile within {port, traffic class} to use.
1885 * 0 for disabling both WRED and ECN for this type of traffic.
1886 * Access: RW
1887 */
1888MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
1889
1890/* reg_cwtpm_ntcp_y
1891 * Non-TCP Yellow Profile.
1892 * Index of the profile within {port, traffic class} to use.
1893 * 0 for disabling both WRED and ECN for this type of traffic.
1894 * Access: RW
1895 */
1896MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
1897
1898/* reg_cwtpm_ntcp_r
1899 * Non-TCP Red Profile.
1900 * Index of the profile within {port, traffic class} to use.
1901 * 0 for disabling both WRED and ECN for this type of traffic.
1902 * Access: RW
1903 */
1904MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
1905
1906#define MLXSW_REG_CWTPM_RESET_PROFILE 0
1907
1908static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
1909 u8 traffic_class, u8 profile,
1910 bool wred, bool ecn)
1911{
1912 MLXSW_REG_ZERO(cwtpm, payload);
1913 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
1914 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
1915 mlxsw_reg_cwtpm_ew_set(payload, wred);
1916 mlxsw_reg_cwtpm_ee_set(payload, ecn);
1917 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
1918 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
1919 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
1920 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
1921 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
1922 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
1923}
1924
Ido Schimmel7050f432018-07-18 11:14:40 +03001925/* PGCR - Policy-Engine General Configuration Register
1926 * ---------------------------------------------------
1927 * This register configures general Policy-Engine settings.
1928 */
1929#define MLXSW_REG_PGCR_ID 0x3001
1930#define MLXSW_REG_PGCR_LEN 0x20
1931
1932MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
1933
1934/* reg_pgcr_default_action_pointer_base
1935 * Default action pointer base. Each region has a default action pointer
1936 * which is equal to default_action_pointer_base + region_id.
1937 * Access: RW
1938 */
1939MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
1940
1941static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
1942{
1943 MLXSW_REG_ZERO(pgcr, payload);
1944 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
1945}
1946
Jiri Pirkoaf7170e2017-02-03 10:28:57 +01001947/* PPBT - Policy-Engine Port Binding Table
1948 * ---------------------------------------
1949 * This register is used for configuration of the Port Binding Table.
1950 */
1951#define MLXSW_REG_PPBT_ID 0x3002
1952#define MLXSW_REG_PPBT_LEN 0x14
1953
1954MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
1955
1956enum mlxsw_reg_pxbt_e {
1957 MLXSW_REG_PXBT_E_IACL,
1958 MLXSW_REG_PXBT_E_EACL,
1959};
1960
1961/* reg_ppbt_e
1962 * Access: Index
1963 */
1964MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
1965
1966enum mlxsw_reg_pxbt_op {
1967 MLXSW_REG_PXBT_OP_BIND,
1968 MLXSW_REG_PXBT_OP_UNBIND,
1969};
1970
1971/* reg_ppbt_op
1972 * Access: RW
1973 */
1974MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
1975
1976/* reg_ppbt_local_port
1977 * Local port. Not including CPU port.
1978 * Access: Index
1979 */
1980MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
1981
1982/* reg_ppbt_g
1983 * group - When set, the binding is of an ACL group. When cleared,
1984 * the binding is of an ACL.
1985 * Must be set to 1 for Spectrum.
1986 * Access: RW
1987 */
1988MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
1989
1990/* reg_ppbt_acl_info
1991 * ACL/ACL group identifier. If the g bit is set, this field should hold
1992 * the acl_group_id, else it should hold the acl_id.
1993 * Access: RW
1994 */
1995MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
1996
1997static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
1998 enum mlxsw_reg_pxbt_op op,
1999 u8 local_port, u16 acl_info)
2000{
2001 MLXSW_REG_ZERO(ppbt, payload);
2002 mlxsw_reg_ppbt_e_set(payload, e);
2003 mlxsw_reg_ppbt_op_set(payload, op);
2004 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2005 mlxsw_reg_ppbt_g_set(payload, true);
2006 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2007}
2008
Jiri Pirko3279da42017-02-03 10:28:53 +01002009/* PACL - Policy-Engine ACL Register
2010 * ---------------------------------
2011 * This register is used for configuration of the ACL.
2012 */
2013#define MLXSW_REG_PACL_ID 0x3004
2014#define MLXSW_REG_PACL_LEN 0x70
2015
2016MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2017
2018/* reg_pacl_v
2019 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2020 * while the ACL is bounded to either a port, VLAN or ACL rule.
2021 * Access: RW
2022 */
2023MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2024
2025/* reg_pacl_acl_id
2026 * An identifier representing the ACL (managed by software)
2027 * Range 0 .. cap_max_acl_regions - 1
2028 * Access: Index
2029 */
2030MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2031
2032#define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2033
2034/* reg_pacl_tcam_region_info
2035 * Opaque object that represents a TCAM region.
2036 * Obtained through PTAR register.
2037 * Access: RW
2038 */
2039MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2040 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2041
2042static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2043 bool valid, const char *tcam_region_info)
2044{
2045 MLXSW_REG_ZERO(pacl, payload);
2046 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2047 mlxsw_reg_pacl_v_set(payload, valid);
2048 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2049}
2050
Jiri Pirko10fabef2017-02-03 10:28:54 +01002051/* PAGT - Policy-Engine ACL Group Table
2052 * ------------------------------------
2053 * This register is used for configuration of the ACL Group Table.
2054 */
2055#define MLXSW_REG_PAGT_ID 0x3005
2056#define MLXSW_REG_PAGT_BASE_LEN 0x30
2057#define MLXSW_REG_PAGT_ACL_LEN 4
2058#define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2059#define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2060 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2061
2062MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2063
2064/* reg_pagt_size
2065 * Number of ACLs in the group.
2066 * Size 0 invalidates a group.
2067 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2068 * Total number of ACLs in all groups must be lower or equal
2069 * to cap_max_acl_tot_groups
2070 * Note: a group which is binded must not be invalidated
2071 * Access: Index
2072 */
2073MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2074
2075/* reg_pagt_acl_group_id
2076 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2077 * the ACL Group identifier (managed by software).
2078 * Access: Index
2079 */
2080MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2081
2082/* reg_pagt_acl_id
2083 * ACL identifier
2084 * Access: RW
2085 */
2086MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2087
2088static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2089{
2090 MLXSW_REG_ZERO(pagt, payload);
2091 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2092}
2093
2094static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2095 u16 acl_id)
2096{
2097 u8 size = mlxsw_reg_pagt_size_get(payload);
2098
2099 if (index >= size)
2100 mlxsw_reg_pagt_size_set(payload, index + 1);
2101 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2102}
2103
Jiri Pirkod9c26612017-02-03 10:28:55 +01002104/* PTAR - Policy-Engine TCAM Allocation Register
2105 * ---------------------------------------------
2106 * This register is used for allocation of regions in the TCAM.
2107 * Note: Query method is not supported on this register.
2108 */
2109#define MLXSW_REG_PTAR_ID 0x3006
2110#define MLXSW_REG_PTAR_BASE_LEN 0x20
2111#define MLXSW_REG_PTAR_KEY_ID_LEN 1
2112#define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2113#define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2114 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2115
2116MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2117
2118enum mlxsw_reg_ptar_op {
2119 /* allocate a TCAM region */
2120 MLXSW_REG_PTAR_OP_ALLOC,
2121 /* resize a TCAM region */
2122 MLXSW_REG_PTAR_OP_RESIZE,
2123 /* deallocate TCAM region */
2124 MLXSW_REG_PTAR_OP_FREE,
2125 /* test allocation */
2126 MLXSW_REG_PTAR_OP_TEST,
2127};
2128
2129/* reg_ptar_op
2130 * Access: OP
2131 */
2132MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2133
2134/* reg_ptar_action_set_type
2135 * Type of action set to be used on this region.
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002136 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
Jiri Pirkod9c26612017-02-03 10:28:55 +01002137 * Access: WO
2138 */
2139MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2140
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002141enum mlxsw_reg_ptar_key_type {
2142 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2143 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2144};
2145
Jiri Pirkod9c26612017-02-03 10:28:55 +01002146/* reg_ptar_key_type
2147 * TCAM key type for the region.
Jiri Pirkod9c26612017-02-03 10:28:55 +01002148 * Access: WO
2149 */
2150MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2151
2152/* reg_ptar_region_size
2153 * TCAM region size. When allocating/resizing this is the requested size,
2154 * the response is the actual size. Note that actual size may be
2155 * larger than requested.
2156 * Allowed range 1 .. cap_max_rules-1
2157 * Reserved during op deallocate.
2158 * Access: WO
2159 */
2160MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2161
2162/* reg_ptar_region_id
2163 * Region identifier
2164 * Range 0 .. cap_max_regions-1
2165 * Access: Index
2166 */
2167MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2168
2169/* reg_ptar_tcam_region_info
2170 * Opaque object that represents the TCAM region.
2171 * Returned when allocating a region.
2172 * Provided by software for ACL generation and region deallocation and resize.
2173 * Access: RW
2174 */
2175MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2176 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2177
2178/* reg_ptar_flexible_key_id
2179 * Identifier of the Flexible Key.
2180 * Only valid if key_type == "FLEX_KEY"
2181 * The key size will be rounded up to one of the following values:
2182 * 9B, 18B, 36B, 54B.
2183 * This field is reserved for in resize operation.
2184 * Access: WO
2185 */
2186MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2187 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2188
2189static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002190 enum mlxsw_reg_ptar_key_type key_type,
Jiri Pirkod9c26612017-02-03 10:28:55 +01002191 u16 region_size, u16 region_id,
2192 const char *tcam_region_info)
2193{
2194 MLXSW_REG_ZERO(ptar, payload);
2195 mlxsw_reg_ptar_op_set(payload, op);
2196 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002197 mlxsw_reg_ptar_key_type_set(payload, key_type);
Jiri Pirkod9c26612017-02-03 10:28:55 +01002198 mlxsw_reg_ptar_region_size_set(payload, region_size);
2199 mlxsw_reg_ptar_region_id_set(payload, region_id);
2200 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2201}
2202
2203static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2204 u16 key_id)
2205{
2206 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2207}
2208
2209static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2210{
2211 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2212}
2213
Jiri Pirkod1206492017-02-03 10:28:59 +01002214/* PPBS - Policy-Engine Policy Based Switching Register
2215 * ----------------------------------------------------
2216 * This register retrieves and sets Policy Based Switching Table entries.
2217 */
2218#define MLXSW_REG_PPBS_ID 0x300C
2219#define MLXSW_REG_PPBS_LEN 0x14
2220
2221MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2222
2223/* reg_ppbs_pbs_ptr
2224 * Index into the PBS table.
2225 * For Spectrum, the index points to the KVD Linear.
2226 * Access: Index
2227 */
2228MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2229
2230/* reg_ppbs_system_port
2231 * Unique port identifier for the final destination of the packet.
2232 * Access: RW
2233 */
2234MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2235
2236static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2237 u16 system_port)
2238{
2239 MLXSW_REG_ZERO(ppbs, payload);
2240 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2241 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2242}
2243
Jiri Pirko937b6822017-02-03 10:28:58 +01002244/* PRCR - Policy-Engine Rules Copy Register
2245 * ----------------------------------------
2246 * This register is used for accessing rules within a TCAM region.
2247 */
2248#define MLXSW_REG_PRCR_ID 0x300D
2249#define MLXSW_REG_PRCR_LEN 0x40
2250
2251MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2252
2253enum mlxsw_reg_prcr_op {
2254 /* Move rules. Moves the rules from "tcam_region_info" starting
2255 * at offset "offset" to "dest_tcam_region_info"
2256 * at offset "dest_offset."
2257 */
2258 MLXSW_REG_PRCR_OP_MOVE,
2259 /* Copy rules. Copies the rules from "tcam_region_info" starting
2260 * at offset "offset" to "dest_tcam_region_info"
2261 * at offset "dest_offset."
2262 */
2263 MLXSW_REG_PRCR_OP_COPY,
2264};
2265
2266/* reg_prcr_op
2267 * Access: OP
2268 */
2269MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2270
2271/* reg_prcr_offset
2272 * Offset within the source region to copy/move from.
2273 * Access: Index
2274 */
2275MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2276
2277/* reg_prcr_size
2278 * The number of rules to copy/move.
2279 * Access: WO
2280 */
2281MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2282
2283/* reg_prcr_tcam_region_info
2284 * Opaque object that represents the source TCAM region.
2285 * Access: Index
2286 */
2287MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2288 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2289
2290/* reg_prcr_dest_offset
2291 * Offset within the source region to copy/move to.
2292 * Access: Index
2293 */
2294MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2295
2296/* reg_prcr_dest_tcam_region_info
2297 * Opaque object that represents the destination TCAM region.
2298 * Access: Index
2299 */
2300MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2301 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2302
2303static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2304 const char *src_tcam_region_info,
2305 u16 src_offset,
2306 const char *dest_tcam_region_info,
2307 u16 dest_offset, u16 size)
2308{
2309 MLXSW_REG_ZERO(prcr, payload);
2310 mlxsw_reg_prcr_op_set(payload, op);
2311 mlxsw_reg_prcr_offset_set(payload, src_offset);
2312 mlxsw_reg_prcr_size_set(payload, size);
2313 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2314 src_tcam_region_info);
2315 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2316 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2317 dest_tcam_region_info);
2318}
2319
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002320/* PEFA - Policy-Engine Extended Flexible Action Register
2321 * ------------------------------------------------------
2322 * This register is used for accessing an extended flexible action entry
2323 * in the central KVD Linear Database.
2324 */
2325#define MLXSW_REG_PEFA_ID 0x300F
2326#define MLXSW_REG_PEFA_LEN 0xB0
2327
2328MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2329
2330/* reg_pefa_index
2331 * Index in the KVD Linear Centralized Database.
2332 * Access: Index
2333 */
2334MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2335
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002336/* reg_pefa_a
2337 * Index in the KVD Linear Centralized Database.
2338 * Activity
2339 * For a new entry: set if ca=0, clear if ca=1
2340 * Set if a packet lookup has hit on the specific entry
2341 * Access: RO
2342 */
2343MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2344
2345/* reg_pefa_ca
2346 * Clear activity
2347 * When write: activity is according to this field
2348 * When read: after reading the activity is cleared according to ca
2349 * Access: OP
2350 */
2351MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2352
Yotam Gigi58726562017-09-19 10:00:12 +02002353#define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002354
2355/* reg_pefa_flex_action_set
2356 * Action-set to perform when rule is matched.
2357 * Must be zero padded if action set is shorter.
2358 * Access: RW
2359 */
Yotam Gigi58726562017-09-19 10:00:12 +02002360MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002361
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002362static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002363 const char *flex_action_set)
2364{
2365 MLXSW_REG_ZERO(pefa, payload);
2366 mlxsw_reg_pefa_index_set(payload, index);
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002367 mlxsw_reg_pefa_ca_set(payload, ca);
2368 if (flex_action_set)
2369 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2370 flex_action_set);
2371}
2372
2373static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2374{
2375 *p_a = mlxsw_reg_pefa_a_get(payload);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002376}
2377
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002378/* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
2379 * -----------------------------------------------------
2380 * This register is used for accessing rules within a TCAM region.
2381 * It is a new version of PTCE in order to support wider key,
2382 * mask and action within a TCAM region. This register is not supported
2383 * by SwitchX and SwitchX-2.
2384 */
2385#define MLXSW_REG_PTCE2_ID 0x3017
2386#define MLXSW_REG_PTCE2_LEN 0x1D8
2387
2388MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2389
2390/* reg_ptce2_v
2391 * Valid.
2392 * Access: RW
2393 */
2394MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2395
2396/* reg_ptce2_a
2397 * Activity. Set if a packet lookup has hit on the specific entry.
2398 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
2399 * Access: RO
2400 */
2401MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2402
2403enum mlxsw_reg_ptce2_op {
2404 /* Read operation. */
2405 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2406 /* clear on read operation. Used to read entry
2407 * and clear Activity bit.
2408 */
2409 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2410 /* Write operation. Used to write a new entry to the table.
2411 * All R/W fields are relevant for new entry. Activity bit is set
2412 * for new entries - Note write with v = 0 will delete the entry.
2413 */
2414 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2415 /* Update action. Only action set will be updated. */
2416 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2417 /* Clear activity. A bit is cleared for the entry. */
2418 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2419};
2420
2421/* reg_ptce2_op
2422 * Access: OP
2423 */
2424MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2425
2426/* reg_ptce2_offset
2427 * Access: Index
2428 */
2429MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2430
Jiri Pirko42df8352018-07-08 23:51:24 +03002431/* reg_ptce2_priority
2432 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
2433 * Note: priority does not have to be unique per rule.
2434 * Within a region, higher priority should have lower offset (no limitation
2435 * between regions in a multi-region).
2436 * Access: RW
2437 */
2438MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2439
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002440/* reg_ptce2_tcam_region_info
2441 * Opaque object that represents the TCAM region.
2442 * Access: Index
2443 */
2444MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2445 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2446
Ido Schimmelaecefac2018-07-25 09:23:51 +03002447#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002448
2449/* reg_ptce2_flex_key_blocks
2450 * ACL Key.
2451 * Access: RW
2452 */
2453MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002454 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002455
2456/* reg_ptce2_mask
2457 * mask- in the same size as key. A bit that is set directs the TCAM
2458 * to compare the corresponding bit in key. A bit that is clear directs
2459 * the TCAM to ignore the corresponding bit in key.
2460 * Access: RW
2461 */
2462MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002463 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002464
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002465/* reg_ptce2_flex_action_set
2466 * ACL action set.
2467 * Access: RW
2468 */
2469MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
Yotam Gigi58726562017-09-19 10:00:12 +02002470 MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002471
2472static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2473 enum mlxsw_reg_ptce2_op op,
2474 const char *tcam_region_info,
Jiri Pirko42df8352018-07-08 23:51:24 +03002475 u16 offset, u32 priority)
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002476{
2477 MLXSW_REG_ZERO(ptce2, payload);
2478 mlxsw_reg_ptce2_v_set(payload, valid);
2479 mlxsw_reg_ptce2_op_set(payload, op);
2480 mlxsw_reg_ptce2_offset_set(payload, offset);
Jiri Pirko42df8352018-07-08 23:51:24 +03002481 mlxsw_reg_ptce2_priority_set(payload, priority);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002482 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2483}
2484
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03002485/* PERPT - Policy-Engine ERP Table Register
2486 * ----------------------------------------
2487 * This register adds and removes eRPs from the eRP table.
2488 */
2489#define MLXSW_REG_PERPT_ID 0x3021
2490#define MLXSW_REG_PERPT_LEN 0x80
2491
2492MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2493
2494/* reg_perpt_erpt_bank
2495 * eRP table bank.
2496 * Range 0 .. cap_max_erp_table_banks - 1
2497 * Access: Index
2498 */
2499MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2500
2501/* reg_perpt_erpt_index
2502 * Index to eRP table within the eRP bank.
2503 * Range is 0 .. cap_max_erp_table_bank_size - 1
2504 * Access: Index
2505 */
2506MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2507
2508enum mlxsw_reg_perpt_key_size {
2509 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2510 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2511 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2512 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2513};
2514
2515/* reg_perpt_key_size
2516 * Access: OP
2517 */
2518MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2519
2520/* reg_perpt_bf_bypass
2521 * 0 - The eRP is used only if bloom filter state is set for the given
2522 * rule.
2523 * 1 - The eRP is used regardless of bloom filter state.
2524 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
2525 * Access: RW
2526 */
2527MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2528
2529/* reg_perpt_erp_id
2530 * eRP ID for use by the rules.
2531 * Access: RW
2532 */
2533MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2534
2535/* reg_perpt_erpt_base_bank
2536 * Base eRP table bank, points to head of erp_vector
2537 * Range is 0 .. cap_max_erp_table_banks - 1
2538 * Access: OP
2539 */
2540MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2541
2542/* reg_perpt_erpt_base_index
2543 * Base index to eRP table within the eRP bank
2544 * Range is 0 .. cap_max_erp_table_bank_size - 1
2545 * Access: OP
2546 */
2547MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2548
2549/* reg_perpt_erp_index_in_vector
2550 * eRP index in the vector.
2551 * Access: OP
2552 */
2553MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2554
2555/* reg_perpt_erp_vector
2556 * eRP vector.
2557 * Access: OP
2558 */
2559MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2560
2561/* reg_perpt_mask
2562 * Mask
2563 * 0 - A-TCAM will ignore the bit in key
2564 * 1 - A-TCAM will compare the bit in key
2565 * Access: RW
2566 */
2567MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2568
2569static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
2570 unsigned long *erp_vector,
2571 unsigned long size)
2572{
2573 unsigned long bit;
2574
2575 for_each_set_bit(bit, erp_vector, size)
2576 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
2577}
2578
2579static inline void
2580mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
2581 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
2582 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
2583 char *mask)
2584{
2585 MLXSW_REG_ZERO(perpt, payload);
2586 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
2587 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
2588 mlxsw_reg_perpt_key_size_set(payload, key_size);
2589 mlxsw_reg_perpt_bf_bypass_set(payload, true);
2590 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
2591 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
2592 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
2593 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
2594 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
2595}
2596
Jiri Pirko33907872018-07-18 11:14:37 +03002597/* PERAR - Policy-Engine Region Association Register
2598 * -------------------------------------------------
2599 * This register associates a hw region for region_id's. Changing on the fly
2600 * is supported by the device.
2601 */
2602#define MLXSW_REG_PERAR_ID 0x3026
2603#define MLXSW_REG_PERAR_LEN 0x08
2604
2605MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
2606
2607/* reg_perar_region_id
2608 * Region identifier
2609 * Range 0 .. cap_max_regions-1
2610 * Access: Index
2611 */
2612MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
2613
2614static inline unsigned int
2615mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
2616{
2617 return DIV_ROUND_UP(block_num, 4);
2618}
2619
2620/* reg_perar_hw_region
2621 * HW Region
2622 * Range 0 .. cap_max_regions-1
2623 * Default: hw_region = region_id
2624 * For a 8 key block region, 2 consecutive regions are used
2625 * For a 12 key block region, 3 consecutive regions are used
2626 * Access: RW
2627 */
2628MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
2629
2630static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
2631 u16 hw_region)
2632{
2633 MLXSW_REG_ZERO(perar, payload);
2634 mlxsw_reg_perar_region_id_set(payload, region_id);
2635 mlxsw_reg_perar_hw_region_set(payload, hw_region);
2636}
2637
Ido Schimmelaecefac2018-07-25 09:23:51 +03002638/* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
2639 * -----------------------------------------------------
2640 * This register is a new version of PTCE-V2 in order to support the
2641 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
2642 */
2643#define MLXSW_REG_PTCE3_ID 0x3027
2644#define MLXSW_REG_PTCE3_LEN 0xF0
2645
2646MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
2647
2648/* reg_ptce3_v
2649 * Valid.
2650 * Access: RW
2651 */
2652MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
2653
2654enum mlxsw_reg_ptce3_op {
2655 /* Write operation. Used to write a new entry to the table.
2656 * All R/W fields are relevant for new entry. Activity bit is set
2657 * for new entries. Write with v = 0 will delete the entry. Must
2658 * not be used if an entry exists.
2659 */
2660 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
2661 /* Update operation */
2662 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
2663 /* Read operation */
2664 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
2665};
2666
2667/* reg_ptce3_op
2668 * Access: OP
2669 */
2670MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
2671
2672/* reg_ptce3_priority
2673 * Priority of the rule. Higher values win.
2674 * For Spectrum-2 range is 1..cap_kvd_size - 1
2675 * Note: Priority does not have to be unique per rule.
2676 * Access: RW
2677 */
2678MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
2679
2680/* reg_ptce3_tcam_region_info
2681 * Opaque object that represents the TCAM region.
2682 * Access: Index
2683 */
2684MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
2685 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2686
2687/* reg_ptce3_flex2_key_blocks
2688 * ACL key. The key must be masked according to eRP (if exists) or
2689 * according to master mask.
2690 * Access: Index
2691 */
2692MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
2693 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2694
2695/* reg_ptce3_erp_id
2696 * eRP ID.
2697 * Access: Index
2698 */
2699MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
2700
2701/* reg_ptce3_delta_start
2702 * Start point of delta_value and delta_mask, in bits. Must not exceed
2703 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
2704 * Access: Index
2705 */
2706MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
2707
2708/* reg_ptce3_delta_mask
2709 * Delta mask.
2710 * 0 - Ignore relevant bit in delta_value
2711 * 1 - Compare relevant bit in delta_value
2712 * Delta mask must not be set for reserved fields in the key blocks.
2713 * Note: No delta when no eRPs. Thus, for regions with
2714 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
2715 * Access: Index
2716 */
2717MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
2718
2719/* reg_ptce3_delta_value
2720 * Delta value.
2721 * Bits which are masked by delta_mask must be 0.
2722 * Access: Index
2723 */
2724MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
2725
2726/* reg_ptce3_prune_vector
2727 * Pruning vector relative to the PERPT.erp_id.
2728 * Used for reducing lookups.
2729 * 0 - NEED: Do a lookup using the eRP.
2730 * 1 - PRUNE: Do not perform a lookup using the eRP.
2731 * Maybe be modified by PEAPBL and PEAPBM.
2732 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
2733 * all 1's or all 0's.
2734 * Access: RW
2735 */
2736MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
2737
2738/* reg_ptce3_prune_ctcam
2739 * Pruning on C-TCAM. Used for reducing lookups.
2740 * 0 - NEED: Do a lookup in the C-TCAM.
2741 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
2742 * Access: RW
2743 */
2744MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
2745
2746/* reg_ptce3_large_exists
2747 * Large entry key ID exists.
2748 * Within the region:
2749 * 0 - SINGLE: The large_entry_key_id is not currently in use.
2750 * For rule insert: The MSB of the key (blocks 6..11) will be added.
2751 * For rule delete: The MSB of the key will be removed.
2752 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
2753 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
2754 * For rule delete: The MSB of the key will not be removed.
2755 * Access: WO
2756 */
2757MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
2758
2759/* reg_ptce3_large_entry_key_id
2760 * Large entry key ID.
2761 * A key for 12 key blocks rules. Reserved when region has less than 12 key
2762 * blocks. Must be different for different keys which have the same common
2763 * 6 key blocks (MSB, blocks 6..11) key within a region.
2764 * Range is 0..cap_max_pe_large_key_id - 1
2765 * Access: RW
2766 */
2767MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
2768
2769/* reg_ptce3_action_pointer
2770 * Pointer to action.
2771 * Range is 0..cap_max_kvd_action_sets - 1
2772 * Access: RW
2773 */
2774MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
2775
2776static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
2777 enum mlxsw_reg_ptce3_op op,
2778 u32 priority,
2779 const char *tcam_region_info,
2780 const char *key, u8 erp_id,
2781 bool large_exists, u32 lkey_id,
2782 u32 action_pointer)
2783{
2784 MLXSW_REG_ZERO(ptce3, payload);
2785 mlxsw_reg_ptce3_v_set(payload, valid);
2786 mlxsw_reg_ptce3_op_set(payload, op);
2787 mlxsw_reg_ptce3_priority_set(payload, priority);
2788 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
2789 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
2790 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
2791 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
2792 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
2793 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
2794}
2795
Ido Schimmel481662a2018-07-18 11:14:38 +03002796/* PERCR - Policy-Engine Region Configuration Register
2797 * ---------------------------------------------------
2798 * This register configures the region parameters. The region_id must be
2799 * allocated.
2800 */
2801#define MLXSW_REG_PERCR_ID 0x302A
2802#define MLXSW_REG_PERCR_LEN 0x80
2803
2804MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
2805
2806/* reg_percr_region_id
2807 * Region identifier.
2808 * Range 0..cap_max_regions-1
2809 * Access: Index
2810 */
2811MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
2812
2813/* reg_percr_atcam_ignore_prune
2814 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
2815 * Access: RW
2816 */
2817MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
2818
2819/* reg_percr_ctcam_ignore_prune
2820 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
2821 * Access: RW
2822 */
2823MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
2824
2825/* reg_percr_bf_bypass
2826 * Bloom filter bypass.
2827 * 0 - Bloom filter is used (default)
2828 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
2829 * region_id or eRP. See PERPT.bf_bypass
2830 * Access: RW
2831 */
2832MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
2833
2834/* reg_percr_master_mask
2835 * Master mask. Logical OR mask of all masks of all rules of a region
2836 * (both A-TCAM and C-TCAM). When there are no eRPs
2837 * (erpt_pointer_valid = 0), then this provides the mask.
2838 * Access: RW
2839 */
2840MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
2841
2842static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
2843{
2844 MLXSW_REG_ZERO(percr, payload);
2845 mlxsw_reg_percr_region_id_set(payload, region_id);
2846 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
2847 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
2848 mlxsw_reg_percr_bf_bypass_set(payload, true);
Ido Schimmel481662a2018-07-18 11:14:38 +03002849}
2850
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03002851/* PERERP - Policy-Engine Region eRP Register
2852 * ------------------------------------------
2853 * This register configures the region eRP. The region_id must be
2854 * allocated.
2855 */
2856#define MLXSW_REG_PERERP_ID 0x302B
2857#define MLXSW_REG_PERERP_LEN 0x1C
2858
2859MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
2860
2861/* reg_pererp_region_id
2862 * Region identifier.
2863 * Range 0..cap_max_regions-1
2864 * Access: Index
2865 */
2866MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
2867
2868/* reg_pererp_ctcam_le
2869 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
2870 * Access: RW
2871 */
2872MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
2873
2874/* reg_pererp_erpt_pointer_valid
2875 * erpt_pointer is valid.
2876 * Access: RW
2877 */
2878MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
2879
2880/* reg_pererp_erpt_bank_pointer
2881 * Pointer to eRP table bank. May be modified at any time.
2882 * Range 0..cap_max_erp_table_banks-1
2883 * Reserved when erpt_pointer_valid = 0
2884 */
2885MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
2886
2887/* reg_pererp_erpt_pointer
2888 * Pointer to eRP table within the eRP bank. Can be changed for an
2889 * existing region.
2890 * Range 0..cap_max_erp_table_size-1
2891 * Reserved when erpt_pointer_valid = 0
2892 * Access: RW
2893 */
2894MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
2895
2896/* reg_pererp_erpt_vector
2897 * Vector of allowed eRP indexes starting from erpt_pointer within the
2898 * erpt_bank_pointer. Next entries will be in next bank.
2899 * Note that eRP index is used and not eRP ID.
2900 * Reserved when erpt_pointer_valid = 0
2901 * Access: RW
2902 */
2903MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
2904
2905/* reg_pererp_master_rp_id
2906 * Master RP ID. When there are no eRPs, then this provides the eRP ID
2907 * for the lookup. Can be changed for an existing region.
2908 * Reserved when erpt_pointer_valid = 1
2909 * Access: RW
2910 */
2911MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
2912
Ido Schimmel91329e22018-07-25 09:23:50 +03002913static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
2914 unsigned long *erp_vector,
2915 unsigned long size)
2916{
2917 unsigned long bit;
2918
2919 for_each_set_bit(bit, erp_vector, size)
2920 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
2921}
2922
2923static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
2924 bool ctcam_le, bool erpt_pointer_valid,
2925 u8 erpt_bank_pointer, u8 erpt_pointer,
2926 u8 master_rp_id)
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03002927{
2928 MLXSW_REG_ZERO(pererp, payload);
2929 mlxsw_reg_pererp_region_id_set(payload, region_id);
Ido Schimmel91329e22018-07-25 09:23:50 +03002930 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
2931 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
2932 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
2933 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
2934 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03002935}
2936
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03002937/* IEDR - Infrastructure Entry Delete Register
2938 * ----------------------------------------------------
2939 * This register is used for deleting entries from the entry tables.
2940 * It is legitimate to attempt to delete a nonexisting entry (the device will
2941 * respond as a good flow).
2942 */
2943#define MLXSW_REG_IEDR_ID 0x3804
2944#define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
2945#define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
2946#define MLXSW_REG_IEDR_REC_MAX_COUNT 64
2947#define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
2948 MLXSW_REG_IEDR_REC_LEN * \
2949 MLXSW_REG_IEDR_REC_MAX_COUNT)
2950
2951MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
2952
2953/* reg_iedr_num_rec
2954 * Number of records.
2955 * Access: OP
2956 */
2957MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
2958
2959/* reg_iedr_rec_type
2960 * Resource type.
2961 * Access: OP
2962 */
2963MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
2964 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
2965
2966/* reg_iedr_rec_size
2967 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
2968 * Access: OP
2969 */
2970MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 11,
2971 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
2972
2973/* reg_iedr_rec_index_start
2974 * Resource index start.
2975 * Access: OP
2976 */
2977MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
2978 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
2979
2980static inline void mlxsw_reg_iedr_pack(char *payload)
2981{
2982 MLXSW_REG_ZERO(iedr, payload);
2983}
2984
2985static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
2986 u8 rec_type, u16 rec_size,
2987 u32 rec_index_start)
2988{
2989 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
2990
2991 if (rec_index >= num_rec)
2992 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
2993 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
2994 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
2995 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
2996}
2997
Petr Machata746da422018-07-27 15:26:58 +03002998/* QPTS - QoS Priority Trust State Register
2999 * ----------------------------------------
3000 * This register controls the port policy to calculate the switch priority and
3001 * packet color based on incoming packet fields.
3002 */
3003#define MLXSW_REG_QPTS_ID 0x4002
3004#define MLXSW_REG_QPTS_LEN 0x8
3005
3006MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3007
3008/* reg_qpts_local_port
3009 * Local port number.
3010 * Access: Index
3011 *
3012 * Note: CPU port is supported.
3013 */
3014MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
3015
3016enum mlxsw_reg_qpts_trust_state {
3017 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3018 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3019};
3020
3021/* reg_qpts_trust_state
3022 * Trust state for a given port.
3023 * Access: RW
3024 */
3025MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3026
3027static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
3028 enum mlxsw_reg_qpts_trust_state ts)
3029{
3030 MLXSW_REG_ZERO(qpts, payload);
3031
3032 mlxsw_reg_qpts_local_port_set(payload, local_port);
3033 mlxsw_reg_qpts_trust_state_set(payload, ts);
3034}
3035
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003036/* QPCR - QoS Policer Configuration Register
3037 * -----------------------------------------
3038 * The QPCR register is used to create policers - that limit
3039 * the rate of bytes or packets via some trap group.
3040 */
3041#define MLXSW_REG_QPCR_ID 0x4004
3042#define MLXSW_REG_QPCR_LEN 0x28
3043
3044MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3045
3046enum mlxsw_reg_qpcr_g {
3047 MLXSW_REG_QPCR_G_GLOBAL = 2,
3048 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3049};
3050
3051/* reg_qpcr_g
3052 * The policer type.
3053 * Access: Index
3054 */
3055MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3056
3057/* reg_qpcr_pid
3058 * Policer ID.
3059 * Access: Index
3060 */
3061MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3062
3063/* reg_qpcr_color_aware
3064 * Is the policer aware of colors.
3065 * Must be 0 (unaware) for cpu port.
3066 * Access: RW for unbounded policer. RO for bounded policer.
3067 */
3068MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3069
3070/* reg_qpcr_bytes
3071 * Is policer limit is for bytes per sec or packets per sec.
3072 * 0 - packets
3073 * 1 - bytes
3074 * Access: RW for unbounded policer. RO for bounded policer.
3075 */
3076MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3077
3078enum mlxsw_reg_qpcr_ir_units {
3079 MLXSW_REG_QPCR_IR_UNITS_M,
3080 MLXSW_REG_QPCR_IR_UNITS_K,
3081};
3082
3083/* reg_qpcr_ir_units
3084 * Policer's units for cir and eir fields (for bytes limits only)
3085 * 1 - 10^3
3086 * 0 - 10^6
3087 * Access: OP
3088 */
3089MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3090
3091enum mlxsw_reg_qpcr_rate_type {
3092 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3093 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3094};
3095
3096/* reg_qpcr_rate_type
3097 * Policer can have one limit (single rate) or 2 limits with specific operation
3098 * for packets that exceed the lower rate but not the upper one.
3099 * (For cpu port must be single rate)
3100 * Access: RW for unbounded policer. RO for bounded policer.
3101 */
3102MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3103
3104/* reg_qpc_cbs
3105 * Policer's committed burst size.
3106 * The policer is working with time slices of 50 nano sec. By default every
3107 * slice is granted the proportionate share of the committed rate. If we want to
3108 * allow a slice to exceed that share (while still keeping the rate per sec) we
3109 * can allow burst. The burst size is between the default proportionate share
3110 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3111 * committed rate will result in exceeding the rate). The burst size must be a
3112 * log of 2 and will be determined by 2^cbs.
3113 * Access: RW
3114 */
3115MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3116
3117/* reg_qpcr_cir
3118 * Policer's committed rate.
3119 * The rate used for sungle rate, the lower rate for double rate.
3120 * For bytes limits, the rate will be this value * the unit from ir_units.
3121 * (Resolution error is up to 1%).
3122 * Access: RW
3123 */
3124MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3125
3126/* reg_qpcr_eir
3127 * Policer's exceed rate.
3128 * The higher rate for double rate, reserved for single rate.
3129 * Lower rate for double rate policer.
3130 * For bytes limits, the rate will be this value * the unit from ir_units.
3131 * (Resolution error is up to 1%).
3132 * Access: RW
3133 */
3134MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3135
3136#define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3137
3138/* reg_qpcr_exceed_action.
3139 * What to do with packets between the 2 limits for double rate.
3140 * Access: RW for unbounded policer. RO for bounded policer.
3141 */
3142MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3143
3144enum mlxsw_reg_qpcr_action {
3145 /* Discard */
3146 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3147 /* Forward and set color to red.
3148 * If the packet is intended to cpu port, it will be dropped.
3149 */
3150 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3151};
3152
3153/* reg_qpcr_violate_action
3154 * What to do with packets that cross the cir limit (for single rate) or the eir
3155 * limit (for double rate).
3156 * Access: RW for unbounded policer. RO for bounded policer.
3157 */
3158MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3159
3160static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3161 enum mlxsw_reg_qpcr_ir_units ir_units,
3162 bool bytes, u32 cir, u16 cbs)
3163{
3164 MLXSW_REG_ZERO(qpcr, payload);
3165 mlxsw_reg_qpcr_pid_set(payload, pid);
3166 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3167 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3168 mlxsw_reg_qpcr_violate_action_set(payload,
3169 MLXSW_REG_QPCR_ACTION_DISCARD);
3170 mlxsw_reg_qpcr_cir_set(payload, cir);
3171 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3172 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3173 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3174}
3175
Ido Schimmel2c63a552016-04-06 17:10:07 +02003176/* QTCT - QoS Switch Traffic Class Table
3177 * -------------------------------------
3178 * Configures the mapping between the packet switch priority and the
3179 * traffic class on the transmit port.
3180 */
3181#define MLXSW_REG_QTCT_ID 0x400A
3182#define MLXSW_REG_QTCT_LEN 0x08
3183
Jiri Pirko21978dc2016-10-21 16:07:20 +02003184MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
Ido Schimmel2c63a552016-04-06 17:10:07 +02003185
3186/* reg_qtct_local_port
3187 * Local port number.
3188 * Access: Index
3189 *
3190 * Note: CPU port is not supported.
3191 */
3192MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
3193
3194/* reg_qtct_sub_port
3195 * Virtual port within the physical port.
3196 * Should be set to 0 when virtual ports are not enabled on the port.
3197 * Access: Index
3198 */
3199MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3200
3201/* reg_qtct_switch_prio
3202 * Switch priority.
3203 * Access: Index
3204 */
3205MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3206
3207/* reg_qtct_tclass
3208 * Traffic class.
3209 * Default values:
3210 * switch_prio 0 : tclass 1
3211 * switch_prio 1 : tclass 0
3212 * switch_prio i : tclass i, for i > 1
3213 * Access: RW
3214 */
3215MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3216
3217static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3218 u8 switch_prio, u8 tclass)
3219{
3220 MLXSW_REG_ZERO(qtct, payload);
3221 mlxsw_reg_qtct_local_port_set(payload, local_port);
3222 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3223 mlxsw_reg_qtct_tclass_set(payload, tclass);
3224}
3225
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003226/* QEEC - QoS ETS Element Configuration Register
3227 * ---------------------------------------------
3228 * Configures the ETS elements.
3229 */
3230#define MLXSW_REG_QEEC_ID 0x400D
3231#define MLXSW_REG_QEEC_LEN 0x1C
3232
Jiri Pirko21978dc2016-10-21 16:07:20 +02003233MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003234
3235/* reg_qeec_local_port
3236 * Local port number.
3237 * Access: Index
3238 *
3239 * Note: CPU port is supported.
3240 */
3241MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
3242
3243enum mlxsw_reg_qeec_hr {
3244 MLXSW_REG_QEEC_HIERARCY_PORT,
3245 MLXSW_REG_QEEC_HIERARCY_GROUP,
3246 MLXSW_REG_QEEC_HIERARCY_SUBGROUP,
3247 MLXSW_REG_QEEC_HIERARCY_TC,
3248};
3249
3250/* reg_qeec_element_hierarchy
3251 * 0 - Port
3252 * 1 - Group
3253 * 2 - Subgroup
3254 * 3 - Traffic Class
3255 * Access: Index
3256 */
3257MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3258
3259/* reg_qeec_element_index
3260 * The index of the element in the hierarchy.
3261 * Access: Index
3262 */
3263MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3264
3265/* reg_qeec_next_element_index
3266 * The index of the next (lower) element in the hierarchy.
3267 * Access: RW
3268 *
3269 * Note: Reserved for element_hierarchy 0.
3270 */
3271MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3272
3273enum {
3274 MLXSW_REG_QEEC_BYTES_MODE,
3275 MLXSW_REG_QEEC_PACKETS_MODE,
3276};
3277
3278/* reg_qeec_pb
3279 * Packets or bytes mode.
3280 * 0 - Bytes mode
3281 * 1 - Packets mode
3282 * Access: RW
3283 *
3284 * Note: Used for max shaper configuration. For Spectrum, packets mode
3285 * is supported only for traffic classes of CPU port.
3286 */
3287MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3288
3289/* reg_qeec_mase
3290 * Max shaper configuration enable. Enables configuration of the max
3291 * shaper on this ETS element.
3292 * 0 - Disable
3293 * 1 - Enable
3294 * Access: RW
3295 */
3296MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3297
3298/* A large max rate will disable the max shaper. */
3299#define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */
3300
3301/* reg_qeec_max_shaper_rate
3302 * Max shaper information rate.
3303 * For CPU port, can only be configured for port hierarchy.
3304 * When in bytes mode, value is specified in units of 1000bps.
3305 * Access: RW
3306 */
3307MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
3308
3309/* reg_qeec_de
3310 * DWRR configuration enable. Enables configuration of the dwrr and
3311 * dwrr_weight.
3312 * 0 - Disable
3313 * 1 - Enable
3314 * Access: RW
3315 */
3316MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3317
3318/* reg_qeec_dwrr
3319 * Transmission selection algorithm to use on the link going down from
3320 * the ETS element.
3321 * 0 - Strict priority
3322 * 1 - DWRR
3323 * Access: RW
3324 */
3325MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3326
3327/* reg_qeec_dwrr_weight
3328 * DWRR weight on the link going down from the ETS element. The
3329 * percentage of bandwidth guaranteed to an ETS element within
3330 * its hierarchy. The sum of all weights across all ETS elements
3331 * within one hierarchy should be equal to 100. Reserved when
3332 * transmission selection algorithm is strict priority.
3333 * Access: RW
3334 */
3335MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3336
3337static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
3338 enum mlxsw_reg_qeec_hr hr, u8 index,
3339 u8 next_index)
3340{
3341 MLXSW_REG_ZERO(qeec, payload);
3342 mlxsw_reg_qeec_local_port_set(payload, local_port);
3343 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3344 mlxsw_reg_qeec_element_index_set(payload, index);
3345 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3346}
3347
Petr Machatae67131d2018-07-27 15:26:59 +03003348/* QRWE - QoS ReWrite Enable
3349 * -------------------------
3350 * This register configures the rewrite enable per receive port.
3351 */
3352#define MLXSW_REG_QRWE_ID 0x400F
3353#define MLXSW_REG_QRWE_LEN 0x08
3354
3355MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3356
3357/* reg_qrwe_local_port
3358 * Local port number.
3359 * Access: Index
3360 *
3361 * Note: CPU port is supported. No support for router port.
3362 */
3363MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
3364
3365/* reg_qrwe_dscp
3366 * Whether to enable DSCP rewrite (default is 0, don't rewrite).
3367 * Access: RW
3368 */
3369MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3370
3371/* reg_qrwe_pcp
3372 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
3373 * Access: RW
3374 */
3375MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3376
3377static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
3378 bool rewrite_pcp, bool rewrite_dscp)
3379{
3380 MLXSW_REG_ZERO(qrwe, payload);
3381 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3382 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3383 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3384}
3385
Petr Machata55fb71f2018-07-27 15:27:00 +03003386/* QPDSM - QoS Priority to DSCP Mapping
3387 * ------------------------------------
3388 * QoS Priority to DSCP Mapping Register
3389 */
3390#define MLXSW_REG_QPDSM_ID 0x4011
3391#define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
3392#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
3393#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3394#define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3395 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3396 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3397
3398MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3399
3400/* reg_qpdsm_local_port
3401 * Local Port. Supported for data packets from CPU port.
3402 * Access: Index
3403 */
3404MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
3405
3406/* reg_qpdsm_prio_entry_color0_e
3407 * Enable update of the entry for color 0 and a given port.
3408 * Access: WO
3409 */
3410MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
3411 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
3412 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3413
3414/* reg_qpdsm_prio_entry_color0_dscp
3415 * DSCP field in the outer label of the packet for color 0 and a given port.
3416 * Reserved when e=0.
3417 * Access: RW
3418 */
3419MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
3420 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
3421 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3422
3423/* reg_qpdsm_prio_entry_color1_e
3424 * Enable update of the entry for color 1 and a given port.
3425 * Access: WO
3426 */
3427MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
3428 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
3429 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3430
3431/* reg_qpdsm_prio_entry_color1_dscp
3432 * DSCP field in the outer label of the packet for color 1 and a given port.
3433 * Reserved when e=0.
3434 * Access: RW
3435 */
3436MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
3437 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
3438 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3439
3440/* reg_qpdsm_prio_entry_color2_e
3441 * Enable update of the entry for color 2 and a given port.
3442 * Access: WO
3443 */
3444MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
3445 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
3446 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3447
3448/* reg_qpdsm_prio_entry_color2_dscp
3449 * DSCP field in the outer label of the packet for color 2 and a given port.
3450 * Reserved when e=0.
3451 * Access: RW
3452 */
3453MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
3454 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
3455 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3456
3457static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
3458{
3459 MLXSW_REG_ZERO(qpdsm, payload);
3460 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
3461}
3462
3463static inline void
3464mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
3465{
3466 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
3467 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
3468 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
3469 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
3470 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
3471 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
3472}
3473
Petr Machata02837d72018-07-27 15:26:57 +03003474/* QPDPM - QoS Port DSCP to Priority Mapping Register
3475 * --------------------------------------------------
3476 * This register controls the mapping from DSCP field to
3477 * Switch Priority for IP packets.
3478 */
3479#define MLXSW_REG_QPDPM_ID 0x4013
3480#define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
3481#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
3482#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
3483#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
3484 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
3485 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
3486
3487MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
3488
3489/* reg_qpdpm_local_port
3490 * Local Port. Supported for data packets from CPU port.
3491 * Access: Index
3492 */
3493MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
3494
3495/* reg_qpdpm_dscp_e
3496 * Enable update of the specific entry. When cleared, the switch_prio and color
3497 * fields are ignored and the previous switch_prio and color values are
3498 * preserved.
3499 * Access: WO
3500 */
3501MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
3502 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3503
3504/* reg_qpdpm_dscp_prio
3505 * The new Switch Priority value for the relevant DSCP value.
3506 * Access: RW
3507 */
3508MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
3509 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
3510 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3511
3512static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
3513{
3514 MLXSW_REG_ZERO(qpdpm, payload);
3515 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
3516}
3517
3518static inline void
3519mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
3520{
3521 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
3522 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
3523}
3524
Petr Machata671ae8a2018-08-05 09:03:06 +03003525/* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
3526 * ------------------------------------------------------------------
3527 * This register configures if the Switch Priority to Traffic Class mapping is
3528 * based on Multicast packet indication. If so, then multicast packets will get
3529 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
3530 * QTCT.
3531 * By default, Switch Priority to Traffic Class mapping is not based on
3532 * Multicast packet indication.
3533 */
3534#define MLXSW_REG_QTCTM_ID 0x401A
3535#define MLXSW_REG_QTCTM_LEN 0x08
3536
3537MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
3538
3539/* reg_qtctm_local_port
3540 * Local port number.
3541 * No support for CPU port.
3542 * Access: Index
3543 */
3544MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
3545
3546/* reg_qtctm_mc
3547 * Multicast Mode
3548 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
3549 * indication (default is 0, not based on Multicast packet indication).
3550 */
3551MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
3552
3553static inline void
3554mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
3555{
3556 MLXSW_REG_ZERO(qtctm, payload);
3557 mlxsw_reg_qtctm_local_port_set(payload, local_port);
3558 mlxsw_reg_qtctm_mc_set(payload, mc);
3559}
3560
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003561/* PMLP - Ports Module to Local Port Register
3562 * ------------------------------------------
3563 * Configures the assignment of modules to local ports.
3564 */
3565#define MLXSW_REG_PMLP_ID 0x5002
3566#define MLXSW_REG_PMLP_LEN 0x40
3567
Jiri Pirko21978dc2016-10-21 16:07:20 +02003568MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003569
3570/* reg_pmlp_rxtx
3571 * 0 - Tx value is used for both Tx and Rx.
3572 * 1 - Rx value is taken from a separte field.
3573 * Access: RW
3574 */
3575MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
3576
3577/* reg_pmlp_local_port
3578 * Local port number.
3579 * Access: Index
3580 */
3581MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
3582
3583/* reg_pmlp_width
3584 * 0 - Unmap local port.
3585 * 1 - Lane 0 is used.
3586 * 2 - Lanes 0 and 1 are used.
3587 * 4 - Lanes 0, 1, 2 and 3 are used.
3588 * Access: RW
3589 */
3590MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
3591
3592/* reg_pmlp_module
3593 * Module number.
3594 * Access: RW
3595 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01003596MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003597
3598/* reg_pmlp_tx_lane
3599 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
3600 * Access: RW
3601 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01003602MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003603
3604/* reg_pmlp_rx_lane
3605 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
3606 * equal to Tx lane.
3607 * Access: RW
3608 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01003609MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003610
3611static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
3612{
3613 MLXSW_REG_ZERO(pmlp, payload);
3614 mlxsw_reg_pmlp_local_port_set(payload, local_port);
3615}
3616
3617/* PMTU - Port MTU Register
3618 * ------------------------
3619 * Configures and reports the port MTU.
3620 */
3621#define MLXSW_REG_PMTU_ID 0x5003
3622#define MLXSW_REG_PMTU_LEN 0x10
3623
Jiri Pirko21978dc2016-10-21 16:07:20 +02003624MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003625
3626/* reg_pmtu_local_port
3627 * Local port number.
3628 * Access: Index
3629 */
3630MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
3631
3632/* reg_pmtu_max_mtu
3633 * Maximum MTU.
3634 * When port type (e.g. Ethernet) is configured, the relevant MTU is
3635 * reported, otherwise the minimum between the max_mtu of the different
3636 * types is reported.
3637 * Access: RO
3638 */
3639MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
3640
3641/* reg_pmtu_admin_mtu
3642 * MTU value to set port to. Must be smaller or equal to max_mtu.
3643 * Note: If port type is Infiniband, then port must be disabled, when its
3644 * MTU is set.
3645 * Access: RW
3646 */
3647MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
3648
3649/* reg_pmtu_oper_mtu
3650 * The actual MTU configured on the port. Packets exceeding this size
3651 * will be dropped.
3652 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
3653 * oper_mtu might be smaller than admin_mtu.
3654 * Access: RO
3655 */
3656MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
3657
3658static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
3659 u16 new_mtu)
3660{
3661 MLXSW_REG_ZERO(pmtu, payload);
3662 mlxsw_reg_pmtu_local_port_set(payload, local_port);
3663 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
3664 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
3665 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
3666}
3667
3668/* PTYS - Port Type and Speed Register
3669 * -----------------------------------
3670 * Configures and reports the port speed type.
3671 *
3672 * Note: When set while the link is up, the changes will not take effect
3673 * until the port transitions from down to up state.
3674 */
3675#define MLXSW_REG_PTYS_ID 0x5004
3676#define MLXSW_REG_PTYS_LEN 0x40
3677
Jiri Pirko21978dc2016-10-21 16:07:20 +02003678MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003679
Tal Bar8e1ed732018-03-21 09:34:06 +02003680/* an_disable_admin
3681 * Auto negotiation disable administrative configuration
3682 * 0 - Device doesn't support AN disable.
3683 * 1 - Device supports AN disable.
3684 * Access: RW
3685 */
3686MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
3687
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003688/* reg_ptys_local_port
3689 * Local port number.
3690 * Access: Index
3691 */
3692MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
3693
Elad Raz79417702016-10-28 21:35:53 +02003694#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003695#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
3696
3697/* reg_ptys_proto_mask
3698 * Protocol mask. Indicates which protocol is used.
3699 * 0 - Infiniband.
3700 * 1 - Fibre Channel.
3701 * 2 - Ethernet.
3702 * Access: Index
3703 */
3704MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
3705
Ido Schimmel4149b972016-09-12 13:26:24 +02003706enum {
3707 MLXSW_REG_PTYS_AN_STATUS_NA,
3708 MLXSW_REG_PTYS_AN_STATUS_OK,
3709 MLXSW_REG_PTYS_AN_STATUS_FAIL,
3710};
3711
3712/* reg_ptys_an_status
3713 * Autonegotiation status.
3714 * Access: RO
3715 */
3716MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
3717
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003718#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
3719#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
3720#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
3721#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
3722#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
3723#define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
3724#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
3725#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
3726#define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
3727#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
3728#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
3729#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
3730#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
3731#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
Ido Schimmelb9d66a32016-09-12 13:26:27 +02003732#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003733#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
3734#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
3735#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
3736#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
3737#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
3738#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
3739#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
3740#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
3741#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
3742#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
3743#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
3744#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
3745#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
3746
3747/* reg_ptys_eth_proto_cap
3748 * Ethernet port supported speeds and protocols.
3749 * Access: RO
3750 */
3751MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
3752
Elad Raz79417702016-10-28 21:35:53 +02003753/* reg_ptys_ib_link_width_cap
3754 * IB port supported widths.
3755 * Access: RO
3756 */
3757MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
3758
3759#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
3760#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
3761#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
3762#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
3763#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
3764#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
3765
3766/* reg_ptys_ib_proto_cap
3767 * IB port supported speeds and protocols.
3768 * Access: RO
3769 */
3770MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
3771
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003772/* reg_ptys_eth_proto_admin
3773 * Speed and protocol to set port to.
3774 * Access: RW
3775 */
3776MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
3777
Elad Raz79417702016-10-28 21:35:53 +02003778/* reg_ptys_ib_link_width_admin
3779 * IB width to set port to.
3780 * Access: RW
3781 */
3782MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
3783
3784/* reg_ptys_ib_proto_admin
3785 * IB speeds and protocols to set port to.
3786 * Access: RW
3787 */
3788MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
3789
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003790/* reg_ptys_eth_proto_oper
3791 * The current speed and protocol configured for the port.
3792 * Access: RO
3793 */
3794MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
3795
Elad Raz79417702016-10-28 21:35:53 +02003796/* reg_ptys_ib_link_width_oper
3797 * The current IB width to set port to.
3798 * Access: RO
3799 */
3800MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
3801
3802/* reg_ptys_ib_proto_oper
3803 * The current IB speed and protocol.
3804 * Access: RO
3805 */
3806MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
3807
Ido Schimmel4149b972016-09-12 13:26:24 +02003808/* reg_ptys_eth_proto_lp_advertise
3809 * The protocols that were advertised by the link partner during
3810 * autonegotiation.
3811 * Access: RO
3812 */
3813MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
3814
Elad Raz401c8b42016-10-28 21:35:52 +02003815static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
Tal Bar8e1ed732018-03-21 09:34:06 +02003816 u32 proto_admin, bool autoneg)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003817{
3818 MLXSW_REG_ZERO(ptys, payload);
3819 mlxsw_reg_ptys_local_port_set(payload, local_port);
3820 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
3821 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
Tal Bar8e1ed732018-03-21 09:34:06 +02003822 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003823}
3824
Elad Raz401c8b42016-10-28 21:35:52 +02003825static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
3826 u32 *p_eth_proto_cap,
3827 u32 *p_eth_proto_adm,
3828 u32 *p_eth_proto_oper)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003829{
3830 if (p_eth_proto_cap)
3831 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
3832 if (p_eth_proto_adm)
3833 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
3834 if (p_eth_proto_oper)
3835 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
3836}
3837
Elad Raz79417702016-10-28 21:35:53 +02003838static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
3839 u16 proto_admin, u16 link_width)
3840{
3841 MLXSW_REG_ZERO(ptys, payload);
3842 mlxsw_reg_ptys_local_port_set(payload, local_port);
3843 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
3844 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
3845 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
3846}
3847
3848static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
3849 u16 *p_ib_link_width_cap,
3850 u16 *p_ib_proto_oper,
3851 u16 *p_ib_link_width_oper)
3852{
3853 if (p_ib_proto_cap)
3854 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
3855 if (p_ib_link_width_cap)
3856 *p_ib_link_width_cap =
3857 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
3858 if (p_ib_proto_oper)
3859 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
3860 if (p_ib_link_width_oper)
3861 *p_ib_link_width_oper =
3862 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
3863}
3864
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003865/* PPAD - Port Physical Address Register
3866 * -------------------------------------
3867 * The PPAD register configures the per port physical MAC address.
3868 */
3869#define MLXSW_REG_PPAD_ID 0x5005
3870#define MLXSW_REG_PPAD_LEN 0x10
3871
Jiri Pirko21978dc2016-10-21 16:07:20 +02003872MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003873
3874/* reg_ppad_single_base_mac
3875 * 0: base_mac, local port should be 0 and mac[7:0] is
3876 * reserved. HW will set incremental
3877 * 1: single_mac - mac of the local_port
3878 * Access: RW
3879 */
3880MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
3881
3882/* reg_ppad_local_port
3883 * port number, if single_base_mac = 0 then local_port is reserved
3884 * Access: RW
3885 */
3886MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
3887
3888/* reg_ppad_mac
3889 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
3890 * If single_base_mac = 1 - the per port MAC address
3891 * Access: RW
3892 */
3893MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
3894
3895static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
3896 u8 local_port)
3897{
3898 MLXSW_REG_ZERO(ppad, payload);
3899 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
3900 mlxsw_reg_ppad_local_port_set(payload, local_port);
3901}
3902
3903/* PAOS - Ports Administrative and Operational Status Register
3904 * -----------------------------------------------------------
3905 * Configures and retrieves per port administrative and operational status.
3906 */
3907#define MLXSW_REG_PAOS_ID 0x5006
3908#define MLXSW_REG_PAOS_LEN 0x10
3909
Jiri Pirko21978dc2016-10-21 16:07:20 +02003910MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003911
3912/* reg_paos_swid
3913 * Switch partition ID with which to associate the port.
3914 * Note: while external ports uses unique local port numbers (and thus swid is
3915 * redundant), router ports use the same local port number where swid is the
3916 * only indication for the relevant port.
3917 * Access: Index
3918 */
3919MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
3920
3921/* reg_paos_local_port
3922 * Local port number.
3923 * Access: Index
3924 */
3925MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
3926
3927/* reg_paos_admin_status
3928 * Port administrative state (the desired state of the port):
3929 * 1 - Up.
3930 * 2 - Down.
3931 * 3 - Up once. This means that in case of link failure, the port won't go
3932 * into polling mode, but will wait to be re-enabled by software.
3933 * 4 - Disabled by system. Can only be set by hardware.
3934 * Access: RW
3935 */
3936MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
3937
3938/* reg_paos_oper_status
3939 * Port operational state (the current state):
3940 * 1 - Up.
3941 * 2 - Down.
3942 * 3 - Down by port failure. This means that the device will not let the
3943 * port up again until explicitly specified by software.
3944 * Access: RO
3945 */
3946MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
3947
3948/* reg_paos_ase
3949 * Admin state update enabled.
3950 * Access: WO
3951 */
3952MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
3953
3954/* reg_paos_ee
3955 * Event update enable. If this bit is set, event generation will be
3956 * updated based on the e field.
3957 * Access: WO
3958 */
3959MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
3960
3961/* reg_paos_e
3962 * Event generation on operational state change:
3963 * 0 - Do not generate event.
3964 * 1 - Generate Event.
3965 * 2 - Generate Single Event.
3966 * Access: RW
3967 */
3968MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
3969
3970static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
3971 enum mlxsw_port_admin_status status)
3972{
3973 MLXSW_REG_ZERO(paos, payload);
3974 mlxsw_reg_paos_swid_set(payload, 0);
3975 mlxsw_reg_paos_local_port_set(payload, local_port);
3976 mlxsw_reg_paos_admin_status_set(payload, status);
3977 mlxsw_reg_paos_oper_status_set(payload, 0);
3978 mlxsw_reg_paos_ase_set(payload, 1);
3979 mlxsw_reg_paos_ee_set(payload, 1);
3980 mlxsw_reg_paos_e_set(payload, 1);
3981}
3982
Ido Schimmel6f253d82016-04-06 17:10:12 +02003983/* PFCC - Ports Flow Control Configuration Register
3984 * ------------------------------------------------
3985 * Configures and retrieves the per port flow control configuration.
3986 */
3987#define MLXSW_REG_PFCC_ID 0x5007
3988#define MLXSW_REG_PFCC_LEN 0x20
3989
Jiri Pirko21978dc2016-10-21 16:07:20 +02003990MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
Ido Schimmel6f253d82016-04-06 17:10:12 +02003991
3992/* reg_pfcc_local_port
3993 * Local port number.
3994 * Access: Index
3995 */
3996MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
3997
3998/* reg_pfcc_pnat
3999 * Port number access type. Determines the way local_port is interpreted:
4000 * 0 - Local port number.
4001 * 1 - IB / label port number.
4002 * Access: Index
4003 */
4004MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
4005
4006/* reg_pfcc_shl_cap
4007 * Send to higher layers capabilities:
4008 * 0 - No capability of sending Pause and PFC frames to higher layers.
4009 * 1 - Device has capability of sending Pause and PFC frames to higher
4010 * layers.
4011 * Access: RO
4012 */
4013MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4014
4015/* reg_pfcc_shl_opr
4016 * Send to higher layers operation:
4017 * 0 - Pause and PFC frames are handled by the port (default).
4018 * 1 - Pause and PFC frames are handled by the port and also sent to
4019 * higher layers. Only valid if shl_cap = 1.
4020 * Access: RW
4021 */
4022MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4023
4024/* reg_pfcc_ppan
4025 * Pause policy auto negotiation.
4026 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
4027 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
4028 * based on the auto-negotiation resolution.
4029 * Access: RW
4030 *
4031 * Note: The auto-negotiation advertisement is set according to pptx and
4032 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
4033 */
4034MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4035
4036/* reg_pfcc_prio_mask_tx
4037 * Bit per priority indicating if Tx flow control policy should be
4038 * updated based on bit pfctx.
4039 * Access: WO
4040 */
4041MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4042
4043/* reg_pfcc_prio_mask_rx
4044 * Bit per priority indicating if Rx flow control policy should be
4045 * updated based on bit pfcrx.
4046 * Access: WO
4047 */
4048MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4049
4050/* reg_pfcc_pptx
4051 * Admin Pause policy on Tx.
4052 * 0 - Never generate Pause frames (default).
4053 * 1 - Generate Pause frames according to Rx buffer threshold.
4054 * Access: RW
4055 */
4056MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4057
4058/* reg_pfcc_aptx
4059 * Active (operational) Pause policy on Tx.
4060 * 0 - Never generate Pause frames.
4061 * 1 - Generate Pause frames according to Rx buffer threshold.
4062 * Access: RO
4063 */
4064MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4065
4066/* reg_pfcc_pfctx
4067 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
4068 * 0 - Never generate priority Pause frames on the specified priority
4069 * (default).
4070 * 1 - Generate priority Pause frames according to Rx buffer threshold on
4071 * the specified priority.
4072 * Access: RW
4073 *
4074 * Note: pfctx and pptx must be mutually exclusive.
4075 */
4076MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4077
4078/* reg_pfcc_pprx
4079 * Admin Pause policy on Rx.
4080 * 0 - Ignore received Pause frames (default).
4081 * 1 - Respect received Pause frames.
4082 * Access: RW
4083 */
4084MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4085
4086/* reg_pfcc_aprx
4087 * Active (operational) Pause policy on Rx.
4088 * 0 - Ignore received Pause frames.
4089 * 1 - Respect received Pause frames.
4090 * Access: RO
4091 */
4092MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4093
4094/* reg_pfcc_pfcrx
4095 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
4096 * 0 - Ignore incoming priority Pause frames on the specified priority
4097 * (default).
4098 * 1 - Respect incoming priority Pause frames on the specified priority.
4099 * Access: RW
4100 */
4101MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4102
Ido Schimmeld81a6bd2016-04-06 17:10:16 +02004103#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4104
4105static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4106{
4107 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4108 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4109 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4110 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4111}
4112
Ido Schimmel6f253d82016-04-06 17:10:12 +02004113static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
4114{
4115 MLXSW_REG_ZERO(pfcc, payload);
4116 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4117}
4118
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004119/* PPCNT - Ports Performance Counters Register
4120 * -------------------------------------------
4121 * The PPCNT register retrieves per port performance counters.
4122 */
4123#define MLXSW_REG_PPCNT_ID 0x5008
4124#define MLXSW_REG_PPCNT_LEN 0x100
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004125#define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004126
Jiri Pirko21978dc2016-10-21 16:07:20 +02004127MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004128
4129/* reg_ppcnt_swid
4130 * For HCA: must be always 0.
4131 * Switch partition ID to associate port with.
4132 * Switch partitions are numbered from 0 to 7 inclusively.
4133 * Switch partition 254 indicates stacking ports.
4134 * Switch partition 255 indicates all switch partitions.
4135 * Only valid on Set() operation with local_port=255.
4136 * Access: Index
4137 */
4138MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4139
4140/* reg_ppcnt_local_port
4141 * Local port number.
4142 * 255 indicates all ports on the device, and is only allowed
4143 * for Set() operation.
4144 * Access: Index
4145 */
4146MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
4147
4148/* reg_ppcnt_pnat
4149 * Port number access type:
4150 * 0 - Local port number
4151 * 1 - IB port number
4152 * Access: Index
4153 */
4154MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4155
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004156enum mlxsw_reg_ppcnt_grp {
4157 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
Jiri Pirko1222d152018-07-15 10:45:42 +03004158 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004159 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004160 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004161 MLXSW_REG_PPCNT_TC_CNT = 0x11,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004162 MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004163};
4164
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004165/* reg_ppcnt_grp
4166 * Performance counter group.
4167 * Group 63 indicates all groups. Only valid on Set() operation with
4168 * clr bit set.
4169 * 0x0: IEEE 802.3 Counters
4170 * 0x1: RFC 2863 Counters
4171 * 0x2: RFC 2819 Counters
4172 * 0x3: RFC 3635 Counters
4173 * 0x5: Ethernet Extended Counters
4174 * 0x8: Link Level Retransmission Counters
4175 * 0x10: Per Priority Counters
4176 * 0x11: Per Traffic Class Counters
4177 * 0x12: Physical Layer Counters
Yuval Mintz0afc1222017-11-06 07:23:46 +01004178 * 0x13: Per Traffic Class Congestion Counters
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004179 * Access: Index
4180 */
4181MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4182
4183/* reg_ppcnt_clr
4184 * Clear counters. Setting the clr bit will reset the counter value
4185 * for all counters in the counter group. This bit can be set
4186 * for both Set() and Get() operation.
4187 * Access: OP
4188 */
4189MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4190
4191/* reg_ppcnt_prio_tc
4192 * Priority for counter set that support per priority, valid values: 0-7.
4193 * Traffic class for counter set that support per traffic class,
4194 * valid values: 0- cap_max_tclass-1 .
4195 * For HCA: cap_max_tclass is always 8.
4196 * Otherwise must be 0.
4197 * Access: Index
4198 */
4199MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
4200
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004201/* Ethernet IEEE 802.3 Counter Group */
4202
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004203/* reg_ppcnt_a_frames_transmitted_ok
4204 * Access: RO
4205 */
4206MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004207 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004208
4209/* reg_ppcnt_a_frames_received_ok
4210 * Access: RO
4211 */
4212MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004213 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004214
4215/* reg_ppcnt_a_frame_check_sequence_errors
4216 * Access: RO
4217 */
4218MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004219 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004220
4221/* reg_ppcnt_a_alignment_errors
4222 * Access: RO
4223 */
4224MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004225 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004226
4227/* reg_ppcnt_a_octets_transmitted_ok
4228 * Access: RO
4229 */
4230MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004231 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004232
4233/* reg_ppcnt_a_octets_received_ok
4234 * Access: RO
4235 */
4236MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004237 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004238
4239/* reg_ppcnt_a_multicast_frames_xmitted_ok
4240 * Access: RO
4241 */
4242MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004243 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004244
4245/* reg_ppcnt_a_broadcast_frames_xmitted_ok
4246 * Access: RO
4247 */
4248MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004249 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004250
4251/* reg_ppcnt_a_multicast_frames_received_ok
4252 * Access: RO
4253 */
4254MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004255 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004256
4257/* reg_ppcnt_a_broadcast_frames_received_ok
4258 * Access: RO
4259 */
4260MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004261 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004262
4263/* reg_ppcnt_a_in_range_length_errors
4264 * Access: RO
4265 */
4266MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004267 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004268
4269/* reg_ppcnt_a_out_of_range_length_field
4270 * Access: RO
4271 */
4272MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004273 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004274
4275/* reg_ppcnt_a_frame_too_long_errors
4276 * Access: RO
4277 */
4278MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004279 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004280
4281/* reg_ppcnt_a_symbol_error_during_carrier
4282 * Access: RO
4283 */
4284MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004285 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004286
4287/* reg_ppcnt_a_mac_control_frames_transmitted
4288 * Access: RO
4289 */
4290MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004291 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004292
4293/* reg_ppcnt_a_mac_control_frames_received
4294 * Access: RO
4295 */
4296MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004297 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004298
4299/* reg_ppcnt_a_unsupported_opcodes_received
4300 * Access: RO
4301 */
4302MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004303 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004304
4305/* reg_ppcnt_a_pause_mac_ctrl_frames_received
4306 * Access: RO
4307 */
4308MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004309 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004310
4311/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
4312 * Access: RO
4313 */
4314MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004315 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004316
Jiri Pirko1222d152018-07-15 10:45:42 +03004317/* Ethernet RFC 2819 Counter Group */
4318
4319/* reg_ppcnt_ether_stats_pkts64octets
4320 * Access: RO
4321 */
4322MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
4323 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4324
4325/* reg_ppcnt_ether_stats_pkts65to127octets
4326 * Access: RO
4327 */
4328MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
4329 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4330
4331/* reg_ppcnt_ether_stats_pkts128to255octets
4332 * Access: RO
4333 */
4334MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
4335 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4336
4337/* reg_ppcnt_ether_stats_pkts256to511octets
4338 * Access: RO
4339 */
4340MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
4341 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4342
4343/* reg_ppcnt_ether_stats_pkts512to1023octets
4344 * Access: RO
4345 */
4346MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
4347 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4348
4349/* reg_ppcnt_ether_stats_pkts1024to1518octets
4350 * Access: RO
4351 */
4352MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
4353 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4354
4355/* reg_ppcnt_ether_stats_pkts1519to2047octets
4356 * Access: RO
4357 */
4358MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
4359 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4360
4361/* reg_ppcnt_ether_stats_pkts2048to4095octets
4362 * Access: RO
4363 */
4364MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
4365 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4366
4367/* reg_ppcnt_ether_stats_pkts4096to8191octets
4368 * Access: RO
4369 */
4370MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
4371 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
4372
4373/* reg_ppcnt_ether_stats_pkts8192to10239octets
4374 * Access: RO
4375 */
4376MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
4377 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
4378
Yuval Mintz0afc1222017-11-06 07:23:46 +01004379/* Ethernet Extended Counter Group Counters */
4380
4381/* reg_ppcnt_ecn_marked
4382 * Access: RO
4383 */
4384MLXSW_ITEM64(reg, ppcnt, ecn_marked,
4385 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4386
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004387/* Ethernet Per Priority Group Counters */
4388
4389/* reg_ppcnt_rx_octets
4390 * Access: RO
4391 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004392MLXSW_ITEM64(reg, ppcnt, rx_octets,
4393 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004394
4395/* reg_ppcnt_rx_frames
4396 * Access: RO
4397 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004398MLXSW_ITEM64(reg, ppcnt, rx_frames,
4399 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004400
4401/* reg_ppcnt_tx_octets
4402 * Access: RO
4403 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004404MLXSW_ITEM64(reg, ppcnt, tx_octets,
4405 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004406
4407/* reg_ppcnt_tx_frames
4408 * Access: RO
4409 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004410MLXSW_ITEM64(reg, ppcnt, tx_frames,
4411 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004412
4413/* reg_ppcnt_rx_pause
4414 * Access: RO
4415 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004416MLXSW_ITEM64(reg, ppcnt, rx_pause,
4417 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004418
4419/* reg_ppcnt_rx_pause_duration
4420 * Access: RO
4421 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004422MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
4423 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004424
4425/* reg_ppcnt_tx_pause
4426 * Access: RO
4427 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004428MLXSW_ITEM64(reg, ppcnt, tx_pause,
4429 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004430
4431/* reg_ppcnt_tx_pause_duration
4432 * Access: RO
4433 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004434MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
4435 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004436
4437/* reg_ppcnt_rx_pause_transition
4438 * Access: RO
4439 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004440MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
4441 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004442
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004443/* Ethernet Per Traffic Group Counters */
4444
4445/* reg_ppcnt_tc_transmit_queue
4446 * Contains the transmit queue depth in cells of traffic class
4447 * selected by prio_tc and the port selected by local_port.
4448 * The field cannot be cleared.
4449 * Access: RO
4450 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004451MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
4452 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004453
4454/* reg_ppcnt_tc_no_buffer_discard_uc
4455 * The number of unicast packets dropped due to lack of shared
4456 * buffer resources.
4457 * Access: RO
4458 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004459MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
4460 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004461
Yuval Mintz0afc1222017-11-06 07:23:46 +01004462/* Ethernet Per Traffic Class Congestion Group Counters */
4463
4464/* reg_ppcnt_wred_discard
4465 * Access: RO
4466 */
4467MLXSW_ITEM64(reg, ppcnt, wred_discard,
4468 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4469
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004470static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
4471 enum mlxsw_reg_ppcnt_grp grp,
4472 u8 prio_tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004473{
4474 MLXSW_REG_ZERO(ppcnt, payload);
4475 mlxsw_reg_ppcnt_swid_set(payload, 0);
4476 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
4477 mlxsw_reg_ppcnt_pnat_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004478 mlxsw_reg_ppcnt_grp_set(payload, grp);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004479 mlxsw_reg_ppcnt_clr_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004480 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004481}
4482
Elad Raz71367932016-10-28 21:35:54 +02004483/* PLIB - Port Local to InfiniBand Port
4484 * ------------------------------------
4485 * The PLIB register performs mapping from Local Port into InfiniBand Port.
4486 */
4487#define MLXSW_REG_PLIB_ID 0x500A
4488#define MLXSW_REG_PLIB_LEN 0x10
4489
4490MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
4491
4492/* reg_plib_local_port
4493 * Local port number.
4494 * Access: Index
4495 */
4496MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
4497
4498/* reg_plib_ib_port
4499 * InfiniBand port remapping for local_port.
4500 * Access: RW
4501 */
4502MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
4503
Ido Schimmelb98ff152016-04-06 17:10:00 +02004504/* PPTB - Port Prio To Buffer Register
4505 * -----------------------------------
4506 * Configures the switch priority to buffer table.
4507 */
4508#define MLXSW_REG_PPTB_ID 0x500B
Ido Schimmel11719a52016-07-15 11:15:02 +02004509#define MLXSW_REG_PPTB_LEN 0x10
Ido Schimmelb98ff152016-04-06 17:10:00 +02004510
Jiri Pirko21978dc2016-10-21 16:07:20 +02004511MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
Ido Schimmelb98ff152016-04-06 17:10:00 +02004512
4513enum {
4514 MLXSW_REG_PPTB_MM_UM,
4515 MLXSW_REG_PPTB_MM_UNICAST,
4516 MLXSW_REG_PPTB_MM_MULTICAST,
4517};
4518
4519/* reg_pptb_mm
4520 * Mapping mode.
4521 * 0 - Map both unicast and multicast packets to the same buffer.
4522 * 1 - Map only unicast packets.
4523 * 2 - Map only multicast packets.
4524 * Access: Index
4525 *
4526 * Note: SwitchX-2 only supports the first option.
4527 */
4528MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
4529
4530/* reg_pptb_local_port
4531 * Local port number.
4532 * Access: Index
4533 */
4534MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
4535
4536/* reg_pptb_um
4537 * Enables the update of the untagged_buf field.
4538 * Access: RW
4539 */
4540MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
4541
4542/* reg_pptb_pm
4543 * Enables the update of the prio_to_buff field.
4544 * Bit <i> is a flag for updating the mapping for switch priority <i>.
4545 * Access: RW
4546 */
4547MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
4548
4549/* reg_pptb_prio_to_buff
4550 * Mapping of switch priority <i> to one of the allocated receive port
4551 * buffers.
4552 * Access: RW
4553 */
4554MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
4555
4556/* reg_pptb_pm_msb
4557 * Enables the update of the prio_to_buff field.
4558 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
4559 * Access: RW
4560 */
4561MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
4562
4563/* reg_pptb_untagged_buff
4564 * Mapping of untagged frames to one of the allocated receive port buffers.
4565 * Access: RW
4566 *
4567 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
4568 * Spectrum, as it maps untagged packets based on the default switch priority.
4569 */
4570MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
4571
Ido Schimmel11719a52016-07-15 11:15:02 +02004572/* reg_pptb_prio_to_buff_msb
4573 * Mapping of switch priority <i+8> to one of the allocated receive port
4574 * buffers.
4575 * Access: RW
4576 */
4577MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
4578
Ido Schimmelb98ff152016-04-06 17:10:00 +02004579#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
4580
4581static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
4582{
4583 MLXSW_REG_ZERO(pptb, payload);
4584 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
4585 mlxsw_reg_pptb_local_port_set(payload, local_port);
4586 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
Ido Schimmel11719a52016-07-15 11:15:02 +02004587 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
4588}
4589
4590static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
4591 u8 buff)
4592{
4593 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
4594 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
Ido Schimmelb98ff152016-04-06 17:10:00 +02004595}
4596
Jiri Pirkoe0594362015-10-16 14:01:31 +02004597/* PBMC - Port Buffer Management Control Register
4598 * ----------------------------------------------
4599 * The PBMC register configures and retrieves the port packet buffer
4600 * allocation for different Prios, and the Pause threshold management.
4601 */
4602#define MLXSW_REG_PBMC_ID 0x500C
Ido Schimmel7ad7cd62016-04-06 17:10:04 +02004603#define MLXSW_REG_PBMC_LEN 0x6C
Jiri Pirkoe0594362015-10-16 14:01:31 +02004604
Jiri Pirko21978dc2016-10-21 16:07:20 +02004605MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004606
4607/* reg_pbmc_local_port
4608 * Local port number.
4609 * Access: Index
4610 */
4611MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
4612
4613/* reg_pbmc_xoff_timer_value
4614 * When device generates a pause frame, it uses this value as the pause
4615 * timer (time for the peer port to pause in quota-512 bit time).
4616 * Access: RW
4617 */
4618MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
4619
4620/* reg_pbmc_xoff_refresh
4621 * The time before a new pause frame should be sent to refresh the pause RW
4622 * state. Using the same units as xoff_timer_value above (in quota-512 bit
4623 * time).
4624 * Access: RW
4625 */
4626MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
4627
Ido Schimmeld6b7c132016-04-06 17:10:05 +02004628#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
4629
Jiri Pirkoe0594362015-10-16 14:01:31 +02004630/* reg_pbmc_buf_lossy
4631 * The field indicates if the buffer is lossy.
4632 * 0 - Lossless
4633 * 1 - Lossy
4634 * Access: RW
4635 */
4636MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
4637
4638/* reg_pbmc_buf_epsb
4639 * Eligible for Port Shared buffer.
4640 * If epsb is set, packets assigned to buffer are allowed to insert the port
4641 * shared buffer.
4642 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
4643 * Access: RW
4644 */
4645MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
4646
4647/* reg_pbmc_buf_size
4648 * The part of the packet buffer array is allocated for the specific buffer.
4649 * Units are represented in cells.
4650 * Access: RW
4651 */
4652MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
4653
Ido Schimmel155f9de2016-04-06 17:10:13 +02004654/* reg_pbmc_buf_xoff_threshold
4655 * Once the amount of data in the buffer goes above this value, device
4656 * starts sending PFC frames for all priorities associated with the
4657 * buffer. Units are represented in cells. Reserved in case of lossy
4658 * buffer.
4659 * Access: RW
4660 *
4661 * Note: In Spectrum, reserved for buffer[9].
4662 */
4663MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
4664 0x08, 0x04, false);
4665
4666/* reg_pbmc_buf_xon_threshold
4667 * When the amount of data in the buffer goes below this value, device
4668 * stops sending PFC frames for the priorities associated with the
4669 * buffer. Units are represented in cells. Reserved in case of lossy
4670 * buffer.
4671 * Access: RW
4672 *
4673 * Note: In Spectrum, reserved for buffer[9].
4674 */
4675MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
4676 0x08, 0x04, false);
4677
Jiri Pirkoe0594362015-10-16 14:01:31 +02004678static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
4679 u16 xoff_timer_value, u16 xoff_refresh)
4680{
4681 MLXSW_REG_ZERO(pbmc, payload);
4682 mlxsw_reg_pbmc_local_port_set(payload, local_port);
4683 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
4684 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
4685}
4686
4687static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
4688 int buf_index,
4689 u16 size)
4690{
4691 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
4692 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
4693 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
4694}
4695
Ido Schimmel155f9de2016-04-06 17:10:13 +02004696static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
4697 int buf_index, u16 size,
4698 u16 threshold)
4699{
4700 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
4701 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
4702 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
4703 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
4704 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
4705}
4706
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004707/* PSPA - Port Switch Partition Allocation
4708 * ---------------------------------------
4709 * Controls the association of a port with a switch partition and enables
4710 * configuring ports as stacking ports.
4711 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +02004712#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004713#define MLXSW_REG_PSPA_LEN 0x8
4714
Jiri Pirko21978dc2016-10-21 16:07:20 +02004715MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004716
4717/* reg_pspa_swid
4718 * Switch partition ID.
4719 * Access: RW
4720 */
4721MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
4722
4723/* reg_pspa_local_port
4724 * Local port number.
4725 * Access: Index
4726 */
4727MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
4728
4729/* reg_pspa_sub_port
4730 * Virtual port within the local port. Set to 0 when virtual ports are
4731 * disabled on the local port.
4732 * Access: Index
4733 */
4734MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
4735
4736static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
4737{
4738 MLXSW_REG_ZERO(pspa, payload);
4739 mlxsw_reg_pspa_swid_set(payload, swid);
4740 mlxsw_reg_pspa_local_port_set(payload, local_port);
4741 mlxsw_reg_pspa_sub_port_set(payload, 0);
4742}
4743
4744/* HTGT - Host Trap Group Table
4745 * ----------------------------
4746 * Configures the properties for forwarding to CPU.
4747 */
4748#define MLXSW_REG_HTGT_ID 0x7002
Elad Raze158e5e2017-02-06 13:56:27 +01004749#define MLXSW_REG_HTGT_LEN 0x20
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004750
Jiri Pirko21978dc2016-10-21 16:07:20 +02004751MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004752
4753/* reg_htgt_swid
4754 * Switch partition ID.
4755 * Access: Index
4756 */
4757MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
4758
4759#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
4760
4761/* reg_htgt_type
4762 * CPU path type.
4763 * Access: RW
4764 */
4765MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
4766
Ido Schimmel801bd3d2015-10-15 17:43:28 +02004767enum mlxsw_reg_htgt_trap_group {
4768 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004769 MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX,
4770 MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL,
4771 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
4772 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
4773 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
4774 MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02004775 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004776 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
Yotam Gigib48cfc82017-09-19 10:00:20 +02004777 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
4778 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004779 MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02004780 MLXSW_REG_HTGT_TRAP_GROUP_SP_HOST_MISS,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004781 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
4782 MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
4783 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
4784 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
Yotam Gigib48cfc82017-09-19 10:00:20 +02004785 MLXSW_REG_HTGT_TRAP_GROUP_SP_RPF,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004786 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
Arkadi Sharshevsky588823f2017-07-17 14:15:31 +02004787 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_MLD,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02004788 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_ND,
Ido Schimmel801bd3d2015-10-15 17:43:28 +02004789};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004790
4791/* reg_htgt_trap_group
4792 * Trap group number. User defined number specifying which trap groups
4793 * should be forwarded to the CPU. The mapping between trap IDs and trap
4794 * groups is configured using HPKT register.
4795 * Access: Index
4796 */
4797MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
4798
4799enum {
4800 MLXSW_REG_HTGT_POLICER_DISABLE,
4801 MLXSW_REG_HTGT_POLICER_ENABLE,
4802};
4803
4804/* reg_htgt_pide
4805 * Enable policer ID specified using 'pid' field.
4806 * Access: RW
4807 */
4808MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
4809
Nogah Frankel579c82e2016-11-25 10:33:42 +01004810#define MLXSW_REG_HTGT_INVALID_POLICER 0xff
4811
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004812/* reg_htgt_pid
4813 * Policer ID for the trap group.
4814 * Access: RW
4815 */
4816MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
4817
4818#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
4819
4820/* reg_htgt_mirror_action
4821 * Mirror action to use.
4822 * 0 - Trap to CPU.
4823 * 1 - Trap to CPU and mirror to a mirroring agent.
4824 * 2 - Mirror to a mirroring agent and do not trap to CPU.
4825 * Access: RW
4826 *
4827 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
4828 */
4829MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
4830
4831/* reg_htgt_mirroring_agent
4832 * Mirroring agent.
4833 * Access: RW
4834 */
4835MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
4836
Nogah Frankel579c82e2016-11-25 10:33:42 +01004837#define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
4838
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004839/* reg_htgt_priority
4840 * Trap group priority.
4841 * In case a packet matches multiple classification rules, the packet will
4842 * only be trapped once, based on the trap ID associated with the group (via
4843 * register HPKT) with the highest priority.
4844 * Supported values are 0-7, with 7 represnting the highest priority.
4845 * Access: RW
4846 *
4847 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
4848 * by the 'trap_group' field.
4849 */
4850MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
4851
Nogah Frankel579c82e2016-11-25 10:33:42 +01004852#define MLXSW_REG_HTGT_DEFAULT_TC 7
4853
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004854/* reg_htgt_local_path_cpu_tclass
4855 * CPU ingress traffic class for the trap group.
4856 * Access: RW
4857 */
4858MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
4859
Nogah Frankel579c82e2016-11-25 10:33:42 +01004860enum mlxsw_reg_htgt_local_path_rdq {
4861 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
4862 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
4863 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
4864 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
4865};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004866/* reg_htgt_local_path_rdq
4867 * Receive descriptor queue (RDQ) to use for the trap group.
4868 * Access: RW
4869 */
4870MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
4871
Nogah Frankel579c82e2016-11-25 10:33:42 +01004872static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
4873 u8 priority, u8 tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004874{
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004875 MLXSW_REG_ZERO(htgt, payload);
Nogah Frankel579c82e2016-11-25 10:33:42 +01004876
4877 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
4878 mlxsw_reg_htgt_pide_set(payload,
4879 MLXSW_REG_HTGT_POLICER_DISABLE);
4880 } else {
4881 mlxsw_reg_htgt_pide_set(payload,
4882 MLXSW_REG_HTGT_POLICER_ENABLE);
4883 mlxsw_reg_htgt_pid_set(payload, policer_id);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004884 }
Nogah Frankel579c82e2016-11-25 10:33:42 +01004885
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004886 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02004887 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004888 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
4889 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
Nogah Frankel579c82e2016-11-25 10:33:42 +01004890 mlxsw_reg_htgt_priority_set(payload, priority);
4891 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
4892 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004893}
4894
4895/* HPKT - Host Packet Trap
4896 * -----------------------
4897 * Configures trap IDs inside trap groups.
4898 */
4899#define MLXSW_REG_HPKT_ID 0x7003
4900#define MLXSW_REG_HPKT_LEN 0x10
4901
Jiri Pirko21978dc2016-10-21 16:07:20 +02004902MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004903
4904enum {
4905 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
4906 MLXSW_REG_HPKT_ACK_REQUIRED,
4907};
4908
4909/* reg_hpkt_ack
4910 * Require acknowledgements from the host for events.
4911 * If set, then the device will wait for the event it sent to be acknowledged
4912 * by the host. This option is only relevant for event trap IDs.
4913 * Access: RW
4914 *
4915 * Note: Currently not supported by firmware.
4916 */
4917MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
4918
4919enum mlxsw_reg_hpkt_action {
4920 MLXSW_REG_HPKT_ACTION_FORWARD,
4921 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
4922 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
4923 MLXSW_REG_HPKT_ACTION_DISCARD,
4924 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
4925 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
4926};
4927
4928/* reg_hpkt_action
4929 * Action to perform on packet when trapped.
4930 * 0 - No action. Forward to CPU based on switching rules.
4931 * 1 - Trap to CPU (CPU receives sole copy).
4932 * 2 - Mirror to CPU (CPU receives a replica of the packet).
4933 * 3 - Discard.
4934 * 4 - Soft discard (allow other traps to act on the packet).
4935 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
4936 * Access: RW
4937 *
4938 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
4939 * addressed to the CPU.
4940 */
4941MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
4942
4943/* reg_hpkt_trap_group
4944 * Trap group to associate the trap with.
4945 * Access: RW
4946 */
4947MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
4948
4949/* reg_hpkt_trap_id
4950 * Trap ID.
4951 * Access: Index
4952 *
4953 * Note: A trap ID can only be associated with a single trap group. The device
4954 * will associate the trap ID with the last trap group configured.
4955 */
4956MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
4957
4958enum {
4959 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
4960 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
4961 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
4962};
4963
4964/* reg_hpkt_ctrl
4965 * Configure dedicated buffer resources for control packets.
Nogah Frankeld570b7e2016-11-25 10:33:38 +01004966 * Ignored by SwitchX-2.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004967 * 0 - Keep factory defaults.
4968 * 1 - Do not use control buffer for this trap ID.
4969 * 2 - Use control buffer for this trap ID.
4970 * Access: RW
4971 */
4972MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
4973
Nogah Frankeld570b7e2016-11-25 10:33:38 +01004974static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
4975 enum mlxsw_reg_htgt_trap_group trap_group,
4976 bool is_ctrl)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004977{
4978 MLXSW_REG_ZERO(hpkt, payload);
4979 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
4980 mlxsw_reg_hpkt_action_set(payload, action);
4981 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
4982 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
Nogah Frankeld570b7e2016-11-25 10:33:38 +01004983 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
4984 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
4985 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004986}
4987
Ido Schimmel69c407a2016-07-02 11:00:13 +02004988/* RGCR - Router General Configuration Register
4989 * --------------------------------------------
4990 * The register is used for setting up the router configuration.
4991 */
4992#define MLXSW_REG_RGCR_ID 0x8001
4993#define MLXSW_REG_RGCR_LEN 0x28
4994
Jiri Pirko21978dc2016-10-21 16:07:20 +02004995MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
Ido Schimmel69c407a2016-07-02 11:00:13 +02004996
4997/* reg_rgcr_ipv4_en
4998 * IPv4 router enable.
4999 * Access: RW
5000 */
5001MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
5002
5003/* reg_rgcr_ipv6_en
5004 * IPv6 router enable.
5005 * Access: RW
5006 */
5007MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
5008
5009/* reg_rgcr_max_router_interfaces
5010 * Defines the maximum number of active router interfaces for all virtual
5011 * routers.
5012 * Access: RW
5013 */
5014MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
5015
5016/* reg_rgcr_usp
5017 * Update switch priority and packet color.
5018 * 0 - Preserve the value of Switch Priority and packet color.
5019 * 1 - Recalculate the value of Switch Priority and packet color.
5020 * Access: RW
5021 *
5022 * Note: Not supported by SwitchX and SwitchX-2.
5023 */
5024MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
5025
5026/* reg_rgcr_pcp_rw
5027 * Indicates how to handle the pcp_rewrite_en value:
5028 * 0 - Preserve the value of pcp_rewrite_en.
5029 * 2 - Disable PCP rewrite.
5030 * 3 - Enable PCP rewrite.
5031 * Access: RW
5032 *
5033 * Note: Not supported by SwitchX and SwitchX-2.
5034 */
5035MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
5036
5037/* reg_rgcr_activity_dis
5038 * Activity disable:
5039 * 0 - Activity will be set when an entry is hit (default).
5040 * 1 - Activity will not be set when an entry is hit.
5041 *
5042 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
5043 * (RALUE).
5044 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
5045 * Entry (RAUHT).
5046 * Bits 2:7 are reserved.
5047 * Access: RW
5048 *
5049 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
5050 */
5051MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
5052
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02005053static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
5054 bool ipv6_en)
Ido Schimmel69c407a2016-07-02 11:00:13 +02005055{
5056 MLXSW_REG_ZERO(rgcr, payload);
5057 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02005058 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
Ido Schimmel69c407a2016-07-02 11:00:13 +02005059}
5060
Ido Schimmel3dc26682016-07-02 11:00:18 +02005061/* RITR - Router Interface Table Register
5062 * --------------------------------------
5063 * The register is used to configure the router interface table.
5064 */
5065#define MLXSW_REG_RITR_ID 0x8002
5066#define MLXSW_REG_RITR_LEN 0x40
5067
Jiri Pirko21978dc2016-10-21 16:07:20 +02005068MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
Ido Schimmel3dc26682016-07-02 11:00:18 +02005069
5070/* reg_ritr_enable
5071 * Enables routing on the router interface.
5072 * Access: RW
5073 */
5074MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
5075
5076/* reg_ritr_ipv4
5077 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
5078 * interface.
5079 * Access: RW
5080 */
5081MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
5082
5083/* reg_ritr_ipv6
5084 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
5085 * interface.
5086 * Access: RW
5087 */
5088MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
5089
Yotam Gigi4af59642017-09-19 10:00:18 +02005090/* reg_ritr_ipv4_mc
5091 * IPv4 multicast routing enable.
5092 * Access: RW
5093 */
5094MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
5095
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005096/* reg_ritr_ipv6_mc
5097 * IPv6 multicast routing enable.
5098 * Access: RW
5099 */
5100MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
5101
Ido Schimmel3dc26682016-07-02 11:00:18 +02005102enum mlxsw_reg_ritr_if_type {
Petr Machata78676ad2017-07-31 09:27:26 +02005103 /* VLAN interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02005104 MLXSW_REG_RITR_VLAN_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02005105 /* FID interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02005106 MLXSW_REG_RITR_FID_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02005107 /* Sub-port interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02005108 MLXSW_REG_RITR_SP_IF,
Petr Machata99ae8e32017-09-02 23:49:09 +02005109 /* Loopback Interface. */
5110 MLXSW_REG_RITR_LOOPBACK_IF,
Ido Schimmel3dc26682016-07-02 11:00:18 +02005111};
5112
5113/* reg_ritr_type
Petr Machata78676ad2017-07-31 09:27:26 +02005114 * Router interface type as per enum mlxsw_reg_ritr_if_type.
Ido Schimmel3dc26682016-07-02 11:00:18 +02005115 * Access: RW
5116 */
5117MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
5118
5119enum {
5120 MLXSW_REG_RITR_RIF_CREATE,
5121 MLXSW_REG_RITR_RIF_DEL,
5122};
5123
5124/* reg_ritr_op
5125 * Opcode:
5126 * 0 - Create or edit RIF.
5127 * 1 - Delete RIF.
5128 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
5129 * is not supported. An interface must be deleted and re-created in order
5130 * to update properties.
5131 * Access: WO
5132 */
5133MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
5134
5135/* reg_ritr_rif
5136 * Router interface index. A pointer to the Router Interface Table.
5137 * Access: Index
5138 */
5139MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
5140
5141/* reg_ritr_ipv4_fe
5142 * IPv4 Forwarding Enable.
5143 * Enables routing of IPv4 traffic on the router interface. When disabled,
5144 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
5145 * Not supported in SwitchX-2.
5146 * Access: RW
5147 */
5148MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
5149
5150/* reg_ritr_ipv6_fe
5151 * IPv6 Forwarding Enable.
5152 * Enables routing of IPv6 traffic on the router interface. When disabled,
5153 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
5154 * Not supported in SwitchX-2.
5155 * Access: RW
5156 */
5157MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
5158
Yotam Gigi4af59642017-09-19 10:00:18 +02005159/* reg_ritr_ipv4_mc_fe
5160 * IPv4 Multicast Forwarding Enable.
5161 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
5162 * will be enabled.
5163 * Access: RW
5164 */
5165MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
5166
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005167/* reg_ritr_ipv6_mc_fe
5168 * IPv6 Multicast Forwarding Enable.
5169 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
5170 * will be enabled.
5171 * Access: RW
5172 */
5173MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
5174
Ido Schimmela94a6142016-08-17 16:39:33 +02005175/* reg_ritr_lb_en
5176 * Loop-back filter enable for unicast packets.
5177 * If the flag is set then loop-back filter for unicast packets is
5178 * implemented on the RIF. Multicast packets are always subject to
5179 * loop-back filtering.
5180 * Access: RW
5181 */
5182MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
5183
Ido Schimmel3dc26682016-07-02 11:00:18 +02005184/* reg_ritr_virtual_router
5185 * Virtual router ID associated with the router interface.
5186 * Access: RW
5187 */
5188MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
5189
5190/* reg_ritr_mtu
5191 * Router interface MTU.
5192 * Access: RW
5193 */
5194MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
5195
5196/* reg_ritr_if_swid
5197 * Switch partition ID.
5198 * Access: RW
5199 */
5200MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
5201
5202/* reg_ritr_if_mac
5203 * Router interface MAC address.
5204 * In Spectrum, all MAC addresses must have the same 38 MSBits.
5205 * Access: RW
5206 */
5207MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
5208
Ido Schimmelc3a49542018-07-14 11:39:54 +03005209/* reg_ritr_if_vrrp_id_ipv6
5210 * VRRP ID for IPv6
5211 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
5212 * Access: RW
5213 */
5214MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
5215
5216/* reg_ritr_if_vrrp_id_ipv4
5217 * VRRP ID for IPv4
5218 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
5219 * Access: RW
5220 */
5221MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
5222
Ido Schimmel3dc26682016-07-02 11:00:18 +02005223/* VLAN Interface */
5224
5225/* reg_ritr_vlan_if_vid
5226 * VLAN ID.
5227 * Access: RW
5228 */
5229MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
5230
5231/* FID Interface */
5232
5233/* reg_ritr_fid_if_fid
5234 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
5235 * the vFID range are supported.
5236 * Access: RW
5237 */
5238MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
5239
5240static inline void mlxsw_reg_ritr_fid_set(char *payload,
5241 enum mlxsw_reg_ritr_if_type rif_type,
5242 u16 fid)
5243{
5244 if (rif_type == MLXSW_REG_RITR_FID_IF)
5245 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
5246 else
5247 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
5248}
5249
5250/* Sub-port Interface */
5251
5252/* reg_ritr_sp_if_lag
5253 * LAG indication. When this bit is set the system_port field holds the
5254 * LAG identifier.
5255 * Access: RW
5256 */
5257MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
5258
5259/* reg_ritr_sp_system_port
5260 * Port unique indentifier. When lag bit is set, this field holds the
5261 * lag_id in bits 0:9.
5262 * Access: RW
5263 */
5264MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
5265
5266/* reg_ritr_sp_if_vid
5267 * VLAN ID.
5268 * Access: RW
5269 */
5270MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
5271
Petr Machata99ae8e32017-09-02 23:49:09 +02005272/* Loopback Interface */
5273
5274enum mlxsw_reg_ritr_loopback_protocol {
5275 /* IPinIP IPv4 underlay Unicast */
5276 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
5277 /* IPinIP IPv6 underlay Unicast */
5278 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
5279};
5280
5281/* reg_ritr_loopback_protocol
5282 * Access: RW
5283 */
5284MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
5285
5286enum mlxsw_reg_ritr_loopback_ipip_type {
5287 /* Tunnel is IPinIP. */
5288 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
5289 /* Tunnel is GRE, no key. */
5290 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
5291 /* Tunnel is GRE, with a key. */
5292 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
5293};
5294
5295/* reg_ritr_loopback_ipip_type
5296 * Encapsulation type.
5297 * Access: RW
5298 */
5299MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
5300
5301enum mlxsw_reg_ritr_loopback_ipip_options {
5302 /* The key is defined by gre_key. */
5303 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
5304};
5305
5306/* reg_ritr_loopback_ipip_options
5307 * Access: RW
5308 */
5309MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
5310
5311/* reg_ritr_loopback_ipip_uvr
5312 * Underlay Virtual Router ID.
5313 * Range is 0..cap_max_virtual_routers-1.
5314 * Reserved for Spectrum-2.
5315 * Access: RW
5316 */
5317MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
5318
5319/* reg_ritr_loopback_ipip_usip*
5320 * Encapsulation Underlay source IP.
5321 * Access: RW
5322 */
5323MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
5324MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
5325
5326/* reg_ritr_loopback_ipip_gre_key
5327 * GRE Key.
5328 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
5329 * Access: RW
5330 */
5331MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
5332
Arkadi Sharshevsky0f630fc2017-03-28 17:24:11 +02005333/* Shared between ingress/egress */
5334enum mlxsw_reg_ritr_counter_set_type {
5335 /* No Count. */
5336 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
5337 /* Basic. Used for router interfaces, counting the following:
5338 * - Error and Discard counters.
5339 * - Unicast, Multicast and Broadcast counters. Sharing the
5340 * same set of counters for the different type of traffic
5341 * (IPv4, IPv6 and mpls).
5342 */
5343 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
5344};
5345
5346/* reg_ritr_ingress_counter_index
5347 * Counter Index for flow counter.
5348 * Access: RW
5349 */
5350MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
5351
5352/* reg_ritr_ingress_counter_set_type
5353 * Igress Counter Set Type for router interface counter.
5354 * Access: RW
5355 */
5356MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
5357
5358/* reg_ritr_egress_counter_index
5359 * Counter Index for flow counter.
5360 * Access: RW
5361 */
5362MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
5363
5364/* reg_ritr_egress_counter_set_type
5365 * Egress Counter Set Type for router interface counter.
5366 * Access: RW
5367 */
5368MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
5369
5370static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
5371 bool enable, bool egress)
5372{
5373 enum mlxsw_reg_ritr_counter_set_type set_type;
5374
5375 if (enable)
5376 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
5377 else
5378 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
5379 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
5380
5381 if (egress)
5382 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
5383 else
5384 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
5385}
5386
Ido Schimmel3dc26682016-07-02 11:00:18 +02005387static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
5388{
5389 MLXSW_REG_ZERO(ritr, payload);
5390 mlxsw_reg_ritr_rif_set(payload, rif);
5391}
5392
5393static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
5394 u16 system_port, u16 vid)
5395{
5396 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
5397 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
5398 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
5399}
5400
5401static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
5402 enum mlxsw_reg_ritr_if_type type,
Petr Machata9571e822017-09-02 23:49:14 +02005403 u16 rif, u16 vr_id, u16 mtu)
Ido Schimmel3dc26682016-07-02 11:00:18 +02005404{
5405 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
5406
5407 MLXSW_REG_ZERO(ritr, payload);
5408 mlxsw_reg_ritr_enable_set(payload, enable);
5409 mlxsw_reg_ritr_ipv4_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02005410 mlxsw_reg_ritr_ipv6_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02005411 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005412 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
Ido Schimmel3dc26682016-07-02 11:00:18 +02005413 mlxsw_reg_ritr_type_set(payload, type);
5414 mlxsw_reg_ritr_op_set(payload, op);
5415 mlxsw_reg_ritr_rif_set(payload, rif);
5416 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02005417 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02005418 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005419 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
Ido Schimmela94a6142016-08-17 16:39:33 +02005420 mlxsw_reg_ritr_lb_en_set(payload, 1);
Ido Schimmel69132292017-03-10 08:53:42 +01005421 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
Ido Schimmel3dc26682016-07-02 11:00:18 +02005422 mlxsw_reg_ritr_mtu_set(payload, mtu);
Petr Machata9571e822017-09-02 23:49:14 +02005423}
5424
5425static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
5426{
Ido Schimmel3dc26682016-07-02 11:00:18 +02005427 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
5428}
5429
Petr Machata99ae8e32017-09-02 23:49:09 +02005430static inline void
5431mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
5432 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
5433 enum mlxsw_reg_ritr_loopback_ipip_options options,
5434 u16 uvr_id, u32 gre_key)
5435{
5436 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
5437 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
5438 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
5439 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
5440}
5441
5442static inline void
5443mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
5444 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
5445 enum mlxsw_reg_ritr_loopback_ipip_options options,
5446 u16 uvr_id, u32 usip, u32 gre_key)
5447{
5448 mlxsw_reg_ritr_loopback_protocol_set(payload,
5449 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
5450 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
5451 uvr_id, gre_key);
5452 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
5453}
5454
Yotam Gigi46a70542017-09-19 10:00:13 +02005455/* RTAR - Router TCAM Allocation Register
5456 * --------------------------------------
5457 * This register is used for allocation of regions in the TCAM table.
5458 */
5459#define MLXSW_REG_RTAR_ID 0x8004
5460#define MLXSW_REG_RTAR_LEN 0x20
5461
5462MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
5463
5464enum mlxsw_reg_rtar_op {
5465 MLXSW_REG_RTAR_OP_ALLOCATE,
5466 MLXSW_REG_RTAR_OP_RESIZE,
5467 MLXSW_REG_RTAR_OP_DEALLOCATE,
5468};
5469
5470/* reg_rtar_op
5471 * Access: WO
5472 */
5473MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
5474
5475enum mlxsw_reg_rtar_key_type {
5476 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
5477 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
5478};
5479
5480/* reg_rtar_key_type
5481 * TCAM key type for the region.
5482 * Access: WO
5483 */
5484MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
5485
5486/* reg_rtar_region_size
5487 * TCAM region size. When allocating/resizing this is the requested
5488 * size, the response is the actual size.
5489 * Note: Actual size may be larger than requested.
5490 * Reserved for op = Deallocate
5491 * Access: WO
5492 */
5493MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
5494
5495static inline void mlxsw_reg_rtar_pack(char *payload,
5496 enum mlxsw_reg_rtar_op op,
5497 enum mlxsw_reg_rtar_key_type key_type,
5498 u16 region_size)
5499{
5500 MLXSW_REG_ZERO(rtar, payload);
5501 mlxsw_reg_rtar_op_set(payload, op);
5502 mlxsw_reg_rtar_key_type_set(payload, key_type);
5503 mlxsw_reg_rtar_region_size_set(payload, region_size);
5504}
5505
Yotam Gigi089f9812016-07-05 11:27:48 +02005506/* RATR - Router Adjacency Table Register
5507 * --------------------------------------
5508 * The RATR register is used to configure the Router Adjacency (next-hop)
5509 * Table.
5510 */
5511#define MLXSW_REG_RATR_ID 0x8008
5512#define MLXSW_REG_RATR_LEN 0x2C
5513
Jiri Pirko21978dc2016-10-21 16:07:20 +02005514MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
Yotam Gigi089f9812016-07-05 11:27:48 +02005515
5516enum mlxsw_reg_ratr_op {
5517 /* Read */
5518 MLXSW_REG_RATR_OP_QUERY_READ = 0,
5519 /* Read and clear activity */
5520 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
5521 /* Write Adjacency entry */
5522 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
5523 /* Write Adjacency entry only if the activity is cleared.
5524 * The write may not succeed if the activity is set. There is not
5525 * direct feedback if the write has succeeded or not, however
5526 * the get will reveal the actual entry (SW can compare the get
5527 * response to the set command).
5528 */
5529 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
5530};
5531
5532/* reg_ratr_op
5533 * Note that Write operation may also be used for updating
5534 * counter_set_type and counter_index. In this case all other
5535 * fields must not be updated.
5536 * Access: OP
5537 */
5538MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
5539
5540/* reg_ratr_v
5541 * Valid bit. Indicates if the adjacency entry is valid.
5542 * Note: the device may need some time before reusing an invalidated
5543 * entry. During this time the entry can not be reused. It is
5544 * recommended to use another entry before reusing an invalidated
5545 * entry (e.g. software can put it at the end of the list for
5546 * reusing). Trying to access an invalidated entry not yet cleared
5547 * by the device results with failure indicating "Try Again" status.
5548 * When valid is '0' then egress_router_interface,trap_action,
5549 * adjacency_parameters and counters are reserved
5550 * Access: RW
5551 */
5552MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
5553
5554/* reg_ratr_a
5555 * Activity. Set for new entries. Set if a packet lookup has hit on
5556 * the specific entry. To clear the a bit, use "clear activity".
5557 * Access: RO
5558 */
5559MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
5560
Petr Machata7c819de2017-09-02 23:49:10 +02005561enum mlxsw_reg_ratr_type {
5562 /* Ethernet */
5563 MLXSW_REG_RATR_TYPE_ETHERNET,
5564 /* IPoIB Unicast without GRH.
5565 * Reserved for Spectrum.
5566 */
5567 MLXSW_REG_RATR_TYPE_IPOIB_UC,
5568 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
5569 * adjacency).
5570 * Reserved for Spectrum.
5571 */
5572 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
5573 /* IPoIB Multicast.
5574 * Reserved for Spectrum.
5575 */
5576 MLXSW_REG_RATR_TYPE_IPOIB_MC,
5577 /* MPLS.
5578 * Reserved for SwitchX/-2.
5579 */
5580 MLXSW_REG_RATR_TYPE_MPLS,
5581 /* IPinIP Encap.
5582 * Reserved for SwitchX/-2.
5583 */
5584 MLXSW_REG_RATR_TYPE_IPIP,
5585};
5586
5587/* reg_ratr_type
5588 * Adjacency entry type.
5589 * Access: RW
5590 */
5591MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
5592
Yotam Gigi089f9812016-07-05 11:27:48 +02005593/* reg_ratr_adjacency_index_low
5594 * Bits 15:0 of index into the adjacency table.
5595 * For SwitchX and SwitchX-2, the adjacency table is linear and
5596 * used for adjacency entries only.
5597 * For Spectrum, the index is to the KVD linear.
5598 * Access: Index
5599 */
5600MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
5601
5602/* reg_ratr_egress_router_interface
5603 * Range is 0 .. cap_max_router_interfaces - 1
5604 * Access: RW
5605 */
5606MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
5607
5608enum mlxsw_reg_ratr_trap_action {
5609 MLXSW_REG_RATR_TRAP_ACTION_NOP,
5610 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
5611 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
5612 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
5613 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
5614};
5615
5616/* reg_ratr_trap_action
5617 * see mlxsw_reg_ratr_trap_action
5618 * Access: RW
5619 */
5620MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
5621
Yotam Gigi089f9812016-07-05 11:27:48 +02005622/* reg_ratr_adjacency_index_high
5623 * Bits 23:16 of the adjacency_index.
5624 * Access: Index
5625 */
5626MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
5627
Petr Machata6c4153b2017-09-02 23:49:11 +02005628enum mlxsw_reg_ratr_trap_id {
5629 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
5630 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
5631};
5632
Yotam Gigi089f9812016-07-05 11:27:48 +02005633/* reg_ratr_trap_id
5634 * Trap ID to be reported to CPU.
5635 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
5636 * For trap_action of NOP, MIRROR and DISCARD_ERROR
5637 * Access: RW
5638 */
5639MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
5640
5641/* reg_ratr_eth_destination_mac
5642 * MAC address of the destination next-hop.
5643 * Access: RW
5644 */
5645MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
5646
Petr Machata7c819de2017-09-02 23:49:10 +02005647enum mlxsw_reg_ratr_ipip_type {
5648 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
5649 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
5650 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
5651 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
5652};
5653
5654/* reg_ratr_ipip_type
5655 * Underlay destination ip type.
5656 * Note: the type field must match the protocol of the router interface.
5657 * Access: RW
5658 */
5659MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
5660
5661/* reg_ratr_ipip_ipv4_udip
5662 * Underlay ipv4 dip.
5663 * Reserved when ipip_type is IPv6.
5664 * Access: RW
5665 */
5666MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
5667
5668/* reg_ratr_ipip_ipv6_ptr
5669 * Pointer to IPv6 underlay destination ip address.
5670 * For Spectrum: Pointer to KVD linear space.
5671 * Access: RW
5672 */
5673MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
5674
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02005675enum mlxsw_reg_flow_counter_set_type {
5676 /* No count */
5677 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
5678 /* Count packets and bytes */
5679 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
5680 /* Count only packets */
5681 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
5682};
5683
5684/* reg_ratr_counter_set_type
5685 * Counter set type for flow counters
5686 * Access: RW
5687 */
5688MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
5689
5690/* reg_ratr_counter_index
5691 * Counter index for flow counters
5692 * Access: RW
5693 */
5694MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
5695
Yotam Gigi089f9812016-07-05 11:27:48 +02005696static inline void
5697mlxsw_reg_ratr_pack(char *payload,
5698 enum mlxsw_reg_ratr_op op, bool valid,
Petr Machata89e41982017-09-02 23:49:15 +02005699 enum mlxsw_reg_ratr_type type,
Yotam Gigi089f9812016-07-05 11:27:48 +02005700 u32 adjacency_index, u16 egress_rif)
5701{
5702 MLXSW_REG_ZERO(ratr, payload);
5703 mlxsw_reg_ratr_op_set(payload, op);
5704 mlxsw_reg_ratr_v_set(payload, valid);
Petr Machata89e41982017-09-02 23:49:15 +02005705 mlxsw_reg_ratr_type_set(payload, type);
Yotam Gigi089f9812016-07-05 11:27:48 +02005706 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
5707 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
5708 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
5709}
5710
5711static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
5712 const char *dest_mac)
5713{
5714 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
5715}
5716
Petr Machata7c819de2017-09-02 23:49:10 +02005717static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
5718{
5719 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
5720 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
5721}
5722
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02005723static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
5724 bool counter_enable)
5725{
5726 enum mlxsw_reg_flow_counter_set_type set_type;
5727
5728 if (counter_enable)
5729 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
5730 else
5731 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
5732
5733 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
5734 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
5735}
5736
Yuval Mintzddb362c2018-01-14 12:33:13 +01005737/* RDPM - Router DSCP to Priority Mapping
5738 * --------------------------------------
5739 * Controls the mapping from DSCP field to switch priority on routed packets
5740 */
5741#define MLXSW_REG_RDPM_ID 0x8009
5742#define MLXSW_REG_RDPM_BASE_LEN 0x00
5743#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
5744#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
5745#define MLXSW_REG_RDPM_LEN 0x40
5746#define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
5747 MLXSW_REG_RDPM_LEN - \
5748 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
5749
5750MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
5751
5752/* reg_dscp_entry_e
5753 * Enable update of the specific entry
5754 * Access: Index
5755 */
5756MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
5757 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
5758
5759/* reg_dscp_entry_prio
5760 * Switch Priority
5761 * Access: RW
5762 */
5763MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
5764 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
5765
5766static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
5767 u8 prio)
5768{
5769 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
5770 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
5771}
5772
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +02005773/* RICNT - Router Interface Counter Register
5774 * -----------------------------------------
5775 * The RICNT register retrieves per port performance counters
5776 */
5777#define MLXSW_REG_RICNT_ID 0x800B
5778#define MLXSW_REG_RICNT_LEN 0x100
5779
5780MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
5781
5782/* reg_ricnt_counter_index
5783 * Counter index
5784 * Access: RW
5785 */
5786MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
5787
5788enum mlxsw_reg_ricnt_counter_set_type {
5789 /* No Count. */
5790 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
5791 /* Basic. Used for router interfaces, counting the following:
5792 * - Error and Discard counters.
5793 * - Unicast, Multicast and Broadcast counters. Sharing the
5794 * same set of counters for the different type of traffic
5795 * (IPv4, IPv6 and mpls).
5796 */
5797 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
5798};
5799
5800/* reg_ricnt_counter_set_type
5801 * Counter Set Type for router interface counter
5802 * Access: RW
5803 */
5804MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
5805
5806enum mlxsw_reg_ricnt_opcode {
5807 /* Nop. Supported only for read access*/
5808 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
5809 /* Clear. Setting the clr bit will reset the counter value for
5810 * all counters of the specified Router Interface.
5811 */
5812 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
5813};
5814
5815/* reg_ricnt_opcode
5816 * Opcode
5817 * Access: RW
5818 */
5819MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
5820
5821/* reg_ricnt_good_unicast_packets
5822 * good unicast packets.
5823 * Access: RW
5824 */
5825MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
5826
5827/* reg_ricnt_good_multicast_packets
5828 * good multicast packets.
5829 * Access: RW
5830 */
5831MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
5832
5833/* reg_ricnt_good_broadcast_packets
5834 * good broadcast packets
5835 * Access: RW
5836 */
5837MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
5838
5839/* reg_ricnt_good_unicast_bytes
5840 * A count of L3 data and padding octets not including L2 headers
5841 * for good unicast frames.
5842 * Access: RW
5843 */
5844MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
5845
5846/* reg_ricnt_good_multicast_bytes
5847 * A count of L3 data and padding octets not including L2 headers
5848 * for good multicast frames.
5849 * Access: RW
5850 */
5851MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
5852
5853/* reg_ritr_good_broadcast_bytes
5854 * A count of L3 data and padding octets not including L2 headers
5855 * for good broadcast frames.
5856 * Access: RW
5857 */
5858MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
5859
5860/* reg_ricnt_error_packets
5861 * A count of errored frames that do not pass the router checks.
5862 * Access: RW
5863 */
5864MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
5865
5866/* reg_ricnt_discrad_packets
5867 * A count of non-errored frames that do not pass the router checks.
5868 * Access: RW
5869 */
5870MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
5871
5872/* reg_ricnt_error_bytes
5873 * A count of L3 data and padding octets not including L2 headers
5874 * for errored frames.
5875 * Access: RW
5876 */
5877MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
5878
5879/* reg_ricnt_discard_bytes
5880 * A count of L3 data and padding octets not including L2 headers
5881 * for non-errored frames that do not pass the router checks.
5882 * Access: RW
5883 */
5884MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
5885
5886static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
5887 enum mlxsw_reg_ricnt_opcode op)
5888{
5889 MLXSW_REG_ZERO(ricnt, payload);
5890 mlxsw_reg_ricnt_op_set(payload, op);
5891 mlxsw_reg_ricnt_counter_index_set(payload, index);
5892 mlxsw_reg_ricnt_counter_set_type_set(payload,
5893 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
5894}
5895
Yotam Gigi4fc92842017-09-19 10:00:17 +02005896/* RRCR - Router Rules Copy Register Layout
5897 * ----------------------------------------
5898 * This register is used for moving and copying route entry rules.
5899 */
5900#define MLXSW_REG_RRCR_ID 0x800F
5901#define MLXSW_REG_RRCR_LEN 0x24
5902
5903MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
5904
5905enum mlxsw_reg_rrcr_op {
5906 /* Move rules */
5907 MLXSW_REG_RRCR_OP_MOVE,
5908 /* Copy rules */
5909 MLXSW_REG_RRCR_OP_COPY,
5910};
5911
5912/* reg_rrcr_op
5913 * Access: WO
5914 */
5915MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
5916
5917/* reg_rrcr_offset
5918 * Offset within the region from which to copy/move.
5919 * Access: Index
5920 */
5921MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
5922
5923/* reg_rrcr_size
5924 * The number of rules to copy/move.
5925 * Access: WO
5926 */
5927MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
5928
5929/* reg_rrcr_table_id
5930 * Identifier of the table on which to perform the operation. Encoding is the
5931 * same as in RTAR.key_type
5932 * Access: Index
5933 */
5934MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
5935
5936/* reg_rrcr_dest_offset
5937 * Offset within the region to which to copy/move
5938 * Access: Index
5939 */
5940MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
5941
5942static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
5943 u16 offset, u16 size,
5944 enum mlxsw_reg_rtar_key_type table_id,
5945 u16 dest_offset)
5946{
5947 MLXSW_REG_ZERO(rrcr, payload);
5948 mlxsw_reg_rrcr_op_set(payload, op);
5949 mlxsw_reg_rrcr_offset_set(payload, offset);
5950 mlxsw_reg_rrcr_size_set(payload, size);
5951 mlxsw_reg_rrcr_table_id_set(payload, table_id);
5952 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
5953}
5954
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02005955/* RALTA - Router Algorithmic LPM Tree Allocation Register
5956 * -------------------------------------------------------
5957 * RALTA is used to allocate the LPM trees of the SHSPM method.
5958 */
5959#define MLXSW_REG_RALTA_ID 0x8010
5960#define MLXSW_REG_RALTA_LEN 0x04
5961
Jiri Pirko21978dc2016-10-21 16:07:20 +02005962MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02005963
5964/* reg_ralta_op
5965 * opcode (valid for Write, must be 0 on Read)
5966 * 0 - allocate a tree
5967 * 1 - deallocate a tree
5968 * Access: OP
5969 */
5970MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
5971
5972enum mlxsw_reg_ralxx_protocol {
5973 MLXSW_REG_RALXX_PROTOCOL_IPV4,
5974 MLXSW_REG_RALXX_PROTOCOL_IPV6,
5975};
5976
5977/* reg_ralta_protocol
5978 * Protocol.
5979 * Deallocation opcode: Reserved.
5980 * Access: RW
5981 */
5982MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
5983
5984/* reg_ralta_tree_id
5985 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
5986 * the tree identifier (managed by software).
5987 * Note that tree_id 0 is allocated for a default-route tree.
5988 * Access: Index
5989 */
5990MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
5991
5992static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
5993 enum mlxsw_reg_ralxx_protocol protocol,
5994 u8 tree_id)
5995{
5996 MLXSW_REG_ZERO(ralta, payload);
5997 mlxsw_reg_ralta_op_set(payload, !alloc);
5998 mlxsw_reg_ralta_protocol_set(payload, protocol);
5999 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
6000}
6001
Jiri Pirkoa9823352016-07-04 08:23:06 +02006002/* RALST - Router Algorithmic LPM Structure Tree Register
6003 * ------------------------------------------------------
6004 * RALST is used to set and query the structure of an LPM tree.
6005 * The structure of the tree must be sorted as a sorted binary tree, while
6006 * each node is a bin that is tagged as the length of the prefixes the lookup
6007 * will refer to. Therefore, bin X refers to a set of entries with prefixes
6008 * of X bits to match with the destination address. The bin 0 indicates
6009 * the default action, when there is no match of any prefix.
6010 */
6011#define MLXSW_REG_RALST_ID 0x8011
6012#define MLXSW_REG_RALST_LEN 0x104
6013
Jiri Pirko21978dc2016-10-21 16:07:20 +02006014MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
Jiri Pirkoa9823352016-07-04 08:23:06 +02006015
6016/* reg_ralst_root_bin
6017 * The bin number of the root bin.
6018 * 0<root_bin=<(length of IP address)
6019 * For a default-route tree configure 0xff
6020 * Access: RW
6021 */
6022MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
6023
6024/* reg_ralst_tree_id
6025 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
6026 * Access: Index
6027 */
6028MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
6029
6030#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
6031#define MLXSW_REG_RALST_BIN_OFFSET 0x04
6032#define MLXSW_REG_RALST_BIN_COUNT 128
6033
6034/* reg_ralst_left_child_bin
6035 * Holding the children of the bin according to the stored tree's structure.
6036 * For trees composed of less than 4 blocks, the bins in excess are reserved.
6037 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
6038 * Access: RW
6039 */
6040MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
6041
6042/* reg_ralst_right_child_bin
6043 * Holding the children of the bin according to the stored tree's structure.
6044 * For trees composed of less than 4 blocks, the bins in excess are reserved.
6045 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
6046 * Access: RW
6047 */
6048MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
6049 false);
6050
6051static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
6052{
6053 MLXSW_REG_ZERO(ralst, payload);
6054
6055 /* Initialize all bins to have no left or right child */
6056 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
6057 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
6058
6059 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
6060 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
6061}
6062
6063static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
6064 u8 left_child_bin,
6065 u8 right_child_bin)
6066{
6067 int bin_index = bin_number - 1;
6068
6069 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
6070 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
6071 right_child_bin);
6072}
6073
Jiri Pirko20ae4052016-07-04 08:23:07 +02006074/* RALTB - Router Algorithmic LPM Tree Binding Register
6075 * ----------------------------------------------------
6076 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
6077 */
6078#define MLXSW_REG_RALTB_ID 0x8012
6079#define MLXSW_REG_RALTB_LEN 0x04
6080
Jiri Pirko21978dc2016-10-21 16:07:20 +02006081MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
Jiri Pirko20ae4052016-07-04 08:23:07 +02006082
6083/* reg_raltb_virtual_router
6084 * Virtual Router ID
6085 * Range is 0..cap_max_virtual_routers-1
6086 * Access: Index
6087 */
6088MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
6089
6090/* reg_raltb_protocol
6091 * Protocol.
6092 * Access: Index
6093 */
6094MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
6095
6096/* reg_raltb_tree_id
6097 * Tree to be used for the {virtual_router, protocol}
6098 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
6099 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
6100 * Access: RW
6101 */
6102MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
6103
6104static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
6105 enum mlxsw_reg_ralxx_protocol protocol,
6106 u8 tree_id)
6107{
6108 MLXSW_REG_ZERO(raltb, payload);
6109 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
6110 mlxsw_reg_raltb_protocol_set(payload, protocol);
6111 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
6112}
6113
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006114/* RALUE - Router Algorithmic LPM Unicast Entry Register
6115 * -----------------------------------------------------
6116 * RALUE is used to configure and query LPM entries that serve
6117 * the Unicast protocols.
6118 */
6119#define MLXSW_REG_RALUE_ID 0x8013
6120#define MLXSW_REG_RALUE_LEN 0x38
6121
Jiri Pirko21978dc2016-10-21 16:07:20 +02006122MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006123
6124/* reg_ralue_protocol
6125 * Protocol.
6126 * Access: Index
6127 */
6128MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
6129
6130enum mlxsw_reg_ralue_op {
6131 /* Read operation. If entry doesn't exist, the operation fails. */
6132 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
6133 /* Clear on read operation. Used to read entry and
6134 * clear Activity bit.
6135 */
6136 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
6137 /* Write operation. Used to write a new entry to the table. All RW
6138 * fields are written for new entry. Activity bit is set
6139 * for new entries.
6140 */
6141 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
6142 /* Update operation. Used to update an existing route entry and
6143 * only update the RW fields that are detailed in the field
6144 * op_u_mask. If entry doesn't exist, the operation fails.
6145 */
6146 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
6147 /* Clear activity. The Activity bit (the field a) is cleared
6148 * for the entry.
6149 */
6150 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
6151 /* Delete operation. Used to delete an existing entry. If entry
6152 * doesn't exist, the operation fails.
6153 */
6154 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
6155};
6156
6157/* reg_ralue_op
6158 * Operation.
6159 * Access: OP
6160 */
6161MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
6162
6163/* reg_ralue_a
6164 * Activity. Set for new entries. Set if a packet lookup has hit on the
6165 * specific entry, only if the entry is a route. To clear the a bit, use
6166 * "clear activity" op.
6167 * Enabled by activity_dis in RGCR
6168 * Access: RO
6169 */
6170MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
6171
6172/* reg_ralue_virtual_router
6173 * Virtual Router ID
6174 * Range is 0..cap_max_virtual_routers-1
6175 * Access: Index
6176 */
6177MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
6178
6179#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
6180#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
6181#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
6182
6183/* reg_ralue_op_u_mask
6184 * opcode update mask.
6185 * On read operation, this field is reserved.
6186 * This field is valid for update opcode, otherwise - reserved.
6187 * This field is a bitmask of the fields that should be updated.
6188 * Access: WO
6189 */
6190MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
6191
6192/* reg_ralue_prefix_len
6193 * Number of bits in the prefix of the LPM route.
6194 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
6195 * two entries in the physical HW table.
6196 * Access: Index
6197 */
6198MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
6199
6200/* reg_ralue_dip*
6201 * The prefix of the route or of the marker that the object of the LPM
6202 * is compared with. The most significant bits of the dip are the prefix.
Petr Machata806a1c1a2017-07-31 09:27:24 +02006203 * The least significant bits must be '0' if the prefix_len is smaller
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006204 * than 128 for IPv6 or smaller than 32 for IPv4.
6205 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
6206 * Access: Index
6207 */
6208MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
Ido Schimmel62547f42017-07-18 10:10:23 +02006209MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006210
6211enum mlxsw_reg_ralue_entry_type {
6212 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
6213 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
6214 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
6215};
6216
6217/* reg_ralue_entry_type
6218 * Entry type.
6219 * Note - for Marker entries, the action_type and action fields are reserved.
6220 * Access: RW
6221 */
6222MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
6223
6224/* reg_ralue_bmp_len
6225 * The best match prefix length in the case that there is no match for
6226 * longer prefixes.
6227 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
6228 * Note for any update operation with entry_type modification this
6229 * field must be set.
6230 * Access: RW
6231 */
6232MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
6233
6234enum mlxsw_reg_ralue_action_type {
6235 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
6236 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
6237 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
6238};
6239
6240/* reg_ralue_action_type
6241 * Action Type
6242 * Indicates how the IP address is connected.
6243 * It can be connected to a local subnet through local_erif or can be
6244 * on a remote subnet connected through a next-hop router,
6245 * or transmitted to the CPU.
6246 * Reserved when entry_type = MARKER_ENTRY
6247 * Access: RW
6248 */
6249MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
6250
6251enum mlxsw_reg_ralue_trap_action {
6252 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
6253 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
6254 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
6255 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
6256 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
6257};
6258
6259/* reg_ralue_trap_action
6260 * Trap action.
6261 * For IP2ME action, only NOP and MIRROR are possible.
6262 * Access: RW
6263 */
6264MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
6265
6266/* reg_ralue_trap_id
6267 * Trap ID to be reported to CPU.
6268 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
6269 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
6270 * Access: RW
6271 */
6272MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
6273
6274/* reg_ralue_adjacency_index
6275 * Points to the first entry of the group-based ECMP.
6276 * Only relevant in case of REMOTE action.
6277 * Access: RW
6278 */
6279MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
6280
6281/* reg_ralue_ecmp_size
6282 * Amount of sequential entries starting
6283 * from the adjacency_index (the number of ECMPs).
6284 * The valid range is 1-64, 512, 1024, 2048 and 4096.
6285 * Reserved when trap_action is TRAP or DISCARD_ERROR.
6286 * Only relevant in case of REMOTE action.
6287 * Access: RW
6288 */
6289MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
6290
6291/* reg_ralue_local_erif
6292 * Egress Router Interface.
6293 * Only relevant in case of LOCAL action.
6294 * Access: RW
6295 */
6296MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
6297
Petr Machata83930cd2017-07-31 09:27:27 +02006298/* reg_ralue_ip2me_v
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006299 * Valid bit for the tunnel_ptr field.
6300 * If valid = 0 then trap to CPU as IP2ME trap ID.
6301 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
6302 * decapsulation then tunnel decapsulation is done.
6303 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
6304 * decapsulation then trap as IP2ME trap ID.
6305 * Only relevant in case of IP2ME action.
6306 * Access: RW
6307 */
Petr Machata83930cd2017-07-31 09:27:27 +02006308MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006309
Petr Machata83930cd2017-07-31 09:27:27 +02006310/* reg_ralue_ip2me_tunnel_ptr
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006311 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
6312 * For Spectrum, pointer to KVD Linear.
6313 * Only relevant in case of IP2ME action.
6314 * Access: RW
6315 */
Petr Machata83930cd2017-07-31 09:27:27 +02006316MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006317
6318static inline void mlxsw_reg_ralue_pack(char *payload,
6319 enum mlxsw_reg_ralxx_protocol protocol,
6320 enum mlxsw_reg_ralue_op op,
6321 u16 virtual_router, u8 prefix_len)
6322{
6323 MLXSW_REG_ZERO(ralue, payload);
6324 mlxsw_reg_ralue_protocol_set(payload, protocol);
Jiri Pirko0e7df1a2016-08-17 16:39:34 +02006325 mlxsw_reg_ralue_op_set(payload, op);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006326 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
6327 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
6328 mlxsw_reg_ralue_entry_type_set(payload,
6329 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
6330 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
6331}
6332
6333static inline void mlxsw_reg_ralue_pack4(char *payload,
6334 enum mlxsw_reg_ralxx_protocol protocol,
6335 enum mlxsw_reg_ralue_op op,
6336 u16 virtual_router, u8 prefix_len,
6337 u32 dip)
6338{
6339 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
6340 mlxsw_reg_ralue_dip4_set(payload, dip);
6341}
6342
Ido Schimmel62547f42017-07-18 10:10:23 +02006343static inline void mlxsw_reg_ralue_pack6(char *payload,
6344 enum mlxsw_reg_ralxx_protocol protocol,
6345 enum mlxsw_reg_ralue_op op,
6346 u16 virtual_router, u8 prefix_len,
6347 const void *dip)
6348{
6349 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
6350 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
6351}
6352
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006353static inline void
6354mlxsw_reg_ralue_act_remote_pack(char *payload,
6355 enum mlxsw_reg_ralue_trap_action trap_action,
6356 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
6357{
6358 mlxsw_reg_ralue_action_type_set(payload,
6359 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
6360 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
6361 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
6362 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
6363 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
6364}
6365
6366static inline void
6367mlxsw_reg_ralue_act_local_pack(char *payload,
6368 enum mlxsw_reg_ralue_trap_action trap_action,
6369 u16 trap_id, u16 local_erif)
6370{
6371 mlxsw_reg_ralue_action_type_set(payload,
6372 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
6373 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
6374 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
6375 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
6376}
6377
6378static inline void
6379mlxsw_reg_ralue_act_ip2me_pack(char *payload)
6380{
6381 mlxsw_reg_ralue_action_type_set(payload,
6382 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
6383}
6384
Petr Machataa43da822017-09-02 23:49:12 +02006385static inline void
6386mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
6387{
6388 mlxsw_reg_ralue_action_type_set(payload,
6389 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
6390 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
6391 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
6392}
6393
Yotam Gigi4457b3df2016-07-05 11:27:40 +02006394/* RAUHT - Router Algorithmic LPM Unicast Host Table Register
6395 * ----------------------------------------------------------
6396 * The RAUHT register is used to configure and query the Unicast Host table in
6397 * devices that implement the Algorithmic LPM.
6398 */
6399#define MLXSW_REG_RAUHT_ID 0x8014
6400#define MLXSW_REG_RAUHT_LEN 0x74
6401
Jiri Pirko21978dc2016-10-21 16:07:20 +02006402MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02006403
6404enum mlxsw_reg_rauht_type {
6405 MLXSW_REG_RAUHT_TYPE_IPV4,
6406 MLXSW_REG_RAUHT_TYPE_IPV6,
6407};
6408
6409/* reg_rauht_type
6410 * Access: Index
6411 */
6412MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
6413
6414enum mlxsw_reg_rauht_op {
6415 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
6416 /* Read operation */
6417 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
6418 /* Clear on read operation. Used to read entry and clear
6419 * activity bit.
6420 */
6421 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
6422 /* Add. Used to write a new entry to the table. All R/W fields are
6423 * relevant for new entry. Activity bit is set for new entries.
6424 */
6425 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
6426 /* Update action. Used to update an existing route entry and
6427 * only update the following fields:
6428 * trap_action, trap_id, mac, counter_set_type, counter_index
6429 */
6430 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
6431 /* Clear activity. A bit is cleared for the entry. */
6432 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
6433 /* Delete entry */
6434 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
6435 /* Delete all host entries on a RIF. In this command, dip
6436 * field is reserved.
6437 */
6438};
6439
6440/* reg_rauht_op
6441 * Access: OP
6442 */
6443MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
6444
6445/* reg_rauht_a
6446 * Activity. Set for new entries. Set if a packet lookup has hit on
6447 * the specific entry.
6448 * To clear the a bit, use "clear activity" op.
6449 * Enabled by activity_dis in RGCR
6450 * Access: RO
6451 */
6452MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
6453
6454/* reg_rauht_rif
6455 * Router Interface
6456 * Access: Index
6457 */
6458MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
6459
6460/* reg_rauht_dip*
6461 * Destination address.
6462 * Access: Index
6463 */
6464MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02006465MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02006466
6467enum mlxsw_reg_rauht_trap_action {
6468 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
6469 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
6470 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
6471 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
6472 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
6473};
6474
6475/* reg_rauht_trap_action
6476 * Access: RW
6477 */
6478MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
6479
6480enum mlxsw_reg_rauht_trap_id {
6481 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
6482 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
6483};
6484
6485/* reg_rauht_trap_id
6486 * Trap ID to be reported to CPU.
6487 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
6488 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
6489 * trap_id is reserved.
6490 * Access: RW
6491 */
6492MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
6493
6494/* reg_rauht_counter_set_type
6495 * Counter set type for flow counters
6496 * Access: RW
6497 */
6498MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
6499
6500/* reg_rauht_counter_index
6501 * Counter index for flow counters
6502 * Access: RW
6503 */
6504MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
6505
6506/* reg_rauht_mac
6507 * MAC address.
6508 * Access: RW
6509 */
6510MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
6511
6512static inline void mlxsw_reg_rauht_pack(char *payload,
6513 enum mlxsw_reg_rauht_op op, u16 rif,
6514 const char *mac)
6515{
6516 MLXSW_REG_ZERO(rauht, payload);
6517 mlxsw_reg_rauht_op_set(payload, op);
6518 mlxsw_reg_rauht_rif_set(payload, rif);
6519 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
6520}
6521
6522static inline void mlxsw_reg_rauht_pack4(char *payload,
6523 enum mlxsw_reg_rauht_op op, u16 rif,
6524 const char *mac, u32 dip)
6525{
6526 mlxsw_reg_rauht_pack(payload, op, rif, mac);
6527 mlxsw_reg_rauht_dip4_set(payload, dip);
6528}
6529
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02006530static inline void mlxsw_reg_rauht_pack6(char *payload,
6531 enum mlxsw_reg_rauht_op op, u16 rif,
6532 const char *mac, const char *dip)
6533{
6534 mlxsw_reg_rauht_pack(payload, op, rif, mac);
6535 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
6536 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
6537}
6538
Arkadi Sharshevsky7cfcbc72017-08-24 08:40:08 +02006539static inline void mlxsw_reg_rauht_pack_counter(char *payload,
6540 u64 counter_index)
6541{
6542 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
6543 mlxsw_reg_rauht_counter_set_type_set(payload,
6544 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
6545}
6546
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02006547/* RALEU - Router Algorithmic LPM ECMP Update Register
6548 * ---------------------------------------------------
6549 * The register enables updating the ECMP section in the action for multiple
6550 * LPM Unicast entries in a single operation. The update is executed to
6551 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
6552 */
6553#define MLXSW_REG_RALEU_ID 0x8015
6554#define MLXSW_REG_RALEU_LEN 0x28
6555
Jiri Pirko21978dc2016-10-21 16:07:20 +02006556MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02006557
6558/* reg_raleu_protocol
6559 * Protocol.
6560 * Access: Index
6561 */
6562MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
6563
6564/* reg_raleu_virtual_router
6565 * Virtual Router ID
6566 * Range is 0..cap_max_virtual_routers-1
6567 * Access: Index
6568 */
6569MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
6570
6571/* reg_raleu_adjacency_index
6572 * Adjacency Index used for matching on the existing entries.
6573 * Access: Index
6574 */
6575MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
6576
6577/* reg_raleu_ecmp_size
6578 * ECMP Size used for matching on the existing entries.
6579 * Access: Index
6580 */
6581MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
6582
6583/* reg_raleu_new_adjacency_index
6584 * New Adjacency Index.
6585 * Access: WO
6586 */
6587MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
6588
6589/* reg_raleu_new_ecmp_size
6590 * New ECMP Size.
6591 * Access: WO
6592 */
6593MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
6594
6595static inline void mlxsw_reg_raleu_pack(char *payload,
6596 enum mlxsw_reg_ralxx_protocol protocol,
6597 u16 virtual_router,
6598 u32 adjacency_index, u16 ecmp_size,
6599 u32 new_adjacency_index,
6600 u16 new_ecmp_size)
6601{
6602 MLXSW_REG_ZERO(raleu, payload);
6603 mlxsw_reg_raleu_protocol_set(payload, protocol);
6604 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
6605 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
6606 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
6607 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
6608 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
6609}
6610
Yotam Gigi7cf2c202016-07-05 11:27:41 +02006611/* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
6612 * ----------------------------------------------------------------
6613 * The RAUHTD register allows dumping entries from the Router Unicast Host
6614 * Table. For a given session an entry is dumped no more than one time. The
6615 * first RAUHTD access after reset is a new session. A session ends when the
6616 * num_rec response is smaller than num_rec request or for IPv4 when the
6617 * num_entries is smaller than 4. The clear activity affect the current session
6618 * or the last session if a new session has not started.
6619 */
6620#define MLXSW_REG_RAUHTD_ID 0x8018
6621#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
6622#define MLXSW_REG_RAUHTD_REC_LEN 0x20
6623#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
6624#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
6625 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
6626#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
6627
Jiri Pirko21978dc2016-10-21 16:07:20 +02006628MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
Yotam Gigi7cf2c202016-07-05 11:27:41 +02006629
6630#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
6631#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
6632
6633/* reg_rauhtd_filter_fields
6634 * if a bit is '0' then the relevant field is ignored and dump is done
6635 * regardless of the field value
6636 * Bit0 - filter by activity: entry_a
6637 * Bit3 - filter by entry rip: entry_rif
6638 * Access: Index
6639 */
6640MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
6641
6642enum mlxsw_reg_rauhtd_op {
6643 MLXSW_REG_RAUHTD_OP_DUMP,
6644 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
6645};
6646
6647/* reg_rauhtd_op
6648 * Access: OP
6649 */
6650MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
6651
6652/* reg_rauhtd_num_rec
6653 * At request: number of records requested
6654 * At response: number of records dumped
6655 * For IPv4, each record has 4 entries at request and up to 4 entries
6656 * at response
6657 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
6658 * Access: Index
6659 */
6660MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
6661
6662/* reg_rauhtd_entry_a
6663 * Dump only if activity has value of entry_a
6664 * Reserved if filter_fields bit0 is '0'
6665 * Access: Index
6666 */
6667MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
6668
6669enum mlxsw_reg_rauhtd_type {
6670 MLXSW_REG_RAUHTD_TYPE_IPV4,
6671 MLXSW_REG_RAUHTD_TYPE_IPV6,
6672};
6673
6674/* reg_rauhtd_type
6675 * Dump only if record type is:
6676 * 0 - IPv4
6677 * 1 - IPv6
6678 * Access: Index
6679 */
6680MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
6681
6682/* reg_rauhtd_entry_rif
6683 * Dump only if RIF has value of entry_rif
6684 * Reserved if filter_fields bit3 is '0'
6685 * Access: Index
6686 */
6687MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
6688
6689static inline void mlxsw_reg_rauhtd_pack(char *payload,
6690 enum mlxsw_reg_rauhtd_type type)
6691{
6692 MLXSW_REG_ZERO(rauhtd, payload);
6693 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
6694 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
6695 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
6696 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
6697 mlxsw_reg_rauhtd_type_set(payload, type);
6698}
6699
6700/* reg_rauhtd_ipv4_rec_num_entries
6701 * Number of valid entries in this record:
6702 * 0 - 1 valid entry
6703 * 1 - 2 valid entries
6704 * 2 - 3 valid entries
6705 * 3 - 4 valid entries
6706 * Access: RO
6707 */
6708MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
6709 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
6710 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
6711
6712/* reg_rauhtd_rec_type
6713 * Record type.
6714 * 0 - IPv4
6715 * 1 - IPv6
6716 * Access: RO
6717 */
6718MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
6719 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
6720
6721#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
6722
6723/* reg_rauhtd_ipv4_ent_a
6724 * Activity. Set for new entries. Set if a packet lookup has hit on the
6725 * specific entry.
6726 * Access: RO
6727 */
6728MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
6729 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
6730
6731/* reg_rauhtd_ipv4_ent_rif
6732 * Router interface.
6733 * Access: RO
6734 */
6735MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6736 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
6737
6738/* reg_rauhtd_ipv4_ent_dip
6739 * Destination IPv4 address.
6740 * Access: RO
6741 */
6742MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6743 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
6744
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02006745#define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
6746
6747/* reg_rauhtd_ipv6_ent_a
6748 * Activity. Set for new entries. Set if a packet lookup has hit on the
6749 * specific entry.
6750 * Access: RO
6751 */
6752MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
6753 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
6754
6755/* reg_rauhtd_ipv6_ent_rif
6756 * Router interface.
6757 * Access: RO
6758 */
6759MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6760 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
6761
6762/* reg_rauhtd_ipv6_ent_dip
6763 * Destination IPv6 address.
6764 * Access: RO
6765 */
6766MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
6767 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
6768
Yotam Gigi7cf2c202016-07-05 11:27:41 +02006769static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
6770 int ent_index, u16 *p_rif,
6771 u32 *p_dip)
6772{
6773 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
6774 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
6775}
6776
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02006777static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
6778 int rec_index, u16 *p_rif,
6779 char *p_dip)
6780{
6781 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
6782 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
6783}
6784
Petr Machata1e659eb2017-09-02 23:49:13 +02006785/* RTDP - Routing Tunnel Decap Properties Register
6786 * -----------------------------------------------
6787 * The RTDP register is used for configuring the tunnel decap properties of NVE
6788 * and IPinIP.
6789 */
6790#define MLXSW_REG_RTDP_ID 0x8020
6791#define MLXSW_REG_RTDP_LEN 0x44
6792
6793MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
6794
6795enum mlxsw_reg_rtdp_type {
6796 MLXSW_REG_RTDP_TYPE_NVE,
6797 MLXSW_REG_RTDP_TYPE_IPIP,
6798};
6799
6800/* reg_rtdp_type
6801 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
6802 * Access: RW
6803 */
6804MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
6805
6806/* reg_rtdp_tunnel_index
6807 * Index to the Decap entry.
6808 * For Spectrum, Index to KVD Linear.
6809 * Access: Index
6810 */
6811MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
6812
6813/* IPinIP */
6814
6815/* reg_rtdp_ipip_irif
6816 * Ingress Router Interface for the overlay router
6817 * Access: RW
6818 */
6819MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
6820
6821enum mlxsw_reg_rtdp_ipip_sip_check {
6822 /* No sip checks. */
6823 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
6824 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
6825 * equal ipv4_usip.
6826 */
6827 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
6828 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
6829 * equal ipv6_usip.
6830 */
6831 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
6832};
6833
6834/* reg_rtdp_ipip_sip_check
6835 * SIP check to perform. If decapsulation failed due to these configurations
6836 * then trap_id is IPIP_DECAP_ERROR.
6837 * Access: RW
6838 */
6839MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
6840
6841/* If set, allow decapsulation of IPinIP (without GRE). */
6842#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
6843/* If set, allow decapsulation of IPinGREinIP without a key. */
6844#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
6845/* If set, allow decapsulation of IPinGREinIP with a key. */
6846#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
6847
6848/* reg_rtdp_ipip_type_check
6849 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
6850 * these configurations then trap_id is IPIP_DECAP_ERROR.
6851 * Access: RW
6852 */
6853MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
6854
6855/* reg_rtdp_ipip_gre_key_check
6856 * Whether GRE key should be checked. When check is enabled:
6857 * - A packet received as IPinIP (without GRE) will always pass.
6858 * - A packet received as IPinGREinIP without a key will not pass the check.
6859 * - A packet received as IPinGREinIP with a key will pass the check only if the
6860 * key in the packet is equal to expected_gre_key.
6861 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
6862 * Access: RW
6863 */
6864MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
6865
6866/* reg_rtdp_ipip_ipv4_usip
6867 * Underlay IPv4 address for ipv4 source address check.
6868 * Reserved when sip_check is not '1'.
6869 * Access: RW
6870 */
6871MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
6872
6873/* reg_rtdp_ipip_ipv6_usip_ptr
6874 * This field is valid when sip_check is "sipv6 check explicitly". This is a
6875 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
6876 * is to the KVD linear.
6877 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
6878 * Access: RW
6879 */
6880MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
6881
6882/* reg_rtdp_ipip_expected_gre_key
6883 * GRE key for checking.
6884 * Reserved when gre_key_check is '0'.
6885 * Access: RW
6886 */
6887MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
6888
6889static inline void mlxsw_reg_rtdp_pack(char *payload,
6890 enum mlxsw_reg_rtdp_type type,
6891 u32 tunnel_index)
6892{
6893 MLXSW_REG_ZERO(rtdp, payload);
6894 mlxsw_reg_rtdp_type_set(payload, type);
6895 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
6896}
6897
6898static inline void
6899mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
6900 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
6901 unsigned int type_check, bool gre_key_check,
6902 u32 ipv4_usip, u32 expected_gre_key)
6903{
6904 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
6905 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
6906 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
6907 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
6908 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
6909 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
6910}
6911
Yotam Gigi5080c7e2017-09-19 10:00:14 +02006912/* RIGR-V2 - Router Interface Group Register Version 2
6913 * ---------------------------------------------------
6914 * The RIGR_V2 register is used to add, remove and query egress interface list
6915 * of a multicast forwarding entry.
6916 */
6917#define MLXSW_REG_RIGR2_ID 0x8023
6918#define MLXSW_REG_RIGR2_LEN 0xB0
6919
6920#define MLXSW_REG_RIGR2_MAX_ERIFS 32
6921
6922MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
6923
6924/* reg_rigr2_rigr_index
6925 * KVD Linear index.
6926 * Access: Index
6927 */
6928MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
6929
6930/* reg_rigr2_vnext
6931 * Next RIGR Index is valid.
6932 * Access: RW
6933 */
6934MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
6935
6936/* reg_rigr2_next_rigr_index
6937 * Next RIGR Index. The index is to the KVD linear.
6938 * Reserved when vnxet = '0'.
6939 * Access: RW
6940 */
6941MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
6942
6943/* reg_rigr2_vrmid
6944 * RMID Index is valid.
6945 * Access: RW
6946 */
6947MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
6948
6949/* reg_rigr2_rmid_index
6950 * RMID Index.
6951 * Range 0 .. max_mid - 1
6952 * Reserved when vrmid = '0'.
6953 * The index is to the Port Group Table (PGT)
6954 * Access: RW
6955 */
6956MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
6957
6958/* reg_rigr2_erif_entry_v
6959 * Egress Router Interface is valid.
6960 * Note that low-entries must be set if high-entries are set. For
6961 * example: if erif_entry[2].v is set then erif_entry[1].v and
6962 * erif_entry[0].v must be set.
6963 * Index can be from 0 to cap_mc_erif_list_entries-1
6964 * Access: RW
6965 */
6966MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
6967
6968/* reg_rigr2_erif_entry_erif
6969 * Egress Router Interface.
6970 * Valid range is from 0 to cap_max_router_interfaces - 1
6971 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
6972 * Access: RW
6973 */
6974MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
6975
6976static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
6977 bool vnext, u32 next_rigr_index)
6978{
6979 MLXSW_REG_ZERO(rigr2, payload);
6980 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
6981 mlxsw_reg_rigr2_vnext_set(payload, vnext);
6982 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
6983 mlxsw_reg_rigr2_vrmid_set(payload, 0);
6984 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
6985}
6986
6987static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
6988 bool v, u16 erif)
6989{
6990 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
6991 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
6992}
6993
Ido Schimmele4718592017-11-02 17:14:08 +01006994/* RECR-V2 - Router ECMP Configuration Version 2 Register
6995 * ------------------------------------------------------
6996 */
6997#define MLXSW_REG_RECR2_ID 0x8025
6998#define MLXSW_REG_RECR2_LEN 0x38
6999
7000MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
7001
7002/* reg_recr2_pp
7003 * Per-port configuration
7004 * Access: Index
7005 */
7006MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
7007
7008/* reg_recr2_sh
7009 * Symmetric hash
7010 * Access: RW
7011 */
7012MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
7013
7014/* reg_recr2_seed
7015 * Seed
7016 * Access: RW
7017 */
7018MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
7019
7020enum {
7021 /* Enable IPv4 fields if packet is not TCP and not UDP */
7022 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
7023 /* Enable IPv4 fields if packet is TCP or UDP */
7024 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
7025 /* Enable IPv6 fields if packet is not TCP and not UDP */
7026 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
7027 /* Enable IPv6 fields if packet is TCP or UDP */
7028 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
7029 /* Enable TCP/UDP header fields if packet is IPv4 */
7030 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
7031 /* Enable TCP/UDP header fields if packet is IPv6 */
7032 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
7033};
7034
7035/* reg_recr2_outer_header_enables
7036 * Bit mask where each bit enables a specific layer to be included in
7037 * the hash calculation.
7038 * Access: RW
7039 */
7040MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
7041
7042enum {
7043 /* IPv4 Source IP */
7044 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
7045 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
7046 /* IPv4 Destination IP */
7047 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
7048 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
7049 /* IP Protocol */
7050 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
7051 /* IPv6 Source IP */
7052 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
7053 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
7054 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
7055 /* IPv6 Destination IP */
7056 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
7057 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
7058 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
7059 /* IPv6 Next Header */
7060 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
7061 /* IPv6 Flow Label */
7062 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
7063 /* TCP/UDP Source Port */
7064 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
7065 /* TCP/UDP Destination Port */
7066 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
7067};
7068
7069/* reg_recr2_outer_header_fields_enable
7070 * Packet fields to enable for ECMP hash subject to outer_header_enable.
7071 * Access: RW
7072 */
7073MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
7074
7075static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
7076{
7077 int i;
7078
7079 for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
7080 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7081 true);
7082}
7083
7084static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
7085{
7086 int i;
7087
7088 for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
7089 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7090 true);
7091}
7092
7093static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
7094{
7095 int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
7096
7097 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7098
7099 i = MLXSW_REG_RECR2_IPV6_SIP8;
7100 for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
7101 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7102 true);
7103}
7104
7105static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
7106{
7107 int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
7108
7109 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7110
7111 i = MLXSW_REG_RECR2_IPV6_DIP8;
7112 for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
7113 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7114 true);
7115}
7116
7117static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
7118{
7119 MLXSW_REG_ZERO(recr2, payload);
7120 mlxsw_reg_recr2_pp_set(payload, false);
7121 mlxsw_reg_recr2_sh_set(payload, true);
7122 mlxsw_reg_recr2_seed_set(payload, seed);
7123}
7124
Yotam Gigi2e654e32017-09-19 10:00:16 +02007125/* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
7126 * --------------------------------------------------------------
7127 * The RMFT_V2 register is used to configure and query the multicast table.
7128 */
7129#define MLXSW_REG_RMFT2_ID 0x8027
7130#define MLXSW_REG_RMFT2_LEN 0x174
7131
7132MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
7133
7134/* reg_rmft2_v
7135 * Valid
7136 * Access: RW
7137 */
7138MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
7139
7140enum mlxsw_reg_rmft2_type {
7141 MLXSW_REG_RMFT2_TYPE_IPV4,
7142 MLXSW_REG_RMFT2_TYPE_IPV6
7143};
7144
7145/* reg_rmft2_type
7146 * Access: Index
7147 */
7148MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
7149
7150enum mlxsw_sp_reg_rmft2_op {
7151 /* For Write:
7152 * Write operation. Used to write a new entry to the table. All RW
7153 * fields are relevant for new entry. Activity bit is set for new
7154 * entries - Note write with v (Valid) 0 will delete the entry.
7155 * For Query:
7156 * Read operation
7157 */
7158 MLXSW_REG_RMFT2_OP_READ_WRITE,
7159};
7160
7161/* reg_rmft2_op
7162 * Operation.
7163 * Access: OP
7164 */
7165MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
7166
7167/* reg_rmft2_a
7168 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
7169 * entry.
7170 * Access: RO
7171 */
7172MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
7173
7174/* reg_rmft2_offset
7175 * Offset within the multicast forwarding table to write to.
7176 * Access: Index
7177 */
7178MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
7179
7180/* reg_rmft2_virtual_router
7181 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
7182 * Access: RW
7183 */
7184MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
7185
7186enum mlxsw_reg_rmft2_irif_mask {
7187 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
7188 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
7189};
7190
7191/* reg_rmft2_irif_mask
7192 * Ingress RIF mask.
7193 * Access: RW
7194 */
7195MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
7196
7197/* reg_rmft2_irif
7198 * Ingress RIF index.
7199 * Access: RW
7200 */
7201MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
7202
Yuval Mintza82b1b82018-03-26 15:01:38 +03007203/* reg_rmft2_dip{4,6}
7204 * Destination IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02007205 * Access: RW
7206 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007207MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007208MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
7209
Yuval Mintza82b1b82018-03-26 15:01:38 +03007210/* reg_rmft2_dip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02007211 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
7212 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
7213 * Access: RW
7214 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007215MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007216MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
7217
Yuval Mintza82b1b82018-03-26 15:01:38 +03007218/* reg_rmft2_sip{4,6}
7219 * Source IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02007220 * Access: RW
7221 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007222MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007223MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
7224
Yuval Mintza82b1b82018-03-26 15:01:38 +03007225/* reg_rmft2_sip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02007226 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
7227 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
7228 * Access: RW
7229 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007230MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007231MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
7232
7233/* reg_rmft2_flexible_action_set
7234 * ACL action set. The only supported action types in this field and in any
7235 * action-set pointed from here are as follows:
7236 * 00h: ACTION_NULL
7237 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
7238 * 03h: ACTION_TRAP
7239 * 06h: ACTION_QOS
7240 * 08h: ACTION_POLICING_MONITORING
7241 * 10h: ACTION_ROUTER_MC
7242 * Access: RW
7243 */
7244MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
7245 MLXSW_REG_FLEX_ACTION_SET_LEN);
7246
7247static inline void
Yuval Mintza82b1b82018-03-26 15:01:38 +03007248mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
7249 u16 virtual_router,
7250 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7251 const char *flex_action_set)
Yotam Gigi2e654e32017-09-19 10:00:16 +02007252{
7253 MLXSW_REG_ZERO(rmft2, payload);
7254 mlxsw_reg_rmft2_v_set(payload, v);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007255 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
7256 mlxsw_reg_rmft2_offset_set(payload, offset);
7257 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
7258 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
7259 mlxsw_reg_rmft2_irif_set(payload, irif);
Yuval Mintza82b1b82018-03-26 15:01:38 +03007260 if (flex_action_set)
7261 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
7262 flex_action_set);
7263}
7264
7265static inline void
7266mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
7267 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7268 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
7269 const char *flexible_action_set)
7270{
7271 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
7272 irif_mask, irif, flexible_action_set);
7273 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007274 mlxsw_reg_rmft2_dip4_set(payload, dip4);
7275 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
7276 mlxsw_reg_rmft2_sip4_set(payload, sip4);
7277 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
Yuval Mintza82b1b82018-03-26 15:01:38 +03007278}
7279
7280static inline void
7281mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
7282 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7283 struct in6_addr dip6, struct in6_addr dip6_mask,
7284 struct in6_addr sip6, struct in6_addr sip6_mask,
7285 const char *flexible_action_set)
7286{
7287 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
7288 irif_mask, irif, flexible_action_set);
7289 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
7290 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
7291 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
7292 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
7293 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007294}
7295
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007296/* MFCR - Management Fan Control Register
7297 * --------------------------------------
7298 * This register controls the settings of the Fan Speed PWM mechanism.
7299 */
7300#define MLXSW_REG_MFCR_ID 0x9001
7301#define MLXSW_REG_MFCR_LEN 0x08
7302
Jiri Pirko21978dc2016-10-21 16:07:20 +02007303MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007304
7305enum mlxsw_reg_mfcr_pwm_frequency {
7306 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
7307 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
7308 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
7309 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
7310 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
7311 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
7312 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
7313 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
7314};
7315
7316/* reg_mfcr_pwm_frequency
7317 * Controls the frequency of the PWM signal.
7318 * Access: RW
7319 */
Jiri Pirkof7ad3d42016-11-11 11:22:53 +01007320MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007321
7322#define MLXSW_MFCR_TACHOS_MAX 10
7323
7324/* reg_mfcr_tacho_active
7325 * Indicates which of the tachometer is active (bit per tachometer).
7326 * Access: RO
7327 */
7328MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
7329
7330#define MLXSW_MFCR_PWMS_MAX 5
7331
7332/* reg_mfcr_pwm_active
7333 * Indicates which of the PWM control is active (bit per PWM).
7334 * Access: RO
7335 */
7336MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
7337
7338static inline void
7339mlxsw_reg_mfcr_pack(char *payload,
7340 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
7341{
7342 MLXSW_REG_ZERO(mfcr, payload);
7343 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
7344}
7345
7346static inline void
7347mlxsw_reg_mfcr_unpack(char *payload,
7348 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
7349 u16 *p_tacho_active, u8 *p_pwm_active)
7350{
7351 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
7352 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
7353 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
7354}
7355
7356/* MFSC - Management Fan Speed Control Register
7357 * --------------------------------------------
7358 * This register controls the settings of the Fan Speed PWM mechanism.
7359 */
7360#define MLXSW_REG_MFSC_ID 0x9002
7361#define MLXSW_REG_MFSC_LEN 0x08
7362
Jiri Pirko21978dc2016-10-21 16:07:20 +02007363MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007364
7365/* reg_mfsc_pwm
7366 * Fan pwm to control / monitor.
7367 * Access: Index
7368 */
7369MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
7370
7371/* reg_mfsc_pwm_duty_cycle
7372 * Controls the duty cycle of the PWM. Value range from 0..255 to
7373 * represent duty cycle of 0%...100%.
7374 * Access: RW
7375 */
7376MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
7377
7378static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
7379 u8 pwm_duty_cycle)
7380{
7381 MLXSW_REG_ZERO(mfsc, payload);
7382 mlxsw_reg_mfsc_pwm_set(payload, pwm);
7383 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
7384}
7385
7386/* MFSM - Management Fan Speed Measurement
7387 * ---------------------------------------
7388 * This register controls the settings of the Tacho measurements and
7389 * enables reading the Tachometer measurements.
7390 */
7391#define MLXSW_REG_MFSM_ID 0x9003
7392#define MLXSW_REG_MFSM_LEN 0x08
7393
Jiri Pirko21978dc2016-10-21 16:07:20 +02007394MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007395
7396/* reg_mfsm_tacho
7397 * Fan tachometer index.
7398 * Access: Index
7399 */
7400MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
7401
7402/* reg_mfsm_rpm
7403 * Fan speed (round per minute).
7404 * Access: RO
7405 */
7406MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
7407
7408static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
7409{
7410 MLXSW_REG_ZERO(mfsm, payload);
7411 mlxsw_reg_mfsm_tacho_set(payload, tacho);
7412}
7413
Jiri Pirko55c63aa2016-11-22 11:24:12 +01007414/* MFSL - Management Fan Speed Limit Register
7415 * ------------------------------------------
7416 * The Fan Speed Limit register is used to configure the fan speed
7417 * event / interrupt notification mechanism. Fan speed threshold are
7418 * defined for both under-speed and over-speed.
7419 */
7420#define MLXSW_REG_MFSL_ID 0x9004
7421#define MLXSW_REG_MFSL_LEN 0x0C
7422
7423MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
7424
7425/* reg_mfsl_tacho
7426 * Fan tachometer index.
7427 * Access: Index
7428 */
7429MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
7430
7431/* reg_mfsl_tach_min
7432 * Tachometer minimum value (minimum RPM).
7433 * Access: RW
7434 */
7435MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
7436
7437/* reg_mfsl_tach_max
7438 * Tachometer maximum value (maximum RPM).
7439 * Access: RW
7440 */
7441MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
7442
7443static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
7444 u16 tach_min, u16 tach_max)
7445{
7446 MLXSW_REG_ZERO(mfsl, payload);
7447 mlxsw_reg_mfsl_tacho_set(payload, tacho);
7448 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
7449 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
7450}
7451
7452static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
7453 u16 *p_tach_min, u16 *p_tach_max)
7454{
7455 if (p_tach_min)
7456 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
7457
7458 if (p_tach_max)
7459 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
7460}
7461
Jiri Pirko85926f82015-11-27 13:45:56 +01007462/* MTCAP - Management Temperature Capabilities
7463 * -------------------------------------------
7464 * This register exposes the capabilities of the device and
7465 * system temperature sensing.
7466 */
7467#define MLXSW_REG_MTCAP_ID 0x9009
7468#define MLXSW_REG_MTCAP_LEN 0x08
7469
Jiri Pirko21978dc2016-10-21 16:07:20 +02007470MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01007471
7472/* reg_mtcap_sensor_count
7473 * Number of sensors supported by the device.
7474 * This includes the QSFP module sensors (if exists in the QSFP module).
7475 * Access: RO
7476 */
7477MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
7478
7479/* MTMP - Management Temperature
7480 * -----------------------------
7481 * This register controls the settings of the temperature measurements
7482 * and enables reading the temperature measurements. Note that temperature
7483 * is in 0.125 degrees Celsius.
7484 */
7485#define MLXSW_REG_MTMP_ID 0x900A
7486#define MLXSW_REG_MTMP_LEN 0x20
7487
Jiri Pirko21978dc2016-10-21 16:07:20 +02007488MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01007489
7490/* reg_mtmp_sensor_index
7491 * Sensors index to access.
7492 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
7493 * (module 0 is mapped to sensor_index 64).
7494 * Access: Index
7495 */
7496MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
7497
7498/* Convert to milli degrees Celsius */
7499#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
7500
7501/* reg_mtmp_temperature
7502 * Temperature reading from the sensor. Reading is in 0.125 Celsius
7503 * degrees units.
7504 * Access: RO
7505 */
7506MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
7507
7508/* reg_mtmp_mte
7509 * Max Temperature Enable - enables measuring the max temperature on a sensor.
7510 * Access: RW
7511 */
7512MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
7513
7514/* reg_mtmp_mtr
7515 * Max Temperature Reset - clears the value of the max temperature register.
7516 * Access: WO
7517 */
7518MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
7519
7520/* reg_mtmp_max_temperature
7521 * The highest measured temperature from the sensor.
7522 * When the bit mte is cleared, the field max_temperature is reserved.
7523 * Access: RO
7524 */
7525MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
7526
Ido Schimmel62b0e922017-10-30 10:51:18 +01007527/* reg_mtmp_tee
7528 * Temperature Event Enable.
7529 * 0 - Do not generate event
7530 * 1 - Generate event
7531 * 2 - Generate single event
7532 * Access: RW
7533 */
7534MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
7535
7536#define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
7537
7538/* reg_mtmp_temperature_threshold_hi
7539 * High threshold for Temperature Warning Event. In 0.125 Celsius.
7540 * Access: RW
7541 */
7542MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
7543
7544/* reg_mtmp_temperature_threshold_lo
7545 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
7546 * Access: RW
7547 */
7548MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
7549
Jiri Pirko85926f82015-11-27 13:45:56 +01007550#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
7551
7552/* reg_mtmp_sensor_name
7553 * Sensor Name
7554 * Access: RO
7555 */
7556MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
7557
7558static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
7559 bool max_temp_enable,
7560 bool max_temp_reset)
7561{
7562 MLXSW_REG_ZERO(mtmp, payload);
7563 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
7564 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
7565 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
Ido Schimmel62b0e922017-10-30 10:51:18 +01007566 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
7567 MLXSW_REG_MTMP_THRESH_HI);
Jiri Pirko85926f82015-11-27 13:45:56 +01007568}
7569
7570static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
7571 unsigned int *p_max_temp,
7572 char *sensor_name)
7573{
7574 u16 temp;
7575
7576 if (p_temp) {
7577 temp = mlxsw_reg_mtmp_temperature_get(payload);
7578 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
7579 }
7580 if (p_max_temp) {
Jiri Pirkoacf35a42015-12-11 16:10:39 +01007581 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
Jiri Pirko85926f82015-11-27 13:45:56 +01007582 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
7583 }
7584 if (sensor_name)
7585 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
7586}
7587
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02007588/* MCIA - Management Cable Info Access
7589 * -----------------------------------
7590 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
7591 */
7592
7593#define MLXSW_REG_MCIA_ID 0x9014
7594#define MLXSW_REG_MCIA_LEN 0x40
7595
7596MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
7597
7598/* reg_mcia_l
7599 * Lock bit. Setting this bit will lock the access to the specific
7600 * cable. Used for updating a full page in a cable EPROM. Any access
7601 * other then subsequence writes will fail while the port is locked.
7602 * Access: RW
7603 */
7604MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
7605
7606/* reg_mcia_module
7607 * Module number.
7608 * Access: Index
7609 */
7610MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
7611
7612/* reg_mcia_status
7613 * Module status.
7614 * Access: RO
7615 */
7616MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
7617
7618/* reg_mcia_i2c_device_address
7619 * I2C device address.
7620 * Access: RW
7621 */
7622MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
7623
7624/* reg_mcia_page_number
7625 * Page number.
7626 * Access: RW
7627 */
7628MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
7629
7630/* reg_mcia_device_address
7631 * Device address.
7632 * Access: RW
7633 */
7634MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
7635
7636/* reg_mcia_size
7637 * Number of bytes to read/write (up to 48 bytes).
7638 * Access: RW
7639 */
7640MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
7641
7642#define MLXSW_SP_REG_MCIA_EEPROM_SIZE 48
7643
7644/* reg_mcia_eeprom
7645 * Bytes to read/write.
7646 * Access: RW
7647 */
7648MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_SP_REG_MCIA_EEPROM_SIZE);
7649
7650static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
7651 u8 page_number, u16 device_addr,
7652 u8 size, u8 i2c_device_addr)
7653{
7654 MLXSW_REG_ZERO(mcia, payload);
7655 mlxsw_reg_mcia_module_set(payload, module);
7656 mlxsw_reg_mcia_l_set(payload, lock);
7657 mlxsw_reg_mcia_page_number_set(payload, page_number);
7658 mlxsw_reg_mcia_device_address_set(payload, device_addr);
7659 mlxsw_reg_mcia_size_set(payload, size);
7660 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
7661}
7662
Yotam Gigi43a46852016-07-21 12:03:14 +02007663/* MPAT - Monitoring Port Analyzer Table
7664 * -------------------------------------
7665 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
7666 * For an enabled analyzer, all fields except e (enable) cannot be modified.
7667 */
7668#define MLXSW_REG_MPAT_ID 0x901A
7669#define MLXSW_REG_MPAT_LEN 0x78
7670
Jiri Pirko21978dc2016-10-21 16:07:20 +02007671MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
Yotam Gigi43a46852016-07-21 12:03:14 +02007672
7673/* reg_mpat_pa_id
7674 * Port Analyzer ID.
7675 * Access: Index
7676 */
7677MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
7678
7679/* reg_mpat_system_port
7680 * A unique port identifier for the final destination of the packet.
7681 * Access: RW
7682 */
7683MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
7684
7685/* reg_mpat_e
7686 * Enable. Indicating the Port Analyzer is enabled.
7687 * Access: RW
7688 */
7689MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
7690
7691/* reg_mpat_qos
7692 * Quality Of Service Mode.
7693 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
7694 * PCP, DEI, DSCP or VL) are configured.
7695 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
7696 * same as in the original packet that has triggered the mirroring. For
7697 * SPAN also the pcp,dei are maintained.
7698 * Access: RW
7699 */
7700MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
7701
Yotam Gigi23019052016-07-21 12:03:15 +02007702/* reg_mpat_be
7703 * Best effort mode. Indicates mirroring traffic should not cause packet
7704 * drop or back pressure, but will discard the mirrored packets. Mirrored
7705 * packets will be forwarded on a best effort manner.
7706 * 0: Do not discard mirrored packets
7707 * 1: Discard mirrored packets if causing congestion
7708 * Access: RW
7709 */
7710MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
7711
Petr Machata0d6cd3f2018-02-27 14:53:39 +01007712enum mlxsw_reg_mpat_span_type {
7713 /* Local SPAN Ethernet.
7714 * The original packet is not encapsulated.
7715 */
7716 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
7717
Petr Machata41947662018-05-10 13:13:04 +03007718 /* Remote SPAN Ethernet VLAN.
7719 * The packet is forwarded to the monitoring port on the monitoring
7720 * VLAN.
7721 */
7722 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
7723
Petr Machata0d6cd3f2018-02-27 14:53:39 +01007724 /* Encapsulated Remote SPAN Ethernet L3 GRE.
7725 * The packet is encapsulated with GRE header.
7726 */
7727 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
7728};
7729
7730/* reg_mpat_span_type
7731 * SPAN type.
7732 * Access: RW
7733 */
7734MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
7735
7736/* Remote SPAN - Ethernet VLAN
7737 * - - - - - - - - - - - - - -
7738 */
7739
7740/* reg_mpat_eth_rspan_vid
7741 * Encapsulation header VLAN ID.
7742 * Access: RW
7743 */
7744MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
7745
7746/* Encapsulated Remote SPAN - Ethernet L2
7747 * - - - - - - - - - - - - - - - - - - -
7748 */
7749
7750enum mlxsw_reg_mpat_eth_rspan_version {
7751 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
7752};
7753
7754/* reg_mpat_eth_rspan_version
7755 * RSPAN mirror header version.
7756 * Access: RW
7757 */
7758MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
7759
7760/* reg_mpat_eth_rspan_mac
7761 * Destination MAC address.
7762 * Access: RW
7763 */
7764MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
7765
7766/* reg_mpat_eth_rspan_tp
7767 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
7768 * Access: RW
7769 */
7770MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
7771
7772/* Encapsulated Remote SPAN - Ethernet L3
7773 * - - - - - - - - - - - - - - - - - - -
7774 */
7775
7776enum mlxsw_reg_mpat_eth_rspan_protocol {
7777 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
7778 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
7779};
7780
7781/* reg_mpat_eth_rspan_protocol
7782 * SPAN encapsulation protocol.
7783 * Access: RW
7784 */
7785MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
7786
7787/* reg_mpat_eth_rspan_ttl
7788 * Encapsulation header Time-to-Live/HopLimit.
7789 * Access: RW
7790 */
7791MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
7792
7793/* reg_mpat_eth_rspan_smac
7794 * Source MAC address
7795 * Access: RW
7796 */
7797MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
7798
7799/* reg_mpat_eth_rspan_dip*
7800 * Destination IP address. The IP version is configured by protocol.
7801 * Access: RW
7802 */
7803MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
7804MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
7805
7806/* reg_mpat_eth_rspan_sip*
7807 * Source IP address. The IP version is configured by protocol.
7808 * Access: RW
7809 */
7810MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
7811MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
7812
Yotam Gigi43a46852016-07-21 12:03:14 +02007813static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
Petr Machata1da93eb2018-02-27 14:53:40 +01007814 u16 system_port, bool e,
7815 enum mlxsw_reg_mpat_span_type span_type)
Yotam Gigi43a46852016-07-21 12:03:14 +02007816{
7817 MLXSW_REG_ZERO(mpat, payload);
7818 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
7819 mlxsw_reg_mpat_system_port_set(payload, system_port);
7820 mlxsw_reg_mpat_e_set(payload, e);
7821 mlxsw_reg_mpat_qos_set(payload, 1);
Yotam Gigi23019052016-07-21 12:03:15 +02007822 mlxsw_reg_mpat_be_set(payload, 1);
Petr Machata1da93eb2018-02-27 14:53:40 +01007823 mlxsw_reg_mpat_span_type_set(payload, span_type);
Yotam Gigi23019052016-07-21 12:03:15 +02007824}
7825
Petr Machata0d6cd3f2018-02-27 14:53:39 +01007826static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
7827{
7828 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
7829}
7830
7831static inline void
7832mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
7833 enum mlxsw_reg_mpat_eth_rspan_version version,
7834 const char *mac,
7835 bool tp)
7836{
7837 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
7838 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
7839 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
7840}
7841
7842static inline void
7843mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
7844 const char *smac,
7845 u32 sip, u32 dip)
7846{
7847 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
7848 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
7849 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
7850 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
7851 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
7852 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
7853}
7854
7855static inline void
7856mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
7857 const char *smac,
7858 struct in6_addr sip, struct in6_addr dip)
7859{
7860 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
7861 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
7862 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
7863 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
7864 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
7865 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
7866}
7867
Yotam Gigi23019052016-07-21 12:03:15 +02007868/* MPAR - Monitoring Port Analyzer Register
7869 * ----------------------------------------
7870 * MPAR register is used to query and configure the port analyzer port mirroring
7871 * properties.
7872 */
7873#define MLXSW_REG_MPAR_ID 0x901B
7874#define MLXSW_REG_MPAR_LEN 0x08
7875
Jiri Pirko21978dc2016-10-21 16:07:20 +02007876MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
Yotam Gigi23019052016-07-21 12:03:15 +02007877
7878/* reg_mpar_local_port
7879 * The local port to mirror the packets from.
7880 * Access: Index
7881 */
7882MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
7883
7884enum mlxsw_reg_mpar_i_e {
7885 MLXSW_REG_MPAR_TYPE_EGRESS,
7886 MLXSW_REG_MPAR_TYPE_INGRESS,
7887};
7888
7889/* reg_mpar_i_e
7890 * Ingress/Egress
7891 * Access: Index
7892 */
7893MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
7894
7895/* reg_mpar_enable
7896 * Enable mirroring
7897 * By default, port mirroring is disabled for all ports.
7898 * Access: RW
7899 */
7900MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
7901
7902/* reg_mpar_pa_id
7903 * Port Analyzer ID.
7904 * Access: RW
7905 */
7906MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
7907
7908static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
7909 enum mlxsw_reg_mpar_i_e i_e,
7910 bool enable, u8 pa_id)
7911{
7912 MLXSW_REG_ZERO(mpar, payload);
7913 mlxsw_reg_mpar_local_port_set(payload, local_port);
7914 mlxsw_reg_mpar_enable_set(payload, enable);
7915 mlxsw_reg_mpar_i_e_set(payload, i_e);
7916 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
Yotam Gigi43a46852016-07-21 12:03:14 +02007917}
7918
Jiri Pirko12b003b2018-05-27 09:56:13 +03007919/* MRSR - Management Reset and Shutdown Register
7920 * ---------------------------------------------
7921 * MRSR register is used to reset or shutdown the switch or
7922 * the entire system (when applicable).
7923 */
7924#define MLXSW_REG_MRSR_ID 0x9023
7925#define MLXSW_REG_MRSR_LEN 0x08
7926
7927MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
7928
7929/* reg_mrsr_command
7930 * Reset/shutdown command
7931 * 0 - do nothing
7932 * 1 - software reset
7933 * Access: WO
7934 */
7935MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
7936
7937static inline void mlxsw_reg_mrsr_pack(char *payload)
7938{
7939 MLXSW_REG_ZERO(mrsr, payload);
7940 mlxsw_reg_mrsr_command_set(payload, 1);
7941}
7942
Ido Schimmel3161c152015-11-27 13:45:54 +01007943/* MLCR - Management LED Control Register
7944 * --------------------------------------
7945 * Controls the system LEDs.
7946 */
7947#define MLXSW_REG_MLCR_ID 0x902B
7948#define MLXSW_REG_MLCR_LEN 0x0C
7949
Jiri Pirko21978dc2016-10-21 16:07:20 +02007950MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
Ido Schimmel3161c152015-11-27 13:45:54 +01007951
7952/* reg_mlcr_local_port
7953 * Local port number.
7954 * Access: RW
7955 */
7956MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
7957
7958#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
7959
7960/* reg_mlcr_beacon_duration
7961 * Duration of the beacon to be active, in seconds.
7962 * 0x0 - Will turn off the beacon.
7963 * 0xFFFF - Will turn on the beacon until explicitly turned off.
7964 * Access: RW
7965 */
7966MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
7967
7968/* reg_mlcr_beacon_remain
7969 * Remaining duration of the beacon, in seconds.
7970 * 0xFFFF indicates an infinite amount of time.
7971 * Access: RO
7972 */
7973MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
7974
7975static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
7976 bool active)
7977{
7978 MLXSW_REG_ZERO(mlcr, payload);
7979 mlxsw_reg_mlcr_local_port_set(payload, local_port);
7980 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
7981 MLXSW_REG_MLCR_DURATION_MAX : 0);
7982}
7983
Yotam Gigi4f2402d2017-05-23 21:56:24 +02007984/* MCQI - Management Component Query Information
7985 * ---------------------------------------------
7986 * This register allows querying information about firmware components.
7987 */
7988#define MLXSW_REG_MCQI_ID 0x9061
7989#define MLXSW_REG_MCQI_BASE_LEN 0x18
7990#define MLXSW_REG_MCQI_CAP_LEN 0x14
7991#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
7992
7993MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
7994
7995/* reg_mcqi_component_index
7996 * Index of the accessed component.
7997 * Access: Index
7998 */
7999MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
8000
8001enum mlxfw_reg_mcqi_info_type {
8002 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
8003};
8004
8005/* reg_mcqi_info_type
8006 * Component properties set.
8007 * Access: RW
8008 */
8009MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
8010
8011/* reg_mcqi_offset
8012 * The requested/returned data offset from the section start, given in bytes.
8013 * Must be DWORD aligned.
8014 * Access: RW
8015 */
8016MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
8017
8018/* reg_mcqi_data_size
8019 * The requested/returned data size, given in bytes. If data_size is not DWORD
8020 * aligned, the last bytes are zero padded.
8021 * Access: RW
8022 */
8023MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
8024
8025/* reg_mcqi_cap_max_component_size
8026 * Maximum size for this component, given in bytes.
8027 * Access: RO
8028 */
8029MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
8030
8031/* reg_mcqi_cap_log_mcda_word_size
8032 * Log 2 of the access word size in bytes. Read and write access must be aligned
8033 * to the word size. Write access must be done for an integer number of words.
8034 * Access: RO
8035 */
8036MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
8037
8038/* reg_mcqi_cap_mcda_max_write_size
8039 * Maximal write size for MCDA register
8040 * Access: RO
8041 */
8042MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
8043
8044static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
8045{
8046 MLXSW_REG_ZERO(mcqi, payload);
8047 mlxsw_reg_mcqi_component_index_set(payload, component_index);
8048 mlxsw_reg_mcqi_info_type_set(payload,
8049 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
8050 mlxsw_reg_mcqi_offset_set(payload, 0);
8051 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
8052}
8053
8054static inline void mlxsw_reg_mcqi_unpack(char *payload,
8055 u32 *p_cap_max_component_size,
8056 u8 *p_cap_log_mcda_word_size,
8057 u16 *p_cap_mcda_max_write_size)
8058{
8059 *p_cap_max_component_size =
8060 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
8061 *p_cap_log_mcda_word_size =
8062 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
8063 *p_cap_mcda_max_write_size =
8064 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
8065}
8066
Yotam Gigi191839d2017-05-23 21:56:25 +02008067/* MCC - Management Component Control
8068 * ----------------------------------
8069 * Controls the firmware component and updates the FSM.
8070 */
8071#define MLXSW_REG_MCC_ID 0x9062
8072#define MLXSW_REG_MCC_LEN 0x1C
8073
8074MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
8075
8076enum mlxsw_reg_mcc_instruction {
8077 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
8078 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
8079 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
8080 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
8081 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
8082 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
8083};
8084
8085/* reg_mcc_instruction
8086 * Command to be executed by the FSM.
8087 * Applicable for write operation only.
8088 * Access: RW
8089 */
8090MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
8091
8092/* reg_mcc_component_index
8093 * Index of the accessed component. Applicable only for commands that
8094 * refer to components. Otherwise, this field is reserved.
8095 * Access: Index
8096 */
8097MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
8098
8099/* reg_mcc_update_handle
8100 * Token representing the current flow executed by the FSM.
8101 * Access: WO
8102 */
8103MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
8104
8105/* reg_mcc_error_code
8106 * Indicates the successful completion of the instruction, or the reason it
8107 * failed
8108 * Access: RO
8109 */
8110MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
8111
8112/* reg_mcc_control_state
8113 * Current FSM state
8114 * Access: RO
8115 */
8116MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
8117
8118/* reg_mcc_component_size
8119 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
8120 * the size may shorten the update time. Value 0x0 means that size is
8121 * unspecified.
8122 * Access: WO
8123 */
8124MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
8125
8126static inline void mlxsw_reg_mcc_pack(char *payload,
8127 enum mlxsw_reg_mcc_instruction instr,
8128 u16 component_index, u32 update_handle,
8129 u32 component_size)
8130{
8131 MLXSW_REG_ZERO(mcc, payload);
8132 mlxsw_reg_mcc_instruction_set(payload, instr);
8133 mlxsw_reg_mcc_component_index_set(payload, component_index);
8134 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
8135 mlxsw_reg_mcc_component_size_set(payload, component_size);
8136}
8137
8138static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
8139 u8 *p_error_code, u8 *p_control_state)
8140{
8141 if (p_update_handle)
8142 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
8143 if (p_error_code)
8144 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
8145 if (p_control_state)
8146 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
8147}
8148
Yotam Gigi4625d592017-05-23 21:56:26 +02008149/* MCDA - Management Component Data Access
8150 * ---------------------------------------
8151 * This register allows reading and writing a firmware component.
8152 */
8153#define MLXSW_REG_MCDA_ID 0x9063
8154#define MLXSW_REG_MCDA_BASE_LEN 0x10
8155#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
8156#define MLXSW_REG_MCDA_LEN \
8157 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
8158
8159MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
8160
8161/* reg_mcda_update_handle
8162 * Token representing the current flow executed by the FSM.
8163 * Access: RW
8164 */
8165MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
8166
8167/* reg_mcda_offset
8168 * Offset of accessed address relative to component start. Accesses must be in
8169 * accordance to log_mcda_word_size in MCQI reg.
8170 * Access: RW
8171 */
8172MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
8173
8174/* reg_mcda_size
8175 * Size of the data accessed, given in bytes.
8176 * Access: RW
8177 */
8178MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
8179
8180/* reg_mcda_data
8181 * Data block accessed.
8182 * Access: RW
8183 */
8184MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
8185
8186static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
8187 u32 offset, u16 size, u8 *data)
8188{
8189 int i;
8190
8191 MLXSW_REG_ZERO(mcda, payload);
8192 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
8193 mlxsw_reg_mcda_offset_set(payload, offset);
8194 mlxsw_reg_mcda_size_set(payload, size);
8195
8196 for (i = 0; i < size / 4; i++)
8197 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
8198}
8199
Yotam Gigi0677d682017-01-23 11:07:10 +01008200/* MPSC - Monitoring Packet Sampling Configuration Register
8201 * --------------------------------------------------------
8202 * MPSC Register is used to configure the Packet Sampling mechanism.
8203 */
8204#define MLXSW_REG_MPSC_ID 0x9080
8205#define MLXSW_REG_MPSC_LEN 0x1C
8206
8207MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
8208
8209/* reg_mpsc_local_port
8210 * Local port number
8211 * Not supported for CPU port
8212 * Access: Index
8213 */
8214MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
8215
8216/* reg_mpsc_e
8217 * Enable sampling on port local_port
8218 * Access: RW
8219 */
8220MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
8221
8222#define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
8223
8224/* reg_mpsc_rate
8225 * Sampling rate = 1 out of rate packets (with randomization around
8226 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
8227 * Access: RW
8228 */
8229MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
8230
8231static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
8232 u32 rate)
8233{
8234 MLXSW_REG_ZERO(mpsc, payload);
8235 mlxsw_reg_mpsc_local_port_set(payload, local_port);
8236 mlxsw_reg_mpsc_e_set(payload, e);
8237 mlxsw_reg_mpsc_rate_set(payload, rate);
8238}
8239
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008240/* MGPC - Monitoring General Purpose Counter Set Register
8241 * The MGPC register retrieves and sets the General Purpose Counter Set.
8242 */
8243#define MLXSW_REG_MGPC_ID 0x9081
8244#define MLXSW_REG_MGPC_LEN 0x18
8245
8246MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
8247
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008248/* reg_mgpc_counter_set_type
8249 * Counter set type.
8250 * Access: OP
8251 */
8252MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
8253
8254/* reg_mgpc_counter_index
8255 * Counter index.
8256 * Access: Index
8257 */
8258MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
8259
8260enum mlxsw_reg_mgpc_opcode {
8261 /* Nop */
8262 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
8263 /* Clear counters */
8264 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
8265};
8266
8267/* reg_mgpc_opcode
8268 * Opcode.
8269 * Access: OP
8270 */
8271MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
8272
8273/* reg_mgpc_byte_counter
8274 * Byte counter value.
8275 * Access: RW
8276 */
8277MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
8278
8279/* reg_mgpc_packet_counter
8280 * Packet counter value.
8281 * Access: RW
8282 */
8283MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
8284
8285static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
8286 enum mlxsw_reg_mgpc_opcode opcode,
Arkadi Sharshevsky6bba7e22017-08-24 08:40:07 +02008287 enum mlxsw_reg_flow_counter_set_type set_type)
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008288{
8289 MLXSW_REG_ZERO(mgpc, payload);
8290 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
8291 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
8292 mlxsw_reg_mgpc_opcode_set(payload, opcode);
8293}
8294
Petr Machata14aefd92017-10-20 09:16:15 +02008295/* TIGCR - Tunneling IPinIP General Configuration Register
8296 * -------------------------------------------------------
8297 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
8298 */
8299#define MLXSW_REG_TIGCR_ID 0xA801
8300#define MLXSW_REG_TIGCR_LEN 0x10
8301
8302MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
8303
8304/* reg_tigcr_ipip_ttlc
8305 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
8306 * header.
8307 * Access: RW
8308 */
8309MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
8310
8311/* reg_tigcr_ipip_ttl_uc
8312 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
8313 * reg_tigcr_ipip_ttlc is unset.
8314 * Access: RW
8315 */
8316MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
8317
8318static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
8319{
8320 MLXSW_REG_ZERO(tigcr, payload);
8321 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
8322 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
8323}
8324
Jiri Pirkoe0594362015-10-16 14:01:31 +02008325/* SBPR - Shared Buffer Pools Register
8326 * -----------------------------------
8327 * The SBPR configures and retrieves the shared buffer pools and configuration.
8328 */
8329#define MLXSW_REG_SBPR_ID 0xB001
8330#define MLXSW_REG_SBPR_LEN 0x14
8331
Jiri Pirko21978dc2016-10-21 16:07:20 +02008332MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008333
Jiri Pirko497e8592016-04-08 19:11:24 +02008334/* shared direstion enum for SBPR, SBCM, SBPM */
8335enum mlxsw_reg_sbxx_dir {
8336 MLXSW_REG_SBXX_DIR_INGRESS,
8337 MLXSW_REG_SBXX_DIR_EGRESS,
Jiri Pirkoe0594362015-10-16 14:01:31 +02008338};
8339
8340/* reg_sbpr_dir
8341 * Direction.
8342 * Access: Index
8343 */
8344MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
8345
8346/* reg_sbpr_pool
8347 * Pool index.
8348 * Access: Index
8349 */
8350MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
8351
Petr Machataf0024f02018-09-20 09:21:28 +03008352/* reg_sbpr_infi_size
8353 * Size is infinite.
8354 * Access: RW
8355 */
8356MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
8357
Jiri Pirkoe0594362015-10-16 14:01:31 +02008358/* reg_sbpr_size
8359 * Pool size in buffer cells.
Petr Machataf0024f02018-09-20 09:21:28 +03008360 * Reserved when infi_size = 1.
Jiri Pirkoe0594362015-10-16 14:01:31 +02008361 * Access: RW
8362 */
8363MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
8364
8365enum mlxsw_reg_sbpr_mode {
8366 MLXSW_REG_SBPR_MODE_STATIC,
8367 MLXSW_REG_SBPR_MODE_DYNAMIC,
8368};
8369
8370/* reg_sbpr_mode
8371 * Pool quota calculation mode.
8372 * Access: RW
8373 */
8374MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
8375
8376static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
Jiri Pirko497e8592016-04-08 19:11:24 +02008377 enum mlxsw_reg_sbxx_dir dir,
Petr Machataf0024f02018-09-20 09:21:28 +03008378 enum mlxsw_reg_sbpr_mode mode, u32 size,
8379 bool infi_size)
Jiri Pirkoe0594362015-10-16 14:01:31 +02008380{
8381 MLXSW_REG_ZERO(sbpr, payload);
8382 mlxsw_reg_sbpr_pool_set(payload, pool);
8383 mlxsw_reg_sbpr_dir_set(payload, dir);
8384 mlxsw_reg_sbpr_mode_set(payload, mode);
8385 mlxsw_reg_sbpr_size_set(payload, size);
Petr Machataf0024f02018-09-20 09:21:28 +03008386 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008387}
8388
8389/* SBCM - Shared Buffer Class Management Register
8390 * ----------------------------------------------
8391 * The SBCM register configures and retrieves the shared buffer allocation
8392 * and configuration according to Port-PG, including the binding to pool
8393 * and definition of the associated quota.
8394 */
8395#define MLXSW_REG_SBCM_ID 0xB002
8396#define MLXSW_REG_SBCM_LEN 0x28
8397
Jiri Pirko21978dc2016-10-21 16:07:20 +02008398MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008399
8400/* reg_sbcm_local_port
8401 * Local port number.
8402 * For Ingress: excludes CPU port and Router port
8403 * For Egress: excludes IP Router
8404 * Access: Index
8405 */
8406MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
8407
8408/* reg_sbcm_pg_buff
8409 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
8410 * For PG buffer: range is 0..cap_max_pg_buffers - 1
8411 * For traffic class: range is 0..cap_max_tclass - 1
8412 * Note that when traffic class is in MC aware mode then the traffic
8413 * classes which are MC aware cannot be configured.
8414 * Access: Index
8415 */
8416MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
8417
Jiri Pirkoe0594362015-10-16 14:01:31 +02008418/* reg_sbcm_dir
8419 * Direction.
8420 * Access: Index
8421 */
8422MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
8423
8424/* reg_sbcm_min_buff
8425 * Minimum buffer size for the limiter, in cells.
8426 * Access: RW
8427 */
8428MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
8429
Jiri Pirkoc30a53c2016-04-14 18:19:22 +02008430/* shared max_buff limits for dynamic threshold for SBCM, SBPM */
8431#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
8432#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
8433
Petr Machatad144e3a2018-09-20 09:21:29 +03008434/* reg_sbcm_infi_max
8435 * Max buffer is infinite.
8436 * Access: RW
8437 */
8438MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
8439
Jiri Pirkoe0594362015-10-16 14:01:31 +02008440/* reg_sbcm_max_buff
8441 * When the pool associated to the port-pg/tclass is configured to
8442 * static, Maximum buffer size for the limiter configured in cells.
8443 * When the pool associated to the port-pg/tclass is configured to
8444 * dynamic, the max_buff holds the "alpha" parameter, supporting
8445 * the following values:
8446 * 0: 0
8447 * i: (1/128)*2^(i-1), for i=1..14
8448 * 0xFF: Infinity
Petr Machatad144e3a2018-09-20 09:21:29 +03008449 * Reserved when infi_max = 1.
Jiri Pirkoe0594362015-10-16 14:01:31 +02008450 * Access: RW
8451 */
8452MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
8453
8454/* reg_sbcm_pool
8455 * Association of the port-priority to a pool.
8456 * Access: RW
8457 */
8458MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
8459
8460static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
Jiri Pirko497e8592016-04-08 19:11:24 +02008461 enum mlxsw_reg_sbxx_dir dir,
Petr Machatad144e3a2018-09-20 09:21:29 +03008462 u32 min_buff, u32 max_buff,
8463 bool infi_max, u8 pool)
Jiri Pirkoe0594362015-10-16 14:01:31 +02008464{
8465 MLXSW_REG_ZERO(sbcm, payload);
8466 mlxsw_reg_sbcm_local_port_set(payload, local_port);
8467 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
8468 mlxsw_reg_sbcm_dir_set(payload, dir);
8469 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
8470 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
Petr Machatad144e3a2018-09-20 09:21:29 +03008471 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008472 mlxsw_reg_sbcm_pool_set(payload, pool);
8473}
8474
Jiri Pirko9efc8f62016-04-08 19:11:25 +02008475/* SBPM - Shared Buffer Port Management Register
8476 * ---------------------------------------------
Jiri Pirkoe0594362015-10-16 14:01:31 +02008477 * The SBPM register configures and retrieves the shared buffer allocation
8478 * and configuration according to Port-Pool, including the definition
8479 * of the associated quota.
8480 */
8481#define MLXSW_REG_SBPM_ID 0xB003
8482#define MLXSW_REG_SBPM_LEN 0x28
8483
Jiri Pirko21978dc2016-10-21 16:07:20 +02008484MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008485
8486/* reg_sbpm_local_port
8487 * Local port number.
8488 * For Ingress: excludes CPU port and Router port
8489 * For Egress: excludes IP Router
8490 * Access: Index
8491 */
8492MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
8493
8494/* reg_sbpm_pool
8495 * The pool associated to quota counting on the local_port.
8496 * Access: Index
8497 */
8498MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
8499
Jiri Pirkoe0594362015-10-16 14:01:31 +02008500/* reg_sbpm_dir
8501 * Direction.
8502 * Access: Index
8503 */
8504MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
8505
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008506/* reg_sbpm_buff_occupancy
8507 * Current buffer occupancy in cells.
8508 * Access: RO
8509 */
8510MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
8511
8512/* reg_sbpm_clr
8513 * Clear Max Buffer Occupancy
8514 * When this bit is set, max_buff_occupancy field is cleared (and a
8515 * new max value is tracked from the time the clear was performed).
8516 * Access: OP
8517 */
8518MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
8519
8520/* reg_sbpm_max_buff_occupancy
8521 * Maximum value of buffer occupancy in cells monitored. Cleared by
8522 * writing to the clr field.
8523 * Access: RO
8524 */
8525MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
8526
Jiri Pirkoe0594362015-10-16 14:01:31 +02008527/* reg_sbpm_min_buff
8528 * Minimum buffer size for the limiter, in cells.
8529 * Access: RW
8530 */
8531MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
8532
8533/* reg_sbpm_max_buff
8534 * When the pool associated to the port-pg/tclass is configured to
8535 * static, Maximum buffer size for the limiter configured in cells.
8536 * When the pool associated to the port-pg/tclass is configured to
8537 * dynamic, the max_buff holds the "alpha" parameter, supporting
8538 * the following values:
8539 * 0: 0
8540 * i: (1/128)*2^(i-1), for i=1..14
8541 * 0xFF: Infinity
8542 * Access: RW
8543 */
8544MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
8545
8546static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008547 enum mlxsw_reg_sbxx_dir dir, bool clr,
Jiri Pirkoe0594362015-10-16 14:01:31 +02008548 u32 min_buff, u32 max_buff)
8549{
8550 MLXSW_REG_ZERO(sbpm, payload);
8551 mlxsw_reg_sbpm_local_port_set(payload, local_port);
8552 mlxsw_reg_sbpm_pool_set(payload, pool);
8553 mlxsw_reg_sbpm_dir_set(payload, dir);
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008554 mlxsw_reg_sbpm_clr_set(payload, clr);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008555 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
8556 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
8557}
8558
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008559static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
8560 u32 *p_max_buff_occupancy)
8561{
8562 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
8563 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
8564}
8565
Jiri Pirkoe0594362015-10-16 14:01:31 +02008566/* SBMM - Shared Buffer Multicast Management Register
8567 * --------------------------------------------------
8568 * The SBMM register configures and retrieves the shared buffer allocation
8569 * and configuration for MC packets according to Switch-Priority, including
8570 * the binding to pool and definition of the associated quota.
8571 */
8572#define MLXSW_REG_SBMM_ID 0xB004
8573#define MLXSW_REG_SBMM_LEN 0x28
8574
Jiri Pirko21978dc2016-10-21 16:07:20 +02008575MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008576
8577/* reg_sbmm_prio
8578 * Switch Priority.
8579 * Access: Index
8580 */
8581MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
8582
8583/* reg_sbmm_min_buff
8584 * Minimum buffer size for the limiter, in cells.
8585 * Access: RW
8586 */
8587MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
8588
8589/* reg_sbmm_max_buff
8590 * When the pool associated to the port-pg/tclass is configured to
8591 * static, Maximum buffer size for the limiter configured in cells.
8592 * When the pool associated to the port-pg/tclass is configured to
8593 * dynamic, the max_buff holds the "alpha" parameter, supporting
8594 * the following values:
8595 * 0: 0
8596 * i: (1/128)*2^(i-1), for i=1..14
8597 * 0xFF: Infinity
8598 * Access: RW
8599 */
8600MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
8601
8602/* reg_sbmm_pool
8603 * Association of the port-priority to a pool.
8604 * Access: RW
8605 */
8606MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
8607
8608static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
8609 u32 max_buff, u8 pool)
8610{
8611 MLXSW_REG_ZERO(sbmm, payload);
8612 mlxsw_reg_sbmm_prio_set(payload, prio);
8613 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
8614 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
8615 mlxsw_reg_sbmm_pool_set(payload, pool);
8616}
8617
Jiri Pirko26176de2016-04-14 18:19:26 +02008618/* SBSR - Shared Buffer Status Register
8619 * ------------------------------------
8620 * The SBSR register retrieves the shared buffer occupancy according to
8621 * Port-Pool. Note that this register enables reading a large amount of data.
8622 * It is the user's responsibility to limit the amount of data to ensure the
8623 * response can match the maximum transfer unit. In case the response exceeds
8624 * the maximum transport unit, it will be truncated with no special notice.
8625 */
8626#define MLXSW_REG_SBSR_ID 0xB005
8627#define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
8628#define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
8629#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
8630#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
8631 MLXSW_REG_SBSR_REC_LEN * \
8632 MLXSW_REG_SBSR_REC_MAX_COUNT)
8633
Jiri Pirko21978dc2016-10-21 16:07:20 +02008634MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
Jiri Pirko26176de2016-04-14 18:19:26 +02008635
8636/* reg_sbsr_clr
8637 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
8638 * field is cleared (and a new max value is tracked from the time the clear
8639 * was performed).
8640 * Access: OP
8641 */
8642MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
8643
8644/* reg_sbsr_ingress_port_mask
8645 * Bit vector for all ingress network ports.
8646 * Indicates which of the ports (for which the relevant bit is set)
8647 * are affected by the set operation. Configuration of any other port
8648 * does not change.
8649 * Access: Index
8650 */
8651MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
8652
8653/* reg_sbsr_pg_buff_mask
8654 * Bit vector for all switch priority groups.
8655 * Indicates which of the priorities (for which the relevant bit is set)
8656 * are affected by the set operation. Configuration of any other priority
8657 * does not change.
8658 * Range is 0..cap_max_pg_buffers - 1
8659 * Access: Index
8660 */
8661MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
8662
8663/* reg_sbsr_egress_port_mask
8664 * Bit vector for all egress network ports.
8665 * Indicates which of the ports (for which the relevant bit is set)
8666 * are affected by the set operation. Configuration of any other port
8667 * does not change.
8668 * Access: Index
8669 */
8670MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
8671
8672/* reg_sbsr_tclass_mask
8673 * Bit vector for all traffic classes.
8674 * Indicates which of the traffic classes (for which the relevant bit is
8675 * set) are affected by the set operation. Configuration of any other
8676 * traffic class does not change.
8677 * Range is 0..cap_max_tclass - 1
8678 * Access: Index
8679 */
8680MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
8681
8682static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
8683{
8684 MLXSW_REG_ZERO(sbsr, payload);
8685 mlxsw_reg_sbsr_clr_set(payload, clr);
8686}
8687
8688/* reg_sbsr_rec_buff_occupancy
8689 * Current buffer occupancy in cells.
8690 * Access: RO
8691 */
8692MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
8693 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
8694
8695/* reg_sbsr_rec_max_buff_occupancy
8696 * Maximum value of buffer occupancy in cells monitored. Cleared by
8697 * writing to the clr field.
8698 * Access: RO
8699 */
8700MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
8701 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
8702
8703static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
8704 u32 *p_buff_occupancy,
8705 u32 *p_max_buff_occupancy)
8706{
8707 *p_buff_occupancy =
8708 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
8709 *p_max_buff_occupancy =
8710 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
8711}
8712
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02008713/* SBIB - Shared Buffer Internal Buffer Register
8714 * ---------------------------------------------
8715 * The SBIB register configures per port buffers for internal use. The internal
8716 * buffers consume memory on the port buffers (note that the port buffers are
8717 * used also by PBMC).
8718 *
8719 * For Spectrum this is used for egress mirroring.
8720 */
8721#define MLXSW_REG_SBIB_ID 0xB006
8722#define MLXSW_REG_SBIB_LEN 0x10
8723
Jiri Pirko21978dc2016-10-21 16:07:20 +02008724MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02008725
8726/* reg_sbib_local_port
8727 * Local port number
8728 * Not supported for CPU port and router port
8729 * Access: Index
8730 */
8731MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
8732
8733/* reg_sbib_buff_size
8734 * Units represented in cells
8735 * Allowed range is 0 to (cap_max_headroom_size - 1)
8736 * Default is 0
8737 * Access: RW
8738 */
8739MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
8740
8741static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
8742 u32 buff_size)
8743{
8744 MLXSW_REG_ZERO(sbib, payload);
8745 mlxsw_reg_sbib_local_port_set(payload, local_port);
8746 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
8747}
8748
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008749static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
8750 MLXSW_REG(sgcr),
8751 MLXSW_REG(spad),
8752 MLXSW_REG(smid),
8753 MLXSW_REG(sspr),
8754 MLXSW_REG(sfdat),
8755 MLXSW_REG(sfd),
8756 MLXSW_REG(sfn),
8757 MLXSW_REG(spms),
8758 MLXSW_REG(spvid),
8759 MLXSW_REG(spvm),
8760 MLXSW_REG(spaft),
8761 MLXSW_REG(sfgc),
8762 MLXSW_REG(sftr),
8763 MLXSW_REG(sfdf),
8764 MLXSW_REG(sldr),
8765 MLXSW_REG(slcr),
8766 MLXSW_REG(slcor),
8767 MLXSW_REG(spmlr),
8768 MLXSW_REG(svfa),
8769 MLXSW_REG(svpe),
8770 MLXSW_REG(sfmr),
8771 MLXSW_REG(spvmlr),
Nogah Frankelad53fa02017-11-06 07:23:44 +01008772 MLXSW_REG(cwtp),
8773 MLXSW_REG(cwtpm),
Ido Schimmel7050f432018-07-18 11:14:40 +03008774 MLXSW_REG(pgcr),
Jiri Pirkoaf7170e2017-02-03 10:28:57 +01008775 MLXSW_REG(ppbt),
Jiri Pirko3279da42017-02-03 10:28:53 +01008776 MLXSW_REG(pacl),
Jiri Pirko10fabef2017-02-03 10:28:54 +01008777 MLXSW_REG(pagt),
Jiri Pirkod9c26612017-02-03 10:28:55 +01008778 MLXSW_REG(ptar),
Jiri Pirkod1206492017-02-03 10:28:59 +01008779 MLXSW_REG(ppbs),
Jiri Pirko937b6822017-02-03 10:28:58 +01008780 MLXSW_REG(prcr),
Jiri Pirkoe3426e12017-02-03 10:29:00 +01008781 MLXSW_REG(pefa),
Jiri Pirko0171cdec2017-02-03 10:28:56 +01008782 MLXSW_REG(ptce2),
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03008783 MLXSW_REG(perpt),
Jiri Pirko33907872018-07-18 11:14:37 +03008784 MLXSW_REG(perar),
Ido Schimmelaecefac2018-07-25 09:23:51 +03008785 MLXSW_REG(ptce3),
Ido Schimmel481662a2018-07-18 11:14:38 +03008786 MLXSW_REG(percr),
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03008787 MLXSW_REG(pererp),
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03008788 MLXSW_REG(iedr),
Petr Machata746da422018-07-27 15:26:58 +03008789 MLXSW_REG(qpts),
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01008790 MLXSW_REG(qpcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008791 MLXSW_REG(qtct),
8792 MLXSW_REG(qeec),
Petr Machatae67131d2018-07-27 15:26:59 +03008793 MLXSW_REG(qrwe),
Petr Machata55fb71f2018-07-27 15:27:00 +03008794 MLXSW_REG(qpdsm),
Petr Machata02837d72018-07-27 15:26:57 +03008795 MLXSW_REG(qpdpm),
Petr Machata671ae8a2018-08-05 09:03:06 +03008796 MLXSW_REG(qtctm),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008797 MLXSW_REG(pmlp),
8798 MLXSW_REG(pmtu),
8799 MLXSW_REG(ptys),
8800 MLXSW_REG(ppad),
8801 MLXSW_REG(paos),
8802 MLXSW_REG(pfcc),
8803 MLXSW_REG(ppcnt),
Elad Raz71367932016-10-28 21:35:54 +02008804 MLXSW_REG(plib),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008805 MLXSW_REG(pptb),
8806 MLXSW_REG(pbmc),
8807 MLXSW_REG(pspa),
8808 MLXSW_REG(htgt),
8809 MLXSW_REG(hpkt),
8810 MLXSW_REG(rgcr),
8811 MLXSW_REG(ritr),
Yotam Gigi46a70542017-09-19 10:00:13 +02008812 MLXSW_REG(rtar),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008813 MLXSW_REG(ratr),
Petr Machata1e659eb2017-09-02 23:49:13 +02008814 MLXSW_REG(rtdp),
Yuval Mintzddb362c2018-01-14 12:33:13 +01008815 MLXSW_REG(rdpm),
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +02008816 MLXSW_REG(ricnt),
Yotam Gigi4fc92842017-09-19 10:00:17 +02008817 MLXSW_REG(rrcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008818 MLXSW_REG(ralta),
8819 MLXSW_REG(ralst),
8820 MLXSW_REG(raltb),
8821 MLXSW_REG(ralue),
8822 MLXSW_REG(rauht),
8823 MLXSW_REG(raleu),
8824 MLXSW_REG(rauhtd),
Yotam Gigi5080c7e2017-09-19 10:00:14 +02008825 MLXSW_REG(rigr2),
Ido Schimmele4718592017-11-02 17:14:08 +01008826 MLXSW_REG(recr2),
Yotam Gigi2e654e32017-09-19 10:00:16 +02008827 MLXSW_REG(rmft2),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008828 MLXSW_REG(mfcr),
8829 MLXSW_REG(mfsc),
8830 MLXSW_REG(mfsm),
Jiri Pirko55c63aa2016-11-22 11:24:12 +01008831 MLXSW_REG(mfsl),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008832 MLXSW_REG(mtcap),
8833 MLXSW_REG(mtmp),
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008834 MLXSW_REG(mcia),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008835 MLXSW_REG(mpat),
8836 MLXSW_REG(mpar),
Jiri Pirko12b003b2018-05-27 09:56:13 +03008837 MLXSW_REG(mrsr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008838 MLXSW_REG(mlcr),
Yotam Gigi0677d682017-01-23 11:07:10 +01008839 MLXSW_REG(mpsc),
Yotam Gigi4f2402d2017-05-23 21:56:24 +02008840 MLXSW_REG(mcqi),
Yotam Gigi191839d2017-05-23 21:56:25 +02008841 MLXSW_REG(mcc),
Yotam Gigi4625d592017-05-23 21:56:26 +02008842 MLXSW_REG(mcda),
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008843 MLXSW_REG(mgpc),
Petr Machata14aefd92017-10-20 09:16:15 +02008844 MLXSW_REG(tigcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008845 MLXSW_REG(sbpr),
8846 MLXSW_REG(sbcm),
8847 MLXSW_REG(sbpm),
8848 MLXSW_REG(sbmm),
8849 MLXSW_REG(sbsr),
8850 MLXSW_REG(sbib),
8851};
8852
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008853static inline const char *mlxsw_reg_id_str(u16 reg_id)
8854{
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008855 const struct mlxsw_reg_info *reg_info;
8856 int i;
8857
8858 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
8859 reg_info = mlxsw_reg_infos[i];
8860 if (reg_info->id == reg_id)
8861 return reg_info->name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008862 }
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008863 return "*UNKNOWN*";
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008864}
8865
8866/* PUDE - Port Up / Down Event
8867 * ---------------------------
8868 * Reports the operational state change of a port.
8869 */
8870#define MLXSW_REG_PUDE_LEN 0x10
8871
8872/* reg_pude_swid
8873 * Switch partition ID with which to associate the port.
8874 * Access: Index
8875 */
8876MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
8877
8878/* reg_pude_local_port
8879 * Local port number.
8880 * Access: Index
8881 */
8882MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
8883
8884/* reg_pude_admin_status
8885 * Port administrative state (the desired state).
8886 * 1 - Up.
8887 * 2 - Down.
8888 * 3 - Up once. This means that in case of link failure, the port won't go
8889 * into polling mode, but will wait to be re-enabled by software.
8890 * 4 - Disabled by system. Can only be set by hardware.
8891 * Access: RO
8892 */
8893MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
8894
8895/* reg_pude_oper_status
8896 * Port operatioanl state.
8897 * 1 - Up.
8898 * 2 - Down.
8899 * 3 - Down by port failure. This means that the device will not let the
8900 * port up again until explicitly specified by software.
8901 * Access: RO
8902 */
8903MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
8904
8905#endif