From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5CAEA057D for ; Wed, 18 Mar 2020 21:34:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5022E1C025; Wed, 18 Mar 2020 21:34:18 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id CD4271B203 for ; Wed, 18 Mar 2020 21:34:15 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id a23so21106plm.1 for ; Wed, 18 Mar 2020 13:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=69DDz4/vG4oGSwLpYSfJUUGqnJ8PAp3rYp/b+qIzf3A=; b=lUw7dBDzt9zLE2sB7ngWiYrsTY4f7Z9iEpO4ClATU+RhK/XpPDr2qblvPlqsZayMZl /vSDoo4Rb4FULddOfv7qAodl8q2Ox6Rf/SxGz9iG8GOp1VsqETfgguMhm28Hdze231Oj vB3IlRCeX5nAL1DPyVRi8fe5DTOEpx3UL1btC4Yd5dpzt6GtZv3SHNKthvedscc4cbFD BAV7XlRUFID+sr5lyjg6uWDp5nKiu80XCRScwvYUwc9cY7CnclD3b0pbdf7j1SShVzpq gx0G83f2XsyTUp25JeEIpm6SS0renw3R3hi3vBLfRAUH24Fn6rm4BZ8CYRuDemUAaG3Q nLDA== 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=69DDz4/vG4oGSwLpYSfJUUGqnJ8PAp3rYp/b+qIzf3A=; b=GW/GPyEV5O4zcmGnaSFDApqyGdDBMdEbjrrDwZNptIknl/i5n5xr1X4sipwxgzgz7B R8wOIv6tAB1jSfVtNBc+K4wEvijvgzatOb9nPuspBihDm8oKySHQBbD5hppmPdWrLX/Y fXs8NaYgNCUrhFAP3tCpqfq+0hMJwC/j5hZg4OKL7wL2wAGeY4y4EFQ920nEYzzPqYDE xOXQet6b0qVuLlOYFyq68qTlcsTxm6hg9f74lJZWJLrmBOGq29plcbAaM7gFyfmpcUMW MtipiGtDqwBaNaKEityeypOgQdUP8ZsbHLGeK1P9yyNYeCSwk8vU8i2K8o6FSCP62R05 7H7g== X-Gm-Message-State: ANhLgQ2u7ZmmxUv+0Lqdnez1efw9M2E34jpxuGj8s7bK8zk8pAo13Wsk b0/BSVj44lccHOERrwjx2WA+wQ== X-Google-Smtp-Source: ADFU+vs+2Bb9G/DT5eCxLTOElWQ3DAPuGx9mOSmSUIPwa1tWrrHBKOqZS43ChMfhd4ekZvl7UMsCkA== X-Received: by 2002:a17:90a:e38b:: with SMTP id b11mr2975pjz.98.1584563654817; Wed, 18 Mar 2020 13:34:14 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id p2sm7627591pfb.41.2020.03.18.13.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 13:34:13 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org Date: Wed, 18 Mar 2020 13:29:55 -0700 Message-Id: <20200318202957.18121-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318202957.18121-1-stephen@networkplumber.org> References: <20200316235612.29854-1-stephen@networkplumber.org> <20200318202957.18121-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2 2/4] net/netvsc: handle receive packets during multi-channel setup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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