diff mbox

[U-Boot,05/11,v2] drivers/net/vsc9953: Add command to show/clear port counters

Message ID 1435078136-22809-6-git-send-email-codrin.ciubotariu@freescale.com
State Changes Requested
Headers show

Commit Message

Codrin Ciubotariu June 23, 2015, 4:48 p.m. UTC
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.

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com>
---
Changes for v2:
        - removed Change-id field;

 drivers/net/vsc9953.c | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/vsc9953.h     | 116 ++++++++++++++++++++-
 2 files changed, 393 insertions(+), 3 deletions(-)

Comments

Joe Hershberger June 25, 2015, 10:33 p.m. UTC | #1
Hi Codrin,

On Tue, Jun 23, 2015 at 11:48 AM, Codrin Ciubotariu
<codrin.ciubotariu@freescale.com> wrote:
> 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.
>
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com>
> ---
> Changes for v2:
>         - removed Change-id field;
>
>  drivers/net/vsc9953.c | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/vsc9953.h     | 116 ++++++++++++++++++++-
>  2 files changed, 393 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
> index 4df751a..62ab0eb 100644
> --- a/drivers/net/vsc9953.c
> +++ b/drivers/net/vsc9953.c
> @@ -672,6 +672,219 @@ static void vsc9953_port_config_show(int port_no)
>         printf("%8s\n", duplex == DUPLEX_FULL ? "full" : "half");
>  }
>
> +/* Show VSC9953 ports' statistics */
> +static void vsc9953_port_statistics_show(int port_no)
> +{
> +       u32                             rx_val, tx_val;
> +       struct vsc9953_system_reg       *l2sys_reg;

Use a single space. Place each variable on its own line.

> +
> +       /* Administrative down */
> +       if (!vsc9953_l2sw.port[port_no].enabled) {
> +               printf("Port %d is administrative down\n", port_no);
> +               return;
> +       }
> +
> +       l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET +
> +                       VSC9953_SYS_OFFSET);
> +
> +       printf("Statistics for L2 Switch port %d:\n", port_no);
> +
> +       /* Set counter view for our port */
> +       out_le32(&l2sys_reg->sys.stat_cfg, port_no);
> +
> +#define VSC9953_STATS_PRINTF "%-15s %10u"
> +
> +       /* Get number of Rx and Tx frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx frames:", rx_val, "Tx frames:", tx_val);
> +
> +       /* Get number of Rx and Tx bytes */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_oct);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_oct);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx bytes:", rx_val, "Tx bytes:", tx_val);
> +
> +       /* Get number of Rx frames received ok and Tx frames sent ok */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_0) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_1) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_2) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_3) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_4) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_5) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_6) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_7) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_0) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_1) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_2) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_3) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_4) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_5) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_6) +
> +                in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_7);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx frames ok:", rx_val, "Tx frames ok:", tx_val);
> +
> +       /* Get number of Rx and Tx unicast frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_uc);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_uc);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx unicast:", rx_val, "Tx unicast:", tx_val);
> +
> +       /* Get number of Rx and Tx broadcast frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_bc);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_bc);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx broadcast:", rx_val, "Tx broadcast:", tx_val);
> +
> +       /* Get number of Rx and Tx frames of 64B */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx 64B:", rx_val, "Tx 64B:", tx_val);
> +
> +       /* Get number of Rx and Tx frames with sizes between 65B and 127B */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx 65B-127B:", rx_val, "Tx 65B-127B:", tx_val);
> +
> +       /* Get number of Rx and Tx frames with sizes between 128B and 255B */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx 128B-255B:", rx_val, "Tx 128B-255B:", tx_val);
> +
> +       /* Get number of Rx and Tx frames with sizes between 256B and 511B */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx 256B-511B:", rx_val, "Tx 256B-511B:", tx_val);
> +
> +       /* Get number of Rx and Tx frames with sizes between 512B and 1023B */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx 512B-1023B:", rx_val, "Tx 512B-1023B:", tx_val);
> +
> +       /* Get number of Rx and Tx frames with sizes between 1024B and 1526B */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx 1024B-1526B:", rx_val, "Tx 1024B-1526B:", tx_val);
> +
> +       /* Get number of Rx and Tx jumbo frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx jumbo:", rx_val, "Tx jumbo:", tx_val);
> +
> +       /* Get number of Rx and Tx dropped frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_tail) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_0) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_1) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_2) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_3) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_4) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_5) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_6) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_7) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_0) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_1) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_2) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_3) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_4) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_5) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_6) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_7);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_drop) +
> +                in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx drops:", rx_val, "Tx drops:", tx_val);
> +
> +       /* Get number of Rx frames with CRC or alignment errors
> +        * and number of detected Tx collisions
> +        */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_crc);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_col);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx CRC&align:", rx_val, "Tx coll:", tx_val);
> +
> +       /* Get number of Rx undersized frames and
> +        * number of Tx aged frames
> +        */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short);
> +       tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged);
> +       printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
> +              "Rx undersize:", rx_val, "Tx aged:", tx_val);
> +
> +       /* Get number of Rx oversized frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long);
> +       printf(VSC9953_STATS_PRINTF"\n", "Rx oversized:", rx_val);
> +
> +       /* Get number of Rx fragmented frames */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag);
> +       printf(VSC9953_STATS_PRINTF"\n", "Rx fragments:", rx_val);
> +
> +       /* Get number of Rx jabber errors */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber);
> +       printf(VSC9953_STATS_PRINTF"\n", "Rx jabbers:", rx_val);
> +
> +       /* Get number of Rx frames filtered due to classification rules or
> +        * no destination ports
> +        */
> +       rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) +
> +                in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_local);
> +       printf(VSC9953_STATS_PRINTF"\n", "Rx filtered:", rx_val);
> +
> +       printf("\n");
> +}
> +
> +/* Clear statistics for a VSC9953 port */
> +static void vsc9953_port_statistics_clear(int port_no)
> +{
> +       struct vsc9953_system_reg       *l2sys_reg;

Use a single space.

> +
> +       /* Administrative down */
> +       if (!vsc9953_l2sw.port[port_no].enabled) {
> +               printf("Port %d is administrative down\n", port_no);
> +               return;
> +       }
> +
> +       l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET +
> +                               VSC9953_SYS_OFFSET);
> +
> +       /* Clear all counter groups for our ports */
> +       out_le32(&l2sys_reg->sys.stat_cfg, port_no |
> +                CONFIG_VSC9953_STAT_CLEAR_RX | CONFIG_VSC9953_STAT_CLEAR_TX |
> +                CONFIG_VSC9953_STAT_CLEAR_DR);
> +}
> +
>  /* IDs used to track keywords in a command */
>  enum keyword_id {
>         id_key_end = -1,
> @@ -680,6 +893,8 @@ enum keyword_id {
>         id_port,
>         id_enable,
>         id_disable,
> +       id_statistics,
> +       id_clear,
>         id_count,       /* keep last */
>  };
>
> @@ -749,6 +964,44 @@ static int vsc9953_port_config_key_func(struct command_def *parsed_cmd)
>         return 0;
>  }
>
> +#define VSC9953_PORT_STATS_HELP "ethsw [port <port_no>] statistics " \
> +"{ [help] | [clear] } - show an l2 switch port's statistics"
> +
> +static int vsc9953_port_stats_help_key_func(struct command_def *parsed_cmd)
> +{
> +       printf(VSC9953_PORT_STATS_HELP"\n");
> +
> +       return 0;

Please use:
+       return CMD_RET_SUCCESS;

> +}
> +
> +static int vsc9953_port_stats_key_func(struct command_def *parsed_cmd)
> +{
> +       int i;
> +
> +       if (parsed_cmd->port != VSC9953_CMD_PORT_ALL) {
> +               vsc9953_port_statistics_show(parsed_cmd->port);
> +       } else {
> +               for (i = 0; i < VSC9953_MAX_PORTS; i++)
> +                       vsc9953_port_statistics_show(i);
> +       }
> +
> +       return 0;

Please use:
+       return CMD_RET_SUCCESS;

> +}
> +
> +static int vsc9953_port_stats_clear_key_func(struct command_def *parsed_cmd)
> +{
> +       int i;
> +
> +       if (parsed_cmd->port != VSC9953_CMD_PORT_ALL) {
> +               vsc9953_port_statistics_clear(parsed_cmd->port);
> +       } else {
> +               for (i = 0; i < VSC9953_MAX_PORTS; i++)
> +                       vsc9953_port_statistics_clear(i);
> +       }
> +
> +       return 0;

Please use:
+       return CMD_RET_SUCCESS;

> +}
> +
>  struct keywords_to_function {
>         enum keyword_id cmd_keyword[VSC9953_MAX_CMD_PARAMS];
>         int (*keyword_function)(struct command_def *parsed_cmd);
> @@ -771,6 +1024,26 @@ struct keywords_to_function {
>                                         id_key_end,
>                         },
>                         .keyword_function = &vsc9953_port_config_key_func,
> +               }, {
> +                       .cmd_keyword = {
> +                                       id_statistics,
> +                                       id_key_end,
> +                       },
> +                       .keyword_function = &vsc9953_port_stats_key_func,
> +               }, {
> +                       .cmd_keyword = {
> +                                       id_statistics,
> +                                       id_help,
> +                                       id_key_end,
> +                       },
> +                       .keyword_function = &vsc9953_port_stats_help_key_func,

If you're going to add this, shouldn't you also add one that prints
"VSC9953_PORT_CONF_HELP" individually?

> +               }, {
> +                       .cmd_keyword = {
> +                                       id_statistics,
> +                                       id_clear,
> +                                       id_key_end,
> +                       },
> +                       .keyword_function = &vsc9953_port_stats_clear_key_func,
>                 },
>  };
>
> @@ -816,6 +1089,12 @@ struct keyword_def {
>                 }, {
>                                 .keyword_name = "disable",
>                                 .match = &keyword_match_gen,
> +               }, {
> +                               .keyword_name = "statistics",
> +                               .match = &keyword_match_gen,
> +               }, {
> +                               .keyword_name = "clear",
> +                               .match = &keyword_match_gen,
>                 },
>  };
>
> @@ -993,6 +1272,7 @@ __ret:
>  U_BOOT_CMD(ethsw, VSC9953_MAX_CMD_PARAMS, 0, do_ethsw,
>            "vsc9953 l2 switch commands",
>            VSC9953_PORT_CONF_HELP"\n"
> +          VSC9953_PORT_STATS_HELP"\n"
>  );
>
>  #endif /* CONFIG_VSC9953_CMD */
> diff --git a/include/vsc9953.h b/include/vsc9953.h
> index bf81623..482acac 100644
> --- a/include/vsc9953.h
> +++ b/include/vsc9953.h
> @@ -84,6 +84,11 @@
>  /* Macros for vsc9953_sys_pause_cfgtot_tail_drop_lvl register */
>  #define CONFIG_VSC9953_TOT_TAIL_DROP_LVL       0x000003ff
>
> +/* Macros for vsc9953_sys_sys.stat_cfg register */
> +#define CONFIG_VSC9953_STAT_CLEAR_RX   0x00000400
> +#define CONFIG_VSC9953_STAT_CLEAR_TX   0x00000800
> +#define CONFIG_VSC9953_STAT_CLEAR_DR   0x00001000
> +
>  /* Macros for vsc9953_vcap_core_cfg.vcap_mv_cfg register */
>  #define        CONFIG_VSC9953_VCAP_MV_CFG      0x0000ffff
>  #define        CONFIG_VSC9953_VCAP_UPDATE_CTRL 0x01000004
> @@ -339,10 +344,115 @@ struct   vsc9953_qsys_reg {
>
>  /* VSC9953 SYS structure for T1040 U-boot*/
>
> +struct vsc9953_rx_cntrs {
> +       u32     c_rx_oct;
> +       u32     c_rx_uc;
> +       u32     c_rx_mc;
> +       u32     c_rx_bc;
> +       u32     c_rx_short;
> +       u32     c_rx_frag;
> +       u32     c_rx_jabber;
> +       u32     c_rx_crc;
> +       u32     c_rx_symbol_err;
> +       u32     c_rx_sz_64;
> +       u32     c_rx_sz_65_127;
> +       u32     c_rx_sz_128_255;
> +       u32     c_rx_sz_256_511;
> +       u32     c_rx_sz_512_1023;
> +       u32     c_rx_sz_1024_1526;
> +       u32     c_rx_sz_jumbo;
> +       u32     c_rx_pause;
> +       u32     c_rx_control;
> +       u32     c_rx_long;
> +       u32     c_rx_cat_drop;
> +       u32     c_rx_red_prio_0;
> +       u32     c_rx_red_prio_1;
> +       u32     c_rx_red_prio_2;
> +       u32     c_rx_red_prio_3;
> +       u32     c_rx_red_prio_4;
> +       u32     c_rx_red_prio_5;
> +       u32     c_rx_red_prio_6;
> +       u32     c_rx_red_prio_7;
> +       u32     c_rx_yellow_prio_0;
> +       u32     c_rx_yellow_prio_1;
> +       u32     c_rx_yellow_prio_2;
> +       u32     c_rx_yellow_prio_3;
> +       u32     c_rx_yellow_prio_4;
> +       u32     c_rx_yellow_prio_5;
> +       u32     c_rx_yellow_prio_6;
> +       u32     c_rx_yellow_prio_7;
> +       u32     c_rx_green_prio_0;
> +       u32     c_rx_green_prio_1;
> +       u32     c_rx_green_prio_2;
> +       u32     c_rx_green_prio_3;
> +       u32     c_rx_green_prio_4;
> +       u32     c_rx_green_prio_5;
> +       u32     c_rx_green_prio_6;
> +       u32     c_rx_green_prio_7;
> +       u32     reserved[20];
> +};
> +
> +struct vsc9953_tx_cntrs {
> +       u32     c_tx_oct;
> +       u32     c_tx_uc;
> +       u32     c_tx_mc;
> +       u32     c_tx_bc;
> +       u32     c_tx_col;
> +       u32     c_tx_drop;
> +       u32     c_tx_pause;
> +       u32     c_tx_sz_64;
> +       u32     c_tx_sz_65_127;
> +       u32     c_tx_sz_128_255;
> +       u32     c_tx_sz_256_511;
> +       u32     c_tx_sz_512_1023;
> +       u32     c_tx_sz_1024_1526;
> +       u32     c_tx_sz_jumbo;
> +       u32     c_tx_yellow_prio_0;
> +       u32     c_tx_yellow_prio_1;
> +       u32     c_tx_yellow_prio_2;
> +       u32     c_tx_yellow_prio_3;
> +       u32     c_tx_yellow_prio_4;
> +       u32     c_tx_yellow_prio_5;
> +       u32     c_tx_yellow_prio_6;
> +       u32     c_tx_yellow_prio_7;
> +       u32     c_tx_green_prio_0;
> +       u32     c_tx_green_prio_1;
> +       u32     c_tx_green_prio_2;
> +       u32     c_tx_green_prio_3;
> +       u32     c_tx_green_prio_4;
> +       u32     c_tx_green_prio_5;
> +       u32     c_tx_green_prio_6;
> +       u32     c_tx_green_prio_7;
> +       u32     c_tx_aged;
> +       u32     reserved[33];
> +};
> +
> +struct vsc9953_drop_cntrs {
> +       u32     c_dr_local;
> +       u32     c_dr_tail;
> +       u32     c_dr_yellow_prio_0;
> +       u32     c_dr_yellow_prio_1;
> +       u32     c_dr_yellow_prio_2;
> +       u32     c_dr_yellow_prio_3;
> +       u32     c_dr_yellow_prio_4;
> +       u32     c_dr_yellow_prio_5;
> +       u32     c_dr_yellow_prio_6;
> +       u32     c_dr_yellow_prio_7;
> +       u32     c_dr_green_prio_0;
> +       u32     c_dr_green_prio_1;
> +       u32     c_dr_green_prio_2;
> +       u32     c_dr_green_prio_3;
> +       u32     c_dr_green_prio_4;
> +       u32     c_dr_green_prio_5;
> +       u32     c_dr_green_prio_6;
> +       u32     c_dr_green_prio_7;
> +       u32     reserved[46];
> +};
> +
>  struct vsc9953_sys_stat {
> -       u32     rx_cntrs[64];
> -       u32     tx_cntrs[64];
> -       u32     drop_cntrs[64];
> +       struct vsc9953_rx_cntrs         rx_cntrs;
> +       struct vsc9953_tx_cntrs         tx_cntrs;
> +       struct vsc9953_drop_cntrs       drop_cntrs;
>         u32     reserved1[6];
>  };
>
> --
> 1.9.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Codrin Ciubotariu June 30, 2015, 9:01 a.m. UTC | #2
Hi Joe,

I will make the changes you requested.

Thanks and best regards,
Codrin

> -----Original Message-----
> From: Joe Hershberger [mailto:joe.hershberger@gmail.com]
> Sent: Friday, June 26, 2015 1:34 AM
> To: Ciubotariu Codrin Constantin-B43658
> Cc: u-boot; Joe Hershberger; Sun York-R58495
> Subject: Re: [U-Boot] [PATCH 05/11 v2] drivers/net/vsc9953: Add command to
> show/clear port counters
diff mbox

Patch

diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
index 4df751a..62ab0eb 100644
--- a/drivers/net/vsc9953.c
+++ b/drivers/net/vsc9953.c
@@ -672,6 +672,219 @@  static void vsc9953_port_config_show(int port_no)
 	printf("%8s\n", duplex == DUPLEX_FULL ? "full" : "half");
 }
 
