drivers/net: set close behaviour flag at probing
authorThomas Monjalon <thomas@monjalon.net>
Sun, 11 Nov 2018 22:46:11 +0000 (23:46 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 13 Nov 2018 23:35:53 +0000 (00:35 +0100)
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")
Fixes: 6c99085d972b ("net/vmxnet3: fix hot-unplug")
Fixes: 4d7877fde2ef ("net/ena: remove resources when port is being closed")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/ena/ena_ethdev.c
drivers/net/mlx5/mlx5.c
drivers/net/vmxnet3/vmxnet3_ethdev.c

index abe1e7b..05a4fbe 100644 (file)
@@ -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);
index ed1fcfc..9e5cab1 100644 (file)
@@ -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;
index 84acd9d..93e5de9 100644 (file)
@@ -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