* [PATCH] igb: Fix extts capture value format for 82580/i354/i350
@ 2023-05-31 9:08 Yuezhen Luan
2023-05-31 22:01 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Yuezhen Luan @ 2023-05-31 9:08 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni
Cc: intel-wired-lan, netdev, linux-kernel, jacob.e.keller,
Yuezhen Luan
82580/i354/i350 features circle-counter-like timestamp registers
that are different with newer i210. The EXTTS capture value in
AUXTSMPx should be converted from raw circle counter value to
timestamp value in resolution of 1 nanosec by the driver.
Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 58872a4c2..187daa8ef 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
struct e1000_hw *hw = &adapter->hw;
struct ptp_clock_event event;
struct timespec64 ts;
+ unsigned long flags;
if (pin < 0 || pin >= IGB_N_SDP)
return;
@@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
if (hw->mac.type == e1000_82580 ||
hw->mac.type == e1000_i354 ||
hw->mac.type == e1000_i350) {
- s64 ns = rd32(auxstmpl);
+ u64 ns = rd32(auxstmpl);
- ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
+ ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
+ spin_lock_irqsave(&adapter->tc, ns);
+ ns = timecounter_cyc2time(&adapter->tc, ns);
+ spin_unlock_irqrestore(&adapter->tc, ns);
ts = ns_to_timespec64(ns);
} else {
ts.tv_nsec = rd32(auxstmpl);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] igb: Fix extts capture value format for 82580/i354/i350
2023-05-31 9:08 Yuezhen Luan
@ 2023-05-31 22:01 ` Simon Horman
0 siblings, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-05-31 22:01 UTC (permalink / raw)
To: Yuezhen Luan
Cc: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni,
intel-wired-lan, netdev, linux-kernel, jacob.e.keller
On Wed, May 31, 2023 at 09:08:05AM +0000, Yuezhen Luan wrote:
> 82580/i354/i350 features circle-counter-like timestamp registers
> that are different with newer i210. The EXTTS capture value in
> AUXTSMPx should be converted from raw circle counter value to
> timestamp value in resolution of 1 nanosec by the driver.
>
> Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
> ---
> drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 58872a4c2..187daa8ef 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
> struct e1000_hw *hw = &adapter->hw;
> struct ptp_clock_event event;
> struct timespec64 ts;
> + unsigned long flags;
>
> if (pin < 0 || pin >= IGB_N_SDP)
> return;
> @@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
> if (hw->mac.type == e1000_82580 ||
> hw->mac.type == e1000_i354 ||
> hw->mac.type == e1000_i350) {
> - s64 ns = rd32(auxstmpl);
> + u64 ns = rd32(auxstmpl);
>
> - ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
> + ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
> + spin_lock_irqsave(&adapter->tc, ns);
> + ns = timecounter_cyc2time(&adapter->tc, ns);
> + spin_unlock_irqrestore(&adapter->tc, ns);
Hi Yuezhen Luan,
unfortunately this doesn't compile because the arguments to
spin_lock_irqsave/spin_unlock_irqrestore are wrong.
> ts = ns_to_timespec64(ns);
> } else {
> ts.tv_nsec = rd32(auxstmpl);
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] igb: Fix extts capture value format for 82580/i354/i350
@ 2023-06-01 1:59 Yuezhen Luan
0 siblings, 0 replies; 3+ messages in thread
From: Yuezhen Luan @ 2023-06-01 1:59 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni
Cc: intel-wired-lan, netdev, linux-kernel, jacob.e.keller,
Yuezhen Luan
82580/i354/i350 features circle-counter-like timestamp registers
that are different with newer i210. The EXTTS capture value in
AUXTSMPx should be converted from raw circle counter value to
timestamp value in resolution of 1 nanosec by the driver.
Signed-off-by: Yuezhen Luan <eggcar.luan@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 58872a4c2..bb3db387d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6947,6 +6947,7 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
struct e1000_hw *hw = &adapter->hw;
struct ptp_clock_event event;
struct timespec64 ts;
+ unsigned long flags;
if (pin < 0 || pin >= IGB_N_SDP)
return;
@@ -6954,9 +6955,12 @@ static void igb_extts(struct igb_adapter *adapter, int tsintr_tt)
if (hw->mac.type == e1000_82580 ||
hw->mac.type == e1000_i354 ||
hw->mac.type == e1000_i350) {
- s64 ns = rd32(auxstmpl);
+ u64 ns = rd32(auxstmpl);
- ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32;
+ ns += ((u64)(rd32(auxstmph) & 0xFF)) << 32;
+ spin_lock_irqsave(&adapter->tmreg_lock, flags);
+ ns = timecounter_cyc2time(&adapter->tc, ns);
+ spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
ts = ns_to_timespec64(ns);
} else {
ts.tv_nsec = rd32(auxstmpl);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-01 1:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01 1:59 [PATCH] igb: Fix extts capture value format for 82580/i354/i350 Yuezhen Luan
-- strict thread matches above, loose matches on Subject: below --
2023-05-31 9:08 Yuezhen Luan
2023-05-31 22:01 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).