[dpdk-dev] [PATCH v2 3/7] pci: Pass rte_pci_addr to functions instead of separate args

2016-12-01 Thread Shreyansh Jain
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 
> ---
>  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), ,
> - , , ) != 0)
> + if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), ) 
> != 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, ) < 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)..

-
Shreyansh


[dpdk-dev] [PATCH v2 6/7] pci: Combine rte_eal_pci_scan and rte_eal_pci_probe

2016-11-25 Thread Shreyansh Jain
On Thursday 24 November 2016 01:37 AM, Ben Walker wrote:
> Two functions is both confusing and unnecessary. Previously,
> rte_eal_pci_scan populated an internal list of devices by
> scanning sysfs. Then, rte_eal_pci_probe would match registered
> drivers to that internal list. These are not really useful
> operations to perform separately, though, so
> simplify the api down to just rte_eal_pci_probe which can
> be called repeatedly through the lifetime of the application
> to scan for new or removed PCI devices and load or unload
> drivers as required.

Agree with this.
And similar case exists for rte_eal_dev_init() for which there is 
another patch floated by Jerin [1].

Also, I am already merging these two (EAL Bus model) [2]. So, we have:
  - Only a probe called from EAL for all devices, whether PCI, VDEV or 
another other type
  - Probe in turns performs all scans and driver->probes()

Concern I have is that with the change of placement for device scan, 
would it impact the external modules/PMDs as currently the scanned list 
is created *before* eal_plugins_init(). But, now the list is created 
*after* plugin initialization.

There are other similar inits like creation of slave threads. As well as 
concern raised by Ferruh about device enumeration.

I don't have clear idea of all such dependencies. Maybe David and Ferruh 
in CC might be able to comment better.

[1] http://dpdk.org/ml/archives/dev/2016-November/050415.html
[2] http://dpdk.org/ml/archives/dev/2016-November/050301.html

>
> Signed-off-by: Ben Walker 
> ---
>  app/test/test_pci.c |  2 +-
>  lib/librte_eal/bsdapp/eal/eal.c |  3 ---
>  lib/librte_eal/bsdapp/eal/eal_pci.c | 17 +
>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 -
>  lib/librte_eal/common/eal_common_pci.c  |  6 ++
>  lib/librte_eal/common/eal_private.h | 14 +-
>  lib/librte_eal/common/include/rte_pci.h | 17 +
>  lib/librte_eal/linuxapp/eal/eal.c   |  3 ---
>  lib/librte_eal/linuxapp/eal/eal_pci.c   | 18 +-
>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 -
>  10 files changed, 19 insertions(+), 63 deletions(-)
>
> diff --git a/app/test/test_pci.c b/app/test/test_pci.c
> index cda186d..fdd84f7 100644
> --- a/app/test/test_pci.c
> +++ b/app/test/test_pci.c
> @@ -180,7 +180,7 @@ test_pci_setup(void)
>   TAILQ_INSERT_TAIL(_pci_device_list, dev, next);
>   }
>
> - ret = rte_eal_pci_scan();
> + ret = rte_eal_pci_probe();
>   TEST_ASSERT_SUCCESS(ret, "failed to scan PCI bus");
>   rte_eal_pci_dump(stdout);
>
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index 35e3117..fd44528 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -561,9 +561,6 @@ rte_eal_init(int argc, char **argv)
>   if (rte_eal_timer_init() < 0)
>   rte_panic("Cannot init HPET or TSC timers\n");
>
> - if (rte_eal_pci_init() < 0)
> - rte_panic("Cannot init PCI\n");
> -
>   eal_check_mem_on_local_socket();
>
>   if (eal_plugins_init() < 0)
> diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
> b/lib/librte_eal/bsdapp/eal/eal_pci.c
> index 8b3ed88..6c3a169 100644
> --- a/lib/librte_eal/bsdapp/eal/eal_pci.c
> +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
> @@ -361,7 +361,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
>   * list. Call pci_scan_one() for each pci entry found.
>   */
>  int
> -rte_eal_pci_scan(void)
> +pci_scan(void)
>  {
>   int fd;
>   unsigned dev_count = 0;
> @@ -667,18 +667,3 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
>
>   return ret;
>  }
> -
> -/* Init the PCI EAL subsystem */
> -int
> -rte_eal_pci_init(void)
> -{
> - /* for debug purposes, PCI can be disabled */
> - if (internal_config.no_pci)
> - return 0;
> -
> - if (rte_eal_pci_scan() < 0) {
> - RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
> - return -1;
> - }
> - return 0;
> -}
> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
> b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> index 2f81f7c..67c469c 100644
> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> @@ -44,7 +44,6 @@ DPDK_2.0 {
>   rte_eal_pci_probe;
>   rte_eal_pci_probe_one;
>   rte_eal_pci_register;
> - rte_eal_pci_scan;
>   rte_eal_pci_unregister;
>   rte_eal_process_type;
>   rte_eal_remote_launch;
> diff --git a/lib/librte_eal/common/eal_common_pci.c 
> b/lib/librte_eal/common/eal_common_pci.c
> index 4f8c3a0..d50a534 100644
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -81,6 +81,7 @@
>  #include 
>
>  #include "eal_private.h"
> +#include "eal_internal_cfg.h"
>
>  struct pci_driver_list pci_driver_list =
> 

[dpdk-dev] [PATCH v2 4/7] pci: rte_eal_pci_scan now handles removal of PCI devices

2016-11-25 Thread Shreyansh Jain
Hi Ben,

On Thursday 24 November 2016 01:37 AM, Ben Walker wrote:
> rte_eal_pci_scan can be called repeatedly to re-scan the PCI
> bus. If a device was removed from the system, the associated
> driver will automatically be unloaded.
>
> Signed-off-by: Ben Walker 
> ---
[...]

While reviewing, I found that there are some checkpatch warnings on this 
patch:

--->8---
### [PATCH v2 4/7] pci: rte_eal_pci_scan now handles removal of PCI devices

WARNING:LONG_LINE_COMMENT: line over 80 characters
#76: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:490:
+   /* Search the device list for devices that are no longer present 
on the system

WARNING:LONG_LINE_STRING: line over 80 characters
#105: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:519:
+   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" 
was removed.\n",

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a 
separate line
#111: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:525:
+* Unload it. */

WARNING:LONG_LINE_STRING: line over 80 characters
#112: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:526:
+   RTE_LOG(DEBUG, EAL, "  Unload driver: 
%x:%x %s\n",

WARNING:LONG_LINE: line over 80 characters
#113: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:527:
+   dev->id.vendor_id, 
dev->id.device_id,

WARNING:LONG_LINE_COMMENT: line over 80 characters
#117: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:531:
+   /* It doesn't matter what remove 
returns -

WARNING:LONG_LINE_COMMENT: line over 80 characters
#118: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:532:
+* we're removing the device 
either way. */

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a 
separate line
#118: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:532:
+* we're removing the device 
either way. */

WARNING:LONG_LINE: line over 80 characters
#125: FILE: lib/librte_eal/linuxapp/eal/eal_pci.c:539:
+   if (dev->driver->drv_flags & 
RTE_PCI_DRV_NEED_MAPPING)

total: 0 errors, 9 warnings, 69 lines checked

--->8---


[dpdk-dev] [PATCH v2 3/7] pci: Pass rte_pci_addr to functions instead of separate args

2016-11-25 Thread Shreyansh Jain
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 
> ---
>  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;
>   }
>
> +

Unnecessary new line.

>   while ((e = readdir(dir)) != NULL) {
>   if (e->d_name[0] == '.')
>   continue;
>
> - if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), ,
> - , , ) != 0)
> + if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), ) 
> != 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, ) < 0)
>   goto error;
>   }
>   closedir(dir);
> +
>   return 0;
>
>  error:
>

This is much more cleaner than passing all the BDF entries.
Except the above unnecessary new line:

Acked-by: Shreyansh Jain 


[dpdk-dev] [PATCH v2 2/7] pci: Separate detaching ethernet ports from PCI devices

2016-11-25 Thread Shreyansh Jain
On Thursday 24 November 2016 01:37 AM, Ben Walker wrote:
> Attaching and detaching ethernet ports from an application
> is not the same thing as physically removing a PCI device,
> so clarify the flags indicating support. All PCI devices
> are assumed to be physically removable, so no flag is
> necessary in the PCI layer.
>
> Signed-off-by: Ben Walker 
> ---
>  doc/guides/prog_guide/port_hotplug_framework.rst | 2 +-
>  drivers/net/bnxt/bnxt_ethdev.c   | 3 ++-
>  drivers/net/e1000/em_ethdev.c| 4 ++--
>  drivers/net/e1000/igb_ethdev.c   | 7 ---
>  drivers/net/fm10k/fm10k_ethdev.c | 4 ++--
>  drivers/net/i40e/i40e_ethdev.c   | 4 ++--
>  drivers/net/i40e/i40e_ethdev_vf.c| 3 ++-
>  drivers/net/ixgbe/ixgbe_ethdev.c | 7 ---
>  drivers/net/nfp/nfp_net.c| 4 ++--
>  drivers/net/virtio/virtio_ethdev.c   | 3 ++-
>  drivers/net/vmxnet3/vmxnet3_ethdev.c | 3 ++-
>  drivers/net/xenvirt/rte_eth_xenvirt.c| 2 +-
>  lib/librte_eal/common/include/rte_pci.h  | 2 --
>  lib/librte_ether/rte_ethdev.c| 2 --
>  14 files changed, 26 insertions(+), 24 deletions(-)
>
> diff --git a/doc/guides/prog_guide/port_hotplug_framework.rst 
> b/doc/guides/prog_guide/port_hotplug_framework.rst
> index 6e4436e..d68d08e 100644
> --- a/doc/guides/prog_guide/port_hotplug_framework.rst
> +++ b/doc/guides/prog_guide/port_hotplug_framework.rst
> @@ -106,5 +106,5 @@ Limitations
>
>  *   Not all PMDs support detaching feature.
>  To know whether a PMD can support detaching, search for the
> -"RTE_PCI_DRV_DETACHABLE" flag in PMD implementation. If the flag is
> +"RTE_ETH_DEV_DETAHABLE" flag in rte_eth_dev::data::dev_flags. If the 
> flag is

Incorrect spelling. Should be 'RTE_ETH_DEV_DETACHABLE'.

>  defined in the PMD, detaching is supported.
> diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
> index 035fe07..a2100f6 100644
> --- a/drivers/net/bnxt/bnxt_ethdev.c
> +++ b/drivers/net/bnxt/bnxt_ethdev.c
> @@ -1051,6 +1051,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
>   RTE_LOG(INFO, PMD, "%s", bnxt_version);
>
>   rte_eth_copy_pci_info(eth_dev, eth_dev->pci_dev);
> + eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
>   bp = eth_dev->data->dev_private;
>
>   if (bnxt_vf_pciid(eth_dev->pci_dev->id.device_id))
[...]

-
Shreyansh



[dpdk-dev] [PATCH v2 1/7] pci: If a driver's probe function fails, unmap resources.

2016-11-25 Thread Shreyansh Jain
On Thursday 24 November 2016 01:37 AM, Ben Walker wrote:
> If resources were mapped prior to probe, unmap them
> if probe fails.
>
> This does not handle the case where the kernel driver was
> forcibly unbound prior to probe.
>
> Signed-off-by: Ben Walker 
> ---
>  lib/librte_eal/common/eal_common_pci.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_pci.c 
> b/lib/librte_eal/common/eal_common_pci.c
> index 6bff675..4f8c3a0 100644
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -215,8 +215,11 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
> struct rte_pci_device *d
>
>   /* call the driver probe() function */
>   ret = dr->probe(dr, dev);
> - if (ret)
> + if (ret) {
>   dev->driver = NULL;
> + if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
> + rte_eal_pci_unmap_device(dev);
> + }
>
>   return ret;
>   }
>

Acked-by: Shreyansh Jain 


[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-23 Thread Shreyansh Jain
I should have replied to this earlier, apologies.

On Sunday 20 November 2016 09:00 PM, David Marchand wrote:
> On Thu, Nov 17, 2016 at 6:29 AM, Shreyansh Jain  
> wrote:
>> DPDK has been inherently a PCI inclined framework. Because of this, the
>> design of device tree (or list) within DPDK is also PCI inclined. A non-PCI
>> device doesn't have a way of being expressed without using hooks started from
>> EAL to PMD.
>>
>> With this cover letter, some patches are presented which try to break this
>> strict linkage of EAL with PCI devices. Aim is to generalize the device
>> hierarchy on the lines of how Linux handles it:
>>
>> device A1
>>   |
>>   +==.'==.+ Bus A.
>>  |`--> driver A11 \
>>   device A2`-> driver A12  \__
>> |CPU |
>> /`
>> device A1  /
>>   |   /
>>   +==.'==.+ Bus A`
>>  |`--> driver B11
>>   device A2`-> driver B12
>>
>> Simply put:
>>  - a bus is connect to CPU (or core)
>>  - devices are conneted to Bus
>>  - drivers are running instances which manage one or more devices
>>  - bus is responsible for identifying devices (and interrupt propogation)
>>  - driver is responsible for initializing the device
>>
>> (*Reusing text from email [1])
>> In context of DPDK EAL:
>>  - a generic bus (not a driver, not a device). I don't know how to categorize
>>a bus. It is certainly not a device, and then handler for a bus (physical)
>>can be considered a 'bus driver'. So, just 'rte_bus'.
>>  - there is a bus for each physical implementation (or virtual). So, a 
>> rte_bus
>>Object for PCI, VDEV, ABC, DEF and so on.
>>  - Buses are registered just like a PMD - RTE_PMD_BUS_REGISTER()
>>  - Each registered bus is part of a doubly list.
>>-- Each device inherits rte_bus
>>-- Each driver inherits rte_bus
>>-- Device and Drivers lists are part of rte_bus
>>  - eth_driver is no more required - it was just a holder for PMDs to register
>>themselves. It can be replaced with rte_xxx_driver and corresponding init/
>>uninit moved to rte_driver
>>  - rte_eth_dev modified to disassociate itself from rte_pci_device and 
>> connect
>>to generic rte_device
>>
>> Once again, improvising from [1]:
>>
>>   __ rte_bus_list
>>  /
>>  +--'---+
>>  |rte_bus   |
>>  | driver_list--> List of rte_bus specific
>>  | device_listdevices
>>  | scan | `-> List of rte_bus associated
>>  | match| drivers
>>  | dump |
>>  | ..some refcnt| (#)
>>  +--|--|+
>>   _/\_
>> +/+ +-\---+
>> |rte_device   | |rte_driver   |
>> | rte_bus | | rte_bus |
>> | rte_driver  |(#)  | init|
>> | | | uninit  |
>> |  devargs| | dev_private_size|
>> +---||+ | drv_flags   |(#)
>> ||  | intr_handle(2*) |(#)
>> | \ +--\\\+
>> |  \_   \\\
>> |\  |||
>>  +--|-+ +|--+   |||
>>  |rte_pci_device  | |rte_xxx_device | (4*)  |||
>>  | PCI specific   | | xxx device|   |||
>>  | info (mem,)| | specific fns  |  / | \
>>  ++ +---+ /  |  \
>> _/  /\
>>/___/  \
>> +-'--++'---++--'+
>> |rte_pci_driver  ||rte_vdev_driver ||rte_xxx_driver |
>> | PCI id table,  || <probably, ||   |
>> | oth

[dpdk-dev] [PATCH v2 3/8] drivers: Use ETH_DEV_PCI_DEV() helper

2016-11-22 Thread Shreyansh Jain
On Monday 21 November 2016 10:25 PM, Jan Blunck wrote:
> The drivers should not directly access the rte_eth_dev->pci_dev but use
> a macro instead. This is a preparation for replacing the pci_dev with
> a struct rte_device member in the future.
>
> Signed-off-by: Jan Blunck 
> ---
>  drivers/net/bnxt/bnxt_ethdev.c   | 19 ++-
>  drivers/net/bnxt/bnxt_ring.c | 11 +++---
>  drivers/net/cxgbe/cxgbe_ethdev.c |  2 +-
>  drivers/net/e1000/em_ethdev.c| 20 ++-
>  drivers/net/e1000/igb_ethdev.c   | 50 +++
>  drivers/net/e1000/igb_pf.c   |  3 +-
>  drivers/net/ena/ena_ethdev.c |  2 +-
>  drivers/net/enic/enic_ethdev.c   |  2 +-
>  drivers/net/fm10k/fm10k_ethdev.c | 49 ++-

I found a couple of placed in the fm10k_ethdev file where pci_dev usage 
can be replaced with ETH_DEV_PCI_DEV() macro. For example,
  - fm10k_dev_tx_init() +681,
  - fm10k_set_tx_function +2774

Can you please check once again?

>  drivers/net/i40e/i40e_ethdev.c   | 44 
>  drivers/net/i40e/i40e_ethdev.h   |  4 +++
>  drivers/net/i40e/i40e_ethdev_vf.c| 38 ++---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 65 
> +---
>  drivers/net/ixgbe/ixgbe_pf.c |  2 +-
>  drivers/net/qede/qede_ethdev.c   | 17 +-
>  drivers/net/vmxnet3/vmxnet3_ethdev.c |  4 +--
>  16 files changed, 185 insertions(+), 147 deletions(-)

Some changes in szedata2 are also on similar lines:
  - rte_szedata2_eth_dev_init +1419, +1420, ... 
  - rte_szedata2_eth_dev_uninit

Some changes in nicvf_ethdev.c also are missing, I think:
  - nicvf_eth_dev_init +1980
  - nicvf_dev_info_get +1350

and nfp/nfp_net.c
  - nfp_net_init(), +2333, +2403
  - nfp_net_close, +718, +737
  - nfp_net_dev_link_status_print
  - nfp_net_irq_unmask, +1161

and bnx2x_ethdev.c
  - bnx2x_common_dev_init
  - and access to intr_handle which can replaced with
ETH_DEV_TO_INTR_HANDLE

Is there any specific reason these changes are not part of your patch?

[...]
> diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
> index 298cef4..9d4bea7 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -671,6 +671,10 @@ i40e_get_vsi_from_adapter(struct i40e_adapter *adapter)
>  #define I40E_VF_TO_HW(vf) \
>   (&(((struct i40e_vf *)vf)->adapter->hw))
>
> +/* ETH_DEV_TO_INTR_HANDLE */
> +#define ETH_DEV_TO_INTR_HANDLE(ptr) \
> + (&(ETH_DEV_PCI_DEV(ptr)->intr_handle))
> +

Can this be in rte_ethdev.h just like ETH_DEV_PCI_DEV?
Or, as this is specific to rte_pci_device, probably in rte_pci.h?
Many drivers can be replaced this for accessing intr_handle.

-
Shreyansh


[dpdk-dev] [PATCH v2 1/8] eal: define container_of macro

2016-11-22 Thread Shreyansh Jain
On Monday 21 November 2016 10:25 PM, Jan Blunck wrote:
> This macro is based on Jan Viktorin's original patch but also checks the
> type of the passed pointer against the type of the member.
>
> Signed-off-by: Jan Viktorin 
> Signed-off-by: Shreyansh Jain 
> [jblunck at infradead.org: add type checking and __extension__]
> Signed-off-by: Jan Blunck 
> ---
>  lib/librte_eal/common/include/rte_common.h | 20 
>  1 file changed, 20 insertions(+)
>
> diff --git a/lib/librte_eal/common/include/rte_common.h 
> b/lib/librte_eal/common/include/rte_common.h
> index db5ac91..8dda3e2 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -331,6 +331,26 @@ rte_bsf32(uint32_t v)
>  #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
>  #endif
>
> +/**
> + * Return pointer to the wrapping struct instance.
> + *
> + * Example:
> + *
> + *  struct wrapper {
> + *  ...
> + *  struct child c;
> + *  ...
> + *  };
> + *
> + *  struct child *x = obtain(...);
> + *  struct wrapper *w = container_of(x, struct wrapper, c);
> + */
> +#ifndef container_of
> +#define container_of(ptr, type, member)  __extension__ ({
> \
> + typeof(((type *)0)->member) *_ptr = (ptr);  \
> + (type *)(((char *)_ptr) - offsetof(type, member)); })
> +#endif
> +
>  #define _RTE_STR(x) #x
>  /** Take a macro value and get a string version of it */
>  #define RTE_STR(x) _RTE_STR(x)
>

I will start using this in my patchset.

Acked-by: Shreyansh Jain 


[dpdk-dev] [PATCH 0/4] libeventdev API and northbound implementation

2016-11-22 Thread Shreyansh Jain
On Tuesday 22 November 2016 07:30 AM, Yuanhan Liu wrote:
> On Sat, Nov 19, 2016 at 12:57:15AM +0530, Jerin Jacob wrote:
>> On Fri, Nov 18, 2016 at 04:04:29PM +, Bruce Richardson wrote:
>>> +Thomas
>>>
>>> On Fri, Nov 18, 2016 at 03:25:18PM +, Bruce Richardson wrote:
 On Fri, Nov 18, 2016 at 11:14:58AM +0530, Jerin Jacob wrote:
> As previously discussed in RFC v1 [1], RFC v2 [2], with changes
> described in [3] (also pasted below), here is the first non-draft series
> for this new API.
>
> [1] http://dpdk.org/ml/archives/dev/2016-August/045181.html
> [2] http://dpdk.org/ml/archives/dev/2016-October/048592.html
> [3] http://dpdk.org/ml/archives/dev/2016-October/048196.html
>
> Changes since RFC v2:
>
> - Updated the documentation to define the need for this library[Jerin]
> - Added RTE_EVENT_QUEUE_CFG_*_ONLY configuration parameters in
>   struct rte_event_queue_conf to enable optimized sw implementation 
> [Bruce]
> - Introduced RTE_EVENT_OP* ops [Bruce]
> - Added nb_event_queue_flows,nb_event_port_dequeue_depth, 
> nb_event_port_enqueue_depth
>   in rte_event_dev_configure() like ethdev and crypto library[Jerin]
> - Removed rte_event_release() and replaced with RTE_EVENT_OP_RELEASE ops 
> to
>   reduce fast path APIs and it is redundant too[Jerin]
> - In the view of better application portability, Removed pin_event
>   from rte_event_enqueue as it is just hint and Intel/NXP can not support 
> it[Jerin]
> - Added rte_event_port_links_get()[Jerin]
> - Added rte_event_dev_dump[Harry]
>
> Notes:
>
> - This patch set is check-patch clean with an exception that
> 02/04 has one WARNING:MACRO_WITH_FLOW_CONTROL
> - Looking forward to getting additional maintainers for libeventdev
>
>
> Possible next steps:
> 1) Review this patch set
> 2) Integrate Intel's SW driver[http://dpdk.org/dev/patchwork/patch/17049/]
> 3) Review proposed examples/eventdev_pipeline 
> application[http://dpdk.org/dev/patchwork/patch/17053/]
> 4) Review proposed functional 
> tests[http://dpdk.org/dev/patchwork/patch/17051/]
> 5) Cavium's HW based eventdev driver
>
> I am planning to work on (3),(4) and (5)
>
 Thanks Jerin,

 we'll review and get back to you with any comments or feedback (1), and
 obviously start working on item (2) also! :-)

 I'm also wonder whether we should have a staging tree for this work to
 make interaction between us easier. Although this may not be
 finalised enough for 17.02 release, do you think having an
 dpdk-eventdev-next tree would be a help? My thinking is that once we get
 the eventdev library itself in reasonable shape following our review, we
 could commit that and make any changes thereafter as new patches, rather
 than constantly respinning the same set. It also gives us a clean git
 tree to base the respective driver implementations on from our two sides.

 Thomas, any thoughts here on your end - or from anyone else?
>>
>> I was thinking more or less along the same lines. To avoid re-spinning the
>> same set, it is better to have libeventdev library mark as EXPERIMENTAL
>> and commit it somewhere on dpdk-eventdev-next or main tree
>>
>> I think, EXPERIMENTAL status can be changed only when
>> - At least two event drivers available
>> - Functional test applications fine with at least two drivers
>> - Portable example application to showcase the features of the library
>> - eventdev integration with another dpdk subsystem such as ethdev
>
> I'm wondering maybe we could have a staging tree, for all features like
> this one (and one branch for each feature)?
>
>   --yliu
>

+1

It would help a lot of 'experimental' stuff reach a wider audience 
without waiting for a complete cycle of upstreaming.
Though, I am not sure how would we limit the branches - or if that is 
even required.

-- 
-
Shreyansh


[dpdk-dev] [PATCH v2 1/8] eal: define container_of macro

2016-11-22 Thread Shreyansh Jain
> -Original Message-
> From: Jan Viktorin [mailto:viktorin at rehivetech.com]
> Sent: Tuesday, November 22, 2016 6:03 PM
> To: Shreyansh Jain 
> Cc: Thomas Monjalon ; Jan Blunck
> ; dev at dpdk.org; david.marchand at 6wind.com
> Subject: Re: [dpdk-dev] [PATCH v2 1/8] eal: define container_of macro
> 
> On Tue, 22 Nov 2016 11:26:50 +
> Shreyansh Jain  wrote:
> 
> > > -Original Message-
> > > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > > Sent: Tuesday, November 22, 2016 3:50 PM
> > > To: Shreyansh Jain ; Jan Blunck
> > > 
> > > Cc: dev at dpdk.org; david.marchand at 6wind.com; Jan Viktorin
> > > 
> > > Subject: Re: [dpdk-dev] [PATCH v2 1/8] eal: define container_of macro
> > >
> > > 2016-11-22 15:33, Shreyansh Jain:
> > > > On Monday 21 November 2016 10:25 PM, Jan Blunck wrote:
> > > > > This macro is based on Jan Viktorin's original patch but also checks
> the
> > > > > type of the passed pointer against the type of the member.
> > > > >
> > > > > Signed-off-by: Jan Viktorin 
> > > > > Signed-off-by: Shreyansh Jain 
> > > > > [jblunck at infradead.org: add type checking and __extension__]
> > > > > Signed-off-by: Jan Blunck 
> > > >
> > > > I will start using this in my patchset.
> > > >
> > > > Acked-by: Shreyansh Jain 
> > >
> > > It is a bit strange to have this patch in a series which do
> > > not use it. I am in favor of getting it when it is used
> > > (and included) in another series.
> >
> > I can add this patch to my series, if Jan is ok about this.
> 
> It's OK. Just merge it someday ;).

Actually, I meant Jan Blunck ;D
I have already been using your patch since long.

> 
> Jan
> 
> >
> > -
> > Shreyansh
> 
> 
> 
> --
>   Jan ViktorinE-mail: Viktorin at RehiveTech.com
>   System ArchitectWeb:www.RehiveTech.com
>   RehiveTech
>   Brno, Czech Republic


[dpdk-dev] [PATCH v2 1/8] eal: define container_of macro

2016-11-22 Thread Shreyansh Jain
> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Tuesday, November 22, 2016 3:50 PM
> To: Shreyansh Jain ; Jan Blunck
> 
> Cc: dev at dpdk.org; david.marchand at 6wind.com; Jan Viktorin
> 
> Subject: Re: [dpdk-dev] [PATCH v2 1/8] eal: define container_of macro
> 
> 2016-11-22 15:33, Shreyansh Jain:
> > On Monday 21 November 2016 10:25 PM, Jan Blunck wrote:
> > > This macro is based on Jan Viktorin's original patch but also checks the
> > > type of the passed pointer against the type of the member.
> > >
> > > Signed-off-by: Jan Viktorin 
> > > Signed-off-by: Shreyansh Jain 
> > > [jblunck at infradead.org: add type checking and __extension__]
> > > Signed-off-by: Jan Blunck 
> >
> > I will start using this in my patchset.
> >
> > Acked-by: Shreyansh Jain 
> 
> It is a bit strange to have this patch in a series which do
> not use it. I am in favor of getting it when it is used
> (and included) in another series.

I can add this patch to my series, if Jan is ok about this.

-
Shreyansh


[dpdk-dev] [PATCH] eal: postpone vdev initialization

2016-11-21 Thread Shreyansh Jain
On Sunday 20 November 2016 01:30 PM, Jerin Jacob wrote:
> Some platform like octeontx may use pci and
> vdev based combined device to represent a logical
> dpdk functional device.In such case, postponing the
> vdev initialization after pci device
> initialization will provide the better view of
> the pci device resources in the system in
> vdev's probe function, and it allows better
> functional subsystem registration in vdev probe
> function.
>
> As a bonus, This patch fixes a bond device
> initialization use case.
>
> example command to reproduce the issue:
> ../testpmd -c 0x2  --vdev 'eth_bond0,mode=0,
> slave=:02:00.0,slave=:03:00.0' --
> --port-topology=chained
>
> root cause:
> In existing case(vdev initialization and then pci
> initialization), creates three Ethernet ports with
> following port ids
> 0 - Bond device
> 1 - PCI device 0
> 2 - PCI devive 1
>
> Since testpmd, calls the configure/start on all the ports on
> start up,it will translate to following illegal setup sequence
>
> 1)bond device configure/start
> 1.1) pci device0 stop/configure/start
> 1.2) pci device1 stop/configure/start
> 2)pci device 0 configure(illegal setup case,
> as device in start state)
>
> The fix changes the initialization sequence and
> allow initialization in following valid setup order
> 1) pcie device 0 configure/start
> 2) pcie device 1 configure/start
> 3) bond device 2 configure/start
> 3.1) pcie device 0/stop/configure/start
> 3.2) pcie device 1/stop/configure/start
>
> Signed-off-by: Jerin Jacob 
> ---
>  lib/librte_eal/bsdapp/eal/eal.c   | 6 +++---
>  lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
> index 35e3117..2206277 100644
> --- a/lib/librte_eal/bsdapp/eal/eal.c
> +++ b/lib/librte_eal/bsdapp/eal/eal.c
> @@ -577,9 +577,6 @@ rte_eal_init(int argc, char **argv)
>   rte_config.master_lcore, thread_id, cpuset,
>   ret == 0 ? "" : "...");
>
> - if (rte_eal_dev_init() < 0)
> - rte_panic("Cannot init pmd devices\n");
> -
>   RTE_LCORE_FOREACH_SLAVE(i) {
>
>   /*
> @@ -616,6 +613,9 @@ rte_eal_init(int argc, char **argv)
>   if (rte_eal_pci_probe())
>   rte_panic("Cannot probe PCI\n");
>
> + if (rte_eal_dev_init() < 0)
> + rte_panic("Cannot init pmd devices\n");
> +
>   rte_eal_mcfg_complete();
>
>   return fctret;
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
> b/lib/librte_eal/linuxapp/eal/eal.c
> index 2075282..16dd5b9 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -841,9 +841,6 @@ rte_eal_init(int argc, char **argv)
>   rte_config.master_lcore, (int)thread_id, cpuset,
>   ret == 0 ? "" : "...");
>
> - if (rte_eal_dev_init() < 0)
> - rte_panic("Cannot init pmd devices\n");
> -
>   if (rte_eal_intr_init() < 0)
>   rte_panic("Cannot init interrupt-handling thread\n");
>
> @@ -887,6 +884,9 @@ rte_eal_init(int argc, char **argv)
>   if (rte_eal_pci_probe())
>   rte_panic("Cannot probe PCI\n");
>
> + if (rte_eal_dev_init() < 0)
> + rte_panic("Cannot init pmd devices\n");
> +
>   rte_eal_mcfg_complete();
>
>   return fctret;
>

Movement looks fine to me.

IMO, rte_eal_dev_init() is a misleading name. It actually performs a 
driver->probe for vdev - which is parallel to rte_eal_pci_probe.

-
Shreyansh


[dpdk-dev] [RFC PATCH 6/6] eal: removing eth_driver

2016-11-18 Thread Shreyansh Jain
sorry for delay in responding; somehow I didn't notice this email.

On Thursday 17 November 2016 06:23 PM, Jan Blunck wrote:
> On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain  
> wrote:
>> This patch demonstrates how eth_driver can be replaced with appropriate
>> changes for rte_xxx_driver from the PMD itself. It uses ixgbe_ethernet as
>> an example.
>>
>> A large set of changes exists in the rte_ethdev.c - primarily because too
>> much PCI centric code (names, assumption of rte_pci_device) still exists
>> in it. Most, except symbol naming, has been changed in this patch.
>>
>> This proposes that:
>>  - PMD would declare the rte_xxx_driver. In case of ixgbe, it would be
>>rte_pci_driver.
>>  - Probe and remove continue to exists in rte_pci_driver. But, the
>>rte_driver has new hooks for init and uninit. The rationale is that
>>once a ethernet or cryto device is created, the rte_driver->init would
>>be responsible for initializing the device.
>>-- Eth_dev -> rte_driver -> rte_pci_driver
>>   |`-> probe/remove
>>   `--> init/uninit
>
> Hmm, from my perspective this moves struct rte_driver a step closer to
> struct rte_eth_dev instead of decoupling them. It is up to the
> rte_driver->probe if it wants to allocate a struct rte_eth_dev,
> rte_crypto_dev or the famous rte_foo_dev.

That 'closeness' was my intention - to make rte_eth_dev an 
implementation of rte_device type.

rte_eth_dev == rte_cryptodev == rte_anyother_functional_device
- for the above context. All would include rte_device.

As for rte_driver->probe(), it still comes in the rte_driver->init()'s 
role to initialize the 'generic' functional device associated with the 
driver. And, allowing bus specific driver (like PCI) for its individual 
initialization using rte_xxx_driver->probe.

>
> Instead of explicitly modelling rte_eth_dev specifics like init, unit
> or dev_private_size I think we should delegate this to the
> rte_driver->probe instead. Most of what is in rte_eth_dev_pci_probe()
> today is anyway a rte_eth_dev_allocate_priv() anyway. I already have
> some patches in this area in my patch stack.

Can be done - either way rte_pci_driver->probe() ends up calling 
driver->init() (or erstwhile eth_driver->eth_dev_init()).

But, I still think it is better to keep them separate.
A PCI device is type of rte_device, physically.
A ethernet device is type of rte_device, logically.
They both should exist independently. It will help in splitting the 
functionality from physical layout in future - if need be.

>
>
>>  - necessary changes in the rte_eth_dev have also been done so that it
>>refers to the rte_device and rte_driver rather than rte_xxx_*. This
>>would imply, ethernet device is 'linked' to a rte_device/rte_driver
>>which in turn is a rte_xxx_device/rte_xxx_driver type.
>>- for all operations related to extraction relvant xxx type,
>>  container_of would have to be used.
>>
>> Signed-off-by: Shreyansh Jain 
>> ---
>>  drivers/net/ixgbe/ixgbe_ethdev.c | 49 
>> +---
>>  lib/librte_ether/rte_ethdev.c| 36 +
>>  lib/librte_ether/rte_ethdev.h|  6 ++---
>>  3 files changed, 51 insertions(+), 40 deletions(-)
>>
>> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c 
>> b/drivers/net/ixgbe/ixgbe_ethdev.c
>> index edc9b22..acead31 100644
>> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
>> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>> @@ -1419,7 +1419,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
>> return 0;
>> }
>>
>> -   pci_dev = eth_dev->pci_dev;
>> +   pci_dev = container_of(eth_dev->device, struct rte_pci_device, 
>> device);
>>
>> rte_eth_copy_pci_info(eth_dev, pci_dev);
>>
>> @@ -1532,7 +1532,9 @@ static int
>>  eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
>>  {
>> struct ixgbe_hw *hw;
>> -   struct rte_pci_device *pci_dev = eth_dev->pci_dev;
>> +   struct rte_pci_device *pci_dev;
>> +
>> +   pci_dev = container_of(eth_dev->device, struct rte_pci_device, 
>> device);
>>
>> PMD_INIT_FUNC_TRACE();
>>
>> @@ -1562,32 +1564,33 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
>> return 0;
>>  }
>>
>> -static struct eth_driver rte_ixgbe_pmd = {
>> -   .pci_drv = {
>> -   .id_table = pci_id_ixgbe_map,
>> -   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_P

[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-17 Thread Shreyansh Jain
On Thursday 17 November 2016 05:25 PM, Jan Blunck wrote:
> On Thu, Nov 17, 2016 at 6:29 AM, Shreyansh Jain  
> wrote:
>> DPDK has been inherently a PCI inclined framework. Because of this, the
>> design of device tree (or list) within DPDK is also PCI inclined. A non-PCI
>> device doesn't have a way of being expressed without using hooks started from
>> EAL to PMD.
>>
>> With this cover letter, some patches are presented which try to break this
>> strict linkage of EAL with PCI devices. Aim is to generalize the device
>> hierarchy on the lines of how Linux handles it:
>>
>> device A1
>>   |
>>   +==.'==.+ Bus A.
>>  |`--> driver A11 \
>>   device A2`-> driver A12  \__
>> |CPU |
>> /`
>> device A1  /
>>   |   /
>>   +==.'==.+ Bus A`
>>  |`--> driver B11
>>   device A2`-> driver B12
>>
>> Simply put:
>>  - a bus is connect to CPU (or core)
>>  - devices are conneted to Bus
>>  - drivers are running instances which manage one or more devices
>>  - bus is responsible for identifying devices (and interrupt propogation)
>>  - driver is responsible for initializing the device
>>
>> (*Reusing text from email [1])
>> In context of DPDK EAL:
>>  - a generic bus (not a driver, not a device). I don't know how to categorize
>>a bus. It is certainly not a device, and then handler for a bus (physical)
>>can be considered a 'bus driver'. So, just 'rte_bus'.
>>  - there is a bus for each physical implementation (or virtual). So, a 
>> rte_bus
>>Object for PCI, VDEV, ABC, DEF and so on.
>>  - Buses are registered just like a PMD - RTE_PMD_BUS_REGISTER()
>>  - Each registered bus is part of a doubly list.
>>-- Each device inherits rte_bus
>>-- Each driver inherits rte_bus
>>-- Device and Drivers lists are part of rte_bus
>>  - eth_driver is no more required - it was just a holder for PMDs to register
>>themselves. It can be replaced with rte_xxx_driver and corresponding init/
>>uninit moved to rte_driver
>>  - rte_eth_dev modified to disassociate itself from rte_pci_device and 
>> connect
>>to generic rte_device
>>
>> Once again, improvising from [1]:
>>
>>   __ rte_bus_list
>>  /
>>  +--'---+
>>  |rte_bus   |
>>  | driver_list--> List of rte_bus specific
>>  | device_listdevices
>>  | scan | `-> List of rte_bus associated
>>  | match| drivers
>>  | dump |
>>  | ..some refcnt| (#)
>>  +--|--|+
>>   _/\_
>> +/+ +-\---+
>> |rte_device   | |rte_driver   |
>> | rte_bus | | rte_bus |
>> | rte_driver  |(#)  | init|
>> | | | uninit  |
>> |  devargs| | dev_private_size|
>> +---||+ | drv_flags   |(#)
>> ||  | intr_handle(2*) |(#)
>> | \ +--\\\+
>> |  \_   \\\
>> |\  |||
>>  +--|-+ +|--+   |||
>>  |rte_pci_device  | |rte_xxx_device | (4*)  |||
>>  | PCI specific   | | xxx device|   |||
>>  | info (mem,)| | specific fns  |  / | \
>>  ++ +---+ /  |  \
>> _/  /\
>>/___/  \
>> +-'--++'---++--'+
>> |rte_pci_driver  ||rte_vdev_driver ||rte_xxx_driver |
>> | PCI id table,  || <probably, ||   |
>> | other driver   ||  nothing>  |+---

[dpdk-dev] [RFC PATCH 1/6] eal: define container macro

2016-11-17 Thread Shreyansh Jain
On Thursday 17 November 2016 05:36 PM, Jan Blunck wrote:
> On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain  
> wrote:
>> From: Jan Viktorin 
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> ---
>>  lib/librte_eal/common/include/rte_common.h | 18 ++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/lib/librte_eal/common/include/rte_common.h 
>> b/lib/librte_eal/common/include/rte_common.h
>> index db5ac91..8152bd9 100644
>> --- a/lib/librte_eal/common/include/rte_common.h
>> +++ b/lib/librte_eal/common/include/rte_common.h
>> @@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)
>>  #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
>>  #endif
>>
>> +/**
>> + * Return pointer to the wrapping struct instance.
>> + * Example:
>> + *
>> + *  struct wrapper {
>> + *  ...
>> + *  struct child c;
>> + *  ...
>> + *  };
>> + *
>> + *  struct child *x = obtain(...);
>> + *  struct wrapper *w = container_of(x, struct wrapper, c);
>> + */
>> +#ifndef container_of
>> +#define container_of(p, type, member) \
>> +   ((type *) (((char *) (p)) - offsetof(type, member)))
>
> Are there any reasons why you choose to implement this in a non-type
> safe way? Catching obvious bugs at compile time is in the interest of
> us and our users from my point of view.

No specific reason. I just took an existing patchset floating in ML. If 
you can point me to some better implementation, I will use that.

>
>
>> +#endif
>> +
>>  #define _RTE_STR(x) #x
>>  /** Take a macro value and get a string version of it */
>>  #define RTE_STR(x) _RTE_STR(x)
>> --
>> 2.7.4
>>
>


-- 
-
Shreyansh


[dpdk-dev] [RFC PATCH 2/6] eal: introduce bus-device-driver structure

2016-11-17 Thread Shreyansh Jain
Hello Jan,

Thanks for comments. Replies inline.

On Thursday 17 November 2016 04:49 PM, Jan Blunck wrote:
> On Thu, Nov 17, 2016 at 6:30 AM, Shreyansh Jain  
> wrote:
>> A device is connected to a bus and services by a driver associated with
>> the bus. It is responsibility of the bus to identify the devices (scan)
>> and then assign each device to a matching driver.
>>
>> A PMD would allocate a rte_xxx_driver and rte_xxx_device.
>> rte_xxx_driver has rte_driver and rte_bus embedded. Similarly, rte_xxx_device
>> has rte_device and rte_bus embedded.
>
> I don't think so: the rte_xxx_device embeds the generic rte_device and
> references a the rte_bus
> that it is attached to.

You mean?

  struct rte_pci_device {
struct rte_device device;
struct rte_bus *bus;
...
}

If yes then I have a different view.
'device' is connected to a bus. pci_device is just a type of device. 
Only way it should know about the bus is through the parent rte_device.
rte_device can reference the bus.

>
>> When a ethernet or crypto device (rte_eth_dev, rte_cryptodev) is allocated,
>> it contains a reference of rte_device and rte_driver.
>> Each ethernet device implementation would use container_of for finding the
>> enclosing structure of rte_xxx_*.
>>
>> +---+
>>  +--+   |rte_pci_device |
>>  |rte_eth_dev   |   |+-+|
>>  |++|   .>rte_device   ||
>>  ||rte_device*-'|+-+|
>>  |++|   ||rte_bus  ||
>>  |  |   |+-+|
>>  /  /   +---+
>>
>> Signed-off-by: Shreyansh Jain 
>> ---
>>  lib/librte_eal/common/include/rte_bus.h | 243 
>> 
>>  lib/librte_eal/common/include/rte_dev.h |  36 ++---
>>  2 files changed, 261 insertions(+), 18 deletions(-)
>>  create mode 100644 lib/librte_eal/common/include/rte_bus.h
>>
>> diff --git a/lib/librte_eal/common/include/rte_bus.h 
>> b/lib/librte_eal/common/include/rte_bus.h
>> new file mode 100644
>> index 000..dc3aeb8
>> --- /dev/null
>> +++ b/lib/librte_eal/common/include/rte_bus.h
>> @@ -0,0 +1,243 @@
>> +/*-
>> + *   BSD LICENSE
>> + *
>> + *   Copyright(c) 2016 NXP
>> + *   All rights reserved.
>> + *
>> + *   Redistribution and use in source and binary forms, with or without
>> + *   modification, are permitted provided that the following conditions
>> + *   are met:
>> + *
>> + * * Redistributions of source code must retain the above copyright
>> + *   notice, this list of conditions and the following disclaimer.
>> + * * Redistributions in binary form must reproduce the above copyright
>> + *   notice, this list of conditions and the following disclaimer in
>> + *   the documentation and/or other materials provided with the
>> + *   distribution.
>> + * * Neither the name of NXP nor the names of its
>> + *   contributors may be used to endorse or promote products derived
>> + *   from this software without specific prior written permission.
>> + *
>> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
>> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
>> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
>> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
>> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
>> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
>> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
>> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> + */
>> +
>> +#ifndef _RTE_BUS_H_
>> +#define _RTE_BUS_H_
>> +
>> +/**
>> + * @file
>> + *
>> + * RTE PMD Bus Abstraction interfaces
>> + *
>> + * This file exposes APIs and Interfaces for Bus Abstraction over the 
>> devices
>> + * drivers in EAL.
>> + */
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +
>> +
>> +/** 

[dpdk-dev] [RFC PATCH 6/6] eal: removing eth_driver

2016-11-17 Thread Shreyansh Jain
This patch demonstrates how eth_driver can be replaced with appropriate
changes for rte_xxx_driver from the PMD itself. It uses ixgbe_ethernet as
an example.

A large set of changes exists in the rte_ethdev.c - primarily because too
much PCI centric code (names, assumption of rte_pci_device) still exists
in it. Most, except symbol naming, has been changed in this patch.

This proposes that:
 - PMD would declare the rte_xxx_driver. In case of ixgbe, it would be
   rte_pci_driver.
 - Probe and remove continue to exists in rte_pci_driver. But, the
   rte_driver has new hooks for init and uninit. The rationale is that
   once a ethernet or cryto device is created, the rte_driver->init would
   be responsible for initializing the device.
   -- Eth_dev -> rte_driver -> rte_pci_driver
  |`-> probe/remove
  `--> init/uninit
 - necessary changes in the rte_eth_dev have also been done so that it
   refers to the rte_device and rte_driver rather than rte_xxx_*. This
   would imply, ethernet device is 'linked' to a rte_device/rte_driver
   which in turn is a rte_xxx_device/rte_xxx_driver type.
   - for all operations related to extraction relvant xxx type,
 container_of would have to be used.

Signed-off-by: Shreyansh Jain 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 49 +---
 lib/librte_ether/rte_ethdev.c| 36 +
 lib/librte_ether/rte_ethdev.h|  6 ++---
 3 files changed, 51 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index edc9b22..acead31 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1419,7 +1419,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
return 0;
}

-   pci_dev = eth_dev->pci_dev;
+   pci_dev = container_of(eth_dev->device, struct rte_pci_device, device);

rte_eth_copy_pci_info(eth_dev, pci_dev);

@@ -1532,7 +1532,9 @@ static int
 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
 {
struct ixgbe_hw *hw;
-   struct rte_pci_device *pci_dev = eth_dev->pci_dev;
+   struct rte_pci_device *pci_dev;
+
+   pci_dev = container_of(eth_dev->device, struct rte_pci_device, device);

PMD_INIT_FUNC_TRACE();

@@ -1562,32 +1564,33 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
return 0;
 }

-static struct eth_driver rte_ixgbe_pmd = {
-   .pci_drv = {
-   .id_table = pci_id_ixgbe_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
-   RTE_PCI_DRV_DETACHABLE,
-   .probe = rte_eth_dev_pci_probe,
-   .remove = rte_eth_dev_pci_remove,
+static struct rte_pci_driver rte_ixgbe_pci_driver = {
+   .id_table = pci_id_ixgbe_map,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
+RTE_PCI_DRV_DETACHABLE,
+   .probe = rte_eth_dev_pci_probe,
+   .remove = rte_eth_dev_pci_remove,
+   .driver = {
+   .driver_init_t= eth_ixgbe_dev_init,
+   .driver_uninit_t= eth_ixgbe_dev_uninit,
+   .dev_private_size = sizeof(struct ixgbe_adapter),
},
-   .eth_dev_init = eth_ixgbe_dev_init,
-   .eth_dev_uninit = eth_ixgbe_dev_uninit,
-   .dev_private_size = sizeof(struct ixgbe_adapter),
 };

 /*
  * virtual function driver struct
  */
-static struct eth_driver rte_ixgbevf_pmd = {
-   .pci_drv = {
-   .id_table = pci_id_ixgbevf_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
-   .probe = rte_eth_dev_pci_probe,
-   .remove = rte_eth_dev_pci_remove,
+static struct rte_pci_driver rte_ixgbevf_pci_driver = {
+   .id_table = pci_id_ixgbevf_map,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+   .probe = rte_eth_dev_pci_probe,
+   .remove = rte_eth_dev_pci_remove,
+   .driver = {
+   /* rte_driver hooks */
+   .init = eth_ixgbevf_dev_init,
+   .uninit = eth_ixgbevf_dev_uninit,
+   .dev_private_size = sizeof(struct ixgbe_adapter),
},
-   .eth_dev_init = eth_ixgbevf_dev_init,
-   .eth_dev_uninit = eth_ixgbevf_dev_uninit,
-   .dev_private_size = sizeof(struct ixgbe_adapter),
 };

 static int
@@ -7592,7 +7595,7 @@ ixgbevf_dev_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
ixgbevf_dev_interrupt_action(dev);
 }

-RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pci_driver);
 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
-RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd.pci_drv);
+RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pci_driver);
 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/libr

[dpdk-dev] [RFC PATCH 5/6] eal: supporting bus model in init process

2016-11-17 Thread Shreyansh Jain
This patch makes necessary changes to the EAL for handling bus scan and
probe. Most of the scan function has been moved to bus/* implementation,
(currently only for pci, linuxapp). There are still some functions which
exists in the EAL (bind, unbind module, mmap etc).

Missing/Grey area;
 - Should all the operations for a PCI device, whether binding to a driver
   or mmap, be moved to PCI bus code base? All of that is not relevant for
   a bus, but then having multiple implementation areas for a common
   sub-system (PCI, here) is also not a nice thing.

Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/linuxapp/eal/Makefile  |   1 +
 lib/librte_eal/linuxapp/eal/eal.c |  51 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c | 298 --
 3 files changed, 44 insertions(+), 306 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index 4e206f0..124dceb 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_bus.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 2075282..332d1f4 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -739,6 +739,44 @@ static int rte_eal_vfio_setup(void)
 }
 #endif

+static int
+rte_eal_scan(void)
+{
+   int ret = 0;
+
+   /* For now, as vdev replacement is not complete, continue with a call
+* rte_bus_list scan
+*/
+   rte_eal_bus_scan();
+
+   ret = rte_eal_dev_init();
+   if (ret) {
+   RTE_LOG(ERR, EAL, "Cannot init pmd devices\n");
+   }
+
+out:
+   return ret;
+}
+
+static int
+rte_eal_probe(void)
+{
+   int ret = 0;
+
+   /* Probe & Initialize PCI devices */
+   ret = rte_eal_pci_probe();
+   if (ret) {
+   RTE_LOG(ERR, EAL, "Cannot probe PCI\n");
+   goto out;
+   }
+
+   /* ToDo: vdev scan already does the probe - it should be moved here */
+
+   /* Last successful bus probe would set ret = 0 */
+out:
+   return ret;
+}
+
 /* Launch threads, called at application init(). */
 int
 rte_eal_init(int argc, char **argv)
@@ -802,9 +840,6 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
rte_panic("Cannot init logs\n");

-   if (rte_eal_pci_init() < 0)
-   rte_panic("Cannot init PCI\n");
-
 #ifdef VFIO_PRESENT
if (rte_eal_vfio_setup() < 0)
rte_panic("Cannot init VFIO\n");
@@ -828,6 +863,9 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_timer_init() < 0)
rte_panic("Cannot init HPET or TSC timers\n");

+   if (rte_eal_scan() < 0)
+   rte_panic("Cannot scan for devices\n");
+
eal_check_mem_on_local_socket();

if (eal_plugins_init() < 0)
@@ -841,9 +879,6 @@ rte_eal_init(int argc, char **argv)
rte_config.master_lcore, (int)thread_id, cpuset,
ret == 0 ? "" : "...");

-   if (rte_eal_dev_init() < 0)
-   rte_panic("Cannot init pmd devices\n");
-
if (rte_eal_intr_init() < 0)
rte_panic("Cannot init interrupt-handling thread\n");

@@ -884,8 +919,8 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_wait_lcore();

/* Probe & Initialize PCI devices */
-   if (rte_eal_pci_probe())
-   rte_panic("Cannot probe PCI\n");
+   if (rte_eal_probe())
+   rte_panic("Cannot complete probe\n");

rte_eal_mcfg_complete();

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 876ba38..e3916ab 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -224,202 +224,6 @@ pci_parse_one_sysfs_resource(char *line, size_t len, 
uint64_t *phys_addr,
return 0;
 }

-/* parse the "resource" sysfs file */
-static int
-pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
-{
-   FILE *f;
-   char buf[BUFSIZ];
-   int i;
-   uint64_t phys_addr, end_addr, flags;
-
-   f = fopen(filename, "r");
-   if (f == NULL) {
-   RTE_LOG(ERR, EAL, "Cannot open sysfs resource\n");
-   return -1;
-   

[dpdk-dev] [RFC PATCH 4/6] eal/common: handle bus abstraction for device/driver objects

2016-11-17 Thread Shreyansh Jain
Primary changes done by this patch are based on:
 - Devices belong to the bus hence the device list is bus instance
   specific
 - Similarly, drivers belong to the bus and thus they too are enclosed
   within the bus instance.
 - All device insertion and driver registration should proceed through
   bus APIs. A new file, eal_common_bus.c has been added for that.

Exiting driver registration and device insert/remove APIs have been
modified to work with bus on which device/driver belong. On the same
lines, the PCI common functions have been modified to work with bus rather
than device/driver directly.

rte_eal_pci_scan is no longer an exposed API. It is part of the bus
implementation. Though, probe continues to be part of the common PCI
operations.

Probe has been split into match and probe. Match has been moved to bus/*
code and is a hook now. EAL code would be modified to handle this hook.

Missing/Grey area:
 - Some API like inserting a device at a particular position in the device
   list are missing. Same for driver. These are needed for cases where
   device update is done rather than addition.
 - Probe is a property of a driver but it should be initiated from a bus,
   for example when added a new device (hotplugging). At present
   rte_driver has the probe hook. This should be wrapped around some API
   at the bus level so that bus can search through multiple drivers
   associated with it for calling probe.

Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_bus.c  | 188 ++
 lib/librte_eal/common/eal_common_dev.c  |  31 +++--
 lib/librte_eal/common/eal_common_pci.c  | 226 +++-
 lib/librte_eal/common/include/rte_pci.h |  11 +-
 4 files changed, 342 insertions(+), 114 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_bus.c

diff --git a/lib/librte_eal/common/eal_common_bus.c 
b/lib/librte_eal/common/eal_common_bus.c
new file mode 100644
index 000..3de1ac7
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -0,0 +1,188 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 NXP
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of NXP nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "eal_private.h"
+
+/** @internal
+ * Add a device to a bus.
+ */
+void
+rte_eal_bus_add_device(struct rte_bus *bus, struct rte_device *dev)
+{
+   /* XXX all the additions can be address ordered ?
+* for example, calling rte_eal_compare_pci_addr and getting <=
+* and performing insert a specific location
+*/
+   RTE_VERIFY(bus);
+   RTE_VERIFY(dev);
+
+   TAILQ_INSERT_TAIL(>device_list, dev, next);
+}
+
+/** @internal
+ * Remove a device from its bus.
+ */
+void
+rte_eal_bus_remove_device(struct rte_device *dev)
+{
+   struct rte_bus *bus;
+   RTE_VERIFY(bus);
+   RTE_VERIFY(dev);
+
+   bus = dev->bus;
+   TAILQ_REMOVE(>device_list, dev, next);
+}
+
+/** @internal
+ * Associate a driver with a bus.
+ */
+void
+rte_eal_bus_add_driver(struct rte_bus *bus, struct rte_driver *drv)
+{
+   RTE_VERIFY(bus);
+   RTE_VERIFY(drv);
+
+   TAILQ_INSERT_TAIL(>driver_list, drv, next);
+}
+
+/** @internal
+ * Disassociate a driver from bus.
+ */
+void
+rte_eal_bus_remove_driver(struct rte_driver *drv)
+{
+   struct rte_bus *bus;
+   RTE_

[dpdk-dev] [RFC PATCH 3/6] bus: add bus driver layer

2016-11-17 Thread Shreyansh Jain
A bus is managed using a 'bus driver'. This patch introduces a sample
PCI bus driver which essentially is the scan and match implementation for
PCI.

There are multiple possible alternatives to where such a driver can be
kept within the DPDK code:
1. librte_bus
 - For each type of bus, there would a file like 'eal_xxx_bus' which would
   then be bound with the eal library.
 - Within this way, another possibility was librte_bus_xxx.

2. Within the drivers/* folder:
 - drivers/bus, parallel to drivers/net and drivers/crypto
 - This way, each bus implmentation would be within the drivers/* area and
   a new implementation would only mean adding a new set of files and
   corresponding changes to the Makefiles.

3. Problem with (3) is that the naming is misleading. drivers/net and
   drivers/crypto are essentially two functionalities rather than drivers.
   Putting driver/bus parallel to these would be misleading in literal
   terms.
   Another possibility is to keep the drivers parallel to 'drivers' folder
   in root of DPDK.
   This is the implementation preferred in this patch.
   A new bus would mean adding a new folder structure within 'bus' -
   including distinction between linuxapp and bsdapp.

In all the three cases, the bus drivers would be instantiated using a
constructor similar to RTE_PMD_REGISTER_XXX. OR, specifically in case of
(2), it would be a priority based constructor.
(__attribute__((contructor(XX))) to assure that buses are loaded before
the drivers are loaded.

Further, as of now the 'pci_bus.c' only shows the scan and dump hooks.
rte_bus also includes hooks for 'dump'ing all devices on the bus and
'find_dev' for finding a device given its rte_device. Each of these
'optional' implementation are more like helpers but have implementation
which is specific to the bus. Hooks for finding a device can be used for
hotplugging (searching before adding a new device, removing existing).
Similarly, 'dump' is a way to represent device information in bus specific
way.

Missing/Grey areas:
 - A lot of PCI specific code is still in EAL - for example mapping. These
   can be moved into bus. Mapping of memory should be a bus property.
 - PMDINFOGEN symbol support for bus - this patch doesn't take care of
   that
 - there would be multiple lists for each bus. Would those be shared
   across various libraries, internal or external, which can be associated
   with DPDK? Should a tailq registration like method be used?

Pending work:
 - The integration of bus/* with librte_eal is not complete. There might
   be symbol issues.
 - Notification support for drivers over a bus doesn't exist yet. Probably
   that needs to be integrated with interrupt handling - no work on this
   has been done yet.

Signed-off-by: Shreyansh Jain 
---
 bus/Makefile   |  36 
 bus/pci/Makefile   |  37 
 bus/pci/linuxapp/pci_bus.c | 418 +
 bus/pci/linuxapp/pci_bus.h |  55 ++
 4 files changed, 546 insertions(+)
 create mode 100644 bus/Makefile
 create mode 100644 bus/pci/Makefile
 create mode 100644 bus/pci/linuxapp/pci_bus.c
 create mode 100644 bus/pci/linuxapp/pci_bus.h

diff --git a/bus/Makefile b/bus/Makefile
new file mode 100644
index 000..cfa548c
--- /dev/null
+++ b/bus/Makefile
@@ -0,0 +1,36 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 NXP.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of NXP nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+DIR

[dpdk-dev] [RFC PATCH 2/6] eal: introduce bus-device-driver structure

2016-11-17 Thread Shreyansh Jain
A device is connected to a bus and services by a driver associated with
the bus. It is responsibility of the bus to identify the devices (scan)
and then assign each device to a matching driver.

A PMD would allocate a rte_xxx_driver and rte_xxx_device.
rte_xxx_driver has rte_driver and rte_bus embedded. Similarly, rte_xxx_device
has rte_device and rte_bus embedded.

When a ethernet or crypto device (rte_eth_dev, rte_cryptodev) is allocated,
it contains a reference of rte_device and rte_driver.
Each ethernet device implementation would use container_of for finding the
enclosing structure of rte_xxx_*.

+---+
 +--+   |rte_pci_device |
 |rte_eth_dev   |   |+-+|
 |++|   .>rte_device   ||
 ||rte_device*-'|+-+|
 |++|   ||rte_bus  ||
 |  |   |+-+|
 /  /   +---+

Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/include/rte_bus.h | 243 
 lib/librte_eal/common/include/rte_dev.h |  36 ++---
 2 files changed, 261 insertions(+), 18 deletions(-)
 create mode 100644 lib/librte_eal/common/include/rte_bus.h

diff --git a/lib/librte_eal/common/include/rte_bus.h 
b/lib/librte_eal/common/include/rte_bus.h
new file mode 100644
index 000..dc3aeb8
--- /dev/null
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -0,0 +1,243 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 NXP
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of NXP nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_BUS_H_
+#define _RTE_BUS_H_
+
+/**
+ * @file
+ *
+ * RTE PMD Bus Abstraction interfaces
+ *
+ * This file exposes APIs and Interfaces for Bus Abstraction over the devices
+ * drivers in EAL.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+#include 
+#include 
+
+
+/** Double linked list of buses */
+TAILQ_HEAD(rte_bus_list, rte_bus);
+
+/**
+ * Bus specific scan for devices attached on the bus.
+ * For each bus object, the scan would be reponsible for finding devices and
+ * adding them to its private device list.
+ *
+ * Successful detection of a device results in rte_device object which is
+ * embedded within the respective device type (rte_pci_device, for example).
+ * Thereafter, PCI specific bus would need to perform
+ * container_of(rte_pci_device) to obtain PCI device object.
+ *
+ * Scan failure of a bus is not treated as exit criteria for application. Scan
+ * for all other buses would still continue.
+ *
+ * @param void
+ * @return
+ * 0 for successful scan
+ * !0 (<0) for unsuccessful scan with error value
+ */
+typedef int (* bus_scan_t)(void);
+
+/**
+ * Bus specific match for devices and drivers which can service them.
+ * For each scanned device, during probe the match would link the devices with
+ * drivers which can service the device.
+ *
+ * It is the work of each bus handler to obtain the specific device object
+ * using container_of (or typecasting, as a less preferred way).
+ *
+ * @param drv
+ * Driver object attached to the bus
+ * @param dev
+ * Device object which is being probed.
+ * @return
+ * 0 for successful match
+ * !0 for unsuccessful match
+ */
+typedef int (* bus_match_t)(struct rte_driver *drv, struct rte_device *dev);
+
+/**
+ * Dump the devices on the 

[dpdk-dev] [RFC PATCH 1/6] eal: define container macro

2016-11-17 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/include/rte_common.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index db5ac91..8152bd9 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif

+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *  ...
+ *  struct child c;
+ *  ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#ifndef container_of
+#define container_of(p, type, member) \
+   ((type *) (((char *) (p)) - offsetof(type, member)))
+#endif
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
-- 
2.7.4



[dpdk-dev] [RFC PATCH 0/6] Restructure EAL device model for bus support

2016-11-17 Thread Shreyansh Jain
etter, some patches have been posted. These are _only_ for
discussion purpose. They are not complete and neither compilable.
All the patches, except 0001, have sufficient context about what the changes
are and rationale for same. Obviously, code is best answer.

=== Patch description: ===

Patch 0001: Introduce container_of macro. Originally a patch from Jan.

Patch 0002: introduce changes to rte_device/rte_driver for rte_bus, and
rte_bus definition itself.

Patch 0003: Add a new layer for 'bus driver' with linuxapp PCI as an example

Patch 0004: Changes with respect to rte_bus APIs and impact on eal_common_pci

Patch 0005: Change to rte_eal_init (of linuxapp only, for now) for supporting
bus->scan. Probe is still being done old way, but in a new wrapper

Patch 0006: eth_driver removal and corresponding changes in ixgbe_ethdev, as
an example. Includes changes to rte_ethdev to remove most possible
PCI references. But, work still remains.

=== Pending Items/Questions: ===

 - Interrupt and notification handling. How to allow drivers to be notified
   of presence/plugging of a device.
 - Placement of bus driver/handling code. librte_bus, bus/, drivers/bus?
 -- Also from a pespective of a external library and whether symbols would be
available in that.
 -- and secondary processes
 - VDEV bus is missing from current set.
 - Locking of list for supporting hotplugging. Or, at the least safe add/
   remove
 - PMDINFOGEN support or lack of it.
 - Is there ever a case where rte_eth_dev needs to be resolved from
   rte_pci_device? I couldn't find any such use and neither a use-case for it.
 - There should be a way for Bus APIs to return a generic list handle so that
   EAL doesn't need to bother about bus->driver_list like dereferencing. This
   is untidy as well as less portable (in terms of code movement, not arch).
 - Are more helper hooks required for a bus?
 -- I can think of scan, match, dump, find, plug (device), unplug (device),
associate (driver), disassociate (driver). But, most of the work is
already being done by lower instances (rte_device/driver etc).

Further:
 - In next few days I will make all necessary changes on the lines mentioned
   in the patches. This would include changing the drivers/* and librte_eal/*
 - As an when review comments float in and agreement reached, I will keep
   changing the model
 - There are grey areas like interrupt, notification, locking of bus/list
   which require more discussion. I will try and post a rfc for those as well
   or if someone can help me on those - great
 - Change would include PCI bus and VDEV bus handling. A new bus (NXP's FSLMC)
   would also be layered over this series to verify the model of 'bus
   registration'. This is also part of 17.02 roadmap.

[1] http://dpdk.org/ml/archives/dev/2016-November/050186.html

Jan Viktorin (1):
  eal: define container macro

Shreyansh Jain (5):
  eal: introduce bus-device-driver structure
  bus: add bus driver layer
  eal/common: handle bus abstraction for device/driver objects
  eal: supporting bus model in init process
  eal: removing eth_driver

 bus/Makefile   |  36 +++
 bus/pci/Makefile   |  37 +++
 bus/pci/linuxapp/pci_bus.c | 418 +
 bus/pci/linuxapp/pci_bus.h |  55 
 drivers/net/ixgbe/ixgbe_ethdev.c   |  49 ++--
 lib/librte_eal/common/eal_common_bus.c | 188 +
 lib/librte_eal/common/eal_common_dev.c |  31 ++-
 lib/librte_eal/common/eal_common_pci.c | 226 +---
 lib/librte_eal/common/include/rte_bus.h| 243 +
 lib/librte_eal/common/include/rte_common.h |  18 ++
 lib/librte_eal/common/include/rte_dev.h|  36 +--
 lib/librte_eal/common/include/rte_pci.h|  11 +-
 lib/librte_eal/linuxapp/eal/Makefile   |   1 +
 lib/librte_eal/linuxapp/eal/eal.c  |  51 +++-
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 298 
 lib/librte_ether/rte_ethdev.c  |  36 ++-
 lib/librte_ether/rte_ethdev.h  |   6 +-
 17 files changed, 1262 insertions(+), 478 deletions(-)
 create mode 100644 bus/Makefile
 create mode 100644 bus/pci/Makefile
 create mode 100644 bus/pci/linuxapp/pci_bus.c
 create mode 100644 bus/pci/linuxapp/pci_bus.h
 create mode 100644 lib/librte_eal/common/eal_common_bus.c
 create mode 100644 lib/librte_eal/common/include/rte_bus.h

-- 
2.7.4



[dpdk-dev] Clarification for eth_driver changes

2016-11-16 Thread Shreyansh Jain
On Monday 14 November 2016 11:08 PM, Ferruh Yigit wrote:
[...]
> What I was thinking is:
>
> rte_device/driver are not abstract classes.
>
> rte_bus device/driver is an abstract class and any bus inherited from
> this class.
> rte_func device/driver is and abstract class and eth/crypto inherited
> from this class.
>
> eal layer only deal with rte_bus
> pmd's only deal with functional device/driver
>
> but still, it is required to know device <-> driver, and functional <->
> bus, relations. rte_dev/rte_driver are to provide this links.
>
> But yes this add extra layer and with second thought I am not sure if it
> is really possible to separate bus and functionality, this was just an
> idea ..
[...]

I understand your point. It would really nice if we can achieve that 
level pluggable-ness where drivers would be able to choose a 'profile' - 
where 'profiles' are like net/crypto etc. In your text, 
profile==functionality.

Maybe once the basic model is in place, we can revisit this idea.

-
Shreyansh


[dpdk-dev] Clarification for eth_driver changes

2016-11-12 Thread Shreyansh Jain
Hello Ferruh,

(Please ignore if line wrappings are not correct. Using a possibly
unconfigured mail client).

> -Original Message-
> From: Ferruh Yigit [mailto:ferruh.yigit at intel.com]
> Sent: Saturday, November 12, 2016 12:46 AM
> To: Shreyansh Jain ; David Marchand
> 
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] Clarification for eth_driver changes
> 
> On 11/10/2016 11:05 AM, Shreyansh Jain wrote:
> > Hello David,
> >
> > On Thursday 10 November 2016 01:46 PM, David Marchand wrote:
> >> Hello Shreyansh,
> >>
> >> On Thu, Nov 10, 2016 at 8:26 AM, Shreyansh Jain 
> wrote:
> >>> I need some help and clarification regarding some changes I am doing to
> >>> cleanup the EAL code.
> >>>
> >>> There are some changes which should be done for eth_driver/rte_eth_device
> >>> structures:
> >>>
> >>> 1. most obvious, eth_driver should be renamed to rte_eth_driver.
> >>> 2. eth_driver currently has rte_pci_driver embedded in it
> >>>  - there can be ethernet devices which are _not_ PCI
> >>>  - in which case, this structure should be removed.
> >>
> >> Do we really need to keep a eth_driver ?
> >
> > No. As you have rightly mentioned below (as well as in your Jan'16
> > post), it is a mere convenience.
> 
> Isn't it good to separate the logic related which bus device connected
> and what functionality it provides. Because these two can be flexible:

Indeed. The very idea of a Bus model is to make a hierarchy which allows
for pluggability/flexibility in terms of devices being used. But, until now I
have only considered placement hierarchy and not functional hierarchy. (more
below)

> 
> device -> virtual_bus -> ethernet_functionality
> device -> pci_bus -> crypto_functionality
> device -> x_bus   -> y_function
>

Ok.

> 
> what about:
> 
> create generic bus driver/device and all eal level deal with generic
> bus. different buses inherit from generic bus logic



[dpdk-dev] [PATCH v1] doc: fix release notes for 16.11

2016-11-11 Thread Shreyansh Jain
On Friday 11 November 2016 05:34 PM, John McNamara wrote:
[...]
> -* **Improved device/driver hierarchy and generalized hotplugging**
> +* **Improved device/driver hierarchy and generalized hotplugging.**
>
> -  Device and driver relationship has been restructured by introducing generic
> -  classes. This paves way for having PCI, VDEV and other device types as
> -  just instantiated objects rather than classes in themselves. Hotplugging 
> too
> -  has been generalized into EAL so that ethernet or crypto devices can use 
> the
> +  The device and driver relationship has been restructured by introducing 
> generic
> +  classes. This paves the way for having PCI, VDEV and other device types as
> +  instantiated objects rather than classes in themselves. Hotplugging has 
> also
> +  been generalized into EAL so that Ethernet or crypto devices can use the
>common infrastructure.
>
> -  * removed ``pmd_type`` as way of segregation of devices
> -  * moved ``numa_node`` and ``devargs`` into ``rte_driver`` from
> +  * Removed ``pmd_type`` as a way of segregation of devices.
> +  * Moved ``numa_node`` and ``devargs`` into ``rte_driver`` from
>  ``rte_pci_driver``. These can now be used by any instantiated object of
>  ``rte_driver``.
> -  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
> -  * renamed devinit/devuninit handlers to probe/remove to make it more
> -semantically correct with respect to device<=>driver relationship
> -  * moved hotplugging support to EAL. Hereafter, PCI and vdev can use the
> +  * Added ``rte_device`` class and all PCI and VDEV devices inherit from it
> +  * Renamed devinit/devuninit handlers to probe/remove to make it more
> +semantically correct with respect to the device <=> driver relationship.
> +  * Moved hotplugging support to EAL. Hereafter, PCI and vdev can use the
>  APIs ``rte_eal_dev_attach`` and ``rte_eal_dev_detach``.
> -  * helpers and support macros have been renamed to make them more synonymous
> +  * Renamed helpers and support macros to make them more synonymous
>  with their device types
> -(e.g. ``PMD_REGISTER_DRIVER`` => ``RTE_PMD_REGISTER_PCI``)
> +(e.g. ``PMD_REGISTER_DRIVER`` => ``RTE_PMD_REGISTER_PCI``).
>* Device naming functions have been generalized from ethdev and cryptodev
>  to EAL. ``rte_eal_pci_device_name`` has been introduced for obtaining
>  unique device name from PCI Domain-BDF description.

If it is possible to have a Reviewed-by for a particular part of a patch:

Reviewed-by: Shreyansh Jain 


[dpdk-dev] [PATCH] doc: add sub-repositories information

2016-11-11 Thread Shreyansh Jain
Hello Ferruh,

Trivial comment/suggestion:

On Thursday 10 November 2016 10:57 PM, Ferruh Yigit wrote:
> DPDK switched to main and sub-repositories approach, this patch
> documents new approach and updates development process according.
>
> Signed-off-by: Ferruh Yigit 
> ---
>  doc/guides/contributing/patches.rst | 18 +++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/doc/guides/contributing/patches.rst 
> b/doc/guides/contributing/patches.rst
> index 729aea7..bec9bfc 100644
> --- a/doc/guides/contributing/patches.rst
> +++ b/doc/guides/contributing/patches.rst
> @@ -20,7 +20,14 @@ The DPDK development process has the following features:
>  * There is a mailing list where developers submit patches.
>  * There are maintainers for hierarchical components.
>  * Patches are reviewed publicly on the mailing list.
> -* Successfully reviewed patches are merged to the master branch of the 
> repository.
> +* Successfully reviewed patches are merged to the repository.
> +
> +|
> +
> +* There are main repository ``dpdk`` and sub-repositories ``dpdk-next-*``.
> +* A patch should be sent for its target repository. Like net drivers should 
> be on top of dpdk-next-net repository.
> +* All sub-repositories merged into main repository for -rc1 and -rc2 
> versions of the release.

'All sub-repositories *are* merged into ...'?

> +* After -rc2 release all patches should target main repository.
>
>  The mailing list for DPDK development is `dev at dpdk.org 
> `_.
>  Contributors will need to `register for the mailing list 
> `_ in order to submit patches.
> @@ -33,12 +40,17 @@ Refer to the `Pro Git Book 
> `_ for further informat
>  Getting the Source Code
>  ---
>
> -The source code can be cloned using either of the following::
> +The source code can be cloned using either of the following:
>
> -git clone git://dpdk.org/dpdk
> +main repository::
>
> +git clone git://dpdk.org/dpdk
>  git clone http://dpdk.org/git/dpdk
>
> +sub-repositories (`list `_)::
> +
> +git clone git://dpdk.org/next/dpdk-next-*
> +git clone http://dpdk.org/git/next/dpdk-next-*
>
>  Make your Changes
>  -
>

-
Shreyansh


[dpdk-dev] [PATCH v7 11/21] eal/soc: implement probing of drivers

2016-11-11 Thread Shreyansh Jain
On Thursday 10 November 2016 02:56 PM, Thomas Monjalon wrote:
> 2016-11-10 14:40, Shreyansh Jain:
>> On Thursday 10 November 2016 01:11 PM, Jianbo Liu wrote:
>>> On 10 November 2016 at 14:10, Shreyansh Jain  
>>> wrote:
>>>> On Thursday 10 November 2016 09:00 AM, Jianbo Liu wrote:
>>>>> I'm still not sure about the purpose of soc_scan, and how to use it.
>>>>
>>>>
>>>> For each device to be used by DPDK, which cannot be scanned/identified 
>>>> using
>>>> the existing PCI/VDEV methods (sysfs/bus/pci), 'soc_scan_t' provides a way
>>>> for driver to make those devices part of device lists.
>>>>
>>>> Ideally, 'scan' is not a function of a driver. It is a bus function - which
>>>> is missing in this case.
>>>>
>>>>> If it's for each driver, it should at least struct rte_soc_driver * as
>>>>> its parameter.
>>>>
>>>>
>>>> Its for each driver - assuming that each non-PCI driver which implements it
>>>> knows how to find devices which it can control (for example, special area 
>>>> in
>>>> sysfs, or even platform bus).
>>>>
>>>
>>> Considering there are several drivers in a platform bus, each driver
>>> call the scan function, like the rte_eal_soc_scan_platform_bus() you
>>> implemented.
>>> The first will add soc devices to the list, but the remaining calls
>>> are redundant.
>>
>> Indeed. This is exactly the issue we will face if we try and move this
>> scan/match logic to PCI - all devices are identified in one step.
>>
>> There is a difference in principle here:
>> A SoC device/driver combination is essentially focused towards a single
>> type of bus<->devices. For example, a NXP PMD would implement a scan
>> function which would scan for all devices on NXP's bus. This would not
>> conflict with another XYZ SoC PMD which scans its specific bus.
>>
>> There is caveat to this - the platform bus. There can be multiple
>> drivers which can serve platform bus compliant devices. First
>> PMD->scan() initiated for such a bus/device would leave all other scans
>> redundant.
>>
>> More similar caveats will come if we consider somewhat generic buses. At
>> least I couldn't find any interest for such devices in the ML when I
>> picked this series (from where Jan left it).
>>
>> Probably when more common type of PMDs come in, some default scan
>> implementation can check for skipping those devices which are already
>> added. It would be redundant but harmless.
>
> If several drivers use the same bus, it means the bus is standard enough
> to be implemented in EAL. So the scan function of this bus should be
> called only once when calling the generic EAL scan function.
>

In the current model, without a bus like object, this can only be 
implemented as a hack. This is because:
- If each driver has its scan, some of them (those on a common bus) 
would have their scan nullified
- Then, EAL would initiate the scan on their behalf. (rte_eal_init)
- Whereas, for those drivers which are 'special' scan, EAL would have to 
call each driver's scan.
- This selection is manual code change (nullifying the scan function).
- And then, EAL would have various 'generic' scan's chained together 
other than driver->scan().

A cleaner model would have been that EAL always calls the drivers->scan().

Obviously, this issue vanishes as soon as we have the bus->scan() like 
implementation where a bus would represent multiple devices/drivers.

_
Shreyansh


[dpdk-dev] [PATCH] doc: announce API and ABI changes for librte_eal

2016-11-10 Thread Shreyansh Jain
Signed-off-by: Shreyansh Jain 
---
 doc/guides/rel_notes/deprecation.rst | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 1a9e1ae..2af2476 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -35,3 +35,13 @@ Deprecation Notices
 * mempool: The functions for single/multi producer/consumer are deprecated
   and will be removed in 17.02.
   It is replaced by ``rte_mempool_generic_get/put`` functions.
+
+* ABI/API changes are planned for 17.02: ``rte_device``, ``rte_driver`` will be
+  impacted because of introduction of a new ``rte_bus`` hierarchy. This would
+  also impact the way devices are identified by EAL. A bus-device-driver model
+  will be introduced providing a hierarchical view of devices.
+
+* ``eth_driver`` is planned to be removed in 17.02. This currently serves as
+  a placeholder for PMDs to register themselves. Changes for ``rte_bus`` will
+  provide a way to handle device initialization currently being done in
+  ``eth_driver``.
-- 
2.7.4



[dpdk-dev] Clarification for eth_driver changes

2016-11-10 Thread Shreyansh Jain
Hello David,

On Thursday 10 November 2016 01:46 PM, David Marchand wrote:
> Hello Shreyansh,
>
> On Thu, Nov 10, 2016 at 8:26 AM, Shreyansh Jain  
> wrote:
>> I need some help and clarification regarding some changes I am doing to
>> cleanup the EAL code.
>>
>> There are some changes which should be done for eth_driver/rte_eth_device
>> structures:
>>
>> 1. most obvious, eth_driver should be renamed to rte_eth_driver.
>> 2. eth_driver currently has rte_pci_driver embedded in it
>>  - there can be ethernet devices which are _not_ PCI
>>  - in which case, this structure should be removed.
>
> Do we really need to keep a eth_driver ?

No. As you have rightly mentioned below (as well as in your Jan'16 
post), it is a mere convenience.

> As far as I can see, it is only a convenient wrapper for existing pci
> drivers, but in the end it is just a pci_driver with ethdev context in
> it that could be pushed to each existing driver.

Indeed. My problem (or lack of understanding) is that all PMDs rely on 
it and I don't know in what all pattern they have envisioned using this 
model of ethdev->pci_dev, the initialization sequences.
rte_device->init/uninit would settle most of those worries, I think.

>
> In my initial description
> http://dpdk.org/ml/archives/dev/2016-January/031390.html, what I had
> in mind was only having a rte_eth_device pointing to a generic
> rte_device.

Though I had read it (during the rte_device/driver series) but didn't 
remember it while posting this. I agree with your point of doing away 
with eth_driver.

> If we need to invoke some generic driver ops from ethdev (I can only
> see the ethdev hotplug api, maybe I missed something), then we would
> go through rte_eth_device -> rte_device -> rte_driver.

Agree with you.

> The rte_driver keeps its own bus/private logic in its code, and no
> need to expose a type.

Agree.

>
>
>> 3. Similarly, rte_eth_dev has rte_pci_device which should be replaced with
>> rte_device.
>
> Yes, that's the main change for me.

Indeed. This is a big change. It impacts a lot of EAL code.

>
>
> Thanks.
>

Intent of this email was to know if I am missing something in assuming 
that eth_driver is actually not being used much. I will keep the 
comments from your email in mind while making changes. Thanks.

_
Shreyansh


[dpdk-dev] [PATCH v7 11/21] eal/soc: implement probing of drivers

2016-11-10 Thread Shreyansh Jain
On Thursday 10 November 2016 01:11 PM, Jianbo Liu wrote:
> On 10 November 2016 at 14:10, Shreyansh Jain  
> wrote:
>> On Thursday 10 November 2016 09:00 AM, Jianbo Liu wrote:
>>>
>>> On 28 October 2016 at 20:26, Shreyansh Jain 
>>> wrote:
>>>>
>>>> Each SoC PMD registers a set of callback for scanning its own bus/infra
>>>> and
>>>> matching devices to drivers when probe is called.
>>>> This patch introduces the infra for calls to SoC scan on
>>>> rte_eal_soc_init()
>>>> and match on rte_eal_soc_probe().
>>>>
>>>> Patch also adds test case for scan and probe.
>>>>
>>>> Signed-off-by: Jan Viktorin 
>>>> Signed-off-by: Shreyansh Jain 
>>>> Signed-off-by: Hemant Agrawal 
>>>> --
>>>> v4:
>>>>  - Update test_soc for descriptive test function names
>>>>  - Comments over test functions
>>>>  - devinit and devuninint --> probe/remove
>>>>  - RTE_VERIFY at some places
>>>> ---
>>>>  app/test/test_soc.c | 205
>>>> ++-
>>>>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   4 +
>>>>  lib/librte_eal/common/eal_common_soc.c  | 213
>>>> +++-
>>>>  lib/librte_eal/common/include/rte_soc.h |  75 -
>>>>  lib/librte_eal/linuxapp/eal/eal.c   |   5 +
>>>>  lib/librte_eal/linuxapp/eal/eal_soc.c   |  21 ++-
>>>>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |   4 +
>>>>  7 files changed, 519 insertions(+), 8 deletions(-)
>>>>
>>> ..
>>>
>>>>  /**
>>>> + * SoC device scan callback, called from rte_eal_soc_init.
>>>> + * For various SoC, the bus on which devices are attached maynot be
>>>> compliant
>>>> + * to a standard platform (or platform bus itself). In which case, extra
>>>> + * steps are implemented by PMD to scan over the bus and add devices to
>>>> SoC
>>>> + * device list.
>>>> + */
>>>> +typedef void (soc_scan_t)(void);
>>>
>>>
>>> I'm still not sure about the purpose of soc_scan, and how to use it.
>>
>>
>> For each device to be used by DPDK, which cannot be scanned/identified using
>> the existing PCI/VDEV methods (sysfs/bus/pci), 'soc_scan_t' provides a way
>> for driver to make those devices part of device lists.
>>
>> Ideally, 'scan' is not a function of a driver. It is a bus function - which
>> is missing in this case.
>>
>>> If it's for each driver, it should at least struct rte_soc_driver * as
>>> its parameter.
>>
>>
>> Its for each driver - assuming that each non-PCI driver which implements it
>> knows how to find devices which it can control (for example, special area in
>> sysfs, or even platform bus).
>>
>
> Considering there are several drivers in a platform bus, each driver
> call the scan function, like the rte_eal_soc_scan_platform_bus() you
> implemented.
> The first will add soc devices to the list, but the remaining calls
> are redundant.

Indeed. This is exactly the issue we will face if we try and move this 
scan/match logic to PCI - all devices are identified in one step.

There is a difference in principle here:
A SoC device/driver combination is essentially focused towards a single 
type of bus<->devices. For example, a NXP PMD would implement a scan 
function which would scan for all devices on NXP's bus. This would not 
conflict with another XYZ SoC PMD which scans its specific bus.

There is caveat to this - the platform bus. There can be multiple 
drivers which can serve platform bus compliant devices. First 
PMD->scan() initiated for such a bus/device would leave all other scans 
redundant.

More similar caveats will come if we consider somewhat generic buses. At 
least I couldn't find any interest for such devices in the ML when I 
picked this series (from where Jan left it).

Probably when more common type of PMDs come in, some default scan 
implementation can check for skipping those devices which are already 
added. It would be redundant but harmless.

>
> The other issue is adding the driver parameter. Do you need extra
> information from driver to scan the bus?
>
>>> If it's for each bus, why it is in rte_soc_driver?
>>
>>
>> Short answer - lack of a better place. It should be in dev.h probably
>> (rte_device/driver) but it would look out of place (as that represents PCI
>> devices also which cannot 

[dpdk-dev] Clarification for eth_driver changes

2016-11-10 Thread Shreyansh Jain
On Thursday 10 November 2016 01:33 PM, Thomas Monjalon wrote:
> 2016-11-10 15:51, Jianbo Liu:
>> On 10 November 2016 at 15:26, Shreyansh Jain  
>> wrote:
>>> This is what the current outline of eth_driver is:
>>>
>>> ++
>>> | eth_driver |
>>> | +-+|
>>> | | rte_pci_driver  ||
>>> | | +--+||
>>> | | | rte_driver   |||
>>> | | |  name[]  |||
>>> | | |  ... |||
>>> | | +--+||
>>> | |  .probe ||
>>> | |  .remove||
>>> | |  ...||
>>> | +-+|
>>> |  .eth_dev_init |
>>> |  .eth_dev_uninit   |
>>> ++
>>>
>>> This is what I was thinking:
>>>
>>> +-++--+
>>> | rte_pci_driver  ||eth_driver|
>>> | +--+|   _|_struct rte_driver *p |
>>> | | rte_driver   <---/ | .eth_dev_init|
>>> | |  ... ||| .eth_dev_uninit  |
>>> | |  name||+--+
>>> | |||
>>> | +--+|
>>> |  |
>>> +-+
>>>
>>> ::Impact::
>>> Various drivers use the rte_pci_driver embedded in the eth_driver object for
>>> device initialization.
>>>  == They assume that rte_pci_driver is directly embedded and hence simply
>>> dereference.
>>>  == e.g. eth_igb_dev_init() in drivers/net/e1000/igb_ethdev.c file
>>>
>>> With the above change, such drivers would have to access rte_driver and then
>>> perform container_of to obtain their respective rte_xxx_driver.
>>>  == this would be useful in case there is a non-PCI driver
>>>
>>> ::Problem::
>>> I am not sure of reason as to why eth_driver embedded rte_pci_driver in
>>> first place - other than a convenient way to define it before PCI driver
>>> registration.
>>>
>>> As all the existing PMDs are impacted - am I missing something here in
>>> making the above change?
>>>
>>
>> How do you know eth_driver->p is pointing to a rte_pci_driver or 
>> rte_soc_driver?
>> Maybe you need to add a type/flag in rte_driver.
>
> Why do you need any bus information at ethdev level?
>

AFAIK, we don't need it. Above text is not stating anything on that 
grounds either, I think. Isn't it?

-
Shreyansh


[dpdk-dev] Clarification for eth_driver changes

2016-11-10 Thread Shreyansh Jain
On Thursday 10 November 2016 01:21 PM, Jianbo Liu wrote:
> On 10 November 2016 at 15:26, Shreyansh Jain  
> wrote:
>> Hello David, list,
>>
>> I need some help and clarification regarding some changes I am doing to
>> cleanup the EAL code.
>>
>> There are some changes which should be done for eth_driver/rte_eth_device
>> structures:
>>
>> 1. most obvious, eth_driver should be renamed to rte_eth_driver.
>> 2. eth_driver currently has rte_pci_driver embedded in it
>>  - there can be ethernet devices which are _not_ PCI
>>  - in which case, this structure should be removed.
>> 3. Similarly, rte_eth_dev has rte_pci_device which should be replaced with
>> rte_device.
>>
>> This is what the current outline of eth_driver is:
>>
>> ++
>> | eth_driver |
>> | +-+|
>> | | rte_pci_driver  ||
>> | | +--+||
>> | | | rte_driver   |||
>> | | |  name[]  |||
>> | | |  ... |||
>> | | +--+||
>> | |  .probe ||
>> | |  .remove||
>> | |  ...||
>> | +-+|
>> |  .eth_dev_init |
>> |  .eth_dev_uninit   |
>> ++
>>
>> This is what I was thinking:
>>
>> +-++--+
>> | rte_pci_driver  ||eth_driver|
>> | +--+|   _|_struct rte_driver *p |
>> | | rte_driver   <---/ | .eth_dev_init|
>> | |  ... ||| .eth_dev_uninit  |
>> | |  name||+--+
>> | |||
>> | +--+|
>> |  |
>> +-+
>>
>> ::Impact::
>> Various drivers use the rte_pci_driver embedded in the eth_driver object for
>> device initialization.
>>  == They assume that rte_pci_driver is directly embedded and hence simply
>> dereference.
>>  == e.g. eth_igb_dev_init() in drivers/net/e1000/igb_ethdev.c file
>>
>> With the above change, such drivers would have to access rte_driver and then
>> perform container_of to obtain their respective rte_xxx_driver.
>>  == this would be useful in case there is a non-PCI driver
>>
>> ::Problem::
>> I am not sure of reason as to why eth_driver embedded rte_pci_driver in
>> first place - other than a convenient way to define it before PCI driver
>> registration.
>>
>> As all the existing PMDs are impacted - am I missing something here in
>> making the above change?
>>
>
> How do you know eth_driver->p is pointing to a rte_pci_driver or 
> rte_soc_driver?
> Maybe you need to add a type/flag in rte_driver.

My take: PMD implementation would specify this - similar to how it is 
done now. A PCI PMD would perform a container_of(rte_pci_driver,...).
I don't think we need a differentiation here - primarily because 
generic doesn't handle the eth_driver.

>
>> Probably, similar is the case for rte_eth_dev.
>>
>> -
>> Shreyansh
>


-- 
-
Shreyansh


[dpdk-dev] Clarification for eth_driver changes

2016-11-10 Thread Shreyansh Jain
Hello David, list,

I need some help and clarification regarding some changes I am doing to 
cleanup the EAL code.

There are some changes which should be done for 
eth_driver/rte_eth_device structures:

1. most obvious, eth_driver should be renamed to rte_eth_driver.
2. eth_driver currently has rte_pci_driver embedded in it
  - there can be ethernet devices which are _not_ PCI
  - in which case, this structure should be removed.
3. Similarly, rte_eth_dev has rte_pci_device which should be replaced 
with rte_device.

This is what the current outline of eth_driver is:

++
| eth_driver |
| +-+|
| | rte_pci_driver  ||
| | +--+||
| | | rte_driver   |||
| | |  name[]  |||
| | |  ... |||
| | +--+||
| |  .probe ||
| |  .remove||
| |  ...||
| +-+|
|  .eth_dev_init |
|  .eth_dev_uninit   |
++

This is what I was thinking:

+-++--+
| rte_pci_driver  ||eth_driver|
| +--+|   _|_struct rte_driver *p |
| | rte_driver   <---/ | .eth_dev_init|
| |  ... ||| .eth_dev_uninit  |
| |  name||+--+
| |||
| +--+|
|  |
+-+

::Impact::
Various drivers use the rte_pci_driver embedded in the eth_driver object 
for device initialization.
  == They assume that rte_pci_driver is directly embedded and hence 
simply dereference.
  == e.g. eth_igb_dev_init() in drivers/net/e1000/igb_ethdev.c file

With the above change, such drivers would have to access rte_driver and 
then perform container_of to obtain their respective rte_xxx_driver.
  == this would be useful in case there is a non-PCI driver

::Problem::
I am not sure of reason as to why eth_driver embedded rte_pci_driver in 
first place - other than a convenient way to define it before PCI driver 
registration.

As all the existing PMDs are impacted - am I missing something here in 
making the above change?

Probably, similar is the case for rte_eth_dev.

-
Shreyansh


[dpdk-dev] [PATCH v7 11/21] eal/soc: implement probing of drivers

2016-11-10 Thread Shreyansh Jain
On Thursday 10 November 2016 09:00 AM, Jianbo Liu wrote:
> On 28 October 2016 at 20:26, Shreyansh Jain  wrote:
>> Each SoC PMD registers a set of callback for scanning its own bus/infra and
>> matching devices to drivers when probe is called.
>> This patch introduces the infra for calls to SoC scan on rte_eal_soc_init()
>> and match on rte_eal_soc_probe().
>>
>> Patch also adds test case for scan and probe.
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> Signed-off-by: Hemant Agrawal 
>> --
>> v4:
>>  - Update test_soc for descriptive test function names
>>  - Comments over test functions
>>  - devinit and devuninint --> probe/remove
>>  - RTE_VERIFY at some places
>> ---
>>  app/test/test_soc.c | 205 
>> ++-
>>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   4 +
>>  lib/librte_eal/common/eal_common_soc.c  | 213 
>> +++-
>>  lib/librte_eal/common/include/rte_soc.h |  75 -
>>  lib/librte_eal/linuxapp/eal/eal.c   |   5 +
>>  lib/librte_eal/linuxapp/eal/eal_soc.c   |  21 ++-
>>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |   4 +
>>  7 files changed, 519 insertions(+), 8 deletions(-)
>>
> ..
>
>>  /**
>> + * SoC device scan callback, called from rte_eal_soc_init.
>> + * For various SoC, the bus on which devices are attached maynot be 
>> compliant
>> + * to a standard platform (or platform bus itself). In which case, extra
>> + * steps are implemented by PMD to scan over the bus and add devices to SoC
>> + * device list.
>> + */
>> +typedef void (soc_scan_t)(void);
>
> I'm still not sure about the purpose of soc_scan, and how to use it.

For each device to be used by DPDK, which cannot be scanned/identified 
using the existing PCI/VDEV methods (sysfs/bus/pci), 'soc_scan_t' 
provides a way for driver to make those devices part of device lists.

Ideally, 'scan' is not a function of a driver. It is a bus function - 
which is missing in this case.

> If it's for each driver, it should at least struct rte_soc_driver * as
> its parameter.

Its for each driver - assuming that each non-PCI driver which implements 
it knows how to find devices which it can control (for example, special 
area in sysfs, or even platform bus).

> If it's for each bus, why it is in rte_soc_driver?

Short answer - lack of a better place. It should be in dev.h probably 
(rte_device/driver) but it would look out of place (as that represents 
PCI devices also which cannot implement it - all PCI devices are scanned 
in one go irrespective of driver)

> I know you will implement bus driver in the future, but we need to
> make it clear for current simplified implementation.

Current implementation makes only a single assumption - that rather than 
relying on EAL for identifying devices (as being done now), next best 
option in existing framework (driver) should have control of finding 
devices.

This is primarily to make the SoC work parallel to PCI implementation 
without much top-down changes in EAL.

Bus model, improvises it by moving this implementation a little above in 
hierarchy - in rte_bus<-rte_driver<-PMD.

I understand your apprehension - 'driver-scanning-for-devices' is indeed 
not correct real world analogy. It is just a place holder for enabling 
those drivers/PMDs which cannot work in absence of the right model.
And that is still work in progress.

>
>> +
>> +/**
>> + * Custom device<=>driver match callback for SoC
>> + * Unlike PCI, SoC devices don't have a fixed definition of device
>> + * identification. PMDs can implement a specific matching function in which
>> + * driver and device objects are provided to perform custom match.
>> + */
>> +typedef int (soc_match_t)(struct rte_soc_driver *, struct rte_soc_device *);
>> +
>> +/**
>>   * A structure describing a SoC driver.
>>   */
>>  struct rte_soc_driver {
>> @@ -104,6 +120,8 @@ struct rte_soc_driver {
>> struct rte_driver driver;  /**< Inherit core driver. */
>> soc_probe_t *probe;/**< Device probe */
>> soc_remove_t *remove;  /**< Device remove */
>> +   soc_scan_t *scan_fn;   /**< Callback for scanning SoC 
>> bus*/
>> +   soc_match_t *match_fn; /**< Callback to match dev<->drv 
>> */
>> const struct rte_soc_id *id_table; /**< ID table, NULL terminated */
>>  };
>>
>> @@ -146,12 +164,63 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
>>  }
>>
>>  /**
>> + *

[dpdk-dev] [PATCH v7 08/21] eal/soc: implement SoC device list and dump

2016-11-10 Thread Shreyansh Jain
On Thursday 10 November 2016 08:36 AM, Jianbo Liu wrote:
> On 28 October 2016 at 20:26, Shreyansh Jain  wrote:
>> From: Jan Viktorin 
>>
>> SoC devices would be linked in a separate list (from PCI). This is used for
>> probe function.
>> A helper for dumping the device list is added.
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> Signed-off-by: Hemant Agrawal 
>> ---
>>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
>>  lib/librte_eal/common/eal_common_soc.c  | 34 
>> +
>>  lib/librte_eal/common/include/rte_soc.h |  9 +++
>>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
>>  4 files changed, 47 insertions(+)
>>
>> diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
>> b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
>> index cf6fb8e..86e3cfd 100644
>> --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
>> +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
>> @@ -171,11 +171,13 @@ DPDK_16.11 {
>> rte_eal_dev_attach;
>> rte_eal_dev_detach;
>> rte_eal_map_resource;
>> +   rte_eal_soc_dump;
>> rte_eal_soc_register;
>> rte_eal_soc_unregister;
>> rte_eal_unmap_resource;
>> rte_eal_vdrv_register;
>> rte_eal_vdrv_unregister;
>> +   soc_device_list;
>> soc_driver_list;
>>
>>  } DPDK_16.07;
>> diff --git a/lib/librte_eal/common/eal_common_soc.c 
>> b/lib/librte_eal/common/eal_common_soc.c
>> index 56135ed..5dcddc5 100644
>> --- a/lib/librte_eal/common/eal_common_soc.c
>> +++ b/lib/librte_eal/common/eal_common_soc.c
>> @@ -31,6 +31,8 @@
>>   *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>   */
>>
>> +#include 
>> +#include 
>>  #include 
>>
>>  #include 
>> @@ -40,6 +42,38 @@
>>  /* Global SoC driver list */
>>  struct soc_driver_list soc_driver_list =
>> TAILQ_HEAD_INITIALIZER(soc_driver_list);
>> +struct soc_device_list soc_device_list =
>> +   TAILQ_HEAD_INITIALIZER(soc_device_list);
>> +
>> +/* dump one device */
>> +static int
>> +soc_dump_one_device(FILE *f, struct rte_soc_device *dev)
>> +{
>> +   int i;
>> +
>> +   fprintf(f, "%s", dev->addr.name);
>> +   fprintf(f, " - fdt_path: %s\n",
>> +   dev->addr.fdt_path ? dev->addr.fdt_path : "(none)");
>> +
>> +   for (i = 0; dev->id && dev->id[i].compatible; ++i)
>> +   fprintf(f, "   %s\n", dev->id[i].compatible);
>> +
>> +   return 0;
>> +}
>> +
>> +/* dump devices on the bus to an output stream */
>> +void
>> +rte_eal_soc_dump(FILE *f)
>> +{
>> +   struct rte_soc_device *dev = NULL;
>> +
>> +   if (!f)
>> +   return;
>> +
>> +   TAILQ_FOREACH(dev, _device_list, next) {
>> +   soc_dump_one_device(f, dev);
>> +   }
>> +}
>>
>>  /* register a driver */
>>  void
>> diff --git a/lib/librte_eal/common/include/rte_soc.h 
>> b/lib/librte_eal/common/include/rte_soc.h
>> index 23b06a9..347e611 100644
>> --- a/lib/librte_eal/common/include/rte_soc.h
>> +++ b/lib/librte_eal/common/include/rte_soc.h
>> @@ -56,8 +56,12 @@ extern "C" {
>>
>>  extern struct soc_driver_list soc_driver_list;
>>  /**< Global list of SoC Drivers */
>> +extern struct soc_device_list soc_device_list;
>> +/**< Global list of SoC Devices */
>>
>>  TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked 
>> Q. */
>> +TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked 
>> Q. */
>> +
>>
>>  struct rte_soc_id {
>> const char *compatible; /**< OF compatible specification */
>> @@ -142,6 +146,11 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
>>  }
>>
>>  /**
>> + * Dump discovered SoC devices.
>> + */
>> +void rte_eal_soc_dump(FILE *f);
>
> If it is to dump device information (not driver), is it proper to
> rename it rte_eal_soc_device_dump()?

Well, 'SoC'=='device' in this context. Isn't it?
In which case, 'soc_device' is just redundant/reuse of a descriptive word.

Or, on a second thought, 'SoC' represents a bus type here. In which 
case, this name sounds better. This would also warrant 
rte_eal_soc_register->rte_eal_soc_device_register.

But, if I ne

[dpdk-dev] [PATCH v7 06/21] eal/soc: introduce very essential SoC infra definitions

2016-11-10 Thread Shreyansh Jain
On Thursday 10 November 2016 09:39 AM, Jianbo Liu wrote:
> On 28 October 2016 at 20:26, Shreyansh Jain  wrote:
>> From: Jan Viktorin 
>>
>> Define initial structures and functions for the SoC infrastructure.
>> This patch supports only a very minimal functions for now.
>> More features will be added in the following commits.
>>
>> Includes rte_device/rte_driver inheritance of
>> rte_soc_device/rte_soc_driver.
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> Signed-off-by: Hemant Agrawal 
>> ---
>>  app/test/Makefile   |   1 +
>>  app/test/test_soc.c |  90 +
>>  lib/librte_eal/common/Makefile  |   2 +-
>>  lib/librte_eal/common/eal_private.h |   4 +
>>  lib/librte_eal/common/include/rte_soc.h | 138 
>> 
>>  5 files changed, 234 insertions(+), 1 deletion(-)
>>  create mode 100644 app/test/test_soc.c
>>  create mode 100644 lib/librte_eal/common/include/rte_soc.h
>>
> 
>
>
>> +/**
>> + * Utility function to write a SoC device name, this device name can later 
>> be
>> + * used to retrieve the corresponding rte_soc_addr using above functions.
>> + *
>> + * @param addr
>> + * The SoC address
>> + * @param output
>> + * The output buffer string
>> + * @param size
>> + * The output buffer size
>> + * @return
>> + *  0 on success, negative on error.
>> + */
>> +static inline void
>> +rte_eal_soc_device_name(const struct rte_soc_addr *addr,
>> +   char *output, size_t size)
>> +{
>> +   int ret;
>> +
>> +   RTE_VERIFY(addr != NULL);
>> +   RTE_VERIFY(size >= strlen(addr->name));
>
> Is it better to use (size > strlen(addr->name)?

Yes, I missed the '\0' in this.
I will fix this.

>
>> +   ret = snprintf(output, size, "%s", addr->name);
>> +   RTE_VERIFY(ret >= 0);
>> +}
>> +
>> +static inline int
>> +rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
>> +const struct rte_soc_addr *a1)
>> +{
>> +   if (a0 == NULL || a1 == NULL)
>> +   return -1;
>> +
>> +   RTE_VERIFY(a0->name != NULL);
>> +   RTE_VERIFY(a1->name != NULL);
>> +
>> +   return strcmp(a0->name, a1->name);
>> +}
>> +
>> +#endif
>> --
>> 2.7.4
>>
>


-- 
-
Shreyansh


[dpdk-dev] [PATCH v7 03/21] eal/linux: generalize PCI kernel unbinding driver to EAL

2016-11-10 Thread Shreyansh Jain
Hello Jianbo,

Thanks a lot for your time in commenting this. My comments inline (as 
well as on other similar mails).

On Thursday 10 November 2016 07:54 AM, Jianbo Liu wrote:
> On 28 October 2016 at 20:26, Shreyansh Jain  wrote:
>> From: Jan Viktorin 
>>
>> Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided
>> into two parts. First, determination of the path and string identification
>> of the device to be unbound. Second, the actual unbind operation which is
>> generic.
>>
>> BSD implementation updated as ENOTSUP
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> --
>> Changes since v2:
>>  - update BSD support for unbind kernel driver
>> ---
>>  lib/librte_eal/bsdapp/eal/eal.c   |  7 +++
>>  lib/librte_eal/bsdapp/eal/eal_pci.c   |  4 ++--
>>  lib/librte_eal/common/eal_private.h   | 13 +
>>  lib/librte_eal/linuxapp/eal/eal.c | 26 ++
>>  lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +
>>  5 files changed, 57 insertions(+), 26 deletions(-)
>>
>> diff --git a/lib/librte_eal/bsdapp/eal/eal.c 
>> b/lib/librte_eal/bsdapp/eal/eal.c
>> index 35e3117..5271fc2 100644
>> --- a/lib/librte_eal/bsdapp/eal/eal.c
>> +++ b/lib/librte_eal/bsdapp/eal/eal.c
>> @@ -633,3 +633,10 @@ rte_eal_process_type(void)
>>  {
>> return rte_config.process_type;
>>  }
>> +
>> +int
>> +rte_eal_unbind_kernel_driver(const char *devpath __rte_unused,
>> +const char *devid __rte_unused)
>> +{
>> +   return -ENOTSUP;
>> +}
>> diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
>> b/lib/librte_eal/bsdapp/eal/eal_pci.c
>> index 7ed0115..703f034 100644
>> --- a/lib/librte_eal/bsdapp/eal/eal_pci.c
>> +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
>> @@ -89,11 +89,11 @@
>>
>>  /* unbind kernel driver for this device */
>>  int
>> -pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
>> +pci_unbind_kernel_driver(struct rte_pci_device *dev)
>>  {
>> RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented "
>> "for BSD\n");
>> -   return -ENOTSUP;
>> +   return rte_eal_unbind_kernel_driver(dev);
>
> Missing the second parameter for devid.

Indeed. I will fix this.
Being BSD, I didn't compile test this part. I will have to find a way to 
fix this in my sanity before sending next series.

>
>>  }
>>
>>  /* Map pci device */
>> diff --git a/lib/librte_eal/common/eal_private.h 
>> b/lib/librte_eal/common/eal_private.h
>> index 9e7d8f6..b0c208a 100644
>> --- a/lib/librte_eal/common/eal_private.h
>> +++ b/lib/librte_eal/common/eal_private.h
>> @@ -256,6 +256,19 @@ int rte_eal_alarm_init(void);
>>  int rte_eal_check_module(const char *module_name);
>>
>>  /**
>> + * Unbind kernel driver bound to the device specified by the given devpath,
>> + * and its string identification.
>> + *
>> + * @param devpath  path to the device directory ("/sys/.../devices/")
>> + * @param devididentification of the device ()
>> + *
>> + * @return
>> + *  -1  unbind has failed
>> + *   0  module has been unbound
>> + */
>> +int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid);
>> +
>> +/**
>>   * Get cpu core_id.
>>   *
>>   * This function is private to the EAL.
>> diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
>> b/lib/librte_eal/linuxapp/eal/eal.c
>> index 2075282..5f6676d 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal.c
>> @@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name)
>> /* Module has been found */
>> return 1;
>>  }
>> +
>> +int
>> +rte_eal_unbind_kernel_driver(const char *devpath, const char *devid)
>> +{
>> +   char filename[PATH_MAX];
>> +   FILE *f;
>> +
>> +   snprintf(filename, sizeof(filename),
>> +"%s/driver/unbind", devpath);
>> +
>> +   f = fopen(filename, "w");
>> +   if (f == NULL) /* device was not bound */
>> +   return 0;
>> +
>> +   if (fwrite(devid, strlen(devid), 1, f) == 0) {
>> +   RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
>> +   filename);
>> +   goto error;
>> +   }
>> +
>&g

[dpdk-dev] [PATCH v7 00/21] Introduce SoC device/driver framework for EAL

2016-11-09 Thread Shreyansh Jain
Hello Thomas,

On Wednesday 09 November 2016 03:47 PM, Thomas Monjalon wrote:
> Hi Shreyansh,
>
> I realize that we had a lot of off-list discussions on this topic
> and there was no public explanation of the status of this series.

Thanks for your email. (and all the suggestions you have given 
offline/IRC etc.)
I was beginning to wonder that probably only Jan and me were the ones 
interested in this. Ironically, I felt that being EAL changes, a lot of 
people would come and be critic of it - giving an opportunity to get it 
widely accepted.

>
> 2016-10-28 17:56, Shreyansh Jain:
> [...]
>> As of now EAL is primarly focused on PCI initialization/probing.
>
> Right. DPDK was PCI centric.
> We must give PCI its right role: a bus as other ones.
> A first step was done in 16.11 (thanks to you Shreyansh, Jan and David)
> to have a better device model.
> The next step is to rework the bus abstraction.

Or, this change can be broken into multiple steps:
1. Create a PCI parallel layer for non-PCI devices. (call it SoC, or 
whatever else - doesn't really matter. More below).
2. Generalize this 'soc' changeset into common
3. Complete generalization by introducing a Linux like model of 
bus<=>device<=>driver.

Which was what my current approach was - expecting that SoC patchset 
would allow me to introduce NXP PMD and parallel to it I can keep 
pushing EAL generic changes towards generic bus arch.

>
> It seems a bus can be defined with the properties scan/match/notify,
> leading to initialize the devices.

'notify' is something which I am not completely clear with - but, in 
principle, agree.

>
> More comments below your technical presentation.
>
> [...]
>> This patchset introduces SoC framework which would enable SoC drivers and
>> drivers to be plugged into EAL, very similar to how PCI drivers/devices are
>> done today.
>>
>> This is a stripped down version of PCI framework which allows the SoC PMDs
>> to implement their own routines for detecting devices and linking devices to
>> drivers.
>>
>> 1) Changes to EAL
>>  rte_eal_init()
>>   |- rte_eal_pci_init(): Find PCI devices from sysfs
>>   |- rte_eal_soc_init(): Calls PMDs->scan_fn
>>   |- ...
>>   |- rte_eal_memzone_init()
>>   |- ...
>>   |- rte_eal_pci_probe(): Driver<=>Device initialization, PMD->devinit()
>>   `- rte_eal_soc_probe(): Calls PMDs->match_fn and PMDs->devinit();
>>
>> 2) New device/driver structures:
>>   - rte_soc_driver (inheriting rte_driver)
>>   - rte_soc_device (inheriting rte_device)
>>   - rte_eth_dev and eth_driver embedded rte_soc_device and rte_soc_driver,
>> respectively.
>>
>> 3) The SoC PMDs need to:
>>  - define rte_soc_driver with necessary scan and match callbacks
>>  - Register themselves using DRIVER_REGISTER_SOC()
>>  - Implement respective bus scanning in the scan callbacks to add necessary
>>devices to SoC device list
>>  - Implement necessary eth_dev_init/uninint for ethernet instances
>
> These callbacks are not specific to a SoC.

Agree; this is just a note - it exactly what a PCI PMD does.

> By the way a SoC defines nothing specific. You are using the SoC word
> as an equivalent of non-PCI.

Yes, primarily because SoC is a very broad word which can encompass a 
variety of devices (buses/drivers). So, we have PCI set, VDEV set, and 
everything else represented by 'SoC'.
The complete set is based on this principle: to have a generic subsystem 
_parallel_ to PCI (so as not to impact it) which can represent all 
devices not already included in PCI set'. - Actually, it is _nothing_ 
specific.

> We must have a bus abstraction like the one you are defining for the SoC
> but it must be generic and defined on top of PCI, so we can plug any
> bus in it: PCI, vdev (as a software bus), any other well-defined bus,
> and some driver-specific bus which can be implemented directly in the
> driver (the NXP case AFAIK).

Indeed - that is an ideal approach. And honestly, true attribution, it 
is not my original idea. It is yours, from our IRC discussion.
And it was ironic as well because Declan came up with similar suggestion 
much earlier but no one commented on it.

>
>> 4) Design considerations that are same as PCI:
>>  - SoC initialization is being done through rte_eal_init(), just after PCI
>>initialization is done.
>>  - As in case of PCI, probe is done after rte_eal_pci_probe() to link the
>>devices detected with the drivers registered.
>>  - Device attach/detach functions are available and have been designed on
>>the lines of PCI framework.
>>  - PMDs register using DRIVER_REGISTER_SOC, very similar to
>>DRIVER_REGISTER_PCI for PCI devices.
>&

[dpdk-dev] [PATCH] pci: Don't call probe callback if driver already loaded.

2016-11-02 Thread Shreyansh Jain
On 10/26/2016 3:20 AM, Ben Walker wrote:
> If the user asks to probe multiple times, the probe
> callback should only be called on devices that don't have
> a driver already loaded.
>
> This is useful if a driver is registered after the
> execution of a program has started and the list of devices
> needs to be re-scanned.
>
> Signed-off-by: Ben Walker 
> ---
>  lib/librte_eal/common/eal_common_pci.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/lib/librte_eal/common/eal_common_pci.c 
> b/lib/librte_eal/common/eal_common_pci.c
> index 638cd86..971ad20 100644
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -289,6 +289,10 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
>   if (dev == NULL)
>   return -1;
>
> + /* Check if a driver is already loaded */
> + if (dev->driver != NULL)
> + return 0;
> +

In case if it is required to change the driver assigned to a device, would it 
mean application relies on detach(dev)->new-driver-plugged-in->attach(dev) 
sequence?
To me, the above change sounds fine. Though, I am not aware if there is even a 
use case for changing driver assigned to a device. detach()->attach() should be 
able to work in those cases, I think.

>   TAILQ_FOREACH(dr, _driver_list, next) {
>   rc = rte_eal_pci_probe_one_driver(dr, dev);
>   if (rc < 0)
>

-
Shreyansh



[dpdk-dev] PCIe Hot Insert/Remove Support

2016-11-02 Thread Shreyansh Jain
Hello Ben,

Apologies for joining this discussion late.

On 10/24/2016 11:46 PM, Walker, Benjamin wrote:
> Hi all,
>
> My name is Ben Walker and I'm the technical lead for SPDK (it's like DPDK, but
> for storage devices). SPDK relies on DPDK only for the base functionality in 
> the
> EAL - memory management, the rings, and the PCI scanning code. A key feature 
> for
> storage devices is support for hot insert and remove, so we're currently 
> working
> through how best to implement this for a user space driver. While doing this
> work, we've run into a few issues with the current DPDK PCI/device/driver
> framework that I'd like to discuss with this list. I'm not entirely ramped up 
> on
> all of the current activity in this area or what the future plans are, so 
> please
> educate me if something is coming that will address our current issues. I'm
> working off of the latest commit on the master branch as of today.

There has been some work recently ([1], [2]) which generalized the overall DPDK 
EAL framework to not look at devices as PCI only. In that sense, the 
attach/detach routines were also generalized. But, dynamically removing device 
during the application initialization is still something which is grey area 
(from what I understand).
There are some callbacks which the application can register (eal interrupts), 
but it would entirely depend on drivers ability to handle interrupts generated 
from device.

A complete restructuring of EAL is still open discussion - which might include 
this point. There is a patch series floated by Jan (and subsequently managed by 
me) here [3]. I also initiated a discussion on this lines in DPDK User Summit 
in Ireland (Slide 18 of [4] might interest you).

[1] http://dpdk.org/ml/archives/dev/2016-January/031390.html
[2] http://dpdk.org/ml/archives/dev/2016-September/047099.html
[3] http://dpdk.org/ml/archives/dev/2016-October/049606.html
[4] 
https://dpdksummit.com/Archive/pdf/2016Userspace/Day02-Session03-ShreyanshJain-Userspace2016.pdf

>
> Today, there appears to be two lists - one of PCI devices and one of drivers. 
> To
> update the list of PCI devices, you call rte_eal_pci_scan(), which scans the 
> PCI
> bus. That call does not attempt to load any drivers. One scan is automatically
> performed when the eal is first initialized. To add or remove drivers from the
> driver list you call rte_eal_driver_register/unregister. To match drivers in 
> the
> driver list to devices in the device list, you call rte_eal_pci_probe.

I agree with this general flow.

>
> There are a few problems with how the code works for us. First,
> rte_eal_pci_scan's algorithm will not correctly detect devices that are in its
> internal list but weren't found by the most recent PCI bus scan (i.e. they 
> were
> hot removed). DPDK's scan doesn't seem to comprehend hot remove in any way.

Indeed. And this not just limited to failure to scan hot-removed, but also 
those devices which are either ethernet or crypto but not PCI bus compliant. 
Essentially, the complete DPDK scan model assumes that PCI compliant devices 
are available *before* scan is performed and across the scan process.
Hotplugging is limited to applications ability to attach/detach devices.

> Fortunately there is a public API to remove devices from the device list -
> rte_eal_pci_detach. That function will automatically unload any drivers
> associated with the device and then remove it from the list. There is a 
> similar
> call for adding a device to the list - rte_eal_pci_probe_one, which will add a
> device to the device list and then automatically match it to drivers. I think 
> if
> rte_eal_pci_scan is going to be a public interface (and it is), it needs to
> correctly comprehend the removal of PCI devices. Otherwise, make it a private

In some parallel discussions, there have been talk of scan being non-PCI 
centric - which would make this API hidden beneath another layer of generic 
scan. Either way, clean handling of a hot-plugging case is indeed desirable. 
See [4] above.

> API that is only called in response to rte_eal_init and only expose the public
> probe_one/detach calls for modifying the list of devices. My preference is for
> the former, not the latter.

Generic way of DPDK application is to start, rely on DPDK framework to find 
devices which have already been attached to the PCI drivers (bind script) and 
then wait for probing to finish  (rte_eal_init) so as to start the I/O 
(creating pool, queue setup, etc). In the later method suggested by you, this 
model doesn't bode well. From what I make of it,  applications would then be 
responsible for attaches thereby making them call extra APIs. In that context, 
I too prefer the former (handling hotplug).

>
> Second, rte_eal_pci_probe will call the driver initialization functions each
> time a probe happens, even if the driver has already been successfully loaded.
> This tends to crash a lot of the PMDs. It seems to me like rte_eal_pci_probe 
> is
> not 

[dpdk-dev] [PATCH v7 00/21] Introduce SoC device/driver framework for EAL

2016-10-28 Thread Shreyansh Jain
On Friday 28 October 2016 05:56 PM, Shreyansh Jain wrote:
> Introduction:
> =
>
> This patch set is direct derivative of Jan's original series [1],[2].
>
>  - This version is based on master HEAD (ca41215)
>
>  - In this, I am merging the series [11] back. It was initially part
>of this set but I had split considering that those changes in PCI
>were good standalone as well. But, 1) not much feedback was avail-
>able and 2) this patchset is a use-case for those patches making
>it easier to review. Just like what Jan had intended in original
>series.
>
>  - SoC support is not enabled by default. It needs the 'enable-soc' toggle
>on command line. This is primarily because this patchset is still
>experimental and we would like to keep it isolated from non-SoC ops.
>Though, it does impact the ABI.

Sending v7 as patch 11/21 of v6 wasn't received by mailing list leading 
to automated build failure. No other change has been done.

-
Shreyansh


[dpdk-dev] [PATCH v7 21/21] eal/crypto: Support rte_soc_driver/device for cryptodev

2016-10-28 Thread Shreyansh Jain
- rte_cryptodev_driver/rte_cryptodev_dev embeds rte_soc_driver/device for
  linking SoC PMDs to crypto devices.
- Add probe and remove functions linked

Signed-off-by: Hemant Agrawal 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_cryptodev/rte_cryptodev.c   | 122 -
 lib/librte_cryptodev/rte_cryptodev.h   |   3 +
 lib/librte_cryptodev/rte_cryptodev_pmd.h   |  18 +++-
 lib/librte_cryptodev/rte_cryptodev_version.map |   2 +
 4 files changed, 140 insertions(+), 5 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index 127e8d0..77ec9fe 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -422,7 +422,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,

int retval;

-   cryptodrv = (struct rte_cryptodev_driver *)pci_drv;
+   cryptodrv = container_of(pci_drv, struct rte_cryptodev_driver,
+pci_drv);
if (cryptodrv == NULL)
return -ENODEV;

@@ -489,7 +490,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
if (cryptodev == NULL)
return -ENODEV;

-   cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver;
+   cryptodrv = container_of(pci_dev->driver, struct rte_cryptodev_driver,
+pci_drv);
if (cryptodrv == NULL)
return -ENODEV;

@@ -513,6 +515,111 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
return 0;
 }

+
+int
+rte_cryptodev_soc_probe(struct rte_soc_driver *soc_drv,
+ struct rte_soc_device *soc_dev)
+{
+   struct rte_cryptodev_driver *cryptodrv;
+   struct rte_cryptodev *cryptodev;
+
+   char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
+
+   int retval;
+
+   cryptodrv = container_of(soc_drv, struct rte_cryptodev_driver,
+soc_drv);
+
+   rte_eal_soc_device_name(_dev->addr, cryptodev_name,
+   sizeof(cryptodev_name));
+
+   cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name,
+  rte_socket_id());
+   if (cryptodev == NULL)
+   return -ENOMEM;
+
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   cryptodev->data->dev_private =
+   rte_zmalloc_socket(
+   "cryptodev private structure",
+   cryptodrv->dev_private_size,
+   RTE_CACHE_LINE_SIZE,
+   rte_socket_id());
+
+   if (cryptodev->data->dev_private == NULL)
+   rte_panic("Cannot allocate memzone for private "
+   "device data");
+   }
+
+   cryptodev->soc_dev = soc_dev;
+   cryptodev->driver = cryptodrv;
+
+   /* init user callbacks */
+   TAILQ_INIT(&(cryptodev->link_intr_cbs));
+
+   /* Invoke PMD device initialization function */
+   retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev);
+   if (retval == 0)
+   return 0;
+
+   CDEV_LOG_ERR("driver %s: cryptodev_init(%s) failed\n",
+   soc_drv->driver.name,
+   soc_dev->addr.name);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(cryptodev->data->dev_private);
+
+   cryptodev->attached = RTE_CRYPTODEV_DETACHED;
+   cryptodev_globals.nb_devs--;
+
+   return -ENXIO;
+}
+
+int
+rte_cryptodev_soc_remove(struct rte_soc_device *soc_dev)
+{
+   const struct rte_cryptodev_driver *cryptodrv;
+   struct rte_cryptodev *cryptodev;
+   char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
+   int ret;
+
+   if (soc_dev == NULL)
+   return -EINVAL;
+
+   rte_eal_soc_device_name(_dev->addr, cryptodev_name,
+   sizeof(cryptodev_name));
+
+   cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
+   if (cryptodev == NULL)
+   return -ENODEV;
+
+   cryptodrv = container_of(soc_dev->driver,
+   struct rte_cryptodev_driver, soc_drv);
+   if (cryptodrv == NULL)
+   return -ENODEV;
+
+   /* Invoke PMD device uninit function */
+   if (*cryptodrv->cryptodev_uninit) {
+   ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev);
+   if (ret)
+   return ret;
+   }
+
+   /* free crypto device */
+   rte_cryptodev_pmd_release_device(cryptodev);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(cryptodev->data->dev_private);
+
+   cryptodev->pci_dev = NULL;
+   cryptodev-&

[dpdk-dev] [PATCH v7 20/21] ether: introduce ethernet dev probe remove

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 148 +-
 lib/librte_ether/rte_ethdev.h |  31 +
 2 files changed, 177 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4c61246..972e916 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -325,6 +325,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 }

 int
+rte_eth_dev_soc_probe(struct rte_soc_driver *soc_drv,
+ struct rte_soc_device *soc_dev)
+{
+   struct eth_driver*eth_drv;
+   struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
+   int diag;
+
+   eth_drv = container_of(soc_drv, struct eth_driver, soc_drv);
+
+   rte_eal_soc_device_name(_dev->addr, ethdev_name,
+   sizeof(ethdev_name));
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
+   if (eth_dev == NULL)
+   return -ENOMEM;
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   eth_dev->data->dev_private = rte_zmalloc(
+ "ethdev private structure",
+ eth_drv->dev_private_size,
+ RTE_CACHE_LINE_SIZE);
+   if (eth_dev->data->dev_private == NULL)
+   rte_panic("Cannot allocate memzone for private port "
+ "data\n");
+   }
+   eth_dev->soc_dev = soc_dev;
+   eth_dev->driver = eth_drv;
+   eth_dev->data->rx_mbuf_alloc_failed = 0;
+
+   /* init user callbacks */
+   TAILQ_INIT(&(eth_dev->link_intr_cbs));
+
+   /*
+* Set the default MTU.
+*/
+   eth_dev->data->mtu = ETHER_MTU;
+
+   /* Invoke PMD device initialization function */
+   diag = (*eth_drv->eth_dev_init)(eth_dev);
+   if (diag == 0)
+   return 0;
+
+   RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(%s) failed\n",
+   soc_drv->driver.name,
+   soc_dev->addr.name);
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(eth_dev->data->dev_private);
+   rte_eth_dev_release_port(eth_dev);
+   return diag;
+}
+
+int
+rte_eth_dev_soc_remove(struct rte_soc_device *soc_dev)
+{
+   const struct eth_driver *eth_drv;
+   struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+   int ret;
+
+   if (soc_dev == NULL)
+   return -EINVAL;
+
+   rte_eal_soc_device_name(_dev->addr, ethdev_name,
+   sizeof(ethdev_name));
+
+   eth_dev = rte_eth_dev_allocated(ethdev_name);
+   if (eth_dev == NULL)
+   return -ENODEV;
+
+   eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv);
+
+   /* Invoke PMD device uninit function */
+   if (*eth_drv->eth_dev_uninit) {
+   ret = (*eth_drv->eth_dev_uninit)(eth_dev);
+   if (ret)
+   return ret;
+   }
+
+   /* free ether device */
+   rte_eth_dev_release_port(eth_dev);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(eth_dev->data->dev_private);
+
+   eth_dev->soc_dev = NULL;
+   eth_dev->driver = NULL;
+   eth_dev->data = NULL;
+
+   return 0;
+}
+
+
+int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1557,6 +1652,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct 
rte_eth_dev_info *dev_info)
RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
(*dev->dev_ops->dev_infos_get)(dev, dev_info);
dev_info->pci_dev = dev->pci_dev;
+   dev_info->soc_dev = dev->soc_dev;
dev_info->driver_name = dev->data->drv_name;
dev_info->nb_rx_queues = dev->data->nb_rx_queues;
dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2535,8 +2631,15 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 static inline
 struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev)
 {
-   if (dev->pci_dev)
+   if (dev->pci_dev) {
+   RTE_ASSERT(dev->soc_dev == NULL);
return >pci_dev->intr_handle;
+   }
+
+   if (dev->soc_dev) {
+   RTE_ASSERT(dev->pci_dev == NULL);
+   return >soc_dev->intr_handle;
+   }

RTE_ASSERT(0);
return NULL;
@@ -2573,6 +2676,23 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int 
op, void *data)
return 0;
 }

+static inline
+const char *eth_dev_get_driver_name(const struct rte_eth_dev *d

[dpdk-dev] [PATCH v7 19/21] ether: extract function eth_dev_get_intr_handle

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

We abstract access to the intr_handle here as we want to get
it either from the pci_dev or soc_dev.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a1e3aaf..4c61246 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2532,6 +2532,16 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
rte_spinlock_unlock(_eth_dev_cb_lock);
 }

+static inline
+struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev)
+{
+   if (dev->pci_dev)
+   return >pci_dev->intr_handle;
+
+   RTE_ASSERT(0);
+   return NULL;
+}
+
 int
 rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 {
@@ -2544,7 +2554,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int 
op, void *data)
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

dev = _eth_devices[port_id];
-   intr_handle = >pci_dev->intr_handle;
+   intr_handle = eth_dev_get_intr_handle(dev);
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
@@ -2604,7 +2614,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t 
queue_id,
return -EINVAL;
}

-   intr_handle = >pci_dev->intr_handle;
+   intr_handle = eth_dev_get_intr_handle(dev);
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
-- 
2.7.4



[dpdk-dev] [PATCH v7 18/21] ether: verify we copy info from a PCI device

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Now that different types of ethdev exist, check for presence of PCI dev
while copying out the info.
Similar would be done for SoC.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 347c230..a1e3aaf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3206,6 +3206,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct 
rte_pci_device *pci_de
return;
}

+   RTE_VERIFY(eth_dev->pci_dev != NULL);
+
eth_dev->data->dev_flags = 0;
if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-- 
2.7.4



[dpdk-dev] [PATCH v7 17/21] ether: utilize container_of for pci_drv

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

It is not necessary to place the rte_pci_driver at the beginning
of the rte_eth_dev struct anymore as we use the container_of macro
to get the parent pointer.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 4 ++--
 lib/librte_ether/rte_ethdev.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..347c230 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -241,7 +241,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,

int diag;

-   eth_drv = (struct eth_driver *)pci_drv;
+   eth_drv = container_of(pci_drv, struct eth_driver, pci_drv);

rte_eal_pci_device_name(_dev->addr, ethdev_name,
sizeof(ethdev_name));
@@ -302,7 +302,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
if (eth_dev == NULL)
return -ENODEV;

-   eth_drv = (const struct eth_driver *)pci_dev->driver;
+   eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv);

/* Invoke PMD device uninit function */
if (*eth_drv->eth_dev_uninit) {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 38641e8..f893fe0 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1850,7 +1850,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev 
*eth_dev);
  * Each Ethernet driver acts as a PCI driver and is represented by a generic
  * *eth_driver* structure that holds:
  *
- * - An *rte_pci_driver* structure (which must be the first field).
+ * - An *rte_pci_driver* structure.
  *
  * - The *eth_dev_init* function invoked for each matching PCI device.
  *
-- 
2.7.4



[dpdk-dev] [PATCH v7 16/21] eal/soc: additional features for SoC

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Additional features introduced:
 - Find kernel driver through sysfs bindings
 - Dummy implementation for mapping to kernel driver
 - DMA coherency value from sysfs
 - Numa node number from sysfs
 - Support for updating device during probe if already registered

Signed-off-by: Jan Viktorin 
[Shreyansh: merge multiple patches into single set]
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_soc.c  |  30 
 lib/librte_eal/common/eal_private.h |  23 ++
 lib/librte_eal/common/include/rte_soc.h |  28 +++
 lib/librte_eal/linuxapp/eal/eal_soc.c   | 129 
 4 files changed, 210 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
index 44f5559..29c38e0 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -114,6 +114,26 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *drv,
return ret;
}

+   if (!dev->is_dma_coherent) {
+   if (!(drv->drv_flags & RTE_SOC_DRV_ACCEPT_NONCC)) {
+   RTE_LOG(DEBUG, EAL,
+   "  device is not DMA coherent, skipping\n");
+   return 1;
+   }
+   }
+
+   if (drv->drv_flags & RTE_SOC_DRV_NEED_MAPPING) {
+   /* map resources */
+   ret = rte_eal_soc_map_device(dev);
+   if (ret)
+   return ret;
+   } else if (drv->drv_flags & RTE_SOC_DRV_FORCE_UNBIND
+   && rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   /* unbind */
+   if (soc_unbind_kernel_driver(dev) < 0)
+   return -1;
+   }
+
dev->driver = drv;
RTE_VERIFY(drv->probe != NULL);
return drv->probe(drv, dev);
@@ -166,6 +186,10 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *drv,
if (drv->remove && (drv->remove(dev) < 0))
return -1;  /* negative value is an error */

+   if (drv->drv_flags & RTE_SOC_DRV_NEED_MAPPING)
+   /* unmap resources for devices */
+   rte_eal_soc_unmap_device(dev);
+
/* clear driver structure */
dev->driver = NULL;

@@ -241,6 +265,12 @@ rte_eal_soc_probe_one(const struct rte_soc_addr *addr)
if (addr == NULL)
return -1;

+   /* update current SoC device in global list, kernel bindings might have
+* changed since last time we looked at it.
+*/
+   if (soc_update_device(addr) < 0)
+   goto err_return;
+
TAILQ_FOREACH(dev, _device_list, next) {
if (rte_eal_compare_soc_addr(>addr, addr))
continue;
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index d810f9f..30c648d 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -159,6 +159,29 @@ int pci_update_device(const struct rte_pci_addr *addr);
 int pci_unbind_kernel_driver(struct rte_pci_device *dev);

 /**
+ * Update a soc device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *  The SoC address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int soc_update_device(const struct rte_soc_addr *addr);
+
+/**
+ * Unbind kernel driver for this device
+ *
+ * This function is private to EAL.
+ *
+ * @return
+ *   0 on success, negative on error
+ */
+int soc_unbind_kernel_driver(struct rte_soc_device *dev);
+
+/**
  * Map the PCI resource of a PCI device in virtual memory
  *
  * This function is private to EAL.
diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 8be3db7..d7f7ec8 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -46,9 +46,11 @@ extern "C" {

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -63,6 +65,14 @@ extern struct soc_device_list soc_device_list;
 TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */
 TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */

+#define SOC_MAX_RESOURCE 6
+
+struct rte_soc_resource {
+   uint64_t phys_addr;
+   uint64_t len;
+   void *addr;
+};
+
 struct rte_soc_id {
union {
const char *compatible; /**< OF compatible specification */
@@ -84,8 +94,12 @@ struct rte_soc_device {
struct rte_device device;   /**< Inherit code device */
struct rte_soc_addr addr;   /**< SoC device Location */
struct rte_soc_id *id;  /**< SoC device ID list */
+   struct rte_soc_res

[dpdk-dev] [PATCH v7 15/21] eal/soc: add default scan for Soc devices

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@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 
[Shreyansh: restructure commit to be an optional implementation]
Signed-off-by: Shreyansh Jain 

--
 v5:
 - Update rte_eal_soc_scan to rte_eal_soc_scan_platform_bus
 - Fix comments over scan and match functions
---
 lib/librte_eal/common/include/rte_soc.h |  16 +-
 lib/librte_eal/linuxapp/eal/eal_soc.c   | 315 
 2 files changed, 329 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 38f897d..8be3db7 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -64,7 +64,10 @@ TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC 
drivers in D-linked Q. */
 TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */

 struct rte_soc_id {
-   const char *compatible; /**< OF compatible specification */
+   union {
+   const char *compatible; /**< OF compatible specification */
+   char *_compatible;
+   };
uint64_t priv_data; /**< SoC Driver specific data */
 };

@@ -200,7 +203,16 @@ rte_eal_parse_soc_spec(const char *spec, struct 
rte_soc_addr *addr)
 }

 /**
- * Default function for matching the Soc driver with device. Each driver can
+ * Helper function for scanning for new SoC devices on platform bus.
+ *
+ * @return
+ * 0 on success
+ * !0 on failure to scan
+ */
+int rte_eal_soc_scan_platform_bus(void);
+
+/**
+ * Helper function for matching the Soc driver with device. Each driver can
  * either use this function or define their own soc matching function.
  * This function relies on the compatible string extracted from sysfs. But,
  * a SoC might have different way of identifying its devices. Such SoC can
diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c 
b/lib/librte_eal/linuxapp/eal/eal_soc.c
index 3929a76..d8dfe97 100644
--- a/lib/librte_eal/linuxapp/eal/eal_soc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_soc.c
@@ -48,6 +48,321 @@
 #include 
 #include 

+/** Pathname of SoC devices directory. */
+#define SYSFS_SOC_DEVICES "/sys/bus/platform/devices"
+
+static const char *
+soc_get_sysfs_path(void)
+{
+   const char *path = NULL;
+
+   path = getenv("SYSFS_SOC_DEVICES");
+   if (path == NULL)
+   return SYSFS_SOC_DEVICES;
+
+   return path;
+}
+
+static char *
+dev_read_uevent(const char *dirname)
+{
+   char filename[PATH_MAX];
+   struct stat st;
+   char *buf;
+   ssize_t total = 0;
+   int fd;
+
+   snprintf(filename, sizeof(filename), "%s/uevent", dirname);
+   fd = open(filename, O_RDONLY);
+   if (fd < 0) {
+   RTE_LOG(WARNING, EAL, "Failed to open file %s\n", filename);
+   return strdup("");
+   }
+
+   if (fstat(fd, ) < 0) {
+   RTE_LOG(ERR, EAL, "Failed to stat file %s\n", filename);
+   close(fd);
+   return NULL;
+   }
+
+   if (st.st_size == 0) {
+   close(fd);
+   return strdup("");
+   }
+
+   buf = malloc(st.st_size + 1);
+   if (buf == NULL) {
+   RTE_LOG(ERR, EAL, "Failed to alloc memory to read %s\n",
+   filename);
+   close(fd);
+   return NULL;
+   }
+
+   while (total < st.st_size) {
+   ssize_t rlen = read(fd, buf + total, st.st_size - total);
+   if (rlen < 0) {
+   if (errno == EINTR)
+   continue;
+
+   RTE_LOG(ERR, EAL, "Failed to read file %s\n", filename);
+
+   free(buf);
+   close(fd);
+   return NULL;
+   }
+   if (rlen == 0) /* EOF */
+   break;
+
+   total += rlen;
+   }
+
+   buf[total] = '\0';
+   close(fd);
+
+   return buf;
+}
+
+static const char *
+dev_uevent_find(const char *uevent, const char *key)
+{
+   const size_t keylen = strlen(key);
+   const size_t total = strlen(uevent);
+   const char *p = uevent;
+
+   /* check whether it is the first key */
+   if (!strncmp(uevent, key, keylen))
+   return uevent + keylen;
+
+   /* check 2nd key or further... */
+   do {
+   p = strstr(p, key);
+   if (p == NULL)
+   break;
+
+   if (p[-1] == '\n') /* check we are at a new line */
+   return p + keylen;
+
+   p += keylen; /* skip this

[dpdk-dev] [PATCH v7 14/21] eal/soc: add intr_handle

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/common/include/rte_soc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 40490b9..38f897d 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -53,6 +53,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 

 extern struct soc_driver_list soc_driver_list;
 /**< Global list of SoC Drivers */
@@ -80,6 +81,7 @@ struct rte_soc_device {
struct rte_device device;   /**< Inherit code device */
struct rte_soc_addr addr;   /**< SoC device Location */
struct rte_soc_id *id;  /**< SoC device ID list */
+   struct rte_intr_handle intr_handle; /**< Interrupt handle */
struct rte_soc_driver *driver;  /**< Associated driver */
 };

-- 
2.7.4



[dpdk-dev] [PATCH v7 13/21] eal/soc: add drv_flags

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

The flags are copied from the PCI ones. They should be refactorized into a
general set of flags in the future.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/common/include/rte_soc.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index fb5ea7b..40490b9 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -123,8 +123,18 @@ struct rte_soc_driver {
soc_scan_t *scan_fn;   /**< Callback for scanning SoC bus*/
soc_match_t *match_fn; /**< Callback to match dev<->drv */
const struct rte_soc_id *id_table; /**< ID table, NULL terminated */
+   uint32_t drv_flags;/**< Control handling of device */
 };

+/** Device needs to map its resources by EAL */
+#define RTE_SOC_DRV_NEED_MAPPING 0x0001
+/** Device needs to be unbound even if no module is provieded */
+#define RTE_SOC_DRV_FORCE_UNBIND 0x0004
+/** Device driver supports link state interrupt */
+#define RTE_SOC_DRV_INTR_LSC0x0008
+/** Device driver supports detaching capability */
+#define RTE_SOC_DRV_DETACHABLE  0x0010
+
 /**
  * Utility function to write a SoC device name, this device name can later be
  * used to retrieve the corresponding rte_soc_addr using above functions.
-- 
2.7.4



[dpdk-dev] [PATCH v7 12/21] eal/soc: extend and utilize devargs

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

It is assumed that SoC Devices provided on command line are prefixed with
"soc:". This patch adds parse and attach support for such devices.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/common/eal_common_dev.c  | 27 +
 lib/librte_eal/common/eal_common_devargs.c  | 17 
 lib/librte_eal/common/eal_common_soc.c  | 61 -
 lib/librte_eal/common/include/rte_devargs.h |  8 
 lib/librte_eal/common/include/rte_soc.h | 24 
 5 files changed, 120 insertions(+), 17 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 457d227..ebbcf47 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -107,17 +107,23 @@ rte_eal_dev_init(void)

 int rte_eal_dev_attach(const char *name, const char *devargs)
 {
-   struct rte_pci_addr addr;
+   struct rte_soc_addr soc_addr;
+   struct rte_pci_addr pci_addr;

if (name == NULL || devargs == NULL) {
RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
return -EINVAL;
}

-   if (eal_parse_pci_DomBDF(name, ) == 0) {
-   if (rte_eal_pci_probe_one() < 0)
+   memset(_addr, 0, sizeof(soc_addr));
+   if (rte_eal_parse_soc_spec(name, _addr) == 0) {
+   if (rte_eal_soc_probe_one(_addr) < 0) {
+   free(soc_addr.name);
+   goto err;
+   }
+   } else if (eal_parse_pci_DomBDF(name, _addr) == 0) {
+   if (rte_eal_pci_probe_one(_addr) < 0)
goto err;
-
} else {
if (rte_eal_vdev_init(name, devargs))
goto err;
@@ -132,15 +138,22 @@ err:

 int rte_eal_dev_detach(const char *name)
 {
-   struct rte_pci_addr addr;
+   struct rte_soc_addr soc_addr;
+   struct rte_pci_addr pci_addr;

if (name == NULL) {
RTE_LOG(ERR, EAL, "Invalid device provided.\n");
return -EINVAL;
}

-   if (eal_parse_pci_DomBDF(name, ) == 0) {
-   if (rte_eal_pci_detach() < 0)
+   memset(_addr, 0, sizeof(soc_addr));
+   if (rte_eal_parse_soc_spec(name, _addr) == 0) {
+   if (rte_eal_soc_detach(_addr) < 0) {
+   free(soc_addr.name);
+   goto err;
+   }
+   } else if (eal_parse_pci_DomBDF(name, _addr) == 0) {
+   if (rte_eal_pci_detach(_addr) < 0)
goto err;
} else {
if (rte_eal_vdev_uninit(name))
diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index e403717..e1dae1a 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -41,6 +41,7 @@
 #include 

 #include 
+#include 
 #include 
 #include "eal_private.h"

@@ -105,6 +106,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char 
*devargs_str)
goto fail;

break;
+
+   case RTE_DEVTYPE_WHITELISTED_SOC:
+   case RTE_DEVTYPE_BLACKLISTED_SOC:
+   /* try to parse soc device with prefix "soc:" */
+   if (rte_eal_parse_soc_spec(buf, >soc.addr) != 0)
+   goto fail;
+   break;
+
case RTE_DEVTYPE_VIRTUAL:
/* save driver name */
ret = snprintf(devargs->virt.drv_name,
@@ -166,6 +175,14 @@ rte_eal_devargs_dump(FILE *f)
   devargs->pci.addr.devid,
   devargs->pci.addr.function,
   devargs->args);
+   else if (devargs->type == RTE_DEVTYPE_WHITELISTED_SOC)
+   fprintf(f, "  SoC whitelist %s %s\n",
+  devargs->soc.addr.name,
+  devargs->soc.addr.fdt_path);
+   else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_SOC)
+   fprintf(f, "  SoC blacklist %s %s\n",
+  devargs->soc.addr.name,
+  devargs->soc.addr.fdt_path);
else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
fprintf(f, "  VIRTUAL %s %s\n",
   devargs->virt.drv_name,
diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
index 256cef8..44f5559 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -37,6 +37,8 @@

 #include 
 #include 
+#include 
+#include 
 #include 

 #include "eal_private.h"
@@ -70,6 +72,2

[dpdk-dev] [PATCH v7 11/21] eal/soc: implement probing of drivers

2016-10-28 Thread Shreyansh Jain
Each SoC PMD registers a set of callback for scanning its own bus/infra and
matching devices to drivers when probe is called.
This patch introduces the infra for calls to SoC scan on rte_eal_soc_init()
and match on rte_eal_soc_probe().

Patch also adds test case for scan and probe.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
--
v4:
 - Update test_soc for descriptive test function names
 - Comments over test functions
 - devinit and devuninint --> probe/remove
 - RTE_VERIFY at some places
---
 app/test/test_soc.c | 205 ++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   4 +
 lib/librte_eal/common/eal_common_soc.c  | 213 +++-
 lib/librte_eal/common/include/rte_soc.h |  75 -
 lib/librte_eal/linuxapp/eal/eal.c   |   5 +
 lib/librte_eal/linuxapp/eal/eal_soc.c   |  21 ++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   4 +
 7 files changed, 519 insertions(+), 8 deletions(-)

diff --git a/app/test/test_soc.c b/app/test/test_soc.c
index ac03e64..b587d5e 100644
--- a/app/test/test_soc.c
+++ b/app/test/test_soc.c
@@ -87,14 +87,65 @@ static int test_compare_addr(void)
  */
 struct test_wrapper {
struct rte_soc_driver soc_drv;
+   struct rte_soc_device soc_dev;
 };

+static int empty_pmd0_probe(struct rte_soc_driver *drv,
+ struct rte_soc_device *dev);
+static int empty_pmd0_remove(struct rte_soc_device *dev);
+
+static void always_find_dev0_cb(void);
+static int match_dev0_by_name(struct rte_soc_driver *drv,
+ struct rte_soc_device *dev);
+
+static void always_find_dev1_cb(void);
+static int match_dev1_by_name(struct rte_soc_driver *drv,
+ struct rte_soc_device *dev);
+
+/**
+ * Dummy probe handler for PMD driver 'pmd0'.
+ *
+ * @param drv
+ * driver object
+ * @param dev
+ * device object
+ * @return
+ * 0 on success
+ */
+static int
+empty_pmd0_probe(struct rte_soc_driver *drv __rte_unused,
+  struct rte_soc_device *dev __rte_unused)
+{
+   return 0;
+}
+
+/**
+ * Remove handler for PMD driver 'pmd0'.
+ *
+ * @param dev
+ * device to remove
+ * @return
+ * 0 on success
+ */
+static int
+empty_pmd0_remove(struct rte_soc_device *dev)
+{
+   /* Release the memory associated with dev->addr.name */
+   free(dev->addr.name);
+
+   return 0;
+}
+
 struct test_wrapper empty_pmd0 = {
.soc_drv = {
.driver = {
.name = "empty_pmd0"
},
-   },
+   .probe = empty_pmd0_probe,
+   .remove = empty_pmd0_remove,
+   .scan_fn = always_find_dev0_cb,
+   .match_fn = match_dev0_by_name,
+   }
 };

 struct test_wrapper empty_pmd1 = {
@@ -102,9 +153,87 @@ struct test_wrapper empty_pmd1 = {
.driver = {
.name = "empty_pmd1"
},
+   .scan_fn = always_find_dev1_cb,
+   .match_fn = match_dev1_by_name,
},
 };

+/**
+ * Bus scan by PMD 'pmd0' for adding device 'dev0'
+ *
+ * @param void
+ * @return void
+ */
+static void
+always_find_dev0_cb(void)
+{
+   /* SoC's scan would scan devices on its bus and add to
+* soc_device_list
+*/
+   empty_pmd0.soc_dev.addr.name = strdup("empty_pmd0_dev");
+
+   TAILQ_INSERT_TAIL(_device_list, _pmd0.soc_dev, next);
+}
+
+/**
+ * Match device 'dev0' with driver PMD pmd0
+ *
+ * @param drv
+ * Driver with this matching needs to be done; unused here
+ * @param dev
+ * device to be matched against driver
+ * @return
+ * 0 on successful matched
+ * 1 if driver<=>device don't match
+ */
+static int
+match_dev0_by_name(struct rte_soc_driver *drv __rte_unused,
+  struct rte_soc_device *dev)
+{
+   if (!dev->addr.name || strcmp(dev->addr.name, "empty_pmd0_dev"))
+   return 0;
+
+   return 1;
+}
+
+/**
+ * Bus scan by PMD 'pmd0' for adding device 'dev1'
+ *
+ * @param void
+ * @return void
+ */
+static void
+always_find_dev1_cb(void)
+{
+   /* SoC's scan would scan devices on its bus and add to
+* soc_device_list
+*/
+   empty_pmd0.soc_dev.addr.name = strdup("empty_pmd1_dev");
+
+   TAILQ_INSERT_TAIL(_device_list, _pmd1.soc_dev, next);
+}
+
+/**
+ * Match device 'dev1' with driver PMD pmd0
+ *
+ * @param drv
+ * Driver with this matching needs to be done; unused here
+ * @param dev
+ * device to be matched against driver
+ * @return
+ * 0 on successful matched
+ * 1 if driver<=>device don't match
+ */
+static int
+match_dev1_by_name(struct rte_soc_driver *drv __rte_unused,
+  struct rte_soc_device *dev)
+{
+   if (!dev->addr.name || strcmp(dev->addr.name

[dpdk-dev] [PATCH v7 10/21] eal/soc: init SoC infra from EAL

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/bsdapp/eal/Makefile|  1 +
 lib/librte_eal/bsdapp/eal/eal.c   |  4 +++
 lib/librte_eal/bsdapp/eal/eal_soc.c   | 46 
 lib/librte_eal/common/eal_private.h   | 10 +++
 lib/librte_eal/linuxapp/eal/Makefile  |  1 +
 lib/librte_eal/linuxapp/eal/eal.c |  3 ++
 lib/librte_eal/linuxapp/eal/eal_soc.c | 56 +++
 7 files changed, 121 insertions(+)
 create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index a15b762..42b3a2b 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_soc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_timer.c
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 9b93da3..2d62b9d 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -564,6 +565,9 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_pci_init() < 0)
rte_panic("Cannot init PCI\n");

+   if (rte_eal_soc_init() < 0)
+   rte_panic("Cannot init SoC\n");
+
eal_check_mem_on_local_socket();

if (eal_plugins_init() < 0)
diff --git a/lib/librte_eal/bsdapp/eal/eal_soc.c 
b/lib/librte_eal/bsdapp/eal/eal_soc.c
new file mode 100644
index 000..cb297ff
--- /dev/null
+++ b/lib/librte_eal/bsdapp/eal/eal_soc.c
@@ -0,0 +1,46 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Init the SoC EAL subsystem */
+int
+rte_eal_soc_init(void)
+{
+   return 0;
+}
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 0e8d6f7..d810f9f 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -122,6 +122,16 @@ int rte_eal_pci_init(void);
 struct rte_soc_driver;
 struct rte_soc_device;

+/**
+ * Init the SoC infra.
+ *
+ * This function is private to EAL.
+ *
+ * @return
+ *   0 on success, negative on error
+ */
+int rte_eal_soc_init(void);
+
 struct rte_pci_driver;
 struct rte_pci_device;

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index a520477..59e30fa 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_vfio.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += e

[dpdk-dev] [PATCH v7 09/21] eal: introduce command line enable SoC option

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Support --enable-soc. SoC support is disabled by default.

Signed-off-by: Jan Viktorin 
[Shreyansh: Change --no-soc to --enable-soc; disabled by default]
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 doc/guides/testpmd_app_ug/run_app.rst  | 4 
 lib/librte_eal/common/eal_common_options.c | 5 +
 lib/librte_eal/common/eal_internal_cfg.h   | 1 +
 lib/librte_eal/common/eal_options.h| 2 ++
 4 files changed, 12 insertions(+)

diff --git a/doc/guides/testpmd_app_ug/run_app.rst 
b/doc/guides/testpmd_app_ug/run_app.rst
index d7c5120..4dafe5f 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information 
on these options.

 Use malloc instead of hugetlbfs.

+*   ``--enable-soc``
+
+Enable SoC framework support
+

 Testpmd Command-line Options
 
diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 6ca8af1..2156ab3 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -75,6 +75,7 @@ const struct option
 eal_long_options[] = {
{OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM},
{OPT_CREATE_UIO_DEV,0, NULL, OPT_CREATE_UIO_DEV_NUM   },
+   {OPT_ENABLE_SOC,0, NULL, OPT_ENABLE_SOC_NUM   },
{OPT_FILE_PREFIX,   1, NULL, OPT_FILE_PREFIX_NUM  },
{OPT_HELP,  0, NULL, OPT_HELP_NUM },
{OPT_HUGE_DIR,  1, NULL, OPT_HUGE_DIR_NUM },
@@ -843,6 +844,10 @@ eal_parse_common_option(int opt, const char *optarg,
break;

/* long options */
+   case OPT_ENABLE_SOC_NUM:
+   conf->enable_soc = 1;
+   break;
+
case OPT_HUGE_UNLINK_NUM:
conf->hugepage_unlink = 1;
break;
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index 5f1367e..2a6e3ea 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -67,6 +67,7 @@ struct internal_config {
unsigned hugepage_unlink; /**< true to unlink backing files */
volatile unsigned xen_dom0_support; /**< support app running on Xen 
Dom0*/
volatile unsigned no_pci; /**< true to disable PCI */
+   volatile unsigned enable_soc; /**< true to enable SoC */
volatile unsigned no_hpet;/**< true to disable HPET */
volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping

* instead of native TSC */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index a881c62..6e679c3 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -49,6 +49,8 @@ enum {
OPT_BASE_VIRTADDR_NUM,
 #define OPT_CREATE_UIO_DEV"create-uio-dev"
OPT_CREATE_UIO_DEV_NUM,
+#define OPT_ENABLE_SOC"enable-soc"
+   OPT_ENABLE_SOC_NUM,
 #define OPT_FILE_PREFIX   "file-prefix"
OPT_FILE_PREFIX_NUM,
 #define OPT_HUGE_DIR  "huge-dir"
-- 
2.7.4



[dpdk-dev] [PATCH v7 08/21] eal/soc: implement SoC device list and dump

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

SoC devices would be linked in a separate list (from PCI). This is used for
probe function.
A helper for dumping the device list is added.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_soc.c  | 34 +
 lib/librte_eal/common/include/rte_soc.h |  9 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 4 files changed, 47 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index cf6fb8e..86e3cfd 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -171,11 +171,13 @@ DPDK_16.11 {
rte_eal_dev_attach;
rte_eal_dev_detach;
rte_eal_map_resource;
+   rte_eal_soc_dump;
rte_eal_soc_register;
rte_eal_soc_unregister;
rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;
+   soc_device_list;
soc_driver_list;

 } DPDK_16.07;
diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
index 56135ed..5dcddc5 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -31,6 +31,8 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
+#include 
 #include 

 #include 
@@ -40,6 +42,38 @@
 /* Global SoC driver list */
 struct soc_driver_list soc_driver_list =
TAILQ_HEAD_INITIALIZER(soc_driver_list);
+struct soc_device_list soc_device_list =
+   TAILQ_HEAD_INITIALIZER(soc_device_list);
+
+/* dump one device */
+static int
+soc_dump_one_device(FILE *f, struct rte_soc_device *dev)
+{
+   int i;
+
+   fprintf(f, "%s", dev->addr.name);
+   fprintf(f, " - fdt_path: %s\n",
+   dev->addr.fdt_path ? dev->addr.fdt_path : "(none)");
+
+   for (i = 0; dev->id && dev->id[i].compatible; ++i)
+   fprintf(f, "   %s\n", dev->id[i].compatible);
+
+   return 0;
+}
+
+/* dump devices on the bus to an output stream */
+void
+rte_eal_soc_dump(FILE *f)
+{
+   struct rte_soc_device *dev = NULL;
+
+   if (!f)
+   return;
+
+   TAILQ_FOREACH(dev, _device_list, next) {
+   soc_dump_one_device(f, dev);
+   }
+}

 /* register a driver */
 void
diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 23b06a9..347e611 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -56,8 +56,12 @@ extern "C" {

 extern struct soc_driver_list soc_driver_list;
 /**< Global list of SoC Drivers */
+extern struct soc_device_list soc_device_list;
+/**< Global list of SoC Devices */

 TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */
+TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */
+

 struct rte_soc_id {
const char *compatible; /**< OF compatible specification */
@@ -142,6 +146,11 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
 }

 /**
+ * Dump discovered SoC devices.
+ */
+void rte_eal_soc_dump(FILE *f);
+
+/**
  * Register a SoC driver.
  */
 void rte_eal_soc_register(struct rte_soc_driver *driver);
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index ab6b985..0155025 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -175,11 +175,13 @@ DPDK_16.11 {
rte_eal_dev_attach;
rte_eal_dev_detach;
rte_eal_map_resource;
+   rte_eal_soc_dump;
rte_eal_soc_register;
rte_eal_soc_unregister;
rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;
+   soc_device_list;
soc_driver_list;

 } DPDK_16.07;
-- 
2.7.4



[dpdk-dev] [PATCH v7 07/21] eal/soc: add SoC PMD register/unregister logic

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC
(on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the
registered drivers.

Test case has been introduced to verify the registration and
deregistration.

Signed-off-by: Jan Viktorin 
[Shreyansh: update PMD registration method]
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 app/test/test_soc.c | 111 
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   3 +
 lib/librte_eal/common/eal_common_soc.c  |  56 
 lib/librte_eal/common/include/rte_soc.h |  26 ++
 lib/librte_eal/linuxapp/eal/Makefile|   1 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   3 +
 6 files changed, 200 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_soc.c

diff --git a/app/test/test_soc.c b/app/test/test_soc.c
index 916a863..ac03e64 100644
--- a/app/test/test_soc.c
+++ b/app/test/test_soc.c
@@ -75,6 +75,108 @@ static int test_compare_addr(void)
free(a2.name);
free(a1.name);
free(a0.name);
+
+   return 0;
+}
+
+/**
+ * Empty PMD driver based on the SoC infra.
+ *
+ * The rte_soc_device is usually wrapped in some higher-level struct
+ * (eth_driver). We simulate such a wrapper with an anonymous struct here.
+ */
+struct test_wrapper {
+   struct rte_soc_driver soc_drv;
+};
+
+struct test_wrapper empty_pmd0 = {
+   .soc_drv = {
+   .driver = {
+   .name = "empty_pmd0"
+   },
+   },
+};
+
+struct test_wrapper empty_pmd1 = {
+   .soc_drv = {
+   .driver = {
+   .name = "empty_pmd1"
+   },
+   },
+};
+
+static int
+count_registered_socdrvs(void)
+{
+   int i;
+   struct rte_soc_driver *drv;
+
+   i = 0;
+   TAILQ_FOREACH(drv, _driver_list, next)
+   i += 1;
+
+   return i;
+}
+
+static int
+test_register_unregister(void)
+{
+   struct rte_soc_driver *drv;
+   int count;
+
+   rte_eal_soc_register(_pmd0.soc_drv);
+
+   TEST_ASSERT(!TAILQ_EMPTY(_driver_list),
+   "No PMD is present but the empty_pmd0 should be there");
+   drv = TAILQ_FIRST(_driver_list);
+   TEST_ASSERT(!strcmp(drv->driver.name, "empty_pmd0"),
+   "The registered PMD is not empty_pmd0 but '%s'",
+   drv->driver.name);
+
+   rte_eal_soc_register(_pmd1.soc_drv);
+
+   count = count_registered_socdrvs();
+   TEST_ASSERT_EQUAL(count, 2, "Expected 2 PMDs but detected %d", count);
+
+   rte_eal_soc_unregister(_pmd0.soc_drv);
+   count = count_registered_socdrvs();
+   TEST_ASSERT_EQUAL(count, 1, "Expected 1 PMDs but detected %d", count);
+
+   rte_eal_soc_unregister(_pmd1.soc_drv);
+
+   printf("%s has been successful\n", __func__);
+   return 0;
+}
+
+/* save real devices and drivers until the tests finishes */
+struct soc_driver_list real_soc_driver_list =
+   TAILQ_HEAD_INITIALIZER(real_soc_driver_list);
+
+static int test_soc_setup(void)
+{
+   struct rte_soc_driver *drv;
+
+   /* no real drivers for the test */
+   while (!TAILQ_EMPTY(_driver_list)) {
+   drv = TAILQ_FIRST(_driver_list);
+   rte_eal_soc_unregister(drv);
+   TAILQ_INSERT_TAIL(_soc_driver_list, drv, next);
+   }
+
+   return 0;
+}
+
+static int test_soc_cleanup(void)
+{
+   struct rte_soc_driver *drv;
+
+   /* bring back real drivers after the test */
+   while (!TAILQ_EMPTY(_soc_driver_list)) {
+   drv = TAILQ_FIRST(_soc_driver_list);
+   TAILQ_REMOVE(_soc_driver_list, drv, next);
+   rte_eal_soc_register(drv);
+   }
+
return 0;
 }

@@ -84,6 +186,15 @@ test_soc(void)
if (test_compare_addr())
return -1;

+   if (test_soc_setup())
+   return -1;
+
+   if (test_register_unregister())
+   return -1;
+
+   if (test_soc_cleanup())
+   return -1;
+
return 0;
 }

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 11d9f59..cf6fb8e 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -171,8 +171,11 @@ DPDK_16.11 {
rte_eal_dev_attach;
rte_eal_dev_detach;
rte_eal_map_resource;
+   rte_eal_soc_register;
+   rte_eal_soc_unregister;
rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;
+   soc_driver_list;

 } DPDK_16.07;
diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
new file mode 100644
index 000..56135ed
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_soc.

[dpdk-dev] [PATCH v7 06/21] eal/soc: introduce very essential SoC infra definitions

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Define initial structures and functions for the SoC infrastructure.
This patch supports only a very minimal functions for now.
More features will be added in the following commits.

Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 app/test/Makefile   |   1 +
 app/test/test_soc.c |  90 +
 lib/librte_eal/common/Makefile  |   2 +-
 lib/librte_eal/common/eal_private.h |   4 +
 lib/librte_eal/common/include/rte_soc.h | 138 
 5 files changed, 234 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_soc.c
 create mode 100644 lib/librte_eal/common/include/rte_soc.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 5be023a..30295af 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -77,6 +77,7 @@ APP = test
 #
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c
 SRCS-y += test.c
+SRCS-y += test_soc.c
 SRCS-y += resource.c
 SRCS-y += test_resource.c
 test_resource.res: test_resource.c
diff --git a/app/test/test_soc.c b/app/test/test_soc.c
new file mode 100644
index 000..916a863
--- /dev/null
+++ b/app/test/test_soc.c
@@ -0,0 +1,90 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "test.h"
+
+static char *safe_strdup(const char *s)
+{
+   char *c = strdup(s);
+
+   if (c == NULL)
+   rte_panic("failed to strdup '%s'\n", s);
+
+   return c;
+}
+
+static int test_compare_addr(void)
+{
+   struct rte_soc_addr a0;
+   struct rte_soc_addr a1;
+   struct rte_soc_addr a2;
+
+   a0.name = safe_strdup("ethernet0");
+   a0.fdt_path = NULL;
+
+   a1.name = safe_strdup("ethernet0");
+   a1.fdt_path = NULL;
+
+   a2.name = safe_strdup("ethernet1");
+   a2.fdt_path = NULL;
+
+   TEST_ASSERT(!rte_eal_compare_soc_addr(, ),
+   "Failed to compare two soc addresses that equal");
+   TEST_ASSERT(rte_eal_compare_soc_addr(, ),
+   "Failed to compare two soc addresses that differs");
+
+   free(a2.name);
+   free(a1.name);
+   free(a0.name);
+   return 0;
+}
+
+static int
+test_soc(void)
+{
+   if (test_compare_addr())
+   return -1;
+
+   return 0;
+}
+
+REGISTER_TEST_COMMAND(soc_autotest, test_soc);
diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index dfd64aa..b414008 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk

 INC := rte_branch_prediction.h rte_common.h
 INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h
-INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h
+INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h
 INC += rte_per_lcore.h rte_random.h
 INC += rte_tailq.h rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_version.h
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index c8c2131..0e8d6f7 100644
--- a/

[dpdk-dev] [PATCH v7 05/21] eal: define container macro

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/include/rte_common.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index db5ac91..8152bd9 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif

+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *  ...
+ *  struct child c;
+ *  ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#ifndef container_of
+#define container_of(p, type, member) \
+   ((type *) (((char *) (p)) - offsetof(type, member)))
+#endif
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
-- 
2.7.4



[dpdk-dev] [PATCH v7 04/21] eal/linux: generalize PCI kernel driver extraction to EAL

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Generalize the PCI-specific pci_get_kernel_driver_by_path. The function
is general enough, we have just moved it to eal.c, changed the prefix to
rte_eal and provided it privately to other parts of EAL.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/bsdapp/eal/eal.c   |  7 +++
 lib/librte_eal/common/eal_private.h   | 14 ++
 lib/librte_eal/linuxapp/eal/eal.c | 29 +
 lib/librte_eal/linuxapp/eal/eal_pci.c | 31 +--
 4 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 5271fc2..9b93da3 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -640,3 +640,10 @@ rte_eal_unbind_kernel_driver(const char *devpath 
__rte_unused,
 {
return -ENOTSUP;
 }
+
+int
+rte_eal_get_kernel_driver_by_path(const char *filename __rte_unused,
+ char *dri_name __rte_unused)
+{
+   return -ENOTSUP;
+}
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index b0c208a..c8c2131 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -269,6 +269,20 @@ int rte_eal_check_module(const char *module_name);
 int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid);

 /**
+ * Extract the kernel driver name from the absolute path to the driver.
+ *
+ * @param filename  path to the driver ("/driver")
+ * @path  dri_name  target buffer where to place the driver name
+ *  (should be at least PATH_MAX long)
+ *
+ * @return
+ *  -1   on failure
+ *   0   when successful
+ *   1   when there is no such driver
+ */
+int rte_eal_get_kernel_driver_by_path(const char *filename, char *dri_name);
+
+/**
  * Get cpu core_id.
  *
  * This function is private to the EAL.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 5f6676d..00af21c 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -969,3 +969,32 @@ error:
fclose(f);
return -1;
 }
+
+int
+rte_eal_get_kernel_driver_by_path(const char *filename, char *dri_name)
+{
+   int count;
+   char path[PATH_MAX];
+   char *name;
+
+   if (!filename || !dri_name)
+   return -1;
+
+   count = readlink(filename, path, PATH_MAX);
+   if (count >= PATH_MAX)
+   return -1;
+
+   /* For device does not have a driver */
+   if (count < 0)
+   return 1;
+
+   path[count] = '\0';
+
+   name = strrchr(path, '/');
+   if (name) {
+   strncpy(dri_name, name + 1, strlen(name + 1) + 1);
+   return 0;
+   }
+
+   return -1;
+}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index a03553f..e1cf9e8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -78,35 +78,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev)
return rte_eal_unbind_kernel_driver(devpath, devid);
 }

-static int
-pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
-{
-   int count;
-   char path[PATH_MAX];
-   char *name;
-
-   if (!filename || !dri_name)
-   return -1;
-
-   count = readlink(filename, path, PATH_MAX);
-   if (count >= PATH_MAX)
-   return -1;
-
-   /* For device does not have a driver */
-   if (count < 0)
-   return 1;
-
-   path[count] = '\0';
-
-   name = strrchr(path, '/');
-   if (name) {
-   strncpy(dri_name, name + 1, strlen(name + 1) + 1);
-   return 0;
-   }
-
-   return -1;
-}
-
 /* Map pci device */
 int
 rte_eal_pci_map_device(struct rte_pci_device *dev)
@@ -354,7 +325,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,

/* parse driver */
snprintf(filename, sizeof(filename), "%s/driver", dirname);
-   ret = pci_get_kernel_driver_by_path(filename, driver);
+   ret = rte_eal_get_kernel_driver_by_path(filename, driver);
if (ret < 0) {
RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
free(dev);
-- 
2.7.4



[dpdk-dev] [PATCH v7 03/21] eal/linux: generalize PCI kernel unbinding driver to EAL

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided
into two parts. First, determination of the path and string identification
of the device to be unbound. Second, the actual unbind operation which is
generic.

BSD implementation updated as ENOTSUP

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
--
Changes since v2:
 - update BSD support for unbind kernel driver
---
 lib/librte_eal/bsdapp/eal/eal.c   |  7 +++
 lib/librte_eal/bsdapp/eal/eal_pci.c   |  4 ++--
 lib/librte_eal/common/eal_private.h   | 13 +
 lib/librte_eal/linuxapp/eal/eal.c | 26 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +
 5 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 35e3117..5271fc2 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -633,3 +633,10 @@ rte_eal_process_type(void)
 {
return rte_config.process_type;
 }
+
+int
+rte_eal_unbind_kernel_driver(const char *devpath __rte_unused,
+const char *devid __rte_unused)
+{
+   return -ENOTSUP;
+}
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 7ed0115..703f034 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -89,11 +89,11 @@

 /* unbind kernel driver for this device */
 int
-pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
+pci_unbind_kernel_driver(struct rte_pci_device *dev)
 {
RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented "
"for BSD\n");
-   return -ENOTSUP;
+   return rte_eal_unbind_kernel_driver(dev);
 }

 /* Map pci device */
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 9e7d8f6..b0c208a 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -256,6 +256,19 @@ int rte_eal_alarm_init(void);
 int rte_eal_check_module(const char *module_name);

 /**
+ * Unbind kernel driver bound to the device specified by the given devpath,
+ * and its string identification.
+ *
+ * @param devpath  path to the device directory ("/sys/.../devices/")
+ * @param devididentification of the device ()
+ *
+ * @return
+ *  -1  unbind has failed
+ *   0  module has been unbound
+ */
+int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid);
+
+/**
  * Get cpu core_id.
  *
  * This function is private to the EAL.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 2075282..5f6676d 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name)
/* Module has been found */
return 1;
 }
+
+int
+rte_eal_unbind_kernel_driver(const char *devpath, const char *devid)
+{
+   char filename[PATH_MAX];
+   FILE *f;
+
+   snprintf(filename, sizeof(filename),
+"%s/driver/unbind", devpath);
+
+   f = fopen(filename, "w");
+   if (f == NULL) /* device was not bound */
+   return 0;
+
+   if (fwrite(devid, strlen(devid), 1, f) == 0) {
+   RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
+   filename);
+   goto error;
+   }
+
+   fclose(f);
+   return 0;
+error:
+   fclose(f);
+   return -1;
+}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 876ba38..a03553f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -59,38 +59,23 @@ int
 pci_unbind_kernel_driver(struct rte_pci_device *dev)
 {
int n;
-   FILE *f;
-   char filename[PATH_MAX];
-   char buf[BUFSIZ];
+   char devpath[PATH_MAX];
+   char devid[BUFSIZ];
struct rte_pci_addr *loc = >addr;

-   /* open /sys/bus/pci/devices/:BB:CC.D/driver */
-   snprintf(filename, sizeof(filename),
-   "%s/" PCI_PRI_FMT "/driver/unbind", pci_get_sysfs_path(),
+   /* devpath /sys/bus/pci/devices/:BB:CC.D */
+   snprintf(devpath, sizeof(devpath),
+   "%s/" PCI_PRI_FMT, pci_get_sysfs_path(),
loc->domain, loc->bus, loc->devid, loc->function);

-   f = fopen(filename, "w");
-   if (f == NULL) /* device was not bound */
-   return 0;
-
-   n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
+   n = snprintf(devid, sizeof(devid), PCI_PRI_FMT "\n",
 loc->domain, loc->bus, loc->devid, loc->function);
-   if ((n < 0) || (n >= (int)sizeof(

[dpdk-dev] [PATCH v7 02/21] eal: generalize PCI map/unmap resource to EAL

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

The functions pci_map_resource, pci_unmap_resource are generic so the
pci_* prefix can be omitted. The functions are moved to the
eal_common_dev.c so they can be reused by other infrastructure.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_dev.c  | 39 +
 lib/librte_eal/common/eal_common_pci.c  | 39 -
 lib/librte_eal/common/eal_common_pci_uio.c  | 16 +-
 lib/librte_eal/common/include/rte_dev.h | 32 
 lib/librte_eal/common/include/rte_pci.h | 32 
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c   |  2 +-
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c  |  5 ++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 10 files changed, 89 insertions(+), 82 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 8b3ed88..7ed0115 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -228,7 +228,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, 
int res_idx,

/* if matching map is found, then use it */
offset = res_idx * pagesz;
-   mapaddr = pci_map_resource(NULL, fd, (off_t)offset,
+   mapaddr = rte_eal_map_resource(NULL, fd, (off_t)offset,
(size_t)dev->mem_resource[res_idx].len, 0);
close(fd);
if (mapaddr == MAP_FAILED)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 2f81f7c..11d9f59 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -170,6 +170,8 @@ DPDK_16.11 {
rte_delay_us_callback_register;
rte_eal_dev_attach;
rte_eal_dev_detach;
+   rte_eal_map_resource;
+   rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 4f3b493..457d227 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -151,3 +152,41 @@ err:
RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", name);
return -EINVAL;
 }
+
+/* map a particular resource from a file */
+void *
+rte_eal_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
+int additional_flags)
+{
+   void *mapaddr;
+
+   /* Map the Memory resource of device */
+   mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
+   MAP_SHARED | additional_flags, fd, offset);
+   if (mapaddr == MAP_FAILED) {
+   RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s"
+   " (%p)\n", __func__, fd, requested_addr,
+   (unsigned long)size, (unsigned long)offset,
+   strerror(errno), mapaddr);
+   } else
+   RTE_LOG(DEBUG, EAL, "  Device memory mapped at %p\n", mapaddr);
+
+   return mapaddr;
+}
+
+/* unmap a particular resource */
+void
+rte_eal_unmap_resource(void *requested_addr, size_t size)
+{
+   if (requested_addr == NULL)
+   return;
+
+   /* Unmap the Memory resource of device */
+   if (munmap(requested_addr, size)) {
+   RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n",
+   __func__, requested_addr, (unsigned long)size,
+   strerror(errno));
+   } else
+   RTE_LOG(DEBUG, EAL, "  Device memory unmapped at %p\n",
+   requested_addr);
+}
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 638cd86..464acc1 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -67,7 +67,6 @@
 #include 
 #include 
 #include 
-#include 

 #include 
 #include 
@@ -114,44 +113,6 @@ static struct rte_devargs *pci_devargs_lookup(struct 
rte_pci_device *dev)
return NULL;
 }

-/* map a particular resource from a file */
-void *
-pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
-int additional_flags)
-{
-   void *mapaddr;
-
-   /* Map the PCI memory resource of device */
-   mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
-   MAP_SHARED | additional_flags, fd, offset);
-   if (mapaddr == MAP_FAILED) {
-   RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s 
(%p)\n",
-

[dpdk-dev] [PATCH v7 01/21] eal: generalize PCI kernel driver enum to EAL

2016-10-28 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 

--
Changes since v0:
 - fix compilation error due to missing include
---
 lib/librte_eal/common/include/rte_dev.h | 12 
 lib/librte_eal/common/include/rte_pci.h |  9 -
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 8840380..6975b9f 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -109,6 +109,18 @@ struct rte_mem_resource {
void *addr; /**< Virtual address, NULL when not mapped. */
 };

+/**
+ * Kernel driver passthrough type
+ */
+enum rte_kernel_driver {
+   RTE_KDRV_UNKNOWN = 0,
+   RTE_KDRV_IGB_UIO,
+   RTE_KDRV_VFIO,
+   RTE_KDRV_UIO_GENERIC,
+   RTE_KDRV_NIC_UIO,
+   RTE_KDRV_NONE,
+};
+
 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
 /** Double linked list of devices. */
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 9ce8847..2c7046f 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -135,15 +135,6 @@ struct rte_pci_addr {

 struct rte_devargs;

-enum rte_kernel_driver {
-   RTE_KDRV_UNKNOWN = 0,
-   RTE_KDRV_IGB_UIO,
-   RTE_KDRV_VFIO,
-   RTE_KDRV_UIO_GENERIC,
-   RTE_KDRV_NIC_UIO,
-   RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
-- 
2.7.4



[dpdk-dev] [PATCH v7 00/21] Introduce SoC device/driver framework for EAL

2016-10-28 Thread Shreyansh Jain
n
   them.
 - Patch 0015~0016 add support for default function which PMDs can use for
   scanning platform bus. These functions are optional and need to be hooked
   to by PMDs.
 - Patch 0017~0019 makes changes to PCI as well as ethdev code to remove
   assumption that eth_driver is a PCI driver.
 - Patch 0020 adds necessary ethdev probe/remove functions for PMDs to use
 - Patch 0021 adds support for SoC driver/devices, along with probe/remove
   functions for Cryptodev devices.

Future/Pending Changes:
===
- Device whitelisting/blacklist still relies on command line '-b' and '-c'
  which are internally implemented using OPT_PCI_BLACKLIST/OPT_PCI_WHITELIST.
  This needs to be changed to a generic form - OPT_DEV_*LIST - probably.
- No cryptodriver currently uses SoC framework - probably a example driver
  can be created to demonstrate usage.
- test case for enable-soc command line parameter
- This patch impacts a couple of ABIs (rte_device/driver) and thus require
  a patch for bump of libraries (if need be) and documentation.

 [1] http://dpdk.org/ml/archives/dev/2016-January/030915.html
 [2] http://www.dpdk.org/ml/archives/dev/2016-May/038486.html
 [3] http://dpdk.org/ml/archives/dev/2016-August/045707.html
 [4] http://dpdk.org/ml/archives/dev/2016-May/038948.html
 [5] http://dpdk.org/ml/archives/dev/2016-May/038953.html
 [6] http://dpdk.org/ml/archives/dev/2016-May/038487.html
 [7] http://dpdk.org/ml/archives/dev/2016-May/038488.html
 [8] http://dpdk.org/ml/archives/dev/2016-May/038489.html
 [9] http://dpdk.org/ml/archives/dev/2016-May/038491.html
[10] http://dpdk.org/ml/archives/dev/2016-September/046256.html
[11] http://dpdk.org/ml/archives/dev/2016-October/048915.html

Changes since v6;
 - Fix patch rebase over HEAD (ca41215)

Changes since v5:
 - fix devinit/devuninit name change; it was in wrong patch
 - rebased over HEAD (ca41215)
 - Update to pending section of coverletter

Changes since v4:
 - change name of rte_eal_soc_scan function name to
   rte_eal_soc_scan_platform_bus. This still remains a helper function.
 - Fix comments over scan and match functions

Changes since v3:
 - rebasing over HEAD (fed622df tag: v16.11-rc1)
 - Add support for default scan function; PMD can use this for
   scanning on platform bus.
 - Support for kernel driver bind/unbind, numa and DMA from
   Jan's original patches.
 - SoC is disabled by default. '--enable-soc' command line parameter
   enables it. doc updated.
 - Updated testcase function names and comments
 - Map file addition alphabetically ordered
 - Patch author corrected

Changes since v2:
 - Rebasing over rte_driver/device patchset v9 [10]
 - Added cryptodev support for SoC
 - Default match function for SoC device<=>Driver
 - Some variables renamed to reflect 'drv' rather than 'dr'

Change since v1 [2]:
 - Removed patch 1-5 which were for generalizing some PCI specific routines
   into EAL. These patches are good-to-have but not directly linked to SoC
   and hence would be proposed separately.
 - Removed support for sysfs parsing (patches 6~9)
 - Rebasing over the recent (v8) version of rte_driver/device patchset
 - Rebasing over master (16.07)
 - Changes to various map file to change API intro to 16.11 from 16.07

Jan Viktorin (19):
  eal: generalize PCI kernel driver enum to EAL
  eal: generalize PCI map/unmap resource to EAL
  eal/linux: generalize PCI kernel unbinding driver to EAL
  eal/linux: generalize PCI kernel driver extraction to EAL
  eal: define container macro
  eal/soc: introduce very essential SoC infra definitions
  eal/soc: add SoC PMD register/unregister logic
  eal/soc: implement SoC device list and dump
  eal: introduce command line enable SoC option
  eal/soc: init SoC infra from EAL
  eal/soc: extend and utilize devargs
  eal/soc: add drv_flags
  eal/soc: add intr_handle
  eal/soc: add default scan for Soc devices
  eal/soc: additional features for SoC
  ether: utilize container_of for pci_drv
  ether: verify we copy info from a PCI device
  ether: extract function eth_dev_get_intr_handle
  ether: introduce ethernet dev probe remove

Shreyansh Jain (2):
  eal/soc: implement probing of drivers
  eal/crypto: Support rte_soc_driver/device for cryptodev

 app/test/Makefile   |   1 +
 app/test/test_soc.c | 404 +++
 doc/guides/testpmd_app_ug/run_app.rst   |   4 +
 lib/librte_cryptodev/rte_cryptodev.c| 122 +-
 lib/librte_cryptodev/rte_cryptodev.h|   3 +
 lib/librte_cryptodev/rte_cryptodev_pmd.h|  18 +-
 lib/librte_cryptodev/rte_cryptodev_version.map  |   2 +
 lib/librte_eal/bsdapp/eal/Makefile  |   1 +
 lib/librte_eal/bsdapp/eal/eal.c |  18 +
 lib/librte_eal/bsdapp/eal/eal_pci.c |   6 +-
 lib/librte_eal/bsdapp/eal/eal_soc.c |  46 +++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  11 +
 lib/librte_eal/common/Makefile  |   2 +-

[dpdk-dev] [PATCH v6 21/21] eal/crypto: Support rte_soc_driver/device for cryptodev

2016-10-27 Thread Shreyansh Jain
- rte_cryptodev_driver/rte_cryptodev_dev embeds rte_soc_driver/device for
  linking SoC PMDs to crypto devices.
- Add probe and remove functions linked

Signed-off-by: Hemant Agrawal 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_cryptodev/rte_cryptodev.c   | 122 -
 lib/librte_cryptodev/rte_cryptodev.h   |   3 +
 lib/librte_cryptodev/rte_cryptodev_pmd.h   |  18 +++-
 lib/librte_cryptodev/rte_cryptodev_version.map |   2 +
 4 files changed, 140 insertions(+), 5 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index 127e8d0..77ec9fe 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -422,7 +422,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,

int retval;

-   cryptodrv = (struct rte_cryptodev_driver *)pci_drv;
+   cryptodrv = container_of(pci_drv, struct rte_cryptodev_driver,
+pci_drv);
if (cryptodrv == NULL)
return -ENODEV;

@@ -489,7 +490,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
if (cryptodev == NULL)
return -ENODEV;

-   cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver;
+   cryptodrv = container_of(pci_dev->driver, struct rte_cryptodev_driver,
+pci_drv);
if (cryptodrv == NULL)
return -ENODEV;

@@ -513,6 +515,111 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
return 0;
 }

+
+int
+rte_cryptodev_soc_probe(struct rte_soc_driver *soc_drv,
+ struct rte_soc_device *soc_dev)
+{
+   struct rte_cryptodev_driver *cryptodrv;
+   struct rte_cryptodev *cryptodev;
+
+   char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
+
+   int retval;
+
+   cryptodrv = container_of(soc_drv, struct rte_cryptodev_driver,
+soc_drv);
+
+   rte_eal_soc_device_name(_dev->addr, cryptodev_name,
+   sizeof(cryptodev_name));
+
+   cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name,
+  rte_socket_id());
+   if (cryptodev == NULL)
+   return -ENOMEM;
+
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   cryptodev->data->dev_private =
+   rte_zmalloc_socket(
+   "cryptodev private structure",
+   cryptodrv->dev_private_size,
+   RTE_CACHE_LINE_SIZE,
+   rte_socket_id());
+
+   if (cryptodev->data->dev_private == NULL)
+   rte_panic("Cannot allocate memzone for private "
+   "device data");
+   }
+
+   cryptodev->soc_dev = soc_dev;
+   cryptodev->driver = cryptodrv;
+
+   /* init user callbacks */
+   TAILQ_INIT(&(cryptodev->link_intr_cbs));
+
+   /* Invoke PMD device initialization function */
+   retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev);
+   if (retval == 0)
+   return 0;
+
+   CDEV_LOG_ERR("driver %s: cryptodev_init(%s) failed\n",
+   soc_drv->driver.name,
+   soc_dev->addr.name);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(cryptodev->data->dev_private);
+
+   cryptodev->attached = RTE_CRYPTODEV_DETACHED;
+   cryptodev_globals.nb_devs--;
+
+   return -ENXIO;
+}
+
+int
+rte_cryptodev_soc_remove(struct rte_soc_device *soc_dev)
+{
+   const struct rte_cryptodev_driver *cryptodrv;
+   struct rte_cryptodev *cryptodev;
+   char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
+   int ret;
+
+   if (soc_dev == NULL)
+   return -EINVAL;
+
+   rte_eal_soc_device_name(_dev->addr, cryptodev_name,
+   sizeof(cryptodev_name));
+
+   cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
+   if (cryptodev == NULL)
+   return -ENODEV;
+
+   cryptodrv = container_of(soc_dev->driver,
+   struct rte_cryptodev_driver, soc_drv);
+   if (cryptodrv == NULL)
+   return -ENODEV;
+
+   /* Invoke PMD device uninit function */
+   if (*cryptodrv->cryptodev_uninit) {
+   ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev);
+   if (ret)
+   return ret;
+   }
+
+   /* free crypto device */
+   rte_cryptodev_pmd_release_device(cryptodev);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(cryptodev->data->dev_private);
+
+   cryptodev->pci_dev = NULL;
+   cryptodev-&

[dpdk-dev] [PATCH v6 20/21] ether: introduce ethernet dev probe remove

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 148 +-
 lib/librte_ether/rte_ethdev.h |  31 +
 2 files changed, 177 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 4c61246..972e916 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -325,6 +325,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 }

 int
+rte_eth_dev_soc_probe(struct rte_soc_driver *soc_drv,
+ struct rte_soc_device *soc_dev)
+{
+   struct eth_driver*eth_drv;
+   struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+
+   int diag;
+
+   eth_drv = container_of(soc_drv, struct eth_driver, soc_drv);
+
+   rte_eal_soc_device_name(_dev->addr, ethdev_name,
+   sizeof(ethdev_name));
+
+   eth_dev = rte_eth_dev_allocate(ethdev_name);
+   if (eth_dev == NULL)
+   return -ENOMEM;
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   eth_dev->data->dev_private = rte_zmalloc(
+ "ethdev private structure",
+ eth_drv->dev_private_size,
+ RTE_CACHE_LINE_SIZE);
+   if (eth_dev->data->dev_private == NULL)
+   rte_panic("Cannot allocate memzone for private port "
+ "data\n");
+   }
+   eth_dev->soc_dev = soc_dev;
+   eth_dev->driver = eth_drv;
+   eth_dev->data->rx_mbuf_alloc_failed = 0;
+
+   /* init user callbacks */
+   TAILQ_INIT(&(eth_dev->link_intr_cbs));
+
+   /*
+* Set the default MTU.
+*/
+   eth_dev->data->mtu = ETHER_MTU;
+
+   /* Invoke PMD device initialization function */
+   diag = (*eth_drv->eth_dev_init)(eth_dev);
+   if (diag == 0)
+   return 0;
+
+   RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(%s) failed\n",
+   soc_drv->driver.name,
+   soc_dev->addr.name);
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(eth_dev->data->dev_private);
+   rte_eth_dev_release_port(eth_dev);
+   return diag;
+}
+
+int
+rte_eth_dev_soc_remove(struct rte_soc_device *soc_dev)
+{
+   const struct eth_driver *eth_drv;
+   struct rte_eth_dev *eth_dev;
+   char ethdev_name[RTE_ETH_NAME_MAX_LEN];
+   int ret;
+
+   if (soc_dev == NULL)
+   return -EINVAL;
+
+   rte_eal_soc_device_name(_dev->addr, ethdev_name,
+   sizeof(ethdev_name));
+
+   eth_dev = rte_eth_dev_allocated(ethdev_name);
+   if (eth_dev == NULL)
+   return -ENODEV;
+
+   eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv);
+
+   /* Invoke PMD device uninit function */
+   if (*eth_drv->eth_dev_uninit) {
+   ret = (*eth_drv->eth_dev_uninit)(eth_dev);
+   if (ret)
+   return ret;
+   }
+
+   /* free ether device */
+   rte_eth_dev_release_port(eth_dev);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(eth_dev->data->dev_private);
+
+   eth_dev->soc_dev = NULL;
+   eth_dev->driver = NULL;
+   eth_dev->data = NULL;
+
+   return 0;
+}
+
+
+int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1557,6 +1652,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct 
rte_eth_dev_info *dev_info)
RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
(*dev->dev_ops->dev_infos_get)(dev, dev_info);
dev_info->pci_dev = dev->pci_dev;
+   dev_info->soc_dev = dev->soc_dev;
dev_info->driver_name = dev->data->drv_name;
dev_info->nb_rx_queues = dev->data->nb_rx_queues;
dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2535,8 +2631,15 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 static inline
 struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev)
 {
-   if (dev->pci_dev)
+   if (dev->pci_dev) {
+   RTE_ASSERT(dev->soc_dev == NULL);
return >pci_dev->intr_handle;
+   }
+
+   if (dev->soc_dev) {
+   RTE_ASSERT(dev->pci_dev == NULL);
+   return >soc_dev->intr_handle;
+   }

RTE_ASSERT(0);
return NULL;
@@ -2573,6 +2676,23 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int 
op, void *data)
return 0;
 }

+static inline
+const char *eth_dev_get_driver_name(const struct rte_eth_dev *d

[dpdk-dev] [PATCH v6 19/21] ether: extract function eth_dev_get_intr_handle

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

We abstract access to the intr_handle here as we want to get
it either from the pci_dev or soc_dev.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a1e3aaf..4c61246 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2532,6 +2532,16 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
rte_spinlock_unlock(_eth_dev_cb_lock);
 }

+static inline
+struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev)
+{
+   if (dev->pci_dev)
+   return >pci_dev->intr_handle;
+
+   RTE_ASSERT(0);
+   return NULL;
+}
+
 int
 rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 {
@@ -2544,7 +2554,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int 
op, void *data)
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

dev = _eth_devices[port_id];
-   intr_handle = >pci_dev->intr_handle;
+   intr_handle = eth_dev_get_intr_handle(dev);
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
@@ -2604,7 +2614,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t 
queue_id,
return -EINVAL;
}

-   intr_handle = >pci_dev->intr_handle;
+   intr_handle = eth_dev_get_intr_handle(dev);
if (!intr_handle->intr_vec) {
RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
return -EPERM;
-- 
2.7.4



[dpdk-dev] [PATCH v6 18/21] ether: verify we copy info from a PCI device

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Now that different types of ethdev exist, check for presence of PCI dev
while copying out the info.
Similar would be done for SoC.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 347c230..a1e3aaf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3206,6 +3206,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct 
rte_pci_device *pci_de
return;
}

+   RTE_VERIFY(eth_dev->pci_dev != NULL);
+
eth_dev->data->dev_flags = 0;
if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-- 
2.7.4



[dpdk-dev] [PATCH v6 17/21] ether: utilize container_of for pci_drv

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

It is not necessary to place the rte_pci_driver at the beginning
of the rte_eth_dev struct anymore as we use the container_of macro
to get the parent pointer.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_ether/rte_ethdev.c | 4 ++--
 lib/librte_ether/rte_ethdev.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fde8112..347c230 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -241,7 +241,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,

int diag;

-   eth_drv = (struct eth_driver *)pci_drv;
+   eth_drv = container_of(pci_drv, struct eth_driver, pci_drv);

rte_eal_pci_device_name(_dev->addr, ethdev_name,
sizeof(ethdev_name));
@@ -302,7 +302,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
if (eth_dev == NULL)
return -ENODEV;

-   eth_drv = (const struct eth_driver *)pci_dev->driver;
+   eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv);

/* Invoke PMD device uninit function */
if (*eth_drv->eth_dev_uninit) {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 38641e8..f893fe0 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1850,7 +1850,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev 
*eth_dev);
  * Each Ethernet driver acts as a PCI driver and is represented by a generic
  * *eth_driver* structure that holds:
  *
- * - An *rte_pci_driver* structure (which must be the first field).
+ * - An *rte_pci_driver* structure.
  *
  * - The *eth_dev_init* function invoked for each matching PCI device.
  *
-- 
2.7.4



[dpdk-dev] [PATCH v6 16/21] eal/soc: additional features for SoC

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Additional features introduced:
 - Find kernel driver through sysfs bindings
 - Dummy implementation for mapping to kernel driver
 - DMA coherency value from sysfs
 - Numa node number from sysfs
 - Support for updating device during probe if already registered

Signed-off-by: Jan Viktorin 
[Shreyansh: merge multiple patches into single set]
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_soc.c  |  30 
 lib/librte_eal/common/eal_private.h |  23 ++
 lib/librte_eal/common/include/rte_soc.h |  28 +++
 lib/librte_eal/linuxapp/eal/eal_soc.c   | 129 
 4 files changed, 210 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
index 44f5559..29c38e0 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -114,6 +114,26 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *drv,
return ret;
}

+   if (!dev->is_dma_coherent) {
+   if (!(drv->drv_flags & RTE_SOC_DRV_ACCEPT_NONCC)) {
+   RTE_LOG(DEBUG, EAL,
+   "  device is not DMA coherent, skipping\n");
+   return 1;
+   }
+   }
+
+   if (drv->drv_flags & RTE_SOC_DRV_NEED_MAPPING) {
+   /* map resources */
+   ret = rte_eal_soc_map_device(dev);
+   if (ret)
+   return ret;
+   } else if (drv->drv_flags & RTE_SOC_DRV_FORCE_UNBIND
+   && rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   /* unbind */
+   if (soc_unbind_kernel_driver(dev) < 0)
+   return -1;
+   }
+
dev->driver = drv;
RTE_VERIFY(drv->probe != NULL);
return drv->probe(drv, dev);
@@ -166,6 +186,10 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *drv,
if (drv->remove && (drv->remove(dev) < 0))
return -1;  /* negative value is an error */

+   if (drv->drv_flags & RTE_SOC_DRV_NEED_MAPPING)
+   /* unmap resources for devices */
+   rte_eal_soc_unmap_device(dev);
+
/* clear driver structure */
dev->driver = NULL;

@@ -241,6 +265,12 @@ rte_eal_soc_probe_one(const struct rte_soc_addr *addr)
if (addr == NULL)
return -1;

