All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/3] netvsc: optimize calculation of number of slots
@ 2017-05-29 18:31 Stephen Hemminger
  2017-05-29 18:31 ` [PATCH net-next 2/3] netvsc: use hv_get_bytes_to_read Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-05-29 18:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

Speed up transmit check for fragmented packets by using existing
macros to compute number of pages, and eliminate loop since
each skb fragment is only one page.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c | 43 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 4421a6d00375..548c78863ce9 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -343,34 +343,14 @@ static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb,
 	return slots_used;
 }
 
-static int count_skb_frag_slots(struct sk_buff *skb)
-{
-	int i, frags = skb_shinfo(skb)->nr_frags;
-	int pages = 0;
-
-	for (i = 0; i < frags; i++) {
-		skb_frag_t *frag = skb_shinfo(skb)->frags + i;
-		unsigned long size = skb_frag_size(frag);
-		unsigned long offset = frag->page_offset;
-
-		/* Skip unused frames from start of page */
-		offset &= ~PAGE_MASK;
-		pages += PFN_UP(offset + size);
-	}
-	return pages;
-}
-
-static int netvsc_get_slots(struct sk_buff *skb)
+/* Estimate number of page buffers neede to transmit
+ * Need at most 2 for RNDIS header plus skb body and fragments.
+ */
+static unsigned int netvsc_get_slots(const struct sk_buff *skb)
 {
-	char *data = skb->data;
-	unsigned int offset = offset_in_page(data);
-	unsigned int len = skb_headlen(skb);
-	int slots;
-	int frag_slots;
-
-	slots = DIV_ROUND_UP(offset + len, PAGE_SIZE);
-	frag_slots = count_skb_frag_slots(skb);
-	return slots + frag_slots;
+	return PFN_UP(offset_in_page(skb->data)+ skb_headlen(skb))
+		+ skb_shinfo(skb)->nr_frags
+		+ 2;
 }
 
 static u32 net_checksum_info(struct sk_buff *skb)
@@ -408,21 +388,18 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 	struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
 	struct hv_page_buffer *pb = page_buf;
 
-	/* We will atmost need two pages to describe the rndis
-	 * header. We can only transmit MAX_PAGE_BUFFER_COUNT number
+	/* We can only transmit MAX_PAGE_BUFFER_COUNT number
 	 * of pages in a single packet. If skb is scattered around
 	 * more pages we try linearizing it.
 	 */
-
-	num_data_pgs = netvsc_get_slots(skb) + 2;
-
+	num_data_pgs = netvsc_get_slots(skb);
 	if (unlikely(num_data_pgs > MAX_PAGE_BUFFER_COUNT)) {
 		++net_device_ctx->eth_stats.tx_scattered;
 
 		if (skb_linearize(skb))
 			goto no_memory;
 
-		num_data_pgs = netvsc_get_slots(skb) + 2;
+		num_data_pgs = netvsc_get_slots(skb);
 		if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) {
 			++net_device_ctx->eth_stats.tx_too_big;
 			goto drop;
-- 
2.11.0

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

* [PATCH net-next 2/3] netvsc: use hv_get_bytes_to_read
  2017-05-29 18:31 [PATCH net-next 1/3] netvsc: optimize calculation of number of slots Stephen Hemminger
@ 2017-05-29 18:31 ` Stephen Hemminger
  2017-05-29 18:31 ` [PATCH net-next 3/3] netvsc: use typed pointer for internal state Stephen Hemminger
  2017-05-30  0:42 ` [PATCH net-next 1/3] netvsc: optimize calculation of number of slots David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-05-29 18:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

Don't need need to look at write space in netvsc_close.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 548c78863ce9..c3e0277186bb 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -118,7 +118,7 @@ static int netvsc_close(struct net_device *net)
 	struct net_device_context *net_device_ctx = netdev_priv(net);
 	struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
 	int ret;
-	u32 aread, awrite, i, msec = 10, retry = 0, retry_max = 20;
+	u32 aread, i, msec = 10, retry = 0, retry_max = 20;
 	struct vmbus_channel *chn;
 
 	netif_tx_disable(net);
