DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Walker, Benjamin" <benjamin.walker@intel.com>
To: "shreyansh.jain@nxp.com" <shreyansh.jain@nxp.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 3/7] pci: Pass rte_pci_addr to functions instead of separate args
Date: Fri, 2 Dec 2016 16:16:58 +0000	[thread overview]
Message-ID: <1480695417.4630.45.camel@intel.com> (raw)
In-Reply-To: <abed91f3-d6e7-d850-1fd5-3fc3de4f7595@nxp.com>

On Thu, 2016-12-01 at 11:56 +0530, Shreyansh Jain wrote:
> Hello Ben,
> 
> On Thursday 24 November 2016 01:37 AM, Ben Walker wrote:
> > 
> > Instead of passing domain, bus, devid, func, just pass
> > an rte_pci_addr.
> > 
> > Signed-off-by: Ben Walker <benjamin.walker@intel.com>
> > ---
> >  lib/librte_eal/linuxapp/eal/eal_pci.c | 32 +++++++++++++-------------------
> >  1 file changed, 13 insertions(+), 19 deletions(-)
> > 
> > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
> > b/lib/librte_eal/linuxapp/eal/eal_pci.c
> > index 876ba38..073af5f 100644
> > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> > @@ -267,8 +267,7 @@ pci_parse_sysfs_resource(const char *filename, struct
> > rte_pci_device *dev)
> > 
> >  /* Scan one pci sysfs entry, and fill the devices list from it. */
> >  static int
> > -pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
> > -	     uint8_t devid, uint8_t function)
> > +pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
> >  {
> >  	char filename[PATH_MAX];
> >  	unsigned long tmp;
> > @@ -281,10 +280,7 @@ pci_scan_one(const char *dirname, uint16_t domain,
> > uint8_t bus,
> >  		return -1;
> > 
> >  	memset(dev, 0, sizeof(*dev));
> > -	dev->addr.domain = domain;
> > -	dev->addr.bus = bus;
> > -	dev->addr.devid = devid;
> > -	dev->addr.function = function;
> > +	dev->addr = *addr;
> > 
> >  	/* get vendor id */
> >  	snprintf(filename, sizeof(filename), "%s/vendor", dirname);
> > @@ -429,16 +425,14 @@ pci_update_device(const struct rte_pci_addr *addr)
> >  		 pci_get_sysfs_path(), addr->domain, addr->bus, addr-
> > >devid,
> >  		 addr->function);
> > 
> > -	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
> > -				addr->function);
> > +	return pci_scan_one(filename, addr);
> >  }
> > 
> >  /*
> >   * split up a pci address into its constituent parts.
> >   */
> >  static int
> > -parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
> > -		uint8_t *bus, uint8_t *devid, uint8_t *function)
> > +parse_pci_addr_format(const char *buf, int bufsize, struct rte_pci_addr
> > *addr)
> >  {
> >  	/* first split on ':' */
> >  	union splitaddr {
> > @@ -466,10 +460,10 @@ parse_pci_addr_format(const char *buf, int bufsize,
> > uint16_t *domain,
> > 
> >  	/* now convert to int values */
> >  	errno = 0;
> > -	*domain = (uint16_t)strtoul(splitaddr.domain, NULL, 16);
> > -	*bus = (uint8_t)strtoul(splitaddr.bus, NULL, 16);
> > -	*devid = (uint8_t)strtoul(splitaddr.devid, NULL, 16);
> > -	*function = (uint8_t)strtoul(splitaddr.function, NULL, 10);
> > +	addr->domain = (uint16_t)strtoul(splitaddr.domain, NULL, 16);
> > +	addr->bus = (uint8_t)strtoul(splitaddr.bus, NULL, 16);
> > +	addr->devid = (uint8_t)strtoul(splitaddr.devid, NULL, 16);
> > +	addr->function = (uint8_t)strtoul(splitaddr.function, NULL, 10);
> >  	if (errno != 0)
> >  		goto error;
> > 
> > @@ -490,8 +484,7 @@ rte_eal_pci_scan(void)
> >  	struct dirent *e;
> >  	DIR *dir;
> >  	char dirname[PATH_MAX];
> > -	uint16_t domain;
> > -	uint8_t bus, devid, function;
> > +	struct rte_pci_addr addr;
> > 
> >  	dir = opendir(pci_get_sysfs_path());
> >  	if (dir == NULL) {
> > @@ -500,20 +493,21 @@ rte_eal_pci_scan(void)
> >  		return -1;
> >  	}
> > 
> > +
> >  	while ((e = readdir(dir)) != NULL) {
> >  		if (e->d_name[0] == '.')
> >  			continue;
> > 
> > -		if (parse_pci_addr_format(e->d_name, sizeof(e->d_name),
> > &domain,
> > -				&bus, &devid, &function) != 0)
> > +		if (parse_pci_addr_format(e->d_name, sizeof(e->d_name),
> > &addr) != 0)
> >  			continue;
> > 
> >  		snprintf(dirname, sizeof(dirname), "%s/%s",
> >  				pci_get_sysfs_path(), e->d_name);
> > -		if (pci_scan_one(dirname, domain, bus, devid, function) <
> > 0)
> > +		if (pci_scan_one(dirname, &addr) < 0)
> >  			goto error;
> >  	}
> >  	closedir(dir);
> > +
> >  	return 0;
> > 
> >  error:
> > 
> 
> Do you mind if I use this patch directly as part of my patchset for bus 
> Model? I was doing a similar change to make the pci_scan_one simpler 
> (and pass along a new argument)..

Sure, go ahead.

> 
> -
> Shreyansh

  reply	other threads:[~2016-12-02 16:17 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 19:36 [dpdk-dev] Improved PCI hotplug support Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 1/7] pci: If a driver's probe function fails, unmap resources Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 2/7] pci: Separate detaching ethernet ports from PCI devices Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 3/7] pci: Pass rte_pci_addr to functions instead of separate args Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 4/7] pci: rte_eal_pci_scan now handles removal of PCI devices Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 5/7] pci: Move driver registration above pci scan Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 6/7] pci: Combine rte_eal_pci_scan and rte_eal_pci_probe Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 7/7] pci: Clarify interfaces for dynamic attach/detach of drivers Ben Walker
2016-11-23 20:07 ` [dpdk-dev] [PATCH v2 1/7] pci: If a driver's probe function fails, unmap resources Ben Walker
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 2/7] pci: Separate detaching ethernet ports from PCI devices Ben Walker
2016-11-25  9:25     ` Shreyansh Jain
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 3/7] pci: Pass rte_pci_addr to functions instead of separate args Ben Walker
2016-11-25 10:33     ` Shreyansh Jain
2016-12-01  6:26     ` Shreyansh Jain
2016-12-02 16:16       ` Walker, Benjamin [this message]
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 4/7] pci: rte_eal_pci_scan now handles removal of PCI devices Ben Walker
2016-11-25 10:44     ` Shreyansh Jain
2017-02-09 16:59     ` [dpdk-dev] [PATCH v3 1/3] " Ben Walker
2017-02-09 16:59       ` [dpdk-dev] [PATCH v3 2/3] pci: Move driver registration above pci scan Ben Walker
2017-02-09 16:59       ` [dpdk-dev] [PATCH v3 3/3] pci: Clarify interfaces for dynamic attach/detach of drivers Ben Walker
2019-01-23 16:19       ` [dpdk-dev] [PATCH v3 1/3] pci: rte_eal_pci_scan now handles removal of PCI devices Ferruh Yigit
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 5/7] pci: Move driver registration above pci scan Ben Walker
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 6/7] pci: Combine rte_eal_pci_scan and rte_eal_pci_probe Ben Walker
2016-11-25 10:56     ` Shreyansh Jain
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 7/7] pci: Clarify interfaces for dynamic attach/detach of drivers Ben Walker
2016-12-03  6:55     ` Shreyansh Jain
2016-11-25  9:21   ` [dpdk-dev] [PATCH v2 1/7] pci: If a driver's probe function fails, unmap resources Shreyansh Jain
2016-12-21 16:19     ` Thomas Monjalon
2017-01-04 17:39       ` Thomas Monjalon
2017-01-09 17:12         ` Thomas Monjalon
2017-01-11 17:10   ` [dpdk-dev] [PATCH v3 1/3] " Ben Walker
2017-01-11 17:10     ` [dpdk-dev] [PATCH v3 2/3] pci: Separate detaching ethernet ports from PCI devices Ben Walker
2017-01-11 17:10     ` [dpdk-dev] [PATCH v3 3/3] pci: Pass rte_pci_addr to functions instead of separate args Ben Walker
2017-01-12 14:58       ` 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=1480695417.4630.45.camel@intel.com \
    --to=benjamin.walker@intel.com \
    --cc=dev@dpdk.org \
    --cc=shreyansh.jain@nxp.com \
    /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).