]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
virtio-net: Add initial MTU advice feature
authorAaron Conole <aconole@redhat.com>
Fri, 3 Jun 2016 20:57:12 +0000 (16:57 -0400)
committerSi-Wei Liu <si-wei.liu@oracle.com>
Fri, 15 Sep 2017 18:24:22 +0000 (14:24 -0400)
This commit adds the feature bit and associated mtu device entry for the
virtio network device.  When a virtio device comes up, it checks the
feature bit for the VIRTIO_NET_F_MTU feature.  If such feature bit is
enabled, the driver will read the advised MTU and use it as the initial
value.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 14de9d114a82a564b94388c95af79a701dc93134)

Orabug: 26584452

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
drivers/net/virtio_net.c
include/uapi/linux/virtio_net.h

index 63e5510c7888ed7578b0bb74aa8fec3d12d9a8a2..4634cba53b70325da0190f4ef779b4ace12690df 100644 (file)
@@ -1719,6 +1719,7 @@ static int virtnet_probe(struct virtio_device *vdev)
        struct net_device *dev;
        struct virtnet_info *vi;
        u16 max_queue_pairs;
+       int mtu;
 
        if (!vdev->config->get) {
                dev_err(&vdev->dev, "%s failure: config access disabled\n",
@@ -1835,6 +1836,14 @@ static int virtnet_probe(struct virtio_device *vdev)
        if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
                vi->has_cvq = true;
 
+       if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
+               mtu = virtio_cread16(vdev,
+                                    offsetof(struct virtio_net_config,
+                                             mtu));
+               if (virtnet_change_mtu(dev, mtu))
+                       __virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
+       }
+
        if (vi->any_header_sg)
                dev->needed_headroom = vi->hdr_len;
 
@@ -2025,6 +2034,7 @@ static unsigned int features[] = {
        VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
        VIRTIO_NET_F_CTRL_MAC_ADDR,
        VIRTIO_F_ANY_LAYOUT,
+       VIRTIO_NET_F_MTU,
 };
 
 static struct virtio_driver virtio_net_driver = {
index 7bbee79ca2933f518a16f0250e7bbfd0a4e85fe0..fb5d30aa114f13168b346e61e5a0ade91798fbc0 100644 (file)
@@ -54,6 +54,7 @@
 #define VIRTIO_NET_F_MQ        22      /* Device supports Receive Flow
                                         * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23  /* Set MAC address */
+#define VIRTIO_NET_F_MTU 25    /* Initial MTU advice */
 
 #ifndef VIRTIO_NET_NO_LEGACY
 #define VIRTIO_NET_F_GSO       6       /* Host handles pkts w/ any GSO type */
@@ -72,6 +73,8 @@ struct virtio_net_config {
         * Legal values are between 1 and 0x8000
         */
        __u16 max_virtqueue_pairs;
+       /* Default maximum transmit unit advice */
+       __u16 mtu;
 } __attribute__((packed));
 
 /*