]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx4: rely on ethdev for Tx/Rx queue arrays
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Fri, 1 Sep 2017 08:07:06 +0000 (10:07 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 00:49:48 +0000 (02:49 +0200)
Allocation and management of Tx/Rx queue arrays is done by wrappers at the
ethdev level. The resulting information is copied to the private structure
while configuring the device, where it is managed separately by the PMD.

This is redundant and consumes space in the private structure.

Relying more on ethdev also means there is no need to protect the PMD
against burst function calls while closing the device anymore.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
drivers/net/mlx4/mlx4.c
drivers/net/mlx4/mlx4.h
drivers/net/mlx4/mlx4_ethdev.c
drivers/net/mlx4/mlx4_flow.c
drivers/net/mlx4/mlx4_intr.c
drivers/net/mlx4/mlx4_rxq.c
drivers/net/mlx4/mlx4_txq.c

index 317d0e635b615216b6d37858d9a46201de74adad..b0849034fb2b3fea4968d551b53540d7a2ac01ed 100644 (file)
@@ -44,7 +44,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 /* Verbs headers do not support -pedantic. */
 #ifdef PEDANTIC
@@ -88,8 +87,6 @@ const char *pmd_mlx4_init_params[] = {
 /**
  * DPDK callback for Ethernet device configuration.
  *
- * Prepare the driver for a given number of TX and RX queues.
- *
  * @param dev
  *   Pointer to Ethernet device structure.
  *
@@ -99,22 +96,7 @@ const char *pmd_mlx4_init_params[] = {
 static int
 mlx4_dev_configure(struct rte_eth_dev *dev)
 {
-       struct priv *priv = dev->data->dev_private;
-       unsigned int rxqs_n = dev->data->nb_rx_queues;
-       unsigned int txqs_n = dev->data->nb_tx_queues;
-
-       priv->rxqs = (void *)dev->data->rx_queues;
-       priv->txqs = (void *)dev->data->tx_queues;
-       if (txqs_n != priv->txqs_n) {
-               INFO("%p: TX queues number update: %u -> %u",
-                    (void *)dev, priv->txqs_n, txqs_n);
-               priv->txqs_n = txqs_n;
-       }
-       if (rxqs_n != priv->rxqs_n) {
-               INFO("%p: Rx queues number update: %u -> %u",
-                    (void *)dev, priv->rxqs_n, rxqs_n);
-               priv->rxqs_n = rxqs_n;
-       }
+       (void)dev;
        return 0;
 }
 
@@ -196,7 +178,6 @@ static void
 mlx4_dev_close(struct rte_eth_dev *dev)
 {
        struct priv *priv = dev->data->dev_private;
-       void *tmp;
        unsigned int i;
 
        if (priv == NULL)
@@ -205,41 +186,12 @@ mlx4_dev_close(struct rte_eth_dev *dev)
              (void *)dev,
              ((priv->ctx != NULL) ? priv->ctx->device->name : ""));
        mlx4_mac_addr_del(priv);
-       /*
-        * Prevent crashes when queues are still in use. This is unfortunately
-        * still required for DPDK 1.3 because some programs (such as testpmd)
-        * never release them before closing the device.
-        */
        dev->rx_pkt_burst = mlx4_rx_burst_removed;
        dev->tx_pkt_burst = mlx4_tx_burst_removed;
-       if (priv->rxqs != NULL) {
-               /* XXX race condition if mlx4_rx_burst() is still running. */
-               usleep(1000);
-               for (i = 0; (i != priv->rxqs_n); ++i) {
-                       tmp = (*priv->rxqs)[i];
-                       if (tmp == NULL)
-                               continue;
-                       (*priv->rxqs)[i] = NULL;
-                       mlx4_rxq_cleanup(tmp);
-                       rte_free(tmp);
-               }
-               priv->rxqs_n = 0;
-               priv->rxqs = NULL;
-       }
-       if (priv->txqs != NULL) {
-               /* XXX race condition if mlx4_tx_burst() is still running. */
-               usleep(1000);
-               for (i = 0; (i != priv->txqs_n); ++i) {
-                       tmp = (*priv->txqs)[i];
-                       if (tmp == NULL)
-                               continue;
-                       (*priv->txqs)[i] = NULL;
-                       mlx4_txq_cleanup(tmp);
-                       rte_free(tmp);
-               }
-               priv->txqs_n = 0;
-               priv->txqs = NULL;
-       }
+       for (i = 0; i != dev->data->nb_rx_queues; ++i)
+               mlx4_rx_queue_release(dev->data->rx_queues[i]);
+       for (i = 0; i != dev->data->nb_tx_queues; ++i)
+               mlx4_tx_queue_release(dev->data->tx_queues[i]);
        if (priv->pd != NULL) {
                assert(priv->ctx != NULL);
                claim_zero(ibv_dealloc_pd(priv->pd));
index 1cd4db3f079c4c828459307328b80537c45b9442..93e5502c7114db16110dea5f39c1bd7266ba301a 100644 (file)
@@ -104,11 +104,6 @@ struct priv {
        unsigned int vf:1; /* This is a VF device. */
        unsigned int intr_alarm:1; /* An interrupt alarm is scheduled. */
        unsigned int isolated:1; /* Toggle isolated mode. */
-       /* RX/TX queues. */
-       unsigned int rxqs_n; /* RX queues array size. */
-       unsigned int txqs_n; /* TX queues array size. */
-       struct rxq *(*rxqs)[]; /* RX queues. */
-       struct txq *(*txqs)[]; /* TX queues. */
        struct rte_intr_handle intr_handle; /* Port interrupt handle. */
        struct rte_flow_drop *flow_drop_queue; /* Flow drop queue. */
        LIST_HEAD(mlx4_flows, rte_flow) flows;
index 5f1dba2ec65b989922c7130a735c56539813a8be..a9e8059b8e703b342626d703af8a09f28c71e805 100644 (file)
@@ -574,17 +574,14 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 void
 mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
-       struct priv *priv = dev->data->dev_private;
        struct rte_eth_stats tmp;
        unsigned int i;
        unsigned int idx;
 
-       if (priv == NULL)
-               return;
        memset(&tmp, 0, sizeof(tmp));
        /* Add software counters. */
-       for (i = 0; (i != priv->rxqs_n); ++i) {
-               struct rxq *rxq = (*priv->rxqs)[i];
+       for (i = 0; i != dev->data->nb_rx_queues; ++i) {
+               struct rxq *rxq = dev->data->rx_queues[i];
 
                if (rxq == NULL)
                        continue;
@@ -600,8 +597,8 @@ mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
                tmp.ierrors += rxq->stats.idropped;
                tmp.rx_nombuf += rxq->stats.rx_nombuf;
        }
-       for (i = 0; (i != priv->txqs_n); ++i) {
-               struct txq *txq = (*priv->txqs)[i];
+       for (i = 0; i != dev->data->nb_tx_queues; ++i) {
+               struct txq *txq = dev->data->tx_queues[i];
 
                if (txq == NULL)
                        continue;
@@ -627,25 +624,23 @@ mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 void
 mlx4_stats_reset(struct rte_eth_dev *dev)
 {
-       struct priv *priv = dev->data->dev_private;
        unsigned int i;
-       unsigned int idx;
 
-       if (priv == NULL)
-               return;
-       for (i = 0; (i != priv->rxqs_n); ++i) {
-               if ((*priv->rxqs)[i] == NULL)
-                       continue;
-               idx = (*priv->rxqs)[i]->stats.idx;
-               (*priv->rxqs)[i]->stats =
-                       (struct mlx4_rxq_stats){ .idx = idx };
+       for (i = 0; i != dev->data->nb_rx_queues; ++i) {
+               struct rxq *rxq = dev->data->rx_queues[i];
+
+               if (rxq)
+                       rxq->stats = (struct mlx4_rxq_stats){
+                               .idx = rxq->stats.idx,
+                       };
        }
-       for (i = 0; (i != priv->txqs_n); ++i) {
-               if ((*priv->txqs)[i] == NULL)
-                       continue;
-               idx = (*priv->txqs)[i]->stats.idx;
-               (*priv->txqs)[i]->stats =
-                       (struct mlx4_txq_stats){ .idx = idx };
+       for (i = 0; i != dev->data->nb_tx_queues; ++i) {
+               struct txq *txq = dev->data->tx_queues[i];
+
+               if (txq)
+                       txq->stats = (struct mlx4_txq_stats){
+                               .idx = txq->stats.idx,
+                       };
        }
 }
 
index e1775458d2fb55c61ca805f73cdf2d52c88be077..0885a91c255187f7b1104a0690dbb5788974f397 100644 (file)
@@ -691,7 +691,8 @@ mlx4_flow_prepare(struct priv *priv,
                                (const struct rte_flow_action_queue *)
                                actions->conf;
 
-                       if (!queue || (queue->index > (priv->rxqs_n - 1)))
+                       if (!queue || (queue->index >
+                                      (priv->dev->data->nb_rx_queues - 1)))
                                goto exit_action_not_supported;
                        action.queue = 1;
                } else {
@@ -841,7 +842,7 @@ mlx4_flow_create_action_queue(struct priv *priv,
        if (action->drop) {
                qp = priv->flow_drop_queue ? priv->flow_drop_queue->qp : NULL;
        } else {
-               struct rxq *rxq = (*priv->rxqs)[action->queue_id];
+               struct rxq *rxq = priv->dev->data->rx_queues[action->queue_id];
 
                qp = rxq->qp;
                rte_flow->qp = qp;
index 76d2e01f20b7a52ba613407237fb654ef9fb70c4..e3449ee26833bd60237a6e3eea5bee88b4569c09 100644 (file)
@@ -91,7 +91,7 @@ static int
 mlx4_rx_intr_vec_enable(struct priv *priv)
 {
        unsigned int i;
-       unsigned int rxqs_n = priv->rxqs_n;
+       unsigned int rxqs_n = priv->dev->data->nb_rx_queues;
        unsigned int n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID);
        unsigned int count = 0;
        struct rte_intr_handle *intr_handle = &priv->intr_handle;
@@ -105,7 +105,7 @@ mlx4_rx_intr_vec_enable(struct priv *priv)
                return -rte_errno;
        }
        for (i = 0; i != n; ++i) {
-               struct rxq *rxq = (*priv->rxqs)[i];
+               struct rxq *rxq = priv->dev->data->rx_queues[i];
 
                /* Skip queues that cannot request interrupts. */
                if (!rxq || !rxq->channel) {
@@ -324,8 +324,7 @@ error:
 int
 mlx4_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx)
 {
-       struct priv *priv = dev->data->dev_private;
-       struct rxq *rxq = (*priv->rxqs)[idx];
+       struct rxq *rxq = dev->data->rx_queues[idx];
        struct ibv_cq *ev_cq;
        void *ev_ctx;
        int ret;
@@ -361,8 +360,7 @@ mlx4_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx)
 int
 mlx4_rx_intr_enable(struct rte_eth_dev *dev, uint16_t idx)
 {
-       struct priv *priv = dev->data->dev_private;
-       struct rxq *rxq = (*priv->rxqs)[idx];
+       struct rxq *rxq = dev->data->rx_queues[idx];
        int ret;
 
        if (!rxq || !rxq->channel)
index 7f675a425d092a5fa102c99e514ff4fcc83626a1..409983ff71c4a738278af506515a9c4021078394 100644 (file)
@@ -403,15 +403,15 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                    struct rte_mempool *mp)
 {
        struct priv *priv = dev->data->dev_private;
-       struct rxq *rxq = (*priv->rxqs)[idx];
+       struct rxq *rxq = dev->data->rx_queues[idx];
        int ret;
 
        DEBUG("%p: configuring queue %u for %u descriptors",
              (void *)dev, idx, desc);
-       if (idx >= priv->rxqs_n) {
+       if (idx >= dev->data->nb_rx_queues) {
                rte_errno = EOVERFLOW;
                ERROR("%p: queue index out of range (%u >= %u)",
-                     (void *)dev, idx, priv->rxqs_n);
+                     (void *)dev, idx, dev->data->nb_rx_queues);
                return -rte_errno;
        }
        if (rxq != NULL) {
@@ -421,7 +421,7 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                        rte_errno = EEXIST;
                        return -rte_errno;
                }
-               (*priv->rxqs)[idx] = NULL;
+               dev->data->rx_queues[idx] = NULL;
                if (idx == 0)
                        mlx4_mac_addr_del(priv);
                mlx4_rxq_cleanup(rxq);
@@ -441,7 +441,7 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                rxq->stats.idx = idx;
                DEBUG("%p: adding Rx queue %p to list",
                      (void *)dev, (void *)rxq);
-               (*priv->rxqs)[idx] = rxq;
+               dev->data->rx_queues[idx] = rxq;
                /* Update receive callback. */
                dev->rx_pkt_burst = mlx4_rx_burst;
        }
@@ -464,11 +464,11 @@ mlx4_rx_queue_release(void *dpdk_rxq)
        if (rxq == NULL)
                return;
        priv = rxq->priv;
-       for (i = 0; (i != priv->rxqs_n); ++i)
-               if ((*priv->rxqs)[i] == rxq) {
+       for (i = 0; i != priv->dev->data->nb_rx_queues; ++i)
+               if (priv->dev->data->rx_queues[i] == rxq) {
                        DEBUG("%p: removing Rx queue %p from list",
                              (void *)priv->dev, (void *)rxq);
-                       (*priv->rxqs)[i] = NULL;
+                       priv->dev->data->rx_queues[i] = NULL;
                        if (i == 0)
                                mlx4_mac_addr_del(priv);
                        break;
@@ -522,8 +522,8 @@ mlx4_mac_addr_add(struct priv *priv)
                return 0;
        if (priv->isolated)
                return 0;
-       if (*priv->rxqs && (*priv->rxqs)[0])
-               rxq = (*priv->rxqs)[0];
+       if (priv->dev->data->rx_queues && priv->dev->data->rx_queues[0])
+               rxq = priv->dev->data->rx_queues[0];
        else
                return 0;
 
index 945833bad2796cbf24188808015899b6685f9c1d..e0245b0de84d80fb387905184171619c3cc2a04a 100644 (file)
@@ -401,15 +401,15 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                    unsigned int socket, const struct rte_eth_txconf *conf)
 {
        struct priv *priv = dev->data->dev_private;
-       struct txq *txq = (*priv->txqs)[idx];
+       struct txq *txq = dev->data->tx_queues[idx];
        int ret;
 
        DEBUG("%p: configuring queue %u for %u descriptors",
              (void *)dev, idx, desc);
-       if (idx >= priv->txqs_n) {
+       if (idx >= dev->data->nb_tx_queues) {
                rte_errno = EOVERFLOW;
                ERROR("%p: queue index out of range (%u >= %u)",
-                     (void *)dev, idx, priv->txqs_n);
+                     (void *)dev, idx, dev->data->nb_tx_queues);
                return -rte_errno;
        }
        if (txq != NULL) {
@@ -419,7 +419,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                        rte_errno = EEXIST;
                        return -rte_errno;
                }
-               (*priv->txqs)[idx] = NULL;
+               dev->data->tx_queues[idx] = NULL;
                mlx4_txq_cleanup(txq);
        } else {
                txq = rte_calloc_socket("TXQ", 1, sizeof(*txq), 0, socket);
@@ -437,7 +437,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                txq->stats.idx = idx;
                DEBUG("%p: adding Tx queue %p to list",
                      (void *)dev, (void *)txq);
-               (*priv->txqs)[idx] = txq;
+               dev->data->tx_queues[idx] = txq;
                /* Update send callback. */
                dev->tx_pkt_burst = mlx4_tx_burst;
        }
@@ -460,11 +460,11 @@ mlx4_tx_queue_release(void *dpdk_txq)
        if (txq == NULL)
                return;
        priv = txq->priv;
-       for (i = 0; (i != priv->txqs_n); ++i)
-               if ((*priv->txqs)[i] == txq) {
+       for (i = 0; i != priv->dev->data->nb_tx_queues; ++i)
+               if (priv->dev->data->tx_queues[i] == txq) {
                        DEBUG("%p: removing Tx queue %p from list",
                              (void *)priv->dev, (void *)txq);
-                       (*priv->txqs)[i] = NULL;
+                       priv->dev->data->tx_queues[i] = NULL;
                        break;
                }
        mlx4_txq_cleanup(txq);