Although their "removed" version acts as a safety against unexpected bursts while queues are being modified by the control path, these callbacks are set per device instead of per queue. It makes sense to update them during start/stop/close cycles instead of queue setup.
As a side effect, this commit addresses a bug left over from a prior commit: bringing the link down causes the "removed" Tx callback to be used, however the normal callback is not restored when bringing it back up, preventing the application from sending traffic at all. Updating callbacks for a link change is not necessary as bringing the netdevice down is normally enough to prevent traffic from flowing in. Fixes: a4951cb98fdf ("net/mlx4: drop scatter/gather support") Signed-off-by: Adrien Mazarguil <adrien.mazarg...@6wind.com> Acked-by: Nelio Laranjeiro <nelio.laranje...@6wind.com> --- drivers/net/mlx4/mlx4.c | 11 ++++++++--- drivers/net/mlx4/mlx4_ethdev.c | 4 ---- drivers/net/mlx4/mlx4_rxq.c | 2 -- drivers/net/mlx4/mlx4_txq.c | 2 -- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index f02508a..52f8d51 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -149,6 +149,9 @@ mlx4_dev_start(struct rte_eth_dev *dev) error.message ? error.message : "(unspecified)"); goto err; } + rte_wmb(); + dev->tx_pkt_burst = mlx4_tx_burst; + dev->rx_pkt_burst = mlx4_rx_burst; return 0; err: /* Rollback. */ @@ -173,6 +176,9 @@ mlx4_dev_stop(struct rte_eth_dev *dev) return; DEBUG("%p: detaching flows from all RX queues", (void *)dev); priv->started = 0; + dev->tx_pkt_burst = mlx4_tx_burst_removed; + dev->rx_pkt_burst = mlx4_rx_burst_removed; + rte_wmb(); mlx4_flow_sync(priv, NULL); mlx4_intr_uninstall(priv); } @@ -191,14 +197,13 @@ mlx4_dev_close(struct rte_eth_dev *dev) struct priv *priv = dev->data->dev_private; unsigned int i; - if (priv == NULL) - return; DEBUG("%p: closing device \"%s\"", (void *)dev, ((priv->ctx != NULL) ? priv->ctx->device->name : "")); - mlx4_flow_clean(priv); dev->rx_pkt_burst = mlx4_rx_burst_removed; dev->tx_pkt_burst = mlx4_tx_burst_removed; + rte_wmb(); + mlx4_flow_clean(priv); 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) diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index 01fb195..ebf2339 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -467,20 +467,16 @@ mlx4_set_flags(struct priv *priv, unsigned int keep, unsigned int flags) static int mlx4_dev_set_link(struct priv *priv, int up) { - struct rte_eth_dev *dev = priv->dev; int err; if (up) { err = mlx4_set_flags(priv, ~IFF_UP, IFF_UP); if (err) return err; - dev->rx_pkt_burst = mlx4_rx_burst; } else { err = mlx4_set_flags(priv, ~IFF_UP, ~IFF_UP); if (err) return err; - dev->rx_pkt_burst = mlx4_rx_burst_removed; - dev->tx_pkt_burst = mlx4_tx_burst_removed; } return 0; } diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index bcb7b94..693db4f 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -436,8 +436,6 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, rte_free(rxq); return ret; } - /* Update receive callback. */ - dev->rx_pkt_burst = mlx4_rx_burst; } return ret; } diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index e0245b0..c1fdbaf 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -438,8 +438,6 @@ mlx4_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); dev->data->tx_queues[idx] = txq; - /* Update send callback. */ - dev->tx_pkt_burst = mlx4_tx_burst; } return ret; } -- 2.1.4