* [PATCH] net/mana: return probe failure if there is no device found
@ 2023-04-27 2:18 longli
2023-05-06 1:32 ` [PATCH v2] " longli
0 siblings, 1 reply; 3+ messages in thread
From: longli @ 2023-04-27 2:18 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Ajay Sharma, Long Li, stable
From: Long Li <longli@microsoft.com>
When there is no device found on this PCI device, return probe failure and
release allocated resources for this PCI device.
Fixes: 517ed6e2d5 ("net/mana: add basic driver with build environment")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/net/mana/mana.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 2463f34c1e..90d083aae7 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -1343,6 +1343,7 @@ mana_probe_port(struct ibv_device *ibdev, struct ibv_device_attr_ex *dev_attr,
/*
* Goes through the IB device list to look for the IB port matching the
* mac_addr. If found, create a rte_eth_dev for it.
+ * Return value: number of successfully probed deivces
*/
static int
mana_pci_probe_mac(struct rte_pci_device *pci_dev,
@@ -1352,8 +1353,9 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
int ibv_idx;
struct ibv_context *ctx;
int num_devices;
- int ret = 0;
+ int ret;
uint8_t port;
+ int count = 0;
ibv_list = ibv_get_device_list(&num_devices);
for (ibv_idx = 0; ibv_idx < num_devices; ibv_idx++) {
@@ -1383,6 +1385,12 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
ret = ibv_query_device_ex(ctx, NULL, &dev_attr);
ibv_close_device(ctx);
+ if (ret) {
+ DRV_LOG(ERR, "Failed to query IB device %s",
+ ibdev->name);
+ continue;
+ }
+
for (port = 1; port <= dev_attr.orig_attr.phys_port_cnt;
port++) {
struct rte_ether_addr addr;
@@ -1394,15 +1402,17 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
continue;
ret = mana_probe_port(ibdev, &dev_attr, port, pci_dev, &addr);
- if (ret)
+ if (ret) {
DRV_LOG(ERR, "Probe on IB port %u failed %d", port, ret);
- else
+ } else {
+ count++;
DRV_LOG(INFO, "Successfully probed on IB port %u", port);
+ }
}
}
ibv_free_device_list(ibv_list);
- return ret;
+ return count;
}
/*
@@ -1416,6 +1426,7 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct mana_conf conf = {0};
unsigned int i;
int ret;
+ int count = 0;
if (args && args->drv_str) {
ret = mana_parse_args(args, &conf);
@@ -1433,16 +1444,21 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
/* If there are no driver parameters, probe on all ports */
- if (!conf.index)
- return mana_pci_probe_mac(pci_dev, NULL);
+ if (conf.index) {
+ for (i = 0; i < conf.index; i++)
+ count += mana_pci_probe_mac(pci_dev,
+ &conf.mac_array[i]);
+ } else {
+ count = mana_pci_probe_mac(pci_dev, NULL);
+ }
- for (i = 0; i < conf.index; i++) {
- ret = mana_pci_probe_mac(pci_dev, &conf.mac_array[i]);
- if (ret)
- return ret;
+ if (!count) {
+ rte_memzone_free(mana_shared_mz);
+ mana_shared_mz = NULL;
+ ret = -ENODEV;
}
- return 0;
+ return ret;
}
static int
@@ -1475,6 +1491,7 @@ mana_pci_remove(struct rte_pci_device *pci_dev)
if (!mana_shared_data->primary_cnt) {
DRV_LOG(DEBUG, "free shared memezone data");
rte_memzone_free(mana_shared_mz);
+ mana_shared_mz = NULL;
}
rte_spinlock_unlock(&mana_shared_data_lock);
--
2.32.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] net/mana: return probe failure if there is no device found
2023-04-27 2:18 [PATCH] net/mana: return probe failure if there is no device found longli
@ 2023-05-06 1:32 ` longli
2023-05-19 16:08 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: longli @ 2023-05-06 1:32 UTC (permalink / raw)
To: Ferruh Yigit, Andrew Rybchenko; +Cc: dev, Ajay Sharma, Long Li, stable
From: Long Li <longli@microsoft.com>
When there is no device found on this PCI device, return probe failure and
release allocated resources for this PCI device.
Fixes: 517ed6e2d590 ("net/mana: add basic driver with build environment")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
Change log
v2: fixed typo
drivers/net/mana/mana.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 2463f34c1e..7630118d4f 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -1343,6 +1343,7 @@ mana_probe_port(struct ibv_device *ibdev, struct ibv_device_attr_ex *dev_attr,
/*
* Goes through the IB device list to look for the IB port matching the
* mac_addr. If found, create a rte_eth_dev for it.
+ * Return value: number of successfully probed devices
*/
static int
mana_pci_probe_mac(struct rte_pci_device *pci_dev,
@@ -1352,8 +1353,9 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
int ibv_idx;
struct ibv_context *ctx;
int num_devices;
- int ret = 0;
+ int ret;
uint8_t port;
+ int count = 0;
ibv_list = ibv_get_device_list(&num_devices);
for (ibv_idx = 0; ibv_idx < num_devices; ibv_idx++) {
@@ -1383,6 +1385,12 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
ret = ibv_query_device_ex(ctx, NULL, &dev_attr);
ibv_close_device(ctx);
+ if (ret) {
+ DRV_LOG(ERR, "Failed to query IB device %s",
+ ibdev->name);
+ continue;
+ }
+
for (port = 1; port <= dev_attr.orig_attr.phys_port_cnt;
port++) {
struct rte_ether_addr addr;
@@ -1394,15 +1402,17 @@ mana_pci_probe_mac(struct rte_pci_device *pci_dev,
continue;
ret = mana_probe_port(ibdev, &dev_attr, port, pci_dev, &addr);
- if (ret)
+ if (ret) {
DRV_LOG(ERR, "Probe on IB port %u failed %d", port, ret);
- else
+ } else {
+ count++;
DRV_LOG(INFO, "Successfully probed on IB port %u", port);
+ }
}
}
ibv_free_device_list(ibv_list);
- return ret;
+ return count;
}
/*
@@ -1416,6 +1426,7 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct mana_conf conf = {0};
unsigned int i;
int ret;
+ int count = 0;
if (args && args->drv_str) {
ret = mana_parse_args(args, &conf);
@@ -1433,16 +1444,21 @@ mana_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
/* If there are no driver parameters, probe on all ports */
- if (!conf.index)
- return mana_pci_probe_mac(pci_dev, NULL);
+ if (conf.index) {
+ for (i = 0; i < conf.index; i++)
+ count += mana_pci_probe_mac(pci_dev,
+ &conf.mac_array[i]);
+ } else {
+ count = mana_pci_probe_mac(pci_dev, NULL);
+ }
- for (i = 0; i < conf.index; i++) {
- ret = mana_pci_probe_mac(pci_dev, &conf.mac_array[i]);
- if (ret)
- return ret;
+ if (!count) {
+ rte_memzone_free(mana_shared_mz);
+ mana_shared_mz = NULL;
+ ret = -ENODEV;
}
- return 0;
+ return ret;
}
static int
@@ -1475,6 +1491,7 @@ mana_pci_remove(struct rte_pci_device *pci_dev)
if (!mana_shared_data->primary_cnt) {
DRV_LOG(DEBUG, "free shared memezone data");
rte_memzone_free(mana_shared_mz);
+ mana_shared_mz = NULL;
}
rte_spinlock_unlock(&mana_shared_data_lock);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net/mana: return probe failure if there is no device found
2023-05-06 1:32 ` [PATCH v2] " longli
@ 2023-05-19 16:08 ` Ferruh Yigit
0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2023-05-19 16:08 UTC (permalink / raw)
To: longli, Andrew Rybchenko; +Cc: dev, Ajay Sharma, Long Li, stable
On 5/6/2023 2:32 AM, longli@linuxonhyperv.com wrote:
> From: Long Li <longli@microsoft.com>
>
> When there is no device found on this PCI device, return probe failure and
> release allocated resources for this PCI device.
>
> Fixes: 517ed6e2d590 ("net/mana: add basic driver with build environment")
> Cc: stable@dpdk.org
>
> Signed-off-by: Long Li <longli@microsoft.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-19 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 2:18 [PATCH] net/mana: return probe failure if there is no device found longli
2023-05-06 1:32 ` [PATCH v2] " longli
2023-05-19 16:08 ` 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).