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>
This commit is contained in:
Codrin Ciubotariu
2015-07-24 16:55:29 +03:00
committed by York Sun
parent 24a23deb90
commit 86719f0cd5
4 changed files with 415 additions and 3 deletions

View File

@@ -13,6 +13,16 @@
static const char *ethsw_name;
#define ETHSW_PORT_STATS_HELP "ethsw [port <port_no>] statistics " \
"{ [help] | [clear] } - show an l2 switch port's statistics"
static int ethsw_port_stats_help_key_func(struct ethsw_command_def *parsed_cmd)
{
printf(ETHSW_PORT_STATS_HELP"\n");
return CMD_RET_SUCCESS;
}
static struct keywords_to_function {
enum ethsw_keyword_id cmd_keyword[ETHSW_MAX_CMD_PARAMS];
int cmd_func_offset;
@@ -42,6 +52,31 @@ static struct keywords_to_function {
.cmd_func_offset = offsetof(struct ethsw_command_func,
port_show),
.keyword_function = NULL,
}, {
.cmd_keyword = {
ethsw_id_statistics,
ethsw_id_help,
ethsw_id_key_end,
},
.cmd_func_offset = -1,
.keyword_function = &ethsw_port_stats_help_key_func,
}, {
.cmd_keyword = {
ethsw_id_statistics,
ethsw_id_key_end,
},
.cmd_func_offset = offsetof(struct ethsw_command_func,
port_stats),
.keyword_function = NULL,
}, {
.cmd_keyword = {
ethsw_id_statistics,
ethsw_id_clear,
ethsw_id_key_end,
},
.cmd_func_offset = offsetof(struct ethsw_command_func,
port_stats_clear),
.keyword_function = NULL,
},
};
@@ -88,6 +123,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,
},
};
@@ -344,4 +385,5 @@ static int do_ethsw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(ethsw, ETHSW_MAX_CMD_PARAMS, 0, do_ethsw,
"Ethernet l2 switch commands",
ETHSW_PORT_CONF_HELP"\n"
ETHSW_PORT_STATS_HELP"\n"
);