From: Sean Anderson <sean.anderson@linux.dev>
To: Nicolas Ferre <nicolas.ferre@microchip.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Sean Anderson <sean.anderson@linux.dev>
Subject: [PATCH net-next] net: cadence: macb: Synchronize standard stats
Date: Mon, 3 Mar 2025 18:18:32 -0500 [thread overview]
Message-ID: <20250303231832.1648274-1-sean.anderson@linux.dev> (raw)
The new stats calculations add several additional calls to
macb/gem_update_stats() and accesses to bp->hw_stats. These are
protected by a spinlock since commit fa52f15c745c ("net: cadence: macb:
Synchronize stats calculations"), which was applied in parallel. Add
some locking now that the net has been merged into net-next.
Fixes: f6af690a295a ("net: cadence: macb: Report standard stats")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
drivers/net/ethernet/cadence/macb_main.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 6c462de81f20..b5797c1ac0a4 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3253,9 +3253,11 @@ static void macb_get_pause_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct macb_stats *hwstat = &bp->hw_stats.macb;
+ spin_lock_irq(&bp->stats_lock);
macb_update_stats(bp);
pause_stats->tx_pause_frames = hwstat->tx_pause_frames;
pause_stats->rx_pause_frames = hwstat->rx_pause_frames;
+ spin_unlock_irq(&bp->stats_lock);
}
static void gem_get_pause_stats(struct net_device *dev,
@@ -3264,9 +3266,11 @@ static void gem_get_pause_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct gem_stats *hwstat = &bp->hw_stats.gem;
+ spin_lock_irq(&bp->stats_lock);
gem_update_stats(bp);
pause_stats->tx_pause_frames = hwstat->tx_pause_frames;
pause_stats->rx_pause_frames = hwstat->rx_pause_frames;
+ spin_unlock_irq(&bp->stats_lock);
}
static void macb_get_eth_mac_stats(struct net_device *dev,
@@ -3275,6 +3279,7 @@ static void macb_get_eth_mac_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct macb_stats *hwstat = &bp->hw_stats.macb;
+ spin_lock_irq(&bp->stats_lock);
macb_update_stats(bp);
mac_stats->FramesTransmittedOK = hwstat->tx_ok;
mac_stats->SingleCollisionFrames = hwstat->tx_single_cols;
@@ -3290,6 +3295,7 @@ static void macb_get_eth_mac_stats(struct net_device *dev,
mac_stats->FramesLostDueToIntMACRcvError = hwstat->rx_overruns;
mac_stats->InRangeLengthErrors = hwstat->rx_length_mismatch;
mac_stats->FrameTooLongErrors = hwstat->rx_oversize_pkts;
+ spin_unlock_irq(&bp->stats_lock);
}
static void gem_get_eth_mac_stats(struct net_device *dev,
@@ -3298,6 +3304,7 @@ static void gem_get_eth_mac_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct gem_stats *hwstat = &bp->hw_stats.gem;
+ spin_lock_irq(&bp->stats_lock);
gem_update_stats(bp);
mac_stats->FramesTransmittedOK = hwstat->tx_frames;
mac_stats->SingleCollisionFrames = hwstat->tx_single_collision_frames;
@@ -3320,6 +3327,7 @@ static void gem_get_eth_mac_stats(struct net_device *dev,
mac_stats->BroadcastFramesReceivedOK = hwstat->rx_broadcast_frames;
mac_stats->InRangeLengthErrors = hwstat->rx_length_field_frame_errors;
mac_stats->FrameTooLongErrors = hwstat->rx_oversize_frames;
+ spin_unlock_irq(&bp->stats_lock);
}
/* TODO: Report SQE test errors when added to phy_stats */
@@ -3329,8 +3337,10 @@ static void macb_get_eth_phy_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct macb_stats *hwstat = &bp->hw_stats.macb;
+ spin_lock_irq(&bp->stats_lock);
macb_update_stats(bp);
phy_stats->SymbolErrorDuringCarrier = hwstat->rx_symbol_errors;
+ spin_unlock_irq(&bp->stats_lock);
}
static void gem_get_eth_phy_stats(struct net_device *dev,
@@ -3339,8 +3349,10 @@ static void gem_get_eth_phy_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct gem_stats *hwstat = &bp->hw_stats.gem;
+ spin_lock_irq(&bp->stats_lock);
gem_update_stats(bp);
phy_stats->SymbolErrorDuringCarrier = hwstat->rx_symbol_errors;
+ spin_unlock_irq(&bp->stats_lock);
}
static void macb_get_rmon_stats(struct net_device *dev,
@@ -3350,10 +3362,12 @@ static void macb_get_rmon_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct macb_stats *hwstat = &bp->hw_stats.macb;
+ spin_lock_irq(&bp->stats_lock);
macb_update_stats(bp);
rmon_stats->undersize_pkts = hwstat->rx_undersize_pkts;
rmon_stats->oversize_pkts = hwstat->rx_oversize_pkts;
rmon_stats->jabbers = hwstat->rx_jabbers;
+ spin_unlock_irq(&bp->stats_lock);
}
static const struct ethtool_rmon_hist_range gem_rmon_ranges[] = {
@@ -3374,6 +3388,7 @@ static void gem_get_rmon_stats(struct net_device *dev,
struct macb *bp = netdev_priv(dev);
struct gem_stats *hwstat = &bp->hw_stats.gem;
+ spin_lock_irq(&bp->stats_lock);
gem_update_stats(bp);
rmon_stats->undersize_pkts = hwstat->rx_undersized_frames;
rmon_stats->oversize_pkts = hwstat->rx_oversize_frames;
@@ -3392,6 +3407,7 @@ static void gem_get_rmon_stats(struct net_device *dev,
rmon_stats->hist_tx[4] = hwstat->tx_512_1023_byte_frames;
rmon_stats->hist_tx[5] = hwstat->tx_1024_1518_byte_frames;
rmon_stats->hist_tx[6] = hwstat->tx_greater_than_1518_byte_frames;
+ spin_unlock_irq(&bp->stats_lock);
*ranges = gem_rmon_ranges;
}
--
2.35.1.1320.gc452695387.dirty
next reply other threads:[~2025-03-03 23:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 23:18 Sean Anderson [this message]
2025-03-05 2:00 ` [PATCH net-next] net: cadence: macb: Synchronize standard stats patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250303231832.1648274-1-sean.anderson@linux.dev \
--to=sean.anderson@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox