Commit cf99c1dd authored by Ruud Bos's avatar Ruud Bos Committed by Tony Nguyen

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: default avatarRuud Bos <kernel.hbk@gmail.com>
Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 8ab55aba
...@@ -6739,12 +6739,52 @@ void igb_update_stats(struct igb_adapter *adapter) ...@@ -6739,12 +6739,52 @@ void igb_update_stats(struct igb_adapter *adapter)
} }
} }
static void igb_perout(struct igb_adapter *adapter, int tsintr_tt)
{
int pin = ptp_find_pin(adapter->ptp_clock, PTP_PF_PEROUT, tsintr_tt);
struct e1000_hw *hw = &adapter->hw;
struct timespec64 ts;
u32 tsauxc;
if (pin < 0 || pin >= IGB_N_PEROUT)
return;
spin_lock(&adapter->tmreg_lock);
ts = timespec64_add(adapter->perout[pin].start,
adapter->perout[pin].period);
/* u32 conversion of tv_sec is safe until y2106 */
wr32((tsintr_tt == 1) ? E1000_TRGTTIML1 : E1000_TRGTTIML0, ts.tv_nsec);
wr32((tsintr_tt == 1) ? E1000_TRGTTIMH1 : E1000_TRGTTIMH0, (u32)ts.tv_sec);
tsauxc = rd32(E1000_TSAUXC);
tsauxc |= TSAUXC_EN_TT0;
wr32(E1000_TSAUXC, tsauxc);
adapter->perout[pin].start = ts;
spin_unlock(&adapter->tmreg_lock);
}
static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
{
int pin = ptp_find_pin(adapter->ptp_clock, PTP_PF_EXTTS, tsintr_tt);
struct e1000_hw *hw = &adapter->hw;
struct ptp_clock_event event;
u32 sec, nsec;
if (pin < 0 || pin >= IGB_N_EXTTS)
return;
nsec = rd32((tsintr_tt == 1) ? E1000_AUXSTMPL1 : E1000_AUXSTMPL0);
sec = rd32((tsintr_tt == 1) ? E1000_AUXSTMPH1 : E1000_AUXSTMPH0);
event.type = PTP_CLOCK_EXTTS;
event.index = tsintr_tt;
event.timestamp = sec * 1000000000ULL + nsec;
ptp_clock_event(adapter->ptp_clock, &event);
}
static void igb_tsync_interrupt(struct igb_adapter *adapter) static void igb_tsync_interrupt(struct igb_adapter *adapter)
{ {
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
u32 ack = 0, tsicr = rd32(E1000_TSICR);
struct ptp_clock_event event; struct ptp_clock_event event;
struct timespec64 ts;
u32 ack = 0, tsauxc, sec, nsec, tsicr = rd32(E1000_TSICR);
if (tsicr & TSINTR_SYS_WRAP) { if (tsicr & TSINTR_SYS_WRAP) {
event.type = PTP_CLOCK_PPS; event.type = PTP_CLOCK_PPS;
...@@ -6760,51 +6800,22 @@ static void igb_tsync_interrupt(struct igb_adapter *adapter) ...@@ -6760,51 +6800,22 @@ static void igb_tsync_interrupt(struct igb_adapter *adapter)
} }
if (tsicr & TSINTR_TT0) { if (tsicr & TSINTR_TT0) {
spin_lock(&adapter->tmreg_lock); igb_perout(adapter, 0);
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);
ack |= TSINTR_TT0; ack |= TSINTR_TT0;
} }
if (tsicr & TSINTR_TT1) { if (tsicr & TSINTR_TT1) {
spin_lock(&adapter->tmreg_lock); igb_perout(adapter, 1);
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);
ack |= TSINTR_TT1; ack |= TSINTR_TT1;
} }
if (tsicr & TSINTR_AUTT0) { if (tsicr & TSINTR_AUTT0) {
nsec = rd32(E1000_AUXSTMPL0); igb_extts(adapter, 0);
sec = rd32(E1000_AUXSTMPH0);
event.type = PTP_CLOCK_EXTTS;
event.index = 0;
event.timestamp = sec * 1000000000ULL + nsec;
ptp_clock_event(adapter->ptp_clock, &event);
ack |= TSINTR_AUTT0; ack |= TSINTR_AUTT0;
} }
if (tsicr & TSINTR_AUTT1) { if (tsicr & TSINTR_AUTT1) {
nsec = rd32(E1000_AUXSTMPL1); igb_extts(adapter, 1);
sec = rd32(E1000_AUXSTMPH1);
event.type = PTP_CLOCK_EXTTS;
event.index = 1;
event.timestamp = sec * 1000000000ULL + nsec;
ptp_clock_event(adapter->ptp_clock, &event);
ack |= TSINTR_AUTT1; ack |= TSINTR_AUTT1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment