* [PATCH] net/mlx5: fix reusing Rx/Tx queues
@ 2017-03-20 23:38 Yongseok Koh
2017-03-21 8:03 ` Nélio Laranjeiro
2017-03-21 17:50 ` [PATCH v2] " Yongseok Koh
0 siblings, 2 replies; 5+ messages in thread
From: Yongseok Koh @ 2017-03-20 23:38 UTC (permalink / raw)
To: ferruh.yigit
Cc: dev, adrien.mazarguil, nelio.laranjeiro, Yongseok Koh, stable
When configuring Rx/Tx queue, if queue already exists, it is reused. But if
the queue size is changed, it must be resized to not access/overwrite
invalid memory.
Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx")
CC: stable@dpdk.org
Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
drivers/net/mlx5/mlx5_rxq.c | 13 +++++++++++++
drivers/net/mlx5/mlx5_txq.c | 13 +++++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index e6070a0e5..aa28efc3d 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1261,6 +1261,19 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
}
(*priv->rxqs)[idx] = NULL;
rxq_cleanup(rxq_ctrl);
+ /* Resize if rxq size is chagned. */
+ if (rxq_ctrl->rxq.elts_n != log2above(desc)) {
+ rxq_ctrl = rte_realloc(rxq_ctrl,
+ sizeof(*rxq_ctrl) +
+ desc * sizeof(struct rte_mbuf *),
+ RTE_CACHE_LINE_SIZE);
+ if (!rxq_ctrl) {
+ ERROR("%p: unable to reallocate queue index %u",
+ (void *)dev, idx);
+ priv_unlock(priv);
+ return -ENOMEM;
+ }
+ }
} else {
rxq_ctrl = rte_calloc_socket("RXQ", 1, sizeof(*rxq_ctrl) +
desc * sizeof(struct rte_mbuf *),
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index bbfce756b..371dcd2f6 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -532,6 +532,19 @@ mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
}
(*priv->txqs)[idx] = NULL;
txq_cleanup(txq_ctrl);
+ /* Resize if txq size is chagned. */
+ if (txq_ctrl->txq.elts_n != log2above(desc)) {
+ txq_ctrl = rte_realloc(txq_ctrl,
+ sizeof(*txq_ctrl) +
+ desc * sizeof(struct rte_mbuf *),
+ RTE_CACHE_LINE_SIZE);
+ if (!txq_ctrl) {
+ ERROR("%p: unable to reallocate queue index %u",
+ (void *)dev, idx);
+ priv_unlock(priv);
+ return -ENOMEM;
+ }
+ }
} else {
txq_ctrl =
rte_calloc_socket("TXQ", 1,
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: fix reusing Rx/Tx queues
2017-03-20 23:38 [PATCH] net/mlx5: fix reusing Rx/Tx queues Yongseok Koh
@ 2017-03-21 8:03 ` Nélio Laranjeiro
2017-03-21 17:50 ` [PATCH v2] " Yongseok Koh
1 sibling, 0 replies; 5+ messages in thread
From: Nélio Laranjeiro @ 2017-03-21 8:03 UTC (permalink / raw)
To: Yongseok Koh; +Cc: ferruh.yigit, dev, adrien.mazarguil, stable
Yongseok,
Please see few comments below
On Mon, Mar 20, 2017 at 04:38:04PM -0700, Yongseok Koh wrote:
> When configuring Rx/Tx queue, if queue already exists, it is reused. But if
> the queue size is changed, it must be resized to not access/overwrite
> invalid memory.
>
> Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx")
>
> CC: stable@dpdk.org
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_rxq.c | 13 +++++++++++++
> drivers/net/mlx5/mlx5_txq.c | 13 +++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
> index e6070a0e5..aa28efc3d 100644
> --- a/drivers/net/mlx5/mlx5_rxq.c
> +++ b/drivers/net/mlx5/mlx5_rxq.c
> @@ -1261,6 +1261,19 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
> }
> (*priv->rxqs)[idx] = NULL;
> rxq_cleanup(rxq_ctrl);
> + /* Resize if rxq size is chagned. */
Typo in the comment (chagned instead of change).
> + if (rxq_ctrl->rxq.elts_n != log2above(desc)) {
> + rxq_ctrl = rte_realloc(rxq_ctrl,
> + sizeof(*rxq_ctrl) +
> + desc * sizeof(struct rte_mbuf *),
> + RTE_CACHE_LINE_SIZE);
> + if (!rxq_ctrl) {
> + ERROR("%p: unable to reallocate queue index %u",
> + (void *)dev, idx);
> + priv_unlock(priv);
> + return -ENOMEM;
> + }
> + }
> } else {
> rxq_ctrl = rte_calloc_socket("RXQ", 1, sizeof(*rxq_ctrl) +
> desc * sizeof(struct rte_mbuf *),
> diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
> index bbfce756b..371dcd2f6 100644
> --- a/drivers/net/mlx5/mlx5_txq.c
> +++ b/drivers/net/mlx5/mlx5_txq.c
> @@ -532,6 +532,19 @@ mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
> }
> (*priv->txqs)[idx] = NULL;
> txq_cleanup(txq_ctrl);
> + /* Resize if txq size is chagned. */
Same here.
> + if (txq_ctrl->txq.elts_n != log2above(desc)) {
> + txq_ctrl = rte_realloc(txq_ctrl,
> + sizeof(*txq_ctrl) +
> + desc * sizeof(struct rte_mbuf *),
> + RTE_CACHE_LINE_SIZE);
> + if (!txq_ctrl) {
> + ERROR("%p: unable to reallocate queue index %u",
> + (void *)dev, idx);
> + priv_unlock(priv);
> + return -ENOMEM;
> + }
> + }
> } else {
> txq_ctrl =
> rte_calloc_socket("TXQ", 1,
> --
> 2.11.0
By the same time, can you also fix the indentation please?
Thanks,
--
Nélio Laranjeiro
6WIND
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] net/mlx5: fix reusing Rx/Tx queues
2017-03-20 23:38 [PATCH] net/mlx5: fix reusing Rx/Tx queues Yongseok Koh
2017-03-21 8:03 ` Nélio Laranjeiro
@ 2017-03-21 17:50 ` Yongseok Koh
2017-03-22 7:50 ` Nélio Laranjeiro
1 sibling, 1 reply; 5+ messages in thread
From: Yongseok Koh @ 2017-03-21 17:50 UTC (permalink / raw)
To: ferruh.yigit
Cc: dev, adrien.mazarguil, nelio.laranjeiro, Yongseok Koh, stable
When configuring Rx/Tx queue, if queue already exists, it is reused. But if
the queue size is changed, it must be resized to not access/overwrite
invalid memory.
Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx")
CC: stable@dpdk.org
Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
v2:
* fix typo and indentataion
drivers/net/mlx5/mlx5_rxq.c | 13 +++++++++++++
drivers/net/mlx5/mlx5_txq.c | 13 +++++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index e6070a0e5..98fa05063 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1261,6 +1261,19 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
}
(*priv->rxqs)[idx] = NULL;
rxq_cleanup(rxq_ctrl);
+ /* Resize if rxq size is changed. */
+ if (rxq_ctrl->rxq.elts_n != log2above(desc)) {
+ rxq_ctrl = rte_realloc(rxq_ctrl,
+ sizeof(*rxq_ctrl) +
+ desc * sizeof(struct rte_mbuf *),
+ RTE_CACHE_LINE_SIZE);
+ if (!rxq_ctrl) {
+ ERROR("%p: unable to reallocate queue index %u",
+ (void *)dev, idx);
+ priv_unlock(priv);
+ return -ENOMEM;
+ }
+ }
} else {
rxq_ctrl = rte_calloc_socket("RXQ", 1, sizeof(*rxq_ctrl) +
desc * sizeof(struct rte_mbuf *),
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index bbfce756b..e9b837d10 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -532,6 +532,19 @@ mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
}
(*priv->txqs)[idx] = NULL;
txq_cleanup(txq_ctrl);
+ /* Resize if txq size is changed. */
+ if (txq_ctrl->txq.elts_n != log2above(desc)) {
+ txq_ctrl = rte_realloc(txq_ctrl,
+ sizeof(*txq_ctrl) +
+ desc * sizeof(struct rte_mbuf *),
+ RTE_CACHE_LINE_SIZE);
+ if (!txq_ctrl) {
+ ERROR("%p: unable to reallocate queue index %u",
+ (void *)dev, idx);
+ priv_unlock(priv);
+ return -ENOMEM;
+ }
+ }
} else {
txq_ctrl =
rte_calloc_socket("TXQ", 1,
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] net/mlx5: fix reusing Rx/Tx queues
2017-03-21 17:50 ` [PATCH v2] " Yongseok Koh
@ 2017-03-22 7:50 ` Nélio Laranjeiro
2017-03-22 14:56 ` Ferruh Yigit
0 siblings, 1 reply; 5+ messages in thread
From: Nélio Laranjeiro @ 2017-03-22 7:50 UTC (permalink / raw)
To: Yongseok Koh; +Cc: ferruh.yigit, dev, adrien.mazarguil, stable
On Tue, Mar 21, 2017 at 10:50:51AM -0700, Yongseok Koh wrote:
> When configuring Rx/Tx queue, if queue already exists, it is reused. But if
> the queue size is changed, it must be resized to not access/overwrite
> invalid memory.
>
> Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx")
>
> CC: stable@dpdk.org
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> ---
>
> v2:
> * fix typo and indentataion
>
> drivers/net/mlx5/mlx5_rxq.c | 13 +++++++++++++
> drivers/net/mlx5/mlx5_txq.c | 13 +++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
> index e6070a0e5..98fa05063 100644
> --- a/drivers/net/mlx5/mlx5_rxq.c
> +++ b/drivers/net/mlx5/mlx5_rxq.c
> @@ -1261,6 +1261,19 @@ mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
> }
> (*priv->rxqs)[idx] = NULL;
> rxq_cleanup(rxq_ctrl);
> + /* Resize if rxq size is changed. */
> + if (rxq_ctrl->rxq.elts_n != log2above(desc)) {
> + rxq_ctrl = rte_realloc(rxq_ctrl,
> + sizeof(*rxq_ctrl) +
> + desc * sizeof(struct rte_mbuf *),
> + RTE_CACHE_LINE_SIZE);
> + if (!rxq_ctrl) {
> + ERROR("%p: unable to reallocate queue index %u",
> + (void *)dev, idx);
> + priv_unlock(priv);
> + return -ENOMEM;
> + }
> + }
> } else {
> rxq_ctrl = rte_calloc_socket("RXQ", 1, sizeof(*rxq_ctrl) +
> desc * sizeof(struct rte_mbuf *),
> diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
> index bbfce756b..e9b837d10 100644
> --- a/drivers/net/mlx5/mlx5_txq.c
> +++ b/drivers/net/mlx5/mlx5_txq.c
> @@ -532,6 +532,19 @@ mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
> }
> (*priv->txqs)[idx] = NULL;
> txq_cleanup(txq_ctrl);
> + /* Resize if txq size is changed. */
> + if (txq_ctrl->txq.elts_n != log2above(desc)) {
> + txq_ctrl = rte_realloc(txq_ctrl,
> + sizeof(*txq_ctrl) +
> + desc * sizeof(struct rte_mbuf *),
> + RTE_CACHE_LINE_SIZE);
> + if (!txq_ctrl) {
> + ERROR("%p: unable to reallocate queue index %u",
> + (void *)dev, idx);
> + priv_unlock(priv);
> + return -ENOMEM;
> + }
> + }
> } else {
> txq_ctrl =
> rte_calloc_socket("TXQ", 1,
> --
> 2.11.0
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
--
Nélio Laranjeiro
6WIND
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] net/mlx5: fix reusing Rx/Tx queues
2017-03-22 7:50 ` Nélio Laranjeiro
@ 2017-03-22 14:56 ` Ferruh Yigit
0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2017-03-22 14:56 UTC (permalink / raw)
To: Nélio Laranjeiro, Yongseok Koh; +Cc: dev, adrien.mazarguil, stable
On 3/22/2017 7:50 AM, Nélio Laranjeiro wrote:
> On Tue, Mar 21, 2017 at 10:50:51AM -0700, Yongseok Koh wrote:
>> When configuring Rx/Tx queue, if queue already exists, it is reused. But if
>> the queue size is changed, it must be resized to not access/overwrite
>> invalid memory.
>>
>> Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx")
>> CC: stable@dpdk.org
>> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-22 14:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-20 23:38 [PATCH] net/mlx5: fix reusing Rx/Tx queues Yongseok Koh
2017-03-21 8:03 ` Nélio Laranjeiro
2017-03-21 17:50 ` [PATCH v2] " Yongseok Koh
2017-03-22 7:50 ` Nélio Laranjeiro
2017-03-22 14:56 ` Ferruh Yigit
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.