Skip to content

Commit dbcf24d

Browse files
jasowangdavem330
authored andcommitted
virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO
Commit a02e896 ("virtio-net: ethtool configurable LRO") maps LRO to virtio guest offloading features and allows the administrator to enable and disable those features via ethtool. This leads to several issues: - For a device that doesn't support control guest offloads, the "LRO" can't be disabled triggering WARN in dev_disable_lro() when turning off LRO or when enabling forwarding bridging etc. - For a device that supports control guest offloads, the guest offloads are disabled in cases of bridging, forwarding etc slowing down the traffic. Fix this by using NETIF_F_GRO_HW instead. Though the spec does not guarantee packets to be re-segmented as the original ones, we can add that to the spec, possibly with a flag for devices to differentiate between GRO and LRO. Further, we never advertised LRO historically before a02e896 ("virtio-net: ethtool configurable LRO") and so bridged/forwarded configs effectively always relied on virtio receive offloads behaving like GRO - thus even if this breaks any configs it is at least not a regression. Fixes: a02e896 ("virtio-net: ethtool configurable LRO") Acked-by: Michael S. Tsirkin <[email protected]> Reported-by: Ivan <[email protected]> Tested-by: Ivan <[email protected]> Signed-off-by: Jason Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 09e856d commit dbcf24d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/net/virtio_net.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const unsigned long guest_offloads[] = {
6363
VIRTIO_NET_F_GUEST_CSUM
6464
};
6565

66-
#define GUEST_OFFLOAD_LRO_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
66+
#define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
6767
(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
6868
(1ULL << VIRTIO_NET_F_GUEST_ECN) | \
6969
(1ULL << VIRTIO_NET_F_GUEST_UFO))
@@ -2515,7 +2515,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
25152515
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
25162516
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
25172517
virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
2518-
NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing LRO/CSUM, disable LRO/CSUM first");
2518+
NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
25192519
return -EOPNOTSUPP;
25202520
}
25212521

@@ -2646,15 +2646,15 @@ static int virtnet_set_features(struct net_device *dev,
26462646
u64 offloads;
26472647
int err;
26482648

2649-
if ((dev->features ^ features) & NETIF_F_LRO) {
2649+
if ((dev->features ^ features) & NETIF_F_GRO_HW) {
26502650
if (vi->xdp_enabled)
26512651
return -EBUSY;
26522652

2653-
if (features & NETIF_F_LRO)
2653+
if (features & NETIF_F_GRO_HW)
26542654
offloads = vi->guest_offloads_capable;
26552655
else
26562656
offloads = vi->guest_offloads_capable &
2657-
~GUEST_OFFLOAD_LRO_MASK;
2657+
~GUEST_OFFLOAD_GRO_HW_MASK;
26582658

26592659
err = virtnet_set_guest_offloads(vi, offloads);
26602660
if (err)
@@ -3134,9 +3134,9 @@ static int virtnet_probe(struct virtio_device *vdev)
31343134
dev->features |= NETIF_F_RXCSUM;
31353135
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
31363136
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
3137-
dev->features |= NETIF_F_LRO;
3137+
dev->features |= NETIF_F_GRO_HW;
31383138
if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
3139-
dev->hw_features |= NETIF_F_LRO;
3139+
dev->hw_features |= NETIF_F_GRO_HW;
31403140

31413141
dev->vlan_features = dev->features;
31423142

0 commit comments

Comments
 (0)