patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/mlx5: fix Rx/Tx descriptors number adjustment
@ 2020-06-11 17:43 Alexander Kozyrev
  2020-06-15 10:51 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kozyrev @ 2020-06-11 17:43 UTC (permalink / raw)
  To: dev; +Cc: stable, rasland, matan

The number of descriptors to configure in a Rx/Tx queue is passed to
the mlx5_tx/rx_queue_pre_setup() function by value. That means any
adjustments of this variable are local and cannot affect the actual
value that is used to allocate mbufs in the mlx5_txq/rxq_new()
functions. Pass the number as a reference to actually update it.

Fixes: 6218063b ("net/mlx5: refactor Rx data path")
Fixes: 1d88ba17 ("net/mlx5: refactor Tx data path")
Cc: stable@dpdk.org

Signed-off-by: Alexander Kozyrev <akozyrev@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 14 +++++++-------
 drivers/net/mlx5/mlx5_txq.c | 22 +++++++++++-----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 78046fd..dda0073 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -453,19 +453,19 @@
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 static int
-mlx5_rx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc)
+mlx5_rx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t *desc)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 
-	if (!rte_is_power_of_2(desc)) {
-		desc = 1 << log2above(desc);
+	if (!rte_is_power_of_2(*desc)) {
+		*desc = 1 << log2above(*desc);
 		DRV_LOG(WARNING,
 			"port %u increased number of descriptors in Rx queue %u"
 			" to the next power of two (%d)",
-			dev->data->port_id, idx, desc);
+			dev->data->port_id, idx, *desc);
 	}
 	DRV_LOG(DEBUG, "port %u configuring Rx queue %u for %u descriptors",
-		dev->data->port_id, idx, desc);
+		dev->data->port_id, idx, *desc);
 	if (idx >= priv->rxqs_n) {
 		DRV_LOG(ERR, "port %u Rx queue index out of range (%u >= %u)",
 			dev->data->port_id, idx, priv->rxqs_n);
@@ -511,7 +511,7 @@
 		container_of(rxq, struct mlx5_rxq_ctrl, rxq);
 	int res;
 
-	res = mlx5_rx_queue_pre_setup(dev, idx, desc);
+	res = mlx5_rx_queue_pre_setup(dev, idx, &desc);
 	if (res)
 		return res;
 	rxq_ctrl = mlx5_rxq_new(dev, idx, desc, socket, conf, mp);
@@ -552,7 +552,7 @@
 		container_of(rxq, struct mlx5_rxq_ctrl, rxq);
 	int res;
 
-	res = mlx5_rx_queue_pre_setup(dev, idx, desc);
+	res = mlx5_rx_queue_pre_setup(dev, idx, &desc);
 	if (res)
 		return res;
 	if (hairpin_conf->peer_count != 1 ||
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index f7b548f..90f3296 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -150,27 +150,27 @@
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 static int
-mlx5_tx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc)
+mlx5_tx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t *desc)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 
-	if (desc <= MLX5_TX_COMP_THRESH) {
+	if (*desc <= MLX5_TX_COMP_THRESH) {
 		DRV_LOG(WARNING,
 			"port %u number of descriptors requested for Tx queue"
 			" %u must be higher than MLX5_TX_COMP_THRESH, using %u"
-			" instead of %u",
-			dev->data->port_id, idx, MLX5_TX_COMP_THRESH + 1, desc);
-		desc = MLX5_TX_COMP_THRESH + 1;
+			" instead of %u", dev->data->port_id, idx,
+			MLX5_TX_COMP_THRESH + 1, *desc);
+		*desc = MLX5_TX_COMP_THRESH + 1;
 	}
