netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe
@ 2017-12-11 16:56 Stephen Hemminger
  2017-12-11 16:56 ` [PATCH net-next 1/2] hv_netvsc: Fix the receive buffer size limit Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Hemminger @ 2017-12-11 16:56 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev

The default for receive buffer descriptors is not correct, it should
match the default receive buffer size and the upper limit of receive
buffer size is too low.  Also, for older versions of Window servers
hosts, different lower limit check is necessary, otherwise the buffer
request will be rejected by the host, resulting vNIC not come up.

This patch set corrects these problems.

Haiyang Zhang (2):
  hv_netvsc: Fix the receive buffer size limit
  hv_netvsc: Fix the TX/RX buffer default sizes

 drivers/net/hyperv/hyperv_net.h | 19 ++++++++++++++++---
 drivers/net/hyperv/netvsc.c     |  5 +++++
 drivers/net/hyperv/netvsc_drv.c |  4 ----
 3 files changed, 21 insertions(+), 7 deletions(-)

-- 
2.11.0

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

* [PATCH net-next 1/2] hv_netvsc: Fix the receive buffer size limit
  2017-12-11 16:56 [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe Stephen Hemminger
@ 2017-12-11 16:56 ` Stephen Hemminger
  2017-12-11 16:56 ` [PATCH net-next 2/2] hv_netvsc: Fix the TX/RX buffer default sizes Stephen Hemminger
  2017-12-13 18:25 ` [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2017-12-11 16:56 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev

From: Haiyang Zhang <haiyangz@microsoft.com>

The max should be 31 MB on host with NVSP version > 2.

On legacy hosts (NVSP version <=2) only 15 MB receive buffer is allowed,
otherwise the buffer request will be rejected by the host, resulting
vNIC not coming up.

The NVSP version is only available after negotiation. So, we add the
limit checking for legacy hosts in netvsc_init_buf().

Fixes: 5023a6db73196 ("netvsc: increase default receive buffer size")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/hyperv_net.h | 6 ++++--
 drivers/net/hyperv/netvsc.c     | 5 +++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 3d940c67ea94..373455f216ce 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -637,9 +637,11 @@ struct nvsp_message {
 #define NETVSC_MTU 65535
 #define NETVSC_MTU_MIN ETH_MIN_MTU
 
-#define NETVSC_RECEIVE_BUFFER_SIZE		(1024*1024*16)	/* 16MB */
-#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY	(1024*1024*15)  /* 15MB */
+/* Max buffer sizes allowed by a host */
+#define NETVSC_RECEIVE_BUFFER_SIZE		(1024 * 1024 * 31) /* 31MB */
+#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY	(1024 * 1024 * 15) /* 15MB */
 #define NETVSC_SEND_BUFFER_SIZE			(1024 * 1024 * 15)   /* 15MB */
+
 #define NETVSC_INVALID_INDEX			-1
 
 #define NETVSC_SEND_SECTION_SIZE		6144
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index e4bcd202a56a..e5d16a8cf0d6 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -268,6 +268,11 @@ static int netvsc_init_buf(struct hv_device *device,
 	buf_size = device_info->recv_sections * device_info->recv_section_size;
 	buf_size = roundup(buf_size, PAGE_SIZE);
 
+	/* Legacy hosts only allow smaller receive buffer */
+	if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_2)
+		buf_size = min_t(unsigned int, buf_size,
+				 NETVSC_RECEIVE_BUFFER_SIZE_LEGACY);
+
 	net_device->recv_buf = vzalloc(buf_size);
 	if (!net_device->recv_buf) {
 		netdev_err(ndev,
-- 
2.11.0

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

* [PATCH net-next 2/2] hv_netvsc: Fix the TX/RX buffer default sizes
  2017-12-11 16:56 [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe Stephen Hemminger
  2017-12-11 16:56 ` [PATCH net-next 1/2] hv_netvsc: Fix the receive buffer size limit Stephen Hemminger
@ 2017-12-11 16:56 ` Stephen Hemminger
  2017-12-13 18:25 ` [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2017-12-11 16:56 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin; +Cc: devel, netdev

From: Haiyang Zhang <haiyangz@microsoft.com>

The values were not computed correctly. There are no significant
visible impact, though.

The intended size of RX buffer is 16 MB, and the default slot size is 1728.
So, NETVSC_DEFAULT_RX should be 16*1024*1024 / 1728 = 9709.

The intended size of TX buffer is 1 MB, and the slot size is 6144.
So, NETVSC_DEFAULT_TX should be 1024*1024 / 6144 = 170.

The patch puts the formula directly into the macro, and moves them to
hyperv_net.h, together with related macros.

Fixes: 5023a6db73196 ("netvsc: increase default receive buffer size")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/hyperv_net.h | 13 ++++++++++++-
 drivers/net/hyperv/netvsc_drv.c |  4 ----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 373455f216ce..845ddc7bba46 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -640,13 +640,24 @@ struct nvsp_message {
 /* Max buffer sizes allowed by a host */
 #define NETVSC_RECEIVE_BUFFER_SIZE		(1024 * 1024 * 31) /* 31MB */
 #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY	(1024 * 1024 * 15) /* 15MB */
-#define NETVSC_SEND_BUFFER_SIZE			(1024 * 1024 * 15)   /* 15MB */
+#define NETVSC_RECEIVE_BUFFER_DEFAULT		(1024 * 1024 * 16)
+
+#define NETVSC_SEND_BUFFER_SIZE			(1024 * 1024 * 15)  /* 15MB */
+#define NETVSC_SEND_BUFFER_DEFAULT		(1024 * 1024)
 
 #define NETVSC_INVALID_INDEX			-1
 
 #define NETVSC_SEND_SECTION_SIZE		6144
 #define NETVSC_RECV_SECTION_SIZE		1728
 
+/* Default size of TX buf: 1MB, RX buf: 16MB */
+#define NETVSC_MIN_TX_SECTIONS	10
+#define NETVSC_DEFAULT_TX	(NETVSC_SEND_BUFFER_DEFAULT \
+				 / NETVSC_SEND_SECTION_SIZE)
+#define NETVSC_MIN_RX_SECTIONS	10
+#define NETVSC_DEFAULT_RX	(NETVSC_RECEIVE_BUFFER_DEFAULT \
+				 / NETVSC_RECV_SECTION_SIZE)
+
 #define NETVSC_RECEIVE_BUFFER_ID		0xcafe
 #define NETVSC_SEND_BUFFER_ID			0
 
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index dc70de674ca9..b6a434ac64d3 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -47,10 +47,6 @@
 #include "hyperv_net.h"
 
 #define RING_SIZE_MIN		64
-#define NETVSC_MIN_TX_SECTIONS	10
-#define NETVSC_DEFAULT_TX	192	/* ~1M */
-#define NETVSC_MIN_RX_SECTIONS	10	/* ~64K */
-#define NETVSC_DEFAULT_RX	10485   /* Max ~16M */
 
 #define LINKCHANGE_INT (2 * HZ)
 #define VF_TAKEOVER_INT (HZ / 10)
-- 
2.11.0

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

* Re: [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe
  2017-12-11 16:56 [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe Stephen Hemminger
  2017-12-11 16:56 ` [PATCH net-next 1/2] hv_netvsc: Fix the receive buffer size limit Stephen Hemminger
  2017-12-11 16:56 ` [PATCH net-next 2/2] hv_netvsc: Fix the TX/RX buffer default sizes Stephen Hemminger
@ 2017-12-13 18:25 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-12-13 18:25 UTC (permalink / raw)
  To: stephen; +Cc: kys, haiyangz, sthemmin, devel, netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon, 11 Dec 2017 08:56:56 -0800

> The default for receive buffer descriptors is not correct, it should
> match the default receive buffer size and the upper limit of receive
> buffer size is too low.  Also, for older versions of Window servers
> hosts, different lower limit check is necessary, otherwise the buffer
> request will be rejected by the host, resulting vNIC not come up.
> 
> This patch set corrects these problems.

Series applied.

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

end of thread, other threads:[~2017-12-13 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-11 16:56 [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe Stephen Hemminger
2017-12-11 16:56 ` [PATCH net-next 1/2] hv_netvsc: Fix the receive buffer size limit Stephen Hemminger
2017-12-11 16:56 ` [PATCH net-next 2/2] hv_netvsc: Fix the TX/RX buffer default sizes Stephen Hemminger
2017-12-13 18:25 ` [PATCH net-next 0/2] hv_netvsc: Fix default and limit of recv buffe David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).