From patchwork Thu Jun 27 09:33:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 167892 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2092216ilk; Thu, 27 Jun 2019 02:36:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeBOHDnLQvg28h4D+64QvxvsVPHXkxb9uIdfRkteq1BXN5t+KLZvKXTe8pWTPLDatjOt/A X-Received: by 2002:a5d:6a42:: with SMTP id t2mr2427351wrw.352.1561628162351; Thu, 27 Jun 2019 02:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561628162; cv=none; d=google.com; s=arc-20160816; b=veWnYZ65mDcgiD5sZioDqf+j/ZIOLD8FGNPvMq10H3kktmJBfFGDne5hb6Ac4bjlQL AOXISOQG3iHNNNACT/HyxQQ7k91mKMmv8Z54uYpDvUL77ySH/i1lC3jdjX+qmO2FgOPL LeS8NQgEAo51/bJ7McDKbso7I1KDxsSBAPesJj6ABhdLilrgLa9km6WhuiXzUpKBiww2 +JjUO4oklHn25oAFkD2nXLMwzt1TutDjxEwjjMilxm6z+xmqr6RgaroMASg7Io+abaw8 Pv+dzvX8mMNe8ayyya25OA67m9TwIhRtZDVtyj5qXm2ifrv12abqd2G4fF+ehvbERmKU 4sKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=MdNFMkbPdKtAnYo4XqJxrwW5zEGMShy3AcW7my1p9/w=; b=DgbpVxjjnUPgQGXXZ+KtlvM+mmaMY7VFeT8DWqJQQHIxKEz/lAhVu+lInJOIjGb9gL JFiHCMu1Y2wkg7/Lii0WZRxbkk6UuZQy2dIRNf35OAWVJQO0jjpQGdxdB11P6sqNGyCP S5jUNXH7JHztY5ZlerJhR3z9UsGrMFF5/JK8oozdxlfjYJd0nd97aUkdwX3DMZzYayDc RF7wv3BDc/w1CT5I94lqejQVwUwlX+H8SwoRLZ50vvhmJFTzfjORAyXdx43W46hPjHr0 8KM0bdT7Kw8FdhDbhJnzY09eSYc4kxtUvYOnQ9RUJOo96cqgkYrqNwVj502Ua8wfZtSk Qzwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id f25si1491459wrc.305.2019.06.27.02.36.02; Thu, 27 Jun 2019 02:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 57FF52BF2; Thu, 27 Jun 2019 11:35:40 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id CBAC625D9 for ; Thu, 27 Jun 2019 11:35:33 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 669CA200B9F; Thu, 27 Jun 2019 11:35:33 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id B391D200748; Thu, 27 Jun 2019 11:35:31 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id D62D64031E; Thu, 27 Jun 2019 17:35:26 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 27 Jun 2019 15:03:40 +0530 Message-Id: <20190627093343.5171-3-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627093343.5171-1-hemant.agrawal@nxp.com> References: <20190625104411.19565-1-hemant.agrawal@nxp.com> <20190627093343.5171-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 2/5] bus/fslmc: enhance error handling for dev parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Shreyansh Jain In case an incorrect device is found, it was quiting further search rather than skipping it. Signed-off-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_bus.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.17.1 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; }