Intel Wired LAN Driver Updates 2024-03-06 (igc, igb, ice)
Subsystems (3)
Tony Nguyen
maintainerThis 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.
The following are changes since commit c055fc00c07be1f0df7375ab0036cebd1106ed38:
net/rds: fix WARNING in rds_conn_connect_if_down
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 1GbE
Przemek Kitszel (1):
ice: fix stats being updated by way too large values
Vinicius Costa Gomes (2):
igc: Fix missing time sync events
igb: Fix missing time sync events
drivers/net/ethernet/intel/ice/ice_main.c | 24 +++++++++++------------ drivers/net/ethernet/intel/igb/igb_main.c | 23 +++++----------------- drivers/net/ethernet/intel/igc/igc_main.c | 12 +----------- 3 files changed, 17 insertions(+), 42 deletions(-)
Signature · 1 line
2.41.0
Tony Nguyen
maintainerPATCH 1/3 igc: Fix missing time sync events
From: Vinicius Costa Gomes <[email protected]>
Fix "double" clearing of interrupts, which can cause external events or timestamps to be missed.
The IGC_TSIRC Time Sync Interrupt Cause register can be cleared in two ways, by either reading it or by writing '1' into the specific cause bit. This is documented in section 8.16.1.
The following flow was used:
1. read IGC_TSIRC into 'tsicr';
2. handle the interrupts present in 'tsirc' and mark them in 'ack';
3. write 'ack' into IGC_TSICR;
As both (1) and (3) will clear the interrupt cause, if the same interrupt happens again between (1) and (3) it will be ignored, causing events to be missed.
Remove the extra clear in (3).
--- drivers/net/ethernet/intel/igc/igc_main.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +1 -11
@@ -5302,25 +5302,22 @@ igc_features_check(struct sk_buff *skb, struct net_device *dev,static void igc_tsync_interrupt (struct igc_adapter *adapter) { -u32 ack, tsauxc, sec, nsec, tsicr;struct igc_hw *hw = &adapter->hw; +u32 tsauxc, sec, nsec, tsicr;struct ptp_clock_event event;struct timespec64 ts; tsicr =rd32 (IGC_TSICR ); - ack =0 ;if (tsicr &IGC_TSICR_SYS_WRAP ) { event.type =PTP_CLOCK_PPS ;if (adapter->ptp_caps.pps)ptp_clock_event (adapter->ptp_clock, &event); - ack |=IGC_TSICR_SYS_WRAP ; }if (tsicr &IGC_TSICR_TXTS ) {/* retrieve hardware timestamp */ igc_ptp_tx_tstamp_event (adapter); - ack |=IGC_TSICR_TXTS ; }if (tsicr &IGC_TSICR_TT0 ) {
@@ -5334,7 +5331,6 @@ static void igc_tsync_interrupt(struct igc_adapter *adapter)wr32 (IGC_TSAUXC , tsauxc); adapter->perout[0 ].start = ts;spin_unlock (&adapter->tmreg_lock); - ack |=IGC_TSICR_TT0 ; }if (tsicr &IGC_TSICR_TT1 ) {
@@ -5348,7 +5344,6 @@ static void igc_tsync_interrupt(struct igc_adapter *adapter)wr32 (IGC_TSAUXC , tsauxc); adapter->perout[1 ].start = ts;spin_unlock (&adapter->tmreg_lock); - ack |=IGC_TSICR_TT1 ; }if (tsicr &IGC_TSICR_AUTT0 ) {
@@ -5358,7 +5353,6 @@ static void igc_tsync_interrupt(struct igc_adapter *adapter) event.index =0 ; event.timestamp = sec *NSEC_PER_SEC + nsec;ptp_clock_event (adapter->ptp_clock, &event); - ack |=IGC_TSICR_AUTT0 ; }if (tsicr &IGC_TSICR_AUTT1 ) {
@@ -5368,11 +5362,7 @@ static void igc_tsync_interrupt(struct igc_adapter *adapter) event.index =1 ; event.timestamp = sec *NSEC_PER_SEC + nsec;ptp_clock_event (adapter->ptp_clock, &event); - ack |=IGC_TSICR_AUTT1 ; } - -/* acknowledge the interrupts */ -wr32 (IGC_TSICR , ack); }/**
Signature · 1 line
2.41.0
Tony Nguyen
maintainerPATCH 2/3 igb: Fix missing time sync events
In reply to Tony NguyenFrom: Vinicius Costa Gomes <[email protected]>
Fix "double" clearing of interrupts, which can cause external events or timestamps to be missed.
The E1000_TSIRC Time Sync Interrupt Cause register can be cleared in two ways, by either reading it or by writing '1' into the specific cause bit. This is documented in section 8.16.1.
The following flow was used:
1. read E1000_TSIRC into 'tsicr';
2. handle the interrupts present into 'tsirc' and mark them in 'ack';
3. write 'ack' into E1000_TSICR;
As both (1) and (3) will clear the interrupt cause, if the same interrupt happens again between (1) and (3) it will be ignored, causing events to be missed.
Remove the extra clear in (3).
--- drivers/net/ethernet/intel/igb/igb_main.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +5 -18
@@ -6985,44 +6985,31 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)static void igb_tsync_interrupt (struct igb_adapter *adapter) {struct e1000_hw *hw = &adapter->hw; -u32 ack =0 , tsicr =rd32 (E1000_TSICR ); +u32 tsicr =rd32 (E1000_TSICR );struct ptp_clock_event event;if (tsicr &TSINTR_SYS_WRAP ) { event.type =PTP_CLOCK_PPS ;if (adapter->ptp_caps.pps)ptp_clock_event (adapter->ptp_clock, &event); - ack |=TSINTR_SYS_WRAP ; }if (tsicr &E1000_TSICR_TXTS ) {/* retrieve hardware timestamp */ schedule_work (&adapter->ptp_tx_work); - ack |=E1000_TSICR_TXTS ; } -if (tsicr &TSINTR_TT0 ) { +if (tsicr &TSINTR_TT0 )igb_perout (adapter,0 ); - ack |=TSINTR_TT0 ; - } -if (tsicr &TSINTR_TT1 ) { +if (tsicr &TSINTR_TT1 )igb_perout (adapter,1 ); - ack |=TSINTR_TT1 ; - } -if (tsicr &TSINTR_AUTT0 ) { +if (tsicr &TSINTR_AUTT0 )igb_extts (adapter,0 ); - ack |=TSINTR_AUTT0 ; - } -if (tsicr &TSINTR_AUTT1 ) { +if (tsicr &TSINTR_AUTT1 )igb_extts (adapter,1 ); - ack |=TSINTR_AUTT1 ; - } - -/* acknowledge the interrupts */ -wr32 (E1000_TSICR , ack); }static irqreturn_t igb_msix_other (int irq,void *data)
Signature · 1 line
2.41.0
Tony Nguyen
maintainerPATCH 3/3 ice: fix stats being updated by way too large values
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Simplify stats accumulation logic to fix the case where we don't take previous stat value into account, we should always respect it.
Main netdev stats of our PF (Tx/Rx packets/bytes) were reported orders of magnitude too big during OpenStack reconfiguration events, possibly other reconfiguration cases too.
The regression was reported to be between 6.1 and 6.2, so I was almost certain that on of the two "preserve stats over reset" commits were the culprit. While reading the code, it was found that in some cases we will increase the stats by arbitrarily large number (thanks to ignoring "-prev" part of condition, after zeroing it).
Note that this fixes also the case where we were around limits of u64, but that was not the regression reported.
Full disclosure: I remember suggesting this particular piece of code to Ben a few years ago, so blame on me.
--- drivers/net/ethernet/intel/ice/ice_main.c | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +11 -13
@@ -6737,6 +6737,7 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi) {struct rtnl_link_stats64 *net_stats, *stats_prev;struct rtnl_link_stats64 *vsi_stats; +struct ice_pf *pf = vsi->back;u64 pkts, bytes;int i;
@@ -6782,21 +6783,18 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi) net_stats = &vsi->net_stats; stats_prev = &vsi->net_stats_prev; -/* clear prev counters after reset */ -if (vsi_stats->tx_packets < stats_prev->tx_packets || - vsi_stats->rx_packets < stats_prev->rx_packets) { - stats_prev->tx_packets =0 ; - stats_prev->tx_bytes =0 ; - stats_prev->rx_packets =0 ; - stats_prev->rx_bytes =0 ; +/* Update netdev counters, but keep in mind that values could start at +* random value after PF reset. And as we increase the reported stat by +* diff of Prev-Cur, we need to be sure that Prev is valid. If it's not, +* let's skip this round. +*/ +if (likely (pf->stat_prev_loaded)) { + net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; + net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; + net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; + net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; } -/* update netdev counters */ - net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; - net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; - net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; - net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; - stats_prev->tx_packets = vsi_stats->tx_packets; stats_prev->tx_bytes = vsi_stats->tx_bytes; stats_prev->rx_packets = vsi_stats->rx_packets;
Signature · 1 line
2.41.0
This series was applied to netdev/net.git (main) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Tony Nguyen <[email protected]>:
Quoted 9 lines · On Wed, 6 Mar 2024 10:26:11 -0800 you wrote:
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.
[...]
Here is the summary with links:
- [net,1/3] igc: Fix missing time sync events
https://git.kernel.org/netdev/net/c/244ae992e3e8 - [net,2/3] igb: Fix missing time sync events https://git.kernel.org/netdev/net/c/ee14cc9ea19b - [net,3/3] ice: fix stats being updated by way too large values https://git.kernel.org/netdev/net/c/257310e99870
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html