All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-net: Read MAC only after initializing MSI-X
@ 2011-08-13  8:51 Sasha Levin
  2011-08-14  2:53 ` Rusty Russell
                   ` (3 more replies)
  0 siblings, 4 replies; 31+ messages in thread
From: Sasha Levin @ 2011-08-13  8:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sasha Levin, Rusty Russell, Michael S. Tsirkin, virtualization,
	netdev, kvm

The MAC of a virtio-net device is located at the first field of the device
specific header. This header is located at offset 20 if the device doesn't
support MSI-X or offset 24 if it does.

Current code in virtnet_probe() used to probe the MAC before checking for
MSI-X, which means that the read was always made from offset 20 regardless
of whether MSI-X in enabled or not.

This patch moves the MAC probe to after the detection of whether MSI-X is
enabled. This way the MAC will be read from offset 24 if the device indeed
supports MSI-X.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Cc: kvm@vger.kernel.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 drivers/net/virtio_net.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0c7321c..55ccf96 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -981,14 +981,6 @@ static int virtnet_probe(struct virtio_device *vdev)
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 
-	/* Configuration may specify what MAC to use.  Otherwise random. */
-	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
-		vdev->config->get(vdev,
-				  offsetof(struct virtio_net_config, mac),
-				  dev->dev_addr, dev->addr_len);
-	} else
-		random_ether_addr(dev->dev_addr);
-
 	/* Set up our device-specific information */
 	vi = netdev_priv(dev);
 	netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight);
@@ -1032,6 +1024,14 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= NETIF_F_HW_VLAN_FILTER;
 	}
 
+	/* Configuration may specify what MAC to use.  Otherwise random. */
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
+		vdev->config->get(vdev,
+				  offsetof(struct virtio_net_config, mac),
+				  dev->dev_addr, dev->addr_len);
+	} else
+		random_ether_addr(dev->dev_addr);
+
 	err = register_netdev(dev);
 	if (err) {
 		pr_debug("virtio_net: registering device failed\n");
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 31+ messages in thread
* [PATCH] virtio-net: Read MAC only after initializing MSI-X
@ 2011-08-13  8:51 Sasha Levin
  0 siblings, 0 replies; 31+ messages in thread
From: Sasha Levin @ 2011-08-13  8:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: kvm, Michael S. Tsirkin, netdev, virtualization, Sasha Levin

The MAC of a virtio-net device is located at the first field of the device
specific header. This header is located at offset 20 if the device doesn't
support MSI-X or offset 24 if it does.

Current code in virtnet_probe() used to probe the MAC before checking for
MSI-X, which means that the read was always made from offset 20 regardless
of whether MSI-X in enabled or not.

This patch moves the MAC probe to after the detection of whether MSI-X is
enabled. This way the MAC will be read from offset 24 if the device indeed
supports MSI-X.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Cc: kvm@vger.kernel.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 drivers/net/virtio_net.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0c7321c..55ccf96 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -981,14 +981,6 @@ static int virtnet_probe(struct virtio_device *vdev)
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 
-	/* Configuration may specify what MAC to use.  Otherwise random. */
-	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
-		vdev->config->get(vdev,
-				  offsetof(struct virtio_net_config, mac),
-				  dev->dev_addr, dev->addr_len);
-	} else
-		random_ether_addr(dev->dev_addr);
-
 	/* Set up our device-specific information */
 	vi = netdev_priv(dev);
 	netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight);
@@ -1032,6 +1024,14 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= NETIF_F_HW_VLAN_FILTER;
 	}
 
+	/* Configuration may specify what MAC to use.  Otherwise random. */
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
+		vdev->config->get(vdev,
+				  offsetof(struct virtio_net_config, mac),
+				  dev->dev_addr, dev->addr_len);
+	} else
+		random_ether_addr(dev->dev_addr);
+
 	err = register_netdev(dev);
 	if (err) {
 		pr_debug("virtio_net: registering device failed\n");
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2011-10-04  1:18 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-13  8:51 [PATCH] virtio-net: Read MAC only after initializing MSI-X Sasha Levin
2011-08-14  2:53 ` Rusty Russell
2011-08-14  2:53 ` Rusty Russell
2011-08-14 13:57   ` Sasha Levin
2011-08-15  0:25     ` Rusty Russell
2011-08-15  0:25     ` Rusty Russell
2011-08-15 22:17       ` Sasha Levin
2011-08-15 22:17       ` Sasha Levin
2011-08-14 13:57   ` Sasha Levin
2011-08-19 15:23 ` Michael S. Tsirkin
2011-08-19 15:23 ` Michael S. Tsirkin
2011-08-19 16:33   ` Sasha Levin
2011-08-19 16:33   ` Sasha Levin
2011-08-20 20:00     ` Michael S. Tsirkin
2011-09-19  3:35       ` Rusty Russell
2011-09-19  6:01         ` Michael S. Tsirkin
2011-09-19  7:49           ` Rusty Russell
2011-09-28 18:30             ` Sasha Levin
2011-10-02  9:11               ` Michael S. Tsirkin
2011-10-02  9:09             ` Michael S. Tsirkin
2011-10-03 23:51               ` Rusty Russell
2011-08-20 20:00     ` Michael S. Tsirkin
2011-08-22  0:24   ` Rusty Russell
2011-08-22  8:36     ` Michael S. Tsirkin
2011-08-22  8:36     ` Michael S. Tsirkin
2011-08-23  3:49       ` Rusty Russell
2011-08-23  3:49       ` Rusty Russell
2011-08-31 16:24       ` Sasha Levin
2011-08-31 16:24       ` Sasha Levin
2011-08-22  0:24   ` Rusty Russell
2011-08-13  8:51 Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.