mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-07 00:59:06 +00:00
virtio_net: checksum offloading handling fix
[ Upstream commit604141c036
] In virtio spec 0.95, VIRTIO_NET_F_GUEST_CSUM was designed to handle partially checksummed packets, and the validation of fully checksummed packets by the device is independent of VIRTIO_NET_F_GUEST_CSUM negotiation. However, the specification erroneously stated: "If VIRTIO_NET_F_GUEST_CSUM is not negotiated, the device MUST set flags to zero and SHOULD supply a fully checksummed packet to the driver." This statement is inaccurate because even without VIRTIO_NET_F_GUEST_CSUM negotiation, the device can still set the VIRTIO_NET_HDR_F_DATA_VALID flag. Essentially, the device can facilitate the validation of these packets' checksums - a process known as RX checksum offloading - removing the need for the driver to do so. This scenario is currently not implemented in the driver and requires correction. The necessary specification correction[1] has been made and approved in the virtio TC vote. [1] https://lists.oasis-open.org/archives/virtio-comment/202401/msg00011.html Fixes:4f49129be6
("virtio-net: Set RXCSUM feature if GUEST_CSUM is available") Signed-off-by: Heng Qi <hengqi@linux.alibaba.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a71b686418
commit
ef609fd734
1 changed files with 10 additions and 2 deletions
|
@ -4453,8 +4453,16 @@ static int virtnet_probe(struct virtio_device *vdev)
|
||||||
dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
|
dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
|
||||||
/* (!csum && gso) case will be fixed by register_netdev() */
|
/* (!csum && gso) case will be fixed by register_netdev() */
|
||||||
}
|
}
|
||||||
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
|
|
||||||
dev->features |= NETIF_F_RXCSUM;
|
/* 1. With VIRTIO_NET_F_GUEST_CSUM negotiation, the driver doesn't
|
||||||
|
* need to calculate checksums for partially checksummed packets,
|
||||||
|
* as they're considered valid by the upper layer.
|
||||||
|
* 2. Without VIRTIO_NET_F_GUEST_CSUM negotiation, the driver only
|
||||||
|
* receives fully checksummed packets. The device may assist in
|
||||||
|
* validating these packets' checksums, so the driver won't have to.
|
||||||
|
*/
|
||||||
|
dev->features |= NETIF_F_RXCSUM;
|
||||||
|
|
||||||
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
|
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
|
||||||
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
|
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
|
||||||
dev->features |= NETIF_F_GRO_HW;
|
dev->features |= NETIF_F_GRO_HW;
|
||||||
|
|
Loading…
Reference in a new issue