From: Vincenzo Frascino <vincenzo.frascino@arm.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Michael Walle <michael@walle.cc>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Maxim Kochetkov <fido_max@inbox.ru>,
Colin Foster <colin.foster@in-advantage.com>,
Richie Pearn <richard.pearn@nxp.com>,
linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 net-next 4/4] time64.h: consolidate uses of PSEC_PER_NSEC
Date: Tue, 28 Jun 2022 16:31:02 +0100 [thread overview]
Message-ID: <57e275bd-11c1-233a-e716-317f20139efe@arm.com> (raw)
In-Reply-To: <20220628145238.3247853-5-vladimir.oltean@nxp.com>
On 6/28/22 15:52, Vladimir Oltean wrote:
> 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 and the ocelot/felix DSA driver
> to a PSEC_PER_NSEC macro. This macro is placed in include/linux/time64.h
> as opposed to its relatives (PSEC_PER_SEC etc) from include/vdso/time64.h
> because the vDSO library does not (yet) need/use it.
>
> 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>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for the vDSO parts
> ---
> v1->v2:
> - move PSEC_PER_NSEC to include/linux/time64.h
> - add missing include of linux/time.h
>
> drivers/net/dsa/ocelot/felix_vsc9959.c | 5 +++--
> include/linux/time64.h | 3 +++
> net/sched/sch_taprio.c | 5 +++--
> 3 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 27d8b56cc21c..28bd4892c30a 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -16,6 +16,7 @@
> #include <linux/iopoll.h>
> #include <linux/mdio.h>
> #include <linux/pci.h>
> +#include <linux/time.h>
> #include "felix.h"
>
> #define VSC9959_NUM_PORTS 6
> @@ -1235,7 +1236,7 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
> u32 max_sdu;
>
> if (min_gate_len[tc] == U64_MAX /* Gate always open */ ||
> - min_gate_len[tc] * 1000 > needed_bit_time_ps) {
> + min_gate_len[tc] * PSEC_PER_NSEC > needed_bit_time_ps) {
> /* Setting QMAXSDU_CFG to 0 disables oversized frame
> * dropping.
> */
> @@ -1249,7 +1250,7 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
> * frame, make sure to enable oversize frame dropping
> * for frames larger than the smallest that would fit.
> */
> - max_sdu = div_u64(min_gate_len[tc] * 1000,
> + max_sdu = div_u64(min_gate_len[tc] * PSEC_PER_NSEC,
> picos_per_byte);
> /* A TC gate may be completely closed, which is a
> * special case where all packets are oversized.
> diff --git a/include/linux/time64.h b/include/linux/time64.h
> index 81b9686a2079..2fb8232cff1d 100644
> --- a/include/linux/time64.h
> +++ b/include/linux/time64.h
> @@ -20,6 +20,9 @@ struct itimerspec64 {
> struct timespec64 it_value;
> };
>
> +/* Parameters used to convert the timespec values: */
> +#define PSEC_PER_NSEC 1000L
> +
> /* Located here for timespec[64]_valid_strict */
> #define TIME64_MAX ((s64)~((u64)1 << 63))
> #define TIME64_MIN (-TIME64_MAX - 1)
> diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
> index b9c71a304d39..0b941dd63d26 100644
> --- a/net/sched/sch_taprio.c
> +++ b/net/sched/sch_taprio.c
> @@ -18,6 +18,7 @@
> #include <linux/module.h>
> #include <linux/spinlock.h>
> #include <linux/rcupdate.h>
> +#include <linux/time.h>
> #include <net/netlink.h>
> #include <net/pkt_sched.h>
> #include <net/pkt_cls.h>
> @@ -176,7 +177,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 +552,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)));
> }
>
--
Regards,
Vincenzo
next prev parent reply other threads:[~2022-06-28 15:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 14:52 [PATCH v2 net-next 0/4] Prevent permanently closed tc-taprio gates from blocking a Felix DSA switch port Vladimir Oltean
2022-06-28 14:52 ` [PATCH v2 net-next 1/4] net: dsa: felix: keep reference on entire tc-taprio config Vladimir Oltean
2022-06-28 14:52 ` [PATCH v2 net-next 2/4] net: dsa: felix: keep QSYS_TAG_CONFIG_INIT_GATE_STATE(0xFF) out of rmw Vladimir Oltean
2022-06-28 14:52 ` [PATCH v2 net-next 3/4] net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port Vladimir Oltean
2022-06-28 14:52 ` [PATCH v2 net-next 4/4] time64.h: consolidate uses of PSEC_PER_NSEC Vladimir Oltean
2022-06-28 15:31 ` Vincenzo Frascino [this message]
2022-07-01 6:00 ` [PATCH v2 net-next 0/4] Prevent permanently closed tc-taprio gates from blocking a Felix DSA switch port patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57e275bd-11c1-233a-e716-317f20139efe@arm.com \
--to=vincenzo.frascino@arm.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=colin.foster@in-advantage.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=fido_max@inbox.ru \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=michael@walle.cc \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richard.pearn@nxp.com \
--cc=tglx@linutronix.de \
--cc=vinicius.gomes@intel.com \
--cc=vivien.didelot@gmail.com \
--cc=vladimir.oltean@nxp.com \
--cc=xiaoliang.yang_1@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox