From f079d69c7601561b9f85dd693f72163a399acba5 Mon Sep 17 00:00:00 2001 From: chengyechun Date: Fri, 28 Jul 2023 11:41:50 +0800 Subject: [PATCH] use mul_u64_u64_div_u64 and convert .adjfreq to .adjfine --- ...-obsolte-u64_stats_fetch_-_irq-users.patch | 110 ++++++++++++++++++ ...u64-and-convert-.adjfreq-to-.adjfine.patch | 87 ++++++++++++++ i40e.spec | 12 +- 3 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 backport-Remove-the-obsolte-u64_stats_fetch_-_irq-users.patch create mode 100644 backport-use-mul_u64_u64_div_u64-and-convert-.adjfreq-to-.adjfine.patch diff --git a/backport-Remove-the-obsolte-u64_stats_fetch_-_irq-users.patch b/backport-Remove-the-obsolte-u64_stats_fetch_-_irq-users.patch new file mode 100644 index 0000000..34a7c14 --- /dev/null +++ b/backport-Remove-the-obsolte-u64_stats_fetch_-_irq-users.patch @@ -0,0 +1,110 @@ +From 068c38ad88ccb09e5e966d4db5cedab0e02b3b95 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +Date: Wed, 26 Oct 2022 15:22:27 +0200 +Subject: [PATCH] Remove the obsolte u64_stats_fetch_*_irq users + +Conflict:NA +Reference:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=068c38ad88ccb09e5e966d4db5ce +dab0e02b3b95 +--- + src/i40e_ethtool_stats.h | 8 ++++---- + src/i40e_main.c | 16 ++++++++-------- + 2 files changed, 12 insertions(+), 12 deletions(-) + +diff --git a/src/i40e_ethtool_stats.h b/src/i40e_ethtool_stats.h +index 0851064..e93acfe 100644 +--- a/src/i40e_ethtool_stats.h ++++ b/src/i40e_ethtool_stats.h +@@ -190,10 +190,10 @@ i40e_add_queue_stats(u64 **data, struct i40e_ring *ring) + */ + #ifdef HAVE_NDO_GET_STATS64 + do { +- start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp); ++ start = !ring ? 0 : u64_stats_fetch_begin(&ring->syncp); + for (i = 0; i < size; i++) + i40e_add_one_ethtool_stat(&(*data)[i], ring, &stats[i]); +- } while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start)); ++ } while (ring && u64_stats_fetch_retry(&ring->syncp, start)); + #else + for (i = 0; i < size; i++) + i40e_add_one_ethtool_stat(&(*data)[i], ring, &stats[i]); +@@ -237,14 +237,14 @@ i40e_add_rx_queue_xdp_stats(u64 **data, struct i40e_ring *rx_ring) + #ifdef HAVE_NDO_GET_STATS64 + do { + start = !rx_ring ? 0 : +- u64_stats_fetch_begin_irq(&rx_ring->syncp); ++ u64_stats_fetch_begin(&rx_ring->syncp); + #endif + for (i = 0; i < xdp_size; i++) { + i40e_add_one_ethtool_stat(&(*data)[i], rx_ring, + &xdp_stats[i]); + } + #ifdef HAVE_NDO_GET_STATS64 +- } while (rx_ring && u64_stats_fetch_retry_irq(&rx_ring->syncp, start)); ++ } while (rx_ring && u64_stats_fetch_retry(&rx_ring->syncp, start)); + #endif + + /* Once we successfully copy the stats in, update the data pointer */ +diff --git a/src/i40e_main.c b/src/i40e_main.c +index ed4271e..170f033 100644 +--- a/src/i40e_main.c ++++ b/src/i40e_main.c +@@ -482,10 +482,10 @@ static void i40e_get_netdev_stats_struct_tx(struct i40e_ring *ring, + unsigned int start; + + do { +- start = u64_stats_fetch_begin_irq(&ring->syncp); ++ start = u64_stats_fetch_begin(&ring->syncp); + packets = ring->stats.packets; + bytes = ring->stats.bytes; +- } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); ++ } while (u64_stats_fetch_retry(&ring->syncp, start)); + + stats->tx_packets += packets; + stats->tx_bytes += bytes; +@@ -541,10 +541,10 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct( + rx_ring = &tx_ring[1]; + + do { +- start = u64_stats_fetch_begin_irq(&rx_ring->syncp); ++ start = u64_stats_fetch_begin(&rx_ring->syncp); + packets = rx_ring->stats.packets; + bytes = rx_ring->stats.bytes; +- } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start)); ++ } while (u64_stats_fetch_retry(&rx_ring->syncp, start)); + + stats->rx_packets += packets; + stats->rx_bytes += bytes; +@@ -1011,12 +1011,12 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi) + + #ifdef HAVE_NDO_GET_STATS64 + do { +- start = u64_stats_fetch_begin_irq(&p->syncp); ++ start = u64_stats_fetch_begin(&p->syncp); + #endif + packets = p->stats.packets; + bytes = p->stats.bytes; + #ifdef HAVE_NDO_GET_STATS64 +- } while (u64_stats_fetch_retry_irq(&p->syncp, start)); ++ } while (u64_stats_fetch_retry(&p->syncp, start)); + #endif + tx_b += bytes; + tx_p += packets; +@@ -1030,12 +1030,12 @@ static void i40e_update_vsi_stats(struct i40e_vsi *vsi) + p = &p[1]; + #ifdef HAVE_NDO_GET_STATS64 + do { +- start = u64_stats_fetch_begin_irq(&p->syncp); ++ start = u64_stats_fetch_begin(&p->syncp); + #endif + packets = p->stats.packets; + bytes = p->stats.bytes; + #ifdef HAVE_NDO_GET_STATS64 +- } while (u64_stats_fetch_retry_irq(&p->syncp, start)); ++ } while (u64_stats_fetch_retry(&p->syncp, start)); + #endif + rx_b += bytes; + rx_p += packets; +-- +2.23.0 + diff --git a/backport-use-mul_u64_u64_div_u64-and-convert-.adjfreq-to-.adjfine.patch b/backport-use-mul_u64_u64_div_u64-and-convert-.adjfreq-to-.adjfine.patch new file mode 100644 index 0000000..a696049 --- /dev/null +++ b/backport-use-mul_u64_u64_div_u64-and-convert-.adjfreq-to-.adjfine.patch @@ -0,0 +1,87 @@ +From cdd3bf98592117f59be2daa0f2ca00f352d7abbc Mon Sep 17 00:00:00 2001 +From: Jacob Keller +Date: Thu, 21 Jul 2022 14:29:59 -0700 +Subject: [PATCH] use mul_u64_u64_div_u64 and convert .adjfreq to .adjfine + +Conflict:NA +Reference:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ccd3bf98592117f59be2daa0f2ca00f352d7abbc + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3626a690b717c18a969274e1fe000f8885d5afad + +--- + src/i40e_ptp.c | 35 ++++++++++++++--------------------- + 1 file changed, 14 insertions(+), 21 deletions(-) + +diff --git a/src/i40e_ptp.c b/src/i40e_ptp.c +index a94b774..710c02b 100644 +--- a/src/i40e_ptp.c ++++ b/src/i40e_ptp.c +@@ -349,44 +349,37 @@ static void i40e_ptp_convert_to_hwtstamp(struct skb_shared_hwtstamps *hwtstamps, + } + + /** +- * i40e_ptp_adjfreq - Adjust the PHC frequency ++ * i40e_ptp_adjfine - Adjust the PHC frequency + * @ptp: The PTP clock structure +- * @ppb: Parts per billion adjustment from the base ++ * @scaled_ppm: Scaled_ppm Parts per million adjustment from the base + * +- * Adjust the frequency of the PHC by the indicated parts per billion from the +- * base frequency. ++ * Adjust the frequency of the PHC by the indicated delta from the base ++ * frequency. ++ * ++ * Scaled parts per million is ppm with a 16 bit binary fractional filed. + **/ +-static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) ++static int i40e_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) + { + struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); + struct i40e_hw *hw = &pf->hw; + u64 adj, freq, diff; + int neg_adj = 0; + +- if (ppb < 0) { ++ if (scaled_ppm < 0) { + neg_adj = 1; +- ppb = -ppb; ++ scaled_ppm = -scaled_ppm; + } + +- freq = I40E_PTP_40GB_INCVAL; +- freq *= ppb; +- diff = div_u64(freq, 1000000000ULL); ++ smp_mb(); /* Force any pending update before accessing. */ ++ freq = I40E_PTP_40GB_INCVAL * READ_ONCE(pf->ptp_adj_mult); ++ diff = mul_u64_u64_div_u64(freq, (u64)scaled_ppm, ++ 1000000000ULL << 16); + + if (neg_adj) + adj = I40E_PTP_40GB_INCVAL - diff; + else + adj = I40E_PTP_40GB_INCVAL + diff; + +- /* At some link speeds, the base incval is so large that directly +- * multiplying by ppb would result in arithmetic overflow even when +- * using a u64. Avoid this by instead calculating the new incval +- * always in terms of the 40GbE clock rate and then multiplying by the +- * link speed factor afterwards. This does result in slightly lower +- * precision at lower link speeds, but it is fairly minor. +- */ +- smp_mb(); /* Force any pending update before accessing. */ +- adj *= READ_ONCE(pf->ptp_adj_mult); +- + wr32(hw, I40E_PRTTSYN_INC_L, (u32)adj); + wr32(hw, I40E_PRTTSYN_INC_H, (u32)(adj >> 32)); + +@@ -1558,7 +1551,7 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf) + sizeof(pf->ptp_caps.name) - 1); + pf->ptp_caps.owner = THIS_MODULE; + pf->ptp_caps.max_adj = 999999999; +- pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; ++ pf->ptp_caps.adjfine = i40e_ptp_adjfine; + pf->ptp_caps.adjtime = i40e_ptp_adjtime; + #ifdef HAVE_PTP_CLOCK_INFO_GETTIME64 + pf->ptp_caps.gettime64 = i40e_ptp_gettime; +-- +2.23.0 + diff --git a/i40e.spec b/i40e.spec index 8607e86..18b15f5 100644 --- a/i40e.spec +++ b/i40e.spec @@ -9,12 +9,15 @@ Name: i40e Summary: Intel(R) 40-10 Gigabit Ethernet Connection Network Driver Version: 2.22.8 -Release: 2 +Release: 3 Vendor: Intel Corporation License: GPL-2.0 URL: http://support.intel.com Source0: https://downloadmirror.intel.com/763931/%{name}-%{version}.tar.gz +Patch6000: backport-Remove-the-obsolte-u64_stats_fetch_-_irq-users.patch +Patch6001: backport-use-mul_u64_u64_div_u64-and-convert-.adjfreq-to-.adjfine.patch + Requires: kernel, findutils, gawk, bash, hwdata BuildRequires: kernel-devel hwdata elfutils-devel uname-build-checks gcc @@ -381,6 +384,13 @@ else fi %changelog +* Wed Jul 26 2023 chengyechun - 2.22.8-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Remove the obsolte u64_stats_fetch_*_irq() users + use mul_u64_u64_div_u64 and convert .adjfreq to .adjfine + * Thu Feb 2 2023 chengyechun - 2.22.8-2 - Type:bugfix - ID:NA