1
2
3
4#ifndef _MLXSW_REG_H
5#define _MLXSW_REG_H
6
7#include <linux/kernel.h>
8#include <linux/string.h>
9#include <linux/bitops.h>
10#include <linux/if_vlan.h>
11
12#include "item.h"
13#include "port.h"
14
15struct mlxsw_reg_info {
16 u16 id;
17 u16 len;
18 const char *name;
19};
20
21#define MLXSW_REG_DEFINE(_name, _id, _len) \
22static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
23 .id = _id, \
24 .len = _len, \
25 .name = #_name, \
26}
27
28#define MLXSW_REG(type) (&mlxsw_reg_##type)
29#define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
30#define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
31
32
33
34
35
36#define MLXSW_REG_SGCR_ID 0x2000
37#define MLXSW_REG_SGCR_LEN 0x10
38
39MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
40
41
42
43
44
45
46
47MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
48
49static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
50{
51 MLXSW_REG_ZERO(sgcr, payload);
52 mlxsw_reg_sgcr_llb_set(payload, !!llb);
53}
54
55
56
57
58
59#define MLXSW_REG_SPAD_ID 0x2002
60#define MLXSW_REG_SPAD_LEN 0x10
61
62MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
63
64
65
66
67
68
69
70MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
71
72
73
74
75
76#define MLXSW_REG_SSPR_ID 0x2008
77#define MLXSW_REG_SSPR_LEN 0x8
78
79MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
80
81
82
83
84
85
86
87
88
89
90
91MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
92
93
94
95
96
97
98MLXSW_ITEM32_LP(reg, sspr, 0x00, 16, 0x00, 12);
99
100
101
102
103
104
105
106MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
107
108
109
110
111
112
113
114
115
116MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
117
118static inline void mlxsw_reg_sspr_pack(char *payload, u16 local_port)
119{
120 MLXSW_REG_ZERO(sspr, payload);
121 mlxsw_reg_sspr_m_set(payload, 1);
122 mlxsw_reg_sspr_local_port_set(payload, local_port);
123 mlxsw_reg_sspr_sub_port_set(payload, 0);
124 mlxsw_reg_sspr_system_port_set(payload, local_port);
125}
126
127
128
129
130
131
132#define MLXSW_REG_SFDAT_ID 0x2009
133#define MLXSW_REG_SFDAT_LEN 0x8
134
135MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
136
137
138
139
140
141MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
142
143
144
145
146
147
148
149
150MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
151
152static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
153{
154 MLXSW_REG_ZERO(sfdat, payload);
155 mlxsw_reg_sfdat_swid_set(payload, 0);
156 mlxsw_reg_sfdat_age_time_set(payload, age_time);
157}
158
159
160
161
162
163
164
165
166#define MLXSW_REG_SFD_ID 0x200A
167#define MLXSW_REG_SFD_BASE_LEN 0x10
168#define MLXSW_REG_SFD_REC_LEN 0x10
169#define MLXSW_REG_SFD_REC_MAX_COUNT 64
170#define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
171 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
172
173MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
174
175
176
177
178
179MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
180
181enum mlxsw_reg_sfd_op {
182
183 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
184
185 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
186
187 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
188
189
190
191 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
192
193
194
195
196 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
197
198
199
200
201
202 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
203
204
205
206 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
207};
208
209
210
211
212
213MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
214
215
216
217
218
219
220
221
222MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
223
224
225
226
227
228
229
230
231MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
232
233static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
234 u32 record_locator)
235{
236 MLXSW_REG_ZERO(sfd, payload);
237 mlxsw_reg_sfd_op_set(payload, op);
238 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
239}
240
241
242
243
244
245MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
246 MLXSW_REG_SFD_REC_LEN, 0x00, false);
247
248enum mlxsw_reg_sfd_rec_type {
249 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
250 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
251 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
252 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC,
253};
254
255
256
257
258
259MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
260 MLXSW_REG_SFD_REC_LEN, 0x00, false);
261
262enum mlxsw_reg_sfd_rec_policy {
263
264 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
265
266
267
268 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
269
270 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
271};
272
273
274
275
276
277MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
278 MLXSW_REG_SFD_REC_LEN, 0x00, false);
279
280
281
282
283
284
285
286MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
287 MLXSW_REG_SFD_REC_LEN, 0x00, false);
288
289
290
291
292
293MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
294 MLXSW_REG_SFD_REC_LEN, 0x02);
295
296enum mlxsw_reg_sfd_rec_action {
297
298 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
299
300 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
301
302 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
303
304 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
305 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
306};
307
308
309
310
311
312
313MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
314 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
315
316
317
318
319
320
321
322MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
323 MLXSW_REG_SFD_REC_LEN, 0x08, false);
324
325
326
327
328
329
330
331
332
333
334
335MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
336 MLXSW_REG_SFD_REC_LEN, 0x08, false);
337
338
339
340
341
342MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
343 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
344
345static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
346 enum mlxsw_reg_sfd_rec_type rec_type,
347 const char *mac,
348 enum mlxsw_reg_sfd_rec_action action)
349{
350 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
351
352 if (rec_index >= num_rec)
353 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
354 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
355 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
356 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
357 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
358}
359
360static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
361 enum mlxsw_reg_sfd_rec_policy policy,
362 const char *mac, u16 fid_vid,
363 enum mlxsw_reg_sfd_rec_action action,
364 u16 local_port)
365{
366 mlxsw_reg_sfd_rec_pack(payload, rec_index,
367 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
368 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
369 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
370 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
371 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
372}
373
374
375
376
377
378
379MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
380 MLXSW_REG_SFD_REC_LEN, 0x08, false);
381
382
383
384
385
386
387
388
389
390
391
392MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
393 MLXSW_REG_SFD_REC_LEN, 0x08, false);
394
395
396
397
398
399MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
400 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
401
402
403
404
405
406MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
407 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
408
409static inline void
410mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
411 enum mlxsw_reg_sfd_rec_policy policy,
412 const char *mac, u16 fid_vid,
413 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
414 u16 lag_id)
415{
416 mlxsw_reg_sfd_rec_pack(payload, rec_index,
417 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
418 mac, action);
419 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
420 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
421 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
422 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
423 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
424}
425
426
427
428
429
430
431
432
433MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
434 MLXSW_REG_SFD_REC_LEN, 0x08, false);
435
436
437
438
439
440
441MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
442 MLXSW_REG_SFD_REC_LEN, 0x08, false);
443
444
445
446
447
448
449
450MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
451 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
452
453static inline void
454mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
455 const char *mac, u16 fid_vid,
456 enum mlxsw_reg_sfd_rec_action action, u16 mid)
457{
458 mlxsw_reg_sfd_rec_pack(payload, rec_index,
459 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
460 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
461 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
462 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
463}
464
465
466
467
468
469
470
471MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24,
472 8, MLXSW_REG_SFD_REC_LEN, 0x08, false);
473
474
475
476
477
478MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
479 MLXSW_REG_SFD_REC_LEN, 0x08, false);
480
481enum mlxsw_reg_sfd_uc_tunnel_protocol {
482 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4,
483 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6,
484};
485
486
487
488
489
490MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27,
491 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
492
493
494
495
496
497
498
499
500MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0,
501 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
502
503static inline void
504mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
505 enum mlxsw_reg_sfd_rec_policy policy,
506 const char *mac, u16 fid,
507 enum mlxsw_reg_sfd_rec_action action,
508 enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
509{
510 mlxsw_reg_sfd_rec_pack(payload, rec_index,
511 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
512 action);
513 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
514 mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
515 mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
516}
517
518static inline void
519mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index,
520 enum mlxsw_reg_sfd_rec_policy policy,
521 const char *mac, u16 fid,
522 enum mlxsw_reg_sfd_rec_action action, u32 uip)
523{
524 mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
525 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
526 mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, policy, mac, fid,
527 action,
528 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4);
529}
530
531static inline void
532mlxsw_reg_sfd_uc_tunnel_pack6(char *payload, int rec_index, const char *mac,
533 u16 fid, enum mlxsw_reg_sfd_rec_action action,
534 u32 uip_ptr)
535{
536 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip_ptr);
537
538 mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index,
539 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY,
540 mac, fid, action,
541 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6);
542}
543
544enum mlxsw_reg_tunnel_port {
545 MLXSW_REG_TUNNEL_PORT_NVE,
546 MLXSW_REG_TUNNEL_PORT_VPLS,
547 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL0,
548 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL1,
549};
550
551
552
553
554
555
556#define MLXSW_REG_SFN_ID 0x200B
557#define MLXSW_REG_SFN_BASE_LEN 0x10
558#define MLXSW_REG_SFN_REC_LEN 0x10
559#define MLXSW_REG_SFN_REC_MAX_COUNT 64
560#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
561 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
562
563MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
564
565
566
567
568
569MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
570
571
572
573
574
575MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
576
577
578
579
580
581
582
583
584
585MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
586
587static inline void mlxsw_reg_sfn_pack(char *payload)
588{
589 MLXSW_REG_ZERO(sfn, payload);
590 mlxsw_reg_sfn_swid_set(payload, 0);
591 mlxsw_reg_sfn_end_set(payload, 0);
592 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
593}
594
595
596
597
598
599MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
600 MLXSW_REG_SFN_REC_LEN, 0x00, false);
601
602enum mlxsw_reg_sfn_rec_type {
603
604 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
605
606 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
607
608 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
609
610 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
611
612 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
613
614 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
615};
616
617
618
619
620
621MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
622 MLXSW_REG_SFN_REC_LEN, 0x00, false);
623
624
625
626
627
628MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
629 MLXSW_REG_SFN_REC_LEN, 0x02);
630
631
632
633
634
635
636MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
637 MLXSW_REG_SFN_REC_LEN, 0x08, false);
638
639
640
641
642
643MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
644 MLXSW_REG_SFN_REC_LEN, 0x08, false);
645
646
647
648
649
650MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
651 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
652
653static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
654 char *mac, u16 *p_vid,
655 u16 *p_local_port)
656{
657 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
658 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
659 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
660}
661
662
663
664
665
666MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
667 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
668
669static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
670 char *mac, u16 *p_vid,
671 u16 *p_lag_id)
672{
673 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
674 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
675 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
676}
677
678
679
680
681
682
683
684MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
685 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
686
687enum mlxsw_reg_sfn_uc_tunnel_protocol {
688 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
689 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
690};
691
692
693
694
695
696MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
697 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
698
699
700
701
702
703
704
705MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
706 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
707
708
709
710
711
712
713MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4,
714 MLXSW_REG_SFN_REC_LEN, 0x10, false);
715
716static inline void
717mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac,
718 u16 *p_fid, u32 *p_uip,
719 enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto)
720{
721 u32 uip_msb, uip_lsb;
722
723 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
724 *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
725 uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index);
726 uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index);
727 *p_uip = uip_msb << 24 | uip_lsb;
728 *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index);
729}
730
731
732
733
734
735#define MLXSW_REG_SPMS_ID 0x200D
736#define MLXSW_REG_SPMS_LEN 0x404
737
738MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
739
740
741
742
743
744MLXSW_ITEM32_LP(reg, spms, 0x00, 16, 0x00, 12);
745
746enum mlxsw_reg_spms_state {
747 MLXSW_REG_SPMS_STATE_NO_CHANGE,
748 MLXSW_REG_SPMS_STATE_DISCARDING,
749 MLXSW_REG_SPMS_STATE_LEARNING,
750 MLXSW_REG_SPMS_STATE_FORWARDING,
751};
752
753
754
755
756
757
758
759
760
761MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
762
763static inline void mlxsw_reg_spms_pack(char *payload, u16 local_port)
764{
765 MLXSW_REG_ZERO(spms, payload);
766 mlxsw_reg_spms_local_port_set(payload, local_port);
767}
768
769static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
770 enum mlxsw_reg_spms_state state)
771{
772 mlxsw_reg_spms_state_set(payload, vid, state);
773}
774
775
776
777
778
779#define MLXSW_REG_SPVID_ID 0x200E
780#define MLXSW_REG_SPVID_LEN 0x08
781
782MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
783
784
785
786
787
788
789MLXSW_ITEM32(reg, spvid, tport, 0x00, 24, 1);
790
791
792
793
794
795
796MLXSW_ITEM32_LP(reg, spvid, 0x00, 16, 0x00, 12);
797
798
799
800
801
802
803MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
804
805
806
807
808
809
810
811MLXSW_ITEM32(reg, spvid, egr_et_set, 0x04, 24, 1);
812
813
814
815
816
817
818
819
820
821
822
823MLXSW_ITEM32(reg, spvid, et_vlan, 0x04, 16, 2);
824
825
826
827
828
829MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
830
831static inline void mlxsw_reg_spvid_pack(char *payload, u16 local_port, u16 pvid,
832 u8 et_vlan)
833{
834 MLXSW_REG_ZERO(spvid, payload);
835 mlxsw_reg_spvid_local_port_set(payload, local_port);
836 mlxsw_reg_spvid_pvid_set(payload, pvid);
837 mlxsw_reg_spvid_et_vlan_set(payload, et_vlan);
838}
839
840
841
842
843
844
845
846#define MLXSW_REG_SPVM_ID 0x200F
847#define MLXSW_REG_SPVM_BASE_LEN 0x04
848#define MLXSW_REG_SPVM_REC_LEN 0x04
849#define MLXSW_REG_SPVM_REC_MAX_COUNT 255
850#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
851 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
852
853MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
854
855
856
857
858
859
860
861MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
862
863
864
865
866
867
868MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
869
870
871
872
873
874MLXSW_ITEM32_LP(reg, spvm, 0x00, 16, 0x00, 12);
875
876
877
878
879
880
881MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
882
883
884
885
886
887MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
888
889
890
891
892
893MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
894 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
895 MLXSW_REG_SPVM_REC_LEN, 0, false);
896
897
898
899
900
901MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
902 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
903 MLXSW_REG_SPVM_REC_LEN, 0, false);
904
905
906
907
908
909
910MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
911 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
912 MLXSW_REG_SPVM_REC_LEN, 0, false);
913
914
915
916
917
918MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
919 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
920 MLXSW_REG_SPVM_REC_LEN, 0, false);
921
922static inline void mlxsw_reg_spvm_pack(char *payload, u16 local_port,
923 u16 vid_begin, u16 vid_end,
924 bool is_member, bool untagged)
925{
926 int size = vid_end - vid_begin + 1;
927 int i;
928
929 MLXSW_REG_ZERO(spvm, payload);
930 mlxsw_reg_spvm_local_port_set(payload, local_port);
931 mlxsw_reg_spvm_num_rec_set(payload, size);
932
933 for (i = 0; i < size; i++) {
934 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
935 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
936 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
937 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
938 }
939}
940
941
942
943
944
945
946#define MLXSW_REG_SPAFT_ID 0x2010
947#define MLXSW_REG_SPAFT_LEN 0x08
948
949MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
950
951
952
953
954
955
956
957MLXSW_ITEM32_LP(reg, spaft, 0x00, 16, 0x00, 12);
958
959
960
961
962
963
964MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
965
966
967
968
969
970MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
971
972
973
974
975
976MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
977
978
979
980
981
982MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
983
984static inline void mlxsw_reg_spaft_pack(char *payload, u16 local_port,
985 bool allow_untagged)
986{
987 MLXSW_REG_ZERO(spaft, payload);
988 mlxsw_reg_spaft_local_port_set(payload, local_port);
989 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
990 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
991 mlxsw_reg_spaft_allow_tagged_set(payload, true);
992}
993
994
995
996
997
998
999#define MLXSW_REG_SFGC_ID 0x2011
1000#define MLXSW_REG_SFGC_LEN 0x10
1001
1002MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
1003
1004enum mlxsw_reg_sfgc_type {
1005 MLXSW_REG_SFGC_TYPE_BROADCAST,
1006 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
1007 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
1008 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
1009 MLXSW_REG_SFGC_TYPE_RESERVED,
1010 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
1011 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
1012 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
1013 MLXSW_REG_SFGC_TYPE_MAX,
1014};
1015
1016
1017
1018
1019
1020MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
1021
1022enum mlxsw_reg_sfgc_bridge_type {
1023 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
1024 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
1025};
1026
1027
1028
1029
1030
1031
1032MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
1033
1034enum mlxsw_flood_table_type {
1035 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
1036 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
1037 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
1038 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
1039 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
1040};
1041
1042
1043
1044
1045
1046
1047
1048MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
1049
1050
1051
1052
1053
1054
1055MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
1056
1057
1058
1059
1060
1061MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
1062
1063
1064
1065
1066
1067MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
1068
1069
1070
1071
1072
1073MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
1074
1075static inline void
1076mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
1077 enum mlxsw_reg_sfgc_bridge_type bridge_type,
1078 enum mlxsw_flood_table_type table_type,
1079 unsigned int flood_table)
1080{
1081 MLXSW_REG_ZERO(sfgc, payload);
1082 mlxsw_reg_sfgc_type_set(payload, type);
1083 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
1084 mlxsw_reg_sfgc_table_type_set(payload, table_type);
1085 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
1086 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
1087}
1088
1089
1090
1091
1092
1093
1094#define MLXSW_REG_SFDF_ID 0x2013
1095#define MLXSW_REG_SFDF_LEN 0x14
1096
1097MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
1098
1099
1100
1101
1102
1103MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1104
1105enum mlxsw_reg_sfdf_flush_type {
1106 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1107 MLXSW_REG_SFDF_FLUSH_PER_FID,
1108 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1109 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1110 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1111 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1112 MLXSW_REG_SFDF_FLUSH_PER_NVE,
1113 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
1114};
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1131
1132
1133
1134
1135
1136
1137
1138MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1139
1140static inline void mlxsw_reg_sfdf_pack(char *payload,
1141 enum mlxsw_reg_sfdf_flush_type type)
1142{
1143 MLXSW_REG_ZERO(sfdf, payload);
1144 mlxsw_reg_sfdf_flush_type_set(payload, type);
1145 mlxsw_reg_sfdf_flush_static_set(payload, true);
1146}
1147
1148
1149
1150
1151
1152MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1153
1154
1155
1156
1157
1158MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1159
1160
1161
1162
1163
1164MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1165
1166
1167
1168
1169
1170MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1171
1172
1173
1174
1175
1176MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1177
1178
1179
1180
1181
1182
1183
1184#define MLXSW_REG_SLDR_ID 0x2014
1185#define MLXSW_REG_SLDR_LEN 0x0C
1186
1187MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
1188
1189enum mlxsw_reg_sldr_op {
1190
1191 MLXSW_REG_SLDR_OP_LAG_CREATE,
1192 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1193
1194 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1195
1196 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1197};
1198
1199
1200
1201
1202
1203MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1204
1205
1206
1207
1208
1209MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1210
1211static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1212{
1213 MLXSW_REG_ZERO(sldr, payload);
1214 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1215 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1216}
1217
1218static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1219{
1220 MLXSW_REG_ZERO(sldr, payload);
1221 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1222 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1223}
1224
1225
1226
1227
1228
1229
1230
1231MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1232
1233
1234
1235
1236
1237MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1238
1239static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1240 u16 local_port)
1241{
1242 MLXSW_REG_ZERO(sldr, payload);
1243 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1244 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1245 mlxsw_reg_sldr_num_ports_set(payload, 1);
1246 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1247}
1248
1249static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1250 u16 local_port)
1251{
1252 MLXSW_REG_ZERO(sldr, payload);
1253 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1254 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1255 mlxsw_reg_sldr_num_ports_set(payload, 1);
1256 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1257}
1258
1259
1260
1261
1262
1263
1264#define MLXSW_REG_SLCR_ID 0x2015
1265#define MLXSW_REG_SLCR_LEN 0x10
1266
1267MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
1268
1269enum mlxsw_reg_slcr_pp {
1270
1271 MLXSW_REG_SLCR_PP_GLOBAL,
1272
1273 MLXSW_REG_SLCR_PP_PER_PORT,
1274};
1275
1276
1277
1278
1279
1280
1281MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1282
1283
1284
1285
1286
1287
1288
1289
1290MLXSW_ITEM32_LP(reg, slcr, 0x00, 16, 0x00, 12);
1291
1292enum mlxsw_reg_slcr_type {
1293 MLXSW_REG_SLCR_TYPE_CRC,
1294 MLXSW_REG_SLCR_TYPE_XOR,
1295 MLXSW_REG_SLCR_TYPE_RANDOM,
1296};
1297
1298
1299
1300
1301
1302MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1303
1304
1305#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1306
1307#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1308
1309#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1310#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1311 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1312 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1313
1314#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1315
1316#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1317#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1318 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1319 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1320
1321#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1322
1323#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1324#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1325 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1326 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1327
1328#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1329
1330#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1331#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1332 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1333 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1334
1335#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1336
1337#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1338
1339#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1340
1341#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1342
1343#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1344
1345#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1346
1347#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1348
1349#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1350
1351#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1352
1353#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1354
1355
1356
1357
1358
1359
1360
1361
1362MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1363
1364
1365
1366
1367
1368MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
1369
1370static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
1371{
1372 MLXSW_REG_ZERO(slcr, payload);
1373 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
1374 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
1375 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1376 mlxsw_reg_slcr_seed_set(payload, seed);
1377}
1378
1379
1380
1381
1382
1383
1384#define MLXSW_REG_SLCOR_ID 0x2016
1385#define MLXSW_REG_SLCOR_LEN 0x10
1386
1387MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
1388
1389enum mlxsw_reg_slcor_col {
1390
1391 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1392 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1393 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1394 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1395};
1396
1397
1398
1399
1400
1401MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1402
1403
1404
1405
1406
1407
1408MLXSW_ITEM32_LP(reg, slcor, 0x00, 16, 0x00, 12);
1409
1410
1411
1412
1413
1414MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1415
1416
1417
1418
1419
1420
1421MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1422
1423static inline void mlxsw_reg_slcor_pack(char *payload,
1424 u16 local_port, u16 lag_id,
1425 enum mlxsw_reg_slcor_col col)
1426{
1427 MLXSW_REG_ZERO(slcor, payload);
1428 mlxsw_reg_slcor_col_set(payload, col);
1429 mlxsw_reg_slcor_local_port_set(payload, local_port);
1430 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1431}
1432
1433static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1434 u16 local_port, u16 lag_id,
1435 u8 port_index)
1436{
1437 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1438 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1439 mlxsw_reg_slcor_port_index_set(payload, port_index);
1440}
1441
1442static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1443 u16 local_port, u16 lag_id)
1444{
1445 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1446 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1447}
1448
1449static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1450 u16 local_port, u16 lag_id)
1451{
1452 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1453 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1454}
1455
1456static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1457 u16 local_port, u16 lag_id)
1458{
1459 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1460 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1461}
1462
1463
1464
1465
1466
1467#define MLXSW_REG_SPMLR_ID 0x2018
1468#define MLXSW_REG_SPMLR_LEN 0x8
1469
1470MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
1471
1472
1473
1474
1475
1476MLXSW_ITEM32_LP(reg, spmlr, 0x00, 16, 0x00, 12);
1477
1478
1479
1480
1481
1482
1483MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1484
1485enum mlxsw_reg_spmlr_learn_mode {
1486 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1487 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1488 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1489};
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1503
1504static inline void mlxsw_reg_spmlr_pack(char *payload, u16 local_port,
1505 enum mlxsw_reg_spmlr_learn_mode mode)
1506{
1507 MLXSW_REG_ZERO(spmlr, payload);
1508 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1509 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1510 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1511}
1512
1513
1514
1515
1516
1517
1518#define MLXSW_REG_SVFA_ID 0x201C
1519#define MLXSW_REG_SVFA_LEN 0x10
1520
1521MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
1522
1523
1524
1525
1526
1527MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1528
1529
1530
1531
1532
1533
1534
1535MLXSW_ITEM32_LP(reg, svfa, 0x00, 16, 0x00, 12);
1536
1537enum mlxsw_reg_svfa_mt {
1538 MLXSW_REG_SVFA_MT_VID_TO_FID,
1539 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1540};
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1551
1552
1553
1554
1555
1556
1557
1558
1559MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1560
1561
1562
1563
1564
1565MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1566
1567
1568
1569
1570
1571MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1572
1573
1574
1575
1576
1577
1578
1579MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1580
1581
1582
1583
1584
1585
1586
1587MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1588
1589static inline void mlxsw_reg_svfa_pack(char *payload, u16 local_port,
1590 enum mlxsw_reg_svfa_mt mt, bool valid,
1591 u16 fid, u16 vid)
1592{
1593 MLXSW_REG_ZERO(svfa, payload);
1594 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1595 mlxsw_reg_svfa_swid_set(payload, 0);
1596 mlxsw_reg_svfa_local_port_set(payload, local_port);
1597 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1598 mlxsw_reg_svfa_v_set(payload, valid);
1599 mlxsw_reg_svfa_fid_set(payload, fid);
1600 mlxsw_reg_svfa_vid_set(payload, vid);
1601}
1602
1603
1604
1605
1606
1607
1608#define MLXSW_REG_SPVTR_ID 0x201D
1609#define MLXSW_REG_SPVTR_LEN 0x10
1610
1611MLXSW_REG_DEFINE(spvtr, MLXSW_REG_SPVTR_ID, MLXSW_REG_SPVTR_LEN);
1612
1613
1614
1615
1616
1617
1618
1619MLXSW_ITEM32(reg, spvtr, tport, 0x00, 24, 1);
1620
1621
1622
1623
1624
1625
1626MLXSW_ITEM32_LP(reg, spvtr, 0x00, 16, 0x00, 12);
1627
1628
1629
1630
1631
1632
1633
1634MLXSW_ITEM32(reg, spvtr, ippe, 0x04, 31, 1);
1635
1636
1637
1638
1639
1640
1641
1642
1643MLXSW_ITEM32(reg, spvtr, ipve, 0x04, 30, 1);
1644
1645
1646
1647
1648
1649
1650
1651MLXSW_ITEM32(reg, spvtr, epve, 0x04, 29, 1);
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663MLXSW_ITEM32(reg, spvtr, ipprio_mode, 0x04, 20, 4);
1664
1665enum mlxsw_reg_spvtr_ipvid_mode {
1666
1667 MLXSW_REG_SPVTR_IPVID_MODE_IEEE_COMPLIANT_PVID,
1668
1669 MLXSW_REG_SPVTR_IPVID_MODE_PUSH_VLAN_FOR_UNTAGGED_PACKET,
1670
1671 MLXSW_REG_SPVTR_IPVID_MODE_ALWAYS_PUSH_VLAN,
1672};
1673
1674
1675
1676
1677
1678
1679MLXSW_ITEM32(reg, spvtr, ipvid_mode, 0x04, 16, 4);
1680
1681enum mlxsw_reg_spvtr_epvid_mode {
1682
1683 MLXSW_REG_SPVTR_EPVID_MODE_IEEE_COMPLIANT_VLAN_MEMBERSHIP,
1684
1685 MLXSW_REG_SPVTR_EPVID_MODE_POP_VLAN,
1686};
1687
1688
1689
1690
1691
1692
1693MLXSW_ITEM32(reg, spvtr, epvid_mode, 0x04, 0, 4);
1694
1695static inline void mlxsw_reg_spvtr_pack(char *payload, bool tport,
1696 u16 local_port,
1697 enum mlxsw_reg_spvtr_ipvid_mode ipvid_mode)
1698{
1699 MLXSW_REG_ZERO(spvtr, payload);
1700 mlxsw_reg_spvtr_tport_set(payload, tport);
1701 mlxsw_reg_spvtr_local_port_set(payload, local_port);
1702 mlxsw_reg_spvtr_ipvid_mode_set(payload, ipvid_mode);
1703 mlxsw_reg_spvtr_ipve_set(payload, true);
1704}
1705
1706
1707
1708
1709
1710#define MLXSW_REG_SVPE_ID 0x201E
1711#define MLXSW_REG_SVPE_LEN 0x4
1712
1713MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
1714
1715
1716
1717
1718
1719
1720
1721MLXSW_ITEM32_LP(reg, svpe, 0x00, 16, 0x00, 12);
1722
1723
1724
1725
1726
1727
1728
1729MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1730
1731static inline void mlxsw_reg_svpe_pack(char *payload, u16 local_port,
1732 bool enable)
1733{
1734 MLXSW_REG_ZERO(svpe, payload);
1735 mlxsw_reg_svpe_local_port_set(payload, local_port);
1736 mlxsw_reg_svpe_vp_en_set(payload, enable);
1737}
1738
1739
1740
1741
1742
1743#define MLXSW_REG_SFMR_ID 0x201F
1744#define MLXSW_REG_SFMR_LEN 0x18
1745
1746MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
1747
1748enum mlxsw_reg_sfmr_op {
1749 MLXSW_REG_SFMR_OP_CREATE_FID,
1750 MLXSW_REG_SFMR_OP_DESTROY_FID,
1751};
1752
1753
1754
1755
1756
1757
1758
1759MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1760
1761
1762
1763
1764
1765MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1766
1767
1768
1769
1770
1771
1772
1773MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1774
1775
1776
1777
1778
1779
1780
1781
1782MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1783
1784
1785
1786
1787
1788
1789
1790MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1791
1792
1793
1794
1795
1796
1797
1798
1799MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1800
1801
1802
1803
1804
1805
1806
1807MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1808
1809static inline void mlxsw_reg_sfmr_pack(char *payload,
1810 enum mlxsw_reg_sfmr_op op, u16 fid,
1811 u16 fid_offset)
1812{
1813 MLXSW_REG_ZERO(sfmr, payload);
1814 mlxsw_reg_sfmr_op_set(payload, op);
1815 mlxsw_reg_sfmr_fid_set(payload, fid);
1816 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1817 mlxsw_reg_sfmr_vtfp_set(payload, false);
1818 mlxsw_reg_sfmr_vv_set(payload, false);
1819}
1820
1821
1822
1823
1824
1825#define MLXSW_REG_SPVMLR_ID 0x2020
1826#define MLXSW_REG_SPVMLR_BASE_LEN 0x04
1827#define MLXSW_REG_SPVMLR_REC_LEN 0x04
1828#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
1829#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1830 MLXSW_REG_SPVMLR_REC_LEN * \
1831 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1832
1833MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
1834
1835
1836
1837
1838
1839
1840
1841MLXSW_ITEM32_LP(reg, spvmlr, 0x00, 16, 0x00, 12);
1842
1843
1844
1845
1846
1847MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1848
1849
1850
1851
1852
1853
1854MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1855 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1856
1857
1858
1859
1860
1861MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1862 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1863
1864static inline void mlxsw_reg_spvmlr_pack(char *payload, u16 local_port,
1865 u16 vid_begin, u16 vid_end,
1866 bool learn_enable)
1867{
1868 int num_rec = vid_end - vid_begin + 1;
1869 int i;
1870
1871 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1872
1873 MLXSW_REG_ZERO(spvmlr, payload);
1874 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1875 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1876
1877 for (i = 0; i < num_rec; i++) {
1878 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1879 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1880 }
1881}
1882
1883
1884
1885
1886
1887
1888
1889#define MLXSW_REG_SPVC_ID 0x2026
1890#define MLXSW_REG_SPVC_LEN 0x0C
1891
1892MLXSW_REG_DEFINE(spvc, MLXSW_REG_SPVC_ID, MLXSW_REG_SPVC_LEN);
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902MLXSW_ITEM32_LP(reg, spvc, 0x00, 16, 0x00, 12);
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913MLXSW_ITEM32(reg, spvc, inner_et2, 0x08, 17, 1);
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923MLXSW_ITEM32(reg, spvc, et2, 0x08, 16, 1);
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934MLXSW_ITEM32(reg, spvc, inner_et1, 0x08, 9, 1);
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944MLXSW_ITEM32(reg, spvc, et1, 0x08, 8, 1);
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955MLXSW_ITEM32(reg, spvc, inner_et0, 0x08, 1, 1);
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965MLXSW_ITEM32(reg, spvc, et0, 0x08, 0, 1);
1966
1967static inline void mlxsw_reg_spvc_pack(char *payload, u16 local_port, bool et1,
1968 bool et0)
1969{
1970 MLXSW_REG_ZERO(spvc, payload);
1971 mlxsw_reg_spvc_local_port_set(payload, local_port);
1972
1973
1974
1975 mlxsw_reg_spvc_inner_et1_set(payload, 1);
1976 mlxsw_reg_spvc_inner_et0_set(payload, 1);
1977 mlxsw_reg_spvc_et1_set(payload, et1);
1978 mlxsw_reg_spvc_et0_set(payload, et0);
1979}
1980
1981
1982
1983
1984
1985
1986
1987#define MLXSW_REG_SPEVET_ID 0x202A
1988#define MLXSW_REG_SPEVET_LEN 0x08
1989
1990MLXSW_REG_DEFINE(spevet, MLXSW_REG_SPEVET_ID, MLXSW_REG_SPEVET_LEN);
1991
1992
1993
1994
1995
1996
1997MLXSW_ITEM32_LP(reg, spevet, 0x00, 16, 0x00, 12);
1998
1999
2000
2001
2002
2003
2004
2005
2006MLXSW_ITEM32(reg, spevet, et_vlan, 0x04, 16, 2);
2007
2008static inline void mlxsw_reg_spevet_pack(char *payload, u16 local_port,
2009 u8 et_vlan)
2010{
2011 MLXSW_REG_ZERO(spevet, payload);
2012 mlxsw_reg_spevet_local_port_set(payload, local_port);
2013 mlxsw_reg_spevet_et_vlan_set(payload, et_vlan);
2014}
2015
2016
2017
2018
2019
2020
2021#define MLXSW_REG_SFTR2_ID 0x202F
2022#define MLXSW_REG_SFTR2_LEN 0x120
2023
2024MLXSW_REG_DEFINE(sftr2, MLXSW_REG_SFTR2_ID, MLXSW_REG_SFTR2_LEN);
2025
2026
2027
2028
2029
2030MLXSW_ITEM32(reg, sftr2, swid, 0x00, 24, 8);
2031
2032
2033
2034
2035
2036
2037MLXSW_ITEM32(reg, sftr2, flood_table, 0x00, 16, 6);
2038
2039
2040
2041
2042
2043
2044MLXSW_ITEM32(reg, sftr2, index, 0x00, 0, 16);
2045
2046
2047
2048
2049
2050MLXSW_ITEM32(reg, sftr2, table_type, 0x04, 16, 3);
2051
2052
2053
2054
2055
2056MLXSW_ITEM32(reg, sftr2, range, 0x04, 0, 16);
2057
2058
2059
2060
2061
2062MLXSW_ITEM_BIT_ARRAY(reg, sftr2, port, 0x20, 0x80, 1);
2063
2064
2065
2066
2067
2068MLXSW_ITEM_BIT_ARRAY(reg, sftr2, port_mask, 0xA0, 0x80, 1);
2069
2070static inline void mlxsw_reg_sftr2_pack(char *payload,
2071 unsigned int flood_table,
2072 unsigned int index,
2073 enum mlxsw_flood_table_type table_type,
2074 unsigned int range, u16 port, bool set)
2075{
2076 MLXSW_REG_ZERO(sftr2, payload);
2077 mlxsw_reg_sftr2_swid_set(payload, 0);
2078 mlxsw_reg_sftr2_flood_table_set(payload, flood_table);
2079 mlxsw_reg_sftr2_index_set(payload, index);
2080 mlxsw_reg_sftr2_table_type_set(payload, table_type);
2081 mlxsw_reg_sftr2_range_set(payload, range);
2082 mlxsw_reg_sftr2_port_set(payload, port, set);
2083 mlxsw_reg_sftr2_port_mask_set(payload, port, 1);
2084}
2085
2086
2087
2088
2089
2090
2091
2092#define MLXSW_REG_SMID2_ID 0x2034
2093#define MLXSW_REG_SMID2_LEN 0x120
2094
2095MLXSW_REG_DEFINE(smid2, MLXSW_REG_SMID2_ID, MLXSW_REG_SMID2_LEN);
2096
2097
2098
2099
2100
2101MLXSW_ITEM32(reg, smid2, swid, 0x00, 24, 8);
2102
2103
2104
2105
2106
2107
2108MLXSW_ITEM32(reg, smid2, mid, 0x00, 0, 16);
2109
2110
2111
2112
2113
2114MLXSW_ITEM_BIT_ARRAY(reg, smid2, port, 0x20, 0x80, 1);
2115
2116
2117
2118
2119
2120MLXSW_ITEM_BIT_ARRAY(reg, smid2, port_mask, 0xA0, 0x80, 1);
2121
2122static inline void mlxsw_reg_smid2_pack(char *payload, u16 mid, u16 port,
2123 bool set)
2124{
2125 MLXSW_REG_ZERO(smid2, payload);
2126 mlxsw_reg_smid2_swid_set(payload, 0);
2127 mlxsw_reg_smid2_mid_set(payload, mid);
2128 mlxsw_reg_smid2_port_set(payload, port, set);
2129 mlxsw_reg_smid2_port_mask_set(payload, port, 1);
2130}
2131
2132
2133
2134
2135
2136#define MLXSW_REG_CWTP_ID 0x2802
2137#define MLXSW_REG_CWTP_BASE_LEN 0x28
2138#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
2139#define MLXSW_REG_CWTP_LEN 0x40
2140
2141MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
2142
2143
2144
2145
2146
2147
2148MLXSW_ITEM32_LP(reg, cwtp, 0x00, 16, 0x00, 12);
2149
2150
2151
2152
2153
2154MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
2155
2156
2157
2158
2159
2160MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
2161 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
2162
2163
2164
2165
2166
2167
2168MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
2169 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2170
2171
2172
2173
2174
2175MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
2176 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
2177
2178#define MLXSW_REG_CWTP_MIN_VALUE 64
2179#define MLXSW_REG_CWTP_MAX_PROFILE 2
2180#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
2181
2182static inline void mlxsw_reg_cwtp_pack(char *payload, u16 local_port,
2183 u8 traffic_class)
2184{
2185 int i;
2186
2187 MLXSW_REG_ZERO(cwtp, payload);
2188 mlxsw_reg_cwtp_local_port_set(payload, local_port);
2189 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
2190
2191 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
2192 mlxsw_reg_cwtp_profile_min_set(payload, i,
2193 MLXSW_REG_CWTP_MIN_VALUE);
2194 mlxsw_reg_cwtp_profile_max_set(payload, i,
2195 MLXSW_REG_CWTP_MIN_VALUE);
2196 }
2197}
2198
2199#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
2200
2201static inline void
2202mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
2203 u32 probability)
2204{
2205 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
2206
2207 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
2208 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
2209 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
2210}
2211
2212
2213
2214
2215
2216#define MLXSW_REG_CWTPM_ID 0x2803
2217#define MLXSW_REG_CWTPM_LEN 0x44
2218
2219MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
2220
2221
2222
2223
2224
2225
2226MLXSW_ITEM32_LP(reg, cwtpm, 0x00, 16, 0x00, 12);
2227
2228
2229
2230
2231
2232MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
2233
2234
2235
2236
2237
2238
2239
2240MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
2241
2242
2243
2244
2245
2246
2247
2248MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
2249
2250
2251
2252
2253
2254
2255
2256MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
2257
2258
2259
2260
2261
2262
2263
2264MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
2265
2266
2267
2268
2269
2270
2271
2272MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
2273
2274
2275
2276
2277
2278
2279
2280MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
2281
2282
2283
2284
2285
2286
2287
2288MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
2289
2290
2291
2292
2293
2294
2295
2296MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
2297
2298#define MLXSW_REG_CWTPM_RESET_PROFILE 0
2299
2300static inline void mlxsw_reg_cwtpm_pack(char *payload, u16 local_port,
2301 u8 traffic_class, u8 profile,
2302 bool wred, bool ecn)
2303{
2304 MLXSW_REG_ZERO(cwtpm, payload);
2305 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
2306 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
2307 mlxsw_reg_cwtpm_ew_set(payload, wred);
2308 mlxsw_reg_cwtpm_ee_set(payload, ecn);
2309 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
2310 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
2311 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
2312 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
2313 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
2314 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
2315}
2316
2317
2318
2319
2320
2321#define MLXSW_REG_PGCR_ID 0x3001
2322#define MLXSW_REG_PGCR_LEN 0x20
2323
2324MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
2325
2326
2327
2328
2329
2330
2331MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
2332
2333static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
2334{
2335 MLXSW_REG_ZERO(pgcr, payload);
2336 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
2337}
2338
2339
2340
2341
2342
2343#define MLXSW_REG_PPBT_ID 0x3002
2344#define MLXSW_REG_PPBT_LEN 0x14
2345
2346MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
2347
2348enum mlxsw_reg_pxbt_e {
2349 MLXSW_REG_PXBT_E_IACL,
2350 MLXSW_REG_PXBT_E_EACL,
2351};
2352
2353
2354
2355
2356MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
2357
2358enum mlxsw_reg_pxbt_op {
2359 MLXSW_REG_PXBT_OP_BIND,
2360 MLXSW_REG_PXBT_OP_UNBIND,
2361};
2362
2363
2364
2365
2366MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
2367
2368
2369
2370
2371
2372MLXSW_ITEM32_LP(reg, ppbt, 0x00, 16, 0x00, 12);
2373
2374
2375
2376
2377
2378
2379
2380MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
2381
2382
2383
2384
2385
2386
2387MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
2388
2389static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
2390 enum mlxsw_reg_pxbt_op op,
2391 u16 local_port, u16 acl_info)
2392{
2393 MLXSW_REG_ZERO(ppbt, payload);
2394 mlxsw_reg_ppbt_e_set(payload, e);
2395 mlxsw_reg_ppbt_op_set(payload, op);
2396 mlxsw_reg_ppbt_local_port_set(payload, local_port);
2397 mlxsw_reg_ppbt_g_set(payload, true);
2398 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
2399}
2400
2401
2402
2403
2404
2405#define MLXSW_REG_PACL_ID 0x3004
2406#define MLXSW_REG_PACL_LEN 0x70
2407
2408MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2409
2410
2411
2412
2413
2414
2415MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2416
2417
2418
2419
2420
2421
2422MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2423
2424#define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2425
2426
2427
2428
2429
2430
2431MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2432 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2433
2434static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2435 bool valid, const char *tcam_region_info)
2436{
2437 MLXSW_REG_ZERO(pacl, payload);
2438 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2439 mlxsw_reg_pacl_v_set(payload, valid);
2440 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2441}
2442
2443
2444
2445
2446
2447#define MLXSW_REG_PAGT_ID 0x3005
2448#define MLXSW_REG_PAGT_BASE_LEN 0x30
2449#define MLXSW_REG_PAGT_ACL_LEN 4
2450#define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2451#define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2452 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2453
2454MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2466
2467
2468
2469
2470
2471
2472MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2473
2474
2475
2476
2477
2478
2479
2480MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
2481
2482
2483
2484
2485
2486MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2487
2488static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2489{
2490 MLXSW_REG_ZERO(pagt, payload);
2491 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2492}
2493
2494static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2495 u16 acl_id, bool multi)
2496{
2497 u8 size = mlxsw_reg_pagt_size_get(payload);
2498
2499 if (index >= size)
2500 mlxsw_reg_pagt_size_set(payload, index + 1);
2501 mlxsw_reg_pagt_multi_set(payload, index, multi);
2502 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2503}
2504
2505
2506
2507
2508
2509
2510#define MLXSW_REG_PTAR_ID 0x3006
2511#define MLXSW_REG_PTAR_BASE_LEN 0x20
2512#define MLXSW_REG_PTAR_KEY_ID_LEN 1
2513#define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2514#define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2515 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2516
2517MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2518
2519enum mlxsw_reg_ptar_op {
2520
2521 MLXSW_REG_PTAR_OP_ALLOC,
2522
2523 MLXSW_REG_PTAR_OP_RESIZE,
2524
2525 MLXSW_REG_PTAR_OP_FREE,
2526
2527 MLXSW_REG_PTAR_OP_TEST,
2528};
2529
2530
2531
2532
2533MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2534
2535
2536
2537
2538
2539
2540MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2541
2542enum mlxsw_reg_ptar_key_type {
2543 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50,
2544 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51,
2545};
2546
2547
2548
2549
2550
2551MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2562
2563
2564
2565
2566
2567
2568MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2569
2570
2571
2572
2573
2574
2575
2576MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2577 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2588 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2589
2590static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
2591 enum mlxsw_reg_ptar_key_type key_type,
2592 u16 region_size, u16 region_id,
2593 const char *tcam_region_info)
2594{
2595 MLXSW_REG_ZERO(ptar, payload);
2596 mlxsw_reg_ptar_op_set(payload, op);
2597 mlxsw_reg_ptar_action_set_type_set(payload, 2);
2598 mlxsw_reg_ptar_key_type_set(payload, key_type);
2599 mlxsw_reg_ptar_region_size_set(payload, region_size);
2600 mlxsw_reg_ptar_region_id_set(payload, region_id);
2601 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2602}
2603
2604static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2605 u16 key_id)
2606{
2607 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2608}
2609
2610static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2611{
2612 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2613}
2614
2615
2616
2617
2618
2619#define MLXSW_REG_PPBS_ID 0x300C
2620#define MLXSW_REG_PPBS_LEN 0x14
2621
2622MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2623
2624
2625
2626
2627
2628
2629MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2630
2631
2632
2633
2634
2635MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2636
2637static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2638 u16 system_port)
2639{
2640 MLXSW_REG_ZERO(ppbs, payload);
2641 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2642 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2643}
2644
2645
2646
2647
2648
2649#define MLXSW_REG_PRCR_ID 0x300D
2650#define MLXSW_REG_PRCR_LEN 0x40
2651
2652MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2653
2654enum mlxsw_reg_prcr_op {
2655
2656
2657
2658
2659 MLXSW_REG_PRCR_OP_MOVE,
2660
2661
2662
2663
2664 MLXSW_REG_PRCR_OP_COPY,
2665};
2666
2667
2668
2669
2670MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2671
2672
2673
2674
2675
2676MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2677
2678
2679
2680
2681
2682MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2683
2684
2685
2686
2687
2688MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2689 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2690
2691
2692
2693
2694
2695MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2696
2697
2698
2699
2700
2701MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2702 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2703
2704static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2705 const char *src_tcam_region_info,
2706 u16 src_offset,
2707 const char *dest_tcam_region_info,
2708 u16 dest_offset, u16 size)
2709{
2710 MLXSW_REG_ZERO(prcr, payload);
2711 mlxsw_reg_prcr_op_set(payload, op);
2712 mlxsw_reg_prcr_offset_set(payload, src_offset);
2713 mlxsw_reg_prcr_size_set(payload, size);
2714 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2715 src_tcam_region_info);
2716 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2717 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2718 dest_tcam_region_info);
2719}
2720
2721
2722
2723
2724
2725
2726#define MLXSW_REG_PEFA_ID 0x300F
2727#define MLXSW_REG_PEFA_LEN 0xB0
2728
2729MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2730
2731
2732
2733
2734
2735MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2736
2737
2738
2739
2740
2741
2742
2743
2744MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2745
2746
2747
2748
2749
2750
2751
2752MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2753
2754#define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
2755
2756
2757
2758
2759
2760
2761MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
2762
2763static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
2764 const char *flex_action_set)
2765{
2766 MLXSW_REG_ZERO(pefa, payload);
2767 mlxsw_reg_pefa_index_set(payload, index);
2768 mlxsw_reg_pefa_ca_set(payload, ca);
2769 if (flex_action_set)
2770 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2771 flex_action_set);
2772}
2773
2774static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2775{
2776 *p_a = mlxsw_reg_pefa_a_get(payload);
2777}
2778
2779
2780
2781
2782
2783
2784
2785#define MLXSW_REG_PEMRBT_ID 0x3014
2786#define MLXSW_REG_PEMRBT_LEN 0x14
2787
2788MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
2789
2790enum mlxsw_reg_pemrbt_protocol {
2791 MLXSW_REG_PEMRBT_PROTO_IPV4,
2792 MLXSW_REG_PEMRBT_PROTO_IPV6,
2793};
2794
2795
2796
2797
2798MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
2799
2800
2801
2802
2803
2804
2805MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
2806
2807static inline void
2808mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
2809 u16 group_id)
2810{
2811 MLXSW_REG_ZERO(pemrbt, payload);
2812 mlxsw_reg_pemrbt_protocol_set(payload, protocol);
2813 mlxsw_reg_pemrbt_group_id_set(payload, group_id);
2814}
2815
2816
2817
2818
2819
2820
2821
2822
2823#define MLXSW_REG_PTCE2_ID 0x3017
2824#define MLXSW_REG_PTCE2_LEN 0x1D8
2825
2826MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2827
2828
2829
2830
2831
2832MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2833
2834
2835
2836
2837
2838
2839MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2840
2841enum mlxsw_reg_ptce2_op {
2842
2843 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2844
2845
2846
2847 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2848
2849
2850
2851
2852 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2853
2854 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2855
2856 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2857};
2858
2859
2860
2861
2862MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2863
2864
2865
2866
2867MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2868
2869
2870
2871
2872
2873
2874
2875
2876MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2877
2878
2879
2880
2881
2882MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2883 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2884
2885#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
2886
2887
2888
2889
2890
2891MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
2892 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2893
2894
2895
2896
2897
2898
2899
2900MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
2901 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2902
2903
2904
2905
2906
2907MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
2908 MLXSW_REG_FLEX_ACTION_SET_LEN);
2909
2910static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2911 enum mlxsw_reg_ptce2_op op,
2912 const char *tcam_region_info,
2913 u16 offset, u32 priority)
2914{
2915 MLXSW_REG_ZERO(ptce2, payload);
2916 mlxsw_reg_ptce2_v_set(payload, valid);
2917 mlxsw_reg_ptce2_op_set(payload, op);
2918 mlxsw_reg_ptce2_offset_set(payload, offset);
2919 mlxsw_reg_ptce2_priority_set(payload, priority);
2920 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2921}
2922
2923
2924
2925
2926
2927#define MLXSW_REG_PERPT_ID 0x3021
2928#define MLXSW_REG_PERPT_LEN 0x80
2929
2930MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2931
2932
2933
2934
2935
2936
2937MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2938
2939
2940
2941
2942
2943
2944MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2945
2946enum mlxsw_reg_perpt_key_size {
2947 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2948 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2949 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2950 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2951};
2952
2953
2954
2955
2956MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2957
2958
2959
2960
2961
2962
2963
2964
2965MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2966
2967
2968
2969
2970
2971MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2972
2973
2974
2975
2976
2977
2978MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2979
2980
2981
2982
2983
2984
2985MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2986
2987
2988
2989
2990
2991MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2992
2993
2994
2995
2996
2997MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2998
2999
3000
3001
3002
3003
3004
3005MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3006
3007static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
3008 unsigned long *erp_vector,
3009 unsigned long size)
3010{
3011 unsigned long bit;
3012
3013 for_each_set_bit(bit, erp_vector, size)
3014 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
3015}
3016
3017static inline void
3018mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
3019 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
3020 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
3021 char *mask)
3022{
3023 MLXSW_REG_ZERO(perpt, payload);
3024 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
3025 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
3026 mlxsw_reg_perpt_key_size_set(payload, key_size);
3027 mlxsw_reg_perpt_bf_bypass_set(payload, false);
3028 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
3029 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
3030 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
3031 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
3032 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
3033}
3034
3035
3036
3037
3038
3039
3040#define MLXSW_REG_PERAR_ID 0x3026
3041#define MLXSW_REG_PERAR_LEN 0x08
3042
3043MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
3044
3045
3046
3047
3048
3049
3050MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
3051
3052static inline unsigned int
3053mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
3054{
3055 return DIV_ROUND_UP(block_num, 4);
3056}
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
3067
3068static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
3069 u16 hw_region)
3070{
3071 MLXSW_REG_ZERO(perar, payload);
3072 mlxsw_reg_perar_region_id_set(payload, region_id);
3073 mlxsw_reg_perar_hw_region_set(payload, hw_region);
3074}
3075
3076
3077
3078
3079
3080
3081#define MLXSW_REG_PTCE3_ID 0x3027
3082#define MLXSW_REG_PTCE3_LEN 0xF0
3083
3084MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
3085
3086
3087
3088
3089
3090MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
3091
3092enum mlxsw_reg_ptce3_op {
3093
3094
3095
3096
3097
3098 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
3099
3100 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
3101
3102 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
3103};
3104
3105
3106
3107
3108MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
3109
3110
3111
3112
3113
3114
3115
3116MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
3117
3118
3119
3120
3121
3122MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
3123 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
3124
3125
3126
3127
3128
3129
3130MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
3131 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
3132
3133
3134
3135
3136
3137MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
3138
3139
3140
3141
3142
3143
3144MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
3156
3157
3158
3159
3160
3161
3162MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
3175
3176
3177
3178
3179
3180
3181
3182MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
3206
3207
3208
3209
3210
3211
3212MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
3213
3214static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
3215 enum mlxsw_reg_ptce3_op op,
3216 u32 priority,
3217 const char *tcam_region_info,
3218 const char *key, u8 erp_id,
3219 u16 delta_start, u8 delta_mask,
3220 u8 delta_value, bool large_exists,
3221 u32 lkey_id, u32 action_pointer)
3222{
3223 MLXSW_REG_ZERO(ptce3, payload);
3224 mlxsw_reg_ptce3_v_set(payload, valid);
3225 mlxsw_reg_ptce3_op_set(payload, op);
3226 mlxsw_reg_ptce3_priority_set(payload, priority);
3227 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
3228 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
3229 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
3230 mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
3231 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
3232 mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
3233 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
3234 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
3235 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
3236}
3237
3238
3239
3240
3241
3242
3243#define MLXSW_REG_PERCR_ID 0x302A
3244#define MLXSW_REG_PERCR_LEN 0x80
3245
3246MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
3247
3248
3249
3250
3251
3252
3253MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
3254
3255
3256
3257
3258
3259MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
3260
3261
3262
3263
3264
3265MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
3266
3267
3268
3269
3270
3271
3272
3273
3274MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
3275
3276
3277
3278
3279
3280
3281
3282MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
3283
3284static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
3285{
3286 MLXSW_REG_ZERO(percr, payload);
3287 mlxsw_reg_percr_region_id_set(payload, region_id);
3288 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
3289 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
3290 mlxsw_reg_percr_bf_bypass_set(payload, false);
3291}
3292
3293
3294
3295
3296
3297
3298#define MLXSW_REG_PERERP_ID 0x302B
3299#define MLXSW_REG_PERERP_LEN 0x1C
3300
3301MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
3302
3303
3304
3305
3306
3307
3308MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
3309
3310
3311
3312
3313
3314MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
3315
3316
3317
3318
3319
3320MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
3321
3322
3323
3324
3325
3326
3327MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
3328
3329
3330
3331
3332
3333
3334
3335
3336MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
3337
3338
3339
3340
3341
3342
3343
3344
3345MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
3346
3347
3348
3349
3350
3351
3352
3353MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
3354
3355static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
3356 unsigned long *erp_vector,
3357 unsigned long size)
3358{
3359 unsigned long bit;
3360
3361 for_each_set_bit(bit, erp_vector, size)
3362 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
3363}
3364
3365static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
3366 bool ctcam_le, bool erpt_pointer_valid,
3367 u8 erpt_bank_pointer, u8 erpt_pointer,
3368 u8 master_rp_id)
3369{
3370 MLXSW_REG_ZERO(pererp, payload);
3371 mlxsw_reg_pererp_region_id_set(payload, region_id);
3372 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
3373 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
3374 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
3375 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
3376 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
3377}
3378
3379
3380
3381
3382
3383#define MLXSW_REG_PEABFE_ID 0x3022
3384#define MLXSW_REG_PEABFE_BASE_LEN 0x10
3385#define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
3386#define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
3387#define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
3388 MLXSW_REG_PEABFE_BF_REC_LEN * \
3389 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
3390
3391MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
3392
3393
3394
3395
3396
3397
3398MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
3399
3400
3401
3402
3403
3404
3405
3406MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
3407 MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
3408 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3409
3410
3411
3412
3413
3414
3415MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
3416 MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
3417 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3418
3419
3420
3421
3422
3423
3424MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
3425 MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
3426 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
3427
3428static inline void mlxsw_reg_peabfe_pack(char *payload)
3429{
3430 MLXSW_REG_ZERO(peabfe, payload);
3431}
3432
3433static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
3434 u8 state, u8 bank, u32 bf_index)
3435{
3436 u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
3437
3438 if (rec_index >= num_rec)
3439 mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
3440 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
3441 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
3442 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
3443}
3444
3445
3446
3447
3448
3449
3450
3451#define MLXSW_REG_IEDR_ID 0x3804
3452#define MLXSW_REG_IEDR_BASE_LEN 0x10
3453#define MLXSW_REG_IEDR_REC_LEN 0x8
3454#define MLXSW_REG_IEDR_REC_MAX_COUNT 64
3455#define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
3456 MLXSW_REG_IEDR_REC_LEN * \
3457 MLXSW_REG_IEDR_REC_MAX_COUNT)
3458
3459MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
3460
3461
3462
3463
3464
3465MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
3466
3467
3468
3469
3470
3471MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
3472 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3473
3474
3475
3476
3477
3478MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13,
3479 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
3480
3481
3482
3483
3484
3485MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
3486 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
3487
3488static inline void mlxsw_reg_iedr_pack(char *payload)
3489{
3490 MLXSW_REG_ZERO(iedr, payload);
3491}
3492
3493static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
3494 u8 rec_type, u16 rec_size,
3495 u32 rec_index_start)
3496{
3497 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
3498
3499 if (rec_index >= num_rec)
3500 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
3501 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
3502 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
3503 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
3504}
3505
3506
3507
3508
3509
3510
3511#define MLXSW_REG_QPTS_ID 0x4002
3512#define MLXSW_REG_QPTS_LEN 0x8
3513
3514MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
3515
3516
3517
3518
3519
3520
3521
3522MLXSW_ITEM32_LP(reg, qpts, 0x00, 16, 0x00, 12);
3523
3524enum mlxsw_reg_qpts_trust_state {
3525 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3526 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2,
3527};
3528
3529
3530
3531
3532
3533MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3534
3535static inline void mlxsw_reg_qpts_pack(char *payload, u16 local_port,
3536 enum mlxsw_reg_qpts_trust_state ts)
3537{
3538 MLXSW_REG_ZERO(qpts, payload);
3539
3540 mlxsw_reg_qpts_local_port_set(payload, local_port);
3541 mlxsw_reg_qpts_trust_state_set(payload, ts);
3542}
3543
3544
3545
3546
3547
3548
3549#define MLXSW_REG_QPCR_ID 0x4004
3550#define MLXSW_REG_QPCR_LEN 0x28
3551
3552MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3553
3554enum mlxsw_reg_qpcr_g {
3555 MLXSW_REG_QPCR_G_GLOBAL = 2,
3556 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3557};
3558
3559
3560
3561
3562
3563MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3564
3565
3566
3567
3568
3569MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3570
3571
3572
3573
3574
3575MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1);
3576
3577
3578
3579
3580
3581
3582MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3583
3584
3585
3586
3587
3588
3589
3590MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3591
3592enum mlxsw_reg_qpcr_ir_units {
3593 MLXSW_REG_QPCR_IR_UNITS_M,
3594 MLXSW_REG_QPCR_IR_UNITS_K,
3595};
3596
3597
3598
3599
3600
3601
3602
3603MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3604
3605enum mlxsw_reg_qpcr_rate_type {
3606 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3607 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3608};
3609
3610
3611
3612
3613
3614
3615
3616MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3630
3631
3632
3633
3634
3635
3636
3637
3638MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3649
3650#define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3651
3652
3653
3654
3655
3656MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3657
3658enum mlxsw_reg_qpcr_action {
3659
3660 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3661
3662
3663
3664 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3665};
3666
3667
3668
3669
3670
3671
3672MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3673
3674
3675
3676
3677
3678MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64);
3679
3680
3681#define MLXSW_REG_QPCR_LOWEST_CIR 1
3682#define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000)
3683#define MLXSW_REG_QPCR_LOWEST_CBS 4
3684#define MLXSW_REG_QPCR_HIGHEST_CBS 24
3685
3686
3687#define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024
3688#define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL
3689#define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4
3690#define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4
3691#define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25
3692#define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31
3693
3694static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3695 enum mlxsw_reg_qpcr_ir_units ir_units,
3696 bool bytes, u32 cir, u16 cbs)
3697{
3698 MLXSW_REG_ZERO(qpcr, payload);
3699 mlxsw_reg_qpcr_pid_set(payload, pid);
3700 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3701 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3702 mlxsw_reg_qpcr_violate_action_set(payload,
3703 MLXSW_REG_QPCR_ACTION_DISCARD);
3704 mlxsw_reg_qpcr_cir_set(payload, cir);
3705 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3706 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3707 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3708}
3709
3710
3711
3712
3713
3714
3715#define MLXSW_REG_QTCT_ID 0x400A
3716#define MLXSW_REG_QTCT_LEN 0x08
3717
3718MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
3719
3720
3721
3722
3723
3724
3725
3726MLXSW_ITEM32_LP(reg, qtct, 0x00, 16, 0x00, 12);
3727
3728
3729
3730
3731
3732
3733MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3734
3735
3736
3737
3738
3739MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3750
3751static inline void mlxsw_reg_qtct_pack(char *payload, u16 local_port,
3752 u8 switch_prio, u8 tclass)
3753{
3754 MLXSW_REG_ZERO(qtct, payload);
3755 mlxsw_reg_qtct_local_port_set(payload, local_port);
3756 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3757 mlxsw_reg_qtct_tclass_set(payload, tclass);
3758}
3759
3760
3761
3762
3763
3764#define MLXSW_REG_QEEC_ID 0x400D
3765#define MLXSW_REG_QEEC_LEN 0x20
3766
3767MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
3768
3769
3770
3771
3772
3773
3774
3775MLXSW_ITEM32_LP(reg, qeec, 0x00, 16, 0x00, 12);
3776
3777enum mlxsw_reg_qeec_hr {
3778 MLXSW_REG_QEEC_HR_PORT,
3779 MLXSW_REG_QEEC_HR_GROUP,
3780 MLXSW_REG_QEEC_HR_SUBGROUP,
3781 MLXSW_REG_QEEC_HR_TC,
3782};
3783
3784
3785
3786
3787
3788
3789
3790
3791MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3792
3793
3794
3795
3796
3797MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3798
3799
3800
3801
3802
3803
3804
3805MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3806
3807
3808
3809
3810
3811
3812
3813
3814MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
3827
3828enum {
3829 MLXSW_REG_QEEC_BYTES_MODE,
3830 MLXSW_REG_QEEC_PACKETS_MODE,
3831};
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3843
3844
3845#define MLXSW_REG_QEEC_MIS_MIN 200000
3846
3847
3848
3849
3850
3851
3852
3853MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3854
3855
3856
3857
3858
3859
3860
3861
3862MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3863
3864
3865#define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1)
3866
3867
3868
3869
3870
3871
3872
3873MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31);
3874
3875
3876
3877
3878
3879
3880
3881
3882MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3883
3884
3885
3886
3887
3888
3889
3890
3891MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
3912
3913#define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25
3914#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
3915#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
3916#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11
3917#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4 11
3918
3919static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
3920 enum mlxsw_reg_qeec_hr hr, u8 index,
3921 u8 next_index)
3922{
3923 MLXSW_REG_ZERO(qeec, payload);
3924 mlxsw_reg_qeec_local_port_set(payload, local_port);
3925 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3926 mlxsw_reg_qeec_element_index_set(payload, index);
3927 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3928}
3929
3930static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u16 local_port,
3931 bool ptps)
3932{
3933 MLXSW_REG_ZERO(qeec, payload);
3934 mlxsw_reg_qeec_local_port_set(payload, local_port);
3935 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
3936 mlxsw_reg_qeec_ptps_set(payload, ptps);
3937}
3938
3939
3940
3941
3942
3943#define MLXSW_REG_QRWE_ID 0x400F
3944#define MLXSW_REG_QRWE_LEN 0x08
3945
3946MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3947
3948
3949
3950
3951
3952
3953
3954MLXSW_ITEM32_LP(reg, qrwe, 0x00, 16, 0x00, 12);
3955
3956
3957
3958
3959
3960MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3961
3962
3963
3964
3965
3966MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3967
3968static inline void mlxsw_reg_qrwe_pack(char *payload, u16 local_port,
3969 bool rewrite_pcp, bool rewrite_dscp)
3970{
3971 MLXSW_REG_ZERO(qrwe, payload);
3972 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3973 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3974 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3975}
3976
3977
3978
3979
3980
3981#define MLXSW_REG_QPDSM_ID 0x4011
3982#define MLXSW_REG_QPDSM_BASE_LEN 0x04
3983#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4
3984#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3985#define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3986 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3987 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3988
3989MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3990
3991
3992
3993
3994
3995MLXSW_ITEM32_LP(reg, qpdsm, 0x00, 16, 0x00, 12);
3996
3997
3998
3999
4000
4001MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
4002 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
4003 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4004
4005
4006
4007
4008
4009
4010MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
4011 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
4012 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4013
4014
4015
4016
4017
4018MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
4019 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
4020 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4021
4022
4023
4024
4025
4026
4027MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
4028 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
4029 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4030
4031
4032
4033
4034
4035MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
4036 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
4037 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4038
4039
4040
4041
4042
4043
4044MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
4045 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
4046 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
4047
4048static inline void mlxsw_reg_qpdsm_pack(char *payload, u16 local_port)
4049{
4050 MLXSW_REG_ZERO(qpdsm, payload);
4051 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
4052}
4053
4054static inline void
4055mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
4056{
4057 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
4058 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
4059 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
4060 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
4061 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
4062 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
4063}
4064
4065
4066
4067
4068
4069
4070
4071
4072#define MLXSW_REG_QPDP_ID 0x4007
4073#define MLXSW_REG_QPDP_LEN 0x8
4074
4075MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
4076
4077
4078
4079
4080
4081MLXSW_ITEM32_LP(reg, qpdp, 0x00, 16, 0x00, 12);
4082
4083
4084
4085
4086
4087MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
4088
4089static inline void mlxsw_reg_qpdp_pack(char *payload, u16 local_port,
4090 u8 switch_prio)
4091{
4092 MLXSW_REG_ZERO(qpdp, payload);
4093 mlxsw_reg_qpdp_local_port_set(payload, local_port);
4094 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
4095}
4096
4097
4098
4099
4100
4101
4102#define MLXSW_REG_QPDPM_ID 0x4013
4103#define MLXSW_REG_QPDPM_BASE_LEN 0x4
4104#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2
4105#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
4106#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
4107 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
4108 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
4109
4110MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
4111
4112
4113
4114
4115
4116MLXSW_ITEM32_LP(reg, qpdpm, 0x00, 16, 0x00, 12);
4117
4118
4119
4120
4121
4122
4123
4124MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
4125 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4126
4127
4128
4129
4130
4131MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
4132 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
4133 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
4134
4135static inline void mlxsw_reg_qpdpm_pack(char *payload, u16 local_port)
4136{
4137 MLXSW_REG_ZERO(qpdpm, payload);
4138 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
4139}
4140
4141static inline void
4142mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
4143{
4144 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
4145 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
4146}
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157#define MLXSW_REG_QTCTM_ID 0x401A
4158#define MLXSW_REG_QTCTM_LEN 0x08
4159
4160MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
4161
4162
4163
4164
4165
4166
4167MLXSW_ITEM32_LP(reg, qtctm, 0x00, 16, 0x00, 12);
4168
4169
4170
4171
4172
4173
4174MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
4175
4176static inline void
4177mlxsw_reg_qtctm_pack(char *payload, u16 local_port, bool mc)
4178{
4179 MLXSW_REG_ZERO(qtctm, payload);
4180 mlxsw_reg_qtctm_local_port_set(payload, local_port);
4181 mlxsw_reg_qtctm_mc_set(payload, mc);
4182}
4183
4184
4185
4186
4187
4188
4189#define MLXSW_REG_QPSC_ID 0x401B
4190#define MLXSW_REG_QPSC_LEN 0x28
4191
4192MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
4193
4194enum mlxsw_reg_qpsc_port_speed {
4195 MLXSW_REG_QPSC_PORT_SPEED_100M,
4196 MLXSW_REG_QPSC_PORT_SPEED_1G,
4197 MLXSW_REG_QPSC_PORT_SPEED_10G,
4198 MLXSW_REG_QPSC_PORT_SPEED_25G,
4199};
4200
4201
4202
4203
4204
4205MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
4206
4207
4208
4209
4210
4211
4212
4213MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
4214
4215
4216
4217
4218
4219
4220
4221MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
4222
4223
4224
4225
4226
4227
4228MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
4229
4230
4231
4232
4233
4234
4235
4236MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
4237
4238
4239
4240
4241
4242MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
4243
4244
4245
4246
4247
4248
4249
4250MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
4271
4272static inline void
4273mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
4274 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
4275 u8 shaper_bs, u8 port_to_shaper_credits,
4276 int ing_timestamp_inc, int egr_timestamp_inc)
4277{
4278 MLXSW_REG_ZERO(qpsc, payload);
4279 mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
4280 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
4281 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
4282 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
4283 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
4284 mlxsw_reg_qpsc_ptsc_we_set(payload, true);
4285 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
4286 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
4287 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
4288}
4289
4290
4291
4292
4293
4294#define MLXSW_REG_PMLP_ID 0x5002
4295#define MLXSW_REG_PMLP_LEN 0x40
4296
4297MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
4298
4299
4300
4301
4302
4303
4304MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
4305
4306
4307
4308
4309
4310MLXSW_ITEM32_LP(reg, pmlp, 0x00, 16, 0x00, 12);
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
4321
4322
4323
4324
4325
4326MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
4327
4328
4329
4330
4331
4332
4333
4334
4335MLXSW_ITEM32_INDEXED(reg, pmlp, slot_index, 0x04, 8, 4, 0x04, 0x00, false);
4336
4337
4338
4339
4340
4341MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
4342
4343
4344
4345
4346
4347
4348MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
4349
4350static inline void mlxsw_reg_pmlp_pack(char *payload, u16 local_port)
4351{
4352 MLXSW_REG_ZERO(pmlp, payload);
4353 mlxsw_reg_pmlp_local_port_set(payload, local_port);
4354}
4355
4356
4357
4358
4359
4360#define MLXSW_REG_PMTU_ID 0x5003
4361#define MLXSW_REG_PMTU_LEN 0x10
4362
4363MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
4364
4365
4366
4367
4368
4369MLXSW_ITEM32_LP(reg, pmtu, 0x00, 16, 0x00, 12);
4370
4371
4372
4373
4374
4375
4376
4377
4378MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
4379
4380
4381
4382
4383
4384
4385
4386MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
4387
4388
4389
4390
4391
4392
4393
4394
4395MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
4396
4397static inline void mlxsw_reg_pmtu_pack(char *payload, u16 local_port,
4398 u16 new_mtu)
4399{
4400 MLXSW_REG_ZERO(pmtu, payload);
4401 mlxsw_reg_pmtu_local_port_set(payload, local_port);
4402 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
4403 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
4404 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
4405}
4406
4407
4408
4409
4410
4411
4412
4413
4414#define MLXSW_REG_PTYS_ID 0x5004
4415#define MLXSW_REG_PTYS_LEN 0x40
4416
4417MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
4418
4419
4420
4421
4422
4423
4424
4425MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
4426
4427
4428
4429
4430
4431MLXSW_ITEM32_LP(reg, ptys, 0x00, 16, 0x00, 12);
4432
4433#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
4434#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
4435
4436
4437
4438
4439
4440
4441
4442
4443MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
4444
4445enum {
4446 MLXSW_REG_PTYS_AN_STATUS_NA,
4447 MLXSW_REG_PTYS_AN_STATUS_OK,
4448 MLXSW_REG_PTYS_AN_STATUS_FAIL,
4449};
4450
4451
4452
4453
4454
4455MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
4456
4457#define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
4458#define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
4459#define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
4460#define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
4461#define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
4462#define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
4463#define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
4464#define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
4465#define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
4466#define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
4467#define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
4468#define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
4469
4470
4471
4472
4473
4474MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
4475
4476#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
4477#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
4478#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
4479#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
4480#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
4481#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
4482#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
4483#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
4484#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
4485#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
4486#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
4487#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
4488#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
4489#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
4490#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
4491#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
4492#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
4493#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
4494#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(24)
4495#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_T BIT(25)
4496#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
4497#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
4498#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
4499#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
4500#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
4501
4502
4503
4504
4505
4506MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
4507
4508
4509
4510
4511
4512MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
4513
4514#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
4515#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
4516#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
4517#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
4518#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
4519#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
4520
4521
4522
4523
4524
4525MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
4526
4527
4528
4529
4530
4531MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
4532
4533
4534
4535
4536
4537MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
4538
4539
4540
4541
4542
4543MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
4544
4545
4546
4547
4548
4549MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
4550
4551
4552
4553
4554
4555MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
4556
4557
4558
4559
4560
4561MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
4562
4563
4564
4565
4566
4567MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
4568
4569
4570
4571
4572
4573MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
4574
4575enum mlxsw_reg_ptys_connector_type {
4576 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
4577 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
4578 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
4579 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
4580 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
4581 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
4582 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
4583 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
4584 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
4585};
4586
4587
4588
4589
4590
4591MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
4592
4593static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port,
4594 u32 proto_admin, bool autoneg)
4595{
4596 MLXSW_REG_ZERO(ptys, payload);
4597 mlxsw_reg_ptys_local_port_set(payload, local_port);
4598 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4599 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
4600 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4601}
4602
4603static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u16 local_port,
4604 u32 proto_admin, bool autoneg)
4605{
4606 MLXSW_REG_ZERO(ptys, payload);
4607 mlxsw_reg_ptys_local_port_set(payload, local_port);
4608 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
4609 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
4610 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
4611}
4612
4613static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
4614 u32 *p_eth_proto_cap,
4615 u32 *p_eth_proto_admin,
4616 u32 *p_eth_proto_oper)
4617{
4618 if (p_eth_proto_cap)
4619 *p_eth_proto_cap =
4620 mlxsw_reg_ptys_eth_proto_cap_get(payload);
4621 if (p_eth_proto_admin)
4622 *p_eth_proto_admin =
4623 mlxsw_reg_ptys_eth_proto_admin_get(payload);
4624 if (p_eth_proto_oper)
4625 *p_eth_proto_oper =
4626 mlxsw_reg_ptys_eth_proto_oper_get(payload);
4627}
4628
4629static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
4630 u32 *p_eth_proto_cap,
4631 u32 *p_eth_proto_admin,
4632 u32 *p_eth_proto_oper)
4633{
4634 if (p_eth_proto_cap)
4635 *p_eth_proto_cap =
4636 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
4637 if (p_eth_proto_admin)
4638 *p_eth_proto_admin =
4639 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
4640 if (p_eth_proto_oper)
4641 *p_eth_proto_oper =
4642 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
4643}
4644
4645static inline void mlxsw_reg_ptys_ib_pack(char *payload, u16 local_port,
4646 u16 proto_admin, u16 link_width)
4647{
4648 MLXSW_REG_ZERO(ptys, payload);
4649 mlxsw_reg_ptys_local_port_set(payload, local_port);
4650 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
4651 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
4652 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
4653}
4654
4655static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
4656 u16 *p_ib_link_width_cap,
4657 u16 *p_ib_proto_oper,
4658 u16 *p_ib_link_width_oper)
4659{
4660 if (p_ib_proto_cap)
4661 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
4662 if (p_ib_link_width_cap)
4663 *p_ib_link_width_cap =
4664 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
4665 if (p_ib_proto_oper)
4666 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
4667 if (p_ib_link_width_oper)
4668 *p_ib_link_width_oper =
4669 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
4670}
4671
4672
4673
4674
4675
4676#define MLXSW_REG_PPAD_ID 0x5005
4677#define MLXSW_REG_PPAD_LEN 0x10
4678
4679MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
4680
4681
4682
4683
4684
4685
4686
4687MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
4688
4689
4690
4691
4692
4693MLXSW_ITEM32_LP(reg, ppad, 0x00, 16, 0x00, 24);
4694
4695
4696
4697
4698
4699
4700MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
4701
4702static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
4703 u16 local_port)
4704{
4705 MLXSW_REG_ZERO(ppad, payload);
4706 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
4707 mlxsw_reg_ppad_local_port_set(payload, local_port);
4708}
4709
4710
4711
4712
4713
4714#define MLXSW_REG_PAOS_ID 0x5006
4715#define MLXSW_REG_PAOS_LEN 0x10
4716
4717MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
4718
4719
4720
4721
4722
4723
4724
4725
4726MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
4727
4728
4729
4730
4731
4732MLXSW_ITEM32_LP(reg, paos, 0x00, 16, 0x00, 12);
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
4754
4755
4756
4757
4758
4759MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
4760
4761
4762
4763
4764
4765
4766MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
4767
4768
4769
4770
4771
4772
4773
4774
4775MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
4776
4777static inline void mlxsw_reg_paos_pack(char *payload, u16 local_port,
4778 enum mlxsw_port_admin_status status)
4779{
4780 MLXSW_REG_ZERO(paos, payload);
4781 mlxsw_reg_paos_swid_set(payload, 0);
4782 mlxsw_reg_paos_local_port_set(payload, local_port);
4783 mlxsw_reg_paos_admin_status_set(payload, status);
4784 mlxsw_reg_paos_oper_status_set(payload, 0);
4785 mlxsw_reg_paos_ase_set(payload, 1);
4786 mlxsw_reg_paos_ee_set(payload, 1);
4787 mlxsw_reg_paos_e_set(payload, 1);
4788}
4789
4790
4791
4792
4793
4794#define MLXSW_REG_PFCC_ID 0x5007
4795#define MLXSW_REG_PFCC_LEN 0x20
4796
4797MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
4798
4799
4800
4801
4802
4803MLXSW_ITEM32_LP(reg, pfcc, 0x00, 16, 0x00, 12);
4804
4805
4806
4807
4808
4809
4810
4811MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
4812
4813
4814
4815
4816
4817
4818
4819
4820MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4821
4822
4823
4824
4825
4826
4827
4828
4829MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4842
4843
4844
4845
4846
4847
4848MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4849
4850
4851
4852
4853
4854
4855MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4856
4857
4858
4859
4860
4861
4862
4863MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4864
4865
4866
4867
4868
4869
4870
4871MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4884
4885
4886
4887
4888
4889
4890
4891MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4892
4893
4894
4895
4896
4897
4898
4899MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4900
4901
4902
4903
4904
4905
4906
4907
4908MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4909
4910#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4911
4912static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4913{
4914 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4915 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4916 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4917 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4918}
4919
4920static inline void mlxsw_reg_pfcc_pack(char *payload, u16 local_port)
4921{
4922 MLXSW_REG_ZERO(pfcc, payload);
4923 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4924}
4925
4926
4927
4928
4929
4930#define MLXSW_REG_PPCNT_ID 0x5008
4931#define MLXSW_REG_PPCNT_LEN 0x100
4932#define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
4933
4934MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4946
4947
4948
4949
4950
4951MLXSW_ITEM32_LP(reg, ppcnt, 0x00, 16, 0x00, 12);
4952
4953
4954
4955
4956
4957
4958
4959MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4960
4961enum mlxsw_reg_ppcnt_grp {
4962 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
4963 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
4964 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
4965 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
4966 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
4967 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
4968 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
4969 MLXSW_REG_PPCNT_TC_CNT = 0x11,
4970 MLXSW_REG_PPCNT_TC_CONG_CNT = 0x13,
4971};
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4991
4992
4993
4994
4995
4996
4997
4998MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4999
5000
5001
5002
5003
5004
5005
5006MLXSW_ITEM32(reg, ppcnt, lp_gl, 0x04, 30, 1);
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
5017
5018
5019
5020
5021
5022
5023MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
5024 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5025
5026
5027
5028
5029MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
5030 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5031
5032
5033
5034
5035MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
5036 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5037
5038
5039
5040
5041MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
5042 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5043
5044
5045
5046
5047MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
5048 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5049
5050
5051
5052
5053MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
5054 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5055
5056
5057
5058
5059MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
5060 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5061
5062
5063
5064
5065MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
5066 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5067
5068
5069
5070
5071MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
5072 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5073
5074
5075
5076
5077MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
5078 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5079
5080
5081
5082
5083MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
5084 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5085
5086
5087
5088
5089MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
5090 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5091
5092
5093
5094
5095MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
5096 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5097
5098
5099
5100
5101MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
5102 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5103
5104
5105
5106
5107MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
5108 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5109
5110
5111
5112
5113MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
5114 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5115
5116
5117
5118
5119MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
5120 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5121
5122
5123
5124
5125MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
5126 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5127
5128
5129
5130
5131MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
5132 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5133
5134
5135
5136
5137
5138
5139MLXSW_ITEM64(reg, ppcnt, if_in_discards,
5140 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5141
5142
5143
5144
5145MLXSW_ITEM64(reg, ppcnt, if_out_discards,
5146 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5147
5148
5149
5150
5151MLXSW_ITEM64(reg, ppcnt, if_out_errors,
5152 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5153
5154
5155
5156
5157
5158
5159MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
5160 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5161
5162
5163
5164
5165MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
5166 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
5167
5168
5169
5170
5171MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
5172 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5173
5174
5175
5176
5177MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
5178 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5179
5180
5181
5182
5183MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
5184 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5185
5186
5187
5188
5189MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
5190 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5191
5192
5193
5194
5195MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
5196 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5197
5198
5199
5200
5201MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
5202 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
5203
5204
5205
5206
5207MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
5208 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
5209
5210
5211
5212
5213MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
5214 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
5215
5216
5217
5218
5219MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
5220 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
5221
5222
5223
5224
5225MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
5226 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
5227
5228
5229
5230
5231MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
5232 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
5233
5234
5235
5236
5237
5238
5239MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
5240 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5241
5242
5243
5244
5245MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
5246 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5247
5248
5249
5250
5251MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
5252 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5253
5254
5255
5256
5257MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
5258 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5259
5260
5261
5262
5263
5264
5265MLXSW_ITEM64(reg, ppcnt, ecn_marked,
5266 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5267
5268
5269
5270
5271
5272
5273MLXSW_ITEM64(reg, ppcnt, ingress_general,
5274 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5275
5276
5277
5278
5279MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
5280 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5281
5282
5283
5284
5285MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
5286 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
5287
5288
5289
5290
5291MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
5292 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
5293
5294
5295
5296
5297MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
5298 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5299
5300
5301
5302
5303MLXSW_ITEM64(reg, ppcnt, loopback_filter,
5304 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5305
5306
5307
5308
5309MLXSW_ITEM64(reg, ppcnt, egress_general,
5310 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
5311
5312
5313
5314
5315MLXSW_ITEM64(reg, ppcnt, egress_hoq,
5316 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
5317
5318
5319
5320
5321MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
5322 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5323
5324
5325
5326
5327MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
5328 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5329
5330
5331
5332
5333MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
5334 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5335
5336
5337
5338
5339MLXSW_ITEM64(reg, ppcnt, egress_sll,
5340 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5341
5342
5343
5344
5345
5346
5347MLXSW_ITEM64(reg, ppcnt, rx_octets,
5348 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5349
5350
5351
5352
5353MLXSW_ITEM64(reg, ppcnt, rx_frames,
5354 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
5355
5356
5357
5358
5359MLXSW_ITEM64(reg, ppcnt, tx_octets,
5360 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
5361
5362
5363
5364
5365MLXSW_ITEM64(reg, ppcnt, tx_frames,
5366 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
5367
5368
5369
5370
5371MLXSW_ITEM64(reg, ppcnt, rx_pause,
5372 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
5373
5374
5375
5376
5377MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
5378 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
5379
5380
5381
5382
5383MLXSW_ITEM64(reg, ppcnt, tx_pause,
5384 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
5385
5386
5387
5388
5389MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
5390 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
5391
5392
5393
5394
5395MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
5396 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
5407 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5408
5409
5410
5411
5412
5413
5414MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
5415 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5416
5417
5418
5419
5420
5421
5422MLXSW_ITEM64(reg, ppcnt, wred_discard,
5423 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
5424
5425
5426
5427
5428MLXSW_ITEM64(reg, ppcnt, ecn_marked_tc,
5429 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
5430
5431static inline void mlxsw_reg_ppcnt_pack(char *payload, u16 local_port,
5432 enum mlxsw_reg_ppcnt_grp grp,
5433 u8 prio_tc)
5434{
5435 MLXSW_REG_ZERO(ppcnt, payload);
5436 mlxsw_reg_ppcnt_swid_set(payload, 0);
5437 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
5438 mlxsw_reg_ppcnt_pnat_set(payload, 0);
5439 mlxsw_reg_ppcnt_grp_set(payload, grp);
5440 mlxsw_reg_ppcnt_clr_set(payload, 0);
5441 mlxsw_reg_ppcnt_lp_gl_set(payload, 1);
5442 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
5443}
5444
5445
5446
5447
5448
5449#define MLXSW_REG_PLIB_ID 0x500A
5450#define MLXSW_REG_PLIB_LEN 0x10
5451
5452MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
5453
5454
5455
5456
5457
5458MLXSW_ITEM32_LP(reg, plib, 0x00, 16, 0x00, 12);
5459
5460
5461
5462
5463
5464MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
5465
5466
5467
5468
5469
5470#define MLXSW_REG_PPTB_ID 0x500B
5471#define MLXSW_REG_PPTB_LEN 0x10
5472
5473MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
5474
5475enum {
5476 MLXSW_REG_PPTB_MM_UM,
5477 MLXSW_REG_PPTB_MM_UNICAST,
5478 MLXSW_REG_PPTB_MM_MULTICAST,
5479};
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
5491
5492
5493
5494
5495
5496MLXSW_ITEM32_LP(reg, pptb, 0x00, 16, 0x00, 12);
5497
5498
5499
5500
5501
5502MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
5503
5504
5505
5506
5507
5508
5509MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
5510
5511
5512
5513
5514
5515
5516MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
5517
5518
5519
5520
5521
5522
5523MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
5524
5525
5526
5527
5528
5529
5530
5531
5532MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
5533
5534
5535
5536
5537
5538
5539MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
5540
5541#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
5542
5543static inline void mlxsw_reg_pptb_pack(char *payload, u16 local_port)
5544{
5545 MLXSW_REG_ZERO(pptb, payload);
5546 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
5547 mlxsw_reg_pptb_local_port_set(payload, local_port);
5548 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5549 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
5550}
5551
5552static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
5553 u8 buff)
5554{
5555 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
5556 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
5557}
5558
5559
5560
5561
5562
5563
5564#define MLXSW_REG_PBMC_ID 0x500C
5565#define MLXSW_REG_PBMC_LEN 0x6C
5566
5567MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
5568
5569
5570
5571
5572
5573MLXSW_ITEM32_LP(reg, pbmc, 0x00, 16, 0x00, 12);
5574
5575
5576
5577
5578
5579
5580MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
5581
5582
5583
5584
5585
5586
5587
5588MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
5589
5590#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
5591
5592
5593
5594
5595
5596
5597
5598MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
5599
5600
5601
5602
5603
5604
5605
5606
5607MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
5608
5609
5610
5611
5612
5613
5614MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
5626 0x08, 0x04, false);
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
5638 0x08, 0x04, false);
5639
5640static inline void mlxsw_reg_pbmc_pack(char *payload, u16 local_port,
5641 u16 xoff_timer_value, u16 xoff_refresh)
5642{
5643 MLXSW_REG_ZERO(pbmc, payload);
5644 mlxsw_reg_pbmc_local_port_set(payload, local_port);
5645 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
5646 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
5647}
5648
5649static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
5650 int buf_index,
5651 u16 size)
5652{
5653 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
5654 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5655 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5656}
5657
5658static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
5659 int buf_index, u16 size,
5660 u16 threshold)
5661{
5662 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
5663 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
5664 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
5665 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
5666 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
5667}
5668
5669
5670
5671
5672
5673
5674#define MLXSW_REG_PSPA_ID 0x500D
5675#define MLXSW_REG_PSPA_LEN 0x8
5676
5677MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
5678
5679
5680
5681
5682
5683MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
5684
5685
5686
5687
5688
5689MLXSW_ITEM32_LP(reg, pspa, 0x00, 16, 0x00, 0);
5690
5691
5692
5693
5694
5695
5696MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
5697
5698static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u16 local_port)
5699{
5700 MLXSW_REG_ZERO(pspa, payload);
5701 mlxsw_reg_pspa_swid_set(payload, swid);
5702 mlxsw_reg_pspa_local_port_set(payload, local_port);
5703 mlxsw_reg_pspa_sub_port_set(payload, 0);
5704}
5705
5706
5707
5708
5709
5710#define MLXSW_REG_PMAOS_ID 0x5012
5711#define MLXSW_REG_PMAOS_LEN 0x10
5712
5713MLXSW_REG_DEFINE(pmaos, MLXSW_REG_PMAOS_ID, MLXSW_REG_PMAOS_LEN);
5714
5715
5716
5717
5718
5719
5720
5721MLXSW_ITEM32(reg, pmaos, rst, 0x00, 31, 1);
5722
5723
5724
5725
5726
5727MLXSW_ITEM32(reg, pmaos, slot_index, 0x00, 24, 4);
5728
5729
5730
5731
5732
5733MLXSW_ITEM32(reg, pmaos, module, 0x00, 16, 8);
5734
5735enum mlxsw_reg_pmaos_admin_status {
5736 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED = 1,
5737 MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED = 2,
5738
5739
5740
5741
5742 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED_ONCE = 3,
5743};
5744
5745
5746
5747
5748
5749
5750
5751MLXSW_ITEM32(reg, pmaos, admin_status, 0x00, 8, 4);
5752
5753
5754
5755
5756
5757
5758
5759MLXSW_ITEM32(reg, pmaos, ase, 0x04, 31, 1);
5760
5761
5762
5763
5764
5765
5766
5767MLXSW_ITEM32(reg, pmaos, ee, 0x04, 30, 1);
5768
5769enum mlxsw_reg_pmaos_e {
5770 MLXSW_REG_PMAOS_E_DO_NOT_GENERATE_EVENT,
5771 MLXSW_REG_PMAOS_E_GENERATE_EVENT,
5772 MLXSW_REG_PMAOS_E_GENERATE_SINGLE_EVENT,
5773};
5774
5775
5776
5777
5778
5779MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2);
5780
5781static inline void mlxsw_reg_pmaos_pack(char *payload, u8 slot_index, u8 module)
5782{
5783 MLXSW_REG_ZERO(pmaos, payload);
5784 mlxsw_reg_pmaos_slot_index_set(payload, slot_index);
5785 mlxsw_reg_pmaos_module_set(payload, module);
5786}
5787
5788
5789
5790
5791
5792#define MLXSW_REG_PPLR_ID 0x5018
5793#define MLXSW_REG_PPLR_LEN 0x8
5794
5795MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
5796
5797
5798
5799
5800
5801MLXSW_ITEM32_LP(reg, pplr, 0x00, 16, 0x00, 12);
5802
5803
5804
5805
5806#define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
5807
5808
5809
5810
5811
5812MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
5813
5814static inline void mlxsw_reg_pplr_pack(char *payload, u16 local_port,
5815 bool phy_local)
5816{
5817 MLXSW_REG_ZERO(pplr, payload);
5818 mlxsw_reg_pplr_local_port_set(payload, local_port);
5819 mlxsw_reg_pplr_lb_en_set(payload,
5820 phy_local ?
5821 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
5822}
5823
5824
5825
5826
5827
5828
5829
5830#define MLXSW_REG_PMTDB_ID 0x501A
5831#define MLXSW_REG_PMTDB_LEN 0x40
5832
5833MLXSW_REG_DEFINE(pmtdb, MLXSW_REG_PMTDB_ID, MLXSW_REG_PMTDB_LEN);
5834
5835
5836
5837
5838
5839MLXSW_ITEM32(reg, pmtdb, slot_index, 0x00, 24, 4);
5840
5841
5842
5843
5844
5845MLXSW_ITEM32(reg, pmtdb, module, 0x00, 16, 8);
5846
5847
5848
5849
5850
5851MLXSW_ITEM32(reg, pmtdb, ports_width, 0x00, 12, 4);
5852
5853
5854
5855
5856
5857MLXSW_ITEM32(reg, pmtdb, num_ports, 0x00, 8, 4);
5858
5859enum mlxsw_reg_pmtdb_status {
5860 MLXSW_REG_PMTDB_STATUS_SUCCESS,
5861};
5862
5863
5864
5865
5866
5867MLXSW_ITEM32(reg, pmtdb, status, 0x00, 0, 4);
5868
5869
5870
5871
5872
5873
5874
5875MLXSW_ITEM16_INDEXED(reg, pmtdb, port_num, 0x04, 0, 10, 0x02, 0x00, false);
5876
5877static inline void mlxsw_reg_pmtdb_pack(char *payload, u8 slot_index, u8 module,
5878 u8 ports_width, u8 num_ports)
5879{
5880 MLXSW_REG_ZERO(pmtdb, payload);
5881 mlxsw_reg_pmtdb_slot_index_set(payload, slot_index);
5882 mlxsw_reg_pmtdb_module_set(payload, module);
5883 mlxsw_reg_pmtdb_ports_width_set(payload, ports_width);
5884 mlxsw_reg_pmtdb_num_ports_set(payload, num_ports);
5885}
5886
5887
5888
5889
5890
5891
5892#define MLXSW_REG_PMECR_ID 0x501B
5893#define MLXSW_REG_PMECR_LEN 0x20
5894
5895MLXSW_REG_DEFINE(pmecr, MLXSW_REG_PMECR_ID, MLXSW_REG_PMECR_LEN);
5896
5897
5898
5899
5900
5901MLXSW_ITEM32_LP(reg, pmecr, 0x00, 16, 0x00, 12);
5902
5903
5904
5905
5906
5907
5908MLXSW_ITEM32(reg, pmecr, ee, 0x04, 30, 1);
5909
5910
5911
5912
5913
5914
5915
5916MLXSW_ITEM32(reg, pmecr, eswi, 0x04, 24, 1);
5917
5918
5919
5920
5921
5922
5923
5924
5925MLXSW_ITEM32(reg, pmecr, swi, 0x04, 8, 1);
5926
5927enum mlxsw_reg_pmecr_e {
5928 MLXSW_REG_PMECR_E_DO_NOT_GENERATE_EVENT,
5929 MLXSW_REG_PMECR_E_GENERATE_EVENT,
5930 MLXSW_REG_PMECR_E_GENERATE_SINGLE_EVENT,
5931};
5932
5933
5934
5935
5936
5937MLXSW_ITEM32(reg, pmecr, e, 0x04, 0, 2);
5938
5939static inline void mlxsw_reg_pmecr_pack(char *payload, u16 local_port,
5940 enum mlxsw_reg_pmecr_e e)
5941{
5942 MLXSW_REG_ZERO(pmecr, payload);
5943 mlxsw_reg_pmecr_local_port_set(payload, local_port);
5944 mlxsw_reg_pmecr_e_set(payload, e);
5945 mlxsw_reg_pmecr_ee_set(payload, true);
5946 mlxsw_reg_pmecr_swi_set(payload, true);
5947 mlxsw_reg_pmecr_eswi_set(payload, true);
5948}
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958#define MLXSW_REG_PMPE_ID 0x5024
5959#define MLXSW_REG_PMPE_LEN 0x10
5960
5961MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN);
5962
5963
5964
5965
5966
5967MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4);
5968
5969
5970
5971
5972
5973MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8);
5974
5975enum mlxsw_reg_pmpe_module_status {
5976 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1,
5977 MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED,
5978 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR,
5979 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED,
5980};
5981
5982
5983
5984
5985
5986MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4);
5987
5988
5989
5990
5991
5992MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4);
5993
5994
5995
5996
5997
5998#define MLXSW_REG_PDDR_ID 0x5031
5999#define MLXSW_REG_PDDR_LEN 0x100
6000
6001MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN);
6002
6003
6004
6005
6006
6007MLXSW_ITEM32_LP(reg, pddr, 0x00, 16, 0x00, 12);
6008
6009enum mlxsw_reg_pddr_page_select {
6010 MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1,
6011};
6012
6013
6014
6015
6016
6017MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8);
6018
6019enum mlxsw_reg_pddr_trblsh_group_opcode {
6020
6021 MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR,
6022};
6023
6024
6025
6026
6027
6028MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
6029
6030
6031
6032
6033
6034MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
6035
6036static inline void mlxsw_reg_pddr_pack(char *payload, u16 local_port,
6037 u8 page_select)
6038{
6039 MLXSW_REG_ZERO(pddr, payload);
6040 mlxsw_reg_pddr_local_port_set(payload, local_port);
6041 mlxsw_reg_pddr_page_select_set(payload, page_select);
6042}
6043
6044
6045
6046
6047
6048
6049#define MLXSW_REG_PMMP_ID 0x5044
6050#define MLXSW_REG_PMMP_LEN 0x2C
6051
6052MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN);
6053
6054
6055
6056
6057
6058MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8);
6059
6060
6061
6062
6063
6064MLXSW_ITEM32(reg, pmmp, slot_index, 0x00, 24, 4);
6065
6066
6067
6068
6069
6070MLXSW_ITEM32(reg, pmmp, sticky, 0x00, 0, 1);
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080MLXSW_ITEM32(reg, pmmp, eeprom_override_mask, 0x04, 16, 16);
6081
6082enum {
6083
6084 MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK = BIT(8),
6085};
6086
6087
6088
6089
6090
6091MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16);
6092
6093static inline void mlxsw_reg_pmmp_pack(char *payload, u8 slot_index, u8 module)
6094{
6095 MLXSW_REG_ZERO(pmmp, payload);
6096 mlxsw_reg_pmmp_slot_index_set(payload, slot_index);
6097 mlxsw_reg_pmmp_module_set(payload, module);
6098}
6099
6100
6101
6102
6103
6104#define MLXSW_REG_PLLP_ID 0x504A
6105#define MLXSW_REG_PLLP_LEN 0x10
6106
6107MLXSW_REG_DEFINE(pllp, MLXSW_REG_PLLP_ID, MLXSW_REG_PLLP_LEN);
6108
6109
6110
6111
6112
6113MLXSW_ITEM32_LP(reg, pllp, 0x00, 16, 0x00, 12);
6114
6115
6116
6117
6118
6119MLXSW_ITEM32(reg, pllp, label_port, 0x00, 0, 8);
6120
6121
6122
6123
6124
6125MLXSW_ITEM32(reg, pllp, split_num, 0x04, 0, 4);
6126
6127
6128
6129
6130
6131MLXSW_ITEM32(reg, pllp, slot_index, 0x08, 0, 4);
6132
6133static inline void mlxsw_reg_pllp_pack(char *payload, u16 local_port)
6134{
6135 MLXSW_REG_ZERO(pllp, payload);
6136 mlxsw_reg_pllp_local_port_set(payload, local_port);
6137}
6138
6139static inline void mlxsw_reg_pllp_unpack(char *payload, u8 *label_port,
6140 u8 *split_num, u8 *slot_index)
6141{
6142 *label_port = mlxsw_reg_pllp_label_port_get(payload);
6143 *split_num = mlxsw_reg_pllp_split_num_get(payload);
6144 *slot_index = mlxsw_reg_pllp_slot_index_get(payload);
6145}
6146
6147
6148
6149
6150
6151
6152#define MLXSW_REG_PMTM_ID 0x5067
6153#define MLXSW_REG_PMTM_LEN 0x10
6154
6155MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
6156
6157
6158
6159
6160
6161MLXSW_ITEM32(reg, pmtm, slot_index, 0x00, 24, 4);
6162
6163
6164
6165
6166
6167MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
6168
6169enum mlxsw_reg_pmtm_module_type {
6170 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_4_LANES = 0,
6171 MLXSW_REG_PMTM_MODULE_TYPE_QSFP = 1,
6172 MLXSW_REG_PMTM_MODULE_TYPE_SFP = 2,
6173 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_SINGLE_LANE = 4,
6174 MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_2_LANES = 8,
6175 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP4X = 10,
6176 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP2X = 11,
6177 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP1X = 12,
6178 MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD = 14,
6179 MLXSW_REG_PMTM_MODULE_TYPE_OSFP = 15,
6180 MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD = 16,
6181 MLXSW_REG_PMTM_MODULE_TYPE_DSFP = 17,
6182 MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP8X = 18,
6183 MLXSW_REG_PMTM_MODULE_TYPE_TWISTED_PAIR = 19,
6184};
6185
6186
6187
6188
6189
6190MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 5);
6191
6192static inline void mlxsw_reg_pmtm_pack(char *payload, u8 slot_index, u8 module)
6193{
6194 MLXSW_REG_ZERO(pmtm, payload);
6195 mlxsw_reg_pmtm_slot_index_set(payload, slot_index);
6196 mlxsw_reg_pmtm_module_set(payload, module);
6197}
6198
6199
6200
6201
6202
6203#define MLXSW_REG_HTGT_ID 0x7002
6204#define MLXSW_REG_HTGT_LEN 0x20
6205
6206MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
6207
6208
6209
6210
6211
6212MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
6213
6214#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0
6215
6216
6217
6218
6219
6220MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
6221
6222enum mlxsw_reg_htgt_trap_group {
6223 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
6224 MLXSW_REG_HTGT_TRAP_GROUP_CORE_EVENT,
6225 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
6226 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
6227 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
6228 MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
6229 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
6230 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
6231 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
6232 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
6233 MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
6234 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
6235 MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE,
6236 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
6237 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
6238 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
6239 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
6240 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
6241 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
6242 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
6243 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
6244 MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
6245 MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
6246 MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS,
6247 MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
6248 MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
6249 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
6250 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
6251 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
6252 MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
6253 MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
6254 MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
6255
6256 __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
6257 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
6258};
6259
6260
6261
6262
6263
6264
6265
6266MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
6267
6268enum {
6269 MLXSW_REG_HTGT_POLICER_DISABLE,
6270 MLXSW_REG_HTGT_POLICER_ENABLE,
6271};
6272
6273
6274
6275
6276
6277MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
6278
6279#define MLXSW_REG_HTGT_INVALID_POLICER 0xff
6280
6281
6282
6283
6284
6285MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
6286
6287#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
6299
6300
6301
6302
6303
6304MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
6305
6306#define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
6320
6321#define MLXSW_REG_HTGT_DEFAULT_TC 7
6322
6323
6324
6325
6326
6327MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
6328
6329enum mlxsw_reg_htgt_local_path_rdq {
6330 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
6331 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
6332 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
6333 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
6334};
6335
6336
6337
6338
6339MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
6340
6341static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
6342 u8 priority, u8 tc)
6343{
6344 MLXSW_REG_ZERO(htgt, payload);
6345
6346 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
6347 mlxsw_reg_htgt_pide_set(payload,
6348 MLXSW_REG_HTGT_POLICER_DISABLE);
6349 } else {
6350 mlxsw_reg_htgt_pide_set(payload,
6351 MLXSW_REG_HTGT_POLICER_ENABLE);
6352 mlxsw_reg_htgt_pid_set(payload, policer_id);
6353 }
6354
6355 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
6356 mlxsw_reg_htgt_trap_group_set(payload, group);
6357 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
6358 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
6359 mlxsw_reg_htgt_priority_set(payload, priority);
6360 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
6361 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
6362}
6363
6364
6365
6366
6367
6368#define MLXSW_REG_HPKT_ID 0x7003
6369#define MLXSW_REG_HPKT_LEN 0x10
6370
6371MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
6372
6373enum {
6374 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
6375 MLXSW_REG_HPKT_ACK_REQUIRED,
6376};
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
6387
6388enum mlxsw_reg_hpkt_action {
6389 MLXSW_REG_HPKT_ACTION_FORWARD,
6390 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
6391 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
6392 MLXSW_REG_HPKT_ACTION_DISCARD,
6393 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
6394 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
6395 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
6396 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
6397};
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
6415
6416
6417
6418
6419
6420MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
6421
6422
6423
6424
6425
6426
6427
6428
6429MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10);
6430
6431enum {
6432 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
6433 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
6434 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
6435};
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
6446
6447static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
6448 enum mlxsw_reg_htgt_trap_group trap_group,
6449 bool is_ctrl)
6450{
6451 MLXSW_REG_ZERO(hpkt, payload);
6452 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
6453 mlxsw_reg_hpkt_action_set(payload, action);
6454 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
6455 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
6456 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
6457 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
6458 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
6459}
6460
6461
6462
6463
6464
6465#define MLXSW_REG_RGCR_ID 0x8001
6466#define MLXSW_REG_RGCR_LEN 0x28
6467
6468MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
6469
6470
6471
6472
6473
6474MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
6475
6476
6477
6478
6479
6480MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
6481
6482
6483
6484
6485
6486
6487MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
6525
6526static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
6527 bool ipv6_en)
6528{
6529 MLXSW_REG_ZERO(rgcr, payload);
6530 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
6531 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
6532}
6533
6534
6535
6536
6537
6538#define MLXSW_REG_RITR_ID 0x8002
6539#define MLXSW_REG_RITR_LEN 0x40
6540
6541MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
6542
6543
6544
6545
6546
6547MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
6548
6549
6550
6551
6552
6553
6554MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
6555
6556
6557
6558
6559
6560
6561MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
6562
6563
6564
6565
6566
6567MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
6568
6569
6570
6571
6572
6573MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
6574
6575enum mlxsw_reg_ritr_if_type {
6576
6577 MLXSW_REG_RITR_VLAN_IF,
6578
6579 MLXSW_REG_RITR_FID_IF,
6580
6581 MLXSW_REG_RITR_SP_IF,
6582
6583 MLXSW_REG_RITR_LOOPBACK_IF,
6584};
6585
6586
6587
6588
6589
6590MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
6591
6592enum {
6593 MLXSW_REG_RITR_RIF_CREATE,
6594 MLXSW_REG_RITR_RIF_DEL,
6595};
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
6607
6608
6609
6610
6611
6612MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
6613
6614
6615
6616
6617
6618
6619
6620
6621MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
6622
6623
6624
6625
6626
6627
6628
6629
6630MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
6631
6632
6633
6634
6635
6636
6637
6638MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
6639
6640
6641
6642
6643
6644
6645
6646MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
6647
6648
6649
6650
6651
6652
6653
6654
6655MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
6656
6657
6658
6659
6660
6661MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
6662
6663
6664
6665
6666
6667MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
6668
6669
6670
6671
6672
6673MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
6674
6675
6676
6677
6678
6679MLXSW_ITEM32(reg, ritr, if_mac_profile_id, 0x10, 16, 4);
6680
6681
6682
6683
6684
6685
6686MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
6687
6688
6689
6690
6691
6692
6693MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
6694
6695
6696
6697
6698
6699
6700MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
6701
6702
6703
6704
6705
6706
6707
6708MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
6709
6710
6711
6712
6713
6714
6715
6716
6717MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
6718
6719static inline void mlxsw_reg_ritr_fid_set(char *payload,
6720 enum mlxsw_reg_ritr_if_type rif_type,
6721 u16 fid)
6722{
6723 if (rif_type == MLXSW_REG_RITR_FID_IF)
6724 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
6725 else
6726 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
6727}
6728
6729
6730
6731
6732
6733
6734
6735
6736MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
6737
6738
6739
6740
6741
6742
6743MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
6744
6745
6746
6747
6748
6749MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
6750
6751
6752
6753enum mlxsw_reg_ritr_loopback_protocol {
6754
6755 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
6756
6757 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
6758
6759 MLXSW_REG_RITR_LOOPBACK_GENERIC,
6760};
6761
6762
6763
6764
6765MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
6766
6767enum mlxsw_reg_ritr_loopback_ipip_type {
6768
6769 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
6770
6771 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
6772
6773 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
6774};
6775
6776
6777
6778
6779
6780MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
6781
6782enum mlxsw_reg_ritr_loopback_ipip_options {
6783
6784 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
6785};
6786
6787
6788
6789
6790MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
6791
6792
6793
6794
6795
6796
6797
6798MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
6799
6800
6801
6802
6803
6804
6805MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
6806
6807
6808
6809
6810
6811MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
6812MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
6813
6814
6815
6816
6817
6818
6819MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
6820
6821
6822enum mlxsw_reg_ritr_counter_set_type {
6823
6824 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
6825
6826
6827
6828
6829
6830
6831 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
6832};
6833
6834
6835
6836
6837
6838MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
6839
6840
6841
6842
6843
6844MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
6845
6846
6847
6848
6849
6850MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
6851
6852
6853
6854
6855
6856MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
6857
6858static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
6859 bool enable, bool egress)
6860{
6861 enum mlxsw_reg_ritr_counter_set_type set_type;
6862
6863 if (enable)
6864 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
6865 else
6866 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
6867
6868 if (egress) {
6869 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
6870 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
6871 } else {
6872 mlxsw_reg_ritr_ingress_counter_set_type_set(payload, set_type);
6873 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
6874 }
6875}
6876
6877static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
6878{
6879 MLXSW_REG_ZERO(ritr, payload);
6880 mlxsw_reg_ritr_rif_set(payload, rif);
6881}
6882
6883static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
6884 u16 system_port, u16 vid)
6885{
6886 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
6887 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
6888 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
6889}
6890
6891static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
6892 enum mlxsw_reg_ritr_if_type type,
6893 u16 rif, u16 vr_id, u16 mtu)
6894{
6895 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
6896
6897 MLXSW_REG_ZERO(ritr, payload);
6898 mlxsw_reg_ritr_enable_set(payload, enable);
6899 mlxsw_reg_ritr_ipv4_set(payload, 1);
6900 mlxsw_reg_ritr_ipv6_set(payload, 1);
6901 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
6902 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
6903 mlxsw_reg_ritr_type_set(payload, type);
6904 mlxsw_reg_ritr_op_set(payload, op);
6905 mlxsw_reg_ritr_rif_set(payload, rif);
6906 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
6907 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
6908 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
6909 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
6910 mlxsw_reg_ritr_lb_en_set(payload, 1);
6911 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
6912 mlxsw_reg_ritr_mtu_set(payload, mtu);
6913}
6914
6915static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
6916{
6917 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
6918}
6919
6920static inline void
6921mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
6922 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6923 enum mlxsw_reg_ritr_loopback_ipip_options options,
6924 u16 uvr_id, u16 underlay_rif, u32 gre_key)
6925{
6926 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
6927 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
6928 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
6929 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
6930 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
6931}
6932
6933static inline void
6934mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
6935 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6936 enum mlxsw_reg_ritr_loopback_ipip_options options,
6937 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
6938{
6939 mlxsw_reg_ritr_loopback_protocol_set(payload,
6940 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
6941 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
6942 uvr_id, underlay_rif, gre_key);
6943 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
6944}
6945
6946static inline void
6947mlxsw_reg_ritr_loopback_ipip6_pack(char *payload,
6948 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
6949 enum mlxsw_reg_ritr_loopback_ipip_options options,
6950 u16 uvr_id, u16 underlay_rif,
6951 const struct in6_addr *usip, u32 gre_key)
6952{
6953 enum mlxsw_reg_ritr_loopback_protocol protocol =
6954 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6;
6955
6956 mlxsw_reg_ritr_loopback_protocol_set(payload, protocol);
6957 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
6958 uvr_id, underlay_rif, gre_key);
6959 mlxsw_reg_ritr_loopback_ipip_usip6_memcpy_to(payload,
6960 (const char *)usip);
6961}
6962
6963
6964
6965
6966
6967#define MLXSW_REG_RTAR_ID 0x8004
6968#define MLXSW_REG_RTAR_LEN 0x20
6969
6970MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
6971
6972enum mlxsw_reg_rtar_op {
6973 MLXSW_REG_RTAR_OP_ALLOCATE,
6974 MLXSW_REG_RTAR_OP_RESIZE,
6975 MLXSW_REG_RTAR_OP_DEALLOCATE,
6976};
6977
6978
6979
6980
6981MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
6982
6983enum mlxsw_reg_rtar_key_type {
6984 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
6985 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
6986};
6987
6988
6989
6990
6991
6992MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
6993
6994
6995
6996
6997
6998
6999
7000
7001MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
7002
7003static inline void mlxsw_reg_rtar_pack(char *payload,
7004 enum mlxsw_reg_rtar_op op,
7005 enum mlxsw_reg_rtar_key_type key_type,
7006 u16 region_size)
7007{
7008 MLXSW_REG_ZERO(rtar, payload);
7009 mlxsw_reg_rtar_op_set(payload, op);
7010 mlxsw_reg_rtar_key_type_set(payload, key_type);
7011 mlxsw_reg_rtar_region_size_set(payload, region_size);
7012}
7013
7014
7015
7016
7017
7018
7019#define MLXSW_REG_RATR_ID 0x8008
7020#define MLXSW_REG_RATR_LEN 0x2C
7021
7022MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
7023
7024enum mlxsw_reg_ratr_op {
7025
7026 MLXSW_REG_RATR_OP_QUERY_READ = 0,
7027
7028 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
7029
7030 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
7031
7032
7033
7034
7035
7036
7037 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
7038};
7039
7040
7041
7042
7043
7044
7045
7046MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
7061
7062
7063
7064
7065
7066
7067MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
7068
7069enum mlxsw_reg_ratr_type {
7070
7071 MLXSW_REG_RATR_TYPE_ETHERNET,
7072
7073
7074
7075 MLXSW_REG_RATR_TYPE_IPOIB_UC,
7076
7077
7078
7079
7080 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
7081
7082
7083
7084 MLXSW_REG_RATR_TYPE_IPOIB_MC,
7085
7086
7087
7088 MLXSW_REG_RATR_TYPE_MPLS,
7089
7090
7091
7092 MLXSW_REG_RATR_TYPE_IPIP,
7093};
7094
7095
7096
7097
7098
7099MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
7100
7101
7102
7103
7104
7105
7106
7107
7108MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
7109
7110
7111
7112
7113
7114MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
7115
7116enum mlxsw_reg_ratr_trap_action {
7117 MLXSW_REG_RATR_TRAP_ACTION_NOP,
7118 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
7119 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
7120 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
7121 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
7122};
7123
7124
7125
7126
7127
7128MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
7129
7130
7131
7132
7133
7134MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
7135
7136enum mlxsw_reg_ratr_trap_id {
7137 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
7138 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
7139};
7140
7141
7142
7143
7144
7145
7146
7147MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
7148
7149
7150
7151
7152
7153MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
7154
7155enum mlxsw_reg_ratr_ipip_type {
7156
7157 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
7158
7159 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
7160};
7161
7162
7163
7164
7165
7166
7167MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
7168
7169
7170
7171
7172
7173
7174MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
7175
7176
7177
7178
7179
7180
7181MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
7182
7183enum mlxsw_reg_flow_counter_set_type {
7184
7185 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
7186
7187 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
7188
7189 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
7190};
7191
7192
7193
7194
7195
7196MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
7197
7198
7199
7200
7201
7202MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
7203
7204static inline void
7205mlxsw_reg_ratr_pack(char *payload,
7206 enum mlxsw_reg_ratr_op op, bool valid,
7207 enum mlxsw_reg_ratr_type type,
7208 u32 adjacency_index, u16 egress_rif)
7209{
7210 MLXSW_REG_ZERO(ratr, payload);
7211 mlxsw_reg_ratr_op_set(payload, op);
7212 mlxsw_reg_ratr_v_set(payload, valid);
7213 mlxsw_reg_ratr_type_set(payload, type);
7214 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
7215 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
7216 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
7217}
7218
7219static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
7220 const char *dest_mac)
7221{
7222 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
7223}
7224
7225static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
7226{
7227 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
7228 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
7229}
7230
7231static inline void mlxsw_reg_ratr_ipip6_entry_pack(char *payload, u32 ipv6_ptr)
7232{
7233 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV6);
7234 mlxsw_reg_ratr_ipip_ipv6_ptr_set(payload, ipv6_ptr);
7235}
7236
7237static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
7238 bool counter_enable)
7239{
7240 enum mlxsw_reg_flow_counter_set_type set_type;
7241
7242 if (counter_enable)
7243 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
7244 else
7245 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
7246
7247 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
7248 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
7249}
7250
7251
7252
7253
7254
7255#define MLXSW_REG_RDPM_ID 0x8009
7256#define MLXSW_REG_RDPM_BASE_LEN 0x00
7257#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
7258#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
7259#define MLXSW_REG_RDPM_LEN 0x40
7260#define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
7261 MLXSW_REG_RDPM_LEN - \
7262 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
7263
7264MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
7265
7266
7267
7268
7269
7270MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
7271 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
7272
7273
7274
7275
7276
7277MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
7278 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
7279
7280static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
7281 u8 prio)
7282{
7283 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
7284 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
7285}
7286
7287
7288
7289
7290
7291#define MLXSW_REG_RICNT_ID 0x800B
7292#define MLXSW_REG_RICNT_LEN 0x100
7293
7294MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
7295
7296
7297
7298
7299
7300MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
7301
7302enum mlxsw_reg_ricnt_counter_set_type {
7303
7304 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
7305
7306
7307
7308
7309
7310
7311 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
7312};
7313
7314
7315
7316
7317
7318MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
7319
7320enum mlxsw_reg_ricnt_opcode {
7321
7322 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
7323
7324
7325
7326 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
7327};
7328
7329
7330
7331
7332
7333MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
7334
7335
7336
7337
7338
7339MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
7340
7341
7342
7343
7344
7345MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
7346
7347
7348
7349
7350
7351MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
7352
7353
7354
7355
7356
7357
7358MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
7359
7360
7361
7362
7363
7364
7365MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
7366
7367
7368
7369
7370
7371
7372MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
7373
7374
7375
7376
7377
7378MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
7379
7380
7381
7382
7383
7384MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
7385
7386
7387
7388
7389
7390
7391MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
7392
7393
7394
7395
7396
7397
7398MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
7399
7400static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
7401 enum mlxsw_reg_ricnt_opcode op)
7402{
7403 MLXSW_REG_ZERO(ricnt, payload);
7404 mlxsw_reg_ricnt_op_set(payload, op);
7405 mlxsw_reg_ricnt_counter_index_set(payload, index);
7406 mlxsw_reg_ricnt_counter_set_type_set(payload,
7407 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
7408}
7409
7410
7411
7412
7413
7414#define MLXSW_REG_RRCR_ID 0x800F
7415#define MLXSW_REG_RRCR_LEN 0x24
7416
7417MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
7418
7419enum mlxsw_reg_rrcr_op {
7420
7421 MLXSW_REG_RRCR_OP_MOVE,
7422
7423 MLXSW_REG_RRCR_OP_COPY,
7424};
7425
7426
7427
7428
7429MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
7430
7431
7432
7433
7434
7435MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
7436
7437
7438
7439
7440
7441MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
7442
7443
7444
7445
7446
7447
7448MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
7449
7450
7451
7452
7453
7454MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
7455
7456static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
7457 u16 offset, u16 size,
7458 enum mlxsw_reg_rtar_key_type table_id,
7459 u16 dest_offset)
7460{
7461 MLXSW_REG_ZERO(rrcr, payload);
7462 mlxsw_reg_rrcr_op_set(payload, op);
7463 mlxsw_reg_rrcr_offset_set(payload, offset);
7464 mlxsw_reg_rrcr_size_set(payload, size);
7465 mlxsw_reg_rrcr_table_id_set(payload, table_id);
7466 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
7467}
7468
7469
7470
7471
7472
7473#define MLXSW_REG_RALTA_ID 0x8010
7474#define MLXSW_REG_RALTA_LEN 0x04
7475
7476MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
7477
7478
7479
7480
7481
7482
7483
7484MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
7485
7486enum mlxsw_reg_ralxx_protocol {
7487 MLXSW_REG_RALXX_PROTOCOL_IPV4,
7488 MLXSW_REG_RALXX_PROTOCOL_IPV6,
7489};
7490
7491
7492
7493
7494
7495
7496MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
7497
7498
7499
7500
7501
7502
7503
7504MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
7505
7506static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
7507 enum mlxsw_reg_ralxx_protocol protocol,
7508 u8 tree_id)
7509{
7510 MLXSW_REG_ZERO(ralta, payload);
7511 mlxsw_reg_ralta_op_set(payload, !alloc);
7512 mlxsw_reg_ralta_protocol_set(payload, protocol);
7513 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
7514}
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525#define MLXSW_REG_RALST_ID 0x8011
7526#define MLXSW_REG_RALST_LEN 0x104
7527
7528MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
7529
7530
7531
7532
7533
7534
7535
7536MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
7537
7538
7539
7540
7541
7542MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
7543
7544#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
7545#define MLXSW_REG_RALST_BIN_OFFSET 0x04
7546#define MLXSW_REG_RALST_BIN_COUNT 128
7547
7548
7549
7550
7551
7552
7553
7554MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
7555
7556
7557
7558
7559
7560
7561
7562MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
7563 false);
7564
7565static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
7566{
7567 MLXSW_REG_ZERO(ralst, payload);
7568
7569
7570 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
7571 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
7572
7573 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
7574 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
7575}
7576
7577static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
7578 u8 left_child_bin,
7579 u8 right_child_bin)
7580{
7581 int bin_index = bin_number - 1;
7582
7583 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
7584 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
7585 right_child_bin);
7586}
7587
7588
7589
7590
7591
7592#define MLXSW_REG_RALTB_ID 0x8012
7593#define MLXSW_REG_RALTB_LEN 0x04
7594
7595MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
7596
7597
7598
7599
7600
7601
7602MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
7603
7604
7605
7606
7607
7608MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
7609
7610
7611
7612
7613
7614
7615
7616MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
7617
7618static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
7619 enum mlxsw_reg_ralxx_protocol protocol,
7620 u8 tree_id)
7621{
7622 MLXSW_REG_ZERO(raltb, payload);
7623 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
7624 mlxsw_reg_raltb_protocol_set(payload, protocol);
7625 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
7626}
7627
7628
7629
7630
7631
7632
7633#define MLXSW_REG_RALUE_ID 0x8013
7634#define MLXSW_REG_RALUE_LEN 0x38
7635
7636MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
7637
7638
7639
7640
7641
7642MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
7643
7644enum mlxsw_reg_ralue_op {
7645
7646 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
7647
7648
7649
7650 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
7651
7652
7653
7654
7655 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
7656
7657
7658
7659
7660 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
7661
7662
7663
7664 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
7665
7666
7667
7668 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
7669};
7670
7671
7672
7673
7674
7675MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
7676
7677
7678
7679
7680
7681
7682
7683
7684MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
7685
7686
7687
7688
7689
7690
7691MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
7692
7693#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
7694#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
7695#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
7696
7697
7698
7699
7700
7701
7702
7703
7704MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
7705
7706
7707
7708
7709
7710
7711
7712MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
7723MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
7724
7725enum mlxsw_reg_ralue_entry_type {
7726 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
7727 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
7728 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
7729};
7730
7731
7732
7733
7734
7735
7736MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
7747
7748enum mlxsw_reg_ralue_action_type {
7749 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
7750 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
7751 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
7752};
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
7764
7765enum mlxsw_reg_ralue_trap_action {
7766 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
7767 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
7768 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
7769 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
7770 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
7771};
7772
7773
7774
7775
7776
7777
7778MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
7779
7780
7781
7782
7783
7784
7785
7786MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
7787
7788
7789
7790
7791
7792
7793MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
7804
7805
7806
7807
7808
7809
7810MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
7823
7824
7825
7826
7827
7828
7829
7830MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
7831
7832static inline void mlxsw_reg_ralue_pack(char *payload,
7833 enum mlxsw_reg_ralxx_protocol protocol,
7834 enum mlxsw_reg_ralue_op op,
7835 u16 virtual_router, u8 prefix_len)
7836{
7837 MLXSW_REG_ZERO(ralue, payload);
7838 mlxsw_reg_ralue_protocol_set(payload, protocol);
7839 mlxsw_reg_ralue_op_set(payload, op);
7840 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
7841 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
7842 mlxsw_reg_ralue_entry_type_set(payload,
7843 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
7844 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
7845}
7846
7847static inline void mlxsw_reg_ralue_pack4(char *payload,
7848 enum mlxsw_reg_ralxx_protocol protocol,
7849 enum mlxsw_reg_ralue_op op,
7850 u16 virtual_router, u8 prefix_len,
7851 u32 *dip)
7852{
7853 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7854 if (dip)
7855 mlxsw_reg_ralue_dip4_set(payload, *dip);
7856}
7857
7858static inline void mlxsw_reg_ralue_pack6(char *payload,
7859 enum mlxsw_reg_ralxx_protocol protocol,
7860 enum mlxsw_reg_ralue_op op,
7861 u16 virtual_router, u8 prefix_len,
7862 const void *dip)
7863{
7864 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
7865 if (dip)
7866 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
7867}
7868
7869static inline void
7870mlxsw_reg_ralue_act_remote_pack(char *payload,
7871 enum mlxsw_reg_ralue_trap_action trap_action,
7872 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
7873{
7874 mlxsw_reg_ralue_action_type_set(payload,
7875 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
7876 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7877 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7878 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
7879 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
7880}
7881
7882static inline void
7883mlxsw_reg_ralue_act_local_pack(char *payload,
7884 enum mlxsw_reg_ralue_trap_action trap_action,
7885 u16 trap_id, u16 local_erif)
7886{
7887 mlxsw_reg_ralue_action_type_set(payload,
7888 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
7889 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
7890 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
7891 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
7892}
7893
7894static inline void
7895mlxsw_reg_ralue_act_ip2me_pack(char *payload)
7896{
7897 mlxsw_reg_ralue_action_type_set(payload,
7898 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7899}
7900
7901static inline void
7902mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
7903{
7904 mlxsw_reg_ralue_action_type_set(payload,
7905 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
7906 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
7907 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
7908}
7909
7910
7911
7912
7913
7914
7915#define MLXSW_REG_RAUHT_ID 0x8014
7916#define MLXSW_REG_RAUHT_LEN 0x74
7917
7918MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
7919
7920enum mlxsw_reg_rauht_type {
7921 MLXSW_REG_RAUHT_TYPE_IPV4,
7922 MLXSW_REG_RAUHT_TYPE_IPV6,
7923};
7924
7925
7926
7927
7928MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
7929
7930enum mlxsw_reg_rauht_op {
7931 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
7932
7933 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
7934
7935
7936
7937 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
7938
7939
7940
7941 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
7942
7943
7944
7945
7946 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
7947
7948 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
7949
7950 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
7951
7952
7953
7954};
7955
7956
7957
7958
7959MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
7960
7961
7962
7963
7964
7965
7966
7967
7968MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
7969
7970
7971
7972
7973
7974MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
7975
7976
7977
7978
7979
7980MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
7981MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
7982
7983enum mlxsw_reg_rauht_trap_action {
7984 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
7985 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
7986 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
7987 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
7988 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
7989};
7990
7991
7992
7993
7994MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
7995
7996enum mlxsw_reg_rauht_trap_id {
7997 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
7998 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
7999};
8000
8001
8002
8003
8004
8005
8006
8007
8008MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
8009
8010
8011
8012
8013
8014MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
8015
8016
8017
8018
8019
8020MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
8021
8022
8023
8024
8025
8026MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
8027
8028static inline void mlxsw_reg_rauht_pack(char *payload,
8029 enum mlxsw_reg_rauht_op op, u16 rif,
8030 const char *mac)
8031{
8032 MLXSW_REG_ZERO(rauht, payload);
8033 mlxsw_reg_rauht_op_set(payload, op);
8034 mlxsw_reg_rauht_rif_set(payload, rif);
8035 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
8036}
8037
8038static inline void mlxsw_reg_rauht_pack4(char *payload,
8039 enum mlxsw_reg_rauht_op op, u16 rif,
8040 const char *mac, u32 dip)
8041{
8042 mlxsw_reg_rauht_pack(payload, op, rif, mac);
8043 mlxsw_reg_rauht_dip4_set(payload, dip);
8044}
8045
8046static inline void mlxsw_reg_rauht_pack6(char *payload,
8047 enum mlxsw_reg_rauht_op op, u16 rif,
8048 const char *mac, const char *dip)
8049{
8050 mlxsw_reg_rauht_pack(payload, op, rif, mac);
8051 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
8052 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
8053}
8054
8055static inline void mlxsw_reg_rauht_pack_counter(char *payload,
8056 u64 counter_index)
8057{
8058 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
8059 mlxsw_reg_rauht_counter_set_type_set(payload,
8060 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
8061}
8062
8063
8064
8065
8066
8067
8068
8069#define MLXSW_REG_RALEU_ID 0x8015
8070#define MLXSW_REG_RALEU_LEN 0x28
8071
8072MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
8073
8074
8075
8076
8077
8078MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
8079
8080
8081
8082
8083
8084
8085MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
8086
8087
8088
8089
8090
8091MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
8092
8093
8094
8095
8096
8097MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
8098
8099
8100
8101
8102
8103MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
8104
8105
8106
8107
8108
8109MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
8110
8111static inline void mlxsw_reg_raleu_pack(char *payload,
8112 enum mlxsw_reg_ralxx_protocol protocol,
8113 u16 virtual_router,
8114 u32 adjacency_index, u16 ecmp_size,
8115 u32 new_adjacency_index,
8116 u16 new_ecmp_size)
8117{
8118 MLXSW_REG_ZERO(raleu, payload);
8119 mlxsw_reg_raleu_protocol_set(payload, protocol);
8120 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
8121 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
8122 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
8123 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
8124 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
8125}
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136#define MLXSW_REG_RAUHTD_ID 0x8018
8137#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
8138#define MLXSW_REG_RAUHTD_REC_LEN 0x20
8139#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
8140#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
8141 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
8142#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
8143
8144MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
8145
8146#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
8147#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
8148
8149
8150
8151
8152
8153
8154
8155
8156MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
8157
8158enum mlxsw_reg_rauhtd_op {
8159 MLXSW_REG_RAUHTD_OP_DUMP,
8160 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
8161};
8162
8163
8164
8165
8166MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
8177
8178
8179
8180
8181
8182
8183MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
8184
8185enum mlxsw_reg_rauhtd_type {
8186 MLXSW_REG_RAUHTD_TYPE_IPV4,
8187 MLXSW_REG_RAUHTD_TYPE_IPV6,
8188};
8189
8190
8191
8192
8193
8194
8195
8196MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
8197
8198
8199
8200
8201
8202
8203MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
8204
8205static inline void mlxsw_reg_rauhtd_pack(char *payload,
8206 enum mlxsw_reg_rauhtd_type type)
8207{
8208 MLXSW_REG_ZERO(rauhtd, payload);
8209 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
8210 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
8211 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
8212 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
8213 mlxsw_reg_rauhtd_type_set(payload, type);
8214}
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
8225 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
8226 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
8227
8228
8229
8230
8231
8232
8233
8234MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
8235 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
8236
8237#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
8238
8239
8240
8241
8242
8243
8244MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
8245 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
8246
8247
8248
8249
8250
8251MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8252 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
8253
8254
8255
8256
8257
8258MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8259 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
8260
8261#define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
8262
8263
8264
8265
8266
8267
8268MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
8269 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
8270
8271
8272
8273
8274
8275MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
8276 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
8277
8278
8279
8280
8281
8282MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
8283 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
8284
8285static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
8286 int ent_index, u16 *p_rif,
8287 u32 *p_dip)
8288{
8289 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
8290 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
8291}
8292
8293static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
8294 int rec_index, u16 *p_rif,
8295 char *p_dip)
8296{
8297 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
8298 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
8299}
8300
8301
8302
8303
8304
8305
8306#define MLXSW_REG_RTDP_ID 0x8020
8307#define MLXSW_REG_RTDP_LEN 0x44
8308
8309MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
8310
8311enum mlxsw_reg_rtdp_type {
8312 MLXSW_REG_RTDP_TYPE_NVE,
8313 MLXSW_REG_RTDP_TYPE_IPIP,
8314};
8315
8316
8317
8318
8319
8320MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
8321
8322
8323
8324
8325
8326
8327MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
8328
8329
8330
8331
8332
8333
8334MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
8335
8336
8337
8338
8339
8340
8341
8342MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
8343
8344enum mlxsw_reg_rtdp_ipip_sip_check {
8345
8346 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
8347
8348
8349
8350 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
8351
8352
8353
8354 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
8355};
8356
8357
8358
8359
8360
8361
8362MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
8363
8364
8365#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
8366
8367#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
8368
8369#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
8370
8371
8372
8373
8374
8375
8376MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
8388
8389
8390
8391
8392
8393
8394MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
8395
8396
8397
8398
8399
8400
8401
8402
8403MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
8404
8405
8406
8407
8408
8409
8410MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
8411
8412static inline void mlxsw_reg_rtdp_pack(char *payload,
8413 enum mlxsw_reg_rtdp_type type,
8414 u32 tunnel_index)
8415{
8416 MLXSW_REG_ZERO(rtdp, payload);
8417 mlxsw_reg_rtdp_type_set(payload, type);
8418 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
8419}
8420
8421static inline void
8422mlxsw_reg_rtdp_ipip_pack(char *payload, u16 irif,
8423 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8424 unsigned int type_check, bool gre_key_check,
8425 u32 expected_gre_key)
8426{
8427 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
8428 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
8429 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
8430 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
8431 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
8432}
8433
8434static inline void
8435mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
8436 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8437 unsigned int type_check, bool gre_key_check,
8438 u32 ipv4_usip, u32 expected_gre_key)
8439{
8440 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
8441 gre_key_check, expected_gre_key);
8442 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
8443}
8444
8445static inline void
8446mlxsw_reg_rtdp_ipip6_pack(char *payload, u16 irif,
8447 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
8448 unsigned int type_check, bool gre_key_check,
8449 u32 ipv6_usip_ptr, u32 expected_gre_key)
8450{
8451 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
8452 gre_key_check, expected_gre_key);
8453 mlxsw_reg_rtdp_ipip_ipv6_usip_ptr_set(payload, ipv6_usip_ptr);
8454}
8455
8456
8457
8458
8459
8460
8461#define MLXSW_REG_RIPS_ID 0x8021
8462#define MLXSW_REG_RIPS_LEN 0x14
8463
8464MLXSW_REG_DEFINE(rips, MLXSW_REG_RIPS_ID, MLXSW_REG_RIPS_LEN);
8465
8466
8467
8468
8469
8470
8471MLXSW_ITEM32(reg, rips, index, 0x00, 0, 24);
8472
8473
8474
8475
8476
8477MLXSW_ITEM_BUF(reg, rips, ipv6, 0x04, 16);
8478
8479static inline void mlxsw_reg_rips_pack(char *payload, u32 index,
8480 const struct in6_addr *ipv6)
8481{
8482 MLXSW_REG_ZERO(rips, payload);
8483 mlxsw_reg_rips_index_set(payload, index);
8484 mlxsw_reg_rips_ipv6_memcpy_to(payload, (const char *)ipv6);
8485}
8486
8487
8488
8489
8490
8491
8492#define MLXSW_REG_RATRAD_ID 0x8022
8493#define MLXSW_REG_RATRAD_LEN 0x210
8494
8495MLXSW_REG_DEFINE(ratrad, MLXSW_REG_RATRAD_ID, MLXSW_REG_RATRAD_LEN);
8496
8497enum {
8498
8499 MLXSW_REG_RATRAD_OP_READ_ACTIVITY,
8500
8501 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY,
8502};
8503
8504
8505
8506
8507MLXSW_ITEM32(reg, ratrad, op, 0x00, 30, 2);
8508
8509
8510
8511
8512
8513
8514
8515
8516MLXSW_ITEM32(reg, ratrad, ecmp_size, 0x00, 0, 13);
8517
8518
8519
8520
8521
8522MLXSW_ITEM32(reg, ratrad, adjacency_index, 0x04, 0, 24);
8523
8524
8525
8526
8527
8528
8529MLXSW_ITEM_BIT_ARRAY(reg, ratrad, activity_vector, 0x10, 0x200, 1);
8530
8531static inline void mlxsw_reg_ratrad_pack(char *payload, u32 adjacency_index,
8532 u16 ecmp_size)
8533{
8534 MLXSW_REG_ZERO(ratrad, payload);
8535 mlxsw_reg_ratrad_op_set(payload,
8536 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY);
8537 mlxsw_reg_ratrad_ecmp_size_set(payload, ecmp_size);
8538 mlxsw_reg_ratrad_adjacency_index_set(payload, adjacency_index);
8539}
8540
8541
8542
8543
8544
8545
8546#define MLXSW_REG_RIGR2_ID 0x8023
8547#define MLXSW_REG_RIGR2_LEN 0xB0
8548
8549#define MLXSW_REG_RIGR2_MAX_ERIFS 32
8550
8551MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
8552
8553
8554
8555
8556
8557MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
8558
8559
8560
8561
8562
8563MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
8564
8565
8566
8567
8568
8569
8570MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
8571
8572
8573
8574
8575
8576MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
8577
8578
8579
8580
8581
8582
8583
8584
8585MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
8596
8597
8598
8599
8600
8601
8602
8603MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
8604
8605static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
8606 bool vnext, u32 next_rigr_index)
8607{
8608 MLXSW_REG_ZERO(rigr2, payload);
8609 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
8610 mlxsw_reg_rigr2_vnext_set(payload, vnext);
8611 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
8612 mlxsw_reg_rigr2_vrmid_set(payload, 0);
8613 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
8614}
8615
8616static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
8617 bool v, u16 erif)
8618{
8619 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
8620 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
8621}
8622
8623
8624
8625
8626#define MLXSW_REG_RECR2_ID 0x8025
8627#define MLXSW_REG_RECR2_LEN 0x38
8628
8629MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
8630
8631
8632
8633
8634
8635MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
8636
8637
8638
8639
8640
8641MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
8642
8643
8644
8645
8646
8647MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
8648
8649enum {
8650
8651 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
8652
8653 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
8654
8655 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
8656
8657 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
8658
8659 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
8660
8661 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
8662
8663 __MLXSW_REG_RECR2_HEADER_CNT,
8664};
8665
8666
8667
8668
8669
8670
8671MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
8672
8673enum {
8674
8675 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
8676 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
8677
8678 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
8679 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
8680
8681 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
8682
8683 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
8684 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
8685 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
8686
8687 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
8688 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
8689 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
8690
8691 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
8692
8693 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
8694
8695 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
8696
8697 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
8698
8699 __MLXSW_REG_RECR2_FIELD_CNT,
8700};
8701
8702
8703
8704
8705
8706MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
8707
8708
8709
8710
8711
8712
8713MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_enables, 0x2C, 0x04, 1);
8714
8715enum {
8716
8717 MLXSW_REG_RECR2_INNER_IPV4_SIP0 = 3,
8718 MLXSW_REG_RECR2_INNER_IPV4_SIP3 = 6,
8719
8720 MLXSW_REG_RECR2_INNER_IPV4_DIP0 = 7,
8721 MLXSW_REG_RECR2_INNER_IPV4_DIP3 = 10,
8722
8723 MLXSW_REG_RECR2_INNER_IPV4_PROTOCOL = 11,
8724
8725 MLXSW_REG_RECR2_INNER_IPV6_SIP0_7 = 12,
8726 MLXSW_REG_RECR2_INNER_IPV6_SIP8 = 20,
8727 MLXSW_REG_RECR2_INNER_IPV6_SIP15 = 27,
8728
8729 MLXSW_REG_RECR2_INNER_IPV6_DIP0_7 = 28,
8730 MLXSW_REG_RECR2_INNER_IPV6_DIP8 = 36,
8731 MLXSW_REG_RECR2_INNER_IPV6_DIP15 = 43,
8732
8733 MLXSW_REG_RECR2_INNER_IPV6_NEXT_HEADER = 44,
8734
8735 MLXSW_REG_RECR2_INNER_IPV6_FLOW_LABEL = 45,
8736
8737 MLXSW_REG_RECR2_INNER_TCP_UDP_SPORT = 46,
8738
8739 MLXSW_REG_RECR2_INNER_TCP_UDP_DPORT = 47,
8740
8741 __MLXSW_REG_RECR2_INNER_FIELD_CNT,
8742};
8743
8744
8745
8746
8747
8748MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_fields_enable, 0x30, 0x08, 1);
8749
8750static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
8751{
8752 MLXSW_REG_ZERO(recr2, payload);
8753 mlxsw_reg_recr2_pp_set(payload, false);
8754 mlxsw_reg_recr2_sh_set(payload, true);
8755 mlxsw_reg_recr2_seed_set(payload, seed);
8756}
8757
8758
8759
8760
8761
8762#define MLXSW_REG_RMFT2_ID 0x8027
8763#define MLXSW_REG_RMFT2_LEN 0x174
8764
8765MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
8766
8767
8768
8769
8770
8771MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
8772
8773enum mlxsw_reg_rmft2_type {
8774 MLXSW_REG_RMFT2_TYPE_IPV4,
8775 MLXSW_REG_RMFT2_TYPE_IPV6
8776};
8777
8778
8779
8780
8781MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
8782
8783enum mlxsw_sp_reg_rmft2_op {
8784
8785
8786
8787
8788
8789
8790
8791 MLXSW_REG_RMFT2_OP_READ_WRITE,
8792};
8793
8794
8795
8796
8797
8798MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
8799
8800
8801
8802
8803
8804
8805MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
8806
8807
8808
8809
8810
8811MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
8812
8813
8814
8815
8816
8817MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
8818
8819enum mlxsw_reg_rmft2_irif_mask {
8820 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
8821 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
8822};
8823
8824
8825
8826
8827
8828MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
8829
8830
8831
8832
8833
8834MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
8835
8836
8837
8838
8839
8840MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
8841MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
8842
8843
8844
8845
8846
8847
8848MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
8849MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
8850
8851
8852
8853
8854
8855MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
8856MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
8857
8858
8859
8860
8861
8862
8863MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
8864MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
8878 MLXSW_REG_FLEX_ACTION_SET_LEN);
8879
8880static inline void
8881mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
8882 u16 virtual_router,
8883 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8884 const char *flex_action_set)
8885{
8886 MLXSW_REG_ZERO(rmft2, payload);
8887 mlxsw_reg_rmft2_v_set(payload, v);
8888 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
8889 mlxsw_reg_rmft2_offset_set(payload, offset);
8890 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
8891 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
8892 mlxsw_reg_rmft2_irif_set(payload, irif);
8893 if (flex_action_set)
8894 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
8895 flex_action_set);
8896}
8897
8898static inline void
8899mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8900 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8901 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
8902 const char *flexible_action_set)
8903{
8904 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8905 irif_mask, irif, flexible_action_set);
8906 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
8907 mlxsw_reg_rmft2_dip4_set(payload, dip4);
8908 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
8909 mlxsw_reg_rmft2_sip4_set(payload, sip4);
8910 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
8911}
8912
8913static inline void
8914mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
8915 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
8916 struct in6_addr dip6, struct in6_addr dip6_mask,
8917 struct in6_addr sip6, struct in6_addr sip6_mask,
8918 const char *flexible_action_set)
8919{
8920 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
8921 irif_mask, irif, flexible_action_set);
8922 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
8923 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
8924 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
8925 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
8926 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
8927}
8928
8929
8930
8931
8932
8933
8934
8935#define MLXSW_REG_RXLTE_ID 0x8050
8936#define MLXSW_REG_RXLTE_LEN 0x0C
8937
8938MLXSW_REG_DEFINE(rxlte, MLXSW_REG_RXLTE_ID, MLXSW_REG_RXLTE_LEN);
8939
8940
8941
8942
8943
8944
8945MLXSW_ITEM32(reg, rxlte, virtual_router, 0x00, 0, 16);
8946
8947enum mlxsw_reg_rxlte_protocol {
8948 MLXSW_REG_RXLTE_PROTOCOL_IPV4,
8949 MLXSW_REG_RXLTE_PROTOCOL_IPV6,
8950};
8951
8952
8953
8954
8955MLXSW_ITEM32(reg, rxlte, protocol, 0x04, 0, 4);
8956
8957
8958
8959
8960MLXSW_ITEM32(reg, rxlte, lpm_xlt_en, 0x08, 0, 1);
8961
8962static inline void mlxsw_reg_rxlte_pack(char *payload, u16 virtual_router,
8963 enum mlxsw_reg_rxlte_protocol protocol,
8964 bool lpm_xlt_en)
8965{
8966 MLXSW_REG_ZERO(rxlte, payload);
8967 mlxsw_reg_rxlte_virtual_router_set(payload, virtual_router);
8968 mlxsw_reg_rxlte_protocol_set(payload, protocol);
8969 mlxsw_reg_rxlte_lpm_xlt_en_set(payload, lpm_xlt_en);
8970}
8971
8972
8973
8974
8975
8976
8977#define MLXSW_REG_RXLTM_ID 0x8051
8978#define MLXSW_REG_RXLTM_LEN 0x14
8979
8980MLXSW_REG_DEFINE(rxltm, MLXSW_REG_RXLTM_ID, MLXSW_REG_RXLTM_LEN);
8981
8982
8983
8984
8985
8986
8987MLXSW_ITEM32(reg, rxltm, m0_val_v6, 0x10, 16, 8);
8988
8989
8990
8991
8992
8993
8994MLXSW_ITEM32(reg, rxltm, m0_val_v4, 0x10, 0, 6);
8995
8996static inline void mlxsw_reg_rxltm_pack(char *payload, u8 m0_val_v4, u8 m0_val_v6)
8997{
8998 MLXSW_REG_ZERO(rxltm, payload);
8999 mlxsw_reg_rxltm_m0_val_v6_set(payload, m0_val_v6);
9000 mlxsw_reg_rxltm_m0_val_v4_set(payload, m0_val_v4);
9001}
9002
9003
9004
9005
9006
9007
9008
9009
9010#define MLXSW_REG_RLCMLD_ID 0x8055
9011#define MLXSW_REG_RLCMLD_LEN 0x30
9012
9013MLXSW_REG_DEFINE(rlcmld, MLXSW_REG_RLCMLD_ID, MLXSW_REG_RLCMLD_LEN);
9014
9015enum mlxsw_reg_rlcmld_select {
9016 MLXSW_REG_RLCMLD_SELECT_ML_ENTRIES,
9017 MLXSW_REG_RLCMLD_SELECT_M_ENTRIES,
9018 MLXSW_REG_RLCMLD_SELECT_M_AND_ML_ENTRIES,
9019};
9020
9021
9022
9023
9024
9025MLXSW_ITEM32(reg, rlcmld, select, 0x00, 16, 2);
9026
9027enum mlxsw_reg_rlcmld_filter_fields {
9028 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_PROTOCOL = 0x04,
9029 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_VIRTUAL_ROUTER = 0x08,
9030 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_DIP = 0x10,
9031};
9032
9033
9034
9035
9036
9037MLXSW_ITEM32(reg, rlcmld, filter_fields, 0x00, 0, 8);
9038
9039enum mlxsw_reg_rlcmld_protocol {
9040 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV4,
9041 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV6,
9042};
9043
9044
9045
9046
9047MLXSW_ITEM32(reg, rlcmld, protocol, 0x08, 0, 4);
9048
9049
9050
9051
9052
9053
9054MLXSW_ITEM32(reg, rlcmld, virtual_router, 0x0C, 0, 16);
9055
9056
9057
9058
9059
9060
9061MLXSW_ITEM32(reg, rlcmld, dip4, 0x1C, 0, 32);
9062MLXSW_ITEM_BUF(reg, rlcmld, dip6, 0x10, 16);
9063
9064
9065
9066
9067
9068
9069
9070MLXSW_ITEM32(reg, rlcmld, dip_mask4, 0x2C, 0, 32);
9071MLXSW_ITEM_BUF(reg, rlcmld, dip_mask6, 0x20, 16);
9072
9073static inline void __mlxsw_reg_rlcmld_pack(char *payload,
9074 enum mlxsw_reg_rlcmld_select select,
9075 enum mlxsw_reg_rlcmld_protocol protocol,
9076 u16 virtual_router)
9077{
9078 u8 filter_fields = MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_PROTOCOL |
9079 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_VIRTUAL_ROUTER |
9080 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_DIP;
9081
9082 MLXSW_REG_ZERO(rlcmld, payload);
9083 mlxsw_reg_rlcmld_select_set(payload, select);
9084 mlxsw_reg_rlcmld_filter_fields_set(payload, filter_fields);
9085 mlxsw_reg_rlcmld_protocol_set(payload, protocol);
9086 mlxsw_reg_rlcmld_virtual_router_set(payload, virtual_router);
9087}
9088
9089static inline void mlxsw_reg_rlcmld_pack4(char *payload,
9090 enum mlxsw_reg_rlcmld_select select,
9091 u16 virtual_router,
9092 u32 dip, u32 dip_mask)
9093{
9094 __mlxsw_reg_rlcmld_pack(payload, select,
9095 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV4,
9096 virtual_router);
9097 mlxsw_reg_rlcmld_dip4_set(payload, dip);
9098 mlxsw_reg_rlcmld_dip_mask4_set(payload, dip_mask);
9099}
9100
9101static inline void mlxsw_reg_rlcmld_pack6(char *payload,
9102 enum mlxsw_reg_rlcmld_select select,
9103 u16 virtual_router,
9104 const void *dip, const void *dip_mask)
9105{
9106 __mlxsw_reg_rlcmld_pack(payload, select,
9107 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV6,
9108 virtual_router);
9109 mlxsw_reg_rlcmld_dip6_memcpy_to(payload, dip);
9110 mlxsw_reg_rlcmld_dip_mask6_memcpy_to(payload, dip_mask);
9111}
9112
9113
9114
9115
9116
9117
9118#define MLXSW_REG_RLPMCE_ID 0x8056
9119#define MLXSW_REG_RLPMCE_LEN 0x4
9120
9121MLXSW_REG_DEFINE(rlpmce, MLXSW_REG_RLPMCE_ID, MLXSW_REG_RLPMCE_LEN);
9122
9123
9124
9125
9126
9127
9128
9129MLXSW_ITEM32(reg, rlpmce, flush, 0x00, 4, 1);
9130
9131
9132
9133
9134
9135
9136
9137MLXSW_ITEM32(reg, rlpmce, disable, 0x00, 0, 1);
9138
9139static inline void mlxsw_reg_rlpmce_pack(char *payload, bool flush,
9140 bool disable)
9141{
9142 MLXSW_REG_ZERO(rlpmce, payload);
9143 mlxsw_reg_rlpmce_flush_set(payload, flush);
9144 mlxsw_reg_rlpmce_disable_set(payload, disable);
9145}
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157#define MLXSW_REG_XLTQ_ID 0x7802
9158#define MLXSW_REG_XLTQ_LEN 0x2C
9159
9160MLXSW_REG_DEFINE(xltq, MLXSW_REG_XLTQ_ID, MLXSW_REG_XLTQ_LEN);
9161
9162enum mlxsw_reg_xltq_xm_device_id {
9163 MLXSW_REG_XLTQ_XM_DEVICE_ID_UNKNOWN,
9164 MLXSW_REG_XLTQ_XM_DEVICE_ID_XLT = 0xCF71,
9165};
9166
9167
9168
9169
9170
9171MLXSW_ITEM32(reg, xltq, xm_device_id, 0x04, 0, 16);
9172
9173
9174
9175
9176MLXSW_ITEM32(reg, xltq, xlt_cap_ipv4_lpm, 0x10, 0, 1);
9177
9178
9179
9180
9181MLXSW_ITEM32(reg, xltq, xlt_cap_ipv6_lpm, 0x10, 1, 1);
9182
9183
9184
9185
9186
9187
9188MLXSW_ITEM32(reg, xltq, cap_xlt_entries, 0x20, 0, 32);
9189
9190
9191
9192
9193
9194MLXSW_ITEM32(reg, xltq, cap_xlt_mtable, 0x24, 0, 32);
9195
9196static inline void mlxsw_reg_xltq_pack(char *payload)
9197{
9198 MLXSW_REG_ZERO(xltq, payload);
9199}
9200
9201static inline void mlxsw_reg_xltq_unpack(char *payload, u16 *xm_device_id, bool *xlt_cap_ipv4_lpm,
9202 bool *xlt_cap_ipv6_lpm, u32 *cap_xlt_entries,
9203 u32 *cap_xlt_mtable)
9204{
9205 *xm_device_id = mlxsw_reg_xltq_xm_device_id_get(payload);
9206 *xlt_cap_ipv4_lpm = mlxsw_reg_xltq_xlt_cap_ipv4_lpm_get(payload);
9207 *xlt_cap_ipv6_lpm = mlxsw_reg_xltq_xlt_cap_ipv6_lpm_get(payload);
9208 *cap_xlt_entries = mlxsw_reg_xltq_cap_xlt_entries_get(payload);
9209 *cap_xlt_mtable = mlxsw_reg_xltq_cap_xlt_mtable_get(payload);
9210}
9211
9212
9213
9214
9215
9216
9217
9218#define MLXSW_REG_XMDR_ID 0x7803
9219#define MLXSW_REG_XMDR_BASE_LEN 0x20
9220#define MLXSW_REG_XMDR_TRANS_LEN 0x80
9221#define MLXSW_REG_XMDR_LEN (MLXSW_REG_XMDR_BASE_LEN + \
9222 MLXSW_REG_XMDR_TRANS_LEN)
9223
9224MLXSW_REG_DEFINE(xmdr, MLXSW_REG_XMDR_ID, MLXSW_REG_XMDR_LEN);
9225
9226
9227
9228
9229
9230
9231
9232MLXSW_ITEM32(reg, xmdr, bulk_entry, 0x04, 8, 1);
9233
9234
9235
9236
9237
9238
9239
9240
9241MLXSW_ITEM32(reg, xmdr, num_rec, 0x04, 0, 4);
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253MLXSW_ITEM_BIT_ARRAY(reg, xmdr, reply_vect, 0x08, 4, 1);
9254
9255static inline void mlxsw_reg_xmdr_pack(char *payload, bool bulk_entry)
9256{
9257 MLXSW_REG_ZERO(xmdr, payload);
9258 mlxsw_reg_xmdr_bulk_entry_set(payload, bulk_entry);
9259}
9260
9261enum mlxsw_reg_xmdr_c_cmd_id {
9262 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V4 = 0x30,
9263 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V6 = 0x31,
9264};
9265
9266#define MLXSW_REG_XMDR_C_LT_ROUTE_V4_LEN 32
9267#define MLXSW_REG_XMDR_C_LT_ROUTE_V6_LEN 48
9268
9269
9270
9271MLXSW_ITEM32(reg, xmdr_c, cmd_id, 0x00, 24, 8);
9272
9273
9274
9275MLXSW_ITEM32(reg, xmdr_c, seq_number, 0x00, 12, 12);
9276
9277enum mlxsw_reg_xmdr_c_ltr_op {
9278
9279 MLXSW_REG_XMDR_C_LTR_OP_WRITE = 0,
9280
9281 MLXSW_REG_XMDR_C_LTR_OP_UPDATE = 1,
9282 MLXSW_REG_XMDR_C_LTR_OP_DELETE = 2,
9283};
9284
9285
9286
9287
9288MLXSW_ITEM32(reg, xmdr_c, ltr_op, 0x04, 24, 8);
9289
9290
9291
9292
9293
9294MLXSW_ITEM32(reg, xmdr_c, ltr_trap_action, 0x04, 20, 4);
9295
9296enum mlxsw_reg_xmdr_c_ltr_trap_id_num {
9297 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS0,
9298 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS1,
9299 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS2,
9300 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS3,
9301};
9302
9303
9304
9305
9306MLXSW_ITEM32(reg, xmdr_c, ltr_trap_id_num, 0x04, 16, 4);
9307
9308
9309
9310
9311
9312MLXSW_ITEM32(reg, xmdr_c, ltr_virtual_router, 0x04, 0, 16);
9313
9314
9315
9316
9317MLXSW_ITEM32(reg, xmdr_c, ltr_prefix_len, 0x08, 24, 8);
9318
9319
9320
9321
9322
9323
9324MLXSW_ITEM32(reg, xmdr_c, ltr_bmp_len, 0x08, 16, 8);
9325
9326
9327
9328
9329
9330MLXSW_ITEM32(reg, xmdr_c, ltr_entry_type, 0x08, 4, 4);
9331
9332enum mlxsw_reg_xmdr_c_ltr_action_type {
9333 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_LOCAL,
9334 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_REMOTE,
9335 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME,
9336};
9337
9338
9339
9340
9341MLXSW_ITEM32(reg, xmdr_c, ltr_action_type, 0x08, 0, 4);
9342
9343
9344
9345
9346
9347MLXSW_ITEM32(reg, xmdr_c, ltr_erif, 0x10, 0, 16);
9348
9349
9350
9351
9352
9353MLXSW_ITEM32(reg, xmdr_c, ltr_adjacency_index, 0x10, 0, 24);
9354
9355#define MLXSW_REG_XMDR_C_LTR_POINTER_TO_TUNNEL_DISABLED_MAGIC 0xFFFFFF
9356
9357
9358
9359
9360MLXSW_ITEM32(reg, xmdr_c, ltr_pointer_to_tunnel, 0x10, 0, 24);
9361
9362
9363
9364
9365
9366
9367
9368MLXSW_ITEM32(reg, xmdr_c, ltr_ecmp_size, 0x14, 0, 32);
9369
9370
9371
9372
9373
9374
9375
9376MLXSW_ITEM32(reg, xmdr_c, ltr_dip4, 0x1C, 0, 32);
9377MLXSW_ITEM_BUF(reg, xmdr_c, ltr_dip6, 0x1C, 16);
9378
9379static inline void
9380mlxsw_reg_xmdr_c_ltr_pack(char *xmdr_payload, unsigned int trans_offset,
9381 enum mlxsw_reg_xmdr_c_cmd_id cmd_id, u16 seq_number,
9382 enum mlxsw_reg_xmdr_c_ltr_op op, u16 virtual_router,
9383 u8 prefix_len)
9384{
9385 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9386 u8 num_rec = mlxsw_reg_xmdr_num_rec_get(xmdr_payload);
9387
9388 mlxsw_reg_xmdr_num_rec_set(xmdr_payload, num_rec + 1);
9389
9390 mlxsw_reg_xmdr_c_cmd_id_set(payload, cmd_id);
9391 mlxsw_reg_xmdr_c_seq_number_set(payload, seq_number);
9392 mlxsw_reg_xmdr_c_ltr_op_set(payload, op);
9393 mlxsw_reg_xmdr_c_ltr_virtual_router_set(payload, virtual_router);
9394 mlxsw_reg_xmdr_c_ltr_prefix_len_set(payload, prefix_len);
9395 mlxsw_reg_xmdr_c_ltr_entry_type_set(payload,
9396 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
9397 mlxsw_reg_xmdr_c_ltr_bmp_len_set(payload, prefix_len);
9398}
9399
9400static inline unsigned int
9401mlxsw_reg_xmdr_c_ltr_pack4(char *xmdr_payload, unsigned int trans_offset,
9402 u16 seq_number, enum mlxsw_reg_xmdr_c_ltr_op op,
9403 u16 virtual_router, u8 prefix_len, u32 *dip)
9404{
9405 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9406
9407 mlxsw_reg_xmdr_c_ltr_pack(xmdr_payload, trans_offset,
9408 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V4,
9409 seq_number, op, virtual_router, prefix_len);
9410 if (dip)
9411 mlxsw_reg_xmdr_c_ltr_dip4_set(payload, *dip);
9412 return MLXSW_REG_XMDR_C_LT_ROUTE_V4_LEN;
9413}
9414
9415static inline unsigned int
9416mlxsw_reg_xmdr_c_ltr_pack6(char *xmdr_payload, unsigned int trans_offset,
9417 u16 seq_number, enum mlxsw_reg_xmdr_c_ltr_op op,
9418 u16 virtual_router, u8 prefix_len, const void *dip)
9419{
9420 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9421
9422 mlxsw_reg_xmdr_c_ltr_pack(xmdr_payload, trans_offset,
9423 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V6,
9424 seq_number, op, virtual_router, prefix_len);
9425 if (dip)
9426 mlxsw_reg_xmdr_c_ltr_dip6_memcpy_to(payload, dip);
9427 return MLXSW_REG_XMDR_C_LT_ROUTE_V6_LEN;
9428}
9429
9430static inline void
9431mlxsw_reg_xmdr_c_ltr_act_remote_pack(char *xmdr_payload, unsigned int trans_offset,
9432 enum mlxsw_reg_ralue_trap_action trap_action,
9433 enum mlxsw_reg_xmdr_c_ltr_trap_id_num trap_id_num,
9434 u32 adjacency_index, u16 ecmp_size)
9435{
9436 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9437
9438 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_REMOTE);
9439 mlxsw_reg_xmdr_c_ltr_trap_action_set(payload, trap_action);
9440 mlxsw_reg_xmdr_c_ltr_trap_id_num_set(payload, trap_id_num);
9441 mlxsw_reg_xmdr_c_ltr_adjacency_index_set(payload, adjacency_index);
9442 mlxsw_reg_xmdr_c_ltr_ecmp_size_set(payload, ecmp_size);
9443}
9444
9445static inline void
9446mlxsw_reg_xmdr_c_ltr_act_local_pack(char *xmdr_payload, unsigned int trans_offset,
9447 enum mlxsw_reg_ralue_trap_action trap_action,
9448 enum mlxsw_reg_xmdr_c_ltr_trap_id_num trap_id_num, u16 erif)
9449{
9450 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9451
9452 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_LOCAL);
9453 mlxsw_reg_xmdr_c_ltr_trap_action_set(payload, trap_action);
9454 mlxsw_reg_xmdr_c_ltr_trap_id_num_set(payload, trap_id_num);
9455 mlxsw_reg_xmdr_c_ltr_erif_set(payload, erif);
9456}
9457
9458static inline void mlxsw_reg_xmdr_c_ltr_act_ip2me_pack(char *xmdr_payload,
9459 unsigned int trans_offset)
9460{
9461 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9462
9463 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME);
9464 mlxsw_reg_xmdr_c_ltr_pointer_to_tunnel_set(payload,
9465 MLXSW_REG_XMDR_C_LTR_POINTER_TO_TUNNEL_DISABLED_MAGIC);
9466}
9467
9468static inline void mlxsw_reg_xmdr_c_ltr_act_ip2me_tun_pack(char *xmdr_payload,
9469 unsigned int trans_offset,
9470 u32 pointer_to_tunnel)
9471{
9472 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset;
9473
9474 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME);
9475 mlxsw_reg_xmdr_c_ltr_pointer_to_tunnel_set(payload, pointer_to_tunnel);
9476}
9477
9478
9479
9480
9481
9482#define MLXSW_REG_XRMT_ID 0x7810
9483#define MLXSW_REG_XRMT_LEN 0x14
9484
9485MLXSW_REG_DEFINE(xrmt, MLXSW_REG_XRMT_ID, MLXSW_REG_XRMT_LEN);
9486
9487
9488
9489
9490
9491
9492MLXSW_ITEM32(reg, xrmt, index, 0x04, 0, 20);
9493
9494
9495
9496
9497MLXSW_ITEM32(reg, xrmt, l0_val, 0x10, 24, 8);
9498
9499static inline void mlxsw_reg_xrmt_pack(char *payload, u32 index, u8 l0_val)
9500{
9501 MLXSW_REG_ZERO(xrmt, payload);
9502 mlxsw_reg_xrmt_index_set(payload, index);
9503 mlxsw_reg_xrmt_l0_val_set(payload, l0_val);
9504}
9505
9506
9507
9508
9509
9510
9511
9512#define MLXSW_REG_XRALTA_ID 0x7811
9513#define MLXSW_REG_XRALTA_LEN 0x08
9514#define MLXSW_REG_XRALTA_RALTA_OFFSET 0x04
9515
9516MLXSW_REG_DEFINE(xralta, MLXSW_REG_XRALTA_ID, MLXSW_REG_XRALTA_LEN);
9517
9518static inline void mlxsw_reg_xralta_pack(char *payload, bool alloc,
9519 enum mlxsw_reg_ralxx_protocol protocol,
9520 u8 tree_id)
9521{
9522 char *ralta_payload = payload + MLXSW_REG_XRALTA_RALTA_OFFSET;
9523
9524 MLXSW_REG_ZERO(xralta, payload);
9525 mlxsw_reg_ralta_pack(ralta_payload, alloc, protocol, tree_id);
9526}
9527
9528
9529
9530
9531
9532
9533
9534#define MLXSW_REG_XRALST_ID 0x7812
9535#define MLXSW_REG_XRALST_LEN 0x108
9536#define MLXSW_REG_XRALST_RALST_OFFSET 0x04
9537
9538MLXSW_REG_DEFINE(xralst, MLXSW_REG_XRALST_ID, MLXSW_REG_XRALST_LEN);
9539
9540static inline void mlxsw_reg_xralst_pack(char *payload, u8 root_bin, u8 tree_id)
9541{
9542 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET;
9543
9544 MLXSW_REG_ZERO(xralst, payload);
9545 mlxsw_reg_ralst_pack(ralst_payload, root_bin, tree_id);
9546}
9547
9548static inline void mlxsw_reg_xralst_bin_pack(char *payload, u8 bin_number,
9549 u8 left_child_bin,
9550 u8 right_child_bin)
9551{
9552 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET;
9553
9554 mlxsw_reg_ralst_bin_pack(ralst_payload, bin_number, left_child_bin,
9555 right_child_bin);
9556}
9557
9558
9559
9560
9561
9562
9563
9564
9565#define MLXSW_REG_XRALTB_ID 0x7813
9566#define MLXSW_REG_XRALTB_LEN 0x08
9567#define MLXSW_REG_XRALTB_RALTB_OFFSET 0x04
9568
9569MLXSW_REG_DEFINE(xraltb, MLXSW_REG_XRALTB_ID, MLXSW_REG_XRALTB_LEN);
9570
9571static inline void mlxsw_reg_xraltb_pack(char *payload, u16 virtual_router,
9572 enum mlxsw_reg_ralxx_protocol protocol,
9573 u8 tree_id)
9574{
9575 char *raltb_payload = payload + MLXSW_REG_XRALTB_RALTB_OFFSET;
9576
9577 MLXSW_REG_ZERO(xraltb, payload);
9578 mlxsw_reg_raltb_pack(raltb_payload, virtual_router, protocol, tree_id);
9579}
9580
9581
9582
9583
9584
9585#define MLXSW_REG_MFCR_ID 0x9001
9586#define MLXSW_REG_MFCR_LEN 0x08
9587
9588MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
9589
9590enum mlxsw_reg_mfcr_pwm_frequency {
9591 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
9592 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
9593 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
9594 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
9595 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
9596 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
9597 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
9598 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
9599};
9600
9601
9602
9603
9604
9605MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
9606
9607#define MLXSW_MFCR_TACHOS_MAX 10
9608
9609
9610
9611
9612
9613MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
9614
9615#define MLXSW_MFCR_PWMS_MAX 5
9616
9617
9618
9619
9620
9621MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
9622
9623static inline void
9624mlxsw_reg_mfcr_pack(char *payload,
9625 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
9626{
9627 MLXSW_REG_ZERO(mfcr, payload);
9628 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
9629}
9630
9631static inline void
9632mlxsw_reg_mfcr_unpack(char *payload,
9633 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
9634 u16 *p_tacho_active, u8 *p_pwm_active)
9635{
9636 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
9637 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
9638 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
9639}
9640
9641
9642
9643
9644
9645#define MLXSW_REG_MFSC_ID 0x9002
9646#define MLXSW_REG_MFSC_LEN 0x08
9647
9648MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
9649
9650
9651
9652
9653
9654MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
9655
9656
9657
9658
9659
9660
9661MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
9662
9663static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
9664 u8 pwm_duty_cycle)
9665{
9666 MLXSW_REG_ZERO(mfsc, payload);
9667 mlxsw_reg_mfsc_pwm_set(payload, pwm);
9668 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
9669}
9670
9671
9672
9673
9674
9675
9676#define MLXSW_REG_MFSM_ID 0x9003
9677#define MLXSW_REG_MFSM_LEN 0x08
9678
9679MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
9680
9681
9682
9683
9684
9685MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
9686
9687
9688
9689
9690
9691MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
9692
9693static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
9694{
9695 MLXSW_REG_ZERO(mfsm, payload);
9696 mlxsw_reg_mfsm_tacho_set(payload, tacho);
9697}
9698
9699
9700
9701
9702
9703
9704
9705#define MLXSW_REG_MFSL_ID 0x9004
9706#define MLXSW_REG_MFSL_LEN 0x0C
9707
9708MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
9709
9710
9711
9712
9713
9714MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
9715
9716
9717
9718
9719
9720MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
9721
9722
9723
9724
9725
9726MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
9727
9728static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
9729 u16 tach_min, u16 tach_max)
9730{
9731 MLXSW_REG_ZERO(mfsl, payload);
9732 mlxsw_reg_mfsl_tacho_set(payload, tacho);
9733 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
9734 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
9735}
9736
9737static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
9738 u16 *p_tach_min, u16 *p_tach_max)
9739{
9740 if (p_tach_min)
9741 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
9742
9743 if (p_tach_max)
9744 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
9745}
9746
9747
9748
9749
9750
9751
9752#define MLXSW_REG_FORE_ID 0x9007
9753#define MLXSW_REG_FORE_LEN 0x0C
9754
9755MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
9756
9757
9758
9759
9760
9761
9762
9763MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
9764
9765static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
9766 bool *fault)
9767{
9768 u16 limit;
9769
9770 if (fault) {
9771 limit = mlxsw_reg_fore_fan_under_limit_get(payload);
9772 *fault = limit & BIT(tacho);
9773 }
9774}
9775
9776
9777
9778
9779
9780
9781#define MLXSW_REG_MTCAP_ID 0x9009
9782#define MLXSW_REG_MTCAP_LEN 0x08
9783
9784MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
9785
9786
9787
9788
9789
9790
9791MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
9792
9793
9794
9795
9796
9797
9798
9799#define MLXSW_REG_MTMP_ID 0x900A
9800#define MLXSW_REG_MTMP_LEN 0x20
9801
9802MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
9803
9804
9805
9806
9807
9808MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4);
9809
9810#define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
9811#define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
9812
9813
9814
9815
9816
9817
9818MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
9819
9820
9821#define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
9822 ((v_) >= 0) ? ((v_) * 125) : \
9823 ((s16)((GENMASK(15, 0) + (v_) + 1) \
9824 * 125)); })
9825
9826
9827
9828
9829
9830
9831
9832MLXSW_ITEM32(reg, mtmp, max_operational_temperature, 0x04, 16, 16);
9833
9834
9835
9836
9837
9838
9839MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
9840
9841
9842
9843
9844
9845MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
9846
9847
9848
9849
9850
9851MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
9852
9853
9854
9855
9856
9857
9858MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868enum mlxsw_reg_mtmp_tee {
9869 MLXSW_REG_MTMP_TEE_NO_EVENT,
9870 MLXSW_REG_MTMP_TEE_GENERATE_EVENT,
9871 MLXSW_REG_MTMP_TEE_GENERATE_SINGLE_EVENT,
9872};
9873
9874MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
9875
9876#define MLXSW_REG_MTMP_THRESH_HI 0x348
9877
9878
9879
9880
9881
9882MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
9883
9884#define MLXSW_REG_MTMP_HYSTERESIS_TEMP 0x28
9885
9886
9887
9888
9889MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
9890
9891#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
9892
9893
9894
9895
9896
9897MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
9898
9899static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index,
9900 u16 sensor_index, bool max_temp_enable,
9901 bool max_temp_reset)
9902{
9903 MLXSW_REG_ZERO(mtmp, payload);
9904 mlxsw_reg_mtmp_slot_index_set(payload, slot_index);
9905 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
9906 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
9907 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
9908 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
9909 MLXSW_REG_MTMP_THRESH_HI);
9910}
9911
9912static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
9913 int *p_max_temp, int *p_temp_hi,
9914 int *p_max_oper_temp,
9915 char *sensor_name)
9916{
9917 s16 temp;
9918
9919 if (p_temp) {
9920 temp = mlxsw_reg_mtmp_temperature_get(payload);
9921 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9922 }
9923 if (p_max_temp) {
9924 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
9925 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9926 }
9927 if (p_temp_hi) {
9928 temp = mlxsw_reg_mtmp_temperature_threshold_hi_get(payload);
9929 *p_temp_hi = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9930 }
9931 if (p_max_oper_temp) {
9932 temp = mlxsw_reg_mtmp_max_operational_temperature_get(payload);
9933 *p_max_oper_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
9934 }
9935 if (sensor_name)
9936 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
9937}
9938
9939
9940
9941
9942
9943#define MLXSW_REG_MTWE_ID 0x900B
9944#define MLXSW_REG_MTWE_LEN 0x10
9945
9946MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN);
9947
9948
9949
9950
9951
9952
9953
9954MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
9955
9956
9957
9958
9959
9960#define MLXSW_REG_MTBR_ID 0x900F
9961#define MLXSW_REG_MTBR_BASE_LEN 0x10
9962#define MLXSW_REG_MTBR_REC_LEN 0x04
9963#define MLXSW_REG_MTBR_REC_MAX_COUNT 47
9964#define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
9965 MLXSW_REG_MTBR_REC_LEN * \
9966 MLXSW_REG_MTBR_REC_MAX_COUNT)
9967
9968MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
9969
9970
9971
9972
9973
9974MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4);
9975
9976
9977
9978
9979
9980
9981MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
9982
9983
9984
9985
9986
9987
9988
9989
9990MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
9991
9992
9993
9994
9995
9996
9997MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
9998 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
9999
10000
10001
10002
10003
10004
10005MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
10006 MLXSW_REG_MTBR_REC_LEN, 0x00, false);
10007
10008static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index,
10009 u16 base_sensor_index, u8 num_rec)
10010{
10011 MLXSW_REG_ZERO(mtbr, payload);
10012 mlxsw_reg_mtbr_slot_index_set(payload, slot_index);
10013 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
10014 mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
10015}
10016
10017
10018enum mlxsw_reg_mtbr_temp_status {
10019 MLXSW_REG_MTBR_NO_CONN = 0x8000,
10020 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
10021 MLXSW_REG_MTBR_INDEX_NA = 0x8002,
10022 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
10023};
10024
10025
10026#define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
10027
10028static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
10029 u16 *p_temp, u16 *p_max_temp)
10030{
10031 if (p_temp)
10032 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
10033 if (p_max_temp)
10034 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
10035}
10036
10037
10038
10039
10040
10041
10042#define MLXSW_REG_MCIA_ID 0x9014
10043#define MLXSW_REG_MCIA_LEN 0x40
10044
10045MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
10046
10047
10048
10049
10050
10051
10052
10053MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
10054
10055
10056
10057
10058
10059MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
10060
10061
10062
10063
10064
10065MLXSW_ITEM32(reg, mcia, slot, 0x00, 12, 4);
10066
10067enum {
10068 MLXSW_REG_MCIA_STATUS_GOOD = 0,
10069
10070 MLXSW_REG_MCIA_STATUS_NO_EEPROM_MODULE = 1,
10071
10072 MLXSW_REG_MCIA_STATUS_MODULE_NOT_SUPPORTED = 2,
10073
10074 MLXSW_REG_MCIA_STATUS_MODULE_NOT_CONNECTED = 3,
10075
10076 MLXSW_REG_MCIA_STATUS_I2C_ERROR = 9,
10077
10078 MLXSW_REG_MCIA_STATUS_MODULE_DISABLED = 16,
10079};
10080
10081
10082
10083
10084
10085MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
10086
10087
10088
10089
10090
10091MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
10092
10093
10094
10095
10096
10097MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
10098
10099
10100
10101
10102
10103MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
10104
10105
10106
10107
10108
10109MLXSW_ITEM32(reg, mcia, bank_number, 0x08, 16, 8);
10110
10111
10112
10113
10114
10115MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
10116
10117#define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
10118#define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
10119#define MLXSW_REG_MCIA_EEPROM_SIZE 48
10120#define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
10121#define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
10122#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
10123#define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
10124#define MLXSW_REG_MCIA_TH_PAGE_NUM 3
10125#define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
10126#define MLXSW_REG_MCIA_PAGE0_LO 0
10127#define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
10128#define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
10129
10130enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
10131 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
10132 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
10133 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
10134};
10135
10136enum mlxsw_reg_mcia_eeprom_module_info_id {
10137 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
10138 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
10139 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
10140 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
10141 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
10142 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP = 0x19,
10143};
10144
10145enum mlxsw_reg_mcia_eeprom_module_info {
10146 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
10147 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
10148 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
10149 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
10150};
10151
10152
10153
10154
10155
10156MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
10157
10158
10159
10160
10161
10162#define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
10163 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
10164 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
10165
10166static inline void mlxsw_reg_mcia_pack(char *payload, u8 slot_index, u8 module,
10167 u8 lock, u8 page_number,
10168 u16 device_addr, u8 size,
10169 u8 i2c_device_addr)
10170{
10171 MLXSW_REG_ZERO(mcia, payload);
10172 mlxsw_reg_mcia_slot_set(payload, slot_index);
10173 mlxsw_reg_mcia_module_set(payload, module);
10174 mlxsw_reg_mcia_l_set(payload, lock);
10175 mlxsw_reg_mcia_page_number_set(payload, page_number);
10176 mlxsw_reg_mcia_device_address_set(payload, device_addr);
10177 mlxsw_reg_mcia_size_set(payload, size);
10178 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
10179}
10180
10181
10182
10183
10184
10185
10186#define MLXSW_REG_MPAT_ID 0x901A
10187#define MLXSW_REG_MPAT_LEN 0x78
10188
10189MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
10190
10191
10192
10193
10194
10195MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
10196
10197
10198
10199
10200
10201
10202MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4);
10203
10204
10205
10206
10207
10208MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
10209
10210
10211
10212
10213
10214MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
10236
10237enum mlxsw_reg_mpat_span_type {
10238
10239
10240
10241 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
10242
10243
10244
10245
10246
10247 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
10248
10249
10250
10251
10252 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
10253};
10254
10255
10256
10257
10258
10259MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
10260
10261
10262
10263
10264
10265MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1);
10266
10267
10268
10269
10270
10271MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14);
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
10282
10283
10284
10285
10286
10287enum mlxsw_reg_mpat_eth_rspan_version {
10288 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
10289};
10290
10291
10292
10293
10294
10295MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
10296
10297
10298
10299
10300
10301MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
10302
10303
10304
10305
10306
10307MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
10308
10309
10310
10311
10312
10313enum mlxsw_reg_mpat_eth_rspan_protocol {
10314 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
10315 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
10316};
10317
10318
10319
10320
10321
10322MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
10323
10324
10325
10326
10327
10328MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
10329
10330
10331
10332
10333
10334MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
10335
10336
10337
10338
10339
10340MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
10341MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
10342
10343
10344
10345
10346
10347MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
10348MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
10349
10350static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
10351 u16 system_port, bool e,
10352 enum mlxsw_reg_mpat_span_type span_type)
10353{
10354 MLXSW_REG_ZERO(mpat, payload);
10355 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
10356 mlxsw_reg_mpat_system_port_set(payload, system_port);
10357 mlxsw_reg_mpat_e_set(payload, e);
10358 mlxsw_reg_mpat_qos_set(payload, 1);
10359 mlxsw_reg_mpat_be_set(payload, 1);
10360 mlxsw_reg_mpat_span_type_set(payload, span_type);
10361}
10362
10363static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
10364{
10365 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
10366}
10367
10368static inline void
10369mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
10370 enum mlxsw_reg_mpat_eth_rspan_version version,
10371 const char *mac,
10372 bool tp)
10373{
10374 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
10375 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
10376 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
10377}
10378
10379static inline void
10380mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
10381 const char *smac,
10382 u32 sip, u32 dip)
10383{
10384 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
10385 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
10386 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
10387 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
10388 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
10389 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
10390}
10391
10392static inline void
10393mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
10394 const char *smac,
10395 struct in6_addr sip, struct in6_addr dip)
10396{
10397 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
10398 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
10399 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
10400 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
10401 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
10402 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
10403}
10404
10405
10406
10407
10408
10409
10410#define MLXSW_REG_MPAR_ID 0x901B
10411#define MLXSW_REG_MPAR_LEN 0x0C
10412
10413MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
10414
10415
10416
10417
10418
10419MLXSW_ITEM32_LP(reg, mpar, 0x00, 16, 0x00, 4);
10420
10421enum mlxsw_reg_mpar_i_e {
10422 MLXSW_REG_MPAR_TYPE_EGRESS,
10423 MLXSW_REG_MPAR_TYPE_INGRESS,
10424};
10425
10426
10427
10428
10429
10430MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
10431
10432
10433
10434
10435
10436
10437MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
10438
10439
10440
10441
10442
10443MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
10444
10445#define MLXSW_REG_MPAR_RATE_MAX 3500000000UL
10446
10447
10448
10449
10450
10451
10452
10453
10454MLXSW_ITEM32(reg, mpar, probability_rate, 0x08, 0, 32);
10455
10456static inline void mlxsw_reg_mpar_pack(char *payload, u16 local_port,
10457 enum mlxsw_reg_mpar_i_e i_e,
10458 bool enable, u8 pa_id,
10459 u32 probability_rate)
10460{
10461 MLXSW_REG_ZERO(mpar, payload);
10462 mlxsw_reg_mpar_local_port_set(payload, local_port);
10463 mlxsw_reg_mpar_enable_set(payload, enable);
10464 mlxsw_reg_mpar_i_e_set(payload, i_e);
10465 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
10466 mlxsw_reg_mpar_probability_rate_set(payload, probability_rate);
10467}
10468
10469
10470
10471
10472
10473
10474#define MLXSW_REG_MGIR_ID 0x9020
10475#define MLXSW_REG_MGIR_LEN 0x9C
10476
10477MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
10478
10479
10480
10481
10482MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
10483
10484#define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
10485
10486
10487
10488
10489
10490MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
10491
10492
10493
10494
10495MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
10496
10497
10498
10499
10500MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
10501
10502
10503
10504
10505MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
10506
10507static inline void mlxsw_reg_mgir_pack(char *payload)
10508{
10509 MLXSW_REG_ZERO(mgir, payload);
10510}
10511
10512static inline void
10513mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
10514 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
10515{
10516 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
10517 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
10518 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
10519 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
10520 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
10521}
10522
10523
10524
10525
10526
10527
10528#define MLXSW_REG_MRSR_ID 0x9023
10529#define MLXSW_REG_MRSR_LEN 0x08
10530
10531MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
10532
10533
10534
10535
10536
10537
10538
10539MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
10540
10541static inline void mlxsw_reg_mrsr_pack(char *payload)
10542{
10543 MLXSW_REG_ZERO(mrsr, payload);
10544 mlxsw_reg_mrsr_command_set(payload, 1);
10545}
10546
10547
10548
10549
10550
10551#define MLXSW_REG_MLCR_ID 0x902B
10552#define MLXSW_REG_MLCR_LEN 0x0C
10553
10554MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
10555
10556
10557
10558
10559
10560MLXSW_ITEM32_LP(reg, mlcr, 0x00, 16, 0x00, 24);
10561
10562#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
10563
10564
10565
10566
10567
10568
10569
10570MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
10571
10572
10573
10574
10575
10576
10577MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
10578
10579static inline void mlxsw_reg_mlcr_pack(char *payload, u16 local_port,
10580 bool active)
10581{
10582 MLXSW_REG_ZERO(mlcr, payload);
10583 mlxsw_reg_mlcr_local_port_set(payload, local_port);
10584 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
10585 MLXSW_REG_MLCR_DURATION_MAX : 0);
10586}
10587
10588
10589
10590
10591
10592
10593#define MLXSW_REG_MCION_ID 0x9052
10594#define MLXSW_REG_MCION_LEN 0x18
10595
10596MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN);
10597
10598
10599
10600
10601
10602MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8);
10603
10604
10605
10606
10607
10608MLXSW_ITEM32(reg, mcion, slot_index, 0x00, 12, 4);
10609
10610enum {
10611 MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0),
10612 MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8),
10613};
10614
10615
10616
10617
10618
10619MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16);
10620
10621static inline void mlxsw_reg_mcion_pack(char *payload, u8 slot_index, u8 module)
10622{
10623 MLXSW_REG_ZERO(mcion, payload);
10624 mlxsw_reg_mcion_slot_index_set(payload, slot_index);
10625 mlxsw_reg_mcion_module_set(payload, module);
10626}
10627
10628
10629
10630
10631
10632
10633#define MLXSW_REG_MTPPS_ID 0x9053
10634#define MLXSW_REG_MTPPS_LEN 0x3C
10635
10636MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
10637
10638
10639
10640
10641
10642
10643MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
10644
10645enum mlxsw_reg_mtpps_pin_mode {
10646 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
10647};
10648
10649
10650
10651
10652
10653
10654MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
10655
10656#define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
10657
10658
10659
10660
10661
10662MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
10673
10674static inline void
10675mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
10676{
10677 MLXSW_REG_ZERO(mtpps, payload);
10678 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
10679 mlxsw_reg_mtpps_pin_mode_set(payload,
10680 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
10681 mlxsw_reg_mtpps_enable_set(payload, true);
10682 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
10683}
10684
10685
10686
10687
10688
10689#define MLXSW_REG_MTUTC_ID 0x9055
10690#define MLXSW_REG_MTUTC_LEN 0x1C
10691
10692MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
10693
10694enum mlxsw_reg_mtutc_operation {
10695 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
10696 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
10697};
10698
10699
10700
10701
10702
10703MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
10704
10705
10706
10707
10708
10709
10710
10711MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
10712
10713
10714
10715
10716
10717MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
10718
10719static inline void
10720mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
10721 u32 freq_adj, u32 utc_sec)
10722{
10723 MLXSW_REG_ZERO(mtutc, payload);
10724 mlxsw_reg_mtutc_operation_set(payload, oper);
10725 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
10726 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
10727}
10728
10729
10730
10731
10732
10733#define MLXSW_REG_MCQI_ID 0x9061
10734#define MLXSW_REG_MCQI_BASE_LEN 0x18
10735#define MLXSW_REG_MCQI_CAP_LEN 0x14
10736#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
10737
10738MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
10739
10740
10741
10742
10743
10744MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
10745
10746enum mlxfw_reg_mcqi_info_type {
10747 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
10748};
10749
10750
10751
10752
10753
10754MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
10755
10756
10757
10758
10759
10760
10761MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
10762
10763
10764
10765
10766
10767
10768MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
10769
10770
10771
10772
10773
10774MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
10775
10776
10777
10778
10779
10780
10781MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
10782
10783
10784
10785
10786
10787MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
10788
10789static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
10790{
10791 MLXSW_REG_ZERO(mcqi, payload);
10792 mlxsw_reg_mcqi_component_index_set(payload, component_index);
10793 mlxsw_reg_mcqi_info_type_set(payload,
10794 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
10795 mlxsw_reg_mcqi_offset_set(payload, 0);
10796 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
10797}
10798
10799static inline void mlxsw_reg_mcqi_unpack(char *payload,
10800 u32 *p_cap_max_component_size,
10801 u8 *p_cap_log_mcda_word_size,
10802 u16 *p_cap_mcda_max_write_size)
10803{
10804 *p_cap_max_component_size =
10805 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
10806 *p_cap_log_mcda_word_size =
10807 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
10808 *p_cap_mcda_max_write_size =
10809 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
10810}
10811
10812
10813
10814
10815
10816#define MLXSW_REG_MCC_ID 0x9062
10817#define MLXSW_REG_MCC_LEN 0x1C
10818
10819MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
10820
10821enum mlxsw_reg_mcc_instruction {
10822 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
10823 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
10824 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
10825 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
10826 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
10827 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
10828};
10829
10830
10831
10832
10833
10834
10835MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
10836
10837
10838
10839
10840
10841
10842MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
10843
10844
10845
10846
10847
10848MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
10849
10850
10851
10852
10853
10854
10855MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
10856
10857
10858
10859
10860
10861MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
10862
10863
10864
10865
10866
10867
10868
10869MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
10870
10871static inline void mlxsw_reg_mcc_pack(char *payload,
10872 enum mlxsw_reg_mcc_instruction instr,
10873 u16 component_index, u32 update_handle,
10874 u32 component_size)
10875{
10876 MLXSW_REG_ZERO(mcc, payload);
10877 mlxsw_reg_mcc_instruction_set(payload, instr);
10878 mlxsw_reg_mcc_component_index_set(payload, component_index);
10879 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
10880 mlxsw_reg_mcc_component_size_set(payload, component_size);
10881}
10882
10883static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
10884 u8 *p_error_code, u8 *p_control_state)
10885{
10886 if (p_update_handle)
10887 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
10888 if (p_error_code)
10889 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
10890 if (p_control_state)
10891 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
10892}
10893
10894
10895
10896
10897
10898#define MLXSW_REG_MCDA_ID 0x9063
10899#define MLXSW_REG_MCDA_BASE_LEN 0x10
10900#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
10901#define MLXSW_REG_MCDA_LEN \
10902 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
10903
10904MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
10905
10906
10907
10908
10909
10910MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
10911
10912
10913
10914
10915
10916
10917MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
10918
10919
10920
10921
10922
10923MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
10924
10925
10926
10927
10928
10929MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
10930
10931static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
10932 u32 offset, u16 size, u8 *data)
10933{
10934 int i;
10935
10936 MLXSW_REG_ZERO(mcda, payload);
10937 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
10938 mlxsw_reg_mcda_offset_set(payload, offset);
10939 mlxsw_reg_mcda_size_set(payload, size);
10940
10941 for (i = 0; i < size / 4; i++)
10942 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
10943}
10944
10945
10946
10947
10948
10949#define MLXSW_REG_MPSC_ID 0x9080
10950#define MLXSW_REG_MPSC_LEN 0x1C
10951
10952MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
10953
10954
10955
10956
10957
10958
10959MLXSW_ITEM32_LP(reg, mpsc, 0x00, 16, 0x00, 12);
10960
10961
10962
10963
10964
10965MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
10966
10967#define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
10968
10969
10970
10971
10972
10973
10974MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
10975
10976static inline void mlxsw_reg_mpsc_pack(char *payload, u16 local_port, bool e,
10977 u32 rate)
10978{
10979 MLXSW_REG_ZERO(mpsc, payload);
10980 mlxsw_reg_mpsc_local_port_set(payload, local_port);
10981 mlxsw_reg_mpsc_e_set(payload, e);
10982 mlxsw_reg_mpsc_rate_set(payload, rate);
10983}
10984
10985
10986
10987
10988#define MLXSW_REG_MGPC_ID 0x9081
10989#define MLXSW_REG_MGPC_LEN 0x18
10990
10991MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
10992
10993
10994
10995
10996
10997MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
10998
10999
11000
11001
11002
11003MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
11004
11005enum mlxsw_reg_mgpc_opcode {
11006
11007 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
11008
11009 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
11010};
11011
11012
11013
11014
11015
11016MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
11017
11018
11019
11020
11021
11022MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
11023
11024
11025
11026
11027
11028MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
11029
11030static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
11031 enum mlxsw_reg_mgpc_opcode opcode,
11032 enum mlxsw_reg_flow_counter_set_type set_type)
11033{
11034 MLXSW_REG_ZERO(mgpc, payload);
11035 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
11036 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
11037 mlxsw_reg_mgpc_opcode_set(payload, opcode);
11038}
11039
11040
11041
11042
11043
11044
11045#define MLXSW_REG_MPRS_ID 0x9083
11046#define MLXSW_REG_MPRS_LEN 0x14
11047
11048MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
11049
11050
11051
11052
11053
11054
11055
11056MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
11057
11058
11059
11060
11061
11062
11063
11064MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
11065
11066
11067
11068
11069
11070
11071
11072MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
11073
11074static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
11075 u16 vxlan_udp_dport)
11076{
11077 MLXSW_REG_ZERO(mprs, payload);
11078 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
11079 mlxsw_reg_mprs_parsing_en_set(payload, true);
11080 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
11081}
11082
11083
11084
11085
11086#define MLXSW_REG_MOGCR_ID 0x9086
11087#define MLXSW_REG_MOGCR_LEN 0x20
11088
11089MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
11090
11091
11092
11093
11094
11095
11096
11097
11098MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
11099
11100
11101
11102
11103
11104
11105
11106
11107MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
11108
11109
11110
11111
11112
11113
11114
11115MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14);
11116
11117
11118
11119
11120
11121
11122#define MLXSW_REG_MPAGR_ID 0x9089
11123#define MLXSW_REG_MPAGR_LEN 0x0C
11124
11125MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN);
11126
11127enum mlxsw_reg_mpagr_trigger {
11128 MLXSW_REG_MPAGR_TRIGGER_EGRESS,
11129 MLXSW_REG_MPAGR_TRIGGER_INGRESS,
11130 MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED,
11131 MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER,
11132 MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG,
11133 MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG,
11134 MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN,
11135 MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY,
11136};
11137
11138
11139
11140
11141
11142MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4);
11143
11144
11145
11146
11147
11148MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4);
11149
11150#define MLXSW_REG_MPAGR_RATE_MAX 3500000000UL
11151
11152
11153
11154
11155
11156
11157
11158MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32);
11159
11160static inline void mlxsw_reg_mpagr_pack(char *payload,
11161 enum mlxsw_reg_mpagr_trigger trigger,
11162 u8 pa_id, u32 probability_rate)
11163{
11164 MLXSW_REG_ZERO(mpagr, payload);
11165 mlxsw_reg_mpagr_trigger_set(payload, trigger);
11166 mlxsw_reg_mpagr_pa_id_set(payload, pa_id);
11167 mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate);
11168}
11169
11170
11171
11172
11173
11174
11175#define MLXSW_REG_MOMTE_ID 0x908D
11176#define MLXSW_REG_MOMTE_LEN 0x10
11177
11178MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN);
11179
11180
11181
11182
11183
11184MLXSW_ITEM32_LP(reg, momte, 0x00, 16, 0x00, 12);
11185
11186enum mlxsw_reg_momte_type {
11187 MLXSW_REG_MOMTE_TYPE_WRED = 0x20,
11188 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31,
11189 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32,
11190 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33,
11191 MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40,
11192 MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50,
11193 MLXSW_REG_MOMTE_TYPE_ECN = 0x60,
11194 MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70,
11195};
11196
11197
11198
11199
11200
11201MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
11202
11203
11204
11205
11206
11207
11208
11209MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
11210
11211static inline void mlxsw_reg_momte_pack(char *payload, u16 local_port,
11212 enum mlxsw_reg_momte_type type)
11213{
11214 MLXSW_REG_ZERO(momte, payload);
11215 mlxsw_reg_momte_local_port_set(payload, local_port);
11216 mlxsw_reg_momte_type_set(payload, type);
11217}
11218
11219
11220
11221
11222
11223
11224
11225
11226#define MLXSW_REG_MTPPPC_ID 0x9090
11227#define MLXSW_REG_MTPPPC_LEN 0x28
11228
11229MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
11230
11231
11232
11233
11234
11235
11236
11237
11238MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
11239
11240
11241
11242
11243
11244
11245
11246
11247MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
11248
11249static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
11250{
11251 MLXSW_REG_ZERO(mtpppc, payload);
11252 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
11253 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
11254}
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266#define MLXSW_REG_MTPPTR_ID 0x9091
11267#define MLXSW_REG_MTPPTR_BASE_LEN 0x10
11268#define MLXSW_REG_MTPPTR_REC_LEN 0x10
11269#define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
11270#define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
11271 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
11272
11273MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
11274
11275
11276
11277
11278
11279MLXSW_ITEM32_LP(reg, mtpptr, 0x00, 16, 0x00, 12);
11280
11281enum mlxsw_reg_mtpptr_dir {
11282 MLXSW_REG_MTPPTR_DIR_INGRESS,
11283 MLXSW_REG_MTPPTR_DIR_EGRESS,
11284};
11285
11286
11287
11288
11289
11290MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
11291
11292
11293
11294
11295
11296MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
11297
11298
11299
11300
11301
11302
11303MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
11304
11305
11306
11307
11308
11309
11310MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
11311 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
11312 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
11313
11314
11315
11316
11317
11318MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
11319 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
11320 MLXSW_REG_MTPPTR_REC_LEN, 0, false);
11321
11322
11323
11324
11325
11326MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
11327 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
11328 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
11329
11330
11331
11332
11333
11334
11335
11336MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
11337 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
11338 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
11339
11340
11341
11342
11343
11344MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
11345 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
11346 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
11347
11348static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
11349 unsigned int rec,
11350 u8 *p_message_type,
11351 u8 *p_domain_number,
11352 u16 *p_sequence_id,
11353 u64 *p_timestamp)
11354{
11355 u32 timestamp_high, timestamp_low;
11356
11357 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
11358 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
11359 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
11360 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
11361 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
11362 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
11363}
11364
11365
11366
11367
11368
11369
11370#define MLXSW_REG_MTPTPT_ID 0x9092
11371#define MLXSW_REG_MTPTPT_LEN 0x08
11372
11373MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
11374
11375enum mlxsw_reg_mtptpt_trap_id {
11376 MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
11377 MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
11378};
11379
11380
11381
11382
11383
11384MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
11385
11386
11387
11388
11389
11390
11391
11392MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
11393
11394static inline void mlxsw_reg_mtptptp_pack(char *payload,
11395 enum mlxsw_reg_mtptpt_trap_id trap_id,
11396 u16 message_type)
11397{
11398 MLXSW_REG_ZERO(mtptpt, payload);
11399 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
11400 mlxsw_reg_mtptpt_message_type_set(payload, message_type);
11401}
11402
11403
11404
11405
11406#define MLXSW_REG_MFGD_ID 0x90F0
11407#define MLXSW_REG_MFGD_LEN 0x0C
11408
11409MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN);
11410
11411
11412
11413
11414
11415
11416MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2);
11417
11418
11419
11420
11421MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1);
11422
11423
11424
11425
11426
11427
11428#define MLXSW_REG_MGPIR_ID 0x9100
11429#define MLXSW_REG_MGPIR_LEN 0xA0
11430
11431MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
11432
11433enum mlxsw_reg_mgpir_device_type {
11434 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
11435 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
11436};
11437
11438
11439
11440
11441
11442MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
11443
11444
11445
11446
11447MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
11448
11449
11450
11451
11452
11453MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
11454
11455
11456
11457
11458
11459MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
11460
11461
11462
11463
11464
11465MLXSW_ITEM32(reg, mgpir, max_modules_per_slot, 0x04, 16, 8);
11466
11467
11468
11469
11470
11471MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
11472
11473
11474
11475
11476
11477MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
11478
11479static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
11480{
11481 MLXSW_REG_ZERO(mgpir, payload);
11482 mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
11483}
11484
11485static inline void
11486mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
11487 enum mlxsw_reg_mgpir_device_type *device_type,
11488 u8 *devices_per_flash, u8 *num_of_modules,
11489 u8 *num_of_slots)
11490{
11491 if (num_of_devices)
11492 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
11493 if (device_type)
11494 *device_type = mlxsw_reg_mgpir_device_type_get(payload);
11495 if (devices_per_flash)
11496 *devices_per_flash =
11497 mlxsw_reg_mgpir_devices_per_flash_get(payload);
11498 if (num_of_modules)
11499 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
11500 if (num_of_slots)
11501 *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
11502}
11503
11504
11505
11506
11507
11508
11509#define MLXSW_REG_MBCT_ID 0x9120
11510#define MLXSW_REG_MBCT_LEN 0x420
11511
11512MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN);
11513
11514
11515
11516
11517
11518MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4);
11519
11520
11521
11522
11523
11524MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11);
11525
11526enum mlxsw_reg_mbct_op {
11527 MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1,
11528 MLXSW_REG_MBCT_OP_DATA_TRANSFER,
11529 MLXSW_REG_MBCT_OP_ACTIVATE,
11530 MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6,
11531 MLXSW_REG_MBCT_OP_QUERY_STATUS,
11532};
11533
11534
11535
11536
11537MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4);
11538
11539
11540
11541
11542
11543MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1);
11544
11545
11546
11547
11548
11549
11550MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1);
11551
11552enum mlxsw_reg_mbct_status {
11553
11554
11555
11556 MLXSW_REG_MBCT_STATUS_PART_DATA = 2,
11557 MLXSW_REG_MBCT_STATUS_LAST_DATA,
11558 MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE,
11559
11560 MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE,
11561
11562 MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7,
11563 MLXSW_REG_MBCT_STATUS_INI_ERROR,
11564 MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED,
11565 MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11,
11566};
11567
11568
11569
11570
11571
11572MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5);
11573
11574enum mlxsw_reg_mbct_fsm_state {
11575 MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5,
11576 MLXSW_REG_MBCT_FSM_STATE_ERROR,
11577};
11578
11579
11580
11581
11582
11583MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4);
11584
11585#define MLXSW_REG_MBCT_DATA_LEN 1024
11586
11587
11588
11589
11590
11591MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN);
11592
11593static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index,
11594 enum mlxsw_reg_mbct_op op, bool oee)
11595{
11596 MLXSW_REG_ZERO(mbct, payload);
11597 mlxsw_reg_mbct_slot_index_set(payload, slot_index);
11598 mlxsw_reg_mbct_op_set(payload, op);
11599 mlxsw_reg_mbct_oee_set(payload, oee);
11600}
11601
11602static inline void mlxsw_reg_mbct_dt_pack(char *payload,
11603 u16 data_size, bool last,
11604 const char *data)
11605{
11606 if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN))
11607 return;
11608 mlxsw_reg_mbct_data_size_set(payload, data_size);
11609 mlxsw_reg_mbct_last_set(payload, last);
11610 mlxsw_reg_mbct_data_memcpy_to(payload, data);
11611}
11612
11613static inline void
11614mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
11615 enum mlxsw_reg_mbct_status *p_status,
11616 enum mlxsw_reg_mbct_fsm_state *p_fsm_state)
11617{
11618 if (p_slot_index)
11619 *p_slot_index = mlxsw_reg_mbct_slot_index_get(payload);
11620 *p_status = mlxsw_reg_mbct_status_get(payload);
11621 if (p_fsm_state)
11622 *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
11623}
11624
11625
11626
11627
11628
11629
11630
11631#define MLXSW_REG_MDDQ_ID 0x9161
11632#define MLXSW_REG_MDDQ_LEN 0x30
11633
11634MLXSW_REG_DEFINE(mddq, MLXSW_REG_MDDQ_ID, MLXSW_REG_MDDQ_LEN);
11635
11636
11637
11638
11639
11640
11641
11642MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1);
11643
11644enum mlxsw_reg_mddq_query_type {
11645 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1,
11646 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME = 3,
11647};
11648
11649
11650
11651
11652MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8);
11653
11654
11655
11656
11657
11658MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4);
11659
11660
11661
11662
11663
11664MLXSW_ITEM32(reg, mddq, slot_info_provisioned, 0x10, 31, 1);
11665
11666
11667
11668
11669
11670
11671MLXSW_ITEM32(reg, mddq, slot_info_sr_valid, 0x10, 30, 1);
11672
11673enum mlxsw_reg_mddq_slot_info_ready {
11674 MLXSW_REG_MDDQ_SLOT_INFO_READY_NOT_READY,
11675 MLXSW_REG_MDDQ_SLOT_INFO_READY_READY,
11676 MLXSW_REG_MDDQ_SLOT_INFO_READY_ERROR,
11677};
11678
11679
11680
11681
11682
11683
11684MLXSW_ITEM32(reg, mddq, slot_info_lc_ready, 0x10, 28, 2);
11685
11686
11687
11688
11689
11690MLXSW_ITEM32(reg, mddq, slot_info_active, 0x10, 27, 1);
11691
11692
11693
11694
11695
11696
11697MLXSW_ITEM32(reg, mddq, slot_info_hw_revision, 0x14, 16, 16);
11698
11699
11700
11701
11702
11703
11704MLXSW_ITEM32(reg, mddq, slot_info_ini_file_version, 0x14, 0, 16);
11705
11706
11707
11708
11709MLXSW_ITEM32(reg, mddq, slot_info_card_type, 0x18, 0, 8);
11710
11711static inline void
11712__mlxsw_reg_mddq_pack(char *payload, u8 slot_index,
11713 enum mlxsw_reg_mddq_query_type query_type)
11714{
11715 MLXSW_REG_ZERO(mddq, payload);
11716 mlxsw_reg_mddq_slot_index_set(payload, slot_index);
11717 mlxsw_reg_mddq_query_type_set(payload, query_type);
11718}
11719
11720static inline void
11721mlxsw_reg_mddq_slot_info_pack(char *payload, u8 slot_index, bool sie)
11722{
11723 __mlxsw_reg_mddq_pack(payload, slot_index,
11724 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO);
11725 mlxsw_reg_mddq_sie_set(payload, sie);
11726}
11727
11728static inline void
11729mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index,
11730 bool *p_provisioned, bool *p_sr_valid,
11731 enum mlxsw_reg_mddq_slot_info_ready *p_lc_ready,
11732 bool *p_active, u16 *p_hw_revision,
11733 u16 *p_ini_file_version,
11734 u8 *p_card_type)
11735{
11736 *p_slot_index = mlxsw_reg_mddq_slot_index_get(payload);
11737 *p_provisioned = mlxsw_reg_mddq_slot_info_provisioned_get(payload);
11738 *p_sr_valid = mlxsw_reg_mddq_slot_info_sr_valid_get(payload);
11739 *p_lc_ready = mlxsw_reg_mddq_slot_info_lc_ready_get(payload);
11740 *p_active = mlxsw_reg_mddq_slot_info_active_get(payload);
11741 *p_hw_revision = mlxsw_reg_mddq_slot_info_hw_revision_get(payload);
11742 *p_ini_file_version = mlxsw_reg_mddq_slot_info_ini_file_version_get(payload);
11743 *p_card_type = mlxsw_reg_mddq_slot_info_card_type_get(payload);
11744}
11745
11746#define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20
11747
11748
11749
11750
11751
11752MLXSW_ITEM_BUF(reg, mddq, slot_ascii_name, 0x10,
11753 MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN);
11754
11755static inline void
11756mlxsw_reg_mddq_slot_name_pack(char *payload, u8 slot_index)
11757{
11758 __mlxsw_reg_mddq_pack(payload, slot_index,
11759 MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME);
11760}
11761
11762static inline void
11763mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name)
11764{
11765 mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name);
11766}
11767
11768
11769
11770
11771
11772#define MLXSW_REG_MDDC_ID 0x9163
11773#define MLXSW_REG_MDDC_LEN 0x30
11774
11775MLXSW_REG_DEFINE(mddc, MLXSW_REG_MDDC_ID, MLXSW_REG_MDDC_LEN);
11776
11777
11778
11779
11780
11781MLXSW_ITEM32(reg, mddc, slot_index, 0x00, 0, 4);
11782
11783
11784
11785
11786
11787MLXSW_ITEM32(reg, mddc, rst, 0x04, 29, 1);
11788
11789
11790
11791
11792
11793MLXSW_ITEM32(reg, mddc, device_enable, 0x04, 28, 1);
11794
11795static inline void mlxsw_reg_mddc_pack(char *payload, u8 slot_index, bool rst,
11796 bool device_enable)
11797{
11798 MLXSW_REG_ZERO(mddc, payload);
11799 mlxsw_reg_mddc_slot_index_set(payload, slot_index);
11800 mlxsw_reg_mddc_rst_set(payload, rst);
11801 mlxsw_reg_mddc_device_enable_set(payload, device_enable);
11802}
11803
11804
11805
11806
11807#define MLXSW_REG_MFDE_ID 0x9200
11808#define MLXSW_REG_MFDE_LEN 0x30
11809
11810MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN);
11811
11812
11813
11814
11815
11816MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 24, 8);
11817
11818enum mlxsw_reg_mfde_severity {
11819
11820 MLXSW_REG_MFDE_SEVERITY_FATL = 2,
11821
11822 MLXSW_REG_MFDE_SEVERITY_NRML = 3,
11823
11824 MLXSW_REG_MFDE_SEVERITY_INTR = 5,
11825};
11826
11827
11828
11829
11830
11831MLXSW_ITEM32(reg, mfde, severity, 0x00, 16, 8);
11832
11833enum mlxsw_reg_mfde_event_id {
11834
11835 MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1,
11836
11837 MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP,
11838
11839 MLXSW_REG_MFDE_EVENT_ID_TEST,
11840
11841 MLXSW_REG_MFDE_EVENT_ID_FW_ASSERT,
11842
11843 MLXSW_REG_MFDE_EVENT_ID_FATAL_CAUSE,
11844};
11845
11846
11847
11848
11849MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 16);
11850
11851enum mlxsw_reg_mfde_method {
11852 MLXSW_REG_MFDE_METHOD_QUERY,
11853 MLXSW_REG_MFDE_METHOD_WRITE,
11854};
11855
11856
11857
11858
11859MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1);
11860
11861
11862
11863
11864
11865MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1);
11866
11867enum mlxsw_reg_mfde_command_type {
11868 MLXSW_REG_MFDE_COMMAND_TYPE_MAD,
11869 MLXSW_REG_MFDE_COMMAND_TYPE_EMAD,
11870 MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF,
11871};
11872
11873
11874
11875
11876MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2);
11877
11878
11879
11880
11881
11882MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16);
11883
11884
11885
11886
11887
11888MLXSW_ITEM32(reg, mfde, crspace_to_log_address, 0x10, 0, 32);
11889
11890
11891
11892
11893
11894
11895MLXSW_ITEM32(reg, mfde, crspace_to_oe, 0x14, 24, 1);
11896
11897
11898
11899
11900
11901MLXSW_ITEM32(reg, mfde, crspace_to_log_id, 0x14, 0, 4);
11902
11903
11904
11905
11906
11907MLXSW_ITEM64(reg, mfde, crspace_to_log_ip, 0x18, 0, 64);
11908
11909
11910
11911
11912
11913
11914MLXSW_ITEM32(reg, mfde, kvd_im_stop_oe, 0x10, 24, 1);
11915
11916
11917
11918
11919
11920MLXSW_ITEM32(reg, mfde, kvd_im_stop_pipes_mask, 0x10, 0, 16);
11921
11922
11923
11924
11925
11926MLXSW_ITEM32(reg, mfde, fw_assert_var0, 0x10, 0, 32);
11927MLXSW_ITEM32(reg, mfde, fw_assert_var1, 0x14, 0, 32);
11928MLXSW_ITEM32(reg, mfde, fw_assert_var2, 0x18, 0, 32);
11929MLXSW_ITEM32(reg, mfde, fw_assert_var3, 0x1C, 0, 32);
11930MLXSW_ITEM32(reg, mfde, fw_assert_var4, 0x20, 0, 32);
11931
11932
11933
11934
11935
11936MLXSW_ITEM32(reg, mfde, fw_assert_existptr, 0x24, 0, 32);
11937
11938
11939
11940
11941
11942MLXSW_ITEM32(reg, mfde, fw_assert_callra, 0x28, 0, 32);
11943
11944
11945
11946
11947
11948
11949MLXSW_ITEM32(reg, mfde, fw_assert_oe, 0x2C, 24, 1);
11950
11951
11952
11953
11954
11955
11956MLXSW_ITEM32(reg, mfde, fw_assert_tile_v, 0x2C, 23, 1);
11957
11958
11959
11960
11961
11962MLXSW_ITEM32(reg, mfde, fw_assert_tile_index, 0x2C, 16, 6);
11963
11964
11965
11966
11967
11968MLXSW_ITEM32(reg, mfde, fw_assert_ext_synd, 0x2C, 0, 16);
11969
11970
11971
11972
11973
11974MLXSW_ITEM32(reg, mfde, fatal_cause_id, 0x10, 0, 18);
11975
11976
11977
11978
11979
11980
11981MLXSW_ITEM32(reg, mfde, fatal_cause_tile_v, 0x14, 23, 1);
11982
11983
11984
11985
11986
11987MLXSW_ITEM32(reg, mfde, fatal_cause_tile_index, 0x14, 16, 6);
11988
11989
11990
11991
11992
11993#define MLXSW_REG_TNGCR_ID 0xA001
11994#define MLXSW_REG_TNGCR_LEN 0x44
11995
11996MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
11997
11998enum mlxsw_reg_tngcr_type {
11999 MLXSW_REG_TNGCR_TYPE_VXLAN,
12000 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
12001 MLXSW_REG_TNGCR_TYPE_GENEVE,
12002 MLXSW_REG_TNGCR_TYPE_NVGRE,
12003};
12004
12005
12006
12007
12008
12009
12010
12011MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
12012
12013
12014
12015
12016
12017MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
12018
12019
12020
12021
12022
12023MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
12024
12025
12026
12027
12028
12029MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
12030
12031enum {
12032
12033 MLXSW_REG_TNGCR_FL_NO_COPY,
12034
12035
12036
12037
12038 MLXSW_REG_TNGCR_FL_COPY,
12039};
12040
12041
12042
12043
12044
12045MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
12046
12047enum {
12048
12049
12050
12051 MLXSW_REG_TNGCR_FL_NO_HASH,
12052
12053
12054
12055 MLXSW_REG_TNGCR_FL_HASH,
12056};
12057
12058
12059
12060
12061
12062MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
12063
12064
12065
12066
12067
12068MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
12069
12070
12071
12072
12073
12074
12075MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
12076
12077enum {
12078
12079 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
12080
12081 MLXSW_REG_TNGCR_UDP_SPORT_HASH,
12082};
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
12093
12094
12095
12096
12097
12098
12099MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
12120
12121
12122
12123
12124
12125
12126MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
12127
12128
12129
12130
12131
12132
12133MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
12134
12135
12136
12137
12138
12139
12140MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
12141
12142
12143
12144
12145
12146MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
12147
12148
12149
12150
12151
12152
12153MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
12154
12155static inline void mlxsw_reg_tngcr_pack(char *payload,
12156 enum mlxsw_reg_tngcr_type type,
12157 bool valid, u8 ttl)
12158{
12159 MLXSW_REG_ZERO(tngcr, payload);
12160 mlxsw_reg_tngcr_type_set(payload, type);
12161 mlxsw_reg_tngcr_nve_valid_set(payload, valid);
12162 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
12163 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
12164 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
12165 mlxsw_reg_tngcr_nve_flh_set(payload, 0);
12166 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
12167 MLXSW_REG_TNGCR_UDP_SPORT_HASH);
12168 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
12169 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
12170 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
12171}
12172
12173
12174
12175
12176
12177
12178#define MLXSW_REG_TNUMT_ID 0xA003
12179#define MLXSW_REG_TNUMT_LEN 0x20
12180
12181MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
12182
12183enum mlxsw_reg_tnumt_record_type {
12184 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
12185 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
12186 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
12187};
12188
12189
12190
12191
12192
12193MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
12194
12195
12196
12197
12198
12199MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
12200
12201
12202
12203
12204
12205
12206MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
12207
12208
12209
12210
12211
12212MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
12213
12214
12215
12216
12217
12218MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
12219
12220
12221
12222
12223
12224
12225MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
12226
12227
12228
12229
12230
12231MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
12232
12233
12234
12235
12236
12237
12238MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
12239
12240static inline void mlxsw_reg_tnumt_pack(char *payload,
12241 enum mlxsw_reg_tnumt_record_type type,
12242 enum mlxsw_reg_tunnel_port tport,
12243 u32 underlay_mc_ptr, bool vnext,
12244 u32 next_underlay_mc_ptr,
12245 u8 record_size)
12246{
12247 MLXSW_REG_ZERO(tnumt, payload);
12248 mlxsw_reg_tnumt_record_type_set(payload, type);
12249 mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
12250 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
12251 mlxsw_reg_tnumt_vnext_set(payload, vnext);
12252 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
12253 mlxsw_reg_tnumt_record_size_set(payload, record_size);
12254}
12255
12256
12257
12258
12259
12260
12261#define MLXSW_REG_TNQCR_ID 0xA010
12262#define MLXSW_REG_TNQCR_LEN 0x0C
12263
12264MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
12265
12266
12267
12268
12269
12270
12271
12272
12273MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
12274
12275static inline void mlxsw_reg_tnqcr_pack(char *payload)
12276{
12277 MLXSW_REG_ZERO(tnqcr, payload);
12278 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
12279}
12280
12281
12282
12283
12284
12285
12286#define MLXSW_REG_TNQDR_ID 0xA011
12287#define MLXSW_REG_TNQDR_LEN 0x08
12288
12289MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
12290
12291
12292
12293
12294
12295MLXSW_ITEM32_LP(reg, tnqdr, 0x00, 16, 0x00, 12);
12296
12297
12298
12299
12300
12301MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
12302
12303static inline void mlxsw_reg_tnqdr_pack(char *payload, u16 local_port)
12304{
12305 MLXSW_REG_ZERO(tnqdr, payload);
12306 mlxsw_reg_tnqdr_local_port_set(payload, local_port);
12307 mlxsw_reg_tnqdr_dscp_set(payload, 0);
12308}
12309
12310
12311
12312
12313
12314
12315#define MLXSW_REG_TNEEM_ID 0xA012
12316#define MLXSW_REG_TNEEM_LEN 0x0C
12317
12318MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
12319
12320
12321
12322
12323
12324MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
12325
12326
12327
12328
12329
12330MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
12331
12332static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
12333 u8 underlay_ecn)
12334{
12335 MLXSW_REG_ZERO(tneem, payload);
12336 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
12337 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
12338}
12339
12340
12341
12342
12343
12344
12345#define MLXSW_REG_TNDEM_ID 0xA013
12346#define MLXSW_REG_TNDEM_LEN 0x0C
12347
12348MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
12349
12350
12351
12352
12353
12354MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
12355
12356
12357
12358
12359
12360MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
12361
12362
12363
12364
12365
12366
12367MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
12368
12369
12370
12371
12372
12373
12374
12375MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
12376
12377
12378
12379
12380
12381
12382MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
12383
12384static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
12385 u8 overlay_ecn, u8 ecn, bool trap_en,
12386 u16 trap_id)
12387{
12388 MLXSW_REG_ZERO(tndem, payload);
12389 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
12390 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
12391 mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
12392 mlxsw_reg_tndem_trap_en_set(payload, trap_en);
12393 mlxsw_reg_tndem_trap_id_set(payload, trap_id);
12394}
12395
12396
12397
12398
12399
12400
12401#define MLXSW_REG_TNPC_ID 0xA020
12402#define MLXSW_REG_TNPC_LEN 0x18
12403
12404MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
12405
12406
12407
12408
12409
12410MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
12411
12412
12413
12414
12415
12416MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
12417
12418
12419
12420
12421
12422MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
12423
12424static inline void mlxsw_reg_tnpc_pack(char *payload,
12425 enum mlxsw_reg_tunnel_port tport,
12426 bool learn_enable)
12427{
12428 MLXSW_REG_ZERO(tnpc, payload);
12429 mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
12430 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
12431 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
12432}
12433
12434
12435
12436
12437
12438#define MLXSW_REG_TIGCR_ID 0xA801
12439#define MLXSW_REG_TIGCR_LEN 0x10
12440
12441MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
12442
12443
12444
12445
12446
12447
12448MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
12449
12450
12451
12452
12453
12454
12455MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
12456
12457static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
12458{
12459 MLXSW_REG_ZERO(tigcr, payload);
12460 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
12461 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
12462}
12463
12464
12465
12466
12467
12468
12469#define MLXSW_REG_TIEEM_ID 0xA812
12470#define MLXSW_REG_TIEEM_LEN 0x0C
12471
12472MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
12473
12474
12475
12476
12477
12478MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
12479
12480
12481
12482
12483
12484MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
12485
12486static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
12487 u8 underlay_ecn)
12488{
12489 MLXSW_REG_ZERO(tieem, payload);
12490 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
12491 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
12492}
12493
12494
12495
12496
12497
12498
12499#define MLXSW_REG_TIDEM_ID 0xA813
12500#define MLXSW_REG_TIDEM_LEN 0x0C
12501
12502MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN);
12503
12504
12505
12506
12507
12508MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2);
12509
12510
12511
12512
12513
12514MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2);
12515
12516
12517
12518
12519
12520
12521MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2);
12522
12523
12524
12525
12526
12527
12528
12529MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4);
12530
12531
12532
12533
12534
12535
12536MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9);
12537
12538static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn,
12539 u8 overlay_ecn, u8 eip_ecn,
12540 bool trap_en, u16 trap_id)
12541{
12542 MLXSW_REG_ZERO(tidem, payload);
12543 mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn);
12544 mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn);
12545 mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn);
12546 mlxsw_reg_tidem_trap_en_set(payload, trap_en);
12547 mlxsw_reg_tidem_trap_id_set(payload, trap_id);
12548}
12549
12550
12551
12552
12553
12554#define MLXSW_REG_SBPR_ID 0xB001
12555#define MLXSW_REG_SBPR_LEN 0x14
12556
12557MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
12558
12559
12560
12561
12562
12563MLXSW_ITEM32(reg, sbpr, desc, 0x00, 31, 1);
12564
12565
12566enum mlxsw_reg_sbxx_dir {
12567 MLXSW_REG_SBXX_DIR_INGRESS,
12568 MLXSW_REG_SBXX_DIR_EGRESS,
12569};
12570
12571
12572
12573
12574
12575MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
12576
12577
12578
12579
12580
12581MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
12582
12583
12584
12585
12586
12587MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
12588
12589
12590
12591
12592
12593
12594MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
12595
12596enum mlxsw_reg_sbpr_mode {
12597 MLXSW_REG_SBPR_MODE_STATIC,
12598 MLXSW_REG_SBPR_MODE_DYNAMIC,
12599};
12600
12601
12602
12603
12604
12605MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
12606
12607static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
12608 enum mlxsw_reg_sbxx_dir dir,
12609 enum mlxsw_reg_sbpr_mode mode, u32 size,
12610 bool infi_size)
12611{
12612 MLXSW_REG_ZERO(sbpr, payload);
12613 mlxsw_reg_sbpr_pool_set(payload, pool);
12614 mlxsw_reg_sbpr_dir_set(payload, dir);
12615 mlxsw_reg_sbpr_mode_set(payload, mode);
12616 mlxsw_reg_sbpr_size_set(payload, size);
12617 mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
12618}
12619
12620
12621
12622
12623
12624
12625
12626#define MLXSW_REG_SBCM_ID 0xB002
12627#define MLXSW_REG_SBCM_LEN 0x28
12628
12629MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
12630
12631
12632
12633
12634
12635
12636
12637MLXSW_ITEM32_LP(reg, sbcm, 0x00, 16, 0x00, 4);
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
12648
12649
12650
12651
12652
12653MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
12654
12655
12656
12657
12658
12659MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
12660
12661
12662#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
12663#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
12664
12665
12666
12667
12668
12669MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
12684
12685
12686
12687
12688
12689MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
12690
12691static inline void mlxsw_reg_sbcm_pack(char *payload, u16 local_port, u8 pg_buff,
12692 enum mlxsw_reg_sbxx_dir dir,
12693 u32 min_buff, u32 max_buff,
12694 bool infi_max, u8 pool)
12695{
12696 MLXSW_REG_ZERO(sbcm, payload);
12697 mlxsw_reg_sbcm_local_port_set(payload, local_port);
12698 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
12699 mlxsw_reg_sbcm_dir_set(payload, dir);
12700 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
12701 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
12702 mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
12703 mlxsw_reg_sbcm_pool_set(payload, pool);
12704}
12705
12706
12707
12708
12709
12710
12711
12712#define MLXSW_REG_SBPM_ID 0xB003
12713#define MLXSW_REG_SBPM_LEN 0x28
12714
12715MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
12716
12717
12718
12719
12720
12721
12722
12723MLXSW_ITEM32_LP(reg, sbpm, 0x00, 16, 0x00, 12);
12724
12725
12726
12727
12728
12729MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
12730
12731
12732
12733
12734
12735MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
12736
12737
12738
12739
12740
12741MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
12742
12743
12744
12745
12746
12747
12748
12749MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
12750
12751
12752
12753
12754
12755
12756MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
12757
12758
12759
12760
12761
12762MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
12776
12777static inline void mlxsw_reg_sbpm_pack(char *payload, u16 local_port, u8 pool,
12778 enum mlxsw_reg_sbxx_dir dir, bool clr,
12779 u32 min_buff, u32 max_buff)
12780{
12781 MLXSW_REG_ZERO(sbpm, payload);
12782 mlxsw_reg_sbpm_local_port_set(payload, local_port);
12783 mlxsw_reg_sbpm_pool_set(payload, pool);
12784 mlxsw_reg_sbpm_dir_set(payload, dir);
12785 mlxsw_reg_sbpm_clr_set(payload, clr);
12786 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
12787 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
12788}
12789
12790static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
12791 u32 *p_max_buff_occupancy)
12792{
12793 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
12794 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
12795}
12796
12797
12798
12799
12800
12801
12802
12803#define MLXSW_REG_SBMM_ID 0xB004
12804#define MLXSW_REG_SBMM_LEN 0x28
12805
12806MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
12807
12808
12809
12810
12811
12812MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
12813
12814
12815
12816
12817
12818MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
12832
12833
12834
12835
12836
12837MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
12838
12839static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
12840 u32 max_buff, u8 pool)
12841{
12842 MLXSW_REG_ZERO(sbmm, payload);
12843 mlxsw_reg_sbmm_prio_set(payload, prio);
12844 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
12845 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
12846 mlxsw_reg_sbmm_pool_set(payload, pool);
12847}
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857#define MLXSW_REG_SBSR_ID 0xB005
12858#define MLXSW_REG_SBSR_BASE_LEN 0x5C
12859#define MLXSW_REG_SBSR_REC_LEN 0x8
12860#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
12861#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
12862 MLXSW_REG_SBSR_REC_LEN * \
12863 MLXSW_REG_SBSR_REC_MAX_COUNT)
12864
12865MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
12866
12867
12868
12869
12870
12871
12872
12873MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
12874
12875#define MLXSW_REG_SBSR_NUM_PORTS_IN_PAGE 256
12876
12877
12878
12879
12880
12881
12882
12883MLXSW_ITEM32(reg, sbsr, port_page, 0x04, 0, 4);
12884
12885
12886
12887
12888
12889
12890
12891
12892MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
12903
12904
12905
12906
12907
12908
12909
12910
12911MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
12922
12923static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
12924{
12925 MLXSW_REG_ZERO(sbsr, payload);
12926 mlxsw_reg_sbsr_clr_set(payload, clr);
12927}
12928
12929
12930
12931
12932
12933MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
12934 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
12935
12936
12937
12938
12939
12940
12941MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
12942 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
12943
12944static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
12945 u32 *p_buff_occupancy,
12946 u32 *p_max_buff_occupancy)
12947{
12948 *p_buff_occupancy =
12949 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
12950 *p_max_buff_occupancy =
12951 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
12952}
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962#define MLXSW_REG_SBIB_ID 0xB006
12963#define MLXSW_REG_SBIB_LEN 0x10
12964
12965MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
12966
12967
12968
12969
12970
12971
12972MLXSW_ITEM32_LP(reg, sbib, 0x00, 16, 0x00, 12);
12973
12974
12975
12976
12977
12978
12979
12980MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
12981
12982static inline void mlxsw_reg_sbib_pack(char *payload, u16 local_port,
12983 u32 buff_size)
12984{
12985 MLXSW_REG_ZERO(sbib, payload);
12986 mlxsw_reg_sbib_local_port_set(payload, local_port);
12987 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
12988}
12989
12990static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
12991 MLXSW_REG(sgcr),
12992 MLXSW_REG(spad),
12993 MLXSW_REG(sspr),
12994 MLXSW_REG(sfdat),
12995 MLXSW_REG(sfd),
12996 MLXSW_REG(sfn),
12997 MLXSW_REG(spms),
12998 MLXSW_REG(spvid),
12999 MLXSW_REG(spvm),
13000 MLXSW_REG(spaft),
13001 MLXSW_REG(sfgc),
13002 MLXSW_REG(sfdf),
13003 MLXSW_REG(sldr),
13004 MLXSW_REG(slcr),
13005 MLXSW_REG(slcor),
13006 MLXSW_REG(spmlr),
13007 MLXSW_REG(svfa),
13008 MLXSW_REG(spvtr),
13009 MLXSW_REG(svpe),
13010 MLXSW_REG(sfmr),
13011 MLXSW_REG(spvmlr),
13012 MLXSW_REG(spvc),
13013 MLXSW_REG(spevet),
13014 MLXSW_REG(sftr2),
13015 MLXSW_REG(smid2),
13016 MLXSW_REG(cwtp),
13017 MLXSW_REG(cwtpm),
13018 MLXSW_REG(pgcr),
13019 MLXSW_REG(ppbt),
13020 MLXSW_REG(pacl),
13021 MLXSW_REG(pagt),
13022 MLXSW_REG(ptar),
13023 MLXSW_REG(ppbs),
13024 MLXSW_REG(prcr),
13025 MLXSW_REG(pefa),
13026 MLXSW_REG(pemrbt),
13027 MLXSW_REG(ptce2),
13028 MLXSW_REG(perpt),
13029 MLXSW_REG(peabfe),
13030 MLXSW_REG(perar),
13031 MLXSW_REG(ptce3),
13032 MLXSW_REG(percr),
13033 MLXSW_REG(pererp),
13034 MLXSW_REG(iedr),
13035 MLXSW_REG(qpts),
13036 MLXSW_REG(qpcr),
13037 MLXSW_REG(qtct),
13038 MLXSW_REG(qeec),
13039 MLXSW_REG(qrwe),
13040 MLXSW_REG(qpdsm),
13041 MLXSW_REG(qpdp),
13042 MLXSW_REG(qpdpm),
13043 MLXSW_REG(qtctm),
13044 MLXSW_REG(qpsc),
13045 MLXSW_REG(pmlp),
13046 MLXSW_REG(pmtu),
13047 MLXSW_REG(ptys),
13048 MLXSW_REG(ppad),
13049 MLXSW_REG(paos),
13050 MLXSW_REG(pfcc),
13051 MLXSW_REG(ppcnt),
13052 MLXSW_REG(plib),
13053 MLXSW_REG(pptb),
13054 MLXSW_REG(pbmc),
13055 MLXSW_REG(pspa),
13056 MLXSW_REG(pmaos),
13057 MLXSW_REG(pplr),
13058 MLXSW_REG(pmtdb),
13059 MLXSW_REG(pmecr),
13060 MLXSW_REG(pmpe),
13061 MLXSW_REG(pddr),
13062 MLXSW_REG(pmmp),
13063 MLXSW_REG(pllp),
13064 MLXSW_REG(pmtm),
13065 MLXSW_REG(htgt),
13066 MLXSW_REG(hpkt),
13067 MLXSW_REG(rgcr),
13068 MLXSW_REG(ritr),
13069 MLXSW_REG(rtar),
13070 MLXSW_REG(ratr),
13071 MLXSW_REG(rtdp),
13072 MLXSW_REG(rips),
13073 MLXSW_REG(ratrad),
13074 MLXSW_REG(rdpm),
13075 MLXSW_REG(ricnt),
13076 MLXSW_REG(rrcr),
13077 MLXSW_REG(ralta),
13078 MLXSW_REG(ralst),
13079 MLXSW_REG(raltb),
13080 MLXSW_REG(ralue),
13081 MLXSW_REG(rauht),
13082 MLXSW_REG(raleu),
13083 MLXSW_REG(rauhtd),
13084 MLXSW_REG(rigr2),
13085 MLXSW_REG(recr2),
13086 MLXSW_REG(rmft2),
13087 MLXSW_REG(rxlte),
13088 MLXSW_REG(rxltm),
13089 MLXSW_REG(rlcmld),
13090 MLXSW_REG(rlpmce),
13091 MLXSW_REG(xltq),
13092 MLXSW_REG(xmdr),
13093 MLXSW_REG(xrmt),
13094 MLXSW_REG(xralta),
13095 MLXSW_REG(xralst),
13096 MLXSW_REG(xraltb),
13097 MLXSW_REG(mfcr),
13098 MLXSW_REG(mfsc),
13099 MLXSW_REG(mfsm),
13100 MLXSW_REG(mfsl),
13101 MLXSW_REG(fore),
13102 MLXSW_REG(mtcap),
13103 MLXSW_REG(mtmp),
13104 MLXSW_REG(mtwe),
13105 MLXSW_REG(mtbr),
13106 MLXSW_REG(mcia),
13107 MLXSW_REG(mpat),
13108 MLXSW_REG(mpar),
13109 MLXSW_REG(mgir),
13110 MLXSW_REG(mrsr),
13111 MLXSW_REG(mlcr),
13112 MLXSW_REG(mcion),
13113 MLXSW_REG(mtpps),
13114 MLXSW_REG(mtutc),
13115 MLXSW_REG(mpsc),
13116 MLXSW_REG(mcqi),
13117 MLXSW_REG(mcc),
13118 MLXSW_REG(mcda),
13119 MLXSW_REG(mgpc),
13120 MLXSW_REG(mprs),
13121 MLXSW_REG(mogcr),
13122 MLXSW_REG(mpagr),
13123 MLXSW_REG(momte),
13124 MLXSW_REG(mtpppc),
13125 MLXSW_REG(mtpptr),
13126 MLXSW_REG(mtptpt),
13127 MLXSW_REG(mfgd),
13128 MLXSW_REG(mgpir),
13129 MLXSW_REG(mbct),
13130 MLXSW_REG(mddq),
13131 MLXSW_REG(mddc),
13132 MLXSW_REG(mfde),
13133 MLXSW_REG(tngcr),
13134 MLXSW_REG(tnumt),
13135 MLXSW_REG(tnqcr),
13136 MLXSW_REG(tnqdr),
13137 MLXSW_REG(tneem),
13138 MLXSW_REG(tndem),
13139 MLXSW_REG(tnpc),
13140 MLXSW_REG(tigcr),
13141 MLXSW_REG(tieem),
13142 MLXSW_REG(tidem),
13143 MLXSW_REG(sbpr),
13144 MLXSW_REG(sbcm),
13145 MLXSW_REG(sbpm),
13146 MLXSW_REG(sbmm),
13147 MLXSW_REG(sbsr),
13148 MLXSW_REG(sbib),
13149};
13150
13151static inline const char *mlxsw_reg_id_str(u16 reg_id)
13152{
13153 const struct mlxsw_reg_info *reg_info;
13154 int i;
13155
13156 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
13157 reg_info = mlxsw_reg_infos[i];
13158 if (reg_info->id == reg_id)
13159 return reg_info->name;
13160 }
13161 return "*UNKNOWN*";
13162}
13163
13164
13165
13166
13167
13168#define MLXSW_REG_PUDE_LEN 0x10
13169
13170
13171
13172
13173
13174MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
13175
13176
13177
13178
13179
13180MLXSW_ITEM32_LP(reg, pude, 0x00, 16, 0x00, 12);
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
13202
13203#endif
13204