diff options
authorMatan Azrad <>2017-07-31 17:30:29 +0300
committerYuanhan Liu <>2017-08-29 14:55:38 +0800
commit9747893cbf7eb8458d0dd1ff7d9b09b180a4f955 (patch)
parentea0c41bce01aeafd24b490f50c142d0a7fd35dfa (diff)
net/mlx4: fix probe failure report
[ upstream commit 8d0f80167d43949bd24374bcf294a149246dfd1c ] The corrupted code doesn't return error when probe function fails due to error in device mac address getting. By this way, the probe function may return success even if the ETH dev is not allocated. Hence, the probe caller, for example failsafe PMD, fails when it tries to get ETH dev after the device was plugged out while mlx4 was probing it. The fix adds error report to the probe caller when priv_get_mac fails and in all other failure options which are missing it. By this way, it prevents the unexpected behavior to miss ETH device after the device was probed successfully. Fixes: 7fae69eeff13 ("mlx4: new poll mode driver") Fixes: 001a520e419f ("net/mlx4: add port parameter") Fixes: 7b0661539229 ("mlx4: check if port is configured for ethernet") Fixes: fec3608673e6 ("mlx4: query netdevice to get initial MAC address") Signed-off-by: Matan Azrad <> Acked-by: Adrien Mazarguil <>
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index c983bc8..02e5a1f 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5767,12 +5767,15 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
ibv_dev = list[i];
DEBUG("device opened");
- if (ibv_query_device(attr_ctx, &device_attr))
+ if (ibv_query_device(attr_ctx, &device_attr)) {
+ err = ENODEV;
goto error;
+ }
INFO("%u port(s) detected", device_attr.phys_port_cnt);
if (mlx4_args(pci_dev->device.devargs, &conf)) {
ERROR("failed to process device arguments");
+ err = EINVAL;
goto error;
/* Use all ports when none are defined */
@@ -5806,19 +5809,23 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
DEBUG("using port %u (%08" PRIx32 ")", port, test);
ctx = ibv_open_device(ibv_dev);
- if (ctx == NULL)
+ if (ctx == NULL) {
+ err = ENODEV;
goto port_error;
+ }
/* Check port status. */
err = ibv_query_port(ctx, port, &port_attr);
if (err) {
ERROR("port query failed: %s", strerror(err));
+ err = ENODEV;
goto port_error;
if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
ERROR("port %d is not configured in Ethernet mode",
+ err = EINVAL;
goto port_error;
@@ -5855,6 +5862,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
if (ibv_exp_query_device(ctx, &exp_device_attr)) {
ERROR("ibv_exp_query_device() failed");
+ err = ENODEV;
goto port_error;
@@ -5930,6 +5938,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
if (priv_get_mac(priv, &mac.addr_bytes)) {
ERROR("cannot get MAC address, is mlx4_en loaded?"
" (errno: %s)", strerror(errno));
+ err = ENODEV;
goto port_error;
INFO("port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",