@@ -139,15 +139,11 @@ static int netvsc_close(struct net_device *net)
 			if (!chn)
 				continue;
 
-			hv_get_ringbuffer_availbytes(&chn->inbound, &aread,
-						     &awrite);
-
+			aread = hv_get_bytes_to_read(&chn->inbound);
 			if (aread)
 				break;
 
-			hv_get_ringbuffer_availbytes(&chn->outbound, &aread,
-						     &awrite);
-
+			aread = hv_get_bytes_to_read(&chn->outbound);
 			if (aread)
 				break;
 		}
-- 
2.11.0

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

* [PATCH net-next 3/3] netvsc: use typed pointer for internal state
  2017-05-29 18:31 [PATCH net-next 1/3] netvsc: optimize calculation of number of slots Stephen Hemminger
  2017-05-29 18:31 ` [PATCH net-next 2/3] netvsc: use hv_get_bytes_to_read Stephen Hemminger
@ 2017-05-29 18:31 ` Stephen Hemminger
  2017-05-30  0:42 ` [PATCH net-next 1/3] netvsc: optimize calculation of number of slots David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-05-29 18:31 UTC (permalink / raw)
  To: davem; +Cc: netdev, Stephen Hemminger

The element netvsc_device:extension is always a pointer to RNDIS
information.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/hyperv_net.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 262b2ea576a3..f82d54e0208c 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -763,8 +763,7 @@ struct netvsc_device {
 
 	refcount_t sc_offered;
 
-	/* Holds rndis device info */
-	void *extension;
+	struct rndis_device *extension;
 
 	int ring_size;
 
-- 
2.11.0

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

* Re: [PATCH net-next 1/3] netvsc: optimize calculation of number of slots
  2017-05-29 18:31 [PATCH net-next 1/3] netvsc: optimize calculation of number of slots Stephen Hemminger
  2017-05-29 18:31 ` [PATCH net-next 2/3] netvsc: use hv_get_bytes_to_read Stephen Hemminger
  2017-05-29 18:31 ` [PATCH net-next 3/3] netvsc: use typed pointer for internal state Stephen Hemminger
@ 2017-05-30  0:42 ` David Miller
  2017-05-30 17:16   ` Stephen Hemminger
  2 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2017-05-30  0:42 UTC (permalink / raw)
  To: stephen; +Cc: netdev, sthemmin


Stephen, please provide proper header "[PATCH net-next 0/3] " postings
with your patch series, so we know at a high level what this patch
series is doing, how it is doing it, and why it is doing it that
way.

I've been quite liberal with your patch postings in the past, hoping
you would catch on, but now I'm going to simply enforce what I ask
of every other patch series submitter.

Thanks.

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

* Re: [PATCH net-next 1/3] netvsc: optimize calculation of number of slots
  2017-05-30  0:42 ` [PATCH net-next 1/3] netvsc: optimize calculation of number of slots David Miller
@ 2017-05-30 17:16   ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-05-30 17:16 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, sthemmin

On Mon, 29 May 2017 20:42:04 -0400 (EDT)
David Miller <davem@davemloft.net> wrote:

> Stephen, please provide proper header "[PATCH net-next 0/3] " postings
> with your patch series, so we know at a high level what this patch
> series is doing, how it is doing it, and why it is doing it that
> way.

Sure, these were just misc small cleanups. Prefer to send them out
in small chunks, not mixed with bug fixes and new features.

> I've been quite liberal with your patch postings in the past, hoping
> you would catch on, but now I'm going to simply enforce what I ask
> of every other patch series submitter.

Sorry, thought it was obvious from content.

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

end of thread, other threads:[~2017-05-30 17:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-29 18:31 [PATCH net-next 1/3] netvsc: optimize calculation of number of slots Stephen Hemminger
2017-05-29 18:31 ` [PATCH net-next 2/3] netvsc: use hv_get_bytes_to_read Stephen Hemminger
2017-05-29 18:31 ` [PATCH net-next 3/3] netvsc: use typed pointer for internal state Stephen Hemminger
2017-05-30  0:42 ` [PATCH net-next 1/3] netvsc: optimize calculation of number of slots David Miller
2017-05-30 17:16   ` Stephen Hemminger

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.