Thread (17 messages) 17 messages, 2 authors, 2025-06-08

Re: [RFC PATCH v2 4/8] virtio_net: add supports for extended offloads

From: Akihiko Odaki <hidden>
Date: 2025-05-31 06:19:01

On 2025/05/30 23:49, Paolo Abeni wrote:
quoted hunk ↗ jump to hunk
The virtio_net driver needs it to implement GSO over UDP tunnel
offload.

The only missing piece is mapping them to/from the extended
features.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
v1 -> v2:
  - drop unused macro
  - restrict the offload remap range as per latest spec update
---
  drivers/net/virtio_net.c | 26 ++++++++++++++++++++++++--
  1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index e53ba600605a..ec638b4aa1c1 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -35,6 +35,24 @@ module_param(csum, bool, 0444);
  module_param(gso, bool, 0444);
  module_param(napi_tx, bool, 0644);
  
+#define VIRTIO_OFFLOAD_MAP_MIN	46
+#define VIRTIO_OFFLOAD_MAP_MAX	47
+#define VIRTIO_FEATURES_MAP_MIN	65
+#define VIRTIO_O2F_DELTA	(VIRTIO_FEATURES_MAP_MIN - VIRTIO_OFFLOAD_MAP_MIN)
+
+static bool virtio_is_mapped_offload(unsigned int obit)
+{
+	return obit >= VIRTIO_OFFLOAD_MAP_MIN &&
+	       obit <= VIRTIO_OFFLOAD_MAP_MAX;
+}
+
+#define VIRTIO_OFFLOAD_TO_FEATURE(obit)	\
+	({								\
+		unsigned int __o = obit;				\
+		virtio_is_mapped_offload(__o) ? __o + VIRTIO_O2F_DELTA :\
+						__o;			\
+	})
I wonder why this is a macro while virtio_is_mapped_offload() is a function.
+
 >   /* FIXME: MTU in config. */>   #define GOOD_PACKET_LEN (ETH_HLEN + 
VLAN_HLEN + ETH_DATA_LEN)
quoted hunk ↗ jump to hunk
  #define GOOD_COPY_LEN	128
@@ -7037,9 +7055,13 @@ static int virtnet_probe(struct virtio_device *vdev)
  		netif_carrier_on(dev);
  	}
  
-	for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
-		if (virtio_has_feature(vi->vdev, guest_offloads[i]))
+	for (i = 0; i < ARRAY_SIZE(guest_offloads); i++) {
+		unsigned int fbit;
+
+		fbit = VIRTIO_OFFLOAD_TO_FEATURE(guest_offloads[i]);
+		if (virtio_has_feature(vi->vdev, fbit))
  			set_bit(guest_offloads[i], &vi->guest_offloads);
+	}
  	vi->guest_offloads_capable = vi->guest_offloads;
  
  	rtnl_unlock();
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help