mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
eth: fbnic: Move hw_stats_lock out of fbnic_dev
Move hw_stats_lock out of fbnic_dev to a more appropriate struct fbnic_hw_stats since the only use of this lock is to protect access to the hardware stats. While at it, enclose the lock and stats initialization in a single init call. Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250825200206.2357713-2-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
ef5ca97293
commit
2ee5c8c0c2
|
|
@ -84,9 +84,6 @@ struct fbnic_dev {
|
|||
/* Local copy of hardware statistics */
|
||||
struct fbnic_hw_stats hw_stats;
|
||||
|
||||
/* Lock protecting access to hw_stats */
|
||||
spinlock_t hw_stats_lock;
|
||||
|
||||
struct fbnic_fw_log fw_log;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@ static void fbnic_get_ethtool_stats(struct net_device *dev,
|
|||
|
||||
fbnic_get_hw_stats(fbn->fbd);
|
||||
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
fbnic_report_hw_stats(fbnic_gstrings_hw_stats, &fbd->hw_stats,
|
||||
FBNIC_HW_FIXED_STATS_LEN, &data);
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ static void fbnic_get_ethtool_stats(struct net_device *dev,
|
|||
fbnic_report_hw_stats(fbnic_gstrings_hw_q_stats, hw_q,
|
||||
FBNIC_HW_Q_STATS_LEN, &data);
|
||||
}
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
|
||||
for (i = 0; i < FBNIC_MAX_XDPQS; i++)
|
||||
fbnic_get_xdp_queue_stats(fbn->tx[i + FBNIC_MAX_TXQS], &data);
|
||||
|
|
|
|||
|
|
@ -421,9 +421,9 @@ static void fbnic_get_hw_rxq_stats32(struct fbnic_dev *fbd,
|
|||
void fbnic_get_hw_q_stats(struct fbnic_dev *fbd,
|
||||
struct fbnic_hw_q_stats *hw_q)
|
||||
{
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
fbnic_get_hw_rxq_stats32(fbd, hw_q);
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
}
|
||||
|
||||
static void fbnic_reset_pcie_stats_asic(struct fbnic_dev *fbd,
|
||||
|
|
@ -512,14 +512,21 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd,
|
|||
|
||||
void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
|
||||
{
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
fbnic_reset_tmi_stats(fbd, &fbd->hw_stats.tmi);
|
||||
fbnic_reset_tti_stats(fbd, &fbd->hw_stats.tti);
|
||||
fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc);
|
||||
fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb);
|
||||
fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q);
|
||||
fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie);
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
}
|
||||
|
||||
void fbnic_init_hw_stats(struct fbnic_dev *fbd)
|
||||
{
|
||||
spin_lock_init(&fbd->hw_stats.lock);
|
||||
|
||||
fbnic_reset_hw_stats(fbd);
|
||||
}
|
||||
|
||||
static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd)
|
||||
|
|
@ -533,19 +540,19 @@ static void __fbnic_get_hw_stats32(struct fbnic_dev *fbd)
|
|||
|
||||
void fbnic_get_hw_stats32(struct fbnic_dev *fbd)
|
||||
{
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
__fbnic_get_hw_stats32(fbd);
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
}
|
||||
|
||||
void fbnic_get_hw_stats(struct fbnic_dev *fbd)
|
||||
{
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
__fbnic_get_hw_stats32(fbd);
|
||||
|
||||
fbnic_get_tmi_stats(fbd, &fbd->hw_stats.tmi);
|
||||
fbnic_get_tti_stats(fbd, &fbd->hw_stats.tti);
|
||||
fbnic_get_rxb_stats(fbd, &fbd->hw_stats.rxb);
|
||||
fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie);
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#define _FBNIC_HW_STATS_H_
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#include "fbnic_csr.h"
|
||||
|
||||
|
|
@ -122,11 +123,15 @@ struct fbnic_hw_stats {
|
|||
struct fbnic_rxb_stats rxb;
|
||||
struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];
|
||||
struct fbnic_pcie_stats pcie;
|
||||
|
||||
/* Lock protecting the access to hw stats */
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
|
||||
|
||||
void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
|
||||
void fbnic_init_hw_stats(struct fbnic_dev *fbd);
|
||||
void fbnic_get_hw_q_stats(struct fbnic_dev *fbd,
|
||||
struct fbnic_hw_q_stats *hw_q);
|
||||
void fbnic_get_hw_stats32(struct fbnic_dev *fbd);
|
||||
|
|
|
|||
|
|
@ -424,12 +424,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);
|
||||
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);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
|
||||
stats64->tx_bytes = tx_bytes;
|
||||
stats64->tx_packets = tx_packets;
|
||||
|
|
@ -460,7 +460,7 @@ static void fbnic_get_stats64(struct net_device *dev,
|
|||
rx_packets = stats->packets;
|
||||
rx_dropped = stats->dropped;
|
||||
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
/* Record drops for the host FIFOs.
|
||||
* 4: network to Host, 6: BMC to Host
|
||||
* Exclude the BMC and MC FIFOs as those stats may contain drops
|
||||
|
|
@ -480,7 +480,7 @@ static void fbnic_get_stats64(struct net_device *dev,
|
|||
/* Report packets with errors */
|
||||
rx_errors += fbd->hw_stats.hw_q[i].rde_pkt_err.value;
|
||||
}
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
|
||||
stats64->rx_bytes = rx_bytes;
|
||||
stats64->rx_packets = rx_packets;
|
||||
|
|
@ -608,12 +608,12 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx,
|
|||
|
||||
fbnic_get_hw_q_stats(fbd, fbd->hw_stats.hw_q);
|
||||
|
||||
spin_lock(&fbd->hw_stats_lock);
|
||||
spin_lock(&fbd->hw_stats.lock);
|
||||
rx->hw_drop_overruns = fbd->hw_stats.hw_q[idx].rde_pkt_cq_drop.value +
|
||||
fbd->hw_stats.hw_q[idx].rde_pkt_bdq_drop.value;
|
||||
rx->hw_drops = fbd->hw_stats.hw_q[idx].rde_pkt_err.value +
|
||||
rx->hw_drop_overruns;
|
||||
spin_unlock(&fbd->hw_stats_lock);
|
||||
spin_unlock(&fbd->hw_stats.lock);
|
||||
}
|
||||
|
||||
static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx,
|
||||
|
|
|
|||
|
|
@ -304,10 +304,9 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
|
||||
fbnic_devlink_register(fbd);
|
||||
fbnic_dbg_fbd_init(fbd);
|
||||
spin_lock_init(&fbd->hw_stats_lock);
|
||||
|
||||
/* Capture snapshot of hardware stats so netdev can calculate delta */
|
||||
fbnic_reset_hw_stats(fbd);
|
||||
fbnic_init_hw_stats(fbd);
|
||||
|
||||
fbnic_hwmon_register(fbd);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user