net/mlx5: select Rx/Tx callbacks when starting device
authorYongseok Koh <yskoh@mellanox.com>
Thu, 6 Jul 2017 18:41:09 +0000 (11:41 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 7 Jul 2017 09:55:47 +0000 (11:55 +0200)
The callbacks are global to a device but the selection is made every queue
configuration, which is redundant.

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
drivers/net/mlx5/mlx5_ethdev.c
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mlx5/mlx5_trigger.c
drivers/net/mlx5/mlx5_txq.c

index 039335e..54c4c6c 100644 (file)
@@ -923,8 +923,6 @@ mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
        struct priv *priv = dev->data->dev_private;
        int ret = 0;
        unsigned int i;
-       uint16_t (*rx_func)(void *, struct rte_mbuf **, uint16_t) =
-               mlx5_rx_burst;
        unsigned int max_frame_len;
        int rehash;
        int restart = priv->started;
@@ -944,7 +942,7 @@ mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
        /* Temporarily replace RX handler with a fake one, assuming it has not
         * been copied elsewhere. */
        dev->rx_pkt_burst = removed_rx_burst;
-       /* Make sure everyone has left mlx5_rx_burst() and uses
+       /* Make sure everyone has left dev->rx_pkt_burst() and uses
         * removed_rx_burst() instead. */
        rte_wmb();
        usleep(1000);
@@ -1018,17 +1016,13 @@ recover:
                /* Double fault, disable RX. */
                break;
        }
-       /*
-        * Use a safe RX burst function in case of error, otherwise mimic
-        * mlx5_dev_start().
-        */
+       /* Mimic mlx5_dev_start(). */
        if (ret) {
                ERROR("unable to reconfigure RX queues, RX disabled");
-               rx_func = removed_rx_burst;
        } else if (restart &&
-                !rehash &&
-                !priv_create_hash_rxqs(priv) &&
-                !priv_rehash_flows(priv)) {
+                  !rehash &&
+                  !priv_create_hash_rxqs(priv) &&
+                  !priv_rehash_flows(priv)) {
                if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_NONE)
                        priv_fdir_enable(priv);
                priv_dev_interrupt_handler_install(priv, dev);
@@ -1036,7 +1030,12 @@ recover:
        priv->mtu = mtu;
        /* Burst functions can now be called again. */
        rte_wmb();
-       dev->rx_pkt_burst = rx_func;
+       /*
+        * Use a safe RX burst function in case of error, otherwise select RX
+        * burst function again.
+        */
+       if (!ret)
+               priv_select_rx_function(priv);
 out:
        priv_unlock(priv);
        assert(ret >= 0);
index 22be999..98b20eb 100644 (file)
@@ -1226,8 +1226,6 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                DEBUG("%p: adding RX queue %p to list",
                      (void *)dev, (void *)rxq_ctrl);
                (*priv->rxqs)[idx] = &rxq_ctrl->rxq;
-               /* Update receive callback. */
-               priv_select_rx_function(priv);
        }
        priv_unlock(priv);
        return -ret;
index 40f23da..595a9e0 100644 (file)
@@ -72,6 +72,9 @@ mlx5_dev_start(struct rte_eth_dev *dev)
                priv_unlock(priv);
                return 0;
        }
+       /* Update Rx/Tx callback. */
+       priv_select_tx_function(priv);
+       priv_select_rx_function(priv);
        DEBUG("%p: allocating and configuring hash RX queues", (void *)dev);
        err = priv_create_hash_rxqs(priv);
        if (!err)
index ac9dfc5..03e23f5 100644 (file)
@@ -496,8 +496,6 @@ mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                DEBUG("%p: adding TX queue %p to list",
                      (void *)dev, (void *)txq_ctrl);
                (*priv->txqs)[idx] = &txq_ctrl->txq;
-               /* Update send callback. */
-               priv_select_tx_function(priv);
        }
        priv_unlock(priv);
        return -ret;