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