blob: debcf264839844018f43bcff970956cfe3e9b993 [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
2057#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
2058
2059/* reg_ptys_proto_mask
2060 * Protocol mask. Indicates which protocol is used.
2061 * 0 - Infiniband.
2062 * 1 - Fibre Channel.
2063 * 2 - Ethernet.
2064 * Access: Index
2065 */
2066MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
2067
Ido Schimmel4149b972016-09-12 13:26:24 +02002068enum {
2069 MLXSW_REG_PTYS_AN_STATUS_NA,
2070 MLXSW_REG_PTYS_AN_STATUS_OK,
2071 MLXSW_REG_PTYS_AN_STATUS_FAIL,
2072};
2073
2074/* reg_ptys_an_status
2075 * Autonegotiation status.
2076 * Access: RO
2077 */
2078MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
2079
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002080#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
2081#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
2082#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
2083#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
2084#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
2085#define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
2086#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
2087#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
2088#define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
2089#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
2090#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
2091#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
2092#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
2093#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
Ido Schimmelb9d66a32016-09-12 13:26:27 +02002094#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002095#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
2096#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
2097#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
2098#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
2099#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
2100#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
2101#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
2102#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
2103#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
2104#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
2105#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
2106#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
2107#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
2108
2109/* reg_ptys_eth_proto_cap
2110 * Ethernet port supported speeds and protocols.
2111 * Access: RO
2112 */
2113MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
2114
2115/* reg_ptys_eth_proto_admin
2116 * Speed and protocol to set port to.
2117 * Access: RW
2118 */
2119MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
2120
2121/* reg_ptys_eth_proto_oper
2122 * The current speed and protocol configured for the port.
2123 * Access: RO
2124 */
2125MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
2126
Ido Schimmel4149b972016-09-12 13:26:24 +02002127/* reg_ptys_eth_proto_lp_advertise
2128 * The protocols that were advertised by the link partner during
2129 * autonegotiation.
2130 * Access: RO
2131 */
2132MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
2133
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002134static inline void mlxsw_reg_ptys_pack(char *payload, u8 local_port,
2135 u32 proto_admin)
2136{
2137 MLXSW_REG_ZERO(ptys, payload);
2138 mlxsw_reg_ptys_local_port_set(payload, local_port);
2139 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
2140 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
2141}
2142
2143static inline void mlxsw_reg_ptys_unpack(char *payload, u32 *p_eth_proto_cap,
2144 u32 *p_eth_proto_adm,
2145 u32 *p_eth_proto_oper)
2146{
2147 if (p_eth_proto_cap)
2148 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
2149 if (p_eth_proto_adm)
2150 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
2151 if (p_eth_proto_oper)
2152 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
2153}
2154
2155/* PPAD - Port Physical Address Register
2156 * -------------------------------------
2157 * The PPAD register configures the per port physical MAC address.
2158 */
2159#define MLXSW_REG_PPAD_ID 0x5005
2160#define MLXSW_REG_PPAD_LEN 0x10
2161
Jiri Pirko21978dc2016-10-21 16:07:20 +02002162MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002163
2164/* reg_ppad_single_base_mac
2165 * 0: base_mac, local port should be 0 and mac[7:0] is
2166 * reserved. HW will set incremental
2167 * 1: single_mac - mac of the local_port
2168 * Access: RW
2169 */
2170MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
2171
2172/* reg_ppad_local_port
2173 * port number, if single_base_mac = 0 then local_port is reserved
2174 * Access: RW
2175 */
2176MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
2177
2178/* reg_ppad_mac
2179 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
2180 * If single_base_mac = 1 - the per port MAC address
2181 * Access: RW
2182 */
2183MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
2184
2185static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
2186 u8 local_port)
2187{
2188 MLXSW_REG_ZERO(ppad, payload);
2189 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
2190 mlxsw_reg_ppad_local_port_set(payload, local_port);
2191}
2192
2193/* PAOS - Ports Administrative and Operational Status Register
2194 * -----------------------------------------------------------
2195 * Configures and retrieves per port administrative and operational status.
2196 */
2197#define MLXSW_REG_PAOS_ID 0x5006
2198#define MLXSW_REG_PAOS_LEN 0x10
2199
Jiri Pirko21978dc2016-10-21 16:07:20 +02002200MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002201
2202/* reg_paos_swid
2203 * Switch partition ID with which to associate the port.
2204 * Note: while external ports uses unique local port numbers (and thus swid is
2205 * redundant), router ports use the same local port number where swid is the
2206 * only indication for the relevant port.
2207 * Access: Index
2208 */
2209MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
2210
2211/* reg_paos_local_port
2212 * Local port number.
2213 * Access: Index
2214 */
2215MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
2216
2217/* reg_paos_admin_status
2218 * Port administrative state (the desired state of the port):
2219 * 1 - Up.
2220 * 2 - Down.
2221 * 3 - Up once. This means that in case of link failure, the port won't go
2222 * into polling mode, but will wait to be re-enabled by software.
2223 * 4 - Disabled by system. Can only be set by hardware.
2224 * Access: RW
2225 */
2226MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
2227
2228/* reg_paos_oper_status
2229 * Port operational state (the current state):
2230 * 1 - Up.
2231 * 2 - Down.
2232 * 3 - Down by port failure. This means that the device will not let the
2233 * port up again until explicitly specified by software.
2234 * Access: RO
2235 */
2236MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
2237
2238/* reg_paos_ase
2239 * Admin state update enabled.
2240 * Access: WO
2241 */
2242MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
2243
2244/* reg_paos_ee
2245 * Event update enable. If this bit is set, event generation will be
2246 * updated based on the e field.
2247 * Access: WO
2248 */
2249MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
2250
2251/* reg_paos_e
2252 * Event generation on operational state change:
2253 * 0 - Do not generate event.
2254 * 1 - Generate Event.
2255 * 2 - Generate Single Event.
2256 * Access: RW
2257 */
2258MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
2259
2260static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
2261 enum mlxsw_port_admin_status status)
2262{
2263 MLXSW_REG_ZERO(paos, payload);
2264 mlxsw_reg_paos_swid_set(payload, 0);
2265 mlxsw_reg_paos_local_port_set(payload, local_port);
2266 mlxsw_reg_paos_admin_status_set(payload, status);
2267 mlxsw_reg_paos_oper_status_set(payload, 0);
2268 mlxsw_reg_paos_ase_set(payload, 1);
2269 mlxsw_reg_paos_ee_set(payload, 1);
2270 mlxsw_reg_paos_e_set(payload, 1);
2271}
2272
Ido Schimmel6f253d82016-04-06 17:10:12 +02002273/* PFCC - Ports Flow Control Configuration Register
2274 * ------------------------------------------------
2275 * Configures and retrieves the per port flow control configuration.
2276 */
2277#define MLXSW_REG_PFCC_ID 0x5007
2278#define MLXSW_REG_PFCC_LEN 0x20
2279
Jiri Pirko21978dc2016-10-21 16:07:20 +02002280MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
Ido Schimmel6f253d82016-04-06 17:10:12 +02002281
2282/* reg_pfcc_local_port
2283 * Local port number.
2284 * Access: Index
2285 */
2286MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
2287
2288/* reg_pfcc_pnat
2289 * Port number access type. Determines the way local_port is interpreted:
2290 * 0 - Local port number.
2291 * 1 - IB / label port number.
2292 * Access: Index
2293 */
2294MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
2295
2296/* reg_pfcc_shl_cap
2297 * Send to higher layers capabilities:
2298 * 0 - No capability of sending Pause and PFC frames to higher layers.
2299 * 1 - Device has capability of sending Pause and PFC frames to higher
2300 * layers.
2301 * Access: RO
2302 */
2303MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
2304
2305/* reg_pfcc_shl_opr
2306 * Send to higher layers operation:
2307 * 0 - Pause and PFC frames are handled by the port (default).
2308 * 1 - Pause and PFC frames are handled by the port and also sent to
2309 * higher layers. Only valid if shl_cap = 1.
2310 * Access: RW
2311 */
2312MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
2313
2314/* reg_pfcc_ppan
2315 * Pause policy auto negotiation.
2316 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
2317 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
2318 * based on the auto-negotiation resolution.
2319 * Access: RW
2320 *
2321 * Note: The auto-negotiation advertisement is set according to pptx and
2322 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
2323 */
2324MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
2325
2326/* reg_pfcc_prio_mask_tx
2327 * Bit per priority indicating if Tx flow control policy should be
2328 * updated based on bit pfctx.
2329 * Access: WO
2330 */
2331MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
2332
2333/* reg_pfcc_prio_mask_rx
2334 * Bit per priority indicating if Rx flow control policy should be
2335 * updated based on bit pfcrx.
2336 * Access: WO
2337 */
2338MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
2339
2340/* reg_pfcc_pptx
2341 * Admin Pause policy on Tx.
2342 * 0 - Never generate Pause frames (default).
2343 * 1 - Generate Pause frames according to Rx buffer threshold.
2344 * Access: RW
2345 */
2346MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
2347
2348/* reg_pfcc_aptx
2349 * Active (operational) Pause policy on Tx.
2350 * 0 - Never generate Pause frames.
2351 * 1 - Generate Pause frames according to Rx buffer threshold.
2352 * Access: RO
2353 */
2354MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
2355
2356/* reg_pfcc_pfctx
2357 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
2358 * 0 - Never generate priority Pause frames on the specified priority
2359 * (default).
2360 * 1 - Generate priority Pause frames according to Rx buffer threshold on
2361 * the specified priority.
2362 * Access: RW
2363 *
2364 * Note: pfctx and pptx must be mutually exclusive.
2365 */
2366MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
2367
2368/* reg_pfcc_pprx
2369 * Admin Pause policy on Rx.
2370 * 0 - Ignore received Pause frames (default).
2371 * 1 - Respect received Pause frames.
2372 * Access: RW
2373 */
2374MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
2375
2376/* reg_pfcc_aprx
2377 * Active (operational) Pause policy on Rx.
2378 * 0 - Ignore received Pause frames.
2379 * 1 - Respect received Pause frames.
2380 * Access: RO
2381 */
2382MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
2383
2384/* reg_pfcc_pfcrx
2385 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
2386 * 0 - Ignore incoming priority Pause frames on the specified priority
2387 * (default).
2388 * 1 - Respect incoming priority Pause frames on the specified priority.
2389 * Access: RW
2390 */
2391MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
2392
Ido Schimmeld81a6bd2016-04-06 17:10:16 +02002393#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
2394
2395static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
2396{
2397 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
2398 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
2399 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
2400 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
2401}
2402
Ido Schimmel6f253d82016-04-06 17:10:12 +02002403static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
2404{
2405 MLXSW_REG_ZERO(pfcc, payload);
2406 mlxsw_reg_pfcc_local_port_set(payload, local_port);
2407}
2408
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002409/* PPCNT - Ports Performance Counters Register
2410 * -------------------------------------------
2411 * The PPCNT register retrieves per port performance counters.
2412 */
2413#define MLXSW_REG_PPCNT_ID 0x5008
2414#define MLXSW_REG_PPCNT_LEN 0x100
2415
Jiri Pirko21978dc2016-10-21 16:07:20 +02002416MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002417
2418/* reg_ppcnt_swid
2419 * For HCA: must be always 0.
2420 * Switch partition ID to associate port with.
2421 * Switch partitions are numbered from 0 to 7 inclusively.
2422 * Switch partition 254 indicates stacking ports.
2423 * Switch partition 255 indicates all switch partitions.
2424 * Only valid on Set() operation with local_port=255.
2425 * Access: Index
2426 */
2427MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
2428
2429/* reg_ppcnt_local_port
2430 * Local port number.
2431 * 255 indicates all ports on the device, and is only allowed
2432 * for Set() operation.
2433 * Access: Index
2434 */
2435MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
2436
2437/* reg_ppcnt_pnat
2438 * Port number access type:
2439 * 0 - Local port number
2440 * 1 - IB port number
2441 * Access: Index
2442 */
2443MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
2444
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002445enum mlxsw_reg_ppcnt_grp {
2446 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
2447 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
Ido Schimmeldf4750e2016-07-19 15:35:54 +02002448 MLXSW_REG_PPCNT_TC_CNT = 0x11,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002449};
2450
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002451/* reg_ppcnt_grp
2452 * Performance counter group.
2453 * Group 63 indicates all groups. Only valid on Set() operation with
2454 * clr bit set.
2455 * 0x0: IEEE 802.3 Counters
2456 * 0x1: RFC 2863 Counters
2457 * 0x2: RFC 2819 Counters
2458 * 0x3: RFC 3635 Counters
2459 * 0x5: Ethernet Extended Counters
2460 * 0x8: Link Level Retransmission Counters
2461 * 0x10: Per Priority Counters
2462 * 0x11: Per Traffic Class Counters
2463 * 0x12: Physical Layer Counters
2464 * Access: Index
2465 */
2466MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
2467
2468/* reg_ppcnt_clr
2469 * Clear counters. Setting the clr bit will reset the counter value
2470 * for all counters in the counter group. This bit can be set
2471 * for both Set() and Get() operation.
2472 * Access: OP
2473 */
2474MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
2475
2476/* reg_ppcnt_prio_tc
2477 * Priority for counter set that support per priority, valid values: 0-7.
2478 * Traffic class for counter set that support per traffic class,
2479 * valid values: 0- cap_max_tclass-1 .
2480 * For HCA: cap_max_tclass is always 8.
2481 * Otherwise must be 0.
2482 * Access: Index
2483 */
2484MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
2485
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002486/* Ethernet IEEE 802.3 Counter Group */
2487
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002488/* reg_ppcnt_a_frames_transmitted_ok
2489 * Access: RO
2490 */
2491MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
2492 0x08 + 0x00, 0, 64);
2493
2494/* reg_ppcnt_a_frames_received_ok
2495 * Access: RO
2496 */
2497MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
2498 0x08 + 0x08, 0, 64);
2499
2500/* reg_ppcnt_a_frame_check_sequence_errors
2501 * Access: RO
2502 */
2503MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
2504 0x08 + 0x10, 0, 64);
2505
2506/* reg_ppcnt_a_alignment_errors
2507 * Access: RO
2508 */
2509MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
2510 0x08 + 0x18, 0, 64);
2511
2512/* reg_ppcnt_a_octets_transmitted_ok
2513 * Access: RO
2514 */
2515MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
2516 0x08 + 0x20, 0, 64);
2517
2518/* reg_ppcnt_a_octets_received_ok
2519 * Access: RO
2520 */
2521MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
2522 0x08 + 0x28, 0, 64);
2523
2524/* reg_ppcnt_a_multicast_frames_xmitted_ok
2525 * Access: RO
2526 */
2527MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
2528 0x08 + 0x30, 0, 64);
2529
2530/* reg_ppcnt_a_broadcast_frames_xmitted_ok
2531 * Access: RO
2532 */
2533MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
2534 0x08 + 0x38, 0, 64);
2535
2536/* reg_ppcnt_a_multicast_frames_received_ok
2537 * Access: RO
2538 */
2539MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
2540 0x08 + 0x40, 0, 64);
2541
2542/* reg_ppcnt_a_broadcast_frames_received_ok
2543 * Access: RO
2544 */
2545MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
2546 0x08 + 0x48, 0, 64);
2547
2548/* reg_ppcnt_a_in_range_length_errors
2549 * Access: RO
2550 */
2551MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
2552 0x08 + 0x50, 0, 64);
2553
2554/* reg_ppcnt_a_out_of_range_length_field
2555 * Access: RO
2556 */
2557MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
2558 0x08 + 0x58, 0, 64);
2559
2560/* reg_ppcnt_a_frame_too_long_errors
2561 * Access: RO
2562 */
2563MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
2564 0x08 + 0x60, 0, 64);
2565
2566/* reg_ppcnt_a_symbol_error_during_carrier
2567 * Access: RO
2568 */
2569MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
2570 0x08 + 0x68, 0, 64);
2571
2572/* reg_ppcnt_a_mac_control_frames_transmitted
2573 * Access: RO
2574 */
2575MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
2576 0x08 + 0x70, 0, 64);
2577
2578/* reg_ppcnt_a_mac_control_frames_received
2579 * Access: RO
2580 */
2581MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
2582 0x08 + 0x78, 0, 64);
2583
2584/* reg_ppcnt_a_unsupported_opcodes_received
2585 * Access: RO
2586 */
2587MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
2588 0x08 + 0x80, 0, 64);
2589
2590/* reg_ppcnt_a_pause_mac_ctrl_frames_received
2591 * Access: RO
2592 */
2593MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
2594 0x08 + 0x88, 0, 64);
2595
2596/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
2597 * Access: RO
2598 */
2599MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
2600 0x08 + 0x90, 0, 64);
2601
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002602/* Ethernet Per Priority Group Counters */
2603
2604/* reg_ppcnt_rx_octets
2605 * Access: RO
2606 */
2607MLXSW_ITEM64(reg, ppcnt, rx_octets, 0x08 + 0x00, 0, 64);
2608
2609/* reg_ppcnt_rx_frames
2610 * Access: RO
2611 */
2612MLXSW_ITEM64(reg, ppcnt, rx_frames, 0x08 + 0x20, 0, 64);
2613
2614/* reg_ppcnt_tx_octets
2615 * Access: RO
2616 */
2617MLXSW_ITEM64(reg, ppcnt, tx_octets, 0x08 + 0x28, 0, 64);
2618
2619/* reg_ppcnt_tx_frames
2620 * Access: RO
2621 */
2622MLXSW_ITEM64(reg, ppcnt, tx_frames, 0x08 + 0x48, 0, 64);
2623
2624/* reg_ppcnt_rx_pause
2625 * Access: RO
2626 */
2627MLXSW_ITEM64(reg, ppcnt, rx_pause, 0x08 + 0x50, 0, 64);
2628
2629/* reg_ppcnt_rx_pause_duration
2630 * Access: RO
2631 */
2632MLXSW_ITEM64(reg, ppcnt, rx_pause_duration, 0x08 + 0x58, 0, 64);
2633
2634/* reg_ppcnt_tx_pause
2635 * Access: RO
2636 */
2637MLXSW_ITEM64(reg, ppcnt, tx_pause, 0x08 + 0x60, 0, 64);
2638
2639/* reg_ppcnt_tx_pause_duration
2640 * Access: RO
2641 */
2642MLXSW_ITEM64(reg, ppcnt, tx_pause_duration, 0x08 + 0x68, 0, 64);
2643
2644/* reg_ppcnt_rx_pause_transition
2645 * Access: RO
2646 */
2647MLXSW_ITEM64(reg, ppcnt, tx_pause_transition, 0x08 + 0x70, 0, 64);
2648
Ido Schimmeldf4750e2016-07-19 15:35:54 +02002649/* Ethernet Per Traffic Group Counters */
2650
2651/* reg_ppcnt_tc_transmit_queue
2652 * Contains the transmit queue depth in cells of traffic class
2653 * selected by prio_tc and the port selected by local_port.
2654 * The field cannot be cleared.
2655 * Access: RO
2656 */
2657MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue, 0x08 + 0x00, 0, 64);
2658
2659/* reg_ppcnt_tc_no_buffer_discard_uc
2660 * The number of unicast packets dropped due to lack of shared
2661 * buffer resources.
2662 * Access: RO
2663 */
2664MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc, 0x08 + 0x08, 0, 64);
2665
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002666static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
2667 enum mlxsw_reg_ppcnt_grp grp,
2668 u8 prio_tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002669{
2670 MLXSW_REG_ZERO(ppcnt, payload);
2671 mlxsw_reg_ppcnt_swid_set(payload, 0);
2672 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
2673 mlxsw_reg_ppcnt_pnat_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002674 mlxsw_reg_ppcnt_grp_set(payload, grp);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002675 mlxsw_reg_ppcnt_clr_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02002676 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002677}
2678
Ido Schimmelb98ff152016-04-06 17:10:00 +02002679/* PPTB - Port Prio To Buffer Register
2680 * -----------------------------------
2681 * Configures the switch priority to buffer table.
2682 */
2683#define MLXSW_REG_PPTB_ID 0x500B
Ido Schimmel11719a52016-07-15 11:15:02 +02002684#define MLXSW_REG_PPTB_LEN 0x10
Ido Schimmelb98ff152016-04-06 17:10:00 +02002685
Jiri Pirko21978dc2016-10-21 16:07:20 +02002686MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
Ido Schimmelb98ff152016-04-06 17:10:00 +02002687
2688enum {
2689 MLXSW_REG_PPTB_MM_UM,
2690 MLXSW_REG_PPTB_MM_UNICAST,
2691 MLXSW_REG_PPTB_MM_MULTICAST,
2692};
2693
2694/* reg_pptb_mm
2695 * Mapping mode.
2696 * 0 - Map both unicast and multicast packets to the same buffer.
2697 * 1 - Map only unicast packets.
2698 * 2 - Map only multicast packets.
2699 * Access: Index
2700 *
2701 * Note: SwitchX-2 only supports the first option.
2702 */
2703MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
2704
2705/* reg_pptb_local_port
2706 * Local port number.
2707 * Access: Index
2708 */
2709MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
2710
2711/* reg_pptb_um
2712 * Enables the update of the untagged_buf field.
2713 * Access: RW
2714 */
2715MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
2716
2717/* reg_pptb_pm
2718 * Enables the update of the prio_to_buff field.
2719 * Bit <i> is a flag for updating the mapping for switch priority <i>.
2720 * Access: RW
2721 */
2722MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
2723
2724/* reg_pptb_prio_to_buff
2725 * Mapping of switch priority <i> to one of the allocated receive port
2726 * buffers.
2727 * Access: RW
2728 */
2729MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
2730
2731/* reg_pptb_pm_msb
2732 * Enables the update of the prio_to_buff field.
2733 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
2734 * Access: RW
2735 */
2736MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
2737
2738/* reg_pptb_untagged_buff
2739 * Mapping of untagged frames to one of the allocated receive port buffers.
2740 * Access: RW
2741 *
2742 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
2743 * Spectrum, as it maps untagged packets based on the default switch priority.
2744 */
2745MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
2746
Ido Schimmel11719a52016-07-15 11:15:02 +02002747/* reg_pptb_prio_to_buff_msb
2748 * Mapping of switch priority <i+8> to one of the allocated receive port
2749 * buffers.
2750 * Access: RW
2751 */
2752MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
2753
Ido Schimmelb98ff152016-04-06 17:10:00 +02002754#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
2755
2756static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
2757{
2758 MLXSW_REG_ZERO(pptb, payload);
2759 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
2760 mlxsw_reg_pptb_local_port_set(payload, local_port);
2761 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
Ido Schimmel11719a52016-07-15 11:15:02 +02002762 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
2763}
2764
2765static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
2766 u8 buff)
2767{
2768 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
2769 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
Ido Schimmelb98ff152016-04-06 17:10:00 +02002770}
2771
Jiri Pirkoe0594362015-10-16 14:01:31 +02002772/* PBMC - Port Buffer Management Control Register
2773 * ----------------------------------------------
2774 * The PBMC register configures and retrieves the port packet buffer
2775 * allocation for different Prios, and the Pause threshold management.
2776 */
2777#define MLXSW_REG_PBMC_ID 0x500C
Ido Schimmel7ad7cd62016-04-06 17:10:04 +02002778#define MLXSW_REG_PBMC_LEN 0x6C
Jiri Pirkoe0594362015-10-16 14:01:31 +02002779
Jiri Pirko21978dc2016-10-21 16:07:20 +02002780MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02002781
2782/* reg_pbmc_local_port
2783 * Local port number.
2784 * Access: Index
2785 */
2786MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
2787
2788/* reg_pbmc_xoff_timer_value
2789 * When device generates a pause frame, it uses this value as the pause
2790 * timer (time for the peer port to pause in quota-512 bit time).
2791 * Access: RW
2792 */
2793MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
2794
2795/* reg_pbmc_xoff_refresh
2796 * The time before a new pause frame should be sent to refresh the pause RW
2797 * state. Using the same units as xoff_timer_value above (in quota-512 bit
2798 * time).
2799 * Access: RW
2800 */
2801MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
2802
Ido Schimmeld6b7c132016-04-06 17:10:05 +02002803#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
2804
Jiri Pirkoe0594362015-10-16 14:01:31 +02002805/* reg_pbmc_buf_lossy
2806 * The field indicates if the buffer is lossy.
2807 * 0 - Lossless
2808 * 1 - Lossy
2809 * Access: RW
2810 */
2811MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
2812
2813/* reg_pbmc_buf_epsb
2814 * Eligible for Port Shared buffer.
2815 * If epsb is set, packets assigned to buffer are allowed to insert the port
2816 * shared buffer.
2817 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
2818 * Access: RW
2819 */
2820MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
2821
2822/* reg_pbmc_buf_size
2823 * The part of the packet buffer array is allocated for the specific buffer.
2824 * Units are represented in cells.
2825 * Access: RW
2826 */
2827MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
2828
Ido Schimmel155f9de2016-04-06 17:10:13 +02002829/* reg_pbmc_buf_xoff_threshold
2830 * Once the amount of data in the buffer goes above this value, device
2831 * starts sending PFC frames for all priorities associated with the
2832 * buffer. Units are represented in cells. Reserved in case of lossy
2833 * buffer.
2834 * Access: RW
2835 *
2836 * Note: In Spectrum, reserved for buffer[9].
2837 */
2838MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
2839 0x08, 0x04, false);
2840
2841/* reg_pbmc_buf_xon_threshold
2842 * When the amount of data in the buffer goes below this value, device
2843 * stops sending PFC frames for the priorities associated with the
2844 * buffer. Units are represented in cells. Reserved in case of lossy
2845 * buffer.
2846 * Access: RW
2847 *
2848 * Note: In Spectrum, reserved for buffer[9].
2849 */
2850MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
2851 0x08, 0x04, false);
2852
Jiri Pirkoe0594362015-10-16 14:01:31 +02002853static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
2854 u16 xoff_timer_value, u16 xoff_refresh)
2855{
2856 MLXSW_REG_ZERO(pbmc, payload);
2857 mlxsw_reg_pbmc_local_port_set(payload, local_port);
2858 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
2859 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
2860}
2861
2862static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
2863 int buf_index,
2864 u16 size)
2865{
2866 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
2867 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
2868 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
2869}
2870
Ido Schimmel155f9de2016-04-06 17:10:13 +02002871static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
2872 int buf_index, u16 size,
2873 u16 threshold)
2874{
2875 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
2876 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
2877 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
2878 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
2879 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
2880}
2881
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002882/* PSPA - Port Switch Partition Allocation
2883 * ---------------------------------------
2884 * Controls the association of a port with a switch partition and enables
2885 * configuring ports as stacking ports.
2886 */
Jiri Pirko3f0effd2015-10-15 17:43:23 +02002887#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002888#define MLXSW_REG_PSPA_LEN 0x8
2889
Jiri Pirko21978dc2016-10-21 16:07:20 +02002890MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002891
2892/* reg_pspa_swid
2893 * Switch partition ID.
2894 * Access: RW
2895 */
2896MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
2897
2898/* reg_pspa_local_port
2899 * Local port number.
2900 * Access: Index
2901 */
2902MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
2903
2904/* reg_pspa_sub_port
2905 * Virtual port within the local port. Set to 0 when virtual ports are
2906 * disabled on the local port.
2907 * Access: Index
2908 */
2909MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
2910
2911static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
2912{
2913 MLXSW_REG_ZERO(pspa, payload);
2914 mlxsw_reg_pspa_swid_set(payload, swid);
2915 mlxsw_reg_pspa_local_port_set(payload, local_port);
2916 mlxsw_reg_pspa_sub_port_set(payload, 0);
2917}
2918
2919/* HTGT - Host Trap Group Table
2920 * ----------------------------
2921 * Configures the properties for forwarding to CPU.
2922 */
2923#define MLXSW_REG_HTGT_ID 0x7002
2924#define MLXSW_REG_HTGT_LEN 0x100
2925
Jiri Pirko21978dc2016-10-21 16:07:20 +02002926MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002927
2928/* reg_htgt_swid
2929 * Switch partition ID.
2930 * Access: Index
2931 */
2932MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
2933
2934#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
2935
2936/* reg_htgt_type
2937 * CPU path type.
2938 * Access: RW
2939 */
2940MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
2941
Ido Schimmel801bd3d2015-10-15 17:43:28 +02002942enum mlxsw_reg_htgt_trap_group {
2943 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
2944 MLXSW_REG_HTGT_TRAP_GROUP_RX,
2945 MLXSW_REG_HTGT_TRAP_GROUP_CTRL,
2946};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02002947
2948/* reg_htgt_trap_group
2949 * Trap group number. User defined number specifying which trap groups
2950 * should be forwarded to the CPU. The mapping between trap IDs and trap
2951 * groups is configured using HPKT register.
2952 * Access: Index
2953 */
2954MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
2955
2956enum {
2957 MLXSW_REG_HTGT_POLICER_DISABLE,
2958 MLXSW_REG_HTGT_POLICER_ENABLE,
2959};
2960
2961/* reg_htgt_pide
2962 * Enable policer ID specified using 'pid' field.
2963 * Access: RW
2964 */
2965MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
2966
2967/* reg_htgt_pid
2968 * Policer ID for the trap group.
2969 * Access: RW
2970 */
2971MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
2972
2973#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
2974
2975/* reg_htgt_mirror_action
2976 * Mirror action to use.
2977 * 0 - Trap to CPU.
2978 * 1 - Trap to CPU and mirror to a mirroring agent.
2979 * 2 - Mirror to a mirroring agent and do not trap to CPU.
2980 * Access: RW
2981 *
2982 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
2983 */
2984MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
2985
2986/* reg_htgt_mirroring_agent
2987 * Mirroring agent.
2988 * Access: RW
2989 */
2990MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
2991
2992/* reg_htgt_priority
2993 * Trap group priority.
2994 * In case a packet matches multiple classification rules, the packet will
2995 * only be trapped once, based on the trap ID associated with the group (via
2996 * register HPKT) with the highest priority.
2997 * Supported values are 0-7, with 7 represnting the highest priority.
2998 * Access: RW
2999 *
3000 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
3001 * by the 'trap_group' field.
3002 */
3003MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
3004
3005/* reg_htgt_local_path_cpu_tclass
3006 * CPU ingress traffic class for the trap group.
3007 * Access: RW
3008 */
3009MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
3010
3011#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD 0x15
3012#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX 0x14
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003013#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL 0x13
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003014
3015/* reg_htgt_local_path_rdq
3016 * Receive descriptor queue (RDQ) to use for the trap group.
3017 * Access: RW
3018 */
3019MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
3020
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003021static inline void mlxsw_reg_htgt_pack(char *payload,
3022 enum mlxsw_reg_htgt_trap_group group)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003023{
3024 u8 swid, rdq;
3025
3026 MLXSW_REG_ZERO(htgt, payload);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003027 switch (group) {
3028 case MLXSW_REG_HTGT_TRAP_GROUP_EMAD:
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003029 swid = MLXSW_PORT_SWID_ALL_SWIDS;
3030 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD;
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003031 break;
3032 case MLXSW_REG_HTGT_TRAP_GROUP_RX:
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003033 swid = 0;
3034 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX;
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003035 break;
3036 case MLXSW_REG_HTGT_TRAP_GROUP_CTRL:
3037 swid = 0;
3038 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL;
3039 break;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003040 }
3041 mlxsw_reg_htgt_swid_set(payload, swid);
3042 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003043 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003044 mlxsw_reg_htgt_pide_set(payload, MLXSW_REG_HTGT_POLICER_DISABLE);
3045 mlxsw_reg_htgt_pid_set(payload, 0);
3046 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
3047 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
3048 mlxsw_reg_htgt_priority_set(payload, 0);
3049 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, 7);
3050 mlxsw_reg_htgt_local_path_rdq_set(payload, rdq);
3051}
3052
3053/* HPKT - Host Packet Trap
3054 * -----------------------
3055 * Configures trap IDs inside trap groups.
3056 */
3057#define MLXSW_REG_HPKT_ID 0x7003
3058#define MLXSW_REG_HPKT_LEN 0x10
3059
Jiri Pirko21978dc2016-10-21 16:07:20 +02003060MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003061
3062enum {
3063 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
3064 MLXSW_REG_HPKT_ACK_REQUIRED,
3065};
3066
3067/* reg_hpkt_ack
3068 * Require acknowledgements from the host for events.
3069 * If set, then the device will wait for the event it sent to be acknowledged
3070 * by the host. This option is only relevant for event trap IDs.
3071 * Access: RW
3072 *
3073 * Note: Currently not supported by firmware.
3074 */
3075MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
3076
3077enum mlxsw_reg_hpkt_action {
3078 MLXSW_REG_HPKT_ACTION_FORWARD,
3079 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
3080 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
3081 MLXSW_REG_HPKT_ACTION_DISCARD,
3082 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
3083 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
3084};
3085
3086/* reg_hpkt_action
3087 * Action to perform on packet when trapped.
3088 * 0 - No action. Forward to CPU based on switching rules.
3089 * 1 - Trap to CPU (CPU receives sole copy).
3090 * 2 - Mirror to CPU (CPU receives a replica of the packet).
3091 * 3 - Discard.
3092 * 4 - Soft discard (allow other traps to act on the packet).
3093 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
3094 * Access: RW
3095 *
3096 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
3097 * addressed to the CPU.
3098 */
3099MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
3100
3101/* reg_hpkt_trap_group
3102 * Trap group to associate the trap with.
3103 * Access: RW
3104 */
3105MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
3106
3107/* reg_hpkt_trap_id
3108 * Trap ID.
3109 * Access: Index
3110 *
3111 * Note: A trap ID can only be associated with a single trap group. The device
3112 * will associate the trap ID with the last trap group configured.
3113 */
3114MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
3115
3116enum {
3117 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
3118 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
3119 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
3120};
3121
3122/* reg_hpkt_ctrl
3123 * Configure dedicated buffer resources for control packets.
3124 * 0 - Keep factory defaults.
3125 * 1 - Do not use control buffer for this trap ID.
3126 * 2 - Use control buffer for this trap ID.
3127 * Access: RW
3128 */
3129MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
3130
Ido Schimmelf24af332015-10-15 17:43:27 +02003131static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003132{
Ido Schimmel801bd3d2015-10-15 17:43:28 +02003133 enum mlxsw_reg_htgt_trap_group trap_group;
Ido Schimmelf24af332015-10-15 17:43:27 +02003134
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003135 MLXSW_REG_ZERO(hpkt, payload);
3136 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
3137 mlxsw_reg_hpkt_action_set(payload, action);
Ido Schimmelf24af332015-10-15 17:43:27 +02003138 switch (trap_id) {
3139 case MLXSW_TRAP_ID_ETHEMAD:
3140 case MLXSW_TRAP_ID_PUDE:
3141 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_EMAD;
3142 break;
3143 default:
3144 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_RX;
3145 break;
3146 }
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003147 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
3148 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
3149 mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT);
3150}
3151
Ido Schimmel69c407a2016-07-02 11:00:13 +02003152/* RGCR - Router General Configuration Register
3153 * --------------------------------------------
3154 * The register is used for setting up the router configuration.
3155 */
3156#define MLXSW_REG_RGCR_ID 0x8001
3157#define MLXSW_REG_RGCR_LEN 0x28
3158
Jiri Pirko21978dc2016-10-21 16:07:20 +02003159MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
Ido Schimmel69c407a2016-07-02 11:00:13 +02003160
3161/* reg_rgcr_ipv4_en
3162 * IPv4 router enable.
3163 * Access: RW
3164 */
3165MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
3166
3167/* reg_rgcr_ipv6_en
3168 * IPv6 router enable.
3169 * Access: RW
3170 */
3171MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
3172
3173/* reg_rgcr_max_router_interfaces
3174 * Defines the maximum number of active router interfaces for all virtual
3175 * routers.
3176 * Access: RW
3177 */
3178MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
3179
3180/* reg_rgcr_usp
3181 * Update switch priority and packet color.
3182 * 0 - Preserve the value of Switch Priority and packet color.
3183 * 1 - Recalculate the value of Switch Priority and packet color.
3184 * Access: RW
3185 *
3186 * Note: Not supported by SwitchX and SwitchX-2.
3187 */
3188MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
3189
3190/* reg_rgcr_pcp_rw
3191 * Indicates how to handle the pcp_rewrite_en value:
3192 * 0 - Preserve the value of pcp_rewrite_en.
3193 * 2 - Disable PCP rewrite.
3194 * 3 - Enable PCP rewrite.
3195 * Access: RW
3196 *
3197 * Note: Not supported by SwitchX and SwitchX-2.
3198 */
3199MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
3200
3201/* reg_rgcr_activity_dis
3202 * Activity disable:
3203 * 0 - Activity will be set when an entry is hit (default).
3204 * 1 - Activity will not be set when an entry is hit.
3205 *
3206 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
3207 * (RALUE).
3208 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
3209 * Entry (RAUHT).
3210 * Bits 2:7 are reserved.
3211 * Access: RW
3212 *
3213 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
3214 */
3215MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
3216
3217static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en)
3218{
3219 MLXSW_REG_ZERO(rgcr, payload);
3220 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
3221}
3222
Ido Schimmel3dc26682016-07-02 11:00:18 +02003223/* RITR - Router Interface Table Register
3224 * --------------------------------------
3225 * The register is used to configure the router interface table.
3226 */
3227#define MLXSW_REG_RITR_ID 0x8002
3228#define MLXSW_REG_RITR_LEN 0x40
3229
Jiri Pirko21978dc2016-10-21 16:07:20 +02003230MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
Ido Schimmel3dc26682016-07-02 11:00:18 +02003231
3232/* reg_ritr_enable
3233 * Enables routing on the router interface.
3234 * Access: RW
3235 */
3236MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
3237
3238/* reg_ritr_ipv4
3239 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
3240 * interface.
3241 * Access: RW
3242 */
3243MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
3244
3245/* reg_ritr_ipv6
3246 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
3247 * interface.
3248 * Access: RW
3249 */
3250MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
3251
3252enum mlxsw_reg_ritr_if_type {
3253 MLXSW_REG_RITR_VLAN_IF,
3254 MLXSW_REG_RITR_FID_IF,
3255 MLXSW_REG_RITR_SP_IF,
3256};
3257
3258/* reg_ritr_type
3259 * Router interface type.
3260 * 0 - VLAN interface.
3261 * 1 - FID interface.
3262 * 2 - Sub-port interface.
3263 * Access: RW
3264 */
3265MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
3266
3267enum {
3268 MLXSW_REG_RITR_RIF_CREATE,
3269 MLXSW_REG_RITR_RIF_DEL,
3270};
3271
3272/* reg_ritr_op
3273 * Opcode:
3274 * 0 - Create or edit RIF.
3275 * 1 - Delete RIF.
3276 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
3277 * is not supported. An interface must be deleted and re-created in order
3278 * to update properties.
3279 * Access: WO
3280 */
3281MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
3282
3283/* reg_ritr_rif
3284 * Router interface index. A pointer to the Router Interface Table.
3285 * Access: Index
3286 */
3287MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
3288
3289/* reg_ritr_ipv4_fe
3290 * IPv4 Forwarding Enable.
3291 * Enables routing of IPv4 traffic on the router interface. When disabled,
3292 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
3293 * Not supported in SwitchX-2.
3294 * Access: RW
3295 */
3296MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
3297
3298/* reg_ritr_ipv6_fe
3299 * IPv6 Forwarding Enable.
3300 * Enables routing of IPv6 traffic on the router interface. When disabled,
3301 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
3302 * Not supported in SwitchX-2.
3303 * Access: RW
3304 */
3305MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
3306
Ido Schimmela94a6142016-08-17 16:39:33 +02003307/* reg_ritr_lb_en
3308 * Loop-back filter enable for unicast packets.
3309 * If the flag is set then loop-back filter for unicast packets is
3310 * implemented on the RIF. Multicast packets are always subject to
3311 * loop-back filtering.
3312 * Access: RW
3313 */
3314MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
3315
Ido Schimmel3dc26682016-07-02 11:00:18 +02003316/* reg_ritr_virtual_router
3317 * Virtual router ID associated with the router interface.
3318 * Access: RW
3319 */
3320MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
3321
3322/* reg_ritr_mtu
3323 * Router interface MTU.
3324 * Access: RW
3325 */
3326MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
3327
3328/* reg_ritr_if_swid
3329 * Switch partition ID.
3330 * Access: RW
3331 */
3332MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
3333
3334/* reg_ritr_if_mac
3335 * Router interface MAC address.
3336 * In Spectrum, all MAC addresses must have the same 38 MSBits.
3337 * Access: RW
3338 */
3339MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
3340
3341/* VLAN Interface */
3342
3343/* reg_ritr_vlan_if_vid
3344 * VLAN ID.
3345 * Access: RW
3346 */
3347MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
3348
3349/* FID Interface */
3350
3351/* reg_ritr_fid_if_fid
3352 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
3353 * the vFID range are supported.
3354 * Access: RW
3355 */
3356MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
3357
3358static inline void mlxsw_reg_ritr_fid_set(char *payload,
3359 enum mlxsw_reg_ritr_if_type rif_type,
3360 u16 fid)
3361{
3362 if (rif_type == MLXSW_REG_RITR_FID_IF)
3363 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
3364 else
3365 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
3366}
3367
3368/* Sub-port Interface */
3369
3370/* reg_ritr_sp_if_lag
3371 * LAG indication. When this bit is set the system_port field holds the
3372 * LAG identifier.
3373 * Access: RW
3374 */
3375MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
3376
3377/* reg_ritr_sp_system_port
3378 * Port unique indentifier. When lag bit is set, this field holds the
3379 * lag_id in bits 0:9.
3380 * Access: RW
3381 */
3382MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
3383
3384/* reg_ritr_sp_if_vid
3385 * VLAN ID.
3386 * Access: RW
3387 */
3388MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
3389
3390static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
3391{
3392 MLXSW_REG_ZERO(ritr, payload);
3393 mlxsw_reg_ritr_rif_set(payload, rif);
3394}
3395
3396static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
3397 u16 system_port, u16 vid)
3398{
3399 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
3400 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
3401 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
3402}
3403
3404static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
3405 enum mlxsw_reg_ritr_if_type type,
3406 u16 rif, u16 mtu, const char *mac)
3407{
3408 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
3409
3410 MLXSW_REG_ZERO(ritr, payload);
3411 mlxsw_reg_ritr_enable_set(payload, enable);
3412 mlxsw_reg_ritr_ipv4_set(payload, 1);
3413 mlxsw_reg_ritr_type_set(payload, type);
3414 mlxsw_reg_ritr_op_set(payload, op);
3415 mlxsw_reg_ritr_rif_set(payload, rif);
3416 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
Ido Schimmela94a6142016-08-17 16:39:33 +02003417 mlxsw_reg_ritr_lb_en_set(payload, 1);
Ido Schimmel3dc26682016-07-02 11:00:18 +02003418 mlxsw_reg_ritr_mtu_set(payload, mtu);
3419 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
3420}
3421
Yotam Gigi089f9812016-07-05 11:27:48 +02003422/* RATR - Router Adjacency Table Register
3423 * --------------------------------------
3424 * The RATR register is used to configure the Router Adjacency (next-hop)
3425 * Table.
3426 */
3427#define MLXSW_REG_RATR_ID 0x8008
3428#define MLXSW_REG_RATR_LEN 0x2C
3429
Jiri Pirko21978dc2016-10-21 16:07:20 +02003430MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
Yotam Gigi089f9812016-07-05 11:27:48 +02003431
3432enum mlxsw_reg_ratr_op {
3433 /* Read */
3434 MLXSW_REG_RATR_OP_QUERY_READ = 0,
3435 /* Read and clear activity */
3436 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
3437 /* Write Adjacency entry */
3438 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
3439 /* Write Adjacency entry only if the activity is cleared.
3440 * The write may not succeed if the activity is set. There is not
3441 * direct feedback if the write has succeeded or not, however
3442 * the get will reveal the actual entry (SW can compare the get
3443 * response to the set command).
3444 */
3445 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
3446};
3447
3448/* reg_ratr_op
3449 * Note that Write operation may also be used for updating
3450 * counter_set_type and counter_index. In this case all other
3451 * fields must not be updated.
3452 * Access: OP
3453 */
3454MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
3455
3456/* reg_ratr_v
3457 * Valid bit. Indicates if the adjacency entry is valid.
3458 * Note: the device may need some time before reusing an invalidated
3459 * entry. During this time the entry can not be reused. It is
3460 * recommended to use another entry before reusing an invalidated
3461 * entry (e.g. software can put it at the end of the list for
3462 * reusing). Trying to access an invalidated entry not yet cleared
3463 * by the device results with failure indicating "Try Again" status.
3464 * When valid is '0' then egress_router_interface,trap_action,
3465 * adjacency_parameters and counters are reserved
3466 * Access: RW
3467 */
3468MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
3469
3470/* reg_ratr_a
3471 * Activity. Set for new entries. Set if a packet lookup has hit on
3472 * the specific entry. To clear the a bit, use "clear activity".
3473 * Access: RO
3474 */
3475MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
3476
3477/* reg_ratr_adjacency_index_low
3478 * Bits 15:0 of index into the adjacency table.
3479 * For SwitchX and SwitchX-2, the adjacency table is linear and
3480 * used for adjacency entries only.
3481 * For Spectrum, the index is to the KVD linear.
3482 * Access: Index
3483 */
3484MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
3485
3486/* reg_ratr_egress_router_interface
3487 * Range is 0 .. cap_max_router_interfaces - 1
3488 * Access: RW
3489 */
3490MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
3491
3492enum mlxsw_reg_ratr_trap_action {
3493 MLXSW_REG_RATR_TRAP_ACTION_NOP,
3494 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
3495 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
3496 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
3497 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
3498};
3499
3500/* reg_ratr_trap_action
3501 * see mlxsw_reg_ratr_trap_action
3502 * Access: RW
3503 */
3504MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
3505
3506enum mlxsw_reg_ratr_trap_id {
3507 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0 = 0,
3508 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1 = 1,
3509};
3510
3511/* reg_ratr_adjacency_index_high
3512 * Bits 23:16 of the adjacency_index.
3513 * Access: Index
3514 */
3515MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
3516
3517/* reg_ratr_trap_id
3518 * Trap ID to be reported to CPU.
3519 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
3520 * For trap_action of NOP, MIRROR and DISCARD_ERROR
3521 * Access: RW
3522 */
3523MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
3524
3525/* reg_ratr_eth_destination_mac
3526 * MAC address of the destination next-hop.
3527 * Access: RW
3528 */
3529MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
3530
3531static inline void
3532mlxsw_reg_ratr_pack(char *payload,
3533 enum mlxsw_reg_ratr_op op, bool valid,
3534 u32 adjacency_index, u16 egress_rif)
3535{
3536 MLXSW_REG_ZERO(ratr, payload);
3537 mlxsw_reg_ratr_op_set(payload, op);
3538 mlxsw_reg_ratr_v_set(payload, valid);
3539 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
3540 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
3541 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
3542}
3543
3544static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
3545 const char *dest_mac)
3546{
3547 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
3548}
3549
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02003550/* RALTA - Router Algorithmic LPM Tree Allocation Register
3551 * -------------------------------------------------------
3552 * RALTA is used to allocate the LPM trees of the SHSPM method.
3553 */
3554#define MLXSW_REG_RALTA_ID 0x8010
3555#define MLXSW_REG_RALTA_LEN 0x04
3556
Jiri Pirko21978dc2016-10-21 16:07:20 +02003557MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02003558
3559/* reg_ralta_op
3560 * opcode (valid for Write, must be 0 on Read)
3561 * 0 - allocate a tree
3562 * 1 - deallocate a tree
3563 * Access: OP
3564 */
3565MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
3566
3567enum mlxsw_reg_ralxx_protocol {
3568 MLXSW_REG_RALXX_PROTOCOL_IPV4,
3569 MLXSW_REG_RALXX_PROTOCOL_IPV6,
3570};
3571
3572/* reg_ralta_protocol
3573 * Protocol.
3574 * Deallocation opcode: Reserved.
3575 * Access: RW
3576 */
3577MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
3578
3579/* reg_ralta_tree_id
3580 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
3581 * the tree identifier (managed by software).
3582 * Note that tree_id 0 is allocated for a default-route tree.
3583 * Access: Index
3584 */
3585MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
3586
3587static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
3588 enum mlxsw_reg_ralxx_protocol protocol,
3589 u8 tree_id)
3590{
3591 MLXSW_REG_ZERO(ralta, payload);
3592 mlxsw_reg_ralta_op_set(payload, !alloc);
3593 mlxsw_reg_ralta_protocol_set(payload, protocol);
3594 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
3595}
3596
Jiri Pirkoa9823352016-07-04 08:23:06 +02003597/* RALST - Router Algorithmic LPM Structure Tree Register
3598 * ------------------------------------------------------
3599 * RALST is used to set and query the structure of an LPM tree.
3600 * The structure of the tree must be sorted as a sorted binary tree, while
3601 * each node is a bin that is tagged as the length of the prefixes the lookup
3602 * will refer to. Therefore, bin X refers to a set of entries with prefixes
3603 * of X bits to match with the destination address. The bin 0 indicates
3604 * the default action, when there is no match of any prefix.
3605 */
3606#define MLXSW_REG_RALST_ID 0x8011
3607#define MLXSW_REG_RALST_LEN 0x104
3608
Jiri Pirko21978dc2016-10-21 16:07:20 +02003609MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
Jiri Pirkoa9823352016-07-04 08:23:06 +02003610
3611/* reg_ralst_root_bin
3612 * The bin number of the root bin.
3613 * 0<root_bin=<(length of IP address)
3614 * For a default-route tree configure 0xff
3615 * Access: RW
3616 */
3617MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
3618
3619/* reg_ralst_tree_id
3620 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
3621 * Access: Index
3622 */
3623MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
3624
3625#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
3626#define MLXSW_REG_RALST_BIN_OFFSET 0x04
3627#define MLXSW_REG_RALST_BIN_COUNT 128
3628
3629/* reg_ralst_left_child_bin
3630 * Holding the children of the bin according to the stored tree's structure.
3631 * For trees composed of less than 4 blocks, the bins in excess are reserved.
3632 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
3633 * Access: RW
3634 */
3635MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
3636
3637/* reg_ralst_right_child_bin
3638 * Holding the children of the bin according to the stored tree's structure.
3639 * For trees composed of less than 4 blocks, the bins in excess are reserved.
3640 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
3641 * Access: RW
3642 */
3643MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
3644 false);
3645
3646static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
3647{
3648 MLXSW_REG_ZERO(ralst, payload);
3649
3650 /* Initialize all bins to have no left or right child */
3651 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
3652 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
3653
3654 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
3655 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
3656}
3657
3658static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
3659 u8 left_child_bin,
3660 u8 right_child_bin)
3661{
3662 int bin_index = bin_number - 1;
3663
3664 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
3665 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
3666 right_child_bin);
3667}
3668
Jiri Pirko20ae4052016-07-04 08:23:07 +02003669/* RALTB - Router Algorithmic LPM Tree Binding Register
3670 * ----------------------------------------------------
3671 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
3672 */
3673#define MLXSW_REG_RALTB_ID 0x8012
3674#define MLXSW_REG_RALTB_LEN 0x04
3675
Jiri Pirko21978dc2016-10-21 16:07:20 +02003676MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
Jiri Pirko20ae4052016-07-04 08:23:07 +02003677
3678/* reg_raltb_virtual_router
3679 * Virtual Router ID
3680 * Range is 0..cap_max_virtual_routers-1
3681 * Access: Index
3682 */
3683MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
3684
3685/* reg_raltb_protocol
3686 * Protocol.
3687 * Access: Index
3688 */
3689MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
3690
3691/* reg_raltb_tree_id
3692 * Tree to be used for the {virtual_router, protocol}
3693 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
3694 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
3695 * Access: RW
3696 */
3697MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
3698
3699static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
3700 enum mlxsw_reg_ralxx_protocol protocol,
3701 u8 tree_id)
3702{
3703 MLXSW_REG_ZERO(raltb, payload);
3704 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
3705 mlxsw_reg_raltb_protocol_set(payload, protocol);
3706 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
3707}
3708
Jiri Pirkod5a1c742016-07-04 08:23:10 +02003709/* RALUE - Router Algorithmic LPM Unicast Entry Register
3710 * -----------------------------------------------------
3711 * RALUE is used to configure and query LPM entries that serve
3712 * the Unicast protocols.
3713 */
3714#define MLXSW_REG_RALUE_ID 0x8013
3715#define MLXSW_REG_RALUE_LEN 0x38
3716
Jiri Pirko21978dc2016-10-21 16:07:20 +02003717MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02003718
3719/* reg_ralue_protocol
3720 * Protocol.
3721 * Access: Index
3722 */
3723MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
3724
3725enum mlxsw_reg_ralue_op {
3726 /* Read operation. If entry doesn't exist, the operation fails. */
3727 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
3728 /* Clear on read operation. Used to read entry and
3729 * clear Activity bit.
3730 */
3731 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
3732 /* Write operation. Used to write a new entry to the table. All RW
3733 * fields are written for new entry. Activity bit is set
3734 * for new entries.
3735 */
3736 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
3737 /* Update operation. Used to update an existing route entry and
3738 * only update the RW fields that are detailed in the field
3739 * op_u_mask. If entry doesn't exist, the operation fails.
3740 */
3741 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
3742 /* Clear activity. The Activity bit (the field a) is cleared
3743 * for the entry.
3744 */
3745 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
3746 /* Delete operation. Used to delete an existing entry. If entry
3747 * doesn't exist, the operation fails.
3748 */
3749 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
3750};
3751
3752/* reg_ralue_op
3753 * Operation.
3754 * Access: OP
3755 */
3756MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
3757
3758/* reg_ralue_a
3759 * Activity. Set for new entries. Set if a packet lookup has hit on the
3760 * specific entry, only if the entry is a route. To clear the a bit, use
3761 * "clear activity" op.
3762 * Enabled by activity_dis in RGCR
3763 * Access: RO
3764 */
3765MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
3766
3767/* reg_ralue_virtual_router
3768 * Virtual Router ID
3769 * Range is 0..cap_max_virtual_routers-1
3770 * Access: Index
3771 */
3772MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
3773
3774#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
3775#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
3776#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
3777
3778/* reg_ralue_op_u_mask
3779 * opcode update mask.
3780 * On read operation, this field is reserved.
3781 * This field is valid for update opcode, otherwise - reserved.
3782 * This field is a bitmask of the fields that should be updated.
3783 * Access: WO
3784 */
3785MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
3786
3787/* reg_ralue_prefix_len
3788 * Number of bits in the prefix of the LPM route.
3789 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
3790 * two entries in the physical HW table.
3791 * Access: Index
3792 */
3793MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
3794
3795/* reg_ralue_dip*
3796 * The prefix of the route or of the marker that the object of the LPM
3797 * is compared with. The most significant bits of the dip are the prefix.
3798 * The list significant bits must be '0' if the prefix_len is smaller
3799 * than 128 for IPv6 or smaller than 32 for IPv4.
3800 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
3801 * Access: Index
3802 */
3803MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
3804
3805enum mlxsw_reg_ralue_entry_type {
3806 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
3807 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
3808 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
3809};
3810
3811/* reg_ralue_entry_type
3812 * Entry type.
3813 * Note - for Marker entries, the action_type and action fields are reserved.
3814 * Access: RW
3815 */
3816MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
3817
3818/* reg_ralue_bmp_len
3819 * The best match prefix length in the case that there is no match for
3820 * longer prefixes.
3821 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
3822 * Note for any update operation with entry_type modification this
3823 * field must be set.
3824 * Access: RW
3825 */
3826MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
3827
3828enum mlxsw_reg_ralue_action_type {
3829 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
3830 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
3831 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
3832};
3833
3834/* reg_ralue_action_type
3835 * Action Type
3836 * Indicates how the IP address is connected.
3837 * It can be connected to a local subnet through local_erif or can be
3838 * on a remote subnet connected through a next-hop router,
3839 * or transmitted to the CPU.
3840 * Reserved when entry_type = MARKER_ENTRY
3841 * Access: RW
3842 */
3843MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
3844
3845enum mlxsw_reg_ralue_trap_action {
3846 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
3847 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
3848 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
3849 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
3850 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
3851};
3852
3853/* reg_ralue_trap_action
3854 * Trap action.
3855 * For IP2ME action, only NOP and MIRROR are possible.
3856 * Access: RW
3857 */
3858MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
3859
3860/* reg_ralue_trap_id
3861 * Trap ID to be reported to CPU.
3862 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
3863 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
3864 * Access: RW
3865 */
3866MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
3867
3868/* reg_ralue_adjacency_index
3869 * Points to the first entry of the group-based ECMP.
3870 * Only relevant in case of REMOTE action.
3871 * Access: RW
3872 */
3873MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
3874
3875/* reg_ralue_ecmp_size
3876 * Amount of sequential entries starting
3877 * from the adjacency_index (the number of ECMPs).
3878 * The valid range is 1-64, 512, 1024, 2048 and 4096.
3879 * Reserved when trap_action is TRAP or DISCARD_ERROR.
3880 * Only relevant in case of REMOTE action.
3881 * Access: RW
3882 */
3883MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
3884
3885/* reg_ralue_local_erif
3886 * Egress Router Interface.
3887 * Only relevant in case of LOCAL action.
3888 * Access: RW
3889 */
3890MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
3891
3892/* reg_ralue_v
3893 * Valid bit for the tunnel_ptr field.
3894 * If valid = 0 then trap to CPU as IP2ME trap ID.
3895 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
3896 * decapsulation then tunnel decapsulation is done.
3897 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
3898 * decapsulation then trap as IP2ME trap ID.
3899 * Only relevant in case of IP2ME action.
3900 * Access: RW
3901 */
3902MLXSW_ITEM32(reg, ralue, v, 0x24, 31, 1);
3903
3904/* reg_ralue_tunnel_ptr
3905 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
3906 * For Spectrum, pointer to KVD Linear.
3907 * Only relevant in case of IP2ME action.
3908 * Access: RW
3909 */
3910MLXSW_ITEM32(reg, ralue, tunnel_ptr, 0x24, 0, 24);
3911
3912static inline void mlxsw_reg_ralue_pack(char *payload,
3913 enum mlxsw_reg_ralxx_protocol protocol,
3914 enum mlxsw_reg_ralue_op op,
3915 u16 virtual_router, u8 prefix_len)
3916{
3917 MLXSW_REG_ZERO(ralue, payload);
3918 mlxsw_reg_ralue_protocol_set(payload, protocol);
Jiri Pirko0e7df1a2016-08-17 16:39:34 +02003919 mlxsw_reg_ralue_op_set(payload, op);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02003920 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
3921 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
3922 mlxsw_reg_ralue_entry_type_set(payload,
3923 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
3924 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
3925}
3926
3927static inline void mlxsw_reg_ralue_pack4(char *payload,
3928 enum mlxsw_reg_ralxx_protocol protocol,
3929 enum mlxsw_reg_ralue_op op,
3930 u16 virtual_router, u8 prefix_len,
3931 u32 dip)
3932{
3933 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
3934 mlxsw_reg_ralue_dip4_set(payload, dip);
3935}
3936
3937static inline void
3938mlxsw_reg_ralue_act_remote_pack(char *payload,
3939 enum mlxsw_reg_ralue_trap_action trap_action,
3940 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
3941{
3942 mlxsw_reg_ralue_action_type_set(payload,
3943 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
3944 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
3945 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
3946 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
3947 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
3948}
3949
3950static inline void
3951mlxsw_reg_ralue_act_local_pack(char *payload,
3952 enum mlxsw_reg_ralue_trap_action trap_action,
3953 u16 trap_id, u16 local_erif)
3954{
3955 mlxsw_reg_ralue_action_type_set(payload,
3956 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
3957 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
3958 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
3959 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
3960}
3961
3962static inline void
3963mlxsw_reg_ralue_act_ip2me_pack(char *payload)
3964{
3965 mlxsw_reg_ralue_action_type_set(payload,
3966 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
3967}
3968
Yotam Gigi4457b3df2016-07-05 11:27:40 +02003969/* RAUHT - Router Algorithmic LPM Unicast Host Table Register
3970 * ----------------------------------------------------------
3971 * The RAUHT register is used to configure and query the Unicast Host table in
3972 * devices that implement the Algorithmic LPM.
3973 */
3974#define MLXSW_REG_RAUHT_ID 0x8014
3975#define MLXSW_REG_RAUHT_LEN 0x74
3976
Jiri Pirko21978dc2016-10-21 16:07:20 +02003977MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02003978
3979enum mlxsw_reg_rauht_type {
3980 MLXSW_REG_RAUHT_TYPE_IPV4,
3981 MLXSW_REG_RAUHT_TYPE_IPV6,
3982};
3983
3984/* reg_rauht_type
3985 * Access: Index
3986 */
3987MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
3988
3989enum mlxsw_reg_rauht_op {
3990 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
3991 /* Read operation */
3992 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
3993 /* Clear on read operation. Used to read entry and clear
3994 * activity bit.
3995 */
3996 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
3997 /* Add. Used to write a new entry to the table. All R/W fields are
3998 * relevant for new entry. Activity bit is set for new entries.
3999 */
4000 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
4001 /* Update action. Used to update an existing route entry and
4002 * only update the following fields:
4003 * trap_action, trap_id, mac, counter_set_type, counter_index
4004 */
4005 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
4006 /* Clear activity. A bit is cleared for the entry. */
4007 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
4008 /* Delete entry */
4009 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
4010 /* Delete all host entries on a RIF. In this command, dip
4011 * field is reserved.
4012 */
4013};
4014
4015/* reg_rauht_op
4016 * Access: OP
4017 */
4018MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
4019
4020/* reg_rauht_a
4021 * Activity. Set for new entries. Set if a packet lookup has hit on
4022 * the specific entry.
4023 * To clear the a bit, use "clear activity" op.
4024 * Enabled by activity_dis in RGCR
4025 * Access: RO
4026 */
4027MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
4028
4029/* reg_rauht_rif
4030 * Router Interface
4031 * Access: Index
4032 */
4033MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
4034
4035/* reg_rauht_dip*
4036 * Destination address.
4037 * Access: Index
4038 */
4039MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
4040
4041enum mlxsw_reg_rauht_trap_action {
4042 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
4043 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
4044 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
4045 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
4046 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
4047};
4048
4049/* reg_rauht_trap_action
4050 * Access: RW
4051 */
4052MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
4053
4054enum mlxsw_reg_rauht_trap_id {
4055 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
4056 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
4057};
4058
4059/* reg_rauht_trap_id
4060 * Trap ID to be reported to CPU.
4061 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
4062 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
4063 * trap_id is reserved.
4064 * Access: RW
4065 */
4066MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
4067
4068/* reg_rauht_counter_set_type
4069 * Counter set type for flow counters
4070 * Access: RW
4071 */
4072MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
4073
4074/* reg_rauht_counter_index
4075 * Counter index for flow counters
4076 * Access: RW
4077 */
4078MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
4079
4080/* reg_rauht_mac
4081 * MAC address.
4082 * Access: RW
4083 */
4084MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
4085
4086static inline void mlxsw_reg_rauht_pack(char *payload,
4087 enum mlxsw_reg_rauht_op op, u16 rif,
4088 const char *mac)
4089{
4090 MLXSW_REG_ZERO(rauht, payload);
4091 mlxsw_reg_rauht_op_set(payload, op);
4092 mlxsw_reg_rauht_rif_set(payload, rif);
4093 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
4094}
4095
4096static inline void mlxsw_reg_rauht_pack4(char *payload,
4097 enum mlxsw_reg_rauht_op op, u16 rif,
4098 const char *mac, u32 dip)
4099{
4100 mlxsw_reg_rauht_pack(payload, op, rif, mac);
4101 mlxsw_reg_rauht_dip4_set(payload, dip);
4102}
4103
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02004104/* RALEU - Router Algorithmic LPM ECMP Update Register
4105 * ---------------------------------------------------
4106 * The register enables updating the ECMP section in the action for multiple
4107 * LPM Unicast entries in a single operation. The update is executed to
4108 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
4109 */
4110#define MLXSW_REG_RALEU_ID 0x8015
4111#define MLXSW_REG_RALEU_LEN 0x28
4112
Jiri Pirko21978dc2016-10-21 16:07:20 +02004113MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02004114
4115/* reg_raleu_protocol
4116 * Protocol.
4117 * Access: Index
4118 */
4119MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
4120
4121/* reg_raleu_virtual_router
4122 * Virtual Router ID
4123 * Range is 0..cap_max_virtual_routers-1
4124 * Access: Index
4125 */
4126MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
4127
4128/* reg_raleu_adjacency_index
4129 * Adjacency Index used for matching on the existing entries.
4130 * Access: Index
4131 */
4132MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
4133
4134/* reg_raleu_ecmp_size
4135 * ECMP Size used for matching on the existing entries.
4136 * Access: Index
4137 */
4138MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
4139
4140/* reg_raleu_new_adjacency_index
4141 * New Adjacency Index.
4142 * Access: WO
4143 */
4144MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
4145
4146/* reg_raleu_new_ecmp_size
4147 * New ECMP Size.
4148 * Access: WO
4149 */
4150MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
4151
4152static inline void mlxsw_reg_raleu_pack(char *payload,
4153 enum mlxsw_reg_ralxx_protocol protocol,
4154 u16 virtual_router,
4155 u32 adjacency_index, u16 ecmp_size,
4156 u32 new_adjacency_index,
4157 u16 new_ecmp_size)
4158{
4159 MLXSW_REG_ZERO(raleu, payload);
4160 mlxsw_reg_raleu_protocol_set(payload, protocol);
4161 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
4162 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
4163 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
4164 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
4165 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
4166}
4167
Yotam Gigi7cf2c202016-07-05 11:27:41 +02004168/* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
4169 * ----------------------------------------------------------------
4170 * The RAUHTD register allows dumping entries from the Router Unicast Host
4171 * Table. For a given session an entry is dumped no more than one time. The
4172 * first RAUHTD access after reset is a new session. A session ends when the
4173 * num_rec response is smaller than num_rec request or for IPv4 when the
4174 * num_entries is smaller than 4. The clear activity affect the current session
4175 * or the last session if a new session has not started.
4176 */
4177#define MLXSW_REG_RAUHTD_ID 0x8018
4178#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
4179#define MLXSW_REG_RAUHTD_REC_LEN 0x20
4180#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
4181#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
4182 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
4183#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
4184
Jiri Pirko21978dc2016-10-21 16:07:20 +02004185MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
Yotam Gigi7cf2c202016-07-05 11:27:41 +02004186
4187#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
4188#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
4189
4190/* reg_rauhtd_filter_fields
4191 * if a bit is '0' then the relevant field is ignored and dump is done
4192 * regardless of the field value
4193 * Bit0 - filter by activity: entry_a
4194 * Bit3 - filter by entry rip: entry_rif
4195 * Access: Index
4196 */
4197MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
4198
4199enum mlxsw_reg_rauhtd_op {
4200 MLXSW_REG_RAUHTD_OP_DUMP,
4201 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
4202};
4203
4204/* reg_rauhtd_op
4205 * Access: OP
4206 */
4207MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
4208
4209/* reg_rauhtd_num_rec
4210 * At request: number of records requested
4211 * At response: number of records dumped
4212 * For IPv4, each record has 4 entries at request and up to 4 entries
4213 * at response
4214 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
4215 * Access: Index
4216 */
4217MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
4218
4219/* reg_rauhtd_entry_a
4220 * Dump only if activity has value of entry_a
4221 * Reserved if filter_fields bit0 is '0'
4222 * Access: Index
4223 */
4224MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
4225
4226enum mlxsw_reg_rauhtd_type {
4227 MLXSW_REG_RAUHTD_TYPE_IPV4,
4228 MLXSW_REG_RAUHTD_TYPE_IPV6,
4229};
4230
4231/* reg_rauhtd_type
4232 * Dump only if record type is:
4233 * 0 - IPv4
4234 * 1 - IPv6
4235 * Access: Index
4236 */
4237MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
4238
4239/* reg_rauhtd_entry_rif
4240 * Dump only if RIF has value of entry_rif
4241 * Reserved if filter_fields bit3 is '0'
4242 * Access: Index
4243 */
4244MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
4245
4246static inline void mlxsw_reg_rauhtd_pack(char *payload,
4247 enum mlxsw_reg_rauhtd_type type)
4248{
4249 MLXSW_REG_ZERO(rauhtd, payload);
4250 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
4251 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
4252 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
4253 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
4254 mlxsw_reg_rauhtd_type_set(payload, type);
4255}
4256
4257/* reg_rauhtd_ipv4_rec_num_entries
4258 * Number of valid entries in this record:
4259 * 0 - 1 valid entry
4260 * 1 - 2 valid entries
4261 * 2 - 3 valid entries
4262 * 3 - 4 valid entries
4263 * Access: RO
4264 */
4265MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
4266 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
4267 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
4268
4269/* reg_rauhtd_rec_type
4270 * Record type.
4271 * 0 - IPv4
4272 * 1 - IPv6
4273 * Access: RO
4274 */
4275MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
4276 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
4277
4278#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
4279
4280/* reg_rauhtd_ipv4_ent_a
4281 * Activity. Set for new entries. Set if a packet lookup has hit on the
4282 * specific entry.
4283 * Access: RO
4284 */
4285MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
4286 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
4287
4288/* reg_rauhtd_ipv4_ent_rif
4289 * Router interface.
4290 * Access: RO
4291 */
4292MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
4293 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
4294
4295/* reg_rauhtd_ipv4_ent_dip
4296 * Destination IPv4 address.
4297 * Access: RO
4298 */
4299MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
4300 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
4301
4302static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
4303 int ent_index, u16 *p_rif,
4304 u32 *p_dip)
4305{
4306 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
4307 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
4308}
4309
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004310/* MFCR - Management Fan Control Register
4311 * --------------------------------------
4312 * This register controls the settings of the Fan Speed PWM mechanism.
4313 */
4314#define MLXSW_REG_MFCR_ID 0x9001
4315#define MLXSW_REG_MFCR_LEN 0x08
4316
Jiri Pirko21978dc2016-10-21 16:07:20 +02004317MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004318
4319enum mlxsw_reg_mfcr_pwm_frequency {
4320 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
4321 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
4322 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
4323 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
4324 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
4325 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
4326 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
4327 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
4328};
4329
4330/* reg_mfcr_pwm_frequency
4331 * Controls the frequency of the PWM signal.
4332 * Access: RW
4333 */
4334MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 6);
4335
4336#define MLXSW_MFCR_TACHOS_MAX 10
4337
4338/* reg_mfcr_tacho_active
4339 * Indicates which of the tachometer is active (bit per tachometer).
4340 * Access: RO
4341 */
4342MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
4343
4344#define MLXSW_MFCR_PWMS_MAX 5
4345
4346/* reg_mfcr_pwm_active
4347 * Indicates which of the PWM control is active (bit per PWM).
4348 * Access: RO
4349 */
4350MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
4351
4352static inline void
4353mlxsw_reg_mfcr_pack(char *payload,
4354 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
4355{
4356 MLXSW_REG_ZERO(mfcr, payload);
4357 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
4358}
4359
4360static inline void
4361mlxsw_reg_mfcr_unpack(char *payload,
4362 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
4363 u16 *p_tacho_active, u8 *p_pwm_active)
4364{
4365 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
4366 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
4367 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
4368}
4369
4370/* MFSC - Management Fan Speed Control Register
4371 * --------------------------------------------
4372 * This register controls the settings of the Fan Speed PWM mechanism.
4373 */
4374#define MLXSW_REG_MFSC_ID 0x9002
4375#define MLXSW_REG_MFSC_LEN 0x08
4376
Jiri Pirko21978dc2016-10-21 16:07:20 +02004377MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004378
4379/* reg_mfsc_pwm
4380 * Fan pwm to control / monitor.
4381 * Access: Index
4382 */
4383MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
4384
4385/* reg_mfsc_pwm_duty_cycle
4386 * Controls the duty cycle of the PWM. Value range from 0..255 to
4387 * represent duty cycle of 0%...100%.
4388 * Access: RW
4389 */
4390MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
4391
4392static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
4393 u8 pwm_duty_cycle)
4394{
4395 MLXSW_REG_ZERO(mfsc, payload);
4396 mlxsw_reg_mfsc_pwm_set(payload, pwm);
4397 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
4398}
4399
4400/* MFSM - Management Fan Speed Measurement
4401 * ---------------------------------------
4402 * This register controls the settings of the Tacho measurements and
4403 * enables reading the Tachometer measurements.
4404 */
4405#define MLXSW_REG_MFSM_ID 0x9003
4406#define MLXSW_REG_MFSM_LEN 0x08
4407
Jiri Pirko21978dc2016-10-21 16:07:20 +02004408MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01004409
4410/* reg_mfsm_tacho
4411 * Fan tachometer index.
4412 * Access: Index
4413 */
4414MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
4415
4416/* reg_mfsm_rpm
4417 * Fan speed (round per minute).
4418 * Access: RO
4419 */
4420MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
4421
4422static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
4423{
4424 MLXSW_REG_ZERO(mfsm, payload);
4425 mlxsw_reg_mfsm_tacho_set(payload, tacho);
4426}
4427
Jiri Pirko85926f82015-11-27 13:45:56 +01004428/* MTCAP - Management Temperature Capabilities
4429 * -------------------------------------------
4430 * This register exposes the capabilities of the device and
4431 * system temperature sensing.
4432 */
4433#define MLXSW_REG_MTCAP_ID 0x9009
4434#define MLXSW_REG_MTCAP_LEN 0x08
4435
Jiri Pirko21978dc2016-10-21 16:07:20 +02004436MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01004437
4438/* reg_mtcap_sensor_count
4439 * Number of sensors supported by the device.
4440 * This includes the QSFP module sensors (if exists in the QSFP module).
4441 * Access: RO
4442 */
4443MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
4444
4445/* MTMP - Management Temperature
4446 * -----------------------------
4447 * This register controls the settings of the temperature measurements
4448 * and enables reading the temperature measurements. Note that temperature
4449 * is in 0.125 degrees Celsius.
4450 */
4451#define MLXSW_REG_MTMP_ID 0x900A
4452#define MLXSW_REG_MTMP_LEN 0x20
4453
Jiri Pirko21978dc2016-10-21 16:07:20 +02004454MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01004455
4456/* reg_mtmp_sensor_index
4457 * Sensors index to access.
4458 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
4459 * (module 0 is mapped to sensor_index 64).
4460 * Access: Index
4461 */
4462MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
4463
4464/* Convert to milli degrees Celsius */
4465#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
4466
4467/* reg_mtmp_temperature
4468 * Temperature reading from the sensor. Reading is in 0.125 Celsius
4469 * degrees units.
4470 * Access: RO
4471 */
4472MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
4473
4474/* reg_mtmp_mte
4475 * Max Temperature Enable - enables measuring the max temperature on a sensor.
4476 * Access: RW
4477 */
4478MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
4479
4480/* reg_mtmp_mtr
4481 * Max Temperature Reset - clears the value of the max temperature register.
4482 * Access: WO
4483 */
4484MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
4485
4486/* reg_mtmp_max_temperature
4487 * The highest measured temperature from the sensor.
4488 * When the bit mte is cleared, the field max_temperature is reserved.
4489 * Access: RO
4490 */
4491MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
4492
4493#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
4494
4495/* reg_mtmp_sensor_name
4496 * Sensor Name
4497 * Access: RO
4498 */
4499MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
4500
4501static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
4502 bool max_temp_enable,
4503 bool max_temp_reset)
4504{
4505 MLXSW_REG_ZERO(mtmp, payload);
4506 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
4507 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
4508 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
4509}
4510
4511static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
4512 unsigned int *p_max_temp,
4513 char *sensor_name)
4514{
4515 u16 temp;
4516
4517 if (p_temp) {
4518 temp = mlxsw_reg_mtmp_temperature_get(payload);
4519 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
4520 }
4521 if (p_max_temp) {
Jiri Pirkoacf35a42015-12-11 16:10:39 +01004522 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
Jiri Pirko85926f82015-11-27 13:45:56 +01004523 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
4524 }
4525 if (sensor_name)
4526 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
4527}
4528
Yotam Gigi43a46852016-07-21 12:03:14 +02004529/* MPAT - Monitoring Port Analyzer Table
4530 * -------------------------------------
4531 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
4532 * For an enabled analyzer, all fields except e (enable) cannot be modified.
4533 */
4534#define MLXSW_REG_MPAT_ID 0x901A
4535#define MLXSW_REG_MPAT_LEN 0x78
4536
Jiri Pirko21978dc2016-10-21 16:07:20 +02004537MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
Yotam Gigi43a46852016-07-21 12:03:14 +02004538
4539/* reg_mpat_pa_id
4540 * Port Analyzer ID.
4541 * Access: Index
4542 */
4543MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
4544
4545/* reg_mpat_system_port
4546 * A unique port identifier for the final destination of the packet.
4547 * Access: RW
4548 */
4549MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
4550
4551/* reg_mpat_e
4552 * Enable. Indicating the Port Analyzer is enabled.
4553 * Access: RW
4554 */
4555MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
4556
4557/* reg_mpat_qos
4558 * Quality Of Service Mode.
4559 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
4560 * PCP, DEI, DSCP or VL) are configured.
4561 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
4562 * same as in the original packet that has triggered the mirroring. For
4563 * SPAN also the pcp,dei are maintained.
4564 * Access: RW
4565 */
4566MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
4567
Yotam Gigi23019052016-07-21 12:03:15 +02004568/* reg_mpat_be
4569 * Best effort mode. Indicates mirroring traffic should not cause packet
4570 * drop or back pressure, but will discard the mirrored packets. Mirrored
4571 * packets will be forwarded on a best effort manner.
4572 * 0: Do not discard mirrored packets
4573 * 1: Discard mirrored packets if causing congestion
4574 * Access: RW
4575 */
4576MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
4577
Yotam Gigi43a46852016-07-21 12:03:14 +02004578static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
4579 u16 system_port, bool e)
4580{
4581 MLXSW_REG_ZERO(mpat, payload);
4582 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
4583 mlxsw_reg_mpat_system_port_set(payload, system_port);
4584 mlxsw_reg_mpat_e_set(payload, e);
4585 mlxsw_reg_mpat_qos_set(payload, 1);
Yotam Gigi23019052016-07-21 12:03:15 +02004586 mlxsw_reg_mpat_be_set(payload, 1);
4587}
4588
4589/* MPAR - Monitoring Port Analyzer Register
4590 * ----------------------------------------
4591 * MPAR register is used to query and configure the port analyzer port mirroring
4592 * properties.
4593 */
4594#define MLXSW_REG_MPAR_ID 0x901B
4595#define MLXSW_REG_MPAR_LEN 0x08
4596
Jiri Pirko21978dc2016-10-21 16:07:20 +02004597MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
Yotam Gigi23019052016-07-21 12:03:15 +02004598
4599/* reg_mpar_local_port
4600 * The local port to mirror the packets from.
4601 * Access: Index
4602 */
4603MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
4604
4605enum mlxsw_reg_mpar_i_e {
4606 MLXSW_REG_MPAR_TYPE_EGRESS,
4607 MLXSW_REG_MPAR_TYPE_INGRESS,
4608};
4609
4610/* reg_mpar_i_e
4611 * Ingress/Egress
4612 * Access: Index
4613 */
4614MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
4615
4616/* reg_mpar_enable
4617 * Enable mirroring
4618 * By default, port mirroring is disabled for all ports.
4619 * Access: RW
4620 */
4621MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
4622
4623/* reg_mpar_pa_id
4624 * Port Analyzer ID.
4625 * Access: RW
4626 */
4627MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
4628
4629static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
4630 enum mlxsw_reg_mpar_i_e i_e,
4631 bool enable, u8 pa_id)
4632{
4633 MLXSW_REG_ZERO(mpar, payload);
4634 mlxsw_reg_mpar_local_port_set(payload, local_port);
4635 mlxsw_reg_mpar_enable_set(payload, enable);
4636 mlxsw_reg_mpar_i_e_set(payload, i_e);
4637 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
Yotam Gigi43a46852016-07-21 12:03:14 +02004638}
4639
Ido Schimmel3161c152015-11-27 13:45:54 +01004640/* MLCR - Management LED Control Register
4641 * --------------------------------------
4642 * Controls the system LEDs.
4643 */
4644#define MLXSW_REG_MLCR_ID 0x902B
4645#define MLXSW_REG_MLCR_LEN 0x0C
4646
Jiri Pirko21978dc2016-10-21 16:07:20 +02004647MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
Ido Schimmel3161c152015-11-27 13:45:54 +01004648
4649/* reg_mlcr_local_port
4650 * Local port number.
4651 * Access: RW
4652 */
4653MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
4654
4655#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
4656
4657/* reg_mlcr_beacon_duration
4658 * Duration of the beacon to be active, in seconds.
4659 * 0x0 - Will turn off the beacon.
4660 * 0xFFFF - Will turn on the beacon until explicitly turned off.
4661 * Access: RW
4662 */
4663MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
4664
4665/* reg_mlcr_beacon_remain
4666 * Remaining duration of the beacon, in seconds.
4667 * 0xFFFF indicates an infinite amount of time.
4668 * Access: RO
4669 */
4670MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
4671
4672static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
4673 bool active)
4674{
4675 MLXSW_REG_ZERO(mlcr, payload);
4676 mlxsw_reg_mlcr_local_port_set(payload, local_port);
4677 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
4678 MLXSW_REG_MLCR_DURATION_MAX : 0);
4679}
4680
Jiri Pirkoe0594362015-10-16 14:01:31 +02004681/* SBPR - Shared Buffer Pools Register
4682 * -----------------------------------
4683 * The SBPR configures and retrieves the shared buffer pools and configuration.
4684 */
4685#define MLXSW_REG_SBPR_ID 0xB001
4686#define MLXSW_REG_SBPR_LEN 0x14
4687
Jiri Pirko21978dc2016-10-21 16:07:20 +02004688MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004689
Jiri Pirko497e8592016-04-08 19:11:24 +02004690/* shared direstion enum for SBPR, SBCM, SBPM */
4691enum mlxsw_reg_sbxx_dir {
4692 MLXSW_REG_SBXX_DIR_INGRESS,
4693 MLXSW_REG_SBXX_DIR_EGRESS,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004694};
4695
4696/* reg_sbpr_dir
4697 * Direction.
4698 * Access: Index
4699 */
4700MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
4701
4702/* reg_sbpr_pool
4703 * Pool index.
4704 * Access: Index
4705 */
4706MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
4707
4708/* reg_sbpr_size
4709 * Pool size in buffer cells.
4710 * Access: RW
4711 */
4712MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
4713
4714enum mlxsw_reg_sbpr_mode {
4715 MLXSW_REG_SBPR_MODE_STATIC,
4716 MLXSW_REG_SBPR_MODE_DYNAMIC,
4717};
4718
4719/* reg_sbpr_mode
4720 * Pool quota calculation mode.
4721 * Access: RW
4722 */
4723MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
4724
4725static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
Jiri Pirko497e8592016-04-08 19:11:24 +02004726 enum mlxsw_reg_sbxx_dir dir,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004727 enum mlxsw_reg_sbpr_mode mode, u32 size)
4728{
4729 MLXSW_REG_ZERO(sbpr, payload);
4730 mlxsw_reg_sbpr_pool_set(payload, pool);
4731 mlxsw_reg_sbpr_dir_set(payload, dir);
4732 mlxsw_reg_sbpr_mode_set(payload, mode);
4733 mlxsw_reg_sbpr_size_set(payload, size);
4734}
4735
4736/* SBCM - Shared Buffer Class Management Register
4737 * ----------------------------------------------
4738 * The SBCM register configures and retrieves the shared buffer allocation
4739 * and configuration according to Port-PG, including the binding to pool
4740 * and definition of the associated quota.
4741 */
4742#define MLXSW_REG_SBCM_ID 0xB002
4743#define MLXSW_REG_SBCM_LEN 0x28
4744
Jiri Pirko21978dc2016-10-21 16:07:20 +02004745MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004746
4747/* reg_sbcm_local_port
4748 * Local port number.
4749 * For Ingress: excludes CPU port and Router port
4750 * For Egress: excludes IP Router
4751 * Access: Index
4752 */
4753MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
4754
4755/* reg_sbcm_pg_buff
4756 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
4757 * For PG buffer: range is 0..cap_max_pg_buffers - 1
4758 * For traffic class: range is 0..cap_max_tclass - 1
4759 * Note that when traffic class is in MC aware mode then the traffic
4760 * classes which are MC aware cannot be configured.
4761 * Access: Index
4762 */
4763MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
4764
Jiri Pirkoe0594362015-10-16 14:01:31 +02004765/* reg_sbcm_dir
4766 * Direction.
4767 * Access: Index
4768 */
4769MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
4770
4771/* reg_sbcm_min_buff
4772 * Minimum buffer size for the limiter, in cells.
4773 * Access: RW
4774 */
4775MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
4776
Jiri Pirkoc30a53c2016-04-14 18:19:22 +02004777/* shared max_buff limits for dynamic threshold for SBCM, SBPM */
4778#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
4779#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
4780
Jiri Pirkoe0594362015-10-16 14:01:31 +02004781/* reg_sbcm_max_buff
4782 * When the pool associated to the port-pg/tclass is configured to
4783 * static, Maximum buffer size for the limiter configured in cells.
4784 * When the pool associated to the port-pg/tclass is configured to
4785 * dynamic, the max_buff holds the "alpha" parameter, supporting
4786 * the following values:
4787 * 0: 0
4788 * i: (1/128)*2^(i-1), for i=1..14
4789 * 0xFF: Infinity
4790 * Access: RW
4791 */
4792MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
4793
4794/* reg_sbcm_pool
4795 * Association of the port-priority to a pool.
4796 * Access: RW
4797 */
4798MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
4799
4800static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
Jiri Pirko497e8592016-04-08 19:11:24 +02004801 enum mlxsw_reg_sbxx_dir dir,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004802 u32 min_buff, u32 max_buff, u8 pool)
4803{
4804 MLXSW_REG_ZERO(sbcm, payload);
4805 mlxsw_reg_sbcm_local_port_set(payload, local_port);
4806 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
4807 mlxsw_reg_sbcm_dir_set(payload, dir);
4808 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
4809 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
4810 mlxsw_reg_sbcm_pool_set(payload, pool);
4811}
4812
Jiri Pirko9efc8f62016-04-08 19:11:25 +02004813/* SBPM - Shared Buffer Port Management Register
4814 * ---------------------------------------------
Jiri Pirkoe0594362015-10-16 14:01:31 +02004815 * The SBPM register configures and retrieves the shared buffer allocation
4816 * and configuration according to Port-Pool, including the definition
4817 * of the associated quota.
4818 */
4819#define MLXSW_REG_SBPM_ID 0xB003
4820#define MLXSW_REG_SBPM_LEN 0x28
4821
Jiri Pirko21978dc2016-10-21 16:07:20 +02004822MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004823
4824/* reg_sbpm_local_port
4825 * Local port number.
4826 * For Ingress: excludes CPU port and Router port
4827 * For Egress: excludes IP Router
4828 * Access: Index
4829 */
4830MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
4831
4832/* reg_sbpm_pool
4833 * The pool associated to quota counting on the local_port.
4834 * Access: Index
4835 */
4836MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
4837
Jiri Pirkoe0594362015-10-16 14:01:31 +02004838/* reg_sbpm_dir
4839 * Direction.
4840 * Access: Index
4841 */
4842MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
4843
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02004844/* reg_sbpm_buff_occupancy
4845 * Current buffer occupancy in cells.
4846 * Access: RO
4847 */
4848MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
4849
4850/* reg_sbpm_clr
4851 * Clear Max Buffer Occupancy
4852 * When this bit is set, max_buff_occupancy field is cleared (and a
4853 * new max value is tracked from the time the clear was performed).
4854 * Access: OP
4855 */
4856MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
4857
4858/* reg_sbpm_max_buff_occupancy
4859 * Maximum value of buffer occupancy in cells monitored. Cleared by
4860 * writing to the clr field.
4861 * Access: RO
4862 */
4863MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
4864
Jiri Pirkoe0594362015-10-16 14:01:31 +02004865/* reg_sbpm_min_buff
4866 * Minimum buffer size for the limiter, in cells.
4867 * Access: RW
4868 */
4869MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
4870
4871/* reg_sbpm_max_buff
4872 * When the pool associated to the port-pg/tclass is configured to
4873 * static, Maximum buffer size for the limiter configured in cells.
4874 * When the pool associated to the port-pg/tclass is configured to
4875 * dynamic, the max_buff holds the "alpha" parameter, supporting
4876 * the following values:
4877 * 0: 0
4878 * i: (1/128)*2^(i-1), for i=1..14
4879 * 0xFF: Infinity
4880 * Access: RW
4881 */
4882MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
4883
4884static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02004885 enum mlxsw_reg_sbxx_dir dir, bool clr,
Jiri Pirkoe0594362015-10-16 14:01:31 +02004886 u32 min_buff, u32 max_buff)
4887{
4888 MLXSW_REG_ZERO(sbpm, payload);
4889 mlxsw_reg_sbpm_local_port_set(payload, local_port);
4890 mlxsw_reg_sbpm_pool_set(payload, pool);
4891 mlxsw_reg_sbpm_dir_set(payload, dir);
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02004892 mlxsw_reg_sbpm_clr_set(payload, clr);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004893 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
4894 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
4895}
4896
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02004897static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
4898 u32 *p_max_buff_occupancy)
4899{
4900 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
4901 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
4902}
4903
Jiri Pirkoe0594362015-10-16 14:01:31 +02004904/* SBMM - Shared Buffer Multicast Management Register
4905 * --------------------------------------------------
4906 * The SBMM register configures and retrieves the shared buffer allocation
4907 * and configuration for MC packets according to Switch-Priority, including
4908 * the binding to pool and definition of the associated quota.
4909 */
4910#define MLXSW_REG_SBMM_ID 0xB004
4911#define MLXSW_REG_SBMM_LEN 0x28
4912
Jiri Pirko21978dc2016-10-21 16:07:20 +02004913MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004914
4915/* reg_sbmm_prio
4916 * Switch Priority.
4917 * Access: Index
4918 */
4919MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
4920
4921/* reg_sbmm_min_buff
4922 * Minimum buffer size for the limiter, in cells.
4923 * Access: RW
4924 */
4925MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
4926
4927/* reg_sbmm_max_buff
4928 * When the pool associated to the port-pg/tclass is configured to
4929 * static, Maximum buffer size for the limiter configured in cells.
4930 * When the pool associated to the port-pg/tclass is configured to
4931 * dynamic, the max_buff holds the "alpha" parameter, supporting
4932 * the following values:
4933 * 0: 0
4934 * i: (1/128)*2^(i-1), for i=1..14
4935 * 0xFF: Infinity
4936 * Access: RW
4937 */
4938MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
4939
4940/* reg_sbmm_pool
4941 * Association of the port-priority to a pool.
4942 * Access: RW
4943 */
4944MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
4945
4946static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
4947 u32 max_buff, u8 pool)
4948{
4949 MLXSW_REG_ZERO(sbmm, payload);
4950 mlxsw_reg_sbmm_prio_set(payload, prio);
4951 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
4952 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
4953 mlxsw_reg_sbmm_pool_set(payload, pool);
4954}
4955
Jiri Pirko26176de2016-04-14 18:19:26 +02004956/* SBSR - Shared Buffer Status Register
4957 * ------------------------------------
4958 * The SBSR register retrieves the shared buffer occupancy according to
4959 * Port-Pool. Note that this register enables reading a large amount of data.
4960 * It is the user's responsibility to limit the amount of data to ensure the
4961 * response can match the maximum transfer unit. In case the response exceeds
4962 * the maximum transport unit, it will be truncated with no special notice.
4963 */
4964#define MLXSW_REG_SBSR_ID 0xB005
4965#define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
4966#define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
4967#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
4968#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
4969 MLXSW_REG_SBSR_REC_LEN * \
4970 MLXSW_REG_SBSR_REC_MAX_COUNT)
4971
Jiri Pirko21978dc2016-10-21 16:07:20 +02004972MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
Jiri Pirko26176de2016-04-14 18:19:26 +02004973
4974/* reg_sbsr_clr
4975 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
4976 * field is cleared (and a new max value is tracked from the time the clear
4977 * was performed).
4978 * Access: OP
4979 */
4980MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
4981
4982/* reg_sbsr_ingress_port_mask
4983 * Bit vector for all ingress network ports.
4984 * Indicates which of the ports (for which the relevant bit is set)
4985 * are affected by the set operation. Configuration of any other port
4986 * does not change.
4987 * Access: Index
4988 */
4989MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
4990
4991/* reg_sbsr_pg_buff_mask
4992 * Bit vector for all switch priority groups.
4993 * Indicates which of the priorities (for which the relevant bit is set)
4994 * are affected by the set operation. Configuration of any other priority
4995 * does not change.
4996 * Range is 0..cap_max_pg_buffers - 1
4997 * Access: Index
4998 */
4999MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
5000
5001/* reg_sbsr_egress_port_mask
5002 * Bit vector for all egress network ports.
5003 * Indicates which of the ports (for which the relevant bit is set)
5004 * are affected by the set operation. Configuration of any other port
5005 * does not change.
5006 * Access: Index
5007 */
5008MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
5009
5010/* reg_sbsr_tclass_mask
5011 * Bit vector for all traffic classes.
5012 * Indicates which of the traffic classes (for which the relevant bit is
5013 * set) are affected by the set operation. Configuration of any other
5014 * traffic class does not change.
5015 * Range is 0..cap_max_tclass - 1
5016 * Access: Index
5017 */
5018MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
5019
5020static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
5021{
5022 MLXSW_REG_ZERO(sbsr, payload);
5023 mlxsw_reg_sbsr_clr_set(payload, clr);
5024}
5025
5026/* reg_sbsr_rec_buff_occupancy
5027 * Current buffer occupancy in cells.
5028 * Access: RO
5029 */
5030MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
5031 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
5032
5033/* reg_sbsr_rec_max_buff_occupancy
5034 * Maximum value of buffer occupancy in cells monitored. Cleared by
5035 * writing to the clr field.
5036 * Access: RO
5037 */
5038MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
5039 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
5040
5041static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
5042 u32 *p_buff_occupancy,
5043 u32 *p_max_buff_occupancy)
5044{
5045 *p_buff_occupancy =
5046 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
5047 *p_max_buff_occupancy =
5048 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
5049}
5050
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02005051/* SBIB - Shared Buffer Internal Buffer Register
5052 * ---------------------------------------------
5053 * The SBIB register configures per port buffers for internal use. The internal
5054 * buffers consume memory on the port buffers (note that the port buffers are
5055 * used also by PBMC).
5056 *
5057 * For Spectrum this is used for egress mirroring.
5058 */
5059#define MLXSW_REG_SBIB_ID 0xB006
5060#define MLXSW_REG_SBIB_LEN 0x10
5061
Jiri Pirko21978dc2016-10-21 16:07:20 +02005062MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02005063
5064/* reg_sbib_local_port
5065 * Local port number
5066 * Not supported for CPU port and router port
5067 * Access: Index
5068 */
5069MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
5070
5071/* reg_sbib_buff_size
5072 * Units represented in cells
5073 * Allowed range is 0 to (cap_max_headroom_size - 1)
5074 * Default is 0
5075 * Access: RW
5076 */
5077MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
5078
5079static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
5080 u32 buff_size)
5081{
5082 MLXSW_REG_ZERO(sbib, payload);
5083 mlxsw_reg_sbib_local_port_set(payload, local_port);
5084 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
5085}
5086
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005087static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
5088 MLXSW_REG(sgcr),
5089 MLXSW_REG(spad),
5090 MLXSW_REG(smid),
5091 MLXSW_REG(sspr),
5092 MLXSW_REG(sfdat),
5093 MLXSW_REG(sfd),
5094 MLXSW_REG(sfn),
5095 MLXSW_REG(spms),
5096 MLXSW_REG(spvid),
5097 MLXSW_REG(spvm),
5098 MLXSW_REG(spaft),
5099 MLXSW_REG(sfgc),
5100 MLXSW_REG(sftr),
5101 MLXSW_REG(sfdf),
5102 MLXSW_REG(sldr),
5103 MLXSW_REG(slcr),
5104 MLXSW_REG(slcor),
5105 MLXSW_REG(spmlr),
5106 MLXSW_REG(svfa),
5107 MLXSW_REG(svpe),
5108 MLXSW_REG(sfmr),
5109 MLXSW_REG(spvmlr),
5110 MLXSW_REG(qtct),
5111 MLXSW_REG(qeec),
5112 MLXSW_REG(pmlp),
5113 MLXSW_REG(pmtu),
5114 MLXSW_REG(ptys),
5115 MLXSW_REG(ppad),
5116 MLXSW_REG(paos),
5117 MLXSW_REG(pfcc),
5118 MLXSW_REG(ppcnt),
5119 MLXSW_REG(pptb),
5120 MLXSW_REG(pbmc),
5121 MLXSW_REG(pspa),
5122 MLXSW_REG(htgt),
5123 MLXSW_REG(hpkt),
5124 MLXSW_REG(rgcr),
5125 MLXSW_REG(ritr),
5126 MLXSW_REG(ratr),
5127 MLXSW_REG(ralta),
5128 MLXSW_REG(ralst),
5129 MLXSW_REG(raltb),
5130 MLXSW_REG(ralue),
5131 MLXSW_REG(rauht),
5132 MLXSW_REG(raleu),
5133 MLXSW_REG(rauhtd),
5134 MLXSW_REG(mfcr),
5135 MLXSW_REG(mfsc),
5136 MLXSW_REG(mfsm),
5137 MLXSW_REG(mtcap),
5138 MLXSW_REG(mtmp),
5139 MLXSW_REG(mpat),
5140 MLXSW_REG(mpar),
5141 MLXSW_REG(mlcr),
5142 MLXSW_REG(sbpr),
5143 MLXSW_REG(sbcm),
5144 MLXSW_REG(sbpm),
5145 MLXSW_REG(sbmm),
5146 MLXSW_REG(sbsr),
5147 MLXSW_REG(sbib),
5148};
5149
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005150static inline const char *mlxsw_reg_id_str(u16 reg_id)
5151{
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005152 const struct mlxsw_reg_info *reg_info;
5153 int i;
5154
5155 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
5156 reg_info = mlxsw_reg_infos[i];
5157 if (reg_info->id == reg_id)
5158 return reg_info->name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005159 }
Jiri Pirko8e9658d2016-10-21 16:07:21 +02005160 return "*UNKNOWN*";
Ido Schimmel4ec14b72015-07-29 23:33:48 +02005161}
5162
5163/* PUDE - Port Up / Down Event
5164 * ---------------------------
5165 * Reports the operational state change of a port.
5166 */
5167#define MLXSW_REG_PUDE_LEN 0x10
5168
5169/* reg_pude_swid
5170 * Switch partition ID with which to associate the port.
5171 * Access: Index
5172 */
5173MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
5174
5175/* reg_pude_local_port
5176 * Local port number.
5177 * Access: Index
5178 */
5179MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
5180
5181/* reg_pude_admin_status
5182 * Port administrative state (the desired state).
5183 * 1 - Up.
5184 * 2 - Down.
5185 * 3 - Up once. This means that in case of link failure, the port won't go
5186 * into polling mode, but will wait to be re-enabled by software.
5187 * 4 - Disabled by system. Can only be set by hardware.
5188 * Access: RO
5189 */
5190MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
5191
5192/* reg_pude_oper_status
5193 * Port operatioanl state.
5194 * 1 - Up.
5195 * 2 - Down.
5196 * 3 - Down by port failure. This means that the device will not let the
5197 * port up again until explicitly specified by software.
5198 * Access: RO
5199 */
5200MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
5201
5202#endif