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>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
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.
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.
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.
40 #include <linux/string.h>
41 #include <linux/bitops.h>
42 #include <linux/if_vlan.h>
47 struct mlxsw_reg_info {
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)
56 /* SGCR - Switch General Configuration Register
57 * --------------------------------------------
58 * This register is used for configuration of the switch capabilities.
60 #define MLXSW_REG_SGCR_ID 0x2000
61 #define MLXSW_REG_SGCR_LEN 0x10
63 static const struct mlxsw_reg_info mlxsw_reg_sgcr = {
64 .id = MLXSW_REG_SGCR_ID,
65 .len = MLXSW_REG_SGCR_LEN,
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.
74 MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
76 static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
78 MLXSW_REG_ZERO(sgcr, payload);
79 mlxsw_reg_sgcr_llb_set(payload, !!llb);
82 /* SPAD - Switch Physical Address Register
83 * ---------------------------------------
84 * The SPAD register configures the switch physical MAC address.
86 #define MLXSW_REG_SPAD_ID 0x2002
87 #define MLXSW_REG_SPAD_LEN 0x10
89 static const struct mlxsw_reg_info mlxsw_reg_spad = {
90 .id = MLXSW_REG_SPAD_ID,
91 .len = MLXSW_REG_SPAD_LEN,
95 * Base MAC address for the switch partitions.
96 * Per switch partition MAC address is equal to:
100 MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
102 /* SSPR - Switch System Port Record Register
103 * -----------------------------------------
104 * Configures the system port to local port mapping.
106 #define MLXSW_REG_SSPR_ID 0x2008
107 #define MLXSW_REG_SSPR_LEN 0x8
109 static const struct mlxsw_reg_info mlxsw_reg_sspr = {
110 .id = MLXSW_REG_SSPR_ID,
111 .len = MLXSW_REG_SSPR_LEN,
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
121 * Note: Must be set for Spectrum.
124 MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
126 /* reg_sspr_local_port
131 MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
134 * Virtual port within the physical port.
135 * Should be set to 0 when virtual ports are not enabled on the port.
139 MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
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).
145 * Currently, only single-ASIC configurations are supported, so we default to
146 * 1:1 mapping between system ports and local ports.
149 MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
151 static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
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);
160 /* 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.
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)
174 static const struct mlxsw_reg_info mlxsw_reg_sfd = {
175 .id = MLXSW_REG_SFD_ID,
176 .len = MLXSW_REG_SFD_LEN,
180 * Switch partition ID for queries. Reserved on Write.
183 MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
185 enum 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
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.
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.
206 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
207 /* Remove learned notification by {MAC, VID/FID}. The response provides
208 * the removed learning notification.
210 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
217 MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
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.
226 MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
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.
235 MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
237 static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
240 MLXSW_REG_ZERO(sfd, payload);
241 mlxsw_reg_sfd_op_set(payload, op);
242 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
246 * Switch partition ID.
249 MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
250 MLXSW_REG_SFD_REC_LEN, 0x00, false);
252 enum mlxsw_reg_sfd_rec_type {
253 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
260 MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
261 MLXSW_REG_SFD_REC_LEN, 0x00, false);
263 enum 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.
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,
274 /* reg_sfd_rec_policy
278 MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
279 MLXSW_REG_SFD_REC_LEN, 0x00, false);
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.
287 MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
288 MLXSW_REG_SFD_REC_LEN, 0x00, false);
294 MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
295 MLXSW_REG_SFD_REC_LEN, 0x02);
297 enum mlxsw_reg_sfd_rec_action {
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,
307 /* reg_sfd_rec_action
308 * Action to apply on the packet.
309 * Note: Dynamic entries can only be configured with NOP action.
312 MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
313 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
315 /* reg_sfd_uc_sub_port
317 * Must be 0 if multichannel VEPA is not enabled.
320 MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
321 MLXSW_REG_SFD_REC_LEN, 0x08, false);
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.
333 MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
334 MLXSW_REG_SFD_REC_LEN, 0x08, false);
336 /* reg_sfd_uc_system_port
337 * Unique port identifier for the final destination of the packet.
340 MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
341 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
343 static 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,
349 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
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);
365 mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
366 char *mac, u16 *p_vid,
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);
374 /* SFN - Switch FDB Notification Register
375 * -------------------------------------------
376 * The switch provides notifications on newly learned FDB entries and
377 * aged out entries. The notifications can be polled by software.
379 #define MLXSW_REG_SFN_ID 0x200B
380 #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
381 #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
382 #define MLXSW_REG_SFN_REC_MAX_COUNT 64
383 #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
384 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
386 static const struct mlxsw_reg_info mlxsw_reg_sfn = {
387 .id = MLXSW_REG_SFN_ID,
388 .len = MLXSW_REG_SFN_LEN,
392 * Switch partition ID.
395 MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
398 * Request: Number of learned notifications and aged-out notification
400 * Response: Number of notification records returned (must be smaller
401 * than or equal to the value requested)
405 MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
407 static inline void mlxsw_reg_sfn_pack(char *payload)
409 MLXSW_REG_ZERO(sfn, payload);
410 mlxsw_reg_sfn_swid_set(payload, 0);
411 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
415 * Switch partition ID.
418 MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
419 MLXSW_REG_SFN_REC_LEN, 0x00, false);
421 enum mlxsw_reg_sfn_rec_type {
422 /* MAC addresses learned on a regular port. */
423 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
424 /* Aged-out MAC address on a regular port */
425 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
429 * Notification record type.
432 MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
433 MLXSW_REG_SFN_REC_LEN, 0x00, false);
439 MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
440 MLXSW_REG_SFN_REC_LEN, 0x02);
442 /* reg_sfd_mac_sub_port
443 * VEPA channel on the local port.
444 * 0 if multichannel VEPA is not enabled.
447 MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
448 MLXSW_REG_SFN_REC_LEN, 0x08, false);
451 * Filtering identifier.
454 MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
455 MLXSW_REG_SFN_REC_LEN, 0x08, false);
457 /* reg_sfd_mac_system_port
458 * Unique port identifier for the final destination of the packet.
461 MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
462 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
464 static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
465 char *mac, u16 *p_vid,
468 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
469 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
470 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
473 /* SPMS - Switch Port MSTP/RSTP State Register
474 * -------------------------------------------
475 * Configures the spanning tree state of a physical port.
477 #define MLXSW_REG_SPMS_ID 0x200D
478 #define MLXSW_REG_SPMS_LEN 0x404
480 static const struct mlxsw_reg_info mlxsw_reg_spms = {
481 .id = MLXSW_REG_SPMS_ID,
482 .len = MLXSW_REG_SPMS_LEN,
485 /* reg_spms_local_port
489 MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
491 enum mlxsw_reg_spms_state {
492 MLXSW_REG_SPMS_STATE_NO_CHANGE,
493 MLXSW_REG_SPMS_STATE_DISCARDING,
494 MLXSW_REG_SPMS_STATE_LEARNING,
495 MLXSW_REG_SPMS_STATE_FORWARDING,
499 * Spanning tree state of each VLAN ID (VID) of the local port.
500 * 0 - Do not change spanning tree state (used only when writing).
501 * 1 - Discarding. No learning or forwarding to/from this port (default).
502 * 2 - Learning. Port is learning, but not forwarding.
503 * 3 - Forwarding. Port is learning and forwarding.
506 MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
508 static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
510 MLXSW_REG_ZERO(spms, payload);
511 mlxsw_reg_spms_local_port_set(payload, local_port);
514 static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
515 enum mlxsw_reg_spms_state state)
517 mlxsw_reg_spms_state_set(payload, vid, state);
520 /* SPVID - Switch Port VID
521 * -----------------------
522 * The switch port VID configures the default VID for a port.
524 #define MLXSW_REG_SPVID_ID 0x200E
525 #define MLXSW_REG_SPVID_LEN 0x08
527 static const struct mlxsw_reg_info mlxsw_reg_spvid = {
528 .id = MLXSW_REG_SPVID_ID,
529 .len = MLXSW_REG_SPVID_LEN,
532 /* reg_spvid_local_port
536 MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
538 /* reg_spvid_sub_port
539 * Virtual port within the physical port.
540 * Should be set to 0 when virtual ports are not enabled on the port.
543 MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
549 MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
551 static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
553 MLXSW_REG_ZERO(spvid, payload);
554 mlxsw_reg_spvid_local_port_set(payload, local_port);
555 mlxsw_reg_spvid_pvid_set(payload, pvid);
558 /* SPVM - Switch Port VLAN Membership
559 * ----------------------------------
560 * The Switch Port VLAN Membership register configures the VLAN membership
561 * of a port in a VLAN denoted by VID. VLAN membership is managed per
562 * virtual port. The register can be used to add and remove VID(s) from a port.
564 #define MLXSW_REG_SPVM_ID 0x200F
565 #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
566 #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
567 #define MLXSW_REG_SPVM_REC_MAX_COUNT 256
568 #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
569 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
571 static const struct mlxsw_reg_info mlxsw_reg_spvm = {
572 .id = MLXSW_REG_SPVM_ID,
573 .len = MLXSW_REG_SPVM_LEN,
577 * Priority tagged. If this bit is set, packets forwarded to the port with
578 * untagged VLAN membership (u bit is set) will be tagged with priority tag
582 MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
585 * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
586 * the pt bit will NOT be updated. To update the pt bit, pte must be set.
589 MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
591 /* reg_spvm_local_port
595 MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
598 * Virtual port within the physical port.
599 * Should be set to 0 when virtual ports are not enabled on the port.
602 MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
605 * Number of records to update. Each record contains: i, e, u, vid.
608 MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
611 * Ingress membership in VLAN ID.
614 MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
615 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
616 MLXSW_REG_SPVM_REC_LEN, 0, false);
619 * Egress membership in VLAN ID.
622 MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
623 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
624 MLXSW_REG_SPVM_REC_LEN, 0, false);
627 * Untagged - port is an untagged member - egress transmission uses untagged
631 MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
632 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
633 MLXSW_REG_SPVM_REC_LEN, 0, false);
636 * Egress membership in VLAN ID.
639 MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
640 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
641 MLXSW_REG_SPVM_REC_LEN, 0, false);
643 static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
644 u16 vid_begin, u16 vid_end,
645 bool is_member, bool untagged)
647 int size = vid_end - vid_begin + 1;
650 MLXSW_REG_ZERO(spvm, payload);
651 mlxsw_reg_spvm_local_port_set(payload, local_port);
652 mlxsw_reg_spvm_num_rec_set(payload, size);
654 for (i = 0; i < size; i++) {
655 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
656 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
657 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
658 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
662 /* SFGC - Switch Flooding Group Configuration
663 * ------------------------------------------
664 * The following register controls the association of flooding tables and MIDs
665 * to packet types used for flooding.
667 #define MLXSW_REG_SFGC_ID 0x2011
668 #define MLXSW_REG_SFGC_LEN 0x10
670 static const struct mlxsw_reg_info mlxsw_reg_sfgc = {
671 .id = MLXSW_REG_SFGC_ID,
672 .len = MLXSW_REG_SFGC_LEN,
675 enum mlxsw_reg_sfgc_type {
676 MLXSW_REG_SFGC_TYPE_BROADCAST,
677 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
678 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
679 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
680 MLXSW_REG_SFGC_TYPE_RESERVED,
681 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
682 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
683 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
684 MLXSW_REG_SFGC_TYPE_MAX,
688 * The traffic type to reach the flooding table.
691 MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
693 enum mlxsw_reg_sfgc_bridge_type {
694 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
695 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
698 /* reg_sfgc_bridge_type
701 * Note: SwitchX-2 only supports 802.1Q mode.
703 MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
705 enum mlxsw_flood_table_type {
706 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
707 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
708 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
709 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3,
710 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
713 /* reg_sfgc_table_type
714 * See mlxsw_flood_table_type
717 * Note: FID offset and FID types are not supported in SwitchX-2.
719 MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
721 /* reg_sfgc_flood_table
722 * Flooding table index to associate with the specific type on the specific
726 MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
729 * The multicast ID for the swid. Not supported for Spectrum
732 MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
734 /* reg_sfgc_counter_set_type
735 * Counter Set Type for flow counters.
738 MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
740 /* reg_sfgc_counter_index
741 * Counter Index for flow counters.
744 MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
747 mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
748 enum mlxsw_reg_sfgc_bridge_type bridge_type,
749 enum mlxsw_flood_table_type table_type,
750 unsigned int flood_table)
752 MLXSW_REG_ZERO(sfgc, payload);
753 mlxsw_reg_sfgc_type_set(payload, type);
754 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
755 mlxsw_reg_sfgc_table_type_set(payload, table_type);
756 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
757 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
760 /* SFTR - Switch Flooding Table Register
761 * -------------------------------------
762 * The switch flooding table is used for flooding packet replication. The table
763 * defines a bit mask of ports for packet replication.
765 #define MLXSW_REG_SFTR_ID 0x2012
766 #define MLXSW_REG_SFTR_LEN 0x420
768 static const struct mlxsw_reg_info mlxsw_reg_sftr = {
769 .id = MLXSW_REG_SFTR_ID,
770 .len = MLXSW_REG_SFTR_LEN,
774 * Switch partition ID with which to associate the port.
777 MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
779 /* reg_sftr_flood_table
780 * Flooding table index to associate with the specific type on the specific
784 MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
787 * Index. Used as an index into the Flooding Table in case the table is
788 * configured to use VID / FID or FID Offset.
791 MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
793 /* reg_sftr_table_type
794 * See mlxsw_flood_table_type
797 MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
800 * Range of entries to update
803 MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
806 * Local port membership (1 bit per port).
809 MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
811 /* reg_sftr_cpu_port_mask
812 * CPU port mask (1 bit per port).
815 MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
817 static inline void mlxsw_reg_sftr_pack(char *payload,
818 unsigned int flood_table,
820 enum mlxsw_flood_table_type table_type,
821 unsigned int range, u8 port, bool set)
823 MLXSW_REG_ZERO(sftr, payload);
824 mlxsw_reg_sftr_swid_set(payload, 0);
825 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
826 mlxsw_reg_sftr_index_set(payload, index);
827 mlxsw_reg_sftr_table_type_set(payload, table_type);
828 mlxsw_reg_sftr_range_set(payload, range);
829 mlxsw_reg_sftr_port_set(payload, port, set);
830 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
833 /* SPMLR - Switch Port MAC Learning Register
834 * -----------------------------------------
835 * Controls the Switch MAC learning policy per port.
837 #define MLXSW_REG_SPMLR_ID 0x2018
838 #define MLXSW_REG_SPMLR_LEN 0x8
840 static const struct mlxsw_reg_info mlxsw_reg_spmlr = {
841 .id = MLXSW_REG_SPMLR_ID,
842 .len = MLXSW_REG_SPMLR_LEN,
845 /* reg_spmlr_local_port
849 MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
851 /* reg_spmlr_sub_port
852 * Virtual port within the physical port.
853 * Should be set to 0 when virtual ports are not enabled on the port.
856 MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
858 enum mlxsw_reg_spmlr_learn_mode {
859 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
860 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
861 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
864 /* reg_spmlr_learn_mode
865 * Learning mode on the port.
866 * 0 - Learning disabled.
867 * 2 - Learning enabled.
870 * In security mode the switch does not learn MACs on the port, but uses the
871 * SMAC to see if it exists on another ingress port. If so, the packet is
872 * classified as a bad packet and is discarded unless the software registers
873 * to receive port security error packets usign HPKT.
875 MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
877 static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
878 enum mlxsw_reg_spmlr_learn_mode mode)
880 MLXSW_REG_ZERO(spmlr, payload);
881 mlxsw_reg_spmlr_local_port_set(payload, local_port);
882 mlxsw_reg_spmlr_sub_port_set(payload, 0);
883 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
886 /* SVFA - Switch VID to FID Allocation Register
887 * --------------------------------------------
888 * Controls the VID to FID mapping and {Port, VID} to FID mapping for
891 #define MLXSW_REG_SVFA_ID 0x201C
892 #define MLXSW_REG_SVFA_LEN 0x10
894 static const struct mlxsw_reg_info mlxsw_reg_svfa = {
895 .id = MLXSW_REG_SVFA_ID,
896 .len = MLXSW_REG_SVFA_LEN,
900 * Switch partition ID.
903 MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
905 /* reg_svfa_local_port
909 * Note: Reserved for 802.1Q FIDs.
911 MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
913 enum mlxsw_reg_svfa_mt {
914 MLXSW_REG_SVFA_MT_VID_TO_FID,
915 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
918 /* reg_svfa_mapping_table
921 * 1 - {Port, VID} to FID
924 * Note: Reserved for SwitchX-2.
926 MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
933 * Note: Reserved for SwitchX-2.
935 MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
941 MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
947 MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
949 /* reg_svfa_counter_set_type
950 * Counter set type for flow counters.
953 * Note: Reserved for SwitchX-2.
955 MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
957 /* reg_svfa_counter_index
958 * Counter index for flow counters.
961 * Note: Reserved for SwitchX-2.
963 MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
965 static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
966 enum mlxsw_reg_svfa_mt mt, bool valid,
969 MLXSW_REG_ZERO(svfa, payload);
970 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
971 mlxsw_reg_svfa_swid_set(payload, 0);
972 mlxsw_reg_svfa_local_port_set(payload, local_port);
973 mlxsw_reg_svfa_mapping_table_set(payload, mt);
974 mlxsw_reg_svfa_v_set(payload, valid);
975 mlxsw_reg_svfa_fid_set(payload, fid);
976 mlxsw_reg_svfa_vid_set(payload, vid);
979 /* SFMR - Switch FID Management Register
980 * -------------------------------------
981 * Creates and configures FIDs.
983 #define MLXSW_REG_SFMR_ID 0x201F
984 #define MLXSW_REG_SFMR_LEN 0x18
986 static const struct mlxsw_reg_info mlxsw_reg_sfmr = {
987 .id = MLXSW_REG_SFMR_ID,
988 .len = MLXSW_REG_SFMR_LEN,
991 enum mlxsw_reg_sfmr_op {
992 MLXSW_REG_SFMR_OP_CREATE_FID,
993 MLXSW_REG_SFMR_OP_DESTROY_FID,
998 * 0 - Create or edit FID.
1002 MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1008 MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1010 /* reg_sfmr_fid_offset
1012 * Used to point into the flooding table selected by SFGC register if
1013 * the table is of type FID-Offset. Otherwise, this field is reserved.
1016 MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1019 * Valid Tunnel Flood Pointer.
1020 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
1023 * Note: Reserved for 802.1Q FIDs.
1025 MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1027 /* reg_sfmr_nve_tunnel_flood_ptr
1028 * Underlay Flooding and BC Pointer.
1029 * Used as a pointer to the first entry of the group based link lists of
1030 * flooding or BC entries (for NVE tunnels).
1033 MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1037 * If not set, then vni is reserved.
1040 * Note: Reserved for 802.1Q FIDs.
1042 MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1045 * Virtual Network Identifier.
1048 * Note: A given VNI can only be assigned to one FID.
1050 MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1052 static inline void mlxsw_reg_sfmr_pack(char *payload,
1053 enum mlxsw_reg_sfmr_op op, u16 fid,
1056 MLXSW_REG_ZERO(sfmr, payload);
1057 mlxsw_reg_sfmr_op_set(payload, op);
1058 mlxsw_reg_sfmr_fid_set(payload, fid);
1059 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1060 mlxsw_reg_sfmr_vtfp_set(payload, false);
1061 mlxsw_reg_sfmr_vv_set(payload, false);
1064 /* PMLP - Ports Module to Local Port Register
1065 * ------------------------------------------
1066 * Configures the assignment of modules to local ports.
1068 #define MLXSW_REG_PMLP_ID 0x5002
1069 #define MLXSW_REG_PMLP_LEN 0x40
1071 static const struct mlxsw_reg_info mlxsw_reg_pmlp = {
1072 .id = MLXSW_REG_PMLP_ID,
1073 .len = MLXSW_REG_PMLP_LEN,
1077 * 0 - Tx value is used for both Tx and Rx.
1078 * 1 - Rx value is taken from a separte field.
1081 MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
1083 /* reg_pmlp_local_port
1084 * Local port number.
1087 MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
1090 * 0 - Unmap local port.
1091 * 1 - Lane 0 is used.
1092 * 2 - Lanes 0 and 1 are used.
1093 * 4 - Lanes 0, 1, 2 and 3 are used.
1096 MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
1102 MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0, false);
1105 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
1108 MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 16, false);
1111 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
1115 MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 24, false);
1117 static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
1119 MLXSW_REG_ZERO(pmlp, payload);
1120 mlxsw_reg_pmlp_local_port_set(payload, local_port);
1123 /* PMTU - Port MTU Register
1124 * ------------------------
1125 * Configures and reports the port MTU.
1127 #define MLXSW_REG_PMTU_ID 0x5003
1128 #define MLXSW_REG_PMTU_LEN 0x10
1130 static const struct mlxsw_reg_info mlxsw_reg_pmtu = {
1131 .id = MLXSW_REG_PMTU_ID,
1132 .len = MLXSW_REG_PMTU_LEN,
1135 /* reg_pmtu_local_port
1136 * Local port number.
1139 MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
1143 * When port type (e.g. Ethernet) is configured, the relevant MTU is
1144 * reported, otherwise the minimum between the max_mtu of the different
1145 * types is reported.
1148 MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
1150 /* reg_pmtu_admin_mtu
1151 * MTU value to set port to. Must be smaller or equal to max_mtu.
1152 * Note: If port type is Infiniband, then port must be disabled, when its
1156 MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
1158 /* reg_pmtu_oper_mtu
1159 * The actual MTU configured on the port. Packets exceeding this size
1161 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
1162 * oper_mtu might be smaller than admin_mtu.
1165 MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
1167 static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
1170 MLXSW_REG_ZERO(pmtu, payload);
1171 mlxsw_reg_pmtu_local_port_set(payload, local_port);
1172 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
1173 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
1174 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
1177 /* PTYS - Port Type and Speed Register
1178 * -----------------------------------
1179 * Configures and reports the port speed type.
1181 * Note: When set while the link is up, the changes will not take effect
1182 * until the port transitions from down to up state.
1184 #define MLXSW_REG_PTYS_ID 0x5004
1185 #define MLXSW_REG_PTYS_LEN 0x40
1187 static const struct mlxsw_reg_info mlxsw_reg_ptys = {
1188 .id = MLXSW_REG_PTYS_ID,
1189 .len = MLXSW_REG_PTYS_LEN,
1192 /* reg_ptys_local_port
1193 * Local port number.
1196 MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
1198 #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
1200 /* reg_ptys_proto_mask
1201 * Protocol mask. Indicates which protocol is used.
1203 * 1 - Fibre Channel.
1207 MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
1209 #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
1210 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
1211 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
1212 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
1213 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
1214 #define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
1215 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
1216 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
1217 #define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
1218 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
1219 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
1220 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
1221 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
1222 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
1223 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
1224 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
1225 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
1226 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
1227 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
1228 #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
1229 #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
1230 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
1231 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
1232 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
1233 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
1234 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
1235 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
1237 /* reg_ptys_eth_proto_cap
1238 * Ethernet port supported speeds and protocols.
1241 MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
1243 /* reg_ptys_eth_proto_admin
1244 * Speed and protocol to set port to.
1247 MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
1249 /* reg_ptys_eth_proto_oper
1250 * The current speed and protocol configured for the port.
1253 MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
1255 static inline void mlxsw_reg_ptys_pack(char *payload, u8 local_port,
1258 MLXSW_REG_ZERO(ptys, payload);
1259 mlxsw_reg_ptys_local_port_set(payload, local_port);
1260 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
1261 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
1264 static inline void mlxsw_reg_ptys_unpack(char *payload, u32 *p_eth_proto_cap,
1265 u32 *p_eth_proto_adm,
1266 u32 *p_eth_proto_oper)
1268 if (p_eth_proto_cap)
1269 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
1270 if (p_eth_proto_adm)
1271 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
1272 if (p_eth_proto_oper)
1273 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
1276 /* PPAD - Port Physical Address Register
1277 * -------------------------------------
1278 * The PPAD register configures the per port physical MAC address.
1280 #define MLXSW_REG_PPAD_ID 0x5005
1281 #define MLXSW_REG_PPAD_LEN 0x10
1283 static const struct mlxsw_reg_info mlxsw_reg_ppad = {
1284 .id = MLXSW_REG_PPAD_ID,
1285 .len = MLXSW_REG_PPAD_LEN,
1288 /* reg_ppad_single_base_mac
1289 * 0: base_mac, local port should be 0 and mac[7:0] is
1290 * reserved. HW will set incremental
1291 * 1: single_mac - mac of the local_port
1294 MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
1296 /* reg_ppad_local_port
1297 * port number, if single_base_mac = 0 then local_port is reserved
1300 MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
1303 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
1304 * If single_base_mac = 1 - the per port MAC address
1307 MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
1309 static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
1312 MLXSW_REG_ZERO(ppad, payload);
1313 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
1314 mlxsw_reg_ppad_local_port_set(payload, local_port);
1317 /* PAOS - Ports Administrative and Operational Status Register
1318 * -----------------------------------------------------------
1319 * Configures and retrieves per port administrative and operational status.
1321 #define MLXSW_REG_PAOS_ID 0x5006
1322 #define MLXSW_REG_PAOS_LEN 0x10
1324 static const struct mlxsw_reg_info mlxsw_reg_paos = {
1325 .id = MLXSW_REG_PAOS_ID,
1326 .len = MLXSW_REG_PAOS_LEN,
1330 * Switch partition ID with which to associate the port.
1331 * Note: while external ports uses unique local port numbers (and thus swid is
1332 * redundant), router ports use the same local port number where swid is the
1333 * only indication for the relevant port.
1336 MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
1338 /* reg_paos_local_port
1339 * Local port number.
1342 MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
1344 /* reg_paos_admin_status
1345 * Port administrative state (the desired state of the port):
1348 * 3 - Up once. This means that in case of link failure, the port won't go
1349 * into polling mode, but will wait to be re-enabled by software.
1350 * 4 - Disabled by system. Can only be set by hardware.
1353 MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
1355 /* reg_paos_oper_status
1356 * Port operational state (the current state):
1359 * 3 - Down by port failure. This means that the device will not let the
1360 * port up again until explicitly specified by software.
1363 MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
1366 * Admin state update enabled.
1369 MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
1372 * Event update enable. If this bit is set, event generation will be
1373 * updated based on the e field.
1376 MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
1379 * Event generation on operational state change:
1380 * 0 - Do not generate event.
1381 * 1 - Generate Event.
1382 * 2 - Generate Single Event.
1385 MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
1387 static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
1388 enum mlxsw_port_admin_status status)
1390 MLXSW_REG_ZERO(paos, payload);
1391 mlxsw_reg_paos_swid_set(payload, 0);
1392 mlxsw_reg_paos_local_port_set(payload, local_port);
1393 mlxsw_reg_paos_admin_status_set(payload, status);
1394 mlxsw_reg_paos_oper_status_set(payload, 0);
1395 mlxsw_reg_paos_ase_set(payload, 1);
1396 mlxsw_reg_paos_ee_set(payload, 1);
1397 mlxsw_reg_paos_e_set(payload, 1);
1400 /* PPCNT - Ports Performance Counters Register
1401 * -------------------------------------------
1402 * The PPCNT register retrieves per port performance counters.
1404 #define MLXSW_REG_PPCNT_ID 0x5008
1405 #define MLXSW_REG_PPCNT_LEN 0x100
1407 static const struct mlxsw_reg_info mlxsw_reg_ppcnt = {
1408 .id = MLXSW_REG_PPCNT_ID,
1409 .len = MLXSW_REG_PPCNT_LEN,
1413 * For HCA: must be always 0.
1414 * Switch partition ID to associate port with.
1415 * Switch partitions are numbered from 0 to 7 inclusively.
1416 * Switch partition 254 indicates stacking ports.
1417 * Switch partition 255 indicates all switch partitions.
1418 * Only valid on Set() operation with local_port=255.
1421 MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
1423 /* reg_ppcnt_local_port
1424 * Local port number.
1425 * 255 indicates all ports on the device, and is only allowed
1426 * for Set() operation.
1429 MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
1432 * Port number access type:
1433 * 0 - Local port number
1434 * 1 - IB port number
1437 MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
1440 * Performance counter group.
1441 * Group 63 indicates all groups. Only valid on Set() operation with
1443 * 0x0: IEEE 802.3 Counters
1444 * 0x1: RFC 2863 Counters
1445 * 0x2: RFC 2819 Counters
1446 * 0x3: RFC 3635 Counters
1447 * 0x5: Ethernet Extended Counters
1448 * 0x8: Link Level Retransmission Counters
1449 * 0x10: Per Priority Counters
1450 * 0x11: Per Traffic Class Counters
1451 * 0x12: Physical Layer Counters
1454 MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
1457 * Clear counters. Setting the clr bit will reset the counter value
1458 * for all counters in the counter group. This bit can be set
1459 * for both Set() and Get() operation.
1462 MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
1464 /* reg_ppcnt_prio_tc
1465 * Priority for counter set that support per priority, valid values: 0-7.
1466 * Traffic class for counter set that support per traffic class,
1467 * valid values: 0- cap_max_tclass-1 .
1468 * For HCA: cap_max_tclass is always 8.
1469 * Otherwise must be 0.
1472 MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
1474 /* reg_ppcnt_a_frames_transmitted_ok
1477 MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
1478 0x08 + 0x00, 0, 64);
1480 /* reg_ppcnt_a_frames_received_ok
1483 MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
1484 0x08 + 0x08, 0, 64);
1486 /* reg_ppcnt_a_frame_check_sequence_errors
1489 MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
1490 0x08 + 0x10, 0, 64);
1492 /* reg_ppcnt_a_alignment_errors
1495 MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
1496 0x08 + 0x18, 0, 64);
1498 /* reg_ppcnt_a_octets_transmitted_ok
1501 MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
1502 0x08 + 0x20, 0, 64);
1504 /* reg_ppcnt_a_octets_received_ok
1507 MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
1508 0x08 + 0x28, 0, 64);
1510 /* reg_ppcnt_a_multicast_frames_xmitted_ok
1513 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
1514 0x08 + 0x30, 0, 64);
1516 /* reg_ppcnt_a_broadcast_frames_xmitted_ok
1519 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
1520 0x08 + 0x38, 0, 64);
1522 /* reg_ppcnt_a_multicast_frames_received_ok
1525 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
1526 0x08 + 0x40, 0, 64);
1528 /* reg_ppcnt_a_broadcast_frames_received_ok
1531 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
1532 0x08 + 0x48, 0, 64);
1534 /* reg_ppcnt_a_in_range_length_errors
1537 MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
1538 0x08 + 0x50, 0, 64);
1540 /* reg_ppcnt_a_out_of_range_length_field
1543 MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
1544 0x08 + 0x58, 0, 64);
1546 /* reg_ppcnt_a_frame_too_long_errors
1549 MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
1550 0x08 + 0x60, 0, 64);
1552 /* reg_ppcnt_a_symbol_error_during_carrier
1555 MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
1556 0x08 + 0x68, 0, 64);
1558 /* reg_ppcnt_a_mac_control_frames_transmitted
1561 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
1562 0x08 + 0x70, 0, 64);
1564 /* reg_ppcnt_a_mac_control_frames_received
1567 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
1568 0x08 + 0x78, 0, 64);
1570 /* reg_ppcnt_a_unsupported_opcodes_received
1573 MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
1574 0x08 + 0x80, 0, 64);
1576 /* reg_ppcnt_a_pause_mac_ctrl_frames_received
1579 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
1580 0x08 + 0x88, 0, 64);
1582 /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
1585 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
1586 0x08 + 0x90, 0, 64);
1588 static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port)
1590 MLXSW_REG_ZERO(ppcnt, payload);
1591 mlxsw_reg_ppcnt_swid_set(payload, 0);
1592 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
1593 mlxsw_reg_ppcnt_pnat_set(payload, 0);
1594 mlxsw_reg_ppcnt_grp_set(payload, 0);
1595 mlxsw_reg_ppcnt_clr_set(payload, 0);
1596 mlxsw_reg_ppcnt_prio_tc_set(payload, 0);
1599 /* PBMC - Port Buffer Management Control Register
1600 * ----------------------------------------------
1601 * The PBMC register configures and retrieves the port packet buffer
1602 * allocation for different Prios, and the Pause threshold management.
1604 #define MLXSW_REG_PBMC_ID 0x500C
1605 #define MLXSW_REG_PBMC_LEN 0x68
1607 static const struct mlxsw_reg_info mlxsw_reg_pbmc = {
1608 .id = MLXSW_REG_PBMC_ID,
1609 .len = MLXSW_REG_PBMC_LEN,
1612 /* reg_pbmc_local_port
1613 * Local port number.
1616 MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
1618 /* reg_pbmc_xoff_timer_value
1619 * When device generates a pause frame, it uses this value as the pause
1620 * timer (time for the peer port to pause in quota-512 bit time).
1623 MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
1625 /* reg_pbmc_xoff_refresh
1626 * The time before a new pause frame should be sent to refresh the pause RW
1627 * state. Using the same units as xoff_timer_value above (in quota-512 bit
1631 MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
1633 /* reg_pbmc_buf_lossy
1634 * The field indicates if the buffer is lossy.
1639 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
1641 /* reg_pbmc_buf_epsb
1642 * Eligible for Port Shared buffer.
1643 * If epsb is set, packets assigned to buffer are allowed to insert the port
1645 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
1648 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
1650 /* reg_pbmc_buf_size
1651 * The part of the packet buffer array is allocated for the specific buffer.
1652 * Units are represented in cells.
1655 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
1657 static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
1658 u16 xoff_timer_value, u16 xoff_refresh)
1660 MLXSW_REG_ZERO(pbmc, payload);
1661 mlxsw_reg_pbmc_local_port_set(payload, local_port);
1662 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
1663 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
1666 static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
1670 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
1671 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
1672 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
1675 /* PSPA - Port Switch Partition Allocation
1676 * ---------------------------------------
1677 * Controls the association of a port with a switch partition and enables
1678 * configuring ports as stacking ports.
1680 #define MLXSW_REG_PSPA_ID 0x500D
1681 #define MLXSW_REG_PSPA_LEN 0x8
1683 static const struct mlxsw_reg_info mlxsw_reg_pspa = {
1684 .id = MLXSW_REG_PSPA_ID,
1685 .len = MLXSW_REG_PSPA_LEN,
1689 * Switch partition ID.
1692 MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
1694 /* reg_pspa_local_port
1695 * Local port number.
1698 MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
1700 /* reg_pspa_sub_port
1701 * Virtual port within the local port. Set to 0 when virtual ports are
1702 * disabled on the local port.
1705 MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
1707 static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
1709 MLXSW_REG_ZERO(pspa, payload);
1710 mlxsw_reg_pspa_swid_set(payload, swid);
1711 mlxsw_reg_pspa_local_port_set(payload, local_port);
1712 mlxsw_reg_pspa_sub_port_set(payload, 0);
1715 /* HTGT - Host Trap Group Table
1716 * ----------------------------
1717 * Configures the properties for forwarding to CPU.
1719 #define MLXSW_REG_HTGT_ID 0x7002
1720 #define MLXSW_REG_HTGT_LEN 0x100
1722 static const struct mlxsw_reg_info mlxsw_reg_htgt = {
1723 .id = MLXSW_REG_HTGT_ID,
1724 .len = MLXSW_REG_HTGT_LEN,
1728 * Switch partition ID.
1731 MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
1733 #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
1739 MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
1741 enum mlxsw_reg_htgt_trap_group {
1742 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
1743 MLXSW_REG_HTGT_TRAP_GROUP_RX,
1744 MLXSW_REG_HTGT_TRAP_GROUP_CTRL,
1747 /* reg_htgt_trap_group
1748 * Trap group number. User defined number specifying which trap groups
1749 * should be forwarded to the CPU. The mapping between trap IDs and trap
1750 * groups is configured using HPKT register.
1753 MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
1756 MLXSW_REG_HTGT_POLICER_DISABLE,
1757 MLXSW_REG_HTGT_POLICER_ENABLE,
1761 * Enable policer ID specified using 'pid' field.
1764 MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
1767 * Policer ID for the trap group.
1770 MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
1772 #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
1774 /* reg_htgt_mirror_action
1775 * Mirror action to use.
1777 * 1 - Trap to CPU and mirror to a mirroring agent.
1778 * 2 - Mirror to a mirroring agent and do not trap to CPU.
1781 * Note: Mirroring to a mirroring agent is only supported in Spectrum.
1783 MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
1785 /* reg_htgt_mirroring_agent
1789 MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
1791 /* reg_htgt_priority
1792 * Trap group priority.
1793 * In case a packet matches multiple classification rules, the packet will
1794 * only be trapped once, based on the trap ID associated with the group (via
1795 * register HPKT) with the highest priority.
1796 * Supported values are 0-7, with 7 represnting the highest priority.
1799 * Note: In SwitchX-2 this field is ignored and the priority value is replaced
1800 * by the 'trap_group' field.
1802 MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
1804 /* reg_htgt_local_path_cpu_tclass
1805 * CPU ingress traffic class for the trap group.
1808 MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
1810 #define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD 0x15
1811 #define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX 0x14
1812 #define MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL 0x13
1814 /* reg_htgt_local_path_rdq
1815 * Receive descriptor queue (RDQ) to use for the trap group.
1818 MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
1820 static inline void mlxsw_reg_htgt_pack(char *payload,
1821 enum mlxsw_reg_htgt_trap_group group)
1825 MLXSW_REG_ZERO(htgt, payload);
1827 case MLXSW_REG_HTGT_TRAP_GROUP_EMAD:
1828 swid = MLXSW_PORT_SWID_ALL_SWIDS;
1829 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_EMAD;
1831 case MLXSW_REG_HTGT_TRAP_GROUP_RX:
1833 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_RX;
1835 case MLXSW_REG_HTGT_TRAP_GROUP_CTRL:
1837 rdq = MLXSW_REG_HTGT_LOCAL_PATH_RDQ_CTRL;
1840 mlxsw_reg_htgt_swid_set(payload, swid);
1841 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
1842 mlxsw_reg_htgt_trap_group_set(payload, group);
1843 mlxsw_reg_htgt_pide_set(payload, MLXSW_REG_HTGT_POLICER_DISABLE);
1844 mlxsw_reg_htgt_pid_set(payload, 0);
1845 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
1846 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
1847 mlxsw_reg_htgt_priority_set(payload, 0);
1848 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, 7);
1849 mlxsw_reg_htgt_local_path_rdq_set(payload, rdq);
1852 /* HPKT - Host Packet Trap
1853 * -----------------------
1854 * Configures trap IDs inside trap groups.
1856 #define MLXSW_REG_HPKT_ID 0x7003
1857 #define MLXSW_REG_HPKT_LEN 0x10
1859 static const struct mlxsw_reg_info mlxsw_reg_hpkt = {
1860 .id = MLXSW_REG_HPKT_ID,
1861 .len = MLXSW_REG_HPKT_LEN,
1865 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
1866 MLXSW_REG_HPKT_ACK_REQUIRED,
1870 * Require acknowledgements from the host for events.
1871 * If set, then the device will wait for the event it sent to be acknowledged
1872 * by the host. This option is only relevant for event trap IDs.
1875 * Note: Currently not supported by firmware.
1877 MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
1879 enum mlxsw_reg_hpkt_action {
1880 MLXSW_REG_HPKT_ACTION_FORWARD,
1881 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
1882 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
1883 MLXSW_REG_HPKT_ACTION_DISCARD,
1884 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
1885 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
1889 * Action to perform on packet when trapped.
1890 * 0 - No action. Forward to CPU based on switching rules.
1891 * 1 - Trap to CPU (CPU receives sole copy).
1892 * 2 - Mirror to CPU (CPU receives a replica of the packet).
1894 * 4 - Soft discard (allow other traps to act on the packet).
1895 * 5 - Trap and soft discard (allow other traps to overwrite this trap).
1898 * Note: Must be set to 0 (forward) for event trap IDs, as they are already
1899 * addressed to the CPU.
1901 MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
1903 /* reg_hpkt_trap_group
1904 * Trap group to associate the trap with.
1907 MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
1913 * Note: A trap ID can only be associated with a single trap group. The device
1914 * will associate the trap ID with the last trap group configured.
1916 MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
1919 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
1920 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
1921 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
1925 * Configure dedicated buffer resources for control packets.
1926 * 0 - Keep factory defaults.
1927 * 1 - Do not use control buffer for this trap ID.
1928 * 2 - Use control buffer for this trap ID.
1931 MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
1933 static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id)
1935 enum mlxsw_reg_htgt_trap_group trap_group;
1937 MLXSW_REG_ZERO(hpkt, payload);
1938 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
1939 mlxsw_reg_hpkt_action_set(payload, action);
1941 case MLXSW_TRAP_ID_ETHEMAD:
1942 case MLXSW_TRAP_ID_PUDE:
1943 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_EMAD;
1946 trap_group = MLXSW_REG_HTGT_TRAP_GROUP_RX;
1949 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
1950 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
1951 mlxsw_reg_hpkt_ctrl_set(payload, MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT);
1954 /* SBPR - Shared Buffer Pools Register
1955 * -----------------------------------
1956 * The SBPR configures and retrieves the shared buffer pools and configuration.
1958 #define MLXSW_REG_SBPR_ID 0xB001
1959 #define MLXSW_REG_SBPR_LEN 0x14
1961 static const struct mlxsw_reg_info mlxsw_reg_sbpr = {
1962 .id = MLXSW_REG_SBPR_ID,
1963 .len = MLXSW_REG_SBPR_LEN,
1966 enum mlxsw_reg_sbpr_dir {
1967 MLXSW_REG_SBPR_DIR_INGRESS,
1968 MLXSW_REG_SBPR_DIR_EGRESS,
1975 MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
1981 MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
1984 * Pool size in buffer cells.
1987 MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
1989 enum mlxsw_reg_sbpr_mode {
1990 MLXSW_REG_SBPR_MODE_STATIC,
1991 MLXSW_REG_SBPR_MODE_DYNAMIC,
1995 * Pool quota calculation mode.
1998 MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
2000 static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
2001 enum mlxsw_reg_sbpr_dir dir,
2002 enum mlxsw_reg_sbpr_mode mode, u32 size)
2004 MLXSW_REG_ZERO(sbpr, payload);
2005 mlxsw_reg_sbpr_pool_set(payload, pool);
2006 mlxsw_reg_sbpr_dir_set(payload, dir);
2007 mlxsw_reg_sbpr_mode_set(payload, mode);
2008 mlxsw_reg_sbpr_size_set(payload, size);
2011 /* SBCM - Shared Buffer Class Management Register
2012 * ----------------------------------------------
2013 * The SBCM register configures and retrieves the shared buffer allocation
2014 * and configuration according to Port-PG, including the binding to pool
2015 * and definition of the associated quota.
2017 #define MLXSW_REG_SBCM_ID 0xB002
2018 #define MLXSW_REG_SBCM_LEN 0x28
2020 static const struct mlxsw_reg_info mlxsw_reg_sbcm = {
2021 .id = MLXSW_REG_SBCM_ID,
2022 .len = MLXSW_REG_SBCM_LEN,
2025 /* reg_sbcm_local_port
2026 * Local port number.
2027 * For Ingress: excludes CPU port and Router port
2028 * For Egress: excludes IP Router
2031 MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
2034 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
2035 * For PG buffer: range is 0..cap_max_pg_buffers - 1
2036 * For traffic class: range is 0..cap_max_tclass - 1
2037 * Note that when traffic class is in MC aware mode then the traffic
2038 * classes which are MC aware cannot be configured.
2041 MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
2043 enum mlxsw_reg_sbcm_dir {
2044 MLXSW_REG_SBCM_DIR_INGRESS,
2045 MLXSW_REG_SBCM_DIR_EGRESS,
2052 MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
2054 /* reg_sbcm_min_buff
2055 * Minimum buffer size for the limiter, in cells.
2058 MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
2060 /* reg_sbcm_max_buff
2061 * When the pool associated to the port-pg/tclass is configured to
2062 * static, Maximum buffer size for the limiter configured in cells.
2063 * When the pool associated to the port-pg/tclass is configured to
2064 * dynamic, the max_buff holds the "alpha" parameter, supporting
2065 * the following values:
2067 * i: (1/128)*2^(i-1), for i=1..14
2071 MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
2074 * Association of the port-priority to a pool.
2077 MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
2079 static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
2080 enum mlxsw_reg_sbcm_dir dir,
2081 u32 min_buff, u32 max_buff, u8 pool)
2083 MLXSW_REG_ZERO(sbcm, payload);
2084 mlxsw_reg_sbcm_local_port_set(payload, local_port);
2085 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
2086 mlxsw_reg_sbcm_dir_set(payload, dir);
2087 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
2088 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
2089 mlxsw_reg_sbcm_pool_set(payload, pool);
2092 /* SBPM - Shared Buffer Class Management Register
2093 * ----------------------------------------------
2094 * The SBPM register configures and retrieves the shared buffer allocation
2095 * and configuration according to Port-Pool, including the definition
2096 * of the associated quota.
2098 #define MLXSW_REG_SBPM_ID 0xB003
2099 #define MLXSW_REG_SBPM_LEN 0x28
2101 static const struct mlxsw_reg_info mlxsw_reg_sbpm = {
2102 .id = MLXSW_REG_SBPM_ID,
2103 .len = MLXSW_REG_SBPM_LEN,
2106 /* reg_sbpm_local_port
2107 * Local port number.
2108 * For Ingress: excludes CPU port and Router port
2109 * For Egress: excludes IP Router
2112 MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
2115 * The pool associated to quota counting on the local_port.
2118 MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
2120 enum mlxsw_reg_sbpm_dir {
2121 MLXSW_REG_SBPM_DIR_INGRESS,
2122 MLXSW_REG_SBPM_DIR_EGRESS,
2129 MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
2131 /* reg_sbpm_min_buff
2132 * Minimum buffer size for the limiter, in cells.
2135 MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
2137 /* reg_sbpm_max_buff
2138 * When the pool associated to the port-pg/tclass is configured to
2139 * static, Maximum buffer size for the limiter configured in cells.
2140 * When the pool associated to the port-pg/tclass is configured to
2141 * dynamic, the max_buff holds the "alpha" parameter, supporting
2142 * the following values:
2144 * i: (1/128)*2^(i-1), for i=1..14
2148 MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
2150 static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
2151 enum mlxsw_reg_sbpm_dir dir,
2152 u32 min_buff, u32 max_buff)
2154 MLXSW_REG_ZERO(sbpm, payload);
2155 mlxsw_reg_sbpm_local_port_set(payload, local_port);
2156 mlxsw_reg_sbpm_pool_set(payload, pool);
2157 mlxsw_reg_sbpm_dir_set(payload, dir);
2158 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
2159 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
2162 /* SBMM - Shared Buffer Multicast Management Register
2163 * --------------------------------------------------
2164 * The SBMM register configures and retrieves the shared buffer allocation
2165 * and configuration for MC packets according to Switch-Priority, including
2166 * the binding to pool and definition of the associated quota.
2168 #define MLXSW_REG_SBMM_ID 0xB004
2169 #define MLXSW_REG_SBMM_LEN 0x28
2171 static const struct mlxsw_reg_info mlxsw_reg_sbmm = {
2172 .id = MLXSW_REG_SBMM_ID,
2173 .len = MLXSW_REG_SBMM_LEN,
2180 MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
2182 /* reg_sbmm_min_buff
2183 * Minimum buffer size for the limiter, in cells.
2186 MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
2188 /* reg_sbmm_max_buff
2189 * When the pool associated to the port-pg/tclass is configured to
2190 * static, Maximum buffer size for the limiter configured in cells.
2191 * When the pool associated to the port-pg/tclass is configured to
2192 * dynamic, the max_buff holds the "alpha" parameter, supporting
2193 * the following values:
2195 * i: (1/128)*2^(i-1), for i=1..14
2199 MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
2202 * Association of the port-priority to a pool.
2205 MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
2207 static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
2208 u32 max_buff, u8 pool)
2210 MLXSW_REG_ZERO(sbmm, payload);
2211 mlxsw_reg_sbmm_prio_set(payload, prio);
2212 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
2213 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
2214 mlxsw_reg_sbmm_pool_set(payload, pool);
2217 static inline const char *mlxsw_reg_id_str(u16 reg_id)
2220 case MLXSW_REG_SGCR_ID:
2222 case MLXSW_REG_SPAD_ID:
2224 case MLXSW_REG_SSPR_ID:
2226 case MLXSW_REG_SFD_ID:
2228 case MLXSW_REG_SFN_ID:
2230 case MLXSW_REG_SPMS_ID:
2232 case MLXSW_REG_SPVID_ID:
2234 case MLXSW_REG_SPVM_ID:
2236 case MLXSW_REG_SFGC_ID:
2238 case MLXSW_REG_SFTR_ID:
2240 case MLXSW_REG_SPMLR_ID:
2242 case MLXSW_REG_SVFA_ID:
2244 case MLXSW_REG_SFMR_ID:
2246 case MLXSW_REG_PMLP_ID:
2248 case MLXSW_REG_PMTU_ID:
2250 case MLXSW_REG_PTYS_ID:
2252 case MLXSW_REG_PPAD_ID:
2254 case MLXSW_REG_PAOS_ID:
2256 case MLXSW_REG_PPCNT_ID:
2258 case MLXSW_REG_PBMC_ID:
2260 case MLXSW_REG_PSPA_ID:
2262 case MLXSW_REG_HTGT_ID:
2264 case MLXSW_REG_HPKT_ID:
2266 case MLXSW_REG_SBPR_ID:
2268 case MLXSW_REG_SBCM_ID:
2270 case MLXSW_REG_SBPM_ID:
2272 case MLXSW_REG_SBMM_ID:
2279 /* PUDE - Port Up / Down Event
2280 * ---------------------------
2281 * Reports the operational state change of a port.
2283 #define MLXSW_REG_PUDE_LEN 0x10
2286 * Switch partition ID with which to associate the port.
2289 MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
2291 /* reg_pude_local_port
2292 * Local port number.
2295 MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
2297 /* reg_pude_admin_status
2298 * Port administrative state (the desired state).
2301 * 3 - Up once. This means that in case of link failure, the port won't go
2302 * into polling mode, but will wait to be re-enabled by software.
2303 * 4 - Disabled by system. Can only be set by hardware.
2306 MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
2308 /* reg_pude_oper_status
2309 * Port operatioanl state.
2312 * 3 - Down by port failure. This means that the device will not let the
2313 * port up again until explicitly specified by software.
2316 MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);