From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id E0CEC2B8B for ; Fri, 23 Nov 2018 15:06:51 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id y139so11962927wmc.5 for ; Fri, 23 Nov 2018 06:06:51 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=Vi3FDV6C3YFeTePRyCeuZ0RziFeV33mqmWbh1D+iO3M=; b=IWRXSpJXbvcVH8SZCrCwoG20hHKUArWXG0CzOh3NYtrzIzCDvlE1W5NNlt04wr4br9 q0AlBo8XKU5EMi3ILRizb7Ig9av+ruQgDEYgSMz6eBM47hxviE+aFFaawTObroqD1lc0 l2fHYn/9mlSr5m29JilhXwTZN3uuiKgrTQxEdau70NF6S0Dg2xJ4Y6/46NJ4zzPyQwrA JAeURfh6xMx6+oohKv7l7746U5pK7WU2wljhrxUJctNjVdZhrgeAWV58C9eO1YyeWF67 IYpuPg+PhfxwtzVB9cxVehvvM5ndHmbVz+MI++l1FQDqO/hRsxtCrghhumLcW8aNwFhg al9A== X-Gm-Message-State: AA+aEWbaNUNXRIDQkwOXZrwOephSBgG27nA15RNCR7gJhCREPp7gWj6p EdN6FiBjthcpUqLJXMwLbh+cG2jV X-Google-Smtp-Source: AFSGD/VIkEpF7Zw36Ohke+/wxdY3bA54oxyQY1J+XgnFroY7FsL8y1d1gR78DM+D43+fAXkxRrxRLA== X-Received: by 2002:a1c:110b:: with SMTP id 11mr13649512wmr.83.1542982011148; Fri, 23 Nov 2018 06:06:51 -0800 (PST) Received: from localhost ([2a01:4b00:f419:6f00:8361:8946:ba2b:d556]) by smtp.gmail.com with ESMTPSA id z13sm15353213wrq.19.2018.11.23.06.06.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 06:06:50 -0800 (PST) From: Luca Boccassi To: stable@dpdk.org Cc: ktraynor@redhat.com Date: Fri, 23 Nov 2018 14:06:44 +0000 Message-Id: <20181123140644.24951-1-bluca@debian.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 18.08] net/vmxnet3: fix hot-unplug 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: , X-List-Received-Date: Fri, 23 Nov 2018 14:06:52 -0000 [ backported from upstream commit 6c99085d972b5f0fddf9f986ea8907ed5dafd086 ] The vmxnet3 driver can't call back into dev_close(), and possibly dev_stop(), in dev_uninit(). When dev_uninit() is called, anything that those routines would want to clean up has already been released. Further, for complete cleanup, it is necessary to release any of the queue resources during dev_close(). This allows a vmxnet3 device to be hot-unplugged without leaking queues. Also set RTE_ETH_DEV_CLOSE_REMOVE on close so that the port resources can be deallocated. Return EBUSY if remove is called before stop. Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver implementation") Cc: stable@dpdk.org Signed-off-by: Brian Russell Signed-off-by: Luca Boccassi --- Removed setting RTE_ETH_DEV_CLOSE_REMOVE which was added in 18.11. drivers/net/vmxnet3/vmxnet3_ethdev.c | 37 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 2613cd135..610b8c8ea 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -355,8 +355,10 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - if (hw->adapter_stopped == 0) - vmxnet3_dev_close(eth_dev); + if (hw->adapter_stopped == 0) { + PMD_INIT_LOG(DEBUG, "Device has not been closed."); + return -EBUSY; + } eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; @@ -803,7 +805,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); if (hw->adapter_stopped == 1) { - PMD_INIT_LOG(DEBUG, "Device already closed."); + PMD_INIT_LOG(DEBUG, "Device already stopped."); return; } @@ -827,7 +829,6 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) /* reset the device */ VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV); PMD_INIT_LOG(DEBUG, "Device reset."); - hw->adapter_stopped = 0; vmxnet3_dev_clear_queues(dev); @@ -837,6 +838,30 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) link.link_speed = ETH_SPEED_NUM_10G; link.link_autoneg = ETH_LINK_FIXED; rte_eth_linkstatus_set(dev, &link); + + hw->adapter_stopped = 1; +} + +static void +vmxnet3_free_queues(struct rte_eth_dev *dev) +{ + int i; + + PMD_INIT_FUNC_TRACE(); + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + void *rxq = dev->data->rx_queues[i]; + + vmxnet3_dev_rx_queue_release(rxq); + } + dev->data->nb_rx_queues = 0; + + for (i = 0; i < dev->data->nb_tx_queues; i++) { + void *txq = dev->data->tx_queues[i]; + + vmxnet3_dev_tx_queue_release(txq); + } + dev->data->nb_tx_queues = 0; } /* @@ -845,12 +870,10 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) static void vmxnet3_dev_close(struct rte_eth_dev *dev) { - struct vmxnet3_hw *hw = dev->data->dev_private; - PMD_INIT_FUNC_TRACE(); vmxnet3_dev_stop(dev); - hw->adapter_stopped = 1; + vmxnet3_free_queues(dev); } static void -- 2.19.1