+/* Show VSC9953 ports' statistics */
+static void vsc9953_port_statistics_show(int port_no)
+{
+	u32				rx_val, tx_val;
+	struct vsc9953_system_reg	*l2sys_reg;
+
+	/* Administrative down */
+	if (!vsc9953_l2sw.port[port_no].enabled) {
+		printf("Port %d is administrative down\n", port_no);
+		return;
+	}
+
+	l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET +
+			VSC9953_SYS_OFFSET);
+
+	printf("Statistics for L2 Switch port %d:\n", port_no);
+
+	/* Set counter view for our port */
+	out_le32(&l2sys_reg->sys.stat_cfg, port_no);
+
+#define VSC9953_STATS_PRINTF "%-15s %10u"
+
+	/* Get number of Rx and Tx frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx frames:", rx_val, "Tx frames:", tx_val);
+
+	/* Get number of Rx and Tx bytes */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_oct);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_oct);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx bytes:", rx_val, "Tx bytes:", tx_val);
+
+	/* Get number of Rx frames received ok and Tx frames sent ok */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_0) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_1) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_2) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_3) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_4) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_5) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_6) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_yellow_prio_7) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_0) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_1) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_2) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_3) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_4) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_5) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_6) +
+		 in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_green_prio_7);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx frames ok:", rx_val, "Tx frames ok:", tx_val);
+
+	/* Get number of Rx and Tx unicast frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_uc);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_uc);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx unicast:", rx_val, "Tx unicast:", tx_val);
+
+	/* Get number of Rx and Tx broadcast frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_bc);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_bc);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx broadcast:", rx_val, "Tx broadcast:", tx_val);
+
+	/* Get number of Rx and Tx frames of 64B */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_64);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_64);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx 64B:", rx_val, "Tx 64B:", tx_val);
+
+	/* Get number of Rx and Tx frames with sizes between 65B and 127B */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_65_127);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_65_127);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx 65B-127B:", rx_val, "Tx 65B-127B:", tx_val);
+
+	/* Get number of Rx and Tx frames with sizes between 128B and 255B */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_128_255);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_128_255);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx 128B-255B:", rx_val, "Tx 128B-255B:", tx_val);
+
+	/* Get number of Rx and Tx frames with sizes between 256B and 511B */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_256_511);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_256_511);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx 256B-511B:", rx_val, "Tx 256B-511B:", tx_val);
+
+	/* Get number of Rx and Tx frames with sizes between 512B and 1023B */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_512_1023);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_512_1023);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx 512B-1023B:", rx_val, "Tx 512B-1023B:", tx_val);
+
+	/* Get number of Rx and Tx frames with sizes between 1024B and 1526B */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_1024_1526);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_1024_1526);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx 1024B-1526B:", rx_val, "Tx 1024B-1526B:", tx_val);
+
+	/* Get number of Rx and Tx jumbo frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_sz_jumbo);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_sz_jumbo);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx jumbo:", rx_val, "Tx jumbo:", tx_val);
+
+	/* Get number of Rx and Tx dropped frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_tail) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_0) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_1) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_2) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_3) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_4) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_5) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_6) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_yellow_prio_7) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_0) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_1) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_2) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_3) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_4) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_5) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_6) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_green_prio_7);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_drop) +
+		 in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx drops:", rx_val, "Tx drops:", tx_val);
+
+	/* Get number of Rx frames with CRC or alignment errors
+	 * and number of detected Tx collisions
+	 */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_crc);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_col);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx CRC&align:", rx_val, "Tx coll:", tx_val);
+
+	/* Get number of Rx undersized frames and
+	 * number of Tx aged frames
+	 */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_short);
+	tx_val = in_le32(&l2sys_reg->stat.tx_cntrs.c_tx_aged);
+	printf(VSC9953_STATS_PRINTF"\t\t"VSC9953_STATS_PRINTF"\n",
+	       "Rx undersize:", rx_val, "Tx aged:", tx_val);
+
+	/* Get number of Rx oversized frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_long);
+	printf(VSC9953_STATS_PRINTF"\n", "Rx oversized:", rx_val);
+
+	/* Get number of Rx fragmented frames */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_frag);
+	printf(VSC9953_STATS_PRINTF"\n", "Rx fragments:", rx_val);
+
+	/* Get number of Rx jabber errors */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_jabber);
+	printf(VSC9953_STATS_PRINTF"\n", "Rx jabbers:", rx_val);
+
+	/* Get number of Rx frames filtered due to classification rules or
+	 * no destination ports
+	 */
+	rx_val = in_le32(&l2sys_reg->stat.rx_cntrs.c_rx_cat_drop) +
+		 in_le32(&l2sys_reg->stat.drop_cntrs.c_dr_local);
+	printf(VSC9953_STATS_PRINTF"\n", "Rx filtered:", rx_val);
+
+	printf("\n");
+}
+
+/* Clear statistics for a VSC9953 port */
+static void vsc9953_port_statistics_clear(int port_no)
+{
+	struct vsc9953_system_reg	*l2sys_reg;
+
+	/* Administrative down */
+	if (!vsc9953_l2sw.port[port_no].enabled) {
+		printf("Port %d is administrative down\n", port_no);
+		return;
+	}
+
+	l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET +
+				VSC9953_SYS_OFFSET);
+
+	/* Clear all counter groups for our ports */
+	out_le32(&l2sys_reg->sys.stat_cfg, port_no |
+		 CONFIG_VSC9953_STAT_CLEAR_RX | CONFIG_VSC9953_STAT_CLEAR_TX |
+		 CONFIG_VSC9953_STAT_CLEAR_DR);
+}
+
 /* IDs used to track keywords in a command */
 enum keyword_id {
 	id_key_end = -1,
@@ -680,6 +893,8 @@  enum keyword_id {
 	id_port,
 	id_enable,
 	id_disable,
+	id_statistics,
+	id_clear,
 	id_count,	/* keep last */
 };
 
@@ -749,6 +964,44 @@  static int vsc9953_port_config_key_func(struct command_def *parsed_cmd)
 	return 0;
 }
 
