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 DA9EBA057D; Wed, 18 Mar 2020 21:34:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 756491C02A; Wed, 18 Mar 2020 21:34:19 +0100 (CET) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id 69F961B203 for ; Wed, 18 Mar 2020 21:34:16 +0100 (CET) Received: by mail-pj1-f68.google.com with SMTP id l36so1845558pjb.3 for ; Wed, 18 Mar 2020 13:34:16 -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=ozZnXIhQ9fjxnFqG0S5PrS5yEVejWDxgOj+qYuLZXzXIdtEc8KCIpUBBTcXh9AKTUR SiPnAxjgGJgHCr2MnV0/3vZUNvYSI2VUV6eICS8IszZKg+6cGr5IRmmsVHZFVKSjC2oX QSmvRiug2+hLau3DLkY9+3fP44K75iP3VVC4TuKd0ioRtxQw7G52hBvt/GY/QUIR0uyC soe6ozH7qOK4Z5YtD2y2ofHC58vumI1NUgPlmyt5JNM+ZAm4hF9MWnBYCREoBVErbrMJ 3XudfdV6j85xIlKbzvalwyWgzWv4YvI82fmqlce4byZA2BPts95Z7jRpuy6WclnEivoH yl1Q== X-Gm-Message-State: ANhLgQ0TfNb8c5LOjQgiaD/wmzc0OPoXTbtewIRwqkNKFPBjulV+J7Yr O3BfPoEpCCIAcbfCvhxvjDoVXjVfy/Q= 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-dev] [PATCH v2 2/4] net/netvsc: handle receive packets during multi-channel setup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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