DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: fix probe failure report
Date: Sun, 13 Aug 2017 15:25:12 +0300	[thread overview]
Message-ID: <1502627112-53405-2-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1502627112-53405-1-git-send-email-matan@mellanox.com>

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 mlx5
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.

This bug was already present in the original code taken from mlx4.

Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters")
Fixes: 1371f4df16bc ("mlx5: check port is configured as ethernet device")

Signed-off-by: Matan Azrad <matan@mellanox.com>
Cc: stable@dpdk.org
---
 drivers/net/mlx5/mlx5.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 1a3d7f1..99a2fb3 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -579,8 +579,10 @@ mlx5_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);
@@ -592,6 +594,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
 			ERROR("port %d is not configured in Ethernet mode",
 			      port);
+			err = EINVAL;
 			goto port_error;
 		}
 
@@ -640,6 +643,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		mlx5_args_assign(priv, &args);
 		if (ibv_exp_query_device(ctx, &exp_device_attr)) {
 			ERROR("ibv_exp_query_device() failed");
+			err = ENODEV;
 			goto port_error;
 		}
 
@@ -728,6 +732,7 @@ mlx5_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 mlx5_en loaded?"
 			      " (errno: %s)", strerror(errno));
+			err = ENODEV;
 			goto port_error;
 		}
 		INFO("port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
-- 
2.7.4

  reply	other threads:[~2017-08-13 12:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-13 12:25 [dpdk-dev] [PATCH 1/2] net/mlx5: support device removal event Matan Azrad
2017-08-13 12:25 ` Matan Azrad [this message]
2017-08-23  9:44   ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix probe failure report Nélio Laranjeiro
2017-09-01 10:40     ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2017-08-23  9:40 ` [dpdk-dev] [PATCH 1/2] net/mlx5: support device removal event Nélio Laranjeiro
2017-08-23 19:44   ` Matan Azrad
2017-08-24  7:38     ` Nélio Laranjeiro
2017-08-24 14:33       ` Matan Azrad
2017-08-25  8:29         ` Nélio Laranjeiro
2017-08-29  8:30           ` [dpdk-dev] [PATCH v2] " Matan Azrad
2017-09-04 12:49             ` Nélio Laranjeiro
2017-09-04 13:55               ` [dpdk-dev] [PATCH v3] " Matan Azrad
2017-09-04 15:33                 ` Adrien Mazarguil
2017-09-04 17:52                   ` Matan Azrad
2017-09-05  9:28                     ` Adrien Mazarguil
2017-09-05 10:38                       ` Matan Azrad
2017-09-05 12:01                         ` Adrien Mazarguil
2017-09-05 13:36                           ` Matan Azrad
2017-09-06  7:12                             ` Adrien Mazarguil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502627112-53405-2-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).