net/mlx5: add reference counter on DPDK Tx queues
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 92adbcd..276401d 100644 (file)
@@ -190,6 +190,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 {
        struct priv *priv = mlx5_get_priv(dev);
        unsigned int i;
+       int ret;
 
        priv_lock(priv);
        DEBUG("%p: closing device \"%s\"",
@@ -201,10 +202,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        priv_mac_addrs_disable(priv);
        priv_destroy_hash_rxqs(priv);
 
-       /* Remove flow director elements. */
-       priv_fdir_disable(priv);
-       priv_fdir_delete_filters_list(priv);
-
        /* Prevent crashes when queues are still in use. */
        dev->rx_pkt_burst = removed_rx_burst;
        dev->tx_pkt_burst = removed_tx_burst;
@@ -212,14 +209,14 @@ mlx5_dev_close(struct rte_eth_dev *dev)
                /* XXX race condition if mlx5_rx_burst() is still running. */
                usleep(1000);
                for (i = 0; (i != priv->rxqs_n); ++i) {
-                       struct rxq *rxq = (*priv->rxqs)[i];
-                       struct rxq_ctrl *rxq_ctrl;
+                       struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
+                       struct mlx5_rxq_ctrl *rxq_ctrl;
 
                        if (rxq == NULL)
                                continue;
-                       rxq_ctrl = container_of(rxq, struct rxq_ctrl, rxq);
+                       rxq_ctrl = container_of(rxq, struct mlx5_rxq_ctrl, rxq);
                        (*priv->rxqs)[i] = NULL;
-                       rxq_cleanup(rxq_ctrl);
+                       mlx5_rxq_cleanup(rxq_ctrl);
                        rte_free(rxq_ctrl);
                }
                priv->rxqs_n = 0;
@@ -228,17 +225,8 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        if (priv->txqs != NULL) {
                /* XXX race condition if mlx5_tx_burst() is still running. */
                usleep(1000);
-               for (i = 0; (i != priv->txqs_n); ++i) {
-                       struct txq *txq = (*priv->txqs)[i];
-                       struct txq_ctrl *txq_ctrl;
-
-                       if (txq == NULL)
-                               continue;
-                       txq_ctrl = container_of(txq, struct txq_ctrl, txq);
-                       (*priv->txqs)[i] = NULL;
-                       txq_cleanup(txq_ctrl);
-                       rte_free(txq_ctrl);
-               }
+               for (i = 0; (i != priv->txqs_n); ++i)
+                       mlx5_priv_txq_release(priv, i);
                priv->txqs_n = 0;
                priv->txqs = NULL;
        }
@@ -256,6 +244,21 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        if (priv->reta_idx != NULL)
                rte_free(priv->reta_idx);
        priv_socket_uninit(priv);
+       ret = mlx5_priv_rxq_ibv_verify(priv);
+       if (ret)
+               WARN("%p: some Verbs Rx queue still remain", (void *)priv);
+       ret = mlx5_priv_txq_ibv_verify(priv);
+       if (ret)
+               WARN("%p: some Verbs Tx queue still remain", (void *)priv);
+       ret = mlx5_priv_txq_verify(priv);
+       if (ret)
+               WARN("%p: some Tx Queues still remain", (void *)priv);
+       ret = priv_flow_verify(priv);
+       if (ret)
+               WARN("%p: some flows still remain", (void *)priv);
+       ret = priv_mr_verify(priv);
+       if (ret)
+               WARN("%p: some Memory Region still remain", (void *)priv);
        priv_unlock(priv);
        memset(priv, 0, sizeof(*priv));
 }
@@ -844,10 +847,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                claim_zero(priv_mac_addr_add(priv, 0,
                                             (const uint8_t (*)[ETHER_ADDR_LEN])
                                             mac.addr_bytes));
-               /* Initialize FD filters list. */
-               err = fdir_init_filters_list(priv);
-               if (err)
-                       goto port_error;
 #ifndef NDEBUG
                {
                        char ifname[IF_NAMESIZE];