[dpdk-dev] [PATCH 0/5] add external mempool manager

2016-01-29 Thread Hunt, David
On 28/01/2016 17:26, Jerin Jacob wrote:
> On Tue, Jan 26, 2016 at 05:25:50PM +, David Hunt wrote:
>> Hi all on the list.
>>
>> Here's a proposed patch for an external mempool manager
>>
>> The External Mempool Manager is an extension to the mempool API that allows
>> users to add and use an external mempool manager, which allows external 
>> memory
>> subsystems such as external hardware memory management systems and software
>> based memory allocators to be used with DPDK.
>
> I like this approach.It will be useful for external hardware memory
> pool managers.
>
> BTW, Do you encounter any performance impact on changing to function
> pointer based approach?

Jerin,
Thanks for your comments.

The performance impacts I've seen depends on whether I'm using an object 
cache for the mempool or not. Without object cache, I see between 0-10% 
degradation. With object cache, I see a slight performance gain of 
between 0-5%. But that will most likely vary from system to system.

>> The existing API to the internal DPDK mempool manager will remain unchanged
>> and will be backward compatible.
>>
>> There are two aspects to external mempool manager.
>>1. Adding the code for your new mempool handler. This is achieved by 
>> adding a
>>   new mempool handler source file into the librte_mempool library, and
>>   using the REGISTER_MEMPOOL_HANDLER macro.
>>2. Using the new API to call rte_mempool_create_ext to create a new 
>> mempool
>>   using the name parameter to identify which handler to use.
>>
>> New API calls added
>>   1. A new mempool 'create' function which accepts mempool handler name.
>>   2. A new mempool 'rte_get_mempool_handler' function which accepts mempool
>>  handler name, and returns the index to the relevant set of callbacks for
>>  that mempool handler
>>
>> Several external mempool managers may be used in the same application. A new
>> mempool can then be created by using the new 'create' function, providing the
>> mempool handler name to point the mempool to the relevant mempool manager
>> callback structure.
>>
>> The old 'create' function can still be called by legacy programs, and will
>> internally work out the mempool handle based on the flags provided (single
>> producer, single consumer, etc). By default handles are created internally to
>> implement the built-in DPDK mempool manager and mempool types.
>>
>> The external mempool manager needs to provide the following functions.
>>   1. alloc - allocates the mempool memory, and adds each object onto a 
>> ring
>>   2. put   - puts an object back into the mempool once an application has
>>  finished with it
>>   3. get   - gets an object from the mempool for use by the application
>>   4. get_count - gets the number of available objects in the mempool
>>   5. free  - frees the mempool memory
>>
>> Every time a get/put/get_count is called from the application/PMD, the
>> callback for that mempool is called. These functions are in the fastpath,
>> and any unoptimised handlers may limit performance.
>>
>> The new APIs are as follows:
>>
>> 1. rte_mempool_create_ext
>>
>> struct rte_mempool *
>> rte_mempool_create_ext(const char * name, unsigned n,
>>  unsigned cache_size, unsigned private_data_size,
>>  int socket_id, unsigned flags,
>>  const char * handler_name);
>>
>> 2. rte_get_mempool_handler
>>
>> int16_t
>> rte_get_mempool_handler(const char *name);
>
> Do we need above public API as, in any case we need rte_mempool* pointer to
> operate on mempools(which has the index anyway)?
>
> May a similar functional API with different name/return will be
> better to figure out, given "name" registered or not in ethernet driver
> which has dependency on a particular HW pool manager.

Good point. An earlier revision required getting the index first, then 
passing that to the create_ext call. Now that the call is by name, the 
'get' is mostly redundant. As you suggest, we may need an API for 
checking the existence of a particular manager/handler. Then again, we 
could always return an error from the create_ext api if it fails to find 
that handler. I'll remove the 'get' for the moment.

Thanks,
David.









[dpdk-dev] [PATCH 0/9] prepare for rte_device / rte_driver

2016-01-29 Thread David Marchand
Following discussions with Jan [1] and some cleanup I started on pci code,
here is a patchset that reworks pdev drivers registration and hotplug api.

The structures changes mentioned in [1] are still to be done, but at least,
I think we are one step closer to it.

Before this patchset, rte_driver .init semantics differed whether it
concerned a pdev or a vdev driver:
- for vdev, it actually meant that a devargs is given to the driver so
  that it creates ethdev / crypto objects, so it was a probing action
- for pdev, it only registered the driver triggering no ethdev / crypto
  objects

Patches 1 to 3 convert all existing pdev drivers into pci drivers and move
their registration in constructors.

Patch 4 might be of interest to Chelsio guys, following a regression they
reported [2].

Patches 5 and 6 align pci drivers and vdev drivers init.

Patches 7 to 9 move hotplug where it belongs.
I did not test patch 8 on FreeBSD (did not even compile it, for now).


[1] http://dpdk.org/ml/archives/dev/2016-January/031390.html
[2] http://dpdk.org/ml/archives/dev/2015-November/028289.html

Regards, 
-- 
David Marchand

David Marchand (9):
  pci: no need for dynamic tailq init
  pci: register all pdev as pci drivers
  drivers: no more pdev drivers
  eal/linux: move back interrupt thread init before setting affinity
  eal: get rid of pmd type
  eal: initialize vdevs right next to pci devices
  pci: add a helper for device name
  pci: add a helper to refresh a device
  eal: relocate hotplug code from ethdev

 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c  |   2 +
 drivers/crypto/qat/rte_qat_cryptodev.c  |  18 +-
 drivers/net/af_packet/rte_eth_af_packet.c   |   2 +
 drivers/net/bnx2x/bnx2x_ethdev.c|  34 +--
 drivers/net/bonding/rte_eth_bond_pmd.c  |   2 +
 drivers/net/cxgbe/cxgbe_ethdev.c|  24 +-
 drivers/net/e1000/em_ethdev.c   |  17 +-
 drivers/net/e1000/igb_ethdev.c  |  40 +---
 drivers/net/enic/enic_ethdev.c  |  23 +-
 drivers/net/fm10k/fm10k_ethdev.c|  23 +-
 drivers/net/i40e/i40e_ethdev.c  |  24 +-
 drivers/net/i40e/i40e_ethdev_vf.c   |  25 +-
 drivers/net/ixgbe/ixgbe_ethdev.c|  46 +---
 drivers/net/mlx4/mlx4.c |  19 +-
 drivers/net/mlx5/mlx5.c |  19 +-
 drivers/net/mpipe/mpipe_tilegx.c|   4 +
 drivers/net/nfp/nfp_net.c   |  21 +-
 drivers/net/null/rte_eth_null.c |   2 +
 drivers/net/pcap/rte_eth_pcap.c |   2 +
 drivers/net/ring/rte_eth_ring.c |   2 +
 drivers/net/szedata2/rte_eth_szedata2.c |   2 +
 drivers/net/virtio/virtio_ethdev.c  |  26 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c|  23 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c   |   2 +
 lib/librte_cryptodev/rte_cryptodev.c|  32 ++-
 lib/librte_cryptodev/rte_cryptodev.h|   2 +
 lib/librte_cryptodev/rte_cryptodev_pmd.h|  18 ++
 lib/librte_cryptodev/rte_cryptodev_version.map  |  10 +-
 lib/librte_eal/bsdapp/eal/eal.c |   7 +
 lib/librte_eal/bsdapp/eal/eal_pci.c |  52 -
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   8 +
 lib/librte_eal/common/eal_common_dev.c  |  50 +++-
 lib/librte_eal/common/eal_common_pci.c  |  17 +-
 lib/librte_eal/common/eal_private.h |  13 ++
 lib/librte_eal/common/include/rte_dev.h |  31 ++-
 lib/librte_eal/common/include/rte_pci.h |  28 +++
 lib/librte_eal/linuxapp/eal/eal.c   |  13 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c   |  16 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   8 +
 lib/librte_ether/rte_ethdev.c   | 296 
 lib/librte_ether/rte_ethdev.h   |  15 ++
 lib/librte_ether/rte_ether_version.map  |   8 +
 42 files changed, 465 insertions(+), 561 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH 1/9] pci: no need for dynamic tailq init