-	if (!rte_is_power_of_2(desc)) {
-		desc = 1 << log2above(desc);
+	if (!rte_is_power_of_2(*desc)) {
+		*desc = 1 << log2above(*desc);
 		DRV_LOG(WARNING,
 			"port %u increased number of descriptors in Tx queue"
 			" %u to the next power of two (%d)",
-			dev->data->port_id, idx, desc);
+			dev->data->port_id, idx, *desc);
 	}
 	DRV_LOG(DEBUG, "port %u configuring queue %u for %u descriptors",
-		dev->data->port_id, idx, desc);
+		dev->data->port_id, idx, *desc);
 	if (idx >= priv->txqs_n) {
 		DRV_LOG(ERR, "port %u Tx queue index out of range (%u >= %u)",
 			dev->data->port_id, idx, priv->txqs_n);
@@ -213,7 +213,7 @@
 		container_of(txq, struct mlx5_txq_ctrl, txq);
 	int res;
 
-	res = mlx5_tx_queue_pre_setup(dev, idx, desc);
+	res = mlx5_tx_queue_pre_setup(dev, idx, &desc);
 	if (res)
 		return res;
 	txq_ctrl = mlx5_txq_new(dev, idx, desc, socket, conf);
@@ -254,7 +254,7 @@
 		container_of(txq, struct mlx5_txq_ctrl, txq);
 	int res;
 
-	res = mlx5_tx_queue_pre_setup(dev, idx, desc);
+	res = mlx5_tx_queue_pre_setup(dev, idx, &desc);
 	if (res)
 		return res;
 	if (hairpin_conf->peer_count != 1 ||
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH] net/mlx5: fix Rx/Tx descriptors number adjustment
  2020-06-11 17:43 [dpdk-stable] [PATCH] net/mlx5: fix Rx/Tx descriptors number adjustment Alexander Kozyrev
@ 2020-06-15 10:51 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2020-06-15 10:51 UTC (permalink / raw)
  To: Alexander Kozyrev, dev; +Cc: stable, Matan Azrad

Hi,

> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@mellanox.com>
> Sent: Thursday, June 11, 2020 8:43 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Raslan Darawsheh <rasland@mellanox.com>; Matan
> Azrad <matan@mellanox.com>
> Subject: [PATCH] net/mlx5: fix Rx/Tx descriptors number adjustment
> 
> The number of descriptors to configure in a Rx/Tx queue is passed to
> the mlx5_tx/rx_queue_pre_setup() function by value. That means any
> adjustments of this variable are local and cannot affect the actual
> value that is used to allocate mbufs in the mlx5_txq/rxq_new()
> functions. Pass the number as a reference to actually update it.
> 
> Fixes: 6218063b ("net/mlx5: refactor Rx data path")
> Fixes: 1d88ba17 ("net/mlx5: refactor Tx data path")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Alexander Kozyrev <akozyrev@mellanox.com>
> Acked-by: Matan Azrad <matan@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_rxq.c | 14 +++++++-------
>  drivers/net/mlx5/mlx5_txq.c | 22 +++++++++++-----------
>  2 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
> index 78046fd..dda0073 100644
> --- a/drivers/net/mlx5/mlx5_rxq.c
> +++ b/drivers/net/mlx5/mlx5_rxq.c
> @@ -453,19 +453,19 @@
>   *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
>  static int
> -mlx5_rx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t
> desc)
> +mlx5_rx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t
> *desc)
>  {
>  	struct mlx5_priv *priv = dev->data->dev_private;
> 
> -	if (!rte_is_power_of_2(desc)) {
> -		desc = 1 << log2above(desc);
> +	if (!rte_is_power_of_2(*desc)) {
> +		*desc = 1 << log2above(*desc);
>  		DRV_LOG(WARNING,
>  			"port %u increased number of descriptors in Rx
> queue %u"
>  			" to the next power of two (%d)",
> -			dev->data->port_id, idx, desc);
> +			dev->data->port_id, idx, *desc);
>  	}
>  	DRV_LOG(DEBUG, "port %u configuring Rx queue %u for %u
> descriptors",
> -		dev->data->port_id, idx, desc);
> +		dev->data->port_id, idx, *desc);
>  	if (idx >= priv->rxqs_n) {
>  		DRV_LOG(ERR, "port %u Rx queue index out of range (%u >=
> %u)",
>  			dev->data->port_id, idx, priv->rxqs_n);
> @@ -511,7 +511,7 @@
>  		container_of(rxq, struct mlx5_rxq_ctrl, rxq);
>  	int res;
> 
> -	res = mlx5_rx_queue_pre_setup(dev, idx, desc);
> +	res = mlx5_rx_queue_pre_setup(dev, idx, &desc);
>  	if (res)
>  		return res;
>  	rxq_ctrl = mlx5_rxq_new(dev, idx, desc, socket, conf, mp);
> @@ -552,7 +552,7 @@
>  		container_of(rxq, struct mlx5_rxq_ctrl, rxq);
>  	int res;
> 
> -	res = mlx5_rx_queue_pre_setup(dev, idx, desc);
> +	res = mlx5_rx_queue_pre_setup(dev, idx, &desc);
>  	if (res)
>  		return res;
>  	if (hairpin_conf->peer_count != 1 ||
> diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
> index f7b548f..90f3296 100644
> --- a/drivers/net/mlx5/mlx5_txq.c
> +++ b/drivers/net/mlx5/mlx5_txq.c
> @@ -150,27 +150,27 @@
>   *   0 on success, a negative errno value otherwise and rte_errno is set.
>   */
>  static int
> -mlx5_tx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t
> desc)
> +mlx5_tx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t
> *desc)
>  {
>  	struct mlx5_priv *priv = dev->data->dev_private;
> 
> -	if (desc <= MLX5_TX_COMP_THRESH) {
> +	if (*desc <= MLX5_TX_COMP_THRESH) {
>  		DRV_LOG(WARNING,
>  			"port %u number of descriptors requested for Tx
> queue"
>  			" %u must be higher than MLX5_TX_COMP_THRESH,
> using %u"
> -			" instead of %u",
> -			dev->data->port_id, idx, MLX5_TX_COMP_THRESH +
> 1, desc);
> -		desc = MLX5_TX_COMP_THRESH + 1;
> +			" instead of %u", dev->data->port_id, idx,
> +			MLX5_TX_COMP_THRESH + 1, *desc);
> +		*desc = MLX5_TX_COMP_THRESH + 1;
>  	}
> -	if (!rte_is_power_of_2(desc)) {
> -		desc = 1 << log2above(desc);
> +	if (!rte_is_power_of_2(*desc)) {
> +		*desc = 1 << log2above(*desc);
>  		DRV_LOG(WARNING,
>  			"port %u increased number of descriptors in Tx
> queue"
>  			" %u to the next power of two (%d)",
> -			dev->data->port_id, idx, desc);
> +			dev->data->port_id, idx, *desc);
>  	}
>  	DRV_LOG(DEBUG, "port %u configuring queue %u for %u
> descriptors",
> -		dev->data->port_id, idx, desc);
> +		dev->data->port_id, idx, *desc);
>  	if (idx >= priv->txqs_n) {
>  		DRV_LOG(ERR, "port %u Tx queue index out of range (%u >=
> %u)",
>  			dev->data->port_id, idx, priv->txqs_n);
> @@ -213,7 +213,7 @@
>  		container_of(txq, struct mlx5_txq_ctrl, txq);
>  	int res;
> 
> -	res = mlx5_tx_queue_pre_setup(dev, idx, desc);
> +	res = mlx5_tx_queue_pre_setup(dev, idx, &desc);
>  	if (res)
>  		return res;
>  	txq_ctrl = mlx5_txq_new(dev, idx, desc, socket, conf);
> @@ -254,7 +254,7 @@
>  		container_of(txq, struct mlx5_txq_ctrl, txq);
>  	int res;
> 
> -	res = mlx5_tx_queue_pre_setup(dev, idx, desc);
> +	res = mlx5_tx_queue_pre_setup(dev, idx, &desc);
>  	if (res)
>  		return res;
>  	if (hairpin_conf->peer_count != 1 ||
> --
> 1.8.3.1


Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-15 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 17:43 [dpdk-stable] [PATCH] net/mlx5: fix Rx/Tx descriptors number adjustment Alexander Kozyrev
2020-06-15 10:51 ` Raslan Darawsheh

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git