blob: c50e754dd7253697a3c36830baedba891ba446ce [file] [log] [blame]
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001/*
2 * drivers/net/ethernet/mellanox/mlxsw/reg.h
Petr Machata0d6cd3f2018-02-27 14:53:39 +01003 * Copyright (c) 2015-2018 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 Pirko3279da42017-02-03 10:28:53 +01006 * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
Yotam Gigi4457b3df2016-07-05 11:27:40 +02007 * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com>
Petr Machata0d6cd3f2018-02-27 14:53:39 +01008 * Copyright (c) 2017-2018 Petr Machata <petrm@mellanox.com>
Ido Schimmel4ec14b72015-07-29 23:33:48 +02009 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the names of the copyright holders nor the names of its
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * Alternatively, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") version 2 as published by the Free
24 * Software Foundation.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _MLXSW_REG_H
40#define _MLXSW_REG_H
41
Jiri Pirko33907872018-07-18 11:14:37 +030042#include <linux/kernel.h>
Ido Schimmel4ec14b72015-07-29 23:33:48 +020043#include <linux/string.h>
44#include <linux/bitops.h>
45#include <linux/if_vlan.h>
46
47#include "item.h"
48#include "port.h"
49
50struct mlxsw_reg_info {
51 u16 id;
52 u16 len; /* In u8 */
Jiri Pirko8e9658d2016-10-21 16:07:21 +020053 const char *name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +020054};
55
Jiri Pirko21978dc2016-10-21 16:07:20 +020056#define MLXSW_REG_DEFINE(_name, _id, _len) \
57static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
58 .id = _id, \
59 .len = _len, \
Jiri Pirko8e9658d2016-10-21 16:07:21 +020060 .name = #_name, \
Jiri Pirko21978dc2016-10-21 16:07:20 +020061}
62
Ido Schimmel4ec14b72015-07-29 23:33:48 +020063#define MLXSW_REG(type) (&mlxsw_reg_##type)
64#define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
65#define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
66
67/* SGCR - Switch General Configuration Register
68 * --------------------------------------------
69 * This register is used for configuration of the switch capabilities.
70 */
71#define MLXSW_REG_SGCR_ID 0x2000
72#define MLXSW_REG_SGCR_LEN 0x10
73
Jiri Pirko21978dc2016-10-21 16:07:20 +020074MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +020075
76/* reg_sgcr_llb
77 * Link Local Broadcast (Default=0)
78 * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
79 * packets and ignore the IGMP snooping entries.
80 * Access: RW
81 */
82MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
83
84static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
85{
86 MLXSW_REG_ZERO(sgcr, payload);
87 mlxsw_reg_sgcr_llb_set(payload, !!llb);
88}
89
90/* SPAD - Switch Physical Address Register
91 * ---------------------------------------
92 * The SPAD register configures the switch physical MAC address.
93 */
94#define MLXSW_REG_SPAD_ID 0x2002
95#define MLXSW_REG_SPAD_LEN 0x10
96
Jiri Pirko21978dc2016-10-21 16:07:20 +020097MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +020098
99/* reg_spad_base_mac
100 * Base MAC address for the switch partitions.
101 * Per switch partition MAC address is equal to:
102 * base_mac + swid
103 * Access: RW
104 */
105MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
106
Elad Razfabe5482016-01-10 21:06:25 +0100107/* SMID - Switch Multicast ID
108 * --------------------------
109 * The MID record maps from a MID (Multicast ID), which is a unique identifier
110 * of the multicast group within the stacking domain, into a list of local
111 * ports into which the packet is replicated.
112 */
113#define MLXSW_REG_SMID_ID 0x2007
114#define MLXSW_REG_SMID_LEN 0x240
115
Jiri Pirko21978dc2016-10-21 16:07:20 +0200116MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
Elad Razfabe5482016-01-10 21:06:25 +0100117
118/* reg_smid_swid
119 * Switch partition ID.
120 * Access: Index
121 */
122MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
123
124/* reg_smid_mid
125 * Multicast identifier - global identifier that represents the multicast group
126 * across all devices.
127 * Access: Index
128 */
129MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
130
131/* reg_smid_port
132 * Local port memebership (1 bit per port).
133 * Access: RW
134 */
135MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
136
137/* reg_smid_port_mask
138 * Local port mask (1 bit per port).
139 * Access: W
140 */
141MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
142
143static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
144 u8 port, bool set)
145{
146 MLXSW_REG_ZERO(smid, payload);
147 mlxsw_reg_smid_swid_set(payload, 0);
148 mlxsw_reg_smid_mid_set(payload, mid);
149 mlxsw_reg_smid_port_set(payload, port, set);
150 mlxsw_reg_smid_port_mask_set(payload, port, 1);
151}
152
Ido Schimmele61011b2015-08-06 16:41:53 +0200153/* SSPR - Switch System Port Record Register
154 * -----------------------------------------
155 * Configures the system port to local port mapping.
156 */
157#define MLXSW_REG_SSPR_ID 0x2008
158#define MLXSW_REG_SSPR_LEN 0x8
159
Jiri Pirko21978dc2016-10-21 16:07:20 +0200160MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
Ido Schimmele61011b2015-08-06 16:41:53 +0200161
162/* reg_sspr_m
163 * Master - if set, then the record describes the master system port.
164 * This is needed in case a local port is mapped into several system ports
165 * (for multipathing). That number will be reported as the source system
166 * port when packets are forwarded to the CPU. Only one master port is allowed
167 * per local port.
168 *
169 * Note: Must be set for Spectrum.
170 * Access: RW
171 */
172MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
173
174/* reg_sspr_local_port
175 * Local port number.
176 *
177 * Access: RW
178 */
179MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
180
181/* reg_sspr_sub_port
182 * Virtual port within the physical port.
183 * Should be set to 0 when virtual ports are not enabled on the port.
184 *
185 * Access: RW
186 */
187MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
188
189/* reg_sspr_system_port
190 * Unique identifier within the stacking domain that represents all the ports
191 * that are available in the system (external ports).
192 *
193 * Currently, only single-ASIC configurations are supported, so we default to
194 * 1:1 mapping between system ports and local ports.
195 * Access: Index
196 */
197MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
198
199static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
200{
201 MLXSW_REG_ZERO(sspr, payload);
202 mlxsw_reg_sspr_m_set(payload, 1);
203 mlxsw_reg_sspr_local_port_set(payload, local_port);
204 mlxsw_reg_sspr_sub_port_set(payload, 0);
205 mlxsw_reg_sspr_system_port_set(payload, local_port);
206}
207
Jiri Pirkoe534a56a2015-10-16 14:01:35 +0200208/* SFDAT - Switch Filtering Database Aging Time
209 * --------------------------------------------
210 * Controls the Switch aging time. Aging time is able to be set per Switch
211 * Partition.
212 */
213#define MLXSW_REG_SFDAT_ID 0x2009
214#define MLXSW_REG_SFDAT_LEN 0x8
215
Jiri Pirko21978dc2016-10-21 16:07:20 +0200216MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
Jiri Pirkoe534a56a2015-10-16 14:01:35 +0200217
218/* reg_sfdat_swid
219 * Switch partition ID.
220 * Access: Index
221 */
222MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
223
224/* reg_sfdat_age_time
225 * Aging time in seconds
226 * Min - 10 seconds
227 * Max - 1,000,000 seconds
228 * Default is 300 seconds.
229 * Access: RW
230 */
231MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
232
233static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
234{
235 MLXSW_REG_ZERO(sfdat, payload);
236 mlxsw_reg_sfdat_swid_set(payload, 0);
237 mlxsw_reg_sfdat_age_time_set(payload, age_time);
238}
239
Jiri Pirko236033b2015-10-16 14:01:28 +0200240/* SFD - Switch Filtering Database
241 * -------------------------------
242 * The following register defines the access to the filtering database.
243 * The register supports querying, adding, removing and modifying the database.
244 * The access is optimized for bulk updates in which case more than one
245 * FDB record is present in the same command.
246 */
247#define MLXSW_REG_SFD_ID 0x200A
248#define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
249#define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
250#define MLXSW_REG_SFD_REC_MAX_COUNT 64
251#define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
252 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
253
Jiri Pirko21978dc2016-10-21 16:07:20 +0200254MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
Jiri Pirko236033b2015-10-16 14:01:28 +0200255
256/* reg_sfd_swid
257 * Switch partition ID for queries. Reserved on Write.
258 * Access: Index
259 */
260MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
261
262enum mlxsw_reg_sfd_op {
263 /* Dump entire FDB a (process according to record_locator) */
264 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
265 /* Query records by {MAC, VID/FID} value */
266 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
267 /* Query and clear activity. Query records by {MAC, VID/FID} value */
268 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
269 /* Test. Response indicates if each of the records could be
270 * added to the FDB.
271 */
272 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
273 /* Add/modify. Aged-out records cannot be added. This command removes
274 * the learning notification of the {MAC, VID/FID}. Response includes
275 * the entries that were added to the FDB.
276 */
277 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
278 /* Remove record by {MAC, VID/FID}. This command also removes
279 * the learning notification and aged-out notifications
280 * of the {MAC, VID/FID}. The response provides current (pre-removal)
281 * entries as non-aged-out.
282 */
283 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
284 /* Remove learned notification by {MAC, VID/FID}. The response provides
285 * the removed learning notification.
286 */
287 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
288};
289
290/* reg_sfd_op
291 * Operation.
292 * Access: OP
293 */
294MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
295
296/* reg_sfd_record_locator
297 * Used for querying the FDB. Use record_locator=0 to initiate the
298 * query. When a record is returned, a new record_locator is
299 * returned to be used in the subsequent query.
300 * Reserved for database update.
301 * Access: Index
302 */
303MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
304
305/* reg_sfd_num_rec
306 * Request: Number of records to read/add/modify/remove
307 * Response: Number of records read/added/replaced/removed
308 * See above description for more details.
309 * Ranges 0..64
310 * Access: RW
311 */
312MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
313
314static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
315 u32 record_locator)
316{
317 MLXSW_REG_ZERO(sfd, payload);
318 mlxsw_reg_sfd_op_set(payload, op);
319 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
320}
321
322/* reg_sfd_rec_swid
323 * Switch partition ID.
324 * Access: Index
325 */
326MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
327 MLXSW_REG_SFD_REC_LEN, 0x00, false);
328
329enum mlxsw_reg_sfd_rec_type {
330 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100331 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
Elad Raz5230b252016-01-10 21:06:24 +0100332 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
Jiri Pirko236033b2015-10-16 14:01:28 +0200333};
334
335/* reg_sfd_rec_type
336 * FDB record type.
337 * Access: RW
338 */
339MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
340 MLXSW_REG_SFD_REC_LEN, 0x00, false);
341
342enum mlxsw_reg_sfd_rec_policy {
343 /* Replacement disabled, aging disabled. */
344 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
345 /* (mlag remote): Replacement enabled, aging disabled,
346 * learning notification enabled on this port.
347 */
348 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
349 /* (ingress device): Replacement enabled, aging enabled. */
350 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
351};
352
353/* reg_sfd_rec_policy
354 * Policy.
355 * Access: RW
356 */
357MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
358 MLXSW_REG_SFD_REC_LEN, 0x00, false);
359
360/* reg_sfd_rec_a
361 * Activity. Set for new static entries. Set for static entries if a frame SMAC
362 * lookup hits on the entry.
363 * To clear the a bit, use "query and clear activity" op.
364 * Access: RO
365 */
366MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
367 MLXSW_REG_SFD_REC_LEN, 0x00, false);
368
369/* reg_sfd_rec_mac
370 * MAC address.
371 * Access: Index
372 */
373MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
374 MLXSW_REG_SFD_REC_LEN, 0x02);
375
376enum mlxsw_reg_sfd_rec_action {
377 /* forward */
378 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
379 /* forward and trap, trap_id is FDB_TRAP */
380 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
381 /* trap and do not forward, trap_id is FDB_TRAP */
Ido Schimmeld82d8c02016-07-02 11:00:17 +0200382 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
383 /* forward to IP router */
384 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
Jiri Pirko236033b2015-10-16 14:01:28 +0200385 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
386};
387
388/* reg_sfd_rec_action
389 * Action to apply on the packet.
390 * Note: Dynamic entries can only be configured with NOP action.
391 * Access: RW
392 */
393MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
394 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
395
396/* reg_sfd_uc_sub_port
Jiri Pirko4e9ec082015-10-28 10:16:59 +0100397 * VEPA channel on local port.
398 * Valid only if local port is a non-stacking port. Must be 0 if multichannel
399 * VEPA is not enabled.
Jiri Pirko236033b2015-10-16 14:01:28 +0200400 * Access: RW
401 */
402MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
403 MLXSW_REG_SFD_REC_LEN, 0x08, false);
404
405/* reg_sfd_uc_fid_vid
406 * Filtering ID or VLAN ID
407 * For SwitchX and SwitchX-2:
408 * - Dynamic entries (policy 2,3) use FID
409 * - Static entries (policy 0) use VID
410 * - When independent learning is configured, VID=FID
411 * For Spectrum: use FID for both Dynamic and Static entries.
412 * VID should not be used.
413 * Access: Index
414 */
415MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
416 MLXSW_REG_SFD_REC_LEN, 0x08, false);
417
418/* reg_sfd_uc_system_port
419 * Unique port identifier for the final destination of the packet.
420 * Access: RW
421 */
422MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
423 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
424
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100425static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
426 enum mlxsw_reg_sfd_rec_type rec_type,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100427 const char *mac,
428 enum mlxsw_reg_sfd_rec_action action)
Jiri Pirko236033b2015-10-16 14:01:28 +0200429{
430 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
431
432 if (rec_index >= num_rec)
433 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
434 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100435 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
Jiri Pirko236033b2015-10-16 14:01:28 +0200436 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100437 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
438}
439
440static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
441 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100442 const char *mac, u16 fid_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100443 enum mlxsw_reg_sfd_rec_action action,
444 u8 local_port)
445{
446 mlxsw_reg_sfd_rec_pack(payload, rec_index,
Elad Raz5230b252016-01-10 21:06:24 +0100447 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
448 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirko236033b2015-10-16 14:01:28 +0200449 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100450 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
Jiri Pirko236033b2015-10-16 14:01:28 +0200451 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
452}
453
Jiri Pirko75c09282015-10-28 10:17:01 +0100454static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100455 char *mac, u16 *p_fid_vid,
Jiri Pirko75c09282015-10-28 10:17:01 +0100456 u8 *p_local_port)
Jiri Pirko236033b2015-10-16 14:01:28 +0200457{
458 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100459 *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
Jiri Pirko236033b2015-10-16 14:01:28 +0200460 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
461}
462
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100463/* reg_sfd_uc_lag_sub_port
464 * LAG sub port.
465 * Must be 0 if multichannel VEPA is not enabled.
466 * Access: RW
467 */
468MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
469 MLXSW_REG_SFD_REC_LEN, 0x08, false);
470
471/* reg_sfd_uc_lag_fid_vid
472 * Filtering ID or VLAN ID
473 * For SwitchX and SwitchX-2:
474 * - Dynamic entries (policy 2,3) use FID
475 * - Static entries (policy 0) use VID
476 * - When independent learning is configured, VID=FID
477 * For Spectrum: use FID for both Dynamic and Static entries.
478 * VID should not be used.
479 * Access: Index
480 */
481MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
482 MLXSW_REG_SFD_REC_LEN, 0x08, false);
483
Ido Schimmelafd7f972015-12-15 16:03:45 +0100484/* reg_sfd_uc_lag_lag_vid
485 * Indicates VID in case of vFIDs. Reserved for FIDs.
486 * Access: RW
487 */
488MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
489 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
490
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100491/* reg_sfd_uc_lag_lag_id
492 * LAG Identifier - pointer into the LAG descriptor table.
493 * Access: RW
494 */
495MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
496 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
497
498static inline void
499mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
500 enum mlxsw_reg_sfd_rec_policy policy,
Ido Schimmel9de6a802015-12-15 16:03:40 +0100501 const char *mac, u16 fid_vid,
Ido Schimmelafd7f972015-12-15 16:03:45 +0100502 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100503 u16 lag_id)
504{
505 mlxsw_reg_sfd_rec_pack(payload, rec_index,
506 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
Elad Raz5230b252016-01-10 21:06:24 +0100507 mac, action);
508 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100509 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
Ido Schimmel9de6a802015-12-15 16:03:40 +0100510 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
Ido Schimmelafd7f972015-12-15 16:03:45 +0100511 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
Jiri Pirkoe4bfbae2015-12-03 12:12:26 +0100512 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
513}
514
515static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
516 char *mac, u16 *p_vid,
517 u16 *p_lag_id)
518{
519 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
520 *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
521 *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
522}
523
Elad Raz5230b252016-01-10 21:06:24 +0100524/* reg_sfd_mc_pgi
525 *
526 * Multicast port group index - index into the port group table.
527 * Value 0x1FFF indicates the pgi should point to the MID entry.
528 * For Spectrum this value must be set to 0x1FFF
529 * Access: RW
530 */
531MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
532 MLXSW_REG_SFD_REC_LEN, 0x08, false);
533
534/* reg_sfd_mc_fid_vid
535 *
536 * Filtering ID or VLAN ID
537 * Access: Index
538 */
539MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
540 MLXSW_REG_SFD_REC_LEN, 0x08, false);
541
542/* reg_sfd_mc_mid
543 *
544 * Multicast identifier - global identifier that represents the multicast
545 * group across all devices.
546 * Access: RW
547 */
548MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
549 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
550
551static inline void
552mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
553 const char *mac, u16 fid_vid,
554 enum mlxsw_reg_sfd_rec_action action, u16 mid)
555{
556 mlxsw_reg_sfd_rec_pack(payload, rec_index,
557 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
558 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
559 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
560 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
561}
562
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200563/* SFN - Switch FDB Notification Register
564 * -------------------------------------------
565 * The switch provides notifications on newly learned FDB entries and
566 * aged out entries. The notifications can be polled by software.
567 */
568#define MLXSW_REG_SFN_ID 0x200B
569#define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
570#define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
571#define MLXSW_REG_SFN_REC_MAX_COUNT 64
572#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
573 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
574
Jiri Pirko21978dc2016-10-21 16:07:20 +0200575MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200576
577/* reg_sfn_swid
578 * Switch partition ID.
579 * Access: Index
580 */
581MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
582
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200583/* reg_sfn_end
584 * Forces the current session to end.
585 * Access: OP
586 */
587MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
588
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200589/* reg_sfn_num_rec
590 * Request: Number of learned notifications and aged-out notification
591 * records requested.
592 * Response: Number of notification records returned (must be smaller
593 * than or equal to the value requested)
594 * Ranges 0..64
595 * Access: OP
596 */
597MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
598
599static inline void mlxsw_reg_sfn_pack(char *payload)
600{
601 MLXSW_REG_ZERO(sfn, payload);
602 mlxsw_reg_sfn_swid_set(payload, 0);
Ido Schimmel1803e0f2016-08-24 12:00:23 +0200603 mlxsw_reg_sfn_end_set(payload, 1);
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200604 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
605}
606
607/* reg_sfn_rec_swid
608 * Switch partition ID.
609 * Access: RO
610 */
611MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
612 MLXSW_REG_SFN_REC_LEN, 0x00, false);
613
614enum mlxsw_reg_sfn_rec_type {
615 /* MAC addresses learned on a regular port. */
616 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
Jiri Pirko3b715712015-12-03 12:12:27 +0100617 /* MAC addresses learned on a LAG port. */
618 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
619 /* Aged-out MAC address on a regular port. */
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200620 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
Jiri Pirko3b715712015-12-03 12:12:27 +0100621 /* Aged-out MAC address on a LAG port. */
622 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200623};
624
625/* reg_sfn_rec_type
626 * Notification record type.
627 * Access: RO
628 */
629MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
630 MLXSW_REG_SFN_REC_LEN, 0x00, false);
631
632/* reg_sfn_rec_mac
633 * MAC address.
634 * Access: RO
635 */
636MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
637 MLXSW_REG_SFN_REC_LEN, 0x02);
638
Jiri Pirko8316f082015-10-28 10:17:00 +0100639/* reg_sfn_mac_sub_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200640 * VEPA channel on the local port.
641 * 0 if multichannel VEPA is not enabled.
642 * Access: RO
643 */
644MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
645 MLXSW_REG_SFN_REC_LEN, 0x08, false);
646
Jiri Pirko8316f082015-10-28 10:17:00 +0100647/* reg_sfn_mac_fid
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200648 * Filtering identifier.
649 * Access: RO
650 */
651MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
652 MLXSW_REG_SFN_REC_LEN, 0x08, false);
653
Jiri Pirko8316f082015-10-28 10:17:00 +0100654/* reg_sfn_mac_system_port
Jiri Pirkof5d88f52015-10-16 14:01:29 +0200655 * Unique port identifier for the final destination of the packet.
656 * Access: RO
657 */
658MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
659 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
660
661static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
662 char *mac, u16 *p_vid,
663 u8 *p_local_port)
664{
665 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
666 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
667 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
668}
669
Jiri Pirko3b715712015-12-03 12:12:27 +0100670/* reg_sfn_mac_lag_lag_id
671 * LAG ID (pointer into the LAG descriptor table).
672 * Access: RO
673 */
674MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
675 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
676
677static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
678 char *mac, u16 *p_vid,
679 u16 *p_lag_id)
680{
681 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
682 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
683 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
684}
685
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200686/* SPMS - Switch Port MSTP/RSTP State Register
687 * -------------------------------------------
688 * Configures the spanning tree state of a physical port.
689 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +0200690#define MLXSW_REG_SPMS_ID 0x200D
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200691#define MLXSW_REG_SPMS_LEN 0x404
692
Jiri Pirko21978dc2016-10-21 16:07:20 +0200693MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200694
695/* reg_spms_local_port
696 * Local port number.
697 * Access: Index
698 */
699MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
700
701enum mlxsw_reg_spms_state {
702 MLXSW_REG_SPMS_STATE_NO_CHANGE,
703 MLXSW_REG_SPMS_STATE_DISCARDING,
704 MLXSW_REG_SPMS_STATE_LEARNING,
705 MLXSW_REG_SPMS_STATE_FORWARDING,
706};
707
708/* reg_spms_state
709 * Spanning tree state of each VLAN ID (VID) of the local port.
710 * 0 - Do not change spanning tree state (used only when writing).
711 * 1 - Discarding. No learning or forwarding to/from this port (default).
712 * 2 - Learning. Port is learning, but not forwarding.
713 * 3 - Forwarding. Port is learning and forwarding.
714 * Access: RW
715 */
716MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
717
Jiri Pirkoebb79632015-10-15 17:43:26 +0200718static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200719{
720 MLXSW_REG_ZERO(spms, payload);
721 mlxsw_reg_spms_local_port_set(payload, local_port);
Jiri Pirkoebb79632015-10-15 17:43:26 +0200722}
723
724static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
725 enum mlxsw_reg_spms_state state)
726{
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200727 mlxsw_reg_spms_state_set(payload, vid, state);
728}
729
Elad Razb2e345f2015-10-16 14:01:30 +0200730/* SPVID - Switch Port VID
731 * -----------------------
732 * The switch port VID configures the default VID for a port.
733 */
734#define MLXSW_REG_SPVID_ID 0x200E
735#define MLXSW_REG_SPVID_LEN 0x08
736
Jiri Pirko21978dc2016-10-21 16:07:20 +0200737MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200738
739/* reg_spvid_local_port
740 * Local port number.
741 * Access: Index
742 */
743MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
744
745/* reg_spvid_sub_port
746 * Virtual port within the physical port.
747 * Should be set to 0 when virtual ports are not enabled on the port.
748 * Access: Index
749 */
750MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
751
752/* reg_spvid_pvid
753 * Port default VID
754 * Access: RW
755 */
756MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
757
758static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
759{
760 MLXSW_REG_ZERO(spvid, payload);
761 mlxsw_reg_spvid_local_port_set(payload, local_port);
762 mlxsw_reg_spvid_pvid_set(payload, pvid);
763}
764
765/* SPVM - Switch Port VLAN Membership
766 * ----------------------------------
767 * The Switch Port VLAN Membership register configures the VLAN membership
768 * of a port in a VLAN denoted by VID. VLAN membership is managed per
769 * virtual port. The register can be used to add and remove VID(s) from a port.
770 */
771#define MLXSW_REG_SPVM_ID 0x200F
772#define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
773#define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
Jiri Pirkof004ec02017-03-14 14:00:00 +0100774#define MLXSW_REG_SPVM_REC_MAX_COUNT 255
Elad Razb2e345f2015-10-16 14:01:30 +0200775#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
776 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
777
Jiri Pirko21978dc2016-10-21 16:07:20 +0200778MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
Elad Razb2e345f2015-10-16 14:01:30 +0200779
780/* reg_spvm_pt
781 * Priority tagged. If this bit is set, packets forwarded to the port with
782 * untagged VLAN membership (u bit is set) will be tagged with priority tag
783 * (VID=0)
784 * Access: RW
785 */
786MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
787
788/* reg_spvm_pte
789 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
790 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
791 * Access: WO
792 */
793MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
794
795/* reg_spvm_local_port
796 * Local port number.
797 * Access: Index
798 */
799MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
800
801/* reg_spvm_sub_port
802 * Virtual port within the physical port.
803 * Should be set to 0 when virtual ports are not enabled on the port.
804 * Access: Index
805 */
806MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
807
808/* reg_spvm_num_rec
809 * Number of records to update. Each record contains: i, e, u, vid.
810 * Access: OP
811 */
812MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
813
814/* reg_spvm_rec_i
815 * Ingress membership in VLAN ID.
816 * Access: Index
817 */
818MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
819 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
820 MLXSW_REG_SPVM_REC_LEN, 0, false);
821
822/* reg_spvm_rec_e
823 * Egress membership in VLAN ID.
824 * Access: Index
825 */
826MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
827 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
828 MLXSW_REG_SPVM_REC_LEN, 0, false);
829
830/* reg_spvm_rec_u
831 * Untagged - port is an untagged member - egress transmission uses untagged
832 * frames on VID<n>
833 * Access: Index
834 */
835MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
836 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
837 MLXSW_REG_SPVM_REC_LEN, 0, false);
838
839/* reg_spvm_rec_vid
840 * Egress membership in VLAN ID.
841 * Access: Index
842 */
843MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
844 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
845 MLXSW_REG_SPVM_REC_LEN, 0, false);
846
847static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
848 u16 vid_begin, u16 vid_end,
849 bool is_member, bool untagged)
850{
851 int size = vid_end - vid_begin + 1;
852 int i;
853
854 MLXSW_REG_ZERO(spvm, payload);
855 mlxsw_reg_spvm_local_port_set(payload, local_port);
856 mlxsw_reg_spvm_num_rec_set(payload, size);
857
858 for (i = 0; i < size; i++) {
859 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
860 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
861 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
862 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
863 }
864}
865
Ido Schimmel148f4722016-02-18 11:30:01 +0100866/* SPAFT - Switch Port Acceptable Frame Types
867 * ------------------------------------------
868 * The Switch Port Acceptable Frame Types register configures the frame
869 * admittance of the port.
870 */
871#define MLXSW_REG_SPAFT_ID 0x2010
872#define MLXSW_REG_SPAFT_LEN 0x08
873
Jiri Pirko21978dc2016-10-21 16:07:20 +0200874MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
Ido Schimmel148f4722016-02-18 11:30:01 +0100875
876/* reg_spaft_local_port
877 * Local port number.
878 * Access: Index
879 *
880 * Note: CPU port is not supported (all tag types are allowed).
881 */
882MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
883
884/* reg_spaft_sub_port
885 * Virtual port within the physical port.
886 * Should be set to 0 when virtual ports are not enabled on the port.
887 * Access: RW
888 */
889MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
890
891/* reg_spaft_allow_untagged
892 * When set, untagged frames on the ingress are allowed (default).
893 * Access: RW
894 */
895MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
896
897/* reg_spaft_allow_prio_tagged
898 * When set, priority tagged frames on the ingress are allowed (default).
899 * Access: RW
900 */
901MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
902
903/* reg_spaft_allow_tagged
904 * When set, tagged frames on the ingress are allowed (default).
905 * Access: RW
906 */
907MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
908
909static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
910 bool allow_untagged)
911{
912 MLXSW_REG_ZERO(spaft, payload);
913 mlxsw_reg_spaft_local_port_set(payload, local_port);
914 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
915 mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
916 mlxsw_reg_spaft_allow_tagged_set(payload, true);
917}
918
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200919/* SFGC - Switch Flooding Group Configuration
920 * ------------------------------------------
921 * The following register controls the association of flooding tables and MIDs
922 * to packet types used for flooding.
923 */
Jiri Pirko36b78e82015-10-15 17:43:24 +0200924#define MLXSW_REG_SFGC_ID 0x2011
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200925#define MLXSW_REG_SFGC_LEN 0x10
926
Jiri Pirko21978dc2016-10-21 16:07:20 +0200927MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200928
929enum mlxsw_reg_sfgc_type {
Ido Schimmelfa6ad052015-10-15 17:43:25 +0200930 MLXSW_REG_SFGC_TYPE_BROADCAST,
931 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
932 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
933 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
934 MLXSW_REG_SFGC_TYPE_RESERVED,
935 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
936 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
937 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
938 MLXSW_REG_SFGC_TYPE_MAX,
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200939};
940
941/* reg_sfgc_type
942 * The traffic type to reach the flooding table.
943 * Access: Index
944 */
945MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
946
947enum mlxsw_reg_sfgc_bridge_type {
948 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
949 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
950};
951
952/* reg_sfgc_bridge_type
953 * Access: Index
954 *
955 * Note: SwitchX-2 only supports 802.1Q mode.
956 */
957MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
958
959enum mlxsw_flood_table_type {
960 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
961 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
962 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
Ido Schimmelda0abcf2017-06-04 16:53:39 +0200963 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200964 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
965};
966
967/* reg_sfgc_table_type
968 * See mlxsw_flood_table_type
969 * Access: RW
970 *
971 * Note: FID offset and FID types are not supported in SwitchX-2.
972 */
973MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
974
975/* reg_sfgc_flood_table
976 * Flooding table index to associate with the specific type on the specific
977 * switch partition.
978 * Access: RW
979 */
980MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
981
982/* reg_sfgc_mid
983 * The multicast ID for the swid. Not supported for Spectrum
984 * Access: RW
985 */
986MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
987
988/* reg_sfgc_counter_set_type
989 * Counter Set Type for flow counters.
990 * Access: RW
991 */
992MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
993
994/* reg_sfgc_counter_index
995 * Counter Index for flow counters.
996 * Access: RW
997 */
998MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
999
1000static inline void
1001mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1002 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1003 enum mlxsw_flood_table_type table_type,
1004 unsigned int flood_table)
1005{
1006 MLXSW_REG_ZERO(sfgc, payload);
1007 mlxsw_reg_sfgc_type_set(payload, type);
1008 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1009 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1010 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1011 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1012}
1013
1014/* SFTR - Switch Flooding Table Register
1015 * -------------------------------------
1016 * The switch flooding table is used for flooding packet replication. The table
1017 * defines a bit mask of ports for packet replication.
1018 */
1019#define MLXSW_REG_SFTR_ID 0x2012
1020#define MLXSW_REG_SFTR_LEN 0x420
1021
Jiri Pirko21978dc2016-10-21 16:07:20 +02001022MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001023
1024/* reg_sftr_swid
1025 * Switch partition ID with which to associate the port.
1026 * Access: Index
1027 */
1028MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
1029
1030/* reg_sftr_flood_table
1031 * Flooding table index to associate with the specific type on the specific
1032 * switch partition.
1033 * Access: Index
1034 */
1035MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1036
1037/* reg_sftr_index
1038 * Index. Used as an index into the Flooding Table in case the table is
1039 * configured to use VID / FID or FID Offset.
1040 * Access: Index
1041 */
1042MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1043
1044/* reg_sftr_table_type
1045 * See mlxsw_flood_table_type
1046 * Access: RW
1047 */
1048MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1049
1050/* reg_sftr_range
1051 * Range of entries to update
1052 * Access: Index
1053 */
1054MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1055
1056/* reg_sftr_port
1057 * Local port membership (1 bit per port).
1058 * Access: RW
1059 */
1060MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1061
1062/* reg_sftr_cpu_port_mask
1063 * CPU port mask (1 bit per port).
1064 * Access: W
1065 */
1066MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1067
1068static inline void mlxsw_reg_sftr_pack(char *payload,
1069 unsigned int flood_table,
1070 unsigned int index,
1071 enum mlxsw_flood_table_type table_type,
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001072 unsigned int range, u8 port, bool set)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001073{
1074 MLXSW_REG_ZERO(sftr, payload);
1075 mlxsw_reg_sftr_swid_set(payload, 0);
1076 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1077 mlxsw_reg_sftr_index_set(payload, index);
1078 mlxsw_reg_sftr_table_type_set(payload, table_type);
1079 mlxsw_reg_sftr_range_set(payload, range);
Ido Schimmelbc2055f2015-10-16 14:01:23 +02001080 mlxsw_reg_sftr_port_set(payload, port, set);
1081 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001082}
1083
Ido Schimmel41933272016-01-27 15:20:17 +01001084/* SFDF - Switch Filtering DB Flush
1085 * --------------------------------
1086 * The switch filtering DB flush register is used to flush the FDB.
1087 * Note that FDB notifications are flushed as well.
1088 */
1089#define MLXSW_REG_SFDF_ID 0x2013
1090#define MLXSW_REG_SFDF_LEN 0x14
1091
Jiri Pirko21978dc2016-10-21 16:07:20 +02001092MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
Ido Schimmel41933272016-01-27 15:20:17 +01001093
1094/* reg_sfdf_swid
1095 * Switch partition ID.
1096 * Access: Index
1097 */
1098MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1099
1100enum mlxsw_reg_sfdf_flush_type {
1101 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1102 MLXSW_REG_SFDF_FLUSH_PER_FID,
1103 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1104 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1105 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1106 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1107};
1108
1109/* reg_sfdf_flush_type
1110 * Flush type.
1111 * 0 - All SWID dynamic entries are flushed.
1112 * 1 - All FID dynamic entries are flushed.
1113 * 2 - All dynamic entries pointing to port are flushed.
1114 * 3 - All FID dynamic entries pointing to port are flushed.
1115 * 4 - All dynamic entries pointing to LAG are flushed.
1116 * 5 - All FID dynamic entries pointing to LAG are flushed.
1117 * Access: RW
1118 */
1119MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1120
1121/* reg_sfdf_flush_static
1122 * Static.
1123 * 0 - Flush only dynamic entries.
1124 * 1 - Flush both dynamic and static entries.
1125 * Access: RW
1126 */
1127MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1128
1129static inline void mlxsw_reg_sfdf_pack(char *payload,
1130 enum mlxsw_reg_sfdf_flush_type type)
1131{
1132 MLXSW_REG_ZERO(sfdf, payload);
1133 mlxsw_reg_sfdf_flush_type_set(payload, type);
1134 mlxsw_reg_sfdf_flush_static_set(payload, true);
1135}
1136
1137/* reg_sfdf_fid
1138 * FID to flush.
1139 * Access: RW
1140 */
1141MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1142
1143/* reg_sfdf_system_port
1144 * Port to flush.
1145 * Access: RW
1146 */
1147MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1148
1149/* reg_sfdf_port_fid_system_port
1150 * Port to flush, pointed to by FID.
1151 * Access: RW
1152 */
1153MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1154
1155/* reg_sfdf_lag_id
1156 * LAG ID to flush.
1157 * Access: RW
1158 */
1159MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1160
1161/* reg_sfdf_lag_fid_lag_id
1162 * LAG ID to flush, pointed to by FID.
1163 * Access: RW
1164 */
1165MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1166
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001167/* SLDR - Switch LAG Descriptor Register
1168 * -----------------------------------------
1169 * The switch LAG descriptor register is populated by LAG descriptors.
1170 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
1171 * max_lag-1.
1172 */
1173#define MLXSW_REG_SLDR_ID 0x2014
1174#define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
1175
Jiri Pirko21978dc2016-10-21 16:07:20 +02001176MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001177
1178enum mlxsw_reg_sldr_op {
1179 /* Indicates a creation of a new LAG-ID, lag_id must be valid */
1180 MLXSW_REG_SLDR_OP_LAG_CREATE,
1181 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1182 /* Ports that appear in the list have the Distributor enabled */
1183 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1184 /* Removes ports from the disributor list */
1185 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1186};
1187
1188/* reg_sldr_op
1189 * Operation.
1190 * Access: RW
1191 */
1192MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1193
1194/* reg_sldr_lag_id
1195 * LAG identifier. The lag_id is the index into the LAG descriptor table.
1196 * Access: Index
1197 */
1198MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1199
1200static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1201{
1202 MLXSW_REG_ZERO(sldr, payload);
1203 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1204 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1205}
1206
1207static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1208{
1209 MLXSW_REG_ZERO(sldr, payload);
1210 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1211 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1212}
1213
1214/* reg_sldr_num_ports
1215 * The number of member ports of the LAG.
1216 * Reserved for Create / Destroy operations
1217 * For Add / Remove operations - indicates the number of ports in the list.
1218 * Access: RW
1219 */
1220MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1221
1222/* reg_sldr_system_port
1223 * System port.
1224 * Access: RW
1225 */
1226MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1227
1228static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1229 u8 local_port)
1230{
1231 MLXSW_REG_ZERO(sldr, payload);
1232 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1233 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1234 mlxsw_reg_sldr_num_ports_set(payload, 1);
1235 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1236}
1237
1238static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1239 u8 local_port)
1240{
1241 MLXSW_REG_ZERO(sldr, payload);
1242 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1243 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1244 mlxsw_reg_sldr_num_ports_set(payload, 1);
1245 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1246}
1247
1248/* SLCR - Switch LAG Configuration 2 Register
1249 * -------------------------------------------
1250 * The Switch LAG Configuration register is used for configuring the
1251 * LAG properties of the switch.
1252 */
1253#define MLXSW_REG_SLCR_ID 0x2015
1254#define MLXSW_REG_SLCR_LEN 0x10
1255
Jiri Pirko21978dc2016-10-21 16:07:20 +02001256MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001257
1258enum mlxsw_reg_slcr_pp {
1259 /* Global Configuration (for all ports) */
1260 MLXSW_REG_SLCR_PP_GLOBAL,
1261 /* Per port configuration, based on local_port field */
1262 MLXSW_REG_SLCR_PP_PER_PORT,
1263};
1264
1265/* reg_slcr_pp
1266 * Per Port Configuration
1267 * Note: Reading at Global mode results in reading port 1 configuration.
1268 * Access: Index
1269 */
1270MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1271
1272/* reg_slcr_local_port
1273 * Local port number
1274 * Supported from CPU port
1275 * Not supported from router port
1276 * Reserved when pp = Global Configuration
1277 * Access: Index
1278 */
1279MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1280
1281enum mlxsw_reg_slcr_type {
1282 MLXSW_REG_SLCR_TYPE_CRC, /* default */
1283 MLXSW_REG_SLCR_TYPE_XOR,
1284 MLXSW_REG_SLCR_TYPE_RANDOM,
1285};
1286
1287/* reg_slcr_type
1288 * Hash type
1289 * Access: RW
1290 */
1291MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1292
1293/* Ingress port */
1294#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1295/* SMAC - for IPv4 and IPv6 packets */
1296#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1297/* SMAC - for non-IP packets */
1298#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1299#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1300 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1301 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1302/* DMAC - for IPv4 and IPv6 packets */
1303#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1304/* DMAC - for non-IP packets */
1305#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1306#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1307 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1308 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1309/* Ethertype - for IPv4 and IPv6 packets */
1310#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1311/* Ethertype - for non-IP packets */
1312#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1313#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1314 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1315 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1316/* VLAN ID - for IPv4 and IPv6 packets */
1317#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1318/* VLAN ID - for non-IP packets */
1319#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1320#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1321 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1322 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1323/* Source IP address (can be IPv4 or IPv6) */
1324#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1325/* Destination IP address (can be IPv4 or IPv6) */
1326#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1327/* TCP/UDP source port */
1328#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1329/* TCP/UDP destination port*/
1330#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1331/* IPv4 Protocol/IPv6 Next Header */
1332#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1333/* IPv6 Flow label */
1334#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1335/* SID - FCoE source ID */
1336#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1337/* DID - FCoE destination ID */
1338#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1339/* OXID - FCoE originator exchange ID */
1340#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1341/* Destination QP number - for RoCE packets */
1342#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1343
1344/* reg_slcr_lag_hash
1345 * LAG hashing configuration. This is a bitmask, in which each set
1346 * bit includes the corresponding item in the LAG hash calculation.
1347 * The default lag_hash contains SMAC, DMAC, VLANID and
1348 * Ethertype (for all packet types).
1349 * Access: RW
1350 */
1351MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1352
1353static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash)
1354{
1355 MLXSW_REG_ZERO(slcr, payload);
1356 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
Elad Raz18c2d2c2016-09-19 08:28:24 +02001357 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001358 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1359}
1360
1361/* SLCOR - Switch LAG Collector Register
1362 * -------------------------------------
1363 * The Switch LAG Collector register controls the Local Port membership
1364 * in a LAG and enablement of the collector.
1365 */
1366#define MLXSW_REG_SLCOR_ID 0x2016
1367#define MLXSW_REG_SLCOR_LEN 0x10
1368
Jiri Pirko21978dc2016-10-21 16:07:20 +02001369MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
Jiri Pirkod1d40be2015-12-03 12:12:25 +01001370
1371enum mlxsw_reg_slcor_col {
1372 /* Port is added with collector disabled */
1373 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1374 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1375 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1376 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1377};
1378
1379/* reg_slcor_col
1380 * Collector configuration
1381 * Access: RW
1382 */
1383MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1384
1385/* reg_slcor_local_port
1386 * Local port number
1387 * Not supported for CPU port
1388 * Access: Index
1389 */
1390MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1391
1392/* reg_slcor_lag_id
1393 * LAG Identifier. Index into the LAG descriptor table.
1394 * Access: Index
1395 */
1396MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1397
1398/* reg_slcor_port_index
1399 * Port index in the LAG list. Only valid on Add Port to LAG col.
1400 * Valid range is from 0 to cap_max_lag_members-1
1401 * Access: RW
1402 */
1403MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1404
1405static inline void mlxsw_reg_slcor_pack(char *payload,
1406 u8 local_port, u16 lag_id,
1407 enum mlxsw_reg_slcor_col col)
1408{
1409 MLXSW_REG_ZERO(slcor, payload);
1410 mlxsw_reg_slcor_col_set(payload, col);
1411 mlxsw_reg_slcor_local_port_set(payload, local_port);
1412 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1413}
1414
1415static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1416 u8 local_port, u16 lag_id,
1417 u8 port_index)
1418{
1419 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1420 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1421 mlxsw_reg_slcor_port_index_set(payload, port_index);
1422}
1423
1424static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1425 u8 local_port, u16 lag_id)
1426{
1427 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1428 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1429}
1430
1431static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1432 u8 local_port, u16 lag_id)
1433{
1434 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1435 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1436}
1437
1438static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1439 u8 local_port, u16 lag_id)
1440{
1441 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1442 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1443}
1444
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001445/* SPMLR - Switch Port MAC Learning Register
1446 * -----------------------------------------
1447 * Controls the Switch MAC learning policy per port.
1448 */
1449#define MLXSW_REG_SPMLR_ID 0x2018
1450#define MLXSW_REG_SPMLR_LEN 0x8
1451
Jiri Pirko21978dc2016-10-21 16:07:20 +02001452MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001453
1454/* reg_spmlr_local_port
1455 * Local port number.
1456 * Access: Index
1457 */
1458MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1459
1460/* reg_spmlr_sub_port
1461 * Virtual port within the physical port.
1462 * Should be set to 0 when virtual ports are not enabled on the port.
1463 * Access: Index
1464 */
1465MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1466
1467enum mlxsw_reg_spmlr_learn_mode {
1468 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1469 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1470 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1471};
1472
1473/* reg_spmlr_learn_mode
1474 * Learning mode on the port.
1475 * 0 - Learning disabled.
1476 * 2 - Learning enabled.
1477 * 3 - Security mode.
1478 *
1479 * In security mode the switch does not learn MACs on the port, but uses the
1480 * SMAC to see if it exists on another ingress port. If so, the packet is
1481 * classified as a bad packet and is discarded unless the software registers
1482 * to receive port security error packets usign HPKT.
1483 */
1484MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1485
1486static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1487 enum mlxsw_reg_spmlr_learn_mode mode)
1488{
1489 MLXSW_REG_ZERO(spmlr, payload);
1490 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1491 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1492 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1493}
1494
Ido Schimmel64790232015-10-16 14:01:33 +02001495/* SVFA - Switch VID to FID Allocation Register
1496 * --------------------------------------------
1497 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
1498 * virtualized ports.
1499 */
1500#define MLXSW_REG_SVFA_ID 0x201C
1501#define MLXSW_REG_SVFA_LEN 0x10
1502
Jiri Pirko21978dc2016-10-21 16:07:20 +02001503MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
Ido Schimmel64790232015-10-16 14:01:33 +02001504
1505/* reg_svfa_swid
1506 * Switch partition ID.
1507 * Access: Index
1508 */
1509MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1510
1511/* reg_svfa_local_port
1512 * Local port number.
1513 * Access: Index
1514 *
1515 * Note: Reserved for 802.1Q FIDs.
1516 */
1517MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1518
1519enum mlxsw_reg_svfa_mt {
1520 MLXSW_REG_SVFA_MT_VID_TO_FID,
1521 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1522};
1523
1524/* reg_svfa_mapping_table
1525 * Mapping table:
1526 * 0 - VID to FID
1527 * 1 - {Port, VID} to FID
1528 * Access: Index
1529 *
1530 * Note: Reserved for SwitchX-2.
1531 */
1532MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1533
1534/* reg_svfa_v
1535 * Valid.
1536 * Valid if set.
1537 * Access: RW
1538 *
1539 * Note: Reserved for SwitchX-2.
1540 */
1541MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1542
1543/* reg_svfa_fid
1544 * Filtering ID.
1545 * Access: RW
1546 */
1547MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1548
1549/* reg_svfa_vid
1550 * VLAN ID.
1551 * Access: Index
1552 */
1553MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1554
1555/* reg_svfa_counter_set_type
1556 * Counter set type for flow counters.
1557 * Access: RW
1558 *
1559 * Note: Reserved for SwitchX-2.
1560 */
1561MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1562
1563/* reg_svfa_counter_index
1564 * Counter index for flow counters.
1565 * Access: RW
1566 *
1567 * Note: Reserved for SwitchX-2.
1568 */
1569MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1570
1571static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1572 enum mlxsw_reg_svfa_mt mt, bool valid,
1573 u16 fid, u16 vid)
1574{
1575 MLXSW_REG_ZERO(svfa, payload);
1576 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1577 mlxsw_reg_svfa_swid_set(payload, 0);
1578 mlxsw_reg_svfa_local_port_set(payload, local_port);
1579 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1580 mlxsw_reg_svfa_v_set(payload, valid);
1581 mlxsw_reg_svfa_fid_set(payload, fid);
1582 mlxsw_reg_svfa_vid_set(payload, vid);
1583}
1584
Ido Schimmel1f65da72015-10-16 14:01:34 +02001585/* SVPE - Switch Virtual-Port Enabling Register
1586 * --------------------------------------------
1587 * Enables port virtualization.
1588 */
1589#define MLXSW_REG_SVPE_ID 0x201E
1590#define MLXSW_REG_SVPE_LEN 0x4
1591
Jiri Pirko21978dc2016-10-21 16:07:20 +02001592MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
Ido Schimmel1f65da72015-10-16 14:01:34 +02001593
1594/* reg_svpe_local_port
1595 * Local port number
1596 * Access: Index
1597 *
1598 * Note: CPU port is not supported (uses VLAN mode only).
1599 */
1600MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1601
1602/* reg_svpe_vp_en
1603 * Virtual port enable.
1604 * 0 - Disable, VLAN mode (VID to FID).
1605 * 1 - Enable, Virtual port mode ({Port, VID} to FID).
1606 * Access: RW
1607 */
1608MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1609
1610static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1611 bool enable)
1612{
1613 MLXSW_REG_ZERO(svpe, payload);
1614 mlxsw_reg_svpe_local_port_set(payload, local_port);
1615 mlxsw_reg_svpe_vp_en_set(payload, enable);
1616}
1617
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001618/* SFMR - Switch FID Management Register
1619 * -------------------------------------
1620 * Creates and configures FIDs.
1621 */
1622#define MLXSW_REG_SFMR_ID 0x201F
1623#define MLXSW_REG_SFMR_LEN 0x18
1624
Jiri Pirko21978dc2016-10-21 16:07:20 +02001625MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
Ido Schimmelf1fb6932015-10-16 14:01:32 +02001626
1627enum mlxsw_reg_sfmr_op {
1628 MLXSW_REG_SFMR_OP_CREATE_FID,
1629 MLXSW_REG_SFMR_OP_DESTROY_FID,
1630};
1631
1632/* reg_sfmr_op
1633 * Operation.
1634 * 0 - Create or edit FID.
1635 * 1 - Destroy FID.
1636 * Access: WO
1637 */
1638MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1639
1640/* reg_sfmr_fid
1641 * Filtering ID.
1642 * Access: Index
1643 */
1644MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1645
1646/* reg_sfmr_fid_offset
1647 * FID offset.
1648 * Used to point into the flooding table selected by SFGC register if
1649 * the table is of type FID-Offset. Otherwise, this field is reserved.
1650 * Access: RW
1651 */
1652MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1653
1654/* reg_sfmr_vtfp
1655 * Valid Tunnel Flood Pointer.
1656 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1657 * Access: RW
1658 *
1659 * Note: Reserved for 802.1Q FIDs.
1660 */
1661MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1662
1663/* reg_sfmr_nve_tunnel_flood_ptr
1664 * Underlay Flooding and BC Pointer.
1665 * Used as a pointer to the first entry of the group based link lists of
1666 * flooding or BC entries (for NVE tunnels).
1667 * Access: RW
1668 */
1669MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1670
1671/* reg_sfmr_vv
1672 * VNI Valid.
1673 * If not set, then vni is reserved.
1674 * Access: RW
1675 *
1676 * Note: Reserved for 802.1Q FIDs.
1677 */
1678MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1679
1680/* reg_sfmr_vni
1681 * Virtual Network Identifier.
1682 * Access: RW
1683 *
1684 * Note: A given VNI can only be assigned to one FID.
1685 */
1686MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1687
1688static inline void mlxsw_reg_sfmr_pack(char *payload,
1689 enum mlxsw_reg_sfmr_op op, u16 fid,
1690 u16 fid_offset)
1691{
1692 MLXSW_REG_ZERO(sfmr, payload);
1693 mlxsw_reg_sfmr_op_set(payload, op);
1694 mlxsw_reg_sfmr_fid_set(payload, fid);
1695 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1696 mlxsw_reg_sfmr_vtfp_set(payload, false);
1697 mlxsw_reg_sfmr_vv_set(payload, false);
1698}
1699
Ido Schimmela4feea72015-10-16 14:01:36 +02001700/* SPVMLR - Switch Port VLAN MAC Learning Register
1701 * -----------------------------------------------
1702 * Controls the switch MAC learning policy per {Port, VID}.
1703 */
1704#define MLXSW_REG_SPVMLR_ID 0x2020
1705#define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
1706#define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
Jiri Pirkoe9093b12017-03-14 14:00:01 +01001707#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
Ido Schimmela4feea72015-10-16 14:01:36 +02001708#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1709 MLXSW_REG_SPVMLR_REC_LEN * \
1710 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1711
Jiri Pirko21978dc2016-10-21 16:07:20 +02001712MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
Ido Schimmela4feea72015-10-16 14:01:36 +02001713
1714/* reg_spvmlr_local_port
1715 * Local ingress port.
1716 * Access: Index
1717 *
1718 * Note: CPU port is not supported.
1719 */
1720MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1721
1722/* reg_spvmlr_num_rec
1723 * Number of records to update.
1724 * Access: OP
1725 */
1726MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1727
1728/* reg_spvmlr_rec_learn_enable
1729 * 0 - Disable learning for {Port, VID}.
1730 * 1 - Enable learning for {Port, VID}.
1731 * Access: RW
1732 */
1733MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1734 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1735
1736/* reg_spvmlr_rec_vid
1737 * VLAN ID to be added/removed from port or for querying.
1738 * Access: Index
1739 */
1740MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1741 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1742
1743static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1744 u16 vid_begin, u16 vid_end,
1745 bool learn_enable)
1746{
1747 int num_rec = vid_end - vid_begin + 1;
1748 int i;
1749
1750 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1751
1752 MLXSW_REG_ZERO(spvmlr, payload);
1753 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1754 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1755
1756 for (i = 0; i < num_rec; i++) {
1757 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1758 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1759 }
1760}
1761
Nogah Frankelad53fa02017-11-06 07:23:44 +01001762/* CWTP - Congetion WRED ECN TClass Profile
1763 * ----------------------------------------
1764 * Configures the profiles for queues of egress port and traffic class
1765 */
1766#define MLXSW_REG_CWTP_ID 0x2802
1767#define MLXSW_REG_CWTP_BASE_LEN 0x28
1768#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
1769#define MLXSW_REG_CWTP_LEN 0x40
1770
1771MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
1772
1773/* reg_cwtp_local_port
1774 * Local port number
1775 * Not supported for CPU port
1776 * Access: Index
1777 */
1778MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
1779
1780/* reg_cwtp_traffic_class
1781 * Traffic Class to configure
1782 * Access: Index
1783 */
1784MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
1785
1786/* reg_cwtp_profile_min
1787 * Minimum Average Queue Size of the profile in cells.
1788 * Access: RW
1789 */
1790MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
1791 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
1792
1793/* reg_cwtp_profile_percent
1794 * Percentage of WRED and ECN marking for maximum Average Queue size
1795 * Range is 0 to 100, units of integer percentage
1796 * Access: RW
1797 */
1798MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
1799 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1800
1801/* reg_cwtp_profile_max
1802 * Maximum Average Queue size of the profile in cells
1803 * Access: RW
1804 */
1805MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
1806 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1807
1808#define MLXSW_REG_CWTP_MIN_VALUE 64
1809#define MLXSW_REG_CWTP_MAX_PROFILE 2
1810#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
1811
1812static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
1813 u8 traffic_class)
1814{
1815 int i;
1816
1817 MLXSW_REG_ZERO(cwtp, payload);
1818 mlxsw_reg_cwtp_local_port_set(payload, local_port);
1819 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
1820
1821 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
1822 mlxsw_reg_cwtp_profile_min_set(payload, i,
1823 MLXSW_REG_CWTP_MIN_VALUE);
1824 mlxsw_reg_cwtp_profile_max_set(payload, i,
1825 MLXSW_REG_CWTP_MIN_VALUE);
1826 }
1827}
1828
1829#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
1830
1831static inline void
1832mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
1833 u32 probability)
1834{
1835 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
1836
1837 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
1838 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
1839 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
1840}
1841
1842/* CWTPM - Congestion WRED ECN TClass and Pool Mapping
1843 * ---------------------------------------------------
1844 * The CWTPM register maps each egress port and traffic class to profile num.
1845 */
1846#define MLXSW_REG_CWTPM_ID 0x2803
1847#define MLXSW_REG_CWTPM_LEN 0x44
1848
1849MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
1850
1851/* reg_cwtpm_local_port
1852 * Local port number
1853 * Not supported for CPU port
1854 * Access: Index
1855 */
1856MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
1857
1858/* reg_cwtpm_traffic_class
1859 * Traffic Class to configure
1860 * Access: Index
1861 */
1862MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
1863
1864/* reg_cwtpm_ew
1865 * Control enablement of WRED for traffic class:
1866 * 0 - Disable
1867 * 1 - Enable
1868 * Access: RW
1869 */
1870MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
1871
1872/* reg_cwtpm_ee
1873 * Control enablement of ECN for traffic class:
1874 * 0 - Disable
1875 * 1 - Enable
1876 * Access: RW
1877 */
1878MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
1879
1880/* reg_cwtpm_tcp_g
1881 * TCP Green Profile.
1882 * Index of the profile within {port, traffic class} to use.
1883 * 0 for disabling both WRED and ECN for this type of traffic.
1884 * Access: RW
1885 */
1886MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
1887
1888/* reg_cwtpm_tcp_y
1889 * TCP Yellow Profile.
1890 * Index of the profile within {port, traffic class} to use.
1891 * 0 for disabling both WRED and ECN for this type of traffic.
1892 * Access: RW
1893 */
1894MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
1895
1896/* reg_cwtpm_tcp_r
1897 * TCP Red Profile.
1898 * Index of the profile within {port, traffic class} to use.
1899 * 0 for disabling both WRED and ECN for this type of traffic.
1900 * Access: RW
1901 */
1902MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
1903
1904/* reg_cwtpm_ntcp_g
1905 * Non-TCP Green Profile.
1906 * Index of the profile within {port, traffic class} to use.
1907 * 0 for disabling both WRED and ECN for this type of traffic.
1908 * Access: RW
1909 */
1910MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
1911
1912/* reg_cwtpm_ntcp_y
1913 * Non-TCP Yellow Profile.
1914 * Index of the profile within {port, traffic class} to use.
1915 * 0 for disabling both WRED and ECN for this type of traffic.
1916 * Access: RW
1917 */
1918MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
1919
1920/* reg_cwtpm_ntcp_r
1921 * Non-TCP Red Profile.
1922 * Index of the profile within {port, traffic class} to use.
1923 * 0 for disabling both WRED and ECN for this type of traffic.
1924 * Access: RW
1925 */
1926MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
1927
1928#define MLXSW_REG_CWTPM_RESET_PROFILE 0
1929
1930static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
1931 u8 traffic_class, u8 profile,
1932 bool wred, bool ecn)
1933{
1934 MLXSW_REG_ZERO(cwtpm, payload);
1935 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
1936 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
1937 mlxsw_reg_cwtpm_ew_set(payload, wred);
1938 mlxsw_reg_cwtpm_ee_set(payload, ecn);
1939 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
1940 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
1941 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
1942 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
1943 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
1944 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
1945}
1946
Ido Schimmel7050f432018-07-18 11:14:40 +03001947/* PGCR - Policy-Engine General Configuration Register
1948 * ---------------------------------------------------
1949 * This register configures general Policy-Engine settings.
1950 */
1951#define MLXSW_REG_PGCR_ID 0x3001
1952#define MLXSW_REG_PGCR_LEN 0x20
1953
1954MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
1955
1956/* reg_pgcr_default_action_pointer_base
1957 * Default action pointer base. Each region has a default action pointer
1958 * which is equal to default_action_pointer_base + region_id.
1959 * Access: RW
1960 */
1961MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
1962
1963static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
1964{
1965 MLXSW_REG_ZERO(pgcr, payload);
1966 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
1967}
1968
Jiri Pirkoaf7170e2017-02-03 10:28:57 +01001969/* PPBT - Policy-Engine Port Binding Table
1970 * ---------------------------------------
1971 * This register is used for configuration of the Port Binding Table.
1972 */
1973#define MLXSW_REG_PPBT_ID 0x3002
1974#define MLXSW_REG_PPBT_LEN 0x14
1975
1976MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
1977
1978enum mlxsw_reg_pxbt_e {
1979 MLXSW_REG_PXBT_E_IACL,
1980 MLXSW_REG_PXBT_E_EACL,
1981};
1982
1983/* reg_ppbt_e
1984 * Access: Index
1985 */
1986MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
1987
1988enum mlxsw_reg_pxbt_op {
1989 MLXSW_REG_PXBT_OP_BIND,
1990 MLXSW_REG_PXBT_OP_UNBIND,
1991};
1992
1993/* reg_ppbt_op
1994 * Access: RW
1995 */
1996MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
1997
1998/* reg_ppbt_local_port
1999 * Local port. Not including CPU port.
2000 * Access: Index
2001 */
2002MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
2003
2004/* reg_ppbt_g
2005 * group - When set, the binding is of an ACL group. When cleared,
2006 * the binding is of an ACL.
2007 * Must be set to 1 for Spectrum.
2008 * Access: RW
2009 */
2010MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2011
2012/* reg_ppbt_acl_info
2013 * ACL/ACL group identifier. If the g bit is set, this field should hold
2014 * the acl_group_id, else it should hold the acl_id.
2015 * Access: RW
2016 */
2017MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2018
2019static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2020 enum mlxsw_reg_pxbt_op op,
2021 u8 local_port, u16 acl_info)
2022{
2023 MLXSW_REG_ZERO(ppbt, payload);
2024 mlxsw_reg_ppbt_e_set(payload, e);
2025 mlxsw_reg_ppbt_op_set(payload, op);
2026 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2027 mlxsw_reg_ppbt_g_set(payload, true);
2028 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2029}
2030
Jiri Pirko3279da42017-02-03 10:28:53 +01002031/* PACL - Policy-Engine ACL Register
2032 * ---------------------------------
2033 * This register is used for configuration of the ACL.
2034 */
2035#define MLXSW_REG_PACL_ID 0x3004
2036#define MLXSW_REG_PACL_LEN 0x70
2037
2038MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2039
2040/* reg_pacl_v
2041 * Valid. Setting the v bit makes the ACL valid. It should not be cleared
2042 * while the ACL is bounded to either a port, VLAN or ACL rule.
2043 * Access: RW
2044 */
2045MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2046
2047/* reg_pacl_acl_id
2048 * An identifier representing the ACL (managed by software)
2049 * Range 0 .. cap_max_acl_regions - 1
2050 * Access: Index
2051 */
2052MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2053
2054#define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2055
2056/* reg_pacl_tcam_region_info
2057 * Opaque object that represents a TCAM region.
2058 * Obtained through PTAR register.
2059 * Access: RW
2060 */
2061MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2062 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2063
2064static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2065 bool valid, const char *tcam_region_info)
2066{
2067 MLXSW_REG_ZERO(pacl, payload);
2068 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2069 mlxsw_reg_pacl_v_set(payload, valid);
2070 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2071}
2072
Jiri Pirko10fabef2017-02-03 10:28:54 +01002073/* PAGT - Policy-Engine ACL Group Table
2074 * ------------------------------------
2075 * This register is used for configuration of the ACL Group Table.
2076 */
2077#define MLXSW_REG_PAGT_ID 0x3005
2078#define MLXSW_REG_PAGT_BASE_LEN 0x30
2079#define MLXSW_REG_PAGT_ACL_LEN 4
2080#define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2081#define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2082 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2083
2084MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2085
2086/* reg_pagt_size
2087 * Number of ACLs in the group.
2088 * Size 0 invalidates a group.
2089 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
2090 * Total number of ACLs in all groups must be lower or equal
2091 * to cap_max_acl_tot_groups
2092 * Note: a group which is binded must not be invalidated
2093 * Access: Index
2094 */
2095MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2096
2097/* reg_pagt_acl_group_id
2098 * An identifier (numbered from 0..cap_max_acl_groups-1) representing
2099 * the ACL Group identifier (managed by software).
2100 * Access: Index
2101 */
2102MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2103
2104/* reg_pagt_acl_id
2105 * ACL identifier
2106 * Access: RW
2107 */
2108MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2109
2110static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2111{
2112 MLXSW_REG_ZERO(pagt, payload);
2113 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2114}
2115
2116static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2117 u16 acl_id)
2118{
2119 u8 size = mlxsw_reg_pagt_size_get(payload);
2120
2121 if (index >= size)
2122 mlxsw_reg_pagt_size_set(payload, index + 1);
2123 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2124}
2125
Jiri Pirkod9c26612017-02-03 10:28:55 +01002126/* PTAR - Policy-Engine TCAM Allocation Register
2127 * ---------------------------------------------
2128 * This register is used for allocation of regions in the TCAM.
2129 * Note: Query method is not supported on this register.
2130 */
2131#define MLXSW_REG_PTAR_ID 0x3006
2132#define MLXSW_REG_PTAR_BASE_LEN 0x20
2133#define MLXSW_REG_PTAR_KEY_ID_LEN 1
2134#define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2135#define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2136 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2137
2138MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2139
2140enum mlxsw_reg_ptar_op {
2141 /* allocate a TCAM region */
2142 MLXSW_REG_PTAR_OP_ALLOC,
2143 /* resize a TCAM region */
2144 MLXSW_REG_PTAR_OP_RESIZE,
2145 /* deallocate TCAM region */
2146 MLXSW_REG_PTAR_OP_FREE,
2147 /* test allocation */
2148 MLXSW_REG_PTAR_OP_TEST,
2149};
2150
2151/* reg_ptar_op
2152 * Access: OP
2153 */
2154MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2155
2156/* reg_ptar_action_set_type
2157 * Type of action set to be used on this region.
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002158 * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
Jiri Pirkod9c26612017-02-03 10:28:55 +01002159 * Access: WO
2160 */
2161MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2162
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002163enum mlxsw_reg_ptar_key_type {
2164 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
2165 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
2166};
2167
Jiri Pirkod9c26612017-02-03 10:28:55 +01002168/* reg_ptar_key_type
2169 * TCAM key type for the region.
Jiri Pirkod9c26612017-02-03 10:28:55 +01002170 * Access: WO
2171 */
2172MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2173
2174/* reg_ptar_region_size
2175 * TCAM region size. When allocating/resizing this is the requested size,
2176 * the response is the actual size. Note that actual size may be
2177 * larger than requested.
2178 * Allowed range 1 .. cap_max_rules-1
2179 * Reserved during op deallocate.
2180 * Access: WO
2181 */
2182MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2183
2184/* reg_ptar_region_id
2185 * Region identifier
2186 * Range 0 .. cap_max_regions-1
2187 * Access: Index
2188 */
2189MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2190
2191/* reg_ptar_tcam_region_info
2192 * Opaque object that represents the TCAM region.
2193 * Returned when allocating a region.
2194 * Provided by software for ACL generation and region deallocation and resize.
2195 * Access: RW
2196 */
2197MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2198 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2199
2200/* reg_ptar_flexible_key_id
2201 * Identifier of the Flexible Key.
2202 * Only valid if key_type == "FLEX_KEY"
2203 * The key size will be rounded up to one of the following values:
2204 * 9B, 18B, 36B, 54B.
2205 * This field is reserved for in resize operation.
2206 * Access: WO
2207 */
2208MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2209 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2210
2211static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002212 enum mlxsw_reg_ptar_key_type key_type,
Jiri Pirkod9c26612017-02-03 10:28:55 +01002213 u16 region_size, u16 region_id,
2214 const char *tcam_region_info)
2215{
2216 MLXSW_REG_ZERO(ptar, payload);
2217 mlxsw_reg_ptar_op_set(payload, op);
2218 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
Jiri Pirko45e0620d2018-07-08 10:00:15 +03002219 mlxsw_reg_ptar_key_type_set(payload, key_type);
Jiri Pirkod9c26612017-02-03 10:28:55 +01002220 mlxsw_reg_ptar_region_size_set(payload, region_size);
2221 mlxsw_reg_ptar_region_id_set(payload, region_id);
2222 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2223}
2224
2225static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2226 u16 key_id)
2227{
2228 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2229}
2230
2231static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2232{
2233 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2234}
2235
Jiri Pirkod1206492017-02-03 10:28:59 +01002236/* PPBS - Policy-Engine Policy Based Switching Register
2237 * ----------------------------------------------------
2238 * This register retrieves and sets Policy Based Switching Table entries.
2239 */
2240#define MLXSW_REG_PPBS_ID 0x300C
2241#define MLXSW_REG_PPBS_LEN 0x14
2242
2243MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2244
2245/* reg_ppbs_pbs_ptr
2246 * Index into the PBS table.
2247 * For Spectrum, the index points to the KVD Linear.
2248 * Access: Index
2249 */
2250MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2251
2252/* reg_ppbs_system_port
2253 * Unique port identifier for the final destination of the packet.
2254 * Access: RW
2255 */
2256MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2257
2258static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2259 u16 system_port)
2260{
2261 MLXSW_REG_ZERO(ppbs, payload);
2262 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2263 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2264}
2265
Jiri Pirko937b6822017-02-03 10:28:58 +01002266/* PRCR - Policy-Engine Rules Copy Register
2267 * ----------------------------------------
2268 * This register is used for accessing rules within a TCAM region.
2269 */
2270#define MLXSW_REG_PRCR_ID 0x300D
2271#define MLXSW_REG_PRCR_LEN 0x40
2272
2273MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2274
2275enum mlxsw_reg_prcr_op {
2276 /* Move rules. Moves the rules from "tcam_region_info" starting
2277 * at offset "offset" to "dest_tcam_region_info"
2278 * at offset "dest_offset."
2279 */
2280 MLXSW_REG_PRCR_OP_MOVE,
2281 /* Copy rules. Copies the rules from "tcam_region_info" starting
2282 * at offset "offset" to "dest_tcam_region_info"
2283 * at offset "dest_offset."
2284 */
2285 MLXSW_REG_PRCR_OP_COPY,
2286};
2287
2288/* reg_prcr_op
2289 * Access: OP
2290 */
2291MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2292
2293/* reg_prcr_offset
2294 * Offset within the source region to copy/move from.
2295 * Access: Index
2296 */
2297MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2298
2299/* reg_prcr_size
2300 * The number of rules to copy/move.
2301 * Access: WO
2302 */
2303MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2304
2305/* reg_prcr_tcam_region_info
2306 * Opaque object that represents the source TCAM region.
2307 * Access: Index
2308 */
2309MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2310 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2311
2312/* reg_prcr_dest_offset
2313 * Offset within the source region to copy/move to.
2314 * Access: Index
2315 */
2316MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2317
2318/* reg_prcr_dest_tcam_region_info
2319 * Opaque object that represents the destination TCAM region.
2320 * Access: Index
2321 */
2322MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2323 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2324
2325static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2326 const char *src_tcam_region_info,
2327 u16 src_offset,
2328 const char *dest_tcam_region_info,
2329 u16 dest_offset, u16 size)
2330{
2331 MLXSW_REG_ZERO(prcr, payload);
2332 mlxsw_reg_prcr_op_set(payload, op);
2333 mlxsw_reg_prcr_offset_set(payload, src_offset);
2334 mlxsw_reg_prcr_size_set(payload, size);
2335 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2336 src_tcam_region_info);
2337 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2338 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2339 dest_tcam_region_info);
2340}
2341
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002342/* PEFA - Policy-Engine Extended Flexible Action Register
2343 * ------------------------------------------------------
2344 * This register is used for accessing an extended flexible action entry
2345 * in the central KVD Linear Database.
2346 */
2347#define MLXSW_REG_PEFA_ID 0x300F
2348#define MLXSW_REG_PEFA_LEN 0xB0
2349
2350MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2351
2352/* reg_pefa_index
2353 * Index in the KVD Linear Centralized Database.
2354 * Access: Index
2355 */
2356MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2357
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002358/* reg_pefa_a
2359 * Index in the KVD Linear Centralized Database.
2360 * Activity
2361 * For a new entry: set if ca=0, clear if ca=1
2362 * Set if a packet lookup has hit on the specific entry
2363 * Access: RO
2364 */
2365MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2366
2367/* reg_pefa_ca
2368 * Clear activity
2369 * When write: activity is according to this field
2370 * When read: after reading the activity is cleared according to ca
2371 * Access: OP
2372 */
2373MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2374
Yotam Gigi58726562017-09-19 10:00:12 +02002375#define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002376
2377/* reg_pefa_flex_action_set
2378 * Action-set to perform when rule is matched.
2379 * Must be zero padded if action set is shorter.
2380 * Access: RW
2381 */
Yotam Gigi58726562017-09-19 10:00:12 +02002382MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002383
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002384static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002385 const char *flex_action_set)
2386{
2387 MLXSW_REG_ZERO(pefa, payload);
2388 mlxsw_reg_pefa_index_set(payload, index);
Jiri Pirko2d186ed42018-07-18 11:14:35 +03002389 mlxsw_reg_pefa_ca_set(payload, ca);
2390 if (flex_action_set)
2391 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2392 flex_action_set);
2393}
2394
2395static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2396{
2397 *p_a = mlxsw_reg_pefa_a_get(payload);
Jiri Pirkoe3426e12017-02-03 10:29:00 +01002398}
2399
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002400/* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
2401 * -----------------------------------------------------
2402 * This register is used for accessing rules within a TCAM region.
2403 * It is a new version of PTCE in order to support wider key,
2404 * mask and action within a TCAM region. This register is not supported
2405 * by SwitchX and SwitchX-2.
2406 */
2407#define MLXSW_REG_PTCE2_ID 0x3017
2408#define MLXSW_REG_PTCE2_LEN 0x1D8
2409
2410MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2411
2412/* reg_ptce2_v
2413 * Valid.
2414 * Access: RW
2415 */
2416MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2417
2418/* reg_ptce2_a
2419 * Activity. Set if a packet lookup has hit on the specific entry.
2420 * To clear the "a" bit, use "clear activity" op or "clear on read" op.
2421 * Access: RO
2422 */
2423MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2424
2425enum mlxsw_reg_ptce2_op {
2426 /* Read operation. */
2427 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2428 /* clear on read operation. Used to read entry
2429 * and clear Activity bit.
2430 */
2431 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2432 /* Write operation. Used to write a new entry to the table.
2433 * All R/W fields are relevant for new entry. Activity bit is set
2434 * for new entries - Note write with v = 0 will delete the entry.
2435 */
2436 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2437 /* Update action. Only action set will be updated. */
2438 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2439 /* Clear activity. A bit is cleared for the entry. */
2440 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2441};
2442
2443/* reg_ptce2_op
2444 * Access: OP
2445 */
2446MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2447
2448/* reg_ptce2_offset
2449 * Access: Index
2450 */
2451MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2452
Jiri Pirko42df8352018-07-08 23:51:24 +03002453/* reg_ptce2_priority
2454 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
2455 * Note: priority does not have to be unique per rule.
2456 * Within a region, higher priority should have lower offset (no limitation
2457 * between regions in a multi-region).
2458 * Access: RW
2459 */
2460MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2461
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002462/* reg_ptce2_tcam_region_info
2463 * Opaque object that represents the TCAM region.
2464 * Access: Index
2465 */
2466MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2467 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2468
Ido Schimmelaecefac2018-07-25 09:23:51 +03002469#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002470
2471/* reg_ptce2_flex_key_blocks
2472 * ACL Key.
2473 * Access: RW
2474 */
2475MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002476 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002477
2478/* reg_ptce2_mask
2479 * mask- in the same size as key. A bit that is set directs the TCAM
2480 * to compare the corresponding bit in key. A bit that is clear directs
2481 * the TCAM to ignore the corresponding bit in key.
2482 * Access: RW
2483 */
2484MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
Ido Schimmelaecefac2018-07-25 09:23:51 +03002485 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002486
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002487/* reg_ptce2_flex_action_set
2488 * ACL action set.
2489 * Access: RW
2490 */
2491MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
Yotam Gigi58726562017-09-19 10:00:12 +02002492 MLXSW_REG_FLEX_ACTION_SET_LEN);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002493
2494static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2495 enum mlxsw_reg_ptce2_op op,
2496 const char *tcam_region_info,
Jiri Pirko42df8352018-07-08 23:51:24 +03002497 u16 offset, u32 priority)
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002498{
2499 MLXSW_REG_ZERO(ptce2, payload);
2500 mlxsw_reg_ptce2_v_set(payload, valid);
2501 mlxsw_reg_ptce2_op_set(payload, op);
2502 mlxsw_reg_ptce2_offset_set(payload, offset);
Jiri Pirko42df8352018-07-08 23:51:24 +03002503 mlxsw_reg_ptce2_priority_set(payload, priority);
Jiri Pirko0171cdec2017-02-03 10:28:56 +01002504 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2505}
2506
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03002507/* PERPT - Policy-Engine ERP Table Register
2508 * ----------------------------------------
2509 * This register adds and removes eRPs from the eRP table.
2510 */
2511#define MLXSW_REG_PERPT_ID 0x3021
2512#define MLXSW_REG_PERPT_LEN 0x80
2513
2514MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2515
2516/* reg_perpt_erpt_bank
2517 * eRP table bank.
2518 * Range 0 .. cap_max_erp_table_banks - 1
2519 * Access: Index
2520 */
2521MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2522
2523/* reg_perpt_erpt_index
2524 * Index to eRP table within the eRP bank.
2525 * Range is 0 .. cap_max_erp_table_bank_size - 1
2526 * Access: Index
2527 */
2528MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2529
2530enum mlxsw_reg_perpt_key_size {
2531 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2532 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2533 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2534 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2535};
2536
2537/* reg_perpt_key_size
2538 * Access: OP
2539 */
2540MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2541
2542/* reg_perpt_bf_bypass
2543 * 0 - The eRP is used only if bloom filter state is set for the given
2544 * rule.
2545 * 1 - The eRP is used regardless of bloom filter state.
2546 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
2547 * Access: RW
2548 */
2549MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2550
2551/* reg_perpt_erp_id
2552 * eRP ID for use by the rules.
2553 * Access: RW
2554 */
2555MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2556
2557/* reg_perpt_erpt_base_bank
2558 * Base eRP table bank, points to head of erp_vector
2559 * Range is 0 .. cap_max_erp_table_banks - 1
2560 * Access: OP
2561 */
2562MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2563
2564/* reg_perpt_erpt_base_index
2565 * Base index to eRP table within the eRP bank
2566 * Range is 0 .. cap_max_erp_table_bank_size - 1
2567 * Access: OP
2568 */
2569MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2570
2571/* reg_perpt_erp_index_in_vector
2572 * eRP index in the vector.
2573 * Access: OP
2574 */
2575MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2576
2577/* reg_perpt_erp_vector
2578 * eRP vector.
2579 * Access: OP
2580 */
2581MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2582
2583/* reg_perpt_mask
2584 * Mask
2585 * 0 - A-TCAM will ignore the bit in key
2586 * 1 - A-TCAM will compare the bit in key
2587 * Access: RW
2588 */
2589MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2590
2591static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
2592 unsigned long *erp_vector,
2593 unsigned long size)
2594{
2595 unsigned long bit;
2596
2597 for_each_set_bit(bit, erp_vector, size)
2598 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
2599}
2600
2601static inline void
2602mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
2603 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
2604 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
2605 char *mask)
2606{
2607 MLXSW_REG_ZERO(perpt, payload);
2608 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
2609 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
2610 mlxsw_reg_perpt_key_size_set(payload, key_size);
2611 mlxsw_reg_perpt_bf_bypass_set(payload, true);
2612 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
2613 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
2614 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
2615 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
2616 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
2617}
2618
Jiri Pirko33907872018-07-18 11:14:37 +03002619/* PERAR - Policy-Engine Region Association Register
2620 * -------------------------------------------------
2621 * This register associates a hw region for region_id's. Changing on the fly
2622 * is supported by the device.
2623 */
2624#define MLXSW_REG_PERAR_ID 0x3026
2625#define MLXSW_REG_PERAR_LEN 0x08
2626
2627MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
2628
2629/* reg_perar_region_id
2630 * Region identifier
2631 * Range 0 .. cap_max_regions-1
2632 * Access: Index
2633 */
2634MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
2635
2636static inline unsigned int
2637mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
2638{
2639 return DIV_ROUND_UP(block_num, 4);
2640}
2641
2642/* reg_perar_hw_region
2643 * HW Region
2644 * Range 0 .. cap_max_regions-1
2645 * Default: hw_region = region_id
2646 * For a 8 key block region, 2 consecutive regions are used
2647 * For a 12 key block region, 3 consecutive regions are used
2648 * Access: RW
2649 */
2650MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
2651
2652static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
2653 u16 hw_region)
2654{
2655 MLXSW_REG_ZERO(perar, payload);
2656 mlxsw_reg_perar_region_id_set(payload, region_id);
2657 mlxsw_reg_perar_hw_region_set(payload, hw_region);
2658}
2659
Ido Schimmelaecefac2018-07-25 09:23:51 +03002660/* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
2661 * -----------------------------------------------------
2662 * This register is a new version of PTCE-V2 in order to support the
2663 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
2664 */
2665#define MLXSW_REG_PTCE3_ID 0x3027
2666#define MLXSW_REG_PTCE3_LEN 0xF0
2667
2668MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
2669
2670/* reg_ptce3_v
2671 * Valid.
2672 * Access: RW
2673 */
2674MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
2675
2676enum mlxsw_reg_ptce3_op {
2677 /* Write operation. Used to write a new entry to the table.
2678 * All R/W fields are relevant for new entry. Activity bit is set
2679 * for new entries. Write with v = 0 will delete the entry. Must
2680 * not be used if an entry exists.
2681 */
2682 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
2683 /* Update operation */
2684 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
2685 /* Read operation */
2686 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
2687};
2688
2689/* reg_ptce3_op
2690 * Access: OP
2691 */
2692MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
2693
2694/* reg_ptce3_priority
2695 * Priority of the rule. Higher values win.
2696 * For Spectrum-2 range is 1..cap_kvd_size - 1
2697 * Note: Priority does not have to be unique per rule.
2698 * Access: RW
2699 */
2700MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
2701
2702/* reg_ptce3_tcam_region_info
2703 * Opaque object that represents the TCAM region.
2704 * Access: Index
2705 */
2706MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
2707 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2708
2709/* reg_ptce3_flex2_key_blocks
2710 * ACL key. The key must be masked according to eRP (if exists) or
2711 * according to master mask.
2712 * Access: Index
2713 */
2714MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
2715 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2716
2717/* reg_ptce3_erp_id
2718 * eRP ID.
2719 * Access: Index
2720 */
2721MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
2722
2723/* reg_ptce3_delta_start
2724 * Start point of delta_value and delta_mask, in bits. Must not exceed
2725 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
2726 * Access: Index
2727 */
2728MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
2729
2730/* reg_ptce3_delta_mask
2731 * Delta mask.
2732 * 0 - Ignore relevant bit in delta_value
2733 * 1 - Compare relevant bit in delta_value
2734 * Delta mask must not be set for reserved fields in the key blocks.
2735 * Note: No delta when no eRPs. Thus, for regions with
2736 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
2737 * Access: Index
2738 */
2739MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
2740
2741/* reg_ptce3_delta_value
2742 * Delta value.
2743 * Bits which are masked by delta_mask must be 0.
2744 * Access: Index
2745 */
2746MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
2747
2748/* reg_ptce3_prune_vector
2749 * Pruning vector relative to the PERPT.erp_id.
2750 * Used for reducing lookups.
2751 * 0 - NEED: Do a lookup using the eRP.
2752 * 1 - PRUNE: Do not perform a lookup using the eRP.
2753 * Maybe be modified by PEAPBL and PEAPBM.
2754 * Note: In Spectrum-2, a region of 8 key blocks must be set to either
2755 * all 1's or all 0's.
2756 * Access: RW
2757 */
2758MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
2759
2760/* reg_ptce3_prune_ctcam
2761 * Pruning on C-TCAM. Used for reducing lookups.
2762 * 0 - NEED: Do a lookup in the C-TCAM.
2763 * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
2764 * Access: RW
2765 */
2766MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
2767
2768/* reg_ptce3_large_exists
2769 * Large entry key ID exists.
2770 * Within the region:
2771 * 0 - SINGLE: The large_entry_key_id is not currently in use.
2772 * For rule insert: The MSB of the key (blocks 6..11) will be added.
2773 * For rule delete: The MSB of the key will be removed.
2774 * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
2775 * For rule insert: The MSB of the key (blocks 6..11) will not be added.
2776 * For rule delete: The MSB of the key will not be removed.
2777 * Access: WO
2778 */
2779MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
2780
2781/* reg_ptce3_large_entry_key_id
2782 * Large entry key ID.
2783 * A key for 12 key blocks rules. Reserved when region has less than 12 key
2784 * blocks. Must be different for different keys which have the same common
2785 * 6 key blocks (MSB, blocks 6..11) key within a region.
2786 * Range is 0..cap_max_pe_large_key_id - 1
2787 * Access: RW
2788 */
2789MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
2790
2791/* reg_ptce3_action_pointer
2792 * Pointer to action.
2793 * Range is 0..cap_max_kvd_action_sets - 1
2794 * Access: RW
2795 */
2796MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
2797
2798static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
2799 enum mlxsw_reg_ptce3_op op,
2800 u32 priority,
2801 const char *tcam_region_info,
2802 const char *key, u8 erp_id,
2803 bool large_exists, u32 lkey_id,
2804 u32 action_pointer)
2805{
2806 MLXSW_REG_ZERO(ptce3, payload);
2807 mlxsw_reg_ptce3_v_set(payload, valid);
2808 mlxsw_reg_ptce3_op_set(payload, op);
2809 mlxsw_reg_ptce3_priority_set(payload, priority);
2810 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
2811 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
2812 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
2813 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
2814 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
2815 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
2816}
2817
Ido Schimmel481662a2018-07-18 11:14:38 +03002818/* PERCR - Policy-Engine Region Configuration Register
2819 * ---------------------------------------------------
2820 * This register configures the region parameters. The region_id must be
2821 * allocated.
2822 */
2823#define MLXSW_REG_PERCR_ID 0x302A
2824#define MLXSW_REG_PERCR_LEN 0x80
2825
2826MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
2827
2828/* reg_percr_region_id
2829 * Region identifier.
2830 * Range 0..cap_max_regions-1
2831 * Access: Index
2832 */
2833MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
2834
2835/* reg_percr_atcam_ignore_prune
2836 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
2837 * Access: RW
2838 */
2839MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
2840
2841/* reg_percr_ctcam_ignore_prune
2842 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
2843 * Access: RW
2844 */
2845MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
2846
2847/* reg_percr_bf_bypass
2848 * Bloom filter bypass.
2849 * 0 - Bloom filter is used (default)
2850 * 1 - Bloom filter is bypassed. The bypass is an OR condition of
2851 * region_id or eRP. See PERPT.bf_bypass
2852 * Access: RW
2853 */
2854MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
2855
2856/* reg_percr_master_mask
2857 * Master mask. Logical OR mask of all masks of all rules of a region
2858 * (both A-TCAM and C-TCAM). When there are no eRPs
2859 * (erpt_pointer_valid = 0), then this provides the mask.
2860 * Access: RW
2861 */
2862MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
2863
2864static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
2865{
2866 MLXSW_REG_ZERO(percr, payload);
2867 mlxsw_reg_percr_region_id_set(payload, region_id);
2868 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
2869 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
2870 mlxsw_reg_percr_bf_bypass_set(payload, true);
Ido Schimmel481662a2018-07-18 11:14:38 +03002871}
2872
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03002873/* PERERP - Policy-Engine Region eRP Register
2874 * ------------------------------------------
2875 * This register configures the region eRP. The region_id must be
2876 * allocated.
2877 */
2878#define MLXSW_REG_PERERP_ID 0x302B
2879#define MLXSW_REG_PERERP_LEN 0x1C
2880
2881MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
2882
2883/* reg_pererp_region_id
2884 * Region identifier.
2885 * Range 0..cap_max_regions-1
2886 * Access: Index
2887 */
2888MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
2889
2890/* reg_pererp_ctcam_le
2891 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
2892 * Access: RW
2893 */
2894MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
2895
2896/* reg_pererp_erpt_pointer_valid
2897 * erpt_pointer is valid.
2898 * Access: RW
2899 */
2900MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
2901
2902/* reg_pererp_erpt_bank_pointer
2903 * Pointer to eRP table bank. May be modified at any time.
2904 * Range 0..cap_max_erp_table_banks-1
2905 * Reserved when erpt_pointer_valid = 0
2906 */
2907MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
2908
2909/* reg_pererp_erpt_pointer
2910 * Pointer to eRP table within the eRP bank. Can be changed for an
2911 * existing region.
2912 * Range 0..cap_max_erp_table_size-1
2913 * Reserved when erpt_pointer_valid = 0
2914 * Access: RW
2915 */
2916MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
2917
2918/* reg_pererp_erpt_vector
2919 * Vector of allowed eRP indexes starting from erpt_pointer within the
2920 * erpt_bank_pointer. Next entries will be in next bank.
2921 * Note that eRP index is used and not eRP ID.
2922 * Reserved when erpt_pointer_valid = 0
2923 * Access: RW
2924 */
2925MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
2926
2927/* reg_pererp_master_rp_id
2928 * Master RP ID. When there are no eRPs, then this provides the eRP ID
2929 * for the lookup. Can be changed for an existing region.
2930 * Reserved when erpt_pointer_valid = 1
2931 * Access: RW
2932 */
2933MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
2934
Ido Schimmel91329e22018-07-25 09:23:50 +03002935static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
2936 unsigned long *erp_vector,
2937 unsigned long size)
2938{
2939 unsigned long bit;
2940
2941 for_each_set_bit(bit, erp_vector, size)
2942 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
2943}
2944
2945static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
2946 bool ctcam_le, bool erpt_pointer_valid,
2947 u8 erpt_bank_pointer, u8 erpt_pointer,
2948 u8 master_rp_id)
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03002949{
2950 MLXSW_REG_ZERO(pererp, payload);
2951 mlxsw_reg_pererp_region_id_set(payload, region_id);
Ido Schimmel91329e22018-07-25 09:23:50 +03002952 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
2953 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
2954 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
2955 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
2956 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03002957}
2958
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03002959/* IEDR - Infrastructure Entry Delete Register
2960 * ----------------------------------------------------
2961 * This register is used for deleting entries from the entry tables.
2962 * It is legitimate to attempt to delete a nonexisting entry (the device will
2963 * respond as a good flow).
2964 */
2965#define MLXSW_REG_IEDR_ID 0x3804
2966#define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
2967#define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
2968#define MLXSW_REG_IEDR_REC_MAX_COUNT 64
2969#define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
2970 MLXSW_REG_IEDR_REC_LEN * \
2971 MLXSW_REG_IEDR_REC_MAX_COUNT)
2972
2973MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
2974
2975/* reg_iedr_num_rec
2976 * Number of records.
2977 * Access: OP
2978 */
2979MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
2980
2981/* reg_iedr_rec_type
2982 * Resource type.
2983 * Access: OP
2984 */
2985MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
2986 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
2987
2988/* reg_iedr_rec_size
2989 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
2990 * Access: OP
2991 */
2992MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 11,
2993 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
2994
2995/* reg_iedr_rec_index_start
2996 * Resource index start.
2997 * Access: OP
2998 */
2999MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3000 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3001
3002static inline void mlxsw_reg_iedr_pack(char *payload)
3003{
3004 MLXSW_REG_ZERO(iedr, payload);
3005}
3006
3007static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3008 u8 rec_type, u16 rec_size,
3009 u32 rec_index_start)
3010{
3011 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3012
3013 if (rec_index >= num_rec)
3014 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3015 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3016 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3017 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3018}
3019
Petr Machata746da422018-07-27 15:26:58 +03003020/* QPTS - QoS Priority Trust State Register
3021 * ----------------------------------------
3022 * This register controls the port policy to calculate the switch priority and
3023 * packet color based on incoming packet fields.
3024 */
3025#define MLXSW_REG_QPTS_ID 0x4002
3026#define MLXSW_REG_QPTS_LEN 0x8
3027
3028MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3029
3030/* reg_qpts_local_port
3031 * Local port number.
3032 * Access: Index
3033 *
3034 * Note: CPU port is supported.
3035 */
3036MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
3037
3038enum mlxsw_reg_qpts_trust_state {
3039 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3040 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
3041};
3042
3043/* reg_qpts_trust_state
3044 * Trust state for a given port.
3045 * Access: RW
3046 */
3047MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3048
3049static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
3050 enum mlxsw_reg_qpts_trust_state ts)
3051{
3052 MLXSW_REG_ZERO(qpts, payload);
3053
3054 mlxsw_reg_qpts_local_port_set(payload, local_port);
3055 mlxsw_reg_qpts_trust_state_set(payload, ts);
3056}
3057
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01003058/* QPCR - QoS Policer Configuration Register
3059 * -----------------------------------------
3060 * The QPCR register is used to create policers - that limit
3061 * the rate of bytes or packets via some trap group.
3062 */
3063#define MLXSW_REG_QPCR_ID 0x4004
3064#define MLXSW_REG_QPCR_LEN 0x28
3065
3066MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3067
3068enum mlxsw_reg_qpcr_g {
3069 MLXSW_REG_QPCR_G_GLOBAL = 2,
3070 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3071};
3072
3073/* reg_qpcr_g
3074 * The policer type.
3075 * Access: Index
3076 */
3077MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3078
3079/* reg_qpcr_pid
3080 * Policer ID.
3081 * Access: Index
3082 */
3083MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3084
3085/* reg_qpcr_color_aware
3086 * Is the policer aware of colors.
3087 * Must be 0 (unaware) for cpu port.
3088 * Access: RW for unbounded policer. RO for bounded policer.
3089 */
3090MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3091
3092/* reg_qpcr_bytes
3093 * Is policer limit is for bytes per sec or packets per sec.
3094 * 0 - packets
3095 * 1 - bytes
3096 * Access: RW for unbounded policer. RO for bounded policer.
3097 */
3098MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3099
3100enum mlxsw_reg_qpcr_ir_units {
3101 MLXSW_REG_QPCR_IR_UNITS_M,
3102 MLXSW_REG_QPCR_IR_UNITS_K,
3103};
3104
3105/* reg_qpcr_ir_units
3106 * Policer's units for cir and eir fields (for bytes limits only)
3107 * 1 - 10^3
3108 * 0 - 10^6
3109 * Access: OP
3110 */
3111MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3112
3113enum mlxsw_reg_qpcr_rate_type {
3114 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3115 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3116};
3117
3118/* reg_qpcr_rate_type
3119 * Policer can have one limit (single rate) or 2 limits with specific operation
3120 * for packets that exceed the lower rate but not the upper one.
3121 * (For cpu port must be single rate)
3122 * Access: RW for unbounded policer. RO for bounded policer.
3123 */
3124MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3125
3126/* reg_qpc_cbs
3127 * Policer's committed burst size.
3128 * The policer is working with time slices of 50 nano sec. By default every
3129 * slice is granted the proportionate share of the committed rate. If we want to
3130 * allow a slice to exceed that share (while still keeping the rate per sec) we
3131 * can allow burst. The burst size is between the default proportionate share
3132 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
3133 * committed rate will result in exceeding the rate). The burst size must be a
3134 * log of 2 and will be determined by 2^cbs.
3135 * Access: RW
3136 */
3137MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3138
3139/* reg_qpcr_cir
3140 * Policer's committed rate.
3141 * The rate used for sungle rate, the lower rate for double rate.
3142 * For bytes limits, the rate will be this value * the unit from ir_units.
3143 * (Resolution error is up to 1%).
3144 * Access: RW
3145 */
3146MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3147
3148/* reg_qpcr_eir
3149 * Policer's exceed rate.
3150 * The higher rate for double rate, reserved for single rate.
3151 * Lower rate for double rate policer.
3152 * For bytes limits, the rate will be this value * the unit from ir_units.
3153 * (Resolution error is up to 1%).
3154 * Access: RW
3155 */
3156MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3157
3158#define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3159
3160/* reg_qpcr_exceed_action.
3161 * What to do with packets between the 2 limits for double rate.
3162 * Access: RW for unbounded policer. RO for bounded policer.
3163 */
3164MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3165
3166enum mlxsw_reg_qpcr_action {
3167 /* Discard */
3168 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3169 /* Forward and set color to red.
3170 * If the packet is intended to cpu port, it will be dropped.
3171 */
3172 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3173};
3174
3175/* reg_qpcr_violate_action
3176 * What to do with packets that cross the cir limit (for single rate) or the eir
3177 * limit (for double rate).
3178 * Access: RW for unbounded policer. RO for bounded policer.
3179 */
3180MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3181
3182static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3183 enum mlxsw_reg_qpcr_ir_units ir_units,
3184 bool bytes, u32 cir, u16 cbs)
3185{
3186 MLXSW_REG_ZERO(qpcr, payload);
3187 mlxsw_reg_qpcr_pid_set(payload, pid);
3188 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3189 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3190 mlxsw_reg_qpcr_violate_action_set(payload,
3191 MLXSW_REG_QPCR_ACTION_DISCARD);
3192 mlxsw_reg_qpcr_cir_set(payload, cir);
3193 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3194 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3195 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3196}
3197
Ido Schimmel2c63a552016-04-06 17:10:07 +02003198/* QTCT - QoS Switch Traffic Class Table
3199 * -------------------------------------
3200 * Configures the mapping between the packet switch priority and the
3201 * traffic class on the transmit port.
3202 */
3203#define MLXSW_REG_QTCT_ID 0x400A
3204#define MLXSW_REG_QTCT_LEN 0x08
3205
Jiri Pirko21978dc2016-10-21 16:07:20 +02003206MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
Ido Schimmel2c63a552016-04-06 17:10:07 +02003207
3208/* reg_qtct_local_port
3209 * Local port number.
3210 * Access: Index
3211 *
3212 * Note: CPU port is not supported.
3213 */
3214MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
3215
3216/* reg_qtct_sub_port
3217 * Virtual port within the physical port.
3218 * Should be set to 0 when virtual ports are not enabled on the port.
3219 * Access: Index
3220 */
3221MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3222
3223/* reg_qtct_switch_prio
3224 * Switch priority.
3225 * Access: Index
3226 */
3227MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3228
3229/* reg_qtct_tclass
3230 * Traffic class.
3231 * Default values:
3232 * switch_prio 0 : tclass 1
3233 * switch_prio 1 : tclass 0
3234 * switch_prio i : tclass i, for i > 1
3235 * Access: RW
3236 */
3237MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3238
3239static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3240 u8 switch_prio, u8 tclass)
3241{
3242 MLXSW_REG_ZERO(qtct, payload);
3243 mlxsw_reg_qtct_local_port_set(payload, local_port);
3244 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3245 mlxsw_reg_qtct_tclass_set(payload, tclass);
3246}
3247
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003248/* QEEC - QoS ETS Element Configuration Register
3249 * ---------------------------------------------
3250 * Configures the ETS elements.
3251 */
3252#define MLXSW_REG_QEEC_ID 0x400D
3253#define MLXSW_REG_QEEC_LEN 0x1C
3254
Jiri Pirko21978dc2016-10-21 16:07:20 +02003255MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
Ido Schimmelb9b7cee2016-04-06 17:10:06 +02003256
3257/* reg_qeec_local_port
3258 * Local port number.
3259 * Access: Index
3260 *
3261 * Note: CPU port is supported.
3262 */
3263MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
3264
3265enum mlxsw_reg_qeec_hr {
3266 MLXSW_REG_QEEC_HIERARCY_PORT,
3267 MLXSW_REG_QEEC_HIERARCY_GROUP,
3268 MLXSW_REG_QEEC_HIERARCY_SUBGROUP,
3269 MLXSW_REG_QEEC_HIERARCY_TC,
3270};
3271
3272/* reg_qeec_element_hierarchy
3273 * 0 - Port
3274 * 1 - Group
3275 * 2 - Subgroup
3276 * 3 - Traffic Class
3277 * Access: Index
3278 */
3279MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3280
3281/* reg_qeec_element_index
3282 * The index of the element in the hierarchy.
3283 * Access: Index
3284 */
3285MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3286
3287/* reg_qeec_next_element_index
3288 * The index of the next (lower) element in the hierarchy.
3289 * Access: RW
3290 *
3291 * Note: Reserved for element_hierarchy 0.
3292 */
3293MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3294
3295enum {
3296 MLXSW_REG_QEEC_BYTES_MODE,
3297 MLXSW_REG_QEEC_PACKETS_MODE,
3298};
3299
3300/* reg_qeec_pb
3301 * Packets or bytes mode.
3302 * 0 - Bytes mode
3303 * 1 - Packets mode
3304 * Access: RW
3305 *
3306 * Note: Used for max shaper configuration. For Spectrum, packets mode
3307 * is supported only for traffic classes of CPU port.
3308 */
3309MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3310
3311/* reg_qeec_mase
3312 * Max shaper configuration enable. Enables configuration of the max
3313 * shaper on this ETS element.
3314 * 0 - Disable
3315 * 1 - Enable
3316 * Access: RW
3317 */
3318MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3319
3320/* A large max rate will disable the max shaper. */
3321#define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */
3322
3323/* reg_qeec_max_shaper_rate
3324 * Max shaper information rate.
3325 * For CPU port, can only be configured for port hierarchy.
3326 * When in bytes mode, value is specified in units of 1000bps.
3327 * Access: RW
3328 */
3329MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
3330
3331/* reg_qeec_de
3332 * DWRR configuration enable. Enables configuration of the dwrr and
3333 * dwrr_weight.
3334 * 0 - Disable
3335 * 1 - Enable
3336 * Access: RW
3337 */
3338MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3339
3340/* reg_qeec_dwrr
3341 * Transmission selection algorithm to use on the link going down from
3342 * the ETS element.
3343 * 0 - Strict priority
3344 * 1 - DWRR
3345 * Access: RW
3346 */
3347MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3348
3349/* reg_qeec_dwrr_weight
3350 * DWRR weight on the link going down from the ETS element. The
3351 * percentage of bandwidth guaranteed to an ETS element within
3352 * its hierarchy. The sum of all weights across all ETS elements
3353 * within one hierarchy should be equal to 100. Reserved when
3354 * transmission selection algorithm is strict priority.
3355 * Access: RW
3356 */
3357MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3358
3359static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
3360 enum mlxsw_reg_qeec_hr hr, u8 index,
3361 u8 next_index)
3362{
3363 MLXSW_REG_ZERO(qeec, payload);
3364 mlxsw_reg_qeec_local_port_set(payload, local_port);
3365 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3366 mlxsw_reg_qeec_element_index_set(payload, index);
3367 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3368}
3369
Petr Machata02837d72018-07-27 15:26:57 +03003370/* QPDPM - QoS Port DSCP to Priority Mapping Register
3371 * --------------------------------------------------
3372 * This register controls the mapping from DSCP field to
3373 * Switch Priority for IP packets.
3374 */
3375#define MLXSW_REG_QPDPM_ID 0x4013
3376#define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
3377#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
3378#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
3379#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
3380 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
3381 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
3382
3383MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
3384
3385/* reg_qpdpm_local_port
3386 * Local Port. Supported for data packets from CPU port.
3387 * Access: Index
3388 */
3389MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
3390
3391/* reg_qpdpm_dscp_e
3392 * Enable update of the specific entry. When cleared, the switch_prio and color
3393 * fields are ignored and the previous switch_prio and color values are
3394 * preserved.
3395 * Access: WO
3396 */
3397MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
3398 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3399
3400/* reg_qpdpm_dscp_prio
3401 * The new Switch Priority value for the relevant DSCP value.
3402 * Access: RW
3403 */
3404MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
3405 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
3406 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3407
3408static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
3409{
3410 MLXSW_REG_ZERO(qpdpm, payload);
3411 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
3412}
3413
3414static inline void
3415mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
3416{
3417 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
3418 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
3419}
3420
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003421/* PMLP - Ports Module to Local Port Register
3422 * ------------------------------------------
3423 * Configures the assignment of modules to local ports.
3424 */
3425#define MLXSW_REG_PMLP_ID 0x5002
3426#define MLXSW_REG_PMLP_LEN 0x40
3427
Jiri Pirko21978dc2016-10-21 16:07:20 +02003428MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003429
3430/* reg_pmlp_rxtx
3431 * 0 - Tx value is used for both Tx and Rx.
3432 * 1 - Rx value is taken from a separte field.
3433 * Access: RW
3434 */
3435MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
3436
3437/* reg_pmlp_local_port
3438 * Local port number.
3439 * Access: Index
3440 */
3441MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
3442
3443/* reg_pmlp_width
3444 * 0 - Unmap local port.
3445 * 1 - Lane 0 is used.
3446 * 2 - Lanes 0 and 1 are used.
3447 * 4 - Lanes 0, 1, 2 and 3 are used.
3448 * Access: RW
3449 */
3450MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
3451
3452/* reg_pmlp_module
3453 * Module number.
3454 * Access: RW
3455 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01003456MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003457
3458/* reg_pmlp_tx_lane
3459 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
3460 * Access: RW
3461 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01003462MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003463
3464/* reg_pmlp_rx_lane
3465 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
3466 * equal to Tx lane.
3467 * Access: RW
3468 */
Ido Schimmelbbeeda22016-01-27 15:20:26 +01003469MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003470
3471static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
3472{
3473 MLXSW_REG_ZERO(pmlp, payload);
3474 mlxsw_reg_pmlp_local_port_set(payload, local_port);
3475}
3476
3477/* PMTU - Port MTU Register
3478 * ------------------------
3479 * Configures and reports the port MTU.
3480 */
3481#define MLXSW_REG_PMTU_ID 0x5003
3482#define MLXSW_REG_PMTU_LEN 0x10
3483
Jiri Pirko21978dc2016-10-21 16:07:20 +02003484MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003485
3486/* reg_pmtu_local_port
3487 * Local port number.
3488 * Access: Index
3489 */
3490MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
3491
3492/* reg_pmtu_max_mtu
3493 * Maximum MTU.
3494 * When port type (e.g. Ethernet) is configured, the relevant MTU is
3495 * reported, otherwise the minimum between the max_mtu of the different
3496 * types is reported.
3497 * Access: RO
3498 */
3499MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
3500
3501/* reg_pmtu_admin_mtu
3502 * MTU value to set port to. Must be smaller or equal to max_mtu.
3503 * Note: If port type is Infiniband, then port must be disabled, when its
3504 * MTU is set.
3505 * Access: RW
3506 */
3507MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
3508
3509/* reg_pmtu_oper_mtu
3510 * The actual MTU configured on the port. Packets exceeding this size
3511 * will be dropped.
3512 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
3513 * oper_mtu might be smaller than admin_mtu.
3514 * Access: RO
3515 */
3516MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
3517
3518static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
3519 u16 new_mtu)
3520{
3521 MLXSW_REG_ZERO(pmtu, payload);
3522 mlxsw_reg_pmtu_local_port_set(payload, local_port);
3523 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
3524 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
3525 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
3526}
3527
3528/* PTYS - Port Type and Speed Register
3529 * -----------------------------------
3530 * Configures and reports the port speed type.
3531 *
3532 * Note: When set while the link is up, the changes will not take effect
3533 * until the port transitions from down to up state.
3534 */
3535#define MLXSW_REG_PTYS_ID 0x5004
3536#define MLXSW_REG_PTYS_LEN 0x40
3537
Jiri Pirko21978dc2016-10-21 16:07:20 +02003538MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003539
Tal Bar8e1ed732018-03-21 09:34:06 +02003540/* an_disable_admin
3541 * Auto negotiation disable administrative configuration
3542 * 0 - Device doesn't support AN disable.
3543 * 1 - Device supports AN disable.
3544 * Access: RW
3545 */
3546MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
3547
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003548/* reg_ptys_local_port
3549 * Local port number.
3550 * Access: Index
3551 */
3552MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
3553
Elad Raz79417702016-10-28 21:35:53 +02003554#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003555#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
3556
3557/* reg_ptys_proto_mask
3558 * Protocol mask. Indicates which protocol is used.
3559 * 0 - Infiniband.
3560 * 1 - Fibre Channel.
3561 * 2 - Ethernet.
3562 * Access: Index
3563 */
3564MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
3565
Ido Schimmel4149b972016-09-12 13:26:24 +02003566enum {
3567 MLXSW_REG_PTYS_AN_STATUS_NA,
3568 MLXSW_REG_PTYS_AN_STATUS_OK,
3569 MLXSW_REG_PTYS_AN_STATUS_FAIL,
3570};
3571
3572/* reg_ptys_an_status
3573 * Autonegotiation status.
3574 * Access: RO
3575 */
3576MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
3577
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003578#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
3579#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
3580#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
3581#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
3582#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
3583#define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
3584#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
3585#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
3586#define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
3587#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
3588#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
3589#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
3590#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
3591#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
Ido Schimmelb9d66a32016-09-12 13:26:27 +02003592#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003593#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
3594#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
3595#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
3596#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
3597#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
3598#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
3599#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
3600#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
3601#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
3602#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
3603#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
3604#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
3605#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
3606
3607/* reg_ptys_eth_proto_cap
3608 * Ethernet port supported speeds and protocols.
3609 * Access: RO
3610 */
3611MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
3612
Elad Raz79417702016-10-28 21:35:53 +02003613/* reg_ptys_ib_link_width_cap
3614 * IB port supported widths.
3615 * Access: RO
3616 */
3617MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
3618
3619#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
3620#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
3621#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
3622#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
3623#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
3624#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
3625
3626/* reg_ptys_ib_proto_cap
3627 * IB port supported speeds and protocols.
3628 * Access: RO
3629 */
3630MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
3631
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003632/* reg_ptys_eth_proto_admin
3633 * Speed and protocol to set port to.
3634 * Access: RW
3635 */
3636MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
3637
Elad Raz79417702016-10-28 21:35:53 +02003638/* reg_ptys_ib_link_width_admin
3639 * IB width to set port to.
3640 * Access: RW
3641 */
3642MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
3643
3644/* reg_ptys_ib_proto_admin
3645 * IB speeds and protocols to set port to.
3646 * Access: RW
3647 */
3648MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
3649
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003650/* reg_ptys_eth_proto_oper
3651 * The current speed and protocol configured for the port.
3652 * Access: RO
3653 */
3654MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
3655
Elad Raz79417702016-10-28 21:35:53 +02003656/* reg_ptys_ib_link_width_oper
3657 * The current IB width to set port to.
3658 * Access: RO
3659 */
3660MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
3661
3662/* reg_ptys_ib_proto_oper
3663 * The current IB speed and protocol.
3664 * Access: RO
3665 */
3666MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
3667
Ido Schimmel4149b972016-09-12 13:26:24 +02003668/* reg_ptys_eth_proto_lp_advertise
3669 * The protocols that were advertised by the link partner during
3670 * autonegotiation.
3671 * Access: RO
3672 */
3673MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
3674
Elad Raz401c8b42016-10-28 21:35:52 +02003675static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
Tal Bar8e1ed732018-03-21 09:34:06 +02003676 u32 proto_admin, bool autoneg)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003677{
3678 MLXSW_REG_ZERO(ptys, payload);
3679 mlxsw_reg_ptys_local_port_set(payload, local_port);
3680 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
3681 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
Tal Bar8e1ed732018-03-21 09:34:06 +02003682 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003683}
3684
Elad Raz401c8b42016-10-28 21:35:52 +02003685static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
3686 u32 *p_eth_proto_cap,
3687 u32 *p_eth_proto_adm,
3688 u32 *p_eth_proto_oper)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003689{
3690 if (p_eth_proto_cap)
3691 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
3692 if (p_eth_proto_adm)
3693 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
3694 if (p_eth_proto_oper)
3695 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
3696}
3697
Elad Raz79417702016-10-28 21:35:53 +02003698static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
3699 u16 proto_admin, u16 link_width)
3700{
3701 MLXSW_REG_ZERO(ptys, payload);
3702 mlxsw_reg_ptys_local_port_set(payload, local_port);
3703 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
3704 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
3705 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
3706}
3707
3708static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
3709 u16 *p_ib_link_width_cap,
3710 u16 *p_ib_proto_oper,
3711 u16 *p_ib_link_width_oper)
3712{
3713 if (p_ib_proto_cap)
3714 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
3715 if (p_ib_link_width_cap)
3716 *p_ib_link_width_cap =
3717 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
3718 if (p_ib_proto_oper)
3719 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
3720 if (p_ib_link_width_oper)
3721 *p_ib_link_width_oper =
3722 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
3723}
3724
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003725/* PPAD - Port Physical Address Register
3726 * -------------------------------------
3727 * The PPAD register configures the per port physical MAC address.
3728 */
3729#define MLXSW_REG_PPAD_ID 0x5005
3730#define MLXSW_REG_PPAD_LEN 0x10
3731
Jiri Pirko21978dc2016-10-21 16:07:20 +02003732MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003733
3734/* reg_ppad_single_base_mac
3735 * 0: base_mac, local port should be 0 and mac[7:0] is
3736 * reserved. HW will set incremental
3737 * 1: single_mac - mac of the local_port
3738 * Access: RW
3739 */
3740MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
3741
3742/* reg_ppad_local_port
3743 * port number, if single_base_mac = 0 then local_port is reserved
3744 * Access: RW
3745 */
3746MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
3747
3748/* reg_ppad_mac
3749 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
3750 * If single_base_mac = 1 - the per port MAC address
3751 * Access: RW
3752 */
3753MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
3754
3755static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
3756 u8 local_port)
3757{
3758 MLXSW_REG_ZERO(ppad, payload);
3759 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
3760 mlxsw_reg_ppad_local_port_set(payload, local_port);
3761}
3762
3763/* PAOS - Ports Administrative and Operational Status Register
3764 * -----------------------------------------------------------
3765 * Configures and retrieves per port administrative and operational status.
3766 */
3767#define MLXSW_REG_PAOS_ID 0x5006
3768#define MLXSW_REG_PAOS_LEN 0x10
3769
Jiri Pirko21978dc2016-10-21 16:07:20 +02003770MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003771
3772/* reg_paos_swid
3773 * Switch partition ID with which to associate the port.
3774 * Note: while external ports uses unique local port numbers (and thus swid is
3775 * redundant), router ports use the same local port number where swid is the
3776 * only indication for the relevant port.
3777 * Access: Index
3778 */
3779MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
3780
3781/* reg_paos_local_port
3782 * Local port number.
3783 * Access: Index
3784 */
3785MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
3786
3787/* reg_paos_admin_status
3788 * Port administrative state (the desired state of the port):
3789 * 1 - Up.
3790 * 2 - Down.
3791 * 3 - Up once. This means that in case of link failure, the port won't go
3792 * into polling mode, but will wait to be re-enabled by software.
3793 * 4 - Disabled by system. Can only be set by hardware.
3794 * Access: RW
3795 */
3796MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
3797
3798/* reg_paos_oper_status
3799 * Port operational state (the current state):
3800 * 1 - Up.
3801 * 2 - Down.
3802 * 3 - Down by port failure. This means that the device will not let the
3803 * port up again until explicitly specified by software.
3804 * Access: RO
3805 */
3806MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
3807
3808/* reg_paos_ase
3809 * Admin state update enabled.
3810 * Access: WO
3811 */
3812MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
3813
3814/* reg_paos_ee
3815 * Event update enable. If this bit is set, event generation will be
3816 * updated based on the e field.
3817 * Access: WO
3818 */
3819MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
3820
3821/* reg_paos_e
3822 * Event generation on operational state change:
3823 * 0 - Do not generate event.
3824 * 1 - Generate Event.
3825 * 2 - Generate Single Event.
3826 * Access: RW
3827 */
3828MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
3829
3830static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
3831 enum mlxsw_port_admin_status status)
3832{
3833 MLXSW_REG_ZERO(paos, payload);
3834 mlxsw_reg_paos_swid_set(payload, 0);
3835 mlxsw_reg_paos_local_port_set(payload, local_port);
3836 mlxsw_reg_paos_admin_status_set(payload, status);
3837 mlxsw_reg_paos_oper_status_set(payload, 0);
3838 mlxsw_reg_paos_ase_set(payload, 1);
3839 mlxsw_reg_paos_ee_set(payload, 1);
3840 mlxsw_reg_paos_e_set(payload, 1);
3841}
3842
Ido Schimmel6f253d82016-04-06 17:10:12 +02003843/* PFCC - Ports Flow Control Configuration Register
3844 * ------------------------------------------------
3845 * Configures and retrieves the per port flow control configuration.
3846 */
3847#define MLXSW_REG_PFCC_ID 0x5007
3848#define MLXSW_REG_PFCC_LEN 0x20
3849
Jiri Pirko21978dc2016-10-21 16:07:20 +02003850MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
Ido Schimmel6f253d82016-04-06 17:10:12 +02003851
3852/* reg_pfcc_local_port
3853 * Local port number.
3854 * Access: Index
3855 */
3856MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
3857
3858/* reg_pfcc_pnat
3859 * Port number access type. Determines the way local_port is interpreted:
3860 * 0 - Local port number.
3861 * 1 - IB / label port number.
3862 * Access: Index
3863 */
3864MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
3865
3866/* reg_pfcc_shl_cap
3867 * Send to higher layers capabilities:
3868 * 0 - No capability of sending Pause and PFC frames to higher layers.
3869 * 1 - Device has capability of sending Pause and PFC frames to higher
3870 * layers.
3871 * Access: RO
3872 */
3873MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
3874
3875/* reg_pfcc_shl_opr
3876 * Send to higher layers operation:
3877 * 0 - Pause and PFC frames are handled by the port (default).
3878 * 1 - Pause and PFC frames are handled by the port and also sent to
3879 * higher layers. Only valid if shl_cap = 1.
3880 * Access: RW
3881 */
3882MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
3883
3884/* reg_pfcc_ppan
3885 * Pause policy auto negotiation.
3886 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
3887 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
3888 * based on the auto-negotiation resolution.
3889 * Access: RW
3890 *
3891 * Note: The auto-negotiation advertisement is set according to pptx and
3892 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
3893 */
3894MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
3895
3896/* reg_pfcc_prio_mask_tx
3897 * Bit per priority indicating if Tx flow control policy should be
3898 * updated based on bit pfctx.
3899 * Access: WO
3900 */
3901MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
3902
3903/* reg_pfcc_prio_mask_rx
3904 * Bit per priority indicating if Rx flow control policy should be
3905 * updated based on bit pfcrx.
3906 * Access: WO
3907 */
3908MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
3909
3910/* reg_pfcc_pptx
3911 * Admin Pause policy on Tx.
3912 * 0 - Never generate Pause frames (default).
3913 * 1 - Generate Pause frames according to Rx buffer threshold.
3914 * Access: RW
3915 */
3916MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
3917
3918/* reg_pfcc_aptx
3919 * Active (operational) Pause policy on Tx.
3920 * 0 - Never generate Pause frames.
3921 * 1 - Generate Pause frames according to Rx buffer threshold.
3922 * Access: RO
3923 */
3924MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
3925
3926/* reg_pfcc_pfctx
3927 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
3928 * 0 - Never generate priority Pause frames on the specified priority
3929 * (default).
3930 * 1 - Generate priority Pause frames according to Rx buffer threshold on
3931 * the specified priority.
3932 * Access: RW
3933 *
3934 * Note: pfctx and pptx must be mutually exclusive.
3935 */
3936MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
3937
3938/* reg_pfcc_pprx
3939 * Admin Pause policy on Rx.
3940 * 0 - Ignore received Pause frames (default).
3941 * 1 - Respect received Pause frames.
3942 * Access: RW
3943 */
3944MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
3945
3946/* reg_pfcc_aprx
3947 * Active (operational) Pause policy on Rx.
3948 * 0 - Ignore received Pause frames.
3949 * 1 - Respect received Pause frames.
3950 * Access: RO
3951 */
3952MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
3953
3954/* reg_pfcc_pfcrx
3955 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
3956 * 0 - Ignore incoming priority Pause frames on the specified priority
3957 * (default).
3958 * 1 - Respect incoming priority Pause frames on the specified priority.
3959 * Access: RW
3960 */
3961MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
3962
Ido Schimmeld81a6bd2016-04-06 17:10:16 +02003963#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
3964
3965static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
3966{
3967 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
3968 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
3969 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
3970 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
3971}
3972
Ido Schimmel6f253d82016-04-06 17:10:12 +02003973static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
3974{
3975 MLXSW_REG_ZERO(pfcc, payload);
3976 mlxsw_reg_pfcc_local_port_set(payload, local_port);
3977}
3978
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003979/* PPCNT - Ports Performance Counters Register
3980 * -------------------------------------------
3981 * The PPCNT register retrieves per port performance counters.
3982 */
3983#define MLXSW_REG_PPCNT_ID 0x5008
3984#define MLXSW_REG_PPCNT_LEN 0x100
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02003985#define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003986
Jiri Pirko21978dc2016-10-21 16:07:20 +02003987MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02003988
3989/* reg_ppcnt_swid
3990 * For HCA: must be always 0.
3991 * Switch partition ID to associate port with.
3992 * Switch partitions are numbered from 0 to 7 inclusively.
3993 * Switch partition 254 indicates stacking ports.
3994 * Switch partition 255 indicates all switch partitions.
3995 * Only valid on Set() operation with local_port=255.
3996 * Access: Index
3997 */
3998MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
3999
4000/* reg_ppcnt_local_port
4001 * Local port number.
4002 * 255 indicates all ports on the device, and is only allowed
4003 * for Set() operation.
4004 * Access: Index
4005 */
4006MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
4007
4008/* reg_ppcnt_pnat
4009 * Port number access type:
4010 * 0 - Local port number
4011 * 1 - IB port number
4012 * Access: Index
4013 */
4014MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4015
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004016enum mlxsw_reg_ppcnt_grp {
4017 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
Jiri Pirko1222d152018-07-15 10:45:42 +03004018 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004019 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004020 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004021 MLXSW_REG_PPCNT_TC_CNT = 0x11,
Yuval Mintz0afc1222017-11-06 07:23:46 +01004022 MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004023};
4024
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004025/* reg_ppcnt_grp
4026 * Performance counter group.
4027 * Group 63 indicates all groups. Only valid on Set() operation with
4028 * clr bit set.
4029 * 0x0: IEEE 802.3 Counters
4030 * 0x1: RFC 2863 Counters
4031 * 0x2: RFC 2819 Counters
4032 * 0x3: RFC 3635 Counters
4033 * 0x5: Ethernet Extended Counters
4034 * 0x8: Link Level Retransmission Counters
4035 * 0x10: Per Priority Counters
4036 * 0x11: Per Traffic Class Counters
4037 * 0x12: Physical Layer Counters
Yuval Mintz0afc1222017-11-06 07:23:46 +01004038 * 0x13: Per Traffic Class Congestion Counters
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004039 * Access: Index
4040 */
4041MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4042
4043/* reg_ppcnt_clr
4044 * Clear counters. Setting the clr bit will reset the counter value
4045 * for all counters in the counter group. This bit can be set
4046 * for both Set() and Get() operation.
4047 * Access: OP
4048 */
4049MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4050
4051/* reg_ppcnt_prio_tc
4052 * Priority for counter set that support per priority, valid values: 0-7.
4053 * Traffic class for counter set that support per traffic class,
4054 * valid values: 0- cap_max_tclass-1 .
4055 * For HCA: cap_max_tclass is always 8.
4056 * Otherwise must be 0.
4057 * Access: Index
4058 */
4059MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
4060
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004061/* Ethernet IEEE 802.3 Counter Group */
4062
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004063/* reg_ppcnt_a_frames_transmitted_ok
4064 * Access: RO
4065 */
4066MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004067 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004068
4069/* reg_ppcnt_a_frames_received_ok
4070 * Access: RO
4071 */
4072MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004073 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004074
4075/* reg_ppcnt_a_frame_check_sequence_errors
4076 * Access: RO
4077 */
4078MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004079 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004080
4081/* reg_ppcnt_a_alignment_errors
4082 * Access: RO
4083 */
4084MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004085 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004086
4087/* reg_ppcnt_a_octets_transmitted_ok
4088 * Access: RO
4089 */
4090MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004091 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004092
4093/* reg_ppcnt_a_octets_received_ok
4094 * Access: RO
4095 */
4096MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004097 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004098
4099/* reg_ppcnt_a_multicast_frames_xmitted_ok
4100 * Access: RO
4101 */
4102MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004103 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004104
4105/* reg_ppcnt_a_broadcast_frames_xmitted_ok
4106 * Access: RO
4107 */
4108MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004109 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004110
4111/* reg_ppcnt_a_multicast_frames_received_ok
4112 * Access: RO
4113 */
4114MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004115 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004116
4117/* reg_ppcnt_a_broadcast_frames_received_ok
4118 * Access: RO
4119 */
4120MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004121 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004122
4123/* reg_ppcnt_a_in_range_length_errors
4124 * Access: RO
4125 */
4126MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004127 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004128
4129/* reg_ppcnt_a_out_of_range_length_field
4130 * Access: RO
4131 */
4132MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004133 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004134
4135/* reg_ppcnt_a_frame_too_long_errors
4136 * Access: RO
4137 */
4138MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004139 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004140
4141/* reg_ppcnt_a_symbol_error_during_carrier
4142 * Access: RO
4143 */
4144MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004145 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004146
4147/* reg_ppcnt_a_mac_control_frames_transmitted
4148 * Access: RO
4149 */
4150MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004151 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004152
4153/* reg_ppcnt_a_mac_control_frames_received
4154 * Access: RO
4155 */
4156MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004157 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004158
4159/* reg_ppcnt_a_unsupported_opcodes_received
4160 * Access: RO
4161 */
4162MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004163 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004164
4165/* reg_ppcnt_a_pause_mac_ctrl_frames_received
4166 * Access: RO
4167 */
4168MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004169 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004170
4171/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
4172 * Access: RO
4173 */
4174MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004175 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004176
Jiri Pirko1222d152018-07-15 10:45:42 +03004177/* Ethernet RFC 2819 Counter Group */
4178
4179/* reg_ppcnt_ether_stats_pkts64octets
4180 * Access: RO
4181 */
4182MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
4183 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4184
4185/* reg_ppcnt_ether_stats_pkts65to127octets
4186 * Access: RO
4187 */
4188MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
4189 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4190
4191/* reg_ppcnt_ether_stats_pkts128to255octets
4192 * Access: RO
4193 */
4194MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
4195 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4196
4197/* reg_ppcnt_ether_stats_pkts256to511octets
4198 * Access: RO
4199 */
4200MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
4201 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4202
4203/* reg_ppcnt_ether_stats_pkts512to1023octets
4204 * Access: RO
4205 */
4206MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
4207 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4208
4209/* reg_ppcnt_ether_stats_pkts1024to1518octets
4210 * Access: RO
4211 */
4212MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
4213 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4214
4215/* reg_ppcnt_ether_stats_pkts1519to2047octets
4216 * Access: RO
4217 */
4218MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
4219 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4220
4221/* reg_ppcnt_ether_stats_pkts2048to4095octets
4222 * Access: RO
4223 */
4224MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
4225 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4226
4227/* reg_ppcnt_ether_stats_pkts4096to8191octets
4228 * Access: RO
4229 */
4230MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
4231 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
4232
4233/* reg_ppcnt_ether_stats_pkts8192to10239octets
4234 * Access: RO
4235 */
4236MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
4237 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
4238
Yuval Mintz0afc1222017-11-06 07:23:46 +01004239/* Ethernet Extended Counter Group Counters */
4240
4241/* reg_ppcnt_ecn_marked
4242 * Access: RO
4243 */
4244MLXSW_ITEM64(reg, ppcnt, ecn_marked,
4245 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4246
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004247/* Ethernet Per Priority Group Counters */
4248
4249/* reg_ppcnt_rx_octets
4250 * Access: RO
4251 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004252MLXSW_ITEM64(reg, ppcnt, rx_octets,
4253 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004254
4255/* reg_ppcnt_rx_frames
4256 * Access: RO
4257 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004258MLXSW_ITEM64(reg, ppcnt, rx_frames,
4259 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004260
4261/* reg_ppcnt_tx_octets
4262 * Access: RO
4263 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004264MLXSW_ITEM64(reg, ppcnt, tx_octets,
4265 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004266
4267/* reg_ppcnt_tx_frames
4268 * Access: RO
4269 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004270MLXSW_ITEM64(reg, ppcnt, tx_frames,
4271 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004272
4273/* reg_ppcnt_rx_pause
4274 * Access: RO
4275 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004276MLXSW_ITEM64(reg, ppcnt, rx_pause,
4277 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004278
4279/* reg_ppcnt_rx_pause_duration
4280 * Access: RO
4281 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004282MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
4283 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004284
4285/* reg_ppcnt_tx_pause
4286 * Access: RO
4287 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004288MLXSW_ITEM64(reg, ppcnt, tx_pause,
4289 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004290
4291/* reg_ppcnt_tx_pause_duration
4292 * Access: RO
4293 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004294MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
4295 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004296
4297/* reg_ppcnt_rx_pause_transition
4298 * Access: RO
4299 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004300MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
4301 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004302
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004303/* Ethernet Per Traffic Group Counters */
4304
4305/* reg_ppcnt_tc_transmit_queue
4306 * Contains the transmit queue depth in cells of traffic class
4307 * selected by prio_tc and the port selected by local_port.
4308 * The field cannot be cleared.
4309 * Access: RO
4310 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004311MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
4312 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004313
4314/* reg_ppcnt_tc_no_buffer_discard_uc
4315 * The number of unicast packets dropped due to lack of shared
4316 * buffer resources.
4317 * Access: RO
4318 */
Nogah Frankel3e8c1fd2017-10-26 10:55:33 +02004319MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
4320 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
Ido Schimmeldf4750e2016-07-19 15:35:54 +02004321
Yuval Mintz0afc1222017-11-06 07:23:46 +01004322/* Ethernet Per Traffic Class Congestion Group Counters */
4323
4324/* reg_ppcnt_wred_discard
4325 * Access: RO
4326 */
4327MLXSW_ITEM64(reg, ppcnt, wred_discard,
4328 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4329
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004330static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
4331 enum mlxsw_reg_ppcnt_grp grp,
4332 u8 prio_tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004333{
4334 MLXSW_REG_ZERO(ppcnt, payload);
4335 mlxsw_reg_ppcnt_swid_set(payload, 0);
4336 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
4337 mlxsw_reg_ppcnt_pnat_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004338 mlxsw_reg_ppcnt_grp_set(payload, grp);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004339 mlxsw_reg_ppcnt_clr_set(payload, 0);
Ido Schimmel34dba0a2016-04-06 17:10:15 +02004340 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004341}
4342
Elad Raz71367932016-10-28 21:35:54 +02004343/* PLIB - Port Local to InfiniBand Port
4344 * ------------------------------------
4345 * The PLIB register performs mapping from Local Port into InfiniBand Port.
4346 */
4347#define MLXSW_REG_PLIB_ID 0x500A
4348#define MLXSW_REG_PLIB_LEN 0x10
4349
4350MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
4351
4352/* reg_plib_local_port
4353 * Local port number.
4354 * Access: Index
4355 */
4356MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
4357
4358/* reg_plib_ib_port
4359 * InfiniBand port remapping for local_port.
4360 * Access: RW
4361 */
4362MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
4363
Ido Schimmelb98ff152016-04-06 17:10:00 +02004364/* PPTB - Port Prio To Buffer Register
4365 * -----------------------------------
4366 * Configures the switch priority to buffer table.
4367 */
4368#define MLXSW_REG_PPTB_ID 0x500B
Ido Schimmel11719a52016-07-15 11:15:02 +02004369#define MLXSW_REG_PPTB_LEN 0x10
Ido Schimmelb98ff152016-04-06 17:10:00 +02004370
Jiri Pirko21978dc2016-10-21 16:07:20 +02004371MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
Ido Schimmelb98ff152016-04-06 17:10:00 +02004372
4373enum {
4374 MLXSW_REG_PPTB_MM_UM,
4375 MLXSW_REG_PPTB_MM_UNICAST,
4376 MLXSW_REG_PPTB_MM_MULTICAST,
4377};
4378
4379/* reg_pptb_mm
4380 * Mapping mode.
4381 * 0 - Map both unicast and multicast packets to the same buffer.
4382 * 1 - Map only unicast packets.
4383 * 2 - Map only multicast packets.
4384 * Access: Index
4385 *
4386 * Note: SwitchX-2 only supports the first option.
4387 */
4388MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
4389
4390/* reg_pptb_local_port
4391 * Local port number.
4392 * Access: Index
4393 */
4394MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
4395
4396/* reg_pptb_um
4397 * Enables the update of the untagged_buf field.
4398 * Access: RW
4399 */
4400MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
4401
4402/* reg_pptb_pm
4403 * Enables the update of the prio_to_buff field.
4404 * Bit <i> is a flag for updating the mapping for switch priority <i>.
4405 * Access: RW
4406 */
4407MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
4408
4409/* reg_pptb_prio_to_buff
4410 * Mapping of switch priority <i> to one of the allocated receive port
4411 * buffers.
4412 * Access: RW
4413 */
4414MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
4415
4416/* reg_pptb_pm_msb
4417 * Enables the update of the prio_to_buff field.
4418 * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
4419 * Access: RW
4420 */
4421MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
4422
4423/* reg_pptb_untagged_buff
4424 * Mapping of untagged frames to one of the allocated receive port buffers.
4425 * Access: RW
4426 *
4427 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
4428 * Spectrum, as it maps untagged packets based on the default switch priority.
4429 */
4430MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
4431
Ido Schimmel11719a52016-07-15 11:15:02 +02004432/* reg_pptb_prio_to_buff_msb
4433 * Mapping of switch priority <i+8> to one of the allocated receive port
4434 * buffers.
4435 * Access: RW
4436 */
4437MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
4438
Ido Schimmelb98ff152016-04-06 17:10:00 +02004439#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
4440
4441static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
4442{
4443 MLXSW_REG_ZERO(pptb, payload);
4444 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
4445 mlxsw_reg_pptb_local_port_set(payload, local_port);
4446 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
Ido Schimmel11719a52016-07-15 11:15:02 +02004447 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
4448}
4449
4450static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
4451 u8 buff)
4452{
4453 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
4454 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
Ido Schimmelb98ff152016-04-06 17:10:00 +02004455}
4456
Jiri Pirkoe0594362015-10-16 14:01:31 +02004457/* PBMC - Port Buffer Management Control Register
4458 * ----------------------------------------------
4459 * The PBMC register configures and retrieves the port packet buffer
4460 * allocation for different Prios, and the Pause threshold management.
4461 */
4462#define MLXSW_REG_PBMC_ID 0x500C
Ido Schimmel7ad7cd62016-04-06 17:10:04 +02004463#define MLXSW_REG_PBMC_LEN 0x6C
Jiri Pirkoe0594362015-10-16 14:01:31 +02004464
Jiri Pirko21978dc2016-10-21 16:07:20 +02004465MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02004466
4467/* reg_pbmc_local_port
4468 * Local port number.
4469 * Access: Index
4470 */
4471MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
4472
4473/* reg_pbmc_xoff_timer_value
4474 * When device generates a pause frame, it uses this value as the pause
4475 * timer (time for the peer port to pause in quota-512 bit time).
4476 * Access: RW
4477 */
4478MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
4479
4480/* reg_pbmc_xoff_refresh
4481 * The time before a new pause frame should be sent to refresh the pause RW
4482 * state. Using the same units as xoff_timer_value above (in quota-512 bit
4483 * time).
4484 * Access: RW
4485 */
4486MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
4487
Ido Schimmeld6b7c132016-04-06 17:10:05 +02004488#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
4489
Jiri Pirkoe0594362015-10-16 14:01:31 +02004490/* reg_pbmc_buf_lossy
4491 * The field indicates if the buffer is lossy.
4492 * 0 - Lossless
4493 * 1 - Lossy
4494 * Access: RW
4495 */
4496MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
4497
4498/* reg_pbmc_buf_epsb
4499 * Eligible for Port Shared buffer.
4500 * If epsb is set, packets assigned to buffer are allowed to insert the port
4501 * shared buffer.
4502 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
4503 * Access: RW
4504 */
4505MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
4506
4507/* reg_pbmc_buf_size
4508 * The part of the packet buffer array is allocated for the specific buffer.
4509 * Units are represented in cells.
4510 * Access: RW
4511 */
4512MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
4513
Ido Schimmel155f9de2016-04-06 17:10:13 +02004514/* reg_pbmc_buf_xoff_threshold
4515 * Once the amount of data in the buffer goes above this value, device
4516 * starts sending PFC frames for all priorities associated with the
4517 * buffer. Units are represented in cells. Reserved in case of lossy
4518 * buffer.
4519 * Access: RW
4520 *
4521 * Note: In Spectrum, reserved for buffer[9].
4522 */
4523MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
4524 0x08, 0x04, false);
4525
4526/* reg_pbmc_buf_xon_threshold
4527 * When the amount of data in the buffer goes below this value, device
4528 * stops sending PFC frames for the priorities associated with the
4529 * buffer. Units are represented in cells. Reserved in case of lossy
4530 * buffer.
4531 * Access: RW
4532 *
4533 * Note: In Spectrum, reserved for buffer[9].
4534 */
4535MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
4536 0x08, 0x04, false);
4537
Jiri Pirkoe0594362015-10-16 14:01:31 +02004538static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
4539 u16 xoff_timer_value, u16 xoff_refresh)
4540{
4541 MLXSW_REG_ZERO(pbmc, payload);
4542 mlxsw_reg_pbmc_local_port_set(payload, local_port);
4543 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
4544 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
4545}
4546
4547static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
4548 int buf_index,
4549 u16 size)
4550{
4551 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
4552 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
4553 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
4554}
4555
Ido Schimmel155f9de2016-04-06 17:10:13 +02004556static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
4557 int buf_index, u16 size,
4558 u16 threshold)
4559{
4560 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
4561 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
4562 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
4563 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
4564 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
4565}
4566
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004567/* PSPA - Port Switch Partition Allocation
4568 * ---------------------------------------
4569 * Controls the association of a port with a switch partition and enables
4570 * configuring ports as stacking ports.
4571 */
Jiri Pirko3f0effd12015-10-15 17:43:23 +02004572#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004573#define MLXSW_REG_PSPA_LEN 0x8
4574
Jiri Pirko21978dc2016-10-21 16:07:20 +02004575MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004576
4577/* reg_pspa_swid
4578 * Switch partition ID.
4579 * Access: RW
4580 */
4581MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
4582
4583/* reg_pspa_local_port
4584 * Local port number.
4585 * Access: Index
4586 */
4587MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
4588
4589/* reg_pspa_sub_port
4590 * Virtual port within the local port. Set to 0 when virtual ports are
4591 * disabled on the local port.
4592 * Access: Index
4593 */
4594MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
4595
4596static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
4597{
4598 MLXSW_REG_ZERO(pspa, payload);
4599 mlxsw_reg_pspa_swid_set(payload, swid);
4600 mlxsw_reg_pspa_local_port_set(payload, local_port);
4601 mlxsw_reg_pspa_sub_port_set(payload, 0);
4602}
4603
4604/* HTGT - Host Trap Group Table
4605 * ----------------------------
4606 * Configures the properties for forwarding to CPU.
4607 */
4608#define MLXSW_REG_HTGT_ID 0x7002
Elad Raze158e5e2017-02-06 13:56:27 +01004609#define MLXSW_REG_HTGT_LEN 0x20
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004610
Jiri Pirko21978dc2016-10-21 16:07:20 +02004611MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004612
4613/* reg_htgt_swid
4614 * Switch partition ID.
4615 * Access: Index
4616 */
4617MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
4618
4619#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
4620
4621/* reg_htgt_type
4622 * CPU path type.
4623 * Access: RW
4624 */
4625MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
4626
Ido Schimmel801bd3d2015-10-15 17:43:28 +02004627enum mlxsw_reg_htgt_trap_group {
4628 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004629 MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX,
4630 MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL,
4631 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
4632 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
4633 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
4634 MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02004635 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004636 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
Yotam Gigib48cfc82017-09-19 10:00:20 +02004637 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
4638 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004639 MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02004640 MLXSW_REG_HTGT_TRAP_GROUP_SP_HOST_MISS,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004641 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
4642 MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
4643 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
4644 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
Yotam Gigib48cfc82017-09-19 10:00:20 +02004645 MLXSW_REG_HTGT_TRAP_GROUP_SP_RPF,
Nogah Frankel117b0da2016-11-25 10:33:44 +01004646 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
Arkadi Sharshevsky588823f2017-07-17 14:15:31 +02004647 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_MLD,
Arkadi Sharshevsky8d548142017-07-18 10:10:11 +02004648 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_ND,
Ido Schimmel801bd3d2015-10-15 17:43:28 +02004649};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004650
4651/* reg_htgt_trap_group
4652 * Trap group number. User defined number specifying which trap groups
4653 * should be forwarded to the CPU. The mapping between trap IDs and trap
4654 * groups is configured using HPKT register.
4655 * Access: Index
4656 */
4657MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
4658
4659enum {
4660 MLXSW_REG_HTGT_POLICER_DISABLE,
4661 MLXSW_REG_HTGT_POLICER_ENABLE,
4662};
4663
4664/* reg_htgt_pide
4665 * Enable policer ID specified using 'pid' field.
4666 * Access: RW
4667 */
4668MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
4669
Nogah Frankel579c82e2016-11-25 10:33:42 +01004670#define MLXSW_REG_HTGT_INVALID_POLICER 0xff
4671
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004672/* reg_htgt_pid
4673 * Policer ID for the trap group.
4674 * Access: RW
4675 */
4676MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
4677
4678#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
4679
4680/* reg_htgt_mirror_action
4681 * Mirror action to use.
4682 * 0 - Trap to CPU.
4683 * 1 - Trap to CPU and mirror to a mirroring agent.
4684 * 2 - Mirror to a mirroring agent and do not trap to CPU.
4685 * Access: RW
4686 *
4687 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
4688 */
4689MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
4690
4691/* reg_htgt_mirroring_agent
4692 * Mirroring agent.
4693 * Access: RW
4694 */
4695MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
4696
Nogah Frankel579c82e2016-11-25 10:33:42 +01004697#define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
4698
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004699/* reg_htgt_priority
4700 * Trap group priority.
4701 * In case a packet matches multiple classification rules, the packet will
4702 * only be trapped once, based on the trap ID associated with the group (via
4703 * register HPKT) with the highest priority.
4704 * Supported values are 0-7, with 7 represnting the highest priority.
4705 * Access: RW
4706 *
4707 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
4708 * by the 'trap_group' field.
4709 */
4710MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
4711
Nogah Frankel579c82e2016-11-25 10:33:42 +01004712#define MLXSW_REG_HTGT_DEFAULT_TC 7
4713
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004714/* reg_htgt_local_path_cpu_tclass
4715 * CPU ingress traffic class for the trap group.
4716 * Access: RW
4717 */
4718MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
4719
Nogah Frankel579c82e2016-11-25 10:33:42 +01004720enum mlxsw_reg_htgt_local_path_rdq {
4721 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
4722 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
4723 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
4724 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
4725};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004726/* reg_htgt_local_path_rdq
4727 * Receive descriptor queue (RDQ) to use for the trap group.
4728 * Access: RW
4729 */
4730MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
4731
Nogah Frankel579c82e2016-11-25 10:33:42 +01004732static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
4733 u8 priority, u8 tc)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004734{
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004735 MLXSW_REG_ZERO(htgt, payload);
Nogah Frankel579c82e2016-11-25 10:33:42 +01004736
4737 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
4738 mlxsw_reg_htgt_pide_set(payload,
4739 MLXSW_REG_HTGT_POLICER_DISABLE);
4740 } else {
4741 mlxsw_reg_htgt_pide_set(payload,
4742 MLXSW_REG_HTGT_POLICER_ENABLE);
4743 mlxsw_reg_htgt_pid_set(payload, policer_id);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004744 }
Nogah Frankel579c82e2016-11-25 10:33:42 +01004745
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004746 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02004747 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004748 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
4749 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
Nogah Frankel579c82e2016-11-25 10:33:42 +01004750 mlxsw_reg_htgt_priority_set(payload, priority);
4751 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
4752 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004753}
4754
4755/* HPKT - Host Packet Trap
4756 * -----------------------
4757 * Configures trap IDs inside trap groups.
4758 */
4759#define MLXSW_REG_HPKT_ID 0x7003
4760#define MLXSW_REG_HPKT_LEN 0x10
4761
Jiri Pirko21978dc2016-10-21 16:07:20 +02004762MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004763
4764enum {
4765 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
4766 MLXSW_REG_HPKT_ACK_REQUIRED,
4767};
4768
4769/* reg_hpkt_ack
4770 * Require acknowledgements from the host for events.
4771 * If set, then the device will wait for the event it sent to be acknowledged
4772 * by the host. This option is only relevant for event trap IDs.
4773 * Access: RW
4774 *
4775 * Note: Currently not supported by firmware.
4776 */
4777MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
4778
4779enum mlxsw_reg_hpkt_action {
4780 MLXSW_REG_HPKT_ACTION_FORWARD,
4781 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
4782 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
4783 MLXSW_REG_HPKT_ACTION_DISCARD,
4784 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
4785 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
4786};
4787
4788/* reg_hpkt_action
4789 * Action to perform on packet when trapped.
4790 * 0 - No action. Forward to CPU based on switching rules.
4791 * 1 - Trap to CPU (CPU receives sole copy).
4792 * 2 - Mirror to CPU (CPU receives a replica of the packet).
4793 * 3 - Discard.
4794 * 4 - Soft discard (allow other traps to act on the packet).
4795 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
4796 * Access: RW
4797 *
4798 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
4799 * addressed to the CPU.
4800 */
4801MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
4802
4803/* reg_hpkt_trap_group
4804 * Trap group to associate the trap with.
4805 * Access: RW
4806 */
4807MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
4808
4809/* reg_hpkt_trap_id
4810 * Trap ID.
4811 * Access: Index
4812 *
4813 * Note: A trap ID can only be associated with a single trap group. The device
4814 * will associate the trap ID with the last trap group configured.
4815 */
4816MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
4817
4818enum {
4819 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
4820 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
4821 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
4822};
4823
4824/* reg_hpkt_ctrl
4825 * Configure dedicated buffer resources for control packets.
Nogah Frankeld570b7e2016-11-25 10:33:38 +01004826 * Ignored by SwitchX-2.
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004827 * 0 - Keep factory defaults.
4828 * 1 - Do not use control buffer for this trap ID.
4829 * 2 - Use control buffer for this trap ID.
4830 * Access: RW
4831 */
4832MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
4833
Nogah Frankeld570b7e2016-11-25 10:33:38 +01004834static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
4835 enum mlxsw_reg_htgt_trap_group trap_group,
4836 bool is_ctrl)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004837{
4838 MLXSW_REG_ZERO(hpkt, payload);
4839 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
4840 mlxsw_reg_hpkt_action_set(payload, action);
4841 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
4842 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
Nogah Frankeld570b7e2016-11-25 10:33:38 +01004843 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
4844 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
4845 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02004846}
4847
Ido Schimmel69c407a2016-07-02 11:00:13 +02004848/* RGCR - Router General Configuration Register
4849 * --------------------------------------------
4850 * The register is used for setting up the router configuration.
4851 */
4852#define MLXSW_REG_RGCR_ID 0x8001
4853#define MLXSW_REG_RGCR_LEN 0x28
4854
Jiri Pirko21978dc2016-10-21 16:07:20 +02004855MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
Ido Schimmel69c407a2016-07-02 11:00:13 +02004856
4857/* reg_rgcr_ipv4_en
4858 * IPv4 router enable.
4859 * Access: RW
4860 */
4861MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
4862
4863/* reg_rgcr_ipv6_en
4864 * IPv6 router enable.
4865 * Access: RW
4866 */
4867MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
4868
4869/* reg_rgcr_max_router_interfaces
4870 * Defines the maximum number of active router interfaces for all virtual
4871 * routers.
4872 * Access: RW
4873 */
4874MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
4875
4876/* reg_rgcr_usp
4877 * Update switch priority and packet color.
4878 * 0 - Preserve the value of Switch Priority and packet color.
4879 * 1 - Recalculate the value of Switch Priority and packet color.
4880 * Access: RW
4881 *
4882 * Note: Not supported by SwitchX and SwitchX-2.
4883 */
4884MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
4885
4886/* reg_rgcr_pcp_rw
4887 * Indicates how to handle the pcp_rewrite_en value:
4888 * 0 - Preserve the value of pcp_rewrite_en.
4889 * 2 - Disable PCP rewrite.
4890 * 3 - Enable PCP rewrite.
4891 * Access: RW
4892 *
4893 * Note: Not supported by SwitchX and SwitchX-2.
4894 */
4895MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
4896
4897/* reg_rgcr_activity_dis
4898 * Activity disable:
4899 * 0 - Activity will be set when an entry is hit (default).
4900 * 1 - Activity will not be set when an entry is hit.
4901 *
4902 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
4903 * (RALUE).
4904 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
4905 * Entry (RAUHT).
4906 * Bits 2:7 are reserved.
4907 * Access: RW
4908 *
4909 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
4910 */
4911MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
4912
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02004913static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
4914 bool ipv6_en)
Ido Schimmel69c407a2016-07-02 11:00:13 +02004915{
4916 MLXSW_REG_ZERO(rgcr, payload);
4917 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
Arkadi Sharshevskye29237e2017-07-18 10:10:09 +02004918 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
Ido Schimmel69c407a2016-07-02 11:00:13 +02004919}
4920
Ido Schimmel3dc26682016-07-02 11:00:18 +02004921/* RITR - Router Interface Table Register
4922 * --------------------------------------
4923 * The register is used to configure the router interface table.
4924 */
4925#define MLXSW_REG_RITR_ID 0x8002
4926#define MLXSW_REG_RITR_LEN 0x40
4927
Jiri Pirko21978dc2016-10-21 16:07:20 +02004928MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
Ido Schimmel3dc26682016-07-02 11:00:18 +02004929
4930/* reg_ritr_enable
4931 * Enables routing on the router interface.
4932 * Access: RW
4933 */
4934MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
4935
4936/* reg_ritr_ipv4
4937 * IPv4 routing enable. Enables routing of IPv4 traffic on the router
4938 * interface.
4939 * Access: RW
4940 */
4941MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
4942
4943/* reg_ritr_ipv6
4944 * IPv6 routing enable. Enables routing of IPv6 traffic on the router
4945 * interface.
4946 * Access: RW
4947 */
4948MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
4949
Yotam Gigi4af59642017-09-19 10:00:18 +02004950/* reg_ritr_ipv4_mc
4951 * IPv4 multicast routing enable.
4952 * Access: RW
4953 */
4954MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
4955
Yuval Mintz9a3d1832018-03-26 15:01:37 +03004956/* reg_ritr_ipv6_mc
4957 * IPv6 multicast routing enable.
4958 * Access: RW
4959 */
4960MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
4961
Ido Schimmel3dc26682016-07-02 11:00:18 +02004962enum mlxsw_reg_ritr_if_type {
Petr Machata78676ad2017-07-31 09:27:26 +02004963 /* VLAN interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02004964 MLXSW_REG_RITR_VLAN_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02004965 /* FID interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02004966 MLXSW_REG_RITR_FID_IF,
Petr Machata78676ad2017-07-31 09:27:26 +02004967 /* Sub-port interface. */
Ido Schimmel3dc26682016-07-02 11:00:18 +02004968 MLXSW_REG_RITR_SP_IF,
Petr Machata99ae8e32017-09-02 23:49:09 +02004969 /* Loopback Interface. */
4970 MLXSW_REG_RITR_LOOPBACK_IF,
Ido Schimmel3dc26682016-07-02 11:00:18 +02004971};
4972
4973/* reg_ritr_type
Petr Machata78676ad2017-07-31 09:27:26 +02004974 * Router interface type as per enum mlxsw_reg_ritr_if_type.
Ido Schimmel3dc26682016-07-02 11:00:18 +02004975 * Access: RW
4976 */
4977MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
4978
4979enum {
4980 MLXSW_REG_RITR_RIF_CREATE,
4981 MLXSW_REG_RITR_RIF_DEL,
4982};
4983
4984/* reg_ritr_op
4985 * Opcode:
4986 * 0 - Create or edit RIF.
4987 * 1 - Delete RIF.
4988 * Reserved for SwitchX-2. For Spectrum, editing of interface properties
4989 * is not supported. An interface must be deleted and re-created in order
4990 * to update properties.
4991 * Access: WO
4992 */
4993MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
4994
4995/* reg_ritr_rif
4996 * Router interface index. A pointer to the Router Interface Table.
4997 * Access: Index
4998 */
4999MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
5000
5001/* reg_ritr_ipv4_fe
5002 * IPv4 Forwarding Enable.
5003 * Enables routing of IPv4 traffic on the router interface. When disabled,
5004 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
5005 * Not supported in SwitchX-2.
5006 * Access: RW
5007 */
5008MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
5009
5010/* reg_ritr_ipv6_fe
5011 * IPv6 Forwarding Enable.
5012 * Enables routing of IPv6 traffic on the router interface. When disabled,
5013 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
5014 * Not supported in SwitchX-2.
5015 * Access: RW
5016 */
5017MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
5018
Yotam Gigi4af59642017-09-19 10:00:18 +02005019/* reg_ritr_ipv4_mc_fe
5020 * IPv4 Multicast Forwarding Enable.
5021 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
5022 * will be enabled.
5023 * Access: RW
5024 */
5025MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
5026
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005027/* reg_ritr_ipv6_mc_fe
5028 * IPv6 Multicast Forwarding Enable.
5029 * When disabled, forwarding is blocked but local traffic (traps and IP to me)
5030 * will be enabled.
5031 * Access: RW
5032 */
5033MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
5034
Ido Schimmela94a6142016-08-17 16:39:33 +02005035/* reg_ritr_lb_en
5036 * Loop-back filter enable for unicast packets.
5037 * If the flag is set then loop-back filter for unicast packets is
5038 * implemented on the RIF. Multicast packets are always subject to
5039 * loop-back filtering.
5040 * Access: RW
5041 */
5042MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
5043
Ido Schimmel3dc26682016-07-02 11:00:18 +02005044/* reg_ritr_virtual_router
5045 * Virtual router ID associated with the router interface.
5046 * Access: RW
5047 */
5048MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
5049
5050/* reg_ritr_mtu
5051 * Router interface MTU.
5052 * Access: RW
5053 */
5054MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
5055
5056/* reg_ritr_if_swid
5057 * Switch partition ID.
5058 * Access: RW
5059 */
5060MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
5061
5062/* reg_ritr_if_mac
5063 * Router interface MAC address.
5064 * In Spectrum, all MAC addresses must have the same 38 MSBits.
5065 * Access: RW
5066 */
5067MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
5068
Ido Schimmelc3a49542018-07-14 11:39:54 +03005069/* reg_ritr_if_vrrp_id_ipv6
5070 * VRRP ID for IPv6
5071 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
5072 * Access: RW
5073 */
5074MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
5075
5076/* reg_ritr_if_vrrp_id_ipv4
5077 * VRRP ID for IPv4
5078 * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
5079 * Access: RW
5080 */
5081MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
5082
Ido Schimmel3dc26682016-07-02 11:00:18 +02005083/* VLAN Interface */
5084
5085/* reg_ritr_vlan_if_vid
5086 * VLAN ID.
5087 * Access: RW
5088 */
5089MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
5090
5091/* FID Interface */
5092
5093/* reg_ritr_fid_if_fid
5094 * Filtering ID. Used to connect a bridge to the router. Only FIDs from
5095 * the vFID range are supported.
5096 * Access: RW
5097 */
5098MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
5099
5100static inline void mlxsw_reg_ritr_fid_set(char *payload,
5101 enum mlxsw_reg_ritr_if_type rif_type,
5102 u16 fid)
5103{
5104 if (rif_type == MLXSW_REG_RITR_FID_IF)
5105 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
5106 else
5107 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
5108}
5109
5110/* Sub-port Interface */
5111
5112/* reg_ritr_sp_if_lag
5113 * LAG indication. When this bit is set the system_port field holds the
5114 * LAG identifier.
5115 * Access: RW
5116 */
5117MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
5118
5119/* reg_ritr_sp_system_port
5120 * Port unique indentifier. When lag bit is set, this field holds the
5121 * lag_id in bits 0:9.
5122 * Access: RW
5123 */
5124MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
5125
5126/* reg_ritr_sp_if_vid
5127 * VLAN ID.
5128 * Access: RW
5129 */
5130MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
5131
Petr Machata99ae8e32017-09-02 23:49:09 +02005132/* Loopback Interface */
5133
5134enum mlxsw_reg_ritr_loopback_protocol {
5135 /* IPinIP IPv4 underlay Unicast */
5136 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
5137 /* IPinIP IPv6 underlay Unicast */
5138 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
5139};
5140
5141/* reg_ritr_loopback_protocol
5142 * Access: RW
5143 */
5144MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
5145
5146enum mlxsw_reg_ritr_loopback_ipip_type {
5147 /* Tunnel is IPinIP. */
5148 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
5149 /* Tunnel is GRE, no key. */
5150 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
5151 /* Tunnel is GRE, with a key. */
5152 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
5153};
5154
5155/* reg_ritr_loopback_ipip_type
5156 * Encapsulation type.
5157 * Access: RW
5158 */
5159MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
5160
5161enum mlxsw_reg_ritr_loopback_ipip_options {
5162 /* The key is defined by gre_key. */
5163 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
5164};
5165
5166/* reg_ritr_loopback_ipip_options
5167 * Access: RW
5168 */
5169MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
5170
5171/* reg_ritr_loopback_ipip_uvr
5172 * Underlay Virtual Router ID.
5173 * Range is 0..cap_max_virtual_routers-1.
5174 * Reserved for Spectrum-2.
5175 * Access: RW
5176 */
5177MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
5178
5179/* reg_ritr_loopback_ipip_usip*
5180 * Encapsulation Underlay source IP.
5181 * Access: RW
5182 */
5183MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
5184MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
5185
5186/* reg_ritr_loopback_ipip_gre_key
5187 * GRE Key.
5188 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
5189 * Access: RW
5190 */
5191MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
5192
Arkadi Sharshevsky0f630fc2017-03-28 17:24:11 +02005193/* Shared between ingress/egress */
5194enum mlxsw_reg_ritr_counter_set_type {
5195 /* No Count. */
5196 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
5197 /* Basic. Used for router interfaces, counting the following:
5198 * - Error and Discard counters.
5199 * - Unicast, Multicast and Broadcast counters. Sharing the
5200 * same set of counters for the different type of traffic
5201 * (IPv4, IPv6 and mpls).
5202 */
5203 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
5204};
5205
5206/* reg_ritr_ingress_counter_index
5207 * Counter Index for flow counter.
5208 * Access: RW
5209 */
5210MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
5211
5212/* reg_ritr_ingress_counter_set_type
5213 * Igress Counter Set Type for router interface counter.
5214 * Access: RW
5215 */
5216MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
5217
5218/* reg_ritr_egress_counter_index
5219 * Counter Index for flow counter.
5220 * Access: RW
5221 */
5222MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
5223
5224/* reg_ritr_egress_counter_set_type
5225 * Egress Counter Set Type for router interface counter.
5226 * Access: RW
5227 */
5228MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
5229
5230static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
5231 bool enable, bool egress)
5232{
5233 enum mlxsw_reg_ritr_counter_set_type set_type;
5234
5235 if (enable)
5236 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
5237 else
5238 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
5239 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
5240
5241 if (egress)
5242 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
5243 else
5244 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
5245}
5246
Ido Schimmel3dc26682016-07-02 11:00:18 +02005247static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
5248{
5249 MLXSW_REG_ZERO(ritr, payload);
5250 mlxsw_reg_ritr_rif_set(payload, rif);
5251}
5252
5253static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
5254 u16 system_port, u16 vid)
5255{
5256 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
5257 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
5258 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
5259}
5260
5261static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
5262 enum mlxsw_reg_ritr_if_type type,
Petr Machata9571e822017-09-02 23:49:14 +02005263 u16 rif, u16 vr_id, u16 mtu)
Ido Schimmel3dc26682016-07-02 11:00:18 +02005264{
5265 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
5266
5267 MLXSW_REG_ZERO(ritr, payload);
5268 mlxsw_reg_ritr_enable_set(payload, enable);
5269 mlxsw_reg_ritr_ipv4_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02005270 mlxsw_reg_ritr_ipv6_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02005271 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005272 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
Ido Schimmel3dc26682016-07-02 11:00:18 +02005273 mlxsw_reg_ritr_type_set(payload, type);
5274 mlxsw_reg_ritr_op_set(payload, op);
5275 mlxsw_reg_ritr_rif_set(payload, rif);
5276 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
Arkadi Sharshevskye717e012017-07-18 10:10:10 +02005277 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
Yotam Gigi4af59642017-09-19 10:00:18 +02005278 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
Yuval Mintz9a3d1832018-03-26 15:01:37 +03005279 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
Ido Schimmela94a6142016-08-17 16:39:33 +02005280 mlxsw_reg_ritr_lb_en_set(payload, 1);
Ido Schimmel69132292017-03-10 08:53:42 +01005281 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
Ido Schimmel3dc26682016-07-02 11:00:18 +02005282 mlxsw_reg_ritr_mtu_set(payload, mtu);
Petr Machata9571e822017-09-02 23:49:14 +02005283}
5284
5285static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
5286{
Ido Schimmel3dc26682016-07-02 11:00:18 +02005287 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
5288}
5289
Petr Machata99ae8e32017-09-02 23:49:09 +02005290static inline void
5291mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
5292 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
5293 enum mlxsw_reg_ritr_loopback_ipip_options options,
5294 u16 uvr_id, u32 gre_key)
5295{
5296 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
5297 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
5298 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
5299 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
5300}
5301
5302static inline void
5303mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
5304 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
5305 enum mlxsw_reg_ritr_loopback_ipip_options options,
5306 u16 uvr_id, u32 usip, u32 gre_key)
5307{
5308 mlxsw_reg_ritr_loopback_protocol_set(payload,
5309 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
5310 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
5311 uvr_id, gre_key);
5312 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
5313}
5314
Yotam Gigi46a70542017-09-19 10:00:13 +02005315/* RTAR - Router TCAM Allocation Register
5316 * --------------------------------------
5317 * This register is used for allocation of regions in the TCAM table.
5318 */
5319#define MLXSW_REG_RTAR_ID 0x8004
5320#define MLXSW_REG_RTAR_LEN 0x20
5321
5322MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
5323
5324enum mlxsw_reg_rtar_op {
5325 MLXSW_REG_RTAR_OP_ALLOCATE,
5326 MLXSW_REG_RTAR_OP_RESIZE,
5327 MLXSW_REG_RTAR_OP_DEALLOCATE,
5328};
5329
5330/* reg_rtar_op
5331 * Access: WO
5332 */
5333MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
5334
5335enum mlxsw_reg_rtar_key_type {
5336 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
5337 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
5338};
5339
5340/* reg_rtar_key_type
5341 * TCAM key type for the region.
5342 * Access: WO
5343 */
5344MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
5345
5346/* reg_rtar_region_size
5347 * TCAM region size. When allocating/resizing this is the requested
5348 * size, the response is the actual size.
5349 * Note: Actual size may be larger than requested.
5350 * Reserved for op = Deallocate
5351 * Access: WO
5352 */
5353MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
5354
5355static inline void mlxsw_reg_rtar_pack(char *payload,
5356 enum mlxsw_reg_rtar_op op,
5357 enum mlxsw_reg_rtar_key_type key_type,
5358 u16 region_size)
5359{
5360 MLXSW_REG_ZERO(rtar, payload);
5361 mlxsw_reg_rtar_op_set(payload, op);
5362 mlxsw_reg_rtar_key_type_set(payload, key_type);
5363 mlxsw_reg_rtar_region_size_set(payload, region_size);
5364}
5365
Yotam Gigi089f9812016-07-05 11:27:48 +02005366/* RATR - Router Adjacency Table Register
5367 * --------------------------------------
5368 * The RATR register is used to configure the Router Adjacency (next-hop)
5369 * Table.
5370 */
5371#define MLXSW_REG_RATR_ID 0x8008
5372#define MLXSW_REG_RATR_LEN 0x2C
5373
Jiri Pirko21978dc2016-10-21 16:07:20 +02005374MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
Yotam Gigi089f9812016-07-05 11:27:48 +02005375
5376enum mlxsw_reg_ratr_op {
5377 /* Read */
5378 MLXSW_REG_RATR_OP_QUERY_READ = 0,
5379 /* Read and clear activity */
5380 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
5381 /* Write Adjacency entry */
5382 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
5383 /* Write Adjacency entry only if the activity is cleared.
5384 * The write may not succeed if the activity is set. There is not
5385 * direct feedback if the write has succeeded or not, however
5386 * the get will reveal the actual entry (SW can compare the get
5387 * response to the set command).
5388 */
5389 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
5390};
5391
5392/* reg_ratr_op
5393 * Note that Write operation may also be used for updating
5394 * counter_set_type and counter_index. In this case all other
5395 * fields must not be updated.
5396 * Access: OP
5397 */
5398MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
5399
5400/* reg_ratr_v
5401 * Valid bit. Indicates if the adjacency entry is valid.
5402 * Note: the device may need some time before reusing an invalidated
5403 * entry. During this time the entry can not be reused. It is
5404 * recommended to use another entry before reusing an invalidated
5405 * entry (e.g. software can put it at the end of the list for
5406 * reusing). Trying to access an invalidated entry not yet cleared
5407 * by the device results with failure indicating "Try Again" status.
5408 * When valid is '0' then egress_router_interface,trap_action,
5409 * adjacency_parameters and counters are reserved
5410 * Access: RW
5411 */
5412MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
5413
5414/* reg_ratr_a
5415 * Activity. Set for new entries. Set if a packet lookup has hit on
5416 * the specific entry. To clear the a bit, use "clear activity".
5417 * Access: RO
5418 */
5419MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
5420
Petr Machata7c819de2017-09-02 23:49:10 +02005421enum mlxsw_reg_ratr_type {
5422 /* Ethernet */
5423 MLXSW_REG_RATR_TYPE_ETHERNET,
5424 /* IPoIB Unicast without GRH.
5425 * Reserved for Spectrum.
5426 */
5427 MLXSW_REG_RATR_TYPE_IPOIB_UC,
5428 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
5429 * adjacency).
5430 * Reserved for Spectrum.
5431 */
5432 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
5433 /* IPoIB Multicast.
5434 * Reserved for Spectrum.
5435 */
5436 MLXSW_REG_RATR_TYPE_IPOIB_MC,
5437 /* MPLS.
5438 * Reserved for SwitchX/-2.
5439 */
5440 MLXSW_REG_RATR_TYPE_MPLS,
5441 /* IPinIP Encap.
5442 * Reserved for SwitchX/-2.
5443 */
5444 MLXSW_REG_RATR_TYPE_IPIP,
5445};
5446
5447/* reg_ratr_type
5448 * Adjacency entry type.
5449 * Access: RW
5450 */
5451MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
5452
Yotam Gigi089f9812016-07-05 11:27:48 +02005453/* reg_ratr_adjacency_index_low
5454 * Bits 15:0 of index into the adjacency table.
5455 * For SwitchX and SwitchX-2, the adjacency table is linear and
5456 * used for adjacency entries only.
5457 * For Spectrum, the index is to the KVD linear.
5458 * Access: Index
5459 */
5460MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
5461
5462/* reg_ratr_egress_router_interface
5463 * Range is 0 .. cap_max_router_interfaces - 1
5464 * Access: RW
5465 */
5466MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
5467
5468enum mlxsw_reg_ratr_trap_action {
5469 MLXSW_REG_RATR_TRAP_ACTION_NOP,
5470 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
5471 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
5472 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
5473 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
5474};
5475
5476/* reg_ratr_trap_action
5477 * see mlxsw_reg_ratr_trap_action
5478 * Access: RW
5479 */
5480MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
5481
Yotam Gigi089f9812016-07-05 11:27:48 +02005482/* reg_ratr_adjacency_index_high
5483 * Bits 23:16 of the adjacency_index.
5484 * Access: Index
5485 */
5486MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
5487
Petr Machata6c4153b2017-09-02 23:49:11 +02005488enum mlxsw_reg_ratr_trap_id {
5489 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
5490 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
5491};
5492
Yotam Gigi089f9812016-07-05 11:27:48 +02005493/* reg_ratr_trap_id
5494 * Trap ID to be reported to CPU.
5495 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
5496 * For trap_action of NOP, MIRROR and DISCARD_ERROR
5497 * Access: RW
5498 */
5499MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
5500
5501/* reg_ratr_eth_destination_mac
5502 * MAC address of the destination next-hop.
5503 * Access: RW
5504 */
5505MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
5506
Petr Machata7c819de2017-09-02 23:49:10 +02005507enum mlxsw_reg_ratr_ipip_type {
5508 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
5509 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
5510 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
5511 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
5512};
5513
5514/* reg_ratr_ipip_type
5515 * Underlay destination ip type.
5516 * Note: the type field must match the protocol of the router interface.
5517 * Access: RW
5518 */
5519MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
5520
5521/* reg_ratr_ipip_ipv4_udip
5522 * Underlay ipv4 dip.
5523 * Reserved when ipip_type is IPv6.
5524 * Access: RW
5525 */
5526MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
5527
5528/* reg_ratr_ipip_ipv6_ptr
5529 * Pointer to IPv6 underlay destination ip address.
5530 * For Spectrum: Pointer to KVD linear space.
5531 * Access: RW
5532 */
5533MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
5534
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02005535enum mlxsw_reg_flow_counter_set_type {
5536 /* No count */
5537 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
5538 /* Count packets and bytes */
5539 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
5540 /* Count only packets */
5541 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
5542};
5543
5544/* reg_ratr_counter_set_type
5545 * Counter set type for flow counters
5546 * Access: RW
5547 */
5548MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
5549
5550/* reg_ratr_counter_index
5551 * Counter index for flow counters
5552 * Access: RW
5553 */
5554MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
5555
Yotam Gigi089f9812016-07-05 11:27:48 +02005556static inline void
5557mlxsw_reg_ratr_pack(char *payload,
5558 enum mlxsw_reg_ratr_op op, bool valid,
Petr Machata89e41982017-09-02 23:49:15 +02005559 enum mlxsw_reg_ratr_type type,
Yotam Gigi089f9812016-07-05 11:27:48 +02005560 u32 adjacency_index, u16 egress_rif)
5561{
5562 MLXSW_REG_ZERO(ratr, payload);
5563 mlxsw_reg_ratr_op_set(payload, op);
5564 mlxsw_reg_ratr_v_set(payload, valid);
Petr Machata89e41982017-09-02 23:49:15 +02005565 mlxsw_reg_ratr_type_set(payload, type);
Yotam Gigi089f9812016-07-05 11:27:48 +02005566 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
5567 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
5568 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
5569}
5570
5571static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
5572 const char *dest_mac)
5573{
5574 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
5575}
5576
Petr Machata7c819de2017-09-02 23:49:10 +02005577static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
5578{
5579 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
5580 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
5581}
5582
Arkadi Sharshevskyf4de25f2017-09-25 10:32:27 +02005583static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
5584 bool counter_enable)
5585{
5586 enum mlxsw_reg_flow_counter_set_type set_type;
5587
5588 if (counter_enable)
5589 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
5590 else
5591 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
5592
5593 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
5594 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
5595}
5596
Yuval Mintzddb362c2018-01-14 12:33:13 +01005597/* RDPM - Router DSCP to Priority Mapping
5598 * --------------------------------------
5599 * Controls the mapping from DSCP field to switch priority on routed packets
5600 */
5601#define MLXSW_REG_RDPM_ID 0x8009
5602#define MLXSW_REG_RDPM_BASE_LEN 0x00
5603#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
5604#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
5605#define MLXSW_REG_RDPM_LEN 0x40
5606#define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
5607 MLXSW_REG_RDPM_LEN - \
5608 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
5609
5610MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
5611
5612/* reg_dscp_entry_e
5613 * Enable update of the specific entry
5614 * Access: Index
5615 */
5616MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
5617 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
5618
5619/* reg_dscp_entry_prio
5620 * Switch Priority
5621 * Access: RW
5622 */
5623MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
5624 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
5625
5626static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
5627 u8 prio)
5628{
5629 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
5630 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
5631}
5632
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +02005633/* RICNT - Router Interface Counter Register
5634 * -----------------------------------------
5635 * The RICNT register retrieves per port performance counters
5636 */
5637#define MLXSW_REG_RICNT_ID 0x800B
5638#define MLXSW_REG_RICNT_LEN 0x100
5639
5640MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
5641
5642/* reg_ricnt_counter_index
5643 * Counter index
5644 * Access: RW
5645 */
5646MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
5647
5648enum mlxsw_reg_ricnt_counter_set_type {
5649 /* No Count. */
5650 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
5651 /* Basic. Used for router interfaces, counting the following:
5652 * - Error and Discard counters.
5653 * - Unicast, Multicast and Broadcast counters. Sharing the
5654 * same set of counters for the different type of traffic
5655 * (IPv4, IPv6 and mpls).
5656 */
5657 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
5658};
5659
5660/* reg_ricnt_counter_set_type
5661 * Counter Set Type for router interface counter
5662 * Access: RW
5663 */
5664MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
5665
5666enum mlxsw_reg_ricnt_opcode {
5667 /* Nop. Supported only for read access*/
5668 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
5669 /* Clear. Setting the clr bit will reset the counter value for
5670 * all counters of the specified Router Interface.
5671 */
5672 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
5673};
5674
5675/* reg_ricnt_opcode
5676 * Opcode
5677 * Access: RW
5678 */
5679MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
5680
5681/* reg_ricnt_good_unicast_packets
5682 * good unicast packets.
5683 * Access: RW
5684 */
5685MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
5686
5687/* reg_ricnt_good_multicast_packets
5688 * good multicast packets.
5689 * Access: RW
5690 */
5691MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
5692
5693/* reg_ricnt_good_broadcast_packets
5694 * good broadcast packets
5695 * Access: RW
5696 */
5697MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
5698
5699/* reg_ricnt_good_unicast_bytes
5700 * A count of L3 data and padding octets not including L2 headers
5701 * for good unicast frames.
5702 * Access: RW
5703 */
5704MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
5705
5706/* reg_ricnt_good_multicast_bytes
5707 * A count of L3 data and padding octets not including L2 headers
5708 * for good multicast frames.
5709 * Access: RW
5710 */
5711MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
5712
5713/* reg_ritr_good_broadcast_bytes
5714 * A count of L3 data and padding octets not including L2 headers
5715 * for good broadcast frames.
5716 * Access: RW
5717 */
5718MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
5719
5720/* reg_ricnt_error_packets
5721 * A count of errored frames that do not pass the router checks.
5722 * Access: RW
5723 */
5724MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
5725
5726/* reg_ricnt_discrad_packets
5727 * A count of non-errored frames that do not pass the router checks.
5728 * Access: RW
5729 */
5730MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
5731
5732/* reg_ricnt_error_bytes
5733 * A count of L3 data and padding octets not including L2 headers
5734 * for errored frames.
5735 * Access: RW
5736 */
5737MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
5738
5739/* reg_ricnt_discard_bytes
5740 * A count of L3 data and padding octets not including L2 headers
5741 * for non-errored frames that do not pass the router checks.
5742 * Access: RW
5743 */
5744MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
5745
5746static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
5747 enum mlxsw_reg_ricnt_opcode op)
5748{
5749 MLXSW_REG_ZERO(ricnt, payload);
5750 mlxsw_reg_ricnt_op_set(payload, op);
5751 mlxsw_reg_ricnt_counter_index_set(payload, index);
5752 mlxsw_reg_ricnt_counter_set_type_set(payload,
5753 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
5754}
5755
Yotam Gigi4fc92842017-09-19 10:00:17 +02005756/* RRCR - Router Rules Copy Register Layout
5757 * ----------------------------------------
5758 * This register is used for moving and copying route entry rules.
5759 */
5760#define MLXSW_REG_RRCR_ID 0x800F
5761#define MLXSW_REG_RRCR_LEN 0x24
5762
5763MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
5764
5765enum mlxsw_reg_rrcr_op {
5766 /* Move rules */
5767 MLXSW_REG_RRCR_OP_MOVE,
5768 /* Copy rules */
5769 MLXSW_REG_RRCR_OP_COPY,
5770};
5771
5772/* reg_rrcr_op
5773 * Access: WO
5774 */
5775MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
5776
5777/* reg_rrcr_offset
5778 * Offset within the region from which to copy/move.
5779 * Access: Index
5780 */
5781MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
5782
5783/* reg_rrcr_size
5784 * The number of rules to copy/move.
5785 * Access: WO
5786 */
5787MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
5788
5789/* reg_rrcr_table_id
5790 * Identifier of the table on which to perform the operation. Encoding is the
5791 * same as in RTAR.key_type
5792 * Access: Index
5793 */
5794MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
5795
5796/* reg_rrcr_dest_offset
5797 * Offset within the region to which to copy/move
5798 * Access: Index
5799 */
5800MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
5801
5802static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
5803 u16 offset, u16 size,
5804 enum mlxsw_reg_rtar_key_type table_id,
5805 u16 dest_offset)
5806{
5807 MLXSW_REG_ZERO(rrcr, payload);
5808 mlxsw_reg_rrcr_op_set(payload, op);
5809 mlxsw_reg_rrcr_offset_set(payload, offset);
5810 mlxsw_reg_rrcr_size_set(payload, size);
5811 mlxsw_reg_rrcr_table_id_set(payload, table_id);
5812 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
5813}
5814
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02005815/* RALTA - Router Algorithmic LPM Tree Allocation Register
5816 * -------------------------------------------------------
5817 * RALTA is used to allocate the LPM trees of the SHSPM method.
5818 */
5819#define MLXSW_REG_RALTA_ID 0x8010
5820#define MLXSW_REG_RALTA_LEN 0x04
5821
Jiri Pirko21978dc2016-10-21 16:07:20 +02005822MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
Jiri Pirko6f9fc3c2016-07-04 08:23:05 +02005823
5824/* reg_ralta_op
5825 * opcode (valid for Write, must be 0 on Read)
5826 * 0 - allocate a tree
5827 * 1 - deallocate a tree
5828 * Access: OP
5829 */
5830MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
5831
5832enum mlxsw_reg_ralxx_protocol {
5833 MLXSW_REG_RALXX_PROTOCOL_IPV4,
5834 MLXSW_REG_RALXX_PROTOCOL_IPV6,
5835};
5836
5837/* reg_ralta_protocol
5838 * Protocol.
5839 * Deallocation opcode: Reserved.
5840 * Access: RW
5841 */
5842MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
5843
5844/* reg_ralta_tree_id
5845 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
5846 * the tree identifier (managed by software).
5847 * Note that tree_id 0 is allocated for a default-route tree.
5848 * Access: Index
5849 */
5850MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
5851
5852static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
5853 enum mlxsw_reg_ralxx_protocol protocol,
5854 u8 tree_id)
5855{
5856 MLXSW_REG_ZERO(ralta, payload);
5857 mlxsw_reg_ralta_op_set(payload, !alloc);
5858 mlxsw_reg_ralta_protocol_set(payload, protocol);
5859 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
5860}
5861
Jiri Pirkoa9823352016-07-04 08:23:06 +02005862/* RALST - Router Algorithmic LPM Structure Tree Register
5863 * ------------------------------------------------------
5864 * RALST is used to set and query the structure of an LPM tree.
5865 * The structure of the tree must be sorted as a sorted binary tree, while
5866 * each node is a bin that is tagged as the length of the prefixes the lookup
5867 * will refer to. Therefore, bin X refers to a set of entries with prefixes
5868 * of X bits to match with the destination address. The bin 0 indicates
5869 * the default action, when there is no match of any prefix.
5870 */
5871#define MLXSW_REG_RALST_ID 0x8011
5872#define MLXSW_REG_RALST_LEN 0x104
5873
Jiri Pirko21978dc2016-10-21 16:07:20 +02005874MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
Jiri Pirkoa9823352016-07-04 08:23:06 +02005875
5876/* reg_ralst_root_bin
5877 * The bin number of the root bin.
5878 * 0<root_bin=<(length of IP address)
5879 * For a default-route tree configure 0xff
5880 * Access: RW
5881 */
5882MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
5883
5884/* reg_ralst_tree_id
5885 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
5886 * Access: Index
5887 */
5888MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
5889
5890#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
5891#define MLXSW_REG_RALST_BIN_OFFSET 0x04
5892#define MLXSW_REG_RALST_BIN_COUNT 128
5893
5894/* reg_ralst_left_child_bin
5895 * Holding the children of the bin according to the stored tree's structure.
5896 * For trees composed of less than 4 blocks, the bins in excess are reserved.
5897 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
5898 * Access: RW
5899 */
5900MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
5901
5902/* reg_ralst_right_child_bin
5903 * Holding the children of the bin according to the stored tree's structure.
5904 * For trees composed of less than 4 blocks, the bins in excess are reserved.
5905 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
5906 * Access: RW
5907 */
5908MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
5909 false);
5910
5911static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
5912{
5913 MLXSW_REG_ZERO(ralst, payload);
5914
5915 /* Initialize all bins to have no left or right child */
5916 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
5917 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
5918
5919 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
5920 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
5921}
5922
5923static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
5924 u8 left_child_bin,
5925 u8 right_child_bin)
5926{
5927 int bin_index = bin_number - 1;
5928
5929 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
5930 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
5931 right_child_bin);
5932}
5933
Jiri Pirko20ae4052016-07-04 08:23:07 +02005934/* RALTB - Router Algorithmic LPM Tree Binding Register
5935 * ----------------------------------------------------
5936 * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
5937 */
5938#define MLXSW_REG_RALTB_ID 0x8012
5939#define MLXSW_REG_RALTB_LEN 0x04
5940
Jiri Pirko21978dc2016-10-21 16:07:20 +02005941MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
Jiri Pirko20ae4052016-07-04 08:23:07 +02005942
5943/* reg_raltb_virtual_router
5944 * Virtual Router ID
5945 * Range is 0..cap_max_virtual_routers-1
5946 * Access: Index
5947 */
5948MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
5949
5950/* reg_raltb_protocol
5951 * Protocol.
5952 * Access: Index
5953 */
5954MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
5955
5956/* reg_raltb_tree_id
5957 * Tree to be used for the {virtual_router, protocol}
5958 * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
5959 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
5960 * Access: RW
5961 */
5962MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
5963
5964static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
5965 enum mlxsw_reg_ralxx_protocol protocol,
5966 u8 tree_id)
5967{
5968 MLXSW_REG_ZERO(raltb, payload);
5969 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
5970 mlxsw_reg_raltb_protocol_set(payload, protocol);
5971 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
5972}
5973
Jiri Pirkod5a1c742016-07-04 08:23:10 +02005974/* RALUE - Router Algorithmic LPM Unicast Entry Register
5975 * -----------------------------------------------------
5976 * RALUE is used to configure and query LPM entries that serve
5977 * the Unicast protocols.
5978 */
5979#define MLXSW_REG_RALUE_ID 0x8013
5980#define MLXSW_REG_RALUE_LEN 0x38
5981
Jiri Pirko21978dc2016-10-21 16:07:20 +02005982MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02005983
5984/* reg_ralue_protocol
5985 * Protocol.
5986 * Access: Index
5987 */
5988MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
5989
5990enum mlxsw_reg_ralue_op {
5991 /* Read operation. If entry doesn't exist, the operation fails. */
5992 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
5993 /* Clear on read operation. Used to read entry and
5994 * clear Activity bit.
5995 */
5996 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
5997 /* Write operation. Used to write a new entry to the table. All RW
5998 * fields are written for new entry. Activity bit is set
5999 * for new entries.
6000 */
6001 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
6002 /* Update operation. Used to update an existing route entry and
6003 * only update the RW fields that are detailed in the field
6004 * op_u_mask. If entry doesn't exist, the operation fails.
6005 */
6006 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
6007 /* Clear activity. The Activity bit (the field a) is cleared
6008 * for the entry.
6009 */
6010 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
6011 /* Delete operation. Used to delete an existing entry. If entry
6012 * doesn't exist, the operation fails.
6013 */
6014 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
6015};
6016
6017/* reg_ralue_op
6018 * Operation.
6019 * Access: OP
6020 */
6021MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
6022
6023/* reg_ralue_a
6024 * Activity. Set for new entries. Set if a packet lookup has hit on the
6025 * specific entry, only if the entry is a route. To clear the a bit, use
6026 * "clear activity" op.
6027 * Enabled by activity_dis in RGCR
6028 * Access: RO
6029 */
6030MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
6031
6032/* reg_ralue_virtual_router
6033 * Virtual Router ID
6034 * Range is 0..cap_max_virtual_routers-1
6035 * Access: Index
6036 */
6037MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
6038
6039#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
6040#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
6041#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
6042
6043/* reg_ralue_op_u_mask
6044 * opcode update mask.
6045 * On read operation, this field is reserved.
6046 * This field is valid for update opcode, otherwise - reserved.
6047 * This field is a bitmask of the fields that should be updated.
6048 * Access: WO
6049 */
6050MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
6051
6052/* reg_ralue_prefix_len
6053 * Number of bits in the prefix of the LPM route.
6054 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
6055 * two entries in the physical HW table.
6056 * Access: Index
6057 */
6058MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
6059
6060/* reg_ralue_dip*
6061 * The prefix of the route or of the marker that the object of the LPM
6062 * is compared with. The most significant bits of the dip are the prefix.
Petr Machata806a1c1a2017-07-31 09:27:24 +02006063 * The least significant bits must be '0' if the prefix_len is smaller
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006064 * than 128 for IPv6 or smaller than 32 for IPv4.
6065 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
6066 * Access: Index
6067 */
6068MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
Ido Schimmel62547f42017-07-18 10:10:23 +02006069MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006070
6071enum mlxsw_reg_ralue_entry_type {
6072 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
6073 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
6074 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
6075};
6076
6077/* reg_ralue_entry_type
6078 * Entry type.
6079 * Note - for Marker entries, the action_type and action fields are reserved.
6080 * Access: RW
6081 */
6082MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
6083
6084/* reg_ralue_bmp_len
6085 * The best match prefix length in the case that there is no match for
6086 * longer prefixes.
6087 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
6088 * Note for any update operation with entry_type modification this
6089 * field must be set.
6090 * Access: RW
6091 */
6092MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
6093
6094enum mlxsw_reg_ralue_action_type {
6095 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
6096 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
6097 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
6098};
6099
6100/* reg_ralue_action_type
6101 * Action Type
6102 * Indicates how the IP address is connected.
6103 * It can be connected to a local subnet through local_erif or can be
6104 * on a remote subnet connected through a next-hop router,
6105 * or transmitted to the CPU.
6106 * Reserved when entry_type = MARKER_ENTRY
6107 * Access: RW
6108 */
6109MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
6110
6111enum mlxsw_reg_ralue_trap_action {
6112 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
6113 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
6114 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
6115 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
6116 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
6117};
6118
6119/* reg_ralue_trap_action
6120 * Trap action.
6121 * For IP2ME action, only NOP and MIRROR are possible.
6122 * Access: RW
6123 */
6124MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
6125
6126/* reg_ralue_trap_id
6127 * Trap ID to be reported to CPU.
6128 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
6129 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
6130 * Access: RW
6131 */
6132MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
6133
6134/* reg_ralue_adjacency_index
6135 * Points to the first entry of the group-based ECMP.
6136 * Only relevant in case of REMOTE action.
6137 * Access: RW
6138 */
6139MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
6140
6141/* reg_ralue_ecmp_size
6142 * Amount of sequential entries starting
6143 * from the adjacency_index (the number of ECMPs).
6144 * The valid range is 1-64, 512, 1024, 2048 and 4096.
6145 * Reserved when trap_action is TRAP or DISCARD_ERROR.
6146 * Only relevant in case of REMOTE action.
6147 * Access: RW
6148 */
6149MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
6150
6151/* reg_ralue_local_erif
6152 * Egress Router Interface.
6153 * Only relevant in case of LOCAL action.
6154 * Access: RW
6155 */
6156MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
6157
Petr Machata83930cd2017-07-31 09:27:27 +02006158/* reg_ralue_ip2me_v
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006159 * Valid bit for the tunnel_ptr field.
6160 * If valid = 0 then trap to CPU as IP2ME trap ID.
6161 * If valid = 1 and the packet format allows NVE or IPinIP tunnel
6162 * decapsulation then tunnel decapsulation is done.
6163 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
6164 * decapsulation then trap as IP2ME trap ID.
6165 * Only relevant in case of IP2ME action.
6166 * Access: RW
6167 */
Petr Machata83930cd2017-07-31 09:27:27 +02006168MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006169
Petr Machata83930cd2017-07-31 09:27:27 +02006170/* reg_ralue_ip2me_tunnel_ptr
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006171 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
6172 * For Spectrum, pointer to KVD Linear.
6173 * Only relevant in case of IP2ME action.
6174 * Access: RW
6175 */
Petr Machata83930cd2017-07-31 09:27:27 +02006176MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006177
6178static inline void mlxsw_reg_ralue_pack(char *payload,
6179 enum mlxsw_reg_ralxx_protocol protocol,
6180 enum mlxsw_reg_ralue_op op,
6181 u16 virtual_router, u8 prefix_len)
6182{
6183 MLXSW_REG_ZERO(ralue, payload);
6184 mlxsw_reg_ralue_protocol_set(payload, protocol);
Jiri Pirko0e7df1a2016-08-17 16:39:34 +02006185 mlxsw_reg_ralue_op_set(payload, op);
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006186 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
6187 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
6188 mlxsw_reg_ralue_entry_type_set(payload,
6189 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
6190 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
6191}
6192
6193static inline void mlxsw_reg_ralue_pack4(char *payload,
6194 enum mlxsw_reg_ralxx_protocol protocol,
6195 enum mlxsw_reg_ralue_op op,
6196 u16 virtual_router, u8 prefix_len,
6197 u32 dip)
6198{
6199 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
6200 mlxsw_reg_ralue_dip4_set(payload, dip);
6201}
6202
Ido Schimmel62547f42017-07-18 10:10:23 +02006203static inline void mlxsw_reg_ralue_pack6(char *payload,
6204 enum mlxsw_reg_ralxx_protocol protocol,
6205 enum mlxsw_reg_ralue_op op,
6206 u16 virtual_router, u8 prefix_len,
6207 const void *dip)
6208{
6209 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
6210 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
6211}
6212
Jiri Pirkod5a1c742016-07-04 08:23:10 +02006213static inline void
6214mlxsw_reg_ralue_act_remote_pack(char *payload,
6215 enum mlxsw_reg_ralue_trap_action trap_action,
6216 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
6217{
6218 mlxsw_reg_ralue_action_type_set(payload,
6219 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
6220 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
6221 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
6222 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
6223 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
6224}
6225
6226static inline void
6227mlxsw_reg_ralue_act_local_pack(char *payload,
6228 enum mlxsw_reg_ralue_trap_action trap_action,
6229 u16 trap_id, u16 local_erif)
6230{
6231 mlxsw_reg_ralue_action_type_set(payload,
6232 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
6233 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
6234 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
6235 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
6236}
6237
6238static inline void
6239mlxsw_reg_ralue_act_ip2me_pack(char *payload)
6240{
6241 mlxsw_reg_ralue_action_type_set(payload,
6242 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
6243}
6244
Petr Machataa43da822017-09-02 23:49:12 +02006245static inline void
6246mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
6247{
6248 mlxsw_reg_ralue_action_type_set(payload,
6249 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
6250 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
6251 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
6252}
6253
Yotam Gigi4457b3df2016-07-05 11:27:40 +02006254/* RAUHT - Router Algorithmic LPM Unicast Host Table Register
6255 * ----------------------------------------------------------
6256 * The RAUHT register is used to configure and query the Unicast Host table in
6257 * devices that implement the Algorithmic LPM.
6258 */
6259#define MLXSW_REG_RAUHT_ID 0x8014
6260#define MLXSW_REG_RAUHT_LEN 0x74
6261
Jiri Pirko21978dc2016-10-21 16:07:20 +02006262MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02006263
6264enum mlxsw_reg_rauht_type {
6265 MLXSW_REG_RAUHT_TYPE_IPV4,
6266 MLXSW_REG_RAUHT_TYPE_IPV6,
6267};
6268
6269/* reg_rauht_type
6270 * Access: Index
6271 */
6272MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
6273
6274enum mlxsw_reg_rauht_op {
6275 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
6276 /* Read operation */
6277 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
6278 /* Clear on read operation. Used to read entry and clear
6279 * activity bit.
6280 */
6281 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
6282 /* Add. Used to write a new entry to the table. All R/W fields are
6283 * relevant for new entry. Activity bit is set for new entries.
6284 */
6285 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
6286 /* Update action. Used to update an existing route entry and
6287 * only update the following fields:
6288 * trap_action, trap_id, mac, counter_set_type, counter_index
6289 */
6290 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
6291 /* Clear activity. A bit is cleared for the entry. */
6292 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
6293 /* Delete entry */
6294 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
6295 /* Delete all host entries on a RIF. In this command, dip
6296 * field is reserved.
6297 */
6298};
6299
6300/* reg_rauht_op
6301 * Access: OP
6302 */
6303MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
6304
6305/* reg_rauht_a
6306 * Activity. Set for new entries. Set if a packet lookup has hit on
6307 * the specific entry.
6308 * To clear the a bit, use "clear activity" op.
6309 * Enabled by activity_dis in RGCR
6310 * Access: RO
6311 */
6312MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
6313
6314/* reg_rauht_rif
6315 * Router Interface
6316 * Access: Index
6317 */
6318MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
6319
6320/* reg_rauht_dip*
6321 * Destination address.
6322 * Access: Index
6323 */
6324MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02006325MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
Yotam Gigi4457b3df2016-07-05 11:27:40 +02006326
6327enum mlxsw_reg_rauht_trap_action {
6328 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
6329 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
6330 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
6331 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
6332 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
6333};
6334
6335/* reg_rauht_trap_action
6336 * Access: RW
6337 */
6338MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
6339
6340enum mlxsw_reg_rauht_trap_id {
6341 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
6342 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
6343};
6344
6345/* reg_rauht_trap_id
6346 * Trap ID to be reported to CPU.
6347 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
6348 * For trap_action of NOP, MIRROR and DISCARD_ERROR,
6349 * trap_id is reserved.
6350 * Access: RW
6351 */
6352MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
6353
6354/* reg_rauht_counter_set_type
6355 * Counter set type for flow counters
6356 * Access: RW
6357 */
6358MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
6359
6360/* reg_rauht_counter_index
6361 * Counter index for flow counters
6362 * Access: RW
6363 */
6364MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
6365
6366/* reg_rauht_mac
6367 * MAC address.
6368 * Access: RW
6369 */
6370MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
6371
6372static inline void mlxsw_reg_rauht_pack(char *payload,
6373 enum mlxsw_reg_rauht_op op, u16 rif,
6374 const char *mac)
6375{
6376 MLXSW_REG_ZERO(rauht, payload);
6377 mlxsw_reg_rauht_op_set(payload, op);
6378 mlxsw_reg_rauht_rif_set(payload, rif);
6379 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
6380}
6381
6382static inline void mlxsw_reg_rauht_pack4(char *payload,
6383 enum mlxsw_reg_rauht_op op, u16 rif,
6384 const char *mac, u32 dip)
6385{
6386 mlxsw_reg_rauht_pack(payload, op, rif, mac);
6387 mlxsw_reg_rauht_dip4_set(payload, dip);
6388}
6389
Arkadi Sharshevsky6929e502017-07-18 10:10:14 +02006390static inline void mlxsw_reg_rauht_pack6(char *payload,
6391 enum mlxsw_reg_rauht_op op, u16 rif,
6392 const char *mac, const char *dip)
6393{
6394 mlxsw_reg_rauht_pack(payload, op, rif, mac);
6395 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
6396 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
6397}
6398
Arkadi Sharshevsky7cfcbc72017-08-24 08:40:08 +02006399static inline void mlxsw_reg_rauht_pack_counter(char *payload,
6400 u64 counter_index)
6401{
6402 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
6403 mlxsw_reg_rauht_counter_set_type_set(payload,
6404 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
6405}
6406
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02006407/* RALEU - Router Algorithmic LPM ECMP Update Register
6408 * ---------------------------------------------------
6409 * The register enables updating the ECMP section in the action for multiple
6410 * LPM Unicast entries in a single operation. The update is executed to
6411 * all entries of a {virtual router, protocol} tuple using the same ECMP group.
6412 */
6413#define MLXSW_REG_RALEU_ID 0x8015
6414#define MLXSW_REG_RALEU_LEN 0x28
6415
Jiri Pirko21978dc2016-10-21 16:07:20 +02006416MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
Jiri Pirkoa59f0b32016-07-05 11:27:49 +02006417
6418/* reg_raleu_protocol
6419 * Protocol.
6420 * Access: Index
6421 */
6422MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
6423
6424/* reg_raleu_virtual_router
6425 * Virtual Router ID
6426 * Range is 0..cap_max_virtual_routers-1
6427 * Access: Index
6428 */
6429MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
6430
6431/* reg_raleu_adjacency_index
6432 * Adjacency Index used for matching on the existing entries.
6433 * Access: Index
6434 */
6435MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
6436
6437/* reg_raleu_ecmp_size
6438 * ECMP Size used for matching on the existing entries.
6439 * Access: Index
6440 */
6441MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
6442
6443/* reg_raleu_new_adjacency_index
6444 * New Adjacency Index.
6445 * Access: WO
6446 */
6447MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
6448
6449/* reg_raleu_new_ecmp_size
6450 * New ECMP Size.
6451 * Access: WO
6452 */
6453MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
6454
6455static inline void mlxsw_reg_raleu_pack(char *payload,
6456 enum mlxsw_reg_ralxx_protocol protocol,
6457 u16 virtual_router,
6458 u32 adjacency_index, u16 ecmp_size,
6459 u32 new_adjacency_index,
6460 u16 new_ecmp_size)
6461{
6462 MLXSW_REG_ZERO(raleu, payload);
6463 mlxsw_reg_raleu_protocol_set(payload, protocol);
6464 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
6465 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
6466 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
6467 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
6468 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
6469}
6470
Yotam Gigi7cf2c202016-07-05 11:27:41 +02006471/* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
6472 * ----------------------------------------------------------------
6473 * The RAUHTD register allows dumping entries from the Router Unicast Host
6474 * Table. For a given session an entry is dumped no more than one time. The
6475 * first RAUHTD access after reset is a new session. A session ends when the
6476 * num_rec response is smaller than num_rec request or for IPv4 when the
6477 * num_entries is smaller than 4. The clear activity affect the current session
6478 * or the last session if a new session has not started.
6479 */
6480#define MLXSW_REG_RAUHTD_ID 0x8018
6481#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
6482#define MLXSW_REG_RAUHTD_REC_LEN 0x20
6483#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
6484#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
6485 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
6486#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
6487
Jiri Pirko21978dc2016-10-21 16:07:20 +02006488MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
Yotam Gigi7cf2c202016-07-05 11:27:41 +02006489
6490#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
6491#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
6492
6493/* reg_rauhtd_filter_fields
6494 * if a bit is '0' then the relevant field is ignored and dump is done
6495 * regardless of the field value
6496 * Bit0 - filter by activity: entry_a
6497 * Bit3 - filter by entry rip: entry_rif
6498 * Access: Index
6499 */
6500MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
6501
6502enum mlxsw_reg_rauhtd_op {
6503 MLXSW_REG_RAUHTD_OP_DUMP,
6504 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
6505};
6506
6507/* reg_rauhtd_op
6508 * Access: OP
6509 */
6510MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
6511
6512/* reg_rauhtd_num_rec
6513 * At request: number of records requested
6514 * At response: number of records dumped
6515 * For IPv4, each record has 4 entries at request and up to 4 entries
6516 * at response
6517 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
6518 * Access: Index
6519 */
6520MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
6521
6522/* reg_rauhtd_entry_a
6523 * Dump only if activity has value of entry_a
6524 * Reserved if filter_fields bit0 is '0'
6525 * Access: Index
6526 */
6527MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
6528
6529enum mlxsw_reg_rauhtd_type {
6530 MLXSW_REG_RAUHTD_TYPE_IPV4,
6531 MLXSW_REG_RAUHTD_TYPE_IPV6,
6532};
6533
6534/* reg_rauhtd_type
6535 * Dump only if record type is:
6536 * 0 - IPv4
6537 * 1 - IPv6
6538 * Access: Index
6539 */
6540MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
6541
6542/* reg_rauhtd_entry_rif
6543 * Dump only if RIF has value of entry_rif
6544 * Reserved if filter_fields bit3 is '0'
6545 * Access: Index
6546 */
6547MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
6548
6549static inline void mlxsw_reg_rauhtd_pack(char *payload,
6550 enum mlxsw_reg_rauhtd_type type)
6551{
6552 MLXSW_REG_ZERO(rauhtd, payload);
6553 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
6554 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
6555 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
6556 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
6557 mlxsw_reg_rauhtd_type_set(payload, type);
6558}
6559
6560/* reg_rauhtd_ipv4_rec_num_entries
6561 * Number of valid entries in this record:
6562 * 0 - 1 valid entry
6563 * 1 - 2 valid entries
6564 * 2 - 3 valid entries
6565 * 3 - 4 valid entries
6566 * Access: RO
6567 */
6568MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
6569 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
6570 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
6571
6572/* reg_rauhtd_rec_type
6573 * Record type.
6574 * 0 - IPv4
6575 * 1 - IPv6
6576 * Access: RO
6577 */
6578MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
6579 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
6580
6581#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
6582
6583/* reg_rauhtd_ipv4_ent_a
6584 * Activity. Set for new entries. Set if a packet lookup has hit on the
6585 * specific entry.
6586 * Access: RO
6587 */
6588MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
6589 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
6590
6591/* reg_rauhtd_ipv4_ent_rif
6592 * Router interface.
6593 * Access: RO
6594 */
6595MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6596 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
6597
6598/* reg_rauhtd_ipv4_ent_dip
6599 * Destination IPv4 address.
6600 * Access: RO
6601 */
6602MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6603 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
6604
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02006605#define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
6606
6607/* reg_rauhtd_ipv6_ent_a
6608 * Activity. Set for new entries. Set if a packet lookup has hit on the
6609 * specific entry.
6610 * Access: RO
6611 */
6612MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
6613 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
6614
6615/* reg_rauhtd_ipv6_ent_rif
6616 * Router interface.
6617 * Access: RO
6618 */
6619MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6620 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
6621
6622/* reg_rauhtd_ipv6_ent_dip
6623 * Destination IPv6 address.
6624 * Access: RO
6625 */
6626MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
6627 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
6628
Yotam Gigi7cf2c202016-07-05 11:27:41 +02006629static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
6630 int ent_index, u16 *p_rif,
6631 u32 *p_dip)
6632{
6633 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
6634 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
6635}
6636
Arkadi Sharshevsky72e8ebe2017-07-18 10:10:16 +02006637static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
6638 int rec_index, u16 *p_rif,
6639 char *p_dip)
6640{
6641 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
6642 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
6643}
6644
Petr Machata1e659eb2017-09-02 23:49:13 +02006645/* RTDP - Routing Tunnel Decap Properties Register
6646 * -----------------------------------------------
6647 * The RTDP register is used for configuring the tunnel decap properties of NVE
6648 * and IPinIP.
6649 */
6650#define MLXSW_REG_RTDP_ID 0x8020
6651#define MLXSW_REG_RTDP_LEN 0x44
6652
6653MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
6654
6655enum mlxsw_reg_rtdp_type {
6656 MLXSW_REG_RTDP_TYPE_NVE,
6657 MLXSW_REG_RTDP_TYPE_IPIP,
6658};
6659
6660/* reg_rtdp_type
6661 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
6662 * Access: RW
6663 */
6664MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
6665
6666/* reg_rtdp_tunnel_index
6667 * Index to the Decap entry.
6668 * For Spectrum, Index to KVD Linear.
6669 * Access: Index
6670 */
6671MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
6672
6673/* IPinIP */
6674
6675/* reg_rtdp_ipip_irif
6676 * Ingress Router Interface for the overlay router
6677 * Access: RW
6678 */
6679MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
6680
6681enum mlxsw_reg_rtdp_ipip_sip_check {
6682 /* No sip checks. */
6683 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
6684 /* Filter packet if underlay is not IPv4 or if underlay SIP does not
6685 * equal ipv4_usip.
6686 */
6687 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
6688 /* Filter packet if underlay is not IPv6 or if underlay SIP does not
6689 * equal ipv6_usip.
6690 */
6691 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
6692};
6693
6694/* reg_rtdp_ipip_sip_check
6695 * SIP check to perform. If decapsulation failed due to these configurations
6696 * then trap_id is IPIP_DECAP_ERROR.
6697 * Access: RW
6698 */
6699MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
6700
6701/* If set, allow decapsulation of IPinIP (without GRE). */
6702#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
6703/* If set, allow decapsulation of IPinGREinIP without a key. */
6704#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
6705/* If set, allow decapsulation of IPinGREinIP with a key. */
6706#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
6707
6708/* reg_rtdp_ipip_type_check
6709 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
6710 * these configurations then trap_id is IPIP_DECAP_ERROR.
6711 * Access: RW
6712 */
6713MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
6714
6715/* reg_rtdp_ipip_gre_key_check
6716 * Whether GRE key should be checked. When check is enabled:
6717 * - A packet received as IPinIP (without GRE) will always pass.
6718 * - A packet received as IPinGREinIP without a key will not pass the check.
6719 * - A packet received as IPinGREinIP with a key will pass the check only if the
6720 * key in the packet is equal to expected_gre_key.
6721 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
6722 * Access: RW
6723 */
6724MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
6725
6726/* reg_rtdp_ipip_ipv4_usip
6727 * Underlay IPv4 address for ipv4 source address check.
6728 * Reserved when sip_check is not '1'.
6729 * Access: RW
6730 */
6731MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
6732
6733/* reg_rtdp_ipip_ipv6_usip_ptr
6734 * This field is valid when sip_check is "sipv6 check explicitly". This is a
6735 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
6736 * is to the KVD linear.
6737 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
6738 * Access: RW
6739 */
6740MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
6741
6742/* reg_rtdp_ipip_expected_gre_key
6743 * GRE key for checking.
6744 * Reserved when gre_key_check is '0'.
6745 * Access: RW
6746 */
6747MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
6748
6749static inline void mlxsw_reg_rtdp_pack(char *payload,
6750 enum mlxsw_reg_rtdp_type type,
6751 u32 tunnel_index)
6752{
6753 MLXSW_REG_ZERO(rtdp, payload);
6754 mlxsw_reg_rtdp_type_set(payload, type);
6755 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
6756}
6757
6758static inline void
6759mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
6760 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
6761 unsigned int type_check, bool gre_key_check,
6762 u32 ipv4_usip, u32 expected_gre_key)
6763{
6764 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
6765 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
6766 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
6767 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
6768 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
6769 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
6770}
6771
Yotam Gigi5080c7e2017-09-19 10:00:14 +02006772/* RIGR-V2 - Router Interface Group Register Version 2
6773 * ---------------------------------------------------
6774 * The RIGR_V2 register is used to add, remove and query egress interface list
6775 * of a multicast forwarding entry.
6776 */
6777#define MLXSW_REG_RIGR2_ID 0x8023
6778#define MLXSW_REG_RIGR2_LEN 0xB0
6779
6780#define MLXSW_REG_RIGR2_MAX_ERIFS 32
6781
6782MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
6783
6784/* reg_rigr2_rigr_index
6785 * KVD Linear index.
6786 * Access: Index
6787 */
6788MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
6789
6790/* reg_rigr2_vnext
6791 * Next RIGR Index is valid.
6792 * Access: RW
6793 */
6794MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
6795
6796/* reg_rigr2_next_rigr_index
6797 * Next RIGR Index. The index is to the KVD linear.
6798 * Reserved when vnxet = '0'.
6799 * Access: RW
6800 */
6801MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
6802
6803/* reg_rigr2_vrmid
6804 * RMID Index is valid.
6805 * Access: RW
6806 */
6807MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
6808
6809/* reg_rigr2_rmid_index
6810 * RMID Index.
6811 * Range 0 .. max_mid - 1
6812 * Reserved when vrmid = '0'.
6813 * The index is to the Port Group Table (PGT)
6814 * Access: RW
6815 */
6816MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
6817
6818/* reg_rigr2_erif_entry_v
6819 * Egress Router Interface is valid.
6820 * Note that low-entries must be set if high-entries are set. For
6821 * example: if erif_entry[2].v is set then erif_entry[1].v and
6822 * erif_entry[0].v must be set.
6823 * Index can be from 0 to cap_mc_erif_list_entries-1
6824 * Access: RW
6825 */
6826MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
6827
6828/* reg_rigr2_erif_entry_erif
6829 * Egress Router Interface.
6830 * Valid range is from 0 to cap_max_router_interfaces - 1
6831 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
6832 * Access: RW
6833 */
6834MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
6835
6836static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
6837 bool vnext, u32 next_rigr_index)
6838{
6839 MLXSW_REG_ZERO(rigr2, payload);
6840 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
6841 mlxsw_reg_rigr2_vnext_set(payload, vnext);
6842 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
6843 mlxsw_reg_rigr2_vrmid_set(payload, 0);
6844 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
6845}
6846
6847static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
6848 bool v, u16 erif)
6849{
6850 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
6851 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
6852}
6853
Ido Schimmele4718592017-11-02 17:14:08 +01006854/* RECR-V2 - Router ECMP Configuration Version 2 Register
6855 * ------------------------------------------------------
6856 */
6857#define MLXSW_REG_RECR2_ID 0x8025
6858#define MLXSW_REG_RECR2_LEN 0x38
6859
6860MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
6861
6862/* reg_recr2_pp
6863 * Per-port configuration
6864 * Access: Index
6865 */
6866MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
6867
6868/* reg_recr2_sh
6869 * Symmetric hash
6870 * Access: RW
6871 */
6872MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
6873
6874/* reg_recr2_seed
6875 * Seed
6876 * Access: RW
6877 */
6878MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
6879
6880enum {
6881 /* Enable IPv4 fields if packet is not TCP and not UDP */
6882 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
6883 /* Enable IPv4 fields if packet is TCP or UDP */
6884 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
6885 /* Enable IPv6 fields if packet is not TCP and not UDP */
6886 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
6887 /* Enable IPv6 fields if packet is TCP or UDP */
6888 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
6889 /* Enable TCP/UDP header fields if packet is IPv4 */
6890 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
6891 /* Enable TCP/UDP header fields if packet is IPv6 */
6892 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
6893};
6894
6895/* reg_recr2_outer_header_enables
6896 * Bit mask where each bit enables a specific layer to be included in
6897 * the hash calculation.
6898 * Access: RW
6899 */
6900MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
6901
6902enum {
6903 /* IPv4 Source IP */
6904 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
6905 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
6906 /* IPv4 Destination IP */
6907 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
6908 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
6909 /* IP Protocol */
6910 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
6911 /* IPv6 Source IP */
6912 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
6913 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
6914 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
6915 /* IPv6 Destination IP */
6916 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
6917 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
6918 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
6919 /* IPv6 Next Header */
6920 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
6921 /* IPv6 Flow Label */
6922 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
6923 /* TCP/UDP Source Port */
6924 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
6925 /* TCP/UDP Destination Port */
6926 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
6927};
6928
6929/* reg_recr2_outer_header_fields_enable
6930 * Packet fields to enable for ECMP hash subject to outer_header_enable.
6931 * Access: RW
6932 */
6933MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
6934
6935static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
6936{
6937 int i;
6938
6939 for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
6940 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
6941 true);
6942}
6943
6944static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
6945{
6946 int i;
6947
6948 for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
6949 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
6950 true);
6951}
6952
6953static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
6954{
6955 int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
6956
6957 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
6958
6959 i = MLXSW_REG_RECR2_IPV6_SIP8;
6960 for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
6961 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
6962 true);
6963}
6964
6965static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
6966{
6967 int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
6968
6969 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
6970
6971 i = MLXSW_REG_RECR2_IPV6_DIP8;
6972 for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
6973 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
6974 true);
6975}
6976
6977static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
6978{
6979 MLXSW_REG_ZERO(recr2, payload);
6980 mlxsw_reg_recr2_pp_set(payload, false);
6981 mlxsw_reg_recr2_sh_set(payload, true);
6982 mlxsw_reg_recr2_seed_set(payload, seed);
6983}
6984
Yotam Gigi2e654e32017-09-19 10:00:16 +02006985/* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
6986 * --------------------------------------------------------------
6987 * The RMFT_V2 register is used to configure and query the multicast table.
6988 */
6989#define MLXSW_REG_RMFT2_ID 0x8027
6990#define MLXSW_REG_RMFT2_LEN 0x174
6991
6992MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
6993
6994/* reg_rmft2_v
6995 * Valid
6996 * Access: RW
6997 */
6998MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
6999
7000enum mlxsw_reg_rmft2_type {
7001 MLXSW_REG_RMFT2_TYPE_IPV4,
7002 MLXSW_REG_RMFT2_TYPE_IPV6
7003};
7004
7005/* reg_rmft2_type
7006 * Access: Index
7007 */
7008MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
7009
7010enum mlxsw_sp_reg_rmft2_op {
7011 /* For Write:
7012 * Write operation. Used to write a new entry to the table. All RW
7013 * fields are relevant for new entry. Activity bit is set for new
7014 * entries - Note write with v (Valid) 0 will delete the entry.
7015 * For Query:
7016 * Read operation
7017 */
7018 MLXSW_REG_RMFT2_OP_READ_WRITE,
7019};
7020
7021/* reg_rmft2_op
7022 * Operation.
7023 * Access: OP
7024 */
7025MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
7026
7027/* reg_rmft2_a
7028 * Activity. Set for new entries. Set if a packet lookup has hit on the specific
7029 * entry.
7030 * Access: RO
7031 */
7032MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
7033
7034/* reg_rmft2_offset
7035 * Offset within the multicast forwarding table to write to.
7036 * Access: Index
7037 */
7038MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
7039
7040/* reg_rmft2_virtual_router
7041 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
7042 * Access: RW
7043 */
7044MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
7045
7046enum mlxsw_reg_rmft2_irif_mask {
7047 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
7048 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
7049};
7050
7051/* reg_rmft2_irif_mask
7052 * Ingress RIF mask.
7053 * Access: RW
7054 */
7055MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
7056
7057/* reg_rmft2_irif
7058 * Ingress RIF index.
7059 * Access: RW
7060 */
7061MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
7062
Yuval Mintza82b1b82018-03-26 15:01:38 +03007063/* reg_rmft2_dip{4,6}
7064 * Destination IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02007065 * Access: RW
7066 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007067MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007068MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
7069
Yuval Mintza82b1b82018-03-26 15:01:38 +03007070/* reg_rmft2_dip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02007071 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
7072 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
7073 * Access: RW
7074 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007075MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007076MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
7077
Yuval Mintza82b1b82018-03-26 15:01:38 +03007078/* reg_rmft2_sip{4,6}
7079 * Source IPv4/6 address
Yotam Gigi2e654e32017-09-19 10:00:16 +02007080 * Access: RW
7081 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007082MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007083MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
7084
Yuval Mintza82b1b82018-03-26 15:01:38 +03007085/* reg_rmft2_sip{4,6}_mask
Yotam Gigi2e654e32017-09-19 10:00:16 +02007086 * A bit that is set directs the TCAM to compare the corresponding bit in key. A
7087 * bit that is clear directs the TCAM to ignore the corresponding bit in key.
7088 * Access: RW
7089 */
Yuval Mintza82b1b82018-03-26 15:01:38 +03007090MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007091MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
7092
7093/* reg_rmft2_flexible_action_set
7094 * ACL action set. The only supported action types in this field and in any
7095 * action-set pointed from here are as follows:
7096 * 00h: ACTION_NULL
7097 * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
7098 * 03h: ACTION_TRAP
7099 * 06h: ACTION_QOS
7100 * 08h: ACTION_POLICING_MONITORING
7101 * 10h: ACTION_ROUTER_MC
7102 * Access: RW
7103 */
7104MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
7105 MLXSW_REG_FLEX_ACTION_SET_LEN);
7106
7107static inline void
Yuval Mintza82b1b82018-03-26 15:01:38 +03007108mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
7109 u16 virtual_router,
7110 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7111 const char *flex_action_set)
Yotam Gigi2e654e32017-09-19 10:00:16 +02007112{
7113 MLXSW_REG_ZERO(rmft2, payload);
7114 mlxsw_reg_rmft2_v_set(payload, v);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007115 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
7116 mlxsw_reg_rmft2_offset_set(payload, offset);
7117 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
7118 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
7119 mlxsw_reg_rmft2_irif_set(payload, irif);
Yuval Mintza82b1b82018-03-26 15:01:38 +03007120 if (flex_action_set)
7121 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
7122 flex_action_set);
7123}
7124
7125static inline void
7126mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
7127 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7128 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
7129 const char *flexible_action_set)
7130{
7131 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
7132 irif_mask, irif, flexible_action_set);
7133 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007134 mlxsw_reg_rmft2_dip4_set(payload, dip4);
7135 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
7136 mlxsw_reg_rmft2_sip4_set(payload, sip4);
7137 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
Yuval Mintza82b1b82018-03-26 15:01:38 +03007138}
7139
7140static inline void
7141mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
7142 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7143 struct in6_addr dip6, struct in6_addr dip6_mask,
7144 struct in6_addr sip6, struct in6_addr sip6_mask,
7145 const char *flexible_action_set)
7146{
7147 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
7148 irif_mask, irif, flexible_action_set);
7149 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
7150 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
7151 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
7152 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
7153 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
Yotam Gigi2e654e32017-09-19 10:00:16 +02007154}
7155
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007156/* MFCR - Management Fan Control Register
7157 * --------------------------------------
7158 * This register controls the settings of the Fan Speed PWM mechanism.
7159 */
7160#define MLXSW_REG_MFCR_ID 0x9001
7161#define MLXSW_REG_MFCR_LEN 0x08
7162
Jiri Pirko21978dc2016-10-21 16:07:20 +02007163MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007164
7165enum mlxsw_reg_mfcr_pwm_frequency {
7166 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
7167 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
7168 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
7169 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
7170 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
7171 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
7172 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
7173 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
7174};
7175
7176/* reg_mfcr_pwm_frequency
7177 * Controls the frequency of the PWM signal.
7178 * Access: RW
7179 */
Jiri Pirkof7ad3d42016-11-11 11:22:53 +01007180MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007181
7182#define MLXSW_MFCR_TACHOS_MAX 10
7183
7184/* reg_mfcr_tacho_active
7185 * Indicates which of the tachometer is active (bit per tachometer).
7186 * Access: RO
7187 */
7188MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
7189
7190#define MLXSW_MFCR_PWMS_MAX 5
7191
7192/* reg_mfcr_pwm_active
7193 * Indicates which of the PWM control is active (bit per PWM).
7194 * Access: RO
7195 */
7196MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
7197
7198static inline void
7199mlxsw_reg_mfcr_pack(char *payload,
7200 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
7201{
7202 MLXSW_REG_ZERO(mfcr, payload);
7203 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
7204}
7205
7206static inline void
7207mlxsw_reg_mfcr_unpack(char *payload,
7208 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
7209 u16 *p_tacho_active, u8 *p_pwm_active)
7210{
7211 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
7212 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
7213 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
7214}
7215
7216/* MFSC - Management Fan Speed Control Register
7217 * --------------------------------------------
7218 * This register controls the settings of the Fan Speed PWM mechanism.
7219 */
7220#define MLXSW_REG_MFSC_ID 0x9002
7221#define MLXSW_REG_MFSC_LEN 0x08
7222
Jiri Pirko21978dc2016-10-21 16:07:20 +02007223MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007224
7225/* reg_mfsc_pwm
7226 * Fan pwm to control / monitor.
7227 * Access: Index
7228 */
7229MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
7230
7231/* reg_mfsc_pwm_duty_cycle
7232 * Controls the duty cycle of the PWM. Value range from 0..255 to
7233 * represent duty cycle of 0%...100%.
7234 * Access: RW
7235 */
7236MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
7237
7238static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
7239 u8 pwm_duty_cycle)
7240{
7241 MLXSW_REG_ZERO(mfsc, payload);
7242 mlxsw_reg_mfsc_pwm_set(payload, pwm);
7243 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
7244}
7245
7246/* MFSM - Management Fan Speed Measurement
7247 * ---------------------------------------
7248 * This register controls the settings of the Tacho measurements and
7249 * enables reading the Tachometer measurements.
7250 */
7251#define MLXSW_REG_MFSM_ID 0x9003
7252#define MLXSW_REG_MFSM_LEN 0x08
7253
Jiri Pirko21978dc2016-10-21 16:07:20 +02007254MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
Jiri Pirko5246f2e2015-11-27 13:45:58 +01007255
7256/* reg_mfsm_tacho
7257 * Fan tachometer index.
7258 * Access: Index
7259 */
7260MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
7261
7262/* reg_mfsm_rpm
7263 * Fan speed (round per minute).
7264 * Access: RO
7265 */
7266MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
7267
7268static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
7269{
7270 MLXSW_REG_ZERO(mfsm, payload);
7271 mlxsw_reg_mfsm_tacho_set(payload, tacho);
7272}
7273
Jiri Pirko55c63aa2016-11-22 11:24:12 +01007274/* MFSL - Management Fan Speed Limit Register
7275 * ------------------------------------------
7276 * The Fan Speed Limit register is used to configure the fan speed
7277 * event / interrupt notification mechanism. Fan speed threshold are
7278 * defined for both under-speed and over-speed.
7279 */
7280#define MLXSW_REG_MFSL_ID 0x9004
7281#define MLXSW_REG_MFSL_LEN 0x0C
7282
7283MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
7284
7285/* reg_mfsl_tacho
7286 * Fan tachometer index.
7287 * Access: Index
7288 */
7289MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
7290
7291/* reg_mfsl_tach_min
7292 * Tachometer minimum value (minimum RPM).
7293 * Access: RW
7294 */
7295MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
7296
7297/* reg_mfsl_tach_max
7298 * Tachometer maximum value (maximum RPM).
7299 * Access: RW
7300 */
7301MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
7302
7303static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
7304 u16 tach_min, u16 tach_max)
7305{
7306 MLXSW_REG_ZERO(mfsl, payload);
7307 mlxsw_reg_mfsl_tacho_set(payload, tacho);
7308 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
7309 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
7310}
7311
7312static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
7313 u16 *p_tach_min, u16 *p_tach_max)
7314{
7315 if (p_tach_min)
7316 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
7317
7318 if (p_tach_max)
7319 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
7320}
7321
Jiri Pirko85926f82015-11-27 13:45:56 +01007322/* MTCAP - Management Temperature Capabilities
7323 * -------------------------------------------
7324 * This register exposes the capabilities of the device and
7325 * system temperature sensing.
7326 */
7327#define MLXSW_REG_MTCAP_ID 0x9009
7328#define MLXSW_REG_MTCAP_LEN 0x08
7329
Jiri Pirko21978dc2016-10-21 16:07:20 +02007330MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01007331
7332/* reg_mtcap_sensor_count
7333 * Number of sensors supported by the device.
7334 * This includes the QSFP module sensors (if exists in the QSFP module).
7335 * Access: RO
7336 */
7337MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
7338
7339/* MTMP - Management Temperature
7340 * -----------------------------
7341 * This register controls the settings of the temperature measurements
7342 * and enables reading the temperature measurements. Note that temperature
7343 * is in 0.125 degrees Celsius.
7344 */
7345#define MLXSW_REG_MTMP_ID 0x900A
7346#define MLXSW_REG_MTMP_LEN 0x20
7347
Jiri Pirko21978dc2016-10-21 16:07:20 +02007348MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
Jiri Pirko85926f82015-11-27 13:45:56 +01007349
7350/* reg_mtmp_sensor_index
7351 * Sensors index to access.
7352 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
7353 * (module 0 is mapped to sensor_index 64).
7354 * Access: Index
7355 */
7356MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
7357
7358/* Convert to milli degrees Celsius */
7359#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
7360
7361/* reg_mtmp_temperature
7362 * Temperature reading from the sensor. Reading is in 0.125 Celsius
7363 * degrees units.
7364 * Access: RO
7365 */
7366MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
7367
7368/* reg_mtmp_mte
7369 * Max Temperature Enable - enables measuring the max temperature on a sensor.
7370 * Access: RW
7371 */
7372MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
7373
7374/* reg_mtmp_mtr
7375 * Max Temperature Reset - clears the value of the max temperature register.
7376 * Access: WO
7377 */
7378MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
7379
7380/* reg_mtmp_max_temperature
7381 * The highest measured temperature from the sensor.
7382 * When the bit mte is cleared, the field max_temperature is reserved.
7383 * Access: RO
7384 */
7385MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
7386
Ido Schimmel62b0e922017-10-30 10:51:18 +01007387/* reg_mtmp_tee
7388 * Temperature Event Enable.
7389 * 0 - Do not generate event
7390 * 1 - Generate event
7391 * 2 - Generate single event
7392 * Access: RW
7393 */
7394MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
7395
7396#define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
7397
7398/* reg_mtmp_temperature_threshold_hi
7399 * High threshold for Temperature Warning Event. In 0.125 Celsius.
7400 * Access: RW
7401 */
7402MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
7403
7404/* reg_mtmp_temperature_threshold_lo
7405 * Low threshold for Temperature Warning Event. In 0.125 Celsius.
7406 * Access: RW
7407 */
7408MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
7409
Jiri Pirko85926f82015-11-27 13:45:56 +01007410#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
7411
7412/* reg_mtmp_sensor_name
7413 * Sensor Name
7414 * Access: RO
7415 */
7416MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
7417
7418static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
7419 bool max_temp_enable,
7420 bool max_temp_reset)
7421{
7422 MLXSW_REG_ZERO(mtmp, payload);
7423 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
7424 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
7425 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
Ido Schimmel62b0e922017-10-30 10:51:18 +01007426 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
7427 MLXSW_REG_MTMP_THRESH_HI);
Jiri Pirko85926f82015-11-27 13:45:56 +01007428}
7429
7430static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
7431 unsigned int *p_max_temp,
7432 char *sensor_name)
7433{
7434 u16 temp;
7435
7436 if (p_temp) {
7437 temp = mlxsw_reg_mtmp_temperature_get(payload);
7438 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
7439 }
7440 if (p_max_temp) {
Jiri Pirkoacf35a42015-12-11 16:10:39 +01007441 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
Jiri Pirko85926f82015-11-27 13:45:56 +01007442 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
7443 }
7444 if (sensor_name)
7445 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
7446}
7447
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02007448/* MCIA - Management Cable Info Access
7449 * -----------------------------------
7450 * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
7451 */
7452
7453#define MLXSW_REG_MCIA_ID 0x9014
7454#define MLXSW_REG_MCIA_LEN 0x40
7455
7456MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
7457
7458/* reg_mcia_l
7459 * Lock bit. Setting this bit will lock the access to the specific
7460 * cable. Used for updating a full page in a cable EPROM. Any access
7461 * other then subsequence writes will fail while the port is locked.
7462 * Access: RW
7463 */
7464MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
7465
7466/* reg_mcia_module
7467 * Module number.
7468 * Access: Index
7469 */
7470MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
7471
7472/* reg_mcia_status
7473 * Module status.
7474 * Access: RO
7475 */
7476MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
7477
7478/* reg_mcia_i2c_device_address
7479 * I2C device address.
7480 * Access: RW
7481 */
7482MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
7483
7484/* reg_mcia_page_number
7485 * Page number.
7486 * Access: RW
7487 */
7488MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
7489
7490/* reg_mcia_device_address
7491 * Device address.
7492 * Access: RW
7493 */
7494MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
7495
7496/* reg_mcia_size
7497 * Number of bytes to read/write (up to 48 bytes).
7498 * Access: RW
7499 */
7500MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
7501
7502#define MLXSW_SP_REG_MCIA_EEPROM_SIZE 48
7503
7504/* reg_mcia_eeprom
7505 * Bytes to read/write.
7506 * Access: RW
7507 */
7508MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_SP_REG_MCIA_EEPROM_SIZE);
7509
7510static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
7511 u8 page_number, u16 device_addr,
7512 u8 size, u8 i2c_device_addr)
7513{
7514 MLXSW_REG_ZERO(mcia, payload);
7515 mlxsw_reg_mcia_module_set(payload, module);
7516 mlxsw_reg_mcia_l_set(payload, lock);
7517 mlxsw_reg_mcia_page_number_set(payload, page_number);
7518 mlxsw_reg_mcia_device_address_set(payload, device_addr);
7519 mlxsw_reg_mcia_size_set(payload, size);
7520 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
7521}
7522
Yotam Gigi43a46852016-07-21 12:03:14 +02007523/* MPAT - Monitoring Port Analyzer Table
7524 * -------------------------------------
7525 * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
7526 * For an enabled analyzer, all fields except e (enable) cannot be modified.
7527 */
7528#define MLXSW_REG_MPAT_ID 0x901A
7529#define MLXSW_REG_MPAT_LEN 0x78
7530
Jiri Pirko21978dc2016-10-21 16:07:20 +02007531MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
Yotam Gigi43a46852016-07-21 12:03:14 +02007532
7533/* reg_mpat_pa_id
7534 * Port Analyzer ID.
7535 * Access: Index
7536 */
7537MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
7538
7539/* reg_mpat_system_port
7540 * A unique port identifier for the final destination of the packet.
7541 * Access: RW
7542 */
7543MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
7544
7545/* reg_mpat_e
7546 * Enable. Indicating the Port Analyzer is enabled.
7547 * Access: RW
7548 */
7549MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
7550
7551/* reg_mpat_qos
7552 * Quality Of Service Mode.
7553 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
7554 * PCP, DEI, DSCP or VL) are configured.
7555 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
7556 * same as in the original packet that has triggered the mirroring. For
7557 * SPAN also the pcp,dei are maintained.
7558 * Access: RW
7559 */
7560MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
7561
Yotam Gigi23019052016-07-21 12:03:15 +02007562/* reg_mpat_be
7563 * Best effort mode. Indicates mirroring traffic should not cause packet
7564 * drop or back pressure, but will discard the mirrored packets. Mirrored
7565 * packets will be forwarded on a best effort manner.
7566 * 0: Do not discard mirrored packets
7567 * 1: Discard mirrored packets if causing congestion
7568 * Access: RW
7569 */
7570MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
7571
Petr Machata0d6cd3f2018-02-27 14:53:39 +01007572enum mlxsw_reg_mpat_span_type {
7573 /* Local SPAN Ethernet.
7574 * The original packet is not encapsulated.
7575 */
7576 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
7577
Petr Machata41947662018-05-10 13:13:04 +03007578 /* Remote SPAN Ethernet VLAN.
7579 * The packet is forwarded to the monitoring port on the monitoring
7580 * VLAN.
7581 */
7582 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
7583
Petr Machata0d6cd3f2018-02-27 14:53:39 +01007584 /* Encapsulated Remote SPAN Ethernet L3 GRE.
7585 * The packet is encapsulated with GRE header.
7586 */
7587 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
7588};
7589
7590/* reg_mpat_span_type
7591 * SPAN type.
7592 * Access: RW
7593 */
7594MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
7595
7596/* Remote SPAN - Ethernet VLAN
7597 * - - - - - - - - - - - - - -
7598 */
7599
7600/* reg_mpat_eth_rspan_vid
7601 * Encapsulation header VLAN ID.
7602 * Access: RW
7603 */
7604MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
7605
7606/* Encapsulated Remote SPAN - Ethernet L2
7607 * - - - - - - - - - - - - - - - - - - -
7608 */
7609
7610enum mlxsw_reg_mpat_eth_rspan_version {
7611 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
7612};
7613
7614/* reg_mpat_eth_rspan_version
7615 * RSPAN mirror header version.
7616 * Access: RW
7617 */
7618MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
7619
7620/* reg_mpat_eth_rspan_mac
7621 * Destination MAC address.
7622 * Access: RW
7623 */
7624MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
7625
7626/* reg_mpat_eth_rspan_tp
7627 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
7628 * Access: RW
7629 */
7630MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
7631
7632/* Encapsulated Remote SPAN - Ethernet L3
7633 * - - - - - - - - - - - - - - - - - - -
7634 */
7635
7636enum mlxsw_reg_mpat_eth_rspan_protocol {
7637 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
7638 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
7639};
7640
7641/* reg_mpat_eth_rspan_protocol
7642 * SPAN encapsulation protocol.
7643 * Access: RW
7644 */
7645MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
7646
7647/* reg_mpat_eth_rspan_ttl
7648 * Encapsulation header Time-to-Live/HopLimit.
7649 * Access: RW
7650 */
7651MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
7652
7653/* reg_mpat_eth_rspan_smac
7654 * Source MAC address
7655 * Access: RW
7656 */
7657MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
7658
7659/* reg_mpat_eth_rspan_dip*
7660 * Destination IP address. The IP version is configured by protocol.
7661 * Access: RW
7662 */
7663MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
7664MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
7665
7666/* reg_mpat_eth_rspan_sip*
7667 * Source IP address. The IP version is configured by protocol.
7668 * Access: RW
7669 */
7670MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
7671MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
7672
Yotam Gigi43a46852016-07-21 12:03:14 +02007673static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
Petr Machata1da93eb2018-02-27 14:53:40 +01007674 u16 system_port, bool e,
7675 enum mlxsw_reg_mpat_span_type span_type)
Yotam Gigi43a46852016-07-21 12:03:14 +02007676{
7677 MLXSW_REG_ZERO(mpat, payload);
7678 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
7679 mlxsw_reg_mpat_system_port_set(payload, system_port);
7680 mlxsw_reg_mpat_e_set(payload, e);
7681 mlxsw_reg_mpat_qos_set(payload, 1);
Yotam Gigi23019052016-07-21 12:03:15 +02007682 mlxsw_reg_mpat_be_set(payload, 1);
Petr Machata1da93eb2018-02-27 14:53:40 +01007683 mlxsw_reg_mpat_span_type_set(payload, span_type);
Yotam Gigi23019052016-07-21 12:03:15 +02007684}
7685
Petr Machata0d6cd3f2018-02-27 14:53:39 +01007686static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
7687{
7688 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
7689}
7690
7691static inline void
7692mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
7693 enum mlxsw_reg_mpat_eth_rspan_version version,
7694 const char *mac,
7695 bool tp)
7696{
7697 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
7698 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
7699 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
7700}
7701
7702static inline void
7703mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
7704 const char *smac,
7705 u32 sip, u32 dip)
7706{
7707 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
7708 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
7709 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
7710 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
7711 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
7712 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
7713}
7714
7715static inline void
7716mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
7717 const char *smac,
7718 struct in6_addr sip, struct in6_addr dip)
7719{
7720 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
7721 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
7722 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
7723 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
7724 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
7725 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
7726}
7727
Yotam Gigi23019052016-07-21 12:03:15 +02007728/* MPAR - Monitoring Port Analyzer Register
7729 * ----------------------------------------
7730 * MPAR register is used to query and configure the port analyzer port mirroring
7731 * properties.
7732 */
7733#define MLXSW_REG_MPAR_ID 0x901B
7734#define MLXSW_REG_MPAR_LEN 0x08
7735
Jiri Pirko21978dc2016-10-21 16:07:20 +02007736MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
Yotam Gigi23019052016-07-21 12:03:15 +02007737
7738/* reg_mpar_local_port
7739 * The local port to mirror the packets from.
7740 * Access: Index
7741 */
7742MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
7743
7744enum mlxsw_reg_mpar_i_e {
7745 MLXSW_REG_MPAR_TYPE_EGRESS,
7746 MLXSW_REG_MPAR_TYPE_INGRESS,
7747};
7748
7749/* reg_mpar_i_e
7750 * Ingress/Egress
7751 * Access: Index
7752 */
7753MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
7754
7755/* reg_mpar_enable
7756 * Enable mirroring
7757 * By default, port mirroring is disabled for all ports.
7758 * Access: RW
7759 */
7760MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
7761
7762/* reg_mpar_pa_id
7763 * Port Analyzer ID.
7764 * Access: RW
7765 */
7766MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
7767
7768static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
7769 enum mlxsw_reg_mpar_i_e i_e,
7770 bool enable, u8 pa_id)
7771{
7772 MLXSW_REG_ZERO(mpar, payload);
7773 mlxsw_reg_mpar_local_port_set(payload, local_port);
7774 mlxsw_reg_mpar_enable_set(payload, enable);
7775 mlxsw_reg_mpar_i_e_set(payload, i_e);
7776 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
Yotam Gigi43a46852016-07-21 12:03:14 +02007777}
7778
Jiri Pirko12b003b2018-05-27 09:56:13 +03007779/* MRSR - Management Reset and Shutdown Register
7780 * ---------------------------------------------
7781 * MRSR register is used to reset or shutdown the switch or
7782 * the entire system (when applicable).
7783 */
7784#define MLXSW_REG_MRSR_ID 0x9023
7785#define MLXSW_REG_MRSR_LEN 0x08
7786
7787MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
7788
7789/* reg_mrsr_command
7790 * Reset/shutdown command
7791 * 0 - do nothing
7792 * 1 - software reset
7793 * Access: WO
7794 */
7795MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
7796
7797static inline void mlxsw_reg_mrsr_pack(char *payload)
7798{
7799 MLXSW_REG_ZERO(mrsr, payload);
7800 mlxsw_reg_mrsr_command_set(payload, 1);
7801}
7802
Ido Schimmel3161c152015-11-27 13:45:54 +01007803/* MLCR - Management LED Control Register
7804 * --------------------------------------
7805 * Controls the system LEDs.
7806 */
7807#define MLXSW_REG_MLCR_ID 0x902B
7808#define MLXSW_REG_MLCR_LEN 0x0C
7809
Jiri Pirko21978dc2016-10-21 16:07:20 +02007810MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
Ido Schimmel3161c152015-11-27 13:45:54 +01007811
7812/* reg_mlcr_local_port
7813 * Local port number.
7814 * Access: RW
7815 */
7816MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
7817
7818#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
7819
7820/* reg_mlcr_beacon_duration
7821 * Duration of the beacon to be active, in seconds.
7822 * 0x0 - Will turn off the beacon.
7823 * 0xFFFF - Will turn on the beacon until explicitly turned off.
7824 * Access: RW
7825 */
7826MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
7827
7828/* reg_mlcr_beacon_remain
7829 * Remaining duration of the beacon, in seconds.
7830 * 0xFFFF indicates an infinite amount of time.
7831 * Access: RO
7832 */
7833MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
7834
7835static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
7836 bool active)
7837{
7838 MLXSW_REG_ZERO(mlcr, payload);
7839 mlxsw_reg_mlcr_local_port_set(payload, local_port);
7840 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
7841 MLXSW_REG_MLCR_DURATION_MAX : 0);
7842}
7843
Yotam Gigi4f2402d2017-05-23 21:56:24 +02007844/* MCQI - Management Component Query Information
7845 * ---------------------------------------------
7846 * This register allows querying information about firmware components.
7847 */
7848#define MLXSW_REG_MCQI_ID 0x9061
7849#define MLXSW_REG_MCQI_BASE_LEN 0x18
7850#define MLXSW_REG_MCQI_CAP_LEN 0x14
7851#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
7852
7853MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
7854
7855/* reg_mcqi_component_index
7856 * Index of the accessed component.
7857 * Access: Index
7858 */
7859MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
7860
7861enum mlxfw_reg_mcqi_info_type {
7862 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
7863};
7864
7865/* reg_mcqi_info_type
7866 * Component properties set.
7867 * Access: RW
7868 */
7869MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
7870
7871/* reg_mcqi_offset
7872 * The requested/returned data offset from the section start, given in bytes.
7873 * Must be DWORD aligned.
7874 * Access: RW
7875 */
7876MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
7877
7878/* reg_mcqi_data_size
7879 * The requested/returned data size, given in bytes. If data_size is not DWORD
7880 * aligned, the last bytes are zero padded.
7881 * Access: RW
7882 */
7883MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
7884
7885/* reg_mcqi_cap_max_component_size
7886 * Maximum size for this component, given in bytes.
7887 * Access: RO
7888 */
7889MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
7890
7891/* reg_mcqi_cap_log_mcda_word_size
7892 * Log 2 of the access word size in bytes. Read and write access must be aligned
7893 * to the word size. Write access must be done for an integer number of words.
7894 * Access: RO
7895 */
7896MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
7897
7898/* reg_mcqi_cap_mcda_max_write_size
7899 * Maximal write size for MCDA register
7900 * Access: RO
7901 */
7902MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
7903
7904static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
7905{
7906 MLXSW_REG_ZERO(mcqi, payload);
7907 mlxsw_reg_mcqi_component_index_set(payload, component_index);
7908 mlxsw_reg_mcqi_info_type_set(payload,
7909 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
7910 mlxsw_reg_mcqi_offset_set(payload, 0);
7911 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
7912}
7913
7914static inline void mlxsw_reg_mcqi_unpack(char *payload,
7915 u32 *p_cap_max_component_size,
7916 u8 *p_cap_log_mcda_word_size,
7917 u16 *p_cap_mcda_max_write_size)
7918{
7919 *p_cap_max_component_size =
7920 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
7921 *p_cap_log_mcda_word_size =
7922 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
7923 *p_cap_mcda_max_write_size =
7924 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
7925}
7926
Yotam Gigi191839d2017-05-23 21:56:25 +02007927/* MCC - Management Component Control
7928 * ----------------------------------
7929 * Controls the firmware component and updates the FSM.
7930 */
7931#define MLXSW_REG_MCC_ID 0x9062
7932#define MLXSW_REG_MCC_LEN 0x1C
7933
7934MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
7935
7936enum mlxsw_reg_mcc_instruction {
7937 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
7938 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
7939 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
7940 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
7941 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
7942 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
7943};
7944
7945/* reg_mcc_instruction
7946 * Command to be executed by the FSM.
7947 * Applicable for write operation only.
7948 * Access: RW
7949 */
7950MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
7951
7952/* reg_mcc_component_index
7953 * Index of the accessed component. Applicable only for commands that
7954 * refer to components. Otherwise, this field is reserved.
7955 * Access: Index
7956 */
7957MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
7958
7959/* reg_mcc_update_handle
7960 * Token representing the current flow executed by the FSM.
7961 * Access: WO
7962 */
7963MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
7964
7965/* reg_mcc_error_code
7966 * Indicates the successful completion of the instruction, or the reason it
7967 * failed
7968 * Access: RO
7969 */
7970MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
7971
7972/* reg_mcc_control_state
7973 * Current FSM state
7974 * Access: RO
7975 */
7976MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
7977
7978/* reg_mcc_component_size
7979 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
7980 * the size may shorten the update time. Value 0x0 means that size is
7981 * unspecified.
7982 * Access: WO
7983 */
7984MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
7985
7986static inline void mlxsw_reg_mcc_pack(char *payload,
7987 enum mlxsw_reg_mcc_instruction instr,
7988 u16 component_index, u32 update_handle,
7989 u32 component_size)
7990{
7991 MLXSW_REG_ZERO(mcc, payload);
7992 mlxsw_reg_mcc_instruction_set(payload, instr);
7993 mlxsw_reg_mcc_component_index_set(payload, component_index);
7994 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
7995 mlxsw_reg_mcc_component_size_set(payload, component_size);
7996}
7997
7998static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
7999 u8 *p_error_code, u8 *p_control_state)
8000{
8001 if (p_update_handle)
8002 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
8003 if (p_error_code)
8004 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
8005 if (p_control_state)
8006 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
8007}
8008
Yotam Gigi4625d592017-05-23 21:56:26 +02008009/* MCDA - Management Component Data Access
8010 * ---------------------------------------
8011 * This register allows reading and writing a firmware component.
8012 */
8013#define MLXSW_REG_MCDA_ID 0x9063
8014#define MLXSW_REG_MCDA_BASE_LEN 0x10
8015#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
8016#define MLXSW_REG_MCDA_LEN \
8017 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
8018
8019MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
8020
8021/* reg_mcda_update_handle
8022 * Token representing the current flow executed by the FSM.
8023 * Access: RW
8024 */
8025MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
8026
8027/* reg_mcda_offset
8028 * Offset of accessed address relative to component start. Accesses must be in
8029 * accordance to log_mcda_word_size in MCQI reg.
8030 * Access: RW
8031 */
8032MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
8033
8034/* reg_mcda_size
8035 * Size of the data accessed, given in bytes.
8036 * Access: RW
8037 */
8038MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
8039
8040/* reg_mcda_data
8041 * Data block accessed.
8042 * Access: RW
8043 */
8044MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
8045
8046static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
8047 u32 offset, u16 size, u8 *data)
8048{
8049 int i;
8050
8051 MLXSW_REG_ZERO(mcda, payload);
8052 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
8053 mlxsw_reg_mcda_offset_set(payload, offset);
8054 mlxsw_reg_mcda_size_set(payload, size);
8055
8056 for (i = 0; i < size / 4; i++)
8057 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
8058}
8059
Yotam Gigi0677d682017-01-23 11:07:10 +01008060/* MPSC - Monitoring Packet Sampling Configuration Register
8061 * --------------------------------------------------------
8062 * MPSC Register is used to configure the Packet Sampling mechanism.
8063 */
8064#define MLXSW_REG_MPSC_ID 0x9080
8065#define MLXSW_REG_MPSC_LEN 0x1C
8066
8067MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
8068
8069/* reg_mpsc_local_port
8070 * Local port number
8071 * Not supported for CPU port
8072 * Access: Index
8073 */
8074MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
8075
8076/* reg_mpsc_e
8077 * Enable sampling on port local_port
8078 * Access: RW
8079 */
8080MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
8081
8082#define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
8083
8084/* reg_mpsc_rate
8085 * Sampling rate = 1 out of rate packets (with randomization around
8086 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
8087 * Access: RW
8088 */
8089MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
8090
8091static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
8092 u32 rate)
8093{
8094 MLXSW_REG_ZERO(mpsc, payload);
8095 mlxsw_reg_mpsc_local_port_set(payload, local_port);
8096 mlxsw_reg_mpsc_e_set(payload, e);
8097 mlxsw_reg_mpsc_rate_set(payload, rate);
8098}
8099
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008100/* MGPC - Monitoring General Purpose Counter Set Register
8101 * The MGPC register retrieves and sets the General Purpose Counter Set.
8102 */
8103#define MLXSW_REG_MGPC_ID 0x9081
8104#define MLXSW_REG_MGPC_LEN 0x18
8105
8106MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
8107
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008108/* reg_mgpc_counter_set_type
8109 * Counter set type.
8110 * Access: OP
8111 */
8112MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
8113
8114/* reg_mgpc_counter_index
8115 * Counter index.
8116 * Access: Index
8117 */
8118MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
8119
8120enum mlxsw_reg_mgpc_opcode {
8121 /* Nop */
8122 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
8123 /* Clear counters */
8124 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
8125};
8126
8127/* reg_mgpc_opcode
8128 * Opcode.
8129 * Access: OP
8130 */
8131MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
8132
8133/* reg_mgpc_byte_counter
8134 * Byte counter value.
8135 * Access: RW
8136 */
8137MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
8138
8139/* reg_mgpc_packet_counter
8140 * Packet counter value.
8141 * Access: RW
8142 */
8143MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
8144
8145static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
8146 enum mlxsw_reg_mgpc_opcode opcode,
Arkadi Sharshevsky6bba7e22017-08-24 08:40:07 +02008147 enum mlxsw_reg_flow_counter_set_type set_type)
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008148{
8149 MLXSW_REG_ZERO(mgpc, payload);
8150 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
8151 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
8152 mlxsw_reg_mgpc_opcode_set(payload, opcode);
8153}
8154
Petr Machata14aefd92017-10-20 09:16:15 +02008155/* TIGCR - Tunneling IPinIP General Configuration Register
8156 * -------------------------------------------------------
8157 * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
8158 */
8159#define MLXSW_REG_TIGCR_ID 0xA801
8160#define MLXSW_REG_TIGCR_LEN 0x10
8161
8162MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
8163
8164/* reg_tigcr_ipip_ttlc
8165 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
8166 * header.
8167 * Access: RW
8168 */
8169MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
8170
8171/* reg_tigcr_ipip_ttl_uc
8172 * The TTL for IPinIP Tunnel encapsulation of unicast packets if
8173 * reg_tigcr_ipip_ttlc is unset.
8174 * Access: RW
8175 */
8176MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
8177
8178static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
8179{
8180 MLXSW_REG_ZERO(tigcr, payload);
8181 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
8182 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
8183}
8184
Jiri Pirkoe0594362015-10-16 14:01:31 +02008185/* SBPR - Shared Buffer Pools Register
8186 * -----------------------------------
8187 * The SBPR configures and retrieves the shared buffer pools and configuration.
8188 */
8189#define MLXSW_REG_SBPR_ID 0xB001
8190#define MLXSW_REG_SBPR_LEN 0x14
8191
Jiri Pirko21978dc2016-10-21 16:07:20 +02008192MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008193
Jiri Pirko497e8592016-04-08 19:11:24 +02008194/* shared direstion enum for SBPR, SBCM, SBPM */
8195enum mlxsw_reg_sbxx_dir {
8196 MLXSW_REG_SBXX_DIR_INGRESS,
8197 MLXSW_REG_SBXX_DIR_EGRESS,
Jiri Pirkoe0594362015-10-16 14:01:31 +02008198};
8199
8200/* reg_sbpr_dir
8201 * Direction.
8202 * Access: Index
8203 */
8204MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
8205
8206/* reg_sbpr_pool
8207 * Pool index.
8208 * Access: Index
8209 */
8210MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
8211
8212/* reg_sbpr_size
8213 * Pool size in buffer cells.
8214 * Access: RW
8215 */
8216MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
8217
8218enum mlxsw_reg_sbpr_mode {
8219 MLXSW_REG_SBPR_MODE_STATIC,
8220 MLXSW_REG_SBPR_MODE_DYNAMIC,
8221};
8222
8223/* reg_sbpr_mode
8224 * Pool quota calculation mode.
8225 * Access: RW
8226 */
8227MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
8228
8229static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
Jiri Pirko497e8592016-04-08 19:11:24 +02008230 enum mlxsw_reg_sbxx_dir dir,
Jiri Pirkoe0594362015-10-16 14:01:31 +02008231 enum mlxsw_reg_sbpr_mode mode, u32 size)
8232{
8233 MLXSW_REG_ZERO(sbpr, payload);
8234 mlxsw_reg_sbpr_pool_set(payload, pool);
8235 mlxsw_reg_sbpr_dir_set(payload, dir);
8236 mlxsw_reg_sbpr_mode_set(payload, mode);
8237 mlxsw_reg_sbpr_size_set(payload, size);
8238}
8239
8240/* SBCM - Shared Buffer Class Management Register
8241 * ----------------------------------------------
8242 * The SBCM register configures and retrieves the shared buffer allocation
8243 * and configuration according to Port-PG, including the binding to pool
8244 * and definition of the associated quota.
8245 */
8246#define MLXSW_REG_SBCM_ID 0xB002
8247#define MLXSW_REG_SBCM_LEN 0x28
8248
Jiri Pirko21978dc2016-10-21 16:07:20 +02008249MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008250
8251/* reg_sbcm_local_port
8252 * Local port number.
8253 * For Ingress: excludes CPU port and Router port
8254 * For Egress: excludes IP Router
8255 * Access: Index
8256 */
8257MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
8258
8259/* reg_sbcm_pg_buff
8260 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
8261 * For PG buffer: range is 0..cap_max_pg_buffers - 1
8262 * For traffic class: range is 0..cap_max_tclass - 1
8263 * Note that when traffic class is in MC aware mode then the traffic
8264 * classes which are MC aware cannot be configured.
8265 * Access: Index
8266 */
8267MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
8268
Jiri Pirkoe0594362015-10-16 14:01:31 +02008269/* reg_sbcm_dir
8270 * Direction.
8271 * Access: Index
8272 */
8273MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
8274
8275/* reg_sbcm_min_buff
8276 * Minimum buffer size for the limiter, in cells.
8277 * Access: RW
8278 */
8279MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
8280
Jiri Pirkoc30a53c2016-04-14 18:19:22 +02008281/* shared max_buff limits for dynamic threshold for SBCM, SBPM */
8282#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
8283#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
8284
Jiri Pirkoe0594362015-10-16 14:01:31 +02008285/* reg_sbcm_max_buff
8286 * When the pool associated to the port-pg/tclass is configured to
8287 * static, Maximum buffer size for the limiter configured in cells.
8288 * When the pool associated to the port-pg/tclass is configured to
8289 * dynamic, the max_buff holds the "alpha" parameter, supporting
8290 * the following values:
8291 * 0: 0
8292 * i: (1/128)*2^(i-1), for i=1..14
8293 * 0xFF: Infinity
8294 * Access: RW
8295 */
8296MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
8297
8298/* reg_sbcm_pool
8299 * Association of the port-priority to a pool.
8300 * Access: RW
8301 */
8302MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
8303
8304static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
Jiri Pirko497e8592016-04-08 19:11:24 +02008305 enum mlxsw_reg_sbxx_dir dir,
Jiri Pirkoe0594362015-10-16 14:01:31 +02008306 u32 min_buff, u32 max_buff, u8 pool)
8307{
8308 MLXSW_REG_ZERO(sbcm, payload);
8309 mlxsw_reg_sbcm_local_port_set(payload, local_port);
8310 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
8311 mlxsw_reg_sbcm_dir_set(payload, dir);
8312 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
8313 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
8314 mlxsw_reg_sbcm_pool_set(payload, pool);
8315}
8316
Jiri Pirko9efc8f62016-04-08 19:11:25 +02008317/* SBPM - Shared Buffer Port Management Register
8318 * ---------------------------------------------
Jiri Pirkoe0594362015-10-16 14:01:31 +02008319 * The SBPM register configures and retrieves the shared buffer allocation
8320 * and configuration according to Port-Pool, including the definition
8321 * of the associated quota.
8322 */
8323#define MLXSW_REG_SBPM_ID 0xB003
8324#define MLXSW_REG_SBPM_LEN 0x28
8325
Jiri Pirko21978dc2016-10-21 16:07:20 +02008326MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008327
8328/* reg_sbpm_local_port
8329 * Local port number.
8330 * For Ingress: excludes CPU port and Router port
8331 * For Egress: excludes IP Router
8332 * Access: Index
8333 */
8334MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
8335
8336/* reg_sbpm_pool
8337 * The pool associated to quota counting on the local_port.
8338 * Access: Index
8339 */
8340MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
8341
Jiri Pirkoe0594362015-10-16 14:01:31 +02008342/* reg_sbpm_dir
8343 * Direction.
8344 * Access: Index
8345 */
8346MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
8347
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008348/* reg_sbpm_buff_occupancy
8349 * Current buffer occupancy in cells.
8350 * Access: RO
8351 */
8352MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
8353
8354/* reg_sbpm_clr
8355 * Clear Max Buffer Occupancy
8356 * When this bit is set, max_buff_occupancy field is cleared (and a
8357 * new max value is tracked from the time the clear was performed).
8358 * Access: OP
8359 */
8360MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
8361
8362/* reg_sbpm_max_buff_occupancy
8363 * Maximum value of buffer occupancy in cells monitored. Cleared by
8364 * writing to the clr field.
8365 * Access: RO
8366 */
8367MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
8368
Jiri Pirkoe0594362015-10-16 14:01:31 +02008369/* reg_sbpm_min_buff
8370 * Minimum buffer size for the limiter, in cells.
8371 * Access: RW
8372 */
8373MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
8374
8375/* reg_sbpm_max_buff
8376 * When the pool associated to the port-pg/tclass is configured to
8377 * static, Maximum buffer size for the limiter configured in cells.
8378 * When the pool associated to the port-pg/tclass is configured to
8379 * dynamic, the max_buff holds the "alpha" parameter, supporting
8380 * the following values:
8381 * 0: 0
8382 * i: (1/128)*2^(i-1), for i=1..14
8383 * 0xFF: Infinity
8384 * Access: RW
8385 */
8386MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
8387
8388static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008389 enum mlxsw_reg_sbxx_dir dir, bool clr,
Jiri Pirkoe0594362015-10-16 14:01:31 +02008390 u32 min_buff, u32 max_buff)
8391{
8392 MLXSW_REG_ZERO(sbpm, payload);
8393 mlxsw_reg_sbpm_local_port_set(payload, local_port);
8394 mlxsw_reg_sbpm_pool_set(payload, pool);
8395 mlxsw_reg_sbpm_dir_set(payload, dir);
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008396 mlxsw_reg_sbpm_clr_set(payload, clr);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008397 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
8398 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
8399}
8400
Jiri Pirko42a7f1d2016-04-14 18:19:27 +02008401static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
8402 u32 *p_max_buff_occupancy)
8403{
8404 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
8405 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
8406}
8407
Jiri Pirkoe0594362015-10-16 14:01:31 +02008408/* SBMM - Shared Buffer Multicast Management Register
8409 * --------------------------------------------------
8410 * The SBMM register configures and retrieves the shared buffer allocation
8411 * and configuration for MC packets according to Switch-Priority, including
8412 * the binding to pool and definition of the associated quota.
8413 */
8414#define MLXSW_REG_SBMM_ID 0xB004
8415#define MLXSW_REG_SBMM_LEN 0x28
8416
Jiri Pirko21978dc2016-10-21 16:07:20 +02008417MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
Jiri Pirkoe0594362015-10-16 14:01:31 +02008418
8419/* reg_sbmm_prio
8420 * Switch Priority.
8421 * Access: Index
8422 */
8423MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
8424
8425/* reg_sbmm_min_buff
8426 * Minimum buffer size for the limiter, in cells.
8427 * Access: RW
8428 */
8429MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
8430
8431/* reg_sbmm_max_buff
8432 * When the pool associated to the port-pg/tclass is configured to
8433 * static, Maximum buffer size for the limiter configured in cells.
8434 * When the pool associated to the port-pg/tclass is configured to
8435 * dynamic, the max_buff holds the "alpha" parameter, supporting
8436 * the following values:
8437 * 0: 0
8438 * i: (1/128)*2^(i-1), for i=1..14
8439 * 0xFF: Infinity
8440 * Access: RW
8441 */
8442MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
8443
8444/* reg_sbmm_pool
8445 * Association of the port-priority to a pool.
8446 * Access: RW
8447 */
8448MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
8449
8450static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
8451 u32 max_buff, u8 pool)
8452{
8453 MLXSW_REG_ZERO(sbmm, payload);
8454 mlxsw_reg_sbmm_prio_set(payload, prio);
8455 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
8456 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
8457 mlxsw_reg_sbmm_pool_set(payload, pool);
8458}
8459
Jiri Pirko26176de2016-04-14 18:19:26 +02008460/* SBSR - Shared Buffer Status Register
8461 * ------------------------------------
8462 * The SBSR register retrieves the shared buffer occupancy according to
8463 * Port-Pool. Note that this register enables reading a large amount of data.
8464 * It is the user's responsibility to limit the amount of data to ensure the
8465 * response can match the maximum transfer unit. In case the response exceeds
8466 * the maximum transport unit, it will be truncated with no special notice.
8467 */
8468#define MLXSW_REG_SBSR_ID 0xB005
8469#define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
8470#define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
8471#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
8472#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
8473 MLXSW_REG_SBSR_REC_LEN * \
8474 MLXSW_REG_SBSR_REC_MAX_COUNT)
8475
Jiri Pirko21978dc2016-10-21 16:07:20 +02008476MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
Jiri Pirko26176de2016-04-14 18:19:26 +02008477
8478/* reg_sbsr_clr
8479 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
8480 * field is cleared (and a new max value is tracked from the time the clear
8481 * was performed).
8482 * Access: OP
8483 */
8484MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
8485
8486/* reg_sbsr_ingress_port_mask
8487 * Bit vector for all ingress network ports.
8488 * Indicates which of the ports (for which the relevant bit is set)
8489 * are affected by the set operation. Configuration of any other port
8490 * does not change.
8491 * Access: Index
8492 */
8493MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
8494
8495/* reg_sbsr_pg_buff_mask
8496 * Bit vector for all switch priority groups.
8497 * Indicates which of the priorities (for which the relevant bit is set)
8498 * are affected by the set operation. Configuration of any other priority
8499 * does not change.
8500 * Range is 0..cap_max_pg_buffers - 1
8501 * Access: Index
8502 */
8503MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
8504
8505/* reg_sbsr_egress_port_mask
8506 * Bit vector for all egress network ports.
8507 * Indicates which of the ports (for which the relevant bit is set)
8508 * are affected by the set operation. Configuration of any other port
8509 * does not change.
8510 * Access: Index
8511 */
8512MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
8513
8514/* reg_sbsr_tclass_mask
8515 * Bit vector for all traffic classes.
8516 * Indicates which of the traffic classes (for which the relevant bit is
8517 * set) are affected by the set operation. Configuration of any other
8518 * traffic class does not change.
8519 * Range is 0..cap_max_tclass - 1
8520 * Access: Index
8521 */
8522MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
8523
8524static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
8525{
8526 MLXSW_REG_ZERO(sbsr, payload);
8527 mlxsw_reg_sbsr_clr_set(payload, clr);
8528}
8529
8530/* reg_sbsr_rec_buff_occupancy
8531 * Current buffer occupancy in cells.
8532 * Access: RO
8533 */
8534MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
8535 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
8536
8537/* reg_sbsr_rec_max_buff_occupancy
8538 * Maximum value of buffer occupancy in cells monitored. Cleared by
8539 * writing to the clr field.
8540 * Access: RO
8541 */
8542MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
8543 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
8544
8545static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
8546 u32 *p_buff_occupancy,
8547 u32 *p_max_buff_occupancy)
8548{
8549 *p_buff_occupancy =
8550 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
8551 *p_max_buff_occupancy =
8552 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
8553}
8554
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02008555/* SBIB - Shared Buffer Internal Buffer Register
8556 * ---------------------------------------------
8557 * The SBIB register configures per port buffers for internal use. The internal
8558 * buffers consume memory on the port buffers (note that the port buffers are
8559 * used also by PBMC).
8560 *
8561 * For Spectrum this is used for egress mirroring.
8562 */
8563#define MLXSW_REG_SBIB_ID 0xB006
8564#define MLXSW_REG_SBIB_LEN 0x10
8565
Jiri Pirko21978dc2016-10-21 16:07:20 +02008566MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
Yotam Gigi51ae8cc2016-07-21 12:03:13 +02008567
8568/* reg_sbib_local_port
8569 * Local port number
8570 * Not supported for CPU port and router port
8571 * Access: Index
8572 */
8573MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
8574
8575/* reg_sbib_buff_size
8576 * Units represented in cells
8577 * Allowed range is 0 to (cap_max_headroom_size - 1)
8578 * Default is 0
8579 * Access: RW
8580 */
8581MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
8582
8583static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
8584 u32 buff_size)
8585{
8586 MLXSW_REG_ZERO(sbib, payload);
8587 mlxsw_reg_sbib_local_port_set(payload, local_port);
8588 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
8589}
8590
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008591static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
8592 MLXSW_REG(sgcr),
8593 MLXSW_REG(spad),
8594 MLXSW_REG(smid),
8595 MLXSW_REG(sspr),
8596 MLXSW_REG(sfdat),
8597 MLXSW_REG(sfd),
8598 MLXSW_REG(sfn),
8599 MLXSW_REG(spms),
8600 MLXSW_REG(spvid),
8601 MLXSW_REG(spvm),
8602 MLXSW_REG(spaft),
8603 MLXSW_REG(sfgc),
8604 MLXSW_REG(sftr),
8605 MLXSW_REG(sfdf),
8606 MLXSW_REG(sldr),
8607 MLXSW_REG(slcr),
8608 MLXSW_REG(slcor),
8609 MLXSW_REG(spmlr),
8610 MLXSW_REG(svfa),
8611 MLXSW_REG(svpe),
8612 MLXSW_REG(sfmr),
8613 MLXSW_REG(spvmlr),
Nogah Frankelad53fa02017-11-06 07:23:44 +01008614 MLXSW_REG(cwtp),
8615 MLXSW_REG(cwtpm),
Ido Schimmel7050f432018-07-18 11:14:40 +03008616 MLXSW_REG(pgcr),
Jiri Pirkoaf7170e2017-02-03 10:28:57 +01008617 MLXSW_REG(ppbt),
Jiri Pirko3279da42017-02-03 10:28:53 +01008618 MLXSW_REG(pacl),
Jiri Pirko10fabef2017-02-03 10:28:54 +01008619 MLXSW_REG(pagt),
Jiri Pirkod9c26612017-02-03 10:28:55 +01008620 MLXSW_REG(ptar),
Jiri Pirkod1206492017-02-03 10:28:59 +01008621 MLXSW_REG(ppbs),
Jiri Pirko937b6822017-02-03 10:28:58 +01008622 MLXSW_REG(prcr),
Jiri Pirkoe3426e12017-02-03 10:29:00 +01008623 MLXSW_REG(pefa),
Jiri Pirko0171cdec2017-02-03 10:28:56 +01008624 MLXSW_REG(ptce2),
Ido Schimmel8c0d1cd2018-07-25 09:23:52 +03008625 MLXSW_REG(perpt),
Jiri Pirko33907872018-07-18 11:14:37 +03008626 MLXSW_REG(perar),
Ido Schimmelaecefac2018-07-25 09:23:51 +03008627 MLXSW_REG(ptce3),
Ido Schimmel481662a2018-07-18 11:14:38 +03008628 MLXSW_REG(percr),
Ido Schimmelf1c7d9c2018-07-18 11:14:39 +03008629 MLXSW_REG(pererp),
Jiri Pirkoc33d0cb2018-07-18 11:14:30 +03008630 MLXSW_REG(iedr),
Petr Machata746da422018-07-27 15:26:58 +03008631 MLXSW_REG(qpts),
Nogah Frankel76a4c7d2016-11-25 10:33:46 +01008632 MLXSW_REG(qpcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008633 MLXSW_REG(qtct),
8634 MLXSW_REG(qeec),
Petr Machata02837d72018-07-27 15:26:57 +03008635 MLXSW_REG(qpdpm),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008636 MLXSW_REG(pmlp),
8637 MLXSW_REG(pmtu),
8638 MLXSW_REG(ptys),
8639 MLXSW_REG(ppad),
8640 MLXSW_REG(paos),
8641 MLXSW_REG(pfcc),
8642 MLXSW_REG(ppcnt),
Elad Raz71367932016-10-28 21:35:54 +02008643 MLXSW_REG(plib),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008644 MLXSW_REG(pptb),
8645 MLXSW_REG(pbmc),
8646 MLXSW_REG(pspa),
8647 MLXSW_REG(htgt),
8648 MLXSW_REG(hpkt),
8649 MLXSW_REG(rgcr),
8650 MLXSW_REG(ritr),
Yotam Gigi46a70542017-09-19 10:00:13 +02008651 MLXSW_REG(rtar),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008652 MLXSW_REG(ratr),
Petr Machata1e659eb2017-09-02 23:49:13 +02008653 MLXSW_REG(rtdp),
Yuval Mintzddb362c2018-01-14 12:33:13 +01008654 MLXSW_REG(rdpm),
Arkadi Sharshevskyba73e972017-03-28 17:24:14 +02008655 MLXSW_REG(ricnt),
Yotam Gigi4fc92842017-09-19 10:00:17 +02008656 MLXSW_REG(rrcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008657 MLXSW_REG(ralta),
8658 MLXSW_REG(ralst),
8659 MLXSW_REG(raltb),
8660 MLXSW_REG(ralue),
8661 MLXSW_REG(rauht),
8662 MLXSW_REG(raleu),
8663 MLXSW_REG(rauhtd),
Yotam Gigi5080c7e2017-09-19 10:00:14 +02008664 MLXSW_REG(rigr2),
Ido Schimmele4718592017-11-02 17:14:08 +01008665 MLXSW_REG(recr2),
Yotam Gigi2e654e32017-09-19 10:00:16 +02008666 MLXSW_REG(rmft2),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008667 MLXSW_REG(mfcr),
8668 MLXSW_REG(mfsc),
8669 MLXSW_REG(mfsm),
Jiri Pirko55c63aa2016-11-22 11:24:12 +01008670 MLXSW_REG(mfsl),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008671 MLXSW_REG(mtcap),
8672 MLXSW_REG(mtmp),
Arkadi Sharshevsky7ca36992017-06-14 09:27:39 +02008673 MLXSW_REG(mcia),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008674 MLXSW_REG(mpat),
8675 MLXSW_REG(mpar),
Jiri Pirko12b003b2018-05-27 09:56:13 +03008676 MLXSW_REG(mrsr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008677 MLXSW_REG(mlcr),
Yotam Gigi0677d682017-01-23 11:07:10 +01008678 MLXSW_REG(mpsc),
Yotam Gigi4f2402d2017-05-23 21:56:24 +02008679 MLXSW_REG(mcqi),
Yotam Gigi191839d2017-05-23 21:56:25 +02008680 MLXSW_REG(mcc),
Yotam Gigi4625d592017-05-23 21:56:26 +02008681 MLXSW_REG(mcda),
Arkadi Sharshevsky57665322017-03-11 09:42:52 +01008682 MLXSW_REG(mgpc),
Petr Machata14aefd92017-10-20 09:16:15 +02008683 MLXSW_REG(tigcr),
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008684 MLXSW_REG(sbpr),
8685 MLXSW_REG(sbcm),
8686 MLXSW_REG(sbpm),
8687 MLXSW_REG(sbmm),
8688 MLXSW_REG(sbsr),
8689 MLXSW_REG(sbib),
8690};
8691
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008692static inline const char *mlxsw_reg_id_str(u16 reg_id)
8693{
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008694 const struct mlxsw_reg_info *reg_info;
8695 int i;
8696
8697 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
8698 reg_info = mlxsw_reg_infos[i];
8699 if (reg_info->id == reg_id)
8700 return reg_info->name;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008701 }
Jiri Pirko8e9658d2016-10-21 16:07:21 +02008702 return "*UNKNOWN*";
Ido Schimmel4ec14b72015-07-29 23:33:48 +02008703}
8704
8705/* PUDE - Port Up / Down Event
8706 * ---------------------------
8707 * Reports the operational state change of a port.
8708 */
8709#define MLXSW_REG_PUDE_LEN 0x10
8710
8711/* reg_pude_swid
8712 * Switch partition ID with which to associate the port.
8713 * Access: Index
8714 */
8715MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
8716
8717/* reg_pude_local_port
8718 * Local port number.
8719 * Access: Index
8720 */
8721MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
8722
8723/* reg_pude_admin_status
8724 * Port administrative state (the desired state).
8725 * 1 - Up.
8726 * 2 - Down.
8727 * 3 - Up once. This means that in case of link failure, the port won't go
8728 * into polling mode, but will wait to be re-enabled by software.
8729 * 4 - Disabled by system. Can only be set by hardware.
8730 * Access: RO
8731 */
8732MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
8733
8734/* reg_pude_oper_status
8735 * Port operatioanl state.
8736 * 1 - Up.
8737 * 2 - Down.
8738 * 3 - Down by port failure. This means that the device will not let the
8739 * port up again until explicitly specified by software.
8740 * Access: RO
8741 */
8742MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
8743
8744#endif