lkml.org 
[lkml]   [2022]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH net-next 1/4] time64.h: define PSEC_PER_NSEC and use it in tc-taprio
    Date
    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 <tglx@linutronix.de>
    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
    \
     
     \ /
      Last update: 2022-06-26 14:06    [W:4.868 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site