lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <AM0PR09MB427698DBBB4F1A52C8A1A810F0E19@AM0PR09MB4276.eurprd09.prod.outlook.com>
Date:   Mon, 19 Jul 2021 11:33:24 +0000
From:   Ruud Bos <ruud.bos@...world.com>
To:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC:     "davem@...emloft.net" <davem@...emloft.net>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "jesse.brandeburg@...el.com" <jesse.brandeburg@...el.com>,
        "anthony.l.nguyen@...el.com" <anthony.l.nguyen@...el.com>
Subject: [PATCH net-next 2/4 resend] igb: move PEROUT and EXTTS isr logic to
 separate functions

Remove code duplication in the tsync interrupt handler function by moving
this logic to separate functions. This keeps the interrupt handler readable
and allows the new functions to be extended for adapter types other than
i210.

Signed-off-by: Ruud Bos <ruud.bos@...world.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 79 +++++++++++++----------
 1 file changed, 44 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 7e6435dc7e80..928ac9ba1c66 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6721,12 +6721,50 @@ void igb_update_stats(struct igb_adapter *adapter)
        }
 }

+static void igb_perout(struct igb_adapter *adapter, int sdp)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       struct timespec64 ts;
+       u32 tsauxc;
+
+       if (sdp < 0 || sdp >= IGB_N_PEROUT)
+               return;
+
+       spin_lock(&adapter->tmreg_lock);
+       ts = timespec64_add(adapter->perout[sdp].start,
+                           adapter->perout[sdp].period);
+       /* u32 conversion of tv_sec is safe until y2106 */
+       wr32((sdp == 1) ? E1000_TRGTTIML1 : E1000_TRGTTIML0, ts.tv_nsec);
+       wr32((sdp == 1) ? E1000_TRGTTIMH1 : E1000_TRGTTIMH0, (u32)ts.tv_sec);
+       tsauxc = rd32(E1000_TSAUXC);
+       tsauxc |= TSAUXC_EN_TT0;
+       wr32(E1000_TSAUXC, tsauxc);
+       adapter->perout[sdp].start = ts;
+       spin_unlock(&adapter->tmreg_lock);
+}
+
+static void igb_extts(struct igb_adapter *adapter, int sdp)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       u32 sec, nsec;
+       struct ptp_clock_event event;
+
+       if (sdp < 0 || sdp >= IGB_N_EXTTS)
+               return;
+
+       nsec = rd32((sdp == 1) ? E1000_AUXSTMPL1 : E1000_AUXSTMPL0);
+       sec  = rd32((sdp == 1) ? E1000_AUXSTMPH1 : E1000_AUXSTMPH0);
+       event.type = PTP_CLOCK_EXTTS;
+       event.index = sdp;
+       event.timestamp = sec * 1000000000ULL + nsec;
+       ptp_clock_event(adapter->ptp_clock, &event);
+}
+
 static void igb_tsync_interrupt(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        struct ptp_clock_event event;
-       struct timespec64 ts;
-       u32 ack = 0, tsauxc, sec, nsec, tsicr = rd32(E1000_TSICR);
+       u32 ack = 0, tsicr = rd32(E1000_TSICR);

        if (tsicr & TSINTR_SYS_WRAP) {
                event.type = PTP_CLOCK_PPS;
@@ -6742,51 +6780,22 @@ static void igb_tsync_interrupt(struct igb_adapter *adapter)
        }

        if (tsicr & TSINTR_TT0) {
-               spin_lock(&adapter->tmreg_lock);
-               ts = timespec64_add(adapter->perout[0].start,
-                                   adapter->perout[0].period);
-               /* u32 conversion of tv_sec is safe until y2106 */
-               wr32(E1000_TRGTTIML0, ts.tv_nsec);
-               wr32(E1000_TRGTTIMH0, (u32)ts.tv_sec);
-               tsauxc = rd32(E1000_TSAUXC);
-               tsauxc |= TSAUXC_EN_TT0;
-               wr32(E1000_TSAUXC, tsauxc);
-               adapter->perout[0].start = ts;
-               spin_unlock(&adapter->tmreg_lock);
+               igb_perout(adapter, 0);
                ack |= TSINTR_TT0;
        }

        if (tsicr & TSINTR_TT1) {
-               spin_lock(&adapter->tmreg_lock);
-               ts = timespec64_add(adapter->perout[1].start,
-                                   adapter->perout[1].period);
-               wr32(E1000_TRGTTIML1, ts.tv_nsec);
-               wr32(E1000_TRGTTIMH1, (u32)ts.tv_sec);
-               tsauxc = rd32(E1000_TSAUXC);
-               tsauxc |= TSAUXC_EN_TT1;
-               wr32(E1000_TSAUXC, tsauxc);
-               adapter->perout[1].start = ts;
-               spin_unlock(&adapter->tmreg_lock);
+               igb_perout(adapter, 1);
                ack |= TSINTR_TT1;
        }

        if (tsicr & TSINTR_AUTT0) {
-               nsec = rd32(E1000_AUXSTMPL0);
-               sec  = rd32(E1000_AUXSTMPH0);
-               event.type = PTP_CLOCK_EXTTS;
-               event.index = 0;
-               event.timestamp = sec * 1000000000ULL + nsec;
-               ptp_clock_event(adapter->ptp_clock, &event);
+               igb_extts(adapter, 0);
                ack |= TSINTR_AUTT0;
        }

        if (tsicr & TSINTR_AUTT1) {
-               nsec = rd32(E1000_AUXSTMPL1);
-               sec  = rd32(E1000_AUXSTMPH1);
-               event.type = PTP_CLOCK_EXTTS;
-               event.index = 1;
-               event.timestamp = sec * 1000000000ULL + nsec;
-               ptp_clock_event(adapter->ptp_clock, &event);
+               igb_extts(adapter, 1);
                ack |= TSINTR_AUTT1;
        }

--
2.30.2


UNRESTRICTED
HBK Benelux B.V., Schutweg 15a, NL-5145 NP Waalwijk, The Netherlands www.hbkworld.com Registered as B.V. (Dutch limited liability company) in the Dutch commercial register 08183075 0000 Company domiciled in Waalwijk Managing Directors : Alexandra Hellemans, Jens Wiegand, Jorn Bagijn The information in this email is confidential. It is intended solely for the addressee. If you are not the intended recipient, please let me know and delete this email.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