2016-01-29 Thread David Marchand
These lists can be initialized once and for all at build time.
With this, those lists are only manipulated in a common place
(and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

Signed-off-by: David Marchand 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c| 3 ---
 lib/librte_eal/common/eal_common_pci.c | 6 --
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 3 ---
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 6c21fbd..4584522 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -483,9 +483,6 @@ int rte_eal_pci_write_config(const struct rte_pci_device 
*dev,
 int
 rte_eal_pci_init(void)
 {
-   TAILQ_INIT(_driver_list);
-   TAILQ_INIT(_device_list);
-
/* for debug purposes, PCI can be disabled */
if (internal_config.no_pci)
return 0;
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index dcfe947..1e12776 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -82,8 +82,10 @@

 #include "eal_private.h"

-struct pci_driver_list pci_driver_list;
-struct pci_device_list pci_device_list;
+struct pci_driver_list pci_driver_list =
+   TAILQ_HEAD_INITIALIZER(pci_driver_list);
+struct pci_device_list pci_device_list =
+   TAILQ_HEAD_INITIALIZER(pci_device_list);

 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index bc5b5be..a354f76 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -625,9 +625,6 @@ int rte_eal_pci_write_config(const struct rte_pci_device 
*device,
 int
 rte_eal_pci_init(void)
 {
-   TAILQ_INIT(_driver_list);
-   TAILQ_INIT(_device_list);
-
/* for debug purposes, PCI can be disabled */
if (internal_config.no_pci)
return 0;
-- 
1.9.1



[dpdk-dev] [PATCH 2/9] pci: register all pdev as pci drivers

2016-01-29 Thread David Marchand
pdev drivers are actually pci drivers.
Wrappers for ethdev and crypto pci drivers, that assume a 1 to 1
association between pci device and upper device, have been added so that
current drivers are not impacted.

Signed-off-by: David Marchand 
---
 drivers/crypto/qat/rte_qat_cryptodev.c |  7 +--
 drivers/net/bnx2x/bnx2x_ethdev.c   | 16 ++--
 drivers/net/cxgbe/cxgbe_ethdev.c   |  5 +++--
 drivers/net/e1000/em_ethdev.c  |  4 +++-
 drivers/net/e1000/igb_ethdev.c | 14 +-
 drivers/net/enic/enic_ethdev.c |  5 +++--
 drivers/net/fm10k/fm10k_ethdev.c   |  4 +++-
 drivers/net/i40e/i40e_ethdev.c |  5 +++--
 drivers/net/i40e/i40e_ethdev_vf.c  |  6 +++---
 drivers/net/ixgbe/ixgbe_ethdev.c   | 10 ++
 drivers/net/nfp/nfp_net.c  |  7 ---
 drivers/net/virtio/virtio_ethdev.c |  4 +++-
 drivers/net/vmxnet3/vmxnet3_ethdev.c   |  5 +++--
 lib/librte_cryptodev/rte_cryptodev.c   | 18 ++
 lib/librte_cryptodev/rte_cryptodev_pmd.h   | 14 ++
 lib/librte_cryptodev/rte_cryptodev_version.map | 10 +-
 lib/librte_ether/rte_ethdev.c  | 16 +---
 lib/librte_ether/rte_ethdev.h  | 15 +++
 lib/librte_ether/rte_ether_version.map |  8 
 19 files changed, 123 insertions(+), 50 deletions(-)

diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c 
b/drivers/crypto/qat/rte_qat_cryptodev.c
index e500c1e..6853aee 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -113,10 +113,12 @@ crypto_qat_dev_init(__attribute__((unused)) struct 
rte_cryptodev_driver *crypto_
 }

 static struct rte_cryptodev_driver rte_qat_pmd = {
-   {
+   .pci_drv = {
.name = "rte_qat_pmd",
.id_table = pci_id_qat_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .devinit = rte_cryptodev_pci_probe,
+   .devuninit = rte_cryptodev_pci_remove,
},
.cryptodev_init = crypto_qat_dev_init,
.dev_private_size = sizeof(struct qat_pmd_private),
@@ -126,7 +128,8 @@ static int
 rte_qat_pmd_init(const char *name __rte_unused, const char *params 
__rte_unused)
 {
PMD_INIT_FUNC_TRACE();
-   return rte_cryptodev_pmd_driver_register(_qat_pmd, PMD_PDEV);
+   rte_eal_pci_register(_qat_pmd.pci_drv);
+   return 0;
 }

 static struct rte_driver pmd_qat_drv = {
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 69df02e..916b9da 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -501,6 +501,8 @@ static struct eth_driver rte_bnx2x_pmd = {
.name = "rte_bnx2x_pmd",
.id_table = pci_id_bnx2x_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+   .devinit = rte_eth_dev_pci_probe,
+   .devuninit = rte_eth_dev_pci_remove,
},
.eth_dev_init = eth_bnx2x_dev_init,
.dev_private_size = sizeof(struct bnx2x_softc),
@@ -514,24 +516,26 @@ static struct eth_driver rte_bnx2xvf_pmd = {
.name = "rte_bnx2xvf_pmd",
.id_table = pci_id_bnx2xvf_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .devinit = rte_eth_dev_pci_probe,
+   .devuninit = rte_eth_dev_pci_remove,
},
.eth_dev_init = eth_bnx2xvf_dev_init,
.dev_private_size = sizeof(struct bnx2x_softc),
 };

-static int rte_bnx2x_pmd_init(const char *name __rte_unused, const char 
*params __rte_unused)
+static int rte_bnx2x_pmd_init(const char *name __rte_unused,
+ const char *params __rte_unused)
 {
PMD_INIT_FUNC_TRACE();
-   rte_eth_driver_register(_bnx2x_pmd);
-
+   rte_eal_pci_register(_bnx2x_pmd.pci_drv);
return 0;
 }

-static int rte_bnx2xvf_pmd_init(const char *name __rte_unused, const char 
*params __rte_unused)
+static int rte_bnx2xvf_pmd_init(const char *name __rte_unused,
+   const char *params __rte_unused)
 {
PMD_INIT_FUNC_TRACE();
-   rte_eth_driver_register(_bnx2xvf_pmd);
-
+   rte_eal_pci_register(_bnx2xvf_pmd.pci_drv);
return 0;
 }

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 97ef152..e425ef2 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -851,6 +851,8 @@ static struct eth_driver rte_cxgbe_pmd = {
.name = "rte_cxgbe_pmd",
.id_table = cxgb4_pci_tbl,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+   .devinit = rte_eth_dev_pci_probe,
+   .devuninit = rte_eth_dev_pci_remove,
},
.eth_dev_init = eth_cxgbe_dev_init,
 

[dpdk-dev] [PATCH 3/9] drivers: no more pdev drivers

2016-01-29 Thread David Marchand
Now that pdev drivers have been converted to pci drivers, there is nothing
left in their init functions that can't go in a constructor.
pdev / vdev drivers init order is changed by this commit, but I can't see
why we would need to preserve it.

Signed-off-by: David Marchand 
---
 drivers/crypto/qat/rte_qat_cryptodev.c | 13 +++-
 drivers/net/bnx2x/bnx2x_ethdev.c   | 26 +++-
 drivers/net/cxgbe/cxgbe_ethdev.c   | 19 +++---
 drivers/net/e1000/em_ethdev.c  | 13 +++-
 drivers/net/e1000/igb_ethdev.c | 34 
 drivers/net/enic/enic_ethdev.c | 18 +++--
 drivers/net/fm10k/fm10k_ethdev.c   | 19 +++---
 drivers/net/i40e/i40e_ethdev.c | 19 +++---
 drivers/net/i40e/i40e_ethdev_vf.c  | 19 +++---
 drivers/net/ixgbe/ixgbe_ethdev.c   | 36 +++---
 drivers/net/mlx4/mlx4.c| 19 +++---
 drivers/net/mlx5/mlx5.c| 19 +++---
 drivers/net/nfp/nfp_net.c  | 14 +++--
 drivers/net/virtio/virtio_ethdev.c | 22 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c   | 18 +++--
 15 files changed, 47 insertions(+), 261 deletions(-)

diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c 
b/drivers/crypto/qat/rte_qat_cryptodev.c
index 6853aee..ded5d60 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -124,17 +124,10 @@ static struct rte_cryptodev_driver rte_qat_pmd = {
.dev_private_size = sizeof(struct qat_pmd_private),
 };

-static int
-rte_qat_pmd_init(const char *name __rte_unused, const char *params 
__rte_unused)
+/* Driver registration */
+static void __attribute__((constructor, used))
+rte_qat_pmd_init(void)
 {
PMD_INIT_FUNC_TRACE();
rte_eal_pci_register(_qat_pmd.pci_drv);
-   return 0;
 }
-
-static struct rte_driver pmd_qat_drv = {
-   .type = PMD_PDEV,
-   .init = rte_qat_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(pmd_qat_drv);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 916b9da..a4b1599 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -523,31 +523,11 @@ static struct eth_driver rte_bnx2xvf_pmd = {
.dev_private_size = sizeof(struct bnx2x_softc),
 };

-static int rte_bnx2x_pmd_init(const char *name __rte_unused,
- const char *params __rte_unused)
+/* Driver registration */
+static void __attribute__((constructor, used))
+rte_bnx2x_pmd_init(void)
 {
PMD_INIT_FUNC_TRACE();
rte_eal_pci_register(_bnx2x_pmd.pci_drv);
-   return 0;
-}
-
-static int rte_bnx2xvf_pmd_init(const char *name __rte_unused,
-   const char *params __rte_unused)
-{
-   PMD_INIT_FUNC_TRACE();
rte_eal_pci_register(_bnx2xvf_pmd.pci_drv);
-   return 0;
 }
-
-static struct rte_driver rte_bnx2x_driver = {
-   .type = PMD_PDEV,
-   .init = rte_bnx2x_pmd_init,
-};
-
-static struct rte_driver rte_bnx2xvf_driver = {
-   .type = PMD_PDEV,
-   .init = rte_bnx2xvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_bnx2x_driver);
-PMD_REGISTER_DRIVER(rte_bnx2xvf_driver);
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index e425ef2..9654ced 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -858,23 +858,10 @@ static struct eth_driver rte_cxgbe_pmd = {
.dev_private_size = sizeof(struct port_info),
 };

-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI CXGBE devices.
- */
-static int rte_cxgbe_pmd_init(const char *name __rte_unused,
- const char *params __rte_unused)
+/* Driver registration */
+static void __attribute__((constructor, used))
+rte_cxgbe_pmd_init(void)
 {
CXGBE_FUNC_TRACE();
rte_eal_pci_register(_cxgbe_pmd.pci_drv);
-   return 0;
 }
-
-static struct rte_driver rte_cxgbe_driver = {
-   .name = "cxgbe_driver",
-   .type = PMD_PDEV,
-   .init = rte_cxgbe_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_cxgbe_driver);
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 973ec97..19b2645 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -348,11 +348,11 @@ static struct eth_driver rte_em_pmd = {
.dev_private_size = sizeof(struct e1000_adapter),
 };

-static int
-rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
+/* Driver registration */
+static void __attribute__((constructor, used))
+rte_em_pmd_init(void)
 {
rte_eal_pci_register(_em_pmd.pci_drv);
-   return 0;
 }

 static int
@@ -1738,10 +1738,3 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
e1000_update_mc_addr_list(hw, (u8 *)mc_addr_set, 

[dpdk-dev] [PATCH 4/9] eal/linux: move back interrupt thread init before setting affinity

2016-01-29 Thread David Marchand
Now that virtio pci driver is initialized in a constructor, we only need to
move the interrupt thread init after loading the plugins.
This way, chelsio driver should be happy again [1].

[1] http://dpdk.org/ml/archives/dev/2015-November/028289.html

Signed-off-by: David Marchand 
---
 lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 635ec36..62241ee 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -823,6 +823,9 @@ rte_eal_init(int argc, char **argv)
if (eal_plugins_init() < 0)
rte_panic("Cannot init plugins\n");

+   if (rte_eal_intr_init() < 0)
+   rte_panic("Cannot init interrupt-handling thread\n");
+
eal_thread_init_master(rte_config.master_lcore);

ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
@@ -834,9 +837,6 @@ rte_eal_init(int argc, char **argv)
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");
-
RTE_LCORE_FOREACH_SLAVE(i) {

/*
-- 
1.9.1



[dpdk-dev] [PATCH 5/9] eal: get rid of pmd type

2016-01-29 Thread David Marchand
Now that we only have vdev drivers, there is no need for a pmd type in
rte_driver.
rte_driver is now purely a vdev thing, and could be renamed later
(then .init would become .probe, .uninit would become .remove).

Signed-off-by: David Marchand 
---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c |  2 ++
 drivers/net/af_packet/rte_eth_af_packet.c  |  2 ++
 drivers/net/bonding/rte_eth_bond_pmd.c |  2 ++
 drivers/net/mpipe/mpipe_tilegx.c   |  4 
 drivers/net/null/rte_eth_null.c|  2 ++
 drivers/net/pcap/rte_eth_pcap.c|  2 ++
 drivers/net/ring/rte_eth_ring.c|  2 ++
 drivers/net/szedata2/rte_eth_szedata2.c|  2 ++
 drivers/net/xenvirt/rte_eth_xenvirt.c  |  2 ++
 lib/librte_cryptodev/rte_cryptodev.c   | 14 ++
 lib/librte_cryptodev/rte_cryptodev.h   |  2 ++
 lib/librte_cryptodev/rte_cryptodev_pmd.h   |  4 
 lib/librte_eal/common/eal_common_dev.c | 11 ---
 lib/librte_eal/common/include/rte_dev.h|  4 
 14 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index d8ccf05..94752de 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -661,7 +661,9 @@ cryptodev_aesni_mb_uninit(const char *name)

 static struct rte_driver cryptodev_aesni_mb_pmd_drv = {
.name = CRYPTODEV_NAME_AESNI_MB_PMD,
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = cryptodev_aesni_mb_init,
.uninit = cryptodev_aesni_mb_uninit
 };
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index 767f36b..6603462 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -838,7 +838,9 @@ exit:

 static struct rte_driver pmd_af_packet_drv = {
.name = "eth_af_packet",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_af_packet_devinit,
 };

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index b1373c6..d19d745 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2493,7 +2493,9 @@ bond_ethdev_configure(struct rte_eth_dev *dev)

 static struct rte_driver bond_drv = {
.name = "eth_bond",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = bond_init,
.uninit = bond_uninit,
 };
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 35134ba..3eaf0db 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1608,13 +1608,17 @@ rte_pmd_mpipe_devinit(const char *ifname,

 static struct rte_driver pmd_mpipe_xgbe_drv = {
.name = "xgbe",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_mpipe_devinit,
 };

 static struct rte_driver pmd_mpipe_gbe_drv = {
.name = "gbe",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_mpipe_devinit,
 };

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 77fc988..f5700bb 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -695,7 +695,9 @@ rte_pmd_null_devuninit(const char *name)

 static struct rte_driver pmd_null_drv = {
.name = "eth_null",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_null_devinit,
.uninit = rte_pmd_null_devuninit,
 };
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index f9230eb..9ab22be 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1092,7 +1092,9 @@ rte_pmd_pcap_devuninit(const char *name)

 static struct rte_driver pmd_pcap_drv = {
.name = "eth_pcap",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_pcap_devinit,
.uninit = rte_pmd_pcap_devuninit,
 };
diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d92b088..9941a1c 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -596,7 +596,9 @@ rte_pmd_ring_devuninit(const char *name)

 static struct rte_driver pmd_ring_drv = {
.name = "eth_ring",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_ring_devinit,
.uninit = rte_pmd_ring_devuninit,
 };
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c 
b/drivers/net/szedata2/rte_eth_szedata2.c
index 9f86c99..6bbb6b0 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1616,7 +1616,9 @@ rte_pmd_szedata2_devuninit(const char *name)

 static struct rte_driver pmd_szedata2_drv = {
.name = "eth_szedata2",
+#ifndef RTE_NEXT_ABI
.type = PMD_VDEV,
+#endif
.init = rte_pmd_szedata2_devinit,
.uninit = rte_pmd_szedata2_devuninit,
 };

[dpdk-dev] [PATCH 6/9] eal: initialize vdevs right next to pci devices

2016-01-29 Thread David Marchand
This way, the resources probing happens in a common place.

Signed-off-by: David Marchand 
---
 lib/librte_eal/bsdapp/eal/eal.c | 7 +++
 lib/librte_eal/common/include/rte_dev.h | 2 +-
 lib/librte_eal/linuxapp/eal/eal.c   | 7 +++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a34e61d..b557a9f 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -582,8 +582,10 @@ rte_eal_init(int argc, char **argv)
rte_config.master_lcore, thread_id, cpuset,
ret == 0 ? "" : "...");

+#ifndef RTE_NEXT_ABI
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");
+#endif

RTE_LCORE_FOREACH_SLAVE(i) {

@@ -617,6 +619,11 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+#ifdef RTE_NEXT_ABI
+   if (rte_eal_dev_init() < 0)
+   rte_panic("Cannot probe vdev devices\n");
+#endif
+
/* Probe & Initialize PCI devices */
if (rte_eal_pci_probe())
rte_panic("Cannot probe PCI\n");
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 88c1a19..df69e28 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -156,7 +156,7 @@ void rte_eal_driver_register(struct rte_driver *driver);
 void rte_eal_driver_unregister(struct rte_driver *driver);

 /**
- * Initalize all the registered drivers in this process
+ * Scan all devargs and attach to drivers if available
  */
 int rte_eal_dev_init(void);

diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 62241ee..95313af 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -834,8 +834,10 @@ rte_eal_init(int argc, char **argv)
rte_config.master_lcore, (int)thread_id, cpuset,
ret == 0 ? "" : "...");

+#ifndef RTE_NEXT_ABI
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");
+#endif

RTE_LCORE_FOREACH_SLAVE(i) {

@@ -873,6 +875,11 @@ rte_eal_init(int argc, char **argv)
rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
rte_eal_mp_wait_lcore();

+#ifdef RTE_NEXT_ABI
+   if (rte_eal_dev_init() < 0)
+   rte_panic("Cannot probe vdev devices\n");
+#endif
+
/* Probe & Initialize PCI devices */
if (rte_eal_pci_probe())
rte_panic("Cannot probe PCI\n");
-- 
1.9.1



[dpdk-dev] [PATCH 7/9] pci: add a helper for device name

2016-01-29 Thread David Marchand
eal is a better place than ethdev for naming resources.
Add a helper here, and make use of it in ethdev hotplug code.

Signed-off-by: David Marchand 
---
 lib/librte_eal/common/include/rte_pci.h | 28 
 lib/librte_ether/rte_ethdev.c   | 22 ++
 2 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 334c12e..9edd5f5 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -309,6 +309,34 @@ eal_parse_pci_DomBDF(const char *input, struct 
rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD

+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.
+ *
+ * @param addr
+ * The PCI Bus-Device-Function address
+ * @param output
+ * The output buffer string
+ * @param size
+ * The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline int
+eal_pci_device_name(const struct rte_pci_addr *addr,
+   char *output, int size)
+{
+   int ret;
+
+   ret = snprintf(output, size, PCI_PRI_FMT,
+  addr->domain, addr->bus,
+  addr->devid, addr->function);
+   if (ret < 0 || ret >= size)
+   return -1;
+
+   return 0;
+}
+
 /* Compare two PCI device addresses. */
 /**
  * Utility function to compare two PCI device addresses.
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 17e4f4d..5ba7479 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -214,20 +214,6 @@ rte_eth_dev_allocate(const char *name, enum 
rte_eth_dev_type type)
return eth_dev;
 }

-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;
-}
-
 int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
@@ -251,9 +237,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,

eth_drv = (struct eth_driver *)pci_drv;

-   /* Create unique Ethernet device name using PCI address */
-   rte_eth_dev_create_unique_device_name(ethdev_name,
-   sizeof(ethdev_name), pci_dev);
+   eal_pci_device_name(_dev->addr, ethdev_name, sizeof(ethdev_name));

eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
if (eth_dev == NULL)
@@ -304,9 +288,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
if (pci_dev == NULL)
return -EINVAL;

-   /* Create unique Ethernet device name using PCI address */
-   rte_eth_dev_create_unique_device_name(ethdev_name,
-   sizeof(ethdev_name), pci_dev);
+   eal_pci_device_name(_dev->addr, ethdev_name, sizeof(ethdev_name));

eth_dev = rte_eth_dev_allocated(ethdev_name);
if (eth_dev == NULL)
-- 
1.9.1



[dpdk-dev] [PATCH 8/9] pci: add a helper to refresh a device

2016-01-29 Thread David Marchand
It will be used mainly for hotplug code.

Signed-off-by: David Marchand 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c   | 49 +++
 lib/librte_eal/common/eal_private.h   | 13 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c | 13 ++
 3 files changed, 75 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 4584522..5dd89e3 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -396,6 +396,55 @@ error:
return -1;
 }

+int
+pci_refresh_device(const struct rte_pci_addr *addr)
+{
+   int fd;
+   struct pci_conf matches[2];
+   struct pci_match_conf match = {
+   .pc_sel = {
+   .pc_domain = addr->domain,
+   .pc_bus = addr->bus,
+   .pc_dev = addr->devid,
+   .pc_func = addr->function,
+   },
+   };
+   struct pci_conf_io conf_io = {
+   .pat_buf_len = 0,
+   .num_patterns = 1,
+   .patterns = {  },
+   .match_buf_len = sizeof(matches),
+   .matches = [0],
+   };
+
+   fd = open("/dev/pci", O_RDONLY);
+   if (fd < 0) {
+   RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
+   goto error;
+   }
+
+   if (ioctl(fd, PCIOCGETCONF, _io) < 0) {
+   RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n",
+   __func__, strerror(errno));
+   goto error;
+   }
+
+   if (conf_io.num_matches != 1)
+   goto error;
+
+   if (pci_scan_one(fd, [0]) < 0)
+   goto error;
+
+   close(fd);
+
+   return 0;
+
+error:
+   if (fd >= 0)
+   close(fd);
+   return -1;
+}
+
 /* Read PCI config space. */
 int rte_eal_pci_read_config(const struct rte_pci_device *dev,
void *buf, size_t len, off_t offset)
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 072e672..ed1903f 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -155,6 +155,19 @@ struct rte_pci_driver;
 struct rte_pci_device;

 /**
+ * Refresh a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ * The PCI Bus-Device-Function address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int pci_refresh_device(const struct rte_pci_addr *addr);
+
+/**
  * Unbind kernel driver for this device
  *
  * This function is private to EAL.
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index a354f76..4fe8b60 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -393,6 +393,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
return 0;
 }

+int
+pci_refresh_device(const struct rte_pci_addr *addr)
+{
+   char filename[PATH_MAX];
+
+   snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+SYSFS_PCI_DEVICES, addr->domain, addr->bus, addr->devid,
+addr->function);
+
+   return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
+   addr->function);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
-- 
1.9.1



[dpdk-dev] [PATCH 9/9] eal: relocate hotplug code from ethdev

2016-01-29 Thread David Marchand
hotplug which deals with resources should come from the layer that already
handles them, i.e. eal.

Signed-off-by: David Marchand 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   8 +
 lib/librte_eal/common/eal_common_dev.c  |  39 
 lib/librte_eal/common/eal_common_pci.c  |  11 +-
 lib/librte_eal/common/include/rte_dev.h |  25 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   8 +
 lib/librte_ether/rte_ethdev.c   | 258 
 6 files changed, 125 insertions(+), 224 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 9d7adf1..9aad048 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -135,3 +135,11 @@ DPDK_2.2 {
rte_xen_dom0_supported;

 } DPDK_2.1;
+
+DPDK_2.3 {
+   global:
+
+   rte_eal_dev_attach;
+   rte_eal_dev_detach;
+
+} DPDK_2.2;
diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 5137172..ec04b3a 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -155,3 +155,42 @@ rte_eal_vdev_uninit(const char *name)
RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
return -EINVAL;
 }
+
+int rte_eal_dev_attach(const char *name, const char *devargs)
+{
+   struct rte_pci_addr addr;
+   int ret = -1;
+
+   if (eal_parse_pci_DomBDF(name, ) == 0) {
+   if (rte_eal_pci_probe_one() < 0)
+   goto err;
+
+   } else {
+   if (rte_eal_vdev_init(name, devargs))
+   goto err;
+   }
+
+   return 0;
+
+err:
+   RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+   return ret;
+}
+
+int rte_eal_dev_detach(const char *name)
+{
+   struct rte_pci_addr addr;
+
+   if (eal_parse_pci_DomBDF(name, ) == 0) {
+   if (rte_eal_pci_detach() < 0)
+   goto err;
+   } else {
+   if (rte_eal_vdev_uninit(name))
+   goto err;
+   }
+   return 0;
+
+err:
+   RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
+   return -1;
+}
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 1e12776..d9aa66b 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -332,6 +332,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
if (addr == NULL)
return -1;

+   /* update current pci device in global list, kernel bindings might have
+* changed since last time we looked at it */
+   if (pci_refresh_device(addr) < 0)
+   goto err_return;
+
TAILQ_FOREACH(dev, _device_list, next) {
if (rte_eal_compare_pci_addr(>addr, addr))
continue;
@@ -344,9 +349,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
return -1;

 err_return:
-   RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
-   " cannot be used\n", dev->addr.domain, dev->addr.bus,
-   dev->addr.devid, dev->addr.function);
+   RTE_LOG(WARNING, EAL,
+   "Requested device " PCI_PRI_FMT " cannot be used\n",
+   addr->domain, addr->bus, addr->devid, addr->function);
return -1;
 }

diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index df69e28..6f026ff 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -182,6 +182,31 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);

+/**
+ * Attach a resource to a registered driver.
+ *
+ * @param name
+ *   The resource name, that refers to a pci resource or some private
+ *   way of designating a resource for vdev drivers. Based on this
+ *   resource name, eal will identify a driver capable of handling
+ *   this resource and pass this resource to the driver probing
+ *   function.
+ * @param devargs
+ *   Device arguments to be passed to the driver.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a resource from its driver.
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define PMD_REGISTER_DRIVER(d)\
 void devinitfn_ ##d(void);\
 void __attribute__((constructor, used)) devinitfn_ ##d(void)\
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index cbe175f..ba0ff56 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -138,3 +138,11 @@ DPDK_2.2 {
 

[dpdk-dev] [PATCH] pmd/snow3g: add new SNOW 3G SW PMD

2016-01-29 Thread Pablo de Lara
Added new SW PMD which makes use of the libsso SW library,
which provides wireless algorithms SNOW 3G UEA2 and UIA2
in software.

This PMD supports cipher-only, hash-only and chained operations
("cipher then hash" and "hash then cipher") of the following
algorithms:
- RTE_CRYPTO_SYM_CIPHER_SNOW3G_UEA2
- RTE_CRYPTO_SYM_HASH_SNOW3G_UIA2

The SNOW 3G hash and cipher algorithms, which are enabled
by this crypto PMD are implemented by Intel's libsso software
library. For library download and build instructions,
see the documentation included (doc/guides/cryptodevs/snow3g.rst)

Signed-off-by: Pablo de Lara 
---
 MAINTAINERS  |   4 +
 config/common_linuxapp   |  10 +-
 doc/guides/cryptodevs/index.rst  |   1 +
 doc/guides/cryptodevs/snow3g.rst |  69 +++
 doc/guides/rel_notes/release_2_3.rst |   4 +
 drivers/crypto/Makefile  |   3 +-
 drivers/crypto/snow3g/Makefile   |  64 +++
 drivers/crypto/snow3g/rte_pmd_snow3g_version.map |   3 +
 drivers/crypto/snow3g/rte_snow3g_pmd.c   | 508 +++
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c   | 291 +
 drivers/crypto/snow3g/rte_snow3g_pmd_private.h   | 107 +
 lib/librte_cryptodev/rte_crypto.h|   4 +
 lib/librte_cryptodev/rte_cryptodev.h |   5 +-
 mk/rte.app.mk|   6 +-
 14 files changed, 1075 insertions(+), 4 deletions(-)
 create mode 100644 doc/guides/cryptodevs/snow3g.rst
 create mode 100644 drivers/crypto/snow3g/Makefile
 create mode 100644 drivers/crypto/snow3g/rte_pmd_snow3g_version.map
 create mode 100644 drivers/crypto/snow3g/rte_snow3g_pmd.c
 create mode 100644 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c
 create mode 100644 drivers/crypto/snow3g/rte_snow3g_pmd_private.h

diff --git a/MAINTAINERS b/MAINTAINERS
index b90aeea..69d27a9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -355,6 +355,10 @@ F: drivers/crypto/aesni_mb/
 Intel QuickAssist
 F: drivers/crypto/qat/

+SNOW 3G PMD
+M: Pablo de Lara 
+F: drivers/crypto/snow3g
+

 Packet processing
 -
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 74bc515..49aa274 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -356,6 +356,14 @@ CONFIG_RTE_AESNI_MB_PMD_MAX_NB_QUEUE_PAIRS=8
 CONFIG_RTE_AESNI_MB_PMD_MAX_NB_SESSIONS=2048

 #
+# Compile PMD for SNOW 3G device
+#
+CONFIG_RTE_LIBRTE_PMD_SNOW3G=n
+CONFIG_RTE_LIBRTE_PMD_SNOW3G_DEBUG=n
+CONFIG_RTE_SNOW3G_PMD_MAX_NB_QUEUE_PAIRS=8
+CONFIG_RTE_SNOW3G_PMD_MAX_NB_SESSIONS=2048
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index 16a5f4a..071e7d2 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -36,4 +36,5 @@ Crypto Device Drivers
 :numbered:

 aesni_mb
+snow3g
 qat
diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
new file mode 100644
index 000..9e81eeb
--- /dev/null
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -0,0 +1,69 @@
+..  BSD LICENSE
+Copyright(c) 2016 Intel Corporation. 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 Intel Corporation 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 

[dpdk-dev] [PATCH v2 0/9] pci cleanup and blacklist rework

2016-01-29 Thread David Marchand
Before 2.2.0 release, while preparing for more changes in eal (and fixing
a problem reported by Roger M. [1]), I came up with this (part of) patchset
that tries to make the pci code more compact and easier to read.

I ended up introducing some hooks in the pci layer to customize pci
blacklist / whitelist handling and make it possible to automatically
bind / unbind pci devices to igb_uio (or equivalent) when attaching
a device.

I am still not really happy:
- the pci blacklist / whitelist makes me think we should let the
  application tell eal which resources to use and get rid of the
  unconditional pci scan code, which means removing rte_eal_pci_probe()
  from rte_eal_init(), and remove rte_eal_dev_init() for vdevs,
- the more I look at this, the more I think automatic bind / unbind for
  pci devices should be called from the pmd context. The drivers know best
  what they require and what they want to do with the resources passed by
  the eal (see the drv_flags / RTE_KDRV_NONE / rte_eal_pci_map_device stuff
  for virtio pmd).
  This behaviour would still be optional, on a per-device basis.

So, I think that these hooks are not that good of an idea and I kept
them private for now, but anyway, sending this for comments.


Changes since v1:
- split the initial patchset. This current patchset now depends on
  [2] sent separately which should be applied first,
- introduced hooks in pci common code,
- implemented automatic bind / unbind for "uio" pci devices


[1] http://dpdk.org/ml/archives/dev/2015-November/028140.html
[2] http://dpdk.org/ml/archives/dev/2016-January/032387.html

-- 
David Marchand

David Marchand (9):
  pci: add internal device list helpers
  pci/linux: minor cleanup
  pci/linux: rework sysfs parsing for driver
  pci: factorize probe/detach code
  pci: cosmetic change
  pci: factorize driver search
  pci: remove driver lookup from detach
  pci: implement blacklist using a hook
  pci: implement automatic bind/unbind

 lib/librte_eal/bsdapp/eal/eal_pci.c|  59 ++--
 lib/librte_eal/common/eal_common_options.c |   8 +
 lib/librte_eal/common/eal_common_pci.c | 438 ++---
 lib/librte_eal/common/eal_options.h|   2 +
 lib/librte_eal/common/eal_private.h|  64 +
 lib/librte_eal/common/include/rte_pci.h|   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 301 
 7 files changed, 627 insertions(+), 252 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v2 1/9] pci: add internal device list helpers

2016-01-29 Thread David Marchand
Remove duplicate code by moving this to helpers in common.

Signed-off-by: David Marchand 
---
Changes since v1:
- moved helpers to eal_private.h

---
 lib/librte_eal/bsdapp/eal/eal_pci.c| 34 ---
 lib/librte_eal/common/eal_common_pci.c | 76 --
 lib/librte_eal/common/eal_private.h| 26 
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 34 +--
 4 files changed, 99 insertions(+), 71 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 5dd89e3..e95249b 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -247,6 +247,7 @@ static int
 pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 {
struct rte_pci_device *dev;
+   struct rte_pci_device *dev2;
struct pci_bar_io bar;
unsigned i, max;

@@ -311,32 +312,15 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
dev->mem_resource[i].phys_addr = bar.pbi_base & 
~((uint64_t)0xf);
}

-   /* device is valid, add in list (sorted) */
-   if (TAILQ_EMPTY(_device_list)) {
-   TAILQ_INSERT_TAIL(_device_list, dev, next);
-   }
+   dev2 = pci_find_device(>addr);
+   if (!dev2)
+   pci_add_device(dev);
else {
-   struct rte_pci_device *dev2 = NULL;
-   int ret;
-
-   TAILQ_FOREACH(dev2, _device_list, next) {
-   ret = rte_eal_compare_pci_addr(>addr, >addr);
-   if (ret > 0)
-   continue;
-   else if (ret < 0) {
-   TAILQ_INSERT_BEFORE(dev2, dev, next);
-   return 0;
-   } else { /* already registered */
-   dev2->kdrv = dev->kdrv;
-   dev2->max_vfs = dev->max_vfs;
-   memmove(dev2->mem_resource,
-   dev->mem_resource,
-   sizeof(dev->mem_resource));
-   free(dev);
-   return 0;
-   }
-   }
-   TAILQ_INSERT_TAIL(_device_list, dev, next);
+   dev2->kdrv = dev->kdrv;
+   dev2->max_vfs = dev->max_vfs;
+   memmove(dev2->mem_resource, dev->mem_resource,
+   sizeof(dev->mem_resource));
+   free(dev);
}

return 0;
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index d9aa66b..c3a33c6 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -139,6 +139,41 @@ pci_unmap_resource(void *requested_addr, size_t size)
requested_addr);
 }

+struct rte_pci_device *
+pci_find_device(const struct rte_pci_addr *addr)
+{
+   struct rte_pci_device *dev;
+
+   TAILQ_FOREACH(dev, _device_list, next) {
+   if (!rte_eal_compare_pci_addr(>addr, addr))
+   break;
+   }
+
+   return dev;
+}
+
+int
+pci_add_device(struct rte_pci_device *dev)
+{
+   struct rte_pci_device *dev2;
+   int ret;
+
+   TAILQ_FOREACH(dev2, _device_list, next) {
+   ret = rte_eal_compare_pci_addr(>addr, >addr);
+   if (ret > 0)
+   continue;
+
+   if (ret == 0)
+   return -1;
+
+   TAILQ_INSERT_BEFORE(dev2, dev, next);
+   return 0;
+   }
+
+   TAILQ_INSERT_TAIL(_device_list, dev, next);
+   return 0;
+}
+
 /*
  * If vendor/device ID match, call the devinit() function of the
  * driver.
@@ -337,16 +372,15 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
if (pci_refresh_device(addr) < 0)
goto err_return;

-   TAILQ_FOREACH(dev, _device_list, next) {
-   if (rte_eal_compare_pci_addr(>addr, addr))
-   continue;
+   dev = pci_find_device(addr);
+   if (!dev)
+   goto err_return;

-   ret = pci_probe_all_drivers(dev);
-   if (ret < 0)
-   goto err_return;
-   return 0;
-   }
-   return -1;
+   ret = pci_probe_all_drivers(dev);
+   if (ret < 0)
+   goto err_return;
+
+   return 0;

 err_return:
RTE_LOG(WARNING, EAL,
@@ -367,23 +401,21 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr)
if (addr == NULL)
return -1;

-   TAILQ_FOREACH(dev, _device_list, next) {
-   if (rte_eal_compare_pci_addr(>addr, addr))
-   continue;
+   dev = pci_find_device(addr);
+   if (!dev)
+   goto err_return;

-   ret = pci_detach_all_drivers(dev);
-   if (ret < 0)
-   goto 

[dpdk-dev] [PATCH v2 2/9] pci/linux: minor cleanup

2016-01-29 Thread David Marchand
Those are the only fields that are explicitly set to 0 while the global
dev pointer is set to 0 a few lines before.

Signed-off-by: David Marchand 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index d9d6de7..6751b48 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -308,7 +308,6 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
dev->id.subsystem_device_id = (uint16_t)tmp;

/* get max_vfs */
-   dev->max_vfs = 0;
snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
if (!access(filename, F_OK) &&
eal_parse_sysfs_value(filename, ) == 0)
@@ -323,12 +322,8 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
}

/* get numa node */
-   snprintf(filename, sizeof(filename), "%s/numa_node",
-dirname);
-   if (access(filename, R_OK) != 0) {
-   /* if no NUMA support, set default to 0 */
-   dev->numa_node = 0;
-   } else {
+   snprintf(filename, sizeof(filename), "%s/numa_node", dirname);
+   if (!access(filename, R_OK)) {
if (eal_parse_sysfs_value(filename, ) < 0) {
free(dev);
return -1;
-- 
1.9.1



[dpdk-dev] [PATCH v2 3/9] pci/linux: rework sysfs parsing for driver

2016-01-29 Thread David Marchand
There is no use for pci_get_kernel_driver_by_path() apart recognising
kernel driver and fill kdrv field.

Signed-off-by: David Marchand 
---
Changes since v1:
- updated the commitlog, Huawei already did the "unknown" -> "none"
  change, so this patch ends up just refactoring code

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 48 ++-
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 6751b48..c3118fc 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -94,32 +94,37 @@ error:
 }

 static int
-pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
+pci_parse_sysfs_driver(const char *filename, struct rte_pci_device *dev)
 {
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;
+   dev->kdrv = RTE_KDRV_NONE;

-   path[count] = '\0';
+   if (count > 0) {
+   dev->kdrv = RTE_KDRV_UNKNOWN;

-   name = strrchr(path, '/');
-   if (name) {
-   strncpy(dri_name, name + 1, strlen(name + 1) + 1);
-   return 0;
+   path[count] = '\0';
+   name = strrchr(path, '/');
+   if (name) {
+   name[0] = '\0';
+   name++;
+   }
+
+   if (!strcmp(name, "vfio-pci"))
+   dev->kdrv = RTE_KDRV_VFIO;
+   else if (!strcmp(name, "igb_uio"))
+   dev->kdrv = RTE_KDRV_IGB_UIO;
+   else if (!strcmp(name, "uio_pci_generic"))
+   dev->kdrv = RTE_KDRV_UIO_GENERIC;
}

-   return -1;
+   return 0;
 }

 /* Map pci device */
@@ -260,8 +265,6 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
unsigned long tmp;
struct rte_pci_device *dev;
struct rte_pci_device *dev2;
-   char driver[PATH_MAX];
-   int ret;

dev = malloc(sizeof(*dev));
if (dev == NULL)
@@ -341,25 +344,12 @@ 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);
-   if (ret < 0) {
+   if (pci_parse_sysfs_driver(filename, dev) < 0) {
RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
free(dev);
return -1;
}

-   if (!ret) {
-   if (!strcmp(driver, "vfio-pci"))
-   dev->kdrv = RTE_KDRV_VFIO;
-   else if (!strcmp(driver, "igb_uio"))
-   dev->kdrv = RTE_KDRV_IGB_UIO;
-   else if (!strcmp(driver, "uio_pci_generic"))
-   dev->kdrv = RTE_KDRV_UIO_GENERIC;
-   else
-   dev->kdrv = RTE_KDRV_UNKNOWN;
-   } else
-   dev->kdrv = RTE_KDRV_UNKNOWN;
-
dev2 = pci_find_device(>addr);
if (!dev2)
pci_add_device(dev);
-- 
1.9.1



[dpdk-dev] [PATCH v2 6/9] pci: factorize driver search

2016-01-29 Thread David Marchand
Same idea as a few commits before, no need to implement the same logic in
probe and detach functions.
Here, the driver matching is done by a helper, then probe / detach
functions are called respectively.

Signed-off-by: David Marchand 
---
 lib/librte_eal/common/eal_common_pci.c | 96 --
 1 file changed, 34 insertions(+), 62 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index fd88305..768421a 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -280,55 +280,16 @@ pci_detach_device(struct rte_pci_driver *dr, struct 
rte_pci_device *dev)
return 0;
 }

-/*
- * If vendor/device ID match, call the devinit() function of all
- * registered driver for the given device. Return -1 if initialization
- * failed, return 1 if no driver is found for this device.
- */
-static int
-pci_probe_all_drivers(struct rte_pci_device *dev)
-{
-   struct rte_pci_driver *dr = NULL;
-   int rc = 0;
-
-   TAILQ_FOREACH(dr, _driver_list, next) {
-   if (!pci_driver_supports_device(dr, dev))
-   continue;
-
-   rc = pci_probe_device(dr, dev);
-   if (rc < 0)
-   /* negative value is an error */
-   return -1;
-   if (rc > 0)
-   /* positive value means device is blacklisted */
-   continue;
-   return 0;
-   }
-   return 1;
-}
-
-/*
- * If vendor/device ID match, call the devuninit() function of all
- * registered driver for the given device. Return -1 if initialization
- * failed, return 1 if no driver is found for this device.
- */
-static int
-pci_detach_all_drivers(struct rte_pci_device *dev)
+static struct rte_pci_driver *
+pci_find_driver(struct rte_pci_device *dev)
 {
-   struct rte_pci_driver *dr = NULL;
-   int rc = 0;
+   struct rte_pci_driver *dr;

TAILQ_FOREACH(dr, _driver_list, next) {
-   if (!pci_driver_supports_device(dr, dev))
-   continue;
-
-   rc = pci_detach_device(dr, dev);
-   if (rc < 0)
-   /* negative value is an error */
-   return -1;
-   return 0;
+   if (pci_driver_supports_device(dr, dev))
+   break;
}
-   return 1;
+   return dr;
 }

 /*
@@ -338,8 +299,8 @@ pci_detach_all_drivers(struct rte_pci_device *dev)
 int
 rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 {
-   struct rte_pci_device *dev = NULL;
-   int ret = 0;
+   struct rte_pci_device *dev;
+   struct rte_pci_driver *dr;

if (addr == NULL)
return -1;
@@ -353,8 +314,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
if (!dev)
goto err_return;

-   ret = pci_probe_all_drivers(dev);
-   if (ret < 0)
+   dr = pci_find_driver(dev);
+   if (!dr)
+   goto err_return;
+
+   if (pci_probe_device(dr, dev) < 0)
goto err_return;

return 0;
@@ -372,8 +336,8 @@ err_return:
 int
 rte_eal_pci_detach(const struct rte_pci_addr *addr)
 {
-   struct rte_pci_device *dev = NULL;
-   int ret = 0;
+   struct rte_pci_device *dev;
+   struct rte_pci_driver *dr;

if (addr == NULL)
return -1;
@@ -382,8 +346,11 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr)
if (!dev)
goto err_return;

-   ret = pci_detach_all_drivers(dev);
-   if (ret < 0)
+   dr = pci_find_driver(dev);
+   if (!dr)
+   goto err_return;
+
+   if (pci_detach_device(dr, dev) < 0)
goto err_return;

TAILQ_REMOVE(_device_list, dev, next);
@@ -404,28 +371,33 @@ err_return:
 int
 rte_eal_pci_probe(void)
 {
-   struct rte_pci_device *dev = NULL;
+   struct rte_pci_device *dev;
+   struct rte_pci_driver *dr;
struct rte_devargs *devargs;
int probe_all = 0;
-   int ret = 0;

if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
probe_all = 1;

TAILQ_FOREACH(dev, _device_list, next) {

+   /* no driver available */
+   dr = pci_find_driver(dev);
+   if (!dr)
+   continue;
+
/* set devargs in PCI structure */
devargs = pci_devargs_lookup(dev);
if (devargs != NULL)
dev->devargs = devargs;

-   /* probe all or only whitelisted devices */
-   if (probe_all)
-   ret = pci_probe_all_drivers(dev);
-   else if (devargs != NULL &&
-   devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-   ret = pci_probe_all_drivers(dev);
-   if (ret < 0)
+   /* skip if not 

[dpdk-dev] [PATCH v2 5/9] pci: cosmetic change

2016-01-29 Thread David Marchand
Indent previous commit, rename functions (internal and local functions do
not need rte_eal_ prefix).

Signed-off-by: David Marchand 
---
 lib/librte_eal/common/eal_common_pci.c | 106 -
 1 file changed, 52 insertions(+), 54 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index a6791c1..fd88305 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -206,50 +206,49 @@ pci_driver_supports_device(const struct rte_pci_driver 
*dr,
  * driver.
  */
 static int
-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
-struct rte_pci_device *dev)
+pci_probe_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
 {
int ret;
-   struct rte_pci_addr *loc = >addr;
+   struct rte_pci_addr *loc = >addr;

-   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket 
%i\n",
-   loc->domain, loc->bus, loc->devid, 
loc->function,
-   dev->numa_node);
+   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+   loc->domain, loc->bus, loc->devid, loc->function,
+   dev->numa_node);

-   RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", 
dev->id.vendor_id,
-   dev->id.device_id, dr->name);
+   RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
+   dev->id.device_id, dr->name);

-   /* no initialization when blacklisted, return without error */
-   if (dev->devargs != NULL &&
-   dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
-   RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not 
initializing\n");
-   return 1;
-   }
+   /* no initialization when blacklisted, return without error */
+   if (dev->devargs != NULL &&
+   dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+   RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not 
initializing\n");
+   return 1;
+   }

-   if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
+   if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
 #ifdef RTE_PCI_CONFIG
-   /*
-* Set PCIe config space for high performance.
-* Return value can be ignored.
-*/
-   pci_config_space_set(dev);
+   /*
+* Set PCIe config space for high performance.
+* Return value can be ignored.
+*/
+   pci_config_space_set(dev);
 #endif
-   /* map resources for devices that use igb_uio */
-   ret = pci_map_device(dev);
-   if (ret != 0)
-   return ret;
-   } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
-   rte_eal_process_type() == RTE_PROC_PRIMARY) {
-   /* unbind current driver */
-   if (pci_unbind_kernel_driver(dev) < 0)
-   return -1;
-   }
-
-   /* reference driver structure */
-   dev->driver = dr;
-
-   /* call the driver devinit() function */
-   return dr->devinit(dr, dev);
+   /* map resources for devices that use igb_uio */
+   ret = pci_map_device(dev);
+   if (ret != 0)
+   return ret;
+   } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
+  rte_eal_process_type() == RTE_PROC_PRIMARY) {
+   /* unbind current driver */
+   if (pci_unbind_kernel_driver(dev) < 0)
+   return -1;
+   }
+
+   /* reference driver structure */
+   dev->driver = dr;
+
+   /* call the driver devinit() function */
+   return dr->devinit(dr, dev);
 }

 /*
@@ -257,29 +256,28 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
  * driver.
  */
 static int
-rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
-   struct rte_pci_device *dev)
+pci_detach_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
 {
-   struct rte_pci_addr *loc = >addr;
+   struct rte_pci_addr *loc = >addr;

-   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket 
%i\n",
-   loc->domain, loc->bus, loc->devid,
-   loc->function, dev->numa_node);
+   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+   loc->domain, loc->bus, loc->devid,
+   loc->function, dev->numa_node);

-   RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", 
dev->id.vendor_id,
-   

[dpdk-dev] [PATCH v2 4/9] pci: factorize probe/detach code

2016-01-29 Thread David Marchand
Move pci id matching to a helper and reuse it in probe and detach
functions.

Signed-off-by: David Marchand 
---
 lib/librte_eal/common/eal_common_pci.c | 67 --
 1 file changed, 23 insertions(+), 44 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index c3a33c6..a6791c1 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -174,14 +174,10 @@ pci_add_device(struct rte_pci_device *dev)
return 0;
 }

-/*
- * If vendor/device ID match, call the devinit() function of the
- * driver.
- */
 static int
-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device 
*dev)
+pci_driver_supports_device(const struct rte_pci_driver *dr,
+  const struct rte_pci_device *dev)
 {
-   int ret;
const struct rte_pci_id *id_table;

for (id_table = dr->id_table; id_table->vendor_id != 0; id_table++) {
@@ -200,6 +196,20 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
id_table->subsystem_device_id != PCI_ANY_ID)
continue;

+   return 1;
+   }
+   return 0;
+}
+
+/*
+ * If vendor/device ID match, call the devinit() function of the
+ * driver.
+ */
+static int
+rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
+struct rte_pci_device *dev)
+{
+   int ret;
struct rte_pci_addr *loc = >addr;

RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket 
%i\n",
@@ -240,9 +250,6 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d

/* call the driver devinit() function */
return dr->devinit(dr, dev);
-   }
-   /* return positive value if driver is not found */
-   return 1;
 }

 /*
@@ -253,27 +260,6 @@ static int
 rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
struct rte_pci_device *dev)
 {
-   const struct rte_pci_id *id_table;
-
-   if ((dr == NULL) || (dev == NULL))
-   return -EINVAL;
-
-   for (id_table = dr->id_table; id_table->vendor_id != 0; id_table++) {
-
-   /* check if device's identifiers match the driver's ones */
-   if (id_table->vendor_id != dev->id.vendor_id &&
-   id_table->vendor_id != PCI_ANY_ID)
-   continue;
-   if (id_table->device_id != dev->id.device_id &&
-   id_table->device_id != PCI_ANY_ID)
-   continue;
-   if (id_table->subsystem_vendor_id != 
dev->id.subsystem_vendor_id &&
-   id_table->subsystem_vendor_id != PCI_ANY_ID)
-   continue;
-   if (id_table->subsystem_device_id != 
dev->id.subsystem_device_id &&
-   id_table->subsystem_device_id != PCI_ANY_ID)
-   continue;
-
struct rte_pci_addr *loc = >addr;

RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket 
%i\n",
@@ -294,10 +280,6 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
pci_unmap_device(dev);

return 0;
-   }
-
-   /* return positive value if driver is not found */
-   return 1;
 }

 /*
@@ -311,16 +293,16 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
struct rte_pci_driver *dr = NULL;
int rc = 0;

-   if (dev == NULL)
-   return -1;
-
TAILQ_FOREACH(dr, _driver_list, next) {
+   if (!pci_driver_supports_device(dr, dev))
+   continue;
+
rc = rte_eal_pci_probe_one_driver(dr, dev);
if (rc < 0)
/* negative value is an error */
return -1;
if (rc > 0)
-   /* positive value means driver not found */
+   /* positive value means device is blacklisted */
continue;
return 0;
}
@@ -338,17 +320,14 @@ pci_detach_all_drivers(struct rte_pci_device *dev)
struct rte_pci_driver *dr = NULL;
int rc = 0;

-   if (dev == NULL)
-   return -1;
-
TAILQ_FOREACH(dr, _driver_list, next) {
+   if (!pci_driver_supports_device(dr, dev))
+   continue;
+
rc = rte_eal_pci_detach_dev(dr, dev);
if (rc < 0)
/* negative value is an error */
return -1;
-   if (rc > 0)
-   /* positive value means driver not found */
-   continue;
return 0;
}
return 1;
-- 
1.9.1



[dpdk-dev] [PATCH v2 7/9] pci: remove driver lookup from detach

2016-01-29 Thread David Marchand
A device is linked to a driver at probe time.
When detaching, we should call this same driver detach() function and no
need for a driver lookup.

Signed-off-by: David Marchand 
---
Changes since v1:
- moved some logs for consistency

---
 lib/librte_eal/common/eal_common_pci.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 768421a..082eab8 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -256,13 +256,9 @@ pci_probe_device(struct rte_pci_driver *dr, struct 
rte_pci_device *dev)
  * driver.
  */
 static int
-pci_detach_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
+pci_detach_device(struct rte_pci_device *dev)
 {
-   struct rte_pci_addr *loc = >addr;
-
-   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
-   loc->domain, loc->bus, loc->devid,
-   loc->function, dev->numa_node);
+   struct rte_pci_driver *dr = dev->driver;

RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
dev->id.device_id, dr->name);
@@ -337,20 +333,19 @@ int
 rte_eal_pci_detach(const struct rte_pci_addr *addr)
 {
struct rte_pci_device *dev;
-   struct rte_pci_driver *dr;

if (addr == NULL)
return -1;

dev = pci_find_device(addr);
-   if (!dev)
+   if (!dev || !dev->driver)
goto err_return;

-   dr = pci_find_driver(dev);
-   if (!dr)
-   goto err_return;
+   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+   dev->addr.domain, dev->addr.bus, dev->addr.devid,
+   dev->addr.function, dev->numa_node);

-   if (pci_detach_device(dr, dev) < 0)
+   if (pci_detach_device(dev) < 0)
goto err_return;

TAILQ_REMOVE(_device_list, dev, next);
-- 
1.9.1



[dpdk-dev] [PATCH v2 8/9] pci: implement blacklist using a hook

2016-01-29 Thread David Marchand
The idea is to prepare a generic hook system for all bus, but I am still
unsure if this approach will be the right one, hence, keeping this as
private for now.

Here, blacklisting policy is removed from pci scan code, making it possible
to override it later by the application (once the api is judged generic and
good enough).

With this, blacklist evaluation moves to rte_eal_pci_probe() only.
This way, rte_eal_pci_probe_one() (used by hotplug when attaching) now
accepts to probe devices that were blacklisted initially.

A new debug trace is added when skipping a device not part of a given
whitelist.

Signed-off-by: David Marchand 
---
 lib/librte_eal/common/eal_common_pci.c | 101 +
 1 file changed, 77 insertions(+), 24 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 082eab8..4a0ec73 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -87,6 +87,62 @@ struct pci_driver_list pci_driver_list =
 struct pci_device_list pci_device_list =
TAILQ_HEAD_INITIALIZER(pci_device_list);

+enum rte_eal_pci_hook {
+   RTE_EAL_PCI_SCAN,
+};
+
+enum rte_eal_pci_hook_return {
+   RTE_EAL_PCI_HOOK_OK,
+   RTE_EAL_PCI_HOOK_ERROR,
+   RTE_EAL_PCI_HOOK_SKIP,
+};
+
+typedef int (rte_eal_pci_hook_t)(enum rte_eal_pci_hook,
+struct rte_pci_driver *,
+struct rte_pci_device *);
+
+static int
+blacklist_pci_hook(enum rte_eal_pci_hook h,
+  struct rte_pci_driver *dr __rte_unused,
+  struct rte_pci_device *dev)
+{
+   int ret;
+
+   switch (h) {
+   case RTE_EAL_PCI_SCAN:
+   {
+   int whitelist =
+   rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI);
+   int blacklist =
+   rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI);
+
+   /*
+* We want to probe this device when:
+* - there is no whitelist/blacklist,
+* - there is a whitelist, and device is part of it,
+* - there is a blacklist, and device is not part of it.
+*/
+   if (whitelist && !dev->devargs) {
+   RTE_LOG(DEBUG, EAL, "  Device is not whitelisted, not 
initializing\n");
+   ret = RTE_EAL_PCI_HOOK_SKIP;
+   } else if (blacklist && dev->devargs) {
+   RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not 
initializing\n");
+   ret = RTE_EAL_PCI_HOOK_SKIP;
+   } else
+   ret = RTE_EAL_PCI_HOOK_OK;
+   break;
+   }
+   default:
+   /* nothing to do here, just say ok */
+   ret = RTE_EAL_PCI_HOOK_OK;
+   break;
+   }
+
+   return ret;
+}
+
+static rte_eal_pci_hook_t *pci_hook = _pci_hook;
+
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
struct rte_devargs *devargs;
@@ -209,22 +265,10 @@ static int
 pci_probe_device(struct rte_pci_driver *dr, struct rte_pci_device *dev)
 {
int ret;
-   struct rte_pci_addr *loc = >addr;
-
-   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
-   loc->domain, loc->bus, loc->devid, loc->function,
-   dev->numa_node);

RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
dev->id.device_id, dr->name);

-   /* no initialization when blacklisted, return without error */
-   if (dev->devargs != NULL &&
-   dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
-   RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not 
initializing\n");
-   return 1;
-   }
-
if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
 #ifdef RTE_PCI_CONFIG
/*
@@ -310,6 +354,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
if (!dev)
goto err_return;

+   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
+   dev->addr.domain, dev->addr.bus,
+   dev->addr.devid, dev->addr.function,
+   dev->numa_node);
+
dr = pci_find_driver(dev);
if (!dr)
goto err_return;
@@ -369,27 +418,31 @@ rte_eal_pci_probe(void)
struct rte_pci_device *dev;
struct rte_pci_driver *dr;
struct rte_devargs *devargs;
-   int probe_all = 0;
-
-   if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
-   probe_all = 1;
+   int ret;

TAILQ_FOREACH(dev, _device_list, next) {

-   /* no driver available */
-   dr = pci_find_driver(dev);
-   if (!dr)
-   continue;
+   RTE_LOG(DEBUG, EAL,
+   "PCI device "PCI_PRI_FMT" on 

[dpdk-dev] [PATCH v2 9/9] pci: implement automatic bind/unbind

2016-01-29 Thread David Marchand
Reuse pci hook to implement automatic bind / unbind.
The more I look at this, the more I think this should go to the PMDs
themselves (with options per devices to control this), with EAL offering
helpers to achieve this.

Signed-off-by: David Marchand 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c|  25 
 lib/librte_eal/common/eal_common_options.c |   8 ++
 lib/librte_eal/common/eal_common_pci.c |  79 +++
 lib/librte_eal/common/eal_options.h|   2 +
 lib/librte_eal/common/eal_private.h|  38 ++
 lib/librte_eal/common/include/rte_pci.h|   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 210 +
 7 files changed, 367 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index e95249b..130f7e9 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -91,6 +91,31 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev 
__rte_unused)
return -ENOTSUP;
 }

