From: Robin Jarry Date: Thu, 3 Mar 2016 14:27:40 +0000 (+0100) Subject: mlx4: ensure number of Rx queues is a power of 2 X-Git-Tag: spdx-start~7319 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=bda501616c2f2f16c9d26bec472bf82d0f9ce6b7;p=dpdk.git mlx4: ensure number of Rx queues is a power of 2 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 --- diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index d3cea0f846..295c38bf03 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -733,6 +733,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. */