From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.217.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793545049; b=vaPqdapJ0z/ytNC1nLnC+LrcODSoMepWgZXqiVP9MEmjC8SVCr9o+tSvgaiYKet26zGe neno+pmESS2qzVeq5hqxuq1z3PuuOOvqPd/HwM+IGlYkgKHuMFudM8bgpxGcKMJRMhBNT KhTZWv2RumC7ZN4YDq0X4Q1OljjaEKgCh0E07VAAJbub5FVRrrsLEO3WV+fgJqkpfY2nk 6xxZbAErtT9OWG5kONYVTTBvgMtT1cRpyIEPV0vB2X/Pb6aRA5hK5hawlv0Tb007DOFK6 1Fb/IP3IMRAvLcf4NfsZR0IOQcjAkKNNaD20UDwsotsXGON2ZJ0VEMXOl/+7wBA6KRg== 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=gI/aZlMcVJwx5SLVrqNSIYAJQ7KvsGaG3kb/fUy/9H/O1MrYyQXgGo+cPuxWTiFyyTj0 TdtngLF+Cc1jPRyM3uxoxrCBr6aa7b7p1oNCYbU0Cf8hSlanVUjl6OwqIfI1lAFOi+lUr 6emk/T3dV8DfRWNA1vnkb1jHaHy1q9GmdWwQZC73fJltSw8kIm+H7ACwhYw2UNDagBvem k8hC/BpxtTptZ4puWjGFh5RfbgPZEYQEmOyeDo+SMC/rk8kyyLOXwAxRvJZB4RJkZdpkm zijYAOrDRu4FSzvhNkmA6XX8pdBkACwO6b7KXAJWpDTjTASi/ZgnTEFz1lIs4Jt6lVQ== 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.47 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) (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 15236606A329 for ; Sun, 1 Nov 2026 14:57:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 15236606A329 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-f47.google.com with SMTP id ada2fe7eead31-7cc2bb73cd9so567165137.3 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=X2ABW+wxAFqpMmngFZ+nw8LoQOOu0sLdp/oGBVThw+VuGYmgOIrtL7s+hiBOsU64NI a35fKCpsWLebYke3oq6SYmy8KZIW4v9gzOOc/JLL2IUHJgk8PhdqXHVeIPamLirO0UlZ +Xlld4Rc4rV0qDF/vHTt9+iOBxZjNsvS2AwUCssC1hAnAHziTTxTRZ2M1JeImyARRlQJ 26vvhiTi2bhPgzgzEZNaFMTakoBpsZPVG+4867+JBN+bZC3Yj/Xs7iD7ObzjC4+nHj4h JBz8r0DAwWLl7S1IDifdDgrgg4POltkmmb7l0POKxTwMKMTP88nq1YCeZUBPKxoQNKKy FgvQ== X-Forwarded-Encrypted: i=1; AKwUvBwypwGLG/CH9peOzBAkYR6hDmPX8eMBElQajVFkXS2XHSeunIG2N6HYb0Oilf59WJlnLrI8zvw=@vger.kernel.org X-Gm-Message-State: AFq9FYKmBF/6UYi1n4FamL5eg3rlmbBt01C54b2Q0fc1U9+q870v1W2Y gKjOSf8vvUQeoj35UQuFFt0V4tlA0HwkU39DNv4PQQByYNlAwi8u1+aR X-Gm-Gg: AYBFou0zhneJWdcKQpucVnbDfoYnwIeyTT2KzBj5fGMPMklUxT/TwmR/xWlsh+ARDW5 /eujrUUBrP2i+wEo56KYZTFzS/GHfbjplpsbgIhZEA5YfLPDVPZa/uvRLZ+SfB0GPVrlvEy77ga jF93YKPQaAKAr/foPRuXr9p8eltnJH4Y0uEuDFH6tPKhxbMwBHhETXvikqYh8/1SjxMhaEPS5F+ 7bLrQBonC/J1Kegm8sTJod45yiExMY8Wrdi/5FwZZEmFM+TJxm87XdoPA7RuxG7cFUkWl56GmrY UwPdnNWT7ZQh0OdOJgxM1CraDvY7whcu92r7lqX/hVIbyla0LrfdPx9vkftvkRicuiLTyaiDS4Z Ct2SieKSN4jZkO7ZCPluYo/KHU3tDpFAuFkp8xWGSSIQuqVMobPOop6SgU5YuKvAfXdi/G9XKs1 S3HO72iOohl/1IdrnxWFXhbntPVAKHu6fCMhOwf0Kko1+Vyb5s2JLBv2kt8CN1koytXpD6bEkrt AVV8NaUU7X4wkJzIQr2gg+73ILMKvKU6LCMLv/zfhIPBhasiKJkRvvNF8aLMcJRW86hQ7K3q8I7 bjve/SBIJpdySvxUjEjBoJWJe7tGvm3zDtgBHEOCJ4/ZoHe5d6Y7rLzb1dskqFEkwI/7h0ytotu pm6oOLpXZhl1TVJbH6trCCjvvn5PcBvZR1+I3a6PmOYp2s5tYxhldDjQK5g70/qdnVNIf 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: netdev@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 > =