[PATCH 0/3] Add sending TX hardware timestamp for TC ETF Qdisc

From: Erez Geva
Date: Wed Dec 09 2020 - 10:58:04 EST


Add support for TX sending hardware timestamp with
Traffic control Earliest TxTime First (ETF) Qdisc.

Why do we need additional timestamp?
Current ETF requires to synchronization the system clock
to the PTP Hardware clock (PHC) we want to send through.
But there are cases that we can not synchronize the system clock with
the desired NIC PHC.
1. We use several NICs with several PTP domains that our device
is not allowed to be PTP master of.
2. We are using another clock source which we need for our system.
Yet our device is not allowed to be PTP master.

Regardless of the exact topology, as the Linux tradition is to allow
the user the freedom to choose,
we propose a patch that will add a hardware timestamp to the packet.
The TC-ETF will use the first timestamp and compare it with
the system clock while send the packet to the network interface driver
with that hardware timestamp that is correlated with the PHC.

Note 1: we do encourage the users to synchronize the system clock with
a PTP clock. Synchronizing the system clock with a PTP clock will
reduce the frequency difference of the PHC and the system clock,
increase the accurecy and may enable the user to reduce the ETF delta.

Note 2: In our network usage models sending a frame has to be very
precise in relation to the PHC. Our user application does have
the exact send time as of PHC perspective so it is able
to provide the hw timestamp.

Note 3: The user can estimate the clocks conversion error done
in the user application and add it to the delta setting of the ETF.

The patches contain:
1. A new flag for the SO_TXTIME socket option.
2. A new cmsg header, SCM_HW_TXTIME to pass the TX hardware timestamp.
3. Add the hardware timestamp to the socket cookie and to the inet cork.
4. As ETF Qdisc is irrelevant to TCP, ignore the TCP.
5. A new flag to the ETF Qdisc setting that mandate
the use of the hardware timestamp in the SKB.
6. The ETF sort packets according to hardware timestamp,
Yet pass the packet to network interface driver based
on the system clock timestamp.

Note 4: The socket buffer hardware timestamp is used by
the network interface driver to send the actual sending timestamp
back to the application. The timestamp is used by the TC ETF
before the socket buffer arrives in the network interface driver.

Erez Geva (3):
Add TX sending hardware timestamp.
Pass TX sending hardware timestamp to a socket's buffer.
The TC ETF Qdisc pass the hardware timestamp to the interface driver.

include/net/inet_sock.h | 1 +
include/net/sock.h | 2 ++
include/uapi/asm-generic/socket.h | 3 ++
include/uapi/linux/net_tstamp.h | 3 +-
include/uapi/linux/pkt_sched.h | 1 +
net/core/sock.c | 9 +++++
net/ipv4/ip_output.c | 2 ++
net/ipv4/raw.c | 1 +
net/ipv6/ip6_output.c | 2 ++
net/ipv6/raw.c | 1 +
net/packet/af_packet.c | 3 ++
net/sched/sch_etf.c | 59 +++++++++++++++++++++++++------
12 files changed, 75 insertions(+), 12 deletions(-)


base-commit: b65054597872ce3aefbc6a666385eabdf9e288da
--
2.20.1