Skip to contentSkip to conversation

igb/igc: use ktime accessors for skb->tstamp

Intel-wired-lan Jacob Keller 2 participants 2 messages Nov 6, 2019 – Nov 7, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

When implementing launch time support in the igb and igc drivers, the skb->tstamp value is assumed to be a s64, but it's declared as a ktime_t value.

Although ktime_t is typedef'd to s64 it wasn't always, and the kernel provides accessors for ktime_t values.

Use the ktime_to_timespec64 and ktime_set accessors instead of directly assuming that the variable is always an s64.

This improves portability if the code is ever moved to another kernel version, or if the definition of ktime_t ever changes again in the future.

---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 ++--
 drivers/net/ethernet/intel/igc/igc_main.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +2 -2
index 9148c62d9ac5..ed7e667d7eb2 100644
@@ -5675,8 +5675,8 @@ static void igb_tx_ctxtdesc(struct igb_ring *tx_ring,
 	 * should have been handled by the upper layers.
 	 */
 	if (tx_ring->launchtime_enable) {
-		ts = ns_to_timespec64(first->skb->tstamp);
-		first->skb->tstamp = 0;
+		ts = ktime_to_timespec64(first->skb->tstamp);
+		first->skb->tstamp = ktime_set(0, 0);
 		context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32);
 	} else {
 		context_desc->seqnum_seed = 0;
drivers/net/ethernet/intel/igc/igc_main.c +2 -2
index 8e424dfab12e..24888676f69b 100644
@@ -824,8 +824,8 @@ static void igc_tx_ctxtdesc(struct igc_ring *tx_ring,
 	 * should have been handled by the upper layers.
 	 */
 	if (tx_ring->launchtime_enable) {
-		ts = ns_to_timespec64(first->skb->tstamp);
-		first->skb->tstamp = 0;
+		ts = ktime_to_timespec64(first->skb->tstamp);
+		first->skb->tstamp = ktime_set(0, 0);
 		context_desc->launch_time = cpu_to_le32(ts.tv_nsec / 32);
 	} else {
 		context_desc->launch_time = 0;
Signature · 1 line
2.23.0.245.gf157bbb9169d
#1 lore raw
Quoted 10 lines · Jacob Keller

When implementing launch time support in the igb and igc drivers, the skb->tstamp value is assumed to be a s64, but it's declared as a ktime_t value.

Although ktime_t is typedef'd to s64 it wasn't always, and the kernel provides accessors for ktime_t values.

Use the ktime_to_timespec64 and ktime_set accessors instead of directly assuming that the variable is always an s64.

Quoted 6 lines

This improves portability if the code is ever moved to another kernel version, or if the definition of ktime_t ever changes again in the future.

---