From: Adrien Mazarguil Date: Thu, 12 Oct 2017 12:19:35 +0000 (+0200) Subject: net/mlx4: update Rx/Tx callbacks consistently X-Git-Tag: spdx-start~1351 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=67e6cce675cc73f15ea172490fdd26591ea6b0dc;p=dpdk.git net/mlx4: update Rx/Tx callbacks consistently 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: 3f75a0271941 ("net/mlx4: drop scatter/gather support") Signed-off-by: Adrien Mazarguil Acked-by: Nelio Laranjeiro --- diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index f02508a3f3..52f8d5126f 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 01fb195e5f..ebf2339d4e 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 bcb7b9490c..693db4f586 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 e0245b0de8..c1fdbaf4cd 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; }