Skip to contentSkip to conversation

netvsc: minor fixes

PATCH In review Stephen Hemminger 2 participants 8 messages Jul 24, 2017 – Jul 25, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover netvsc: minor fixes

This fixes fallout from previous patch related to RTNL and RCU annotaiton. Also one patch sent to wrong list.

Mohammed Gamal (1):
netvsc: Remove redundant use of ipv6_hdr()

Stephen Hemminger (5):
netvsc: remove bogus rtnl_unlock
netvsc: prefetch the first incoming ring element
netvsc: fix netvsc_set_channels
netvsc: include rtnetlink.h
netvsc: remove no longer used max_num_rss queues

 drivers/net/hyperv/hyperv_net.h   |  1 -
 drivers/net/hyperv/netvsc.c       |  8 +++++-
 drivers/net/hyperv/netvsc_drv.c   | 54 +++++++++++++++------------------------
 drivers/net/hyperv/rndis_filter.c |  1 +
 4 files changed, 28 insertions(+), 36 deletions(-)
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/6 netvsc: Remove redundant use of ipv6_hdr()

From: Mohammed Gamal <[email protected]>

This condition already uses an object of type ipv6hdr in the line above. Use the object directly instead of calling ipv6_hdr

---
 drivers/net/hyperv/netvsc_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hyperv/netvsc_drv.c +1 -1
index 1238600d717e..bc2af352d6dd 100644
@@ -339,7 +339,7 @@ static u32 net_checksum_info(struct sk_buff *skb)
 
 		if (ip6->nexthdr == IPPROTO_TCP)
 			return TRANSPORT_INFO_IPV6_TCP;
-		else if (ipv6_hdr(skb)->nexthdr == IPPROTO_UDP)
+		else if (ip6->nexthdr == IPPROTO_UDP)
 			return TRANSPORT_INFO_IPV6_UDP;
 	}
 
Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/6 netvsc: prefetch the first incoming ring element

In reply to Stephen Hemminger

In interrupt handler, prefetch the first incoming ring element so that it is in cache by the time NAPI poll gets to it.

---
 drivers/net/hyperv/netvsc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/hyperv/netvsc.c +7 -1
index 0a9d9feedc3f..06f39a99da7c 100644
@@ -30,6 +30,7 @@
 #include <linux/if_ether.h>
 #include <linux/vmalloc.h>
 #include <linux/rtnetlink.h>
+#include <linux/prefetch.h>
 
 #include <asm/sync_bitops.h>
 
@@ -1265,10 +1266,15 @@ int netvsc_poll(struct napi_struct *napi, int budget)
 void netvsc_channel_cb(void *context)
 {
 	struct netvsc_channel *nvchan = context;
+	struct vmbus_channel *channel = nvchan->channel;
+	struct hv_ring_buffer_info *rbi = &channel->inbound;
+
+	/* preload first vmpacket descriptor */
+	prefetch(hv_get_ring_buffer(rbi) + rbi->priv_read_index);
 
 	if (napi_schedule_prep(&nvchan->napi)) {
 		/* disable interupts from host */
-		hv_begin_read(&nvchan->channel->inbound);
+		hv_begin_read(rbi);
 
 		__napi_schedule(&nvchan->napi);
 	}
Signature · 1 line
2.11.0
#4 lore raw

PATCH 4/6 netvsc: fix netvsc_set_channels

In reply to Stephen Hemminger

The number of channels returned by rndis_filter_device_add maybe less than the number requested. Therefore set correct real number of queues.

---
 drivers/net/hyperv/netvsc_drv.c | 51 +++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 32 deletions(-)
drivers/net/hyperv/netvsc_drv.c +19 -32
index bc2af352d6dd..99ae7fb6ec11 100644
@@ -713,29 +713,6 @@ static void netvsc_get_channels(struct net_device *net,
 	}
 }
 
-static int netvsc_set_queues(struct net_device *net, struct hv_device *dev,
-			     u32 num_chn)
-{
-	struct netvsc_device_info device_info;
-	struct netvsc_device *net_device;
-	int ret;
-
-	memset(&device_info, 0, sizeof(device_info));
-	device_info.num_chn = num_chn;
-	device_info.ring_size = ring_size;
-	device_info.max_num_vrss_chns = num_chn;
-
-	ret = netif_set_real_num_tx_queues(net, num_chn);
-	if (ret)
-		return ret;
-
-	ret = netif_set_real_num_rx_queues(net, num_chn);
-	if (ret)
-		return ret;
-
-	net_device = rndis_filter_device_add(dev, &device_info);
-	return IS_ERR(net_device) ? PTR_ERR(net_device) : 0;
-}
 
 static int netvsc_set_channels(struct net_device *net,
 			       struct ethtool_channels *channels)
