Skip to contentSkip to conversation

hv_netvsc: Implement batching of receive completions

PATCH Applied Haiyang Zhang 2 participants 2 messages Aug 19, 2016 – Aug 20, 2016

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

PATCH 1/1 hv_netvsc: Implement batching of receive completions

From: Haiyang Zhang <[email protected]>

The existing code uses busy retry when unable to send out receive completions due to full ring buffer. It also gives up retrying after limit is reached, and causes receive buffer slots not being recycled. This patch implements batching of receive completions. It also prevents dropping receive completions due to full ring buffer.

---
 drivers/net/hyperv/hyperv_net.h   |   17 ++++
 drivers/net/hyperv/netvsc.c       |  170 ++++++++++++++++++++++++++++++-------
 drivers/net/hyperv/rndis_filter.c |    6 +-
 3 files changed, 160 insertions(+), 33 deletions(-)
drivers/net/hyperv/hyperv_net.h +17 -0
index fa7b1e4..ce45d68 100644
@@ -634,6 +634,20 @@ struct multi_send_data {
 	u32 count; /* counter of batched packets */
 };
 
+struct recv_comp_data {
+	u64 tid; /* transaction id */
+	u32 status;
+};
+
+/* Netvsc Receive Slots Max */
+#define NETVSC_RECVSLOT_MAX (NETVSC_RECEIVE_BUFFER_SIZE / ETH_DATA_LEN + 1)
+
+struct multi_recv_comp {
+	void *buf; /* queued receive completions */
+	u32 first; /* first data entry */
+	u32 next; /* next entry for writing */
+};
+
 struct netvsc_stats {
 	u64 packets;
 	u64 bytes;
@@ -736,6 +750,9 @@ struct netvsc_device {
 	u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
 	u32 pkt_align; /* alignment bytes, e.g. 8 */
 
+	struct multi_recv_comp mrc[VRSS_CHANNEL_MAX];
+	atomic_t num_outstanding_recvs;
+
 	atomic_t open_cnt;
 };
 
drivers/net/hyperv/netvsc.c +138 -32

232 lines not on this page · raw message

drivers/net/hyperv/rndis_filter.c +5 -1
index dd3b335..3ecb2d0 100644
@@ -897,7 +897,8 @@ cleanup:
 
 	/* Wait for all send completions */
 	wait_event(nvdev->wait_drain,
-		atomic_read(&nvdev->num_outstanding_sends) == 0);
+		   atomic_read(&nvdev->num_outstanding_sends) == 0 &&
+		   atomic_read(&nvdev->num_outstanding_recvs) == 0);
 
 	if (request)
 		put_rndis_request(dev, request);
@@ -953,6 +954,9 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
 	set_per_channel_state(new_sc, nvscdev->sub_cb_buf + (chn_index - 1) *
 			      NETVSC_PACKET_SIZE);
 
+	nvscdev->mrc[chn_index].buf = vzalloc(NETVSC_RECVSLOT_MAX *
+					      sizeof(struct recv_comp_data));
+
 	ret = vmbus_open(new_sc, nvscdev->ring_size * PAGE_SIZE,
 			 nvscdev->ring_size * PAGE_SIZE, NULL, 0,
 			 netvsc_channel_cb, new_sc);
Signature · 1 line
1.7.4.1
maintainer Applied
#1 lore raw

From: Haiyang Zhang <[email protected]>
Date: Fri, 19 Aug 2016 14:47:09 -0700

Quoted 10 lines

From: Haiyang Zhang <[email protected]>

The existing code uses busy retry when unable to send out receive completions due to full ring buffer. It also gives up retrying after limit is reached, and causes receive buffer slots not being recycled. This patch implements batching of receive completions. It also prevents dropping receive completions due to full ring buffer.

Applied, thanks.