From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, Shreyansh Jain <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH v3 2/5] bus/fslmc: enhance error handling for dev parsing
Date: Mon, 15 Jul 2019 14:14:39 +0530 [thread overview]
Message-ID: <20190715084442.14686-3-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20190715084442.14686-1-hemant.agrawal@nxp.com>
From: Shreyansh Jain <shreyansh.jain@nxp.com>
In case an incorrect device is found, it was quiting further search
rather than skipping it.
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
drivers/bus/fslmc/fslmc_bus.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 35103d224..a2ed3bcc9 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -33,7 +33,7 @@ uint8_t dpaa2_virt_mode;
uint32_t
rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type)
{
- if (device_type > DPAA2_DEVTYPE_MAX)
+ if (device_type >= DPAA2_DEVTYPE_MAX)
return 0;
return rte_fslmc_bus.device_count[device_type];
}
@@ -135,10 +135,11 @@ static int
scan_one_fslmc_device(char *dev_name)
{
char *dup_dev_name, *t_ptr;
- struct rte_dpaa2_device *dev;
+ struct rte_dpaa2_device *dev = NULL;
+ int ret = -1;
if (!dev_name)
- return -1;
+ return ret;
/* Ignore the Container name itself */
if (!strncmp("dprc", dev_name, 4))
@@ -168,7 +169,8 @@ scan_one_fslmc_device(char *dev_name)
/* Parse the device name and ID */
t_ptr = strtok(dup_dev_name, ".");
if (!t_ptr) {
- DPAA2_BUS_ERR("Incorrect device name observed");
+ DPAA2_BUS_ERR("Invalid device found: (%s)", dup_dev_name);
+ ret = -EINVAL;
goto cleanup;
}
if (!strncmp("dpni", t_ptr, 4))
@@ -192,12 +194,10 @@ scan_one_fslmc_device(char *dev_name)
else
dev->dev_type = DPAA2_UNKNOWN;
- /* Update the device found into the device_count table */
- rte_fslmc_bus.device_count[dev->dev_type]++;
-
t_ptr = strtok(NULL, ".");
if (!t_ptr) {
- DPAA2_BUS_ERR("Incorrect device string observed (null)");
+ DPAA2_BUS_ERR("Skipping invalid device (%s)", dup_dev_name);
+ ret = 0;
goto cleanup;
}
@@ -205,10 +205,14 @@ scan_one_fslmc_device(char *dev_name)
dev->device.name = strdup(dev_name);
if (!dev->device.name) {
DPAA2_BUS_ERR("Unable to clone device name. Out of memory");
+ ret = -ENOMEM;
goto cleanup;
}
dev->device.devargs = fslmc_devargs_lookup(dev);
+ /* Update the device found into the device_count table */
+ rte_fslmc_bus.device_count[dev->dev_type]++;
+
/* Add device in the fslmc device list */
insert_in_device_list(dev);
@@ -222,7 +226,7 @@ scan_one_fslmc_device(char *dev_name)
free(dup_dev_name);
if (dev)
free(dev);
- return -1;
+ return ret;
}
static int
@@ -353,7 +357,7 @@ rte_fslmc_scan(void)
/* Remove all devices in the list */
cleanup_fslmc_device_list();
scan_fail:
- DPAA2_BUS_DEBUG("FSLMC Bus Not Available. Skipping");
+ DPAA2_BUS_DEBUG("FSLMC Bus Not Available. Skipping (%d)", ret);
/* Irrespective of failure, scan only return success */
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2019-07-15 8:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 10:44 [dpdk-dev] [PATCH 1/5] bus/fslmc: support device iteration Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 2/5] bus/fslmc: enhance error handling for dev parsing Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 3/5] bus/fslmc: dynamic iommu mode detection Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 5/5] mempool/dpaa2: vfio dmamap for user allocated memory Hemant Agrawal
2019-06-26 21:50 ` [dpdk-dev] [PATCH 1/5] bus/fslmc: support device iteration Thomas Monjalon
2019-06-27 9:20 ` Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 0/5] FSLMC bus enchancements Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 1/5] bus/fslmc: support device iteration Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 0/5] FSLMC bus enchancements Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 1/5] bus/fslmc: support device iteration Hemant Agrawal
2019-07-15 8:44 ` Hemant Agrawal [this message]
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 3/5] bus/fslmc: dynamic iommu mode detection Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 5/5] mempool/dpaa2: vfio dmamap for user allocated memory Hemant Agrawal
2019-07-15 21:53 ` [dpdk-dev] [PATCH v3 0/5] FSLMC bus enchancements Thomas Monjalon
2019-07-16 11:40 ` Ferruh Yigit
2019-07-16 13:36 ` Thomas Monjalon
2019-07-16 13:43 ` Bruce Richardson
2019-07-19 19:09 ` Ferruh Yigit
2019-07-22 6:56 ` Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 2/5] bus/fslmc: enhance error handling for dev parsing Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 3/5] bus/fslmc: dynamic iommu mode detection Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 5/5] mempool/dpaa2: vfio dmamap for user allocated memory Hemant Agrawal
2019-07-07 19:55 ` Thomas Monjalon
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=20190715084442.14686-3-hemant.agrawal@nxp.com \
--to=hemant.agrawal@nxp.com \
--cc=dev@dpdk.org \
--cc=shreyansh.jain@nxp.com \
--cc=thomas@monjalon.net \
/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).