+int
+pci_rebind_device(const struct rte_pci_device *dev __rte_unused,
+ const char *driver __rte_unused)
+{
+   RTE_LOG(ERR, EAL, "Rebinding device to pci kernel drivers is not 
implemented for BSD\n");
+   return -ENOTSUP;
+}
+
+int
+pci_mapping_driver_bound(const struct rte_pci_device *dev)
+{
+   int ret;
+
+   switch (dev->kdrv) {
+   case RTE_KDRV_NIC_UIO:
+   ret = 1;
+   break;
+   default:
+   ret = 0;
+   break;
+   }
+
+   return ret;
+}
+
 /* Map pci device */
 int
 pci_map_device(struct rte_pci_device *dev)
diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 29942ea..b646abd 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -54,6 +54,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_options.h"
 #include "eal_filesystem.h"
+#include "eal_private.h"

 #define BITS_PER_HEX 4

@@ -95,6 +96,7 @@ eal_long_options[] = {
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
{OPT_VMWARE_TSC_MAP,0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
{OPT_XEN_DOM0,  0, NULL, OPT_XEN_DOM0_NUM },
+   {OPT_PCI_UIO_AUTOBIND,  1, NULL, OPT_PCI_UIO_AUTOBIND_NUM },
{0, 0, NULL, 0}
 };

@@ -897,6 +899,10 @@ eal_parse_common_option(int opt, const char *optarg,
}
break;

+   case OPT_PCI_UIO_AUTOBIND_NUM:
+   pci_init_autobind(optarg);
+   break;
+
/* don't know what to do, leave this to caller */
default:
return 1;
@@ -1019,5 +1025,7 @@ eal_common_usage(void)
   "  --"OPT_NO_PCI"Disable PCI\n"
   "  --"OPT_NO_HPET"   Disable HPET\n"
   "  --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
+  "  --"OPT_PCI_UIO_AUTOBIND"  Set default kernel driver to bind 
pci devices,\n"
+  "when their associated pmd requires 
uio\n"
   "\n", RTE_MAX_LCORE);
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 4a0ec73..04a2490 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -89,6 +89,8 @@ struct pci_device_list pci_device_list =

 enum rte_eal_pci_hook {
RTE_EAL_PCI_SCAN,
+   RTE_EAL_PCI_ATTACH,
+   RTE_EAL_PCI_DETACH,
 };

 enum rte_eal_pci_hook_return {
@@ -132,6 +134,8 @@ blacklist_pci_hook(enum rte_eal_pci_hook h,
ret = RTE_EAL_PCI_HOOK_OK;
break;
}
+   case RTE_EAL_PCI_ATTACH:
+   case RTE_EAL_PCI_DETACH:
default:
/* nothing to do here, just say ok */
ret = RTE_EAL_PCI_HOOK_OK;
@@ -141,6 +145,61 @@ blacklist_pci_hook(enum rte_eal_pci_hook h,
return ret;
 }

+static char *uio_default_driver;
+
+static int
+autobind_uio_pci_hook(enum rte_eal_pci_hook h,
+ struct rte_pci_driver *dr,
+ struct rte_pci_device *dev)
+{
+   int ret;
+
+   /* stack with blacklist_pci_hook */
+   ret = blacklist_pci_hook(h, dr, dev);
+   if (ret != RTE_EAL_PCI_HOOK_OK)
+   goto exit;
+
+   switch (h) {
+   case RTE_EAL_PCI_ATTACH:
+   {
+   /* either nothing needed, or already bound */
+   if (!(dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) ||
+   pci_mapping_driver_bound(dev)) {
+   ret = RTE_EAL_PCI_HOOK_OK;
+   goto exit;
+   }
+
+   if (pci_rebind_device(dev, uio_default_driver) < 0 ||
+   pci_refresh_device(>addr) < 0)
+   ret = RTE_EAL_PCI_HOOK_ERROR;
+   else
+  

[dpdk-dev] [RFC PATCH 0/2] Fix examples/distributor build issue for non x86

2016-01-29 Thread Bruce Richardson
On Fri, Jan 29, 2016 at 08:51:41AM +0530, Jerin Jacob wrote:
> On Sun, Dec 06, 2015 at 08:54:28PM +0530, Jerin Jacob wrote:
> > Introduced rte_prefetch_non_temporal() to remove IA specific 
> > _mm_prefect(addr, 0)
> > gcc intrinsic and build examples/distributor for non 86 platform
> 
> ping for review.
> 

Is there much performance difference between making this a prefetch NT vs making
it an rte_prefetch0 on the platforms you have tested?

/Bruce

> > 
> > Not sure the rte_prefetch_non_temporal mapping correct for
> > all the platforms. Architecture maintainers please check the mapping for
> > rte_prefetch_non_temporal() for specific architecures
> > 
> > Jerin Jacob (2):
> >   eal: introduce rte_prefetch_non_temporal
> >   examples/distributor: remove IA specific __mm_prefetch
> > 
> >  examples/distributor/main.c  |  9 +
> >  lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h |  5 +
> >  lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h |  5 +
> >  lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h |  5 +
> >  lib/librte_eal/common/include/arch/tile/rte_prefetch.h   |  5 +
> >  lib/librte_eal/common/include/arch/x86/rte_prefetch.h|  5 +
> >  lib/librte_eal/common/include/generic/rte_prefetch.h | 12 
> >  7 files changed, 42 insertions(+), 4 deletions(-)
> > 
> > --
> > 2.1.0
> > 


[dpdk-dev] [PATCH 1/4] lib/librte_port: add PCAP file support to source port

2016-01-29 Thread Zhang, Roy Fan
Hi Panu,

Thank you for the careful review and comments.

On 28/01/2016 11:54, Panu Matilainen wrote:
> On 01/27/2016 07:39 PM, Fan Zhang wrote:
>> Originally, source ports in librte_port is an input port used as packet
>> generator. Similar to Linux kernel /dev/zero character device, it
>> generates null packets. This patch adds optional PCAP file support to
>> source port: instead of sending NULL packets, the source port generates
>> packets copied from a PCAP file. To increase the performance, the 
>> packets
>> in the file are loaded to memory initially, and copied to mbufs in 
>> circular
>> manner. Users can enable or disable this feature by setting
>> CONFIG_RTE_PORT_PCAP compiler option "y" or "n".
>>
>> Signed-off-by: Fan Zhang 
>> Acked-by: Cristian Dumitrescu 
>> ---
>>   config/common_bsdapp   |   1 +
>>   config/common_linuxapp |   1 +
>>   lib/librte_port/Makefile   |   4 +
>>   lib/librte_port/rte_port_source_sink.c | 190 
>> +
>>   lib/librte_port/rte_port_source_sink.h |   7 ++
>>   mk/rte.app.mk  |   1 +
>>   6 files changed, 204 insertions(+)
>>
> [...]
>> +#ifdef RTE_PORT_PCAP
>> +
>> +/**
>> + * Load PCAP file, allocate and copy packets in the file to memory
>> + *
>> + * @param p
>> + *   Parameters for source port
>> + * @param port
>> + *   Handle to source port
>> + * @param socket_id
>> + *   Socket id where the memory is created
>> + * @return
>> + *   0 on SUCCESS
>> + *   error code otherwise
>> + */
>> +static int
>> +pcap_source_load(struct rte_port_source_params *p,
>> +struct rte_port_source *port,
>> +int socket_id)
>> +{
> [...]
>> +#else
>> +static int
>> +pcap_source_load(__rte_unused struct rte_port_source_params *p,
>> +struct rte_port_source *port,
>> +__rte_unused int socket_id)
>> +{
>> +port->pkt_buff = NULL;
>> +port->pkt_len = NULL;
>> +port->pkts = NULL;
>> +port->pkt_index = 0;
>> +
>> +return 0;
>> +}
>> +#endif
>
> Same as in patch 3/4, shouldn't this return -ENOTSUP when pcap support 
> is not built in, instead of success?

Thank you for the suggestion. I will make the change in V2.

> [...]
>
>> diff --git a/lib/librte_port/rte_port_source_sink.h 
>> b/lib/librte_port/rte_port_source_sink.h
>> index 0f9be79..6f39bec 100644
>> --- a/lib/librte_port/rte_port_source_sink.h
>> +++ b/lib/librte_port/rte_port_source_sink.h
>> @@ -53,6 +53,13 @@ extern "C" {
>>   struct rte_port_source_params {
>>   /** Pre-initialized buffer pool */
>>   struct rte_mempool *mempool;
>> +/** The full path of the pcap file to read packets from */
>> +char *file_name;
>> +/** The number of bytes to be read from each packet in the
>> + *  pcap file. If this value is 0, the whole packet is read;
>> + *  if it is bigger than packet size, the generated packets
>> + *  will contain the whole packet */
>> +uint32_t n_bytes_per_pkt;
>>   };
>
> This is a likely ABI-break. It "only" appends to the struct, which 
> might in some cases be okay but only when there's no sensible use for 
> the struct within arrays or embedded in structs. The ip_pipeline 
> example for example embeds struct rte_port_source_params within 
> another struct which is could be thought of as an indication that 
> other applications might be doing this as well.
>
> An ABI break for librte_port has not been announced for 2.3 so you'd 
> need to announce the intent to do so in 2.4 now, and then either wait 
> till post 2.3 or wrap this in CONFIG_RTE_NEXT_ABI.
> - Panu -

Before Submitting the patch I have run validate-abi script, the 
validation results showed "compatible" on all libraries.

Also, the patch's added line in the rte_port_source_sink.c was ensured 
that, if the CONFIG_RTE_PORT_PCAP compiler option is set to "n" (by 
default), the added read-only elements in the new rte_source_params 
structure won't be touched.
CONFIG_RTE_PORT_PCAP compiler option lies in config/comm_bsdapp and 
config/com_linuxapp, and is freshly added in this patch.

If an application is built on top of latest release version of 
rte_port_source_sink library, it shall work fine with the new library if 
the new CONFIG_RTE_PORT_PCAP opition is left the default "n".
ip_pipeline example works fine this way.

I hope this changes your mind on breaking the ABI.

Best regards,
Fan


[dpdk-dev] [PATCH 3/4] lib/librte_port: add packet dumping to PCAP file support in sink port

2016-01-29 Thread Zhang, Roy Fan
Hi Panu,

Thank you again for careful review and comments.

On 28/01/2016 11:43, Panu Matilainen wrote:
> On 01/27/2016 07:39 PM, Fan Zhang wrote:
>> Originally, sink ports in librte_port releases received mbufs back to
>> mempool. This patch adds optional packet dumping to PCAP feature in sink
>> port: the packets will be dumped to user defined PCAP file for 
>> storage or
>> debugging. The user may also choose the sink port's activity: either it
>> continuously dump the packets to the file, or stops at certain dumping
>>
>> This feature shares same CONFIG_RTE_PORT_PCAP compiler option as source
>> port PCAP file support feature. Users can enable or disable this feature
>> by setting CONFIG_RTE_PORT_PCAP compiler option "y" or "n".
>>
>> Signed-off-by: Fan Zhang 
>> Acked-by: Cristian Dumitrescu 
>> ---
>>   lib/librte_port/rte_port_source_sink.c | 268 
>> +++--
>>   lib/librte_port/rte_port_source_sink.h |  11 +-
>>   2 files changed, 263 insertions(+), 16 deletions(-)
>>
> [...]
>> +#ifdef RTE_PORT_PCAP
>> +
>> +/**
>> + * Open PCAP file for dumping packets to the file later
>> + *
>> + * @param port
>> + *   Handle to sink port
>> + * @param p
>> + *   Sink port parameter
>> + * @return
>> + *   0 on SUCCESS
>> + *   error code otherwise
>> + */
> [...]
>> +
>> +#else
>> +
>> +static int
>> +pcap_sink_open(struct rte_port_sink *port,
>> +__rte_unused struct rte_port_sink_params *p)
>> +{
>> +port->dumper = NULL;
>> +port->max_pkts = 0;
>> +port->pkt_index = 0;
>> +port->dump_finish = 0;
>> +
>> +return 0;
>> +}
>
> Shouldn't this just return -ENOTSUP instead of success when the pcap 
> feature is not built in?

I agree, I will modify the code in v2.

>> +
>> +static void
>> +pcap_sink_dump_pkt(__rte_unused struct rte_port_sink *port,
>> +__rte_unused struct rte_mbuf *mbuf) {}
>> +
>> +static void
>> +pcap_sink_flush_pkt(__rte_unused void *dumper) {}
>> +
>> +static void
>> +pcap_sink_close(__rte_unused void *dumper) {}
>> +
>> +#endif
>> +
>>   static void *
>>   rte_port_sink_create(__rte_unused void *params, int socket_id)
>>   {
>>   struct rte_port_sink *port;
>> +struct rte_port_sink_params *p = params;
>> +int status;
>>
>>   /* Memory allocation */
>>   port = rte_zmalloc_socket("PORT", sizeof(*port),
>> @@ -360,6 +532,19 @@ rte_port_sink_create(__rte_unused void *params, 
>> int socket_id)
>>   return NULL;
>>   }
>>
>> +/* Try to open PCAP file for dumping, if possible */
>> +status = pcap_sink_open(port, p);
>> +if (status < 0) {
>> +RTE_LOG(ERR, PORT, "%s: Failed to enable PCAP support "
>> +"support\n", __func__);
>> +rte_free(port);
>> +port = NULL;
>> +} else {
>> +if (port->dumper != NULL)
>> +RTE_LOG(INFO, PORT, "Ready to dump packets to file "
>> +"%s\n", p->file_name);
>> +}
>> +
>>   return port;
>>   }
>>
>> @@ -369,6 +554,8 @@ rte_port_sink_tx(void *port, struct rte_mbuf *pkt)
>>   __rte_unused struct rte_port_sink *p = (struct rte_port_sink *) 
>> port;
>>
>>   RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1);
>> +if (p->dumper != NULL)
>> +pcap_sink_dump_pkt(p, pkt);
>>   rte_pktmbuf_free(pkt);
>>   RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1);
>>
>> @@ -387,21 +574,44 @@ rte_port_sink_tx_bulk(void *port, struct 
>> rte_mbuf **pkts,
>>
>>   RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, n_pkts);
>>   RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, n_pkts);
>> -for (i = 0; i < n_pkts; i++) {
>> -struct rte_mbuf *pkt = pkts[i];
>> -
>> -rte_pktmbuf_free(pkt);
>> +if (p->dumper) {
>> +for (i = 0; i < n_pkts; i++) {
>> +struct rte_mbuf *pkt = pkts[i];
>> +
>> +pcap_sink_dump_pkt(p, pkt);
>> +rte_pktmbuf_free(pkt);
>> +}
>> +} else {
>> +for (i = 0; i < n_pkts; i++) {
>> +struct rte_mbuf *pkt = pkts[i];
>> +
>> +rte_pktmbuf_free(pkt);
>> +}
>>   }
>>   } else {
>> -for ( ; pkts_mask; ) {
>> -uint32_t pkt_index = __builtin_ctzll(pkts_mask);
>> -uint64_t pkt_mask = 1LLU << pkt_index;
>> -struct rte_mbuf *pkt = pkts[pkt_index];
>> -
>> -RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1);
>> -RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1);
>> -rte_pktmbuf_free(pkt);
>> -pkts_mask &= ~pkt_mask;
>> +if (p->dumper) {
>> +for ( ; pkts_mask; ) {
>> +uint32_t pkt_index = __builtin_ctzll(pkts_mask);
>> +uint64_t pkt_mask = 1LLU << pkt_index;
>> +struct rte_mbuf *pkt = pkts[pkt_index];
>> +
>> +RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1);
>> +RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1);
>> +pcap_sink_dump_pkt(p, pkt);
>> +  

[dpdk-dev] [PATCH v2 1/1] jobstats: added function abort for job

2016-01-29 Thread Marcin Kerlin
This patch adds new function rte_jobstats_abort. It marks *job* as finished
and time of this work will be add to management time instead of execution time.
This function should be used instead of rte_jobstats_finish if condition occurs,
condition is defined by the application for example when receiving n>0 packets.

v2:
* removed redundant field

Signed-off-by: Marcin Kerlin 
---
 lib/librte_jobstats/rte_jobstats.c   | 20 
 lib/librte_jobstats/rte_jobstats.h   | 14 ++
 lib/librte_jobstats/rte_jobstats_version.map |  7 +++
 3 files changed, 41 insertions(+)

diff --git a/lib/librte_jobstats/rte_jobstats.c 
b/lib/librte_jobstats/rte_jobstats.c
index 2eaac0c..2b42050 100644
--- a/lib/librte_jobstats/rte_jobstats.c
+++ b/lib/librte_jobstats/rte_jobstats.c
@@ -170,6 +170,26 @@ rte_jobstats_start(struct rte_jobstats_context *ctx, 
struct rte_jobstats *job)
 }

 int
+rte_jobstats_abort(struct rte_jobstats *job)
+{
+   struct rte_jobstats_context *ctx;
+   uint64_t now, exec_time;
+
+   /* Some sanity check. */
+   if (unlikely(job == NULL || job->context == NULL))
+   return -EINVAL;
+
+   ctx = job->context;
+   now = get_time();
+   exec_time = now - ctx->state_time;
+   ADD_TIME_MIN_MAX(ctx, management, exec_time);
+   ctx->state_time = now;
+   job->context = NULL;
+
+   return 0;
+}
+
+int
 rte_jobstats_finish(struct rte_jobstats *job, int64_t job_value)
 {
struct rte_jobstats_context *ctx;
diff --git a/lib/librte_jobstats/rte_jobstats.h 
b/lib/librte_jobstats/rte_jobstats.h
index de6a89a..c2b285f 100644
--- a/lib/librte_jobstats/rte_jobstats.h
+++ b/lib/librte_jobstats/rte_jobstats.h
@@ -237,6 +237,20 @@ int
 rte_jobstats_start(struct rte_jobstats_context *ctx, struct rte_jobstats *job);

 /**
+ * Mark that *job* finished its execution, but time of this work will be 
skipped
+ * and added to management time.
+ *
+ * @param job
+ *  Job object.
+ *
+ * @return
+ *  0 on success
+ *  -EINVAL if job is NULL or job was not started (it have no context).
+ */
+int
+rte_jobstats_abort(struct rte_jobstats *job);
+
+/**
  * Mark that *job* finished its execution. Context in which it was executing
  * will receive stat update. After this function call *job* object is ready to
  * be executed in other context.
diff --git a/lib/librte_jobstats/rte_jobstats_version.map 
b/lib/librte_jobstats/rte_jobstats_version.map
index cb01bfd..e3b21ca 100644
--- a/lib/librte_jobstats/rte_jobstats_version.map
+++ b/lib/librte_jobstats/rte_jobstats_version.map
@@ -17,3 +17,10 @@ DPDK_2.0 {

local: *;
 };
+
+DPDK_2.3 {
+   global:
+
+   rte_jobstats_abort;
+
+} DPDK_2.0;
-- 
1.9.1



[dpdk-dev] [PATCH 0/4] DPDK polling-mode driver for Amazon Elastic Network Adapters (ENA)

2016-01-29 Thread Jan Mędala
Hello Thomas,

2016-01-28 16:40 GMT+01:00 Thomas Monjalon :

> >  lib/librte_eal/linuxapp/ena_uio/ena_uio_driver.c   |  276 +++
>
> Sorry the kernel module party is over.
> One day, igb_uio will be removed.
> I suggest to make a first version without interrupt support
> and work with Linux community to fix your issues.
>

Rationale to deliver UIO kernel module is based on lack of legacy INTx
interrupts in ENA device. It's operating only on MSI-X.
Currently we do not implement interrupt support (yet) in PMD, but hardware
was unable to operate under uio_generic_pci driver - probe is failing.
It might be possible to use igb_uio kmod with ENA and I will do necessary
investigation+experiments to prove that.

Could you elaborate on the topic of kernel module removal - how would it
look like, is there going to be generic PCI driver dedicated for MSI-X
devices?

Thanks,
Jan


[dpdk-dev] [PATCH 2/2] kdp: add virtual PMD for kernel slow data path communication

2016-01-29 Thread Yigit, Ferruh
On Thu, Jan 28, 2016 at 08:16:09AM +, Xu, Qian Q wrote:
> Any dependencies with kernel versions? What kernel versions should it 
> support? 
> 
Hi Qian,

Kernel module dependencies is same as KNI, and DPDK supports Kernel version >= 
2.6.34, this is valid for KDP.

For PMD, it is not dependent but uses tun/tap interface, and tun/tap also 
supported for kernel versions >= 2.6.34.

Thanks,
ferruh


[dpdk-dev] [PATCH 0/4] DPDK polling-mode driver for Amazon Elastic Network Adapters (ENA)

2016-01-29 Thread Thomas Monjalon
2016-01-29 16:42, Jan M?dala:
> Hello Thomas,
> 
> 2016-01-28 16:40 GMT+01:00 Thomas Monjalon :
> 
> > >  lib/librte_eal/linuxapp/ena_uio/ena_uio_driver.c   |  276 +++
> >
> > Sorry the kernel module party is over.
> > One day, igb_uio will be removed.
> > I suggest to make a first version without interrupt support
> > and work with Linux community to fix your issues.
> 
> Rationale to deliver UIO kernel module is based on lack of legacy INTx
> interrupts in ENA device. It's operating only on MSI-X.
> Currently we do not implement interrupt support (yet) in PMD, but hardware
> was unable to operate under uio_generic_pci driver - probe is failing.
> It might be possible to use igb_uio kmod with ENA and I will do necessary
> investigation+experiments to prove that.
> 
> Could you elaborate on the topic of kernel module removal - how would it
> look like, is there going to be generic PCI driver dedicated for MSI-X
> devices?

VFIO is the driver which should cover every needs for userspace drivers
requiring a generic kernel module. Another approach is used for mlx devices.
Thanks for checking how to improve your driver.

My other question was about documentation. I don't know your device.
Please any info or pointer?


[dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

2016-01-29 Thread Nélio Laranjeiro
Hi Marc,

On Fri, Jan 29, 2016 at 01:42:05AM +0100, Marc Sune wrote:
>[...]
>  /**
> - * Device supported speeds
> - */
> -#define ETH_SPEED_CAP_NOT_PHY(0)  /*< No phy media > */
> -#define ETH_SPEED_CAP_10M_HD (1 << 0)  /*< 10 Mbps half-duplex> */
> -#define ETH_SPEED_CAP_10M_FD (1 << 1)  /*< 10 Mbps full-duplex> */
> -#define ETH_SPEED_CAP_100M_HD(1 << 2)  /*< 100 Mbps half-duplex> */
> -#define ETH_SPEED_CAP_100M_FD(1 << 3)  /*< 100 Mbps full-duplex> */
> -#define ETH_SPEED_CAP_1G (1 << 4)  /*< 1 Gbps > */
> -#define ETH_SPEED_CAP_2_5G   (1 << 5)  /*< 2.5 Gbps > */
> -#define ETH_SPEED_CAP_5G (1 << 6)  /*< 5 Gbps > */
> -#define ETH_SPEED_CAP_10G(1 << 7)  /*< 10 Mbps > */
> -#define ETH_SPEED_CAP_20G(1 << 8)  /*< 20 Gbps > */
> -#define ETH_SPEED_CAP_25G(1 << 9)  /*< 25 Gbps > */
> -#define ETH_SPEED_CAP_40G(1 << 10)  /*< 40 Gbps > */
> -#define ETH_SPEED_CAP_50G(1 << 11)  /*< 50 Gbps > */
> -#define ETH_SPEED_CAP_56G(1 << 12)  /*< 56 Gbps > */
> -#define ETH_SPEED_CAP_100G   (1 << 13)  /*< 100 Gbps > */
>[...]

In the previous commit you update mlx4.c to use those define, in this
commit it should update it again.

Regards,

-- 
N?lio Laranjeiro
6WIND


[dpdk-dev] [PATCH 0/3] null driver improvements for testability

2016-01-29 Thread Paul Atkins
This patchset adds functionality to the null driver help when testing
a dataplane that uses dpdk.  The idea is that the the dataplane can
have multiple null interfaces attached, and each of theses can be
assigned a mac address. Packets can then be injected into the null
drivers by adding them to a ring, giving the application complete
control of the packets that arrive.  Packets that are sent by a null
driver can be stored on a ring, where the application can pick them up
and verify it is what was expected.  To allow the application to know
when packets have been pulled of the rx ring, counters of the number of
times an rx poll has been made are kept, and these can be retrieved via
the existing APIs.

All of these enhancements are using the existing APIs, and do not
modify the existing behaviour of the null driver if these features
are not configured.


Paul Atkins (3):
  null: add a new arg to allow users to specify ether address
  null: add rings to allow user to provide the mbufs for rx/tx
  null: add xstats to provide the number of rx polls

 drivers/net/null/rte_eth_null.c |  214 +--
 1 file changed, 203 insertions(+), 11 deletions(-)

-- 
1.7.10.4



[dpdk-dev] [PATCH 1/3] null: add a new arg to allow users to specify ether address

2016-01-29 Thread Paul Atkins
Add a new argument to the null driver to allow the user to
specify the ether address to be used instead of the default
which is all zeroes. This also allows the user to specify
an address per device instead of them all using the same
default one.

Signed-off-by: Paul Atkins 
---
 drivers/net/null/rte_eth_null.c |   59 +++
 1 file changed, 48 insertions(+), 11 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 77fc988..9483d6a 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -41,15 +41,21 @@

 #include "rte_eth_null.h"

+#include 
+#include 
+
 #define ETH_NULL_PACKET_SIZE_ARG   "size"
 #define ETH_NULL_PACKET_COPY_ARG   "copy"
+#define ETH_NULL_ETH_ADDR_ARG  "eth_addr"

 static unsigned default_packet_size = 64;
 static unsigned default_packet_copy;
+static struct ether_addr default_eth_addr = { .addr_bytes = {0} };

 static const char *valid_arguments[] = {
ETH_NULL_PACKET_SIZE_ARG,
ETH_NULL_PACKET_COPY_ARG,
+   ETH_NULL_ETH_ADDR_ARG,
NULL
 };

@@ -69,6 +75,7 @@ struct null_queue {
 struct pmd_internals {
unsigned packet_size;
unsigned packet_copy;
+   struct ether_addr eth_addr;
unsigned numa_node;

unsigned nb_rx_queues;
@@ -89,8 +96,6 @@ struct pmd_internals {
uint8_t rss_key[40];/**< 40-byte hash key. */
 };

-
-static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
.link_speed = 1,
@@ -485,11 +490,12 @@ static const struct eth_dev_ops ops = {
.rss_hash_conf_get = eth_rss_hash_conf_get
 };

-int
-eth_dev_null_create(const char *name,
-   const unsigned numa_node,
-   unsigned packet_size,
-   unsigned packet_copy)
+static int
+eth_dev_null_create_internal(const char *name,
+const unsigned numa_node,
+unsigned packet_size,
+unsigned packet_copy,
+struct ether_addr eth_addr)
 {
const unsigned nb_rx_queues = 1;
const unsigned nb_tx_queues = 1;
@@ -539,6 +545,7 @@ eth_dev_null_create(const char *name,
internals->nb_tx_queues = nb_tx_queues;
internals->packet_size = packet_size;
internals->packet_copy = packet_copy;
+   internals->eth_addr = eth_addr;
internals->numa_node = numa_node;

internals->flow_type_rss_offloads =  ETH_RSS_PROTO_MASK;
@@ -551,7 +558,7 @@ eth_dev_null_create(const char *name,
data->nb_rx_queues = (uint16_t)nb_rx_queues;
data->nb_tx_queues = (uint16_t)nb_tx_queues;
data->dev_link = pmd_link;
-   data->mac_addrs = _addr;
+   data->mac_addrs = >eth_addr;
strncpy(data->name, eth_dev->data->name, strlen(eth_dev->data->name));

eth_dev->data = data;
@@ -583,6 +590,16 @@ error:
return -1;
 }

+int
+eth_dev_null_create(const char *name,
+   const unsigned numa_node,
+   unsigned packet_size,
+   unsigned packet_copy)
+{
+   return eth_dev_null_create_internal(name, numa_node, packet_size,
+   packet_copy, default_eth_addr);
+}
+
 static inline int
 get_packet_size_arg(const char *key __rte_unused,
const char *value, void *extra_args)
@@ -617,12 +634,24 @@ get_packet_copy_arg(const char *key __rte_unused,
return 0;
 }

+static inline int
+get_eth_addr_arg(const char *key __rte_unused,
+const char *value, void *extra_args)
+{
+   if (value == NULL || extra_args == NULL)
+   return -EINVAL;
+
+   return cmdline_parse_etheraddr(NULL, value, extra_args,
+  sizeof(struct ether_addr));
+}
+
 static int
 rte_pmd_null_devinit(const char *name, const char *params)
 {
unsigned numa_node;
unsigned packet_size = default_packet_size;
unsigned packet_copy = default_packet_copy;
+   struct ether_addr eth_addr = default_eth_addr;
struct rte_kvargs *kvlist = NULL;
int ret;

@@ -639,7 +668,6 @@ rte_pmd_null_devinit(const char *name, const char *params)
return -1;

if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_SIZE_ARG) == 1) {
-
ret = rte_kvargs_process(kvlist,
ETH_NULL_PACKET_SIZE_ARG,
_packet_size_arg, _size);
@@ -648,20 +676,29 @@ rte_pmd_null_devinit(const char *name, const char *params)
}

if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_COPY_ARG) == 1) {
-
ret = rte_kvargs_process(kvlist,
ETH_NULL_PACKET_COPY_ARG,

[dpdk-dev] [PATCH 2/3] null: add rings to allow user to provide the mbufs for rx/tx

2016-01-29 Thread Paul Atkins
When using the null driver it is useful to be able to
provide a set of mbufs to be received on the interface.
Add an option to specify a ring that the driver can poll to
provide the set of packets that have been received.  Add a
similar ring for the tx side where the packets that are being
transmitted can be stored, so the user can see what was sent.

Signed-off-by: Paul Atkins 
---
 drivers/net/null/rte_eth_null.c |   91 +--
 1 file changed, 88 insertions(+), 3 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 9483d6a..176f477 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -47,6 +47,8 @@
 #define ETH_NULL_PACKET_SIZE_ARG   "size"
 #define ETH_NULL_PACKET_COPY_ARG   "copy"
 #define ETH_NULL_ETH_ADDR_ARG  "eth_addr"
+#define ETH_NULL_RX_RING   "rx_ring"
+#define ETH_NULL_TX_RING   "tx_ring"

 static unsigned default_packet_size = 64;
 static unsigned default_packet_copy;
@@ -56,6 +58,8 @@ static const char *valid_arguments[] = {
ETH_NULL_PACKET_SIZE_ARG,
ETH_NULL_PACKET_COPY_ARG,
ETH_NULL_ETH_ADDR_ARG,
+   ETH_NULL_RX_RING,
+   ETH_NULL_TX_RING,
NULL
 };

@@ -76,6 +80,8 @@ struct pmd_internals {
unsigned packet_size;
unsigned packet_copy;
struct ether_addr eth_addr;
+   struct rte_ring *rx_ring;
+   struct rte_ring *tx_ring;
unsigned numa_node;

unsigned nb_rx_queues;
@@ -158,6 +164,22 @@ eth_null_copy_rx(void *q, struct rte_mbuf **bufs, uint16_t 
nb_bufs)
 }

 static uint16_t
+eth_null_copy_rx_from_ring(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+   int i;
+   struct null_queue *h = q;
+
+   if ((q == NULL) || (bufs == NULL) || (nb_bufs == 0))
+   return 0;
+
+   i = rte_ring_mc_dequeue_burst(h->internals->rx_ring, (void **)bufs,
+ nb_bufs);
+   rte_atomic64_add(>rx_pkts, 1);
+
+   return i;
+}
+
+static uint16_t
 eth_null_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
int i;
@@ -196,6 +218,23 @@ eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t 
nb_bufs)
return i;
 }

+static uint16_t
+eth_null_copy_tx_to_ring(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+   int i;
+   struct null_queue *h = q;
+
+   if ((q == NULL) || (bufs == NULL) || (nb_bufs == 0))
+   return 0;
+
+   i = rte_ring_enqueue_burst(h->internals->tx_ring, (void **)bufs,
+  nb_bufs);
+
+   rte_atomic64_add(>tx_pkts, 1);
+
+   return i;
+}
+
 static int
 eth_dev_configure(struct rte_eth_dev *dev) {
struct pmd_internals *internals;
@@ -495,7 +534,11 @@ eth_dev_null_create_internal(const char *name,
 const unsigned numa_node,
 unsigned packet_size,
 unsigned packet_copy,
-struct ether_addr eth_addr)
+struct ether_addr eth_addr,
+struct rte_ring *rx_ring,
+struct rte_ring *tx_ring
+
+   )
 {
const unsigned nb_rx_queues = 1;
const unsigned nb_tx_queues = 1;
@@ -546,6 +589,8 @@ eth_dev_null_create_internal(const char *name,
internals->packet_size = packet_size;
internals->packet_copy = packet_copy;
internals->eth_addr = eth_addr;
+   internals->rx_ring = rx_ring;
+   internals->tx_ring = tx_ring;
internals->numa_node = numa_node;

internals->flow_type_rss_offloads =  ETH_RSS_PROTO_MASK;
@@ -580,6 +625,10 @@ eth_dev_null_create_internal(const char *name,
eth_dev->rx_pkt_burst = eth_null_rx;
eth_dev->tx_pkt_burst = eth_null_tx;
}
+   if (rx_ring)
+   eth_dev->rx_pkt_burst = eth_null_copy_rx_from_ring;
+   if (tx_ring)
+   eth_dev->tx_pkt_burst = eth_null_copy_tx_to_ring;

return 0;

@@ -597,7 +646,8 @@ eth_dev_null_create(const char *name,
unsigned packet_copy)
 {
return eth_dev_null_create_internal(name, numa_node, packet_size,
-   packet_copy, default_eth_addr);
+   packet_copy, default_eth_addr,
+   NULL, NULL);
 }

 static inline int
@@ -645,6 +695,23 @@ get_eth_addr_arg(const char *key __rte_unused,
   sizeof(struct ether_addr));
 }

+static inline int
+get_ring_arg(const char *key __rte_unused,
+const char *value, void *extra_args)
+{
+   const char *a = value;
+   struct rte_ring **ring = extra_args;
+
+   if ((value == NULL) || (extra_args == NULL))
+   return -EINVAL;
+
+   *ring = rte_ring_create(a, 64, SOCKET_ID_ANY, 0);
+   if 

[dpdk-dev] [PATCH 3/3] null: add xstats to provide the number of rx polls

2016-01-29 Thread Paul Atkins
When using the null driver and passing in packets via
the rx ring, it is useful to know that the driver has
polled the ring. Add a count of rx polls to the xstats
to provide this information.

Signed-off-by: Paul Atkins 
---
 drivers/net/null/rte_eth_null.c |   70 +++
 1 file changed, 70 insertions(+)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 176f477..3feab44 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -65,6 +65,15 @@ static const char *valid_arguments[] = {

 struct pmd_internals;

+struct eth_null_xstats {
+   rte_atomic64_t rx_polls;
+   rte_atomic64_t tx_polls;
+};
+
+struct eth_null_hw_stats {
+   uint64_t rx_polls;
+};
+
 struct null_queue {
struct pmd_internals *internals;

@@ -74,6 +83,7 @@ struct null_queue {
rte_atomic64_t rx_pkts;
rte_atomic64_t tx_pkts;
rte_atomic64_t err_pkts;
+   struct eth_null_xstats xstats;
 };

 struct pmd_internals {
@@ -109,6 +119,19 @@ static struct rte_eth_link pmd_link = {
.link_status = 0
 };

+/* store statistics names and its offset in stats structure */
+struct eth_null_xstats_name_off {
+   char name[RTE_ETH_XSTATS_NAME_SIZE];
+   unsigned offset;
+};
+
+static const struct eth_null_xstats_name_off eth_null_stats_strings[] = {
+   {"rx_polls", offsetof(struct eth_null_xstats, rx_polls)},
+};
+
+#define ETH_NULL_NB_XSTATS_PER_Q (sizeof(eth_null_stats_strings) / \
+ sizeof(eth_null_stats_strings[0]))
+
 static uint16_t
 eth_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
@@ -175,6 +198,7 @@ eth_null_copy_rx_from_ring(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
i = rte_ring_mc_dequeue_burst(h->internals->rx_ring, (void **)bufs,
  nb_bufs);
rte_atomic64_add(>rx_pkts, 1);
+   rte_atomic64_add(>xstats.rx_polls, 1);

return i;
 }
@@ -231,6 +255,7 @@ eth_null_copy_tx_to_ring(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
   nb_bufs);

rte_atomic64_add(>tx_pkts, 1);
+   rte_atomic64_add(>tx_pkts, i);

return i;
 }
@@ -410,6 +435,49 @@ eth_stats_reset(struct rte_eth_dev *dev)
}
 }

+static int
+eth_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
+  unsigned n)
+{
+   struct pmd_internals *internal;
+   unsigned count = ETH_NULL_NB_XSTATS_PER_Q * dev->data->nb_rx_queues;
+   unsigned q, i = 0;
+   uint64_t val, *stats_ptr;
+
+   if (n < count)
+   return count;
+
+   internal = dev->data->dev_private;
+
+   /* Extended stats */
+   count = 0;
+   for (q = 0; q < ETH_NULL_NB_XSTATS_PER_Q; q++) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   stats_ptr = RTE_PTR_ADD(
+   >rx_null_queues[q].xstats,
+   eth_null_stats_strings[i].offset +
+   q * sizeof(uint64_t));
+   val = *stats_ptr;
+   snprintf(xstats[count].name, sizeof(xstats[count].name),
+"rx_queue_%u_%s", q,
+eth_null_stats_strings[count].name);
+   xstats[count++].value = val;
+   }
+   }
+   return count;
+}
+
+static void
+eth_xstats_reset(struct rte_eth_dev *dev)
+{
+   struct pmd_internals *internal;
+   unsigned i;
+
+   internal = dev->data->dev_private;
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   internal->rx_null_queues[i].xstats.rx_polls.cnt = 0;
+}
+
 static void
 eth_queue_release(void *q)
 {
@@ -523,6 +591,8 @@ static const struct eth_dev_ops ops = {
.link_update = eth_link_update,
.stats_get = eth_stats_get,
.stats_reset = eth_stats_reset,
+   .xstats_get = eth_xstats_get,
+   .xstats_reset = eth_xstats_reset,
.reta_update = eth_rss_reta_update,
.reta_query = eth_rss_reta_query,
.rss_hash_update = eth_rss_hash_update,
-- 
1.7.10.4



[dpdk-dev] [PATCH 0/3] null driver improvements for testability

2016-01-29 Thread Thomas Monjalon
Hi Paul,

2016-01-29 16:18, Paul Atkins:
> This patchset adds functionality to the null driver help when testing
> a dataplane that uses dpdk.  The idea is that the the dataplane can
> have multiple null interfaces attached, and each of theses can be
> assigned a mac address. Packets can then be injected into the null
> drivers by adding them to a ring, giving the application complete
> control of the packets that arrive.  Packets that are sent by a null
> driver can be stored on a ring, where the application can pick them up
> and verify it is what was expected.  To allow the application to know
> when packets have been pulled of the rx ring, counters of the number of
> times an rx poll has been made are kept, and these can be retrieved via
> the existing APIs.

I have not read your code, just read this description.
It sounds like being a ring PMD. Have you already checked it?
http://dpdk.org/browse/dpdk/tree/drivers/net/ring/rte_eth_ring.c


[dpdk-dev] [PATCH 0/3] null driver improvements for testability

2016-01-29 Thread Paul Atkins
Hi Thomas,

On 29/01/16 16:31, Thomas Monjalon wrote:
> Hi Paul,
>
> 2016-01-29 16:18, Paul Atkins:
>> This patchset adds functionality to the null driver help when testing
>> a dataplane that uses dpdk.  The idea is that the the dataplane can
>> have multiple null interfaces attached, and each of theses can be
>> assigned a mac address. Packets can then be injected into the null
>> drivers by adding them to a ring, giving the application complete
>> control of the packets that arrive.  Packets that are sent by a null
>> driver can be stored on a ring, where the application can pick them up
>> and verify it is what was expected.  To allow the application to know
>> when packets have been pulled of the rx ring, counters of the number of
>> times an rx poll has been made are kept, and these can be retrieved via
>> the existing APIs.
> I have not read your code, just read this description.
> It sounds like being a ring PMD. Have you already checked it?
> https://urldefense.proofpoint.com/v2/url?u=http-3A__dpdk.org_browse_dpdk_tree_drivers_net_ring_rte-5Feth-5Fring.c=CwICAg=IL_XqQWOjubgfqINi2jTzg=45ezphVDEm8OnEpH-fLWdXvR3RneLhhNZRDLQRgR6LY=wJLO24XFe_B0nZve6mkvocCt7fQWo3PULCTWxrC8rZk=bIWycJrY-PYgzkQsBeRfkl8JCHFcxRAHhHDrqRSzHYs=

I hadn't seen the ring PMD. I will have a look at it and see if I can 
make it do what i need.

thanks,
Paul


[dpdk-dev] [PATCH] examples: l3fwd exact-match path rework

2016-01-29 Thread Tomasz Kulasek
Current implementation of Exact-Match uses different execution path than
for LPM. Unifying them allows to reuse big part of LPM code and sightly
increase performance of Exact-Match.

Main changes:
-
* Packet classification stage is separated from the rest of path for both
  LPM and EM.
* Packet processing, modifying and transmit part is the same for LPM and EM
  and mostly based on the current LPM implementation.
* Shared code is moved to the common file "l3fwd_sse.h".
* While sequential packet classification in EM path, seems to be faster
  than using multi hash lookup, used before, it is used by default. Old
  implementation is moved to the file l3fwd_em_hlm_sse.h and can be enabled
  with HASH_LOOKUP_MULTI global define in compilation time.


This patch depends of Ravi Kerur's "Modify and modularize l3fwd code" and
should be applied after it.

Signed-off-by: Tomasz Kulasek 
---
 examples/l3fwd/l3fwd.h|8 +
 examples/l3fwd/l3fwd_em.c |   12 +-
 examples/l3fwd/l3fwd_em_hlm_sse.h |  341 +
 examples/l3fwd/l3fwd_em_sse.h |  447 +++-
 examples/l3fwd/l3fwd_lpm.c|   15 +-
 examples/l3fwd/l3fwd_lpm_sse.h|  507 -
 examples/l3fwd/l3fwd_sse.h|  501 
 7 files changed, 943 insertions(+), 888 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd_em_hlm_sse.h
 create mode 100644 examples/l3fwd/l3fwd_sse.h

diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
index 50e40fe..9a2c8c3 100644
--- a/examples/l3fwd/l3fwd.h
+++ b/examples/l3fwd/l3fwd.h
@@ -53,6 +53,14 @@
 /* Configure how many packets ahead to prefetch, when reading packets */
 #define PREFETCH_OFFSET  3

+/* Used to mark destination port as 'invalid'. */
+#defineBAD_PORT ((uint16_t)-1)
+
+#define FWDSTEP4
+
+/* replace first 12B of the ethernet header. */
+#defineMASK_ETH 0x3f
+
 /* Hash parameters. */
 #ifdef RTE_ARCH_X86_64
 /* default to 4 million hash entries (approx) */
diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c
index e8f4fee..58f43df 100644
--- a/examples/l3fwd/l3fwd_em.c
+++ b/examples/l3fwd/l3fwd_em.c
@@ -372,7 +372,11 @@ l3fwd_em_simple_forward(struct rte_mbuf *m, uint8_t portid,
  * buffer optimization i.e. ENABLE_MULTI_BUFFER_OPTIMIZE=1.
  */
 #if defined(__SSE4_1__)
+#ifndef HASH_MULTI_LOOKUP
 #include "l3fwd_em_sse.h"
+#else
+#include "l3fwd_em_hlm_sse.h"
+#endif
 #endif

 /*
@@ -596,6 +600,7 @@ populate_ipv6_many_flow_into_table(const struct rte_hash *h,
printf("Hash: Adding 0x%x keys\n", nr_flow);
 }

+/* main processing loop */
 int
 em_main_loop(__attribute__((unused)) void *dummy)
 {
@@ -639,11 +644,8 @@ em_main_loop(__attribute__((unused)) void *dummy)
diff_tsc = cur_tsc - prev_tsc;
if (unlikely(diff_tsc > drain_tsc)) {

-   /*
-* This could be optimized (use queueid instead of
-* portid), but it is not called so often
-*/
-   for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
+   for (i = 0; i < qconf->n_rx_queue; i++) {
+   portid = qconf->rx_queue_list[i].port_id;
if (qconf->tx_mbufs[portid].len == 0)
continue;
send_burst(qconf,
diff --git a/examples/l3fwd/l3fwd_em_hlm_sse.h 
b/examples/l3fwd/l3fwd_em_hlm_sse.h
new file mode 100644
index 000..1c07cbf
--- /dev/null
+++ b/examples/l3fwd/l3fwd_em_hlm_sse.h
@@ -0,0 +1,341 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Intel Corporation. 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 Intel Corporation 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, 

[dpdk-dev] [RFC PATCH 0/2] Fix examples/distributor build issue for non x86

2016-01-29 Thread Jerin Jacob
On Fri, Jan 29, 2016 at 08:03:37AM -0700, Bruce Richardson wrote:
> On Fri, Jan 29, 2016 at 08:51:41AM +0530, Jerin Jacob wrote:
> > On Sun, Dec 06, 2015 at 08:54:28PM +0530, Jerin Jacob wrote:
> > > Introduced rte_prefetch_non_temporal() to remove IA specific 
> > > _mm_prefect(addr, 0)
> > > gcc intrinsic and build examples/distributor for non 86 platform
> > 
> > ping for review.
> > 
> 
> Is there much performance difference between making this a prefetch NT vs 
> making
> it an rte_prefetch0 on the platforms you have tested?

Not much difference. But, I think its worth keep the abstraction as
IA and arm64 architecture supports it.

Jerin

> 
> /Bruce
> 
> > > 
> > > Not sure the rte_prefetch_non_temporal mapping correct for
> > > all the platforms. Architecture maintainers please check the mapping for
> > > rte_prefetch_non_temporal() for specific architecures
> > > 
> > > Jerin Jacob (2):
> > >   eal: introduce rte_prefetch_non_temporal
> > >   examples/distributor: remove IA specific __mm_prefetch
> > > 
> > >  examples/distributor/main.c  |  9 +
> > >  lib/librte_eal/common/include/arch/arm/rte_prefetch_32.h |  5 +
> > >  lib/librte_eal/common/include/arch/arm/rte_prefetch_64.h |  5 +
> > >  lib/librte_eal/common/include/arch/ppc_64/rte_prefetch.h |  5 +
> > >  lib/librte_eal/common/include/arch/tile/rte_prefetch.h   |  5 +
> > >  lib/librte_eal/common/include/arch/x86/rte_prefetch.h|  5 +
> > >  lib/librte_eal/common/include/generic/rte_prefetch.h | 12 
> > > 
> > >  7 files changed, 42 insertions(+), 4 deletions(-)
> > > 
> > > --
> > > 2.1.0
> > > 


[dpdk-dev] which driver to bind for the NIC interfacesg

2016-01-29 Thread Bruce Richardson
On Mon, Jan 25, 2016 at 06:17:23PM +0530, Nagaraj Trivedi wrote:
> Hi all, in the Getting Started Guide for Linux, Release 2.2.0 it is 
> mentioned that we need to bind the ports to uio_pci_generic, igb_uio or 
> vfio-pci. 
> 
> I would like to know exactly among uio_pci_generic, igb_uio or vfio-pci to 
> which one I need to bind the port.
> 
> 
This is touched upon in the documentation here:
http://dpdk.org/doc/guides/linux_gsg/build_dpdk.html#loading-modules-to-enable-userspace-io-for-dpdk

The short version is that it depends upon your use-case. In all cases the
igb_uio module should work, but it is an out-of-tree kernel module. Because of
that vfio and uio_pci_generic are better alternatives, but have some 
restrictions:
* vfio requires an IOMMU be present (though this should change in future 
kernels)
* uio_pci_generic requires the device have legacy interrupts, so won't work with
  virtual function devices.

If in doubt, and if you don't care about out of tree drivers, just go with
igb_uio to start with.

/Bruce



[dpdk-dev] [PATCH 0/5] add external mempool manager

2016-01-29 Thread Jerin Jacob
On Fri, Jan 29, 2016 at 01:40:40PM +, Hunt, David wrote:
> On 28/01/2016 17:26, Jerin Jacob wrote:
> >On Tue, Jan 26, 2016 at 05:25:50PM +, David Hunt wrote:
> >>Hi all on the list.
> >>
> >>Here's a proposed patch for an external mempool manager
> >>
> >>The External Mempool Manager is an extension to the mempool API that allows
> >>users to add and use an external mempool manager, which allows external 
> >>memory
> >>subsystems such as external hardware memory management systems and software
> >>based memory allocators to be used with DPDK.
> >
> >I like this approach.It will be useful for external hardware memory
> >pool managers.
> >
> >BTW, Do you encounter any performance impact on changing to function
> >pointer based approach?
>
> Jerin,
>Thanks for your comments.
>
> The performance impacts I've seen depends on whether I'm using an object
> cache for the mempool or not. Without object cache, I see between 0-10%
> degradation. With object cache, I see a slight performance gain of between
> 0-5%. But that will most likely vary from system to system.
>
> >>The existing API to the internal DPDK mempool manager will remain unchanged
> >>and will be backward compatible.
> >>
> >>There are two aspects to external mempool manager.
> >>   1. Adding the code for your new mempool handler. This is achieved by 
> >> adding a
> >>  new mempool handler source file into the librte_mempool library, and
> >>  using the REGISTER_MEMPOOL_HANDLER macro.
> >>   2. Using the new API to call rte_mempool_create_ext to create a new 
> >> mempool
> >>  using the name parameter to identify which handler to use.
> >>
> >>New API calls added
> >>  1. A new mempool 'create' function which accepts mempool handler name.
> >>  2. A new mempool 'rte_get_mempool_handler' function which accepts mempool
> >> handler name, and returns the index to the relevant set of callbacks 
> >> for
> >> that mempool handler
> >>
> >>Several external mempool managers may be used in the same application. A new
> >>mempool can then be created by using the new 'create' function, providing 
> >>the
> >>mempool handler name to point the mempool to the relevant mempool manager
> >>callback structure.
> >>
> >>The old 'create' function can still be called by legacy programs, and will
> >>internally work out the mempool handle based on the flags provided (single
> >>producer, single consumer, etc). By default handles are created internally 
> >>to
> >>implement the built-in DPDK mempool manager and mempool types.
> >>
> >>The external mempool manager needs to provide the following functions.
> >>  1. alloc - allocates the mempool memory, and adds each object onto a 
> >> ring
> >>  2. put   - puts an object back into the mempool once an application 
> >> has
> >> finished with it
> >>  3. get   - gets an object from the mempool for use by the application
> >>  4. get_count - gets the number of available objects in the mempool
> >>  5. free  - frees the mempool memory
> >>
> >>Every time a get/put/get_count is called from the application/PMD, the
> >>callback for that mempool is called. These functions are in the fastpath,
> >>and any unoptimised handlers may limit performance.
> >>
> >>The new APIs are as follows:
> >>
> >>1. rte_mempool_create_ext
> >>
> >>struct rte_mempool *
> >>rte_mempool_create_ext(const char * name, unsigned n,
> >> unsigned cache_size, unsigned private_data_size,
> >> int socket_id, unsigned flags,
> >> const char * handler_name);
> >>
> >>2. rte_get_mempool_handler
> >>
> >>int16_t
> >>rte_get_mempool_handler(const char *name);
> >
> >Do we need above public API as, in any case we need rte_mempool* pointer to
> >operate on mempools(which has the index anyway)?
> >
> >May a similar functional API with different name/return will be
> >better to figure out, given "name" registered or not in ethernet driver
> >which has dependency on a particular HW pool manager.
>
> Good point. An earlier revision required getting the index first, then
> passing that to the create_ext call. Now that the call is by name, the 'get'
> is mostly redundant. As you suggest, we may need an API for checking the
> existence of a particular manager/handler. Then again, we could always
> return an error from the create_ext api if it fails to find that handler.
> I'll remove the 'get' for the moment.

OK. But I think an API to get external pool manager name should be
required. It's useful in ethernet driver where driver needs to take care
of any special arrangement based on a specific any HW pool manager

something like below, feel free to chage the API name,

inline char* __attribute__((always_inline))
rte_mempool_ext_get_name(struct rte_mempool *mp)
{
return (mempool_handler_list.handler[mp->handler_idx].name)
}


>
> Thanks,
> David.
>
>
>
>
>
>
>


[dpdk-dev] [PATCH 0/3] clean-up on virtual PMDs

2016-01-29 Thread Ferruh Yigit
This is a clean-up patch, no defect fixed, no functional difference 
expected.

Patch mainly removes duplicated fields between data->dev_private
and data (struct rte_eth_dev_data).

There are a few minor cleanups that:
pcap: move a common code into a function
ring: remove duplicated data->rx/tx_queues allocation and assignment


Ferruh Yigit (3):
  pcap: remove duplicate fields in internal data struct
  ring: remove duplicate fields in internal data struct
  null: remove duplicate fields in internal data struct

 drivers/net/null/rte_eth_null.c |  36 ---
 drivers/net/pcap/rte_eth_pcap.c | 130 +++-
 drivers/net/ring/rte_eth_ring.c |  52 +---
 3 files changed, 87 insertions(+), 131 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH 1/3] pcap: remove duplicate fields in internal data struct

2016-01-29 Thread Ferruh Yigit
1- Remove duplicate nb_rx/tx_queues fields from internals
2- Move duplicate code into a common function

Signed-off-by: Ferruh Yigit 
---
 drivers/net/pcap/rte_eth_pcap.c | 130 +++-
 1 file changed, 61 insertions(+), 69 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index f9230eb..c8b7dbd 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -103,8 +103,6 @@ struct tx_pcaps {
 struct pmd_internals {
struct pcap_rx_queue rx_queue[RTE_PMD_RING_MAX_RX_RINGS];
struct pcap_tx_queue tx_queue[RTE_PMD_RING_MAX_TX_RINGS];
-   unsigned nb_rx_queues;
-   unsigned nb_tx_queues;
int if_index;
int single_iface;
 };
@@ -396,7 +394,7 @@ eth_dev_start(struct rte_eth_dev *dev)
}

/* If not open already, open tx pcaps/dumpers */
-   for (i = 0; i < internals->nb_tx_queues; i++) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
tx = >tx_queue[i];

if (!tx->dumper && strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) 
{
@@ -411,7 +409,7 @@ eth_dev_start(struct rte_eth_dev *dev)
}

/* If not open already, open rx pcaps */
-   for (i = 0; i < internals->nb_rx_queues; i++) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
rx = >rx_queue[i];

if (rx->pcap != NULL)
@@ -457,7 +455,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
goto status_down;
}

-   for (i = 0; i < internals->nb_tx_queues; i++) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
tx = >tx_queue[i];

if (tx->dumper != NULL) {
@@ -471,7 +469,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
}
}

-   for (i = 0; i < internals->nb_rx_queues; i++) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
rx = >rx_queue[i];

if (rx->pcap != NULL) {
@@ -499,8 +497,8 @@ eth_dev_info(struct rte_eth_dev *dev,
dev_info->if_index = internals->if_index;
dev_info->max_mac_addrs = 1;
dev_info->max_rx_pktlen = (uint32_t) -1;
-   dev_info->max_rx_queues = (uint16_t)internals->nb_rx_queues;
-   dev_info->max_tx_queues = (uint16_t)internals->nb_tx_queues;
+   dev_info->max_rx_queues = dev->data->nb_rx_queues;
+   dev_info->max_tx_queues = dev->data->nb_tx_queues;
dev_info->min_rx_bufsize = 0;
dev_info->pci_dev = NULL;
 }
@@ -515,16 +513,16 @@ eth_stats_get(struct rte_eth_dev *dev,
unsigned long tx_packets_err_total = 0;
const struct pmd_internals *internal = dev->data->dev_private;

-   for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < 
internal->nb_rx_queues;
-   i++) {
+   for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+   i < dev->data->nb_rx_queues; i++) {
igb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;
igb_stats->q_ibytes[i] = internal->rx_queue[i].rx_bytes;
rx_packets_total += igb_stats->q_ipackets[i];
rx_bytes_total += igb_stats->q_ibytes[i];
}

-   for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS && i < 
internal->nb_tx_queues;
-   i++) {
+   for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+   i < dev->data->nb_tx_queues; i++) {
igb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;
igb_stats->q_obytes[i] = internal->tx_queue[i].tx_bytes;
igb_stats->q_errors[i] = internal->tx_queue[i].err_pkts;
@@ -545,11 +543,11 @@ eth_stats_reset(struct rte_eth_dev *dev)
 {
unsigned i;
struct pmd_internals *internal = dev->data->dev_private;
-   for (i = 0; i < internal->nb_rx_queues; i++) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
internal->rx_queue[i].rx_pkts = 0;
internal->rx_queue[i].rx_bytes = 0;
}
-   for (i = 0; i < internal->nb_tx_queues; i++) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
internal->tx_queue[i].tx_pkts = 0;
internal->tx_queue[i].tx_bytes = 0;
internal->tx_queue[i].err_pkts = 0;
@@ -840,9 +838,6 @@ rte_pmd_init_internals(const char *name, const unsigned 
nb_rx_queues,
/* NOTE: we'll replace the data element, of originally allocated eth_dev
 * so the rings are local per-process */

-   (*internals)->nb_rx_queues = nb_rx_queues;
-   (*internals)->nb_tx_queues = nb_tx_queues;
-
if (pair == NULL)
(*internals)->if_index = 0;
else
@@ -860,11 +855,11 @@ rte_pmd_init_internals(const char *name, const unsigned 
nb_rx_queues,

(*eth_dev)->data = data;
(*eth_dev)->dev_ops = 
-   (*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
(*eth_dev)->driver = NULL;
-   (*eth_dev)->data->kdrv = 

[dpdk-dev] [PATCH 2/3] ring: remove duplicate fields in internal data struct

2016-01-29 Thread Ferruh Yigit
1- Remove duplicate nb_rx/tx_queues fields from internals
2- Remove data->rx/tx_queues allocation, whose auto allocated by
libether
3- Remove duplicate data->rx/tx_queues[i] assignments

Signed-off-by: Ferruh Yigit 
---
 drivers/net/ring/rte_eth_ring.c | 52 +++--
 1 file changed, 14 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index d92b088..47dd5f2 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -59,9 +59,6 @@ struct ring_queue {
 };

 struct pmd_internals {
-   unsigned nb_rx_queues;
-   unsigned nb_tx_queues;
-
struct ring_queue rx_ring_queues[RTE_PMD_RING_MAX_RX_RINGS];
struct ring_queue tx_ring_queues[RTE_PMD_RING_MAX_TX_RINGS];

@@ -138,7 +135,7 @@ eth_dev_set_link_up(struct rte_eth_dev *dev)
 }

 static int
-eth_rx_queue_setup(struct rte_eth_dev *dev,uint16_t rx_queue_id,
+eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
uint16_t nb_rx_desc __rte_unused,
unsigned int socket_id __rte_unused,
const struct rte_eth_rxconf *rx_conf 
__rte_unused,
@@ -165,12 +162,11 @@ static void
 eth_dev_info(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info)
 {
-   struct pmd_internals *internals = dev->data->dev_private;
dev_info->driver_name = drivername;
dev_info->max_mac_addrs = 1;
dev_info->max_rx_pktlen = (uint32_t)-1;
-   dev_info->max_rx_queues = (uint16_t)internals->nb_rx_queues;
-   dev_info->max_tx_queues = (uint16_t)internals->nb_tx_queues;
+   dev_info->max_rx_queues = dev->data->nb_rx_queues;
+   dev_info->max_tx_queues = dev->data->nb_tx_queues;
dev_info->min_rx_bufsize = 0;
dev_info->pci_dev = NULL;
 }
@@ -183,13 +179,13 @@ eth_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *igb_stats)
const struct pmd_internals *internal = dev->data->dev_private;

for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
-   i < internal->nb_rx_queues; i++) {
+   i < dev->data->nb_rx_queues; i++) {
igb_stats->q_ipackets[i] = 
internal->rx_ring_queues[i].rx_pkts.cnt;
rx_total += igb_stats->q_ipackets[i];
}

for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
-   i < internal->nb_tx_queues; i++) {
+   i < dev->data->nb_tx_queues; i++) {
igb_stats->q_opackets[i] = 
internal->tx_ring_queues[i].tx_pkts.cnt;
igb_stats->q_errors[i] = 
internal->tx_ring_queues[i].err_pkts.cnt;
tx_total += igb_stats->q_opackets[i];
@@ -206,9 +202,9 @@ eth_stats_reset(struct rte_eth_dev *dev)
 {
unsigned i;
struct pmd_internals *internal = dev->data->dev_private;
-   for (i = 0; i < internal->nb_rx_queues; i++)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
internal->rx_ring_queues[i].rx_pkts.cnt = 0;
-   for (i = 0; i < internal->nb_tx_queues; i++) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
internal->tx_ring_queues[i].tx_pkts.cnt = 0;
internal->tx_ring_queues[i].err_pkts.cnt = 0;
}
@@ -262,7 +258,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const 
rx_queues[],
struct rte_eth_dev_data *data = NULL;
struct pmd_internals *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
-
unsigned i;

/* do some parameter checking */
@@ -291,20 +286,6 @@ rte_eth_from_rings(const char *name, struct rte_ring 
*const rx_queues[],
goto error;
}

-   data->rx_queues = rte_zmalloc_socket(name, sizeof(void *) * 
nb_rx_queues,
-   0, numa_node);
-   if (data->rx_queues == NULL) {
-   rte_errno = ENOMEM;
-   goto error;
-   }
-
-   data->tx_queues = rte_zmalloc_socket(name, sizeof(void *) * 
nb_tx_queues,
-   0, numa_node);
-   if (data->tx_queues == NULL) {
-   rte_errno = ENOMEM;
-   goto error;
-   }
-
internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
if (internals == NULL) {
rte_errno = ENOMEM;
@@ -327,16 +308,11 @@ rte_eth_from_rings(const char *name, struct rte_ring 
*const rx_queues[],
/* NOTE: we'll replace the data element, of originally allocated eth_dev
 * so the rings are local per-process */

-   internals->nb_rx_queues = nb_rx_queues;
-   internals->nb_tx_queues = nb_tx_queues;
-   for (i = 0; i < nb_rx_queues; i++) {
+   for (i = 0; i < nb_rx_queues; i++)
internals->rx_ring_queues[i].rng = rx_queues[i];
-   data->rx_queues[i] = >rx_ring_queues[i];
-   }
-   for (i = 0; i < nb_tx_queues; i++) {
+
+ 

[dpdk-dev] [PATCH 3/3] null: remove duplicate fields in internal data struct

2016-01-29 Thread Ferruh Yigit
1- remove duplicate nb_rx/tx_queues fields from internals
2- remove duplicate numa_node field from internals

Signed-off-by: Ferruh Yigit 
---
 drivers/net/null/rte_eth_null.c | 36 
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 77fc988..1c354ad 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -69,10 +69,6 @@ struct null_queue {
 struct pmd_internals {
unsigned packet_size;
unsigned packet_copy;
-   unsigned numa_node;
-
-   unsigned nb_rx_queues;
-   unsigned nb_tx_queues;

struct null_queue rx_null_queues[RTE_MAX_QUEUES_PER_PORT];
struct null_queue tx_null_queues[RTE_MAX_QUEUES_PER_PORT];
@@ -192,13 +188,8 @@ eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t 
nb_bufs)
 }

 static int
-eth_dev_configure(struct rte_eth_dev *dev) {
-   struct pmd_internals *internals;
-
-   internals = dev->data->dev_private;
-   internals->nb_rx_queues = dev->data->nb_rx_queues;
-   internals->nb_tx_queues = dev->data->nb_tx_queues;
-
+eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
+{
return 0;
 }

@@ -237,7 +228,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
rx_queue_id,

internals = dev->data->dev_private;

-   if (rx_queue_id >= internals->nb_rx_queues)
+   if (rx_queue_id >= dev->data->nb_rx_queues)
return -ENODEV;

packet_size = internals->packet_size;
@@ -246,7 +237,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
rx_queue_id,
dev->data->rx_queues[rx_queue_id] =
>rx_null_queues[rx_queue_id];
dummy_packet = rte_zmalloc_socket(NULL,
-   packet_size, 0, internals->numa_node);
+   packet_size, 0, dev->data->numa_node);
if (dummy_packet == NULL)
return -ENOMEM;

@@ -271,7 +262,7 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
tx_queue_id,

internals = dev->data->dev_private;

-   if (tx_queue_id >= internals->nb_tx_queues)
+   if (tx_queue_id >= dev->data->nb_tx_queues)
return -ENODEV;

packet_size = internals->packet_size;
@@ -279,7 +270,7 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
tx_queue_id,
dev->data->tx_queues[tx_queue_id] =
>tx_null_queues[tx_queue_id];
dummy_packet = rte_zmalloc_socket(NULL,
-   packet_size, 0, internals->numa_node);
+   packet_size, 0, dev->data->numa_node);
if (dummy_packet == NULL)
return -ENOMEM;

@@ -323,7 +314,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*igb_stats)

internal = dev->data->dev_private;
num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-   RTE_MIN(internal->nb_rx_queues,
+   RTE_MIN(dev->data->nb_rx_queues,
RTE_DIM(internal->rx_null_queues)));
for (i = 0; i < num_stats; i++) {
igb_stats->q_ipackets[i] =
@@ -332,7 +323,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*igb_stats)
}

num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-   RTE_MIN(internal->nb_tx_queues,
+   RTE_MIN(dev->data->nb_tx_queues,
RTE_DIM(internal->tx_null_queues)));
for (i = 0; i < num_stats; i++) {
igb_stats->q_opackets[i] =
@@ -535,11 +526,8 @@ eth_dev_null_create(const char *name,
/* NOTE: we'll replace the data element, of originally allocated eth_dev
 * so the nulls are local per-process */

-   internals->nb_rx_queues = nb_rx_queues;
-   internals->nb_tx_queues = nb_tx_queues;
internals->packet_size = packet_size;
internals->packet_copy = packet_copy;
-   internals->numa_node = numa_node;

internals->flow_type_rss_offloads =  ETH_RSS_PROTO_MASK;
internals->reta_size = RTE_DIM(internals->reta_conf) * 
RTE_RETA_GROUP_SIZE;
@@ -560,10 +548,10 @@ eth_dev_null_create(const char *name,
TAILQ_INIT(_dev->link_intr_cbs);

eth_dev->driver = NULL;
-   eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
-   eth_dev->data->kdrv = RTE_KDRV_NONE;
-   eth_dev->data->drv_name = drivername;
-   eth_dev->data->numa_node = numa_node;
+   data->dev_flags = RTE_ETH_DEV_DETACHABLE;
+   data->kdrv = RTE_KDRV_NONE;
+   data->drv_name = drivername;
+   data->numa_node = numa_node;

/* finally assign rx and tx ops */
if (packet_copy) {
-- 
2.5.0



[dpdk-dev] [PATCH] eal: make resource initialization more robust

2016-01-29 Thread Jianfeng Tan
Current issue: DPDK is not that friendly to container environment, which
caused by that it pre-alloc resource like cores and hugepages. But there
are this or that resource limitations, for examples, cgroup, rlimit,
cpuset, etc.

For cores, this patch makes use of pthread_getaffinity_np to further
narrow down detected cores before parsing coremask (-c), corelist (-l),
and coremap (--lcores).

For hugepages, this patch adds a recover mechanism to the case that
there are no that many hugepages can be used. It relys on a mem access
to fault-in hugepages, and if fails with SIGBUS, recover to previously
saved stack environment with siglongjmp().

Test example:
a. cgcreate -g cpuset,hugetlb:/test-subgroup
b. cgset -r cpuset.cpus=2-3 test-subgroup
c. cgset -r hugetlb.1GB.limit_in_bytes=2147483648 test-subgroup
d. cgexec -g cpuset,hugetlb:test-subgroup \
./examples/l2fwd/build/l2fwd -n 4 -- -p 3

Signed-off-by: Jianfeng Tan 
---
 lib/librte_eal/common/eal_common_lcore.c | 10 +++-
 lib/librte_eal/linuxapp/eal/eal_memory.c | 78 
 2 files changed, 79 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_lcore.c 
b/lib/librte_eal/common/eal_common_lcore.c
index a4263ba..8e9c675 100644
--- a/lib/librte_eal/common/eal_common_lcore.c
+++ b/lib/librte_eal/common/eal_common_lcore.c
@@ -57,6 +57,13 @@ rte_eal_cpu_init(void)
struct rte_config *config = rte_eal_get_configuration();
unsigned lcore_id;
unsigned count = 0;
+   rte_cpuset_t cpuset;
+   pthread_t tid;
+
+   tid = pthread_self();
+   if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t), ) != 0)
+   for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
+   CPU_SET(lcore_id, );

/*
 * Parse the maximum set of logical cores, detect the subset of running
@@ -70,7 +77,8 @@ rte_eal_cpu_init(void)

/* in 1:1 mapping, record related cpu detected state */
lcore_config[lcore_id].detected = eal_cpu_detected(lcore_id);
-   if (lcore_config[lcore_id].detected == 0) {
+   if (lcore_config[lcore_id].detected == 0 ||
+   !CPU_ISSET(lcore_id, )) {
config->lcore_role[lcore_id] = ROLE_OFF;
lcore_config[lcore_id].core_index = -1;
continue;
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 846fd31..837fd9e 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -80,6 +80,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #include 
 #include 
@@ -309,6 +311,12 @@ get_virtual_area(size_t *size, size_t hugepage_sz)
return addr;
 }

+static sigjmp_buf jmpenv;
+
+static void sigbus_handler(int signo __rte_unused)
+{
+   siglongjmp(jmpenv, 1);
+}
 /*
  * Mmap all hugepages of hugepage table: it first open a file in
  * hugetlbfs, then mmap() hugepage_sz data in it. If orig is set, the
@@ -396,7 +404,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl,
if (fd < 0) {
RTE_LOG(ERR, EAL, "%s(): open failed: %s\n", __func__,
strerror(errno));
-   return -1;
+   return i;
}

virtaddr = mmap(vma_addr, hugepage_sz, PROT_READ | PROT_WRITE,
@@ -405,11 +413,26 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl,
RTE_LOG(ERR, EAL, "%s(): mmap failed: %s\n", __func__,
strerror(errno));
close(fd);
-   return -1;
+   return i;
}

if (orig) {
hugepg_tbl[i].orig_va = virtaddr;
+   /* In linux, hugetlb limitations, like cgroup, are
+* enforced at fault time instead of mmap(), even
+* with the option of MAP_POPULATE. Kernel will send
+* a SIGBUS signal. To avoid to be killed, save stack
+* environment here, if SIGBUS happens, we can jump
+* back here.
+*/
+   if (sigsetjmp(jmpenv, 0)) {
+   RTE_LOG(ERR, EAL, "SIGBUS: Cannot mmap more "
+   "hugepages of size %u MB\n",
+   (unsigned)(hugepage_sz / 0x10));
+   munmap(virtaddr, hugepage_sz);
+   close(fd);
+   return i;
+   }
memset(virtaddr, 0, hugepage_sz);
}
else {
@@ -421,7 +444,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl,
 

[dpdk-dev] [PATCH v6 1/8] eal: pci: add api to rd/wr pci bar region

2016-01-29 Thread Santosh Shukla
Introducing below api for pci bar region rd/wr.
Api's are:
- rte_eal_pci_read_bar
- rte_eal_pci_write_bar

Signed-off-by: Santosh Shukla 
---
v5-->v6:
- update api infor in rte_eal_version.map file
  suggested by david manchand.

 lib/librte_eal/bsdapp/eal/eal_pci.c |   19 
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |3 ++
 lib/librte_eal/common/include/rte_pci.h |   38 +++
 lib/librte_eal/linuxapp/eal/eal_pci.c   |   34 
 lib/librte_eal/linuxapp/eal/eal_pci_init.h  |6 
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c  |   28 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |3 ++
 7 files changed, 131 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 95c32c1..2e535ea 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -479,6 +479,25 @@ int rte_eal_pci_write_config(const struct rte_pci_device 
*dev,
return -1;
 }

+int rte_eal_pci_read_bar(const struct rte_pci_device *device __rte_unused,
+void *buf __rte_unused, size_t len __rte_unused,
+off_t offset __rte_unused,
+int bar_idx __rte_unused)
+
+{
+   /* NA */
+   return 1;
+}
+
+int rte_eal_pci_write_bar(const struct rte_pci_device *device __rte_unused,
+ const void *buf __rte_unused, size_t len __rte_unused,
+ off_t offset __rte_unused,
+ int bar_idx __rte_unused)
+{
+   /* NA */
+   return 1;
+}
+
 /* Init the PCI EAL subsystem */
 int
 rte_eal_pci_init(void)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 1b28170..7c7dcf0 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -141,4 +141,7 @@ DPDK_2.3 {

rte_eal_pci_map_device;
rte_eal_pci_unmap_device;
+   rte_eal_pci_read_bar;
+   rte_eal_pci_write_bar;
+
 } DPDK_2.2;
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 2224109..0c667ff 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -471,6 +471,44 @@ int rte_eal_pci_read_config(const struct rte_pci_device 
*device,
void *buf, size_t len, off_t offset);

 /**
+ * Read PCI bar space.
+ *
+ * @param device
+ *   A pointer to a rte_pci_device structure describing the device
+ *   to use
+ * @param buf
+ *   A data buffer where the bytes should be read into
+ * @param len
+ *   The length of the data buffer.
+ * @param offset
+ *   The offset into PCI bar space
+ * @param bar_idx
+ *   The pci bar index (valid range is 0..5)
+ */
+int rte_eal_pci_read_bar(const struct rte_pci_device *device,
+void *buf, size_t len, off_t offset, int bar_idx);
+
+/**
+ * Write PCI bar space.
+ *
+ * @param device
+ *   A pointer to a rte_pci_device structure describing the device
+ *   to use
+ * @param buf
+ *   A data buffer containing the bytes should be written
+ * @param len
+ *   The length of the data buffer.
+ * @param offset
+ *   The offset into PCI config space
+ * @param bar_idx
+ *   The pci bar index (valid range is 0..5)
+*/
+int rte_eal_pci_write_bar(const struct rte_pci_device *device,
+ const void *buf, size_t len, off_t offset,
+ int bar_idx);
+
+
+/**
  * Write PCI config space.
  *
  * @param device
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index db947da..eb503f0 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -621,6 +621,40 @@ int rte_eal_pci_write_config(const struct rte_pci_device 
*device,
}
 }

+int rte_eal_pci_read_bar(const struct rte_pci_device *device,
+void *buf, size_t len, off_t offset,
+int bar_idx)
+
+{
+   const struct rte_intr_handle *intr_handle = >intr_handle;
+
+   switch (device->kdrv) {
+   case RTE_KDRV_VFIO:
+   return pci_vfio_read_bar(intr_handle, buf, len,
+offset, bar_idx);
+   default:
+   RTE_LOG(ERR, EAL, "write bar not supported by driver\n");
+   return -1;
+   }
+}
+
+int rte_eal_pci_write_bar(const struct rte_pci_device *device,
+ const void *buf, size_t len, off_t offset,
+ int bar_idx)
+{
+
+   const struct rte_intr_handle *intr_handle = >intr_handle;
+
+   switch (device->kdrv) {
+   case RTE_KDRV_VFIO:
+   return pci_vfio_write_bar(intr_handle, buf, len,
+ offset, bar_idx);
+   default:
+   RTE_LOG(ERR, EAL, 

[dpdk-dev] [PATCH v6 2/8] linuxapp/vfio: ignore mapping for ioport region

2016-01-29 Thread Santosh Shukla
vfio_pci_mmap() try to map all pci bars. ioport region are not mapped in
vfio/kernel so ignore mmaping for ioport.

Signed-off-by: Santosh Shukla 
---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   20 
 1 file changed, 20 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 34c4558..b704ffd 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -687,6 +687,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
struct pci_map *maps;
uint32_t msix_table_offset = 0;
uint32_t msix_table_size = 0;
+   uint32_t ioport_bar;

dev->intr_handle.fd = -1;
dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
@@ -881,6 +882,25 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
return -1;
}

+   /* chk for io port region */
+   ret = pread64(vfio_dev_fd, _bar, sizeof(ioport_bar),
+ VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX)
+ + PCI_BASE_ADDRESS_0 + i*4);
+
+   if (ret != sizeof(ioport_bar)) {
+   RTE_LOG(ERR, EAL,
+   "Cannot read command (%x) from config space!\n",
+   PCI_BASE_ADDRESS_0 + i*4);
+   return -1;
+   }
+
+   if (ioport_bar & PCI_BASE_ADDRESS_SPACE_IO) {
+   RTE_LOG(INFO, EAL,
+   "Ignore mapping IO port bar(%d) addr: %x\n",
+i, ioport_bar);
+   continue;
+   }
+
/* skip non-mmapable BARs */
if ((reg.flags & VFIO_REGION_INFO_FLAG_MMAP) == 0)
continue;
-- 
1.7.9.5



[dpdk-dev] [PATCH v6 3/8] eal/linux: never check iopl for arm

2016-01-29 Thread Santosh Shukla
iopl() syscall not supported in linux-arm/arm64 so always return 0 value.

Signed-off-by: Santosh Shukla 
Suggested-by: Stephen Hemminger 
Acked-by: Jan Viktorin 
Acked-by: David Marchand 
---
 lib/librte_eal/linuxapp/eal/eal.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 635ec36..a2a3485 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -715,6 +715,8 @@ rte_eal_iopl_init(void)
if (iopl(3) != 0)
return -1;
return 0;
+#elif defined(RTE_ARCH_ARM) || defined(RTE_ARCH_ARM64)
+   return 0; /* iopl syscall not supported for ARM/ARM64 */
 #else
return -1;
 #endif
-- 
1.7.9.5



[dpdk-dev] [PATCH v6 4/8] virtio: Introduce config RTE_VIRTIO_INC_VECTOR

2016-01-29 Thread Santosh Shukla
- virtio_recv_pkts_vec and other virtio vector friend apis are written for
  sse/avx instructions. For arm64 in particular, virtio vector implementation
  does not exist(todo).

So virtio pmd driver wont build for targets like i686, arm64.  By making
RTE_VIRTIO_INC_VECTOR=n, Driver can build for non-sse/avx targets and will work
in non-vectored virtio mode.

Disabling RTE_VIRTIO_INC_VECTOR config for :

- i686 arch as i686 target config says:
  config/defconfig_i686-native-linuxapp-gcc says "Vectorized PMD is not
  supported on 32-bit".

- armv7/v8 arch.

Signed-off-by: Santosh Shukla 
---
v4--> v5:
- squashed v4's RTE_VIRTIO_INC_VECTOR patches into one patch.
- Added ifdefs RTE_xx_xx_INC_VECTOR across _simple_rx_tx flag occurance in code.


 config/common_linuxapp |1 +
 config/defconfig_arm-armv7a-linuxapp-gcc   |4 +++-
 config/defconfig_arm64-armv8a-linuxapp-gcc |4 +++-
 config/defconfig_i686-native-linuxapp-gcc  |1 +
 config/defconfig_i686-native-linuxapp-icc  |1 +
 drivers/net/virtio/Makefile|2 +-
 drivers/net/virtio/virtio_rxtx.c   |   16 +++-
 drivers/net/virtio/virtio_rxtx.h   |2 ++
 8 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 74bc515..8677697 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -274,6 +274,7 @@ CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DRIVER=n
 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n
+CONFIG_RTE_VIRTIO_INC_VECTOR=y

 #
 # Compile burst-oriented VMXNET3 PMD driver
diff --git a/config/defconfig_arm-armv7a-linuxapp-gcc 
b/config/defconfig_arm-armv7a-linuxapp-gcc
index cbebd64..9f852ce 100644
--- a/config/defconfig_arm-armv7a-linuxapp-gcc
+++ b/config/defconfig_arm-armv7a-linuxapp-gcc
@@ -43,6 +43,9 @@ CONFIG_RTE_FORCE_INTRINSICS=y
 CONFIG_RTE_TOOLCHAIN="gcc"
 CONFIG_RTE_TOOLCHAIN_GCC=y

+# Disable VIRTIO VECTOR support
+CONFIG_RTE_VIRTIO_INC_VECTOR=n
+
 # ARM doesn't have support for vmware TSC map
 CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=n

@@ -70,7 +73,6 @@ CONFIG_RTE_LIBRTE_I40E_PMD=n
 CONFIG_RTE_LIBRTE_IXGBE_PMD=n
 CONFIG_RTE_LIBRTE_MLX4_PMD=n
 CONFIG_RTE_LIBRTE_MPIPE_PMD=n
-CONFIG_RTE_LIBRTE_VIRTIO_PMD=n
 CONFIG_RTE_LIBRTE_VMXNET3_PMD=n
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
 CONFIG_RTE_LIBRTE_PMD_BNX2X=n
diff --git a/config/defconfig_arm64-armv8a-linuxapp-gcc 
b/config/defconfig_arm64-armv8a-linuxapp-gcc
index 504f3ed..1a638b3 100644
--- a/config/defconfig_arm64-armv8a-linuxapp-gcc
+++ b/config/defconfig_arm64-armv8a-linuxapp-gcc
@@ -45,8 +45,10 @@ CONFIG_RTE_TOOLCHAIN_GCC=y

 CONFIG_RTE_CACHE_LINE_SIZE=64

+# Disable VIRTIO VECTOR support
+CONFIG_RTE_VIRTIO_INC_VECTOR=n
+
 CONFIG_RTE_IXGBE_INC_VECTOR=n
-CONFIG_RTE_LIBRTE_VIRTIO_PMD=n
 CONFIG_RTE_LIBRTE_IVSHMEM=n
 CONFIG_RTE_LIBRTE_FM10K_PMD=n
 CONFIG_RTE_LIBRTE_I40E_PMD=n
diff --git a/config/defconfig_i686-native-linuxapp-gcc 
b/config/defconfig_i686-native-linuxapp-gcc
index a90de9b..a4b1c49 100644
--- a/config/defconfig_i686-native-linuxapp-gcc
+++ b/config/defconfig_i686-native-linuxapp-gcc
@@ -49,3 +49,4 @@ CONFIG_RTE_LIBRTE_KNI=n
 # Vectorized PMD is not supported on 32-bit
 #
 CONFIG_RTE_IXGBE_INC_VECTOR=n
+CONFIG_RTE_VIRTIO_INC_VECTOR=n
diff --git a/config/defconfig_i686-native-linuxapp-icc 
b/config/defconfig_i686-native-linuxapp-icc
index c021321..f8eb6ad 100644
--- a/config/defconfig_i686-native-linuxapp-icc
+++ b/config/defconfig_i686-native-linuxapp-icc
@@ -49,3 +49,4 @@ CONFIG_RTE_LIBRTE_KNI=n
 # Vectorized PMD is not supported on 32-bit
 #
 CONFIG_RTE_IXGBE_INC_VECTOR=n
+CONFIG_RTE_VIRTIO_INC_VECTOR=n
diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index 43835ba..25a842d 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -50,7 +50,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtqueue.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_ethdev.c
-SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx_simple.c
+SRCS-$(CONFIG_RTE_VIRTIO_INC_VECTOR) += virtio_rxtx_simple.c

 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += lib/librte_eal lib/librte_ether
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 41a1366..d8169d1 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -67,7 +67,9 @@
 #define VIRTIO_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
ETH_TXQ_FLAGS_NOOFFLOADS)

+#ifdef RTE_VIRTIO_INC_VECTOR
 static int use_simple_rxtx;
+#endif

 static void
 vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)
@@ -307,12 +309,13 @@ virtio_dev_vring_start(struct virtqueue *vq, int 
queue_type)
nbufs = 0;
error = ENOSPC;

+#ifdef RTE_VIRTIO_INC_VECTOR
if (use_simple_rxtx)

[dpdk-dev] [PATCH v6 5/8] virtio: move io header and api from virtio_pci.h

2016-01-29 Thread Santosh Shukla
Moving io api and header file i.e. sys/io.h to separate file virtio_io.h

Signed-off-by: Santosh Shukla 
---
v5-->v6:
- included new file virtio_io.h, has in/out api and sys/io.h.

 drivers/net/virtio/virtio_io.h  |  114 +++
 drivers/net/virtio/virtio_pci.c |1 +
 drivers/net/virtio/virtio_pci.h |   30 ---
 3 files changed, 115 insertions(+), 30 deletions(-)
 create mode 100644 drivers/net/virtio/virtio_io.h

diff --git a/drivers/net/virtio/virtio_io.h b/drivers/net/virtio/virtio_io.h
new file mode 100644
index 000..bfa1341
--- /dev/null
+++ b/drivers/net/virtio/virtio_io.h
@@ -0,0 +1,114 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Cavium Networks. 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 Intel Corporation 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 _VIRTIO_IO_H_
+#define _VIRTIO_IO_H_
+
+#include 
+#include "virtio_logs.h"
+
+#if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
+
+#ifdef __FreeBSD__
+#include 
+#include 
+
+static inline void
+outb_p(unsigned char data, unsigned int port)
+{
+
+   outb(port, (u_char)data);
+}
+
+static inline void
+outw_p(unsigned short data, unsigned int port)
+{
+   outw(port, (u_short)data);
+}
+
+static inline void
+outl_p(unsigned int data, unsigned int port)
+{
+   outl(port, (u_int)data);
+}
+
+#else
+#include 
+#endif
+
+#else /* ! X86 */
+
+static inline uint8_t
+inb(unsigned long addr __rte_unused)
+{
+   PMD_INIT_LOG(ERR, "inb() not supported for this RTE_ARCH\n");
+   return 0;
+}
+
+static inline uint16_t
+inw(unsigned long addr __rte_unused)
+{
+   PMD_INIT_LOG(ERR, "inw() not supported for this RTE_ARCH\n");
+   return 0;
+}
+
+static inline uint32_t
+inl(unsigned long addr __rte_unused)
+{
+   PMD_INIT_LOG(ERR, "in() not supported for this RTE_ARCH\n");
+   return 0;
+}
+
+static inline void
+outb_p(unsigned char data __rte_unused, unsigned int port __rte_unused)
+{
+   PMD_INIT_LOG(ERR, "outb_p() not supported for this RTE_ARCH\n");
+   return;
+}
+
+static inline void
+outw_p(unsigned short data __rte_unused, unsigned int port __rte_unused)
+{
+   PMD_INIT_LOG(ERR, "outw_p() not supported for this RTE_ARCH\n");
+   return;
+}
+
+static inline void
+outl_p(unsigned int data __rte_unused, unsigned int port __rte_unused)
+{
+   PMD_INIT_LOG(ERR, "outl_p() not supported for this RTE_ARCH\n");
+   return;
+}
+
+#endif /* X86 */
+#endif /* _VIRTIO_IO_H_ */
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index a9f179f..064f234 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -37,6 +37,7 @@
  #include 
 #endif

+#include "virtio_io.h"
 #include "virtio_pci.h"
 #include "virtio_logs.h"
 #include "virtqueue.h"
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index 99572a0..2fe5835 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -35,14 +35,6 @@
 #define _VIRTIO_PCI_H_

 #include 
-
-#ifdef __FreeBSD__
-#include 
-#include 
-#else
-#include 
-#endif
-
 #include 

 struct virtqueue;
@@ -296,28 +288,6 @@ struct virtio_net_config {
 /* The alignment to use between consumer and producer parts of vring. */
 #define VIRTIO_PCI_VRING_ALIGN 4096

-#ifdef __FreeBSD__
-
-static inline void
-outb_p(unsigned char data, unsigned int port)
-{
-
-   outb(port, (u_char)data);
-}
-
-static inline void

[dpdk-dev] [PATCH v6 6/8] virtio: add vfio api to rd/wr ioport space

2016-01-29 Thread Santosh Shukla
For vfio case - Use pread/pwrite api to access virtio
ioport space.

Signed-off-by: Santosh Shukla 
Signed-off-by: Rizwan Ansari 
Signed-off-by: Rakesh Krishnamurthy 
---
v5-->v6:
- renamed inport_in/out to vfio_in/out
- Renamed file from virtio_vfio_rw.h to virtio_vfio_io.h

 drivers/net/virtio/virtio_vfio_io.h |  104 +++
 1 file changed, 104 insertions(+)
 create mode 100644 drivers/net/virtio/virtio_vfio_io.h

diff --git a/drivers/net/virtio/virtio_vfio_io.h 
b/drivers/net/virtio/virtio_vfio_io.h
new file mode 100644
index 000..218d4ed
--- /dev/null
+++ b/drivers/net/virtio/virtio_vfio_io.h
@@ -0,0 +1,104 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Cavium Networks. 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 Intel Corporation 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 _VIRTIO_VFIO_IO_H_
+#define _VIRTIO_VFIO_IO_H_
+
+#include "virtio_logs.h"
+#if defined(RTE_EAL_VFIO) && defined(RTE_LIBRTE_EAL_LINUXAPP)
+
+#include 
+#include 
+
+/* vfio rd/rw virtio apis */
+static inline void
+vfio_inb(const struct rte_pci_device *pci_dev, uint8_t reg, uint8_t *val)
+{
+   if (rte_eal_pci_read_bar(pci_dev, val, sizeof(uint8_t), reg, 0) <= 0) {
+   PMD_DRV_LOG(ERR, "Can't read from PCI bar space");
+   return;
+   }
+}
+
+static inline void
+vfio_inw(const struct rte_pci_device *pci_dev, uint16_t reg, uint16_t *val)
+{
+   if (rte_eal_pci_read_bar(pci_dev, val, sizeof(uint16_t), reg, 0) <= 0) {
+   PMD_DRV_LOG(ERR, "Can't read from PCI bar space");
+   return;
+   }
+}
+
+static inline void
+vfio_inl(const struct rte_pci_device *pci_dev, uint32_t reg, uint32_t *val)
+{
+   if (rte_eal_pci_read_bar(pci_dev, val, sizeof(uint32_t), reg, 0) <= 0) {
+   PMD_DRV_LOG(ERR, "Can't read from PCI bar space");
+   return;
+   }
+}
+
+static inline void
+vfio_outb_p(const struct rte_pci_device *pci_dev, uint8_t reg, uint8_t val)
+{
+   if (rte_eal_pci_write_bar(pci_dev, , sizeof(uint8_t),
+ reg, 0) <= 0) {
+   PMD_DRV_LOG(ERR, "Can't write to PCI bar space");
+   return;
+   }
+}
+
+
+static inline void
+vfio_outw_p(const struct rte_pci_device *pci_dev, uint16_t reg, uint16_t val)
+{
+   if (rte_eal_pci_write_bar(pci_dev, , sizeof(uint16_t),
+ reg, 0) <= 0) {
+   PMD_DRV_LOG(ERR, "Can't write to PCI bar space");
+   return;
+   }
+}
+
+
+static inline void
+vfio_outl_p(const struct rte_pci_device *pci_dev, uint32_t reg, uint32_t val)
+{
+   if (rte_eal_pci_write_bar(pci_dev, , sizeof(uint32_t),
+ reg, 0) <= 0) {
+   PMD_DRV_LOG(ERR, "Can't write to PCI bar space");
+   return;
+   }
+}
+
+#endif /* RTE_EAL_VFIO && RTE_XX_EAL_LINUXAPP */
+#endif /* _VIRTIO_VFIO_RW_H_ */
-- 
1.7.9.5



[dpdk-dev] [PATCH v6 7/8] virtio: extend pci rw api for vfio

2016-01-29 Thread Santosh Shukla
So far virtio handle rw access for uio / ioport interface,
This patch to extend the support for vfio.

Signed-off-by: Santosh Shukla 
---
 drivers/net/virtio/virtio_io.h  |2 +-
 drivers/net/virtio/virtio_pci.c |  110 ++-
 2 files changed, 98 insertions(+), 14 deletions(-)

diff --git a/drivers/net/virtio/virtio_io.h b/drivers/net/virtio/virtio_io.h
index bfa1341..ce59e3f 100644
--- a/drivers/net/virtio/virtio_io.h
+++ b/drivers/net/virtio/virtio_io.h
@@ -35,7 +35,7 @@
 #define _VIRTIO_IO_H_

 #include 
-#include "virtio_logs.h"
+#include "virtio_vfio_io.h"

 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 064f234..71d4a07 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -37,10 +37,10 @@
  #include 
 #endif

-#include "virtio_io.h"
 #include "virtio_pci.h"
 #include "virtio_logs.h"
 #include "virtqueue.h"
+#include "virtio_io.h"

 /*
  * Following macros are derieved from linux/pci_regs.h, however,
@@ -54,20 +54,104 @@
 #define VIRTIO_PCI_REG_ADDR(hw, reg) \
(unsigned short)((hw)->io_base + (reg))

-#define VIRTIO_READ_REG_1(hw, reg) \
-   inb((VIRTIO_PCI_REG_ADDR((hw), (reg
-#define VIRTIO_WRITE_REG_1(hw, reg, value) \
-   outb_p((unsigned char)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg
+static inline uint8_t
+virtio_read_reg_1(struct virtio_hw *hw, uint64_t reg_offset)
+{
+   uint8_t ret;
+   struct rte_pci_device *dev;
+
+   dev = hw->dev;
+   if (dev->kdrv == RTE_KDRV_VFIO)
+   vfio_inb(dev, reg_offset, );
+   else
+   ret = inb(VIRTIO_PCI_REG_ADDR(hw, reg_offset));
+
+   return ret;
+}
+
+static inline uint16_t
+virtio_read_reg_2(struct virtio_hw *hw, uint64_t reg_offset)
+{
+   uint16_t ret;
+   struct rte_pci_device *dev;
+
+   dev = hw->dev;
+   if (dev->kdrv == RTE_KDRV_VFIO)
+   vfio_inw(dev, reg_offset, );
+   else
+   ret = inw(VIRTIO_PCI_REG_ADDR(hw, reg_offset));
+
+   return ret;
+}
+
+static inline uint32_t
+virtio_read_reg_4(struct virtio_hw *hw, uint64_t reg_offset)
+{
+   uint32_t ret;
+   struct rte_pci_device *dev;
+
+   dev = hw->dev;
+   if (dev->kdrv == RTE_KDRV_VFIO)
+   vfio_inl(dev, reg_offset, );
+   else
+   ret = inl(VIRTIO_PCI_REG_ADDR(hw, reg_offset));
+
+   return ret;
+}
+
+static inline void
+virtio_write_reg_1(struct virtio_hw *hw, uint64_t reg_offset, uint8_t value)
+{
+   struct rte_pci_device *dev;
+
+   dev = hw->dev;
+   if (dev->kdrv == RTE_KDRV_VFIO)
+   vfio_outb_p(dev, reg_offset, value);
+   else
+   outb_p((unsigned char)value,
+  VIRTIO_PCI_REG_ADDR(hw, reg_offset));
+}
+
+static inline void
+virtio_write_reg_2(struct virtio_hw *hw, uint64_t reg_offset, uint16_t value)
+{
+   struct rte_pci_device *dev;
+
+   dev = hw->dev;
+   if (dev->kdrv == RTE_KDRV_VFIO)
+   vfio_outw_p(dev, reg_offset, value);
+   else
+   outw_p((unsigned short)value,
+  VIRTIO_PCI_REG_ADDR(hw, reg_offset));
+}
+
+static inline void
+virtio_write_reg_4(struct virtio_hw *hw, uint64_t reg_offset, uint32_t value)
+{
+   struct rte_pci_device *dev;
+
+   dev = hw->dev;
+   if (dev->kdrv == RTE_KDRV_VFIO)
+   vfio_outl_p(dev, reg_offset, value);
+   else
+   outl_p((unsigned int)value,
+  VIRTIO_PCI_REG_ADDR(hw, reg_offset));
+}
+
+#define VIRTIO_READ_REG_1(hw, reg) \
+   virtio_read_reg_1((hw), (reg))
+#define VIRTIO_WRITE_REG_1(hw, reg, value) \
+   virtio_write_reg_1((hw), (reg), (value))

-#define VIRTIO_READ_REG_2(hw, reg) \
-   inw((VIRTIO_PCI_REG_ADDR((hw), (reg
-#define VIRTIO_WRITE_REG_2(hw, reg, value) \
-   outw_p((unsigned short)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg
+#define VIRTIO_READ_REG_2(hw, reg) \
+   virtio_read_reg_2((hw), (reg))
+#define VIRTIO_WRITE_REG_2(hw, reg, value) \
+   virtio_write_reg_2((hw), (reg), (value))

-#define VIRTIO_READ_REG_4(hw, reg) \
-   inl((VIRTIO_PCI_REG_ADDR((hw), (reg
-#define VIRTIO_WRITE_REG_4(hw, reg, value) \
-   outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg
+#define VIRTIO_READ_REG_4(hw, reg) \
+   virtio_read_reg_4((hw), (reg))
+#define VIRTIO_WRITE_REG_4(hw, reg, value) \
+   virtio_write_reg_4((hw), (reg), (value))

 static void
 legacy_read_dev_config(struct virtio_hw *hw, uint64_t offset,
-- 
1.7.9.5



[dpdk-dev] [PATCH v6 8/8] virtio: do not parse if interface is vfio

2016-01-29 Thread Santosh Shukla
If virtio interface attached to vfio driver then
do not parse for virtio resource. Instead exit with return 0;

Signed-off-by: Santosh Shukla 
---
v5-->v6:
- Removed _noimmu and using deafult rte_kdrv_vfio for drv check.

 drivers/net/virtio/virtio_pci.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 71d4a07..d73a3ad 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -515,7 +515,9 @@ virtio_resource_init_by_ioports(struct rte_pci_device 
*pci_dev)
 static int
 legacy_virtio_resource_init(struct rte_pci_device *pci_dev)
 {
-   if (virtio_resource_init_by_uio(pci_dev) == 0)
+   if (pci_dev->kdrv == RTE_KDRV_VFIO)
+   return 0;
+   else if (virtio_resource_init_by_uio(pci_dev) == 0)
return 0;
else
return virtio_resource_init_by_ioports(pci_dev);
-- 
1.7.9.5



[dpdk-dev] [PATCH v6 0/8] Add virtio support for arm/arm64

2016-01-29 Thread Santosh Shukla
Hi,

Patch series to allow access to virtio using vfio interface.
Tested for vfio-noiommu mode for x86_64/arm64{thunderX} platform.
patch series builds successfully for armv7/v8/x86_64/i686.

Patchset rebased on yuan's under review virtio-1.0 v2 patchset. Refer my public
branch [1]

Step to enable vfio-noiommu mode:
- modprobe vfio-pci
echo 1 > /sys/module/vfio/parameters/enable_unsafe_*
- then bind
./tools/dpdk_nic_bind.py -b vfio-pci :00:03.0

- Testpmd application to try out for:
./app/testpmd -c 0x3 -n 4 -- -i --portmask=0x0  --nb-cores=1 
--port-topology=chained

On host side ping to tapX interface and observe pkt_cnt on guest side.

v5-->v6:
- Removed KDRV_NOIOMMU mode
- patchseries aligned in topic-wise ordered way
- Introduced virtio_io.h; has in/out api, and header file sys/io.h 
- Renamed virtio_vfio_rw.h to virtio_vfio_io.h, renamed ioport_in/out{b,w,l} to
  vfio_in/out{b,w,l}

v4 --> v5:
- Introducing RTE_KDRV_VFIO_NOIOMMU driver mode
- Incorporated v4 review comments, Pl. refer each patchset for review change.

For older version(v4.. v1) patch history, refer [2].

Thanks.
[1] https://github.com/sshukla82/dpdk.git branch virtio-vfio-v6-review
[2] http://comments.gmane.org/gmane.comp.networking.dpdk.devel/31402

Santosh Shukla (8):
  eal: pci: add api to rd/wr pci bar region
  linuxapp/vfio: ignore mapping for ioport region
  eal/linux: never check iopl for arm
  virtio: Introduce config RTE_VIRTIO_INC_VECTOR
  virtio: move io header and api from virtio_pci.h
  virtio: add vfio api to rd/wr ioport space
  virtio: extend pci rw api for vfio
  virtio: do not parse if interface is vfio

 config/common_linuxapp  |1 +
 config/defconfig_arm-armv7a-linuxapp-gcc|4 +-
 config/defconfig_arm64-armv8a-linuxapp-gcc  |4 +-
 config/defconfig_i686-native-linuxapp-gcc   |1 +
 config/defconfig_i686-native-linuxapp-icc   |1 +
 drivers/net/virtio/Makefile |2 +-
 drivers/net/virtio/virtio_io.h  |  114 +++
 drivers/net/virtio/virtio_pci.c |  113 +++---
 drivers/net/virtio/virtio_pci.h |   30 --
 drivers/net/virtio/virtio_rxtx.c|   16 +++-
 drivers/net/virtio/virtio_rxtx.h|2 +
 drivers/net/virtio/virtio_vfio_io.h |  104 +
 lib/librte_eal/bsdapp/eal/eal_pci.c |   19 
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |3 +
 lib/librte_eal/common/include/rte_pci.h |   38 
 lib/librte_eal/linuxapp/eal/eal.c   |2 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   |   34 +++
 lib/librte_eal/linuxapp/eal/eal_pci_init.h  |6 ++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c  |   48 ++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |3 +
 20 files changed, 498 insertions(+), 47 deletions(-)
 create mode 100644 drivers/net/virtio/virtio_io.h
 create mode 100644 drivers/net/virtio/virtio_vfio_io.h

-- 
1.7.9.5



[dpdk-dev] [PATCH] example/ipsec-secgw: ipsec security gateway

2016-01-29 Thread Sergio Gonzalez Monroy
Sample app implementing an IPsec Security Geteway.
The main goal of this app is to show the use of cryptodev framework
in a real world application.

Currently only supported static IPv4 IPsec tunnels using AES-CBC
and HMAC-SHA1.

Also, currently not supported:
- SA auto negotiation (No IKE support)
- chained mbufs

Signed-off-by: Sergio Gonzalez Monroy 
---
 MAINTAINERS  |4 +
 doc/guides/sample_app_ug/index.rst   |1 +
 doc/guides/sample_app_ug/ipsec_secgw.rst |  440 +++
 examples/Makefile|2 +
 examples/ipsec-secgw/Makefile|   58 ++
 examples/ipsec-secgw/esp.c   |  256 +++
 examples/ipsec-secgw/esp.h   |   66 ++
 examples/ipsec-secgw/ipip.h  |  100 +++
 examples/ipsec-secgw/ipsec-secgw.c   | 1218 ++
 examples/ipsec-secgw/ipsec.c |  138 
 examples/ipsec-secgw/ipsec.h |  184 +
 examples/ipsec-secgw/rt.c|  131 
 examples/ipsec-secgw/sa.c|  391 ++
 examples/ipsec-secgw/sp.c|  324 
 14 files changed, 3313 insertions(+)
 create mode 100644 doc/guides/sample_app_ug/ipsec_secgw.rst
 create mode 100644 examples/ipsec-secgw/Makefile
 create mode 100644 examples/ipsec-secgw/esp.c
 create mode 100644 examples/ipsec-secgw/esp.h
 create mode 100644 examples/ipsec-secgw/ipip.h
 create mode 100644 examples/ipsec-secgw/ipsec-secgw.c
 create mode 100644 examples/ipsec-secgw/ipsec.c
 create mode 100644 examples/ipsec-secgw/ipsec.h
 create mode 100644 examples/ipsec-secgw/rt.c
 create mode 100644 examples/ipsec-secgw/sa.c
 create mode 100644 examples/ipsec-secgw/sp.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b90aeea..996eda6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -596,3 +596,7 @@ F: doc/guides/sample_app_ug/vmdq_dcb_forwarding.rst
 M: Pablo de Lara 
 M: Daniel Mrzyglod 
 F: examples/ptpclient/
+
+M: Sergio Gonzalez Monroy 
+F: doc/guides/sample_app_ug/ipsec-secgw.rst
+F: examples/ipsec-secgw/
diff --git a/doc/guides/sample_app_ug/index.rst 
b/doc/guides/sample_app_ug/index.rst
index 8a646dd..88375d2 100644
--- a/doc/guides/sample_app_ug/index.rst
+++ b/doc/guides/sample_app_ug/index.rst
@@ -73,6 +73,7 @@ Sample Applications User Guide
 proc_info
 ptpclient
 performance_thread
+ipsec_secgw

 **Figures**

diff --git a/doc/guides/sample_app_ug/ipsec_secgw.rst 
b/doc/guides/sample_app_ug/ipsec_secgw.rst
new file mode 100644
index 000..7be3f7e
--- /dev/null
+++ b/doc/guides/sample_app_ug/ipsec_secgw.rst
@@ -0,0 +1,440 @@
+..  BSD LICENSE
+Copyright(c) 2010-2016 Intel Corporation. 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 Intel Corporation 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.
+
+IPsec Security Gateway Sample Application
+=
+
+The IPsec Security Gateway application is a minimal example of real work
+application using DPDK cryptodev framework.
+
+Overview
+
+
+The application demonstrates the implementation of a minimal Security Gateway
+(see Constraints bellow) using DPDK based on RFC4301, RFC4303, RFC3602 and
+RFC2404.
+
+Note that IKE is not supported (therefore not IPsec compliant), so only manual
+setting of Security Policies and Associations is allowed.
+
+The Security Policies (SP) are implemented as ACL rules, the Security
+Associations (SA) are stored in a table and the Routing is implemented
+using LPM.
+
+The application splits 

[dpdk-dev] i40evf DPDK init_adminq failed: -53

2016-01-29 Thread Saurabh Mishra
Has anybody seen this before? What's the workaround or fix? We are using
dpdk-2.2.0 on KVM centos:

Host PF version: 1.0.11-k on Centos7


[root@ ~]# ./symmetric_mp fakeelf -c 2 -m2048 -n4 --proc-type=primary -- -p
3 --num-procs=2 --proc-id=0

[.]

EAL: Virtual area found at 0x7fff7580 (size = 0x20)

EAL: Requesting 1024 pages of size 2MB from socket 0

EAL: TSC frequency is ~2600141 KHz

EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable
clock cycles !

EAL: Master lcore 1 is ready (tid=f7fed880;cpuset=[1])

EAL: PCI device :00:04.0 on NUMA socket 0

EAL:   probe driver: 8086:154c rte_i40evf_pmd

EAL:   PCI memory mapped at 0x7620

EAL:   PCI memory mapped at 0x7621

EAL: PCI device :00:05.0 on NUMA socket 0

EAL:   probe driver: 8086:154c rte_i40evf_pmd

EAL:   PCI memory mapped at 0x76214000

EAL:   PCI memory mapped at 0x76224000

PMD: i40evf_init_vf(): init_adminq failed: -53

PMD: i40evf_dev_init(): Init vf failed

EAL: Error - exiting with code: 1

  Cause: Requested device :00:05.0 cannot be used

[root at PA-VM ~]# ./dpdk-2.2.0/tools/dpdk_nic_bind.py --status


Network devices using DPDK-compatible driver



:00:04.0 'Device 154c' drv=igb_uio unused=uio_pci_generic

:00:05.0 'Device 154c' drv=igb_uio unused=uio_pci_generic


Network devices using kernel driver

===

:00:03.0 'RTL-8139/8139C/8139C+' if=eth0 drv=8139cp
unused=igb_uio,uio_pci_generic *Active*


Other network devices

=



[root@ ~]#



04:00.0 *Ether*net controller: Intel Corporation *Ether*net Controller X710
for 10GbE SFP+ (rev 01)

04:00.1 *Ether*net controller: Intel Corporation *Ether*net Controller X710
for 10GbE SFP+ (rev 01)

04:02.0 *Ether*net controller: Intel Corporation XL710/X710 Virtual
Function (rev 01)

04:02.1 *Ether*net controller: Intel Corporation XL710/X710 Virtual
Function (rev 01)

04:0a.0 *Ether*net controller: Intel Corporation XL710/X710 Virtual
Function (rev 01)

04:0a.1 *Ether*net controller: Intel Corporation XL710/X710 Virtual
Function (rev 01)



[root at oscompute3 ~]# dmesg | tail

[2064188.042835] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.062836] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.082862] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.102838] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.122850] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.142852] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.162850] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.182845] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.202845] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[2064188.222858] i40evf :04:0a.1: i40evf_add_ether_addrs: command 15
pending

[root at oscompute3 ~]#


/Saurabh


[dpdk-dev] Increasing the number of traffic classes

2016-01-29 Thread Sridhar.V.Iyer
Hi,

I know that this topic have been covered in the youtube video and mailing list 
(http://dpdk.org/ml/archives/dev/2015-June/018875.html 
) in the past. The 
solution suggested was to have 4 queues per traffic classes and each of those 
could be construed as a sub traffic class (and that a WRR or 1:4 will ensure a 
strict priority order).

However, this solution doesn?t take into account the fact that we can only have 
4 schedulers (for the main traffic classes). If I?m not changing the total 
number of queues, i.e. I?m aiming for 8 TC with 2 queues each or 16 TC with 1 
queue each (in which case WRR logic can be optimized out), how much effort 
would it be to have a configurable (compile time) set of traffic classes? The 
changes would be largely limited to rte_sched.c right?

I?m trying to make these changes to dpdk lib, but am hitting issues in grinder 
updates. Any pointers/help would be great.

Regards,

Sridhar V Iyer
Versa Networks
315-560-4566  (mobile)
408-385-7627  (desk)
sridhariyer at versa-networks.com
 











 









 


<    1   2