net/sfc: store PCI address for represented entities
[dpdk.git] / drivers / net / mlx5 / mlx5_txq.c
index cd13eb9..92fbdab 100644 (file)
@@ -13,6 +13,7 @@
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <ethdev_driver.h>
+#include <rte_bus_pci.h>
 #include <rte_common.h>
 #include <rte_eal_paging.h>
 
@@ -23,6 +24,7 @@
 #include "mlx5_defs.h"
 #include "mlx5_utils.h"
 #include "mlx5.h"
+#include "mlx5_tx.h"
 #include "mlx5_rxtx.h"
 #include "mlx5_autoconf.h"
 
@@ -468,28 +470,21 @@ mlx5_tx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t idx,
 /**
  * DPDK callback to release a TX queue.
  *
- * @param dpdk_txq
- *   Generic TX queue pointer.
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param qid
+ *   Transmit queue index.
  */
 void
-mlx5_tx_queue_release(void *dpdk_txq)
+mlx5_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
 {
-       struct mlx5_txq_data *txq = (struct mlx5_txq_data *)dpdk_txq;
-       struct mlx5_txq_ctrl *txq_ctrl;
-       struct mlx5_priv *priv;
-       unsigned int i;
+       struct mlx5_txq_data *txq = dev->data->tx_queues[qid];
 
        if (txq == NULL)
                return;
-       txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
-       priv = txq_ctrl->priv;
-       for (i = 0; (i != priv->txqs_n); ++i)
-               if ((*priv->txqs)[i] == txq) {
-                       DRV_LOG(DEBUG, "port %u removing Tx queue %u from list",
-                               PORT_ID(priv), txq->idx);
-                       mlx5_txq_release(ETH_DEV(priv), i);
-                       break;
-               }
+       DRV_LOG(DEBUG, "port %u removing Tx queue %u from list",
+               dev->data->port_id, qid);
+       mlx5_txq_release(dev, qid);
 }
 
 /**
@@ -814,7 +809,7 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
        if (config->txqs_inline == MLX5_ARG_UNSET)
                txqs_inline =
 #if defined(RTE_ARCH_ARM64)
-               (priv->pci_dev->id.device_id ==
+               (priv->pci_dev && priv->pci_dev->id.device_id ==
                        PCI_DEVICE_ID_MELLANOX_CONNECTX5BF) ?
                        MLX5_INLINE_MAX_TXQS_BLUEFIELD :
 #endif
@@ -1244,7 +1239,7 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx)
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_txq_ctrl *txq_ctrl;
 
-       if (!(*priv->txqs)[idx])
+       if (priv->txqs == NULL || (*priv->txqs)[idx] == NULL)
                return 0;
        txq_ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
        if (__atomic_sub_fetch(&txq_ctrl->refcnt, 1, __ATOMIC_RELAXED) > 1)