+#define VSC9953_PORT_STATS_HELP "ethsw [port <port_no>] statistics " \
+"{ [help] | [clear] } - show an l2 switch port's statistics"
+
+static int vsc9953_port_stats_help_key_func(struct command_def *parsed_cmd)
+{
+	printf(VSC9953_PORT_STATS_HELP"\n");
+
+	return 0;
+}
+
+static int vsc9953_port_stats_key_func(struct command_def *parsed_cmd)
+{
+	int i;
+
+	if (parsed_cmd->port != VSC9953_CMD_PORT_ALL) {
+		vsc9953_port_statistics_show(parsed_cmd->port);
+	} else {
+		for (i = 0; i < VSC9953_MAX_PORTS; i++)
+			vsc9953_port_statistics_show(i);
+	}
+
+	return 0;
+}
+
+static int vsc9953_port_stats_clear_key_func(struct command_def *parsed_cmd)
+{
+	int i;
+
+	if (parsed_cmd->port != VSC9953_CMD_PORT_ALL) {
+		vsc9953_port_statistics_clear(parsed_cmd->port);
+	} else {
+		for (i = 0; i < VSC9953_MAX_PORTS; i++)
+			vsc9953_port_statistics_clear(i);
+	}
+
+	return 0;
+}
+
 struct keywords_to_function {
 	enum keyword_id cmd_keyword[VSC9953_MAX_CMD_PARAMS];
 	int (*keyword_function)(struct command_def *parsed_cmd);
@@ -771,6 +1024,26 @@  struct keywords_to_function {
 					id_key_end,
 			},
 			.keyword_function = &vsc9953_port_config_key_func,
+		}, {
+			.cmd_keyword = {
+					id_statistics,
+					id_key_end,
+			},
+			.keyword_function = &vsc9953_port_stats_key_func,
+		}, {
+			.cmd_keyword = {
+					id_statistics,
+					id_help,
+					id_key_end,
+			},
+			.keyword_function = &vsc9953_port_stats_help_key_func,
+		}, {
+			.cmd_keyword = {
+					id_statistics,
+					id_clear,
+					id_key_end,
+			},
+			.keyword_function = &vsc9953_port_stats_clear_key_func,
 		},
 };
 
@@ -816,6 +1089,12 @@  struct keyword_def {
 		}, {
 				.keyword_name = "disable",
 				.match = &keyword_match_gen,
+		}, {
+				.keyword_name = "statistics",
+				.match = &keyword_match_gen,
+		}, {
+				.keyword_name = "clear",
+				.match = &keyword_match_gen,
 		},
 };
 
@@ -993,6 +1272,7 @@  __ret:
 U_BOOT_CMD(ethsw, VSC9953_MAX_CMD_PARAMS, 0, do_ethsw,
 	   "vsc9953 l2 switch commands",
 	   VSC9953_PORT_CONF_HELP"\n"
+	   VSC9953_PORT_STATS_HELP"\n"
 );
 
 #endif /* CONFIG_VSC9953_CMD */
diff --git a/include/vsc9953.h b/include/vsc9953.h
index bf81623..482acac 100644
--- a/include/vsc9953.h
+++ b/include/vsc9953.h
@@ -84,6 +84,11 @@ 
 /* Macros for vsc9953_sys_pause_cfgtot_tail_drop_lvl register */
 #define CONFIG_VSC9953_TOT_TAIL_DROP_LVL	0x000003ff
 
+/* Macros for vsc9953_sys_sys.stat_cfg register */
+#define CONFIG_VSC9953_STAT_CLEAR_RX	0x00000400
+#define CONFIG_VSC9953_STAT_CLEAR_TX	0x00000800
+#define CONFIG_VSC9953_STAT_CLEAR_DR	0x00001000
+
 /* Macros for vsc9953_vcap_core_cfg.vcap_mv_cfg register */
 #define	CONFIG_VSC9953_VCAP_MV_CFG	0x0000ffff
 #define	CONFIG_VSC9953_VCAP_UPDATE_CTRL	0x01000004
