Skip to content
Snippets Groups Projects
Commit 2a333afc authored by Oussama Ghorbel's avatar Oussama Ghorbel Committed by Anjan Chanda
Browse files

libethernet: bcm : read extended stats from proc

parent ba7c1395
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
* Copyright (C) 2018 iopsys Software Solutions AB. All rights reserved.
*
* Author: anjan.chanda@iopsys.eu
* oussama.ghorbel@iopsys.eu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -225,10 +226,10 @@ static int bcm_eth_get_stats_from_proc(const char *ifname, struct eth_stats *s)
unsigned long rx_fifo, rx_frame, rx_comp, rx_multi;
unsigned long tx_bytes, tx_packets, tx_err, tx_drop;
unsigned long tx_fifo, tx_coll, tx_carr, tx_comp;
unsigned long tx_mcast_packets, rx_mcast_bytes, tx_mcast_bytes;
unsigned long rx_ucast_packets, tx_ucast_packets;
unsigned long rx_bcast_packets, tx_bcast_packets;
unsigned long rx_err_unknown;
unsigned long tx_mcast_packets = 0, rx_mcast_bytes = 0, tx_mcast_bytes = 0;
unsigned long rx_ucast_packets = 0, tx_ucast_packets = 0;
unsigned long rx_bcast_packets = 0, tx_bcast_packets = 0;
unsigned long rx_err_unknown = 0;
char cmdbuf[512] = {0};
char *ptr;
int ret;
......@@ -253,7 +254,7 @@ static int bcm_eth_get_stats_from_proc(const char *ifname, struct eth_stats *s)
&rx_bcast_packets, &tx_bcast_packets,
&rx_err_unknown);
if (ret != 12)
if (ret < 16)
return -1;
s->tx_bytes = tx_bytes;
......@@ -262,14 +263,14 @@ static int bcm_eth_get_stats_from_proc(const char *ifname, struct eth_stats *s)
s->rx_packets = rx_packets;
s->tx_errors = tx_err;
s->rx_errors = rx_err;
s->tx_discard_packets = tx_drop;
s->rx_discard_packets = rx_drop;
s->tx_ucast_packets = tx_ucast_packets;
s->rx_ucast_packets = rx_ucast_packets;
s->tx_mcast_packets = tx_mcast_packets;
s->rx_mcast_packets = INVALID_UINT32; /* 'rx_mcast_bytes' available */
s->tx_bcast_packets = tx_bcast_packets;
s->rx_bcast_packets = rx_bcast_packets;
s->tx_discard_packets = tx_drop;
s->rx_discard_packets = rx_drop;
s->rx_unknown_packets = rx_err_unknown;
return 0;
......
......@@ -55,10 +55,11 @@ const struct eth_ops *get_eth_driver(const char *ifname)
{
int i;
for (i = 0; i < sizeof(eth_ops)/sizeof(eth_ops[0]); i++)
for (i = 0; i < sizeof(eth_ops)/sizeof(eth_ops[0]); i++) {
if (!strncmp(eth_ops[i]->ifname, ifname,
strlen(eth_ops[i]->ifname)))
return eth_ops[i];
}
return NULL;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment