From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <viktorin@rehivetech.com>
Received: from wes1-so1.wedos.net (wes1-so1-b.wedos.net [46.28.106.43])
 by dpdk.org (Postfix) with ESMTP id 27F61A10
 for <dev@dpdk.org>; Sun, 16 Oct 2016 02:57:05 +0200 (CEST)
Received: from jvn (dynamic-109-81-211-193.ipv4.broadband.iol.cz
 [109.81.211.193])
 by wes1-so1.wedos.net (Postfix) with ESMTPSA id 3sxNG55gtxz4qd;
 Sun, 16 Oct 2016 02:57:01 +0200 (CEST)
Date: Sun, 16 Oct 2016 02:56:58 +0200
From: Jan Viktorin <viktorin@rehivetech.com>
To: Shreyansh Jain <shreyansh.jain@nxp.com>
Cc: <dev@dpdk.org>, <thomas.monjalon@6wind.com>, <david.marchand@6wind.com>
Message-ID: <20161016025658.5182b5b9@jvn>
In-Reply-To: <1476539108-13170-12-git-send-email-shreyansh.jain@nxp.com>
References: <1473410639-10367-1-git-send-email-shreyansh.jain@nxp.com>
 <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com>
 <1476539108-13170-12-git-send-email-shreyansh.jain@nxp.com>
Organization: RehiveTech
X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH v4 11/17] eal/soc: add default scan for Soc
	devices
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Sun, 16 Oct 2016 00:57:05 -0000

On Sat, 15 Oct 2016 19:15:02 +0530
Shreyansh Jain <shreyansh.jain@nxp.com> wrote:

> From: Jan Viktorin <viktorin@rehivetech.com>
> 
> Default implementation which scans the sysfs platform devices hierarchy.
> For each device, extract the ueven and convert into rte_soc_device.
> 
> The information populated can then be used in probe to match against
> the drivers registered.
> 
> Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
> [Shreyansh: restructure commit to be an optional implementation]
> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>

[...]

> +
> +int
> +rte_eal_soc_scan(void)

What about naming it rte_eal_soc_scan_default? This would underline the
fact that this function can be replaced.

Second, this is for the 7/17 patch:
 
-/* register a driver */
 void
 rte_eal_soc_register(struct rte_soc_driver *driver)
 {
+	/* For a valid soc driver, match and scan function
+	 * should be provided.
+	 */
+	RTE_VERIFY(driver != NULL);
+	RTE_VERIFY(driver->match_fn != NULL);
+	RTE_VERIFY(driver->scan_fn != NULL);

What about setting the match_fn and scan_fn to default implementations if they
are NULL? This would make the standard/default approach easier to use.

 	TAILQ_INSERT_TAIL(&soc_driver_list, driver, next);
 }
 

> +{
> +	struct dirent *e;
> +	DIR *dir;
> +	char dirname[PATH_MAX];
> +
> +	dir = opendir(soc_get_sysfs_path());
> +	if (dir == NULL) {
> +		RTE_LOG(ERR, EAL, "%s(): opendir failed: %s\n",
> +			__func__, strerror(errno));
> +		return -1;
> +	}
> +
> +	while ((e = readdir(dir)) != NULL) {
> +		if (e->d_name[0] == '.')
> +			continue;
> +
> +		snprintf(dirname, sizeof(dirname), "%s/%s",
> +				soc_get_sysfs_path(), e->d_name);
> +		if (soc_scan_one(dirname, e->d_name) < 0)
> +			goto error;
> +	}
> +	closedir(dir);
> +	return 0;
> +
> +error:
> +	closedir(dir);
> +	return -1;
> +}
> +
>  /* Init the SoC EAL subsystem */
>  int
>  rte_eal_soc_init(void)



-- 
  Jan Viktorin                E-mail: Viktorin@RehiveTech.com
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic