patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, stable@dpdk.org
Subject: [dpdk-stable] [PATCH v4 2/8] net/netvsc: handle receive packets during multi-channel setup
Date: Tue, 31 Mar 2020 10:13:58 -0700	[thread overview]
Message-ID: <20200331171404.23596-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20200331171404.23596-1-stephen@networkplumber.org>

It is possible for a packet to arrive during the configuration
process when setting up multiple queue mode. This would cause
configure to fail; fix by just ignoring receive packets while
waiting for control commands.

Use the receive ring lock to avoid possible races between
oddly behaved applications doing rx_burst and control operations
concurrently.

Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/netvsc/hn_nvs.c | 41 +++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netvsc/hn_nvs.c b/drivers/net/netvsc/hn_nvs.c
index 6b518685ab6f..477202b2a0b7 100644
--- a/drivers/net/netvsc/hn_nvs.c
+++ b/drivers/net/netvsc/hn_nvs.c
@@ -54,7 +54,7 @@ static int hn_nvs_req_send(struct hn_data *hv,
 }
 
 static int
-hn_nvs_execute(struct hn_data *hv,
+__hn_nvs_execute(struct hn_data *hv,
 	       void *req, uint32_t reqlen,
 	       void *resp, uint32_t resplen,
 	       uint32_t type)
@@ -62,6 +62,7 @@ hn_nvs_execute(struct hn_data *hv,
 	struct vmbus_channel *chan = hn_primary_chan(hv);
 	char buffer[NVS_RESPSIZE_MAX];
 	const struct hn_nvs_hdr *hdr;
+	uint64_t xactid;
 	uint32_t len;
 	int ret;
 
@@ -77,7 +78,7 @@ hn_nvs_execute(struct hn_data *hv,
 
  retry:
 	len = sizeof(buffer);
-	ret = rte_vmbus_chan_recv(chan, buffer, &len, NULL);
+	ret = rte_vmbus_chan_recv(chan, buffer, &len, &xactid);
 	if (ret == -EAGAIN) {
 		rte_delay_us(HN_CHAN_INTERVAL_US);
 		goto retry;
@@ -88,7 +89,20 @@ hn_nvs_execute(struct hn_data *hv,
 		return ret;
 	}
 
+	if (len < sizeof(*hdr)) {
+		PMD_DRV_LOG(ERR, "response missing NVS header");
+		return -EINVAL;
+	}
+
 	hdr = (struct hn_nvs_hdr *)buffer;
+
+	/* Silently drop received packets while waiting for response */
+	if (hdr->type == NVS_TYPE_RNDIS) {
+		hn_nvs_ack_rxbuf(chan, xactid);
+		--hv->rxbuf_outstanding;
+		goto retry;
+	}
+
 	if (hdr->type != type) {
 		PMD_DRV_LOG(ERR, "unexpected NVS resp %#x, expect %#x",
 			    hdr->type, type);
@@ -108,6 +122,29 @@ hn_nvs_execute(struct hn_data *hv,
 	return 0;
 }
 
+
+/*
+ * Execute one control command and get the response.
+ * Only one command can be active on a channel at once
+ * Unlike BSD, DPDK does not have an interrupt context
+ * so the polling is required to wait for response.
+ */
+static int
+hn_nvs_execute(struct hn_data *hv,
+	       void *req, uint32_t reqlen,
+	       void *resp, uint32_t resplen,
+	       uint32_t type)
+{
+	struct hn_rx_queue *rxq = hv->primary;
+	int ret;
+
+	rte_spinlock_lock(&rxq->ring_lock);
+	ret = __hn_nvs_execute(hv, req, reqlen, resp, resplen, type);
+	rte_spinlock_unlock(&rxq->ring_lock);
+
+	return ret;
+}
+
 static int
 hn_nvs_doinit(struct hn_data *hv, uint32_t nvs_ver)
 {
-- 
2.20.1


  parent reply	other threads:[~2020-03-31 17:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200316235612.29854-1-stephen@networkplumber.org>
2020-03-16 23:56 ` [dpdk-stable] [PATCH 1/2] " Stephen Hemminger
     [not found] ` <20200318202957.18121-1-stephen@networkplumber.org>
2020-03-18 20:29   ` [dpdk-stable] [PATCH v2 1/4] net/netvsc: propogate descriptor limits from VF to netvsc Stephen Hemminger
2020-03-18 20:29   ` [dpdk-stable] [PATCH v2 2/4] net/netvsc: handle receive packets during multi-channel setup Stephen Hemminger
2020-03-18 20:29   ` [dpdk-stable] [PATCH v2 3/4] net/netvsc: split send buffers from transmit descriptors Stephen Hemminger
2020-03-18 20:29   ` [dpdk-stable] [PATCH v2 4/4] net/netvsc: don't enable RSS if only single receive queue Stephen Hemminger
     [not found] ` <20200318205104.22486-1-stephen@networkplumber.org>
2020-03-18 20:51   ` [dpdk-stable] [PATCH v3 1/4] net/netvsc: propagate descriptor limits from VF to netvsc Stephen Hemminger
2020-03-18 20:51   ` [dpdk-stable] [PATCH v3 2/4] net/netvsc: handle receive packets during multi-channel setup Stephen Hemminger
2020-03-18 20:51   ` [dpdk-stable] [PATCH v3 3/4] net/netvsc: split send buffers from transmit descriptors Stephen Hemminger
2020-03-18 20:51   ` [dpdk-stable] [PATCH v3 4/4] net/netvsc: don't enable RSS if only single receive queue Stephen Hemminger
     [not found] ` <20200331171404.23596-1-stephen@networkplumber.org>
2020-03-31 17:13   ` [dpdk-stable] [PATCH v4 1/8] net/netvsc: propagate descriptor limits from VF to netvsc Stephen Hemminger
2020-03-31 17:13   ` Stephen Hemminger [this message]
2020-03-31 17:13   ` [dpdk-stable] [PATCH v4 3/8] net/netvsc: split send buffers from transmit descriptors Stephen Hemminger
2020-03-31 17:14   ` [dpdk-stable] [PATCH v4 4/8] net/netvsc: fix invalid rte_free on dev_close Stephen Hemminger
2020-04-06 16:00     ` Ferruh Yigit
2020-03-31 17:14   ` [dpdk-stable] [PATCH v4 5/8] net/netvsc: remove process event optimization Stephen Hemminger
2020-03-31 17:14   ` [dpdk-stable] [PATCH v4 6/8] net/netvsc: handle transmit completions based on burst size Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200331171404.23596-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).