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 350B5A057D for ; Wed, 18 Mar 2020 21:51:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F00B51C027; Wed, 18 Mar 2020 21:51:19 +0100 (CET) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 72F602C23 for ; Wed, 18 Mar 2020 21:51:16 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id m15so14326467pgv.12 for ; Wed, 18 Mar 2020 13:51: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=dJfj2RX9LFZ96pcnxOOpFahreZo/rQK18a36rBKDWJ3BiUox1btMyaGkRJK8Ix0KnB 7/DQ38WgaFCsQpqSlwgLIPC9qNiLwGibMc4wda6TEGFktKlF/1TBlXrf0KLawihLEnB9 h3CAL6kpNBONzQCmsdleD5reNUaaHwSJeZTvC2nwsJhhuU7a3twiJfQCNKivjIf45cFq OYpFbrDjTP6uF+Sk1Nx1FulJYvL4SLNpSsFbkY1krWumNCPf9NLMbhQlFZrMRGWWbRLg avbTctfN2XR1C9vnhd6NSF74gg3r6rzFTnfMb3cCliVMWtYjDmoKe2Wk4wLRa4A+mCAD RIoQ== 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=WrF755ZwLthn5Dskl2K99hujVE1/pb2j5oPIDI6reZ/NXImnfsqDnSvZaTjTa4Fdtk IyuRYknNiLCiBCIZWeLD/gqKSs2g3sJxg4I3IKPaoqsGK3RIUwhgSQNwnZA34ZhWaAqZ 8Nqbjh+EMsasv1C5FhBW1QNJazK62xLLt5fQrL4J00ihvnf/vtfYEzISrLOPZHm+Ee0J qwtxZ3HLZjAOrSxt0WTXz7zqhVqcvBz3t+zm59pcDfUH8Wu2gpXsAX4NbjxkMpcU/82o LpIopuBGh6AkLJ8H5SrOHBKjd5FJeCuot52JFtjF3XNcG62rql22Up5kTXgVG3NGCcxp y5nQ== X-Gm-Message-State: ANhLgQ2XyLwGLDwZRzOdSCmgy9fE1S7VCoZOiHb8+NVkmUBp9bbY6BeG ELVuxZi7zeFecGY+bYo9XNkB6OMZI84= X-Google-Smtp-Source: ADFU+vsEjm8XUEvjNhSJYZSSMOJfVnDtAOmel9w7bWxOvQY5Mxh1jsepWAkZss2Y7/VaH0QhKpc4Kw== X-Received: by 2002:a05:6a00:42:: with SMTP id i2mr176524pfk.108.1584564675448; Wed, 18 Mar 2020 13:51:15 -0700 (PDT) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id e80sm7800150pfh.117.2020.03.18.13.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 13:51:14 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org Date: Wed, 18 Mar 2020 13:51:02 -0700 Message-Id: <20200318205104.22486-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318205104.22486-1-stephen@networkplumber.org> References: <20200316235612.29854-1-stephen@networkplumber.org> <20200318205104.22486-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v3 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