mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 19:31:42 -04:00
bng_en: implement ndo_get_stats64
Implement the ndo_get_stats64 callback to report aggregate network statistics. The driver gathers these by accumulating the per-ring counters into the provided rtnl_link_stats64 structure. Signed-off-by: Bhargava Marreddy <bhargava.marreddy@broadcom.com> Reviewed-by: Vikas Gupta <vikas.gupta@broadcom.com> Link: https://patch.msgid.link/20260406180420.279470-9-bhargava.marreddy@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
50c885cb2e
commit
d4f802eb4e
@@ -2898,6 +2898,46 @@ static int bnge_shutdown_nic(struct bnge_net *bn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bnge_get_port_stats64(struct bnge_net *bn,
|
||||
struct rtnl_link_stats64 *stats)
|
||||
{
|
||||
unsigned int start;
|
||||
u64 *tx, *rx;
|
||||
|
||||
rx = bn->port_stats.sw_stats;
|
||||
tx = bn->port_stats.sw_stats + BNGE_TX_PORT_STATS_BYTE_OFFSET / 8;
|
||||
|
||||
do {
|
||||
start = u64_stats_fetch_begin(&bn->port_stats.syncp);
|
||||
|
||||
stats->rx_crc_errors =
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_fcs_err_frames);
|
||||
stats->rx_frame_errors =
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_align_err_frames);
|
||||
stats->rx_length_errors =
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_undrsz_frames) +
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_ovrsz_frames) +
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_runt_frames);
|
||||
stats->rx_errors =
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_false_carrier_frames) +
|
||||
BNGE_GET_RX_PORT_STATS64(rx, rx_jbr_frames);
|
||||
stats->collisions =
|
||||
BNGE_GET_TX_PORT_STATS64(tx, tx_total_collisions);
|
||||
stats->tx_fifo_errors =
|
||||
BNGE_GET_TX_PORT_STATS64(tx, tx_fifo_underruns);
|
||||
stats->tx_errors = BNGE_GET_TX_PORT_STATS64(tx, tx_err);
|
||||
} while (u64_stats_fetch_retry(&bn->port_stats.syncp, start));
|
||||
}
|
||||
|
||||
static void bnge_get_stats64(struct net_device *dev,
|
||||
struct rtnl_link_stats64 *stats)
|
||||
{
|
||||
struct bnge_net *bn = netdev_priv(dev);
|
||||
|
||||
if (bn->flags & BNGE_FLAG_PORT_STATS)
|
||||
bnge_get_port_stats64(bn, stats);
|
||||
}
|
||||
|
||||
static void bnge_close_core(struct bnge_net *bn)
|
||||
{
|
||||
struct bnge_dev *bd = bn->bd;
|
||||
@@ -2931,6 +2971,7 @@ static const struct net_device_ops bnge_netdev_ops = {
|
||||
.ndo_open = bnge_open,
|
||||
.ndo_stop = bnge_close,
|
||||
.ndo_start_xmit = bnge_start_xmit,
|
||||
.ndo_get_stats64 = bnge_get_stats64,
|
||||
.ndo_features_check = bnge_features_check,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user