blob: 2618e9cf3aab1d2b7a2c425678109efe87f49f2a [file] [log] [blame]
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001/*
2 * drivers/net/ethernet/mellanox/mlxsw/reg.h
3 * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
Ido Schimmel69c407a2016-07-02 11:00:13 +02004 * Copyright (c) 2015-2016 Ido Schimmel <idosch@mellanox.com>
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005 * Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02006 * Copyright (c) 2015-2016 Jiri Pirko <jiri@mellanox.com>
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007 * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com>
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * Alternatively, this software may be distributed under the terms of the
22 * GNU General Public License ("GPL") version 2 as published by the Free
23 * Software Foundation.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _MLXSW_REG_H
39#define _MLXSW_REG_H
40
41#include <linux/string.h>
42#include <linux/bitops.h>
43#include <linux/if_vlan.h>
44
45#include "item.h"
46#include "port.h"
47
48struct mlxsw_reg_info {
49 u16 id;
50 u16 len; /* In u8 */
Jiri Pirko8e9658d2016-10-21 16:07:21 +020051 const char *name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +020052};
53
Jiri Pirko21978dc2016-10-21 16:07:20 +020054#define MLXSW_REG_DEFINE(_name, _id, _len) \
55static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
56 .id = _id, \
57 .len = _len, \
Jiri Pirko8e9658d2016-10-21 16:07:21 +020058 .name = #_name, \
Jiri Pirko21978dc2016-10-21 16:07:20 +020059}
60
Ido Schimmel4ec14b72015-07-29 23:33:48 +020061#define MLXSW_REG(type) (&mlxsw_reg_##type)
62#define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
63#define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
64
65/* SGCR - Switch General Configuration Register
66 * --------------------------------------------
67 * This register is used for configuration of the switch capabilities.
68 */
69#define MLXSW_REG_SGCR_ID 0x2000
70#define MLXSW_REG_SGCR_LEN 0x10
71
Jiri Pirko21978dc2016-10-21 16:07:20 +020072MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +020073
74/* reg_sgcr_llb
75 * Link Local Broadcast (Default=0)
76 * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
77 * packets and ignore the IGMP snooping entries.
78 * Access: RW
79 */
80MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
81
82static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
83{
84 MLXSW_REG_ZERO(sgcr, payload);
85 mlxsw_reg_sgcr_llb_set(payload, !!llb);
86}
87
88/* SPAD - Switch Physical Address Register
89 * ---------------------------------------
90 * The SPAD register configures the switch physical MAC address.
91 */
92#define MLXSW_REG_SPAD_ID 0x2002
93#define MLXSW_REG_SPAD_LEN 0x10
94
Jiri Pirko21978dc2016-10-21 16:07:20 +020095MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +020096
97/* reg_spad_base_mac
98 * Base MAC address for the switch partitions.
99 * Per switch partition MAC address is equal to:
100 * base_mac + swid
101 * Access: RW
102 */
103MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
104
Elad Razfabe5482016-01-10 21:06:25 +0100105/* SMID - Switch Multicast ID
106 * --------------------------
107 * The MID record maps from a MID (Multicast ID), which is a unique identifier
108 * of the multicast group within the stacking domain, into a list of local
109 * ports into which the packet is replicated.
110 */
111#define MLXSW_REG_SMID_ID 0x2007
112#define MLXSW_REG_SMID_LEN 0x240
113
Jiri Pirko21978dc2016-10-21 16:07:20 +0200114MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
Elad Razfabe5482016-01-10 21:06:25 +0100115
116/* reg_smid_swid
117 * Switch partition ID.
118 * Access: Index
119 */
120MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
121
122/* reg_smid_mid
123 * Multicast identifier - global identifier that represents the multicast group
124 * across all devices.
125 * Access: Index
126 */
127MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
128
129/* reg_smid_port
130 * Local port memebership (1 bit per port).
131 * Access: RW
132 */
133MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
134
135/* reg_smid_port_mask
136 * Local port mask (1 bit per port).
137 * Access: W
138 */
139MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
140
141static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
142 u8 port, bool set)
143{
144 MLXSW_REG_ZERO(smid, payload);
145 mlxsw_reg_smid_swid_set(payload, 0);
146 mlxsw_reg_smid_mid_set(payload, mid);
147 mlxsw_reg_smid_port_set(payload, port, set);
148 mlxsw_reg_smid_port_mask_set(payload, port, 1);
149}
150
Ido Schimmele61011b2015-08-06 16:41:53 +0200151/* SSPR - Switch System Port Record Register
152 * -----------------------------------------
153 * Configures the system port to local port mapping.
154 */
155#define MLXSW_REG_SSPR_ID 0x2008
156#define MLXSW_REG_SSPR_LEN 0x8
157
Jiri Pirko21978dc2016-10-21 16:07:20 +0200158MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
Ido Schimmele61011b2015-08-06 16:41:53 +0200159
160/* reg_sspr_m
161 * Master - if set, then the record describes the master system port.
162 * This is needed in case a local port is mapped into several system ports
163 * (for multipathing). That number will be reported as the source system
164 * port when packets are forwarded to the CPU. Only one master port is allowed
165 * per local port.
166 *
167 * Note: Must be set for Spectrum.
168 * Access: RW
169 */
170MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
171
172/* reg_sspr_local_port
173 * Local port number.
174 *
175 * Access: RW
176 */
177MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
178
179/* reg_sspr_sub_port
180 * Virtual port within the physical port.
181 * Should be set to 0 when virtual ports are not enabled on the port.
182 *
183 * Access: RW
184 */
185MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
186
187/* reg_sspr_system_port
188 * Unique identifier within the stacking domain that represents all the ports
189 * that are available in the system (external ports).
190 *
191 * Currently, only single-ASIC configurations are supported, so we default to
192 * 1:1 mapping between system ports and local ports.
193 * Access: Index
194 */
195MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
196
197static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
198{
199 MLXSW_REG_ZERO(sspr, payload);
200 mlxsw_reg_sspr_m_set(payload, 1);
201 mlxsw_reg_sspr_local_port_set(payload, local_port);
202 mlxsw_reg_sspr_sub_port_set(payload, 0);
203 mlxsw_reg_sspr_system_port_set(payload, local_port);
204}
205
Jiri Pirkoe534a56a2015-10-16 14:01:35 +0200206/* SFDAT - Switch Filtering Database Aging Time
207 * --------------------------------------------
208 * Controls the Switch aging time. Aging time is able to be set per Switch
209 * Partition.
210 */
211#define MLXSW_REG_SFDAT_ID 0x2009
212#define MLXSW_REG_SFDAT_LEN 0x8
213
Jiri Pirko21978dc2016-10-21 16:07:20 +0200214MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
Jiri Pirkoe534a56a2015-10-16 14:01:35 +0200215
216/* reg_sfdat_swid
217 * Switch partition ID.
218 * Access: Index
219 */
220MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
221
222/* reg_sfdat_age_time
223 * Aging time in seconds
224 * Min - 10 seconds
225 * Max - 1,000,000 seconds
226 * Default is 300 seconds.
227 * Access: RW
228 */
229MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
230
231static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
232{
233 MLXSW_REG_ZERO(sfdat, payload);
234 mlxsw_reg_sfdat_swid_set(payload, 0);
235 mlxsw_reg_sfdat_age_time_set(payload, age_time);
236}
237
Jiri Pirko236033b2015-10-16 14:01:28 +0200238/* SFD - Switch Filtering Database
239 * -------------------------------
240 * The following register defines the access to the filtering database.
241 * The register supports querying, adding, removing and modifying the database.
242 * The access is optimized for bulk updates in which case more than one
243 * FDB record is present in the same command.
244 */
245#define MLXSW_REG_SFD_ID 0x200A
246#define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
247#define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
248#define MLXSW_REG_SFD_REC_MAX_COUNT 64
249#define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
250 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
251
Jiri Pirko21978dc2016-10-21 16:07:20 +0200252MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
Jiri Pirko236033b2015-10-16 14:01:28 +0200253
254/* reg_sfd_swid
255 * Switch partition ID for queries. Reserved on Write.
256 * Access: Index
257 */
258MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
259
260enum mlxsw_reg_sfd_op {
261 /* Dump entire FDB a (process according to record_locator) */
262 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
263 /* Query records by {MAC, VID/FID} value */
264 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
265 /* Query and clear activity. Query records by {MAC, VID/FID} value */
266 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
267 /* Test. Response indicates if each of the records could be
268 * added to the FDB.
269 */
270 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
271 /* Add/modify. Aged-out records cannot be added. This command removes
272 * the learning notification of the {MAC, VID/FID}. Response includes
273 * the entries that were added to the FDB.
274 */
275 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
276 /* Remove record by {MAC, VID/FID}. This command also removes
277 * the learning notification and aged-out notifications
278 * of the {MAC, VID/FID}. The response provides current (pre-removal)
279 * entries as non-aged-out.
280 */
281 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
282 /* Remove learned notification by {MAC, VID/FID}. The response provides
283 * the removed learning notification.
284 */
285 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
286};
287
288/* reg_sfd_op
289 * Operation.
290 * Access: OP
291 */
292MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
293
294/* reg_sfd_record_locator
295 * Used for querying the FDB. Use record_locator=0 to initiate the
296 * query. When a record is returned, a new record_locator is
297 * returned to be used in the subsequent query.
298 * Reserved for database update.
299 * Access: Index
300 */
301MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
302
303/* reg_sfd_num_rec
304 * Request: Number of records to read/add/modify/remove
305 * Response: Number of records read/added/replaced/removed
306 * See above description for more details.
307 * Ranges 0..64
308 * Access: RW
309 */
310MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
311
312static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
313 u32 record_locator)
314{
315 MLXSW_REG_ZERO(sfd, payload);
316 mlxsw_reg_sfd_op_set(payload, op);
317 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
318}
319
320/* reg_sfd_rec_swid
321 * Switch partition ID.
322 * Access: Index
323 */
324MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
325 MLXSW_REG_SFD_REC_LEN, 0x00, false);
326
327enum mlxsw_reg_sfd_rec_type {
328 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100329 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
Elad Raz5230b252016-01-10 21:06:24 +0100330 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
Jiri Pirko236033b2015-10-16 14:01:28 +0200331};
332
333/* reg_sfd_rec_type
334 * FDB record type.
335 * Access: RW
336 */
337MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
338 MLXSW_REG_SFD_REC_LEN, 0x00, false);
339
340enum mlxsw_reg_sfd_rec_policy {
341 /* Replacement disabled, aging disabled. */
342 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
343 /* (mlag remote): Replacement enabled, aging disabled,
344 * learning notification enabled on this port.
345 */
346 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
347 /* (ingress device): Replacement enabled, aging enabled. */
348 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
349};
350
351/* reg_sfd_rec_policy
352 * Policy.
353 * Access: RW
354 */
355MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
356 MLXSW_REG_SFD_REC_LEN, 0x00, false);
357
358/* reg_sfd_rec_a
359 * Activity. Set for new static entries. Set for static entries if a frame SMAC
360 * lookup hits on the entry.
361 * To clear the a bit, use "query and clear activity" op.
362 * Access: RO
363 */
364MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
365 MLXSW_REG_SFD_REC_LEN, 0x00, false);
366
367/* reg_sfd_rec_mac
368 * MAC address.
369 * Access: Index
370 */
371MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
372 MLXSW_REG_SFD_REC_LEN, 0x02);
373
374enum mlxsw_reg_sfd_rec_action {
375 /* forward */
376 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
377 /* forward and trap, trap_id is FDB_TRAP */
378 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
379 /* trap and do not forward, trap_id is FDB_TRAP */
Ido Schimmeld82d8c02016-07-02 11:00:17 +0200380 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
381 /* forward to IP router */
382 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
Jiri Pirko236033b2015-10-16 14:01:28 +0200383 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
384};
385
386/* reg_sfd_rec_action
387 * Action to apply on the packet.
388 * Note: Dynamic entries can only be configured with NOP action.
389 * Access: RW
390 */
391MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
392 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
393
394/* reg_sfd_uc_sub_port
Jiri Pirko4e9ec082015-10-28 10:16:59 +0100395 * VEPA channel on local port.
396 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
397 * VEPA is not enabled.
Jiri Pirko236033b2015-10-16 14:01:28 +0200398 * Access: RW
399 */
400MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
401 MLXSW_REG_SFD_REC_LEN, 0x08, false);
402
403/* reg_sfd_uc_fid_vid
404 * Filtering ID or VLAN ID
405 * For SwitchX and SwitchX-2:
406 * - Dynamic entries (policy 2,3) use FID
407 * - Static entries (policy 0) use VID
408 * - When independent learning is configured, VID=FID
409 * For Spectrum: use FID for both Dynamic and Static entries.
410 * VID should not be used.
411 * Access: Index
412 */
413MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
414 MLXSW_REG_SFD_REC_LEN, 0x08, false);
415
416/* reg_sfd_uc_system_port
417 * Unique port identifier for the final destination of the packet.
418 * Access: RW
419 */
420MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
421 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
422
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100423static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
424 enum mlxsw_reg_sfd_rec_type rec_type,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100425 const char *mac,
426 enum mlxsw_reg_sfd_rec_action action)
Jiri Pirko236033b2015-10-16 14:01:28 +0200427{
428 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
429
430 if (rec_index >= num_rec)
431 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
432 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100433 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
Jiri Pirko236033b2015-10-16 14:01:28 +0200434 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100435 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
436}
437
438static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
439 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100440 const char *mac, u16 fid_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100441 enum mlxsw_reg_sfd_rec_action action,
442 u8 local_port)
443{
444 mlxsw_reg_sfd_rec_pack(payload, rec_index,
Elad Raz5230b252016-01-10 21:06:24 +0100445 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
446 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirko236033b2015-10-16 14:01:28 +0200447 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100448 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
Jiri Pirko236033b2015-10-16 14:01:28 +0200449 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
450}
451
Jiri Pirko75c09282015-10-28 10:17:01 +0100452static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100453 char *mac, u16 *p_fid_vid,
Jiri Pirko75c09282015-10-28 10:17:01 +0100454 u8 *p_local_port)
Jiri Pirko236033b2015-10-16 14:01:28 +0200455{
456 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100457 *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
Jiri Pirko236033b2015-10-16 14:01:28 +0200458 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
459}
460
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100461/* reg_sfd_uc_lag_sub_port
462 * LAG sub port.
463 * Must be 0 if multichannel VEPA is not enabled.
464 * Access: RW
465 */
466MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
467 MLXSW_REG_SFD_REC_LEN, 0x08, false);
468
469/* reg_sfd_uc_lag_fid_vid
470 * Filtering ID or VLAN ID
471 * For SwitchX and SwitchX-2:
472 * - Dynamic entries (policy 2,3) use FID
473 * - Static entries (policy 0) use VID
474 * - When independent learning is configured, VID=FID
475 * For Spectrum: use FID for both Dynamic and Static entries.
476 * VID should not be used.
477 * Access: Index
478 */
479MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
480 MLXSW_REG_SFD_REC_LEN, 0x08, false);
481
Ido Schimmelafd7f972015-12-15 16:03:45 +0100482/* reg_sfd_uc_lag_lag_vid
483 * Indicates VID in case of vFIDs. Reserved for FIDs.
484 * Access: RW
485 */
486MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
487 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
488
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100489/* reg_sfd_uc_lag_lag_id
490 * LAG Identifier - pointer into the LAG descriptor table.
491 * Access: RW
492 */
493MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
494 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
495
496static inline void
497mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
498 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100499 const char *mac, u16 fid_vid,
Ido Schimmelafd7f972015-12-15 16:03:45 +0100500 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100501 u16 lag_id)
502{
503 mlxsw_reg_sfd_rec_pack(payload, rec_index,
504 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
Elad Raz5230b252016-01-10 21:06:24 +0100505 mac, action);
506 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100507 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100508 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
Ido Schimmelafd7f972015-12-15 16:03:45 +0100509 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100510 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
511}
512
513static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
514 char *mac, u16 *p_vid,
515 u16 *p_lag_id)
516{
517 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
518 *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
519 *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
520}
521
Elad Raz5230b252016-01-10 21:06:24 +0100522/* reg_sfd_mc_pgi
523 *
524 * Multicast port group index - index into the port group table.
525 * Value 0x1FFF indicates the pgi should point to the MID entry.
526 * For Spectrum this value must be set to 0x1FFF
527 * Access: RW
528 */
529MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
530 MLXSW_REG_SFD_REC_LEN, 0x08, false);
531
532/* reg_sfd_mc_fid_vid
533 *
534 * Filtering ID or VLAN ID
535 * Access: Index
536 */
537MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
538 MLXSW_REG_SFD_REC_LEN, 0x08, false);
539
540/* reg_sfd_mc_mid
541 *
542 * Multicast identifier - global identifier that represents the multicast
543 * group across all devices.
544 * Access: RW
545 */
546MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
547 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
548
549static inline void
550mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
551 const char *mac, u16 fid_vid,
552 enum mlxsw_reg_sfd_rec_action action, u16 mid)
553{
554 mlxsw_reg_sfd_rec_pack(payload, rec_index,
555 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
556 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
557 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
558 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
559}
560
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200561/* SFN - Switch FDB Notification Register
562 * -------------------------------------------
563 * The switch provides notifications on newly learned FDB entries and
564 * aged out entries. The notifications can be polled by software.
565 */
566#define MLXSW_REG_SFN_ID 0x200B
567#define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
568#define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
569#define MLXSW_REG_SFN_REC_MAX_COUNT 64
570#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
571 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
572
Jiri Pirko21978dc2016-10-21 16:07:20 +0200573MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200574
575/* reg_sfn_swid
576 * Switch partition ID.
577 * Access: Index
578 */
579MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
580
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200581/* reg_sfn_end
582 * Forces the current session to end.
583 * Access: OP
584 */
585MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
586
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200587/* reg_sfn_num_rec
588 * Request: Number of learned notifications and aged-out notification
589 * records requested.
590 * Response: Number of notification records returned (must be smaller
591 * than or equal to the value requested)
592 * Ranges 0..64
593 * Access: OP
594 */
595MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
596
597static inline void mlxsw_reg_sfn_pack(char *payload)
598{
599 MLXSW_REG_ZERO(sfn, payload);
600 mlxsw_reg_sfn_swid_set(payload, 0);
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200601 mlxsw_reg_sfn_end_set(payload, 1);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200602 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
603}
604
605/* reg_sfn_rec_swid
606 * Switch partition ID.
607 * Access: RO
608 */
609MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
610 MLXSW_REG_SFN_REC_LEN, 0x00, false);
611
612enum mlxsw_reg_sfn_rec_type {
613 /* MAC addresses learned on a regular port. */
614 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
Jiri Pirko3b715712015-12-03 12:12:27 +0100615 /* MAC addresses learned on a LAG port. */
616 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
617 /* Aged-out MAC address on a regular port. */
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200618 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
Jiri Pirko3b715712015-12-03 12:12:27 +0100619 /* Aged-out MAC address on a LAG port. */
620 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200621};
622
623/* reg_sfn_rec_type
624 * Notification record type.
625 * Access: RO
626 */
627MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
628 MLXSW_REG_SFN_REC_LEN, 0x00, false);
629
630/* reg_sfn_rec_mac
631 * MAC address.
632 * Access: RO
633 */
634MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
635 MLXSW_REG_SFN_REC_LEN, 0x02);
636
Jiri Pirko8316f082015-10-28 10:17:00 +0100637/* reg_sfn_mac_sub_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200638 * VEPA channel on the local port.
639 * 0 if multichannel VEPA is not enabled.
640 * Access: RO
641 */
642MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
643 MLXSW_REG_SFN_REC_LEN, 0x08, false);
644
Jiri Pirko8316f082015-10-28 10:17:00 +0100645/* reg_sfn_mac_fid
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200646 * Filtering identifier.
647 * Access: RO
648 */
649MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
650 MLXSW_REG_SFN_REC_LEN, 0x08, false);
651
Jiri Pirko8316f082015-10-28 10:17:00 +0100652/* reg_sfn_mac_system_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200653 * Unique port identifier for the final destination of the packet.
654 * Access: RO
655 */
656MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
657 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
658
659static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
660 char *mac, u16 *p_vid,
661 u8 *p_local_port)
662{
663 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
664 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
665 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
666}
667
Jiri Pirko3b715712015-12-03 12:12:27 +0100668/* reg_sfn_mac_lag_lag_id
669 * LAG ID (pointer into the LAG descriptor table).
670 * Access: RO
671 */
672MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
673 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
674
675static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
676 char *mac, u16 *p_vid,
677 u16 *p_lag_id)
678{
679 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
680 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
681 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
682}
683
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200684/* SPMS - Switch Port MSTP/RSTP State Register
685 * -------------------------------------------
686 * Configures the spanning tree state of a physical port.
687 */
Jiri Pirko3f0effd2015-10-15 17:43:23 +0200688#define MLXSW_REG_SPMS_ID 0x200D
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200689#define MLXSW_REG_SPMS_LEN 0x404
690
Jiri Pirko21978dc2016-10-21 16:07:20 +0200691MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200692
693/* reg_spms_local_port
694 * Local port number.
695 * Access: Index
696 */
697MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
698
699enum mlxsw_reg_spms_state {
700 MLXSW_REG_SPMS_STATE_NO_CHANGE,
701 MLXSW_REG_SPMS_STATE_DISCARDING,
702 MLXSW_REG_SPMS_STATE_LEARNING,
703 MLXSW_REG_SPMS_STATE_FORWARDING,
704};
705
706/* reg_spms_state
707 * Spanning tree state of each VLAN ID (VID) of the local port.
708 * 0 - Do not change spanning tree state (used only when writing).
709 * 1 - Discarding. No learning or forwarding to/from this port (default).
710 * 2 - Learning. Port is learning, but not forwarding.
711 * 3 - Forwarding. Port is learning and forwarding.
712 * Access: RW
713 */
714MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
715
Jiri Pirkoebb79632015-10-15 17:43:26 +0200716static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200717{
718 MLXSW_REG_ZERO(spms, payload);
719 mlxsw_reg_spms_local_port_set(payload, local_port);
Jiri Pirkoebb79632015-10-15 17:43:26 +0200720}
721
722static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
723 enum mlxsw_reg_spms_state state)
724{
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200725 mlxsw_reg_spms_state_set(payload, vid, state);
726}
727
Elad Razb2e345f2015-10-16 14:01:30 +0200728/* SPVID - Switch Port VID
729 * -----------------------
730 * The switch port VID configures the default VID for a port.
731 */
732#define MLXSW_REG_SPVID_ID 0x200E
733#define MLXSW_REG_SPVID_LEN 0x08
734
Jiri Pirko21978dc2016-10-21 16:07:20 +0200735MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200736
737/* reg_spvid_local_port
738 * Local port number.
739 * Access: Index
740 */
741MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
742
743/* reg_spvid_sub_port
744 * Virtual port within the physical port.
745 * Should be set to 0 when virtual ports are not enabled on the port.
746 * Access: Index
747 */
748MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
749
750/* reg_spvid_pvid
751 * Port default VID
752 * Access: RW
753 */
754MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
755
756static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
757{
758 MLXSW_REG_ZERO(spvid, payload);
759 mlxsw_reg_spvid_local_port_set(payload, local_port);
760 mlxsw_reg_spvid_pvid_set(payload, pvid);
761}
762
763/* SPVM - Switch Port VLAN Membership
764 * ----------------------------------
765 * The Switch Port VLAN Membership register configures the VLAN membership
766 * of a port in a VLAN denoted by VID. VLAN membership is managed per
767 * virtual port. The register can be used to add and remove VID(s) from a port.
768 */
769#define MLXSW_REG_SPVM_ID 0x200F
770#define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
771#define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
772#define MLXSW_REG_SPVM_REC_MAX_COUNT 256
773#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
774 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
775
Jiri Pirko21978dc2016-10-21 16:07:20 +0200776MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200777
778/* reg_spvm_pt
779 * Priority tagged. If this bit is set, packets forwarded to the port with
780 * untagged VLAN membership (u bit is set) will be tagged with priority tag
781 * (VID=0)
782 * Access: RW
783 */
784MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
785
786/* reg_spvm_pte
787 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
788 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
789 * Access: WO
790 */
791MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
792
793/* reg_spvm_local_port
794 * Local port number.
795 * Access: Index
796 */
797MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
798
799/* reg_spvm_sub_port
800 * Virtual port within the physical port.
801 * Should be set to 0 when virtual ports are not enabled on the port.
802 * Access: Index
803 */
804MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
805
806/* reg_spvm_num_rec
807 * Number of records to update. Each record contains: i, e, u, vid.
808 * Access: OP
809 */
810MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
811
812/* reg_spvm_rec_i
813 * Ingress membership in VLAN ID.
814 * Access: Index
815 */
816MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
817 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
818 MLXSW_REG_SPVM_REC_LEN, 0, false);
819
820/* reg_spvm_rec_e
821 * Egress membership in VLAN ID.
822 * Access: Index
823 */
824MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
825 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
826 MLXSW_REG_SPVM_REC_LEN, 0, false);
827
828/* reg_spvm_rec_u
829 * Untagged - port is an untagged member - egress transmission uses untagged
830 * frames on VID<n>
831 * Access: Index
832 */
833MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
834 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
835 MLXSW_REG_SPVM_REC_LEN, 0, false);
836
837/* reg_spvm_rec_vid
838 * Egress membership in VLAN ID.
839 * Access: Index
840 */
841MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
842 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
843 MLXSW_REG_SPVM_REC_LEN, 0, false);
844
845static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
846 u16 vid_begin, u16 vid_end,
847 bool is_member, bool untagged)
848{
849 int size = vid_end - vid_begin + 1;
850 int i;
851
852 MLXSW_REG_ZERO(spvm, payload);
853 mlxsw_reg_spvm_local_port_set(payload, local_port);
854 mlxsw_reg_spvm_num_rec_set(payload, size);
855
856 for (i = 0; i < size; i++) {
857 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
858 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
859 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
860 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
861 }
862}
863
Ido Schimmel148f4722016-02-18 11:30:01 +0100864/* SPAFT - Switch Port Acceptable Frame Types
865 * ------------------------------------------
866 * The Switch Port Acceptable Frame Types register configures the frame
867 * admittance of the port.
868 */
869#define MLXSW_REG_SPAFT_ID 0x2010
870#define MLXSW_REG_SPAFT_LEN 0x08
871
Jiri Pirko21978dc2016-10-21 16:07:20 +0200872MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
Ido Schimmel148f4722016-02-18 11:30:01 +0100873
874/* reg_spaft_local_port
875 * Local port number.
876 * Access: Index
877 *
878 * Note: CPU port is not supported (all tag types are allowed).
879 */
880MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
881
882/* reg_spaft_sub_port
883 * Virtual port within the physical port.
884 * Should be set to 0 when virtual ports are not enabled on the port.
885 * Access: RW
886 */
887MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
888
889/* reg_spaft_allow_untagged
890 * When set, untagged frames on the ingress are allowed (default).
891 * Access: RW
892 */
893MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
894
895/* reg_spaft_allow_prio_tagged
896 * When set, priority tagged frames on the ingress are allowed (default).
897 * Access: RW
898 */
899MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
900
901/* reg_spaft_allow_tagged
902 * When set, tagged frames on the ingress are allowed (default).
903 * Access: RW
904 */
905MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
906
907static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
908 bool allow_untagged)
909{
910 MLXSW_REG_ZERO(spaft, payload);
911 mlxsw_reg_spaft_local_port_set(payload, local_port);
912 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
913 mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
914 mlxsw_reg_spaft_allow_tagged_set(payload, true);
915}
916
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200917/* SFGC - Switch Flooding Group Configuration
918 * ------------------------------------------
919 * The following register controls the association of flooding tables and MIDs
920 * to packet types used for flooding.
921 */
Jiri Pirko36b78e82015-10-15 17:43:24 +0200922#define MLXSW_REG_SFGC_ID 0x2011
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200923#define MLXSW_REG_SFGC_LEN 0x10
924
Jiri Pirko21978dc2016-10-21 16:07:20 +0200925MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200926
927enum mlxsw_reg_sfgc_type {
Ido Schimmelfa6ad052015-10-15 17:43:25 +0200928 MLXSW_REG_SFGC_TYPE_BROADCAST,
929 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
930 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
931 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
932 MLXSW_REG_SFGC_TYPE_RESERVED,
933 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
934 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
935 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
936 MLXSW_REG_SFGC_TYPE_MAX,
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200937};
938
939/* reg_sfgc_type
940 * The traffic type to reach the flooding table.
941 * Access: Index
942 */
943MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
944
945enum mlxsw_reg_sfgc_bridge_type {
946 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
947 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
948};
949
950/* reg_sfgc_bridge_type
951 * Access: Index
952 *
953 * Note: SwitchX-2 only supports 802.1Q mode.
954 */
955MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
956
957enum mlxsw_flood_table_type {
958 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
959 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
960 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
961 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3,
962 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
963};
964
965/* reg_sfgc_table_type
966 * See mlxsw_flood_table_type
967 * Access: RW
968 *
969 * Note: FID offset and FID types are not supported in SwitchX-2.
970 */
971MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
972
973/* reg_sfgc_flood_table
974 * Flooding table index to associate with the specific type on the specific
975 * switch partition.
976 * Access: RW
977 */
978MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
979
980/* reg_sfgc_mid
981 * The multicast ID for the swid. Not supported for Spectrum
982 * Access: RW
983 */
984MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
985
986/* reg_sfgc_counter_set_type
987 * Counter Set Type for flow counters.
988 * Access: RW
989 */
990MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
991
992/* reg_sfgc_counter_index
993 * Counter Index for flow counters.
994 * Access: RW
995 */
996MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
997
998static inline void
999mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1000 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1001 enum mlxsw_flood_table_type table_type,
1002 unsigned int flood_table)
1003{
1004 MLXSW_REG_ZERO(sfgc, payload);
1005 mlxsw_reg_sfgc_type_set(payload, type);
1006 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1007 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1008 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1009 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1010}
1011
1012/* SFTR - Switch Flooding Table Register
1013 * -------------------------------------
1014 * The switch flooding table is used for flooding packet replication. The table
1015 * defines a bit mask of ports for packet replication.
1016 */
1017#define MLXSW_REG_SFTR_ID 0x2012
1018#define MLXSW_REG_SFTR_LEN 0x420
1019
Jiri Pirko21978dc2016-10-21 16:07:20 +02001020MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001021
1022/* reg_sftr_swid
1023 * Switch partition ID with which to associate the port.
1024 * Access: Index
1025 */
1026MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
1027
1028/* reg_sftr_flood_table
1029 * Flooding table index to associate with the specific type on the specific
1030 * switch partition.
1031 * Access: Index
1032 */
1033MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1034
1035/* reg_sftr_index
1036 * Index. Used as an index into the Flooding Table in case the table is
1037 * configured to use VID / FID or FID Offset.
1038 * Access: Index
1039 */
1040MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1041
1042/* reg_sftr_table_type
1043 * See mlxsw_flood_table_type
1044 * Access: RW
1045 */
1046MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1047
1048/* reg_sftr_range
1049 * Range of entries to update
1050 * Access: Index
1051 */
1052MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1053
1054/* reg_sftr_port
1055 * Local port membership (1 bit per port).
1056 * Access: RW
1057 */
1058MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1059
1060/* reg_sftr_cpu_port_mask
1061 * CPU port mask (1 bit per port).
1062 * Access: W
1063 */
1064MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1065
1066static inline void mlxsw_reg_sftr_pack(char *payload,
1067 unsigned int flood_table,
1068 unsigned int index,
1069 enum mlxsw_flood_table_type table_type,
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001070 unsigned int range, u8 port, bool set)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001071{
1072 MLXSW_REG_ZERO(sftr, payload);
1073 mlxsw_reg_sftr_swid_set(payload, 0);
1074 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1075 mlxsw_reg_sftr_index_set(payload, index);
1076 mlxsw_reg_sftr_table_type_set(payload, table_type);
1077 mlxsw_reg_sftr_range_set(payload, range);
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001078 mlxsw_reg_sftr_port_set(payload, port, set);
1079 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001080}
1081
Ido Schimmel41933272016-01-27 15:20:17 +01001082/* SFDF - Switch Filtering DB Flush
1083 * --------------------------------
1084 * The switch filtering DB flush register is used to flush the FDB.
1085 * Note that FDB notifications are flushed as well.
1086 */
1087#define MLXSW_REG_SFDF_ID 0x2013
1088#define MLXSW_REG_SFDF_LEN 0x14
1089
Jiri Pirko21978dc2016-10-21 16:07:20 +02001090MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
Ido Schimmel41933272016-01-27 15:20:17 +01001091
1092/* reg_sfdf_swid
1093 * Switch partition ID.
1094 * Access: Index
1095 */
1096MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1097
1098enum mlxsw_reg_sfdf_flush_type {
1099 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1100 MLXSW_REG_SFDF_FLUSH_PER_FID,
1101 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1102 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1103 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1104 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1105};
1106
1107/* reg_sfdf_flush_type
1108 * Flush type.
1109 * 0 - All SWID dynamic entries are flushed.
1110 * 1 - All FID dynamic entries are flushed.
1111 * 2 - All dynamic entries pointing to port are flushed.
1112 * 3 - All FID dynamic entries pointing to port are flushed.
1113 * 4 - All dynamic entries pointing to LAG are flushed.
1114 * 5 - All FID dynamic entries pointing to LAG are flushed.
1115 * Access: RW
1116 */
1117MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1118
1119/* reg_sfdf_flush_static
1120 * Static.
1121 * 0 - Flush only dynamic entries.
1122 * 1 - Flush both dynamic and static entries.
1123 * Access: RW
1124 */
1125MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1126
1127static inline void mlxsw_reg_sfdf_pack(char *payload,
1128 enum mlxsw_reg_sfdf_flush_type type)
1129{
1130 MLXSW_REG_ZERO(sfdf, payload);
1131 mlxsw_reg_sfdf_flush_type_set(payload, type);
1132 mlxsw_reg_sfdf_flush_static_set(payload, true);
1133}
1134
1135/* reg_sfdf_fid
1136 * FID to flush.
1137 * Access: RW
1138 */
1139MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1140
1141/* reg_sfdf_system_port
1142 * Port to flush.
1143 * Access: RW
1144 */
1145MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1146
1147/* reg_sfdf_port_fid_system_port
1148 * Port to flush, pointed to by FID.
1149 * Access: RW
1150 */
1151MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1152
1153/* reg_sfdf_lag_id
1154 * LAG ID to flush.
1155 * Access: RW
1156 */
1157MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1158
1159/* reg_sfdf_lag_fid_lag_id
1160 * LAG ID to flush, pointed to by FID.
1161 * Access: RW
1162 */
1163MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1164
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001165/* SLDR - Switch LAG Descriptor Register
1166 * -----------------------------------------
1167 * The switch LAG descriptor register is populated by LAG descriptors.
1168 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1169 * max_lag-1.
1170 */
1171#define MLXSW_REG_SLDR_ID 0x2014
1172#define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1173
Jiri Pirko21978dc2016-10-21 16:07:20 +02001174MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001175
1176enum mlxsw_reg_sldr_op {
1177 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1178 MLXSW_REG_SLDR_OP_LAG_CREATE,
1179 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1180 /* Ports that appear in the list have the Distributor enabled */
1181 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1182 /* Removes ports from the disributor list */
1183 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1184};
1185
1186/* reg_sldr_op
1187 * Operation.
1188 * Access: RW
1189 */
1190MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1191
1192/* reg_sldr_lag_id
1193 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1194 * Access: Index
1195 */
1196MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1197
1198static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1199{
1200 MLXSW_REG_ZERO(sldr, payload);
1201 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1202 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1203}
1204
1205static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1206{
1207 MLXSW_REG_ZERO(sldr, payload);
1208 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1209 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1210}
1211
1212/* reg_sldr_num_ports
1213 * The number of member ports of the LAG.
1214 * Reserved for Create / Destroy operations
1215 * For Add / Remove operations - indicates the number of ports in the list.
1216 * Access: RW
1217 */
1218MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1219
1220/* reg_sldr_system_port
1221 * System port.
1222 * Access: RW
1223 */
1224MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1225
1226static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1227 u8 local_port)
1228{
1229 MLXSW_REG_ZERO(sldr, payload);
1230 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1231 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1232 mlxsw_reg_sldr_num_ports_set(payload, 1);
1233 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1234}
1235
1236static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1237 u8 local_port)
1238{
1239 MLXSW_REG_ZERO(sldr, payload);
1240 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1241 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1242 mlxsw_reg_sldr_num_ports_set(payload, 1);
1243 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1244}
1245
1246/* SLCR - Switch LAG Configuration 2 Register
1247 * -------------------------------------------
1248 * The Switch LAG Configuration register is used for configuring the
1249 * LAG properties of the switch.
1250 */
1251#define MLXSW_REG_SLCR_ID 0x2015
1252#define MLXSW_REG_SLCR_LEN 0x10
1253
Jiri Pirko21978dc2016-10-21 16:07:20 +02001254MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001255
1256enum mlxsw_reg_slcr_pp {
1257 /* Global Configuration (for all ports) */
1258 MLXSW_REG_SLCR_PP_GLOBAL,
1259 /* Per port configuration, based on local_port field */
1260 MLXSW_REG_SLCR_PP_PER_PORT,
1261};
1262
1263/* reg_slcr_pp
1264 * Per Port Configuration
1265 * Note: Reading at Global mode results in reading port 1 configuration.
1266 * Access: Index
1267 */
1268MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1269
1270/* reg_slcr_local_port
1271 * Local port number
1272 * Supported from CPU port
1273 * Not supported from router port
1274 * Reserved when pp = Global Configuration
1275 * Access: Index
1276 */
1277MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1278
1279enum mlxsw_reg_slcr_type {
1280 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1281 MLXSW_REG_SLCR_TYPE_XOR,
1282 MLXSW_REG_SLCR_TYPE_RANDOM,
1283};
1284
1285/* reg_slcr_type
1286 * Hash type
1287 * Access: RW
1288 */
1289MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1290
1291/* Ingress port */
1292#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1293/* SMAC - for IPv4 and IPv6 packets */
1294#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1295/* SMAC - for non-IP packets */
1296#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1297#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1298 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1299 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1300/* DMAC - for IPv4 and IPv6 packets */
1301#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1302/* DMAC - for non-IP packets */
1303#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1304#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1305 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1306 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1307/* Ethertype - for IPv4 and IPv6 packets */
1308#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1309/* Ethertype - for non-IP packets */
1310#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1311#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1312 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1313 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1314/* VLAN ID - for IPv4 and IPv6 packets */
1315#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1316/* VLAN ID - for non-IP packets */
1317#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1318#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1319 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1320 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1321/* Source IP address (can be IPv4 or IPv6) */
1322#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1323/* Destination IP address (can be IPv4 or IPv6) */
1324#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1325/* TCP/UDP source port */
1326#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1327/* TCP/UDP destination port*/
1328#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1329/* IPv4 Protocol/IPv6 Next Header */
1330#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1331/* IPv6 Flow label */
1332#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1333/* SID - FCoE source ID */
1334#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1335/* DID - FCoE destination ID */
1336#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1337/* OXID - FCoE originator exchange ID */
1338#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1339/* Destination QP number - for RoCE packets */
1340#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1341
1342/* reg_slcr_lag_hash
1343 * LAG hashing configuration. This is a bitmask, in which each set
1344 * bit includes the corresponding item in the LAG hash calculation.
1345 * The default lag_hash contains SMAC, DMAC, VLANID and
1346 * Ethertype (for all packet types).
1347 * Access: RW
1348 */
1349MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1350
1351static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash)
1352{
1353 MLXSW_REG_ZERO(slcr, payload);
1354 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
Elad Raz18c2d2c2016-09-19 08:28:24 +02001355 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001356 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1357}
1358
1359/* SLCOR - Switch LAG Collector Register
1360 * -------------------------------------
1361 * The Switch LAG Collector register controls the Local Port membership
1362 * in a LAG and enablement of the collector.
1363 */
1364#define MLXSW_REG_SLCOR_ID 0x2016
1365#define MLXSW_REG_SLCOR_LEN 0x10
1366
Jiri Pirko21978dc2016-10-21 16:07:20 +02001367MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001368
1369enum mlxsw_reg_slcor_col {
1370 /* Port is added with collector disabled */
1371 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1372 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1373 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1374 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1375};
1376
1377/* reg_slcor_col
1378 * Collector configuration
1379 * Access: RW
1380 */
1381MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1382
1383/* reg_slcor_local_port
1384 * Local port number
1385 * Not supported for CPU port
1386 * Access: Index
1387 */
1388MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1389
1390/* reg_slcor_lag_id
1391 * LAG Identifier. Index into the LAG descriptor table.
1392 * Access: Index
1393 */
1394MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1395
1396/* reg_slcor_port_index
1397 * Port index in the LAG list. Only valid on Add Port to LAG col.
1398 * Valid range is from 0 to cap_max_lag_members-1
1399 * Access: RW
1400 */
1401MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1402
1403static inline void mlxsw_reg_slcor_pack(char *payload,
1404 u8 local_port, u16 lag_id,
1405 enum mlxsw_reg_slcor_col col)
1406{
1407 MLXSW_REG_ZERO(slcor, payload);
1408 mlxsw_reg_slcor_col_set(payload, col);
1409 mlxsw_reg_slcor_local_port_set(payload, local_port);
1410 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1411}
1412
1413static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1414 u8 local_port, u16 lag_id,
1415 u8 port_index)
1416{
1417 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1418 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1419 mlxsw_reg_slcor_port_index_set(payload, port_index);
1420}
1421
1422static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1423 u8 local_port, u16 lag_id)
1424{
1425 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1426 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1427}
1428
1429static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1430 u8 local_port, u16 lag_id)
1431{
1432 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1433 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1434}
1435
1436static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1437 u8 local_port, u16 lag_id)
1438{
1439 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1440 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1441}
1442
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001443/* SPMLR - Switch Port MAC Learning Register
1444 * -----------------------------------------
1445 * Controls the Switch MAC learning policy per port.
1446 */
1447#define MLXSW_REG_SPMLR_ID 0x2018
1448#define MLXSW_REG_SPMLR_LEN 0x8
1449
Jiri Pirko21978dc2016-10-21 16:07:20 +02001450MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001451
1452/* reg_spmlr_local_port
1453 * Local port number.
1454 * Access: Index
1455 */
1456MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1457
1458/* reg_spmlr_sub_port
1459 * Virtual port within the physical port.
1460 * Should be set to 0 when virtual ports are not enabled on the port.
1461 * Access: Index
1462 */
1463MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1464
1465enum mlxsw_reg_spmlr_learn_mode {
1466 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1467 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1468 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1469};
1470
1471/* reg_spmlr_learn_mode
1472 * Learning mode on the port.
1473 * 0 - Learning disabled.
1474 * 2 - Learning enabled.
1475 * 3 - Security mode.
1476 *
1477 * In security mode the switch does not learn MACs on the port, but uses the
1478 * SMAC to see if it exists on another ingress port. If so, the packet is
1479 * classified as a bad packet and is discarded unless the software registers
1480 * to receive port security error packets usign HPKT.
1481 */
1482MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1483
1484static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1485 enum mlxsw_reg_spmlr_learn_mode mode)
1486{
1487 MLXSW_REG_ZERO(spmlr, payload);
1488 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1489 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1490 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1491}
1492
Ido Schimmel64790232015-10-16 14:01:33 +02001493/* SVFA - Switch VID to FID Allocation Register
1494 * --------------------------------------------
1495 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1496 * virtualized ports.
1497 */
1498#define MLXSW_REG_SVFA_ID 0x201C
1499#define MLXSW_REG_SVFA_LEN 0x10
1500
Jiri Pirko21978dc2016-10-21 16:07:20 +02001501MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
Ido Schimmel64790232015-10-16 14:01:33 +02001502
1503/* reg_svfa_swid
1504 * Switch partition ID.
1505 * Access: Index
1506 */
1507MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1508
1509/* reg_svfa_local_port
1510 * Local port number.
1511 * Access: Index
1512 *
1513 * Note: Reserved for 802.1Q FIDs.
1514 */
1515MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1516
1517enum mlxsw_reg_svfa_mt {
1518 MLXSW_REG_SVFA_MT_VID_TO_FID,
1519 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1520};
1521
1522/* reg_svfa_mapping_table
1523 * Mapping table:
1524 * 0 - VID to FID
1525 * 1 - {Port, VID} to FID
1526 * Access: Index
1527 *
1528 * Note: Reserved for SwitchX-2.
1529 */
1530MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1531
1532/* reg_svfa_v
1533 * Valid.
1534 * Valid if set.
1535 * Access: RW
1536 *
1537 * Note: Reserved for SwitchX-2.
1538 */
1539MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1540
1541/* reg_svfa_fid
1542 * Filtering ID.
1543 * Access: RW
1544 */
1545MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1546
1547/* reg_svfa_vid
1548 * VLAN ID.
1549 * Access: Index
1550 */
1551MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1552
1553/* reg_svfa_counter_set_type
1554 * Counter set type for flow counters.
1555 * Access: RW
1556 *
1557 * Note: Reserved for SwitchX-2.
1558 */
1559MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1560
1561/* reg_svfa_counter_index
1562 * Counter index for flow counters.
1563 * Access: RW
1564 *
1565 * Note: Reserved for SwitchX-2.
1566 */
1567MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1568
1569static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1570 enum mlxsw_reg_svfa_mt mt, bool valid,
1571 u16 fid, u16 vid)
1572{
1573 MLXSW_REG_ZERO(svfa, payload);
1574 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1575 mlxsw_reg_svfa_swid_set(payload, 0);
1576 mlxsw_reg_svfa_local_port_set(payload, local_port);
1577 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1578 mlxsw_reg_svfa_v_set(payload, valid);
1579 mlxsw_reg_svfa_fid_set(payload, fid);
1580 mlxsw_reg_svfa_vid_set(payload, vid);
1581}
1582
Ido Schimmel1f65da72015-10-16 14:01:34 +02001583/* SVPE - Switch Virtual-Port Enabling Register
1584 * --------------------------------------------
1585 * Enables port virtualization.
1586 */
1587#define MLXSW_REG_SVPE_ID 0x201E
1588#define MLXSW_REG_SVPE_LEN 0x4
1589
Jiri Pirko21978dc2016-10-21 16:07:20 +02001590MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
Ido Schimmel1f65da72015-10-16 14:01:34 +02001591
1592/* reg_svpe_local_port
1593 * Local port number
1594 * Access: Index
1595 *
1596 * Note: CPU port is not supported (uses VLAN mode only).
1597 */
1598MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1599
1600/* reg_svpe_vp_en
1601 * Virtual port enable.
1602 * 0 - Disable, VLAN mode (VID to FID).
1603 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1604 * Access: RW
1605 */
1606MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1607
1608static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1609 bool enable)
1610{
1611 MLXSW_REG_ZERO(svpe, payload);
1612 mlxsw_reg_svpe_local_port_set(payload, local_port);
1613 mlxsw_reg_svpe_vp_en_set(payload, enable);
1614}
1615
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001616/* SFMR - Switch FID Management Register
1617 * -------------------------------------
1618 * Creates and configures FIDs.
1619 */
1620#define MLXSW_REG_SFMR_ID 0x201F
1621#define MLXSW_REG_SFMR_LEN 0x18
1622
Jiri Pirko21978dc2016-10-21 16:07:20 +02001623MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001624
1625enum mlxsw_reg_sfmr_op {
1626 MLXSW_REG_SFMR_OP_CREATE_FID,
1627 MLXSW_REG_SFMR_OP_DESTROY_FID,
1628};
1629
1630/* reg_sfmr_op
1631 * Operation.
1632 * 0 - Create or edit FID.
1633 * 1 - Destroy FID.
1634 * Access: WO
1635 */
1636MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1637
1638/* reg_sfmr_fid
1639 * Filtering ID.
1640 * Access: Index
1641 */
1642MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1643
1644/* reg_sfmr_fid_offset
1645 * FID offset.
1646 * Used to point into the flooding table selected by SFGC register if
1647 * the table is of type FID-Offset. Otherwise, this field is reserved.
1648 * Access: RW
1649 */
1650MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1651
1652/* reg_sfmr_vtfp
1653 * Valid Tunnel Flood Pointer.
1654 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1655 * Access: RW
1656 *
1657 * Note: Reserved for 802.1Q FIDs.
1658 */
1659MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1660
1661/* reg_sfmr_nve_tunnel_flood_ptr
1662 * Underlay Flooding and BC Pointer.
1663 * Used as a pointer to the first entry of the group based link lists of
1664 * flooding or BC entries (for NVE tunnels).
1665 * Access: RW
1666 */
1667MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1668
1669/* reg_sfmr_vv
1670 * VNI Valid.
1671 * If not set, then vni is reserved.
1672 * Access: RW
1673 *
1674 * Note: Reserved for 802.1Q FIDs.
1675 */
1676MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1677
1678/* reg_sfmr_vni
1679 * Virtual Network Identifier.
1680 * Access: RW
1681 *
1682 * Note: A given VNI can only be assigned to one FID.
1683 */
1684MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1685
1686static inline void mlxsw_reg_sfmr_pack(char *payload,
1687 enum mlxsw_reg_sfmr_op op, u16 fid,
1688 u16 fid_offset)
1689{
1690 MLXSW_REG_ZERO(sfmr, payload);
1691 mlxsw_reg_sfmr_op_set(payload, op);
1692 mlxsw_reg_sfmr_fid_set(payload, fid);
1693 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1694 mlxsw_reg_sfmr_vtfp_set(payload, false);
1695 mlxsw_reg_sfmr_vv_set(payload, false);
1696}
1697
Ido Schimmela4feea72015-10-16 14:01:36 +02001698/* SPVMLR - Switch Port VLAN MAC Learning Register
1699 * -----------------------------------------------
1700 * Controls the switch MAC learning policy per {Port, VID}.
1701 */
1702#define MLXSW_REG_SPVMLR_ID 0x2020
1703#define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1704#define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
1705#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 256
1706#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1707 MLXSW_REG_SPVMLR_REC_LEN * \
1708 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1709
Jiri Pirko21978dc2016-10-21 16:07:20 +02001710MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
Ido Schimmela4feea72015-10-16 14:01:36 +02001711
1712/* reg_spvmlr_local_port
1713 * Local ingress port.
1714 * Access: Index
1715 *
1716 * Note: CPU port is not supported.
1717 */
1718MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1719
1720/* reg_spvmlr_num_rec
1721 * Number of records to update.
1722 * Access: OP
1723 */
1724MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1725
1726/* reg_spvmlr_rec_learn_enable
1727 * 0 - Disable learning for {Port, VID}.
1728 * 1 - Enable learning for {Port, VID}.
1729 * Access: RW
1730 */
1731MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1732 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1733
1734/* reg_spvmlr_rec_vid
1735 * VLAN ID to be added/removed from port or for querying.
1736 * Access: Index
1737 */
1738MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1739 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1740
1741static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1742 u16 vid_begin, u16 vid_end,
1743 bool learn_enable)
1744{
1745 int num_rec = vid_end - vid_begin + 1;
1746 int i;
1747
1748 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1749
1750 MLXSW_REG_ZERO(spvmlr, payload);
1751 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1752 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1753
1754 for (i = 0; i < num_rec; i++) {
1755 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1756 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1757 }
1758}
1759
Ido Schimmel2c63a552016-04-06 17:10:07 +02001760/* QTCT - QoS Switch Traffic Class Table
1761 * -------------------------------------
1762 * Configures the mapping between the packet switch priority and the
1763 * traffic class on the transmit port.
1764 */
1765#define MLXSW_REG_QTCT_ID 0x400A
1766#define MLXSW_REG_QTCT_LEN 0x08
1767
Jiri Pirko21978dc2016-10-21 16:07:20 +02001768MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
Ido Schimmel2c63a552016-04-06 17:10:07 +02001769
1770/* reg_qtct_local_port
1771 * Local port number.
1772 * Access: Index
1773 *
1774 * Note: CPU port is not supported.
1775 */
1776MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
1777
1778/* reg_qtct_sub_port
1779 * Virtual port within the physical port.
1780 * Should be set to 0 when virtual ports are not enabled on the port.
1781 * Access: Index
1782 */
1783MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
1784
1785/* reg_qtct_switch_prio
1786 * Switch priority.
1787 * Access: Index
1788 */
1789MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
1790
1791/* reg_qtct_tclass
1792 * Traffic class.
1793 * Default values:
1794 * switch_prio 0 : tclass 1
1795 * switch_prio 1 : tclass 0
1796 * switch_prio i : tclass i, for i > 1
1797 * Access: RW
1798 */
1799MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
1800
1801static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
1802 u8 switch_prio, u8 tclass)
1803{
1804 MLXSW_REG_ZERO(qtct, payload);
1805 mlxsw_reg_qtct_local_port_set(payload, local_port);
1806 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
1807 mlxsw_reg_qtct_tclass_set(payload, tclass);
1808}
1809
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02001810/* QEEC - QoS ETS Element Configuration Register
1811 * ---------------------------------------------
1812 * Configures the ETS elements.
1813 */
1814#define MLXSW_REG_QEEC_ID 0x400D
1815#define MLXSW_REG_QEEC_LEN 0x1C
1816
Jiri Pirko21978dc2016-10-21 16:07:20 +02001817MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02001818
1819/* reg_qeec_local_port
1820 * Local port number.
1821 * Access: Index
1822 *
1823 * Note: CPU port is supported.
1824 */
1825MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
1826
1827enum mlxsw_reg_qeec_hr {
1828 MLXSW_REG_QEEC_HIERARCY_PORT,
1829 MLXSW_REG_QEEC_HIERARCY_GROUP,
1830 MLXSW_REG_QEEC_HIERARCY_SUBGROUP,
1831 MLXSW_REG_QEEC_HIERARCY_TC,
1832};
1833
1834/* reg_qeec_element_hierarchy
1835 * 0 - Port
1836 * 1 - Group
1837 * 2 - Subgroup
1838 * 3 - Traffic Class
1839 * Access: Index
1840 */
1841MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
1842
1843/* reg_qeec_element_index
1844 * The index of the element in the hierarchy.
1845 * Access: Index
1846 */
1847MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
1848
1849/* reg_qeec_next_element_index
1850 * The index of the next (lower) element in the hierarchy.
1851 * Access: RW
1852 *
1853 * Note: Reserved for element_hierarchy 0.
1854 */
1855MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
1856
1857enum {
1858 MLXSW_REG_QEEC_BYTES_MODE,
1859 MLXSW_REG_QEEC_PACKETS_MODE,
1860};
1861
1862/* reg_qeec_pb
1863 * Packets or bytes mode.
1864 * 0 - Bytes mode
1865 * 1 - Packets mode
1866 * Access: RW
1867 *
1868 * Note: Used for max shaper configuration. For Spectrum, packets mode
1869 * is supported only for traffic classes of CPU port.
1870 */
1871MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
1872
1873/* reg_qeec_mase
1874 * Max shaper configuration enable. Enables configuration of the max
1875 * shaper on this ETS element.
1876 * 0 - Disable
1877 * 1 - Enable
1878 * Access: RW
1879 */
1880MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
1881
1882/* A large max rate will disable the max shaper. */
1883#define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */
1884
1885/* reg_qeec_max_shaper_rate
1886 * Max shaper information rate.
1887 * For CPU port, can only be configured for port hierarchy.
1888 * When in bytes mode, value is specified in units of 1000bps.
1889 * Access: RW
1890 */
1891MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
1892
1893/* reg_qeec_de
1894 * DWRR configuration enable. Enables configuration of the dwrr and
1895 * dwrr_weight.
1896 * 0 - Disable
1897 * 1 - Enable
1898 * Access: RW
1899 */
1900MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
1901
1902/* reg_qeec_dwrr
1903 * Transmission selection algorithm to use on the link going down from
1904 * the ETS element.
1905 * 0 - Strict priority
1906 * 1 - DWRR
1907 * Access: RW
1908 */
1909MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
1910
1911/* reg_qeec_dwrr_weight
1912 * DWRR weight on the link going down from the ETS element. The
1913 * percentage of bandwidth guaranteed to an ETS element within
1914 * its hierarchy. The sum of all weights across all ETS elements
1915 * within one hierarchy should be equal to 100. Reserved when
1916 * transmission selection algorithm is strict priority.
1917 * Access: RW
1918 */
1919MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
1920
1921static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
1922 enum mlxsw_reg_qeec_hr hr, u8 index,
1923 u8 next_index)
1924{
1925 MLXSW_REG_ZERO(qeec, payload);
1926 mlxsw_reg_qeec_local_port_set(payload, local_port);
1927 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
1928 mlxsw_reg_qeec_element_index_set(payload, index);
1929 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
1930}
1931
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001932/* PMLP - Ports Module to Local Port Register
1933 * ------------------------------------------
1934 * Configures the assignment of modules to local ports.
1935 */
1936#define MLXSW_REG_PMLP_ID 0x5002
1937#define MLXSW_REG_PMLP_LEN 0x40
1938
Jiri Pirko21978dc2016-10-21 16:07:20 +02001939MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001940
1941/* reg_pmlp_rxtx
1942 * 0 - Tx value is used for both Tx and Rx.
1943 * 1 - Rx value is taken from a separte field.
1944 * Access: RW
1945 */
1946MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
1947
1948/* reg_pmlp_local_port
1949 * Local port number.
1950 * Access: Index
1951 */
1952MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
1953
1954/* reg_pmlp_width
1955 * 0 - Unmap local port.
1956 * 1 - Lane 0 is used.
1957 * 2 - Lanes 0 and 1 are used.
1958 * 4 - Lanes 0, 1, 2 and 3 are used.
1959 * Access: RW
1960 */
1961MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
1962
1963/* reg_pmlp_module
1964 * Module number.
1965 * Access: RW
1966 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01001967MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001968
1969/* reg_pmlp_tx_lane
1970 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
1971 * Access: RW
1972 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01001973MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001974
1975/* reg_pmlp_rx_lane
1976 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
1977 * equal to Tx lane.
1978 * Access: RW
1979 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01001980MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001981
1982static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
1983{
1984 MLXSW_REG_ZERO(pmlp, payload);
1985 mlxsw_reg_pmlp_local_port_set(payload, local_port);
1986}
1987
1988/* PMTU - Port MTU Register
1989 * ------------------------
1990 * Configures and reports the port MTU.
1991 */
1992#define MLXSW_REG_PMTU_ID 0x5003
1993#define MLXSW_REG_PMTU_LEN 0x10
1994
Jiri Pirko21978dc2016-10-21 16:07:20 +02001995MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001996
1997/* reg_pmtu_local_port
1998 * Local port number.
1999 * Access: Index
2000 */
2001MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
2002
2003/* reg_pmtu_max_mtu
2004 * Maximum MTU.
2005 * When port type (e.g. Ethernet) is configured, the relevant MTU is
2006 * reported, otherwise the minimum between the max_mtu of the different
2007 * types is reported.
2008 * Access: RO
2009 */
2010MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
2011
2012/* reg_pmtu_admin_mtu
2013 * MTU value to set port to. Must be smaller or equal to max_mtu.
2014 * Note: If port type is Infiniband, then port must be disabled, when its
2015 * MTU is set.
2016 * Access: RW
2017 */
2018MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
2019
2020/* reg_pmtu_oper_mtu
2021 * The actual MTU configured on the port. Packets exceeding this size
2022 * will be dropped.
2023 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
2024 * oper_mtu might be smaller than admin_mtu.
2025 * Access: RO
2026 */
2027MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
2028
2029static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
2030 u16 new_mtu)
2031{
2032 MLXSW_REG_ZERO(pmtu, payload);
2033 mlxsw_reg_pmtu_local_port_set(payload, local_port);
2034 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
2035 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
2036 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
2037}
2038
2039/* PTYS - Port Type and Speed Register
2040 * -----------------------------------
2041 * Configures and reports the port speed type.
2042 *
2043 * Note: When set while the link is up, the changes will not take effect
2044 * until the port transitions from down to up state.
2045 */
2046#define MLXSW_REG_PTYS_ID 0x5004
2047#define MLXSW_REG_PTYS_LEN 0x40
2048
Jiri Pirko21978dc2016-10-21 16:07:20 +02002049MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002050
2051/* reg_ptys_local_port
2052 * Local port number.
2053 * Access: Index
2054 */
2055MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
2056
Elad Raz79417702016-10-28 21:35:53 +02002057#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002058#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
2059
2060/* reg_ptys_proto_mask
2061 * Protocol mask. Indicates which protocol is used.
2062 * 0 - Infiniband.
2063 * 1 - Fibre Channel.
2064 * 2 - Ethernet.
2065 * Access: Index
2066 */
2067MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
2068
Ido Schimmel4149b972016-09-12 13:26:24 +02002069enum {
2070 MLXSW_REG_PTYS_AN_STATUS_NA,
2071 MLXSW_REG_PTYS_AN_STATUS_OK,
2072 MLXSW_REG_PTYS_AN_STATUS_FAIL,
2073};
2074
2075/* reg_ptys_an_status
2076 * Autonegotiation status.
2077 * Access: RO
2078 */
2079MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
2080
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002081#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
2082#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
2083#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
2084#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
2085#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
2086#define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
2087#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
2088#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
2089#define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
2090#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
2091#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
2092#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
2093#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
2094#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
Ido Schimmelb9d66a32016-09-12 13:26:27 +02002095#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002096#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
2097#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
2098#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
2099#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
2100#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
2101#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
2102#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
2103#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
2104#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
2105#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
2106#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
2107#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
2108#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
2109
2110/* reg_ptys_eth_proto_cap
2111 * Ethernet port supported speeds and protocols.
2112 * Access: RO
2113 */
2114MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
2115
Elad Raz79417702016-10-28 21:35:53 +02002116/* reg_ptys_ib_link_width_cap
2117 * IB port supported widths.
2118 * Access: RO
2119 */
2120MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
2121
2122#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
2123#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
2124#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
2125#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
2126#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
2127#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
2128
2129/* reg_ptys_ib_proto_cap
2130 * IB port supported speeds and protocols.
2131 * Access: RO
2132 */
2133MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
2134
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002135/* reg_ptys_eth_proto_admin
2136 * Speed and protocol to set port to.
2137 * Access: RW
2138 */
2139MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
2140
Elad Raz79417702016-10-28 21:35:53 +02002141/* reg_ptys_ib_link_width_admin
2142 * IB width to set port to.
2143 * Access: RW
2144 */
2145MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
2146
2147/* reg_ptys_ib_proto_admin
2148 * IB speeds and protocols to set port to.
2149 * Access: RW
2150 */
2151MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
2152
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002153/* reg_ptys_eth_proto_oper
2154 * The current speed and protocol configured for the port.
2155 * Access: RO
2156 */
2157MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
2158
Elad Raz79417702016-10-28 21:35:53 +02002159/* reg_ptys_ib_link_width_oper
2160 * The current IB width to set port to.
2161 * Access: RO
2162 */
2163MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
2164
2165/* reg_ptys_ib_proto_oper
2166 * The current IB speed and protocol.
2167 * Access: RO
2168 */
2169MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
2170
Ido Schimmel4149b972016-09-12 13:26:24 +02002171/* reg_ptys_eth_proto_lp_advertise
2172 * The protocols that were advertised by the link partner during
2173 * autonegotiation.
2174 * Access: RO
2175 */
2176MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
2177
Elad Raz401c8b42016-10-28 21:35:52 +02002178static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
2179 u32 proto_admin)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002180{
2181 MLXSW_REG_ZERO(ptys, payload);
2182 mlxsw_reg_ptys_local_port_set(payload, local_port);
2183 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
2184 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
2185}
2186
Elad Raz401c8b42016-10-28 21:35:52 +02002187static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
2188 u32 *p_eth_proto_cap,
2189 u32 *p_eth_proto_adm,
2190 u32 *p_eth_proto_oper)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002191{
2192 if (p_eth_proto_cap)
2193 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
2194 if (p_eth_proto_adm)
2195 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
2196 if (p_eth_proto_oper)
2197 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
2198}
2199
Elad Raz79417702016-10-28 21:35:53 +02002200static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
2201 u16 proto_admin, u16 link_width)
2202{
2203 MLXSW_REG_ZERO(ptys, payload);
2204 mlxsw_reg_ptys_local_port_set(payload, local_port);
2205 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
2206 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
2207 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
2208}
2209
2210static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
2211 u16 *p_ib_link_width_cap,
2212 u16 *p_ib_proto_oper,
2213 u16 *p_ib_link_width_oper)
2214{
2215 if (p_ib_proto_cap)
2216 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
2217 if (p_ib_link_width_cap)
2218 *p_ib_link_width_cap =
2219 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
2220 if (p_ib_proto_oper)
2221 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
2222 if (p_ib_link_width_oper)
2223 *p_ib_link_width_oper =
2224 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
2225}
2226
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002227/* PPAD - Port Physical Address Register
2228 * -------------------------------------
2229 * The PPAD register configures the per port physical MAC address.
2230 */
2231#define MLXSW_REG_PPAD_ID 0x5005
2232#define MLXSW_REG_PPAD_LEN 0x10
2233
Jiri Pirko21978dc2016-10-21 16:07:20 +02002234MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002235
2236/* reg_ppad_single_base_mac
2237 * 0: base_mac, local port should be 0 and mac[7:0] is
2238 * reserved. HW will set incremental
2239 * 1: single_mac - mac of the local_port
2240 * Access: RW
2241 */
2242MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
2243
2244/* reg_ppad_local_port
2245 * port number, if single_base_mac = 0 then local_port is reserved
2246 * Access: RW
2247 */
2248MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
2249
2250/* reg_ppad_mac
2251 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
2252 * If single_base_mac = 1 - the per port MAC address
2253 * Access: RW
2254 */
2255MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
2256
2257static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
2258 u8 local_port)
2259{
2260 MLXSW_REG_ZERO(ppad, payload);
2261 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
2262 mlxsw_reg_ppad_local_port_set(payload, local_port);
2263}
2264
2265/* PAOS - Ports Administrative and Operational Status Register
2266 * -----------------------------------------------------------
2267 * Configures and retrieves per port administrative and operational status.
2268 */
2269#define MLXSW_REG_PAOS_ID 0x5006
2270#define MLXSW_REG_PAOS_LEN 0x10
2271
Jiri Pirko21978dc2016-10-21 16:07:20 +02002272MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002273
2274/* reg_paos_swid
2275 * Switch partition ID with which to associate the port.
2276 * Note: while external ports uses unique local port numbers (and thus swid is
2277 * redundant), router ports use the same local port number where swid is the
2278 * only indication for the relevant port.
2279 * Access: Index
2280 */
2281MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
2282
2283/* reg_paos_local_port
2284 * Local port number.
2285 * Access: Index
2286 */
2287MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
2288
2289/* reg_paos_admin_status
2290 * Port administrative state (the desired state of the port):
2291 * 1 - Up.
2292 * 2 - Down.
2293 * 3 - Up once. This means that in case of link failure, the port won't go
2294 * into polling mode, but will wait to be re-enabled by software.
2295 * 4 - Disabled by system. Can only be set by hardware.
2296 * Access: RW
2297 */
2298MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
2299
2300/* reg_paos_oper_status
2301 * Port operational state (the current state):
2302 * 1 - Up.
2303 * 2 - Down.
2304 * 3 - Down by port failure. This means that the device will not let the
2305 * port up again until explicitly specified by software.
2306 * Access: RO
2307 */
2308MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
2309
2310/* reg_paos_ase
2311 * Admin state update enabled.
2312 * Access: WO
2313 */
2314MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
2315
2316/* reg_paos_ee
2317 * Event update enable. If this bit is set, event generation will be
2318 * updated based on the e field.
2319 * Access: WO
2320 */
2321MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
2322
2323/* reg_paos_e
2324 * Event generation on operational state change:
2325 * 0 - Do not generate event.
2326 * 1 - Generate Event.
2327 * 2 - Generate Single Event.
2328 * Access: RW
2329 */
2330MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
2331
2332static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
2333 enum mlxsw_port_admin_status status)
2334{
2335 MLXSW_REG_ZERO(paos, payload);
2336 mlxsw_reg_paos_swid_set(payload, 0);
2337 mlxsw_reg_paos_local_port_set(payload, local_port);
2338 mlxsw_reg_paos_admin_status_set(payload, status);
2339 mlxsw_reg_paos_oper_status_set(payload, 0);
2340 mlxsw_reg_paos_ase_set(payload, 1);
2341 mlxsw_reg_paos_ee_set(payload, 1);
2342 mlxsw_reg_paos_e_set(payload, 1);
2343}
2344
Ido Schimmel6f253d82016-04-06 17:10:12 +02002345/* PFCC - Ports Flow Control Configuration Register
2346 * ------------------------------------------------
2347 * Configures and retrieves the per port flow control configuration.
2348 */
2349#define MLXSW_REG_PFCC_ID 0x5007
2350#define MLXSW_REG_PFCC_LEN 0x20
2351
Jiri Pirko21978dc2016-10-21 16:07:20 +02002352MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
Ido Schimmel6f253d82016-04-06 17:10:12 +02002353
2354/* reg_pfcc_local_port
2355 * Local port number.
2356 * Access: Index
2357 */
2358MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
2359
2360/* reg_pfcc_pnat
2361 * Port number access type. Determines the way local_port is interpreted:
2362 * 0 - Local port number.
2363 * 1 - IB / label port number.
2364 * Access: Index
2365 */
2366MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
2367
2368/* reg_pfcc_shl_cap
2369 * Send to higher layers capabilities:
2370 * 0 - No capability of sending Pause and PFC frames to higher layers.
2371 * 1 - Device has capability of sending Pause and PFC frames to higher
2372 * layers.
2373 * Access: RO
2374 */
2375MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
2376
2377/* reg_pfcc_shl_opr
2378 * Send to higher layers operation:
2379 * 0 - Pause and PFC frames are handled by the port (default).
2380 * 1 - Pause and PFC frames are handled by the port and also sent to
2381 * higher layers. Only valid if shl_cap = 1.
2382 * Access: RW
2383 */
2384MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
2385
2386/* reg_pfcc_ppan
2387 * Pause policy auto negotiation.
2388 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
2389 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
2390 * based on the auto-negotiation resolution.
2391 * Access: RW
2392 *
2393 * Note: The auto-negotiation advertisement is set according to pptx and
2394 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
2395 */
2396MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
2397
2398/* reg_pfcc_prio_mask_tx
2399 * Bit per priority indicating if Tx flow control policy should be
2400 * updated based on bit pfctx.
2401 * Access: WO
2402 */
2403MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
2404
2405/* reg_pfcc_prio_mask_rx
2406 * Bit per priority indicating if Rx flow control policy should be
2407 * updated based on bit pfcrx.
2408 * Access: WO
2409 */
2410MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
2411
2412/* reg_pfcc_pptx
2413 * Admin Pause policy on Tx.
2414 * 0 - Never generate Pause frames (default).
2415 * 1 - Generate Pause frames according to Rx buffer threshold.
2416 * Access: RW
2417 */
2418MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
2419
2420/* reg_pfcc_aptx
2421 * Active (operational) Pause policy on Tx.
2422 * 0 - Never generate Pause frames.
2423 * 1 - Generate Pause frames according to Rx buffer threshold.
2424 * Access: RO
2425 */
2426MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
2427
2428/* reg_pfcc_pfctx
2429 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
2430 * 0 - Never generate priority Pause frames on the specified priority
2431 * (default).
2432 * 1 - Generate priority Pause frames according to Rx buffer threshold on
2433 * the specified priority.
2434 * Access: RW
2435 *
2436 * Note: pfctx and pptx must be mutually exclusive.
2437 */
2438MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
2439
2440/* reg_pfcc_pprx
2441 * Admin Pause policy on Rx.
2442 * 0 - Ignore received Pause frames (default).
2443 * 1 - Respect received Pause frames.
2444 * Access: RW
2445 */
2446MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
2447
2448/* reg_pfcc_aprx
2449 * Active (operational) Pause policy on Rx.
2450 * 0 - Ignore received Pause frames.
2451 * 1 - Respect received Pause frames.
2452 * Access: RO
2453 */
2454MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
2455
2456/* reg_pfcc_pfcrx
2457 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
2458 * 0 - Ignore incoming priority Pause frames on the specified priority
2459 * (default).
2460 * 1 - Respect incoming priority Pause frames on the specified priority.
2461 * Access: RW
2462 */
2463MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
2464
Ido Schimmeld81a6bd2016-04-06 17:10:16 +02002465#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
2466
2467static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
2468{
2469 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
2470 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
2471 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
2472 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
2473}
2474
Ido Schimmel6f253d82016-04-06 17:10:12 +02002475static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
2476{
2477 MLXSW_REG_ZERO(pfcc, payload);
2478 mlxsw_reg_pfcc_local_port_set(payload, local_port);
2479}
2480
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002481/* PPCNT - Ports Performance Counters Register
2482 * -------------------------------------------
2483 * The PPCNT register retrieves per port performance counters.
2484 */
2485#define MLXSW_REG_PPCNT_ID 0x5008
2486#define MLXSW_REG_PPCNT_LEN 0x100
2487
Jiri Pirko21978dc2016-10-21 16:07:20 +02002488MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002489
2490/* reg_ppcnt_swid
2491 * For HCA: must be always 0.
2492 * Switch partition ID to associate port with.
2493 * Switch partitions are numbered from 0 to 7 inclusively.
2494 * Switch partition 254 indicates stacking ports.
2495 * Switch partition 255 indicates all switch partitions.
2496 * Only valid on Set() operation with local_port=255.
2497 * Access: Index
2498 */
2499MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
2500
2501/* reg_ppcnt_local_port
2502 * Local port number.
2503 * 255 indicates all ports on the device, and is only allowed
2504 * for Set() operation.
2505 * Access: Index
2506 */
2507MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
2508
2509/* reg_ppcnt_pnat
2510 * Port number access type:
2511 * 0 - Local port number
2512 * 1 - IB port number
2513 * Access: Index
2514 */
2515MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
2516
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002517enum mlxsw_reg_ppcnt_grp {
2518 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
2519 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
Ido Schimmeldf4750e2016-07-19 15:35:54 +02002520 MLXSW_REG_PPCNT_TC_CNT = 0x11,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002521};
2522
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002523/* reg_ppcnt_grp
2524 * Performance counter group.
2525 * Group 63 indicates all groups. Only valid on Set() operation with
2526 * clr bit set.
2527 * 0x0: IEEE 802.3 Counters
2528 * 0x1: RFC 2863 Counters
2529 * 0x2: RFC 2819 Counters
2530 * 0x3: RFC 3635 Counters
2531 * 0x5: Ethernet Extended Counters
2532 * 0x8: Link Level Retransmission Counters
2533 * 0x10: Per Priority Counters
2534 * 0x11: Per Traffic Class Counters
2535 * 0x12: Physical Layer Counters
2536 * Access: Index
2537 */
2538MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
2539
2540/* reg_ppcnt_clr
2541 * Clear counters. Setting the clr bit will reset the counter value
2542 * for all counters in the counter group. This bit can be set
2543 * for both Set() and Get() operation.
2544 * Access: OP
2545 */
2546MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
2547
2548/* reg_ppcnt_prio_tc
2549 * Priority for counter set that support per priority, valid values: 0-7.
2550 * Traffic class for counter set that support per traffic class,
2551 * valid values: 0- cap_max_tclass-1 .
2552 * For HCA: cap_max_tclass is always 8.
2553 * Otherwise must be 0.
2554 * Access: Index
2555 */
2556MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
2557
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002558/* Ethernet IEEE 802.3 Counter Group */
2559
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002560/* reg_ppcnt_a_frames_transmitted_ok
2561 * Access: RO
2562 */
2563MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
2564 0x08 + 0x00, 0, 64);
2565
2566/* reg_ppcnt_a_frames_received_ok
2567 * Access: RO
2568 */
2569MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
2570 0x08 + 0x08, 0, 64);
2571
2572/* reg_ppcnt_a_frame_check_sequence_errors
2573 * Access: RO
2574 */
2575MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
2576 0x08 + 0x10, 0, 64);
2577
2578/* reg_ppcnt_a_alignment_errors
2579 * Access: RO
2580 */
2581MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
2582 0x08 + 0x18, 0, 64);
2583
2584/* reg_ppcnt_a_octets_transmitted_ok
2585 * Access: RO
2586 */
2587MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
2588 0x08 + 0x20, 0, 64);
2589
2590/* reg_ppcnt_a_octets_received_ok
2591 * Access: RO
2592 */
2593MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
2594 0x08 + 0x28, 0, 64);
2595
2596/* reg_ppcnt_a_multicast_frames_xmitted_ok
2597 * Access: RO
2598 */
2599MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
2600 0x08 + 0x30, 0, 64);
2601
2602/* reg_ppcnt_a_broadcast_frames_xmitted_ok
2603 * Access: RO
2604 */
2605MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
2606 0x08 + 0x38, 0, 64);
2607
2608/* reg_ppcnt_a_multicast_frames_received_ok
2609 * Access: RO
2610 */
2611MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
2612 0x08 + 0x40, 0, 64);
2613
2614/* reg_ppcnt_a_broadcast_frames_received_ok
2615 * Access: RO
2616 */
2617MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
2618 0x08 + 0x48, 0, 64);
2619
2620/* reg_ppcnt_a_in_range_length_errors
2621 * Access: RO
2622 */
2623MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
2624 0x08 + 0x50, 0, 64);
2625
2626/* reg_ppcnt_a_out_of_range_length_field
2627 * Access: RO
2628 */
2629MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
2630 0x08 + 0x58, 0, 64);
2631
2632/* reg_ppcnt_a_frame_too_long_errors
2633 * Access: RO
2634 */
2635MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
2636 0x08 + 0x60, 0, 64);
2637
2638/* reg_ppcnt_a_symbol_error_during_carrier
2639 * Access: RO
2640 */
2641MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
2642 0x08 + 0x68, 0, 64);
2643
2644/* reg_ppcnt_a_mac_control_frames_transmitted
2645 * Access: RO
2646 */
2647MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
2648 0x08 + 0x70, 0, 64);
2649
2650/* reg_ppcnt_a_mac_control_frames_received
2651 * Access: RO
2652 */
2653MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
2654 0x08 + 0x78, 0, 64);
2655
2656/* reg_ppcnt_a_unsupported_opcodes_received
2657 * Access: RO
2658 */
2659MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
2660 0x08 + 0x80, 0, 64);
2661
2662/* reg_ppcnt_a_pause_mac_ctrl_frames_received
2663 * Access: RO
2664 */
2665MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
2666 0x08 + 0x88, 0, 64);
2667
2668/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
2669 * Access: RO
2670 */
2671MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
2672 0x08 + 0x90, 0, 64);
2673
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002674/* Ethernet Per Priority Group Counters */
2675
2676/* reg_ppcnt_rx_octets
2677 * Access: RO
2678 */
2679MLXSW_ITEM64(reg, ppcnt, rx_octets, 0x08 + 0x00, 0, 64);
2680
2681/* reg_ppcnt_rx_frames
2682 * Access: RO
2683 */
2684MLXSW_ITEM64(reg, ppcnt, rx_frames, 0x08 + 0x20, 0, 64);
2685
2686/* reg_ppcnt_tx_octets
2687 * Access: RO
2688 */
2689MLXSW_ITEM64(reg, ppcnt, tx_octets, 0x08 + 0x28, 0, 64);
2690
2691/* reg_ppcnt_tx_frames
2692 * Access: RO
2693 */
2694MLXSW_ITEM64(reg, ppcnt, tx_frames, 0x08 + 0x48, 0, 64);
2695
2696/* reg_ppcnt_rx_pause
2697 * Access: RO
2698 */
2699MLXSW_ITEM64(reg, ppcnt, rx_pause, 0x08 + 0x50, 0, 64);
2700
2701/* reg_ppcnt_rx_pause_duration
2702 * Access: RO
2703 */
2704MLXSW_ITEM64(reg, ppcnt, rx_pause_duration, 0x08 + 0x58, 0, 64);
2705
2706/* reg_ppcnt_tx_pause
2707 * Access: RO
2708 */
2709MLXSW_ITEM64(reg, ppcnt, tx_pause, 0x08 + 0x60, 0, 64);
2710
2711/* reg_ppcnt_tx_pause_duration
2712 * Access: RO
2713 */
2714MLXSW_ITEM64(reg, ppcnt, tx_pause_duration, 0x08 + 0x68, 0, 64);
2715
2716/* reg_ppcnt_rx_pause_transition
2717 * Access: RO
2718 */
2719MLXSW_ITEM64(reg, ppcnt, tx_pause_transition, 0x08 + 0x70, 0, 64);
2720
Ido Schimmeldf4750e2016-07-19 15:35:54 +02002721/* Ethernet Per Traffic Group Counters */
2722
2723/* reg_ppcnt_tc_transmit_queue
2724 * Contains the transmit queue depth in cells of traffic class
2725 * selected by prio_tc and the port selected by local_port.
2726 * The field cannot be cleared.
2727 * Access: RO
2728 */
2729MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue, 0x08 + 0x00, 0, 64);
2730
2731/* reg_ppcnt_tc_no_buffer_discard_uc
2732 * The number of unicast packets dropped due to lack of shared
2733 * buffer resources.
2734 * Access: RO
2735 */
2736MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc, 0x08 + 0x08, 0, 64);
2737
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002738static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
2739 enum mlxsw_reg_ppcnt_grp grp,
2740 u8 prio_tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002741{
2742 MLXSW_REG_ZERO(ppcnt, payload);
2743 mlxsw_reg_ppcnt_swid_set(payload, 0);
2744 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
2745 mlxsw_reg_ppcnt_pnat_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002746 mlxsw_reg_ppcnt_grp_set(payload, grp);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002747 mlxsw_reg_ppcnt_clr_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002748 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002749}
2750
Elad Raz71367932016-10-28 21:35:54 +02002751/* PLIB - Port Local to InfiniBand Port
2752 * ------------------------------------
2753 * The PLIB register performs mapping from Local Port into InfiniBand Port.
2754 */
2755#define MLXSW_REG_PLIB_ID 0x500A
2756#define MLXSW_REG_PLIB_LEN 0x10
2757
2758MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
2759
2760/* reg_plib_local_port
2761 * Local port number.
2762 * Access: Index
2763 */
2764MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
2765
2766/* reg_plib_ib_port
2767 * InfiniBand port remapping for local_port.
2768 * Access: RW
2769 */
2770MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
2771
Ido Schimmelb98ff152016-04-06 17:10:00 +02002772/* PPTB - Port Prio To Buffer Register
2773 * -----------------------------------
2774 * Configures the switch priority to buffer table.
2775 */
2776#define MLXSW_REG_PPTB_ID 0x500B
Ido Schimmel11719a52016-07-15 11:15:02 +02002777#define MLXSW_REG_PPTB_LEN 0x10
Ido Schimmelb98ff152016-04-06 17:10:00 +02002778
Jiri Pirko21978dc2016-10-21 16:07:20 +02002779MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
Ido Schimmelb98ff152016-04-06 17:10:00 +02002780
2781enum {
2782 MLXSW_REG_PPTB_MM_UM,
2783 MLXSW_REG_PPTB_MM_UNICAST,
2784 MLXSW_REG_PPTB_MM_MULTICAST,
2785};
2786
2787/* reg_pptb_mm
2788 * Mapping mode.
2789 * 0 - Map both unicast and multicast packets to the same buffer.
2790 * 1 - Map only unicast packets.
2791 * 2 - Map only multicast packets.
2792 * Access: Index
2793 *
2794 * Note: SwitchX-2 only supports the first option.
2795 */
2796MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
2797
2798/* reg_pptb_local_port
2799 * Local port number.
2800 * Access: Index
2801 */
2802MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
2803
2804/* reg_pptb_um
2805 * Enables the update of the untagged_buf field.
2806 * Access: RW
2807 */
2808MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
2809
2810/* reg_pptb_pm
2811 * Enables the update of the prio_to_buff field.
2812 * Bit <i> is a flag for updating the mapping for switch priority <i>.
2813 * Access: RW
2814 */
2815MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
2816
2817/* reg_pptb_prio_to_buff
2818 * Mapping of switch priority <i> to one of the allocated receive port
2819 * buffers.
2820 * Access: RW
2821 */
2822MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
2823
2824/* reg_pptb_pm_msb
2825 * Enables the update of the prio_to_buff field.
2826 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
2827 * Access: RW
2828 */
2829MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
2830
2831/* reg_pptb_untagged_buff
2832 * Mapping of untagged frames to one of the allocated receive port buffers.
2833 * Access: RW
2834 *
2835 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
2836 * Spectrum, as it maps untagged packets based on the default switch priority.
2837 */
2838MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
2839
Ido Schimmel11719a52016-07-15 11:15:02 +02002840/* reg_pptb_prio_to_buff_msb
2841 * Mapping of switch priority <i+8> to one of the allocated receive port
2842 * buffers.
2843 * Access: RW
2844 */
2845MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
2846
Ido Schimmelb98ff152016-04-06 17:10:00 +02002847#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
2848
2849static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
2850{
2851 MLXSW_REG_ZERO(pptb, payload);
2852 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
2853 mlxsw_reg_pptb_local_port_set(payload, local_port);
2854 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
Ido Schimmel11719a52016-07-15 11:15:02 +02002855 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
2856}
2857
2858static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
2859 u8 buff)
2860{
2861 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
2862 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
Ido Schimmelb98ff152016-04-06 17:10:00 +02002863}
2864
Jiri Pirkoe0594362015-10-16 14:01:31 +02002865/* PBMC - Port Buffer Management Control Register
2866 * ----------------------------------------------
2867 * The PBMC register configures and retrieves the port packet buffer
2868 * allocation for different Prios, and the Pause threshold management.
2869 */
2870#define MLXSW_REG_PBMC_ID 0x500C
Ido Schimmel7ad7cd62016-04-06 17:10:04 +02002871#define MLXSW_REG_PBMC_LEN 0x6C
Jiri Pirkoe0594362015-10-16 14:01:31 +02002872
Jiri Pirko21978dc2016-10-21 16:07:20 +02002873MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02002874
2875/* reg_pbmc_local_port
2876 * Local port number.
2877 * Access: Index
2878 */
2879MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
2880
2881/* reg_pbmc_xoff_timer_value
2882 * When device generates a pause frame, it uses this value as the pause
2883 * timer (time for the peer port to pause in quota-512 bit time).
2884 * Access: RW
2885 */
2886MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
2887
2888/* reg_pbmc_xoff_refresh
2889 * The time before a new pause frame should be sent to refresh the pause RW
2890 * state. Using the same units as xoff_timer_value above (in quota-512 bit
2891 * time).
2892 * Access: RW
2893 */
2894MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
2895
Ido Schimmeld6b7c132016-04-06 17:10:05 +02002896#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
2897
Jiri Pirkoe0594362015-10-16 14:01:31 +02002898/* reg_pbmc_buf_lossy
2899 * The field indicates if the buffer is lossy.
2900 * 0 - Lossless
2901 * 1 - Lossy
2902 * Access: RW
2903 */
2904MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
2905
2906/* reg_pbmc_buf_epsb
2907 * Eligible for Port Shared buffer.
2908 * If epsb is set, packets assigned to buffer are allowed to insert the port
2909 * shared buffer.
2910 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
2911 * Access: RW
2912 */
2913MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
2914
2915/* reg_pbmc_buf_size
2916 * The part of the packet buffer array is allocated for the specific buffer.
2917 * Units are represented in cells.
2918 * Access: RW
2919 */
2920MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
2921
Ido Schimmel155f9de2016-04-06 17:10:13 +02002922/* reg_pbmc_buf_xoff_threshold
2923 * Once the amount of data in the buffer goes above this value, device
2924 * starts sending PFC frames for all priorities associated with the
2925 * buffer. Units are represented in cells. Reserved in case of lossy
2926 * buffer.
2927 * Access: RW
2928 *
2929 * Note: In Spectrum, reserved for buffer[9].
2930 */
2931MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
2932 0x08, 0x04, false);
2933
2934/* reg_pbmc_buf_xon_threshold
2935 * When the amount of data in the buffer goes below this value, device
2936 * stops sending PFC frames for the priorities associated with the
2937 * buffer. Units are represented in cells. Reserved in case of lossy
2938 * buffer.
2939 * Access: RW
2940 *
2941 * Note: In Spectrum, reserved for buffer[9].
2942 */
2943MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
2944 0x08, 0x04, false);
2945
Jiri Pirkoe0594362015-10-16 14:01:31 +02002946static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
2947 u16 xoff_timer_value, u16 xoff_refresh)
2948{
2949 MLXSW_REG_ZERO(pbmc, payload);
2950 mlxsw_reg_pbmc_local_port_set(payload, local_port);
2951 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
2952 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
2953}
2954
2955static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
2956 int buf_index,
2957 u16 size)
2958{
2959 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
2960 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
2961 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
2962}
2963
Ido Schimmel155f9de2016-04-06 17:10:13 +02002964static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
2965 int buf_index, u16 size,
2966 u16 threshold)
2967{
2968 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
2969 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
2970 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
2971 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
2972 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
2973}
2974
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002975/* PSPA - Port Switch Partition Allocation
2976 * ---------------------------------------
2977 * Controls the association of a port with a switch partition and enables
2978 * configuring ports as stacking ports.
2979 */
Jiri Pirko3f0effd2015-10-15 17:43:23 +02002980#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002981#define MLXSW_REG_PSPA_LEN 0x8
2982
Jiri Pirko21978dc2016-10-21 16:07:20 +02002983MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002984
2985/* reg_pspa_swid
2986 * Switch partition ID.
2987 * Access: RW
2988 */
2989MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
2990
2991/* reg_pspa_local_port
2992 * Local port number.
2993 * Access: Index
2994 */
2995MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
2996
2997/* reg_pspa_sub_port
2998 * Virtual port within the local port. Set to 0 when virtual ports are
2999 * disabled on the local port.
3000 * Access: Index
3001 */
3002MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
3003
3004static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
3005{
3006 MLXSW_REG_ZERO(pspa, payload);
3007 mlxsw_reg_pspa_swid_set(payload, swid);
3008 mlxsw_reg_pspa_local_port_set(payload, local_port);
3009 mlxsw_reg_pspa_sub_port_set(payload, 0);
3010}
3011
3012/* HTGT - Host Trap Group Table
3013 * ----------------------------
3014 * Configures the properties for forwarding to CPU.
3015 */
3016#define MLXSW_REG_HTGT_ID 0x7002
3017#define MLXSW_REG_HTGT_LEN 0x100
3018
Jiri Pirko21978dc2016-10-21 16:07:20 +02003019MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003020
3021/* reg_htgt_swid
3022 * Switch partition ID.
3023 * Access: Index
3024 */
3025MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
3026
3027#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
3028
3029/* reg_htgt_type
3030 * CPU path type.
3031 * Access: RW
3032 */
3033MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
3034
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003035enum mlxsw_reg_htgt_trap_group {
3036 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
3037 MLXSW_REG_HTGT_TRAP_GROUP_RX,
3038 MLXSW_REG_HTGT_TRAP_GROUP_CTRL,
3039};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003040
3041/* reg_htgt_trap_group
3042 * Trap group number. User defined number specifying which trap groups
3043 * should be forwarded to the CPU. The mapping between trap IDs and trap
3044 * groups is configured using HPKT register.
3045 * Access: Index
3046 */
3047MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
3048
3049enum {
3050 MLXSW_REG_HTGT_POLICER_DISABLE,
3051 MLXSW_REG_HTGT_POLICER_ENABLE,
3052};
3053
3054/* reg_htgt_pide
3055 * Enable policer ID specified using 'pid' field.
3056 * Access: RW
3057 */
3058MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
3059
3060/* reg_htgt_pid
3061 * Policer ID for the trap group.
3062 * Access: RW
3063 */
3064MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
3065
3066#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
3067
3068/* reg_htgt_mirror_action
3069 * Mirror action to use.
3070 * 0 - Trap to CPU.
3071 * 1 - Trap to CPU and mirror to a mirroring agent.
3072 * 2 - Mirror to a mirroring agent and do not trap to CPU.
3073 * Access: RW
3074 *
3075 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
3076 */
3077MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
3078
3079/* reg_htgt_mirroring_agent
3080 * Mirroring agent.
3081 * Access: RW
3082 */
3083MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
3084
3085/* reg_htgt_priority
3086 * Trap group priority.
3087 * In case a packet matches multiple classification rules, the packet will
3088 * only be trapped once, based on the trap ID associated with the group (via
3089 * register HPKT) with the highest priority.
3090 * Supported values are 0-7, with 7 represnting the highest priority.
3091 * Access: RW
3092 *
3093 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
3094 * by the 'trap_group' field.
3095 */
3096MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
3097
3098/* reg_htgt_local_path_cpu_tclass
3099 * CPU ingress traffic class for the trap group.
3100 * Access: RW
3101 */
3102MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
3103
3104#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD 0x15
3105#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX 0x14
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003106#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL 0x13
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003107
3108/* reg_htgt_local_path_rdq
3109 * Receive descriptor queue (RDQ) to use for the trap group.
3110 * Access: RW
3111 */
3112MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
3113
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003114static inline void mlxsw_reg_htgt_pack(char *payload,
3115 enum mlxsw_reg_htgt_trap_group group)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003116{
3117 u8 swid, rdq;
3118
3119 MLXSW_REG_ZERO(htgt, payload);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003120 switch (group) {
3121 case MLXSW_REG_HTGT_TRAP_GROUP_EMAD:
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003122 swid = MLXSW_PORT_SWID_ALL_SWIDS;
3123 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD;
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003124 break;
3125 case MLXSW_REG_HTGT_TRAP_GROUP_RX:
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003126 swid = 0;
3127 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX;
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003128 break;
3129 case MLXSW_REG_HTGT_TRAP_GROUP_CTRL:
3130 swid = 0;
3131 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL;
3132 break;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003133 }
3134 mlxsw_reg_htgt_swid_set(payload, swid);
3135 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003136 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003137 mlxsw_reg_htgt_pide_set(payload, MLXSW_REG_HTGT_POLICER_DISABLE);
3138 mlxsw_reg_htgt_pid_set(payload, 0);
3139 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
3140 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
3141 mlxsw_reg_htgt_priority_set(payload, 0);
3142 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, 7);
3143 mlxsw_reg_htgt_local_path_rdq_set(payload, rdq);
3144}
3145
3146/* HPKT - Host Packet Trap
3147 * -----------------------
3148 * Configures trap IDs inside trap groups.
3149 */
3150#define MLXSW_REG_HPKT_ID 0x7003
3151#define MLXSW_REG_HPKT_LEN 0x10
3152
Jiri Pirko21978dc2016-10-21 16:07:20 +02003153MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003154
3155enum {
3156 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
3157 MLXSW_REG_HPKT_ACK_REQUIRED,
3158};
3159
3160/* reg_hpkt_ack
3161 * Require acknowledgements from the host for events.
3162 * If set, then the device will wait for the event it sent to be acknowledged
3163 * by the host. This option is only relevant for event trap IDs.
3164 * Access: RW
3165 *
3166 * Note: Currently not supported by firmware.
3167 */
3168MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
3169
3170enum mlxsw_reg_hpkt_action {
3171 MLXSW_REG_HPKT_ACTION_FORWARD,
3172 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
3173 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
3174 MLXSW_REG_HPKT_ACTION_DISCARD,
3175 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
3176 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
3177};
3178
3179/* reg_hpkt_action
3180 * Action to perform on packet when trapped.
3181 * 0 - No action. Forward to CPU based on switching rules.
3182 * 1 - Trap to CPU (CPU receives sole copy).
3183 * 2 - Mirror to CPU (CPU receives a replica of the packet).
3184 * 3 - Discard.
3185 * 4 - Soft discard (allow other traps to act on the packet).
3186 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
3187 * Access: RW
3188 *
3189 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
3190 * addressed to the CPU.
3191 */
3192MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
3193
3194/* reg_hpkt_trap_group
3195 * Trap group to associate the trap with.
3196 * Access: RW
3197 */
3198MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
3199
3200/* reg_hpkt_trap_id
3201 * Trap ID.
3202 * Access: Index
3203 *
3204 * Note: A trap ID can only be associated with a single trap group. The device
3205 * will associate the trap ID with the last trap group configured.
3206 */
3207MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
3208
3209enum {
3210 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
3211 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
3212 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
3213};
3214
3215/* reg_hpkt_ctrl
3216 * Configure dedicated buffer resources for control packets.
3217 * 0 - Keep factory defaults.
3218 * 1 - Do not use control buffer for this trap ID.
3219 * 2 - Use control buffer for this trap ID.
3220 * Access: RW
3221 */
3222MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
3223
Ido Schimmelf24af332015-10-15 17:43:27 +02003224static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003225{
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003226 enum mlxsw_reg_htgt_trap_group trap_group;
Ido Schimmelf24af332015-10-15 17:43:27 +02003227
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003228 MLXSW_REG_ZERO(hpkt, payload);
3229 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
3230 mlxsw_reg_hpkt_action_set(payload, action);
Ido Schimmelf24af332015-10-15 17:43:27 +02003231 switch (trap_id) {
3232 case MLXSW_TRAP_ID_ETHEMAD:
3233 case MLXSW_TRAP_ID_PUDE:
3234 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_EMAD;
3235 break;
3236 default:
3237 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_RX;
3238 break;
3239 }
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003240 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
3241 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
3242 mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT);
3243}
3244
Ido Schimmel69c407a2016-07-02 11:00:13 +02003245/* RGCR - Router General Configuration Register
3246 * --------------------------------------------
3247 * The register is used for setting up the router configuration.
3248 */
3249#define MLXSW_REG_RGCR_ID 0x8001
3250#define MLXSW_REG_RGCR_LEN 0x28
3251
Jiri Pirko21978dc2016-10-21 16:07:20 +02003252MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
Ido Schimmel69c407a2016-07-02 11:00:13 +02003253
3254/* reg_rgcr_ipv4_en
3255 * IPv4 router enable.
3256 * Access: RW
3257 */
3258MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
3259
3260/* reg_rgcr_ipv6_en
3261 * IPv6 router enable.
3262 * Access: RW
3263 */
3264MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
3265
3266/* reg_rgcr_max_router_interfaces
3267 * Defines the maximum number of active router interfaces for all virtual
3268 * routers.
3269 * Access: RW
3270 */
3271MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
3272
3273/* reg_rgcr_usp
3274 * Update switch priority and packet color.
3275 * 0 - Preserve the value of Switch Priority and packet color.
3276 * 1 - Recalculate the value of Switch Priority and packet color.
3277 * Access: RW
3278 *
3279 * Note: Not supported by SwitchX and SwitchX-2.
3280 */
3281MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
3282
3283/* reg_rgcr_pcp_rw
3284 * Indicates how to handle the pcp_rewrite_en value:
3285 * 0 - Preserve the value of pcp_rewrite_en.
3286 * 2 - Disable PCP rewrite.
3287 * 3 - Enable PCP rewrite.
3288 * Access: RW
3289 *
3290 * Note: Not supported by SwitchX and SwitchX-2.
3291 */
3292MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
3293
3294/* reg_rgcr_activity_dis
3295 * Activity disable:
3296 * 0 - Activity will be set when an entry is hit (default).
3297 * 1 - Activity will not be set when an entry is hit.
3298 *
3299 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
3300 * (RALUE).
3301 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
3302 * Entry (RAUHT).
3303 * Bits 2:7 are reserved.
3304 * Access: RW
3305 *
3306 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
3307 */
3308MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
3309
3310static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en)
3311{
3312 MLXSW_REG_ZERO(rgcr, payload);
3313 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
3314}
3315
Ido Schimmel3dc26682016-07-02 11:00:18 +02003316/* RITR - Router Interface Table Register
3317 * --------------------------------------
3318 * The register is used to configure the router interface table.
3319 */
3320#define MLXSW_REG_RITR_ID 0x8002
3321#define MLXSW_REG_RITR_LEN 0x40
3322
Jiri Pirko21978dc2016-10-21 16:07:20 +02003323MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
Ido Schimmel3dc26682016-07-02 11:00:18 +02003324
3325/* reg_ritr_enable
3326 * Enables routing on the router interface.
3327 * Access: RW
3328 */
3329MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
3330
3331/* reg_ritr_ipv4
3332 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
3333 * interface.
3334 * Access: RW
3335 */
3336MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
3337
3338/* reg_ritr_ipv6
3339 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
3340 * interface.
3341 * Access: RW
3342 */
3343MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
3344
3345enum mlxsw_reg_ritr_if_type {
3346 MLXSW_REG_RITR_VLAN_IF,
3347 MLXSW_REG_RITR_FID_IF,
3348 MLXSW_REG_RITR_SP_IF,
3349};
3350
3351/* reg_ritr_type
3352 * Router interface type.
3353 * 0 - VLAN interface.
3354 * 1 - FID interface.
3355 * 2 - Sub-port interface.
3356 * Access: RW
3357 */
3358MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
3359
3360enum {
3361 MLXSW_REG_RITR_RIF_CREATE,
3362 MLXSW_REG_RITR_RIF_DEL,
3363};
3364
3365/* reg_ritr_op
3366 * Opcode:
3367 * 0 - Create or edit RIF.
3368 * 1 - Delete RIF.
3369 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
3370 * is not supported. An interface must be deleted and re-created in order
3371 * to update properties.
3372 * Access: WO
3373 */
3374MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
3375
3376/* reg_ritr_rif
3377 * Router interface index. A pointer to the Router Interface Table.
3378 * Access: Index
3379 */
3380MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
3381
3382/* reg_ritr_ipv4_fe
3383 * IPv4 Forwarding Enable.
3384 * Enables routing of IPv4 traffic on the router interface. When disabled,
3385 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
3386 * Not supported in SwitchX-2.
3387 * Access: RW
3388 */
3389MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
3390
3391/* reg_ritr_ipv6_fe
3392 * IPv6 Forwarding Enable.
3393 * Enables routing of IPv6 traffic on the router interface. When disabled,
3394 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
3395 * Not supported in SwitchX-2.
3396 * Access: RW
3397 */
3398MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
3399
Ido Schimmela94a6142016-08-17 16:39:33 +02003400/* reg_ritr_lb_en
3401 * Loop-back filter enable for unicast packets.
3402 * If the flag is set then loop-back filter for unicast packets is
3403 * implemented on the RIF. Multicast packets are always subject to
3404 * loop-back filtering.
3405 * Access: RW
3406 */
3407MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
3408
Ido Schimmel3dc26682016-07-02 11:00:18 +02003409/* reg_ritr_virtual_router
3410 * Virtual router ID associated with the router interface.
3411 * Access: RW
3412 */
3413MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
3414
3415/* reg_ritr_mtu
3416 * Router interface MTU.
3417 * Access: RW
3418 */
3419MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
3420
3421/* reg_ritr_if_swid
3422 * Switch partition ID.
3423 * Access: RW
3424 */
3425MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
3426
3427/* reg_ritr_if_mac
3428 * Router interface MAC address.
3429 * In Spectrum, all MAC addresses must have the same 38 MSBits.
3430 * Access: RW
3431 */
3432MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
3433
3434/* VLAN Interface */
3435
3436/* reg_ritr_vlan_if_vid
3437 * VLAN ID.
3438 * Access: RW
3439 */
3440MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
3441
3442/* FID Interface */
3443
3444/* reg_ritr_fid_if_fid
3445 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
3446 * the vFID range are supported.
3447 * Access: RW
3448 */
3449MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
3450
3451static inline void mlxsw_reg_ritr_fid_set(char *payload,
3452 enum mlxsw_reg_ritr_if_type rif_type,
3453 u16 fid)
3454{
3455 if (rif_type == MLXSW_REG_RITR_FID_IF)
3456 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
3457 else
3458 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
3459}
3460
3461/* Sub-port Interface */
3462
3463/* reg_ritr_sp_if_lag
3464 * LAG indication. When this bit is set the system_port field holds the
3465 * LAG identifier.
3466 * Access: RW
3467 */
3468MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
3469
3470/* reg_ritr_sp_system_port
3471 * Port unique indentifier. When lag bit is set, this field holds the
3472 * lag_id in bits 0:9.
3473 * Access: RW
3474 */
3475MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
3476
3477/* reg_ritr_sp_if_vid
3478 * VLAN ID.
3479 * Access: RW
3480 */
3481MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
3482
3483static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
3484{
3485 MLXSW_REG_ZERO(ritr, payload);
3486 mlxsw_reg_ritr_rif_set(payload, rif);
3487}
3488
3489static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
3490 u16 system_port, u16 vid)
3491{
3492 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
3493 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
3494 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
3495}
3496
3497static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
3498 enum mlxsw_reg_ritr_if_type type,
3499 u16 rif, u16 mtu, const char *mac)
3500{
3501 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
3502
3503 MLXSW_REG_ZERO(ritr, payload);
3504 mlxsw_reg_ritr_enable_set(payload, enable);
3505 mlxsw_reg_ritr_ipv4_set(payload, 1);
3506 mlxsw_reg_ritr_type_set(payload, type);
3507 mlxsw_reg_ritr_op_set(payload, op);
3508 mlxsw_reg_ritr_rif_set(payload, rif);
3509 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
Ido Schimmela94a6142016-08-17 16:39:33 +02003510 mlxsw_reg_ritr_lb_en_set(payload, 1);
Ido Schimmel3dc26682016-07-02 11:00:18 +02003511 mlxsw_reg_ritr_mtu_set(payload, mtu);
3512 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
3513}
3514
Yotam Gigi089f9812016-07-05 11:27:48 +02003515/* RATR - Router Adjacency Table Register
3516 * --------------------------------------
3517 * The RATR register is used to configure the Router Adjacency (next-hop)
3518 * Table.
3519 */
3520#define MLXSW_REG_RATR_ID 0x8008
3521#define MLXSW_REG_RATR_LEN 0x2C
3522
Jiri Pirko21978dc2016-10-21 16:07:20 +02003523MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
Yotam Gigi089f9812016-07-05 11:27:48 +02003524
3525enum mlxsw_reg_ratr_op {
3526 /* Read */
3527 MLXSW_REG_RATR_OP_QUERY_READ = 0,
3528 /* Read and clear activity */
3529 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
3530 /* Write Adjacency entry */
3531 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
3532 /* Write Adjacency entry only if the activity is cleared.
3533 * The write may not succeed if the activity is set. There is not
3534 * direct feedback if the write has succeeded or not, however
3535 * the get will reveal the actual entry (SW can compare the get
3536 * response to the set command).
3537 */
3538 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
3539};
3540
3541/* reg_ratr_op
3542 * Note that Write operation may also be used for updating
3543 * counter_set_type and counter_index. In this case all other
3544 * fields must not be updated.
3545 * Access: OP
3546 */
3547MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
3548
3549/* reg_ratr_v
3550 * Valid bit. Indicates if the adjacency entry is valid.
3551 * Note: the device may need some time before reusing an invalidated
3552 * entry. During this time the entry can not be reused. It is
3553 * recommended to use another entry before reusing an invalidated
3554 * entry (e.g. software can put it at the end of the list for
3555 * reusing). Trying to access an invalidated entry not yet cleared
3556 * by the device results with failure indicating "Try Again" status.
3557 * When valid is '0' then egress_router_interface,trap_action,
3558 * adjacency_parameters and counters are reserved
3559 * Access: RW
3560 */
3561MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
3562
3563/* reg_ratr_a
3564 * Activity. Set for new entries. Set if a packet lookup has hit on
3565 * the specific entry. To clear the a bit, use "clear activity".
3566 * Access: RO
3567 */
3568MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
3569
3570/* reg_ratr_adjacency_index_low
3571 * Bits 15:0 of index into the adjacency table.
3572 * For SwitchX and SwitchX-2, the adjacency table is linear and
3573 * used for adjacency entries only.
3574 * For Spectrum, the index is to the KVD linear.
3575 * Access: Index
3576 */
3577MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
3578
3579/* reg_ratr_egress_router_interface
3580 * Range is 0 .. cap_max_router_interfaces - 1
3581 * Access: RW
3582 */
3583MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
3584
3585enum mlxsw_reg_ratr_trap_action {
3586 MLXSW_REG_RATR_TRAP_ACTION_NOP,
3587 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
3588 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
3589 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
3590 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
3591};
3592
3593/* reg_ratr_trap_action
3594 * see mlxsw_reg_ratr_trap_action
3595 * Access: RW
3596 */
3597MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
3598
3599enum mlxsw_reg_ratr_trap_id {
3600 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0 = 0,
3601 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1 = 1,
3602};
3603
3604/* reg_ratr_adjacency_index_high
3605 * Bits 23:16 of the adjacency_index.
3606 * Access: Index
3607 */
3608MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
3609
3610/* reg_ratr_trap_id
3611 * Trap ID to be reported to CPU.
3612 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
3613 * For trap_action of NOP, MIRROR and DISCARD_ERROR
3614 * Access: RW
3615 */
3616MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
3617
3618/* reg_ratr_eth_destination_mac
3619 * MAC address of the destination next-hop.
3620 * Access: RW
3621 */
3622MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
3623
3624static inline void
3625mlxsw_reg_ratr_pack(char *payload,
3626 enum mlxsw_reg_ratr_op op, bool valid,
3627 u32 adjacency_index, u16 egress_rif)
3628{
3629 MLXSW_REG_ZERO(ratr, payload);
3630 mlxsw_reg_ratr_op_set(payload, op);
3631 mlxsw_reg_ratr_v_set(payload, valid);
3632 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
3633 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
3634 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
3635}
3636
3637static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
3638 const char *dest_mac)
3639{
3640 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
3641}
3642
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02003643/* RALTA - Router Algorithmic LPM Tree Allocation Register
3644 * -------------------------------------------------------
3645 * RALTA is used to allocate the LPM trees of the SHSPM method.
3646 */
3647#define MLXSW_REG_RALTA_ID 0x8010
3648#define MLXSW_REG_RALTA_LEN 0x04
3649
Jiri Pirko21978dc2016-10-21 16:07:20 +02003650MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02003651
3652/* reg_ralta_op
3653 * opcode (valid for Write, must be 0 on Read)
3654 * 0 - allocate a tree
3655 * 1 - deallocate a tree
3656 * Access: OP
3657 */
3658MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
3659
3660enum mlxsw_reg_ralxx_protocol {
3661 MLXSW_REG_RALXX_PROTOCOL_IPV4,
3662 MLXSW_REG_RALXX_PROTOCOL_IPV6,
3663};
3664
3665/* reg_ralta_protocol
3666 * Protocol.
3667 * Deallocation opcode: Reserved.
3668 * Access: RW
3669 */
3670MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
3671
3672/* reg_ralta_tree_id
3673 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
3674 * the tree identifier (managed by software).
3675 * Note that tree_id 0 is allocated for a default-route tree.
3676 * Access: Index
3677 */
3678MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
3679
3680static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
3681 enum mlxsw_reg_ralxx_protocol protocol,
3682 u8 tree_id)
3683{
3684 MLXSW_REG_ZERO(ralta, payload);
3685 mlxsw_reg_ralta_op_set(payload, !alloc);
3686 mlxsw_reg_ralta_protocol_set(payload, protocol);
3687 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
3688}
3689
Jiri Pirkoa9823352016-07-04 08:23:06 +02003690/* RALST - Router Algorithmic LPM Structure Tree Register
3691 * ------------------------------------------------------
3692 * RALST is used to set and query the structure of an LPM tree.
3693 * The structure of the tree must be sorted as a sorted binary tree, while
3694 * each node is a bin that is tagged as the length of the prefixes the lookup
3695 * will refer to. Therefore, bin X refers to a set of entries with prefixes
3696 * of X bits to match with the destination address. The bin 0 indicates
3697 * the default action, when there is no match of any prefix.
3698 */
3699#define MLXSW_REG_RALST_ID 0x8011
3700#define MLXSW_REG_RALST_LEN 0x104
3701
Jiri Pirko21978dc2016-10-21 16:07:20 +02003702MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
Jiri Pirkoa9823352016-07-04 08:23:06 +02003703
3704/* reg_ralst_root_bin
3705 * The bin number of the root bin.
3706 * 0<root_bin=<(length of IP address)
3707 * For a default-route tree configure 0xff
3708 * Access: RW
3709 */
3710MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
3711
3712/* reg_ralst_tree_id
3713 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
3714 * Access: Index
3715 */
3716MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
3717
3718#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
3719#define MLXSW_REG_RALST_BIN_OFFSET 0x04
3720#define MLXSW_REG_RALST_BIN_COUNT 128
3721
3722/* reg_ralst_left_child_bin
3723 * Holding the children of the bin according to the stored tree's structure.
3724 * For trees composed of less than 4 blocks, the bins in excess are reserved.
3725 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
3726 * Access: RW
3727 */
3728MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
3729
3730/* reg_ralst_right_child_bin
3731 * Holding the children of the bin according to the stored tree's structure.
3732 * For trees composed of less than 4 blocks, the bins in excess are reserved.
3733 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
3734 * Access: RW
3735 */
3736MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
3737 false);
3738
3739static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
3740{
3741 MLXSW_REG_ZERO(ralst, payload);
3742
3743 /* Initialize all bins to have no left or right child */
3744 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
3745 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
3746
3747 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
3748 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
3749}
3750
3751static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
3752 u8 left_child_bin,
3753 u8 right_child_bin)
3754{
3755 int bin_index = bin_number - 1;
3756
3757 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
3758 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
3759 right_child_bin);
3760}
3761
Jiri Pirko20ae4052016-07-04 08:23:07 +02003762/* RALTB - Router Algorithmic LPM Tree Binding Register
3763 * ----------------------------------------------------
3764 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
3765 */
3766#define MLXSW_REG_RALTB_ID 0x8012
3767#define MLXSW_REG_RALTB_LEN 0x04
3768
Jiri Pirko21978dc2016-10-21 16:07:20 +02003769MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
Jiri Pirko20ae4052016-07-04 08:23:07 +02003770
3771/* reg_raltb_virtual_router
3772 * Virtual Router ID
3773 * Range is 0..cap_max_virtual_routers-1
3774 * Access: Index
3775 */
3776MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
3777
3778/* reg_raltb_protocol
3779 * Protocol.
3780 * Access: Index
3781 */
3782MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
3783
3784/* reg_raltb_tree_id
3785 * Tree to be used for the {virtual_router, protocol}
3786 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
3787 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
3788 * Access: RW
3789 */
3790MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
3791
3792static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
3793 enum mlxsw_reg_ralxx_protocol protocol,
3794 u8 tree_id)
3795{
3796 MLXSW_REG_ZERO(raltb, payload);
3797 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
3798 mlxsw_reg_raltb_protocol_set(payload, protocol);
3799 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
3800}
3801
Jiri Pirkod5a1c742016-07-04 08:23:10 +02003802/* RALUE - Router Algorithmic LPM Unicast Entry Register
3803 * -----------------------------------------------------
3804 * RALUE is used to configure and query LPM entries that serve
3805 * the Unicast protocols.
3806 */
3807#define MLXSW_REG_RALUE_ID 0x8013
3808#define MLXSW_REG_RALUE_LEN 0x38
3809
Jiri Pirko21978dc2016-10-21 16:07:20 +02003810MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02003811
3812/* reg_ralue_protocol
3813 * Protocol.
3814 * Access: Index
3815 */
3816MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
3817
3818enum mlxsw_reg_ralue_op {
3819 /* Read operation. If entry doesn't exist, the operation fails. */
3820 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
3821 /* Clear on read operation. Used to read entry and
3822 * clear Activity bit.
3823 */
3824 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
3825 /* Write operation. Used to write a new entry to the table. All RW
3826 * fields are written for new entry. Activity bit is set
3827 * for new entries.
3828 */
3829 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
3830 /* Update operation. Used to update an existing route entry and
3831 * only update the RW fields that are detailed in the field
3832 * op_u_mask. If entry doesn't exist, the operation fails.
3833 */
3834 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
3835 /* Clear activity. The Activity bit (the field a) is cleared
3836 * for the entry.
3837 */
3838 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
3839 /* Delete operation. Used to delete an existing entry. If entry
3840 * doesn't exist, the operation fails.
3841 */
3842 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
3843};
3844
3845/* reg_ralue_op
3846 * Operation.
3847 * Access: OP
3848 */
3849MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
3850
3851/* reg_ralue_a
3852 * Activity. Set for new entries. Set if a packet lookup has hit on the
3853 * specific entry, only if the entry is a route. To clear the a bit, use
3854 * "clear activity" op.
3855 * Enabled by activity_dis in RGCR
3856 * Access: RO
3857 */
3858MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
3859
3860/* reg_ralue_virtual_router
3861 * Virtual Router ID
3862 * Range is 0..cap_max_virtual_routers-1
3863 * Access: Index
3864 */
3865MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
3866
3867#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
3868#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
3869#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
3870
3871/* reg_ralue_op_u_mask
3872 * opcode update mask.
3873 * On read operation, this field is reserved.
3874 * This field is valid for update opcode, otherwise - reserved.
3875 * This field is a bitmask of the fields that should be updated.
3876 * Access: WO
3877 */
3878MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
3879
3880/* reg_ralue_prefix_len
3881 * Number of bits in the prefix of the LPM route.
3882 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
3883 * two entries in the physical HW table.
3884 * Access: Index
3885 */
3886MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
3887
3888/* reg_ralue_dip*
3889 * The prefix of the route or of the marker that the object of the LPM
3890 * is compared with. The most significant bits of the dip are the prefix.
3891 * The list significant bits must be '0' if the prefix_len is smaller
3892 * than 128 for IPv6 or smaller than 32 for IPv4.
3893 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
3894 * Access: Index
3895 */
3896MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
3897
3898enum mlxsw_reg_ralue_entry_type {
3899 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
3900 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
3901 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
3902};
3903
3904/* reg_ralue_entry_type
3905 * Entry type.
3906 * Note - for Marker entries, the action_type and action fields are reserved.
3907 * Access: RW
3908 */
3909MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
3910
3911/* reg_ralue_bmp_len
3912 * The best match prefix length in the case that there is no match for
3913 * longer prefixes.
3914 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
3915 * Note for any update operation with entry_type modification this
3916 * field must be set.
3917 * Access: RW
3918 */
3919MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
3920
3921enum mlxsw_reg_ralue_action_type {
3922 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
3923 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
3924 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
3925};
3926
3927/* reg_ralue_action_type
3928 * Action Type
3929 * Indicates how the IP address is connected.
3930 * It can be connected to a local subnet through local_erif or can be
3931 * on a remote subnet connected through a next-hop router,
3932 * or transmitted to the CPU.
3933 * Reserved when entry_type = MARKER_ENTRY
3934 * Access: RW
3935 */
3936MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
3937
3938enum mlxsw_reg_ralue_trap_action {
3939 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
3940 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
3941 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
3942 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
3943 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
3944};
3945
3946/* reg_ralue_trap_action
3947 * Trap action.
3948 * For IP2ME action, only NOP and MIRROR are possible.
3949 * Access: RW
3950 */
3951MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
3952
3953/* reg_ralue_trap_id
3954 * Trap ID to be reported to CPU.
3955 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
3956 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
3957 * Access: RW
3958 */
3959MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
3960
3961/* reg_ralue_adjacency_index
3962 * Points to the first entry of the group-based ECMP.
3963 * Only relevant in case of REMOTE action.
3964 * Access: RW
3965 */
3966MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
3967
3968/* reg_ralue_ecmp_size
3969 * Amount of sequential entries starting
3970 * from the adjacency_index (the number of ECMPs).
3971 * The valid range is 1-64, 512, 1024, 2048 and 4096.
3972 * Reserved when trap_action is TRAP or DISCARD_ERROR.
3973 * Only relevant in case of REMOTE action.
3974 * Access: RW
3975 */
3976MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
3977
3978/* reg_ralue_local_erif
3979 * Egress Router Interface.
3980 * Only relevant in case of LOCAL action.
3981 * Access: RW
3982 */
3983MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
3984
3985/* reg_ralue_v
3986 * Valid bit for the tunnel_ptr field.
3987 * If valid = 0 then trap to CPU as IP2ME trap ID.
3988 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
3989 * decapsulation then tunnel decapsulation is done.
3990 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
3991 * decapsulation then trap as IP2ME trap ID.
3992 * Only relevant in case of IP2ME action.
3993 * Access: RW
3994 */
3995MLXSW_ITEM32(reg, ralue, v, 0x24, 31, 1);
3996
3997/* reg_ralue_tunnel_ptr
3998 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
3999 * For Spectrum, pointer to KVD Linear.
4000 * Only relevant in case of IP2ME action.
4001 * Access: RW
4002 */
4003MLXSW_ITEM32(reg, ralue, tunnel_ptr, 0x24, 0, 24);
4004
4005static inline void mlxsw_reg_ralue_pack(char *payload,
4006 enum mlxsw_reg_ralxx_protocol protocol,
4007 enum mlxsw_reg_ralue_op op,
4008 u16 virtual_router, u8 prefix_len)
4009{
4010 MLXSW_REG_ZERO(ralue, payload);
4011 mlxsw_reg_ralue_protocol_set(payload, protocol);
Jiri Pirko0e7df1a2016-08-17 16:39:34 +02004012 mlxsw_reg_ralue_op_set(payload, op);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02004013 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
4014 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
4015 mlxsw_reg_ralue_entry_type_set(payload,
4016 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
4017 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
4018}
4019
4020static inline void mlxsw_reg_ralue_pack4(char *payload,
4021 enum mlxsw_reg_ralxx_protocol protocol,
4022 enum mlxsw_reg_ralue_op op,
4023 u16 virtual_router, u8 prefix_len,
4024 u32 dip)
4025{
4026 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
4027 mlxsw_reg_ralue_dip4_set(payload, dip);
4028}
4029
4030static inline void
4031mlxsw_reg_ralue_act_remote_pack(char *payload,
4032 enum mlxsw_reg_ralue_trap_action trap_action,
4033 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
4034{
4035 mlxsw_reg_ralue_action_type_set(payload,
4036 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
4037 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
4038 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
4039 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
4040 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
4041}
4042
4043static inline void
4044mlxsw_reg_ralue_act_local_pack(char *payload,
4045 enum mlxsw_reg_ralue_trap_action trap_action,
4046 u16 trap_id, u16 local_erif)
4047{
4048 mlxsw_reg_ralue_action_type_set(payload,
4049 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
4050 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
4051 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
4052 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
4053}
4054
4055static inline void
4056mlxsw_reg_ralue_act_ip2me_pack(char *payload)
4057{
4058 mlxsw_reg_ralue_action_type_set(payload,
4059 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
4060}
4061
Yotam Gigi4457b3df2016-07-05 11:27:40 +02004062/* RAUHT - Router Algorithmic LPM Unicast Host Table Register
4063 * ----------------------------------------------------------
4064 * The RAUHT register is used to configure and query the Unicast Host table in
4065 * devices that implement the Algorithmic LPM.
4066 */
4067#define MLXSW_REG_RAUHT_ID 0x8014
4068#define MLXSW_REG_RAUHT_LEN 0x74
4069
Jiri Pirko21978dc2016-10-21 16:07:20 +02004070MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02004071
4072enum mlxsw_reg_rauht_type {
4073 MLXSW_REG_RAUHT_TYPE_IPV4,
4074 MLXSW_REG_RAUHT_TYPE_IPV6,
4075};
4076
4077/* reg_rauht_type
4078 * Access: Index
4079 */
4080MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
4081
4082enum mlxsw_reg_rauht_op {
4083 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
4084 /* Read operation */
4085 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
4086 /* Clear on read operation. Used to read entry and clear
4087 * activity bit.
4088 */
4089 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
4090 /* Add. Used to write a new entry to the table. All R/W fields are
4091 * relevant for new entry. Activity bit is set for new entries.
4092 */
4093 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
4094 /* Update action. Used to update an existing route entry and
4095 * only update the following fields:
4096 * trap_action, trap_id, mac, counter_set_type, counter_index
4097 */
4098 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
4099 /* Clear activity. A bit is cleared for the entry. */
4100 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
4101 /* Delete entry */
4102 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
4103 /* Delete all host entries on a RIF. In this command, dip
4104 * field is reserved.
4105 */
4106};
4107
4108/* reg_rauht_op
4109 * Access: OP
4110 */
4111MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
4112
4113/* reg_rauht_a
4114 * Activity. Set for new entries. Set if a packet lookup has hit on
4115 * the specific entry.
4116 * To clear the a bit, use "clear activity" op.
4117 * Enabled by activity_dis in RGCR
4118 * Access: RO
4119 */
4120MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
4121
4122/* reg_rauht_rif
4123 * Router Interface
4124 * Access: Index
4125 */
4126MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
4127
4128/* reg_rauht_dip*
4129 * Destination address.
4130 * Access: Index
4131 */
4132MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
4133
4134enum mlxsw_reg_rauht_trap_action {
4135 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
4136 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
4137 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
4138 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
4139 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
4140};
4141
4142/* reg_rauht_trap_action
4143 * Access: RW
4144 */
4145MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
4146
4147enum mlxsw_reg_rauht_trap_id {
4148 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
4149 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
4150};
4151
4152/* reg_rauht_trap_id
4153 * Trap ID to be reported to CPU.
4154 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
4155 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
4156 * trap_id is reserved.
4157 * Access: RW
4158 */
4159MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
4160
4161/* reg_rauht_counter_set_type
4162 * Counter set type for flow counters
4163 * Access: RW
4164 */
4165MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
4166
4167/* reg_rauht_counter_index
4168 * Counter index for flow counters
4169 * Access: RW
4170 */
4171MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
4172
4173/* reg_rauht_mac
4174 * MAC address.
4175 * Access: RW
4176 */
4177MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
4178
4179static inline void mlxsw_reg_rauht_pack(char *payload,
4180 enum mlxsw_reg_rauht_op op, u16 rif,
4181 const char *mac)
4182{
4183 MLXSW_REG_ZERO(rauht, payload);
4184 mlxsw_reg_rauht_op_set(payload, op);
4185 mlxsw_reg_rauht_rif_set(payload, rif);
4186 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
4187}
4188
4189static inline void mlxsw_reg_rauht_pack4(char *payload,
4190 enum mlxsw_reg_rauht_op op, u16 rif,
4191 const char *mac, u32 dip)
4192{
4193 mlxsw_reg_rauht_pack(payload, op, rif, mac);
4194 mlxsw_reg_rauht_dip4_set(payload, dip);
4195}
4196
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02004197/* RALEU - Router Algorithmic LPM ECMP Update Register
4198 * ---------------------------------------------------
4199 * The register enables updating the ECMP section in the action for multiple
4200 * LPM Unicast entries in a single operation. The update is executed to
4201 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
4202 */
4203#define MLXSW_REG_RALEU_ID 0x8015
4204#define MLXSW_REG_RALEU_LEN 0x28
4205
Jiri Pirko21978dc2016-10-21 16:07:20 +02004206MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02004207
4208/* reg_raleu_protocol
4209 * Protocol.
4210 * Access: Index
4211 */
4212MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
4213
4214/* reg_raleu_virtual_router
4215 * Virtual Router ID
4216 * Range is 0..cap_max_virtual_routers-1
4217 * Access: Index
4218 */
4219MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
4220
4221/* reg_raleu_adjacency_index
4222 * Adjacency Index used for matching on the existing entries.
4223 * Access: Index
4224 */
4225MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
4226
4227/* reg_raleu_ecmp_size
4228 * ECMP Size used for matching on the existing entries.
4229 * Access: Index
4230 */
4231MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
4232
4233/* reg_raleu_new_adjacency_index
4234 * New Adjacency Index.
4235 * Access: WO
4236 */
4237MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
4238
4239/* reg_raleu_new_ecmp_size
4240 * New ECMP Size.
4241 * Access: WO
4242 */
4243MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
4244
4245static inline void mlxsw_reg_raleu_pack(char *payload,
4246 enum mlxsw_reg_ralxx_protocol protocol,
4247 u16 virtual_router,
4248 u32 adjacency_index, u16 ecmp_size,
4249 u32 new_adjacency_index,
4250 u16 new_ecmp_size)
4251{
4252 MLXSW_REG_ZERO(raleu, payload);
4253 mlxsw_reg_raleu_protocol_set(payload, protocol);
4254 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
4255 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
4256 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
4257 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
4258 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
4259}
4260
Yotam Gigi7cf2c202016-07-05 11:27:41 +02004261/* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
4262 * ----------------------------------------------------------------
4263 * The RAUHTD register allows dumping entries from the Router Unicast Host
4264 * Table. For a given session an entry is dumped no more than one time. The
4265 * first RAUHTD access after reset is a new session. A session ends when the
4266 * num_rec response is smaller than num_rec request or for IPv4 when the
4267 * num_entries is smaller than 4. The clear activity affect the current session
4268 * or the last session if a new session has not started.
4269 */
4270#define MLXSW_REG_RAUHTD_ID 0x8018
4271#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
4272#define MLXSW_REG_RAUHTD_REC_LEN 0x20
4273#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
4274#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
4275 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
4276#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
4277
Jiri Pirko21978dc2016-10-21 16:07:20 +02004278MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
Yotam Gigi7cf2c202016-07-05 11:27:41 +02004279
4280#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
4281#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
4282
4283/* reg_rauhtd_filter_fields
4284 * if a bit is '0' then the relevant field is ignored and dump is done
4285 * regardless of the field value
4286 * Bit0 - filter by activity: entry_a
4287 * Bit3 - filter by entry rip: entry_rif
4288 * Access: Index
4289 */
4290MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
4291
4292enum mlxsw_reg_rauhtd_op {
4293 MLXSW_REG_RAUHTD_OP_DUMP,
4294 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
4295};
4296
4297/* reg_rauhtd_op
4298 * Access: OP
4299 */
4300MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
4301
4302/* reg_rauhtd_num_rec
4303 * At request: number of records requested
4304 * At response: number of records dumped
4305 * For IPv4, each record has 4 entries at request and up to 4 entries
4306 * at response
4307 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
4308 * Access: Index
4309 */
4310MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
4311
4312/* reg_rauhtd_entry_a
4313 * Dump only if activity has value of entry_a
4314 * Reserved if filter_fields bit0 is '0'
4315 * Access: Index
4316 */
4317MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
4318
4319enum mlxsw_reg_rauhtd_type {
4320 MLXSW_REG_RAUHTD_TYPE_IPV4,
4321 MLXSW_REG_RAUHTD_TYPE_IPV6,
4322};
4323
4324/* reg_rauhtd_type
4325 * Dump only if record type is:
4326 * 0 - IPv4
4327 * 1 - IPv6
4328 * Access: Index
4329 */
4330MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
4331
4332/* reg_rauhtd_entry_rif
4333 * Dump only if RIF has value of entry_rif
4334 * Reserved if filter_fields bit3 is '0'
4335 * Access: Index
4336 */
4337MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
4338
4339static inline void mlxsw_reg_rauhtd_pack(char *payload,
4340 enum mlxsw_reg_rauhtd_type type)
4341{
4342 MLXSW_REG_ZERO(rauhtd, payload);
4343 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
4344 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
4345 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
4346 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
4347 mlxsw_reg_rauhtd_type_set(payload, type);
4348}
4349
4350/* reg_rauhtd_ipv4_rec_num_entries
4351 * Number of valid entries in this record:
4352 * 0 - 1 valid entry
4353 * 1 - 2 valid entries
4354 * 2 - 3 valid entries
4355 * 3 - 4 valid entries
4356 * Access: RO
4357 */
4358MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
4359 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
4360 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
4361
4362/* reg_rauhtd_rec_type
4363 * Record type.
4364 * 0 - IPv4
4365 * 1 - IPv6
4366 * Access: RO
4367 */
4368MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
4369 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
4370
4371#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
4372
4373/* reg_rauhtd_ipv4_ent_a
4374 * Activity. Set for new entries. Set if a packet lookup has hit on the
4375 * specific entry.
4376 * Access: RO
4377 */
4378MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
4379 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
4380
4381/* reg_rauhtd_ipv4_ent_rif
4382 * Router interface.
4383 * Access: RO
4384 */
4385MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
4386 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
4387
4388/* reg_rauhtd_ipv4_ent_dip
4389 * Destination IPv4 address.
4390 * Access: RO
4391 */
4392MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
4393 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
4394
4395static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
4396 int ent_index, u16 *p_rif,
4397 u32 *p_dip)
4398{
4399 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
4400 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
4401}
4402
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004403/* MFCR - Management Fan Control Register
4404 * --------------------------------------
4405 * This register controls the settings of the Fan Speed PWM mechanism.
4406 */
4407#define MLXSW_REG_MFCR_ID 0x9001
4408#define MLXSW_REG_MFCR_LEN 0x08
4409
Jiri Pirko21978dc2016-10-21 16:07:20 +02004410MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004411
4412enum mlxsw_reg_mfcr_pwm_frequency {
4413 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
4414 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
4415 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
4416 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
4417 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
4418 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
4419 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
4420 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
4421};
4422
4423/* reg_mfcr_pwm_frequency
4424 * Controls the frequency of the PWM signal.
4425 * Access: RW
4426 */
Jiri Pirkof7ad3d42016-11-11 11:22:53 +01004427MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004428
4429#define MLXSW_MFCR_TACHOS_MAX 10
4430
4431/* reg_mfcr_tacho_active
4432 * Indicates which of the tachometer is active (bit per tachometer).
4433 * Access: RO
4434 */
4435MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
4436
4437#define MLXSW_MFCR_PWMS_MAX 5
4438
4439/* reg_mfcr_pwm_active
4440 * Indicates which of the PWM control is active (bit per PWM).
4441 * Access: RO
4442 */
4443MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
4444
4445static inline void
4446mlxsw_reg_mfcr_pack(char *payload,
4447 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
4448{
4449 MLXSW_REG_ZERO(mfcr, payload);
4450 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
4451}
4452
4453static inline void
4454mlxsw_reg_mfcr_unpack(char *payload,
4455 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
4456 u16 *p_tacho_active, u8 *p_pwm_active)
4457{
4458 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
4459 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
4460 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
4461}
4462
4463/* MFSC - Management Fan Speed Control Register
4464 * --------------------------------------------
4465 * This register controls the settings of the Fan Speed PWM mechanism.
4466 */
4467#define MLXSW_REG_MFSC_ID 0x9002
4468#define MLXSW_REG_MFSC_LEN 0x08
4469
Jiri Pirko21978dc2016-10-21 16:07:20 +02004470MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004471
4472/* reg_mfsc_pwm
4473 * Fan pwm to control / monitor.
4474 * Access: Index
4475 */
4476MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
4477
4478/* reg_mfsc_pwm_duty_cycle
4479 * Controls the duty cycle of the PWM. Value range from 0..255 to
4480 * represent duty cycle of 0%...100%.
4481 * Access: RW
4482 */
4483MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
4484
4485static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
4486 u8 pwm_duty_cycle)
4487{
4488 MLXSW_REG_ZERO(mfsc, payload);
4489 mlxsw_reg_mfsc_pwm_set(payload, pwm);
4490 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
4491}
4492
4493/* MFSM - Management Fan Speed Measurement
4494 * ---------------------------------------
4495 * This register controls the settings of the Tacho measurements and
4496 * enables reading the Tachometer measurements.
4497 */
4498#define MLXSW_REG_MFSM_ID 0x9003
4499#define MLXSW_REG_MFSM_LEN 0x08
4500
Jiri Pirko21978dc2016-10-21 16:07:20 +02004501MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004502
4503/* reg_mfsm_tacho
4504 * Fan tachometer index.
4505 * Access: Index
4506 */
4507MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
4508
4509/* reg_mfsm_rpm
4510 * Fan speed (round per minute).
4511 * Access: RO
4512 */
4513MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
4514
4515static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
4516{
4517 MLXSW_REG_ZERO(mfsm, payload);
4518 mlxsw_reg_mfsm_tacho_set(payload, tacho);
4519}
4520
Jiri Pirko55c63aa2016-11-22 11:24:12 +01004521/* MFSL - Management Fan Speed Limit Register
4522 * ------------------------------------------
4523 * The Fan Speed Limit register is used to configure the fan speed
4524 * event / interrupt notification mechanism. Fan speed threshold are
4525 * defined for both under-speed and over-speed.
4526 */
4527#define MLXSW_REG_MFSL_ID 0x9004
4528#define MLXSW_REG_MFSL_LEN 0x0C
4529
4530MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
4531
4532/* reg_mfsl_tacho
4533 * Fan tachometer index.
4534 * Access: Index
4535 */
4536MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
4537
4538/* reg_mfsl_tach_min
4539 * Tachometer minimum value (minimum RPM).
4540 * Access: RW
4541 */
4542MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
4543
4544/* reg_mfsl_tach_max
4545 * Tachometer maximum value (maximum RPM).
4546 * Access: RW
4547 */
4548MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
4549
4550static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
4551 u16 tach_min, u16 tach_max)
4552{
4553 MLXSW_REG_ZERO(mfsl, payload);
4554 mlxsw_reg_mfsl_tacho_set(payload, tacho);
4555 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
4556 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
4557}
4558
4559static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
4560 u16 *p_tach_min, u16 *p_tach_max)
4561{
4562 if (p_tach_min)
4563 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
4564
4565 if (p_tach_max)
4566 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
4567}
4568
Jiri Pirko85926f82015-11-27 13:45:56 +01004569/* MTCAP - Management Temperature Capabilities
4570 * -------------------------------------------
4571 * This register exposes the capabilities of the device and
4572 * system temperature sensing.
4573 */
4574#define MLXSW_REG_MTCAP_ID 0x9009
4575#define MLXSW_REG_MTCAP_LEN 0x08
4576
Jiri Pirko21978dc2016-10-21 16:07:20 +02004577MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01004578
4579/* reg_mtcap_sensor_count
4580 * Number of sensors supported by the device.
4581 * This includes the QSFP module sensors (if exists in the QSFP module).
4582 * Access: RO
4583 */
4584MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
4585
4586/* MTMP - Management Temperature
4587 * -----------------------------
4588 * This register controls the settings of the temperature measurements
4589 * and enables reading the temperature measurements. Note that temperature
4590 * is in 0.125 degrees Celsius.
4591 */
4592#define MLXSW_REG_MTMP_ID 0x900A
4593#define MLXSW_REG_MTMP_LEN 0x20
4594
Jiri Pirko21978dc2016-10-21 16:07:20 +02004595MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01004596
4597/* reg_mtmp_sensor_index
4598 * Sensors index to access.
4599 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
4600 * (module 0 is mapped to sensor_index 64).
4601 * Access: Index
4602 */
4603MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
4604
4605/* Convert to milli degrees Celsius */
4606#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
4607
4608/* reg_mtmp_temperature
4609 * Temperature reading from the sensor. Reading is in 0.125 Celsius
4610 * degrees units.
4611 * Access: RO
4612 */
4613MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
4614
4615/* reg_mtmp_mte
4616 * Max Temperature Enable - enables measuring the max temperature on a sensor.
4617 * Access: RW
4618 */
4619MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
4620
4621/* reg_mtmp_mtr
4622 * Max Temperature Reset - clears the value of the max temperature register.
4623 * Access: WO
4624 */
4625MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
4626
4627/* reg_mtmp_max_temperature
4628 * The highest measured temperature from the sensor.
4629 * When the bit mte is cleared, the field max_temperature is reserved.
4630 * Access: RO
4631 */
4632MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
4633
4634#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
4635
4636/* reg_mtmp_sensor_name
4637 * Sensor Name
4638 * Access: RO
4639 */
4640MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
4641
4642static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
4643 bool max_temp_enable,
4644 bool max_temp_reset)
4645{
4646 MLXSW_REG_ZERO(mtmp, payload);
4647 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
4648 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
4649 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
4650}
4651
4652static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
4653 unsigned int *p_max_temp,
4654 char *sensor_name)
4655{
4656 u16 temp;
4657
4658 if (p_temp) {
4659 temp = mlxsw_reg_mtmp_temperature_get(payload);
4660 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
4661 }
4662 if (p_max_temp) {
Jiri Pirkoacf35a42015-12-11 16:10:39 +01004663 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
Jiri Pirko85926f82015-11-27 13:45:56 +01004664 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
4665 }
4666 if (sensor_name)
4667 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
4668}
4669
Yotam Gigi43a46852016-07-21 12:03:14 +02004670/* MPAT - Monitoring Port Analyzer Table
4671 * -------------------------------------
4672 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
4673 * For an enabled analyzer, all fields except e (enable) cannot be modified.
4674 */
4675#define MLXSW_REG_MPAT_ID 0x901A
4676#define MLXSW_REG_MPAT_LEN 0x78
4677
Jiri Pirko21978dc2016-10-21 16:07:20 +02004678MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
Yotam Gigi43a46852016-07-21 12:03:14 +02004679
4680/* reg_mpat_pa_id
4681 * Port Analyzer ID.
4682 * Access: Index
4683 */
4684MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
4685
4686/* reg_mpat_system_port
4687 * A unique port identifier for the final destination of the packet.
4688 * Access: RW
4689 */
4690MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
4691
4692/* reg_mpat_e
4693 * Enable. Indicating the Port Analyzer is enabled.
4694 * Access: RW
4695 */
4696MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
4697
4698/* reg_mpat_qos
4699 * Quality Of Service Mode.
4700 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
4701 * PCP, DEI, DSCP or VL) are configured.
4702 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
4703 * same as in the original packet that has triggered the mirroring. For
4704 * SPAN also the pcp,dei are maintained.
4705 * Access: RW
4706 */
4707MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
4708
Yotam Gigi23019052016-07-21 12:03:15 +02004709/* reg_mpat_be
4710 * Best effort mode. Indicates mirroring traffic should not cause packet
4711 * drop or back pressure, but will discard the mirrored packets. Mirrored
4712 * packets will be forwarded on a best effort manner.
4713 * 0: Do not discard mirrored packets
4714 * 1: Discard mirrored packets if causing congestion
4715 * Access: RW
4716 */
4717MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
4718
Yotam Gigi43a46852016-07-21 12:03:14 +02004719static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
4720 u16 system_port, bool e)
4721{
4722 MLXSW_REG_ZERO(mpat, payload);
4723 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
4724 mlxsw_reg_mpat_system_port_set(payload, system_port);
4725 mlxsw_reg_mpat_e_set(payload, e);
4726 mlxsw_reg_mpat_qos_set(payload, 1);
Yotam Gigi23019052016-07-21 12:03:15 +02004727 mlxsw_reg_mpat_be_set(payload, 1);
4728}
4729
4730/* MPAR - Monitoring Port Analyzer Register
4731 * ----------------------------------------
4732 * MPAR register is used to query and configure the port analyzer port mirroring
4733 * properties.
4734 */
4735#define MLXSW_REG_MPAR_ID 0x901B
4736#define MLXSW_REG_MPAR_LEN 0x08
4737
Jiri Pirko21978dc2016-10-21 16:07:20 +02004738MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
Yotam Gigi23019052016-07-21 12:03:15 +02004739
4740/* reg_mpar_local_port
4741 * The local port to mirror the packets from.
4742 * Access: Index
4743 */
4744MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
4745
4746enum mlxsw_reg_mpar_i_e {
4747 MLXSW_REG_MPAR_TYPE_EGRESS,
4748 MLXSW_REG_MPAR_TYPE_INGRESS,
4749};
4750
4751/* reg_mpar_i_e
4752 * Ingress/Egress
4753 * Access: Index
4754 */
4755MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
4756
4757/* reg_mpar_enable
4758 * Enable mirroring
4759 * By default, port mirroring is disabled for all ports.
4760 * Access: RW
4761 */
4762MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
4763
4764/* reg_mpar_pa_id
4765 * Port Analyzer ID.
4766 * Access: RW
4767 */
4768MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
4769
4770static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
4771 enum mlxsw_reg_mpar_i_e i_e,
4772 bool enable, u8 pa_id)
4773{
4774 MLXSW_REG_ZERO(mpar, payload);
4775 mlxsw_reg_mpar_local_port_set(payload, local_port);
4776 mlxsw_reg_mpar_enable_set(payload, enable);
4777 mlxsw_reg_mpar_i_e_set(payload, i_e);
4778 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
Yotam Gigi43a46852016-07-21 12:03:14 +02004779}
4780
Ido Schimmel3161c152015-11-27 13:45:54 +01004781/* MLCR - Management LED Control Register
4782 * --------------------------------------
4783 * Controls the system LEDs.
4784 */
4785#define MLXSW_REG_MLCR_ID 0x902B
4786#define MLXSW_REG_MLCR_LEN 0x0C
4787
Jiri Pirko21978dc2016-10-21 16:07:20 +02004788MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
Ido Schimmel3161c152015-11-27 13:45:54 +01004789
4790/* reg_mlcr_local_port
4791 * Local port number.
4792 * Access: RW
4793 */
4794MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
4795
4796#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
4797
4798/* reg_mlcr_beacon_duration
4799 * Duration of the beacon to be active, in seconds.
4800 * 0x0 - Will turn off the beacon.
4801 * 0xFFFF - Will turn on the beacon until explicitly turned off.
4802 * Access: RW
4803 */
4804MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
4805
4806/* reg_mlcr_beacon_remain
4807 * Remaining duration of the beacon, in seconds.
4808 * 0xFFFF indicates an infinite amount of time.
4809 * Access: RO
4810 */
4811MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
4812
4813static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
4814 bool active)
4815{
4816 MLXSW_REG_ZERO(mlcr, payload);
4817 mlxsw_reg_mlcr_local_port_set(payload, local_port);
4818 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
4819 MLXSW_REG_MLCR_DURATION_MAX : 0);
4820}
4821
Jiri Pirkoe0594362015-10-16 14:01:31 +02004822/* SBPR - Shared Buffer Pools Register
4823 * -----------------------------------
4824 * The SBPR configures and retrieves the shared buffer pools and configuration.
4825 */
4826#define MLXSW_REG_SBPR_ID 0xB001
4827#define MLXSW_REG_SBPR_LEN 0x14
4828
Jiri Pirko21978dc2016-10-21 16:07:20 +02004829MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004830
Jiri Pirko497e8592016-04-08 19:11:24 +02004831/* shared direstion enum for SBPR, SBCM, SBPM */
4832enum mlxsw_reg_sbxx_dir {
4833 MLXSW_REG_SBXX_DIR_INGRESS,
4834 MLXSW_REG_SBXX_DIR_EGRESS,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004835};
4836
4837/* reg_sbpr_dir
4838 * Direction.
4839 * Access: Index
4840 */
4841MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
4842
4843/* reg_sbpr_pool
4844 * Pool index.
4845 * Access: Index
4846 */
4847MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
4848
4849/* reg_sbpr_size
4850 * Pool size in buffer cells.
4851 * Access: RW
4852 */
4853MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
4854
4855enum mlxsw_reg_sbpr_mode {
4856 MLXSW_REG_SBPR_MODE_STATIC,
4857 MLXSW_REG_SBPR_MODE_DYNAMIC,
4858};
4859
4860/* reg_sbpr_mode
4861 * Pool quota calculation mode.
4862 * Access: RW
4863 */
4864MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
4865
4866static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
Jiri Pirko497e8592016-04-08 19:11:24 +02004867 enum mlxsw_reg_sbxx_dir dir,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004868 enum mlxsw_reg_sbpr_mode mode, u32 size)
4869{
4870 MLXSW_REG_ZERO(sbpr, payload);
4871 mlxsw_reg_sbpr_pool_set(payload, pool);
4872 mlxsw_reg_sbpr_dir_set(payload, dir);
4873 mlxsw_reg_sbpr_mode_set(payload, mode);
4874 mlxsw_reg_sbpr_size_set(payload, size);
4875}
4876
4877/* SBCM - Shared Buffer Class Management Register
4878 * ----------------------------------------------
4879 * The SBCM register configures and retrieves the shared buffer allocation
4880 * and configuration according to Port-PG, including the binding to pool
4881 * and definition of the associated quota.
4882 */
4883#define MLXSW_REG_SBCM_ID 0xB002
4884#define MLXSW_REG_SBCM_LEN 0x28
4885
Jiri Pirko21978dc2016-10-21 16:07:20 +02004886MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004887
4888/* reg_sbcm_local_port
4889 * Local port number.
4890 * For Ingress: excludes CPU port and Router port
4891 * For Egress: excludes IP Router
4892 * Access: Index
4893 */
4894MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
4895
4896/* reg_sbcm_pg_buff
4897 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
4898 * For PG buffer: range is 0..cap_max_pg_buffers - 1
4899 * For traffic class: range is 0..cap_max_tclass - 1
4900 * Note that when traffic class is in MC aware mode then the traffic
4901 * classes which are MC aware cannot be configured.
4902 * Access: Index
4903 */
4904MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
4905
Jiri Pirkoe0594362015-10-16 14:01:31 +02004906/* reg_sbcm_dir
4907 * Direction.
4908 * Access: Index
4909 */
4910MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
4911
4912/* reg_sbcm_min_buff
4913 * Minimum buffer size for the limiter, in cells.
4914 * Access: RW
4915 */
4916MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
4917
Jiri Pirkoc30a53c2016-04-14 18:19:22 +02004918/* shared max_buff limits for dynamic threshold for SBCM, SBPM */
4919#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
4920#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
4921
Jiri Pirkoe0594362015-10-16 14:01:31 +02004922/* reg_sbcm_max_buff
4923 * When the pool associated to the port-pg/tclass is configured to
4924 * static, Maximum buffer size for the limiter configured in cells.
4925 * When the pool associated to the port-pg/tclass is configured to
4926 * dynamic, the max_buff holds the "alpha" parameter, supporting
4927 * the following values:
4928 * 0: 0
4929 * i: (1/128)*2^(i-1), for i=1..14
4930 * 0xFF: Infinity
4931 * Access: RW
4932 */
4933MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
4934
4935/* reg_sbcm_pool
4936 * Association of the port-priority to a pool.
4937 * Access: RW
4938 */
4939MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
4940
4941static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
Jiri Pirko497e8592016-04-08 19:11:24 +02004942 enum mlxsw_reg_sbxx_dir dir,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004943 u32 min_buff, u32 max_buff, u8 pool)
4944{
4945 MLXSW_REG_ZERO(sbcm, payload);
4946 mlxsw_reg_sbcm_local_port_set(payload, local_port);
4947 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
4948 mlxsw_reg_sbcm_dir_set(payload, dir);
4949 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
4950 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
4951 mlxsw_reg_sbcm_pool_set(payload, pool);
4952}
4953
Jiri Pirko9efc8f62016-04-08 19:11:25 +02004954/* SBPM - Shared Buffer Port Management Register
4955 * ---------------------------------------------
Jiri Pirkoe0594362015-10-16 14:01:31 +02004956 * The SBPM register configures and retrieves the shared buffer allocation
4957 * and configuration according to Port-Pool, including the definition
4958 * of the associated quota.
4959 */
4960#define MLXSW_REG_SBPM_ID 0xB003
4961#define MLXSW_REG_SBPM_LEN 0x28
4962
Jiri Pirko21978dc2016-10-21 16:07:20 +02004963MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004964
4965/* reg_sbpm_local_port
4966 * Local port number.
4967 * For Ingress: excludes CPU port and Router port
4968 * For Egress: excludes IP Router
4969 * Access: Index
4970 */
4971MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
4972
4973/* reg_sbpm_pool
4974 * The pool associated to quota counting on the local_port.
4975 * Access: Index
4976 */
4977MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
4978
Jiri Pirkoe0594362015-10-16 14:01:31 +02004979/* reg_sbpm_dir
4980 * Direction.
4981 * Access: Index
4982 */
4983MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
4984
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02004985/* reg_sbpm_buff_occupancy
4986 * Current buffer occupancy in cells.
4987 * Access: RO
4988 */
4989MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
4990
4991/* reg_sbpm_clr
4992 * Clear Max Buffer Occupancy
4993 * When this bit is set, max_buff_occupancy field is cleared (and a
4994 * new max value is tracked from the time the clear was performed).
4995 * Access: OP
4996 */
4997MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
4998
4999/* reg_sbpm_max_buff_occupancy
5000 * Maximum value of buffer occupancy in cells monitored. Cleared by
5001 * writing to the clr field.
5002 * Access: RO
5003 */
5004MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
5005
Jiri Pirkoe0594362015-10-16 14:01:31 +02005006/* reg_sbpm_min_buff
5007 * Minimum buffer size for the limiter, in cells.
5008 * Access: RW
5009 */
5010MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
5011
5012/* reg_sbpm_max_buff
5013 * When the pool associated to the port-pg/tclass is configured to
5014 * static, Maximum buffer size for the limiter configured in cells.
5015 * When the pool associated to the port-pg/tclass is configured to
5016 * dynamic, the max_buff holds the "alpha" parameter, supporting
5017 * the following values:
5018 * 0: 0
5019 * i: (1/128)*2^(i-1), for i=1..14
5020 * 0xFF: Infinity
5021 * Access: RW
5022 */
5023MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
5024
5025static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02005026 enum mlxsw_reg_sbxx_dir dir, bool clr,
Jiri Pirkoe0594362015-10-16 14:01:31 +02005027 u32 min_buff, u32 max_buff)
5028{
5029 MLXSW_REG_ZERO(sbpm, payload);
5030 mlxsw_reg_sbpm_local_port_set(payload, local_port);
5031 mlxsw_reg_sbpm_pool_set(payload, pool);
5032 mlxsw_reg_sbpm_dir_set(payload, dir);
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02005033 mlxsw_reg_sbpm_clr_set(payload, clr);
Jiri Pirkoe0594362015-10-16 14:01:31 +02005034 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
5035 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
5036}
5037
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02005038static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
5039 u32 *p_max_buff_occupancy)
5040{
5041 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
5042 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
5043}
5044
Jiri Pirkoe0594362015-10-16 14:01:31 +02005045/* SBMM - Shared Buffer Multicast Management Register
5046 * --------------------------------------------------
5047 * The SBMM register configures and retrieves the shared buffer allocation
5048 * and configuration for MC packets according to Switch-Priority, including
5049 * the binding to pool and definition of the associated quota.
5050 */
5051#define MLXSW_REG_SBMM_ID 0xB004
5052#define MLXSW_REG_SBMM_LEN 0x28
5053
Jiri Pirko21978dc2016-10-21 16:07:20 +02005054MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02005055
5056/* reg_sbmm_prio
5057 * Switch Priority.
5058 * Access: Index
5059 */
5060MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
5061
5062/* reg_sbmm_min_buff
5063 * Minimum buffer size for the limiter, in cells.
5064 * Access: RW
5065 */
5066MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
5067
5068/* reg_sbmm_max_buff
5069 * When the pool associated to the port-pg/tclass is configured to
5070 * static, Maximum buffer size for the limiter configured in cells.
5071 * When the pool associated to the port-pg/tclass is configured to
5072 * dynamic, the max_buff holds the "alpha" parameter, supporting
5073 * the following values:
5074 * 0: 0
5075 * i: (1/128)*2^(i-1), for i=1..14
5076 * 0xFF: Infinity
5077 * Access: RW
5078 */
5079MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
5080
5081/* reg_sbmm_pool
5082 * Association of the port-priority to a pool.
5083 * Access: RW
5084 */
5085MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
5086
5087static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
5088 u32 max_buff, u8 pool)
5089{
5090 MLXSW_REG_ZERO(sbmm, payload);
5091 mlxsw_reg_sbmm_prio_set(payload, prio);
5092 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
5093 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
5094 mlxsw_reg_sbmm_pool_set(payload, pool);
5095}
5096
Jiri Pirko26176de2016-04-14 18:19:26 +02005097/* SBSR - Shared Buffer Status Register
5098 * ------------------------------------
5099 * The SBSR register retrieves the shared buffer occupancy according to
5100 * Port-Pool. Note that this register enables reading a large amount of data.
5101 * It is the user's responsibility to limit the amount of data to ensure the
5102 * response can match the maximum transfer unit. In case the response exceeds
5103 * the maximum transport unit, it will be truncated with no special notice.
5104 */
5105#define MLXSW_REG_SBSR_ID 0xB005
5106#define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
5107#define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
5108#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
5109#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
5110 MLXSW_REG_SBSR_REC_LEN * \
5111 MLXSW_REG_SBSR_REC_MAX_COUNT)
5112
Jiri Pirko21978dc2016-10-21 16:07:20 +02005113MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
Jiri Pirko26176de2016-04-14 18:19:26 +02005114
5115/* reg_sbsr_clr
5116 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
5117 * field is cleared (and a new max value is tracked from the time the clear
5118 * was performed).
5119 * Access: OP
5120 */
5121MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
5122
5123/* reg_sbsr_ingress_port_mask
5124 * Bit vector for all ingress network ports.
5125 * Indicates which of the ports (for which the relevant bit is set)
5126 * are affected by the set operation. Configuration of any other port
5127 * does not change.
5128 * Access: Index
5129 */
5130MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
5131
5132/* reg_sbsr_pg_buff_mask
5133 * Bit vector for all switch priority groups.
5134 * Indicates which of the priorities (for which the relevant bit is set)
5135 * are affected by the set operation. Configuration of any other priority
5136 * does not change.
5137 * Range is 0..cap_max_pg_buffers - 1
5138 * Access: Index
5139 */
5140MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
5141
5142/* reg_sbsr_egress_port_mask
5143 * Bit vector for all egress network ports.
5144 * Indicates which of the ports (for which the relevant bit is set)
5145 * are affected by the set operation. Configuration of any other port
5146 * does not change.
5147 * Access: Index
5148 */
5149MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
5150
5151/* reg_sbsr_tclass_mask
5152 * Bit vector for all traffic classes.
5153 * Indicates which of the traffic classes (for which the relevant bit is
5154 * set) are affected by the set operation. Configuration of any other
5155 * traffic class does not change.
5156 * Range is 0..cap_max_tclass - 1
5157 * Access: Index
5158 */
5159MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
5160
5161static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
5162{
5163 MLXSW_REG_ZERO(sbsr, payload);
5164 mlxsw_reg_sbsr_clr_set(payload, clr);
5165}
5166
5167/* reg_sbsr_rec_buff_occupancy
5168 * Current buffer occupancy in cells.
5169 * Access: RO
5170 */
5171MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
5172 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
5173
5174/* reg_sbsr_rec_max_buff_occupancy
5175 * Maximum value of buffer occupancy in cells monitored. Cleared by
5176 * writing to the clr field.
5177 * Access: RO
5178 */
5179MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
5180 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
5181
5182static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
5183 u32 *p_buff_occupancy,
5184 u32 *p_max_buff_occupancy)
5185{
5186 *p_buff_occupancy =
5187 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
5188 *p_max_buff_occupancy =
5189 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
5190}
5191
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02005192/* SBIB - Shared Buffer Internal Buffer Register
5193 * ---------------------------------------------
5194 * The SBIB register configures per port buffers for internal use. The internal
5195 * buffers consume memory on the port buffers (note that the port buffers are
5196 * used also by PBMC).
5197 *
5198 * For Spectrum this is used for egress mirroring.
5199 */
5200#define MLXSW_REG_SBIB_ID 0xB006
5201#define MLXSW_REG_SBIB_LEN 0x10
5202
Jiri Pirko21978dc2016-10-21 16:07:20 +02005203MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02005204
5205/* reg_sbib_local_port
5206 * Local port number
5207 * Not supported for CPU port and router port
5208 * Access: Index
5209 */
5210MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
5211
5212/* reg_sbib_buff_size
5213 * Units represented in cells
5214 * Allowed range is 0 to (cap_max_headroom_size - 1)
5215 * Default is 0
5216 * Access: RW
5217 */
5218MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
5219
5220static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
5221 u32 buff_size)
5222{
5223 MLXSW_REG_ZERO(sbib, payload);
5224 mlxsw_reg_sbib_local_port_set(payload, local_port);
5225 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
5226}
5227
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005228static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
5229 MLXSW_REG(sgcr),
5230 MLXSW_REG(spad),
5231 MLXSW_REG(smid),
5232 MLXSW_REG(sspr),
5233 MLXSW_REG(sfdat),
5234 MLXSW_REG(sfd),
5235 MLXSW_REG(sfn),
5236 MLXSW_REG(spms),
5237 MLXSW_REG(spvid),
5238 MLXSW_REG(spvm),
5239 MLXSW_REG(spaft),
5240 MLXSW_REG(sfgc),
5241 MLXSW_REG(sftr),
5242 MLXSW_REG(sfdf),
5243 MLXSW_REG(sldr),
5244 MLXSW_REG(slcr),
5245 MLXSW_REG(slcor),
5246 MLXSW_REG(spmlr),
5247 MLXSW_REG(svfa),
5248 MLXSW_REG(svpe),
5249 MLXSW_REG(sfmr),
5250 MLXSW_REG(spvmlr),
5251 MLXSW_REG(qtct),
5252 MLXSW_REG(qeec),
5253 MLXSW_REG(pmlp),
5254 MLXSW_REG(pmtu),
5255 MLXSW_REG(ptys),
5256 MLXSW_REG(ppad),
5257 MLXSW_REG(paos),
5258 MLXSW_REG(pfcc),
5259 MLXSW_REG(ppcnt),
Elad Raz71367932016-10-28 21:35:54 +02005260 MLXSW_REG(plib),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005261 MLXSW_REG(pptb),
5262 MLXSW_REG(pbmc),
5263 MLXSW_REG(pspa),
5264 MLXSW_REG(htgt),
5265 MLXSW_REG(hpkt),
5266 MLXSW_REG(rgcr),
5267 MLXSW_REG(ritr),
5268 MLXSW_REG(ratr),
5269 MLXSW_REG(ralta),
5270 MLXSW_REG(ralst),
5271 MLXSW_REG(raltb),
5272 MLXSW_REG(ralue),
5273 MLXSW_REG(rauht),
5274 MLXSW_REG(raleu),
5275 MLXSW_REG(rauhtd),
5276 MLXSW_REG(mfcr),
5277 MLXSW_REG(mfsc),
5278 MLXSW_REG(mfsm),
Jiri Pirko55c63aa2016-11-22 11:24:12 +01005279 MLXSW_REG(mfsl),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005280 MLXSW_REG(mtcap),
5281 MLXSW_REG(mtmp),
5282 MLXSW_REG(mpat),
5283 MLXSW_REG(mpar),
5284 MLXSW_REG(mlcr),
5285 MLXSW_REG(sbpr),
5286 MLXSW_REG(sbcm),
5287 MLXSW_REG(sbpm),
5288 MLXSW_REG(sbmm),
5289 MLXSW_REG(sbsr),
5290 MLXSW_REG(sbib),
5291};
5292
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005293static inline const char *mlxsw_reg_id_str(u16 reg_id)
5294{
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005295 const struct mlxsw_reg_info *reg_info;
5296 int i;
5297
5298 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
5299 reg_info = mlxsw_reg_infos[i];
5300 if (reg_info->id == reg_id)
5301 return reg_info->name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005302 }
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005303 return "*UNKNOWN*";
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005304}
5305
5306/* PUDE - Port Up / Down Event
5307 * ---------------------------
5308 * Reports the operational state change of a port.
5309 */
5310#define MLXSW_REG_PUDE_LEN 0x10
5311
5312/* reg_pude_swid
5313 * Switch partition ID with which to associate the port.
5314 * Access: Index
5315 */
5316MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
5317
5318/* reg_pude_local_port
5319 * Local port number.
5320 * Access: Index
5321 */
5322MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
5323
5324/* reg_pude_admin_status
5325 * Port administrative state (the desired state).
5326 * 1 - Up.
5327 * 2 - Down.
5328 * 3 - Up once. This means that in case of link failure, the port won't go
5329 * into polling mode, but will wait to be re-enabled by software.
5330 * 4 - Disabled by system. Can only be set by hardware.
5331 * Access: RO
5332 */
5333MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
5334
5335/* reg_pude_oper_status
5336 * Port operatioanl state.
5337 * 1 - Up.
5338 * 2 - Down.
5339 * 3 - Down by port failure. This means that the device will not let the
5340 * port up again until explicitly specified by software.
5341 * Access: RO
5342 */
5343MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
5344
5345#endif