Patch "virtio-net: ethtool configurable LRO" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    virtio-net: ethtool configurable LRO

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     virtio-net-ethtool-configurable-lro.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2ca7d15d6339c81cb8fca2e218f99ef724fd85fe
Author: Willem de Bruijn <willemb@xxxxxxxxxx>
Date:   Thu Dec 20 17:14:54 2018 -0500

    virtio-net: ethtool configurable LRO
    
    [ Upstream commit a02e8964eaf9271a8a5fcc0c55bd13f933bafc56 ]
    
    Virtio-net devices negotiate LRO support with the host.
    Display the initially negotiated state with ethtool -k.
    
    Also allow configuring it with ethtool -K, reusing the existing
    virtnet_set_guest_offloads helper that configures LRO for XDP.
    This is conditional on VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
    
    Virtio-net negotiates TSO4 and TSO6 separately, but ethtool does not
    distinguish between the two. Display LRO as on only if any offload
    is active.
    
    RTNL is held while calling virtnet_set_features, same as on the path
    from virtnet_xdp_set.
    
    Changes v1 -> v2
      - allow ethtool config (-K) only if VIRTIO_NET_F_CTRL_GUEST_OFFLOADS
      - show LRO as enabled if any LRO variant is enabled
      - do not allow configuration while XDP is active
      - differentiate current features from the capable set, to restore
        on XDP down only those features that were active on XDP up
      - move test out of VIRTIO_NET_F_CSUM/TSO branch, which is tx only
    
    Signed-off-by: Willem de Bruijn <willemb@xxxxxxxxxx>
    Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Stable-dep-of: 604141c036e1 ("virtio_net: checksum offloading handling fix")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 2b012d7165cd0..cbe7be1b8452e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -238,6 +238,7 @@ struct virtnet_info {
 	u32 speed;
 
 	unsigned long guest_offloads;
+	unsigned long guest_offloads_capable;
 
 	/* failover when STANDBY feature enabled */
 	struct failover *failover;
@@ -2548,6 +2549,31 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
 	return 0;
 }
 
+static int virtnet_set_features(struct net_device *dev,
+				netdev_features_t features)
+{
+	struct virtnet_info *vi = netdev_priv(dev);
+	u64 offloads;
+	int err;
+
+	if ((dev->features ^ features) & NETIF_F_LRO) {
+		if (vi->xdp_queue_pairs)
+			return -EBUSY;
+
+		if (features & NETIF_F_LRO)
+			offloads = vi->guest_offloads_capable;
+		else
+			offloads = 0;
+
+		err = virtnet_set_guest_offloads(vi, offloads);
+		if (err)
+			return err;
+		vi->guest_offloads = offloads;
+	}
+
+	return 0;
+}
+
 static const struct net_device_ops virtnet_netdev = {
 	.ndo_open            = virtnet_open,
 	.ndo_stop   	     = virtnet_close,
@@ -2562,6 +2588,7 @@ static const struct net_device_ops virtnet_netdev = {
 	.ndo_xdp_xmit		= virtnet_xdp_xmit,
 	.ndo_features_check	= passthru_features_check,
 	.ndo_get_phys_port_name	= virtnet_get_phys_port_name,
+	.ndo_set_features	= virtnet_set_features,
 };
 
 static void virtnet_config_changed_work(struct work_struct *work)
@@ -3022,6 +3049,11 @@ static int virtnet_probe(struct virtio_device *vdev)
 	}
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
 		dev->features |= NETIF_F_RXCSUM;
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
+		dev->features |= NETIF_F_LRO;
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
+		dev->hw_features |= NETIF_F_LRO;
 
 	dev->vlan_features = dev->features;
 
@@ -3157,6 +3189,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 	for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
 		if (virtio_has_feature(vi->vdev, guest_offloads[i]))
 			set_bit(guest_offloads[i], &vi->guest_offloads);
+	vi->guest_offloads_capable = vi->guest_offloads;
 
 	pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
 		 dev->name, max_queue_pairs);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux