eth: fbnic: Fix drop stats support
Subsystems (3)
cover eth: fbnic: Fix drop stats support
Fix hardware drop stats support on the TX path of fbnic by addressing two
issues: ensure that tx_dropped stats are correctly copied to the rtnl_link_stats64 struct, and protect the copying of drop stats from fdb->hw_stats to the local variable with the hw_stats_lock to ensure consistency.
Mohsin Bashir (2):
eth: fbnic: Fix tx_dropped reporting
eth: fbnic: Lock the tx_dropped update
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/2 eth: fbnic: Fix tx_dropped reporting
Correctly copy the tx_dropped stats from the fbd->hw_stats to the rtnl_link_stats64 struct.
--- drivers/net/ethernet/meta/fbnic/fbnic_netdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +4 -4
@@ -420,16 +420,16 @@ static void fbnic_get_stats64(struct net_device *dev, tx_packets = stats->packets; tx_dropped = stats->dropped; - stats64->tx_bytes = tx_bytes; - stats64->tx_packets = tx_packets; - stats64->tx_dropped = tx_dropped; -/* Record drops from Tx HW Datapath */ tx_dropped += fbd->hw_stats.tmi.drop.frames.value + fbd->hw_stats.tti.cm_drop.frames.value + fbd->hw_stats.tti.frame_drop.frames.value + fbd->hw_stats.tti.tbi_drop.frames.value; + stats64->tx_bytes = tx_bytes; + stats64->tx_packets = tx_packets; + stats64->tx_dropped = tx_dropped; +for (i =0 ; i < fbn->num_tx_queues; i++) {struct fbnic_ring *txr = fbn->tx[i];
Signature · 1 line
2.47.3
Re: [PATCH net 1/2] eth: fbnic: Fix tx_dropped reporting
Quoted 6 lines · Mohsin Bashir
Correctly copy the
tx_droppedstats from thefbd->hw_statsto thertnl_link_stats64struct.Fixes 5f8bd2ce8269 ("eth: fbnic: add support for TMI stats")Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Mohsin Bashir <[email protected]>
Thanks,
I note that the local variable tx_dropped was being saved to stats64 before it's values were accumulated from hw_stats.
PATCH 2/2 eth: fbnic: Lock the tx_dropped update
In reply to Mohsin BashirWrap copying of drop stats on TX path from fbd->hw_stats by the hw_stats_lock. Currently, it is being performed outside the lock and another thread accessing fbd->hw_stats can lead to inconsistencies.
--- drivers/net/ethernet/meta/fbnic/fbnic_netdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +2 -0
@@ -421,10 +421,12 @@ static void fbnic_get_stats64(struct net_device *dev, tx_dropped = stats->dropped;/* Record drops from Tx HW Datapath */ +spin_lock (&fbd->hw_stats_lock); tx_dropped += fbd->hw_stats.tmi.drop.frames.value + fbd->hw_stats.tti.cm_drop.frames.value + fbd->hw_stats.tti.frame_drop.frames.value + fbd->hw_stats.tti.tbi_drop.frames.value; +spin_unlock (&fbd->hw_stats_lock); stats64->tx_bytes = tx_bytes; stats64->tx_packets = tx_packets;
Signature · 1 line
2.47.3
Re: [PATCH net 2/2] eth: fbnic: Lock the tx_dropped update
Quoted 7 lines · Mohsin Bashir
Wrap copying of drop stats on TX path from
fbd->hw_statsby thehw_stats_lock. Currently, it is being performed outside the lock and another thread accessingfbd->hw_statscan lead to inconsistencies.Fixes 5f8bd2ce8269 ("eth: fbnic: add support for TMI stats")Signed-off-by Jakub Kicinski <[email protected]>Signed-off-by Mohsin Bashir <[email protected]>
Thanks,
I note that hw_stats_lock is documented as protecting hw_stats. And that it is already used for that purpose elsewhere in fbnic_get_stats64().
I do wonder if some refactoring could allow only locking hw_stats_lock once in fbnic_get_stats64(). But that line of thought doesn't effect the correctness of this patch.
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Fri, 1 Aug 2025 19:46:34 -0700 you wrote:
Fix hardware drop stats support on the TX path of fbnic by addressing two
issues: ensure thattx_droppedstats are correctly copied to thertnl_link_stats64struct, and protect the copying of drop stats fromfdb->hw_statsto the local variable with thehw_stats_lockto ensure consistency.Mohsin Bashir (2):
eth: fbnic: Fixtx_droppedreporting
eth: fbnic: Lock thetx_droppedupdate[...]
Here is the summary with links:
- [net,1/2] eth: fbnic: Fix tx_dropped reporting
https://git.kernel.org/netdev/net/c/2972395d8fad - [net,2/2] eth: fbnic: Lock the tx_dropped update https://git.kernel.org/netdev/net/c/53abd9c86fd0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html