cmd: net: add a 'net stats' command to dump network statistics

Add a new option to the 'net' command which can be used to dump network
statistics.

To do this, 3 new callbacks are added to the eth_ops structure:
.get_sset_count(), .get_strings(), .get_stats(). These callbacks
have the same functions as in Linux: to return the number of counters,
the strings which describe those counters and the actual values.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Ioana Ciornei 2023-05-23 16:47:47 +03:00 committed by Peng Fan
parent 22df08d82e
commit c85e96d0d1
2 changed files with 59 additions and 1 deletions

View file

@ -167,6 +167,9 @@ enum eth_recv_flags {
* to the network stack. This function should fill in the
* eth_pdata::enetaddr field - optional
* set_promisc: Enable or Disable promiscuous mode
* get_sset_count: Number of statistics counters
* get_string: Names of the statistic counters
* get_stats: The values of the statistic counters
*/
struct eth_ops {
int (*start)(struct udevice *dev);
@ -178,6 +181,9 @@ struct eth_ops {
int (*write_hwaddr)(struct udevice *dev);
int (*read_rom_hwaddr)(struct udevice *dev);
int (*set_promisc)(struct udevice *dev, bool enable);
int (*get_sset_count)(struct udevice *dev);
void (*get_strings)(struct udevice *dev, u8 *data);
void (*get_stats)(struct udevice *dev, u64 *data);
};
#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops)