* [dpdk-stable] [PATCH] net/mlx4: fix probe failure report
@ 2017-08-16 7:53 Matan Azrad
2017-08-16 8:15 ` Yuanhan Liu
0 siblings, 1 reply; 4+ messages in thread
From: Matan Azrad @ 2017-08-16 7:53 UTC (permalink / raw)
To: Yuanhan Liu; +Cc: stable
[ backported from 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: 7b0661539229 ("mlx4: check if port is configured for ethernet")
Fixes: fec3608673e6 ("mlx4: query netdevice to get initial MAC address")
Cc: stable@dpdk.org
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
drivers/net/mlx4/mlx4.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index f682413..4a03d34 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5625,8 +5625,10 @@ 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 = EINVAL;
goto error;
+ }
INFO("%u port(s) detected", device_attr.phys_port_cnt);
for (i = 0; i < device_attr.phys_port_cnt; i++) {
@@ -5652,19 +5654,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",
port);
+ err = EINVAL;
goto port_error;
}
@@ -5701,6 +5707,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
#ifdef HAVE_EXP_QUERY_DEVICE
if (ibv_exp_query_device(ctx, &exp_device_attr)) {
ERROR("ibv_exp_query_device() failed");
+ err = ENODEV;
goto port_error;
}
#ifdef RSS_SUPPORT
@@ -5776,6 +5783,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",
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [PATCH] net/mlx4: fix probe failure report
2017-08-16 7:53 [dpdk-stable] [PATCH] net/mlx4: fix probe failure report Matan Azrad
@ 2017-08-16 8:15 ` Yuanhan Liu
0 siblings, 0 replies; 4+ messages in thread
From: Yuanhan Liu @ 2017-08-16 8:15 UTC (permalink / raw)
To: Matan Azrad; +Cc: stable
On Wed, Aug 16, 2017 at 10:53:54AM +0300, Matan Azrad wrote:
> [ backported from upstream commit
> 8d0f80167d43949bd24374bcf294a149246dfd1c ]
Applied to dpdk-stable/16.11.
Thank you!
--yliu
>
> 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: 7b0661539229 ("mlx4: check if port is configured for ethernet")
> Fixes: fec3608673e6 ("mlx4: query netdevice to get initial MAC address")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---
> drivers/net/mlx4/mlx4.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
> index f682413..4a03d34 100644
> --- a/drivers/net/mlx4/mlx4.c
> +++ b/drivers/net/mlx4/mlx4.c
> @@ -5625,8 +5625,10 @@ 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 = EINVAL;
> goto error;
> + }
> INFO("%u port(s) detected", device_attr.phys_port_cnt);
>
> for (i = 0; i < device_attr.phys_port_cnt; i++) {
> @@ -5652,19 +5654,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",
> port);
> + err = EINVAL;
> goto port_error;
> }
>
> @@ -5701,6 +5707,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
> #ifdef HAVE_EXP_QUERY_DEVICE
> if (ibv_exp_query_device(ctx, &exp_device_attr)) {
> ERROR("ibv_exp_query_device() failed");
> + err = ENODEV;
> goto port_error;
> }
> #ifdef RSS_SUPPORT
> @@ -5776,6 +5783,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",
> --
> 2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [PATCH] net/mlx4: fix probe failure report
2017-07-31 14:30 Matan Azrad
@ 2017-07-31 17:09 ` Ferruh Yigit
0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2017-07-31 17:09 UTC (permalink / raw)
To: Matan Azrad, Adrien Mazarguil; +Cc: dev, stable
On 7/31/2017 3:30 PM, Matan Azrad wrote:
> 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")
> Cc: stable@dpdk.org
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-stable] [PATCH] net/mlx4: fix probe failure report
@ 2017-07-31 14:30 Matan Azrad
2017-07-31 17:09 ` Ferruh Yigit
0 siblings, 1 reply; 4+ messages in thread
From: Matan Azrad @ 2017-07-31 14:30 UTC (permalink / raw)
To: Adrien Mazarguil; +Cc: dev, stable
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 <matan@mellanox.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: stable@dpdk.org
---
drivers/net/mlx4/mlx4.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 94782c2..a94a42b 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -6162,12 +6162,15 @@ struct txq_mp2mr_mbuf_check_data {
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 */
@@ -6201,19 +6204,23 @@ struct txq_mp2mr_mbuf_check_data {
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",
port);
+ err = EINVAL;
goto port_error;
}
@@ -6250,6 +6257,7 @@ struct txq_mp2mr_mbuf_check_data {
#ifdef HAVE_EXP_QUERY_DEVICE
if (ibv_exp_query_device(ctx, &exp_device_attr)) {
ERROR("ibv_exp_query_device() failed");
+ err = ENODEV;
goto port_error;
}
#ifdef RSS_SUPPORT
@@ -6325,6 +6333,7 @@ struct txq_mp2mr_mbuf_check_data {
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",
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-16 8:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16 7:53 [dpdk-stable] [PATCH] net/mlx4: fix probe failure report Matan Azrad
2017-08-16 8:15 ` Yuanhan Liu
-- strict thread matches above, loose matches on Subject: below --
2017-07-31 14:30 Matan Azrad
2017-07-31 17:09 ` Ferruh Yigit
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).