From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DC6F33B6F6 for ; Wed, 4 Feb 2026 18:44:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770230677; cv=none; b=YtoaJnwnbBzGXv/sZX6SQhKT6ARra0qHe/ZWwpm1kVIweLNOiC4fNE9JvnFGV0RLev0vsn5tBUF1l5yp9EHjBlJ41sxX9q6vjdfUgzDhuSjxLghsbsqmEJGLFLJ8Urkaw9Yax4J2RTO7XenBHp7JHUJNEkNbql8LZ7NMwGjM7CE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770230677; c=relaxed/simple; bh=VqLIZNl8jmLGnUXe1BvwJtGoUSDpXd9EP4yjwpGKzII=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G03VqndXWymCRWL2HGlHeNkNoSxkHVc+fGKCkPz1+snSii/UZy2OFDrT8qf6YU7cdZ2MrgpLA3E2zsEN8A94e1V0DkfFGRhcvEW+8wCeqa8YkVaAgc4N0m60d0MU4SkBBabvCiu8gCy7RJZo8V8WmbcN6M5VtQY+UnsRcxgk1Ew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hlNSe6Ar; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=PAm8KrPI; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hlNSe6Ar"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="PAm8KrPI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770230676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Gcs4Ihi3YzOYzBM/idLTJIxE2q0BSxfyQSiUhfJOsk=; b=hlNSe6ArhF3ZosgYlgbBcsmiBieRQkgGJeGCau+uSj6LMNXqP2R2fb7KH8C/q/GvQhs5+4 n6fHNIeiTdCbWAaArF5/SwmMgtYiZt8ub1Mr/kkUT2q+notCZYH5OJXthM8uKf3wZumqgC dITY576w/WyMJwz/GwM7b8qlXZFaQv4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-nKGEBBqYNo2Yfui7NwkuzA-1; Wed, 04 Feb 2026 13:44:35 -0500 X-MC-Unique: nKGEBBqYNo2Yfui7NwkuzA-1 X-Mimecast-MFC-AGG-ID: nKGEBBqYNo2Yfui7NwkuzA_1770230674 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4806865a01bso973245e9.0 for ; Wed, 04 Feb 2026 10:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1770230674; x=1770835474; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=7Gcs4Ihi3YzOYzBM/idLTJIxE2q0BSxfyQSiUhfJOsk=; b=PAm8KrPIs3hhkPA0NKxKMYfNz5UXnra3i8UPL39IR0t5aP6TPVINd2LUnTMoHj9miH Uqagf3raxrdOrK5ICHc7qrl6rQQwJALg5gIsjsjtZ+xUmMaDhaV3qR9yAmB7RkaG+4Q/ 6bJTT1hgg5xrNLd9SCbkUDKzisqrbDMT+WnUxIWaxm4clSVYfdNzKQEqemIQeBN3k1xy 03OICtLq6PyzJmK/8z/u5bMiS+IGto5f2ZC6kpsZh/QZxNecisCMaPOepn6UQZasndaX 4/Kx/CYThIisn/poi2cOoNy+RScNvAtEqW/L+eldSV66x80m1mSSV1tVloPMfcJsJg/B AszQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770230674; x=1770835474; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7Gcs4Ihi3YzOYzBM/idLTJIxE2q0BSxfyQSiUhfJOsk=; b=JfM1EgrFCbLQKmtYVxZV/HHhgGQMXQmYb7wXOKj+w739Xf/T0F/ZgL927ijle9Ugjn IM/DIRE9cOjixDJgBS9PcMokZuNe5YcF5Qloh0xYY8qZeb4RMOztkv29/7TliVtOf95e bzgu6CDQKJLFdrVtF4lUdsraUcCu9t+ZFrvv11oXJRKRyZwWZGVKU3f0ysNJCor3RhdT OHk9pl5Q9WJMNRkXJT2OpplzF+tYUmdxQzOa0tM1UkzOVzTCLh1xx2Do1Ba311UBF+fL +FnrK3Z+N+mQPb01Xs4AKDe0SKtMg8VS5jvM2cuhzwqcSX0zG3wA3y39J+Ue6Ok4EoVn 0Zkg== X-Forwarded-Encrypted: i=1; AJvYcCUldCLxWTStX5TCVO3fdFIMdZVE1v056oUoxzC+VbhmphHRMm1qD79MZjG0hIJR8n4G27gojjH5/u16a0Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzVhHz4mzdN8lGJIka1l6RQxfBUQopenfT+fsLXazI1yepvObtD 1Rx36ZpOPMFEF0GTMkL5wbYpU7k3+/iKw0rfq4DpCnBfaJcXTwx7iEVyMO8LLKkedUHrNqPQFoq HRyoHh/sCHKknkLg498xgkdZXMhO8s5hRzNO4vXa31dXGkcNUYWT/GVXo8XlwCLrTSw== X-Gm-Gg: AZuq6aL5VBCKkO+a3/iXCEircsZQEGa6RUTvbTlxoDuZWBoAZFRjgYtN4Y4M6CkYD+F FkaK2smlaK+w+m6qe9PudPaJUIxZWUq2GrXqTe/QRINIPmLlsVfxnzyfFvkgwvbHFeSvxehKNAI bW9WYsPorVycFGUnFoJ8EtQ7Bd3CetezVGifioOAM+w4dib0SDIZ9+DCLi4krKJSbvfLZ3ONgM4 XtFkvFrJWbhfjw8LOvCMA7iAcDl1aOzs32uVj3ly753UjuRioMJRLPGpAXU2CveeI2gByFXz/LT 3FrCW85ZaBQ/Fc+b3EOPpA2XV8K2HuGowSFVrXVJNVqMcErtjrOhyB+nqYxLWHbY4cIhSIYckxc l6JhqUX0Tj1Hmh/MFdShn0qTR1cLhFrVMGg== X-Received: by 2002:a05:600c:674a:b0:477:73e9:dbe7 with SMTP id 5b1f17b1804b1-4830e986088mr53052215e9.35.1770230673585; Wed, 04 Feb 2026 10:44:33 -0800 (PST) X-Received: by 2002:a05:600c:674a:b0:477:73e9:dbe7 with SMTP id 5b1f17b1804b1-4830e986088mr53051925e9.35.1770230673144; Wed, 04 Feb 2026 10:44:33 -0800 (PST) Received: from redhat.com (IGLD-80-230-34-155.inter.net.il. [80.230.34.155]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48317d33eddsm3164835e9.4.2026.02.04.10.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 10:44:32 -0800 (PST) Date: Wed, 4 Feb 2026 13:44:29 -0500 From: "Michael S. Tsirkin" To: Willem de Bruijn Cc: Jason Wang , Steffen Trumtrar , Xuan Zhuo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Andrew Lunn , Eugenio =?iso-8859-1?Q?P=E9rez?= , virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC v2 2/2] virtio-net: support receive timestamp Message-ID: <20260204134257-mutt-send-email-mst@kernel.org> References: <20260129-v6-7-topic-virtio-net-ptp-v2-0-30a27dc52760@pengutronix.de> <20260129-v6-7-topic-virtio-net-ptp-v2-2-30a27dc52760@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Feb 04, 2026 at 12:55:59PM -0500, Willem de Bruijn wrote: > Jason Wang wrote: > > On Mon, Feb 2, 2026 at 5:06 AM Willem de Bruijn > > wrote: > > > > > > Steffen Trumtrar wrote: > > > > Add optional hardware rx timestamp offload for virtio-net. > > > > > > > > Introduce virtio feature VIRTIO_NET_F_TSTAMP. If negotiated, the > > > > virtio-net header is expanded with room for a timestamp. > > > > > > > > To get and set the hwtstamp the functions ndo_hwtstamp_set/get need > > > > to be implemented. This allows filtering the packets and only time stamp > > > > the packets where the filter matches. This way, the timestamping can > > > > be en/disabled at runtime. > > > > > > > > Tested: > > > > guest: ./timestamping eth0 \ > > > > SOF_TIMESTAMPING_RAW_HARDWARE \ > > > > SOF_TIMESTAMPING_RX_HARDWARE > > > > host: nc -4 -u 192.168.1.1 319 > > > > > > > > Signed-off-by: Steffen Trumtrar > > > > > > > > -- > > > > Changes to last version: > > > > - rework series to use flow filters > > > > - add new struct virtio_net_hdr_v1_hash_tunnel_ts > > > > - original work done by: Willem de Bruijn > > > > --- > > > > drivers/net/virtio_net.c | 136 ++++++++++++++++++++++++++++++++++++---- > > > > include/uapi/linux/virtio_net.h | 9 +++ > > > > 2 files changed, 133 insertions(+), 12 deletions(-) > > > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > > > > index 1bb3aeca66c6e..4e8d9b20c1b34 100644 > > > > --- a/drivers/net/virtio_net.c > > > > +++ b/drivers/net/virtio_net.c > > > > @@ -429,6 +429,9 @@ struct virtnet_info { > > > > struct virtio_net_rss_config_trailer rss_trailer; > > > > u8 rss_hash_key_data[VIRTIO_NET_RSS_MAX_KEY_SIZE]; > > > > > > > > + /* Device passes time stamps from the driver */ > > > > + bool has_tstamp; > > > > + > > > > /* Has control virtqueue */ > > > > bool has_cvq; > > > > > > > > @@ -475,6 +478,8 @@ struct virtnet_info { > > > > > > > > struct control_buf *ctrl; > > > > > > > > + struct kernel_hwtstamp_config tstamp_config; > > > > + > > > > /* Ethtool settings */ > > > > u8 duplex; > > > > u32 speed; > > > > @@ -511,6 +516,7 @@ struct virtio_net_common_hdr { > > > > struct virtio_net_hdr_mrg_rxbuf mrg_hdr; > > > > struct virtio_net_hdr_v1_hash hash_v1_hdr; > > > > struct virtio_net_hdr_v1_hash_tunnel tnl_hdr; > > > > + struct virtio_net_hdr_v1_hash_tunnel_ts ts_hdr; > > > > > > Jason, Michael: creating a new struct for every field is not very > > > elegant. Is it time to find a more forward looking approach to > > > expanding with new fields? Like a TLV, or how netlink structs like > > > tcp_info are extended with support for legacy users that only use > > > a truncated struct? > > > > I fully agree, we need somebody to work on this. > > Great. I'll take a look when I have some time. > > The current approach infers struct virtio_net_hdr_$VARIANT size from > negotiated features: > > - virtio_net: virtio_has_feature > - vhost_net: virtio_features_test_bit > - tun: tun_vnet_parse_size > > Tuntap however also explicitly negotiates length with TUNSETVNETHDRSZ. > > If we create a struct virtio_net_hdr_ext that can be continuously > extended going forward, the host and guest will have to negotiate the > length they both understand, and agree to the min of the two. > > We could use that to implicitly negotiate supported features. E.g., > if len is sizeof(virtio_net_hdr_v1_hash_tunnel) then these features > are supported: > > VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO > VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO > VIRTIO_NET_F_HASH_REPORT > etc. > > But that would mean that all features up to the length have to be > supported, no gaps. I think that is probably not preferable? So then > they still need to negotiate features, as well as length. Does virtio > have a mechanism to negotiate not boolean feature enable/disable but > integers such as struct length? > > Else the change will probably be simpler: keep existing negotiation, > only change the code to once define a struct and keep adding fields. > Rather than defining new structs with each feature and updating many > function arguments and variables to switch to the new struct type. Right I am not sure why we keep doing this. Let's add a VLA at the end of the struct and declare fields can be added at will. > Again, for that see as example struct tcp_info, which is UAPI, but has > been extended many times. -- MST