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 5CA97A0559; Tue, 17 Mar 2020 00:56:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F279C1C0B1; Tue, 17 Mar 2020 00:56:25 +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 876511C066 for ; Tue, 17 Mar 2020 00:56:23 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id x7so10665088pgh.5 for ; Mon, 16 Mar 2020 16:56:23 -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=srYFBTLWB5SmBP/5uZe3cgSvMJLxiRlSEadbmpe0tAo=; b=BHCpypvz/S/SQbQyiLUgVOBZLvorv00sQ4d5cQY+/YM/KLlwpXYt4lbe12qeIJNaKq hVAPnu7YjsecxNhCOxiVkQ6ZiVa/cNtK+1pdciCOsJMzv5lVfoz4FkwFCXLzemV1AVGb CLQuTEzcYx9nTuHGK+ps1Y/C8SY5Irvr8A84Rh/Mv32cmT8nmGijEDgWD6d+ZhLfhywr nX53imP2ck8saH1apMtQ5svVg6otcQCYajOn1OEYm5gDmjD8j7AExTurj0XZYUeoIQ4q R3gQZ8ooXvPGinx3taUW4gtT4KUCVR5362cU2K+MftgX0qHHYQuAnHN/B+Dlz2CmyQ6h o46Q== 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=srYFBTLWB5SmBP/5uZe3cgSvMJLxiRlSEadbmpe0tAo=; b=GKSiHeE8fVw8DYgtnYfcWdr3CckzfDdmuVZQH8T+gwKldYYplfp7cBPwSr+/zWULWd KLnTrO0Rp/gP8ymBC7NSOXEqjOzpH1bW8nfWiaThUBLuQHy/dpveUvoKY2xR8LDt0bK9 4Ygd3KgAHL8bpKNAhJfrBR/hN1KwSd/HO6e2w1ESN1IGqQXDl7zWAS42d5gj7WwI/9Ji ofy+Txnd6N9x190Hvnn+bz6gIEzN575Lle9hQ984Q6zLHhH8FVmvbJbJdZMmp/N00WqQ 66M3igKiFpR3M66t/EAqBF7yOmQQZT6OchcdU6wdLzsHyy/mJVNgB3MFuXLzy+gP3eBl Bx1w== X-Gm-Message-State: ANhLgQ1k9EWAUTm3QE92DSNMIrKEmWr06tn+ii7te+vtg/skZcMCFb0V 0EVyIAoSyuT7gSiTuHFysekjE+ogpVo= X-Google-Smtp-Source: ADFU+vscf2WeTm7+QQYNFwbEP3a1IX6l8aDB8n1depes49G08Zjdu9aHqARfqM6xJhuryxv6jyNBFg== X-Received: by 2002:aa7:953b:: with SMTP id c27mr2203461pfp.201.1584402982039; Mon, 16 Mar 2020 16:56:22 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id m68sm838173pjb.0.2020.03.16.16.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 16:56:20 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , stable@dpdk.org Date: Mon, 16 Mar 2020 16:56:11 -0700 Message-Id: <20200316235612.29854-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316235612.29854-1-stephen@networkplumber.org> References: <20200316235612.29854-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/2] 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. Add a spinlock to ensure that two control operations are not attempted at once. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/netvsc/hn_ethdev.c | 1 + drivers/net/netvsc/hn_nvs.c | 40 ++++++++++++++++++++++++++++++++-- drivers/net/netvsc/hn_var.h | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 564620748daf..01e69de6f3e2 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -951,6 +951,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev) hv->latency = HN_CHAN_LATENCY_NS; hv->max_queues = 1; rte_spinlock_init(&hv->vf_lock); + rte_spinlock_init(&hv->nvs_lock); hv->vf_port = HN_INVALID_PORT; err = hn_parse_args(eth_dev); diff --git a/drivers/net/netvsc/hn_nvs.c b/drivers/net/netvsc/hn_nvs.c index 6b518685ab6f..f56692f4d605 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,28 @@ 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) +{ + int ret; + + rte_spinlock_lock(&hv->nvs_lock); + ret = __hn_nvs_execute(hv, req, reqlen, resp, resplen, type); + rte_spinlock_unlock(&hv->nvs_lock); + + return ret; +} + static int hn_nvs_doinit(struct hn_data *hv, uint32_t nvs_ver) { diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h index 05bc492511ec..7434ff19bfa5 100644 --- a/drivers/net/netvsc/hn_var.h +++ b/drivers/net/netvsc/hn_var.h @@ -97,6 +97,7 @@ struct hn_data { struct rte_vmbus_device *vmbus; struct hn_rx_queue *primary; rte_spinlock_t vf_lock; + rte_spinlock_t nvs_lock; uint16_t port_id; uint16_t vf_port; -- 2.20.1