@@ -743,9 +720,10 @@ static int netvsc_set_channels(struct net_device *net,
 	struct net_device_context *net_device_ctx = netdev_priv(net);
 	struct hv_device *dev = net_device_ctx->device_ctx;
 	struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
-	unsigned int count = channels->combined_count;
+	unsigned int orig, count = channels->combined_count;
+	struct netvsc_device_info device_info;
 	bool was_opened;
-	int ret;
+	int ret = 0;
 
 	/* We do not support separate count for rx, tx, or other */
 	if (count == 0 ||
@@ -764,19 +742,29 @@ static int netvsc_set_channels(struct net_device *net,
 	if (count > nvdev->max_chn)
 		return -EINVAL;
 
+	orig = nvdev->num_chn;
 	was_opened = rndis_filter_opened(nvdev);
 	if (was_opened)
 		rndis_filter_close(nvdev);
 
 	rndis_filter_device_remove(dev, nvdev);
 
-	ret = netvsc_set_queues(net, dev, count);
-	if (ret == 0)
-		nvdev->num_chn = count;
-	else
-		netvsc_set_queues(net, dev, nvdev->num_chn);
+	memset(&device_info, 0, sizeof(device_info));
+	device_info.num_chn = count;
+	device_info.ring_size = ring_size;
+	device_info.max_num_vrss_chns = count;
+
+	nvdev = rndis_filter_device_add(dev, &device_info);
+	if (!IS_ERR(nvdev)) {
+		netif_set_real_num_tx_queues(net, nvdev->num_chn);
+		netif_set_real_num_rx_queues(net, nvdev->num_chn);
+		ret = PTR_ERR(nvdev);
+	} else {
+		device_info.num_chn = orig;
+		device_info.max_num_vrss_chns = count;
+		rndis_filter_device_add(dev, &device_info);
+	}
 
-	nvdev = rtnl_dereference(net_device_ctx->nvdev);
 	if (was_opened)
 		rndis_filter_open(nvdev);
 
@@ -863,7 +851,6 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 	memset(&device_info, 0, sizeof(device_info));
 	device_info.ring_size = ring_size;
 	device_info.num_chn = nvdev->num_chn;
-	device_info.max_num_vrss_chns = nvdev->num_chn;
 
 	rndis_filter_device_remove(hdev, nvdev);
 
Signature · 1 line
2.11.0
#5 lore raw

PATCH 5/6 netvsc: include rtnetlink.h

In reply to Stephen Hemminger

Since these files use rtnl_derefernce make sure and include rtnetlink.h

---
 drivers/net/hyperv/netvsc_drv.c   | 2 ++
 drivers/net/hyperv/rndis_filter.c | 1 +
 2 files changed, 3 insertions(+)
drivers/net/hyperv/netvsc_drv.c +2 -0
index 99ae7fb6ec11..b2b0a1f96940 100644
@@ -33,6 +33,8 @@
 #include <linux/if_vlan.h>
 #include <linux/in.h>
 #include <linux/slab.h>
+#include <linux/rtnetlink.h>
+
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
drivers/net/hyperv/rndis_filter.c +1 -0
index e439886f72c1..eaa3f0d5682a 100644
@@ -28,6 +28,7 @@
 #include <linux/if_vlan.h>
 #include <linux/nls.h>
 #include <linux/vmalloc.h>
+#include <linux/rtnetlink.h>
 
 #include "hyperv_net.h"
 
Signature · 1 line
2.11.0
#6 lore raw

PATCH 6/6 netvsc: remove no longer used max_num_rss queues

In reply to Stephen Hemminger

This value has been calculated in rndis_device_attach since 4.11.

---
 drivers/net/hyperv/hyperv_net.h | 1 -
 drivers/net/hyperv/netvsc_drv.c | 2 --
 2 files changed, 3 deletions(-)
drivers/net/hyperv/hyperv_net.h +0 -1
index afb65f753574..4e7ff348327e 100644
@@ -147,7 +147,6 @@ struct hv_netvsc_packet {
 struct netvsc_device_info {
 	unsigned char mac_adr[ETH_ALEN];
 	int  ring_size;
-	u32  max_num_vrss_chns;
 	u32  num_chn;
 };
 
drivers/net/hyperv/netvsc_drv.c +0 -2
index b2b0a1f96940..8136dd2d927f 100644
@@ -754,7 +754,6 @@ static int netvsc_set_channels(struct net_device *net,
 	memset(&device_info, 0, sizeof(device_info));
 	device_info.num_chn = count;
 	device_info.ring_size = ring_size;
-	device_info.max_num_vrss_chns = count;
 
 	nvdev = rndis_filter_device_add(dev, &device_info);
 	if (!IS_ERR(nvdev)) {
@@ -763,7 +762,6 @@ static int netvsc_set_channels(struct net_device *net,
 		ret = PTR_ERR(nvdev);
 	} else {
 		device_info.num_chn = orig;
-		device_info.max_num_vrss_chns = count;
 		rndis_filter_device_add(dev, &device_info);
 	}
 
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/6 netvsc: remove bogus rtnl_unlock

In reply to Stephen Hemminger

Remove accidental rtnl_unlock from earlier testing.

Fixes 3962981f4822 ("netvsc: add rtnl annotations in rndis")
---
 drivers/net/hyperv/netvsc_drv.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/hyperv/netvsc_drv.c +0 -1
index a164981c15f7..1238600d717e 100644
@@ -1548,7 +1548,6 @@ static int netvsc_probe(struct hv_device *dev,
 
 	netif_set_real_num_tx_queues(net, nvdev->num_chn);
 	netif_set_real_num_rx_queues(net, nvdev->num_chn);
-	rtnl_unlock();
 
 	netdev_lockdep_set_classes(net);
 
Signature · 1 line
2.11.0