net/mlx5: refactor Rx data path
[dpdk.git] / drivers / net / mlx5 / mlx5_ethdev.c
index ca57021..16b05d3 100644 (file)
@@ -1099,8 +1099,8 @@ priv_set_link(struct priv *priv, int up)
                err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
                if (err)
                        return err;
-               dev->rx_pkt_burst = mlx5_rx_burst;
-               dev->tx_pkt_burst = mlx5_tx_burst;
+               priv_select_tx_function(priv);
+               priv_select_rx_function(priv);
        } else {
                err = priv_set_flags(priv, ~IFF_UP, ~IFF_UP);
                if (err)
@@ -1232,34 +1232,40 @@ mlx5_secondary_data_setup(struct priv *priv)
        /* TX queues. */
        for (i = 0; i != nb_tx_queues; ++i) {
                struct txq *primary_txq = (*sd->primary_priv->txqs)[i];
-               struct txq *txq;
+               struct txq_ctrl *primary_txq_ctrl;
+               struct txq_ctrl *txq_ctrl;
 
                if (primary_txq == NULL)
                        continue;
-               txq = rte_calloc_socket("TXQ", 1, sizeof(*txq), 0,
-                                       primary_txq->socket);
-               if (txq != NULL) {
+               primary_txq_ctrl = container_of(primary_txq,
+                                               struct txq_ctrl, txq);
+               txq_ctrl = rte_calloc_socket("TXQ", 1, sizeof(*txq_ctrl), 0,
+                                            primary_txq_ctrl->socket);
+               if (txq_ctrl != NULL) {
                        if (txq_setup(priv->dev,
-                                     txq,
+                                     primary_txq_ctrl,
                                      primary_txq->elts_n,
-                                     primary_txq->socket,
+                                     primary_txq_ctrl->socket,
                                      NULL) == 0) {
-                               txq->stats.idx = primary_txq->stats.idx;
-                               tx_queues[i] = txq;
+                               txq_ctrl->txq.stats.idx =
+                                       primary_txq->stats.idx;
+                               tx_queues[i] = &txq_ctrl->txq;
                                continue;
                        }
-                       rte_free(txq);
+                       rte_free(txq_ctrl);
                }
                while (i) {
-                       txq = tx_queues[--i];
-                       txq_cleanup(txq);
-                       rte_free(txq);
+                       txq_ctrl = tx_queues[--i];
+                       txq_cleanup(txq_ctrl);
+                       rte_free(txq_ctrl);
                }
                goto error;
        }
        /* RX queues. */
        for (i = 0; i != nb_rx_queues; ++i) {
-               struct rxq *primary_rxq = (*sd->primary_priv->rxqs)[i];
+               struct rxq_ctrl *primary_rxq =
+                       container_of((*sd->primary_priv->rxqs)[i],
+                                    struct rxq_ctrl, rxq);
 
                if (primary_rxq == NULL)
                        continue;
@@ -1286,13 +1292,11 @@ mlx5_secondary_data_setup(struct priv *priv)
        rte_mb();
        priv->dev->data = &sd->data;
        rte_mb();
-       priv->dev->tx_pkt_burst = mlx5_tx_burst;
-       priv->dev->rx_pkt_burst = removed_rx_burst;
+       priv_select_tx_function(priv);
+       priv_select_rx_function(priv);
        priv_unlock(priv);
 end:
        /* More sanity checks. */
-       assert(priv->dev->tx_pkt_burst == mlx5_tx_burst);
-       assert(priv->dev->rx_pkt_burst == removed_rx_burst);
        assert(priv->dev->data == &sd->data);
        rte_spinlock_unlock(&sd->lock);
        return priv;
@@ -1303,3 +1307,27 @@ error:
        rte_spinlock_unlock(&sd->lock);
        return NULL;
 }
+
+/**
+ * Configure the TX function to use.
+ *
+ * @param priv
+ *   Pointer to private structure.
+ */
+void
+priv_select_tx_function(struct priv *priv)
+{
+       priv->dev->tx_pkt_burst = mlx5_tx_burst;
+}
+
+/**
+ * Configure the RX function to use.
+ *
+ * @param priv
+ *   Pointer to private structure.
+ */
+void
+priv_select_rx_function(struct priv *priv)
+{
+       priv->dev->rx_pkt_burst = mlx5_rx_burst;
+}