Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue

Tony Nguyen says:

====================
Intel Wired LAN Driver Updates 2024-03-06 (igc, igb, ice)

This series contains updates to igc, igb, and ice drivers.

Vinicius removes double clearing of interrupt register which could cause
timestamp events to be missed on igc and igb.

Przemek corrects calculation of statistics which caused incorrect spikes
in reporting for ice driver.

* '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue:
ice: fix stats being updated by way too large values
igb: Fix missing time sync events
igc: Fix missing time sync events
====================

Link: https://lore.kernel.org/r/20240306182617.625932-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+17 -42
+11 -13
drivers/net/ethernet/intel/ice/ice_main.c
··· 6737 6737 { 6738 6738 struct rtnl_link_stats64 *net_stats, *stats_prev; 6739 6739 struct rtnl_link_stats64 *vsi_stats; 6740 + struct ice_pf *pf = vsi->back; 6740 6741 u64 pkts, bytes; 6741 6742 int i; 6742 6743 ··· 6783 6782 net_stats = &vsi->net_stats; 6784 6783 stats_prev = &vsi->net_stats_prev; 6785 6784 6786 - /* clear prev counters after reset */ 6787 - if (vsi_stats->tx_packets < stats_prev->tx_packets || 6788 - vsi_stats->rx_packets < stats_prev->rx_packets) { 6789 - stats_prev->tx_packets = 0; 6790 - stats_prev->tx_bytes = 0; 6791 - stats_prev->rx_packets = 0; 6792 - stats_prev->rx_bytes = 0; 6785 + /* Update netdev counters, but keep in mind that values could start at 6786 + * random value after PF reset. And as we increase the reported stat by 6787 + * diff of Prev-Cur, we need to be sure that Prev is valid. If it's not, 6788 + * let's skip this round. 6789 + */ 6790 + if (likely(pf->stat_prev_loaded)) { 6791 + net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; 6792 + net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; 6793 + net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; 6794 + net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; 6793 6795 } 6794 - 6795 - /* update netdev counters */ 6796 - net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; 6797 - net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; 6798 - net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; 6799 - net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; 6800 6796 6801 6797 stats_prev->tx_packets = vsi_stats->tx_packets; 6802 6798 stats_prev->tx_bytes = vsi_stats->tx_bytes;
+5 -18
drivers/net/ethernet/intel/igb/igb_main.c
··· 6985 6985 static void igb_tsync_interrupt(struct igb_adapter *adapter) 6986 6986 { 6987 6987 struct e1000_hw *hw = &adapter->hw; 6988 - u32 ack = 0, tsicr = rd32(E1000_TSICR); 6988 + u32 tsicr = rd32(E1000_TSICR); 6989 6989 struct ptp_clock_event event; 6990 6990 6991 6991 if (tsicr & TSINTR_SYS_WRAP) { 6992 6992 event.type = PTP_CLOCK_PPS; 6993 6993 if (adapter->ptp_caps.pps) 6994 6994 ptp_clock_event(adapter->ptp_clock, &event); 6995 - ack |= TSINTR_SYS_WRAP; 6996 6995 } 6997 6996 6998 6997 if (tsicr & E1000_TSICR_TXTS) { 6999 6998 /* retrieve hardware timestamp */ 7000 6999 schedule_work(&adapter->ptp_tx_work); 7001 - ack |= E1000_TSICR_TXTS; 7002 7000 } 7003 7001 7004 - if (tsicr & TSINTR_TT0) { 7002 + if (tsicr & TSINTR_TT0) 7005 7003 igb_perout(adapter, 0); 7006 - ack |= TSINTR_TT0; 7007 - } 7008 7004 7009 - if (tsicr & TSINTR_TT1) { 7005 + if (tsicr & TSINTR_TT1) 7010 7006 igb_perout(adapter, 1); 7011 - ack |= TSINTR_TT1; 7012 - } 7013 7007 7014 - if (tsicr & TSINTR_AUTT0) { 7008 + if (tsicr & TSINTR_AUTT0) 7015 7009 igb_extts(adapter, 0); 7016 - ack |= TSINTR_AUTT0; 7017 - } 7018 7010 7019 - if (tsicr & TSINTR_AUTT1) { 7011 + if (tsicr & TSINTR_AUTT1) 7020 7012 igb_extts(adapter, 1); 7021 - ack |= TSINTR_AUTT1; 7022 - } 7023 - 7024 - /* acknowledge the interrupts */ 7025 - wr32(E1000_TSICR, ack); 7026 7013 } 7027 7014 7028 7015 static irqreturn_t igb_msix_other(int irq, void *data)
+1 -11
drivers/net/ethernet/intel/igc/igc_main.c
··· 5302 5302 5303 5303 static void igc_tsync_interrupt(struct igc_adapter *adapter) 5304 5304 { 5305 - u32 ack, tsauxc, sec, nsec, tsicr; 5306 5305 struct igc_hw *hw = &adapter->hw; 5306 + u32 tsauxc, sec, nsec, tsicr; 5307 5307 struct ptp_clock_event event; 5308 5308 struct timespec64 ts; 5309 5309 5310 5310 tsicr = rd32(IGC_TSICR); 5311 - ack = 0; 5312 5311 5313 5312 if (tsicr & IGC_TSICR_SYS_WRAP) { 5314 5313 event.type = PTP_CLOCK_PPS; 5315 5314 if (adapter->ptp_caps.pps) 5316 5315 ptp_clock_event(adapter->ptp_clock, &event); 5317 - ack |= IGC_TSICR_SYS_WRAP; 5318 5316 } 5319 5317 5320 5318 if (tsicr & IGC_TSICR_TXTS) { 5321 5319 /* retrieve hardware timestamp */ 5322 5320 igc_ptp_tx_tstamp_event(adapter); 5323 - ack |= IGC_TSICR_TXTS; 5324 5321 } 5325 5322 5326 5323 if (tsicr & IGC_TSICR_TT0) { ··· 5331 5334 wr32(IGC_TSAUXC, tsauxc); 5332 5335 adapter->perout[0].start = ts; 5333 5336 spin_unlock(&adapter->tmreg_lock); 5334 - ack |= IGC_TSICR_TT0; 5335 5337 } 5336 5338 5337 5339 if (tsicr & IGC_TSICR_TT1) { ··· 5344 5348 wr32(IGC_TSAUXC, tsauxc); 5345 5349 adapter->perout[1].start = ts; 5346 5350 spin_unlock(&adapter->tmreg_lock); 5347 - ack |= IGC_TSICR_TT1; 5348 5351 } 5349 5352 5350 5353 if (tsicr & IGC_TSICR_AUTT0) { ··· 5353 5358 event.index = 0; 5354 5359 event.timestamp = sec * NSEC_PER_SEC + nsec; 5355 5360 ptp_clock_event(adapter->ptp_clock, &event); 5356 - ack |= IGC_TSICR_AUTT0; 5357 5361 } 5358 5362 5359 5363 if (tsicr & IGC_TSICR_AUTT1) { ··· 5362 5368 event.index = 1; 5363 5369 event.timestamp = sec * NSEC_PER_SEC + nsec; 5364 5370 ptp_clock_event(adapter->ptp_clock, &event); 5365 - ack |= IGC_TSICR_AUTT1; 5366 5371 } 5367 - 5368 - /* acknowledge the interrupts */ 5369 - wr32(IGC_TSICR, ack); 5370 5372 } 5371 5373 5372 5374 /**