From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 49216201 for ; Sun, 11 Nov 2018 23:46:33 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C03B121440; Sun, 11 Nov 2018 17:46:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 11 Nov 2018 17:46:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=m/5PBhTzE6gKvQ7xK+WNNz9 hy2soa53xFodbm6tjYuk=; b=iQysd0jvVnphg+ljwyxBb1Vu52rrGRp2x9rsu3S lKliZ2OgcqPX4b5lziwB13XcrnXi3i7105YPH/9O3WiWIKFnoXoqTEzBVOEhI12D 7PwyYE9iuwHf/P+ESTVXC/Fisv9nBObj2Wq97lE/4163ZZI0AGz0mC4FZZkBqgm3 baYI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=m/5PBhTzE6gKvQ7xK +WNNz9hy2soa53xFodbm6tjYuk=; b=ttvNP8OOwGFdH/Zc3azZe5v8QVJtfS7ia rcCvlInTOl4QBLKDmq8PscYr93flf6CwydnvEi+FDT1N/y3XF+gYf90g+NgV2Gjd iUySn2aFrseb0XTU8w0zHmC5eZaLmZSCiATAzUgTBdpXnlYGaJQRP+oMbDFD9qya 9FwNn2Bd556gP8BBzy2h60z44pwYTPUeheArpeE+xSo+eTjR1btZeMl4ezOmjxo0 DhaR1wadQ5d4qcN1KGTLPXIEr3kVZO4wz2Hcx5Frzgvf62pH+6cRX5sRxs+Lkdie UU9xOanmzOQQGxb3sEeeDSDLAD8k5dG6EyjKQIbSe2oNbsdqg+luA== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id BF65AE4393; Sun, 11 Nov 2018 17:46:30 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ophirmu@mellanox.com, bluca@debian.org, mk@semihalf.com Date: Sun, 11 Nov 2018 23:46:11 +0100 Message-Id: <20181111224611.19234-1-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] drivers/net: set close behaviour flag at probing 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: , X-List-Received-Date: Sun, 11 Nov 2018 22:46:33 -0000 The ethdev flag RTE_ETH_DEV_CLOSE_REMOVE is set for drivers having migrated to the new behaviour of rte_eth_dev_close(). As any other flag, it can be useful to know about its value as soon as the port is probed. Unfortunately, it was set inside the close operation, just before being erased by memset() in rte_eth_dev_release_port(). The flag assignment is moved to the probing stage, so it can be checked by the application in order to anticipate the behaviour. Fixes: 42603bbdb58e ("net/mlx5: release port on close") Cc: ophirmu@mellanox.com Fixes: 6c99085d972b ("net/vmxnet3: fix hot-unplug") Cc: bluca@debian.org Fixes: 4d7877fde2ef ("net/ena: remove resources when port is being closed") Cc: mk@semihalf.com Signed-off-by: Thomas Monjalon --- drivers/net/ena/ena_ethdev.c | 11 ++++++----- drivers/net/mlx5/mlx5.c | 7 ++----- drivers/net/vmxnet3/vmxnet3_ethdev.c | 9 +++------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index abe1e7bd0..05a4fbe0e 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -529,11 +529,6 @@ static void ena_close(struct rte_eth_dev *dev) ena_interrupt_handler_rte, adapter); - /* - * Pass the information to the rte_eth_dev_close() that it should also - * release the private port resources. - */ - dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; /* * MAC is not allocated dynamically. Setting NULL should prevent from * release of the resource in the rte_eth_dev_release_port(). @@ -1666,6 +1661,12 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev) ether_addr_copy((struct ether_addr *)get_feat_ctx.dev_attr.mac_addr, (struct ether_addr *)adapter->mac_addr); + /* + * Pass the information to the rte_eth_dev_close() that it should also + * release the private port resources. + */ + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + adapter->drv_stats = rte_zmalloc("adapter stats", sizeof(*adapter->drv_stats), RTE_CACHE_LINE_SIZE); diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index ed1fcfc74..9e5cab169 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -346,11 +346,6 @@ mlx5_dev_close(struct rte_eth_dev *dev) } memset(priv, 0, sizeof(*priv)); priv->domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID; - /* - * flag to rte_eth_dev_close() that it should release the port resources - * (calling rte_eth_dev_release_port()) in addition to closing it. - */ - dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; /* * Reset mac_addrs to NULL such that it is not freed as part of * rte_eth_dev_release_port(). mac_addrs is part of dev_private so @@ -1114,6 +1109,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err = ENOMEM; goto error; } + /* Flag to call rte_eth_dev_release_port() in rte_eth_dev_close(). */ + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; if (priv->representor) { eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR; eth_dev->data->representor_id = priv->representor_id; diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 84acd9dbb..93e5de9a7 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -318,6 +318,9 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev) hw->perm_addr[0], hw->perm_addr[1], hw->perm_addr[2], hw->perm_addr[3], hw->perm_addr[4], hw->perm_addr[5]); + /* Flag to call rte_eth_dev_release_port() in rte_eth_dev_close(). */ + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + /* Put device in Quiesce Mode */ VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_QUIESCE_DEV); @@ -876,12 +879,6 @@ vmxnet3_dev_close(struct rte_eth_dev *dev) vmxnet3_dev_stop(dev); vmxnet3_free_queues(dev); - - /* - * flag to rte_eth_dev_close() that it should release the port resources - * (calling rte_eth_dev_release_port()) in addition to closing it. - */ - dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; } static void -- 2.19.0