From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: [PATCH v2 7/7] mlx4: make sure that number of RX queues is a power of 2 Date: Thu, 3 Mar 2016 15:27:40 +0100 Message-ID: <1457015260-3041-8-git-send-email-adrien.mazarguil@6wind.com> References: <1456165123-28365-1-git-send-email-adrien.mazarguil@6wind.com> <1457015260-3041-1-git-send-email-adrien.mazarguil@6wind.com> To: dev@dpdk.org Return-path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 719462C22 for ; Thu, 3 Mar 2016 15:28:07 +0100 (CET) Received: by mail-wm0-f41.google.com with SMTP id l68so133752971wml.0 for ; Thu, 03 Mar 2016 06:28:07 -0800 (PST) In-Reply-To: <1457015260-3041-1-git-send-email-adrien.mazarguil@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Robin Jarry In the documentation it is specified that the hardware only supports a number of RX queues if it is a power of 2. Since ibv_exp_create_qp may not return an error when the number of queues is unsupported by hardware, sanitize the value in dev_configure. Signed-off-by: Robin Jarry --- drivers/net/mlx4/mlx4.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 3c1f4c2..67025c7 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -734,6 +734,12 @@ dev_configure(struct rte_eth_dev *dev) } if (rxqs_n == priv->rxqs_n) return 0; + if ((rxqs_n & (rxqs_n - 1)) != 0) { + ERROR("%p: invalid number of RX queues (%u)," + " must be a power of 2", + (void *)dev, rxqs_n); + return EINVAL; + } INFO("%p: RX queues number update: %u -> %u", (void *)dev, priv->rxqs_n, rxqs_n); /* If RSS is enabled, disable it first. */ -- 2.1.4