diff mbox series

[net-next,v6,07/16] net_tstamp: Add TIMESTAMPING SOFTWARE and HARDWARE mask

Message ID 20231019-feature_ptp_netnext-v6-7-71affc27b0e5@bootlin.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: Make timestamping selectable | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches (and no cover letter)
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4094 this patch: 4094
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 1602 this patch: 1602
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4357 this patch: 4357
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Kory Maincent Oct. 19, 2023, 2:29 p.m. UTC
Timestamping software or hardware flags are often used as a group,
therefore adding these masks will easier future use.

I did not use SOF_TIMESTAMPING_SYS_HARDWARE flag as it is deprecated and
not use at all.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
 include/uapi/linux/net_tstamp.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Willem de Bruijn Oct. 19, 2023, 2:48 p.m. UTC | #1
On Thu, Oct 19, 2023 at 10:29 AM Kory Maincent
<kory.maincent@bootlin.com> wrote:
>
> Timestamping software or hardware flags are often used as a group,
> therefore adding these masks will easier future use.

This assumes that device support for timestamping is often symmetric:
a device supports both rx and tx, or neither.

All devices support software receive timestamping, as that timestamp
is taken in the core network stack. But to support transmit timestamps
drivers have to call sbk_tstamp_tx in their ndo_start_xmit.

For hardware timestamping it may be more common to support both or
neither, not sure.

> I did not use SOF_TIMESTAMPING_SYS_HARDWARE flag as it is deprecated and
> not use at all.
>
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
>  include/uapi/linux/net_tstamp.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
> index a2c66b3d7f0f..df8091998c8d 100644
> --- a/include/uapi/linux/net_tstamp.h
> +++ b/include/uapi/linux/net_tstamp.h
> @@ -48,6 +48,14 @@ enum {
>                                          SOF_TIMESTAMPING_TX_SCHED | \
>                                          SOF_TIMESTAMPING_TX_ACK)
>
> +#define SOF_TIMESTAMPING_SOFTWARE_MASK (SOF_TIMESTAMPING_RX_SOFTWARE | \
> +                                        SOF_TIMESTAMPING_TX_SOFTWARE | \
> +                                        SOF_TIMESTAMPING_SOFTWARE)
> +
> +#define SOF_TIMESTAMPING_HARDWARE_MASK (SOF_TIMESTAMPING_RX_HARDWARE | \
> +                                        SOF_TIMESTAMPING_TX_HARDWARE | \
> +                                        SOF_TIMESTAMPING_RAW_HARDWARE)
> +
>  /**
>   * struct so_timestamping - SO_TIMESTAMPING parameter
>   *
>
> --
> 2.25.1
>
Kory Maincent Oct. 24, 2023, 1:40 p.m. UTC | #2
On Thu, 19 Oct 2023 10:48:04 -0400
Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:

> On Thu, Oct 19, 2023 at 10:29 AM Kory Maincent
> <kory.maincent@bootlin.com> wrote:
> >
> > Timestamping software or hardware flags are often used as a group,
> > therefore adding these masks will easier future use.  
> 
> This assumes that device support for timestamping is often symmetric:
> a device supports both rx and tx, or neither.
>
> All devices support software receive timestamping, as that timestamp
> is taken in the core network stack. But to support transmit timestamps
> drivers have to call sbk_tstamp_tx in their ndo_start_xmit.

Yes, and in that software only case they often call ethtool_op_get_ts_info to
fill the timestamp info.

There is several drivers that support hardware and software timestamp, these
mask could be useful for these. In case of asymmetric support we can still use
the SOF_TIMESTAMPING_RX/TX_SOFTWARE flags.

I forgot to specify, in the commit message but this patch is mainly to ease
the next patch of this series to deal with software/hardware time stamping.
Maybe you prefer to have this squash into next patch as had suggested Florian
in last version.

Köry
Willem de Bruijn Oct. 24, 2023, 2:21 p.m. UTC | #3
On Tue, Oct 24, 2023 at 9:40 AM Köry Maincent <kory.maincent@bootlin.com> wrote:
>
> On Thu, 19 Oct 2023 10:48:04 -0400
> Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:
>
> > On Thu, Oct 19, 2023 at 10:29 AM Kory Maincent
> > <kory.maincent@bootlin.com> wrote:
> > >
> > > Timestamping software or hardware flags are often used as a group,
> > > therefore adding these masks will easier future use.
> >
> > This assumes that device support for timestamping is often symmetric:
> > a device supports both rx and tx, or neither.
> >
> > All devices support software receive timestamping, as that timestamp
> > is taken in the core network stack. But to support transmit timestamps
> > drivers have to call sbk_tstamp_tx in their ndo_start_xmit.
>
> Yes, and in that software only case they often call ethtool_op_get_ts_info to
> fill the timestamp info.
>
> There is several drivers that support hardware and software timestamp, these
> mask could be useful for these. In case of asymmetric support we can still use
> the SOF_TIMESTAMPING_RX/TX_SOFTWARE flags.
>
> I forgot to specify, in the commit message but this patch is mainly to ease
> the next patch of this series to deal with software/hardware time stamping.
> Maybe you prefer to have this squash into next patch as had suggested Florian
> in last version.

Thanks. I did not see such use in net/ or in my experience of using
setsockopt SO_TIMESTAMPING.

But I had not considered net device get_ts_info. It would be useful there.

Slight preference from me to keep this a separate patch, as it applies
not only to the use case in your follow-on patch.
diff mbox series

Patch

diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
index a2c66b3d7f0f..df8091998c8d 100644
--- a/include/uapi/linux/net_tstamp.h
+++ b/include/uapi/linux/net_tstamp.h
@@ -48,6 +48,14 @@  enum {
 					 SOF_TIMESTAMPING_TX_SCHED | \
 					 SOF_TIMESTAMPING_TX_ACK)
 
+#define SOF_TIMESTAMPING_SOFTWARE_MASK	(SOF_TIMESTAMPING_RX_SOFTWARE | \
+					 SOF_TIMESTAMPING_TX_SOFTWARE | \
+					 SOF_TIMESTAMPING_SOFTWARE)
+
+#define SOF_TIMESTAMPING_HARDWARE_MASK	(SOF_TIMESTAMPING_RX_HARDWARE | \
+					 SOF_TIMESTAMPING_TX_HARDWARE | \
+					 SOF_TIMESTAMPING_RAW_HARDWARE)
+
 /**
  * struct so_timestamping - SO_TIMESTAMPING parameter
  *