[dpdk-dev,2/2] net/mlx5: fix probe failure report
Checks
Commit Message
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(-)
Comments
On Sun, Aug 13, 2017 at 03:25:12PM +0300, 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 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
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
On 8/23/2017 10:44 AM, Nélio Laranjeiro wrote:
> On Sun, Aug 13, 2017 at 03:25:12PM +0300, 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 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
>
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Applied to dpdk-next-net/master, thanks.
@@ -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",