netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14
@ 2021-12-14 19:50 Tony Nguyen
  2021-12-14 19:50 ` [PATCH net 1/2] ice: Use div64_u64 instead of div_u64 in adjfine Tony Nguyen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tony Nguyen @ 2021-12-14 19:50 UTC (permalink / raw)
  To: davem, kuba; +Cc: Tony Nguyen, netdev, richardcochran, karol.kolacinski

This series contains updates to ice driver only.

Karol corrects division that was causing incorrect calculations and
adds a check to ensure stale timestamps are not being used.

The following are changes since commit 3dd7d40b43663f58d11ee7a3d3798813b26a48f1:
  Merge branch 'mlxsw-fixes'
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE

Karol Kolacinski (2):
  ice: Use div64_u64 instead of div_u64 in adjfine
  ice: Don't put stale timestamps in the skb

 drivers/net/ethernet/intel/ice/ice_ptp.c | 13 +++++--------
 drivers/net/ethernet/intel/ice/ice_ptp.h |  6 ++++++
 2 files changed, 11 insertions(+), 8 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] ice: Use div64_u64 instead of div_u64 in adjfine
  2021-12-14 19:50 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 Tony Nguyen
@ 2021-12-14 19:50 ` Tony Nguyen
  2021-12-14 19:50 ` [PATCH net 2/2] ice: Don't put stale timestamps in the skb Tony Nguyen
  2021-12-15 11:10 ` [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Tony Nguyen @ 2021-12-14 19:50 UTC (permalink / raw)
  To: davem, kuba
  Cc: Karol Kolacinski, netdev, anthony.l.nguyen, richardcochran, Gurucharan G

From: Karol Kolacinski <karol.kolacinski@intel.com>

Change the division in ice_ptp_adjfine from div_u64 to div64_u64.
div_u64 is used when the divisor is 32 bit but in this case incval is
64 bit and it caused incorrect calculations and incval adjustments.

Fixes: 06c16d89d2cb ("ice: register 1588 PTP clock device object for E810 devices")
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index bf7247c6f58e..ad7cabe7932f 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -705,7 +705,7 @@ static int ice_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)
 		scaled_ppm = -scaled_ppm;
 	}
 
-	while ((u64)scaled_ppm > div_u64(U64_MAX, incval)) {
+	while ((u64)scaled_ppm > div64_u64(U64_MAX, incval)) {
 		/* handle overflow by scaling down the scaled_ppm and
 		 * the divisor, losing some precision
 		 */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] ice: Don't put stale timestamps in the skb
  2021-12-14 19:50 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 Tony Nguyen
  2021-12-14 19:50 ` [PATCH net 1/2] ice: Use div64_u64 instead of div_u64 in adjfine Tony Nguyen
@ 2021-12-14 19:50 ` Tony Nguyen
  2021-12-15 11:10 ` [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Tony Nguyen @ 2021-12-14 19:50 UTC (permalink / raw)
  To: davem, kuba
  Cc: Karol Kolacinski, netdev, anthony.l.nguyen, richardcochran, Gurucharan G

From: Karol Kolacinski <karol.kolacinski@intel.com>

The driver has to check if it does not accidentally put the timestamp in
the SKB before previous timestamp gets overwritten.
Timestamp values in the PHY are read only and do not get cleared except
at hardware reset or when a new timestamp value is captured.
The cached_tstamp field is used to detect the case where a new timestamp
has not yet been captured, ensuring that we avoid sending stale
timestamp data to the stack.

Fixes: ea9b847cda64 ("ice: enable transmit timestamps for E810 devices")
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 11 ++++-------
 drivers/net/ethernet/intel/ice/ice_ptp.h |  6 ++++++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index ad7cabe7932f..442b031b0edc 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -1540,19 +1540,16 @@ static void ice_ptp_tx_tstamp_work(struct kthread_work *work)
 		if (err)
 			continue;
 
-		/* Check if the timestamp is valid */
-		if (!(raw_tstamp & ICE_PTP_TS_VALID))
+		/* Check if the timestamp is invalid or stale */
+		if (!(raw_tstamp & ICE_PTP_TS_VALID) ||
+		    raw_tstamp == tx->tstamps[idx].cached_tstamp)
 			continue;
 
-		/* clear the timestamp register, so that it won't show valid
-		 * again when re-used.
-		 */
-		ice_clear_phy_tstamp(hw, tx->quad, phy_idx);
-
 		/* The timestamp is valid, so we'll go ahead and clear this
 		 * index and then send the timestamp up to the stack.
 		 */
 		spin_lock(&tx->lock);
+		tx->tstamps[idx].cached_tstamp = raw_tstamp;
 		clear_bit(idx, tx->in_use);
 		skb = tx->tstamps[idx].skb;
 		tx->tstamps[idx].skb = NULL;
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h
index f71ad317d6c8..53c15fc9d996 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.h
@@ -55,15 +55,21 @@ struct ice_perout_channel {
  * struct ice_tx_tstamp - Tracking for a single Tx timestamp
  * @skb: pointer to the SKB for this timestamp request
  * @start: jiffies when the timestamp was first requested
+ * @cached_tstamp: last read timestamp
  *
  * This structure tracks a single timestamp request. The SKB pointer is
  * provided when initiating a request. The start time is used to ensure that
  * we discard old requests that were not fulfilled within a 2 second time
  * window.
+ * Timestamp values in the PHY are read only and do not get cleared except at
+ * hardware reset or when a new timestamp value is captured. The cached_tstamp
+ * field is used to detect the case where a new timestamp has not yet been
+ * captured, ensuring that we avoid sending stale timestamp data to the stack.
  */
 struct ice_tx_tstamp {
 	struct sk_buff *skb;
 	unsigned long start;
+	u64 cached_tstamp;
 };
 
 /**
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14
  2021-12-14 19:50 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 Tony Nguyen
  2021-12-14 19:50 ` [PATCH net 1/2] ice: Use div64_u64 instead of div_u64 in adjfine Tony Nguyen
  2021-12-14 19:50 ` [PATCH net 2/2] ice: Don't put stale timestamps in the skb Tony Nguyen
@ 2021-12-15 11:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-15 11:10 UTC (permalink / raw)
  To: Tony Nguyen; +Cc: davem, kuba, netdev, richardcochran, karol.kolacinski

Hello:

This series was applied to netdev/net.git (master)
by Tony Nguyen <anthony.l.nguyen@intel.com>:

On Tue, 14 Dec 2021 11:50:18 -0800 you wrote:
> This series contains updates to ice driver only.
> 
> Karol corrects division that was causing incorrect calculations and
> adds a check to ensure stale timestamps are not being used.
> 
> The following are changes since commit 3dd7d40b43663f58d11ee7a3d3798813b26a48f1:
>   Merge branch 'mlxsw-fixes'
> and are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE
> 
> [...]

Here is the summary with links:
  - [net,1/2] ice: Use div64_u64 instead of div_u64 in adjfine
    https://git.kernel.org/netdev/net/c/0013881c1145
  - [net,2/2] ice: Don't put stale timestamps in the skb
    https://git.kernel.org/netdev/net/c/37e738b6fdb1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-15 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 19:50 [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 Tony Nguyen
2021-12-14 19:50 ` [PATCH net 1/2] ice: Use div64_u64 instead of div_u64 in adjfine Tony Nguyen
2021-12-14 19:50 ` [PATCH net 2/2] ice: Don't put stale timestamps in the skb Tony Nguyen
2021-12-15 11:10 ` [PATCH net 0/2][pull request] Intel Wired LAN Driver Updates 2021-12-14 patchwork-bot+netdevbpf

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).