Patchwork virtio-net: Set RXCSUM feature if GUEST_CSUM is available

login
register
mail settings
Submitter Thomas Huth
Date Aug. 27, 2013, 3:09 p.m.
Message ID <1377616142-29590-1-git-send-email-thuth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/270139/
State Accepted
Delegated to: David Miller
Headers show

Comments

Thomas Huth - Aug. 27, 2013, 3:09 p.m.
If the VIRTIO_NET_F_GUEST_CSUM virtio feature is available, the guest
does not have to calculate the checksums on all received packets. This
is pretty much the same feature as RX checksum offloading on real
network cards, so the virtio-net driver should report this by setting
the NETIF_F_RXCSUM flag. When the user now runs "ethtool -k", he or she
can see whether the virtio-net interface has to calculate RX checksums
or not.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
---
 drivers/net/virtio_net.c | 2 ++
 1 file changed, 2 insertions(+)
David Miller - Aug. 29, 2013, 7:57 p.m.
From: Thomas Huth <thuth@linux.vnet.ibm.com>
Date: Tue, 27 Aug 2013 17:09:02 +0200

> If the VIRTIO_NET_F_GUEST_CSUM virtio feature is available, the guest
> does not have to calculate the checksums on all received packets. This
> is pretty much the same feature as RX checksum offloading on real
> network cards, so the virtio-net driver should report this by setting
> the NETIF_F_RXCSUM flag. When the user now runs "ethtool -k", he or she
> can see whether the virtio-net interface has to calculate RX checksums
> or not.
> 
> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>

Can one of the virtio_net folks please review this?

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rusty Russell - Sept. 2, 2013, 1:47 a.m.
David Miller <davem@davemloft.net> writes:
> From: Thomas Huth <thuth@linux.vnet.ibm.com>
> Date: Tue, 27 Aug 2013 17:09:02 +0200
>
>> If the VIRTIO_NET_F_GUEST_CSUM virtio feature is available, the guest
>> does not have to calculate the checksums on all received packets. This
>> is pretty much the same feature as RX checksum offloading on real
>> network cards, so the virtio-net driver should report this by setting
>> the NETIF_F_RXCSUM flag. When the user now runs "ethtool -k", he or she
>> can see whether the virtio-net interface has to calculate RX checksums
>> or not.
>> 
>> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
>
> Can one of the virtio_net folks please review this?

Hmm, so NETIF_F_RXCSUM only exists for ethtool's benefit.  Weird.

But this patch is correct:

Acked-by: Rusty Russell <rusty@rustcorp.com.au>

Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f216002..defec2b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1538,6 +1538,8 @@  static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
+		dev->features |= NETIF_F_RXCSUM;
 
 	dev->vlan_features = dev->features;