@@ -339,10 +344,115 @@  struct	vsc9953_qsys_reg {
 
 /* VSC9953 SYS structure for T1040 U-boot*/
 
+struct vsc9953_rx_cntrs {
+	u32	c_rx_oct;
+	u32	c_rx_uc;
+	u32	c_rx_mc;
+	u32	c_rx_bc;
+	u32	c_rx_short;
+	u32	c_rx_frag;
+	u32	c_rx_jabber;
+	u32	c_rx_crc;
+	u32	c_rx_symbol_err;
+	u32	c_rx_sz_64;
+	u32	c_rx_sz_65_127;
+	u32	c_rx_sz_128_255;
+	u32	c_rx_sz_256_511;
+	u32	c_rx_sz_512_1023;
+	u32	c_rx_sz_1024_1526;
+	u32	c_rx_sz_jumbo;
+	u32	c_rx_pause;
+	u32	c_rx_control;
+	u32	c_rx_long;
+	u32	c_rx_cat_drop;
+	u32	c_rx_red_prio_0;
+	u32	c_rx_red_prio_1;
+	u32	c_rx_red_prio_2;
+	u32	c_rx_red_prio_3;
+	u32	c_rx_red_prio_4;
+	u32	c_rx_red_prio_5;
+	u32	c_rx_red_prio_6;
+	u32	c_rx_red_prio_7;
+	u32	c_rx_yellow_prio_0;
+	u32	c_rx_yellow_prio_1;
+	u32	c_rx_yellow_prio_2;
+	u32	c_rx_yellow_prio_3;
+	u32	c_rx_yellow_prio_4;
+	u32	c_rx_yellow_prio_5;
+	u32	c_rx_yellow_prio_6;
+	u32	c_rx_yellow_prio_7;
+	u32	c_rx_green_prio_0;
+	u32	c_rx_green_prio_1;
+	u32	c_rx_green_prio_2;
+	u32	c_rx_green_prio_3;
+	u32	c_rx_green_prio_4;
+	u32	c_rx_green_prio_5;
+	u32	c_rx_green_prio_6;
+	u32	c_rx_green_prio_7;
+	u32	reserved[20];
+};
+
+struct	vsc9953_tx_cntrs {
+	u32	c_tx_oct;
+	u32	c_tx_uc;
+	u32	c_tx_mc;
+	u32	c_tx_bc;
+	u32	c_tx_col;
+	u32	c_tx_drop;
+	u32	c_tx_pause;
+	u32	c_tx_sz_64;
+	u32	c_tx_sz_65_127;
+	u32	c_tx_sz_128_255;
+	u32	c_tx_sz_256_511;
+	u32	c_tx_sz_512_1023;
+	u32	c_tx_sz_1024_1526;
+	u32	c_tx_sz_jumbo;
+	u32	c_tx_yellow_prio_0;
+	u32	c_tx_yellow_prio_1;
+	u32	c_tx_yellow_prio_2;
+	u32	c_tx_yellow_prio_3;
+	u32	c_tx_yellow_prio_4;
+	u32	c_tx_yellow_prio_5;
+	u32	c_tx_yellow_prio_6;
+	u32	c_tx_yellow_prio_7;
+	u32	c_tx_green_prio_0;
+	u32	c_tx_green_prio_1;
+	u32	c_tx_green_prio_2;
+	u32	c_tx_green_prio_3;
+	u32	c_tx_green_prio_4;
+	u32	c_tx_green_prio_5;
+	u32	c_tx_green_prio_6;
+	u32	c_tx_green_prio_7;
+	u32	c_tx_aged;
+	u32	reserved[33];
+};
+
+struct	vsc9953_drop_cntrs {
+	u32	c_dr_local;
+	u32	c_dr_tail;
+	u32	c_dr_yellow_prio_0;
+	u32	c_dr_yellow_prio_1;
+	u32	c_dr_yellow_prio_2;
+	u32	c_dr_yellow_prio_3;
+	u32	c_dr_yellow_prio_4;
+	u32	c_dr_yellow_prio_5;
+	u32	c_dr_yellow_prio_6;
+	u32	c_dr_yellow_prio_7;
+	u32	c_dr_green_prio_0;
+	u32	c_dr_green_prio_1;
+	u32	c_dr_green_prio_2;
+	u32	c_dr_green_prio_3;
+	u32	c_dr_green_prio_4;
+	u32	c_dr_green_prio_5;
+	u32	c_dr_green_prio_6;
+	u32	c_dr_green_prio_7;
+	u32	reserved[46];
+};
+
 struct	vsc9953_sys_stat {
-	u32	rx_cntrs[64];
-	u32	tx_cntrs[64];
-	u32	drop_cntrs[64];
+	struct vsc9953_rx_cntrs		rx_cntrs;
+	struct vsc9953_tx_cntrs		tx_cntrs;
+	struct vsc9953_drop_cntrs	drop_cntrs;
 	u32	reserved1[6];
 };