net/mlx5: refactor Rx data path
[dpdk.git] / drivers / net / mlx5 / mlx5_ethdev.c
index 280a90a..16b05d3 100644 (file)
@@ -623,8 +623,7 @@ mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 
        };
 
-       if (dev->rx_pkt_burst == mlx5_rx_burst ||
-           dev->rx_pkt_burst == mlx5_rx_burst_sp)
+       if (dev->rx_pkt_burst == mlx5_rx_burst)
                return ptypes;
        return NULL;
 }
@@ -762,19 +761,11 @@ mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
                mb_len = rte_pktmbuf_data_room_size(rxq->mp);
                assert(mb_len >= RTE_PKTMBUF_HEADROOM);
                sp = (max_frame_len > (mb_len - RTE_PKTMBUF_HEADROOM));
-               /* Provide new values to rxq_setup(). */
-               dev->data->dev_conf.rxmode.jumbo_frame = sp;
-               dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame_len;
-               ret = rxq_rehash(dev, rxq);
-               if (ret) {
-                       /* Force SP RX if that queue requires it and abort. */
-                       if (rxq->sp)
-                               rx_func = mlx5_rx_burst_sp;
-                       break;
+               if (sp) {
+                       ERROR("%p: RX scatter is not supported", (void *)dev);
+                       ret = ENOTSUP;
+                       goto out;
                }
-               /* Scattered burst function takes priority. */
-               if (rxq->sp)
-                       rx_func = mlx5_rx_burst_sp;
        }
        /* Burst functions can now be called again. */
        rte_wmb();
@@ -1103,23 +1094,13 @@ priv_set_link(struct priv *priv, int up)
 {
        struct rte_eth_dev *dev = priv->dev;
        int err;
-       unsigned int i;
 
        if (up) {
                err = priv_set_flags(priv, ~IFF_UP, IFF_UP);
                if (err)
                        return err;
-               for (i = 0; i < priv->rxqs_n; i++)
-                       if ((*priv->rxqs)[i]->sp)
-                               break;
-               /* Check if an sp queue exists.
-                * Note: Some old frames might be received.
-                */
-               if (i == priv->rxqs_n)
-                       dev->rx_pkt_burst = mlx5_rx_burst;
-               else
-                       dev->rx_pkt_burst = mlx5_rx_burst_sp;
-               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)
@@ -1251,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;
@@ -1305,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;
@@ -1322,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;
+}