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: 3f75a02719 ("net/mlx4: drop scatter/gather support")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
This commit is contained in:
Adrien Mazarguil 2017-10-12 14:19:35 +02:00 committed by Ferruh Yigit
parent eacaac7bae
commit 67e6cce675
4 changed files with 8 additions and 11 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}