Commit 86719f0cd55bc13186798217b08fa6a048eda27c
Committed by
York Sun
1 parent
24a23deb90
Exists in
v2017.01-smarct4x
and in
30 other branches
drivers/net/vsc9953: Add command to show/clear port counters
The new added command: ethsw [port <port_no>] statistics { [help] | [clear] } will print counters like the number of Rx/Tx frames, number of Rx/Tx bytes, number of Rx/Tx unicast frames, etc. This patch also adds this commnd in the genereric ethsw parser from cmd_ethsw.c Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: York Sun <yorksun@freescale.com>
Showing 4 changed files with 415 additions and 3 deletions Side-by-side Diff
common/cmd_ethsw.c
... | ... | @@ -13,6 +13,16 @@ |
13 | 13 | |
14 | 14 | static const char *ethsw_name; |
15 | 15 | |
16 | +#define ETHSW_PORT_STATS_HELP "ethsw [port <port_no>] statistics " \ | |
17 | +"{ [help] | [clear] } - show an l2 switch port's statistics" | |
18 | + | |
19 | +static int ethsw_port_stats_help_key_func(struct ethsw_command_def *parsed_cmd) | |
20 | +{ | |
21 | + printf(ETHSW_PORT_STATS_HELP"\n"); | |
22 | + | |
23 | + return CMD_RET_SUCCESS; | |
24 | +} | |
25 | + | |
16 | 26 | static struct keywords_to_function { |
17 | 27 | enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS]; |
18 | 28 | int cmd_func_offset; |
... | ... | @@ -42,6 +52,31 @@ |
42 | 52 | .cmd_func_offset = offsetof(struct ethsw_command_func, |
43 | 53 | port_show), |
44 | 54 | .keyword_function = NULL, |
55 | + }, { | |
56 | + .cmd_keyword = { | |
57 | + ethsw_id_statistics, | |
58 | + ethsw_id_help, | |
59 | + ethsw_id_key_end, | |
60 | + }, | |
61 | + .cmd_func_offset = -1, | |
62 | + .keyword_function = ðsw_port_stats_help_key_func, | |
63 | + }, { | |
64 | + .cmd_keyword = { | |
65 | + ethsw_id_statistics, | |
66 | + ethsw_id_key_end, | |
67 | + }, | |
68 | + .cmd_func_offset = offsetof(struct ethsw_command_func, | |
69 | + port_stats), | |
70 | + .keyword_function = NULL, | |
71 | + }, { | |
72 | + .cmd_keyword = { | |
73 | + ethsw_id_statistics, | |
74 | + ethsw_id_clear, | |
75 | + ethsw_id_key_end, | |
76 | + }, | |
77 | + .cmd_func_offset = offsetof(struct ethsw_command_func, | |
78 | + port_stats_clear), | |
79 | + .keyword_function = NULL, | |
45 | 80 | }, |
46 | 81 | }; |
47 | 82 | |
... | ... | @@ -88,6 +123,12 @@ |
88 | 123 | }, { |
89 | 124 | .keyword_name = "disable", |
90 | 125 | .match = &keyword_match_gen, |
126 | + }, { | |
127 | + .keyword_name = "statistics", | |
128 | + .match = &keyword_match_gen, | |
129 | + }, { | |
130 | + .keyword_name = "clear", | |
131 | + .match = &keyword_match_gen, | |
91 | 132 | }, |
92 | 133 | }; |
93 | 134 | |
... | ... | @@ -344,5 +385,6 @@ |
344 | 385 | U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw, |
345 | 386 | "Ethernet l2 switch commands", |
346 | 387 | ETHSW_PORT_CONF_HELP"\n" |
388 | + ETHSW_PORT_STATS_HELP"\n" | |
347 | 389 | ); |
drivers/net/vsc9953.c
... | ... | @@ -500,6 +500,223 @@ |
500 | 500 | printf("%8s\n", duplex == DUPLEX_FULL ? "full" : "half"); |
501 | 501 | } |
502 | 502 | |
503 | +/* Show VSC9953 ports' statistics */ | |
504 | +static void vsc9953_port_statistics_show(int port_no) | |
505 | +{ | |
506 | + u32 rx_val; | |
507 | + u32 tx_val; | |
508 | + struct vsc9953_system_reg *l2sys_reg; | |
509 | + | |
510 | + /* Administrative down */ | |
511 | + if (!vsc9953_l2sw.port[port_no].enabled) { | |
512 | + printf("Port %d is administrative down\n", port_no); | |
513 | + return; | |
514 | + } | |
515 | + | |
516 | + l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + | |
517 | + VSC9953_SYS_OFFSET); | |
518 | + | |
519 | + printf("Statistics for L2 Switch port %d:\n", port_no); | |
520 | + | |
521 | + /* Set counter view for our port */ | |
522 | + out_le32(&l2sys_reg->sys.stat_cfg, port_no); | |
523 | + | |
524 | +#define VSC9953_STATS_PRINTF "%-15s %10u" | |
525 | + | |
526 | + /* Get number of Rx and Tx frames */ | |
527 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short) + | |
528 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag) + | |
529 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber) + | |
530 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long) + | |
531 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64) + | |
532 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127) + | |
533 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255) + | |
534 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511) + | |
535 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023) + | |
536 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526) + | |
537 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo); | |
538 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) + | |
539 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) + | |
540 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) + | |
541 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) + | |
542 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) + | |
543 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) + | |
544 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo); | |
545 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
546 | + "Rx frames:", rx_val, "Tx frames:", tx_val); | |
547 | + | |
548 | + /* Get number of Rx and Tx bytes */ | |
549 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_oct); | |
550 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_oct); | |
551 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
552 | + "Rx bytes:", rx_val, "Tx bytes:", tx_val); | |
553 | + | |
554 | + /* Get number of Rx frames received ok and Tx frames sent ok */ | |
555 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_0) + | |
556 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_1) + | |
557 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_2) + | |
558 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_3) + | |
559 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_4) + | |
560 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_5) + | |
561 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_6) + | |
562 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_7) + | |
563 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_0) + | |
564 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_1) + | |
565 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_2) + | |
566 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_3) + | |
567 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_4) + | |
568 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_5) + | |
569 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_6) + | |
570 | + in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_7); | |
571 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) + | |
572 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) + | |
573 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) + | |
574 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) + | |
575 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) + | |
576 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) + | |
577 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo); | |
578 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
579 | + "Rx frames ok:", rx_val, "Tx frames ok:", tx_val); | |
580 | + | |
581 | + /* Get number of Rx and Tx unicast frames */ | |
582 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_uc); | |
583 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_uc); | |
584 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
585 | + "Rx unicast:", rx_val, "Tx unicast:", tx_val); | |
586 | + | |
587 | + /* Get number of Rx and Tx broadcast frames */ | |
588 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_bc); | |
589 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_bc); | |
590 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
591 | + "Rx broadcast:", rx_val, "Tx broadcast:", tx_val); | |
592 | + | |
593 | + /* Get number of Rx and Tx frames of 64B */ | |
594 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64); | |
595 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64); | |
596 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
597 | + "Rx 64B:", rx_val, "Tx 64B:", tx_val); | |
598 | + | |
599 | + /* Get number of Rx and Tx frames with sizes between 65B and 127B */ | |
600 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127); | |
601 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127); | |
602 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
603 | + "Rx 65B-127B:", rx_val, "Tx 65B-127B:", tx_val); | |
604 | + | |
605 | + /* Get number of Rx and Tx frames with sizes between 128B and 255B */ | |
606 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255); | |
607 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255); | |
608 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
609 | + "Rx 128B-255B:", rx_val, "Tx 128B-255B:", tx_val); | |
610 | + | |
611 | + /* Get number of Rx and Tx frames with sizes between 256B and 511B */ | |
612 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511); | |
613 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511); | |
614 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
615 | + "Rx 256B-511B:", rx_val, "Tx 256B-511B:", tx_val); | |
616 | + | |
617 | + /* Get number of Rx and Tx frames with sizes between 512B and 1023B */ | |
618 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023); | |
619 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023); | |
620 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
621 | + "Rx 512B-1023B:", rx_val, "Tx 512B-1023B:", tx_val); | |
622 | + | |
623 | + /* Get number of Rx and Tx frames with sizes between 1024B and 1526B */ | |
624 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526); | |
625 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526); | |
626 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
627 | + "Rx 1024B-1526B:", rx_val, "Tx 1024B-1526B:", tx_val); | |
628 | + | |
629 | + /* Get number of Rx and Tx jumbo frames */ | |
630 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo); | |
631 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo); | |
632 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
633 | + "Rx jumbo:", rx_val, "Tx jumbo:", tx_val); | |
634 | + | |
635 | + /* Get number of Rx and Tx dropped frames */ | |
636 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) + | |
637 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_tail) + | |
638 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_0) + | |
639 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_1) + | |
640 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_2) + | |
641 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_3) + | |
642 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_4) + | |
643 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_5) + | |
644 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_6) + | |
645 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_7) + | |
646 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_0) + | |
647 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_1) + | |
648 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_2) + | |
649 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_3) + | |
650 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_4) + | |
651 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_5) + | |
652 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_6) + | |
653 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_7); | |
654 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_drop) + | |
655 | + in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged); | |
656 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
657 | + "Rx drops:", rx_val, "Tx drops:", tx_val); | |
658 | + | |
659 | + /* | |
660 | + * Get number of Rx frames with CRC or alignment errors | |
661 | + * and number of detected Tx collisions | |
662 | + */ | |
663 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_crc); | |
664 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_col); | |
665 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
666 | + "Rx CRC&align:", rx_val, "Tx coll:", tx_val); | |
667 | + | |
668 | + /* | |
669 | + * Get number of Rx undersized frames and | |
670 | + * number of Tx aged frames | |
671 | + */ | |
672 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short); | |
673 | + tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged); | |
674 | + printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n", | |
675 | + "Rx undersize:", rx_val, "Tx aged:", tx_val); | |
676 | + | |
677 | + /* Get number of Rx oversized frames */ | |
678 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long); | |
679 | + printf(VSC9953_STATS_PRINTF"\n", "Rx oversized:", rx_val); | |
680 | + | |
681 | + /* Get number of Rx fragmented frames */ | |
682 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag); | |
683 | + printf(VSC9953_STATS_PRINTF"\n", "Rx fragments:", rx_val); | |
684 | + | |
685 | + /* Get number of Rx jabber errors */ | |
686 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber); | |
687 | + printf(VSC9953_STATS_PRINTF"\n", "Rx jabbers:", rx_val); | |
688 | + | |
689 | + /* | |
690 | + * Get number of Rx frames filtered due to classification rules or | |
691 | + * no destination ports | |
692 | + */ | |
693 | + rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) + | |
694 | + in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_local); | |
695 | + printf(VSC9953_STATS_PRINTF"\n", "Rx filtered:", rx_val); | |
696 | + | |
697 | + printf("\n"); | |
698 | +} | |
699 | + | |
700 | +/* Clear statistics for a VSC9953 port */ | |
701 | +static void vsc9953_port_statistics_clear(int port_no) | |
702 | +{ | |
703 | + struct vsc9953_system_reg *l2sys_reg; | |
704 | + | |
705 | + /* Administrative down */ | |
706 | + if (!vsc9953_l2sw.port[port_no].enabled) { | |
707 | + printf("Port %d is administrative down\n", port_no); | |
708 | + return; | |
709 | + } | |
710 | + | |
711 | + l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET + | |
712 | + VSC9953_SYS_OFFSET); | |
713 | + | |
714 | + /* Clear all counter groups for our ports */ | |
715 | + out_le32(&l2sys_reg->sys.stat_cfg, port_no | | |
716 | + VSC9953_STAT_CLEAR_RX | VSC9953_STAT_CLEAR_TX | | |
717 | + VSC9953_STAT_CLEAR_DR); | |
718 | +} | |
719 | + | |
503 | 720 | static int vsc9953_port_status_key_func(struct ethsw_command_def *parsed_cmd) |
504 | 721 | { |
505 | 722 | int i; |
506 | 723 | |
... | ... | @@ -556,11 +773,50 @@ |
556 | 773 | return CMD_RET_SUCCESS; |
557 | 774 | } |
558 | 775 | |
776 | +static int vsc9953_port_stats_key_func(struct ethsw_command_def *parsed_cmd) | |
777 | +{ | |
778 | + int i; | |
779 | + | |
780 | + if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { | |
781 | + if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { | |
782 | + printf("Invalid port number: %d\n", parsed_cmd->port); | |
783 | + return CMD_RET_FAILURE; | |
784 | + } | |
785 | + vsc9953_port_statistics_show(parsed_cmd->port); | |
786 | + } else { | |
787 | + for (i = 0; i < VSC9953_MAX_PORTS; i++) | |
788 | + vsc9953_port_statistics_show(i); | |
789 | + } | |
790 | + | |
791 | + return CMD_RET_SUCCESS; | |
792 | +} | |
793 | + | |
794 | +static int vsc9953_port_stats_clear_key_func(struct ethsw_command_def | |
795 | + *parsed_cmd) | |
796 | +{ | |
797 | + int i; | |
798 | + | |
799 | + if (parsed_cmd->port != ETHSW_CMD_PORT_ALL) { | |
800 | + if (!VSC9953_PORT_CHECK(parsed_cmd->port)) { | |
801 | + printf("Invalid port number: %d\n", parsed_cmd->port); | |
802 | + return CMD_RET_FAILURE; | |
803 | + } | |
804 | + vsc9953_port_statistics_clear(parsed_cmd->port); | |
805 | + } else { | |
806 | + for (i = 0; i < VSC9953_MAX_PORTS; i++) | |
807 | + vsc9953_port_statistics_clear(i); | |
808 | + } | |
809 | + | |
810 | + return CMD_RET_SUCCESS; | |
811 | +} | |
812 | + | |
559 | 813 | static struct ethsw_command_func vsc9953_cmd_func = { |
560 | 814 | .ethsw_name = "L2 Switch VSC9953", |
561 | 815 | .port_enable = &vsc9953_port_status_key_func, |
562 | 816 | .port_disable = &vsc9953_port_status_key_func, |
563 | 817 | .port_show = &vsc9953_port_config_key_func, |
818 | + .port_stats = &vsc9953_port_stats_key_func, | |
819 | + .port_stats_clear = &vsc9953_port_stats_clear_key_func, | |
564 | 820 | }; |
565 | 821 | |
566 | 822 | #endif /* CONFIG_CMD_ETHSW */ |
include/ethsw.h
... | ... | @@ -20,6 +20,8 @@ |
20 | 20 | ethsw_id_port, |
21 | 21 | ethsw_id_enable, |
22 | 22 | ethsw_id_disable, |
23 | + ethsw_id_statistics, | |
24 | + ethsw_id_clear, | |
23 | 25 | ethsw_id_count, /* keep last */ |
24 | 26 | }; |
25 | 27 | |
... | ... | @@ -41,6 +43,8 @@ |
41 | 43 | int (*port_enable)(struct ethsw_command_def *parsed_cmd); |
42 | 44 | int (*port_disable)(struct ethsw_command_def *parsed_cmd); |
43 | 45 | int (*port_show)(struct ethsw_command_def *parsed_cmd); |
46 | + int (*port_stats)(struct ethsw_command_def *parsed_cmd); | |
47 | + int (*port_stats_clear)(struct ethsw_command_def *parsed_cmd); | |
44 | 48 | }; |
45 | 49 | |
46 | 50 | int ethsw_define_functions(const struct ethsw_command_func *cmd_func); |
include/vsc9953.h
... | ... | @@ -77,6 +77,11 @@ |
77 | 77 | /* Macros for vsc9953_sys_pause_cfgtot_tail_drop_lvl register */ |
78 | 78 | #define VSC9953_TOT_TAIL_DROP_LVL 0x000003ff |
79 | 79 | |
80 | +/* Macros for vsc9953_sys_sys.stat_cfg register */ | |
81 | +#define VSC9953_STAT_CLEAR_RX 0x00000400 | |
82 | +#define VSC9953_STAT_CLEAR_TX 0x00000800 | |
83 | +#define VSC9953_STAT_CLEAR_DR 0x00001000 | |
84 | + | |
80 | 85 | /* Macros for vsc9953_vcap_core_cfg.vcap_mv_cfg register */ |
81 | 86 | #define VSC9953_VCAP_MV_CFG 0x0000ffff |
82 | 87 | #define VSC9953_VCAP_UPDATE_CTRL 0x01000004 |
83 | 88 | |
... | ... | @@ -332,10 +337,115 @@ |
332 | 337 | |
333 | 338 | /* VSC9953 SYS structure */ |
334 | 339 | |
340 | +struct vsc9953_rx_cntrs { | |
341 | + u32 c_rx_oct; | |
342 | + u32 c_rx_uc; | |
343 | + u32 c_rx_mc; | |
344 | + u32 c_rx_bc; | |
345 | + u32 c_rx_short; | |
346 | + u32 c_rx_frag; | |
347 | + u32 c_rx_jabber; | |
348 | + u32 c_rx_crc; | |
349 | + u32 c_rx_symbol_err; | |
350 | + u32 c_rx_sz_64; | |
351 | + u32 c_rx_sz_65_127; | |
352 | + u32 c_rx_sz_128_255; | |
353 | + u32 c_rx_sz_256_511; | |
354 | + u32 c_rx_sz_512_1023; | |
355 | + u32 c_rx_sz_1024_1526; | |
356 | + u32 c_rx_sz_jumbo; | |
357 | + u32 c_rx_pause; | |
358 | + u32 c_rx_control; | |
359 | + u32 c_rx_long; | |
360 | + u32 c_rx_cat_drop; | |
361 | + u32 c_rx_red_prio_0; | |
362 | + u32 c_rx_red_prio_1; | |
363 | + u32 c_rx_red_prio_2; | |
364 | + u32 c_rx_red_prio_3; | |
365 | + u32 c_rx_red_prio_4; | |
366 | + u32 c_rx_red_prio_5; | |
367 | + u32 c_rx_red_prio_6; | |
368 | + u32 c_rx_red_prio_7; | |
369 | + u32 c_rx_yellow_prio_0; | |
370 | + u32 c_rx_yellow_prio_1; | |
371 | + u32 c_rx_yellow_prio_2; | |
372 | + u32 c_rx_yellow_prio_3; | |
373 | + u32 c_rx_yellow_prio_4; | |
374 | + u32 c_rx_yellow_prio_5; | |
375 | + u32 c_rx_yellow_prio_6; | |
376 | + u32 c_rx_yellow_prio_7; | |
377 | + u32 c_rx_green_prio_0; | |
378 | + u32 c_rx_green_prio_1; | |
379 | + u32 c_rx_green_prio_2; | |
380 | + u32 c_rx_green_prio_3; | |
381 | + u32 c_rx_green_prio_4; | |
382 | + u32 c_rx_green_prio_5; | |
383 | + u32 c_rx_green_prio_6; | |
384 | + u32 c_rx_green_prio_7; | |
385 | + u32 reserved[20]; | |
386 | +}; | |
387 | + | |
388 | +struct vsc9953_tx_cntrs { | |
389 | + u32 c_tx_oct; | |
390 | + u32 c_tx_uc; | |
391 | + u32 c_tx_mc; | |
392 | + u32 c_tx_bc; | |
393 | + u32 c_tx_col; | |
394 | + u32 c_tx_drop; | |
395 | + u32 c_tx_pause; | |
396 | + u32 c_tx_sz_64; | |
397 | + u32 c_tx_sz_65_127; | |
398 | + u32 c_tx_sz_128_255; | |
399 | + u32 c_tx_sz_256_511; | |
400 | + u32 c_tx_sz_512_1023; | |
401 | + u32 c_tx_sz_1024_1526; | |
402 | + u32 c_tx_sz_jumbo; | |
403 | + u32 c_tx_yellow_prio_0; | |
404 | + u32 c_tx_yellow_prio_1; | |
405 | + u32 c_tx_yellow_prio_2; | |
406 | + u32 c_tx_yellow_prio_3; | |
407 | + u32 c_tx_yellow_prio_4; | |
408 | + u32 c_tx_yellow_prio_5; | |
409 | + u32 c_tx_yellow_prio_6; | |
410 | + u32 c_tx_yellow_prio_7; | |
411 | + u32 c_tx_green_prio_0; | |
412 | + u32 c_tx_green_prio_1; | |
413 | + u32 c_tx_green_prio_2; | |
414 | + u32 c_tx_green_prio_3; | |
415 | + u32 c_tx_green_prio_4; | |
416 | + u32 c_tx_green_prio_5; | |
417 | + u32 c_tx_green_prio_6; | |
418 | + u32 c_tx_green_prio_7; | |
419 | + u32 c_tx_aged; | |
420 | + u32 reserved[33]; | |
421 | +}; | |
422 | + | |
423 | +struct vsc9953_drop_cntrs { | |
424 | + u32 c_dr_local; | |
425 | + u32 c_dr_tail; | |
426 | + u32 c_dr_yellow_prio_0; | |
427 | + u32 c_dr_yellow_prio_1; | |
428 | + u32 c_dr_yellow_prio_2; | |
429 | + u32 c_dr_yellow_prio_3; | |
430 | + u32 c_dr_yellow_prio_4; | |
431 | + u32 c_dr_yellow_prio_5; | |
432 | + u32 c_dr_yellow_prio_6; | |
433 | + u32 c_dr_yellow_prio_7; | |
434 | + u32 c_dr_green_prio_0; | |
435 | + u32 c_dr_green_prio_1; | |
436 | + u32 c_dr_green_prio_2; | |
437 | + u32 c_dr_green_prio_3; | |
438 | + u32 c_dr_green_prio_4; | |
439 | + u32 c_dr_green_prio_5; | |
440 | + u32 c_dr_green_prio_6; | |
441 | + u32 c_dr_green_prio_7; | |
442 | + u32 reserved[46]; | |
443 | +}; | |
444 | + | |
335 | 445 | struct vsc9953_sys_stat { |
336 | - u32 rx_cntrs[64]; | |
337 | - u32 tx_cntrs[64]; | |
338 | - u32 drop_cntrs[64]; | |
446 | + struct vsc9953_rx_cntrs rx_cntrs; | |
447 | + struct vsc9953_tx_cntrs tx_cntrs; | |
448 | + struct vsc9953_drop_cntrs drop_cntrs; | |
339 | 449 | u32 reserved1[6]; |
340 | 450 | }; |
341 | 451 |