All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] netvsc: small changesfor net-next
@ 2017-03-16 23:12 Stephen Hemminger
  2017-03-16 23:12 ` [PATCH net-next 1/3] netvsc: avoid race with callback Stephen Hemminger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-03-16 23:12 UTC (permalink / raw)
  To: kys, davem, haiyangz; +Cc: netdev, Stephen Hemminger

One bugfix, and two non-code patches

Stephen Hemminger (3):
  netvsc: avoid race with callback
  netvsc: add comments about callback's and NAPI
  netvsc: remove unused #define

 drivers/net/hyperv/hyperv_net.h   |  3 ---
 drivers/net/hyperv/netvsc.c       | 31 +++++++++++++++++--------------
 drivers/net/hyperv/rndis_filter.c | 15 ++++++++++-----
 3 files changed, 27 insertions(+), 22 deletions(-)

-- 
2.11.0

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

* [PATCH net-next 1/3] netvsc: avoid race with callback
  2017-03-16 23:12 [PATCH net-next 0/3] netvsc: small changesfor net-next Stephen Hemminger
@ 2017-03-16 23:12 ` Stephen Hemminger
  2017-03-16 23:12 ` [PATCH net-next 2/3] netvsc: add comments about callback's and NAPI Stephen Hemminger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-03-16 23:12 UTC (permalink / raw)
  To: kys, davem, haiyangz; +Cc: netdev, Stephen Hemminger

Change the argument to channel callback from the channel pointer
to the internal data structure containing per-channel info.
This avoids any possible races when callback happens during
initialization and makes IRQ code simpler.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc.c       | 18 +++++-------------
 drivers/net/hyperv/rndis_filter.c | 15 ++++++++++-----
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 0e71164849dd..0a2e9bd98d2c 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1250,21 +1250,12 @@ int netvsc_poll(struct napi_struct *napi, int budget)
 
 void netvsc_channel_cb(void *context)
 {
-	struct vmbus_channel *channel = context;
-	struct hv_device *device = netvsc_channel_to_device(channel);
-	u16 q_idx = channel->offermsg.offer.sub_channel_index;
-	struct netvsc_device *net_device;
-	struct net_device *ndev;
-
-	ndev = hv_get_drvdata(device);
-	if (unlikely(!ndev))
-		return;
+	struct netvsc_channel *nvchan = context;
 
 	/* disable interupts from host */
-	hv_begin_read(&channel->inbound);
+	hv_begin_read(&nvchan->channel->inbound);
 
-	net_device = net_device_to_netvsc_device(ndev);
-	napi_schedule(&net_device->chan_table[q_idx].napi);
+	napi_schedule(&nvchan->napi);
 }
 
 /*
@@ -1294,7 +1285,8 @@ int netvsc_device_add(struct hv_device *device,
 	/* Open the channel */
 	ret = vmbus_open(device->channel, ring_size * PAGE_SIZE,
 			 ring_size * PAGE_SIZE, NULL, 0,
-			 netvsc_channel_cb, device->channel);
+			 netvsc_channel_cb,
+			 net_device->chan_table);
 
 	if (ret != 0) {
 		netdev_err(ndev, "unable to open channel: %d\n", ret);
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index d7b6311e6c19..382b9a62e3c4 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -996,23 +996,28 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
 		hv_get_drvdata(new_sc->primary_channel->device_obj);
 	struct netvsc_device *nvscdev = net_device_to_netvsc_device(ndev);
 	u16 chn_index = new_sc->offermsg.offer.sub_channel_index;
-	int ret;
+	struct netvsc_channel *nvchan;
 	unsigned long flags;
+	int ret;
 
 	if (chn_index >= nvscdev->num_chn)
 		return;
 
-	nvscdev->chan_table[chn_index].mrc.buf
+	nvchan = nvscdev->chan_table + chn_index;
+	nvchan->mrc.buf
 		= vzalloc(NETVSC_RECVSLOT_MAX * sizeof(struct recv_comp_data));
 
+	if (!nvchan->mrc.buf)
+		return;
+
 	ret = vmbus_open(new_sc, nvscdev->ring_size * PAGE_SIZE,
 			 nvscdev->ring_size * PAGE_SIZE, NULL, 0,
-			 netvsc_channel_cb, new_sc);
+			 netvsc_channel_cb, nvchan);
 
 	if (ret == 0)
-		nvscdev->chan_table[chn_index].channel = new_sc;
+		nvchan->channel = new_sc;
 
-	napi_enable(&nvscdev->chan_table[chn_index].napi);
+	napi_enable(&nvchan->napi);
 
 	spin_lock_irqsave(&nvscdev->sc_lock, flags);
 	nvscdev->num_sc_offered--;
-- 
2.11.0

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

* [PATCH net-next 2/3] netvsc: add comments about callback's and NAPI
  2017-03-16 23:12 [PATCH net-next 0/3] netvsc: small changesfor net-next Stephen Hemminger
  2017-03-16 23:12 ` [PATCH net-next 1/3] netvsc: avoid race with callback Stephen Hemminger
