Re: [PATCH] [RFC v2] packet: experimental support for 64-bit timestamps

From: Arnd Bergmann
Date: Tue Nov 28 2017 - 09:45:36 EST


On Tue, Nov 28, 2017 at 3:24 PM, Willem de Bruijn
<willemdebruijn.kernel@xxxxxxxxx> wrote:
> On Tue, Nov 28, 2017 at 8:14 AM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> Unfortunately, we're already stuck with SOL_PACKET/PACKET_TIMESTAMP
> accepting SOF_TIMESTAMPING_RAW_HARDWARE.
>
> Perhaps we can define a new PF_PACKET specific enum where the
> equivalent option has the same value, so is backwards compatible:
>
> enum {
> PACKET_TIMESTAMP_ORIG = 0,
> PACKET_TIMESTAMP_ZERO = 1 << 0,
> PACKET_TIMESTAMP_NS64 = 1 << 1,
> PACKET_TIMESTAMP_HW = 1 << 6
> };
>
> and BUILD_BUG_ON(PACKET_TIMESTAMP_RAW != SOF_TIMESTAMPING_RAW_HARDWARE)
> to document the dependency.

Yes, that would be much cleaner, but in order to do this, we have to
be relatively
confident that existing users don't pass any flags other than
SOF_TIMESTAMPING_RAW_HARDWARE. It might be safer to start
at bit 31 for the new flags to minimize that risk:

/*
* we used to pass SOF_TIMESTAMPING_RAW_HARDWARE from user space,
* but really want our own flags here, so define PACKET_TIMESTAMP_HW to the
* existing value and use the high bits for new non-overlapping flags.
*/
enum {
PACKET_TIMESTAMP_ORIG = 0,
PACKET_TIMESTAMP_HW = 1 << 6,
PACKET_TIMESTAMP_ZERO = 1 << 30,
PACKET_TIMESTAMP_NS64 = 1 << 31,
};

> At high level, the code looks great to me, itself.

Thanks,

Arnd