Thread (13 messages) flat view 13 messages, 3 authors, 2022-06-27
STALE1552d

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH net-next 1/4] time64.h: define PSEC_PER_NSEC and use it in tc-taprio

From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: 2022-06-26 12:05:47
Also in: lkml
Subsystem: cbs/etf/taprio qdiscs, generic vdso library, networking [general], tc subsystem, the rest · Maintainers: Vinicius Costa Gomes, Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jamal Hadi Salim, Jiri Pirko, Linus Torvalds

Time-sensitive networking code needs to work with PTP times expressed in
nanoseconds, and with packet transmission times expressed in
picoseconds, since those would be fractional at higher than gigabit
speed when expressed in nanoseconds.

Convert the existing uses in tc-taprio to a PSEC_PER_NSEC macro.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Gleixner <redacted>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 include/vdso/time64.h  | 1 +
 net/sched/sch_taprio.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/vdso/time64.h b/include/vdso/time64.h
index b40cfa2aa33c..f1c2d02474ae 100644
--- a/include/vdso/time64.h
+++ b/include/vdso/time64.h
@@ -6,6 +6,7 @@
 #define MSEC_PER_SEC	1000L
 #define USEC_PER_MSEC	1000L
 #define NSEC_PER_USEC	1000L
+#define PSEC_PER_NSEC	1000L
 #define NSEC_PER_MSEC	1000000L
 #define USEC_PER_SEC	1000000L
 #define NSEC_PER_SEC	1000000000L
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index b9c71a304d39..55a9c5ad9954 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -176,7 +176,7 @@ static ktime_t get_interval_end_time(struct sched_gate_list *sched,
 
 static int length_to_duration(struct taprio_sched *q, int len)
 {
-	return div_u64(len * atomic64_read(&q->picos_per_byte), 1000);
+	return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC);
 }
 
 /* Returns the entry corresponding to next available interval. If
@@ -551,7 +551,7 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch)
 static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry)
 {
 	atomic_set(&entry->budget,
-		   div64_u64((u64)entry->interval * 1000,
+		   div64_u64((u64)entry->interval * PSEC_PER_NSEC,
 			     atomic64_read(&q->picos_per_byte)));
 }
 
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help