mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
net: cadence: macb: Convert to get_stats64
Convert the existing get_stats implementation to get_stats64. Since we now report 64-bit values, increase the counters to 64-bits as well. Signed-off-by: Sean Anderson <sean.anderson@linux.dev> Link: https://patch.msgid.link/20250214212703.2618652-2-sean.anderson@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
c900e49d58
commit
75696dd0fd
2 changed files with 81 additions and 85 deletions
|
@ -951,75 +951,75 @@ struct macb_tx_skb {
|
|||
* device stats by a periodic timer.
|
||||
*/
|
||||
struct macb_stats {
|
||||
u32 rx_pause_frames;
|
||||
u32 tx_ok;
|
||||
u32 tx_single_cols;
|
||||
u32 tx_multiple_cols;
|
||||
u32 rx_ok;
|
||||
u32 rx_fcs_errors;
|
||||
u32 rx_align_errors;
|
||||
u32 tx_deferred;
|
||||
u32 tx_late_cols;
|
||||
u32 tx_excessive_cols;
|
||||
u32 tx_underruns;
|
||||
u32 tx_carrier_errors;
|
||||
u32 rx_resource_errors;
|
||||
u32 rx_overruns;
|
||||
u32 rx_symbol_errors;
|
||||
u32 rx_oversize_pkts;
|
||||
u32 rx_jabbers;
|
||||
u32 rx_undersize_pkts;
|
||||
u32 sqe_test_errors;
|
||||
u32 rx_length_mismatch;
|
||||
u32 tx_pause_frames;
|
||||
u64 rx_pause_frames;
|
||||
u64 tx_ok;
|
||||
u64 tx_single_cols;
|
||||
u64 tx_multiple_cols;
|
||||
u64 rx_ok;
|
||||
u64 rx_fcs_errors;
|
||||
u64 rx_align_errors;
|
||||
u64 tx_deferred;
|
||||
u64 tx_late_cols;
|
||||
u64 tx_excessive_cols;
|
||||
u64 tx_underruns;
|
||||
u64 tx_carrier_errors;
|
||||
u64 rx_resource_errors;
|
||||
u64 rx_overruns;
|
||||
u64 rx_symbol_errors;
|
||||
u64 rx_oversize_pkts;
|
||||
u64 rx_jabbers;
|
||||
u64 rx_undersize_pkts;
|
||||
u64 sqe_test_errors;
|
||||
u64 rx_length_mismatch;
|
||||
u64 tx_pause_frames;
|
||||
};
|
||||
|
||||
struct gem_stats {
|
||||
u32 tx_octets_31_0;
|
||||
u32 tx_octets_47_32;
|
||||
u32 tx_frames;
|
||||
u32 tx_broadcast_frames;
|
||||
u32 tx_multicast_frames;
|
||||
u32 tx_pause_frames;
|
||||
u32 tx_64_byte_frames;
|
||||
u32 tx_65_127_byte_frames;
|
||||
u32 tx_128_255_byte_frames;
|
||||
u32 tx_256_511_byte_frames;
|
||||
u32 tx_512_1023_byte_frames;
|
||||
u32 tx_1024_1518_byte_frames;
|
||||
u32 tx_greater_than_1518_byte_frames;
|
||||
u32 tx_underrun;
|
||||
u32 tx_single_collision_frames;
|
||||
u32 tx_multiple_collision_frames;
|
||||
u32 tx_excessive_collisions;
|
||||
u32 tx_late_collisions;
|
||||
u32 tx_deferred_frames;
|
||||
u32 tx_carrier_sense_errors;
|
||||
u32 rx_octets_31_0;
|
||||
u32 rx_octets_47_32;
|
||||
u32 rx_frames;
|
||||
u32 rx_broadcast_frames;
|
||||
u32 rx_multicast_frames;
|
||||
u32 rx_pause_frames;
|
||||
u32 rx_64_byte_frames;
|
||||
u32 rx_65_127_byte_frames;
|
||||
u32 rx_128_255_byte_frames;
|
||||
u32 rx_256_511_byte_frames;
|
||||
u32 rx_512_1023_byte_frames;
|
||||
u32 rx_1024_1518_byte_frames;
|
||||
u32 rx_greater_than_1518_byte_frames;
|
||||
u32 rx_undersized_frames;
|
||||
u32 rx_oversize_frames;
|
||||
u32 rx_jabbers;
|
||||
u32 rx_frame_check_sequence_errors;
|
||||
u32 rx_length_field_frame_errors;
|
||||
u32 rx_symbol_errors;
|
||||
u32 rx_alignment_errors;
|
||||
u32 rx_resource_errors;
|
||||
u32 rx_overruns;
|
||||
u32 rx_ip_header_checksum_errors;
|
||||
u32 rx_tcp_checksum_errors;
|
||||
u32 rx_udp_checksum_errors;
|
||||
u64 tx_octets_31_0;
|
||||
u64 tx_octets_47_32;
|
||||
u64 tx_frames;
|
||||
u64 tx_broadcast_frames;
|
||||
u64 tx_multicast_frames;
|
||||
u64 tx_pause_frames;
|
||||
u64 tx_64_byte_frames;
|
||||
u64 tx_65_127_byte_frames;
|
||||
u64 tx_128_255_byte_frames;
|
||||
u64 tx_256_511_byte_frames;
|
||||
u64 tx_512_1023_byte_frames;
|
||||
u64 tx_1024_1518_byte_frames;
|
||||
u64 tx_greater_than_1518_byte_frames;
|
||||
u64 tx_underrun;
|
||||
u64 tx_single_collision_frames;
|
||||
u64 tx_multiple_collision_frames;
|
||||
u64 tx_excessive_collisions;
|
||||
u64 tx_late_collisions;
|
||||
u64 tx_deferred_frames;
|
||||
u64 tx_carrier_sense_errors;
|
||||
u64 rx_octets_31_0;
|
||||
u64 rx_octets_47_32;
|
||||
u64 rx_frames;
|
||||
u64 rx_broadcast_frames;
|
||||
u64 rx_multicast_frames;
|
||||
u64 rx_pause_frames;
|
||||
u64 rx_64_byte_frames;
|
||||
u64 rx_65_127_byte_frames;
|
||||
u64 rx_128_255_byte_frames;
|
||||
u64 rx_256_511_byte_frames;
|
||||
u64 rx_512_1023_byte_frames;
|
||||
u64 rx_1024_1518_byte_frames;
|
||||
u64 rx_greater_than_1518_byte_frames;
|
||||
u64 rx_undersized_frames;
|
||||
u64 rx_oversize_frames;
|
||||
u64 rx_jabbers;
|
||||
u64 rx_frame_check_sequence_errors;
|
||||
u64 rx_length_field_frame_errors;
|
||||
u64 rx_symbol_errors;
|
||||
u64 rx_alignment_errors;
|
||||
u64 rx_resource_errors;
|
||||
u64 rx_overruns;
|
||||
u64 rx_ip_header_checksum_errors;
|
||||
u64 rx_tcp_checksum_errors;
|
||||
u64 rx_udp_checksum_errors;
|
||||
};
|
||||
|
||||
/* Describes the name and offset of an individual statistic register, as
|
||||
|
|
|
@ -988,8 +988,8 @@ err_out:
|
|||
|
||||
static void macb_update_stats(struct macb *bp)
|
||||
{
|
||||
u32 *p = &bp->hw_stats.macb.rx_pause_frames;
|
||||
u32 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
|
||||
u64 *p = &bp->hw_stats.macb.rx_pause_frames;
|
||||
u64 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
|
||||
int offset = MACB_PFR;
|
||||
|
||||
WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
|
||||
|
@ -3069,7 +3069,7 @@ static void gem_update_stats(struct macb *bp)
|
|||
unsigned int i, q, idx;
|
||||
unsigned long *stat;
|
||||
|
||||
u32 *p = &bp->hw_stats.gem.tx_octets_31_0;
|
||||
u64 *p = &bp->hw_stats.gem.tx_octets_31_0;
|
||||
|
||||
for (i = 0; i < GEM_STATS_LEN; ++i, ++p) {
|
||||
u32 offset = gem_statistics[i].offset;
|
||||
|
@ -3092,15 +3092,12 @@ static void gem_update_stats(struct macb *bp)
|
|||
bp->ethtool_stats[idx++] = *stat;
|
||||
}
|
||||
|
||||
static struct net_device_stats *gem_get_stats(struct macb *bp)
|
||||
static void gem_get_stats(struct macb *bp, struct rtnl_link_stats64 *nstat)
|
||||
{
|
||||
struct gem_stats *hwstat = &bp->hw_stats.gem;
|
||||
struct net_device_stats *nstat = &bp->dev->stats;
|
||||
|
||||
if (!netif_running(bp->dev))
|
||||
return nstat;
|
||||
|
||||
gem_update_stats(bp);
|
||||
if (netif_running(bp->dev))
|
||||
gem_update_stats(bp);
|
||||
|
||||
nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors +
|
||||
hwstat->rx_alignment_errors +
|
||||
|
@ -3129,8 +3126,6 @@ static struct net_device_stats *gem_get_stats(struct macb *bp)
|
|||
nstat->tx_aborted_errors = hwstat->tx_excessive_collisions;
|
||||
nstat->tx_carrier_errors = hwstat->tx_carrier_sense_errors;
|
||||
nstat->tx_fifo_errors = hwstat->tx_underrun;
|
||||
|
||||
return nstat;
|
||||
}
|
||||
|
||||
static void gem_get_ethtool_stats(struct net_device *dev,
|
||||
|
@ -3181,14 +3176,17 @@ static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
|
|||
}
|
||||
}
|
||||
|
||||
static struct net_device_stats *macb_get_stats(struct net_device *dev)
|
||||
static void macb_get_stats(struct net_device *dev,
|
||||
struct rtnl_link_stats64 *nstat)
|
||||
{
|
||||
struct macb *bp = netdev_priv(dev);
|
||||
struct net_device_stats *nstat = &bp->dev->stats;
|
||||
struct macb_stats *hwstat = &bp->hw_stats.macb;
|
||||
|
||||
if (macb_is_gem(bp))
|
||||
return gem_get_stats(bp);
|
||||
netdev_stats_to_stats64(nstat, &bp->dev->stats);
|
||||
if (macb_is_gem(bp)) {
|
||||
gem_get_stats(bp, nstat);
|
||||
return;
|
||||
}
|
||||
|
||||
/* read stats from hardware */
|
||||
macb_update_stats(bp);
|
||||
|
@ -3224,8 +3222,6 @@ static struct net_device_stats *macb_get_stats(struct net_device *dev)
|
|||
nstat->tx_carrier_errors = hwstat->tx_carrier_errors;
|
||||
nstat->tx_fifo_errors = hwstat->tx_underruns;
|
||||
/* Don't know about heartbeat or window errors... */
|
||||
|
||||
return nstat;
|
||||
}
|
||||
|
||||
static int macb_get_regs_len(struct net_device *netdev)
|
||||
|
@ -3908,7 +3904,7 @@ static const struct net_device_ops macb_netdev_ops = {
|
|||
.ndo_stop = macb_close,
|
||||
.ndo_start_xmit = macb_start_xmit,
|
||||
.ndo_set_rx_mode = macb_set_rx_mode,
|
||||
.ndo_get_stats = macb_get_stats,
|
||||
.ndo_get_stats64 = macb_get_stats,
|
||||
.ndo_eth_ioctl = macb_ioctl,
|
||||
.ndo_validate_addr = eth_validate_addr,
|
||||
.ndo_change_mtu = macb_change_mtu,
|
||||
|
@ -4569,7 +4565,7 @@ static const struct net_device_ops at91ether_netdev_ops = {
|
|||
.ndo_open = at91ether_open,
|
||||
.ndo_stop = at91ether_close,
|
||||
.ndo_start_xmit = at91ether_start_xmit,
|
||||
.ndo_get_stats = macb_get_stats,
|
||||
.ndo_get_stats64 = macb_get_stats,
|
||||
.ndo_set_rx_mode = macb_set_rx_mode,
|
||||
.ndo_set_mac_address = eth_mac_addr,
|
||||
.ndo_eth_ioctl = macb_ioctl,
|
||||
|
|
Loading…
Add table
Reference in a new issue