1
2
3
4
5
6#include <linux/kernel.h>
7#include <linux/errno.h>
8#include <linux/fsl/mc.h>
9#include "dpni.h"
10#include "dpni-cmd.h"
11
12
13
14
15
16
17
18
19
20
21int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, u8 *key_cfg_buf)
22{
23 int i, j;
24 struct dpni_ext_set_rx_tc_dist *dpni_ext;
25 struct dpni_dist_extract *extr;
26
27 if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS)
28 return -EINVAL;
29
30 dpni_ext = (struct dpni_ext_set_rx_tc_dist *)key_cfg_buf;
31 dpni_ext->num_extracts = cfg->num_extracts;
32
33 for (i = 0; i < cfg->num_extracts; i++) {
34 extr = &dpni_ext->extracts[i];
35
36 switch (cfg->extracts[i].type) {
37 case DPKG_EXTRACT_FROM_HDR:
38 extr->prot = cfg->extracts[i].extract.from_hdr.prot;
39 dpni_set_field(extr->efh_type, EFH_TYPE,
40 cfg->extracts[i].extract.from_hdr.type);
41 extr->size = cfg->extracts[i].extract.from_hdr.size;
42 extr->offset = cfg->extracts[i].extract.from_hdr.offset;
43 extr->field = cpu_to_le32(
44 cfg->extracts[i].extract.from_hdr.field);
45 extr->hdr_index =
46 cfg->extracts[i].extract.from_hdr.hdr_index;
47 break;
48 case DPKG_EXTRACT_FROM_DATA:
49 extr->size = cfg->extracts[i].extract.from_data.size;
50 extr->offset =
51 cfg->extracts[i].extract.from_data.offset;
52 break;
53 case DPKG_EXTRACT_FROM_PARSE:
54 extr->size = cfg->extracts[i].extract.from_parse.size;
55 extr->offset =
56 cfg->extracts[i].extract.from_parse.offset;
57 break;
58 default:
59 return -EINVAL;
60 }
61
62 extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks;
63 dpni_set_field(extr->extract_type, EXTRACT_TYPE,
64 cfg->extracts[i].type);
65
66 for (j = 0; j < DPKG_NUM_OF_MASKS; j++) {
67 extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
68 extr->masks[j].offset =
69 cfg->extracts[i].masks[j].offset;
70 }
71 }
72
73 return 0;
74}
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93int dpni_open(struct fsl_mc_io *mc_io,
94 u32 cmd_flags,
95 int dpni_id,
96 u16 *token)
97{
98 struct fsl_mc_command cmd = { 0 };
99 struct dpni_cmd_open *cmd_params;
100
101 int err;
102
103
104 cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
105 cmd_flags,
106 0);
107 cmd_params = (struct dpni_cmd_open *)cmd.params;
108 cmd_params->dpni_id = cpu_to_le32(dpni_id);
109
110
111 err = mc_send_command(mc_io, &cmd);
112 if (err)
113 return err;
114
115
116 *token = mc_cmd_hdr_read_token(&cmd);
117
118 return 0;
119}
120
121
122
123
124
125
126
127
128
129
130
131
132int dpni_close(struct fsl_mc_io *mc_io,
133 u32 cmd_flags,
134 u16 token)
135{
136 struct fsl_mc_command cmd = { 0 };
137
138
139 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
140 cmd_flags,
141 token);
142
143
144 return mc_send_command(mc_io, &cmd);
145}
146
147
148
149
150
151
152
153
154
155
156
157
158
159int dpni_set_pools(struct fsl_mc_io *mc_io,
160 u32 cmd_flags,
161 u16 token,
162 const struct dpni_pools_cfg *cfg)
163{
164 struct fsl_mc_command cmd = { 0 };
165 struct dpni_cmd_set_pools *cmd_params;
166 int i;
167
168
169 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS,
170 cmd_flags,
171 token);
172 cmd_params = (struct dpni_cmd_set_pools *)cmd.params;
173 cmd_params->num_dpbp = cfg->num_dpbp;
174 for (i = 0; i < DPNI_MAX_DPBP; i++) {
175 cmd_params->dpbp_id[i] = cpu_to_le32(cfg->pools[i].dpbp_id);
176 cmd_params->buffer_size[i] =
177 cpu_to_le16(cfg->pools[i].buffer_size);
178 cmd_params->backup_pool_mask |=
179 DPNI_BACKUP_POOL(cfg->pools[i].backup_pool, i);
180 }
181
182
183 return mc_send_command(mc_io, &cmd);
184}
185
186
187
188
189
190
191
192
193
194int dpni_enable(struct fsl_mc_io *mc_io,
195 u32 cmd_flags,
196 u16 token)
197{
198 struct fsl_mc_command cmd = { 0 };
199
200
201 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
202 cmd_flags,
203 token);
204
205
206 return mc_send_command(mc_io, &cmd);
207}
208
209
210
211
212
213
214
215
216
217int dpni_disable(struct fsl_mc_io *mc_io,
218 u32 cmd_flags,
219 u16 token)
220{
221 struct fsl_mc_command cmd = { 0 };
222
223
224 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE,
225 cmd_flags,
226 token);
227
228
229 return mc_send_command(mc_io, &cmd);
230}
231
232
233
234
235
236
237
238
239
240
241int dpni_is_enabled(struct fsl_mc_io *mc_io,
242 u32 cmd_flags,
243 u16 token,
244 int *en)
245{
246 struct fsl_mc_command cmd = { 0 };
247 struct dpni_rsp_is_enabled *rsp_params;
248 int err;
249
250
251 cmd.header = mc_encode_cmd_header(DPNI_CMDID_IS_ENABLED,
252 cmd_flags,
253 token);
254
255
256 err = mc_send_command(mc_io, &cmd);
257 if (err)
258 return err;
259
260
261 rsp_params = (struct dpni_rsp_is_enabled *)cmd.params;
262 *en = dpni_get_field(rsp_params->enabled, ENABLE);
263
264 return 0;
265}
266
267
268
269
270
271
272
273
274
275int dpni_reset(struct fsl_mc_io *mc_io,
276 u32 cmd_flags,
277 u16 token)
278{
279 struct fsl_mc_command cmd = { 0 };
280
281
282 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
283 cmd_flags,
284 token);
285
286
287 return mc_send_command(mc_io, &cmd);
288}
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
306 u32 cmd_flags,
307 u16 token,
308 u8 irq_index,
309 u8 en)
310{
311 struct fsl_mc_command cmd = { 0 };
312 struct dpni_cmd_set_irq_enable *cmd_params;
313
314
315 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_ENABLE,
316 cmd_flags,
317 token);
318 cmd_params = (struct dpni_cmd_set_irq_enable *)cmd.params;
319 dpni_set_field(cmd_params->enable, ENABLE, en);
320 cmd_params->irq_index = irq_index;
321
322
323 return mc_send_command(mc_io, &cmd);
324}
325
326
327
328
329
330
331
332
333
334
335
336int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
337 u32 cmd_flags,
338 u16 token,
339 u8 irq_index,
340 u8 *en)
341{
342 struct fsl_mc_command cmd = { 0 };
343 struct dpni_cmd_get_irq_enable *cmd_params;
344 struct dpni_rsp_get_irq_enable *rsp_params;
345
346 int err;
347
348
349 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_ENABLE,
350 cmd_flags,
351 token);
352 cmd_params = (struct dpni_cmd_get_irq_enable *)cmd.params;
353 cmd_params->irq_index = irq_index;
354
355
356 err = mc_send_command(mc_io, &cmd);
357 if (err)
358 return err;
359
360
361 rsp_params = (struct dpni_rsp_get_irq_enable *)cmd.params;
362 *en = dpni_get_field(rsp_params->enabled, ENABLE);
363
364 return 0;
365}
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
384 u32 cmd_flags,
385 u16 token,
386 u8 irq_index,
387 u32 mask)
388{
389 struct fsl_mc_command cmd = { 0 };
390 struct dpni_cmd_set_irq_mask *cmd_params;
391
392
393 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_MASK,
394 cmd_flags,
395 token);
396 cmd_params = (struct dpni_cmd_set_irq_mask *)cmd.params;
397 cmd_params->mask = cpu_to_le32(mask);
398 cmd_params->irq_index = irq_index;
399
400
401 return mc_send_command(mc_io, &cmd);
402}
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
418 u32 cmd_flags,
419 u16 token,
420 u8 irq_index,
421 u32 *mask)
422{
423 struct fsl_mc_command cmd = { 0 };
424 struct dpni_cmd_get_irq_mask *cmd_params;
425 struct dpni_rsp_get_irq_mask *rsp_params;
426 int err;
427
428
429 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_MASK,
430 cmd_flags,
431 token);
432 cmd_params = (struct dpni_cmd_get_irq_mask *)cmd.params;
433 cmd_params->irq_index = irq_index;
434
435
436 err = mc_send_command(mc_io, &cmd);
437 if (err)
438 return err;
439
440
441 rsp_params = (struct dpni_rsp_get_irq_mask *)cmd.params;
442 *mask = le32_to_cpu(rsp_params->mask);
443
444 return 0;
445}
446
447
448
449
450
451
452
453
454
455
456
457
458
459int dpni_get_irq_status(struct fsl_mc_io *mc_io,
460 u32 cmd_flags,
461 u16 token,
462 u8 irq_index,
463 u32 *status)
464{
465 struct fsl_mc_command cmd = { 0 };
466 struct dpni_cmd_get_irq_status *cmd_params;
467 struct dpni_rsp_get_irq_status *rsp_params;
468 int err;
469
470
471 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_STATUS,
472 cmd_flags,
473 token);
474 cmd_params = (struct dpni_cmd_get_irq_status *)cmd.params;
475 cmd_params->status = cpu_to_le32(*status);
476 cmd_params->irq_index = irq_index;
477
478
479 err = mc_send_command(mc_io, &cmd);
480 if (err)
481 return err;
482
483
484 rsp_params = (struct dpni_rsp_get_irq_status *)cmd.params;
485 *status = le32_to_cpu(rsp_params->status);
486
487 return 0;
488}
489
490
491
492
493
494
495
496
497
498
499
500
501
502int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
503 u32 cmd_flags,
504 u16 token,
505 u8 irq_index,
506 u32 status)
507{
508 struct fsl_mc_command cmd = { 0 };
509 struct dpni_cmd_clear_irq_status *cmd_params;
510
511
512 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLEAR_IRQ_STATUS,
513 cmd_flags,
514 token);
515 cmd_params = (struct dpni_cmd_clear_irq_status *)cmd.params;
516 cmd_params->irq_index = irq_index;
517 cmd_params->status = cpu_to_le32(status);
518
519
520 return mc_send_command(mc_io, &cmd);
521}
522
523
524
525
526
527
528
529
530
531
532int dpni_get_attributes(struct fsl_mc_io *mc_io,
533 u32 cmd_flags,
534 u16 token,
535 struct dpni_attr *attr)
536{
537 struct fsl_mc_command cmd = { 0 };
538 struct dpni_rsp_get_attr *rsp_params;
539
540 int err;
541
542
543 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR,
544 cmd_flags,
545 token);
546
547
548 err = mc_send_command(mc_io, &cmd);
549 if (err)
550 return err;
551
552
553 rsp_params = (struct dpni_rsp_get_attr *)cmd.params;
554 attr->options = le32_to_cpu(rsp_params->options);
555 attr->num_queues = rsp_params->num_queues;
556 attr->num_tcs = rsp_params->num_tcs;
557 attr->mac_filter_entries = rsp_params->mac_filter_entries;
558 attr->vlan_filter_entries = rsp_params->vlan_filter_entries;
559 attr->qos_entries = rsp_params->qos_entries;
560 attr->fs_entries = le16_to_cpu(rsp_params->fs_entries);
561 attr->qos_key_size = rsp_params->qos_key_size;
562 attr->fs_key_size = rsp_params->fs_key_size;
563 attr->wriop_version = le16_to_cpu(rsp_params->wriop_version);
564
565 return 0;
566}
567
568
569
570
571
572
573
574
575
576
577
578
579
580int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
581 u32 cmd_flags,
582 u16 token,
583 struct dpni_error_cfg *cfg)
584{
585 struct fsl_mc_command cmd = { 0 };
586 struct dpni_cmd_set_errors_behavior *cmd_params;
587
588
589 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR,
590 cmd_flags,
591 token);
592 cmd_params = (struct dpni_cmd_set_errors_behavior *)cmd.params;
593 cmd_params->errors = cpu_to_le32(cfg->errors);
594 dpni_set_field(cmd_params->flags, ERROR_ACTION, cfg->error_action);
595 dpni_set_field(cmd_params->flags, FRAME_ANN, cfg->set_frame_annotation);
596
597
598 return mc_send_command(mc_io, &cmd);
599}
600
601
602
603
604
605
606
607
608
609
610
611int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
612 u32 cmd_flags,
613 u16 token,
614 enum dpni_queue_type qtype,
615 struct dpni_buffer_layout *layout)
616{
617 struct fsl_mc_command cmd = { 0 };
618 struct dpni_cmd_get_buffer_layout *cmd_params;
619 struct dpni_rsp_get_buffer_layout *rsp_params;
620 int err;
621
622
623 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_BUFFER_LAYOUT,
624 cmd_flags,
625 token);
626 cmd_params = (struct dpni_cmd_get_buffer_layout *)cmd.params;
627 cmd_params->qtype = qtype;
628
629
630 err = mc_send_command(mc_io, &cmd);
631 if (err)
632 return err;
633
634
635 rsp_params = (struct dpni_rsp_get_buffer_layout *)cmd.params;
636 layout->pass_timestamp = dpni_get_field(rsp_params->flags, PASS_TS);
637 layout->pass_parser_result = dpni_get_field(rsp_params->flags, PASS_PR);
638 layout->pass_frame_status = dpni_get_field(rsp_params->flags, PASS_FS);
639 layout->private_data_size = le16_to_cpu(rsp_params->private_data_size);
640 layout->data_align = le16_to_cpu(rsp_params->data_align);
641 layout->data_head_room = le16_to_cpu(rsp_params->head_room);
642 layout->data_tail_room = le16_to_cpu(rsp_params->tail_room);
643
644 return 0;
645}
646
647
648
649
650
651
652
653
654
655
656
657
658
659int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
660 u32 cmd_flags,
661 u16 token,
662 enum dpni_queue_type qtype,
663 const struct dpni_buffer_layout *layout)
664{
665 struct fsl_mc_command cmd = { 0 };
666 struct dpni_cmd_set_buffer_layout *cmd_params;
667
668
669 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT,
670 cmd_flags,
671 token);
672 cmd_params = (struct dpni_cmd_set_buffer_layout *)cmd.params;
673 cmd_params->qtype = qtype;
674 cmd_params->options = cpu_to_le16(layout->options);
675 dpni_set_field(cmd_params->flags, PASS_TS, layout->pass_timestamp);
676 dpni_set_field(cmd_params->flags, PASS_PR, layout->pass_parser_result);
677 dpni_set_field(cmd_params->flags, PASS_FS, layout->pass_frame_status);
678 cmd_params->private_data_size = cpu_to_le16(layout->private_data_size);
679 cmd_params->data_align = cpu_to_le16(layout->data_align);
680 cmd_params->head_room = cpu_to_le16(layout->data_head_room);
681 cmd_params->tail_room = cpu_to_le16(layout->data_tail_room);
682
683
684 return mc_send_command(mc_io, &cmd);
685}
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701int dpni_set_offload(struct fsl_mc_io *mc_io,
702 u32 cmd_flags,
703 u16 token,
704 enum dpni_offload type,
705 u32 config)
706{
707 struct fsl_mc_command cmd = { 0 };
708 struct dpni_cmd_set_offload *cmd_params;
709
710 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_OFFLOAD,
711 cmd_flags,
712 token);
713 cmd_params = (struct dpni_cmd_set_offload *)cmd.params;
714 cmd_params->dpni_offload = type;
715 cmd_params->config = cpu_to_le32(config);
716
717 return mc_send_command(mc_io, &cmd);
718}
719
720int dpni_get_offload(struct fsl_mc_io *mc_io,
721 u32 cmd_flags,
722 u16 token,
723 enum dpni_offload type,
724 u32 *config)
725{
726 struct fsl_mc_command cmd = { 0 };
727 struct dpni_cmd_get_offload *cmd_params;
728 struct dpni_rsp_get_offload *rsp_params;
729 int err;
730
731
732 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_OFFLOAD,
733 cmd_flags,
734 token);
735 cmd_params = (struct dpni_cmd_get_offload *)cmd.params;
736 cmd_params->dpni_offload = type;
737
738
739 err = mc_send_command(mc_io, &cmd);
740 if (err)
741 return err;
742
743
744 rsp_params = (struct dpni_rsp_get_offload *)cmd.params;
745 *config = le32_to_cpu(rsp_params->config);
746
747 return 0;
748}
749
750
751
752
753
754
755
756
757
758
759
760
761
762int dpni_get_qdid(struct fsl_mc_io *mc_io,
763 u32 cmd_flags,
764 u16 token,
765 enum dpni_queue_type qtype,
766 u16 *qdid)
767{
768 struct fsl_mc_command cmd = { 0 };
769 struct dpni_cmd_get_qdid *cmd_params;
770 struct dpni_rsp_get_qdid *rsp_params;
771 int err;
772
773
774 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID,
775 cmd_flags,
776 token);
777 cmd_params = (struct dpni_cmd_get_qdid *)cmd.params;
778 cmd_params->qtype = qtype;
779
780
781 err = mc_send_command(mc_io, &cmd);
782 if (err)
783 return err;
784
785
786 rsp_params = (struct dpni_rsp_get_qdid *)cmd.params;
787 *qdid = le16_to_cpu(rsp_params->qdid);
788
789 return 0;
790}
791
792
793
794
795
796
797
798
799
800
801int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
802 u32 cmd_flags,
803 u16 token,
804 u16 *data_offset)
805{
806 struct fsl_mc_command cmd = { 0 };
807 struct dpni_rsp_get_tx_data_offset *rsp_params;
808 int err;
809
810
811 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET,
812 cmd_flags,
813 token);
814
815
816 err = mc_send_command(mc_io, &cmd);
817 if (err)
818 return err;
819
820
821 rsp_params = (struct dpni_rsp_get_tx_data_offset *)cmd.params;
822 *data_offset = le16_to_cpu(rsp_params->data_offset);
823
824 return 0;
825}
826
827
828
829
830
831
832
833
834
835
836int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
837 u32 cmd_flags,
838 u16 token,
839 const struct dpni_link_cfg *cfg)
840{
841 struct fsl_mc_command cmd = { 0 };
842 struct dpni_cmd_link_cfg *cmd_params;
843
844
845 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
846 cmd_flags,
847 token);
848 cmd_params = (struct dpni_cmd_link_cfg *)cmd.params;
849 cmd_params->rate = cpu_to_le32(cfg->rate);
850 cmd_params->options = cpu_to_le64(cfg->options);
851
852
853 return mc_send_command(mc_io, &cmd);
854}
855
856
857
858
859
860
861
862
863
864
865int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
866 u32 cmd_flags,
867 u16 token,
868 struct dpni_link_cfg *cfg)
869{
870 struct fsl_mc_command cmd = { 0 };
871 struct dpni_cmd_link_cfg *rsp_params;
872 int err;
873
874
875 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_CFG,
876 cmd_flags,
877 token);
878
879
880 err = mc_send_command(mc_io, &cmd);
881 if (err)
882 return err;
883
884
885 rsp_params = (struct dpni_cmd_link_cfg *)cmd.params;
886 cfg->rate = le32_to_cpu(rsp_params->rate);
887 cfg->options = le64_to_cpu(rsp_params->options);
888
889 return err;
890}
891
892
893
894
895
896
897
898
899
900
901int dpni_get_link_state(struct fsl_mc_io *mc_io,
902 u32 cmd_flags,
903 u16 token,
904 struct dpni_link_state *state)
905{
906 struct fsl_mc_command cmd = { 0 };
907 struct dpni_rsp_get_link_state *rsp_params;
908 int err;
909
910
911 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE,
912 cmd_flags,
913 token);
914
915
916 err = mc_send_command(mc_io, &cmd);
917 if (err)
918 return err;
919
920
921 rsp_params = (struct dpni_rsp_get_link_state *)cmd.params;
922 state->up = dpni_get_field(rsp_params->flags, LINK_STATE);
923 state->rate = le32_to_cpu(rsp_params->rate);
924 state->options = le64_to_cpu(rsp_params->options);
925
926 return 0;
927}
928
929
930
931
932
933
934
935
936
937
938
939
940int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
941 u32 cmd_flags,
942 u16 token,
943 u16 max_frame_length)
944{
945 struct fsl_mc_command cmd = { 0 };
946 struct dpni_cmd_set_max_frame_length *cmd_params;
947
948
949 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MAX_FRAME_LENGTH,
950 cmd_flags,
951 token);
952 cmd_params = (struct dpni_cmd_set_max_frame_length *)cmd.params;
953 cmd_params->max_frame_length = cpu_to_le16(max_frame_length);
954
955
956 return mc_send_command(mc_io, &cmd);
957}
958
959
960
961
962
963
964
965
966
967
968
969
970int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
971 u32 cmd_flags,
972 u16 token,
973 u16 *max_frame_length)
974{
975 struct fsl_mc_command cmd = { 0 };
976 struct dpni_rsp_get_max_frame_length *rsp_params;
977 int err;
978
979
980 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MAX_FRAME_LENGTH,
981 cmd_flags,
982 token);
983
984
985 err = mc_send_command(mc_io, &cmd);
986 if (err)
987 return err;
988
989
990 rsp_params = (struct dpni_rsp_get_max_frame_length *)cmd.params;
991 *max_frame_length = le16_to_cpu(rsp_params->max_frame_length);
992
993 return 0;
994}
995
996
997
998
999
1000
1001
1002
1003
1004
1005int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
1006 u32 cmd_flags,
1007 u16 token,
1008 int en)
1009{
1010 struct fsl_mc_command cmd = { 0 };
1011 struct dpni_cmd_set_multicast_promisc *cmd_params;
1012
1013
1014 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MCAST_PROMISC,
1015 cmd_flags,
1016 token);
1017 cmd_params = (struct dpni_cmd_set_multicast_promisc *)cmd.params;
1018 dpni_set_field(cmd_params->enable, ENABLE, en);
1019
1020
1021 return mc_send_command(mc_io, &cmd);
1022}
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
1034 u32 cmd_flags,
1035 u16 token,
1036 int *en)
1037{
1038 struct fsl_mc_command cmd = { 0 };
1039 struct dpni_rsp_get_multicast_promisc *rsp_params;
1040 int err;
1041
1042
1043 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MCAST_PROMISC,
1044 cmd_flags,
1045 token);
1046
1047
1048 err = mc_send_command(mc_io, &cmd);
1049 if (err)
1050 return err;
1051
1052
1053 rsp_params = (struct dpni_rsp_get_multicast_promisc *)cmd.params;
1054 *en = dpni_get_field(rsp_params->enabled, ENABLE);
1055
1056 return 0;
1057}
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
1069 u32 cmd_flags,
1070 u16 token,
1071 int en)
1072{
1073 struct fsl_mc_command cmd = { 0 };
1074 struct dpni_cmd_set_unicast_promisc *cmd_params;
1075
1076
1077 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_UNICAST_PROMISC,
1078 cmd_flags,
1079 token);
1080 cmd_params = (struct dpni_cmd_set_unicast_promisc *)cmd.params;
1081 dpni_set_field(cmd_params->enable, ENABLE, en);
1082
1083
1084 return mc_send_command(mc_io, &cmd);
1085}
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
1097 u32 cmd_flags,
1098 u16 token,
1099 int *en)
1100{
1101 struct fsl_mc_command cmd = { 0 };
1102 struct dpni_rsp_get_unicast_promisc *rsp_params;
1103 int err;
1104
1105
1106 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_UNICAST_PROMISC,
1107 cmd_flags,
1108 token);
1109
1110
1111 err = mc_send_command(mc_io, &cmd);
1112 if (err)
1113 return err;
1114
1115
1116 rsp_params = (struct dpni_rsp_get_unicast_promisc *)cmd.params;
1117 *en = dpni_get_field(rsp_params->enabled, ENABLE);
1118
1119 return 0;
1120}
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
1132 u32 cmd_flags,
1133 u16 token,
1134 const u8 mac_addr[6])
1135{
1136 struct fsl_mc_command cmd = { 0 };
1137 struct dpni_cmd_set_primary_mac_addr *cmd_params;
1138 int i;
1139
1140
1141 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC,
1142 cmd_flags,
1143 token);
1144 cmd_params = (struct dpni_cmd_set_primary_mac_addr *)cmd.params;
1145 for (i = 0; i < 6; i++)
1146 cmd_params->mac_addr[i] = mac_addr[5 - i];
1147
1148
1149 return mc_send_command(mc_io, &cmd);
1150}
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
1162 u32 cmd_flags,
1163 u16 token,
1164 u8 mac_addr[6])
1165{
1166 struct fsl_mc_command cmd = { 0 };
1167 struct dpni_rsp_get_primary_mac_addr *rsp_params;
1168 int i, err;
1169
1170
1171 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC,
1172 cmd_flags,
1173 token);
1174
1175
1176 err = mc_send_command(mc_io, &cmd);
1177 if (err)
1178 return err;
1179
1180
1181 rsp_params = (struct dpni_rsp_get_primary_mac_addr *)cmd.params;
1182 for (i = 0; i < 6; i++)
1183 mac_addr[5 - i] = rsp_params->mac_addr[i];
1184
1185 return 0;
1186}
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
1201 u32 cmd_flags,
1202 u16 token,
1203 u8 mac_addr[6])
1204{
1205 struct fsl_mc_command cmd = { 0 };
1206 struct dpni_rsp_get_port_mac_addr *rsp_params;
1207 int i, err;
1208
1209
1210 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PORT_MAC_ADDR,
1211 cmd_flags,
1212 token);
1213
1214
1215 err = mc_send_command(mc_io, &cmd);
1216 if (err)
1217 return err;
1218
1219
1220 rsp_params = (struct dpni_rsp_get_port_mac_addr *)cmd.params;
1221 for (i = 0; i < 6; i++)
1222 mac_addr[5 - i] = rsp_params->mac_addr[i];
1223
1224 return 0;
1225}
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
1237 u32 cmd_flags,
1238 u16 token,
1239 u32 en)
1240{
1241 struct dpni_cmd_enable_vlan_filter *cmd_params;
1242 struct fsl_mc_command cmd = { 0 };
1243
1244
1245 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE_VLAN_FILTER,
1246 cmd_flags,
1247 token);
1248 cmd_params = (struct dpni_cmd_enable_vlan_filter *)cmd.params;
1249 dpni_set_field(cmd_params->en, ENABLE, en);
1250
1251
1252 return mc_send_command(mc_io, &cmd);
1253}
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1275 u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id)
1276{
1277 struct dpni_cmd_vlan_id *cmd_params;
1278 struct fsl_mc_command cmd = { 0 };
1279
1280
1281 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_VLAN_ID,
1282 cmd_flags,
1283 token);
1284 cmd_params = (struct dpni_cmd_vlan_id *)cmd.params;
1285 cmd_params->flags = flags;
1286 cmd_params->tc_id = tc_id;
1287 cmd_params->flow_id = flow_id;
1288 cmd_params->vlan_id = cpu_to_le16(vlan_id);
1289
1290
1291 return mc_send_command(mc_io, &cmd);
1292}
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1304 u16 vlan_id)
1305{
1306 struct dpni_cmd_vlan_id *cmd_params;
1307 struct fsl_mc_command cmd = { 0 };
1308
1309
1310 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_VLAN_ID,
1311 cmd_flags,
1312 token);
1313 cmd_params = (struct dpni_cmd_vlan_id *)cmd.params;
1314 cmd_params->vlan_id = cpu_to_le16(vlan_id);
1315
1316
1317 return mc_send_command(mc_io, &cmd);
1318}
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
1330 u32 cmd_flags,
1331 u16 token,
1332 const u8 mac_addr[6])
1333{
1334 struct fsl_mc_command cmd = { 0 };
1335 struct dpni_cmd_add_mac_addr *cmd_params;
1336 int i;
1337
1338
1339 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR,
1340 cmd_flags,
1341 token);
1342 cmd_params = (struct dpni_cmd_add_mac_addr *)cmd.params;
1343 for (i = 0; i < 6; i++)
1344 cmd_params->mac_addr[i] = mac_addr[5 - i];
1345
1346
1347 return mc_send_command(mc_io, &cmd);
1348}
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
1360 u32 cmd_flags,
1361 u16 token,
1362 const u8 mac_addr[6])
1363{
1364 struct fsl_mc_command cmd = { 0 };
1365 struct dpni_cmd_remove_mac_addr *cmd_params;
1366 int i;
1367
1368
1369 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR,
1370 cmd_flags,
1371 token);
1372 cmd_params = (struct dpni_cmd_remove_mac_addr *)cmd.params;
1373 for (i = 0; i < 6; i++)
1374 cmd_params->mac_addr[i] = mac_addr[5 - i];
1375
1376
1377 return mc_send_command(mc_io, &cmd);
1378}
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
1393 u32 cmd_flags,
1394 u16 token,
1395 int unicast,
1396 int multicast)
1397{
1398 struct fsl_mc_command cmd = { 0 };
1399 struct dpni_cmd_clear_mac_filters *cmd_params;
1400
1401
1402 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_MAC_FILTERS,
1403 cmd_flags,
1404 token);
1405 cmd_params = (struct dpni_cmd_clear_mac_filters *)cmd.params;
1406 dpni_set_field(cmd_params->flags, UNICAST_FILTERS, unicast);
1407 dpni_set_field(cmd_params->flags, MULTICAST_FILTERS, multicast);
1408
1409
1410 return mc_send_command(mc_io, &cmd);
1411}
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
1427 u32 cmd_flags,
1428 u16 token,
1429 u8 tc_id,
1430 const struct dpni_rx_tc_dist_cfg *cfg)
1431{
1432 struct fsl_mc_command cmd = { 0 };
1433 struct dpni_cmd_set_rx_tc_dist *cmd_params;
1434
1435
1436 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_DIST,
1437 cmd_flags,
1438 token);
1439 cmd_params = (struct dpni_cmd_set_rx_tc_dist *)cmd.params;
1440 cmd_params->dist_size = cpu_to_le16(cfg->dist_size);
1441 cmd_params->tc_id = tc_id;
1442 dpni_set_field(cmd_params->flags, DIST_MODE, cfg->dist_mode);
1443 dpni_set_field(cmd_params->flags, MISS_ACTION, cfg->fs_cfg.miss_action);
1444 cmd_params->default_flow_id = cpu_to_le16(cfg->fs_cfg.default_flow_id);
1445 cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova);
1446
1447
1448 return mc_send_command(mc_io, &cmd);
1449}
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463int dpni_set_congestion_notification(
1464 struct fsl_mc_io *mc_io,
1465 u32 cmd_flags,
1466 u16 token,
1467 enum dpni_queue_type qtype,
1468 u8 tc_id,
1469 const struct dpni_congestion_notification_cfg *cfg)
1470{
1471 struct dpni_cmd_set_congestion_notification *cmd_params;
1472 struct fsl_mc_command cmd = { 0 };
1473
1474
1475 cmd.header =
1476 mc_encode_cmd_header(DPNI_CMDID_SET_CONGESTION_NOTIFICATION,
1477 cmd_flags,
1478 token);
1479 cmd_params = (struct dpni_cmd_set_congestion_notification *)cmd.params;
1480 cmd_params->qtype = qtype;
1481 cmd_params->tc = tc_id;
1482 cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
1483 cmd_params->notification_mode = cpu_to_le16(cfg->notification_mode);
1484 cmd_params->dest_priority = cfg->dest_cfg.priority;
1485 dpni_set_field(cmd_params->type_units, DEST_TYPE,
1486 cfg->dest_cfg.dest_type);
1487 dpni_set_field(cmd_params->type_units, CONG_UNITS, cfg->units);
1488 cmd_params->message_iova = cpu_to_le64(cfg->message_iova);
1489 cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx);
1490 cmd_params->threshold_entry = cpu_to_le32(cfg->threshold_entry);
1491 cmd_params->threshold_exit = cpu_to_le32(cfg->threshold_exit);
1492
1493
1494 return mc_send_command(mc_io, &cmd);
1495}
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513int dpni_set_queue(struct fsl_mc_io *mc_io,
1514 u32 cmd_flags,
1515 u16 token,
1516 enum dpni_queue_type qtype,
1517 u8 tc,
1518 u8 index,
1519 u8 options,
1520 const struct dpni_queue *queue)
1521{
1522 struct fsl_mc_command cmd = { 0 };
1523 struct dpni_cmd_set_queue *cmd_params;
1524
1525
1526 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
1527 cmd_flags,
1528 token);
1529 cmd_params = (struct dpni_cmd_set_queue *)cmd.params;
1530 cmd_params->qtype = qtype;
1531 cmd_params->tc = tc;
1532 cmd_params->index = index;
1533 cmd_params->options = options;
1534 cmd_params->dest_id = cpu_to_le32(queue->destination.id);
1535 cmd_params->dest_prio = queue->destination.priority;
1536 dpni_set_field(cmd_params->flags, DEST_TYPE, queue->destination.type);
1537 dpni_set_field(cmd_params->flags, STASH_CTRL, queue->flc.stash_control);
1538 dpni_set_field(cmd_params->flags, HOLD_ACTIVE,
1539 queue->destination.hold_active);
1540 cmd_params->flc = cpu_to_le64(queue->flc.value);
1541 cmd_params->user_context = cpu_to_le64(queue->user_context);
1542
1543
1544 return mc_send_command(mc_io, &cmd);
1545}
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561int dpni_get_queue(struct fsl_mc_io *mc_io,
1562 u32 cmd_flags,
1563 u16 token,
1564 enum dpni_queue_type qtype,
1565 u8 tc,
1566 u8 index,
1567 struct dpni_queue *queue,
1568 struct dpni_queue_id *qid)
1569{
1570 struct fsl_mc_command cmd = { 0 };
1571 struct dpni_cmd_get_queue *cmd_params;
1572 struct dpni_rsp_get_queue *rsp_params;
1573 int err;
1574
1575
1576 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE,
1577 cmd_flags,
1578 token);
1579 cmd_params = (struct dpni_cmd_get_queue *)cmd.params;
1580 cmd_params->qtype = qtype;
1581 cmd_params->tc = tc;
1582 cmd_params->index = index;
1583
1584
1585 err = mc_send_command(mc_io, &cmd);
1586 if (err)
1587 return err;
1588
1589
1590 rsp_params = (struct dpni_rsp_get_queue *)cmd.params;
1591 queue->destination.id = le32_to_cpu(rsp_params->dest_id);
1592 queue->destination.priority = rsp_params->dest_prio;
1593 queue->destination.type = dpni_get_field(rsp_params->flags,
1594 DEST_TYPE);
1595 queue->flc.stash_control = dpni_get_field(rsp_params->flags,
1596 STASH_CTRL);
1597 queue->destination.hold_active = dpni_get_field(rsp_params->flags,
1598 HOLD_ACTIVE);
1599 queue->flc.value = le64_to_cpu(rsp_params->flc);
1600 queue->user_context = le64_to_cpu(rsp_params->user_context);
1601 qid->fqid = le32_to_cpu(rsp_params->fqid);
1602 qid->qdbin = le16_to_cpu(rsp_params->qdbin);
1603
1604 return 0;
1605}
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618int dpni_get_statistics(struct fsl_mc_io *mc_io,
1619 u32 cmd_flags,
1620 u16 token,
1621 u8 page,
1622 union dpni_statistics *stat)
1623{
1624 struct fsl_mc_command cmd = { 0 };
1625 struct dpni_cmd_get_statistics *cmd_params;
1626 struct dpni_rsp_get_statistics *rsp_params;
1627 int i, err;
1628
1629
1630 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS,
1631 cmd_flags,
1632 token);
1633 cmd_params = (struct dpni_cmd_get_statistics *)cmd.params;
1634 cmd_params->page_number = page;
1635
1636
1637 err = mc_send_command(mc_io, &cmd);
1638 if (err)
1639 return err;
1640
1641
1642 rsp_params = (struct dpni_rsp_get_statistics *)cmd.params;
1643 for (i = 0; i < DPNI_STATISTICS_CNT; i++)
1644 stat->raw.counter[i] = le64_to_cpu(rsp_params->counter[i]);
1645
1646 return 0;
1647}
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1665 u32 cmd_flags,
1666 u16 token,
1667 enum dpni_congestion_point cg_point,
1668 enum dpni_queue_type qtype,
1669 u8 tc,
1670 u8 index,
1671 struct dpni_taildrop *taildrop)
1672{
1673 struct fsl_mc_command cmd = { 0 };
1674 struct dpni_cmd_set_taildrop *cmd_params;
1675
1676
1677 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TAILDROP,
1678 cmd_flags,
1679 token);
1680 cmd_params = (struct dpni_cmd_set_taildrop *)cmd.params;
1681 cmd_params->congestion_point = cg_point;
1682 cmd_params->qtype = qtype;
1683 cmd_params->tc = tc;
1684 cmd_params->index = index;
1685 dpni_set_field(cmd_params->enable, ENABLE, taildrop->enable);
1686 cmd_params->units = taildrop->units;
1687 cmd_params->threshold = cpu_to_le32(taildrop->threshold);
1688
1689
1690 return mc_send_command(mc_io, &cmd);
1691}
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1709 u32 cmd_flags,
1710 u16 token,
1711 enum dpni_congestion_point cg_point,
1712 enum dpni_queue_type qtype,
1713 u8 tc,
1714 u8 index,
1715 struct dpni_taildrop *taildrop)
1716{
1717 struct fsl_mc_command cmd = { 0 };
1718 struct dpni_cmd_get_taildrop *cmd_params;
1719 struct dpni_rsp_get_taildrop *rsp_params;
1720 int err;
1721
1722
1723 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TAILDROP,
1724 cmd_flags,
1725 token);
1726 cmd_params = (struct dpni_cmd_get_taildrop *)cmd.params;
1727 cmd_params->congestion_point = cg_point;
1728 cmd_params->qtype = qtype;
1729 cmd_params->tc = tc;
1730 cmd_params->index = index;
1731
1732
1733 err = mc_send_command(mc_io, &cmd);
1734 if (err)
1735 return err;
1736
1737
1738 rsp_params = (struct dpni_rsp_get_taildrop *)cmd.params;
1739 taildrop->enable = dpni_get_field(rsp_params->enable, ENABLE);
1740 taildrop->units = rsp_params->units;
1741 taildrop->threshold = le32_to_cpu(rsp_params->threshold);
1742
1743 return 0;
1744}
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755int dpni_get_api_version(struct fsl_mc_io *mc_io,
1756 u32 cmd_flags,
1757 u16 *major_ver,
1758 u16 *minor_ver)
1759{
1760 struct dpni_rsp_get_api_version *rsp_params;
1761 struct fsl_mc_command cmd = { 0 };
1762 int err;
1763
1764 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
1765 cmd_flags, 0);
1766
1767 err = mc_send_command(mc_io, &cmd);
1768 if (err)
1769 return err;
1770
1771 rsp_params = (struct dpni_rsp_get_api_version *)cmd.params;
1772 *major_ver = le16_to_cpu(rsp_params->major);
1773 *minor_ver = le16_to_cpu(rsp_params->minor);
1774
1775 return 0;
1776}
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
1798 u32 cmd_flags,
1799 u16 token,
1800 const struct dpni_rx_dist_cfg *cfg)
1801{
1802 struct dpni_cmd_set_rx_fs_dist *cmd_params;
1803 struct fsl_mc_command cmd = { 0 };
1804
1805
1806 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_FS_DIST,
1807 cmd_flags,
1808 token);
1809 cmd_params = (struct dpni_cmd_set_rx_fs_dist *)cmd.params;
1810 cmd_params->dist_size = cpu_to_le16(cfg->dist_size);
1811 dpni_set_field(cmd_params->enable, RX_FS_DIST_ENABLE, cfg->enable);
1812 cmd_params->tc = cfg->tc;
1813 cmd_params->miss_flow_id = cpu_to_le16(cfg->fs_miss_flow_id);
1814 cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova);
1815
1816
1817 return mc_send_command(mc_io, &cmd);
1818}
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
1831 u32 cmd_flags,
1832 u16 token,
1833 const struct dpni_rx_dist_cfg *cfg)
1834{
1835 struct dpni_cmd_set_rx_hash_dist *cmd_params;
1836 struct fsl_mc_command cmd = { 0 };
1837
1838
1839 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_HASH_DIST,
1840 cmd_flags,
1841 token);
1842 cmd_params = (struct dpni_cmd_set_rx_hash_dist *)cmd.params;
1843 cmd_params->dist_size = cpu_to_le16(cfg->dist_size);
1844 dpni_set_field(cmd_params->enable, RX_HASH_DIST_ENABLE, cfg->enable);
1845 cmd_params->tc = cfg->tc;
1846 cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova);
1847
1848
1849 return mc_send_command(mc_io, &cmd);
1850}
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1868 u32 cmd_flags,
1869 u16 token,
1870 u8 tc_id,
1871 u16 index,
1872 const struct dpni_rule_cfg *cfg,
1873 const struct dpni_fs_action_cfg *action)
1874{
1875 struct dpni_cmd_add_fs_entry *cmd_params;
1876 struct fsl_mc_command cmd = { 0 };
1877
1878
1879 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_FS_ENT,
1880 cmd_flags,
1881 token);
1882 cmd_params = (struct dpni_cmd_add_fs_entry *)cmd.params;
1883 cmd_params->tc_id = tc_id;
1884 cmd_params->key_size = cfg->key_size;
1885 cmd_params->index = cpu_to_le16(index);
1886 cmd_params->key_iova = cpu_to_le64(cfg->key_iova);
1887 cmd_params->mask_iova = cpu_to_le64(cfg->mask_iova);
1888 cmd_params->options = cpu_to_le16(action->options);
1889 cmd_params->flow_id = cpu_to_le16(action->flow_id);
1890 cmd_params->flc = cpu_to_le64(action->flc);
1891
1892
1893 return mc_send_command(mc_io, &cmd);
1894}
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1908 u32 cmd_flags,
1909 u16 token,
1910 u8 tc_id,
1911 const struct dpni_rule_cfg *cfg)
1912{
1913 struct dpni_cmd_remove_fs_entry *cmd_params;
1914 struct fsl_mc_command cmd = { 0 };
1915
1916
1917 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_FS_ENT,
1918 cmd_flags,
1919 token);
1920 cmd_params = (struct dpni_cmd_remove_fs_entry *)cmd.params;
1921 cmd_params->tc_id = tc_id;
1922 cmd_params->key_size = cfg->key_size;
1923 cmd_params->key_iova = cpu_to_le64(cfg->key_iova);
1924 cmd_params->mask_iova = cpu_to_le64(cfg->mask_iova);
1925
1926
1927 return mc_send_command(mc_io, &cmd);
1928}
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1946 u32 cmd_flags,
1947 u16 token,
1948 const struct dpni_qos_tbl_cfg *cfg)
1949{
1950 struct dpni_cmd_set_qos_table *cmd_params;
1951 struct fsl_mc_command cmd = { 0 };
1952
1953
1954 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QOS_TBL,
1955 cmd_flags,
1956 token);
1957 cmd_params = (struct dpni_cmd_set_qos_table *)cmd.params;
1958 cmd_params->default_tc = cfg->default_tc;
1959 cmd_params->key_cfg_iova = cpu_to_le64(cfg->key_cfg_iova);
1960 dpni_set_field(cmd_params->discard_on_miss, DISCARD_ON_MISS,
1961 cfg->discard_on_miss);
1962
1963
1964 return mc_send_command(mc_io, &cmd);
1965}
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1981 u32 cmd_flags,
1982 u16 token,
1983 const struct dpni_rule_cfg *cfg,
1984 u8 tc_id,
1985 u16 index)
1986{
1987 struct dpni_cmd_add_qos_entry *cmd_params;
1988 struct fsl_mc_command cmd = { 0 };
1989
1990
1991 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_QOS_ENT,
1992 cmd_flags,
1993 token);
1994 cmd_params = (struct dpni_cmd_add_qos_entry *)cmd.params;
1995 cmd_params->tc_id = tc_id;
1996 cmd_params->key_size = cfg->key_size;
1997 cmd_params->index = cpu_to_le16(index);
1998 cmd_params->key_iova = cpu_to_le64(cfg->key_iova);
1999 cmd_params->mask_iova = cpu_to_le64(cfg->mask_iova);
2000
2001
2002 return mc_send_command(mc_io, &cmd);
2003}
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
2015 u32 cmd_flags,
2016 u16 token,
2017 const struct dpni_rule_cfg *cfg)
2018{
2019 struct dpni_cmd_remove_qos_entry *cmd_params;
2020 struct fsl_mc_command cmd = { 0 };
2021
2022
2023 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_QOS_ENT,
2024 cmd_flags,
2025 token);
2026 cmd_params = (struct dpni_cmd_remove_qos_entry *)cmd.params;
2027 cmd_params->key_size = cfg->key_size;
2028 cmd_params->key_iova = cpu_to_le64(cfg->key_iova);
2029 cmd_params->mask_iova = cpu_to_le64(cfg->mask_iova);
2030
2031
2032 return mc_send_command(mc_io, &cmd);
2033}
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
2047 u32 cmd_flags,
2048 u16 token)
2049{
2050 struct fsl_mc_command cmd = { 0 };
2051
2052
2053 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_QOS_TBL,
2054 cmd_flags,
2055 token);
2056
2057
2058 return mc_send_command(mc_io, &cmd);
2059}
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
2073 u32 cmd_flags,
2074 u16 token,
2075 const struct dpni_tx_shaping_cfg *tx_cr_shaper,
2076 const struct dpni_tx_shaping_cfg *tx_er_shaper,
2077 int coupled)
2078{
2079 struct dpni_cmd_set_tx_shaping *cmd_params;
2080 struct fsl_mc_command cmd = { 0 };
2081
2082
2083 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_SHAPING,
2084 cmd_flags,
2085 token);
2086 cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params;
2087 cmd_params->tx_cr_max_burst_size = cpu_to_le16(tx_cr_shaper->max_burst_size);
2088 cmd_params->tx_er_max_burst_size = cpu_to_le16(tx_er_shaper->max_burst_size);
2089 cmd_params->tx_cr_rate_limit = cpu_to_le32(tx_cr_shaper->rate_limit);
2090 cmd_params->tx_er_rate_limit = cpu_to_le32(tx_er_shaper->rate_limit);
2091 dpni_set_field(cmd_params->coupled, COUPLED, coupled);
2092
2093
2094 return mc_send_command(mc_io, &cmd);
2095}
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
2109 u32 cmd_flags,
2110 u16 token,
2111 struct dpni_single_step_cfg *ptp_cfg)
2112{
2113 struct dpni_rsp_single_step_cfg *rsp_params;
2114 struct fsl_mc_command cmd = { 0 };
2115 int err;
2116
2117
2118 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_SINGLE_STEP_CFG,
2119 cmd_flags, token);
2120
2121 err = mc_send_command(mc_io, &cmd);
2122 if (err)
2123 return err;
2124
2125
2126 rsp_params = (struct dpni_rsp_single_step_cfg *)cmd.params;
2127 ptp_cfg->offset = le16_to_cpu(rsp_params->offset);
2128 ptp_cfg->en = dpni_get_field(le16_to_cpu(rsp_params->flags),
2129 PTP_ENABLE) ? 1 : 0;
2130 ptp_cfg->ch_update = dpni_get_field(le16_to_cpu(rsp_params->flags),
2131 PTP_CH_UPDATE) ? 1 : 0;
2132 ptp_cfg->peer_delay = le32_to_cpu(rsp_params->peer_delay);
2133
2134 return err;
2135}
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
2151 u32 cmd_flags,
2152 u16 token,
2153 struct dpni_single_step_cfg *ptp_cfg)
2154{
2155 struct dpni_cmd_single_step_cfg *cmd_params;
2156 struct fsl_mc_command cmd = { 0 };
2157 u16 flags;
2158
2159
2160 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_SINGLE_STEP_CFG,
2161 cmd_flags, token);
2162 cmd_params = (struct dpni_cmd_single_step_cfg *)cmd.params;
2163 cmd_params->offset = cpu_to_le16(ptp_cfg->offset);
2164 cmd_params->peer_delay = cpu_to_le32(ptp_cfg->peer_delay);
2165
2166 flags = le16_to_cpu(cmd_params->flags);
2167 dpni_set_field(flags, PTP_ENABLE, !!ptp_cfg->en);
2168 dpni_set_field(flags, PTP_CH_UPDATE, !!ptp_cfg->ch_update);
2169 cmd_params->flags = cpu_to_le16(flags);
2170
2171
2172 return mc_send_command(mc_io, &cmd);
2173}
2174