blob: c0cc5f102189815dd8a4410bbf6cdb351bae66e8 [file] [log] [blame]
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001/*
2 * drivers/net/ethernet/mellanox/mlxsw/reg.h
3 * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
5 * Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
6 * Copyright (c) 2015 Jiri Pirko <jiri@mellanox.com>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _MLXSW_REG_H
38#define _MLXSW_REG_H
39
40#include <linux/string.h>
41#include <linux/bitops.h>
42#include <linux/if_vlan.h>
43
44#include "item.h"
45#include "port.h"
46
47struct mlxsw_reg_info {
48 u16 id;
49 u16 len; /* In u8 */
50};
51
52#define MLXSW_REG(type) (&mlxsw_reg_##type)
53#define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
54#define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
55
56/* SGCR - Switch General Configuration Register
57 * --------------------------------------------
58 * This register is used for configuration of the switch capabilities.
59 */
60#define MLXSW_REG_SGCR_ID 0x2000
61#define MLXSW_REG_SGCR_LEN 0x10
62
63static const struct mlxsw_reg_info mlxsw_reg_sgcr = {
64 .id = MLXSW_REG_SGCR_ID,
65 .len = MLXSW_REG_SGCR_LEN,
66};
67
68/* reg_sgcr_llb
69 * Link Local Broadcast (Default=0)
70 * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
71 * packets and ignore the IGMP snooping entries.
72 * Access: RW
73 */
74MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
75
76static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
77{
78 MLXSW_REG_ZERO(sgcr, payload);
79 mlxsw_reg_sgcr_llb_set(payload, !!llb);
80}
81
82/* SPAD - Switch Physical Address Register
83 * ---------------------------------------
84 * The SPAD register configures the switch physical MAC address.
85 */
86#define MLXSW_REG_SPAD_ID 0x2002
87#define MLXSW_REG_SPAD_LEN 0x10
88
89static const struct mlxsw_reg_info mlxsw_reg_spad = {
90 .id = MLXSW_REG_SPAD_ID,
91 .len = MLXSW_REG_SPAD_LEN,
92};
93
94/* reg_spad_base_mac
95 * Base MAC address for the switch partitions.
96 * Per switch partition MAC address is equal to:
97 * base_mac + swid
98 * Access: RW
99 */
100MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
101
Ido Schimmele61011b2015-08-06 16:41:53 +0200102/* SSPR - Switch System Port Record Register
103 * -----------------------------------------
104 * Configures the system port to local port mapping.
105 */
106#define MLXSW_REG_SSPR_ID 0x2008
107#define MLXSW_REG_SSPR_LEN 0x8
108
109static const struct mlxsw_reg_info mlxsw_reg_sspr = {
110 .id = MLXSW_REG_SSPR_ID,
111 .len = MLXSW_REG_SSPR_LEN,
112};
113
114/* reg_sspr_m
115 * Master - if set, then the record describes the master system port.
116 * This is needed in case a local port is mapped into several system ports
117 * (for multipathing). That number will be reported as the source system
118 * port when packets are forwarded to the CPU. Only one master port is allowed
119 * per local port.
120 *
121 * Note: Must be set for Spectrum.
122 * Access: RW
123 */
124MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
125
126/* reg_sspr_local_port
127 * Local port number.
128 *
129 * Access: RW
130 */
131MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
132
133/* reg_sspr_sub_port
134 * Virtual port within the physical port.
135 * Should be set to 0 when virtual ports are not enabled on the port.
136 *
137 * Access: RW
138 */
139MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
140
141/* reg_sspr_system_port
142 * Unique identifier within the stacking domain that represents all the ports
143 * that are available in the system (external ports).
144 *
145 * Currently, only single-ASIC configurations are supported, so we default to
146 * 1:1 mapping between system ports and local ports.
147 * Access: Index
148 */
149MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
150
151static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
152{
153 MLXSW_REG_ZERO(sspr, payload);
154 mlxsw_reg_sspr_m_set(payload, 1);
155 mlxsw_reg_sspr_local_port_set(payload, local_port);
156 mlxsw_reg_sspr_sub_port_set(payload, 0);
157 mlxsw_reg_sspr_system_port_set(payload, local_port);
158}
159
Jiri Pirko236033b2015-10-16 14:01:28 +0200160/* SFD - Switch Filtering Database
161 * -------------------------------
162 * The following register defines the access to the filtering database.
163 * The register supports querying, adding, removing and modifying the database.
164 * The access is optimized for bulk updates in which case more than one
165 * FDB record is present in the same command.
166 */
167#define MLXSW_REG_SFD_ID 0x200A
168#define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
169#define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
170#define MLXSW_REG_SFD_REC_MAX_COUNT 64
171#define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
172 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
173
174static const struct mlxsw_reg_info mlxsw_reg_sfd = {
175 .id = MLXSW_REG_SFD_ID,
176 .len = MLXSW_REG_SFD_LEN,
177};
178
179/* reg_sfd_swid
180 * Switch partition ID for queries. Reserved on Write.
181 * Access: Index
182 */
183MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
184
185enum mlxsw_reg_sfd_op {
186 /* Dump entire FDB a (process according to record_locator) */
187 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
188 /* Query records by {MAC, VID/FID} value */
189 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
190 /* Query and clear activity. Query records by {MAC, VID/FID} value */
191 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
192 /* Test. Response indicates if each of the records could be
193 * added to the FDB.
194 */
195 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
196 /* Add/modify. Aged-out records cannot be added. This command removes
197 * the learning notification of the {MAC, VID/FID}. Response includes
198 * the entries that were added to the FDB.
199 */
200 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
201 /* Remove record by {MAC, VID/FID}. This command also removes
202 * the learning notification and aged-out notifications
203 * of the {MAC, VID/FID}. The response provides current (pre-removal)
204 * entries as non-aged-out.
205 */
206 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
207 /* Remove learned notification by {MAC, VID/FID}. The response provides
208 * the removed learning notification.
209 */
210 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
211};
212
213/* reg_sfd_op
214 * Operation.
215 * Access: OP
216 */
217MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
218
219/* reg_sfd_record_locator
220 * Used for querying the FDB. Use record_locator=0 to initiate the
221 * query. When a record is returned, a new record_locator is
222 * returned to be used in the subsequent query.
223 * Reserved for database update.
224 * Access: Index
225 */
226MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
227
228/* reg_sfd_num_rec
229 * Request: Number of records to read/add/modify/remove
230 * Response: Number of records read/added/replaced/removed
231 * See above description for more details.
232 * Ranges 0..64
233 * Access: RW
234 */
235MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
236
237static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
238 u32 record_locator)
239{
240 MLXSW_REG_ZERO(sfd, payload);
241 mlxsw_reg_sfd_op_set(payload, op);
242 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
243}
244
245/* reg_sfd_rec_swid
246 * Switch partition ID.
247 * Access: Index
248 */
249MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
250 MLXSW_REG_SFD_REC_LEN, 0x00, false);
251
252enum mlxsw_reg_sfd_rec_type {
253 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
254};
255
256/* reg_sfd_rec_type
257 * FDB record type.
258 * Access: RW
259 */
260MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
261 MLXSW_REG_SFD_REC_LEN, 0x00, false);
262
263enum mlxsw_reg_sfd_rec_policy {
264 /* Replacement disabled, aging disabled. */
265 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
266 /* (mlag remote): Replacement enabled, aging disabled,
267 * learning notification enabled on this port.
268 */
269 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
270 /* (ingress device): Replacement enabled, aging enabled. */
271 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
272};
273
274/* reg_sfd_rec_policy
275 * Policy.
276 * Access: RW
277 */
278MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
279 MLXSW_REG_SFD_REC_LEN, 0x00, false);
280
281/* reg_sfd_rec_a
282 * Activity. Set for new static entries. Set for static entries if a frame SMAC
283 * lookup hits on the entry.
284 * To clear the a bit, use "query and clear activity" op.
285 * Access: RO
286 */
287MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
288 MLXSW_REG_SFD_REC_LEN, 0x00, false);
289
290/* reg_sfd_rec_mac
291 * MAC address.
292 * Access: Index
293 */
294MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
295 MLXSW_REG_SFD_REC_LEN, 0x02);
296
297enum mlxsw_reg_sfd_rec_action {
298 /* forward */
299 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
300 /* forward and trap, trap_id is FDB_TRAP */
301 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
302 /* trap and do not forward, trap_id is FDB_TRAP */
303 MLXSW_REG_SFD_REC_ACTION_TRAP = 3,
304 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
305};
306
307/* reg_sfd_rec_action
308 * Action to apply on the packet.
309 * Note: Dynamic entries can only be configured with NOP action.
310 * Access: RW
311 */
312MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
313 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
314
315/* reg_sfd_uc_sub_port
316 * LAG sub port.
317 * Must be 0 if multichannel VEPA is not enabled.
318 * Access: RW
319 */
320MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
321 MLXSW_REG_SFD_REC_LEN, 0x08, false);
322
323/* reg_sfd_uc_fid_vid
324 * Filtering ID or VLAN ID
325 * For SwitchX and SwitchX-2:
326 * - Dynamic entries (policy 2,3) use FID
327 * - Static entries (policy 0) use VID
328 * - When independent learning is configured, VID=FID
329 * For Spectrum: use FID for both Dynamic and Static entries.
330 * VID should not be used.
331 * Access: Index
332 */
333MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
334 MLXSW_REG_SFD_REC_LEN, 0x08, false);
335
336/* reg_sfd_uc_system_port
337 * Unique port identifier for the final destination of the packet.
338 * Access: RW
339 */
340MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
341 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
342
343static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
344 enum mlxsw_reg_sfd_rec_policy policy,
345 const char *mac, u16 vid,
346 enum mlxsw_reg_sfd_rec_action action,
347 u8 local_port)
348{
349 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
350
351 if (rec_index >= num_rec)
352 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
353 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
354 mlxsw_reg_sfd_rec_type_set(payload, rec_index,
355 MLXSW_REG_SFD_REC_TYPE_UNICAST);
356 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
357 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
358 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
359 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, vid);
360 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
361 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
362}
363
364static inline void
365mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
366 char *mac, u16 *p_vid,
367 u8 *p_local_port)
368{
369 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
370 *p_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
371 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
372}
373
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200374/* SPMS - Switch Port MSTP/RSTP State Register
375 * -------------------------------------------
376 * Configures the spanning tree state of a physical port.
377 */
Jiri Pirko3f0effd2015-10-15 17:43:23 +0200378#define MLXSW_REG_SPMS_ID 0x200D
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200379#define MLXSW_REG_SPMS_LEN 0x404
380
381static const struct mlxsw_reg_info mlxsw_reg_spms = {
382 .id = MLXSW_REG_SPMS_ID,
383 .len = MLXSW_REG_SPMS_LEN,
384};
385
386/* reg_spms_local_port
387 * Local port number.
388 * Access: Index
389 */
390MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
391
392enum mlxsw_reg_spms_state {
393 MLXSW_REG_SPMS_STATE_NO_CHANGE,
394 MLXSW_REG_SPMS_STATE_DISCARDING,
395 MLXSW_REG_SPMS_STATE_LEARNING,
396 MLXSW_REG_SPMS_STATE_FORWARDING,
397};
398
399/* reg_spms_state
400 * Spanning tree state of each VLAN ID (VID) of the local port.
401 * 0 - Do not change spanning tree state (used only when writing).
402 * 1 - Discarding. No learning or forwarding to/from this port (default).
403 * 2 - Learning. Port is learning, but not forwarding.
404 * 3 - Forwarding. Port is learning and forwarding.
405 * Access: RW
406 */
407MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
408
Jiri Pirkoebb79632015-10-15 17:43:26 +0200409static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200410{
411 MLXSW_REG_ZERO(spms, payload);
412 mlxsw_reg_spms_local_port_set(payload, local_port);
Jiri Pirkoebb79632015-10-15 17:43:26 +0200413}
414
415static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
416 enum mlxsw_reg_spms_state state)
417{
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200418 mlxsw_reg_spms_state_set(payload, vid, state);
419}
420
421/* SFGC - Switch Flooding Group Configuration
422 * ------------------------------------------
423 * The following register controls the association of flooding tables and MIDs
424 * to packet types used for flooding.
425 */
Jiri Pirko36b78e82015-10-15 17:43:24 +0200426#define MLXSW_REG_SFGC_ID 0x2011
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200427#define MLXSW_REG_SFGC_LEN 0x10
428
429static const struct mlxsw_reg_info mlxsw_reg_sfgc = {
430 .id = MLXSW_REG_SFGC_ID,
431 .len = MLXSW_REG_SFGC_LEN,
432};
433
434enum mlxsw_reg_sfgc_type {
Ido Schimmelfa6ad052015-10-15 17:43:25 +0200435 MLXSW_REG_SFGC_TYPE_BROADCAST,
436 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
437 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
438 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
439 MLXSW_REG_SFGC_TYPE_RESERVED,
440 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
441 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
442 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
443 MLXSW_REG_SFGC_TYPE_MAX,
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200444};
445
446/* reg_sfgc_type
447 * The traffic type to reach the flooding table.
448 * Access: Index
449 */
450MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
451
452enum mlxsw_reg_sfgc_bridge_type {
453 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
454 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
455};
456
457/* reg_sfgc_bridge_type
458 * Access: Index
459 *
460 * Note: SwitchX-2 only supports 802.1Q mode.
461 */
462MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
463
464enum mlxsw_flood_table_type {
465 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
466 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
467 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
468 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3,
469 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
470};
471
472/* reg_sfgc_table_type
473 * See mlxsw_flood_table_type
474 * Access: RW
475 *
476 * Note: FID offset and FID types are not supported in SwitchX-2.
477 */
478MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
479
480/* reg_sfgc_flood_table
481 * Flooding table index to associate with the specific type on the specific
482 * switch partition.
483 * Access: RW
484 */
485MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
486
487/* reg_sfgc_mid
488 * The multicast ID for the swid. Not supported for Spectrum
489 * Access: RW
490 */
491MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
492
493/* reg_sfgc_counter_set_type
494 * Counter Set Type for flow counters.
495 * Access: RW
496 */
497MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
498
499/* reg_sfgc_counter_index
500 * Counter Index for flow counters.
501 * Access: RW
502 */
503MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
504
505static inline void
506mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
507 enum mlxsw_reg_sfgc_bridge_type bridge_type,
508 enum mlxsw_flood_table_type table_type,
509 unsigned int flood_table)
510{
511 MLXSW_REG_ZERO(sfgc, payload);
512 mlxsw_reg_sfgc_type_set(payload, type);
513 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
514 mlxsw_reg_sfgc_table_type_set(payload, table_type);
515 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
516 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
517}
518
519/* SFTR - Switch Flooding Table Register
520 * -------------------------------------
521 * The switch flooding table is used for flooding packet replication. The table
522 * defines a bit mask of ports for packet replication.
523 */
524#define MLXSW_REG_SFTR_ID 0x2012
525#define MLXSW_REG_SFTR_LEN 0x420
526
527static const struct mlxsw_reg_info mlxsw_reg_sftr = {
528 .id = MLXSW_REG_SFTR_ID,
529 .len = MLXSW_REG_SFTR_LEN,
530};
531
532/* reg_sftr_swid
533 * Switch partition ID with which to associate the port.
534 * Access: Index
535 */
536MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
537
538/* reg_sftr_flood_table
539 * Flooding table index to associate with the specific type on the specific
540 * switch partition.
541 * Access: Index
542 */
543MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
544
545/* reg_sftr_index
546 * Index. Used as an index into the Flooding Table in case the table is
547 * configured to use VID / FID or FID Offset.
548 * Access: Index
549 */
550MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
551
552/* reg_sftr_table_type
553 * See mlxsw_flood_table_type
554 * Access: RW
555 */
556MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
557
558/* reg_sftr_range
559 * Range of entries to update
560 * Access: Index
561 */
562MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
563
564/* reg_sftr_port
565 * Local port membership (1 bit per port).
566 * Access: RW
567 */
568MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
569
570/* reg_sftr_cpu_port_mask
571 * CPU port mask (1 bit per port).
572 * Access: W
573 */
574MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
575
576static inline void mlxsw_reg_sftr_pack(char *payload,
577 unsigned int flood_table,
578 unsigned int index,
579 enum mlxsw_flood_table_type table_type,
Ido Schimmelbc2055f2015-10-16 14:01:23 +0200580 unsigned int range, u8 port, bool set)
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200581{
582 MLXSW_REG_ZERO(sftr, payload);
583 mlxsw_reg_sftr_swid_set(payload, 0);
584 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
585 mlxsw_reg_sftr_index_set(payload, index);
586 mlxsw_reg_sftr_table_type_set(payload, table_type);
587 mlxsw_reg_sftr_range_set(payload, range);
Ido Schimmelbc2055f2015-10-16 14:01:23 +0200588 mlxsw_reg_sftr_port_set(payload, port, set);
589 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
Ido Schimmel4ec14b72015-07-29 23:33:48 +0200590}
591
592/* SPMLR - Switch Port MAC Learning Register
593 * -----------------------------------------
594 * Controls the Switch MAC learning policy per port.
595 */
596#define MLXSW_REG_SPMLR_ID 0x2018
597#define MLXSW_REG_SPMLR_LEN 0x8
598
599static const struct mlxsw_reg_info mlxsw_reg_spmlr = {
600 .id = MLXSW_REG_SPMLR_ID,
601 .len = MLXSW_REG_SPMLR_LEN,
602};
603
604/* reg_spmlr_local_port
605 * Local port number.
606 * Access: Index
607 */
608MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
609
610/* reg_spmlr_sub_port
611 * Virtual port within the physical port.
612 * Should be set to 0 when virtual ports are not enabled on the port.
613 * Access: Index
614 */
615MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
616
617enum mlxsw_reg_spmlr_learn_mode {
618 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
619 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
620 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
621};
622
623/* reg_spmlr_learn_mode
624 * Learning mode on the port.
625 * 0 - Learning disabled.
626 * 2 - Learning enabled.
627 * 3 - Security mode.
628 *
629 * In security mode the switch does not learn MACs on the port, but uses the
630 * SMAC to see if it exists on another ingress port. If so, the packet is
631 * classified as a bad packet and is discarded unless the software registers
632 * to receive port security error packets usign HPKT.
633 */
634MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
635
636static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
637 enum mlxsw_reg_spmlr_learn_mode mode)
638{
639 MLXSW_REG_ZERO(spmlr, payload);
640 mlxsw_reg_spmlr_local_port_set(payload, local_port);
641 mlxsw_reg_spmlr_sub_port_set(payload, 0);
642 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
643}
644
645/* PMLP - Ports Module to Local Port Register
646 * ------------------------------------------
647 * Configures the assignment of modules to local ports.
648 */
649#define MLXSW_REG_PMLP_ID 0x5002
650#define MLXSW_REG_PMLP_LEN 0x40
651
652static const struct mlxsw_reg_info mlxsw_reg_pmlp = {
653 .id = MLXSW_REG_PMLP_ID,
654 .len = MLXSW_REG_PMLP_LEN,
655};
656
657/* reg_pmlp_rxtx
658 * 0 - Tx value is used for both Tx and Rx.
659 * 1 - Rx value is taken from a separte field.
660 * Access: RW
661 */
662MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
663
664/* reg_pmlp_local_port
665 * Local port number.
666 * Access: Index
667 */
668MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
669
670/* reg_pmlp_width
671 * 0 - Unmap local port.
672 * 1 - Lane 0 is used.
673 * 2 - Lanes 0 and 1 are used.
674 * 4 - Lanes 0, 1, 2 and 3 are used.
675 * Access: RW
676 */
677MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
678
679/* reg_pmlp_module
680 * Module number.
681 * Access: RW
682 */
683MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0, false);
684
685/* reg_pmlp_tx_lane
686 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
687 * Access: RW
688 */
689MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 16, false);
690
691/* reg_pmlp_rx_lane
692 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
693 * equal to Tx lane.
694 * Access: RW
695 */
696MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 24, false);
697
698static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
699{
700 MLXSW_REG_ZERO(pmlp, payload);
701 mlxsw_reg_pmlp_local_port_set(payload, local_port);
702}
703
704/* PMTU - Port MTU Register
705 * ------------------------
706 * Configures and reports the port MTU.
707 */
708#define MLXSW_REG_PMTU_ID 0x5003
709#define MLXSW_REG_PMTU_LEN 0x10
710
711static const struct mlxsw_reg_info mlxsw_reg_pmtu = {
712 .id = MLXSW_REG_PMTU_ID,
713 .len = MLXSW_REG_PMTU_LEN,
714};
715
716/* reg_pmtu_local_port
717 * Local port number.
718 * Access: Index
719 */
720MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
721
722/* reg_pmtu_max_mtu
723 * Maximum MTU.
724 * When port type (e.g. Ethernet) is configured, the relevant MTU is
725 * reported, otherwise the minimum between the max_mtu of the different
726 * types is reported.
727 * Access: RO
728 */
729MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
730
731/* reg_pmtu_admin_mtu
732 * MTU value to set port to. Must be smaller or equal to max_mtu.
733 * Note: If port type is Infiniband, then port must be disabled, when its
734 * MTU is set.
735 * Access: RW
736 */
737MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
738
739/* reg_pmtu_oper_mtu
740 * The actual MTU configured on the port. Packets exceeding this size
741 * will be dropped.
742 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
743 * oper_mtu might be smaller than admin_mtu.
744 * Access: RO
745 */
746MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
747
748static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
749 u16 new_mtu)
750{
751 MLXSW_REG_ZERO(pmtu, payload);
752 mlxsw_reg_pmtu_local_port_set(payload, local_port);
753 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
754 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
755 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
756}
757
758/* PTYS - Port Type and Speed Register
759 * -----------------------------------
760 * Configures and reports the port speed type.
761 *
762 * Note: When set while the link is up, the changes will not take effect
763 * until the port transitions from down to up state.
764 */
765#define MLXSW_REG_PTYS_ID 0x5004
766#define MLXSW_REG_PTYS_LEN 0x40
767
768static const struct mlxsw_reg_info mlxsw_reg_ptys = {
769 .id = MLXSW_REG_PTYS_ID,
770 .len = MLXSW_REG_PTYS_LEN,
771};
772
773/* reg_ptys_local_port
774 * Local port number.
775 * Access: Index
776 */
777MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
778
779#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
780
781/* reg_ptys_proto_mask
782 * Protocol mask. Indicates which protocol is used.
783 * 0 - Infiniband.
784 * 1 - Fibre Channel.
785 * 2 - Ethernet.
786 * Access: Index
787 */
788MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
789
790#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
791#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
792#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
793#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
794#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
795#define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
796#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
797#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
798#define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
799#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
800#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
801#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
802#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
803#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
804#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
805#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
806#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
807#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
808#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
809#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
810#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
811#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
812#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
813#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
814#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
815#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
816#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
817
818/* reg_ptys_eth_proto_cap
819 * Ethernet port supported speeds and protocols.
820 * Access: RO
821 */
822MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
823
824/* reg_ptys_eth_proto_admin
825 * Speed and protocol to set port to.
826 * Access: RW
827 */
828MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
829
830/* reg_ptys_eth_proto_oper
831 * The current speed and protocol configured for the port.
832 * Access: RO
833 */
834MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
835
836static inline void mlxsw_reg_ptys_pack(char *payload, u8 local_port,
837 u32 proto_admin)
838{
839 MLXSW_REG_ZERO(ptys, payload);
840 mlxsw_reg_ptys_local_port_set(payload, local_port);
841 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
842 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
843}
844
845static inline void mlxsw_reg_ptys_unpack(char *payload, u32 *p_eth_proto_cap,
846 u32 *p_eth_proto_adm,
847 u32 *p_eth_proto_oper)
848{
849 if (p_eth_proto_cap)
850 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
851 if (p_eth_proto_adm)
852 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
853 if (p_eth_proto_oper)
854 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
855}
856
857/* PPAD - Port Physical Address Register
858 * -------------------------------------
859 * The PPAD register configures the per port physical MAC address.
860 */
861#define MLXSW_REG_PPAD_ID 0x5005
862#define MLXSW_REG_PPAD_LEN 0x10
863
864static const struct mlxsw_reg_info mlxsw_reg_ppad = {
865 .id = MLXSW_REG_PPAD_ID,
866 .len = MLXSW_REG_PPAD_LEN,
867};
868
869/* reg_ppad_single_base_mac
870 * 0: base_mac, local port should be 0 and mac[7:0] is
871 * reserved. HW will set incremental
872 * 1: single_mac - mac of the local_port
873 * Access: RW
874 */
875MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
876
877/* reg_ppad_local_port
878 * port number, if single_base_mac = 0 then local_port is reserved
879 * Access: RW
880 */
881MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
882
883/* reg_ppad_mac
884 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
885 * If single_base_mac = 1 - the per port MAC address
886 * Access: RW
887 */
888MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
889
890static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
891 u8 local_port)
892{
893 MLXSW_REG_ZERO(ppad, payload);
894 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
895 mlxsw_reg_ppad_local_port_set(payload, local_port);
896}
897
898/* PAOS - Ports Administrative and Operational Status Register
899 * -----------------------------------------------------------
900 * Configures and retrieves per port administrative and operational status.
901 */
902#define MLXSW_REG_PAOS_ID 0x5006
903#define MLXSW_REG_PAOS_LEN 0x10
904
905static const struct mlxsw_reg_info mlxsw_reg_paos = {
906 .id = MLXSW_REG_PAOS_ID,
907 .len = MLXSW_REG_PAOS_LEN,
908};
909
910/* reg_paos_swid
911 * Switch partition ID with which to associate the port.
912 * Note: while external ports uses unique local port numbers (and thus swid is
913 * redundant), router ports use the same local port number where swid is the
914 * only indication for the relevant port.
915 * Access: Index
916 */
917MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
918
919/* reg_paos_local_port
920 * Local port number.
921 * Access: Index
922 */
923MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
924
925/* reg_paos_admin_status
926 * Port administrative state (the desired state of the port):
927 * 1 - Up.
928 * 2 - Down.
929 * 3 - Up once. This means that in case of link failure, the port won't go
930 * into polling mode, but will wait to be re-enabled by software.
931 * 4 - Disabled by system. Can only be set by hardware.
932 * Access: RW
933 */
934MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
935
936/* reg_paos_oper_status
937 * Port operational state (the current state):
938 * 1 - Up.
939 * 2 - Down.
940 * 3 - Down by port failure. This means that the device will not let the
941 * port up again until explicitly specified by software.
942 * Access: RO
943 */
944MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
945
946/* reg_paos_ase
947 * Admin state update enabled.
948 * Access: WO
949 */
950MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
951
952/* reg_paos_ee
953 * Event update enable. If this bit is set, event generation will be
954 * updated based on the e field.
955 * Access: WO
956 */
957MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
958
959/* reg_paos_e
960 * Event generation on operational state change:
961 * 0 - Do not generate event.
962 * 1 - Generate Event.
963 * 2 - Generate Single Event.
964 * Access: RW
965 */
966MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
967
968static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
969 enum mlxsw_port_admin_status status)
970{
971 MLXSW_REG_ZERO(paos, payload);
972 mlxsw_reg_paos_swid_set(payload, 0);
973 mlxsw_reg_paos_local_port_set(payload, local_port);
974 mlxsw_reg_paos_admin_status_set(payload, status);
975 mlxsw_reg_paos_oper_status_set(payload, 0);
976 mlxsw_reg_paos_ase_set(payload, 1);
977 mlxsw_reg_paos_ee_set(payload, 1);
978 mlxsw_reg_paos_e_set(payload, 1);
979}
980
981/* PPCNT - Ports Performance Counters Register
982 * -------------------------------------------
983 * The PPCNT register retrieves per port performance counters.
984 */
985#define MLXSW_REG_PPCNT_ID 0x5008
986#define MLXSW_REG_PPCNT_LEN 0x100
987
988static const struct mlxsw_reg_info mlxsw_reg_ppcnt = {
989 .id = MLXSW_REG_PPCNT_ID,
990 .len = MLXSW_REG_PPCNT_LEN,
991};
992
993/* reg_ppcnt_swid
994 * For HCA: must be always 0.
995 * Switch partition ID to associate port with.
996 * Switch partitions are numbered from 0 to 7 inclusively.
997 * Switch partition 254 indicates stacking ports.
998 * Switch partition 255 indicates all switch partitions.
999 * Only valid on Set() operation with local_port=255.
1000 * Access: Index
1001 */
1002MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
1003
1004/* reg_ppcnt_local_port
1005 * Local port number.
1006 * 255 indicates all ports on the device, and is only allowed
1007 * for Set() operation.
1008 * Access: Index
1009 */
1010MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
1011
1012/* reg_ppcnt_pnat
1013 * Port number access type:
1014 * 0 - Local port number
1015 * 1 - IB port number
1016 * Access: Index
1017 */
1018MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
1019
1020/* reg_ppcnt_grp
1021 * Performance counter group.
1022 * Group 63 indicates all groups. Only valid on Set() operation with
1023 * clr bit set.
1024 * 0x0: IEEE 802.3 Counters
1025 * 0x1: RFC 2863 Counters
1026 * 0x2: RFC 2819 Counters
1027 * 0x3: RFC 3635 Counters
1028 * 0x5: Ethernet Extended Counters
1029 * 0x8: Link Level Retransmission Counters
1030 * 0x10: Per Priority Counters
1031 * 0x11: Per Traffic Class Counters
1032 * 0x12: Physical Layer Counters
1033 * Access: Index
1034 */
1035MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
1036
1037/* reg_ppcnt_clr
1038 * Clear counters. Setting the clr bit will reset the counter value
1039 * for all counters in the counter group. This bit can be set
1040 * for both Set() and Get() operation.
1041 * Access: OP
1042 */
1043MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
1044
1045/* reg_ppcnt_prio_tc
1046 * Priority for counter set that support per priority, valid values: 0-7.
1047 * Traffic class for counter set that support per traffic class,
1048 * valid values: 0- cap_max_tclass-1 .
1049 * For HCA: cap_max_tclass is always 8.
1050 * Otherwise must be 0.
1051 * Access: Index
1052 */
1053MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
1054
1055/* reg_ppcnt_a_frames_transmitted_ok
1056 * Access: RO
1057 */
1058MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
1059 0x08 + 0x00, 0, 64);
1060
1061/* reg_ppcnt_a_frames_received_ok
1062 * Access: RO
1063 */
1064MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
1065 0x08 + 0x08, 0, 64);
1066
1067/* reg_ppcnt_a_frame_check_sequence_errors
1068 * Access: RO
1069 */
1070MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
1071 0x08 + 0x10, 0, 64);
1072
1073/* reg_ppcnt_a_alignment_errors
1074 * Access: RO
1075 */
1076MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
1077 0x08 + 0x18, 0, 64);
1078
1079/* reg_ppcnt_a_octets_transmitted_ok
1080 * Access: RO
1081 */
1082MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
1083 0x08 + 0x20, 0, 64);
1084
1085/* reg_ppcnt_a_octets_received_ok
1086 * Access: RO
1087 */
1088MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
1089 0x08 + 0x28, 0, 64);
1090
1091/* reg_ppcnt_a_multicast_frames_xmitted_ok
1092 * Access: RO
1093 */
1094MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
1095 0x08 + 0x30, 0, 64);
1096
1097/* reg_ppcnt_a_broadcast_frames_xmitted_ok
1098 * Access: RO
1099 */
1100MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
1101 0x08 + 0x38, 0, 64);
1102
1103/* reg_ppcnt_a_multicast_frames_received_ok
1104 * Access: RO
1105 */
1106MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
1107 0x08 + 0x40, 0, 64);
1108
1109/* reg_ppcnt_a_broadcast_frames_received_ok
1110 * Access: RO
1111 */
1112MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
1113 0x08 + 0x48, 0, 64);
1114
1115/* reg_ppcnt_a_in_range_length_errors
1116 * Access: RO
1117 */
1118MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
1119 0x08 + 0x50, 0, 64);
1120
1121/* reg_ppcnt_a_out_of_range_length_field
1122 * Access: RO
1123 */
1124MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
1125 0x08 + 0x58, 0, 64);
1126
1127/* reg_ppcnt_a_frame_too_long_errors
1128 * Access: RO
1129 */
1130MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
1131 0x08 + 0x60, 0, 64);
1132
1133/* reg_ppcnt_a_symbol_error_during_carrier
1134 * Access: RO
1135 */
1136MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
1137 0x08 + 0x68, 0, 64);
1138
1139/* reg_ppcnt_a_mac_control_frames_transmitted
1140 * Access: RO
1141 */
1142MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
1143 0x08 + 0x70, 0, 64);
1144
1145/* reg_ppcnt_a_mac_control_frames_received
1146 * Access: RO
1147 */
1148MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
1149 0x08 + 0x78, 0, 64);
1150
1151/* reg_ppcnt_a_unsupported_opcodes_received
1152 * Access: RO
1153 */
1154MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
1155 0x08 + 0x80, 0, 64);
1156
1157/* reg_ppcnt_a_pause_mac_ctrl_frames_received
1158 * Access: RO
1159 */
1160MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
1161 0x08 + 0x88, 0, 64);
1162
1163/* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
1164 * Access: RO
1165 */
1166MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
1167 0x08 + 0x90, 0, 64);
1168
1169static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port)
1170{
1171 MLXSW_REG_ZERO(ppcnt, payload);
1172 mlxsw_reg_ppcnt_swid_set(payload, 0);
1173 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
1174 mlxsw_reg_ppcnt_pnat_set(payload, 0);
1175 mlxsw_reg_ppcnt_grp_set(payload, 0);
1176 mlxsw_reg_ppcnt_clr_set(payload, 0);
1177 mlxsw_reg_ppcnt_prio_tc_set(payload, 0);
1178}
1179
1180/* PSPA - Port Switch Partition Allocation
1181 * ---------------------------------------
1182 * Controls the association of a port with a switch partition and enables
1183 * configuring ports as stacking ports.
1184 */
Jiri Pirko3f0effd2015-10-15 17:43:23 +02001185#define MLXSW_REG_PSPA_ID 0x500D
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001186#define MLXSW_REG_PSPA_LEN 0x8
1187
1188static const struct mlxsw_reg_info mlxsw_reg_pspa = {
1189 .id = MLXSW_REG_PSPA_ID,
1190 .len = MLXSW_REG_PSPA_LEN,
1191};
1192
1193/* reg_pspa_swid
1194 * Switch partition ID.
1195 * Access: RW
1196 */
1197MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
1198
1199/* reg_pspa_local_port
1200 * Local port number.
1201 * Access: Index
1202 */
1203MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
1204
1205/* reg_pspa_sub_port
1206 * Virtual port within the local port. Set to 0 when virtual ports are
1207 * disabled on the local port.
1208 * Access: Index
1209 */
1210MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
1211
1212static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
1213{
1214 MLXSW_REG_ZERO(pspa, payload);
1215 mlxsw_reg_pspa_swid_set(payload, swid);
1216 mlxsw_reg_pspa_local_port_set(payload, local_port);
1217 mlxsw_reg_pspa_sub_port_set(payload, 0);
1218}
1219
1220/* HTGT - Host Trap Group Table
1221 * ----------------------------
1222 * Configures the properties for forwarding to CPU.
1223 */
1224#define MLXSW_REG_HTGT_ID 0x7002
1225#define MLXSW_REG_HTGT_LEN 0x100
1226
1227static const struct mlxsw_reg_info mlxsw_reg_htgt = {
1228 .id = MLXSW_REG_HTGT_ID,
1229 .len = MLXSW_REG_HTGT_LEN,
1230};
1231
1232/* reg_htgt_swid
1233 * Switch partition ID.
1234 * Access: Index
1235 */
1236MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
1237
1238#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
1239
1240/* reg_htgt_type
1241 * CPU path type.
1242 * Access: RW
1243 */
1244MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
1245
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001246enum mlxsw_reg_htgt_trap_group {
1247 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
1248 MLXSW_REG_HTGT_TRAP_GROUP_RX,
1249 MLXSW_REG_HTGT_TRAP_GROUP_CTRL,
1250};
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001251
1252/* reg_htgt_trap_group
1253 * Trap group number. User defined number specifying which trap groups
1254 * should be forwarded to the CPU. The mapping between trap IDs and trap
1255 * groups is configured using HPKT register.
1256 * Access: Index
1257 */
1258MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
1259
1260enum {
1261 MLXSW_REG_HTGT_POLICER_DISABLE,
1262 MLXSW_REG_HTGT_POLICER_ENABLE,
1263};
1264
1265/* reg_htgt_pide
1266 * Enable policer ID specified using 'pid' field.
1267 * Access: RW
1268 */
1269MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
1270
1271/* reg_htgt_pid
1272 * Policer ID for the trap group.
1273 * Access: RW
1274 */
1275MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
1276
1277#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
1278
1279/* reg_htgt_mirror_action
1280 * Mirror action to use.
1281 * 0 - Trap to CPU.
1282 * 1 - Trap to CPU and mirror to a mirroring agent.
1283 * 2 - Mirror to a mirroring agent and do not trap to CPU.
1284 * Access: RW
1285 *
1286 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
1287 */
1288MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
1289
1290/* reg_htgt_mirroring_agent
1291 * Mirroring agent.
1292 * Access: RW
1293 */
1294MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
1295
1296/* reg_htgt_priority
1297 * Trap group priority.
1298 * In case a packet matches multiple classification rules, the packet will
1299 * only be trapped once, based on the trap ID associated with the group (via
1300 * register HPKT) with the highest priority.
1301 * Supported values are 0-7, with 7 represnting the highest priority.
1302 * Access: RW
1303 *
1304 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
1305 * by the 'trap_group' field.
1306 */
1307MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
1308
1309/* reg_htgt_local_path_cpu_tclass
1310 * CPU ingress traffic class for the trap group.
1311 * Access: RW
1312 */
1313MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
1314
1315#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD 0x15
1316#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX 0x14
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001317#define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL 0x13
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001318
1319/* reg_htgt_local_path_rdq
1320 * Receive descriptor queue (RDQ) to use for the trap group.
1321 * Access: RW
1322 */
1323MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
1324
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001325static inline void mlxsw_reg_htgt_pack(char *payload,
1326 enum mlxsw_reg_htgt_trap_group group)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001327{
1328 u8 swid, rdq;
1329
1330 MLXSW_REG_ZERO(htgt, payload);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001331 switch (group) {
1332 case MLXSW_REG_HTGT_TRAP_GROUP_EMAD:
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001333 swid = MLXSW_PORT_SWID_ALL_SWIDS;
1334 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD;
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001335 break;
1336 case MLXSW_REG_HTGT_TRAP_GROUP_RX:
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001337 swid = 0;
1338 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX;
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001339 break;
1340 case MLXSW_REG_HTGT_TRAP_GROUP_CTRL:
1341 swid = 0;
1342 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL;
1343 break;
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001344 }
1345 mlxsw_reg_htgt_swid_set(payload, swid);
1346 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001347 mlxsw_reg_htgt_trap_group_set(payload, group);
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001348 mlxsw_reg_htgt_pide_set(payload, MLXSW_REG_HTGT_POLICER_DISABLE);
1349 mlxsw_reg_htgt_pid_set(payload, 0);
1350 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
1351 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
1352 mlxsw_reg_htgt_priority_set(payload, 0);
1353 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, 7);
1354 mlxsw_reg_htgt_local_path_rdq_set(payload, rdq);
1355}
1356
1357/* HPKT - Host Packet Trap
1358 * -----------------------
1359 * Configures trap IDs inside trap groups.
1360 */
1361#define MLXSW_REG_HPKT_ID 0x7003
1362#define MLXSW_REG_HPKT_LEN 0x10
1363
1364static const struct mlxsw_reg_info mlxsw_reg_hpkt = {
1365 .id = MLXSW_REG_HPKT_ID,
1366 .len = MLXSW_REG_HPKT_LEN,
1367};
1368
1369enum {
1370 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
1371 MLXSW_REG_HPKT_ACK_REQUIRED,
1372};
1373
1374/* reg_hpkt_ack
1375 * Require acknowledgements from the host for events.
1376 * If set, then the device will wait for the event it sent to be acknowledged
1377 * by the host. This option is only relevant for event trap IDs.
1378 * Access: RW
1379 *
1380 * Note: Currently not supported by firmware.
1381 */
1382MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
1383
1384enum mlxsw_reg_hpkt_action {
1385 MLXSW_REG_HPKT_ACTION_FORWARD,
1386 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
1387 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
1388 MLXSW_REG_HPKT_ACTION_DISCARD,
1389 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
1390 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
1391};
1392
1393/* reg_hpkt_action
1394 * Action to perform on packet when trapped.
1395 * 0 - No action. Forward to CPU based on switching rules.
1396 * 1 - Trap to CPU (CPU receives sole copy).
1397 * 2 - Mirror to CPU (CPU receives a replica of the packet).
1398 * 3 - Discard.
1399 * 4 - Soft discard (allow other traps to act on the packet).
1400 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
1401 * Access: RW
1402 *
1403 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
1404 * addressed to the CPU.
1405 */
1406MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
1407
1408/* reg_hpkt_trap_group
1409 * Trap group to associate the trap with.
1410 * Access: RW
1411 */
1412MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
1413
1414/* reg_hpkt_trap_id
1415 * Trap ID.
1416 * Access: Index
1417 *
1418 * Note: A trap ID can only be associated with a single trap group. The device
1419 * will associate the trap ID with the last trap group configured.
1420 */
1421MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
1422
1423enum {
1424 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
1425 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
1426 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
1427};
1428
1429/* reg_hpkt_ctrl
1430 * Configure dedicated buffer resources for control packets.
1431 * 0 - Keep factory defaults.
1432 * 1 - Do not use control buffer for this trap ID.
1433 * 2 - Use control buffer for this trap ID.
1434 * Access: RW
1435 */
1436MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
1437
Ido Schimmelf24af332015-10-15 17:43:27 +02001438static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id)
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001439{
Ido Schimmel801bd3d2015-10-15 17:43:28 +02001440 enum mlxsw_reg_htgt_trap_group trap_group;
Ido Schimmelf24af332015-10-15 17:43:27 +02001441
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001442 MLXSW_REG_ZERO(hpkt, payload);
1443 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
1444 mlxsw_reg_hpkt_action_set(payload, action);
Ido Schimmelf24af332015-10-15 17:43:27 +02001445 switch (trap_id) {
1446 case MLXSW_TRAP_ID_ETHEMAD:
1447 case MLXSW_TRAP_ID_PUDE:
1448 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_EMAD;
1449 break;
1450 default:
1451 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_RX;
1452 break;
1453 }
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001454 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
1455 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
1456 mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT);
1457}
1458
1459static inline const char *mlxsw_reg_id_str(u16 reg_id)
1460{
1461 switch (reg_id) {
1462 case MLXSW_REG_SGCR_ID:
1463 return "SGCR";
1464 case MLXSW_REG_SPAD_ID:
1465 return "SPAD";
Ido Schimmele61011b2015-08-06 16:41:53 +02001466 case MLXSW_REG_SSPR_ID:
1467 return "SSPR";
Jiri Pirko236033b2015-10-16 14:01:28 +02001468 case MLXSW_REG_SFD_ID:
1469 return "SFD";
Ido Schimmel4ec14b72015-07-29 23:33:48 +02001470 case MLXSW_REG_SPMS_ID:
1471 return "SPMS";
1472 case MLXSW_REG_SFGC_ID:
1473 return "SFGC";
1474 case MLXSW_REG_SFTR_ID:
1475 return "SFTR";
1476 case MLXSW_REG_SPMLR_ID:
1477 return "SPMLR";
1478 case MLXSW_REG_PMLP_ID:
1479 return "PMLP";
1480 case MLXSW_REG_PMTU_ID:
1481 return "PMTU";
1482 case MLXSW_REG_PTYS_ID:
1483 return "PTYS";
1484 case MLXSW_REG_PPAD_ID:
1485 return "PPAD";
1486 case MLXSW_REG_PAOS_ID:
1487 return "PAOS";
1488 case MLXSW_REG_PPCNT_ID:
1489 return "PPCNT";
1490 case MLXSW_REG_PSPA_ID:
1491 return "PSPA";
1492 case MLXSW_REG_HTGT_ID:
1493 return "HTGT";
1494 case MLXSW_REG_HPKT_ID:
1495 return "HPKT";
1496 default:
1497 return "*UNKNOWN*";
1498 }
1499}
1500
1501/* PUDE - Port Up / Down Event
1502 * ---------------------------
1503 * Reports the operational state change of a port.
1504 */
1505#define MLXSW_REG_PUDE_LEN 0x10
1506
1507/* reg_pude_swid
1508 * Switch partition ID with which to associate the port.
1509 * Access: Index
1510 */
1511MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
1512
1513/* reg_pude_local_port
1514 * Local port number.
1515 * Access: Index
1516 */
1517MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
1518
1519/* reg_pude_admin_status
1520 * Port administrative state (the desired state).
1521 * 1 - Up.
1522 * 2 - Down.
1523 * 3 - Up once. This means that in case of link failure, the port won't go
1524 * into polling mode, but will wait to be re-enabled by software.
1525 * 4 - Disabled by system. Can only be set by hardware.
1526 * Access: RO
1527 */
1528MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
1529
1530/* reg_pude_oper_status
1531 * Port operatioanl state.
1532 * 1 - Up.
1533 * 2 - Down.
1534 * 3 - Down by port failure. This means that the device will not let the
1535 * port up again until explicitly specified by software.
1536 * Access: RO
1537 */
1538MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
1539
1540#endif