+   /* update current SoC device in global list, kernel bindings might have
+* changed since last time we looked at it.
+*/
+   if (soc_update_device(addr) < 0)
+   goto err_return;
+
TAILQ_FOREACH(dev, _device_list, next) {
if (rte_eal_compare_soc_addr(>addr, addr))
continue;
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index d810f9f..30c648d 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -159,6 +159,29 @@ int pci_update_device(const struct rte_pci_addr *addr);
 int pci_unbind_kernel_driver(struct rte_pci_device *dev);

 /**
+ * Update a soc device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *  The SoC address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int soc_update_device(const struct rte_soc_addr *addr);
+
+/**
+ * Unbind kernel driver for this device
+ *
+ * This function is private to EAL.
+ *
+ * @return
+ *   0 on success, negative on error
+ */
+int soc_unbind_kernel_driver(struct rte_soc_device *dev);
+
+/**
  * Map the PCI resource of a PCI device in virtual memory
  *
  * This function is private to EAL.
diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 8be3db7..d7f7ec8 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -46,9 +46,11 @@ extern "C" {

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -63,6 +65,14 @@ extern struct soc_device_list soc_device_list;
 TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */
 TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */

+#define SOC_MAX_RESOURCE 6
+
+struct rte_soc_resource {
+   uint64_t phys_addr;
+   uint64_t len;
+   void *addr;
+};
+
 struct rte_soc_id {
union {
const char *compatible; /**< OF compatible specification */
@@ -84,8 +94,12 @@ struct rte_soc_device {
struct rte_device device;   /**< Inherit code device */
struct rte_soc_addr addr;   /**< SoC device Location */
struct rte_soc_id *id;  /**< SoC device ID list */
+   struct rte_soc_res

[dpdk-dev] [PATCH v6 15/21] eal/soc: add default scan for Soc devices

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@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 
[Shreyansh: restructure commit to be an optional implementation]
Signed-off-by: Shreyansh Jain 

--
 v5:
 - Update rte_eal_soc_scan to rte_eal_soc_scan_platform_bus
 - Fix comments over scan and match functions
---
 lib/librte_eal/common/include/rte_soc.h |  16 +-
 lib/librte_eal/linuxapp/eal/eal_soc.c   | 315 
 2 files changed, 329 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 38f897d..8be3db7 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -64,7 +64,10 @@ TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC 
drivers in D-linked Q. */
 TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */

 struct rte_soc_id {
-   const char *compatible; /**< OF compatible specification */
+   union {
+   const char *compatible; /**< OF compatible specification */
+   char *_compatible;
+   };
uint64_t priv_data; /**< SoC Driver specific data */
 };

@@ -200,7 +203,16 @@ rte_eal_parse_soc_spec(const char *spec, struct 
rte_soc_addr *addr)
 }

 /**
- * Default function for matching the Soc driver with device. Each driver can
+ * Helper function for scanning for new SoC devices on platform bus.
+ *
+ * @return
+ * 0 on success
+ * !0 on failure to scan
+ */
+int rte_eal_soc_scan_platform_bus(void);
+
+/**
+ * Helper function for matching the Soc driver with device. Each driver can
  * either use this function or define their own soc matching function.
  * This function relies on the compatible string extracted from sysfs. But,
  * a SoC might have different way of identifying its devices. Such SoC can
diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c 
b/lib/librte_eal/linuxapp/eal/eal_soc.c
index 3929a76..d8dfe97 100644
--- a/lib/librte_eal/linuxapp/eal/eal_soc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_soc.c
@@ -48,6 +48,321 @@
 #include 
 #include 

+/** Pathname of SoC devices directory. */
+#define SYSFS_SOC_DEVICES "/sys/bus/platform/devices"
+
+static const char *
+soc_get_sysfs_path(void)
+{
+   const char *path = NULL;
+
+   path = getenv("SYSFS_SOC_DEVICES");
+   if (path == NULL)
+   return SYSFS_SOC_DEVICES;
+
+   return path;
+}
+
+static char *
+dev_read_uevent(const char *dirname)
+{
+   char filename[PATH_MAX];
+   struct stat st;
+   char *buf;
+   ssize_t total = 0;
+   int fd;
+
+   snprintf(filename, sizeof(filename), "%s/uevent", dirname);
+   fd = open(filename, O_RDONLY);
+   if (fd < 0) {
+   RTE_LOG(WARNING, EAL, "Failed to open file %s\n", filename);
+   return strdup("");
+   }
+
+   if (fstat(fd, ) < 0) {
+   RTE_LOG(ERR, EAL, "Failed to stat file %s\n", filename);
+   close(fd);
+   return NULL;
+   }
+
+   if (st.st_size == 0) {
+   close(fd);
+   return strdup("");
+   }
+
+   buf = malloc(st.st_size + 1);
+   if (buf == NULL) {
+   RTE_LOG(ERR, EAL, "Failed to alloc memory to read %s\n",
+   filename);
+   close(fd);
+   return NULL;
+   }
+
+   while (total < st.st_size) {
+   ssize_t rlen = read(fd, buf + total, st.st_size - total);
+   if (rlen < 0) {
+   if (errno == EINTR)
+   continue;
+
+   RTE_LOG(ERR, EAL, "Failed to read file %s\n", filename);
+
+   free(buf);
+   close(fd);
+   return NULL;
+   }
+   if (rlen == 0) /* EOF */
+   break;
+
+   total += rlen;
+   }
+
+   buf[total] = '\0';
+   close(fd);
+
+   return buf;
+}
+
+static const char *
+dev_uevent_find(const char *uevent, const char *key)
+{
+   const size_t keylen = strlen(key);
+   const size_t total = strlen(uevent);
+   const char *p = uevent;
+
+   /* check whether it is the first key */
+   if (!strncmp(uevent, key, keylen))
+   return uevent + keylen;
+
+   /* check 2nd key or further... */
+   do {
+   p = strstr(p, key);
+   if (p == NULL)
+   break;
+
+   if (p[-1] == '\n') /* check we are at a new line */
+   return p + keylen;
+
+   p += keylen; /* skip this

[dpdk-dev] [PATCH v6 14/21] eal/soc: add intr_handle

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/common/include/rte_soc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 40490b9..38f897d 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -53,6 +53,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 

 extern struct soc_driver_list soc_driver_list;
 /**< Global list of SoC Drivers */
@@ -80,6 +81,7 @@ struct rte_soc_device {
struct rte_device device;   /**< Inherit code device */
struct rte_soc_addr addr;   /**< SoC device Location */
struct rte_soc_id *id;  /**< SoC device ID list */
+   struct rte_intr_handle intr_handle; /**< Interrupt handle */
struct rte_soc_driver *driver;  /**< Associated driver */
 };

-- 
2.7.4



[dpdk-dev] [PATCH v6 13/21] eal/soc: add drv_flags

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

The flags are copied from the PCI ones. They should be refactorized into a
general set of flags in the future.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/common/include/rte_soc.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index fb5ea7b..40490b9 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -123,8 +123,18 @@ struct rte_soc_driver {
soc_scan_t *scan_fn;   /**< Callback for scanning SoC bus*/
soc_match_t *match_fn; /**< Callback to match dev<->drv */
const struct rte_soc_id *id_table; /**< ID table, NULL terminated */
+   uint32_t drv_flags;/**< Control handling of device */
 };

+/** Device needs to map its resources by EAL */
+#define RTE_SOC_DRV_NEED_MAPPING 0x0001
+/** Device needs to be unbound even if no module is provieded */
+#define RTE_SOC_DRV_FORCE_UNBIND 0x0004
+/** Device driver supports link state interrupt */
+#define RTE_SOC_DRV_INTR_LSC0x0008
+/** Device driver supports detaching capability */
+#define RTE_SOC_DRV_DETACHABLE  0x0010
+
 /**
  * Utility function to write a SoC device name, this device name can later be
  * used to retrieve the corresponding rte_soc_addr using above functions.
-- 
2.7.4



[dpdk-dev] [PATCH v6 12/21] eal/soc: extend and utilize devargs

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

It is assumed that SoC Devices provided on command line are prefixed with
"soc:". This patch adds parse and attach support for such devices.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/common/eal_common_dev.c  | 27 +
 lib/librte_eal/common/eal_common_devargs.c  | 17 
 lib/librte_eal/common/eal_common_soc.c  | 61 -
 lib/librte_eal/common/include/rte_devargs.h |  8 
 lib/librte_eal/common/include/rte_soc.h | 24 
 5 files changed, 120 insertions(+), 17 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 457d227..ebbcf47 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -107,17 +107,23 @@ rte_eal_dev_init(void)

 int rte_eal_dev_attach(const char *name, const char *devargs)
 {
-   struct rte_pci_addr addr;
+   struct rte_soc_addr soc_addr;
+   struct rte_pci_addr pci_addr;

if (name == NULL || devargs == NULL) {
RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
return -EINVAL;
}

-   if (eal_parse_pci_DomBDF(name, ) == 0) {
-   if (rte_eal_pci_probe_one() < 0)
+   memset(_addr, 0, sizeof(soc_addr));
+   if (rte_eal_parse_soc_spec(name, _addr) == 0) {
+   if (rte_eal_soc_probe_one(_addr) < 0) {
+   free(soc_addr.name);
+   goto err;
+   }
+   } else if (eal_parse_pci_DomBDF(name, _addr) == 0) {
+   if (rte_eal_pci_probe_one(_addr) < 0)
goto err;
-
} else {
if (rte_eal_vdev_init(name, devargs))
goto err;
@@ -132,15 +138,22 @@ err:

 int rte_eal_dev_detach(const char *name)
 {
-   struct rte_pci_addr addr;
+   struct rte_soc_addr soc_addr;
+   struct rte_pci_addr pci_addr;

if (name == NULL) {
RTE_LOG(ERR, EAL, "Invalid device provided.\n");
return -EINVAL;
}

-   if (eal_parse_pci_DomBDF(name, ) == 0) {
-   if (rte_eal_pci_detach() < 0)
+   memset(_addr, 0, sizeof(soc_addr));
+   if (rte_eal_parse_soc_spec(name, _addr) == 0) {
+   if (rte_eal_soc_detach(_addr) < 0) {
+   free(soc_addr.name);
+   goto err;
+   }
+   } else if (eal_parse_pci_DomBDF(name, _addr) == 0) {
+   if (rte_eal_pci_detach(_addr) < 0)
goto err;
} else {
if (rte_eal_vdev_uninit(name))
diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index e403717..e1dae1a 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -41,6 +41,7 @@
 #include 

 #include 
+#include 
 #include 
 #include "eal_private.h"

@@ -105,6 +106,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char 
*devargs_str)
goto fail;

break;
+
+   case RTE_DEVTYPE_WHITELISTED_SOC:
+   case RTE_DEVTYPE_BLACKLISTED_SOC:
+   /* try to parse soc device with prefix "soc:" */
+   if (rte_eal_parse_soc_spec(buf, >soc.addr) != 0)
+   goto fail;
+   break;
+
case RTE_DEVTYPE_VIRTUAL:
/* save driver name */
ret = snprintf(devargs->virt.drv_name,
@@ -166,6 +175,14 @@ rte_eal_devargs_dump(FILE *f)
   devargs->pci.addr.devid,
   devargs->pci.addr.function,
   devargs->args);
+   else if (devargs->type == RTE_DEVTYPE_WHITELISTED_SOC)
+   fprintf(f, "  SoC whitelist %s %s\n",
+  devargs->soc.addr.name,
+  devargs->soc.addr.fdt_path);
+   else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_SOC)
+   fprintf(f, "  SoC blacklist %s %s\n",
+  devargs->soc.addr.name,
+  devargs->soc.addr.fdt_path);
else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
fprintf(f, "  VIRTUAL %s %s\n",
   devargs->virt.drv_name,
diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
index 256cef8..44f5559 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -37,6 +37,8 @@

 #include 
 #include 
+#include 
+#include 
 #include 

 #include "eal_private.h"
@@ -70,6 +72,2

[dpdk-dev] [PATCH v6 10/21] eal/soc: init SoC infra from EAL

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/bsdapp/eal/Makefile|  1 +
 lib/librte_eal/bsdapp/eal/eal.c   |  4 +++
 lib/librte_eal/bsdapp/eal/eal_soc.c   | 46 
 lib/librte_eal/common/eal_private.h   | 10 +++
 lib/librte_eal/linuxapp/eal/Makefile  |  1 +
 lib/librte_eal/linuxapp/eal/eal.c |  3 ++
 lib/librte_eal/linuxapp/eal/eal_soc.c | 56 +++
 7 files changed, 121 insertions(+)
 create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index a15b762..42b3a2b 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_soc.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_timer.c
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 9b93da3..2d62b9d 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -564,6 +565,9 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_pci_init() < 0)
rte_panic("Cannot init PCI\n");

+   if (rte_eal_soc_init() < 0)
+   rte_panic("Cannot init SoC\n");
+
eal_check_mem_on_local_socket();

if (eal_plugins_init() < 0)
diff --git a/lib/librte_eal/bsdapp/eal/eal_soc.c 
b/lib/librte_eal/bsdapp/eal/eal_soc.c
new file mode 100644
index 000..cb297ff
--- /dev/null
+++ b/lib/librte_eal/bsdapp/eal/eal_soc.c
@@ -0,0 +1,46 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Init the SoC EAL subsystem */
+int
+rte_eal_soc_init(void)
+{
+   return 0;
+}
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 0e8d6f7..d810f9f 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -122,6 +122,16 @@ int rte_eal_pci_init(void);
 struct rte_soc_driver;
 struct rte_soc_device;

+/**
+ * Init the SoC infra.
+ *
+ * This function is private to EAL.
+ *
+ * @return
+ *   0 on success, negative on error
+ */
+int rte_eal_soc_init(void);
+
 struct rte_pci_driver;
 struct rte_pci_device;

diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index a520477..59e30fa 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_vfio.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += e

[dpdk-dev] [PATCH v6 09/21] eal: introduce command line enable SoC option

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Support --enable-soc. SoC support is disabled by default.

Signed-off-by: Jan Viktorin 
[Shreyansh: Change --no-soc to --enable-soc; disabled by default]
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 doc/guides/testpmd_app_ug/run_app.rst  | 4 
 lib/librte_eal/common/eal_common_options.c | 5 +
 lib/librte_eal/common/eal_internal_cfg.h   | 1 +
 lib/librte_eal/common/eal_options.h| 2 ++
 4 files changed, 12 insertions(+)

diff --git a/doc/guides/testpmd_app_ug/run_app.rst 
b/doc/guides/testpmd_app_ug/run_app.rst
index d7c5120..4dafe5f 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information 
on these options.

 Use malloc instead of hugetlbfs.

+*   ``--enable-soc``
+
+Enable SoC framework support
+

 Testpmd Command-line Options
 
diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 6ca8af1..2156ab3 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -75,6 +75,7 @@ const struct option
 eal_long_options[] = {
{OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM},
{OPT_CREATE_UIO_DEV,0, NULL, OPT_CREATE_UIO_DEV_NUM   },
+   {OPT_ENABLE_SOC,0, NULL, OPT_ENABLE_SOC_NUM   },
{OPT_FILE_PREFIX,   1, NULL, OPT_FILE_PREFIX_NUM  },
{OPT_HELP,  0, NULL, OPT_HELP_NUM },
{OPT_HUGE_DIR,  1, NULL, OPT_HUGE_DIR_NUM },
@@ -843,6 +844,10 @@ eal_parse_common_option(int opt, const char *optarg,
break;

/* long options */
+   case OPT_ENABLE_SOC_NUM:
+   conf->enable_soc = 1;
+   break;
+
case OPT_HUGE_UNLINK_NUM:
conf->hugepage_unlink = 1;
break;
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index 5f1367e..2a6e3ea 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -67,6 +67,7 @@ struct internal_config {
unsigned hugepage_unlink; /**< true to unlink backing files */
volatile unsigned xen_dom0_support; /**< support app running on Xen 
Dom0*/
volatile unsigned no_pci; /**< true to disable PCI */
+   volatile unsigned enable_soc; /**< true to enable SoC */
volatile unsigned no_hpet;/**< true to disable HPET */
volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping

* instead of native TSC */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index a881c62..6e679c3 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -49,6 +49,8 @@ enum {
OPT_BASE_VIRTADDR_NUM,
 #define OPT_CREATE_UIO_DEV"create-uio-dev"
OPT_CREATE_UIO_DEV_NUM,
+#define OPT_ENABLE_SOC"enable-soc"
+   OPT_ENABLE_SOC_NUM,
 #define OPT_FILE_PREFIX   "file-prefix"
OPT_FILE_PREFIX_NUM,
 #define OPT_HUGE_DIR  "huge-dir"
-- 
2.7.4



[dpdk-dev] [PATCH v6 08/21] eal/soc: implement SoC device list and dump

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

SoC devices would be linked in a separate list (from PCI). This is used for
probe function.
A helper for dumping the device list is added.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_soc.c  | 34 +
 lib/librte_eal/common/include/rte_soc.h |  9 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 4 files changed, 47 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index cf6fb8e..86e3cfd 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -171,11 +171,13 @@ DPDK_16.11 {
rte_eal_dev_attach;
rte_eal_dev_detach;
rte_eal_map_resource;
+   rte_eal_soc_dump;
rte_eal_soc_register;
rte_eal_soc_unregister;
rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;
+   soc_device_list;
soc_driver_list;

 } DPDK_16.07;
diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
index 56135ed..5dcddc5 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -31,6 +31,8 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
+#include 
 #include 

 #include 
@@ -40,6 +42,38 @@
 /* Global SoC driver list */
 struct soc_driver_list soc_driver_list =
TAILQ_HEAD_INITIALIZER(soc_driver_list);
+struct soc_device_list soc_device_list =
+   TAILQ_HEAD_INITIALIZER(soc_device_list);
+
+/* dump one device */
+static int
+soc_dump_one_device(FILE *f, struct rte_soc_device *dev)
+{
+   int i;
+
+   fprintf(f, "%s", dev->addr.name);
+   fprintf(f, " - fdt_path: %s\n",
+   dev->addr.fdt_path ? dev->addr.fdt_path : "(none)");
+
+   for (i = 0; dev->id && dev->id[i].compatible; ++i)
+   fprintf(f, "   %s\n", dev->id[i].compatible);
+
+   return 0;
+}
+
+/* dump devices on the bus to an output stream */
+void
+rte_eal_soc_dump(FILE *f)
+{
+   struct rte_soc_device *dev = NULL;
+
+   if (!f)
+   return;
+
+   TAILQ_FOREACH(dev, _device_list, next) {
+   soc_dump_one_device(f, dev);
+   }
+}

 /* register a driver */
 void
diff --git a/lib/librte_eal/common/include/rte_soc.h 
b/lib/librte_eal/common/include/rte_soc.h
index 23b06a9..347e611 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -56,8 +56,12 @@ extern "C" {

 extern struct soc_driver_list soc_driver_list;
 /**< Global list of SoC Drivers */
+extern struct soc_device_list soc_device_list;
+/**< Global list of SoC Devices */

 TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */
+TAILQ_HEAD(soc_device_list, rte_soc_device); /**< SoC devices in D-linked Q. */
+

 struct rte_soc_id {
const char *compatible; /**< OF compatible specification */
@@ -142,6 +146,11 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
 }

 /**
+ * Dump discovered SoC devices.
+ */
+void rte_eal_soc_dump(FILE *f);
+
+/**
  * Register a SoC driver.
  */
 void rte_eal_soc_register(struct rte_soc_driver *driver);
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index ab6b985..0155025 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -175,11 +175,13 @@ DPDK_16.11 {
rte_eal_dev_attach;
rte_eal_dev_detach;
rte_eal_map_resource;
+   rte_eal_soc_dump;
rte_eal_soc_register;
rte_eal_soc_unregister;
rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;
+   soc_device_list;
soc_driver_list;

 } DPDK_16.07;
-- 
2.7.4



[dpdk-dev] [PATCH v6 07/21] eal/soc: add SoC PMD register/unregister logic

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC
(on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the
registered drivers.

Test case has been introduced to verify the registration and
deregistration.

Signed-off-by: Jan Viktorin 
[Shreyansh: update PMD registration method]
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 app/test/test_soc.c | 111 
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   3 +
 lib/librte_eal/common/eal_common_soc.c  |  56 
 lib/librte_eal/common/include/rte_soc.h |  26 ++
 lib/librte_eal/linuxapp/eal/Makefile|   1 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   3 +
 6 files changed, 200 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_soc.c

diff --git a/app/test/test_soc.c b/app/test/test_soc.c
index 916a863..ac03e64 100644
--- a/app/test/test_soc.c
+++ b/app/test/test_soc.c
@@ -75,6 +75,108 @@ static int test_compare_addr(void)
free(a2.name);
free(a1.name);
free(a0.name);
+
+   return 0;
+}
+
+/**
+ * Empty PMD driver based on the SoC infra.
+ *
+ * The rte_soc_device is usually wrapped in some higher-level struct
+ * (eth_driver). We simulate such a wrapper with an anonymous struct here.
+ */
+struct test_wrapper {
+   struct rte_soc_driver soc_drv;
+};
+
+struct test_wrapper empty_pmd0 = {
+   .soc_drv = {
+   .driver = {
+   .name = "empty_pmd0"
+   },
+   },
+};
+
+struct test_wrapper empty_pmd1 = {
+   .soc_drv = {
+   .driver = {
+   .name = "empty_pmd1"
+   },
+   },
+};
+
+static int
+count_registered_socdrvs(void)
+{
+   int i;
+   struct rte_soc_driver *drv;
+
+   i = 0;
+   TAILQ_FOREACH(drv, _driver_list, next)
+   i += 1;
+
+   return i;
+}
+
+static int
+test_register_unregister(void)
+{
+   struct rte_soc_driver *drv;
+   int count;
+
+   rte_eal_soc_register(_pmd0.soc_drv);
+
+   TEST_ASSERT(!TAILQ_EMPTY(_driver_list),
+   "No PMD is present but the empty_pmd0 should be there");
+   drv = TAILQ_FIRST(_driver_list);
+   TEST_ASSERT(!strcmp(drv->driver.name, "empty_pmd0"),
+   "The registered PMD is not empty_pmd0 but '%s'",
+   drv->driver.name);
+
+   rte_eal_soc_register(_pmd1.soc_drv);
+
+   count = count_registered_socdrvs();
+   TEST_ASSERT_EQUAL(count, 2, "Expected 2 PMDs but detected %d", count);
+
+   rte_eal_soc_unregister(_pmd0.soc_drv);
+   count = count_registered_socdrvs();
+   TEST_ASSERT_EQUAL(count, 1, "Expected 1 PMDs but detected %d", count);
+
+   rte_eal_soc_unregister(_pmd1.soc_drv);
+
+   printf("%s has been successful\n", __func__);
+   return 0;
+}
+
+/* save real devices and drivers until the tests finishes */
+struct soc_driver_list real_soc_driver_list =
+   TAILQ_HEAD_INITIALIZER(real_soc_driver_list);
+
+static int test_soc_setup(void)
+{
+   struct rte_soc_driver *drv;
+
+   /* no real drivers for the test */
+   while (!TAILQ_EMPTY(_driver_list)) {
+   drv = TAILQ_FIRST(_driver_list);
+   rte_eal_soc_unregister(drv);
+   TAILQ_INSERT_TAIL(_soc_driver_list, drv, next);
+   }
+
+   return 0;
+}
+
+static int test_soc_cleanup(void)
+{
+   struct rte_soc_driver *drv;
+
+   /* bring back real drivers after the test */
+   while (!TAILQ_EMPTY(_soc_driver_list)) {
+   drv = TAILQ_FIRST(_soc_driver_list);
+   TAILQ_REMOVE(_soc_driver_list, drv, next);
+   rte_eal_soc_register(drv);
+   }
+
return 0;
 }

@@ -84,6 +186,15 @@ test_soc(void)
if (test_compare_addr())
return -1;

+   if (test_soc_setup())
+   return -1;
+
+   if (test_register_unregister())
+   return -1;
+
+   if (test_soc_cleanup())
+   return -1;
+
return 0;
 }

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 11d9f59..cf6fb8e 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -171,8 +171,11 @@ DPDK_16.11 {
rte_eal_dev_attach;
rte_eal_dev_detach;
rte_eal_map_resource;
+   rte_eal_soc_register;
+   rte_eal_soc_unregister;
rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;
+   soc_driver_list;

 } DPDK_16.07;
diff --git a/lib/librte_eal/common/eal_common_soc.c 
b/lib/librte_eal/common/eal_common_soc.c
new file mode 100644
index 000..56135ed
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_soc.

[dpdk-dev] [PATCH v6 06/21] eal/soc: introduce very essential SoC infra definitions

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Define initial structures and functions for the SoC infrastructure.
This patch supports only a very minimal functions for now.
More features will be added in the following commits.

Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
Signed-off-by: Hemant Agrawal 
---
 app/test/Makefile   |   1 +
 app/test/test_soc.c |  90 +
 lib/librte_eal/common/Makefile  |   2 +-
 lib/librte_eal/common/eal_private.h |   4 +
 lib/librte_eal/common/include/rte_soc.h | 138 
 5 files changed, 234 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_soc.c
 create mode 100644 lib/librte_eal/common/include/rte_soc.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 5be023a..30295af 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -77,6 +77,7 @@ APP = test
 #
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c
 SRCS-y += test.c
+SRCS-y += test_soc.c
 SRCS-y += resource.c
 SRCS-y += test_resource.c
 test_resource.res: test_resource.c
diff --git a/app/test/test_soc.c b/app/test/test_soc.c
new file mode 100644
index 000..916a863
--- /dev/null
+++ b/app/test/test_soc.c
@@ -0,0 +1,90 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "test.h"
+
+static char *safe_strdup(const char *s)
+{
+   char *c = strdup(s);
+
+   if (c == NULL)
+   rte_panic("failed to strdup '%s'\n", s);
+
+   return c;
+}
+
+static int test_compare_addr(void)
+{
+   struct rte_soc_addr a0;
+   struct rte_soc_addr a1;
+   struct rte_soc_addr a2;
+
+   a0.name = safe_strdup("ethernet0");
+   a0.fdt_path = NULL;
+
+   a1.name = safe_strdup("ethernet0");
+   a1.fdt_path = NULL;
+
+   a2.name = safe_strdup("ethernet1");
+   a2.fdt_path = NULL;
+
+   TEST_ASSERT(!rte_eal_compare_soc_addr(, ),
+   "Failed to compare two soc addresses that equal");
+   TEST_ASSERT(rte_eal_compare_soc_addr(, ),
+   "Failed to compare two soc addresses that differs");
+
+   free(a2.name);
+   free(a1.name);
+   free(a0.name);
+   return 0;
+}
+
+static int
+test_soc(void)
+{
+   if (test_compare_addr())
+   return -1;
+
+   return 0;
+}
+
+REGISTER_TEST_COMMAND(soc_autotest, test_soc);
diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index dfd64aa..b414008 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk

 INC := rte_branch_prediction.h rte_common.h
 INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h
-INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h
+INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h
 INC += rte_per_lcore.h rte_random.h
 INC += rte_tailq.h rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_version.h
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index c8c2131..0e8d6f7 100644
--- a/

[dpdk-dev] [PATCH v6 05/21] eal: define container macro

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/include/rte_common.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index db5ac91..8152bd9 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif

+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *  ...
+ *  struct child c;
+ *  ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#ifndef container_of
+#define container_of(p, type, member) \
+   ((type *) (((char *) (p)) - offsetof(type, member)))
+#endif
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
-- 
2.7.4



[dpdk-dev] [PATCH v6 04/21] eal/linux: generalize PCI kernel driver extraction to EAL

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Generalize the PCI-specific pci_get_kernel_driver_by_path. The function
is general enough, we have just moved it to eal.c, changed the prefix to
rte_eal and provided it privately to other parts of EAL.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/bsdapp/eal/eal.c   |  7 +++
 lib/librte_eal/common/eal_private.h   | 14 ++
 lib/librte_eal/linuxapp/eal/eal.c | 29 +
 lib/librte_eal/linuxapp/eal/eal_pci.c | 31 +--
 4 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 5271fc2..9b93da3 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -640,3 +640,10 @@ rte_eal_unbind_kernel_driver(const char *devpath 
__rte_unused,
 {
return -ENOTSUP;
 }
+
+int
+rte_eal_get_kernel_driver_by_path(const char *filename __rte_unused,
+ char *dri_name __rte_unused)
+{
+   return -ENOTSUP;
+}
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index b0c208a..c8c2131 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -269,6 +269,20 @@ int rte_eal_check_module(const char *module_name);
 int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid);

 /**
+ * Extract the kernel driver name from the absolute path to the driver.
+ *
+ * @param filename  path to the driver ("/driver")
+ * @path  dri_name  target buffer where to place the driver name
+ *  (should be at least PATH_MAX long)
+ *
+ * @return
+ *  -1   on failure
+ *   0   when successful
+ *   1   when there is no such driver
+ */
+int rte_eal_get_kernel_driver_by_path(const char *filename, char *dri_name);
+
+/**
  * Get cpu core_id.
  *
  * This function is private to the EAL.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 5f6676d..00af21c 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -969,3 +969,32 @@ error:
fclose(f);
return -1;
 }
+
+int
+rte_eal_get_kernel_driver_by_path(const char *filename, char *dri_name)
+{
+   int count;
+   char path[PATH_MAX];
+   char *name;
+
+   if (!filename || !dri_name)
+   return -1;
+
+   count = readlink(filename, path, PATH_MAX);
+   if (count >= PATH_MAX)
+   return -1;
+
+   /* For device does not have a driver */
+   if (count < 0)
+   return 1;
+
+   path[count] = '\0';
+
+   name = strrchr(path, '/');
+   if (name) {
+   strncpy(dri_name, name + 1, strlen(name + 1) + 1);
+   return 0;
+   }
+
+   return -1;
+}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index a03553f..e1cf9e8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -78,35 +78,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev)
return rte_eal_unbind_kernel_driver(devpath, devid);
 }

-static int
-pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
-{
-   int count;
-   char path[PATH_MAX];
-   char *name;
-
-   if (!filename || !dri_name)
-   return -1;
-
-   count = readlink(filename, path, PATH_MAX);
-   if (count >= PATH_MAX)
-   return -1;
-
-   /* For device does not have a driver */
-   if (count < 0)
-   return 1;
-
-   path[count] = '\0';
-
-   name = strrchr(path, '/');
-   if (name) {
-   strncpy(dri_name, name + 1, strlen(name + 1) + 1);
-   return 0;
-   }
-
-   return -1;
-}
-
 /* Map pci device */
 int
 rte_eal_pci_map_device(struct rte_pci_device *dev)
@@ -354,7 +325,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,

/* parse driver */
snprintf(filename, sizeof(filename), "%s/driver", dirname);
-   ret = pci_get_kernel_driver_by_path(filename, driver);
+   ret = rte_eal_get_kernel_driver_by_path(filename, driver);
if (ret < 0) {
RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
free(dev);
-- 
2.7.4



[dpdk-dev] [PATCH v6 03/21] eal/linux: generalize PCI kernel unbinding driver to EAL

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided
into two parts. First, determination of the path and string identification
of the device to be unbound. Second, the actual unbind operation which is
generic.

BSD implementation updated as ENOTSUP

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
--
Changes since v2:
 - update BSD support for unbind kernel driver
---
 lib/librte_eal/bsdapp/eal/eal.c   |  7 +++
 lib/librte_eal/bsdapp/eal/eal_pci.c   |  4 ++--
 lib/librte_eal/common/eal_private.h   | 13 +
 lib/librte_eal/linuxapp/eal/eal.c | 26 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +
 5 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 35e3117..5271fc2 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -633,3 +633,10 @@ rte_eal_process_type(void)
 {
return rte_config.process_type;
 }
+
+int
+rte_eal_unbind_kernel_driver(const char *devpath __rte_unused,
+const char *devid __rte_unused)
+{
+   return -ENOTSUP;
+}
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 7ed0115..703f034 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -89,11 +89,11 @@

 /* unbind kernel driver for this device */
 int
-pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
+pci_unbind_kernel_driver(struct rte_pci_device *dev)
 {
RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented "
"for BSD\n");
-   return -ENOTSUP;
+   return rte_eal_unbind_kernel_driver(dev);
 }

 /* Map pci device */
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 9e7d8f6..b0c208a 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -256,6 +256,19 @@ int rte_eal_alarm_init(void);
 int rte_eal_check_module(const char *module_name);

 /**
+ * Unbind kernel driver bound to the device specified by the given devpath,
+ * and its string identification.
+ *
+ * @param devpath  path to the device directory ("/sys/.../devices/")
+ * @param devididentification of the device ()
+ *
+ * @return
+ *  -1  unbind has failed
+ *   0  module has been unbound
+ */
+int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid);
+
+/**
  * Get cpu core_id.
  *
  * This function is private to the EAL.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 2075282..5f6676d 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name)
/* Module has been found */
return 1;
 }
+
+int
+rte_eal_unbind_kernel_driver(const char *devpath, const char *devid)
+{
+   char filename[PATH_MAX];
+   FILE *f;
+
+   snprintf(filename, sizeof(filename),
+"%s/driver/unbind", devpath);
+
+   f = fopen(filename, "w");
+   if (f == NULL) /* device was not bound */
+   return 0;
+
+   if (fwrite(devid, strlen(devid), 1, f) == 0) {
+   RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
+   filename);
+   goto error;
+   }
+
+   fclose(f);
+   return 0;
+error:
+   fclose(f);
+   return -1;
+}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 876ba38..a03553f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -59,38 +59,23 @@ int
 pci_unbind_kernel_driver(struct rte_pci_device *dev)
 {
int n;
-   FILE *f;
-   char filename[PATH_MAX];
-   char buf[BUFSIZ];
+   char devpath[PATH_MAX];
+   char devid[BUFSIZ];
struct rte_pci_addr *loc = >addr;

-   /* open /sys/bus/pci/devices/:BB:CC.D/driver */
-   snprintf(filename, sizeof(filename),
-   "%s/" PCI_PRI_FMT "/driver/unbind", pci_get_sysfs_path(),
+   /* devpath /sys/bus/pci/devices/:BB:CC.D */
+   snprintf(devpath, sizeof(devpath),
+   "%s/" PCI_PRI_FMT, pci_get_sysfs_path(),
loc->domain, loc->bus, loc->devid, loc->function);

-   f = fopen(filename, "w");
-   if (f == NULL) /* device was not bound */
-   return 0;
-
-   n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
+   n = snprintf(devid, sizeof(devid), PCI_PRI_FMT "\n",
 loc->domain, loc->bus, loc->devid, loc->function);
-   if ((n < 0) || (n >= (int)sizeof(

[dpdk-dev] [PATCH v6 02/21] eal: generalize PCI map/unmap resource to EAL

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

The functions pci_map_resource, pci_unmap_resource are generic so the
pci_* prefix can be omitted. The functions are moved to the
eal_common_dev.c so they can be reused by other infrastructure.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_dev.c  | 39 +
 lib/librte_eal/common/eal_common_pci.c  | 39 -
 lib/librte_eal/common/eal_common_pci_uio.c  | 16 +-
 lib/librte_eal/common/include/rte_dev.h | 32 
 lib/librte_eal/common/include/rte_pci.h | 32 
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c   |  2 +-
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c  |  5 ++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 10 files changed, 89 insertions(+), 82 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 8b3ed88..7ed0115 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -228,7 +228,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, 
int res_idx,

/* if matching map is found, then use it */
offset = res_idx * pagesz;
-   mapaddr = pci_map_resource(NULL, fd, (off_t)offset,
+   mapaddr = rte_eal_map_resource(NULL, fd, (off_t)offset,
(size_t)dev->mem_resource[res_idx].len, 0);
close(fd);
if (mapaddr == MAP_FAILED)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 2f81f7c..11d9f59 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -170,6 +170,8 @@ DPDK_16.11 {
rte_delay_us_callback_register;
rte_eal_dev_attach;
rte_eal_dev_detach;
+   rte_eal_map_resource;
+   rte_eal_unmap_resource;
rte_eal_vdrv_register;
rte_eal_vdrv_unregister;

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 4f3b493..457d227 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -151,3 +152,41 @@ err:
RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", name);
return -EINVAL;
 }
+
+/* map a particular resource from a file */
+void *
+rte_eal_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
+int additional_flags)
+{
+   void *mapaddr;
+
+   /* Map the Memory resource of device */
+   mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
+   MAP_SHARED | additional_flags, fd, offset);
+   if (mapaddr == MAP_FAILED) {
+   RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s"
+   " (%p)\n", __func__, fd, requested_addr,
+   (unsigned long)size, (unsigned long)offset,
+   strerror(errno), mapaddr);
+   } else
+   RTE_LOG(DEBUG, EAL, "  Device memory mapped at %p\n", mapaddr);
+
+   return mapaddr;
+}
+
+/* unmap a particular resource */
+void
+rte_eal_unmap_resource(void *requested_addr, size_t size)
+{
+   if (requested_addr == NULL)
+   return;
+
+   /* Unmap the Memory resource of device */
+   if (munmap(requested_addr, size)) {
+   RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n",
+   __func__, requested_addr, (unsigned long)size,
+   strerror(errno));
+   } else
+   RTE_LOG(DEBUG, EAL, "  Device memory unmapped at %p\n",
+   requested_addr);
+}
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 638cd86..464acc1 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -67,7 +67,6 @@
 #include 
 #include 
 #include 
-#include 

 #include 
 #include 
@@ -114,44 +113,6 @@ static struct rte_devargs *pci_devargs_lookup(struct 
rte_pci_device *dev)
return NULL;
 }

-/* map a particular resource from a file */
-void *
-pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
-int additional_flags)
-{
-   void *mapaddr;
-
-   /* Map the PCI memory resource of device */
-   mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,
-   MAP_SHARED | additional_flags, fd, offset);
-   if (mapaddr == MAP_FAILED) {
-   RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s 
(%p)\n",
-

[dpdk-dev] [PATCH v6 01/21] eal: generalize PCI kernel driver enum to EAL

2016-10-27 Thread Shreyansh Jain
From: Jan Viktorin <vikto...@rehivetech.com>

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 

--
Changes since v0:
 - fix compilation error due to missing include
---
 lib/librte_eal/common/include/rte_dev.h | 12 
 lib/librte_eal/common/include/rte_pci.h |  9 -
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 8840380..6975b9f 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -109,6 +109,18 @@ struct rte_mem_resource {
void *addr; /**< Virtual address, NULL when not mapped. */
 };

+/**
+ * Kernel driver passthrough type
+ */
+enum rte_kernel_driver {
+   RTE_KDRV_UNKNOWN = 0,
+   RTE_KDRV_IGB_UIO,
+   RTE_KDRV_VFIO,
+   RTE_KDRV_UIO_GENERIC,
+   RTE_KDRV_NIC_UIO,
+   RTE_KDRV_NONE,
+};
+
 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
 /** Double linked list of devices. */
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 9ce8847..2c7046f 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -135,15 +135,6 @@ struct rte_pci_addr {

 struct rte_devargs;

-enum rte_kernel_driver {
-   RTE_KDRV_UNKNOWN = 0,
-   RTE_KDRV_IGB_UIO,
-   RTE_KDRV_VFIO,
-   RTE_KDRV_UIO_GENERIC,
-   RTE_KDRV_NIC_UIO,
-   RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
-- 
2.7.4



[dpdk-dev] [PATCH v6 00/21] Introduce SoC device/driver framework for EAL

2016-10-27 Thread Shreyansh Jain
n
   them.
 - Patch 0015~0016 add support for default function which PMDs can use for
   scanning platform bus. These functions are optional and need to be hooked
   to by PMDs.
 - Patch 0017~0019 makes changes to PCI as well as ethdev code to remove
   assumption that eth_driver is a PCI driver.
 - Patch 0020 adds necessary ethdev probe/remove functions for PMDs to use
 - Patch 0021 adds support for SoC driver/devices, along with probe/remove
   functions for Cryptodev devices.

Future/Pending Changes:
===
- Device whitelisting/blacklist still relies on command line '-b' and '-c'
  which are internally implemented using OPT_PCI_BLACKLIST/OPT_PCI_WHITELIST.
  This needs to be changed to a generic form - OPT_DEV_*LIST - probably.
- No cryptodriver currently uses SoC framework - probably a example driver
  can be created to demonstrate usage.
- test case for enable-soc command line parameter
- This patch impacts a couple of ABIs (rte_device/driver) and thus require
  a patch for bump of libraries (if need be) and documentation.

 [1] http://dpdk.org/ml/archives/dev/2016-January/030915.html
 [2] http://www.dpdk.org/ml/archives/dev/2016-May/038486.html
 [3] http://dpdk.org/ml/archives/dev/2016-August/045707.html
 [4] http://dpdk.org/ml/archives/dev/2016-May/038948.html
 [5] http://dpdk.org/ml/archives/dev/2016-May/038953.html
 [6] http://dpdk.org/ml/archives/dev/2016-May/038487.html
 [7] http://dpdk.org/ml/archives/dev/2016-May/038488.html
 [8] http://dpdk.org/ml/archives/dev/2016-May/038489.html
 [9] http://dpdk.org/ml/archives/dev/2016-May/038491.html
[10] http://dpdk.org/ml/archives/dev/2016-September/046256.html
[11] http://dpdk.org/ml/archives/dev/2016-October/048915.html

Changes since v5:
 - fix devinit/devuninit name change; it was in wrong patch
 - rebased over HEAD (ca41215)
 - Update to pending section of coverletter

Changes since v4:
 - change name of rte_eal_soc_scan function name to
   rte_eal_soc_scan_platform_bus. This still remains a helper function.
 - Fix comments over scan and match functions

Changes since v3:
 - rebasing over HEAD (fed622df tag: v16.11-rc1)
 - Add support for default scan function; PMD can use this for
   scanning on platform bus.
 - Support for kernel driver bind/unbind, numa and DMA from
   Jan's original patches.
 - SoC is disabled by default. '--enable-soc' command line parameter
   enables it. doc updated.
 - Updated testcase function names and comments
 - Map file addition alphabetically ordered
 - Patch author corrected

Changes since v2:
 - Rebasing over rte_driver/device patchset v9 [10]
 - Added cryptodev support for SoC
 - Default match function for SoC device<=>Driver
 - Some variables renamed to reflect 'drv' rather than 'dr'

Change since v1 [2]:
 - Removed patch 1-5 which were for generalizing some PCI specific routines
   into EAL. These patches are good-to-have but not directly linked to SoC
   and hence would be proposed separately.
 - Removed support for sysfs parsing (patches 6~9)
 - Rebasing over the recent (v8) version of rte_driver/device patchset
 - Rebasing over master (16.07)
 - Changes to various map file to change API intro to 16.11 from 16.07

Jan Viktorin (19):
  eal: generalize PCI kernel driver enum to EAL
  eal: generalize PCI map/unmap resource to EAL
  eal/linux: generalize PCI kernel unbinding driver to EAL
  eal/linux: generalize PCI kernel driver extraction to EAL
  eal: define container macro
  eal/soc: introduce very essential SoC infra definitions
  eal/soc: add SoC PMD register/unregister logic
  eal/soc: implement SoC device list and dump
  eal: introduce command line enable SoC option
  eal/soc: init SoC infra from EAL
  eal/soc: extend and utilize devargs
  eal/soc: add drv_flags
  eal/soc: add intr_handle
  eal/soc: add default scan for Soc devices
  eal/soc: additional features for SoC
  ether: utilize container_of for pci_drv
  ether: verify we copy info from a PCI device
  ether: extract function eth_dev_get_intr_handle
  ether: introduce ethernet dev probe remove

Shreyansh Jain (2):
  eal/soc: implement probing of drivers
  eal/crypto: Support rte_soc_driver/device for cryptodev

 app/test/Makefile   |   1 +
 app/test/test_soc.c | 404 +++
 doc/guides/testpmd_app_ug/run_app.rst   |   4 +
 lib/librte_cryptodev/rte_cryptodev.c| 122 +-
 lib/librte_cryptodev/rte_cryptodev.h|   3 +
 lib/librte_cryptodev/rte_cryptodev_pmd.h|  18 +-
 lib/librte_cryptodev/rte_cryptodev_version.map  |   2 +
 lib/librte_eal/bsdapp/eal/Makefile  |   1 +
 lib/librte_eal/bsdapp/eal/eal.c |  18 +
 lib/librte_eal/bsdapp/eal/eal_pci.c |   6 +-
 lib/librte_eal/bsdapp/eal/eal_soc.c |  46 +++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  11 +
 lib/librte_eal/common/Makefile  |   2 +-
 lib/librte_eal/common/eal_common_dev.c  |  66 ++-
 lib

[dpdk-dev] [PATCH v4] eal: fix lib version for device generalization patches

2016-10-27 Thread Shreyansh Jain
On Thursday 27 October 2016 04:59 PM, Shreyansh Jain wrote:
> index aa0c09a..db20567 100644
> --- a/doc/guides/rel_notes/release_16_11.rst
> +++ b/doc/guides/rel_notes/release_16_11.rst
> @@ -201,6 +201,32 @@ API Changes
>  * The ``file_name`` data type of ``struct rte_port_source_params`` and
>``struct rte_port_sink_params`` is changed from `char *`` to ``const char 
> *``.
>
> +* **Improved device/driver hierarchy and generalized hotplugging**
> +
> +  Device and driver relationship has been restructured by introducing generic
> +  classes. This paves way for having PCI, VDEV and other device types as
> +  just instantiated objects rather than classes in themselves. Hotplugging 
> too
> +  has been generalized into EAL so that ethernet or crypto devices can use 
> the
> +  common infrastructure.
> +
> +  * removed ``pmd_type`` as way of segregation of devices
> +  * moved ``numa_node`` and ``devargs`` into ``rte_driver`` from
> +``rte_pci_driver``. These can now be used by any instantiated object of
> +``rte_driver``.
> +  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
> +  * renamed devinit/devuninit handlers to probe/remove to make it more
> +semantically correct with respect to device<=>driver relationship
> +  * moved hotplugging support to EAL. Hereafter, PCI and vdev can use the
> +APIs ``rte_eal_dev_attach`` and ``rte_eal_dev_detach``.
> +  * helpers and support macros have been renamed to make them more synonymous
> +with their device types
> +(e.g. ``PMD_REGISTER_DRIVER`` => ``RTE_PMD_REGISTER_PCI``)
> +  * Device naming functions have been generalized from ethdev and cryptodev
> +to EAL. ``rte_eal_pci_device_name`` has been introduced for obtaining
> +unique device name from PCI Domain-BDF description.
> +  * Virtual device registration APIs have been added: 
> ``rte_eal_vdrv_register``
> +and ``rte_eal_vdrv_unregister``.
> +
>
>  ABI Changes
>  ---

Even though I have sent the v4, there is another possibility of 
splitting this log across API and ABI changes.
Problem is that most of the changes are quite related in terms of impact 
on ABI and API. (some like rte_device is clear enough, though).
Any suggestions? Would repetitions be OK in release notes?

-
Shreyansh


[dpdk-dev] [PATCH v4] eal: fix lib version for device generalization patches

2016-10-27 Thread Shreyansh Jain
rte_device/driver generalization patches [1] were merged without a change
in the LIBABIVER variable. This patches bumps the macro of affected libs:

- libcryptodev and libetherdev have been bumped
- librte_eal version changed in
  d7e61ad3ae36 ("log: remove deprecated history dump")

Details of ABI/API changes:
- EAL [version already bumped in: d7e61ad3ae36]
  |- type field was removed from rte_driver
  |- rte_pci_device now embeds rte_device
  |- rte_pci_resource renamed to rte_mem_resource
  |- numa_node and devargs of rte_pci_driver is moved to rte_driver
  |- APIs for device hotplug (attach/detach) moved into EAL
  |- API rte_eal_pci_device_name added for PCI device naming
  |- vdev registration API introduced (rte_eal_vdrv_register,
  |  rte_eal_vdrv_unregister

- librte_crypto (v 1=>2)
  |- removed rte_cryptodev_create_unique_device_name API
  |- moved device naming to EAL

- librte_ethdev (v 4=>5)
  |- rte_eth_dev_type is removed
  |- removed dev_type from rte_eth_dev_allocate API
  |- removed API rte_eth_dev_get_device_type
  |- removed API rte_eth_dev_get_addr_by_port
  |- removed API rte_eth_dev_get_port_by_addr
  |- removed rte_cryptodev_create_unique_device_name API
  |- moved device naming to EAL

Also, deprecation notice from 16.07 has been removed and release notes for
16.11 added.

[1] http://dpdk.org/ml/archives/dev/2016-September/047087.html

Signed-off-by: Shreyansh Jain 
--
v4:
 - fix spelling mistakes and incorrect symbol name in doc
 - reword commit log for EAL modification commit id

v3:
 - add API/ABI change info in commit log
 - fix library version change notification in release note
 - fix erroneous change to librte_eal version in v2
---
 doc/guides/rel_notes/deprecation.rst   | 12 
 doc/guides/rel_notes/release_16_11.rst | 30 --
 lib/librte_cryptodev/Makefile  |  2 +-
 lib/librte_ether/Makefile  |  2 +-
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index d5c1490..884a231 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -18,18 +18,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.

-* The ethdev hotplug API is going to be moved to EAL with a notification
-  mechanism added to crypto and ethdev libraries so that hotplug is now
-  available to both of them. This API will be stripped of the device arguments
-  so that it only cares about hotplugging.
-
-* Structures embodying pci and vdev devices are going to be reworked to
-  integrate new common rte_device / rte_driver objects (see
-  http://dpdk.org/ml/archives/dev/2016-January/031390.html).
-  ethdev and crypto libraries will then only handle those objects so that they
-  do not need to care about the kind of devices that are being used, making it
-  easier to add new buses later.
-
 * ABI changes are planned for 16.11 in the ``rte_mbuf`` structure: some fields
   may be reordered to facilitate the writing of ``data_off``, ``refcnt``, and
   ``nb_segs`` in one operation, because some platforms have an overhead if the
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index aa0c09a..db20567 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -201,6 +201,32 @@ API Changes
 * The ``file_name`` data type of ``struct rte_port_source_params`` and
   ``struct rte_port_sink_params`` is changed from `char *`` to ``const char 
*``.

+* **Improved device/driver hierarchy and generalized hotplugging**
+
+  Device and driver relationship has been restructured by introducing generic
+  classes. This paves way for having PCI, VDEV and other device types as
+  just instantiated objects rather than classes in themselves. Hotplugging too
+  has been generalized into EAL so that ethernet or crypto devices can use the
+  common infrastructure.
+
+  * removed ``pmd_type`` as way of segregation of devices
+  * moved ``numa_node`` and ``devargs`` into ``rte_driver`` from
+``rte_pci_driver``. These can now be used by any instantiated object of
+``rte_driver``.
+  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
+  * renamed devinit/devuninit handlers to probe/remove to make it more
+semantically correct with respect to device<=>driver relationship
+  * moved hotplugging support to EAL. Hereafter, PCI and vdev can use the
+APIs ``rte_eal_dev_attach`` and ``rte_eal_dev_detach``.
+  * helpers and support macros have been renamed to make them more synonymous
+with their device types
+(e.g. ``PMD_REGISTER_DRIVER`` => ``RTE_PMD_REGISTER_PCI``)
+  * Device naming functions have been generalized from ethdev and cryptodev
+to EAL. ``rte_eal_pci_device_name`` has been

[dpdk-dev] [PATCH v3] eal: fix libabi macro for device generalization patches

2016-10-27 Thread Shreyansh Jain
Hello Thomas,

On Thursday 27 October 2016 03:45 PM, Thomas Monjalon wrote:
> 2016-10-27 12:38, Shreyansh Jain:
>> rte_device/driver generalization patches [1] were merged without a change
>> in the LIBABIVER macro. This patches bumps the macro of affected libs.
>
> It is not a macro but a Makefile variable.

Yes, I will change that.

>
>> (librte_eal was already bumped; libcryptodev and libetherdev have been
>> bumped).
>
> Please provide the commit id where EAL was bumped.

Ok. Will do.

>
>> Details of ABI/API changes:
>> - EAL (version not bumped)
>
> not bumped -> already bumped

Ok.

>
>>   |- type field was removed from rte_driver
>>   |- rte_pci_device now embeds rte_device
>>   |- rte_pci_resource renamed to rte_mem_resource
>>   |- numa_node and devargs of rte_pci_driver is moved to rte_driver
>>   |- APIs for device hotplug (attach/detach) moved into EAL
>>   |- API rte_eal_pci_device_name added for PCI device naming
>>   |- vdev registration API introduced (rte_eal_vdrv_register,
>>   |  rte_eal_vdrv_unregister
>>
>> - librte_crypto (v 1=>2)
>>   |- removed rte_cryptodev_create_unique_device_name API
>>   |- moved device naming to EAL
>>
>> - librte_ethdev (v 4=>5)
>>   |- rte_eth_dev_type is removed
>>   |- removed dev_type from rte_eth_dev_allocate API
>>   |- removed API rte_eth_dev_get_device_type
>>   |- removed API rte_eth_dev_get_addr_by_port
>>   |- removed API rte_eth_dev_get_port_by_addr
>>   |- removed rte_cryptodev_create_unique_device_name API
>>   |- moved device naming to EAL
>>
>> Also, deprecation notice from 16.07 has been removed and release notes for
>> 16.11 added.
>>
>> [1] http://dpdk.org/ml/archives/dev/2016-September/047087.html
>>
>> Signed-off-by: Shreyansh Jain 
> [...]
>> --- a/doc/guides/rel_notes/release_16_11.rst
>> +++ b/doc/guides/rel_notes/release_16_11.rst
>> @@ -149,6 +149,32 @@ Resolved Issues
>
> It is the "Resolved Issues" section.
> Please move in the "API Changes" section.

Ok.

>
>>  EAL
>>  ~~~
>>
>> +* **Improved device/driver heirarchy and generalized hotplugging**
>
> typo: hierarchy

Yes.

>
>> +  Device and driver relationship has been restructured by introducing 
>> generic
>> +  classes. This paves way for having PCI, VDEV and other device types as
>> +  just instantiated objects rather than classes in themselves. Hotplugging 
>> too
>> +  has been generalized into EAL so that ethernet or crypto devices can use 
>> the
>> +  common infrastructure.
>> +
>> +  * removed ``pmd_type`` as way of segragation of devices
>> +  * moved ``numa_node`` and ``devargs`` into ``rte_driver`` from
>> +``rte_pci_driver``. These can now be used by any instantiated object of
>> +``rte_driver``.
>> +  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
>> +  * renamed devinit/devuninit handlers to probe/remove to make it more
>> +semantically correct with respect to device<=>driver relationship
>> +  * moved hotplugging support to EAL. Hereafter, PCI and vdev can use the
>> +APIs ``rte_eal_dev_attach`` and ``rte_eal_dev_detach``.
>> +  * helpers and support macros have been renamed to make them more 
>> synonymous
>> +with their device types
>> +(e.g. ``PMD_REGISTER_DRIVER`` => ``DRIVER_REGISTER_PCI``)
>
> It is RTE_PMD_REGISTER_PCI

It seems my Friday is earlier than usual :(
I was the one who changed it and I completely forgot about it.

>
>> +  * Device naming functions have been generalized from ethdev and cryptodev
>> +to EAL. ``rte_eal_pci_device_name`` has been introduced for obtaining
>> +unique device name from PCI Domain-BDF description.
>> +  * Virtual device registration APIs have been added: 
>> ``rte_eal_vdrv_register``
>> +and ``rte_eal_vdrv_unregister``.
>
> Thanks
>

I am sending v4 soon.

-
Shreyansh


[dpdk-dev] [PATCH v3] eal: fix libabi macro for device generalization patches

2016-10-27 Thread Shreyansh Jain
rte_device/driver generalization patches [1] were merged without a change
in the LIBABIVER macro. This patches bumps the macro of affected libs.
(librte_eal was already bumped; libcryptodev and libetherdev have been
bumped).

Details of ABI/API changes:
- EAL (version not bumped)
  |- type field was removed from rte_driver
  |- rte_pci_device now embeds rte_device
  |- rte_pci_resource renamed to rte_mem_resource
  |- numa_node and devargs of rte_pci_driver is moved to rte_driver
  |- APIs for device hotplug (attach/detach) moved into EAL
  |- API rte_eal_pci_device_name added for PCI device naming
  |- vdev registration API introduced (rte_eal_vdrv_register,
  |  rte_eal_vdrv_unregister

- librte_crypto (v 1=>2)
  |- removed rte_cryptodev_create_unique_device_name API
  |- moved device naming to EAL

- librte_ethdev (v 4=>5)
  |- rte_eth_dev_type is removed
  |- removed dev_type from rte_eth_dev_allocate API
  |- removed API rte_eth_dev_get_device_type
  |- removed API rte_eth_dev_get_addr_by_port
  |- removed API rte_eth_dev_get_port_by_addr
  |- removed rte_cryptodev_create_unique_device_name API
  |- moved device naming to EAL

Also, deprecation notice from 16.07 has been removed and release notes for
16.11 added.

[1] http://dpdk.org/ml/archives/dev/2016-September/047087.html

Signed-off-by: Shreyansh Jain 
--
v3:
 - add API/ABI change info in commit log
 - fix library version change notification in release note
 - fix erroneous change to librte_eal version in v2
---
 doc/guides/rel_notes/deprecation.rst   | 12 
 doc/guides/rel_notes/release_16_11.rst | 30 --
 lib/librte_cryptodev/Makefile  |  2 +-
 lib/librte_ether/Makefile  |  2 +-
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index d5c1490..884a231 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -18,18 +18,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.

-* The ethdev hotplug API is going to be moved to EAL with a notification
-  mechanism added to crypto and ethdev libraries so that hotplug is now
-  available to both of them. This API will be stripped of the device arguments
-  so that it only cares about hotplugging.
-
-* Structures embodying pci and vdev devices are going to be reworked to
-  integrate new common rte_device / rte_driver objects (see
-  http://dpdk.org/ml/archives/dev/2016-January/031390.html).
-  ethdev and crypto libraries will then only handle those objects so that they
-  do not need to care about the kind of devices that are being used, making it
-  easier to add new buses later.
-
 * ABI changes are planned for 16.11 in the ``rte_mbuf`` structure: some fields
   may be reordered to facilitate the writing of ``data_off``, ``refcnt``, and
   ``nb_segs`` in one operation, because some platforms have an overhead if the
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index aa0c09a..5a5485b 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -149,6 +149,32 @@ Resolved Issues
 EAL
 ~~~

+* **Improved device/driver heirarchy and generalized hotplugging**
+
+  Device and driver relationship has been restructured by introducing generic
+  classes. This paves way for having PCI, VDEV and other device types as
+  just instantiated objects rather than classes in themselves. Hotplugging too
+  has been generalized into EAL so that ethernet or crypto devices can use the
+  common infrastructure.
+
+  * removed ``pmd_type`` as way of segragation of devices
+  * moved ``numa_node`` and ``devargs`` into ``rte_driver`` from
+``rte_pci_driver``. These can now be used by any instantiated object of
+``rte_driver``.
+  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
+  * renamed devinit/devuninit handlers to probe/remove to make it more
+semantically correct with respect to device<=>driver relationship
+  * moved hotplugging support to EAL. Hereafter, PCI and vdev can use the
+APIs ``rte_eal_dev_attach`` and ``rte_eal_dev_detach``.
+  * helpers and support macros have been renamed to make them more synonymous
+with their device types
+(e.g. ``PMD_REGISTER_DRIVER`` => ``DRIVER_REGISTER_PCI``)
+  * Device naming functions have been generalized from ethdev and cryptodev
+to EAL. ``rte_eal_pci_device_name`` has been introduced for obtaining
+unique device name from PCI Domain-BDF description.
+  * Virtual device registration APIs have been added: ``rte_eal_vdrv_register``
+and ``rte_eal_vdrv_unregister``.
+

 Drivers
 ~~~
@@ -232,11 +258,11 @@ The libraries prepended with a plus sign were incremented 
in this version.

 .. code-block:: diff

-

[dpdk-dev] [PATCH v2] eal: fix libabi macro for device generalization patches

2016-10-27 Thread Shreyansh Jain
On Wednesday 26 October 2016 08:53 PM, Thomas Monjalon wrote:
> 2016-10-26 15:25, Ferruh Yigit:
>> eal version seems already increased for this release, 2 => 3, in:
>> d7e61ad3ae36 ("log: remove deprecated history dump")
>
> Yes thanks.
>
>> So NO need to increase it again, sorry for late notice, I just
>> recognized it.
>> Only librte_ether and librte_cryptodev requires the increase.
>
> Please could you also explain in the commit message that:
> - EAL was already bumped
> - what is the breakage in ethdev
> - what is the breakage in cryptodev

Indeed. Will do in v3

>
> Thanks
>

-
Shreyansh


[dpdk-dev] [PATCH v2] eal: fix libabi macro for device generalization patches

2016-10-27 Thread Shreyansh Jain
Hello Ferruh,

On Wednesday 26 October 2016 07:55 PM, Ferruh Yigit wrote:
> Hi Shreyansh,
>
> On 10/26/2016 2:12 PM, Shreyansh Jain wrote:
>> On Wednesday 26 October 2016 06:30 PM, Shreyansh Jain wrote:
>>> rte_device/driver generalization patches [1] were merged without a change
>>> in the LIBABIVER macro. This patches bumps the macro of affected libs.
>>>
>>> Also, deprecation notice from 16.07 has been removed and release notes for
>>> 16.11 added.
>>>
>>> Signed-off-by: Shreyansh Jain 
>>> --
>>> v2:
>>>  - Mark bumped libraries in release_16_11.rst file
>>>  - change code symbol names from text to code layout
>>>
>>> ---
>
> <...>
>
>>>  .. code-block:: diff
>>>
>>> - libethdev.so.4
>>> +   + libethdev.so.4
>>
>> Just noticed:
>> Should the '4' here reflect the current LIBABIVER number?
>> If so, I will send this patch again.
>
> Yes, as you guessed, it should be:
> - libethdev.so.4
> +   + libethdev.so.5
>
> <...>
>
>>> diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
>>> b/lib/librte_eal/bsdapp/eal/Makefile
>>> index a15b762..122798c 100644
>>> --- a/lib/librte_eal/bsdapp/eal/Makefile
>>> +++ b/lib/librte_eal/bsdapp/eal/Makefile
>>> @@ -48,7 +48,7 @@ LDLIBS += -lgcc_s
>>>
>>>  EXPORT_MAP := rte_eal_version.map
>>>
>>> -LIBABIVER := 3
>>> +LIBABIVER := 4
>
> eal version seems already increased for this release, 2 => 3, in:
> d7e61ad3ae36 ("log: remove deprecated history dump")
>
> So NO need to increase it again, sorry for late notice, I just
> recognized it.
> Only librte_ether and librte_cryptodev requires the increase.

Thanks for clearing this.
I will bump librte_ether and librte_cryptodev and send across v3.

>
> <...>
>
> Thanks,
> ferruh
>
>

The LIBABI check script is really helpful. I wish I had run that for 
rte_driver/device patchset. Thanks for that info, though.

-
Shreyansh


[dpdk-dev] [PATCH v2] eal: fix libabi macro for device generalization patches

2016-10-26 Thread Shreyansh Jain
On Wednesday 26 October 2016 06:30 PM, Shreyansh Jain wrote:
> rte_device/driver generalization patches [1] were merged without a change
> in the LIBABIVER macro. This patches bumps the macro of affected libs.
>
> Also, deprecation notice from 16.07 has been removed and release notes for
> 16.11 added.
>
> Signed-off-by: Shreyansh Jain 
> --
> v2:
>  - Mark bumped libraries in release_16_11.rst file
>  - change code symbol names from text to code layout
>
> ---
>  doc/guides/rel_notes/deprecation.rst   | 12 
>  doc/guides/rel_notes/release_16_11.rst | 21 +++--
>  lib/librte_cryptodev/Makefile  |  2 +-
>  lib/librte_eal/bsdapp/eal/Makefile |  2 +-
>  lib/librte_eal/linuxapp/eal/Makefile   |  2 +-
>  lib/librte_ether/Makefile  |  2 +-
>  6 files changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/doc/guides/rel_notes/deprecation.rst 
> b/doc/guides/rel_notes/deprecation.rst
> index d5c1490..884a231 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -18,18 +18,6 @@ Deprecation Notices
>``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
>segments limit to be transmitted by device for TSO/non-TSO packets.
>
> -* The ethdev hotplug API is going to be moved to EAL with a notification
> -  mechanism added to crypto and ethdev libraries so that hotplug is now
> -  available to both of them. This API will be stripped of the device 
> arguments
> -  so that it only cares about hotplugging.
> -
> -* Structures embodying pci and vdev devices are going to be reworked to
> -  integrate new common rte_device / rte_driver objects (see
> -  http://dpdk.org/ml/archives/dev/2016-January/031390.html).
> -  ethdev and crypto libraries will then only handle those objects so that 
> they
> -  do not need to care about the kind of devices that are being used, making 
> it
> -  easier to add new buses later.
> -
>  * ABI changes are planned for 16.11 in the ``rte_mbuf`` structure: some 
> fields
>may be reordered to facilitate the writing of ``data_off``, ``refcnt``, and
>``nb_segs`` in one operation, because some platforms have an overhead if 
> the
> diff --git a/doc/guides/rel_notes/release_16_11.rst 
> b/doc/guides/rel_notes/release_16_11.rst
> index 26cdd62..2d5636c 100644
> --- a/doc/guides/rel_notes/release_16_11.rst
> +++ b/doc/guides/rel_notes/release_16_11.rst
> @@ -149,6 +149,23 @@ Resolved Issues
>  EAL
>  ~~~
>
> +* **Improved device/driver heirarchy and generalized hotplugging**
> +
> +  Device and driver relationship has been restructured by introducing generic
> +  classes. This paves way for having PCI, VDEV and other device types as
> +  just instantiated objects rather than classes in themselves. Hotplugging 
> too
> +  has been generalized into EAL so that ethernet or crypto devices can use 
> the
> +  common infrastructure.
> +
> +  * removed ``pmd_type`` as way of segragation of devices
> +  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
> +  * renamed devinit/devuninit handlers to probe/remove to make it more
> +semantically correct with respect to device<=>driver relationship
> +  * moved hotplugging support to EAL
> +  * helpers and support macros have been renamed to make them more synonymous
> +with their device types
> +(e.g. ``PMD_REGISTER_DRIVER`` => ``DRIVER_REGISTER_PCI``)
> +
>
>  Drivers
>  ~~~
> @@ -232,11 +249,11 @@ The libraries prepended with a plus sign were 
> incremented in this version.
>
>  .. code-block:: diff
>
> - libethdev.so.4
> +   + libethdev.so.4

Just noticed:
Should the '4' here reflect the current LIBABIVER number?
If so, I will send this patch again.

>   librte_acl.so.2
>   librte_cfgfile.so.2
>   librte_cmdline.so.2
> - librte_cryptodev.so.1
> +   + librte_cryptodev.so.1
>   librte_distributor.so.1
> + librte_eal.so.3
>   librte_hash.so.2
> diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile
> index 314a046..aebf5d9 100644
> --- a/lib/librte_cryptodev/Makefile
> +++ b/lib/librte_cryptodev/Makefile
> @@ -34,7 +34,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
>  LIB = librte_cryptodev.a
>
>  # library version
> -LIBABIVER := 1
> +LIBABIVER := 2
>
>  # build flags
>  CFLAGS += -O3
> diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
> b/lib/librte_eal/bsdapp/eal/Makefile
> index a15b762..122798c 100644
> --- a/lib/librte_eal/bsdapp/eal/Makefile
> +++ b/lib/librte_eal/bsdapp/eal/Makefile
> @@ -48,7 +48,7 @@ LDLIBS += -lgcc_s
>
>  EXPORT_MAP := rte_eal_version.map
>
> -LIBABIV

[dpdk-dev] [PATCH] eal: fix libabi macro for device generalization patches

2016-10-26 Thread Shreyansh Jain
On Wednesday 26 October 2016 06:08 PM, Shreyansh Jain wrote:
> rte_device/driver generalization patches [1] were merged without a change
> in the LIBABIVER macro. This patches bumps the macro of affected libs.
>
> Also, deprecation notice from 16.07 has been removed and release notes for
> 16.11 added.
>
> [1] http://dpdk.org/ml/archives/dev/2016-September/047087.html
>
> Signed-off-by: Shreyansh Jain 
> ---
>  doc/guides/rel_notes/deprecation.rst   | 12 
>  doc/guides/rel_notes/release_16_11.rst | 16 
>  lib/librte_cryptodev/Makefile  |  2 +-
>  lib/librte_eal/bsdapp/eal/Makefile |  2 +-
>  lib/librte_eal/linuxapp/eal/Makefile   |  2 +-
>  lib/librte_ether/Makefile  |  2 +-
>  6 files changed, 20 insertions(+), 16 deletions(-)
>

Self-NACK.
missed updating the libraries impacted in the list of libraries.
Sent v2.


[dpdk-dev] [PATCH v2] eal: fix libabi macro for device generalization patches

2016-10-26 Thread Shreyansh Jain
rte_device/driver generalization patches [1] were merged without a change
in the LIBABIVER macro. This patches bumps the macro of affected libs.

Also, deprecation notice from 16.07 has been removed and release notes for
16.11 added.

Signed-off-by: Shreyansh Jain 
--
v2:
 - Mark bumped libraries in release_16_11.rst file
 - change code symbol names from text to code layout

---
 doc/guides/rel_notes/deprecation.rst   | 12 
 doc/guides/rel_notes/release_16_11.rst | 21 +++--
 lib/librte_cryptodev/Makefile  |  2 +-
 lib/librte_eal/bsdapp/eal/Makefile |  2 +-
 lib/librte_eal/linuxapp/eal/Makefile   |  2 +-
 lib/librte_ether/Makefile  |  2 +-
 6 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index d5c1490..884a231 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -18,18 +18,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.

-* The ethdev hotplug API is going to be moved to EAL with a notification
-  mechanism added to crypto and ethdev libraries so that hotplug is now
-  available to both of them. This API will be stripped of the device arguments
-  so that it only cares about hotplugging.
-
-* Structures embodying pci and vdev devices are going to be reworked to
-  integrate new common rte_device / rte_driver objects (see
-  http://dpdk.org/ml/archives/dev/2016-January/031390.html).
-  ethdev and crypto libraries will then only handle those objects so that they
-  do not need to care about the kind of devices that are being used, making it
-  easier to add new buses later.
-
 * ABI changes are planned for 16.11 in the ``rte_mbuf`` structure: some fields
   may be reordered to facilitate the writing of ``data_off``, ``refcnt``, and
   ``nb_segs`` in one operation, because some platforms have an overhead if the
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index 26cdd62..2d5636c 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -149,6 +149,23 @@ Resolved Issues
 EAL
 ~~~

+* **Improved device/driver heirarchy and generalized hotplugging**
+
+  Device and driver relationship has been restructured by introducing generic
+  classes. This paves way for having PCI, VDEV and other device types as
+  just instantiated objects rather than classes in themselves. Hotplugging too
+  has been generalized into EAL so that ethernet or crypto devices can use the
+  common infrastructure.
+
+  * removed ``pmd_type`` as way of segragation of devices
+  * added ``rte_device`` class and all PCI and VDEV devices inherit from it
+  * renamed devinit/devuninit handlers to probe/remove to make it more
+semantically correct with respect to device<=>driver relationship
+  * moved hotplugging support to EAL
+  * helpers and support macros have been renamed to make them more synonymous
+with their device types
+(e.g. ``PMD_REGISTER_DRIVER`` => ``DRIVER_REGISTER_PCI``)
+

 Drivers
 ~~~
@@ -232,11 +249,11 @@ The libraries prepended with a plus sign were incremented 
in this version.

 .. code-block:: diff

- libethdev.so.4
+   + libethdev.so.4
  librte_acl.so.2
  librte_cfgfile.so.2
  librte_cmdline.so.2
- librte_cryptodev.so.1
+   + librte_cryptodev.so.1
  librte_distributor.so.1
+ librte_eal.so.3
  librte_hash.so.2
diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile
index 314a046..aebf5d9 100644
--- a/lib/librte_cryptodev/Makefile
+++ b/lib/librte_cryptodev/Makefile
@@ -34,7 +34,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_cryptodev.a

 # library version
-LIBABIVER := 1
+LIBABIVER := 2

 # build flags
 CFLAGS += -O3
diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index a15b762..122798c 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -48,7 +48,7 @@ LDLIBS += -lgcc_s

 EXPORT_MAP := rte_eal_version.map

-LIBABIVER := 3
+LIBABIVER := 4

 # specific to bsdapp exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c
diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index 4e206f0..4ad7c85 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -37,7 +37,7 @@ ARCH_DIR ?= $(RTE_ARCH)
 EXPORT_MAP := rte_eal_version.map
 VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)

-LIBABIVER := 3
+LIBABIVER := 4

 VPATH += $(RTE_SDK)/lib/librte_eal/common

diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index 488b7c8..bc2e5f6 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)

 EXPORT_MAP := rte_ether_version.map

-

[dpdk-dev] [PATCH] eal: fix libabi macro for device generalization patches

2016-10-26 Thread Shreyansh Jain
rte_device/driver generalization patches [1] were merged without a change
in the LIBABIVER macro. This patches bumps the macro of affected libs.

Also, deprecation notice from 16.07 has been removed and release notes for
16.11 added.

[1] http://dpdk.org/ml/archives/dev/2016-September/047087.html

Signed-off-by: Shreyansh Jain 
---
 doc/guides/rel_notes/deprecation.rst   | 12 
 doc/guides/rel_notes/release_16_11.rst | 16 
 lib/librte_cryptodev/Makefile  |  2 +-
 lib/librte_eal/bsdapp/eal/Makefile |  2 +-
 lib/librte_eal/linuxapp/eal/Makefile   |  2 +-
 lib/librte_ether/Makefile  |  2 +-
 6 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index d5c1490..884a231 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -18,18 +18,6 @@ Deprecation Notices
   ``nb_seg_max`` and ``nb_mtu_seg_max`` providing information about number of
   segments limit to be transmitted by device for TSO/non-TSO packets.

-* The ethdev hotplug API is going to be moved to EAL with a notification
-  mechanism added to crypto and ethdev libraries so that hotplug is now
-  available to both of them. This API will be stripped of the device arguments
-  so that it only cares about hotplugging.
-
-* Structures embodying pci and vdev devices are going to be reworked to
-  integrate new common rte_device / rte_driver objects (see
-  http://dpdk.org/ml/archives/dev/2016-January/031390.html).
-  ethdev and crypto libraries will then only handle those objects so that they
-  do not need to care about the kind of devices that are being used, making it
-  easier to add new buses later.
-
 * ABI changes are planned for 16.11 in the ``rte_mbuf`` structure: some fields
   may be reordered to facilitate the writing of ``data_off``, ``refcnt``, and
   ``nb_segs`` in one operation, because some platforms have an overhead if the
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index 26cdd62..c3f3bd9 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -149,6 +149,22 @@ Resolved Issues
 EAL
 ~~~

+* **Improved device/driver heirarchy and generalized hotplugging**
+
+  Device and driver relationship has been restructured by introducing generic
+  classes. This paves way for having PCI, VDEV and other device types as
+  just instantiated objects rather than classes in themselves. Hotplugging too
+  has been generalized into EAL so that ethernet or cryptodevices can use the
+  common infrastructure.
+
+  * removed pmd_type as way of segragation of devices
+  * added rte_device class and all PCI and VDEV devices inherit from it
+  * renamed devinit/devuninit handlers to probe/remove to make it more
+semantically correct with respect to device<=>driver relationship
+  * moved hotplugging support to EAL
+  * helpers and support macros have been renamed to make them more synonymous
+with their device types (e.g. PMD_REGISTER_DRIVER => DRIVER_REGISTER_PCI)
+

 Drivers
 ~~~
diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile
index 314a046..aebf5d9 100644
--- a/lib/librte_cryptodev/Makefile
+++ b/lib/librte_cryptodev/Makefile
@@ -34,7 +34,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 LIB = librte_cryptodev.a

 # library version
-LIBABIVER := 1
+LIBABIVER := 2

 # build flags
 CFLAGS += -O3
diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index a15b762..122798c 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -48,7 +48,7 @@ LDLIBS += -lgcc_s

 EXPORT_MAP := rte_eal_version.map

-LIBABIVER := 3
+LIBABIVER := 4

 # specific to bsdapp exec-env
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c
diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index 4e206f0..4ad7c85 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -37,7 +37,7 @@ ARCH_DIR ?= $(RTE_ARCH)
 EXPORT_MAP := rte_eal_version.map
 VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR)

-LIBABIVER := 3
+LIBABIVER := 4

 VPATH += $(RTE_SDK)/lib/librte_eal/common

diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index 488b7c8..bc2e5f6 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)

 EXPORT_MAP := rte_ether_version.map

-LIBABIVER := 4
+LIBABIVER := 5

 SRCS-y += rte_ethdev.c

-- 
2.7.4



[dpdk-dev] [PATCH v10 11/25] eal/pci: helpers for device name parsing/update

2016-10-26 Thread Shreyansh Jain
Hello Reshma,

On Tuesday 25 October 2016 09:19 PM, Pattan, Reshma wrote:
> Hi Shreyansh,
>
>> -Original Message-
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Shreyansh Jain
>> Sent: Friday, September 16, 2016 5:30 AM
>> To: dev at dpdk.org
>> Cc: viktorin at rehivetech.com; David Marchand ;
>> hemant.agrawal at nxp.com; Thomas Monjalon
>> ; Shreyansh Jain 
>> Subject: [dpdk-dev] [PATCH v10 11/25] eal/pci: helpers for device name
>> parsing/update
>>
>> From: David Marchand 
>>
>> - Move rte_eth_dev_create_unique_device_name() from ether/rte_ethdev.c to
>>   common/include/rte_pci.h as rte_eal_pci_device_name(). Being a common
>>   method, can be used across crypto/net PCI PMDs.
>> - Remove crypto specific routine and fallback to common name function.
>> - Introduce a eal private Update function for PCI device naming.
>>
>> Signed-off-by: David Marchand 
>> [Shreyansh: Merge crypto/pci helper patches]
>> Signed-off-by: Shreyansh Jain 
>> ---
>>  lib/librte_cryptodev/rte_cryptodev.c| 27 +++---
>>  lib/librte_eal/bsdapp/eal/eal_pci.c | 49
>> +
>>  lib/librte_eal/common/eal_private.h | 13 +
>>  lib/librte_eal/common/include/rte_pci.h | 24 
>>  lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +
>>  lib/librte_ether/rte_ethdev.c   | 24 +++-
>>  6 files changed, 107 insertions(+), 43 deletions(-)
>>
>> diff --git a/lib/librte_cryptodev/rte_cryptodev.c
>> b/lib/librte_cryptodev/rte_cryptodev.c
>> index 2a3b649..c81e366 100644
>> --- a/lib/librte_cryptodev/rte_cryptodev.c
>> +++ b/lib/librte_cryptodev/rte_cryptodev.c
>> @@ -365,23 +365,6 @@ rte_cryptodev_pmd_allocate(const char *name, int
>> socket_id)
>>  return cryptodev;
>>  }
>>
>>   *
>>   * This function is private to EAL.
>> diff --git a/lib/librte_eal/common/include/rte_pci.h
>> b/lib/librte_eal/common/include/rte_pci.h
>> index cf81898..e1f695f 100644
>> --- a/lib/librte_eal/common/include/rte_pci.h
>> +++ b/lib/librte_eal/common/include/rte_pci.h
>> @@ -82,6 +82,7 @@ extern "C" {
>>  /** Formatting string for PCI device identifier: Ex: :00:01.0 */  
>> #define
>> PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
>> +#define PCI_PRI_STR_SIZE sizeof(":XX:XX.X")
>>
>>  /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
>> #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 @@ -308,6
>>
>> +static inline void
>> +rte_eal_pci_device_name(const struct rte_pci_addr *addr,
>> +char *output, size_t size)
>> +{
>> +RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
>> +RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
>> +addr->domain, addr->bus,
>> +addr->devid, addr->function) >= 0); }
>> +
>>
>> +int
>> +pci_update_device(const struct rte_pci_addr *addr) {
>> +char filename[PATH_MAX];
>> +
>> +snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
>> + 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);
>> +}
>> +
>
>
> Earlier device names were created in the format "bus:deviceid.function" as 
> per the below ethdev API.
> Now after above new eal API the name format is "domain:bus:deviceid.func" was 
> that intentional  and why is that so.

Yes, this is intentional.
It is to bring the naming in sync with the device name being used for 
scanning on the bus (/sys/bus/pci/devices/:BB:CC.D/).
Also, it was proposed in a separate patch [1] but merged in this series.

[1] http://dpdk.org/ml/archives/dev/2016-July/044614.html

(Just as a note: I am not the original author of this patch but above is 
what I understood and acked it).

>
>> -static int
>> -rte_eth_dev_create_unique_device_name(char *name, size_t size,
>> -struct rte_pci_device *pci_dev)
>> -{
>> -int ret;
>> -
>> -ret = snprintf(name, size, "%d:%d.%d",
>> -pci_dev->addr.bus, pci_dev->addr.devid,
>> -pci_dev->addr.function);
>> -if (ret < 0)
>> -return ret;
>> -return 0;
>> -}
>> -
>

-
Shreyansh


[dpdk-dev] [PATCH v5 06/21] eal/soc: introduce very essential SoC infra definitions

2016-10-25 Thread Shreyansh Jain
On Tuesday 25 October 2016 11:06 AM, Shreyansh Jain wrote:
> Hello Jan,
>
> On Monday 24 October 2016 09:51 PM, Jan Viktorin wrote:
>> On Mon, 24 Oct 2016 17:29:25 +0530
>> Shreyansh Jain  wrote:
>>
>>> From: Jan Viktorin 
>>>
>>> Define initial structures and functions for the SoC infrastructure.
>>> This patch supports only a very minimal functions for now.
>>> More features will be added in the following commits.
>>>
>>> Includes rte_device/rte_driver inheritance of
>>> rte_soc_device/rte_soc_driver.
>>>
>>> Signed-off-by: Jan Viktorin 
>>> Signed-off-by: Shreyansh Jain 
>>> Signed-off-by: Hemant Agrawal 
>>> ---
>>>  app/test/Makefile   |   1 +
>>>  app/test/test_soc.c |  90 +
>>>  lib/librte_eal/common/Makefile  |   2 +-
>>>  lib/librte_eal/common/eal_private.h |   4 +
>>>  lib/librte_eal/common/include/rte_soc.h | 138
>>> 
>>>  5 files changed, 234 insertions(+), 1 deletion(-)
>>>  create mode 100644 app/test/test_soc.c
>>>  create mode 100644 lib/librte_eal/common/include/rte_soc.h
>>>
>>> diff --git a/app/test/Makefile b/app/test/Makefile
>>
>> [...]
>>
>>> +++ b/lib/librte_eal/common/include/rte_soc.h
>>> @@ -0,0 +1,138 @@
>>
>> [...]
>>
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +
>>> +struct rte_soc_id {
>>> +const char *compatible; /**< OF compatible specification */
>>> +uint64_t priv_data; /**< SoC Driver specific data */
>>
>> Do you expect this to be a pointer?
>
> A 64 bit entry, which can be typecasted to pointer by implementations,
> if required. Or, it might as well remain as a 64bit entry as ID.
>
>>
>>> +};
>>> +
>>
>> [...]
>>
>>> +
>>> +/**
>>> + * Initialization function for the driver called during SoC probing.
>>> + */
>>> +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct
>>> rte_soc_device *);
>>> +
>>> +/**
>>> + * Uninitialization function for the driver called during hotplugging.
>>> + */
>>> +typedef int (soc_devuninit_t)(struct rte_soc_device *);
>>> +
>>> +/**
>>> + * A structure describing a SoC driver.
>>> + */
>>> +struct rte_soc_driver {
>>> +TAILQ_ENTRY(rte_soc_driver) next;  /**< Next in list */
>>> +struct rte_driver driver;  /**< Inherit core driver. */
>>> +soc_devinit_t *devinit;/**< Device initialization */
>>> +soc_devuninit_t *devuninit;/**< Device uninitialization */
>>
>> Shouldn't those functions be named probe/remove?
>
> Indeed. I think there was a comment on v4 as well - I thought I had
> fixed it but it seems I have mixed up my patches. I will send v6
> immediately with this fixed. Thanks for pointing out.

Ah, I just noticed that I did change it - but in Patch 11. Ideally, it 
should have been done here itself. My bad.

>
>>
>>> +const struct rte_soc_id *id_table; /**< ID table, NULL
>>> terminated */
>>> +};
>>> +
>>
>> [...]
>>
>>> +#endif
>>
>>
>>
>
> -
> Shreyansh
>

-
Shreyansh


[dpdk-dev] mbuf changes

2016-10-25 Thread Shreyansh Jain
On Monday 24 October 2016 09:55 PM, Bruce Richardson wrote:
> On Mon, Oct 24, 2016 at 04:11:33PM +, Wiles, Keith wrote:
>>
>>> On Oct 24, 2016, at 10:49 AM, Morten Br?rup  
>>> wrote:
>>>
>>> First of all: Thanks for a great DPDK Userspace 2016!
>>>
>>>
>>>
>>> Continuing the Userspace discussion about Olivier Matz?s proposed mbuf 
>>> changes...
>
> Thanks for keeping the discussion going!
>>>
>>>
>>>
>>> 1.
>>>
>>> Stephen Hemminger had a noteworthy general comment about keeping metadata 
>>> for the NIC in the appropriate section of the mbuf: Metadata generated by 
>>> the NIC?s RX handler belongs in the first cache line, and metadata required 
>>> by the NIC?s TX handler belongs in the second cache line. This also means 
>>> that touching the second cache line on ingress should be avoided if 
>>> possible; and Bruce Richardson mentioned that for this reason m->next was 
>>> zeroed on free().
>>>
> Thinking about it, I suspect there are more fields we can reset on free
> to save time on alloc. Refcnt, as discussed below is one of them, but so
> too could be the nb_segs field and possibly others.
>
>>>
>>>
>>> 2.
>>>
>>> There seemed to be consensus that the size of m->refcnt should match the 
>>> size of m->port because a packet could be duplicated on all physical ports 
>>> for L3 multicast and L2 flooding.
>>>
>>> Furthermore, although a single physical machine (i.e. a single server) with 
>>> 255 physical ports probably doesn?t exist, it might contain more than 255 
>>> virtual machines with a virtual port each, so it makes sense extending 
>>> these mbuf fields from 8 to 16 bits.
>>
>> I thought we also talked about removing the m->port from the mbuf as it is 
>> not really needed.
>>
> Yes, this was mentioned, and also the option of moving the port value to
> the second cacheline, but it appears that NXP are using the port value
> in their NIC drivers for passing in metadata, so we'd need their
> agreement on any move (or removal).

I am not sure where NXP's NIC came into picture on this, but now that it 
is highlighted, this field is required for libevent implementation [1].

A scheduler sending an event, which can be a packet, would only have 
information of a flow_id. From this matching it back to a port, without 
mbuf->port, would be very difficult (costly). There may be way around 
this but at least in current proposal I think port would be important to 
have - even if in second cache line.

But, off the top of my head, as of now it is not being used for any 
specific purpose in NXP's PMD implementation.

Even the SoC patches don't necessarily rely on it except using it 
because it is available.

@Bruce: where did you get the NXP context here from?

[1] http://dpdk.org/ml/archives/dev/2016-October/048592.html

>
>>>
>>>
>>>
>>> 3.
>>>
>>> Someone (Bruce Richardson?) suggested moving m->refcnt and m->port to the 
>>> second cache line, which then generated questions from the audience about 
>>> the real life purpose of m->port, and if m->port could be removed from the 
>>> mbuf structure.
>>>
>>>
>>>
>>> 4.
>>>
>>> I suggested using offset -1 for m->refcnt, so m->refcnt becomes 0 on first 
>>> allocation. This is based on the assumption that other mbuf fields must be 
>>> zeroed at alloc()/free() anyway, so zeroing m->refcnt is cheaper than 
>>> setting it to 1.
>>>
>>> Furthermore (regardless of m->refcnt offset), I suggested that it is not 
>>> required to modify m->refcnt when allocating and freeing the mbuf, thus 
>>> saving one write operation on both alloc() and free(). However, this 
>>> assumes that m->refcnt debugging, e.g. underrun detection, is not required.
>
> I don't think it really matters what sentinal value is used for the
> refcnt because it can't be blindly assigned on free like other fields.
> However, I think 0 as first reference value becomes more awkward
> than 1, because we need to deal with underflow. Consider the situation
> where we have two references to the mbuf, so refcnt is 1, and both are
> freed at the same time. Since the refcnt is not-zero, then both cores
> will do an atomic decrement simultaneously giving a refcnt of -1. We can
> then set this back to zero before freeing, however, I'd still prefer to
> have refcnt be an accurate value so that it always stays positive, and
> we can still set it to "one" on free to avoid having to set on alloc.
>
> Also, if we set refcnt on free rather than alloc, it does set itself up
> as a good candidate for moving to the second cacheline. Fast-path
> processing does not normally update the value.
>
>>>
>>>
>>>
>>> 5.
>>>
>>> And here?s something new to think about:
>>>
>>> m->next already reveals if there are more segments to a packet. Which 
>>> purpose does m->nb_segs serve that is not already covered by m->next?
>
> It is duplicate info, but nb_segs can be used to check the validity of
> the next pointer without having to read the second mbuf cacheline.
>
> Whether it's worth having is something I'm happy enough to 

[dpdk-dev] [PATCH v5 06/21] eal/soc: introduce very essential SoC infra definitions

2016-10-25 Thread Shreyansh Jain
Hello Jan,

On Monday 24 October 2016 09:51 PM, Jan Viktorin wrote:
> On Mon, 24 Oct 2016 17:29:25 +0530
> Shreyansh Jain  wrote:
>
>> From: Jan Viktorin 
>>
>> Define initial structures and functions for the SoC infrastructure.
>> This patch supports only a very minimal functions for now.
>> More features will be added in the following commits.
>>
>> Includes rte_device/rte_driver inheritance of
>> rte_soc_device/rte_soc_driver.
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> Signed-off-by: Hemant Agrawal 
>> ---
>>  app/test/Makefile   |   1 +
>>  app/test/test_soc.c |  90 +
>>  lib/librte_eal/common/Makefile  |   2 +-
>>  lib/librte_eal/common/eal_private.h |   4 +
>>  lib/librte_eal/common/include/rte_soc.h | 138 
>> 
>>  5 files changed, 234 insertions(+), 1 deletion(-)
>>  create mode 100644 app/test/test_soc.c
>>  create mode 100644 lib/librte_eal/common/include/rte_soc.h
>>
>> diff --git a/app/test/Makefile b/app/test/Makefile
>
> [...]
>
>> +++ b/lib/librte_eal/common/include/rte_soc.h
>> @@ -0,0 +1,138 @@
>
> [...]
>
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +
>> +struct rte_soc_id {
>> +const char *compatible; /**< OF compatible specification */
>> +uint64_t priv_data; /**< SoC Driver specific data */
>
> Do you expect this to be a pointer?

A 64 bit entry, which can be typecasted to pointer by implementations, 
if required. Or, it might as well remain as a 64bit entry as ID.

>
>> +};
>> +
>
> [...]
>
>> +
>> +/**
>> + * Initialization function for the driver called during SoC probing.
>> + */
>> +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device 
>> *);
>> +
>> +/**
>> + * Uninitialization function for the driver called during hotplugging.
>> + */
>> +typedef int (soc_devuninit_t)(struct rte_soc_device *);
>> +
>> +/**
>> + * A structure describing a SoC driver.
>> + */
>> +struct rte_soc_driver {
>> +TAILQ_ENTRY(rte_soc_driver) next;  /**< Next in list */
>> +struct rte_driver driver;  /**< Inherit core driver. */
>> +soc_devinit_t *devinit;/**< Device initialization */
>> +soc_devuninit_t *devuninit;/**< Device uninitialization */
>
> Shouldn't those functions be named probe/remove?

Indeed. I think there was a comment on v4 as well - I thought I had 
fixed it but it seems I have mixed up my patches. I will send v6 
immediately with this fixed. Thanks for pointing out.

>
>> +const struct rte_soc_id *id_table; /**< ID table, NULL terminated */
>> +};
>> +
>
> [...]
>
>> +#endif
>
>
>

-
Shreyansh


  1   2   3   4   5   >