Skip to content
Snippets Groups Projects
Commit b7656aa6 authored by Mohd Husaam Mehdi's avatar Mohd Husaam Mehdi
Browse files

Add support for clear_stats

parent ea91b056
Branches
No related tags found
1 merge request!12Add support for clear_stats
Pipeline #124378 failed
...@@ -474,6 +474,31 @@ int bcm_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon) ...@@ -474,6 +474,31 @@ int bcm_eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
return 0; return 0;
} }
int bcm_eth_clear_stats(const char *ifname)
{
int ret, unit = -1, port = -1;
struct ethswctl_data data;
memset(&data, 0, sizeof(struct ethswctl_data));
ret = bcm_eth_get_unit_port(ifname, &unit, &port);
if (ret)
return -1;
data.op = ETHSWSTATPORTCLR;
data.port = port;
data.unit = unit;
ret = eth_ioctl(ifname, SIOCETHSWCTLOPS, &data,
sizeof(struct ethswctl_data));
if (ret != 0) {
libethernet_err("ioctl failed! ret = %d\n", ret);
return -1;
}
return 0;
}
const struct eth_ops bcm_eth_ops = { const struct eth_ops bcm_eth_ops = {
.ifname = "eth", .ifname = "eth",
//.up = bcm_eth_up, //.up = bcm_eth_up,
...@@ -485,4 +510,5 @@ const struct eth_ops bcm_eth_ops = { ...@@ -485,4 +510,5 @@ const struct eth_ops bcm_eth_ops = {
.poweron_phy = bcm_eth_poweron_phy, .poweron_phy = bcm_eth_poweron_phy,
.poweroff_phy = bcm_eth_poweroff_phy, .poweroff_phy = bcm_eth_poweroff_phy,
.reset_phy = bcm_eth_reset_phy, .reset_phy = bcm_eth_reset_phy,
.clear_stats = bcm_eth_clear_stats,
}; };
...@@ -138,6 +138,27 @@ int econet_eth_reset_phy(const char *name, int phy_id) ...@@ -138,6 +138,27 @@ int econet_eth_reset_phy(const char *name, int phy_id)
return 0; return 0;
} }
int econet_clear_stats(const char *ifname)
{
char clear_stats_filename[128] = {0};
FILE *fp = NULL;
// clear stats files are named as eth0.1_clear_stats etc.
snprintf(clear_stats_filename, sizeof(clear_stats_filename), "/proc/tc3162/%s_clear_stats", ifname);
fp = fopen(clear_stats_filename, "w");
if (!fp) {
libethernet_err("%s(): fopen() failed for %s\n", __func__, clear_stats_filename);
return -1;
} else {
// just write 1 to clear the stats
fprintf(fp, "1");
fclose(fp);
}
return 0;
}
/* Declare separate eth ops for all known Econet interfaces */ /* Declare separate eth ops for all known Econet interfaces */
#define ECNT_ETH_OPS(__name, __interface_name) \ #define ECNT_ETH_OPS(__name, __interface_name) \
const struct eth_ops __name = { \ const struct eth_ops __name = { \
...@@ -149,6 +170,7 @@ const struct eth_ops __name = { \ ...@@ -149,6 +170,7 @@ const struct eth_ops __name = { \
.poweron_phy = econet_eth_poweron_phy, \ .poweron_phy = econet_eth_poweron_phy, \
.poweroff_phy = econet_eth_poweroff_phy, \ .poweroff_phy = econet_eth_poweroff_phy, \
.reset_phy = econet_eth_reset_phy, \ .reset_phy = econet_eth_reset_phy, \
.clear_stats = econet_clear_stats, \
} }
ECNT_ETH_OPS(econet_gen_eth_ops, "eth"); ECNT_ETH_OPS(econet_gen_eth_ops, "eth");
......
...@@ -165,6 +165,16 @@ int eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon) ...@@ -165,6 +165,16 @@ int eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon)
return -1; return -1;
} }
int eth_clear_stats(const char *ifname)
{
const struct eth_ops *eth = get_eth_driver(ifname);
if (eth && eth->clear_stats)
return eth->clear_stats(ifname);
return -1;
}
int eth_poweron_phy(const char *ifname, struct eth_phy p) int eth_poweron_phy(const char *ifname, struct eth_phy p)
{ {
const struct eth_ops *eth = get_eth_driver(ifname); const struct eth_ops *eth = get_eth_driver(ifname);
......
...@@ -207,6 +207,8 @@ struct eth_ops { ...@@ -207,6 +207,8 @@ struct eth_ops {
int (*get_stats)(const char *ifname, struct eth_stats *s); int (*get_stats)(const char *ifname, struct eth_stats *s);
int (*get_info)(const char *ifname, struct eth_info *info); int (*get_info)(const char *ifname, struct eth_info *info);
int (*get_rmon_stats)(const char *ifname, struct eth_rmon_stats *rmon); int (*get_rmon_stats)(const char *ifname, struct eth_rmon_stats *rmon);
int (*clear_stats)(const char *ifname);
}; };
...@@ -220,6 +222,7 @@ int eth_set_operstate(const char *ifname, ifopstatus_t s); ...@@ -220,6 +222,7 @@ int eth_set_operstate(const char *ifname, ifopstatus_t s);
int eth_get_stats(const char *ifname, struct eth_stats *c); int eth_get_stats(const char *ifname, struct eth_stats *c);
int eth_get_info(const char *ifname, struct eth_info *info); int eth_get_info(const char *ifname, struct eth_info *info);
int eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon); int eth_get_rmon_stats(const char *ifname, struct eth_rmon_stats *rmon);
int eth_clear_stats(const char *ifname);
int eth_reset_phy(const char *ifname, int phy_id); int eth_reset_phy(const char *ifname, int phy_id);
int eth_poweroff_phy(const char *ifname, struct eth_phy p); int eth_poweroff_phy(const char *ifname, struct eth_phy p);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment