From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id AFC72A0093
	for <public@inbox.dpdk.org>; Tue, 19 May 2020 15:08:08 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id A4A3B1D603;
	Tue, 19 May 2020 15:08:08 +0200 (CEST)
Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com
 [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 6034E1D67B
 for <stable@dpdk.org>; Tue, 19 May 2020 15:08:07 +0200 (CEST)
Received: by mail-wr1-f68.google.com with SMTP id e16so15826685wra.7
 for <stable@dpdk.org>; Tue, 19 May 2020 06:08:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=CyNzjDECdJ6iUTaGnKU9sTQVmLsIqAsKTxvVLMTJWlA=;
 b=W8ybWN0jVugRjQZA/VqKc34ctI8z6/r5l1OAL2Icxb0zJq4A+LtyEUGjoynvo5Y+5V
 J24B+S1LeW7IoETQRoku1XClH1sBSPfj1QIJUOaBJEt7zQB43esm23P4XfXcOoirMlrI
 YBuUuAg5BdxXQOjr/3pEXv5V6N0THJ5BxPRxZbQcZB2RWeki773mr8ZpeTv9FUTB9sWZ
 IXYud8RcYz98opwuPrdSyoaKapSdBBuQgP4SQzK8c7GJZ+HiwflkhzKJ3D00orP/Fk9s
 RKBSdakx/ZSYSjGy9jh7wRMRMAvI3BtuUGFMf2fUnD9uq3YaFEY3x8IxYysLC6BTKqjB
 ZYhw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=CyNzjDECdJ6iUTaGnKU9sTQVmLsIqAsKTxvVLMTJWlA=;
 b=VQuLm9NpVYlG6ILRYZr0zQEDjYrJtKmErmX2wgTUJP2BvjQB6Yg/dv/c62+22rGVYL
 +lXMkl0mm5dWS+RLZgBIcpQEKue8tBRxSUmxpXMvLJkbR7DPL/ecBbVpnyugJljRVYIa
 r80okmsd+aIjOv2b0pldajBCBtyC7EJoqhm3t77tA0BbZqq02Qw6Q/ykwGLiTv7wC4Mj
 s7vqdEeOs1kleGpNN09vF1Lo0pQmCtSUhK89A25Ou8CPFM1Pr/sejBKyYOkzk/NUR069
 /GccTrKrNKJ8YGdtTzKvCcMINK75DQTPaFEWJx200+d7I91I1LBXTmRyRW2RpJNM/u+C
 oL8g==
X-Gm-Message-State: AOAM533pBisGI5GQWxtqS/XhPWv1HwaM6pz+uJe+D41aF4r0iyl5xT0b
 eeL1FGMfcy5cdcawWBY5O+c=
X-Google-Smtp-Source: ABdhPJzjB6CMGEROf2sgFgIsNebUgmG1SLBb9/OgH27jvegcJXow78T+KsDWSHpWeon8wR3HToZ6/g==
X-Received: by 2002:adf:afe9:: with SMTP id y41mr27792795wrd.56.1589893687071; 
 Tue, 19 May 2020 06:08:07 -0700 (PDT)
Received: from localhost ([88.98.246.218])
 by smtp.gmail.com with ESMTPSA id n7sm21049375wro.94.2020.05.19.06.08.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 19 May 2020 06:08:06 -0700 (PDT)
From: luca.boccassi@gmail.com
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dpdk stable <stable@dpdk.org>
Date: Tue, 19 May 2020 14:02:58 +0100
Message-Id: <20200519130549.112823-43-luca.boccassi@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com>
References: <20200519125804.104349-1-luca.boccassi@gmail.com>
 <20200519130549.112823-1-luca.boccassi@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-stable] patch 'net/netvsc: handle Rx packets during
	multi-channel setup' has been queued to stable release 19.11.3
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

Hi,

FYI, your patch has been queued to stable release 19.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/21/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From 244193073d217876eb9c40b9acb48e9a42cd5eaf Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 31 Mar 2020 10:13:58 -0700
Subject: [PATCH] net/netvsc: handle Rx packets during multi-channel setup

[ upstream commit 107f3cf31047e09a146e8ebc3d232f3de9d55466 ]

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")

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 6b518685ab..477202b2a0 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

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 14:04:46.305196628 +0100
+++ 0043-net-netvsc-handle-Rx-packets-during-multi-channel-se.patch	2020-05-19 14:04:44.180647720 +0100
@@ -1,8 +1,10 @@
-From 107f3cf31047e09a146e8ebc3d232f3de9d55466 Mon Sep 17 00:00:00 2001
+From 244193073d217876eb9c40b9acb48e9a42cd5eaf Mon Sep 17 00:00:00 2001
 From: Stephen Hemminger <stephen@networkplumber.org>
 Date: Tue, 31 Mar 2020 10:13:58 -0700
 Subject: [PATCH] net/netvsc: handle Rx packets during multi-channel setup
 
+[ upstream commit 107f3cf31047e09a146e8ebc3d232f3de9d55466 ]
+
 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
@@ -13,7 +15,6 @@
 concurrently.
 
 Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
-Cc: stable@dpdk.org
 
 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
 ---