From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.217.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793545049; b=k45zahEhzRKavTY7GxSDHeY/CTRQaNf4hIK1zo5AoT+VSKqIjUNobKGhFzURKlZosQR3 21dKxFdrn6FukJwrKniWwnXhv3gl+1PgcYGVhU8sRxhIXVSvYzxGz7VVKWg8lbV+JlH8E Se0f3zg3mVOSC/EJK6d/y2FiL3NvgK77/rzxub16PiuqD1a3G+6Czbn1BTvbb3h+iFx9g mkjkt05clKXOEx32EiQA0KNmz70W2lqUSEeyrpHb5qxjxtaCqZJvXH7AEkffgsjK8S9ls gWa1CU3ieS7IoDEYJJCvjdfyEawZWbjZFcZu51hBvumUTkunbw1vY8acwZ068zfKumw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793545049; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=PGMqY+oZ0RvA46OKAo95DoA/lt7CWx4VsMgHlnaoQfk=; b=zAkHi/3lij3N/wwV1SiAJxqZ0XC07fWstgXb+crWq8jqnS43yapxIQztbgKs8y9gkE9n pCqYODeCCuaKSKfwa7mXIWX25lJvu0gDc6+rlNSflCUt158ngGlZpu1RtVclV0Y/mrsEG Gm4PrGrqUaU/6hE7ucf0F3crS1l7G+XdVNYBXDtCB8Gh2pOu0mTiaymBVN0KiG80OCw8+ 3UKoQ3zksoiQpoDGtJpt769+uUsEbEZEajsuvsrm+UsVrawUkfplamdaVR46APfJyXUFm R5pLiWCB/W14hrgOLV3y4CIT886lSz/W9NkGYeEShj9wIy0kcpOzD8plTwgdmbJgzyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YnrXzXXD; arc=none smtp.remote-ip=209.85.217.52 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FFB2606A327 for ; Sun, 1 Nov 2026 14:57:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0FFB2606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YnrXzXXD Received: by mail-vs1-f52.google.com with SMTP id ada2fe7eead31-7cc013095d4so626163137.2 for ; Sun, 01 Nov 2026 06:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793545048; x=1794149848; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=PGMqY+oZ0RvA46OKAo95DoA/lt7CWx4VsMgHlnaoQfk=; b=YnrXzXXDO7AHeU25pOIfi0Q6lPUH72unj6hi5PzCFWFZGiCB388hJtBD4DzkllGc0J WjYLOaesnpl2Ohx2FSGQZ7elGKhBPrhrMVAFC0sbmKfpxK2SBy0nYgvnF+rduLVKFnx8 HTTNgv3IVA3IBj3uVKN+W6/NnvNeDYQTzm0P/2p+qvHzppQ3RhVoZOFRu/NGE2/RKSLz yl/ECevi5DevNrtT9nJzjLqRv8mVzjwhfJ3+lB73hYrq3W8PuFf3375FHd7pjS/wsQ1S hqa4GbMgsJczYccs1pMnSzN2k8J31zSr2av627d2jfhIEAdGJ2dKq1AnkS0RDkJIVjJI JNXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793545048; x=1794149848; h=content-transfer-encoding:content-type:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PGMqY+oZ0RvA46OKAo95DoA/lt7CWx4VsMgHlnaoQfk=; b=MZIjE/M05+gMOgxkdKhKEyshK+zrK9x4xJQCVqyqf45uCFvbBMW9HHDtucH8Wub7WJ mnZqxs7Xj3WFHveaXUJHUtsCvRdY1VnPvtGFv1YkNc0HkLjkEHDNOCHsqUOpUbWJDGWo GY0AVcYK63zG4+v8LeqAHdIEMTTLGpgOILyutD1OY2rZsn6AgCq4Pubyvs0PfA30HVD5 3PifW363zkx9KLpbH46hnifdipzSSxOtRYsCVkN7BsH5B5VLQEu9PK4sn46YDT19Nind eSOz3HTyN53xaNaEBdDRMRc03rzHBsfE30EtU6DejZE5NKC9AnfFN7t4Z/xwNVTN1Ame +Diw== X-Forwarded-Encrypted: i=1; AKwUvBy7s8K0e+5d7BtBCIzEJj5Djg+nVzFaaOivvZVXCITctI3VJ6n42Vxw/GYzXrKISd6Sxkw=@vger.kernel.org X-Gm-Message-State: AFq9FYIqwWCH1pRv+yBcRk+u5xZ77XXF78ujdGxqybsc5xcvFTH71Tkr 9kE2kwxzGZxNWReKc54LtUcBQNhgKe201lSgfEp2o6uJhW7m1FEULeA7 X-Gm-Gg: AYBFou3zumQPQ1v9qaUNtdeVAAzDQe0Qo4d4m+mvM00/kZt4We3irnWZI1kIu4cs82O wPcPsACIaESYc8sHxlSWqwo66a+Y1kW+H7vktZ+RK+Bj0PrzEjCdcwkK/8KCfvuNluPHsg0tfKu hc0B02OC7j4X0/16Uz4zJH0dR+WoDQWzq9W9f1KjhQ4taJczBgVflNonLqIbXJ0ktBXJoeHkQAj tZcCqxPm6x+u/aFDBeaaL5EFAZyWG6NrsrfACkb+VWq5ITll9E/PwUoLGlmJjLeKRTngnZ2vrL2 xOHw+cNmcHuNGVgxutrczwQPEBW6iwQYSrhJhWF/lxw6i0tyOttsZGFMhwZZAZjtImb8KueO78S /X5IFxdY49vCRG/wG5mUOEXjB0aiavmVmZ5f30aL0McFnB/4TZaJ3F8weP2NJpuWDGfN4f1BR5G Zh2TG/CoYQCtNLZGeXhNeo9mrV/CYdN1bT7XTqnkOnAIVuJFbCGWuCQ+oIWAvPLpmQGfC49Qxtz l79lXOKZhkM+vgvGBJyzH7WwkJuTJf5l7Irm/y8wmbZflwf8nzNKyncP2iQhP3y9qbyGyj0LnUJ cmPqtSoFCrwhPPI9Gqdm5Ub9GayOPiXdvIgv1lJcFh8fDmjcSld8GWcEBQKI96LwY2gjtUw2DTE b4jlhUroFPOz06igp9A1ezA6bJtApj0MXgs74VqPu5WlNCrufeiJOPqEypGfKulY1cUE5 X-Received: by 2002:a05:6102:5709:b0:7c1:f530:2d8e with SMTP id ada2fe7eead31-7d072d33bbemr3289437137.35.1793545047921; Sun, 01 Nov 2026 06:57:27 -0800 (PST) Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-992edfb5511sm9722277241.0.2026.11.01.06.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 06:57:27 -0800 (PST) Date: Sun, 01 Nov 2026 09:57:26 -0500 From: Willem de Bruijn To: Steffen Trumtrar , "Michael S. Tsirkin" , Xuan Zhuo , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Richard Cochran , Willem de Bruijn , Andrew Lunn , =?UTF-8?B?RXVnZW5pbyBQw6lyZXo=?= , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Eric Dumazet Cc: Steffen Trumtrar , virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kvm@vger.kernel.org Message-ID: In-Reply-To: <20261026-v6-7-topic-virtio-net-ptp-v4-0-008af03cd43b@pengutronix.de> References: <20261026-v6-7-topic-virtio-net-ptp-v4-0-008af03cd43b@pengutronix.de> Subject: Re: [PATCH RFC v4 0/6] virtio-net: add receive timestamp support X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Steffen Trumtrar wrote: > This series picks up Willem de Bruijn's work on a virtio-net receive > timestamp. The device puts the time of arrival (TAI, ns) into the > virtio-net header so the guest can use it for PTP and RTT estimation > without taking the timestamp itself after the host-to-guest latency. > = > The series is an RFC. I am mostly interested in feedback on the > approach and on the wire format: At a high level +1 from me. Some comments inline. > = > - The timestamp is a new field at the end of virtio_net_common_hdr > after outer_nh_offset and ipsec, offset 32 (see virtio spec), > negotiated with VIRTIO_NET_F_RX_TSTAMP (bit 49). Header size now 40 > bytes. > Willem noted on v3 that virtio_net_common_hdr was not meant to be > extended this way; I kept it as the simplest approach, but a > separate struct for the timestamp header is an option. > - Timestamping is enabled at runtime with SIOCSHWTSTAMP; all > supported rx filters behave the same for now. > - XDP programs can read the timestamp with > bpf_xdp_metadata_rx_timestamp(). > - vhost-net passes the feature through; the timestamp itself is > written by tun. The tun patch is only meant as a reference > implementation for the device side. > - The timestamp is in TAI. Is this a requirement? It is common for PHCs to be synced to TAI, but not 100% the case. Does virtio need to specify this. > The driver reports it as > SOF_TIMESTAMPING_RAW_HARDWARE without a PTP clock (phc_index -1), > so userspace cannot tell which clock it refers to and may compare > it against CLOCK_REALTIME (currently off by 37s). Options I see: > convert to the guest's system time in the driver (correct only if > host and guest agree on the TAI offset), expose a PHC so the > time base is explicit, or keep the raw TAI value and leave the > conversion to userspace. Which one is preferred? > - Like the existing rx_hash, the XDP timestamp callback locates the > header relative to xdp->data, so it must be called before > bpf_xdp_adjust_head(). > = > A virtio spec change is needed as well and not yet proposed. > = > Testing: the feature needs a QEMU that knows VIRTIO_NET_F_RX_TSTAMP and= > sets the matching vnet header size; see > https://github.com/strumtrar/qemu/tree/v11.0.1/virtio-rx-stamps > = > Performance: I measured the receive rate with 64 byte UDP packets in > a nested QEMU/KVM setup with vhost-net. The variance between runs is > larger than any difference between the variants (without the series, > series without the feature, feature negotiated, feature enabled), so > I cannot show a measurable cost or the absence of one. Numbers from > bare metal will follow with a non-RFC version. This does not seem performance sensitive to me. And it is opt-in. IMHO no need for extensive testing for performance regressions. > Signed-off-by: Steffen Trumtrar > --- > Changes in v4: > - zero the header beyond the known fields on tx and in vhost > - grow padded_vnet_hdr for the 40 byte header (big packets) > - install xdp_metadata_ops if only RX_TSTAMP is negotiated > - rename VIRTIO_NET_F_TSTAMP to VIRTIO_NET_F_RX_TSTAMP > - move tstamp to offset 32 (header size 40) to match virtio spec layout= > - drop XDP restriction for SIOCSHWTSTAMP, add xmo_rx_timestamp > - add static_asserts for header sizes > - add support in vhost > - move virtio_net_common_hdr to virtio_net.h > - Link to v3: https://patch.msgid.link/20260921-v6-7-topic-virtio-net-p= tp-v3-0-3350851c4f88@pengutronix.de > Changes in v3: > - rework to use virtio_net_common_hdr instead of adding new struct > Changes in v2: > - rework patches to use flow filter instead of feature flag > - Link to v1: https://lore.kernel.org/r/20231218-v6-7-topic-virtio-net-= ptp-v1-0-cac92b2d8532@pengutronix.de > = > To: Michael S. Tsirkin > To: Xuan Zhuo > To: David S. Miller > To: Jakub Kicinski > To: Paolo Abeni > To: Richard Cochran > To: Willem de Bruijn > To: Andrew Lunn > To: Eugenio P=C3=A9rez > To: Jason Wang > To: Alexei Starovoitov > To: Daniel Borkmann > To: Jesper Dangaard Brouer > To: John Fastabend > To: Stanislav Fomichev > To: Eric Dumazet > Cc: virtualization@lists.linux.dev > Cc: netdev@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: bpf@vger.kernel.org > Cc: kvm@vger.kernel.org > = > --- > Steffen Trumtrar (6): > virtio-net: move virtio_net_common_hdr to virtio_net.h > virtio-net: support receive timestamp > virtio-net: assert header sizes > vhost-net: support VIRTIO_NET_F_RX_TSTAMP > virtio-net: add XDP rx timestamp metadata > tun: add rx timestamp to the vnet header > = > drivers/net/tun.c | 14 ++-- > drivers/net/tun_vnet.h | 18 +++-- > drivers/net/virtio_net.c | 171 ++++++++++++++++++++++++++++++++= ++------ > drivers/vhost/net.c | 17 +++- > include/linux/virtio_net.h | 30 +++++++ > include/uapi/linux/virtio_net.h | 1 + > 6 files changed, 214 insertions(+), 37 deletions(-) > --- > base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222 > change-id: 20231218-v6-7-topic-virtio-net-ptp-3df023bc4f4d > = > Best regards, > -- = > Steffen Trumtrar > =