[dpdk-stable] [PATCH 11/67] net/mlx4: fix single port configuration
Yongseok Koh
yskoh at mellanox.com
Tue Jun 5 02:10:33 CEST 2018
From: Ophir Munk <ophirmu at mellanox.com>
[ upstream commit a43fba2c1ea2e2f602c603f8338542f165b1c06b ]
The number of mlx4 present ports is calculated as follows:
conf.ports.present |= (UINT64_C(1) << device_attr.phys_port_cnt) - 1;
That is - all ones sequence (due to -1 subtraction)
When retrieving the number of ports, 1 must be added in order to obtain
the correct number of ports to the power of 2, as follows:
uint32_t ports = rte_log2_u32(conf->ports.present + 1);
If 1 was not added, in the case of one port, the number of ports would
be falsely calculated as 0.
Fixes: 8264279967dc ("net/mlx4: check max number of ports dynamically")
Cc: stable at dpdk.org
Signed-off-by: Ophir Munk <ophirmu at mellanox.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
---
drivers/net/mlx4/mlx4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 97dac6439..9a5773381 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -336,7 +336,7 @@ mlx4_arg_parse(const char *key, const char *val, struct mlx4_conf *conf)
return -rte_errno;
}
if (strcmp(MLX4_PMD_PORT_KVARG, key) == 0) {
- uint32_t ports = rte_log2_u32(conf->ports.present);
+ uint32_t ports = rte_log2_u32(conf->ports.present + 1);
if (tmp >= ports) {
ERROR("port index %lu outside range [0,%" PRIu32 ")",
--
2.11.0
More information about the stable
mailing list