From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro Subject: Re: [PATCH] net/mlx5: fix reusing Rx/Tx queues Date: Tue, 21 Mar 2017 09:03:41 +0100 Message-ID: <20170321080341.GL12013@autoinstall.dev.6wind.com> References: <20170320233804.47489-1-yskoh@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: ferruh.yigit@intel.com, dev@dpdk.org, adrien.mazarguil@6wind.com, stable@dpdk.org To: Yongseok Koh Return-path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id 1D840201 for ; Tue, 21 Mar 2017 09:03:50 +0100 (CET) Received: by mail-wr0-f177.google.com with SMTP id g10so106737958wrg.2 for ; Tue, 21 Mar 2017 01:03:50 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20170320233804.47489-1-yskoh@mellanox.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 > --- > 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