net/mlx4: fix Rx resource leak in case of error
When creation of a flow rule fails during dev_start(), the usage count of the common RSS context is not decremented, which triggers an assertion failure in debug mode during dev_close(). This is addressed by tracking the initialization status of the common RSS context in order to add missing cleanup code. A similar issue exists in mlx4_rxq_attach(), where usage count is incremented on a Rx queue but not released in case of error. This may lead to the above issue since RSS contexts created by flow rules attach themselves to Rx queues, incrementing their usage count. Fixes: 5697a4142107 ("net/mlx4: relax Rx queue configuration order") Cc: stable@dpdk.org Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
This commit is contained in:
parent
6f2f4948b2
commit
84a684862f
@ -61,6 +61,8 @@ const char *pmd_mlx4_init_params[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void mlx4_dev_stop(struct rte_eth_dev *dev);
|
||||
|
||||
/**
|
||||
* DPDK callback for Ethernet device configuration.
|
||||
*
|
||||
@ -143,8 +145,7 @@ mlx4_dev_start(struct rte_eth_dev *dev)
|
||||
dev->rx_pkt_burst = mlx4_rx_burst;
|
||||
return 0;
|
||||
err:
|
||||
/* Rollback. */
|
||||
priv->started = 0;
|
||||
mlx4_dev_stop(dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -194,6 +195,7 @@ mlx4_dev_close(struct rte_eth_dev *dev)
|
||||
dev->tx_pkt_burst = mlx4_tx_burst_removed;
|
||||
rte_wmb();
|
||||
mlx4_flow_clean(priv);
|
||||
mlx4_rss_deinit(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)
|
||||
|
@ -103,6 +103,7 @@ struct priv {
|
||||
uint32_t vf:1; /**< This is a VF device. */
|
||||
uint32_t intr_alarm:1; /**< An interrupt alarm is scheduled. */
|
||||
uint32_t isolated:1; /**< Toggle isolated mode. */
|
||||
uint32_t rss_init:1; /**< Common RSS context is initialized. */
|
||||
uint32_t hw_csum:1; /**< Checksum offload is supported. */
|
||||
uint32_t hw_csum_l2tun:1; /**< Checksum support for L2 tunnels. */
|
||||
uint32_t hw_fcs_strip:1; /**< FCS stripping toggling is supported. */
|
||||
|
@ -336,6 +336,8 @@ mlx4_rss_init(struct priv *priv)
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
if (priv->rss_init)
|
||||
return 0;
|
||||
/* Prepare range for RSS contexts before creating the first WQ. */
|
||||
ret = mlx4_glue->dv_set_context_attr
|
||||
(priv->ctx,
|
||||
@ -418,6 +420,7 @@ wq_num_check:
|
||||
}
|
||||
wq_num_prev = wq_num;
|
||||
}
|
||||
priv->rss_init = 1;
|
||||
return 0;
|
||||
error:
|
||||
ERROR("cannot initialize common RSS resources (queue %u): %s: %s",
|
||||
@ -446,6 +449,8 @@ mlx4_rss_deinit(struct priv *priv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!priv->rss_init)
|
||||
return;
|
||||
for (i = 0; i != priv->dev->data->nb_rx_queues; ++i) {
|
||||
struct rxq *rxq = priv->dev->data->rx_queues[i];
|
||||
|
||||
@ -454,6 +459,7 @@ mlx4_rss_deinit(struct priv *priv)
|
||||
mlx4_rxq_detach(rxq);
|
||||
}
|
||||
}
|
||||
priv->rss_init = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -606,6 +612,7 @@ error:
|
||||
claim_zero(mlx4_glue->destroy_wq(wq));
|
||||
if (cq)
|
||||
claim_zero(mlx4_glue->destroy_cq(cq));
|
||||
--rxq->usecnt;
|
||||
rte_errno = ret;
|
||||
ERROR("error while attaching Rx queue %p: %s: %s",
|
||||
(void *)rxq, msg, strerror(ret));
|
||||
|
Loading…
x
Reference in New Issue
Block a user