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
77
78#define MLXSW_REG_SMID_ID 0x2007
79#define MLXSW_REG_SMID_LEN 0x240
80
81MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
82
83
84
85
86
87MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
88
89
90
91
92
93
94MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
95
96
97
98
99
100MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
101
102
103
104
105
106MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
107
108static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
109 u8 port, bool set)
110{
111 MLXSW_REG_ZERO(smid, payload);
112 mlxsw_reg_smid_swid_set(payload, 0);
113 mlxsw_reg_smid_mid_set(payload, mid);
114 mlxsw_reg_smid_port_set(payload, port, set);
115 mlxsw_reg_smid_port_mask_set(payload, port, 1);
116}
117
118
119
120
121
122#define MLXSW_REG_SSPR_ID 0x2008
123#define MLXSW_REG_SSPR_LEN 0x8
124
125MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
126
127
128
129
130
131
132
133
134
135
136
137MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
138
139
140
141
142
143
144MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
145
146
147
148
149
150
151
152MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
153
154
155
156
157
158
159
160
161
162MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
163
164static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
165{
166 MLXSW_REG_ZERO(sspr, payload);
167 mlxsw_reg_sspr_m_set(payload, 1);
168 mlxsw_reg_sspr_local_port_set(payload, local_port);
169 mlxsw_reg_sspr_sub_port_set(payload, 0);
170 mlxsw_reg_sspr_system_port_set(payload, local_port);
171}
172
173
174
175
176
177
178#define MLXSW_REG_SFDAT_ID 0x2009
179#define MLXSW_REG_SFDAT_LEN 0x8
180
181MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
182
183
184
185
186
187MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
188
189
190
191
192
193
194
195
196MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
197
198static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
199{
200 MLXSW_REG_ZERO(sfdat, payload);
201 mlxsw_reg_sfdat_swid_set(payload, 0);
202 mlxsw_reg_sfdat_age_time_set(payload, age_time);
203}
204
205
206
207
208
209
210
211
212#define MLXSW_REG_SFD_ID 0x200A
213#define MLXSW_REG_SFD_BASE_LEN 0x10
214#define MLXSW_REG_SFD_REC_LEN 0x10
215#define MLXSW_REG_SFD_REC_MAX_COUNT 64
216#define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
217 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
218
219MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
220
221
222
223
224
225MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
226
227enum mlxsw_reg_sfd_op {
228
229 MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
230
231 MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
232
233 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
234
235
236
237 MLXSW_REG_SFD_OP_WRITE_TEST = 0,
238
239
240
241
242 MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
243
244
245
246
247
248 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
249
250
251
252 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
253};
254
255
256
257
258
259MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
260
261
262
263
264
265
266
267
268MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
269
270
271
272
273
274
275
276
277MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
278
279static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
280 u32 record_locator)
281{
282 MLXSW_REG_ZERO(sfd, payload);
283 mlxsw_reg_sfd_op_set(payload, op);
284 mlxsw_reg_sfd_record_locator_set(payload, record_locator);
285}
286
287
288
289
290
291MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
292 MLXSW_REG_SFD_REC_LEN, 0x00, false);
293
294enum mlxsw_reg_sfd_rec_type {
295 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
296 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
297 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
298};
299
300
301
302
303
304MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
305 MLXSW_REG_SFD_REC_LEN, 0x00, false);
306
307enum mlxsw_reg_sfd_rec_policy {
308
309 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
310
311
312
313 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
314
315 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
316};
317
318
319
320
321
322MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
323 MLXSW_REG_SFD_REC_LEN, 0x00, false);
324
325
326
327
328
329
330
331MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
332 MLXSW_REG_SFD_REC_LEN, 0x00, false);
333
334
335
336
337
338MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
339 MLXSW_REG_SFD_REC_LEN, 0x02);
340
341enum mlxsw_reg_sfd_rec_action {
342
343 MLXSW_REG_SFD_REC_ACTION_NOP = 0,
344
345 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
346
347 MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
348
349 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
350 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
351};
352
353
354
355
356
357
358MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
359 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
360
361
362
363
364
365
366
367MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
368 MLXSW_REG_SFD_REC_LEN, 0x08, false);
369
370
371
372
373
374
375
376
377
378
379
380MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
381 MLXSW_REG_SFD_REC_LEN, 0x08, false);
382
383
384
385
386
387MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
388 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
389
390static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
391 enum mlxsw_reg_sfd_rec_type rec_type,
392 const char *mac,
393 enum mlxsw_reg_sfd_rec_action action)
394{
395 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
396
397 if (rec_index >= num_rec)
398 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
399 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
400 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
401 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
402 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
403}
404
405static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
406 enum mlxsw_reg_sfd_rec_policy policy,
407 const char *mac, u16 fid_vid,
408 enum mlxsw_reg_sfd_rec_action action,
409 u8 local_port)
410{
411 mlxsw_reg_sfd_rec_pack(payload, rec_index,
412 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
413 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
414 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
415 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
416 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
417}
418
419static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
420 char *mac, u16 *p_fid_vid,
421 u8 *p_local_port)
422{
423 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
424 *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
425 *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
426}
427
428
429
430
431
432
433MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
434 MLXSW_REG_SFD_REC_LEN, 0x08, false);
435
436
437
438
439
440
441
442
443
444
445
446MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
447 MLXSW_REG_SFD_REC_LEN, 0x08, false);
448
449
450
451
452
453MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
454 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
455
456
457
458
459
460MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
461 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
462
463static inline void
464mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
465 enum mlxsw_reg_sfd_rec_policy policy,
466 const char *mac, u16 fid_vid,
467 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
468 u16 lag_id)
469{
470 mlxsw_reg_sfd_rec_pack(payload, rec_index,
471 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
472 mac, action);
473 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
474 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
475 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
476 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
477 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
478}
479
480static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
481 char *mac, u16 *p_vid,
482 u16 *p_lag_id)
483{
484 mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
485 *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
486 *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
487}
488
489
490
491
492
493
494
495
496MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
497 MLXSW_REG_SFD_REC_LEN, 0x08, false);
498
499
500
501
502
503
504MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
505 MLXSW_REG_SFD_REC_LEN, 0x08, false);
506
507
508
509
510
511
512
513MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
514 MLXSW_REG_SFD_REC_LEN, 0x0C, false);
515
516static inline void
517mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
518 const char *mac, u16 fid_vid,
519 enum mlxsw_reg_sfd_rec_action action, u16 mid)
520{
521 mlxsw_reg_sfd_rec_pack(payload, rec_index,
522 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
523 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
524 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
525 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
526}
527
528
529
530
531
532
533#define MLXSW_REG_SFN_ID 0x200B
534#define MLXSW_REG_SFN_BASE_LEN 0x10
535#define MLXSW_REG_SFN_REC_LEN 0x10
536#define MLXSW_REG_SFN_REC_MAX_COUNT 64
537#define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
538 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
539
540MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
541
542
543
544
545
546MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
547
548
549
550
551
552MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
553
554
555
556
557
558
559
560
561
562MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
563
564static inline void mlxsw_reg_sfn_pack(char *payload)
565{
566 MLXSW_REG_ZERO(sfn, payload);
567 mlxsw_reg_sfn_swid_set(payload, 0);
568 mlxsw_reg_sfn_end_set(payload, 1);
569 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
570}
571
572
573
574
575
576MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
577 MLXSW_REG_SFN_REC_LEN, 0x00, false);
578
579enum mlxsw_reg_sfn_rec_type {
580
581 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
582
583 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
584
585 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
586
587 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
588};
589
590
591
592
593
594MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
595 MLXSW_REG_SFN_REC_LEN, 0x00, false);
596
597
598
599
600
601MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
602 MLXSW_REG_SFN_REC_LEN, 0x02);
603
604
605
606
607
608
609MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
610 MLXSW_REG_SFN_REC_LEN, 0x08, false);
611
612
613
614
615
616MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
617 MLXSW_REG_SFN_REC_LEN, 0x08, false);
618
619
620
621
622
623MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
624 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
625
626static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
627 char *mac, u16 *p_vid,
628 u8 *p_local_port)
629{
630 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
631 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
632 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
633}
634
635
636
637
638
639MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
640 MLXSW_REG_SFN_REC_LEN, 0x0C, false);
641
642static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
643 char *mac, u16 *p_vid,
644 u16 *p_lag_id)
645{
646 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
647 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
648 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
649}
650
651
652
653
654
655#define MLXSW_REG_SPMS_ID 0x200D
656#define MLXSW_REG_SPMS_LEN 0x404
657
658MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
659
660
661
662
663
664MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
665
666enum mlxsw_reg_spms_state {
667 MLXSW_REG_SPMS_STATE_NO_CHANGE,
668 MLXSW_REG_SPMS_STATE_DISCARDING,
669 MLXSW_REG_SPMS_STATE_LEARNING,
670 MLXSW_REG_SPMS_STATE_FORWARDING,
671};
672
673
674
675
676
677
678
679
680
681MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
682
683static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
684{
685 MLXSW_REG_ZERO(spms, payload);
686 mlxsw_reg_spms_local_port_set(payload, local_port);
687}
688
689static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
690 enum mlxsw_reg_spms_state state)
691{
692 mlxsw_reg_spms_state_set(payload, vid, state);
693}
694
695
696
697
698
699#define MLXSW_REG_SPVID_ID 0x200E
700#define MLXSW_REG_SPVID_LEN 0x08
701
702MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
703
704
705
706
707
708MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
709
710
711
712
713
714
715MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
716
717
718
719
720
721MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
722
723static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
724{
725 MLXSW_REG_ZERO(spvid, payload);
726 mlxsw_reg_spvid_local_port_set(payload, local_port);
727 mlxsw_reg_spvid_pvid_set(payload, pvid);
728}
729
730
731
732
733
734
735
736#define MLXSW_REG_SPVM_ID 0x200F
737#define MLXSW_REG_SPVM_BASE_LEN 0x04
738#define MLXSW_REG_SPVM_REC_LEN 0x04
739#define MLXSW_REG_SPVM_REC_MAX_COUNT 255
740#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
741 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
742
743MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
744
745
746
747
748
749
750
751MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
752
753
754
755
756
757
758MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
759
760
761
762
763
764MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
765
766
767
768
769
770
771MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
772
773
774
775
776
777MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
778
779
780
781
782
783MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
784 MLXSW_REG_SPVM_BASE_LEN, 14, 1,
785 MLXSW_REG_SPVM_REC_LEN, 0, false);
786
787
788
789
790
791MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
792 MLXSW_REG_SPVM_BASE_LEN, 13, 1,
793 MLXSW_REG_SPVM_REC_LEN, 0, false);
794
795
796
797
798
799
800MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
801 MLXSW_REG_SPVM_BASE_LEN, 12, 1,
802 MLXSW_REG_SPVM_REC_LEN, 0, false);
803
804
805
806
807
808MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
809 MLXSW_REG_SPVM_BASE_LEN, 0, 12,
810 MLXSW_REG_SPVM_REC_LEN, 0, false);
811
812static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
813 u16 vid_begin, u16 vid_end,
814 bool is_member, bool untagged)
815{
816 int size = vid_end - vid_begin + 1;
817 int i;
818
819 MLXSW_REG_ZERO(spvm, payload);
820 mlxsw_reg_spvm_local_port_set(payload, local_port);
821 mlxsw_reg_spvm_num_rec_set(payload, size);
822
823 for (i = 0; i < size; i++) {
824 mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
825 mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
826 mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
827 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
828 }
829}
830
831
832
833
834
835
836#define MLXSW_REG_SPAFT_ID 0x2010
837#define MLXSW_REG_SPAFT_LEN 0x08
838
839MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
840
841
842
843
844
845
846
847MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
848
849
850
851
852
853
854MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
855
856
857
858
859
860MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
861
862
863
864
865
866MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
867
868
869
870
871
872MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
873
874static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
875 bool allow_untagged)
876{
877 MLXSW_REG_ZERO(spaft, payload);
878 mlxsw_reg_spaft_local_port_set(payload, local_port);
879 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
880 mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
881 mlxsw_reg_spaft_allow_tagged_set(payload, true);
882}
883
884
885
886
887
888
889#define MLXSW_REG_SFGC_ID 0x2011
890#define MLXSW_REG_SFGC_LEN 0x10
891
892MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
893
894enum mlxsw_reg_sfgc_type {
895 MLXSW_REG_SFGC_TYPE_BROADCAST,
896 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
897 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
898 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
899 MLXSW_REG_SFGC_TYPE_RESERVED,
900 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
901 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
902 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
903 MLXSW_REG_SFGC_TYPE_MAX,
904};
905
906
907
908
909
910MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
911
912enum mlxsw_reg_sfgc_bridge_type {
913 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
914 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
915};
916
917
918
919
920
921
922MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
923
924enum mlxsw_flood_table_type {
925 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
926 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
927 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
928 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
929 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
930};
931
932
933
934
935
936
937
938MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
939
940
941
942
943
944
945MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
946
947
948
949
950
951MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
952
953
954
955
956
957MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
958
959
960
961
962
963MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
964
965static inline void
966mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
967 enum mlxsw_reg_sfgc_bridge_type bridge_type,
968 enum mlxsw_flood_table_type table_type,
969 unsigned int flood_table)
970{
971 MLXSW_REG_ZERO(sfgc, payload);
972 mlxsw_reg_sfgc_type_set(payload, type);
973 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
974 mlxsw_reg_sfgc_table_type_set(payload, table_type);
975 mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
976 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
977}
978
979
980
981
982
983
984#define MLXSW_REG_SFTR_ID 0x2012
985#define MLXSW_REG_SFTR_LEN 0x420
986
987MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
988
989
990
991
992
993MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
994
995
996
997
998
999
1000MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
1001
1002
1003
1004
1005
1006
1007MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
1008
1009
1010
1011
1012
1013MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
1014
1015
1016
1017
1018
1019MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
1020
1021
1022
1023
1024
1025MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
1026
1027
1028
1029
1030
1031MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
1032
1033static inline void mlxsw_reg_sftr_pack(char *payload,
1034 unsigned int flood_table,
1035 unsigned int index,
1036 enum mlxsw_flood_table_type table_type,
1037 unsigned int range, u8 port, bool set)
1038{
1039 MLXSW_REG_ZERO(sftr, payload);
1040 mlxsw_reg_sftr_swid_set(payload, 0);
1041 mlxsw_reg_sftr_flood_table_set(payload, flood_table);
1042 mlxsw_reg_sftr_index_set(payload, index);
1043 mlxsw_reg_sftr_table_type_set(payload, table_type);
1044 mlxsw_reg_sftr_range_set(payload, range);
1045 mlxsw_reg_sftr_port_set(payload, port, set);
1046 mlxsw_reg_sftr_port_mask_set(payload, port, 1);
1047}
1048
1049
1050
1051
1052
1053
1054#define MLXSW_REG_SFDF_ID 0x2013
1055#define MLXSW_REG_SFDF_LEN 0x14
1056
1057MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
1058
1059
1060
1061
1062
1063MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
1064
1065enum mlxsw_reg_sfdf_flush_type {
1066 MLXSW_REG_SFDF_FLUSH_PER_SWID,
1067 MLXSW_REG_SFDF_FLUSH_PER_FID,
1068 MLXSW_REG_SFDF_FLUSH_PER_PORT,
1069 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
1070 MLXSW_REG_SFDF_FLUSH_PER_LAG,
1071 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
1072};
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
1085
1086
1087
1088
1089
1090
1091
1092MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
1093
1094static inline void mlxsw_reg_sfdf_pack(char *payload,
1095 enum mlxsw_reg_sfdf_flush_type type)
1096{
1097 MLXSW_REG_ZERO(sfdf, payload);
1098 mlxsw_reg_sfdf_flush_type_set(payload, type);
1099 mlxsw_reg_sfdf_flush_static_set(payload, true);
1100}
1101
1102
1103
1104
1105
1106MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
1107
1108
1109
1110
1111
1112MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
1113
1114
1115
1116
1117
1118MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
1119
1120
1121
1122
1123
1124MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
1125
1126
1127
1128
1129
1130MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
1131
1132
1133
1134
1135
1136
1137
1138#define MLXSW_REG_SLDR_ID 0x2014
1139#define MLXSW_REG_SLDR_LEN 0x0C
1140
1141MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
1142
1143enum mlxsw_reg_sldr_op {
1144
1145 MLXSW_REG_SLDR_OP_LAG_CREATE,
1146 MLXSW_REG_SLDR_OP_LAG_DESTROY,
1147
1148 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
1149
1150 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
1151};
1152
1153
1154
1155
1156
1157MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
1158
1159
1160
1161
1162
1163MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
1164
1165static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
1166{
1167 MLXSW_REG_ZERO(sldr, payload);
1168 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
1169 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1170}
1171
1172static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
1173{
1174 MLXSW_REG_ZERO(sldr, payload);
1175 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
1176 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1177}
1178
1179
1180
1181
1182
1183
1184
1185MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
1186
1187
1188
1189
1190
1191MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
1192
1193static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
1194 u8 local_port)
1195{
1196 MLXSW_REG_ZERO(sldr, payload);
1197 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
1198 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1199 mlxsw_reg_sldr_num_ports_set(payload, 1);
1200 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1201}
1202
1203static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
1204 u8 local_port)
1205{
1206 MLXSW_REG_ZERO(sldr, payload);
1207 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
1208 mlxsw_reg_sldr_lag_id_set(payload, lag_id);
1209 mlxsw_reg_sldr_num_ports_set(payload, 1);
1210 mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
1211}
1212
1213
1214
1215
1216
1217
1218#define MLXSW_REG_SLCR_ID 0x2015
1219#define MLXSW_REG_SLCR_LEN 0x10
1220
1221MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
1222
1223enum mlxsw_reg_slcr_pp {
1224
1225 MLXSW_REG_SLCR_PP_GLOBAL,
1226
1227 MLXSW_REG_SLCR_PP_PER_PORT,
1228};
1229
1230
1231
1232
1233
1234
1235MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
1236
1237
1238
1239
1240
1241
1242
1243
1244MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
1245
1246enum mlxsw_reg_slcr_type {
1247 MLXSW_REG_SLCR_TYPE_CRC,
1248 MLXSW_REG_SLCR_TYPE_XOR,
1249 MLXSW_REG_SLCR_TYPE_RANDOM,
1250};
1251
1252
1253
1254
1255
1256MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
1257
1258
1259#define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
1260
1261#define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
1262
1263#define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
1264#define MLXSW_REG_SLCR_LAG_HASH_SMAC \
1265 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
1266 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
1267
1268#define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
1269
1270#define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
1271#define MLXSW_REG_SLCR_LAG_HASH_DMAC \
1272 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
1273 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
1274
1275#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
1276
1277#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
1278#define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
1279 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
1280 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
1281
1282#define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
1283
1284#define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
1285#define MLXSW_REG_SLCR_LAG_HASH_VLANID \
1286 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
1287 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
1288
1289#define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
1290
1291#define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
1292
1293#define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
1294
1295#define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
1296
1297#define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
1298
1299#define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
1300
1301#define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
1302
1303#define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
1304
1305#define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
1306
1307#define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
1308
1309
1310
1311
1312
1313
1314
1315
1316MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
1317
1318static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash)
1319{
1320 MLXSW_REG_ZERO(slcr, payload);
1321 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
1322 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
1323 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
1324}
1325
1326
1327
1328
1329
1330
1331#define MLXSW_REG_SLCOR_ID 0x2016
1332#define MLXSW_REG_SLCOR_LEN 0x10
1333
1334MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
1335
1336enum mlxsw_reg_slcor_col {
1337
1338 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
1339 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
1340 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
1341 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
1342};
1343
1344
1345
1346
1347
1348MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
1349
1350
1351
1352
1353
1354
1355MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
1356
1357
1358
1359
1360
1361MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
1362
1363
1364
1365
1366
1367
1368MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
1369
1370static inline void mlxsw_reg_slcor_pack(char *payload,
1371 u8 local_port, u16 lag_id,
1372 enum mlxsw_reg_slcor_col col)
1373{
1374 MLXSW_REG_ZERO(slcor, payload);
1375 mlxsw_reg_slcor_col_set(payload, col);
1376 mlxsw_reg_slcor_local_port_set(payload, local_port);
1377 mlxsw_reg_slcor_lag_id_set(payload, lag_id);
1378}
1379
1380static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
1381 u8 local_port, u16 lag_id,
1382 u8 port_index)
1383{
1384 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1385 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
1386 mlxsw_reg_slcor_port_index_set(payload, port_index);
1387}
1388
1389static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
1390 u8 local_port, u16 lag_id)
1391{
1392 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1393 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
1394}
1395
1396static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
1397 u8 local_port, u16 lag_id)
1398{
1399 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1400 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1401}
1402
1403static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
1404 u8 local_port, u16 lag_id)
1405{
1406 mlxsw_reg_slcor_pack(payload, local_port, lag_id,
1407 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
1408}
1409
1410
1411
1412
1413
1414#define MLXSW_REG_SPMLR_ID 0x2018
1415#define MLXSW_REG_SPMLR_LEN 0x8
1416
1417MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
1418
1419
1420
1421
1422
1423MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
1424
1425
1426
1427
1428
1429
1430MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
1431
1432enum mlxsw_reg_spmlr_learn_mode {
1433 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
1434 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
1435 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
1436};
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
1450
1451static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
1452 enum mlxsw_reg_spmlr_learn_mode mode)
1453{
1454 MLXSW_REG_ZERO(spmlr, payload);
1455 mlxsw_reg_spmlr_local_port_set(payload, local_port);
1456 mlxsw_reg_spmlr_sub_port_set(payload, 0);
1457 mlxsw_reg_spmlr_learn_mode_set(payload, mode);
1458}
1459
1460
1461
1462
1463
1464
1465#define MLXSW_REG_SVFA_ID 0x201C
1466#define MLXSW_REG_SVFA_LEN 0x10
1467
1468MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
1469
1470
1471
1472
1473
1474MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
1475
1476
1477
1478
1479
1480
1481
1482MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
1483
1484enum mlxsw_reg_svfa_mt {
1485 MLXSW_REG_SVFA_MT_VID_TO_FID,
1486 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
1487};
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
1498
1499
1500
1501
1502
1503
1504
1505
1506MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
1507
1508
1509
1510
1511
1512MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
1513
1514
1515
1516
1517
1518MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
1519
1520
1521
1522
1523
1524
1525
1526MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
1527
1528
1529
1530
1531
1532
1533
1534MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
1535
1536static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
1537 enum mlxsw_reg_svfa_mt mt, bool valid,
1538 u16 fid, u16 vid)
1539{
1540 MLXSW_REG_ZERO(svfa, payload);
1541 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
1542 mlxsw_reg_svfa_swid_set(payload, 0);
1543 mlxsw_reg_svfa_local_port_set(payload, local_port);
1544 mlxsw_reg_svfa_mapping_table_set(payload, mt);
1545 mlxsw_reg_svfa_v_set(payload, valid);
1546 mlxsw_reg_svfa_fid_set(payload, fid);
1547 mlxsw_reg_svfa_vid_set(payload, vid);
1548}
1549
1550
1551
1552
1553
1554#define MLXSW_REG_SVPE_ID 0x201E
1555#define MLXSW_REG_SVPE_LEN 0x4
1556
1557MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
1558
1559
1560
1561
1562
1563
1564
1565MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
1566
1567
1568
1569
1570
1571
1572
1573MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
1574
1575static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
1576 bool enable)
1577{
1578 MLXSW_REG_ZERO(svpe, payload);
1579 mlxsw_reg_svpe_local_port_set(payload, local_port);
1580 mlxsw_reg_svpe_vp_en_set(payload, enable);
1581}
1582
1583
1584
1585
1586
1587#define MLXSW_REG_SFMR_ID 0x201F
1588#define MLXSW_REG_SFMR_LEN 0x18
1589
1590MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
1591
1592enum mlxsw_reg_sfmr_op {
1593 MLXSW_REG_SFMR_OP_CREATE_FID,
1594 MLXSW_REG_SFMR_OP_DESTROY_FID,
1595};
1596
1597
1598
1599
1600
1601
1602
1603MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
1604
1605
1606
1607
1608
1609MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
1610
1611
1612
1613
1614
1615
1616
1617MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
1618
1619
1620
1621
1622
1623
1624
1625
1626MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
1627
1628
1629
1630
1631
1632
1633
1634MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
1635
1636
1637
1638
1639
1640
1641
1642
1643MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
1644
1645
1646
1647
1648
1649
1650
1651MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
1652
1653static inline void mlxsw_reg_sfmr_pack(char *payload,
1654 enum mlxsw_reg_sfmr_op op, u16 fid,
1655 u16 fid_offset)
1656{
1657 MLXSW_REG_ZERO(sfmr, payload);
1658 mlxsw_reg_sfmr_op_set(payload, op);
1659 mlxsw_reg_sfmr_fid_set(payload, fid);
1660 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
1661 mlxsw_reg_sfmr_vtfp_set(payload, false);
1662 mlxsw_reg_sfmr_vv_set(payload, false);
1663}
1664
1665
1666
1667
1668
1669#define MLXSW_REG_SPVMLR_ID 0x2020
1670#define MLXSW_REG_SPVMLR_BASE_LEN 0x04
1671#define MLXSW_REG_SPVMLR_REC_LEN 0x04
1672#define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
1673#define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
1674 MLXSW_REG_SPVMLR_REC_LEN * \
1675 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
1676
1677MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
1678
1679
1680
1681
1682
1683
1684
1685MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
1686
1687
1688
1689
1690
1691MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
1692
1693
1694
1695
1696
1697
1698MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
1699 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1700
1701
1702
1703
1704
1705MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
1706 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
1707
1708static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
1709 u16 vid_begin, u16 vid_end,
1710 bool learn_enable)
1711{
1712 int num_rec = vid_end - vid_begin + 1;
1713 int i;
1714
1715 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
1716
1717 MLXSW_REG_ZERO(spvmlr, payload);
1718 mlxsw_reg_spvmlr_local_port_set(payload, local_port);
1719 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
1720
1721 for (i = 0; i < num_rec; i++) {
1722 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
1723 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
1724 }
1725}
1726
1727
1728
1729
1730
1731#define MLXSW_REG_CWTP_ID 0x2802
1732#define MLXSW_REG_CWTP_BASE_LEN 0x28
1733#define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
1734#define MLXSW_REG_CWTP_LEN 0x40
1735
1736MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
1737
1738
1739
1740
1741
1742
1743MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
1744
1745
1746
1747
1748
1749MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
1750
1751
1752
1753
1754
1755MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
1756 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
1757
1758
1759
1760
1761
1762
1763MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
1764 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1765
1766
1767
1768
1769
1770MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
1771 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
1772
1773#define MLXSW_REG_CWTP_MIN_VALUE 64
1774#define MLXSW_REG_CWTP_MAX_PROFILE 2
1775#define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
1776
1777static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
1778 u8 traffic_class)
1779{
1780 int i;
1781
1782 MLXSW_REG_ZERO(cwtp, payload);
1783 mlxsw_reg_cwtp_local_port_set(payload, local_port);
1784 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
1785
1786 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
1787 mlxsw_reg_cwtp_profile_min_set(payload, i,
1788 MLXSW_REG_CWTP_MIN_VALUE);
1789 mlxsw_reg_cwtp_profile_max_set(payload, i,
1790 MLXSW_REG_CWTP_MIN_VALUE);
1791 }
1792}
1793
1794#define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
1795
1796static inline void
1797mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
1798 u32 probability)
1799{
1800 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
1801
1802 mlxsw_reg_cwtp_profile_min_set(payload, index, min);
1803 mlxsw_reg_cwtp_profile_max_set(payload, index, max);
1804 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
1805}
1806
1807
1808
1809
1810
1811#define MLXSW_REG_CWTPM_ID 0x2803
1812#define MLXSW_REG_CWTPM_LEN 0x44
1813
1814MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
1815
1816
1817
1818
1819
1820
1821MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
1822
1823
1824
1825
1826
1827MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
1828
1829
1830
1831
1832
1833
1834
1835MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
1836
1837
1838
1839
1840
1841
1842
1843MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
1844
1845
1846
1847
1848
1849
1850
1851MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
1852
1853
1854
1855
1856
1857
1858
1859MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
1860
1861
1862
1863
1864
1865
1866
1867MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
1868
1869
1870
1871
1872
1873
1874
1875MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
1876
1877
1878
1879
1880
1881
1882
1883MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
1884
1885
1886
1887
1888
1889
1890
1891MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
1892
1893#define MLXSW_REG_CWTPM_RESET_PROFILE 0
1894
1895static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
1896 u8 traffic_class, u8 profile,
1897 bool wred, bool ecn)
1898{
1899 MLXSW_REG_ZERO(cwtpm, payload);
1900 mlxsw_reg_cwtpm_local_port_set(payload, local_port);
1901 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
1902 mlxsw_reg_cwtpm_ew_set(payload, wred);
1903 mlxsw_reg_cwtpm_ee_set(payload, ecn);
1904 mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
1905 mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
1906 mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
1907 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
1908 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
1909 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
1910}
1911
1912
1913
1914
1915
1916#define MLXSW_REG_PGCR_ID 0x3001
1917#define MLXSW_REG_PGCR_LEN 0x20
1918
1919MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
1920
1921
1922
1923
1924
1925
1926MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
1927
1928static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
1929{
1930 MLXSW_REG_ZERO(pgcr, payload);
1931 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
1932}
1933
1934
1935
1936
1937
1938#define MLXSW_REG_PPBT_ID 0x3002
1939#define MLXSW_REG_PPBT_LEN 0x14
1940
1941MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
1942
1943enum mlxsw_reg_pxbt_e {
1944 MLXSW_REG_PXBT_E_IACL,
1945 MLXSW_REG_PXBT_E_EACL,
1946};
1947
1948
1949
1950
1951MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
1952
1953enum mlxsw_reg_pxbt_op {
1954 MLXSW_REG_PXBT_OP_BIND,
1955 MLXSW_REG_PXBT_OP_UNBIND,
1956};
1957
1958
1959
1960
1961MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
1962
1963
1964
1965
1966
1967MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
1968
1969
1970
1971
1972
1973
1974
1975MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
1976
1977
1978
1979
1980
1981
1982MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
1983
1984static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
1985 enum mlxsw_reg_pxbt_op op,
1986 u8 local_port, u16 acl_info)
1987{
1988 MLXSW_REG_ZERO(ppbt, payload);
1989 mlxsw_reg_ppbt_e_set(payload, e);
1990 mlxsw_reg_ppbt_op_set(payload, op);
1991 mlxsw_reg_ppbt_local_port_set(payload, local_port);
1992 mlxsw_reg_ppbt_g_set(payload, true);
1993 mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
1994}
1995
1996
1997
1998
1999
2000#define MLXSW_REG_PACL_ID 0x3004
2001#define MLXSW_REG_PACL_LEN 0x70
2002
2003MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
2004
2005
2006
2007
2008
2009
2010MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
2011
2012
2013
2014
2015
2016
2017MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
2018
2019#define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
2020
2021
2022
2023
2024
2025
2026MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
2027 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2028
2029static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
2030 bool valid, const char *tcam_region_info)
2031{
2032 MLXSW_REG_ZERO(pacl, payload);
2033 mlxsw_reg_pacl_acl_id_set(payload, acl_id);
2034 mlxsw_reg_pacl_v_set(payload, valid);
2035 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
2036}
2037
2038
2039
2040
2041
2042#define MLXSW_REG_PAGT_ID 0x3005
2043#define MLXSW_REG_PAGT_BASE_LEN 0x30
2044#define MLXSW_REG_PAGT_ACL_LEN 4
2045#define MLXSW_REG_PAGT_ACL_MAX_NUM 16
2046#define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
2047 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
2048
2049MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
2061
2062
2063
2064
2065
2066
2067MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
2068
2069
2070
2071
2072
2073MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
2074
2075static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
2076{
2077 MLXSW_REG_ZERO(pagt, payload);
2078 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
2079}
2080
2081static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
2082 u16 acl_id)
2083{
2084 u8 size = mlxsw_reg_pagt_size_get(payload);
2085
2086 if (index >= size)
2087 mlxsw_reg_pagt_size_set(payload, index + 1);
2088 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
2089}
2090
2091
2092
2093
2094
2095
2096#define MLXSW_REG_PTAR_ID 0x3006
2097#define MLXSW_REG_PTAR_BASE_LEN 0x20
2098#define MLXSW_REG_PTAR_KEY_ID_LEN 1
2099#define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
2100#define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
2101 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
2102
2103MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
2104
2105enum mlxsw_reg_ptar_op {
2106
2107 MLXSW_REG_PTAR_OP_ALLOC,
2108
2109 MLXSW_REG_PTAR_OP_RESIZE,
2110
2111 MLXSW_REG_PTAR_OP_FREE,
2112
2113 MLXSW_REG_PTAR_OP_TEST,
2114};
2115
2116
2117
2118
2119MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
2120
2121
2122
2123
2124
2125
2126MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
2127
2128enum mlxsw_reg_ptar_key_type {
2129 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50,
2130 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51,
2131};
2132
2133
2134
2135
2136
2137MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
2148
2149
2150
2151
2152
2153
2154MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
2155
2156
2157
2158
2159
2160
2161
2162MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
2163 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
2174 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
2175
2176static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
2177 enum mlxsw_reg_ptar_key_type key_type,
2178 u16 region_size, u16 region_id,
2179 const char *tcam_region_info)
2180{
2181 MLXSW_REG_ZERO(ptar, payload);
2182 mlxsw_reg_ptar_op_set(payload, op);
2183 mlxsw_reg_ptar_action_set_type_set(payload, 2);
2184 mlxsw_reg_ptar_key_type_set(payload, key_type);
2185 mlxsw_reg_ptar_region_size_set(payload, region_size);
2186 mlxsw_reg_ptar_region_id_set(payload, region_id);
2187 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
2188}
2189
2190static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
2191 u16 key_id)
2192{
2193 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
2194}
2195
2196static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
2197{
2198 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
2199}
2200
2201
2202
2203
2204
2205#define MLXSW_REG_PPBS_ID 0x300C
2206#define MLXSW_REG_PPBS_LEN 0x14
2207
2208MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
2209
2210
2211
2212
2213
2214
2215MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
2216
2217
2218
2219
2220
2221MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
2222
2223static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
2224 u16 system_port)
2225{
2226 MLXSW_REG_ZERO(ppbs, payload);
2227 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
2228 mlxsw_reg_ppbs_system_port_set(payload, system_port);
2229}
2230
2231
2232
2233
2234
2235#define MLXSW_REG_PRCR_ID 0x300D
2236#define MLXSW_REG_PRCR_LEN 0x40
2237
2238MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
2239
2240enum mlxsw_reg_prcr_op {
2241
2242
2243
2244
2245 MLXSW_REG_PRCR_OP_MOVE,
2246
2247
2248
2249
2250 MLXSW_REG_PRCR_OP_COPY,
2251};
2252
2253
2254
2255
2256MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
2257
2258
2259
2260
2261
2262MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
2263
2264
2265
2266
2267
2268MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
2269
2270
2271
2272
2273
2274MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
2275 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2276
2277
2278
2279
2280
2281MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
2282
2283
2284
2285
2286
2287MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
2288 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2289
2290static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
2291 const char *src_tcam_region_info,
2292 u16 src_offset,
2293 const char *dest_tcam_region_info,
2294 u16 dest_offset, u16 size)
2295{
2296 MLXSW_REG_ZERO(prcr, payload);
2297 mlxsw_reg_prcr_op_set(payload, op);
2298 mlxsw_reg_prcr_offset_set(payload, src_offset);
2299 mlxsw_reg_prcr_size_set(payload, size);
2300 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
2301 src_tcam_region_info);
2302 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
2303 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
2304 dest_tcam_region_info);
2305}
2306
2307
2308
2309
2310
2311
2312#define MLXSW_REG_PEFA_ID 0x300F
2313#define MLXSW_REG_PEFA_LEN 0xB0
2314
2315MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
2316
2317
2318
2319
2320
2321MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
2322
2323
2324
2325
2326
2327
2328
2329
2330MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
2331
2332
2333
2334
2335
2336
2337
2338MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
2339
2340#define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
2341
2342
2343
2344
2345
2346
2347MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
2348
2349static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
2350 const char *flex_action_set)
2351{
2352 MLXSW_REG_ZERO(pefa, payload);
2353 mlxsw_reg_pefa_index_set(payload, index);
2354 mlxsw_reg_pefa_ca_set(payload, ca);
2355 if (flex_action_set)
2356 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
2357 flex_action_set);
2358}
2359
2360static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
2361{
2362 *p_a = mlxsw_reg_pefa_a_get(payload);
2363}
2364
2365
2366
2367
2368
2369
2370
2371
2372#define MLXSW_REG_PTCE2_ID 0x3017
2373#define MLXSW_REG_PTCE2_LEN 0x1D8
2374
2375MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
2376
2377
2378
2379
2380
2381MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
2382
2383
2384
2385
2386
2387
2388MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
2389
2390enum mlxsw_reg_ptce2_op {
2391
2392 MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
2393
2394
2395
2396 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
2397
2398
2399
2400
2401 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
2402
2403 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
2404
2405 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
2406};
2407
2408
2409
2410
2411MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
2412
2413
2414
2415
2416MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
2417
2418
2419
2420
2421
2422
2423
2424
2425MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
2426
2427
2428
2429
2430
2431MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
2432 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2433
2434#define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
2435
2436
2437
2438
2439
2440MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
2441 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2442
2443
2444
2445
2446
2447
2448
2449MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
2450 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2451
2452
2453
2454
2455
2456MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
2457 MLXSW_REG_FLEX_ACTION_SET_LEN);
2458
2459static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
2460 enum mlxsw_reg_ptce2_op op,
2461 const char *tcam_region_info,
2462 u16 offset, u32 priority)
2463{
2464 MLXSW_REG_ZERO(ptce2, payload);
2465 mlxsw_reg_ptce2_v_set(payload, valid);
2466 mlxsw_reg_ptce2_op_set(payload, op);
2467 mlxsw_reg_ptce2_offset_set(payload, offset);
2468 mlxsw_reg_ptce2_priority_set(payload, priority);
2469 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
2470}
2471
2472
2473
2474
2475
2476#define MLXSW_REG_PERPT_ID 0x3021
2477#define MLXSW_REG_PERPT_LEN 0x80
2478
2479MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
2480
2481
2482
2483
2484
2485
2486MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
2487
2488
2489
2490
2491
2492
2493MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
2494
2495enum mlxsw_reg_perpt_key_size {
2496 MLXSW_REG_PERPT_KEY_SIZE_2KB,
2497 MLXSW_REG_PERPT_KEY_SIZE_4KB,
2498 MLXSW_REG_PERPT_KEY_SIZE_8KB,
2499 MLXSW_REG_PERPT_KEY_SIZE_12KB,
2500};
2501
2502
2503
2504
2505MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
2506
2507
2508
2509
2510
2511
2512
2513
2514MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
2515
2516
2517
2518
2519
2520MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
2521
2522
2523
2524
2525
2526
2527MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
2528
2529
2530
2531
2532
2533
2534MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
2535
2536
2537
2538
2539
2540MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
2541
2542
2543
2544
2545
2546MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
2547
2548
2549
2550
2551
2552
2553
2554MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2555
2556static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
2557 unsigned long *erp_vector,
2558 unsigned long size)
2559{
2560 unsigned long bit;
2561
2562 for_each_set_bit(bit, erp_vector, size)
2563 mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
2564}
2565
2566static inline void
2567mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
2568 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
2569 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
2570 char *mask)
2571{
2572 MLXSW_REG_ZERO(perpt, payload);
2573 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
2574 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
2575 mlxsw_reg_perpt_key_size_set(payload, key_size);
2576 mlxsw_reg_perpt_bf_bypass_set(payload, true);
2577 mlxsw_reg_perpt_erp_id_set(payload, erp_id);
2578 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
2579 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
2580 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
2581 mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
2582}
2583
2584
2585
2586
2587
2588
2589#define MLXSW_REG_PERAR_ID 0x3026
2590#define MLXSW_REG_PERAR_LEN 0x08
2591
2592MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
2593
2594
2595
2596
2597
2598
2599MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
2600
2601static inline unsigned int
2602mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
2603{
2604 return DIV_ROUND_UP(block_num, 4);
2605}
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
2616
2617static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
2618 u16 hw_region)
2619{
2620 MLXSW_REG_ZERO(perar, payload);
2621 mlxsw_reg_perar_region_id_set(payload, region_id);
2622 mlxsw_reg_perar_hw_region_set(payload, hw_region);
2623}
2624
2625
2626
2627
2628
2629
2630#define MLXSW_REG_PTCE3_ID 0x3027
2631#define MLXSW_REG_PTCE3_LEN 0xF0
2632
2633MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
2634
2635
2636
2637
2638
2639MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
2640
2641enum mlxsw_reg_ptce3_op {
2642
2643
2644
2645
2646
2647 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
2648
2649 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
2650
2651 MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
2652};
2653
2654
2655
2656
2657MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
2658
2659
2660
2661
2662
2663
2664
2665MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
2666
2667
2668
2669
2670
2671MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
2672 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
2673
2674
2675
2676
2677
2678
2679MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
2680 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
2681
2682
2683
2684
2685
2686MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
2687
2688
2689
2690
2691
2692
2693MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
2705
2706
2707
2708
2709
2710
2711MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
2724
2725
2726
2727
2728
2729
2730
2731MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
2755
2756
2757
2758
2759
2760
2761MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
2762
2763static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
2764 enum mlxsw_reg_ptce3_op op,
2765 u32 priority,
2766 const char *tcam_region_info,
2767 const char *key, u8 erp_id,
2768 bool large_exists, u32 lkey_id,
2769 u32 action_pointer)
2770{
2771 MLXSW_REG_ZERO(ptce3, payload);
2772 mlxsw_reg_ptce3_v_set(payload, valid);
2773 mlxsw_reg_ptce3_op_set(payload, op);
2774 mlxsw_reg_ptce3_priority_set(payload, priority);
2775 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
2776 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
2777 mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
2778 mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
2779 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
2780 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
2781}
2782
2783
2784
2785
2786
2787
2788#define MLXSW_REG_PERCR_ID 0x302A
2789#define MLXSW_REG_PERCR_LEN 0x80
2790
2791MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
2792
2793
2794
2795
2796
2797
2798MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
2799
2800
2801
2802
2803
2804MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
2805
2806
2807
2808
2809
2810MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
2811
2812
2813
2814
2815
2816
2817
2818
2819MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
2820
2821
2822
2823
2824
2825
2826
2827MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
2828
2829static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
2830{
2831 MLXSW_REG_ZERO(percr, payload);
2832 mlxsw_reg_percr_region_id_set(payload, region_id);
2833 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
2834 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
2835 mlxsw_reg_percr_bf_bypass_set(payload, true);
2836}
2837
2838
2839
2840
2841
2842
2843#define MLXSW_REG_PERERP_ID 0x302B
2844#define MLXSW_REG_PERERP_LEN 0x1C
2845
2846MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
2847
2848
2849
2850
2851
2852
2853MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
2854
2855
2856
2857
2858
2859MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
2860
2861
2862
2863
2864
2865MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
2866
2867
2868
2869
2870
2871
2872MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
2873
2874
2875
2876
2877
2878
2879
2880
2881MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
2882
2883
2884
2885
2886
2887
2888
2889
2890MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
2891
2892
2893
2894
2895
2896
2897
2898MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
2899
2900static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
2901 unsigned long *erp_vector,
2902 unsigned long size)
2903{
2904 unsigned long bit;
2905
2906 for_each_set_bit(bit, erp_vector, size)
2907 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
2908}
2909
2910static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
2911 bool ctcam_le, bool erpt_pointer_valid,
2912 u8 erpt_bank_pointer, u8 erpt_pointer,
2913 u8 master_rp_id)
2914{
2915 MLXSW_REG_ZERO(pererp, payload);
2916 mlxsw_reg_pererp_region_id_set(payload, region_id);
2917 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
2918 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
2919 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
2920 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
2921 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
2922}
2923
2924
2925
2926
2927
2928
2929
2930#define MLXSW_REG_IEDR_ID 0x3804
2931#define MLXSW_REG_IEDR_BASE_LEN 0x10
2932#define MLXSW_REG_IEDR_REC_LEN 0x8
2933#define MLXSW_REG_IEDR_REC_MAX_COUNT 64
2934#define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
2935 MLXSW_REG_IEDR_REC_LEN * \
2936 MLXSW_REG_IEDR_REC_MAX_COUNT)
2937
2938MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
2939
2940
2941
2942
2943
2944MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
2945
2946
2947
2948
2949
2950MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
2951 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
2952
2953
2954
2955
2956
2957MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 11,
2958 MLXSW_REG_IEDR_REC_LEN, 0x00, false);
2959
2960
2961
2962
2963
2964MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
2965 MLXSW_REG_IEDR_REC_LEN, 0x04, false);
2966
2967static inline void mlxsw_reg_iedr_pack(char *payload)
2968{
2969 MLXSW_REG_ZERO(iedr, payload);
2970}
2971
2972static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
2973 u8 rec_type, u16 rec_size,
2974 u32 rec_index_start)
2975{
2976 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
2977
2978 if (rec_index >= num_rec)
2979 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
2980 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
2981 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
2982 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
2983}
2984
2985
2986
2987
2988
2989
2990#define MLXSW_REG_QPTS_ID 0x4002
2991#define MLXSW_REG_QPTS_LEN 0x8
2992
2993MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
2994
2995
2996
2997
2998
2999
3000
3001MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
3002
3003enum mlxsw_reg_qpts_trust_state {
3004 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
3005 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2,
3006};
3007
3008
3009
3010
3011
3012MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
3013
3014static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
3015 enum mlxsw_reg_qpts_trust_state ts)
3016{
3017 MLXSW_REG_ZERO(qpts, payload);
3018
3019 mlxsw_reg_qpts_local_port_set(payload, local_port);
3020 mlxsw_reg_qpts_trust_state_set(payload, ts);
3021}
3022
3023
3024
3025
3026
3027
3028#define MLXSW_REG_QPCR_ID 0x4004
3029#define MLXSW_REG_QPCR_LEN 0x28
3030
3031MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
3032
3033enum mlxsw_reg_qpcr_g {
3034 MLXSW_REG_QPCR_G_GLOBAL = 2,
3035 MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
3036};
3037
3038
3039
3040
3041
3042MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
3043
3044
3045
3046
3047
3048MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
3049
3050
3051
3052
3053
3054
3055MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
3056
3057
3058
3059
3060
3061
3062
3063MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
3064
3065enum mlxsw_reg_qpcr_ir_units {
3066 MLXSW_REG_QPCR_IR_UNITS_M,
3067 MLXSW_REG_QPCR_IR_UNITS_K,
3068};
3069
3070
3071
3072
3073
3074
3075
3076MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
3077
3078enum mlxsw_reg_qpcr_rate_type {
3079 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
3080 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
3081};
3082
3083
3084
3085
3086
3087
3088
3089MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
3103
3104
3105
3106
3107
3108
3109
3110
3111MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
3122
3123#define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
3124
3125
3126
3127
3128
3129MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
3130
3131enum mlxsw_reg_qpcr_action {
3132
3133 MLXSW_REG_QPCR_ACTION_DISCARD = 1,
3134
3135
3136
3137 MLXSW_REG_QPCR_ACTION_FORWARD = 2,
3138};
3139
3140
3141
3142
3143
3144
3145MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
3146
3147static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
3148 enum mlxsw_reg_qpcr_ir_units ir_units,
3149 bool bytes, u32 cir, u16 cbs)
3150{
3151 MLXSW_REG_ZERO(qpcr, payload);
3152 mlxsw_reg_qpcr_pid_set(payload, pid);
3153 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
3154 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
3155 mlxsw_reg_qpcr_violate_action_set(payload,
3156 MLXSW_REG_QPCR_ACTION_DISCARD);
3157 mlxsw_reg_qpcr_cir_set(payload, cir);
3158 mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
3159 mlxsw_reg_qpcr_bytes_set(payload, bytes);
3160 mlxsw_reg_qpcr_cbs_set(payload, cbs);
3161}
3162
3163
3164
3165
3166
3167
3168#define MLXSW_REG_QTCT_ID 0x400A
3169#define MLXSW_REG_QTCT_LEN 0x08
3170
3171MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
3172
3173
3174
3175
3176
3177
3178
3179MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
3180
3181
3182
3183
3184
3185
3186MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
3187
3188
3189
3190
3191
3192MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
3203
3204static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3205 u8 switch_prio, u8 tclass)
3206{
3207 MLXSW_REG_ZERO(qtct, payload);
3208 mlxsw_reg_qtct_local_port_set(payload, local_port);
3209 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
3210 mlxsw_reg_qtct_tclass_set(payload, tclass);
3211}
3212
3213
3214
3215
3216
3217#define MLXSW_REG_QEEC_ID 0x400D
3218#define MLXSW_REG_QEEC_LEN 0x1C
3219
3220MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
3221
3222
3223
3224
3225
3226
3227
3228MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
3229
3230enum mlxsw_reg_qeec_hr {
3231 MLXSW_REG_QEEC_HIERARCY_PORT,
3232 MLXSW_REG_QEEC_HIERARCY_GROUP,
3233 MLXSW_REG_QEEC_HIERARCY_SUBGROUP,
3234 MLXSW_REG_QEEC_HIERARCY_TC,
3235};
3236
3237
3238
3239
3240
3241
3242
3243
3244MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
3245
3246
3247
3248
3249
3250MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3251
3252
3253
3254
3255
3256
3257
3258MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3259
3260enum {
3261 MLXSW_REG_QEEC_BYTES_MODE,
3262 MLXSW_REG_QEEC_PACKETS_MODE,
3263};
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3275
3276
3277
3278
3279
3280
3281
3282
3283MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
3284
3285
3286#define MLXSW_REG_QEEC_MAS_DIS 200000000
3287
3288
3289
3290
3291
3292
3293
3294MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
3295
3296
3297
3298
3299
3300
3301
3302
3303MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
3304
3305
3306
3307
3308
3309
3310
3311
3312MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
3323
3324static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
3325 enum mlxsw_reg_qeec_hr hr, u8 index,
3326 u8 next_index)
3327{
3328 MLXSW_REG_ZERO(qeec, payload);
3329 mlxsw_reg_qeec_local_port_set(payload, local_port);
3330 mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
3331 mlxsw_reg_qeec_element_index_set(payload, index);
3332 mlxsw_reg_qeec_next_element_index_set(payload, next_index);
3333}
3334
3335
3336
3337
3338
3339#define MLXSW_REG_QRWE_ID 0x400F
3340#define MLXSW_REG_QRWE_LEN 0x08
3341
3342MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
3343
3344
3345
3346
3347
3348
3349
3350MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
3351
3352
3353
3354
3355
3356MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
3357
3358
3359
3360
3361
3362MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
3363
3364static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
3365 bool rewrite_pcp, bool rewrite_dscp)
3366{
3367 MLXSW_REG_ZERO(qrwe, payload);
3368 mlxsw_reg_qrwe_local_port_set(payload, local_port);
3369 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
3370 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
3371}
3372
3373
3374
3375
3376
3377#define MLXSW_REG_QPDSM_ID 0x4011
3378#define MLXSW_REG_QPDSM_BASE_LEN 0x04
3379#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4
3380#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
3381#define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
3382 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
3383 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
3384
3385MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
3386
3387
3388
3389
3390
3391MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
3392
3393
3394
3395
3396
3397MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
3398 MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
3399 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3400
3401
3402
3403
3404
3405
3406MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
3407 MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
3408 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3409
3410
3411
3412
3413
3414MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
3415 MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
3416 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3417
3418
3419
3420
3421
3422
3423MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
3424 MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
3425 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3426
3427
3428
3429
3430
3431MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
3432 MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
3433 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3434
3435
3436
3437
3438
3439
3440MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
3441 MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
3442 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
3443
3444static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
3445{
3446 MLXSW_REG_ZERO(qpdsm, payload);
3447 mlxsw_reg_qpdsm_local_port_set(payload, local_port);
3448}
3449
3450static inline void
3451mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
3452{
3453 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
3454 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
3455 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
3456 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
3457 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
3458 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
3459}
3460
3461
3462
3463
3464
3465
3466#define MLXSW_REG_QPDPM_ID 0x4013
3467#define MLXSW_REG_QPDPM_BASE_LEN 0x4
3468#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2
3469#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
3470#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
3471 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
3472 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
3473
3474MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
3475
3476
3477
3478
3479
3480MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
3481
3482
3483
3484
3485
3486
3487
3488MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
3489 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3490
3491
3492
3493
3494
3495MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
3496 MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
3497 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
3498
3499static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
3500{
3501 MLXSW_REG_ZERO(qpdpm, payload);
3502 mlxsw_reg_qpdpm_local_port_set(payload, local_port);
3503}
3504
3505static inline void
3506mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
3507{
3508 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
3509 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
3510}
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521#define MLXSW_REG_QTCTM_ID 0x401A
3522#define MLXSW_REG_QTCTM_LEN 0x08
3523
3524MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
3525
3526
3527
3528
3529
3530
3531MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
3532
3533
3534
3535
3536
3537
3538MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
3539
3540static inline void
3541mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
3542{
3543 MLXSW_REG_ZERO(qtctm, payload);
3544 mlxsw_reg_qtctm_local_port_set(payload, local_port);
3545 mlxsw_reg_qtctm_mc_set(payload, mc);
3546}
3547
3548
3549
3550
3551
3552#define MLXSW_REG_PMLP_ID 0x5002
3553#define MLXSW_REG_PMLP_LEN 0x40
3554
3555MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
3556
3557
3558
3559
3560
3561
3562MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
3563
3564
3565
3566
3567
3568MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
3569
3570
3571
3572
3573
3574
3575
3576
3577MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
3578
3579
3580
3581
3582
3583MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
3584
3585
3586
3587
3588
3589MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false);
3590
3591
3592
3593
3594
3595
3596MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false);
3597
3598static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
3599{
3600 MLXSW_REG_ZERO(pmlp, payload);
3601 mlxsw_reg_pmlp_local_port_set(payload, local_port);
3602}
3603
3604
3605
3606
3607
3608#define MLXSW_REG_PMTU_ID 0x5003
3609#define MLXSW_REG_PMTU_LEN 0x10
3610
3611MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
3612
3613
3614
3615
3616
3617MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
3618
3619
3620
3621
3622
3623
3624
3625
3626MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
3627
3628
3629
3630
3631
3632
3633
3634MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
3635
3636
3637
3638
3639
3640
3641
3642
3643MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
3644
3645static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
3646 u16 new_mtu)
3647{
3648 MLXSW_REG_ZERO(pmtu, payload);
3649 mlxsw_reg_pmtu_local_port_set(payload, local_port);
3650 mlxsw_reg_pmtu_max_mtu_set(payload, 0);
3651 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
3652 mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
3653}
3654
3655
3656
3657
3658
3659
3660
3661
3662#define MLXSW_REG_PTYS_ID 0x5004
3663#define MLXSW_REG_PTYS_LEN 0x40
3664
3665MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
3666
3667
3668
3669
3670
3671
3672
3673MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
3674
3675
3676
3677
3678
3679MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
3680
3681#define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
3682#define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
3683
3684
3685
3686
3687
3688
3689
3690
3691MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
3692
3693enum {
3694 MLXSW_REG_PTYS_AN_STATUS_NA,
3695 MLXSW_REG_PTYS_AN_STATUS_OK,
3696 MLXSW_REG_PTYS_AN_STATUS_FAIL,
3697};
3698
3699
3700
3701
3702
3703MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
3704
3705#define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
3706#define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
3707#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
3708#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
3709#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
3710#define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
3711#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
3712#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
3713#define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
3714#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
3715#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
3716#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
3717#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
3718#define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
3719#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
3720#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
3721#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
3722#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
3723#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
3724#define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
3725#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
3726#define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
3727#define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
3728#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
3729#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
3730#define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
3731#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
3732#define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
3733
3734
3735
3736
3737
3738MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
3739
3740
3741
3742
3743
3744MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
3745
3746#define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
3747#define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
3748#define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
3749#define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
3750#define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
3751#define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
3752
3753
3754
3755
3756
3757MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
3758
3759
3760
3761
3762
3763MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
3764
3765
3766
3767
3768
3769MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
3770
3771
3772
3773
3774
3775MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
3776
3777
3778
3779
3780
3781MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
3782
3783
3784
3785
3786
3787MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
3788
3789
3790
3791
3792
3793MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
3794
3795
3796
3797
3798
3799
3800MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
3801
3802static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
3803 u32 proto_admin, bool autoneg)
3804{
3805 MLXSW_REG_ZERO(ptys, payload);
3806 mlxsw_reg_ptys_local_port_set(payload, local_port);
3807 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
3808 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
3809 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
3810}
3811
3812static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
3813 u32 *p_eth_proto_cap,
3814 u32 *p_eth_proto_adm,
3815 u32 *p_eth_proto_oper)
3816{
3817 if (p_eth_proto_cap)
3818 *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
3819 if (p_eth_proto_adm)
3820 *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
3821 if (p_eth_proto_oper)
3822 *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
3823}
3824
3825static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
3826 u16 proto_admin, u16 link_width)
3827{
3828 MLXSW_REG_ZERO(ptys, payload);
3829 mlxsw_reg_ptys_local_port_set(payload, local_port);
3830 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
3831 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
3832 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
3833}
3834
3835static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
3836 u16 *p_ib_link_width_cap,
3837 u16 *p_ib_proto_oper,
3838 u16 *p_ib_link_width_oper)
3839{
3840 if (p_ib_proto_cap)
3841 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
3842 if (p_ib_link_width_cap)
3843 *p_ib_link_width_cap =
3844 mlxsw_reg_ptys_ib_link_width_cap_get(payload);
3845 if (p_ib_proto_oper)
3846 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
3847 if (p_ib_link_width_oper)
3848 *p_ib_link_width_oper =
3849 mlxsw_reg_ptys_ib_link_width_oper_get(payload);
3850}
3851
3852
3853
3854
3855
3856#define MLXSW_REG_PPAD_ID 0x5005
3857#define MLXSW_REG_PPAD_LEN 0x10
3858
3859MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
3860
3861
3862
3863
3864
3865
3866
3867MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
3868
3869
3870
3871
3872
3873MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
3874
3875
3876
3877
3878
3879
3880MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
3881
3882static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
3883 u8 local_port)
3884{
3885 MLXSW_REG_ZERO(ppad, payload);
3886 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
3887 mlxsw_reg_ppad_local_port_set(payload, local_port);
3888}
3889
3890
3891
3892
3893
3894#define MLXSW_REG_PAOS_ID 0x5006
3895#define MLXSW_REG_PAOS_LEN 0x10
3896
3897MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
3898
3899
3900
3901
3902
3903
3904
3905
3906MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
3907
3908
3909
3910
3911
3912MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
3934
3935
3936
3937
3938
3939MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
3940
3941
3942
3943
3944
3945
3946MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
3947
3948
3949
3950
3951
3952
3953
3954
3955MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
3956
3957static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
3958 enum mlxsw_port_admin_status status)
3959{
3960 MLXSW_REG_ZERO(paos, payload);
3961 mlxsw_reg_paos_swid_set(payload, 0);
3962 mlxsw_reg_paos_local_port_set(payload, local_port);
3963 mlxsw_reg_paos_admin_status_set(payload, status);
3964 mlxsw_reg_paos_oper_status_set(payload, 0);
3965 mlxsw_reg_paos_ase_set(payload, 1);
3966 mlxsw_reg_paos_ee_set(payload, 1);
3967 mlxsw_reg_paos_e_set(payload, 1);
3968}
3969
3970
3971
3972
3973
3974#define MLXSW_REG_PFCC_ID 0x5007
3975#define MLXSW_REG_PFCC_LEN 0x20
3976
3977MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
3978
3979
3980
3981
3982
3983MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
3984
3985
3986
3987
3988
3989
3990
3991MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
3992
3993
3994
3995
3996
3997
3998
3999
4000MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
4001
4002
4003
4004
4005
4006
4007
4008
4009MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
4022
4023
4024
4025
4026
4027
4028MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
4029
4030
4031
4032
4033
4034
4035MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
4036
4037
4038
4039
4040
4041
4042
4043MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
4044
4045
4046
4047
4048
4049
4050
4051MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
4064
4065
4066
4067
4068
4069
4070
4071MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
4072
4073
4074
4075
4076
4077
4078
4079MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
4080
4081
4082
4083
4084
4085
4086
4087
4088MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
4089
4090#define MLXSW_REG_PFCC_ALL_PRIO 0xFF
4091
4092static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
4093{
4094 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4095 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
4096 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
4097 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
4098}
4099
4100static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
4101{
4102 MLXSW_REG_ZERO(pfcc, payload);
4103 mlxsw_reg_pfcc_local_port_set(payload, local_port);
4104}
4105
4106
4107
4108
4109
4110#define MLXSW_REG_PPCNT_ID 0x5008
4111#define MLXSW_REG_PPCNT_LEN 0x100
4112#define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
4113
4114MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
4126
4127
4128
4129
4130
4131
4132
4133MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
4134
4135
4136
4137
4138
4139
4140
4141MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
4142
4143enum mlxsw_reg_ppcnt_grp {
4144 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
4145 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
4146 MLXSW_REG_PPCNT_EXT_CNT = 0x5,
4147 MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
4148 MLXSW_REG_PPCNT_TC_CNT = 0x11,
4149 MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
4150};
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
4169
4170
4171
4172
4173
4174
4175
4176MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
4187
4188
4189
4190
4191
4192
4193MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
4194 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4195
4196
4197
4198
4199MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
4200 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4201
4202
4203
4204
4205MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
4206 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
4207
4208
4209
4210
4211MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
4212 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
4213
4214
4215
4216
4217MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
4218 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
4219
4220
4221
4222
4223MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
4224 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
4225
4226
4227
4228
4229MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
4230 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
4231
4232
4233
4234
4235MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
4236 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
4237
4238
4239
4240
4241MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
4242 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
4243
4244
4245
4246
4247MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
4248 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
4249
4250
4251
4252
4253MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
4254 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
4255
4256
4257
4258
4259MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
4260 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4261
4262
4263
4264
4265MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
4266 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4267
4268
4269
4270
4271MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
4272 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4273
4274
4275
4276
4277MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
4278 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4279
4280
4281
4282
4283MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
4284 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4285
4286
4287
4288
4289MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
4290 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4291
4292
4293
4294
4295MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
4296 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4297
4298
4299
4300
4301MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
4302 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4303
4304
4305
4306
4307
4308
4309MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
4310 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4311
4312
4313
4314
4315MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
4316 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4317
4318
4319
4320
4321MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
4322 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4323
4324
4325
4326
4327MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
4328 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4329
4330
4331
4332
4333MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
4334 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
4335
4336
4337
4338
4339MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
4340 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
4341
4342
4343
4344
4345MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
4346 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
4347
4348
4349
4350
4351MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
4352 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
4353
4354
4355
4356
4357MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
4358 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
4359
4360
4361
4362
4363MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
4364 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
4365
4366
4367
4368
4369
4370
4371MLXSW_ITEM64(reg, ppcnt, ecn_marked,
4372 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4373
4374
4375
4376
4377
4378
4379MLXSW_ITEM64(reg, ppcnt, rx_octets,
4380 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4381
4382
4383
4384
4385MLXSW_ITEM64(reg, ppcnt, rx_frames,
4386 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
4387
4388
4389
4390
4391MLXSW_ITEM64(reg, ppcnt, tx_octets,
4392 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
4393
4394
4395
4396
4397MLXSW_ITEM64(reg, ppcnt, tx_frames,
4398 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
4399
4400
4401
4402
4403MLXSW_ITEM64(reg, ppcnt, rx_pause,
4404 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
4405
4406
4407
4408
4409MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
4410 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
4411
4412
4413
4414
4415MLXSW_ITEM64(reg, ppcnt, tx_pause,
4416 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
4417
4418
4419
4420
4421MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
4422 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
4423
4424
4425
4426
4427MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
4428 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
4439 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4440
4441
4442
4443
4444
4445
4446MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
4447 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
4448
4449
4450
4451
4452
4453
4454MLXSW_ITEM64(reg, ppcnt, wred_discard,
4455 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
4456
4457static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
4458 enum mlxsw_reg_ppcnt_grp grp,
4459 u8 prio_tc)
4460{
4461 MLXSW_REG_ZERO(ppcnt, payload);
4462 mlxsw_reg_ppcnt_swid_set(payload, 0);
4463 mlxsw_reg_ppcnt_local_port_set(payload, local_port);
4464 mlxsw_reg_ppcnt_pnat_set(payload, 0);
4465 mlxsw_reg_ppcnt_grp_set(payload, grp);
4466 mlxsw_reg_ppcnt_clr_set(payload, 0);
4467 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
4468}
4469
4470
4471
4472
4473
4474#define MLXSW_REG_PLIB_ID 0x500A
4475#define MLXSW_REG_PLIB_LEN 0x10
4476
4477MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
4478
4479
4480
4481
4482
4483MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
4484
4485
4486
4487
4488
4489MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
4490
4491
4492
4493
4494
4495#define MLXSW_REG_PPTB_ID 0x500B
4496#define MLXSW_REG_PPTB_LEN 0x10
4497
4498MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
4499
4500enum {
4501 MLXSW_REG_PPTB_MM_UM,
4502 MLXSW_REG_PPTB_MM_UNICAST,
4503 MLXSW_REG_PPTB_MM_MULTICAST,
4504};
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
4516
4517
4518
4519
4520
4521MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
4522
4523
4524
4525
4526
4527MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
4528
4529
4530
4531
4532
4533
4534MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
4535
4536
4537
4538
4539
4540
4541MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
4542
4543
4544
4545
4546
4547
4548MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
4549
4550
4551
4552
4553
4554
4555
4556
4557MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
4558
4559
4560
4561
4562
4563
4564MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
4565
4566#define MLXSW_REG_PPTB_ALL_PRIO 0xFF
4567
4568static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
4569{
4570 MLXSW_REG_ZERO(pptb, payload);
4571 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
4572 mlxsw_reg_pptb_local_port_set(payload, local_port);
4573 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
4574 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
4575}
4576
4577static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
4578 u8 buff)
4579{
4580 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
4581 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
4582}
4583
4584
4585
4586
4587
4588
4589#define MLXSW_REG_PBMC_ID 0x500C
4590#define MLXSW_REG_PBMC_LEN 0x6C
4591
4592MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
4593
4594
4595
4596
4597
4598MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
4599
4600
4601
4602
4603
4604
4605MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
4606
4607
4608
4609
4610
4611
4612
4613MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
4614
4615#define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
4616
4617
4618
4619
4620
4621
4622
4623MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
4624
4625
4626
4627
4628
4629
4630
4631
4632MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
4633
4634
4635
4636
4637
4638
4639MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
4651 0x08, 0x04, false);
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
4663 0x08, 0x04, false);
4664
4665static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
4666 u16 xoff_timer_value, u16 xoff_refresh)
4667{
4668 MLXSW_REG_ZERO(pbmc, payload);
4669 mlxsw_reg_pbmc_local_port_set(payload, local_port);
4670 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
4671 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
4672}
4673
4674static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
4675 int buf_index,
4676 u16 size)
4677{
4678 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
4679 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
4680 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
4681}
4682
4683static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
4684 int buf_index, u16 size,
4685 u16 threshold)
4686{
4687 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
4688 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
4689 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
4690 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
4691 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
4692}
4693
4694
4695
4696
4697
4698
4699#define MLXSW_REG_PSPA_ID 0x500D
4700#define MLXSW_REG_PSPA_LEN 0x8
4701
4702MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
4703
4704
4705
4706
4707
4708MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
4709
4710
4711
4712
4713
4714MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
4715
4716
4717
4718
4719
4720
4721MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
4722
4723static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
4724{
4725 MLXSW_REG_ZERO(pspa, payload);
4726 mlxsw_reg_pspa_swid_set(payload, swid);
4727 mlxsw_reg_pspa_local_port_set(payload, local_port);
4728 mlxsw_reg_pspa_sub_port_set(payload, 0);
4729}
4730
4731
4732
4733
4734
4735#define MLXSW_REG_HTGT_ID 0x7002
4736#define MLXSW_REG_HTGT_LEN 0x20
4737
4738MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
4739
4740
4741
4742
4743
4744MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
4745
4746#define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0
4747
4748
4749
4750
4751
4752MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
4753
4754enum mlxsw_reg_htgt_trap_group {
4755 MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
4756 MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX,
4757 MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL,
4758 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
4759 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
4760 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
4761 MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP,
4762 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
4763 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
4764 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
4765 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
4766 MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP,
4767 MLXSW_REG_HTGT_TRAP_GROUP_SP_HOST_MISS,
4768 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
4769 MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
4770 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
4771 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
4772 MLXSW_REG_HTGT_TRAP_GROUP_SP_RPF,
4773 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
4774 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_MLD,
4775 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_ND,
4776};
4777
4778
4779
4780
4781
4782
4783
4784MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
4785
4786enum {
4787 MLXSW_REG_HTGT_POLICER_DISABLE,
4788 MLXSW_REG_HTGT_POLICER_ENABLE,
4789};
4790
4791
4792
4793
4794
4795MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
4796
4797#define MLXSW_REG_HTGT_INVALID_POLICER 0xff
4798
4799
4800
4801
4802
4803MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
4804
4805#define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
4817
4818
4819
4820
4821
4822MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
4823
4824#define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
4838
4839#define MLXSW_REG_HTGT_DEFAULT_TC 7
4840
4841
4842
4843
4844
4845MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
4846
4847enum mlxsw_reg_htgt_local_path_rdq {
4848 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
4849 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
4850 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
4851 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
4852};
4853
4854
4855
4856
4857MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
4858
4859static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
4860 u8 priority, u8 tc)
4861{
4862 MLXSW_REG_ZERO(htgt, payload);
4863
4864 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
4865 mlxsw_reg_htgt_pide_set(payload,
4866 MLXSW_REG_HTGT_POLICER_DISABLE);
4867 } else {
4868 mlxsw_reg_htgt_pide_set(payload,
4869 MLXSW_REG_HTGT_POLICER_ENABLE);
4870 mlxsw_reg_htgt_pid_set(payload, policer_id);
4871 }
4872
4873 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
4874 mlxsw_reg_htgt_trap_group_set(payload, group);
4875 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
4876 mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
4877 mlxsw_reg_htgt_priority_set(payload, priority);
4878 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
4879 mlxsw_reg_htgt_local_path_rdq_set(payload, group);
4880}
4881
4882
4883
4884
4885
4886#define MLXSW_REG_HPKT_ID 0x7003
4887#define MLXSW_REG_HPKT_LEN 0x10
4888
4889MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
4890
4891enum {
4892 MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
4893 MLXSW_REG_HPKT_ACK_REQUIRED,
4894};
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
4905
4906enum mlxsw_reg_hpkt_action {
4907 MLXSW_REG_HPKT_ACTION_FORWARD,
4908 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
4909 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
4910 MLXSW_REG_HPKT_ACTION_DISCARD,
4911 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
4912 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
4913};
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
4929
4930
4931
4932
4933
4934MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
4935
4936
4937
4938
4939
4940
4941
4942
4943MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
4944
4945enum {
4946 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
4947 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
4948 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
4949};
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
4960
4961static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
4962 enum mlxsw_reg_htgt_trap_group trap_group,
4963 bool is_ctrl)
4964{
4965 MLXSW_REG_ZERO(hpkt, payload);
4966 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
4967 mlxsw_reg_hpkt_action_set(payload, action);
4968 mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
4969 mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
4970 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
4971 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
4972 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
4973}
4974
4975
4976
4977
4978
4979#define MLXSW_REG_RGCR_ID 0x8001
4980#define MLXSW_REG_RGCR_LEN 0x28
4981
4982MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
4983
4984
4985
4986
4987
4988MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
4989
4990
4991
4992
4993
4994MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
4995
4996
4997
4998
4999
5000
5001MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
5039
5040static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
5041 bool ipv6_en)
5042{
5043 MLXSW_REG_ZERO(rgcr, payload);
5044 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
5045 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
5046}
5047
5048
5049
5050
5051
5052#define MLXSW_REG_RITR_ID 0x8002
5053#define MLXSW_REG_RITR_LEN 0x40
5054
5055MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
5056
5057
5058
5059
5060
5061MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
5062
5063
5064
5065
5066
5067
5068MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
5069
5070
5071
5072
5073
5074
5075MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
5076
5077
5078
5079
5080
5081MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
5082
5083
5084
5085
5086
5087MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
5088
5089enum mlxsw_reg_ritr_if_type {
5090
5091 MLXSW_REG_RITR_VLAN_IF,
5092
5093 MLXSW_REG_RITR_FID_IF,
5094
5095 MLXSW_REG_RITR_SP_IF,
5096
5097 MLXSW_REG_RITR_LOOPBACK_IF,
5098};
5099
5100
5101
5102
5103
5104MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
5105
5106enum {
5107 MLXSW_REG_RITR_RIF_CREATE,
5108 MLXSW_REG_RITR_RIF_DEL,
5109};
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
5121
5122
5123
5124
5125
5126MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
5127
5128
5129
5130
5131
5132
5133
5134
5135MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
5136
5137
5138
5139
5140
5141
5142
5143
5144MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
5145
5146
5147
5148
5149
5150
5151
5152MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
5153
5154
5155
5156
5157
5158
5159
5160MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
5161
5162
5163
5164
5165
5166
5167
5168
5169MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
5170
5171
5172
5173
5174
5175MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
5176
5177
5178
5179
5180
5181MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
5182
5183
5184
5185
5186
5187MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
5188
5189
5190
5191
5192
5193
5194MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
5195
5196
5197
5198
5199
5200
5201MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
5202
5203
5204
5205
5206
5207
5208MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
5209
5210
5211
5212
5213
5214
5215
5216MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
5217
5218
5219
5220
5221
5222
5223
5224
5225MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
5226
5227static inline void mlxsw_reg_ritr_fid_set(char *payload,
5228 enum mlxsw_reg_ritr_if_type rif_type,
5229 u16 fid)
5230{
5231 if (rif_type == MLXSW_REG_RITR_FID_IF)
5232 mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
5233 else
5234 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
5235}
5236
5237
5238
5239
5240
5241
5242
5243
5244MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
5245
5246
5247
5248
5249
5250
5251MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
5252
5253
5254
5255
5256
5257MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
5258
5259
5260
5261enum mlxsw_reg_ritr_loopback_protocol {
5262
5263 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
5264
5265 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
5266};
5267
5268
5269
5270
5271MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
5272
5273enum mlxsw_reg_ritr_loopback_ipip_type {
5274
5275 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
5276
5277 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
5278
5279 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
5280};
5281
5282
5283
5284
5285
5286MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
5287
5288enum mlxsw_reg_ritr_loopback_ipip_options {
5289
5290 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
5291};
5292
5293
5294
5295
5296MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
5297
5298
5299
5300
5301
5302
5303
5304MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
5305
5306
5307
5308
5309
5310MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
5311MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
5312
5313
5314
5315
5316
5317
5318MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
5319
5320
5321enum mlxsw_reg_ritr_counter_set_type {
5322
5323 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
5324
5325
5326
5327
5328
5329
5330 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
5331};
5332
5333
5334
5335
5336
5337MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
5338
5339
5340
5341
5342
5343MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
5344
5345
5346
5347
5348
5349MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
5350
5351
5352
5353
5354
5355MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
5356
5357static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
5358 bool enable, bool egress)
5359{
5360 enum mlxsw_reg_ritr_counter_set_type set_type;
5361
5362 if (enable)
5363 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
5364 else
5365 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
5366 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
5367
5368 if (egress)
5369 mlxsw_reg_ritr_egress_counter_index_set(payload, index);
5370 else
5371 mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
5372}
5373
5374static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
5375{
5376 MLXSW_REG_ZERO(ritr, payload);
5377 mlxsw_reg_ritr_rif_set(payload, rif);
5378}
5379
5380static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
5381 u16 system_port, u16 vid)
5382{
5383 mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
5384 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
5385 mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
5386}
5387
5388static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
5389 enum mlxsw_reg_ritr_if_type type,
5390 u16 rif, u16 vr_id, u16 mtu)
5391{
5392 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
5393
5394 MLXSW_REG_ZERO(ritr, payload);
5395 mlxsw_reg_ritr_enable_set(payload, enable);
5396 mlxsw_reg_ritr_ipv4_set(payload, 1);
5397 mlxsw_reg_ritr_ipv6_set(payload, 1);
5398 mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
5399 mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
5400 mlxsw_reg_ritr_type_set(payload, type);
5401 mlxsw_reg_ritr_op_set(payload, op);
5402 mlxsw_reg_ritr_rif_set(payload, rif);
5403 mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
5404 mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
5405 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
5406 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
5407 mlxsw_reg_ritr_lb_en_set(payload, 1);
5408 mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
5409 mlxsw_reg_ritr_mtu_set(payload, mtu);
5410}
5411
5412static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
5413{
5414 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
5415}
5416
5417static inline void
5418mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
5419 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
5420 enum mlxsw_reg_ritr_loopback_ipip_options options,
5421 u16 uvr_id, u32 gre_key)
5422{
5423 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
5424 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
5425 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
5426 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
5427}
5428
5429static inline void
5430mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
5431 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
5432 enum mlxsw_reg_ritr_loopback_ipip_options options,
5433 u16 uvr_id, u32 usip, u32 gre_key)
5434{
5435 mlxsw_reg_ritr_loopback_protocol_set(payload,
5436 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
5437 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
5438 uvr_id, gre_key);
5439 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
5440}
5441
5442
5443
5444
5445
5446#define MLXSW_REG_RTAR_ID 0x8004
5447#define MLXSW_REG_RTAR_LEN 0x20
5448
5449MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
5450
5451enum mlxsw_reg_rtar_op {
5452 MLXSW_REG_RTAR_OP_ALLOCATE,
5453 MLXSW_REG_RTAR_OP_RESIZE,
5454 MLXSW_REG_RTAR_OP_DEALLOCATE,
5455};
5456
5457
5458
5459
5460MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
5461
5462enum mlxsw_reg_rtar_key_type {
5463 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
5464 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
5465};
5466
5467
5468
5469
5470
5471MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
5472
5473
5474
5475
5476
5477
5478
5479
5480MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
5481
5482static inline void mlxsw_reg_rtar_pack(char *payload,
5483 enum mlxsw_reg_rtar_op op,
5484 enum mlxsw_reg_rtar_key_type key_type,
5485 u16 region_size)
5486{
5487 MLXSW_REG_ZERO(rtar, payload);
5488 mlxsw_reg_rtar_op_set(payload, op);
5489 mlxsw_reg_rtar_key_type_set(payload, key_type);
5490 mlxsw_reg_rtar_region_size_set(payload, region_size);
5491}
5492
5493
5494
5495
5496
5497
5498#define MLXSW_REG_RATR_ID 0x8008
5499#define MLXSW_REG_RATR_LEN 0x2C
5500
5501MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
5502
5503enum mlxsw_reg_ratr_op {
5504
5505 MLXSW_REG_RATR_OP_QUERY_READ = 0,
5506
5507 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
5508
5509 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
5510
5511
5512
5513
5514
5515
5516 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
5517};
5518
5519
5520
5521
5522
5523
5524
5525MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
5540
5541
5542
5543
5544
5545
5546MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
5547
5548enum mlxsw_reg_ratr_type {
5549
5550 MLXSW_REG_RATR_TYPE_ETHERNET,
5551
5552
5553
5554 MLXSW_REG_RATR_TYPE_IPOIB_UC,
5555
5556
5557
5558
5559 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
5560
5561
5562
5563 MLXSW_REG_RATR_TYPE_IPOIB_MC,
5564
5565
5566
5567 MLXSW_REG_RATR_TYPE_MPLS,
5568
5569
5570
5571 MLXSW_REG_RATR_TYPE_IPIP,
5572};
5573
5574
5575
5576
5577
5578MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
5579
5580
5581
5582
5583
5584
5585
5586
5587MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
5588
5589
5590
5591
5592
5593MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
5594
5595enum mlxsw_reg_ratr_trap_action {
5596 MLXSW_REG_RATR_TRAP_ACTION_NOP,
5597 MLXSW_REG_RATR_TRAP_ACTION_TRAP,
5598 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
5599 MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
5600 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
5601};
5602
5603
5604
5605
5606
5607MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
5608
5609
5610
5611
5612
5613MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
5614
5615enum mlxsw_reg_ratr_trap_id {
5616 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
5617 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
5618};
5619
5620
5621
5622
5623
5624
5625
5626MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
5627
5628
5629
5630
5631
5632MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
5633
5634enum mlxsw_reg_ratr_ipip_type {
5635
5636 MLXSW_REG_RATR_IPIP_TYPE_IPV4,
5637
5638 MLXSW_REG_RATR_IPIP_TYPE_IPV6,
5639};
5640
5641
5642
5643
5644
5645
5646MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
5647
5648
5649
5650
5651
5652
5653MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
5654
5655
5656
5657
5658
5659
5660MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
5661
5662enum mlxsw_reg_flow_counter_set_type {
5663
5664 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
5665
5666 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
5667
5668 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
5669};
5670
5671
5672
5673
5674
5675MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
5676
5677
5678
5679
5680
5681MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
5682
5683static inline void
5684mlxsw_reg_ratr_pack(char *payload,
5685 enum mlxsw_reg_ratr_op op, bool valid,
5686 enum mlxsw_reg_ratr_type type,
5687 u32 adjacency_index, u16 egress_rif)
5688{
5689 MLXSW_REG_ZERO(ratr, payload);
5690 mlxsw_reg_ratr_op_set(payload, op);
5691 mlxsw_reg_ratr_v_set(payload, valid);
5692 mlxsw_reg_ratr_type_set(payload, type);
5693 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
5694 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
5695 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
5696}
5697
5698static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
5699 const char *dest_mac)
5700{
5701 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
5702}
5703
5704static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
5705{
5706 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
5707 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
5708}
5709
5710static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
5711 bool counter_enable)
5712{
5713 enum mlxsw_reg_flow_counter_set_type set_type;
5714
5715 if (counter_enable)
5716 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
5717 else
5718 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
5719
5720 mlxsw_reg_ratr_counter_index_set(payload, counter_index);
5721 mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
5722}
5723
5724
5725
5726
5727
5728#define MLXSW_REG_RDPM_ID 0x8009
5729#define MLXSW_REG_RDPM_BASE_LEN 0x00
5730#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
5731#define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
5732#define MLXSW_REG_RDPM_LEN 0x40
5733#define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
5734 MLXSW_REG_RDPM_LEN - \
5735 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
5736
5737MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
5738
5739
5740
5741
5742
5743MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
5744 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
5745
5746
5747
5748
5749
5750MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
5751 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
5752
5753static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
5754 u8 prio)
5755{
5756 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
5757 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
5758}
5759
5760
5761
5762
5763
5764#define MLXSW_REG_RICNT_ID 0x800B
5765#define MLXSW_REG_RICNT_LEN 0x100
5766
5767MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
5768
5769
5770
5771
5772
5773MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
5774
5775enum mlxsw_reg_ricnt_counter_set_type {
5776
5777 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
5778
5779
5780
5781
5782
5783
5784 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
5785};
5786
5787
5788
5789
5790
5791MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
5792
5793enum mlxsw_reg_ricnt_opcode {
5794
5795 MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
5796
5797
5798
5799 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
5800};
5801
5802
5803
5804
5805
5806MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
5807
5808
5809
5810
5811
5812MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
5813
5814
5815
5816
5817
5818MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
5819
5820
5821
5822
5823
5824MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
5825
5826
5827
5828
5829
5830
5831MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
5832
5833
5834
5835
5836
5837
5838MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
5839
5840
5841
5842
5843
5844
5845MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
5846
5847
5848
5849
5850
5851MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
5852
5853
5854
5855
5856
5857MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
5858
5859
5860
5861
5862
5863
5864MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
5865
5866
5867
5868
5869
5870
5871MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
5872
5873static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
5874 enum mlxsw_reg_ricnt_opcode op)
5875{
5876 MLXSW_REG_ZERO(ricnt, payload);
5877 mlxsw_reg_ricnt_op_set(payload, op);
5878 mlxsw_reg_ricnt_counter_index_set(payload, index);
5879 mlxsw_reg_ricnt_counter_set_type_set(payload,
5880 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
5881}
5882
5883
5884
5885
5886
5887#define MLXSW_REG_RRCR_ID 0x800F
5888#define MLXSW_REG_RRCR_LEN 0x24
5889
5890MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
5891
5892enum mlxsw_reg_rrcr_op {
5893
5894 MLXSW_REG_RRCR_OP_MOVE,
5895
5896 MLXSW_REG_RRCR_OP_COPY,
5897};
5898
5899
5900
5901
5902MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
5903
5904
5905
5906
5907
5908MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
5909
5910
5911
5912
5913
5914MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
5915
5916
5917
5918
5919
5920
5921MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
5922
5923
5924
5925
5926
5927MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
5928
5929static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
5930 u16 offset, u16 size,
5931 enum mlxsw_reg_rtar_key_type table_id,
5932 u16 dest_offset)
5933{
5934 MLXSW_REG_ZERO(rrcr, payload);
5935 mlxsw_reg_rrcr_op_set(payload, op);
5936 mlxsw_reg_rrcr_offset_set(payload, offset);
5937 mlxsw_reg_rrcr_size_set(payload, size);
5938 mlxsw_reg_rrcr_table_id_set(payload, table_id);
5939 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
5940}
5941
5942
5943
5944
5945
5946#define MLXSW_REG_RALTA_ID 0x8010
5947#define MLXSW_REG_RALTA_LEN 0x04
5948
5949MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
5950
5951
5952
5953
5954
5955
5956
5957MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
5958
5959enum mlxsw_reg_ralxx_protocol {
5960 MLXSW_REG_RALXX_PROTOCOL_IPV4,
5961 MLXSW_REG_RALXX_PROTOCOL_IPV6,
5962};
5963
5964
5965
5966
5967
5968
5969MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
5970
5971
5972
5973
5974
5975
5976
5977MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
5978
5979static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
5980 enum mlxsw_reg_ralxx_protocol protocol,
5981 u8 tree_id)
5982{
5983 MLXSW_REG_ZERO(ralta, payload);
5984 mlxsw_reg_ralta_op_set(payload, !alloc);
5985 mlxsw_reg_ralta_protocol_set(payload, protocol);
5986 mlxsw_reg_ralta_tree_id_set(payload, tree_id);
5987}
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998#define MLXSW_REG_RALST_ID 0x8011
5999#define MLXSW_REG_RALST_LEN 0x104
6000
6001MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
6002
6003
6004
6005
6006
6007
6008
6009MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
6010
6011
6012
6013
6014
6015MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
6016
6017#define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
6018#define MLXSW_REG_RALST_BIN_OFFSET 0x04
6019#define MLXSW_REG_RALST_BIN_COUNT 128
6020
6021
6022
6023
6024
6025
6026
6027MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
6028
6029
6030
6031
6032
6033
6034
6035MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
6036 false);
6037
6038static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
6039{
6040 MLXSW_REG_ZERO(ralst, payload);
6041
6042
6043 memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
6044 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
6045
6046 mlxsw_reg_ralst_root_bin_set(payload, root_bin);
6047 mlxsw_reg_ralst_tree_id_set(payload, tree_id);
6048}
6049
6050static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
6051 u8 left_child_bin,
6052 u8 right_child_bin)
6053{
6054 int bin_index = bin_number - 1;
6055
6056 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
6057 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
6058 right_child_bin);
6059}
6060
6061
6062
6063
6064
6065#define MLXSW_REG_RALTB_ID 0x8012
6066#define MLXSW_REG_RALTB_LEN 0x04
6067
6068MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
6069
6070
6071
6072
6073
6074
6075MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
6076
6077
6078
6079
6080
6081MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
6082
6083
6084
6085
6086
6087
6088
6089MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
6090
6091static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
6092 enum mlxsw_reg_ralxx_protocol protocol,
6093 u8 tree_id)
6094{
6095 MLXSW_REG_ZERO(raltb, payload);
6096 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
6097 mlxsw_reg_raltb_protocol_set(payload, protocol);
6098 mlxsw_reg_raltb_tree_id_set(payload, tree_id);
6099}
6100
6101
6102
6103
6104
6105
6106#define MLXSW_REG_RALUE_ID 0x8013
6107#define MLXSW_REG_RALUE_LEN 0x38
6108
6109MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
6110
6111
6112
6113
6114
6115MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
6116
6117enum mlxsw_reg_ralue_op {
6118
6119 MLXSW_REG_RALUE_OP_QUERY_READ = 0,
6120
6121
6122
6123 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
6124
6125
6126
6127
6128 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
6129
6130
6131
6132
6133 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
6134
6135
6136
6137 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
6138
6139
6140
6141 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
6142};
6143
6144
6145
6146
6147
6148MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
6149
6150
6151
6152
6153
6154
6155
6156
6157MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
6158
6159
6160
6161
6162
6163
6164MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
6165
6166#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
6167#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
6168#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
6169
6170
6171
6172
6173
6174
6175
6176
6177MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
6178
6179
6180
6181
6182
6183
6184
6185MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
6196MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
6197
6198enum mlxsw_reg_ralue_entry_type {
6199 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
6200 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
6201 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
6202};
6203
6204
6205
6206
6207
6208
6209MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
6220
6221enum mlxsw_reg_ralue_action_type {
6222 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
6223 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
6224 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
6225};
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
6237
6238enum mlxsw_reg_ralue_trap_action {
6239 MLXSW_REG_RALUE_TRAP_ACTION_NOP,
6240 MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
6241 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
6242 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
6243 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
6244};
6245
6246
6247
6248
6249
6250
6251MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
6252
6253
6254
6255
6256
6257
6258
6259MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
6260
6261
6262
6263
6264
6265
6266MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
6277
6278
6279
6280
6281
6282
6283MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
6296
6297
6298
6299
6300
6301
6302
6303MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
6304
6305static inline void mlxsw_reg_ralue_pack(char *payload,
6306 enum mlxsw_reg_ralxx_protocol protocol,
6307 enum mlxsw_reg_ralue_op op,
6308 u16 virtual_router, u8 prefix_len)
6309{
6310 MLXSW_REG_ZERO(ralue, payload);
6311 mlxsw_reg_ralue_protocol_set(payload, protocol);
6312 mlxsw_reg_ralue_op_set(payload, op);
6313 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
6314 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
6315 mlxsw_reg_ralue_entry_type_set(payload,
6316 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
6317 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
6318}
6319
6320static inline void mlxsw_reg_ralue_pack4(char *payload,
6321 enum mlxsw_reg_ralxx_protocol protocol,
6322 enum mlxsw_reg_ralue_op op,
6323 u16 virtual_router, u8 prefix_len,
6324 u32 dip)
6325{
6326 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
6327 mlxsw_reg_ralue_dip4_set(payload, dip);
6328}
6329
6330static inline void mlxsw_reg_ralue_pack6(char *payload,
6331 enum mlxsw_reg_ralxx_protocol protocol,
6332 enum mlxsw_reg_ralue_op op,
6333 u16 virtual_router, u8 prefix_len,
6334 const void *dip)
6335{
6336 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
6337 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
6338}
6339
6340static inline void
6341mlxsw_reg_ralue_act_remote_pack(char *payload,
6342 enum mlxsw_reg_ralue_trap_action trap_action,
6343 u16 trap_id, u32 adjacency_index, u16 ecmp_size)
6344{
6345 mlxsw_reg_ralue_action_type_set(payload,
6346 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
6347 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
6348 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
6349 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
6350 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
6351}
6352
6353static inline void
6354mlxsw_reg_ralue_act_local_pack(char *payload,
6355 enum mlxsw_reg_ralue_trap_action trap_action,
6356 u16 trap_id, u16 local_erif)
6357{
6358 mlxsw_reg_ralue_action_type_set(payload,
6359 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
6360 mlxsw_reg_ralue_trap_action_set(payload, trap_action);
6361 mlxsw_reg_ralue_trap_id_set(payload, trap_id);
6362 mlxsw_reg_ralue_local_erif_set(payload, local_erif);
6363}
6364
6365static inline void
6366mlxsw_reg_ralue_act_ip2me_pack(char *payload)
6367{
6368 mlxsw_reg_ralue_action_type_set(payload,
6369 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
6370}
6371
6372static inline void
6373mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
6374{
6375 mlxsw_reg_ralue_action_type_set(payload,
6376 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
6377 mlxsw_reg_ralue_ip2me_v_set(payload, 1);
6378 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
6379}
6380
6381
6382
6383
6384
6385
6386#define MLXSW_REG_RAUHT_ID 0x8014
6387#define MLXSW_REG_RAUHT_LEN 0x74
6388
6389MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
6390
6391enum mlxsw_reg_rauht_type {
6392 MLXSW_REG_RAUHT_TYPE_IPV4,
6393 MLXSW_REG_RAUHT_TYPE_IPV6,
6394};
6395
6396
6397
6398
6399MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
6400
6401enum mlxsw_reg_rauht_op {
6402 MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
6403
6404 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
6405
6406
6407
6408 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
6409
6410
6411
6412 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
6413
6414
6415
6416
6417 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
6418
6419 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
6420
6421 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
6422
6423
6424
6425};
6426
6427
6428
6429
6430MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
6431
6432
6433
6434
6435
6436
6437
6438
6439MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
6440
6441
6442
6443
6444
6445MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
6446
6447
6448
6449
6450
6451MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
6452MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
6453
6454enum mlxsw_reg_rauht_trap_action {
6455 MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
6456 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
6457 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
6458 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
6459 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
6460};
6461
6462
6463
6464
6465MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
6466
6467enum mlxsw_reg_rauht_trap_id {
6468 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
6469 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
6470};
6471
6472
6473
6474
6475
6476
6477
6478
6479MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
6480
6481
6482
6483
6484
6485MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
6486
6487
6488
6489
6490
6491MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
6492
6493
6494
6495
6496
6497MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
6498
6499static inline void mlxsw_reg_rauht_pack(char *payload,
6500 enum mlxsw_reg_rauht_op op, u16 rif,
6501 const char *mac)
6502{
6503 MLXSW_REG_ZERO(rauht, payload);
6504 mlxsw_reg_rauht_op_set(payload, op);
6505 mlxsw_reg_rauht_rif_set(payload, rif);
6506 mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
6507}
6508
6509static inline void mlxsw_reg_rauht_pack4(char *payload,
6510 enum mlxsw_reg_rauht_op op, u16 rif,
6511 const char *mac, u32 dip)
6512{
6513 mlxsw_reg_rauht_pack(payload, op, rif, mac);
6514 mlxsw_reg_rauht_dip4_set(payload, dip);
6515}
6516
6517static inline void mlxsw_reg_rauht_pack6(char *payload,
6518 enum mlxsw_reg_rauht_op op, u16 rif,
6519 const char *mac, const char *dip)
6520{
6521 mlxsw_reg_rauht_pack(payload, op, rif, mac);
6522 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
6523 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
6524}
6525
6526static inline void mlxsw_reg_rauht_pack_counter(char *payload,
6527 u64 counter_index)
6528{
6529 mlxsw_reg_rauht_counter_index_set(payload, counter_index);
6530 mlxsw_reg_rauht_counter_set_type_set(payload,
6531 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
6532}
6533
6534
6535
6536
6537
6538
6539
6540#define MLXSW_REG_RALEU_ID 0x8015
6541#define MLXSW_REG_RALEU_LEN 0x28
6542
6543MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
6544
6545
6546
6547
6548
6549MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
6550
6551
6552
6553
6554
6555
6556MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
6557
6558
6559
6560
6561
6562MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
6563
6564
6565
6566
6567
6568MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
6569
6570
6571
6572
6573
6574MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
6575
6576
6577
6578
6579
6580MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
6581
6582static inline void mlxsw_reg_raleu_pack(char *payload,
6583 enum mlxsw_reg_ralxx_protocol protocol,
6584 u16 virtual_router,
6585 u32 adjacency_index, u16 ecmp_size,
6586 u32 new_adjacency_index,
6587 u16 new_ecmp_size)
6588{
6589 MLXSW_REG_ZERO(raleu, payload);
6590 mlxsw_reg_raleu_protocol_set(payload, protocol);
6591 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
6592 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
6593 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
6594 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
6595 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
6596}
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607#define MLXSW_REG_RAUHTD_ID 0x8018
6608#define MLXSW_REG_RAUHTD_BASE_LEN 0x20
6609#define MLXSW_REG_RAUHTD_REC_LEN 0x20
6610#define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
6611#define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
6612 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
6613#define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
6614
6615MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
6616
6617#define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
6618#define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
6619
6620
6621
6622
6623
6624
6625
6626
6627MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
6628
6629enum mlxsw_reg_rauhtd_op {
6630 MLXSW_REG_RAUHTD_OP_DUMP,
6631 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
6632};
6633
6634
6635
6636
6637MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
6648
6649
6650
6651
6652
6653
6654MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
6655
6656enum mlxsw_reg_rauhtd_type {
6657 MLXSW_REG_RAUHTD_TYPE_IPV4,
6658 MLXSW_REG_RAUHTD_TYPE_IPV6,
6659};
6660
6661
6662
6663
6664
6665
6666
6667MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
6668
6669
6670
6671
6672
6673
6674MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
6675
6676static inline void mlxsw_reg_rauhtd_pack(char *payload,
6677 enum mlxsw_reg_rauhtd_type type)
6678{
6679 MLXSW_REG_ZERO(rauhtd, payload);
6680 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
6681 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
6682 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
6683 mlxsw_reg_rauhtd_entry_a_set(payload, 1);
6684 mlxsw_reg_rauhtd_type_set(payload, type);
6685}
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
6696 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
6697 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
6698
6699
6700
6701
6702
6703
6704
6705MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
6706 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
6707
6708#define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
6709
6710
6711
6712
6713
6714
6715MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
6716 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
6717
6718
6719
6720
6721
6722MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6723 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
6724
6725
6726
6727
6728
6729MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6730 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
6731
6732#define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
6733
6734
6735
6736
6737
6738
6739MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
6740 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
6741
6742
6743
6744
6745
6746MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
6747 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
6748
6749
6750
6751
6752
6753MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
6754 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
6755
6756static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
6757 int ent_index, u16 *p_rif,
6758 u32 *p_dip)
6759{
6760 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
6761 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
6762}
6763
6764static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
6765 int rec_index, u16 *p_rif,
6766 char *p_dip)
6767{
6768 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
6769 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
6770}
6771
6772
6773
6774
6775
6776
6777#define MLXSW_REG_RTDP_ID 0x8020
6778#define MLXSW_REG_RTDP_LEN 0x44
6779
6780MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
6781
6782enum mlxsw_reg_rtdp_type {
6783 MLXSW_REG_RTDP_TYPE_NVE,
6784 MLXSW_REG_RTDP_TYPE_IPIP,
6785};
6786
6787
6788
6789
6790
6791MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
6792
6793
6794
6795
6796
6797
6798MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
6799
6800
6801
6802
6803
6804
6805
6806MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
6807
6808enum mlxsw_reg_rtdp_ipip_sip_check {
6809
6810 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
6811
6812
6813
6814 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
6815
6816
6817
6818 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
6819};
6820
6821
6822
6823
6824
6825
6826MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
6827
6828
6829#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
6830
6831#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
6832
6833#define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
6834
6835
6836
6837
6838
6839
6840MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
6852
6853
6854
6855
6856
6857
6858MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
6859
6860
6861
6862
6863
6864
6865
6866
6867MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
6868
6869
6870
6871
6872
6873
6874MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
6875
6876static inline void mlxsw_reg_rtdp_pack(char *payload,
6877 enum mlxsw_reg_rtdp_type type,
6878 u32 tunnel_index)
6879{
6880 MLXSW_REG_ZERO(rtdp, payload);
6881 mlxsw_reg_rtdp_type_set(payload, type);
6882 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
6883}
6884
6885static inline void
6886mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
6887 enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
6888 unsigned int type_check, bool gre_key_check,
6889 u32 ipv4_usip, u32 expected_gre_key)
6890{
6891 mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
6892 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
6893 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
6894 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
6895 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
6896 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
6897}
6898
6899
6900
6901
6902
6903
6904#define MLXSW_REG_RIGR2_ID 0x8023
6905#define MLXSW_REG_RIGR2_LEN 0xB0
6906
6907#define MLXSW_REG_RIGR2_MAX_ERIFS 32
6908
6909MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
6910
6911
6912
6913
6914
6915MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
6916
6917
6918
6919
6920
6921MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
6922
6923
6924
6925
6926
6927
6928MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
6929
6930
6931
6932
6933
6934MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
6935
6936
6937
6938
6939
6940
6941
6942
6943MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
6954
6955
6956
6957
6958
6959
6960
6961MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
6962
6963static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
6964 bool vnext, u32 next_rigr_index)
6965{
6966 MLXSW_REG_ZERO(rigr2, payload);
6967 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
6968 mlxsw_reg_rigr2_vnext_set(payload, vnext);
6969 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
6970 mlxsw_reg_rigr2_vrmid_set(payload, 0);
6971 mlxsw_reg_rigr2_rmid_index_set(payload, 0);
6972}
6973
6974static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
6975 bool v, u16 erif)
6976{
6977 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
6978 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
6979}
6980
6981
6982
6983
6984#define MLXSW_REG_RECR2_ID 0x8025
6985#define MLXSW_REG_RECR2_LEN 0x38
6986
6987MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
6988
6989
6990
6991
6992
6993MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
6994
6995
6996
6997
6998
6999MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
7000
7001
7002
7003
7004
7005MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
7006
7007enum {
7008
7009 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
7010
7011 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
7012
7013 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
7014
7015 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
7016
7017 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
7018
7019 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
7020};
7021
7022
7023
7024
7025
7026
7027MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
7028
7029enum {
7030
7031 MLXSW_REG_RECR2_IPV4_SIP0 = 9,
7032 MLXSW_REG_RECR2_IPV4_SIP3 = 12,
7033
7034 MLXSW_REG_RECR2_IPV4_DIP0 = 13,
7035 MLXSW_REG_RECR2_IPV4_DIP3 = 16,
7036
7037 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
7038
7039 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
7040 MLXSW_REG_RECR2_IPV6_SIP8 = 29,
7041 MLXSW_REG_RECR2_IPV6_SIP15 = 36,
7042
7043 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
7044 MLXSW_REG_RECR2_IPV6_DIP8 = 45,
7045 MLXSW_REG_RECR2_IPV6_DIP15 = 52,
7046
7047 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
7048
7049 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
7050
7051 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
7052
7053 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
7054};
7055
7056
7057
7058
7059
7060MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
7061
7062static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
7063{
7064 int i;
7065
7066 for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
7067 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7068 true);
7069}
7070
7071static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
7072{
7073 int i;
7074
7075 for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
7076 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7077 true);
7078}
7079
7080static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
7081{
7082 int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
7083
7084 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7085
7086 i = MLXSW_REG_RECR2_IPV6_SIP8;
7087 for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
7088 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7089 true);
7090}
7091
7092static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
7093{
7094 int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
7095
7096 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
7097
7098 i = MLXSW_REG_RECR2_IPV6_DIP8;
7099 for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
7100 mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
7101 true);
7102}
7103
7104static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
7105{
7106 MLXSW_REG_ZERO(recr2, payload);
7107 mlxsw_reg_recr2_pp_set(payload, false);
7108 mlxsw_reg_recr2_sh_set(payload, true);
7109 mlxsw_reg_recr2_seed_set(payload, seed);
7110}
7111
7112
7113
7114
7115
7116#define MLXSW_REG_RMFT2_ID 0x8027
7117#define MLXSW_REG_RMFT2_LEN 0x174
7118
7119MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
7120
7121
7122
7123
7124
7125MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
7126
7127enum mlxsw_reg_rmft2_type {
7128 MLXSW_REG_RMFT2_TYPE_IPV4,
7129 MLXSW_REG_RMFT2_TYPE_IPV6
7130};
7131
7132
7133
7134
7135MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
7136
7137enum mlxsw_sp_reg_rmft2_op {
7138
7139
7140
7141
7142
7143
7144
7145 MLXSW_REG_RMFT2_OP_READ_WRITE,
7146};
7147
7148
7149
7150
7151
7152MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
7153
7154
7155
7156
7157
7158
7159MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
7160
7161
7162
7163
7164
7165MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
7166
7167
7168
7169
7170
7171MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
7172
7173enum mlxsw_reg_rmft2_irif_mask {
7174 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
7175 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
7176};
7177
7178
7179
7180
7181
7182MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
7183
7184
7185
7186
7187
7188MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
7189
7190
7191
7192
7193
7194MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
7195MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
7196
7197
7198
7199
7200
7201
7202MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
7203MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
7204
7205
7206
7207
7208
7209MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
7210MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
7211
7212
7213
7214
7215
7216
7217MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
7218MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
7232 MLXSW_REG_FLEX_ACTION_SET_LEN);
7233
7234static inline void
7235mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
7236 u16 virtual_router,
7237 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7238 const char *flex_action_set)
7239{
7240 MLXSW_REG_ZERO(rmft2, payload);
7241 mlxsw_reg_rmft2_v_set(payload, v);
7242 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
7243 mlxsw_reg_rmft2_offset_set(payload, offset);
7244 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
7245 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
7246 mlxsw_reg_rmft2_irif_set(payload, irif);
7247 if (flex_action_set)
7248 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
7249 flex_action_set);
7250}
7251
7252static inline void
7253mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
7254 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7255 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
7256 const char *flexible_action_set)
7257{
7258 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
7259 irif_mask, irif, flexible_action_set);
7260 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
7261 mlxsw_reg_rmft2_dip4_set(payload, dip4);
7262 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
7263 mlxsw_reg_rmft2_sip4_set(payload, sip4);
7264 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
7265}
7266
7267static inline void
7268mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
7269 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
7270 struct in6_addr dip6, struct in6_addr dip6_mask,
7271 struct in6_addr sip6, struct in6_addr sip6_mask,
7272 const char *flexible_action_set)
7273{
7274 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
7275 irif_mask, irif, flexible_action_set);
7276 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
7277 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
7278 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
7279 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
7280 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
7281}
7282
7283
7284
7285
7286
7287#define MLXSW_REG_MFCR_ID 0x9001
7288#define MLXSW_REG_MFCR_LEN 0x08
7289
7290MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
7291
7292enum mlxsw_reg_mfcr_pwm_frequency {
7293 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
7294 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
7295 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
7296 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
7297 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
7298 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
7299 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
7300 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
7301};
7302
7303
7304
7305
7306
7307MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
7308
7309#define MLXSW_MFCR_TACHOS_MAX 10
7310
7311
7312
7313
7314
7315MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
7316
7317#define MLXSW_MFCR_PWMS_MAX 5
7318
7319
7320
7321
7322
7323MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
7324
7325static inline void
7326mlxsw_reg_mfcr_pack(char *payload,
7327 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
7328{
7329 MLXSW_REG_ZERO(mfcr, payload);
7330 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
7331}
7332
7333static inline void
7334mlxsw_reg_mfcr_unpack(char *payload,
7335 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
7336 u16 *p_tacho_active, u8 *p_pwm_active)
7337{
7338 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
7339 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
7340 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
7341}
7342
7343
7344
7345
7346
7347#define MLXSW_REG_MFSC_ID 0x9002
7348#define MLXSW_REG_MFSC_LEN 0x08
7349
7350MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
7351
7352
7353
7354
7355
7356MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
7357
7358
7359
7360
7361
7362
7363MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
7364
7365static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
7366 u8 pwm_duty_cycle)
7367{
7368 MLXSW_REG_ZERO(mfsc, payload);
7369 mlxsw_reg_mfsc_pwm_set(payload, pwm);
7370 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
7371}
7372
7373
7374
7375
7376
7377
7378#define MLXSW_REG_MFSM_ID 0x9003
7379#define MLXSW_REG_MFSM_LEN 0x08
7380
7381MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
7382
7383
7384
7385
7386
7387MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
7388
7389
7390
7391
7392
7393MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
7394
7395static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
7396{
7397 MLXSW_REG_ZERO(mfsm, payload);
7398 mlxsw_reg_mfsm_tacho_set(payload, tacho);
7399}
7400
7401
7402
7403
7404
7405
7406
7407#define MLXSW_REG_MFSL_ID 0x9004
7408#define MLXSW_REG_MFSL_LEN 0x0C
7409
7410MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
7411
7412
7413
7414
7415
7416MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
7417
7418
7419
7420
7421
7422MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
7423
7424
7425
7426
7427
7428MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
7429
7430static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
7431 u16 tach_min, u16 tach_max)
7432{
7433 MLXSW_REG_ZERO(mfsl, payload);
7434 mlxsw_reg_mfsl_tacho_set(payload, tacho);
7435 mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
7436 mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
7437}
7438
7439static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
7440 u16 *p_tach_min, u16 *p_tach_max)
7441{
7442 if (p_tach_min)
7443 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
7444
7445 if (p_tach_max)
7446 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
7447}
7448
7449
7450
7451
7452
7453
7454#define MLXSW_REG_MTCAP_ID 0x9009
7455#define MLXSW_REG_MTCAP_LEN 0x08
7456
7457MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
7458
7459
7460
7461
7462
7463
7464MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
7465
7466
7467
7468
7469
7470
7471
7472#define MLXSW_REG_MTMP_ID 0x900A
7473#define MLXSW_REG_MTMP_LEN 0x20
7474
7475MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
7476
7477
7478
7479
7480
7481
7482
7483MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
7484
7485
7486#define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
7487
7488
7489
7490
7491
7492
7493MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
7494
7495
7496
7497
7498
7499MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
7500
7501
7502
7503
7504
7505MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
7506
7507
7508
7509
7510
7511
7512MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
7513
7514
7515
7516
7517
7518
7519
7520
7521MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
7522
7523#define MLXSW_REG_MTMP_THRESH_HI 0x348
7524
7525
7526
7527
7528
7529MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
7530
7531
7532
7533
7534
7535MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
7536
7537#define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
7538
7539
7540
7541
7542
7543MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
7544
7545static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
7546 bool max_temp_enable,
7547 bool max_temp_reset)
7548{
7549 MLXSW_REG_ZERO(mtmp, payload);
7550 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
7551 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
7552 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
7553 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
7554 MLXSW_REG_MTMP_THRESH_HI);
7555}
7556
7557static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
7558 unsigned int *p_max_temp,
7559 char *sensor_name)
7560{
7561 u16 temp;
7562
7563 if (p_temp) {
7564 temp = mlxsw_reg_mtmp_temperature_get(payload);
7565 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
7566 }
7567 if (p_max_temp) {
7568 temp = mlxsw_reg_mtmp_max_temperature_get(payload);
7569 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
7570 }
7571 if (sensor_name)
7572 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
7573}
7574
7575
7576
7577
7578
7579
7580#define MLXSW_REG_MCIA_ID 0x9014
7581#define MLXSW_REG_MCIA_LEN 0x40
7582
7583MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
7584
7585
7586
7587
7588
7589
7590
7591MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
7592
7593
7594
7595
7596
7597MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
7598
7599
7600
7601
7602
7603MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
7604
7605
7606
7607
7608
7609MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
7610
7611
7612
7613
7614
7615MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
7616
7617
7618
7619
7620
7621MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
7622
7623
7624
7625
7626
7627MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
7628
7629#define MLXSW_SP_REG_MCIA_EEPROM_SIZE 48
7630
7631
7632
7633
7634
7635MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_SP_REG_MCIA_EEPROM_SIZE);
7636
7637static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
7638 u8 page_number, u16 device_addr,
7639 u8 size, u8 i2c_device_addr)
7640{
7641 MLXSW_REG_ZERO(mcia, payload);
7642 mlxsw_reg_mcia_module_set(payload, module);
7643 mlxsw_reg_mcia_l_set(payload, lock);
7644 mlxsw_reg_mcia_page_number_set(payload, page_number);
7645 mlxsw_reg_mcia_device_address_set(payload, device_addr);
7646 mlxsw_reg_mcia_size_set(payload, size);
7647 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
7648}
7649
7650
7651
7652
7653
7654
7655#define MLXSW_REG_MPAT_ID 0x901A
7656#define MLXSW_REG_MPAT_LEN 0x78
7657
7658MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
7659
7660
7661
7662
7663
7664MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
7665
7666
7667
7668
7669
7670MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
7671
7672
7673
7674
7675
7676MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
7698
7699enum mlxsw_reg_mpat_span_type {
7700
7701
7702
7703 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
7704
7705
7706
7707
7708
7709 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
7710
7711
7712
7713
7714 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
7715};
7716
7717
7718
7719
7720
7721MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
7732
7733
7734
7735
7736
7737enum mlxsw_reg_mpat_eth_rspan_version {
7738 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
7739};
7740
7741
7742
7743
7744
7745MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
7746
7747
7748
7749
7750
7751MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
7752
7753
7754
7755
7756
7757MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
7758
7759
7760
7761
7762
7763enum mlxsw_reg_mpat_eth_rspan_protocol {
7764 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
7765 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
7766};
7767
7768
7769
7770
7771
7772MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
7773
7774
7775
7776
7777
7778MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
7779
7780
7781
7782
7783
7784MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
7785
7786
7787
7788
7789
7790MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
7791MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
7792
7793
7794
7795
7796
7797MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
7798MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
7799
7800static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
7801 u16 system_port, bool e,
7802 enum mlxsw_reg_mpat_span_type span_type)
7803{
7804 MLXSW_REG_ZERO(mpat, payload);
7805 mlxsw_reg_mpat_pa_id_set(payload, pa_id);
7806 mlxsw_reg_mpat_system_port_set(payload, system_port);
7807 mlxsw_reg_mpat_e_set(payload, e);
7808 mlxsw_reg_mpat_qos_set(payload, 1);
7809 mlxsw_reg_mpat_be_set(payload, 1);
7810 mlxsw_reg_mpat_span_type_set(payload, span_type);
7811}
7812
7813static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
7814{
7815 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
7816}
7817
7818static inline void
7819mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
7820 enum mlxsw_reg_mpat_eth_rspan_version version,
7821 const char *mac,
7822 bool tp)
7823{
7824 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
7825 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
7826 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
7827}
7828
7829static inline void
7830mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
7831 const char *smac,
7832 u32 sip, u32 dip)
7833{
7834 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
7835 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
7836 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
7837 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
7838 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
7839 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
7840}
7841
7842static inline void
7843mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
7844 const char *smac,
7845 struct in6_addr sip, struct in6_addr dip)
7846{
7847 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
7848 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
7849 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
7850 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
7851 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
7852 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
7853}
7854
7855
7856
7857
7858
7859
7860#define MLXSW_REG_MPAR_ID 0x901B
7861#define MLXSW_REG_MPAR_LEN 0x08
7862
7863MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
7864
7865
7866
7867
7868
7869MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
7870
7871enum mlxsw_reg_mpar_i_e {
7872 MLXSW_REG_MPAR_TYPE_EGRESS,
7873 MLXSW_REG_MPAR_TYPE_INGRESS,
7874};
7875
7876
7877
7878
7879
7880MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
7881
7882
7883
7884
7885
7886
7887MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
7888
7889
7890
7891
7892
7893MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
7894
7895static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
7896 enum mlxsw_reg_mpar_i_e i_e,
7897 bool enable, u8 pa_id)
7898{
7899 MLXSW_REG_ZERO(mpar, payload);
7900 mlxsw_reg_mpar_local_port_set(payload, local_port);
7901 mlxsw_reg_mpar_enable_set(payload, enable);
7902 mlxsw_reg_mpar_i_e_set(payload, i_e);
7903 mlxsw_reg_mpar_pa_id_set(payload, pa_id);
7904}
7905
7906
7907
7908
7909
7910
7911#define MLXSW_REG_MRSR_ID 0x9023
7912#define MLXSW_REG_MRSR_LEN 0x08
7913
7914MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
7915
7916
7917
7918
7919
7920
7921
7922MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
7923
7924static inline void mlxsw_reg_mrsr_pack(char *payload)
7925{
7926 MLXSW_REG_ZERO(mrsr, payload);
7927 mlxsw_reg_mrsr_command_set(payload, 1);
7928}
7929
7930
7931
7932
7933
7934#define MLXSW_REG_MLCR_ID 0x902B
7935#define MLXSW_REG_MLCR_LEN 0x0C
7936
7937MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
7938
7939
7940
7941
7942
7943MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
7944
7945#define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
7946
7947
7948
7949
7950
7951
7952
7953MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
7954
7955
7956
7957
7958
7959
7960MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
7961
7962static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
7963 bool active)
7964{
7965 MLXSW_REG_ZERO(mlcr, payload);
7966 mlxsw_reg_mlcr_local_port_set(payload, local_port);
7967 mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
7968 MLXSW_REG_MLCR_DURATION_MAX : 0);
7969}
7970
7971
7972
7973
7974
7975#define MLXSW_REG_MCQI_ID 0x9061
7976#define MLXSW_REG_MCQI_BASE_LEN 0x18
7977#define MLXSW_REG_MCQI_CAP_LEN 0x14
7978#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
7979
7980MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
7981
7982
7983
7984
7985
7986MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
7987
7988enum mlxfw_reg_mcqi_info_type {
7989 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
7990};
7991
7992
7993
7994
7995
7996MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
7997
7998
7999
8000
8001
8002
8003MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
8004
8005
8006
8007
8008
8009
8010MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
8011
8012
8013
8014
8015
8016MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
8017
8018
8019
8020
8021
8022
8023MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
8024
8025
8026
8027
8028
8029MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
8030
8031static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
8032{
8033 MLXSW_REG_ZERO(mcqi, payload);
8034 mlxsw_reg_mcqi_component_index_set(payload, component_index);
8035 mlxsw_reg_mcqi_info_type_set(payload,
8036 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
8037 mlxsw_reg_mcqi_offset_set(payload, 0);
8038 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
8039}
8040
8041static inline void mlxsw_reg_mcqi_unpack(char *payload,
8042 u32 *p_cap_max_component_size,
8043 u8 *p_cap_log_mcda_word_size,
8044 u16 *p_cap_mcda_max_write_size)
8045{
8046 *p_cap_max_component_size =
8047 mlxsw_reg_mcqi_cap_max_component_size_get(payload);
8048 *p_cap_log_mcda_word_size =
8049 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
8050 *p_cap_mcda_max_write_size =
8051 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
8052}
8053
8054
8055
8056
8057
8058#define MLXSW_REG_MCC_ID 0x9062
8059#define MLXSW_REG_MCC_LEN 0x1C
8060
8061MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
8062
8063enum mlxsw_reg_mcc_instruction {
8064 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
8065 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
8066 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
8067 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
8068 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
8069 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
8070};
8071
8072
8073
8074
8075
8076
8077MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
8078
8079
8080
8081
8082
8083
8084MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
8085
8086
8087
8088
8089
8090MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
8091
8092
8093
8094
8095
8096
8097MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
8098
8099
8100
8101
8102
8103MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
8104
8105
8106
8107
8108
8109
8110
8111MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
8112
8113static inline void mlxsw_reg_mcc_pack(char *payload,
8114 enum mlxsw_reg_mcc_instruction instr,
8115 u16 component_index, u32 update_handle,
8116 u32 component_size)
8117{
8118 MLXSW_REG_ZERO(mcc, payload);
8119 mlxsw_reg_mcc_instruction_set(payload, instr);
8120 mlxsw_reg_mcc_component_index_set(payload, component_index);
8121 mlxsw_reg_mcc_update_handle_set(payload, update_handle);
8122 mlxsw_reg_mcc_component_size_set(payload, component_size);
8123}
8124
8125static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
8126 u8 *p_error_code, u8 *p_control_state)
8127{
8128 if (p_update_handle)
8129 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
8130 if (p_error_code)
8131 *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
8132 if (p_control_state)
8133 *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
8134}
8135
8136
8137
8138
8139
8140#define MLXSW_REG_MCDA_ID 0x9063
8141#define MLXSW_REG_MCDA_BASE_LEN 0x10
8142#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
8143#define MLXSW_REG_MCDA_LEN \
8144 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
8145
8146MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
8147
8148
8149
8150
8151
8152MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
8153
8154
8155
8156
8157
8158
8159MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
8160
8161
8162
8163
8164
8165MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
8166
8167
8168
8169
8170
8171MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
8172
8173static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
8174 u32 offset, u16 size, u8 *data)
8175{
8176 int i;
8177
8178 MLXSW_REG_ZERO(mcda, payload);
8179 mlxsw_reg_mcda_update_handle_set(payload, update_handle);
8180 mlxsw_reg_mcda_offset_set(payload, offset);
8181 mlxsw_reg_mcda_size_set(payload, size);
8182
8183 for (i = 0; i < size / 4; i++)
8184 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
8185}
8186
8187
8188
8189
8190
8191#define MLXSW_REG_MPSC_ID 0x9080
8192#define MLXSW_REG_MPSC_LEN 0x1C
8193
8194MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
8195
8196
8197
8198
8199
8200
8201MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
8202
8203
8204
8205
8206
8207MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
8208
8209#define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
8210
8211
8212
8213
8214
8215
8216MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
8217
8218static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
8219 u32 rate)
8220{
8221 MLXSW_REG_ZERO(mpsc, payload);
8222 mlxsw_reg_mpsc_local_port_set(payload, local_port);
8223 mlxsw_reg_mpsc_e_set(payload, e);
8224 mlxsw_reg_mpsc_rate_set(payload, rate);
8225}
8226
8227
8228
8229
8230#define MLXSW_REG_MGPC_ID 0x9081
8231#define MLXSW_REG_MGPC_LEN 0x18
8232
8233MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
8234
8235
8236
8237
8238
8239MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
8240
8241
8242
8243
8244
8245MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
8246
8247enum mlxsw_reg_mgpc_opcode {
8248
8249 MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
8250
8251 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
8252};
8253
8254
8255
8256
8257
8258MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
8259
8260
8261
8262
8263
8264MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
8265
8266
8267
8268
8269
8270MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
8271
8272static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
8273 enum mlxsw_reg_mgpc_opcode opcode,
8274 enum mlxsw_reg_flow_counter_set_type set_type)
8275{
8276 MLXSW_REG_ZERO(mgpc, payload);
8277 mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
8278 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
8279 mlxsw_reg_mgpc_opcode_set(payload, opcode);
8280}
8281
8282
8283
8284
8285
8286#define MLXSW_REG_TIGCR_ID 0xA801
8287#define MLXSW_REG_TIGCR_LEN 0x10
8288
8289MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
8290
8291
8292
8293
8294
8295
8296MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
8297
8298
8299
8300
8301
8302
8303MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
8304
8305static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
8306{
8307 MLXSW_REG_ZERO(tigcr, payload);
8308 mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
8309 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
8310}
8311
8312
8313
8314
8315
8316#define MLXSW_REG_SBPR_ID 0xB001
8317#define MLXSW_REG_SBPR_LEN 0x14
8318
8319MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
8320
8321
8322enum mlxsw_reg_sbxx_dir {
8323 MLXSW_REG_SBXX_DIR_INGRESS,
8324 MLXSW_REG_SBXX_DIR_EGRESS,
8325};
8326
8327
8328
8329
8330
8331MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
8332
8333
8334
8335
8336
8337MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
8338
8339
8340
8341
8342
8343MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
8344
8345enum mlxsw_reg_sbpr_mode {
8346 MLXSW_REG_SBPR_MODE_STATIC,
8347 MLXSW_REG_SBPR_MODE_DYNAMIC,
8348};
8349
8350
8351
8352
8353
8354MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
8355
8356static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
8357 enum mlxsw_reg_sbxx_dir dir,
8358 enum mlxsw_reg_sbpr_mode mode, u32 size)
8359{
8360 MLXSW_REG_ZERO(sbpr, payload);
8361 mlxsw_reg_sbpr_pool_set(payload, pool);
8362 mlxsw_reg_sbpr_dir_set(payload, dir);
8363 mlxsw_reg_sbpr_mode_set(payload, mode);
8364 mlxsw_reg_sbpr_size_set(payload, size);
8365}
8366
8367
8368
8369
8370
8371
8372
8373#define MLXSW_REG_SBCM_ID 0xB002
8374#define MLXSW_REG_SBCM_LEN 0x28
8375
8376MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
8377
8378
8379
8380
8381
8382
8383
8384MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
8395
8396
8397
8398
8399
8400MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
8401
8402
8403
8404
8405
8406MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
8407
8408
8409#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
8410#define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
8424
8425
8426
8427
8428
8429MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
8430
8431static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
8432 enum mlxsw_reg_sbxx_dir dir,
8433 u32 min_buff, u32 max_buff, u8 pool)
8434{
8435 MLXSW_REG_ZERO(sbcm, payload);
8436 mlxsw_reg_sbcm_local_port_set(payload, local_port);
8437 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
8438 mlxsw_reg_sbcm_dir_set(payload, dir);
8439 mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
8440 mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
8441 mlxsw_reg_sbcm_pool_set(payload, pool);
8442}
8443
8444
8445
8446
8447
8448
8449
8450#define MLXSW_REG_SBPM_ID 0xB003
8451#define MLXSW_REG_SBPM_LEN 0x28
8452
8453MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
8454
8455
8456
8457
8458
8459
8460
8461MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
8462
8463
8464
8465
8466
8467MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
8468
8469
8470
8471
8472
8473MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
8474
8475
8476
8477
8478
8479MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
8480
8481
8482
8483
8484
8485
8486
8487MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
8488
8489
8490
8491
8492
8493
8494MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
8495
8496
8497
8498
8499
8500MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
8514
8515static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
8516 enum mlxsw_reg_sbxx_dir dir, bool clr,
8517 u32 min_buff, u32 max_buff)
8518{
8519 MLXSW_REG_ZERO(sbpm, payload);
8520 mlxsw_reg_sbpm_local_port_set(payload, local_port);
8521 mlxsw_reg_sbpm_pool_set(payload, pool);
8522 mlxsw_reg_sbpm_dir_set(payload, dir);
8523 mlxsw_reg_sbpm_clr_set(payload, clr);
8524 mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
8525 mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
8526}
8527
8528static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
8529 u32 *p_max_buff_occupancy)
8530{
8531 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
8532 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
8533}
8534
8535
8536
8537
8538
8539
8540
8541#define MLXSW_REG_SBMM_ID 0xB004
8542#define MLXSW_REG_SBMM_LEN 0x28
8543
8544MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
8545
8546
8547
8548
8549
8550MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
8551
8552
8553
8554
8555
8556MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
8570
8571
8572
8573
8574
8575MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
8576
8577static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
8578 u32 max_buff, u8 pool)
8579{
8580 MLXSW_REG_ZERO(sbmm, payload);
8581 mlxsw_reg_sbmm_prio_set(payload, prio);
8582 mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
8583 mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
8584 mlxsw_reg_sbmm_pool_set(payload, pool);
8585}
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595#define MLXSW_REG_SBSR_ID 0xB005
8596#define MLXSW_REG_SBSR_BASE_LEN 0x5C
8597#define MLXSW_REG_SBSR_REC_LEN 0x8
8598#define MLXSW_REG_SBSR_REC_MAX_COUNT 120
8599#define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
8600 MLXSW_REG_SBSR_REC_LEN * \
8601 MLXSW_REG_SBSR_REC_MAX_COUNT)
8602
8603MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
8604
8605
8606
8607
8608
8609
8610
8611MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
8612
8613
8614
8615
8616
8617
8618
8619
8620MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
8631
8632
8633
8634
8635
8636
8637
8638
8639MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
8650
8651static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
8652{
8653 MLXSW_REG_ZERO(sbsr, payload);
8654 mlxsw_reg_sbsr_clr_set(payload, clr);
8655}
8656
8657
8658
8659
8660
8661MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
8662 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
8663
8664
8665
8666
8667
8668
8669MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
8670 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
8671
8672static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
8673 u32 *p_buff_occupancy,
8674 u32 *p_max_buff_occupancy)
8675{
8676 *p_buff_occupancy =
8677 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
8678 *p_max_buff_occupancy =
8679 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
8680}
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690#define MLXSW_REG_SBIB_ID 0xB006
8691#define MLXSW_REG_SBIB_LEN 0x10
8692
8693MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
8694
8695
8696
8697
8698
8699
8700MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
8701
8702
8703
8704
8705
8706
8707
8708MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
8709
8710static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
8711 u32 buff_size)
8712{
8713 MLXSW_REG_ZERO(sbib, payload);
8714 mlxsw_reg_sbib_local_port_set(payload, local_port);
8715 mlxsw_reg_sbib_buff_size_set(payload, buff_size);
8716}
8717
8718static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
8719 MLXSW_REG(sgcr),
8720 MLXSW_REG(spad),
8721 MLXSW_REG(smid),
8722 MLXSW_REG(sspr),
8723 MLXSW_REG(sfdat),
8724 MLXSW_REG(sfd),
8725 MLXSW_REG(sfn),
8726 MLXSW_REG(spms),
8727 MLXSW_REG(spvid),
8728 MLXSW_REG(spvm),
8729 MLXSW_REG(spaft),
8730 MLXSW_REG(sfgc),
8731 MLXSW_REG(sftr),
8732 MLXSW_REG(sfdf),
8733 MLXSW_REG(sldr),
8734 MLXSW_REG(slcr),
8735 MLXSW_REG(slcor),
8736 MLXSW_REG(spmlr),
8737 MLXSW_REG(svfa),
8738 MLXSW_REG(svpe),
8739 MLXSW_REG(sfmr),
8740 MLXSW_REG(spvmlr),
8741 MLXSW_REG(cwtp),
8742 MLXSW_REG(cwtpm),
8743 MLXSW_REG(pgcr),
8744 MLXSW_REG(ppbt),
8745 MLXSW_REG(pacl),
8746 MLXSW_REG(pagt),
8747 MLXSW_REG(ptar),
8748 MLXSW_REG(ppbs),
8749 MLXSW_REG(prcr),
8750 MLXSW_REG(pefa),
8751 MLXSW_REG(ptce2),
8752 MLXSW_REG(perpt),
8753 MLXSW_REG(perar),
8754 MLXSW_REG(ptce3),
8755 MLXSW_REG(percr),
8756 MLXSW_REG(pererp),
8757 MLXSW_REG(iedr),
8758 MLXSW_REG(qpts),
8759 MLXSW_REG(qpcr),
8760 MLXSW_REG(qtct),
8761 MLXSW_REG(qeec),
8762 MLXSW_REG(qrwe),
8763 MLXSW_REG(qpdsm),
8764 MLXSW_REG(qpdpm),
8765 MLXSW_REG(qtctm),
8766 MLXSW_REG(pmlp),
8767 MLXSW_REG(pmtu),
8768 MLXSW_REG(ptys),
8769 MLXSW_REG(ppad),
8770 MLXSW_REG(paos),
8771 MLXSW_REG(pfcc),
8772 MLXSW_REG(ppcnt),
8773 MLXSW_REG(plib),
8774 MLXSW_REG(pptb),
8775 MLXSW_REG(pbmc),
8776 MLXSW_REG(pspa),
8777 MLXSW_REG(htgt),
8778 MLXSW_REG(hpkt),
8779 MLXSW_REG(rgcr),
8780 MLXSW_REG(ritr),
8781 MLXSW_REG(rtar),
8782 MLXSW_REG(ratr),
8783 MLXSW_REG(rtdp),
8784 MLXSW_REG(rdpm),
8785 MLXSW_REG(ricnt),
8786 MLXSW_REG(rrcr),
8787 MLXSW_REG(ralta),
8788 MLXSW_REG(ralst),
8789 MLXSW_REG(raltb),
8790 MLXSW_REG(ralue),
8791 MLXSW_REG(rauht),
8792 MLXSW_REG(raleu),
8793 MLXSW_REG(rauhtd),
8794 MLXSW_REG(rigr2),
8795 MLXSW_REG(recr2),
8796 MLXSW_REG(rmft2),
8797 MLXSW_REG(mfcr),
8798 MLXSW_REG(mfsc),
8799 MLXSW_REG(mfsm),
8800 MLXSW_REG(mfsl),
8801 MLXSW_REG(mtcap),
8802 MLXSW_REG(mtmp),
8803 MLXSW_REG(mcia),
8804 MLXSW_REG(mpat),
8805 MLXSW_REG(mpar),
8806 MLXSW_REG(mrsr),
8807 MLXSW_REG(mlcr),
8808 MLXSW_REG(mpsc),
8809 MLXSW_REG(mcqi),
8810 MLXSW_REG(mcc),
8811 MLXSW_REG(mcda),
8812 MLXSW_REG(mgpc),
8813 MLXSW_REG(tigcr),
8814 MLXSW_REG(sbpr),
8815 MLXSW_REG(sbcm),
8816 MLXSW_REG(sbpm),
8817 MLXSW_REG(sbmm),
8818 MLXSW_REG(sbsr),
8819 MLXSW_REG(sbib),
8820};
8821
8822static inline const char *mlxsw_reg_id_str(u16 reg_id)
8823{
8824 const struct mlxsw_reg_info *reg_info;
8825 int i;
8826
8827 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
8828 reg_info = mlxsw_reg_infos[i];
8829 if (reg_info->id == reg_id)
8830 return reg_info->name;
8831 }
8832 return "*UNKNOWN*";
8833}
8834
8835
8836
8837
8838
8839#define MLXSW_REG_PUDE_LEN 0x10
8840
8841
8842
8843
8844
8845MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
8846
8847
8848
8849
8850
8851MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
8873
8874#endif
8875