@ 2017-03-16 23:12 ` Stephen Hemminger
  2017-03-16 23:12 ` [PATCH net-next 3/3] netvsc: remove unused #define Stephen Hemminger
  2017-03-17  4:40 ` [PATCH net-next 0/3] netvsc: small changesfor net-next David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-03-16 23:12 UTC (permalink / raw)
  To: kys, davem, haiyangz; +Cc: netdev, Stephen Hemminger

Add some short description of how callback's and NAPI interoperate.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 0a2e9bd98d2c..989b7cd99380 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1209,6 +1209,10 @@ static struct hv_device *netvsc_channel_to_device(struct vmbus_channel *channel)
 	return primary ? primary->device_obj : channel->device_obj;
 }
 
+/* Network processing softirq
+ * Process data in incoming ring buffer from host
+ * Stops when ring is empty or budget is met or exceeded.
+ */
 int netvsc_poll(struct napi_struct *napi, int budget)
 {
 	struct netvsc_channel *nvchan
@@ -1238,7 +1242,11 @@ int netvsc_poll(struct napi_struct *napi, int budget)
 	}
 	hv_pkt_iter_close(channel);
 
-	/* If ring is empty and NAPI is not doing polling */
+	/* If budget was not exhausted and
+	 * not doing busy poll
+	 * then re-enable host interrupts
+	 *  and reschedule if ring is not empty.
+	 */
 	if (work_done < budget &&
 	    napi_complete_done(napi, work_done) &&
 	    hv_end_read(&channel->inbound) != 0)
@@ -1248,6 +1256,9 @@ int netvsc_poll(struct napi_struct *napi, int budget)
 	return work_done;
 }
 
+/* Call back when data is available in host ring buffer.
+ * Processing is deferred until network softirq (NAPI)
+ */
 void netvsc_channel_cb(void *context)
 {
 	struct netvsc_channel *nvchan = context;
-- 
2.11.0

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

* [PATCH net-next 3/3] netvsc: remove unused #define
  2017-03-16 23:12 [PATCH net-next 0/3] netvsc: small changesfor net-next Stephen Hemminger
  2017-03-16 23:12 ` [PATCH net-next 1/3] netvsc: avoid race with callback Stephen Hemminger
  2017-03-16 23:12 ` [PATCH net-next 2/3] netvsc: add comments about callback's and NAPI Stephen Hemminger
@ 2017-03-16 23:12 ` Stephen Hemminger
  2017-03-17  4:40 ` [PATCH net-next 0/3] netvsc: small changesfor net-next David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2017-03-16 23:12 UTC (permalink / raw)
  To: kys, davem, haiyangz; +Cc: netdev, Stephen Hemminger

Not used anywhere.

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

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index b09c4fca1805..6b5f75217694 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -1427,9 +1427,6 @@ struct rndis_message {
 	((void *) rndis_msg)
 
 
-#define __struct_bcount(x)
-
-
 
 #define RNDIS_HEADER_SIZE	(sizeof(struct rndis_message) - \
 				 sizeof(union rndis_message_container))
-- 
2.11.0

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

* Re: [PATCH net-next 0/3] netvsc: small changesfor net-next
  2017-03-16 23:12 [PATCH net-next 0/3] netvsc: small changesfor net-next Stephen Hemminger
                   ` (2 preceding siblings ...)
  2017-03-16 23:12 ` [PATCH net-next 3/3] netvsc: remove unused #define Stephen Hemminger
@ 2017-03-17  4:40 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-03-17  4:40 UTC (permalink / raw)
  To: stephen; +Cc: kys, haiyangz, netdev, sthemmin

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu, 16 Mar 2017 16:12:36 -0700

> One bugfix, and two non-code patches

Series applied.

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

end of thread, other threads:[~2017-03-17  4:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 23:12 [PATCH net-next 0/3] netvsc: small changesfor net-next Stephen Hemminger
2017-03-16 23:12 ` [PATCH net-next 1/3] netvsc: avoid race with callback Stephen Hemminger
2017-03-16 23:12 ` [PATCH net-next 2/3] netvsc: add comments about callback's and NAPI Stephen Hemminger
2017-03-16 23:12 ` [PATCH net-next 3/3] netvsc: remove unused #define Stephen Hemminger
2017-03-17  4:40 ` [PATCH net-next 0/3] netvsc: small changesfor net-next David Miller

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.