[dpdk-dev] [PATCH v3 2/2] mempool: pktmbuf pool default fallback for mempool ops error

2016-09-16 Thread Hemant Agrawal
In the rte_pktmbuf_pool_create, if the default external mempool is
not available, the implementation can default to "ring_mp_mc", which
is an software implementation.

Signed-off-by: Hemant Agrawal 
---
Changes in V3:
* adding warning message to say that falling back to default sw pool
---
 lib/librte_mbuf/rte_mbuf.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 4846b89..8ab0eb1 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -176,6 +176,14 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,

rte_errno = rte_mempool_set_ops_byname(mp,
RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
+
+   /* on error, try falling back to the software based default pool */
+   if (rte_errno == -EOPNOTSUPP) {
+   RTE_LOG(WARNING, MBUF, "Default HW Mempool not supported. "
+   "falling back to sw mempool \"ring_mp_mc\"");
+   rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);
+   }
+
if (rte_errno != 0) {
RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
return NULL;
-- 
1.9.1



[dpdk-dev] [PATCH v3 1/2] eal/mempool: check for external mempool support

2016-09-16 Thread Hemant Agrawal
External offloaded mempool may not be available always. This check enables
run time verification of the presence of external mempool before the
mempool ops are installed.

An application built with a specific external mempool may work fine
on host. But, may not work on VM, specificaly if non-hw specific interfaces
are used e.g. virtio-net.

This is required to make sure that same application can work in all
environment for a given hw platform.

The solution proposed here is that rte_mempool_set_ops_byname should return
specific error in case the current execution environment is not supporting
the given mempool. Thereby allowing it to fallback on software mempool
implementation e.g. "ring_mp_mc"

This patch introduces new optional "supported" as mempool ops function
to check if external mempool instance is available or not.

Signed-off-by: Hemant Agrawal 
---
Changes in v2:
* fixed the pool_verify copy in rte_mempool_register_ops

Changes in v3:
* rename the pool_verify to supported as per David's review comment.
---
 lib/librte_mempool/rte_mempool.h   | 21 +
 lib/librte_mempool/rte_mempool_ops.c   | 19 +++
 lib/librte_mempool/rte_mempool_ring.c  |  4 
 lib/librte_mempool/rte_mempool_stack.c |  3 ++-
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 0243f9e..322f177 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -387,6 +387,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool 
*mp,
  */
 typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);

+/**
+ * Return if the given external mempool is supported for this instance.
+ * it is optional to implement for mempools
+ */
+typedef int (*rte_mempool_supported)(const struct rte_mempool *mp);
+
 /** Structure defining mempool operations structure */
 struct rte_mempool_ops {
char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */
@@ -395,6 +401,8 @@ struct rte_mempool_ops {
rte_mempool_enqueue_t enqueue;   /**< Enqueue an object. */
rte_mempool_dequeue_t dequeue;   /**< Dequeue an object. */
rte_mempool_get_count get_count; /**< Get qty of available objs. */
+   rte_mempool_supported supported;
+   /**< Verify if external mempool is supported for usages*/
 } __rte_cache_aligned;

 #define RTE_MEMPOOL_MAX_OPS_IDX 16  /**< Max registered ops structs */
@@ -516,6 +524,18 @@ void
 rte_mempool_ops_free(struct rte_mempool *mp);

 /**
+ * @internal wrapper to verify the external mempool availability
+ *
+ * @param mp
+ *   Pointer to the memory pool.
+ * @return
+ *   0: Success; external mempool instance is supported
+ * - <0: Error; external mempool instance is not supported
+ */
+int
+rte_mempool_ops_supported(const struct rte_mempool *mp);
+
+/**
  * Set the ops of a mempool.
  *
  * This can only be done on a mempool that is not populated, i.e. just after
@@ -531,6 +551,7 @@ rte_mempool_ops_free(struct rte_mempool *mp);
  *   - 0: Success; the mempool is now using the requested ops functions.
  *   - -EINVAL - Invalid ops struct name provided.
  *   - -EEXIST - mempool already has an ops struct assigned.
+ *   - -EOPNOTSUPP  - mempool instance not supported.
  */
 int
 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
diff --git a/lib/librte_mempool/rte_mempool_ops.c 
b/lib/librte_mempool/rte_mempool_ops.c
index 5f24de2..4554062 100644
--- a/lib/librte_mempool/rte_mempool_ops.c
+++ b/lib/librte_mempool/rte_mempool_ops.c
@@ -85,6 +85,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
ops->enqueue = h->enqueue;
ops->dequeue = h->dequeue;
ops->get_count = h->get_count;
+   ops->supported = h->supported;

rte_spinlock_unlock(_mempool_ops_table.sl);

@@ -123,6 +124,18 @@ rte_mempool_ops_get_count(const struct rte_mempool *mp)
return ops->get_count(mp);
 }

+/* wrapper to check if given external mempool is supported for this instance.*/
+int
+rte_mempool_ops_supported(const struct rte_mempool *mp)
+{
+   struct rte_mempool_ops *ops;
+
+   ops = rte_mempool_get_ops(mp->ops_index);
+   if (ops->supported)
+   return ops->supported(mp);
+   return 0;
+}
+
 /* sets mempool ops previously registered by rte_mempool_register_ops. */
 int
 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
@@ -146,6 +159,12 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const 
char *name,
if (ops == NULL)
return -EINVAL;

+   /*verify if the given mempool is supported for this instance */
+   if (ops->supported) {
+   if (ops->supported(mp))
+   return -EOPNOTSUPP;
+   }
+
mp->ops_index = i;
mp->pool_config = pool_config;
return 0;
diff --git a/lib/librte_mempool/rte_mempool_ring.c 
b/lib/librte_mempool/rte_mempool_ring.c
index 

[dpdk-dev] [PATCH v2] kni: support RHEL 7.3

2016-09-16 Thread Pablo de Lara
Add support for RHEL 7.3, which uses kernel 3.10,
but backported features from newer kernels.

Signed-off-by: Pablo de Lara 
---
Changes in v2:
- Simplified conditional logic

 lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h 
b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
index bdd0806..e28d113 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
@@ -3891,7 +3891,7 @@ skb_set_hash(struct sk_buff *skb, __u32 hash, 
__always_unused int type)
 #if (( LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) ) \
 || ( RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,2) ))
 #define HAVE_NDO_DFLT_BRIDGE_ADD_MASK
-#if (!( RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,2) ))
+#if ( RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(7,2) )
 #define HAVE_NDO_FDB_ADD_VID
 #endif /* !RHEL 7.2 */
 #endif /* >= 3.19.0 */
@@ -3901,12 +3901,13 @@ skb_set_hash(struct sk_buff *skb, __u32 hash, 
__always_unused int type)
 /* vlan_tx_xx functions got renamed to skb_vlan */
 #define vlan_tx_tag_get skb_vlan_tag_get
 #define vlan_tx_tag_present skb_vlan_tag_present
-#if (!( RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,2) ))
+#if ( RHEL_RELEASE_CODE != RHEL_RELEASE_VERSION(7,2) )
 #define HAVE_NDO_BRIDGE_SET_DEL_LINK_FLAGS
 #endif /* !RHEL 7.2 */
 #endif /* 4.0.0 */

-#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) )
+#if (( LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0) ) \
+|| ( RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,3) ))
 /* ndo_bridge_getlink adds new nlflags parameter */
 #define HAVE_NDO_BRIDGE_GETLINK_NLFLAGS
 #endif /* >= 4.1.0 */
-- 
2.7.4



[dpdk-dev] [PATCH v4 0/2] add NULL crypto support in Intel QAT driver

2016-09-16 Thread De Lara Guarch, Pablo


> -Original Message-
> From: Jain, Deepak K
> Sent: Friday, September 16, 2016 1:57 AM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo; Jain, Deepak K
> Subject: [PATCH v4 0/2] add NULL crypto support in Intel QAT driver
> 
> This patchset adds support of NULL crypto in Intel(R) QuickAssist Technology
> driver.
> 
> This patchset depends on following patchset:
> "crypto/qat: add aes-sha384-hmac capability to Intel QAT driver"
> (http://dpdk.org/dev/patchwork/patch/15778/)
> 
> Deepak Kumar JAIN (2):
>   crypto/qat: add NULL capability to Intel QAT driver
>   app/test: add test cases for NULL for Intel QAT driver
> 
> Changes in v4:
> * Correct increment of key size in capabilities.
> 
> Changes in v3:
> * Added information in capability structure.
> 
> Changes in v2:
> * Added new feature information in release_16_11.rst file.
> 
>  app/test/test_cryptodev.c| 10 ++
>  doc/guides/cryptodevs/qat.rst|  3 +-
>  doc/guides/rel_notes/release_16_11.rst   |  1 +
>  drivers/crypto/qat/qat_adf/qat_algs_build_desc.c |  2 ++
>  drivers/crypto/qat/qat_crypto.c  | 45 
> 
>  5 files changed, 60 insertions(+), 1 deletion(-)
> 
> --
> 2.5.5

Applied to dpdk-next-crypto.
Thanks,

Pablo


[dpdk-dev] [PATCH] crypto/null: fix key size increment value

2016-09-16 Thread De Lara Guarch, Pablo


> -Original Message-
> From: Jain, Deepak K
> Sent: Friday, September 16, 2016 3:50 AM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo; Jain, Deepak K
> Subject: [PATCH] crypto/null: fix key size increment value
> 
> This patch fixes the values of increment in key size.
> 
> Fixes:94b0ad8e0a ("null_crypto_pmd: PMD to support null crypto
>   operations")
> 
> Signed-off-by: Deepak Kumar Jain 

Applied to dpdk-next-crypto.
Thanks,

Pablo


[dpdk-dev] How to include pre-build object file (.o) in DPDK makefile?

2016-09-16 Thread Ferruh Yigit
On 9/16/2016 6:04 PM, Lu, Patrick wrote:
> Hi,
> 
> I'm trying to include some hand written assembly (compiled by yasm) in my 
> DPDK program. I couldn't find any example linking the DPDK C code with 
> pre-compiled .o file. I've searched the mk/ and found OBJS-y seems the right 
> variable to include .o file, but when generating the final executable, OBJS-y 
> contains only main.o (generating from main.c).
> 
> I've tried to put my .o file in both source directory as well as build/
> 

Possible to use EXTRA_LDLIBS to provide the object file name, and put
object file into build folder.

Following example worked for me:

$ nm foo.o
 T foo

$ cp foo.o examples/skeleton/build/

$ make -C examples/skeleton EXTRA_LDLIBS="foo.o"
make: Entering directory '.../examples/skeleton'
  CC basicfwd.o
  LD basicfwd
  INSTALL-APP basicfwd
  INSTALL-MAP basicfwd.map
make: Leaving directory '.../examples/skeleton'

$ nm examples/skeleton/build/basicfwd | grep foo
0055fd1d T foo



[dpdk-dev] How to include pre-build object file (.o) in DPDK makefile?

2016-09-16 Thread Lu, Patrick
-Original Message-
From: Yigit, Ferruh 
Sent: Friday, September 16, 2016 11:05 AM
To: Lu, Patrick ; dev at dpdk.org
Subject: Re: [dpdk-dev] How to include pre-build object file (.o) in DPDK 
makefile?

On 9/16/2016 6:04 PM, Lu, Patrick wrote:
> Hi,
> 
> I'm trying to include some hand written assembly (compiled by yasm) in my 
> DPDK program. I couldn't find any example linking the DPDK C code with 
> pre-compiled .o file. I've searched the mk/ and found OBJS-y seems the right 
> variable to include .o file, but when generating the final executable, OBJS-y 
> contains only main.o (generating from main.c).
> 
> I've tried to put my .o file in both source directory as well as 
> build/
> 

Possible to use EXTRA_LDLIBS to provide the object file name, and put object 
file into build folder.

Following example worked for me:

$ nm foo.o
 T foo

$ cp foo.o examples/skeleton/build/

$ make -C examples/skeleton EXTRA_LDLIBS="foo.o"
make: Entering directory '.../examples/skeleton'
  CC basicfwd.o
  LD basicfwd
  INSTALL-APP basicfwd
  INSTALL-MAP basicfwd.map
make: Leaving directory '.../examples/skeleton'

$ nm examples/skeleton/build/basicfwd | grep foo 0055fd1d T foo

Perfect! This works for me.

Sincerely,

Patrick



[dpdk-dev] [PATCH v2 19/19] kni: move kernel version ifdefs to compat header

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/compat.h| 12 
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 16 +---
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h 
b/lib/librte_eal/linuxapp/kni/compat.h
index 9ae50a7..78da08e 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -20,6 +20,14 @@

 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
 #define sk_sleep(s) ((s)->sk_sleep)
+#else
+#define HAVE_SOCKET_WQ
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#define HAVE_STATIC_SOCK_MAP_FD
+#else
+#define kni_sock_map_fd(s) sock_map_fd(s, 0)
 #endif

 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
@@ -39,6 +47,10 @@
 #define HAVE_REBUILD_HEADER
 #endif

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#define HAVE_SK_ALLOC_KERN_PARAM
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
 #define HAVE_TRANS_START_HELPER
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c 
b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 3ba0c57..f54c34b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,7 +40,7 @@

 #define RX_BURST_SZ 4

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#ifdef HAVE_STATIC_SOCK_MAP_FD
 static int kni_sock_map_fd(struct socket *sock)
 {
struct file *file;
@@ -57,8 +57,6 @@ static int kni_sock_map_fd(struct socket *sock)
fd_install(fd, file);
return fd;
 }
-#else
-#define kni_sock_map_fd(s) sock_map_fd(s, 0)
 #endif

 static struct proto kni_raw_proto = {
@@ -225,17 +223,13 @@ kni_sock_poll(struct file *file, struct socket *sock, 
poll_table *wait)
return POLLERR;

kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
  kni->group_id, (uint64_t)sock->wq);
+   poll_wait(file, >wq->wait, wait);
 #else
pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
  kni->group_id, (uint64_t)>wait);
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-   poll_wait(file, >wq->wait, wait);
-#else
poll_wait(file, >wait, wait);
 #endif

@@ -663,7 +657,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
if (kni->vhost_queue != NULL)
return -1;

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#ifdef HAVE_SK_ALLOC_KERN_PARAM
q = (struct kni_vhost_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
_raw_proto, 0);
 #else
@@ -729,7 +723,7 @@ kni_vhost_backend_init(struct kni_dev *kni)

kni->vq_status = BE_START;

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
  q->sockfd, (uint64_t)q->sock->wq,
  (uint64_t)q->sk.sk_wq);
-- 
2.7.4



[dpdk-dev] [PATCH v2 18/19] kni: prefer uint32_t to unsigned int

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  8 
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 22 +++---
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 17 +++--
 lib/librte_eal/linuxapp/kni/kni_net.c   | 24 
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 25 -
 5 files changed, 46 insertions(+), 50 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h 
b/lib/librte_eal/linuxapp/kni/kni_dev.h
index fa9901d..f5a72cd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -55,7 +55,7 @@ struct kni_dev {
struct net_device_stats stats;
int status;
uint16_t group_id;   /* Group ID of a group of KNI devices */
-   unsigned int core_id;/* Core ID to bind */
+   uint32_t core_id;/* Core ID to bind */
char name[RTE_KNI_NAMESIZE]; /* Network device name */
struct task_struct *pthread;

@@ -96,7 +96,7 @@ struct kni_dev {
void *mbuf_va;

/* mbuf size */
-   unsigned int mbuf_size;
+   uint32_t mbuf_size;

/* synchro for request processing */
unsigned long synchro;
@@ -113,7 +113,7 @@ struct kni_dev {
 };

 #ifdef RTE_KNI_VHOST
-unsigned int
+uint32_t
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
 int kni_chk_vhost_rx(struct kni_dev *kni);
 int kni_vhost_init(struct kni_dev *kni);
@@ -125,7 +125,7 @@ struct kni_vhost_queue {
int vnet_hdr_sz;
struct kni_dev *kni;
int sockfd;
-   unsigned int flags;
+   uint32_t flags;
struct sk_buff *cache;
struct rte_kni_fifo *fifo;
 };
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h 
b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 71bc2a9..77048a1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -31,12 +31,12 @@
  * Adds num elements into the fifo. Return the number actually written
  */
 static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-   unsigned int i = 0;
-   unsigned int fifo_write = fifo->write;
-   unsigned int fifo_read = fifo->read;
-   unsigned int new_write = fifo_write;
+   uint32_t i = 0;
+   uint32_t fifo_write = fifo->write;
+   uint32_t fifo_read = fifo->read;
+   uint32_t new_write = fifo_write;

for (i = 0; i < num; i++) {
new_write = (new_write + 1) & (fifo->len - 1);
@@ -55,11 +55,11 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, 
unsigned int num)
  * Get up to num elements from the fifo. Return the number actully read
  */
 static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-   unsigned int i = 0;
-   unsigned int new_read = fifo->read;
-   unsigned int fifo_write = fifo->write;
+   uint32_t i = 0;
+   uint32_t new_read = fifo->read;
+   uint32_t fifo_write = fifo->write;

for (i = 0; i < num; i++) {
if (new_read == fifo_write)
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned int
+static inline uint32_t
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
+kni_fifo_init(struct rte_kni_fifo *fifo, uint32_t size)
 {
fifo->write = 0;
fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index e012b50..95272cc 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -55,7 +55,7 @@ static char *lo_mode;

 /* Kernel thread mode */
 static char *kthread_mode;
-static unsigned int multiple_kthread_on;
+static uint32_t multiple_kthread_on;

 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */

@@ -279,8 +279,8 @@ kni_check_param(struct kni_dev *kni, struct 
rte_kni_device_info *dev)
 }

 static int
-kni_ioctl_create(struct net *net,
-   unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_create(struct net *net, uint32_t ioctl_num,
+   unsigned long ioctl_param)
 {
struct kni_net *knet = net_generic(net, kni_net_id);
int ret;
@@ -473,8 +473,8 @@ kni_ioctl_create(struct net *net,
 }

 static int
-kni_ioctl_release(struct net *net,
-   unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_release(struct net *net, uint32_t ioctl_num,
+   unsigned long ioctl_param)
 {
struct kni_net *knet 

[dpdk-dev] [PATCH v2 17/19] kni: updated log messages

2016-09-16 Thread Ferruh Yigit
Remove some function entrance logs and changed log level of some logs.

Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 9 ++---
 lib/librte_eal/linuxapp/kni/kni_net.c  | 6 ++
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 17299da..e012b50 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -186,7 +186,7 @@ kni_open(struct inode *inode, struct file *file)

/* Create kernel thread for single mode */
if (multiple_kthread_on == 0) {
-   pr_debug("Single kernel thread for all KNI devices\n");
+   pr_info("Single kernel thread for all KNI devices\n");
/* Create kernel thread for RX */
knet->kni_kthread = kthread_run(kni_thread_single, (void *)knet,
"kni_single");
@@ -195,7 +195,7 @@ kni_open(struct inode *inode, struct file *file)
return PTR_ERR(knet->kni_kthread);
}
} else
-   pr_debug("Multiple kernel thread mode enabled\n");
+   pr_info("Multiple kernel thread mode enabled\n");

file->private_data = get_net(net);
pr_debug("/dev/kni opened\n");
@@ -596,8 +596,6 @@ kni_init(void)
 {
int rc;

-   pr_debug(" DPDK kni module loading \n");
-
if (kni_parse_kthread_mode() < 0) {
pr_err("Invalid parameter for kthread_mode\n");
return -EINVAL;
@@ -620,8 +618,6 @@ kni_init(void)
/* Configure the lo mode according to the input parameter */
kni_net_config_lo_mode(lo_mode);

-   pr_debug(" DPDK kni module loaded  \n");
-
return 0;

 out:
@@ -642,7 +638,6 @@ kni_exit(void)
 #else
unregister_pernet_gen_subsys(kni_net_id, _net_ops);
 #endif
-   pr_debug("### DPDK kni module unloaded  ###\n");
 }

 module_init(kni_init);
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c 
b/lib/librte_eal/linuxapp/kni/kni_net.c
index 12dd89f..7c3e30b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -560,8 +560,8 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-   pr_debug("kni_net_ioctl %d\n",
-   ((struct kni_dev *)netdev_priv(dev))->group_id);
+   pr_debug("kni_net_ioctl group:%d cmd:%d\n",
+   ((struct kni_dev *)netdev_priv(dev))->group_id, cmd);

return 0;
 }
@@ -704,8 +704,6 @@ kni_net_init(struct net_device *dev)
 {
struct kni_dev *kni = netdev_priv(dev);

-   pr_debug("kni_net_init\n");
-
init_waitqueue_head(>wq);
mutex_init(>sync_lock);

-- 
2.7.4



[dpdk-dev] [PATCH v2 16/19] kni: remove compile time debug configuration

2016-09-16 Thread Ferruh Yigit
Since switched to kernel dynamic debugging it is possible to remove
compile time debug log configuration.

Signed-off-by: Ferruh Yigit 
---
 config/common_base  |  3 ---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 18 -
 lib/librte_eal/linuxapp/kni/kni_misc.c  |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_net.c   |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 46 -
 5 files changed, 31 insertions(+), 52 deletions(-)

diff --git a/config/common_base b/config/common_base
index 7830535..4a9e5b0 100644
--- a/config/common_base
+++ b/config/common_base
@@ -533,12 +533,9 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n
 CONFIG_RTE_LIBRTE_KNI=n
 CONFIG_RTE_KNI_KMOD=n
 CONFIG_RTE_KNI_PREEMPT_DEFAULT=y
-CONFIG_RTE_KNI_KO_DEBUG=n
 CONFIG_RTE_KNI_VHOST=n
 CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024
 CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=n
-CONFIG_RTE_KNI_VHOST_DEBUG_RX=n
-CONFIG_RTE_KNI_VHOST_DEBUG_TX=n

 #
 # Compile the pdump library
diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h 
b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 7e48203..fa9901d 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -112,12 +112,6 @@ struct kni_dev {
 #endif
 };

-#ifdef RTE_KNI_KO_DEBUG
-   #define KNI_DBG(args...) pr_debug(args)
-#else
-   #define KNI_DBG(args...)
-#endif
-
 #ifdef RTE_KNI_VHOST
 unsigned int
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
@@ -149,16 +143,4 @@ void ixgbe_kni_remove(struct pci_dev *pdev);
 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
 void igb_kni_remove(struct pci_dev *pdev);

-#ifdef RTE_KNI_VHOST_DEBUG_RX
-   #define KNI_DBG_RX(args...) pr_debug(args)
-#else
-   #define KNI_DBG_RX(args...)
-#endif
-
-#ifdef RTE_KNI_VHOST_DEBUG_TX
-   #define KNI_DBG_TX(args...) pr_debug(args)
-#else
-   #define KNI_DBG_TX(args...)
-#endif
-
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 235ce1a..17299da 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -379,7 +379,7 @@ kni_ioctl_create(struct net *net,
pr_debug("mbuf_va:  0x%p\n", dev_info.mbuf_va);
pr_debug("mbuf_size:%u\n", kni->mbuf_size);

-   KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n",
+   pr_debug("PCI: %02x:%02x.%02x %04x:%04x\n",
dev_info.bus,
dev_info.devid,
dev_info.function,
@@ -407,7 +407,7 @@ kni_ioctl_create(struct net *net,
else
ret = -1;

-   KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n",
+   pr_debug("PCI found: pci=0x%p, lad_dev=0x%p\n",
pci, lad_dev);
if (ret == 0) {
kni->lad_dev = lad_dev;
@@ -527,7 +527,7 @@ kni_ioctl(struct inode *inode,
int ret = -EINVAL;
struct net *net = current->nsproxy->net_ns;

-   KNI_DBG("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
+   pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);

/*
 * Switch according to the ioctl called
@@ -543,7 +543,7 @@ kni_ioctl(struct inode *inode,
ret = kni_ioctl_release(net, ioctl_num, ioctl_param);
break;
default:
-   KNI_DBG("IOCTL default\n");
+   pr_debug("IOCTL default\n");
break;
}

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c 
b/lib/librte_eal/linuxapp/kni/kni_net.c
index a732cbd..12dd89f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -547,7 +547,7 @@ kni_net_tx_timeout(struct net_device *dev)
 {
struct kni_dev *kni = netdev_priv(dev);

-   KNI_DBG("Transmit timeout at %ld, latency %ld\n", jiffies,
+   pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies,
jiffies - dev->trans_start);

kni->stats.tx_errors++;
@@ -560,7 +560,7 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-   KNI_DBG("kni_net_ioctl %d\n",
+   pr_debug("kni_net_ioctl %d\n",
((struct kni_dev *)netdev_priv(dev))->group_id);

return 0;
@@ -578,7 +578,7 @@ kni_net_change_mtu(struct net_device *dev, int new_mtu)
struct rte_kni_request req;
struct kni_dev *kni = netdev_priv(dev);

-   KNI_DBG("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
+   pr_debug("kni_net_change_mtu new mtu %d to be set\n", new_mtu);

memset(, 0, sizeof(req));
req.req_id = RTE_KNI_REQ_CHANGE_MTU;
@@ -704,7 +704,7 @@ kni_net_init(struct net_device *dev)
 {
struct kni_dev *kni = 

[dpdk-dev] [PATCH v2 15/19] kni: move functions to eliminate function declarations

2016-09-16 Thread Ferruh Yigit
Function implementations kept same.

Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 301 -
 lib/librte_eal/linuxapp/kni/kni_net.c  | 293 
 2 files changed, 287 insertions(+), 307 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 6947483..235ce1a 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -50,35 +50,6 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 extern const struct pci_device_id ixgbe_pci_tbl[];
 extern const struct pci_device_id igb_pci_tbl[];

-static int kni_open(struct inode *inode, struct file *file);
-static int kni_release(struct inode *inode, struct file *file);
-static int kni_ioctl(struct inode *inode, unsigned int ioctl_num,
-   unsigned long ioctl_param);
-static int kni_compat_ioctl(struct inode *inode, unsigned int ioctl_num,
-   unsigned long ioctl_param);
-static int kni_dev_remove(struct kni_dev *dev);
-
-static int __init kni_parse_kthread_mode(void);
-
-/* KNI processing for single kernel thread mode */
-static int kni_thread_single(void *unused);
-/* KNI processing for multiple kernel thread mode */
-static int kni_thread_multiple(void *param);
-
-static const struct file_operations kni_fops = {
-   .owner = THIS_MODULE,
-   .open = kni_open,
-   .release = kni_release,
-   .unlocked_ioctl = (void *)kni_ioctl,
-   .compat_ioctl = (void *)kni_compat_ioctl,
-};
-
-static struct miscdevice kni_misc = {
-   .minor = MISC_DYNAMIC_MINOR,
-   .name = KNI_DEVICE,
-   .fops = _fops,
-};
-
 /* loopback mode */
 static char *lo_mode;

@@ -149,72 +120,56 @@ static struct pernet_operations kni_net_ops = {
 #endif
 };

-static int __init
-kni_init(void)
+static int
+kni_thread_single(void *data)
 {
-   int rc;
-
-   pr_debug(" DPDK kni module loading \n");
-
-   if (kni_parse_kthread_mode() < 0) {
-   pr_err("Invalid parameter for kthread_mode\n");
-   return -EINVAL;
-   }
+   struct kni_net *knet = data;
+   int j;
+   struct kni_dev *dev;

-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-   rc = register_pernet_subsys(_net_ops);
+   while (!kthread_should_stop()) {
+   down_read(>kni_list_lock);
+   for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
+   list_for_each_entry(dev, >kni_list_head, list) {
+#ifdef RTE_KNI_VHOST
+   kni_chk_vhost_rx(dev);
 #else
-   rc = register_pernet_gen_subsys(_net_id, _net_ops);
+   kni_net_rx(dev);
+#endif
+   kni_net_poll_resp(dev);
+   }
+   }
+   up_read(>kni_list_lock);
+#ifdef RTE_KNI_PREEMPT_DEFAULT
+   /* reschedule out for a while */
+   schedule_timeout_interruptible(
+   usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
-   if (rc)
-   return -EPERM;
-
-   rc = misc_register(_misc);
-   if (rc != 0) {
-   pr_err("Misc registration failed\n");
-   goto out;
}

-   /* Configure the lo mode according to the input parameter */
-   kni_net_config_lo_mode(lo_mode);
-
-   pr_debug(" DPDK kni module loaded  \n");
-
return 0;
-
-out:
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-   unregister_pernet_subsys(_net_ops);
-#else
-   unregister_pernet_gen_subsys(kni_net_id, _net_ops);
-#endif
-   return rc;
 }

-static void __exit
-kni_exit(void)
+static int
+kni_thread_multiple(void *param)
 {
-   misc_deregister(_misc);
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-   unregister_pernet_subsys(_net_ops);
+   int j;
+   struct kni_dev *dev = (struct kni_dev *)param;
+
+   while (!kthread_should_stop()) {
+   for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
+#ifdef RTE_KNI_VHOST
+   kni_chk_vhost_rx(dev);
 #else
-   unregister_pernet_gen_subsys(kni_net_id, _net_ops);
+   kni_net_rx(dev);
 #endif
-   pr_debug("### DPDK kni module unloaded  ###\n");
-}
-
-static int __init
-kni_parse_kthread_mode(void)
-{
-   if (!kthread_mode)
-   return 0;
-
-   if (strcmp(kthread_mode, "single") == 0)
-   return 0;
-   else if (strcmp(kthread_mode, "multiple") == 0)
-   multiple_kthread_on = 1;
-   else
-   return -1;
+   kni_net_poll_resp(dev);
+   }
+#ifdef RTE_KNI_PREEMPT_DEFAULT
+   schedule_timeout_interruptible(
+   usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
+#endif
+   }

return 0;
 }
@@ -249,6 +204,27 @@ kni_open(struct inode *inode, 

[dpdk-dev] [PATCH v2 14/19] kni: remove unnecessary 'out of memory' message

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c 
b/lib/librte_eal/linuxapp/kni/kni_net.c
index 1dca5f0..9585879 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -156,7 +156,6 @@ kni_net_rx_normal(struct kni_dev *kni)

skb = dev_alloc_skb(len + 2);
if (!skb) {
-   pr_err("Out of mem, dropping pkts\n");
/* Update statistics */
kni->stats.rx_dropped++;
continue;
@@ -335,9 +334,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
kni->mbuf_kva;

skb = dev_alloc_skb(len + 2);
-   if (skb == NULL)
-   pr_err("Out of mem, dropping pkts\n");
-   else {
+   if (skb) {
/* Align IP on 16B boundary */
skb_reserve(skb, 2);
memcpy(skb_put(skb, len), data_kva, len);
@@ -349,7 +346,6 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
/* Simulate real usage, allocate/copy skb twice */
skb = dev_alloc_skb(len + 2);
if (skb == NULL) {
-   pr_err("Out of mem, dropping pkts\n");
kni->stats.rx_dropped++;
continue;
}
-- 
2.7.4



[dpdk-dev] [PATCH v2 13/19] kni: update kernel logging

2016-09-16 Thread Ferruh Yigit
Switch to dynamic logging functions. Depending kernel configuration this
may cause previously visible logs disappear.

How to enable dynamic logging:
https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt

Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 13 ---
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 60 -
 lib/librte_eal/linuxapp/kni/kni_net.c   | 34 +--
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 +++
 4 files changed, 61 insertions(+), 58 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h 
b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 643df4b..7e48203 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -25,6 +25,11 @@
 #ifndef _KNI_DEV_H_
 #define _KNI_DEV_H_

+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -107,10 +112,8 @@ struct kni_dev {
 #endif
 };

-#define KNI_ERR(args...) printk(KERN_DEBUG "KNI: Error: " args)
-#define KNI_PRINT(args...) printk(KERN_DEBUG "KNI: " args)
 #ifdef RTE_KNI_KO_DEBUG
-   #define KNI_DBG(args...) printk(KERN_DEBUG "KNI: " args)
+   #define KNI_DBG(args...) pr_debug(args)
 #else
#define KNI_DBG(args...)
 #endif
@@ -147,13 +150,13 @@ int igb_kni_probe(struct pci_dev *pdev, struct net_device 
**lad_dev);
 void igb_kni_remove(struct pci_dev *pdev);

 #ifdef RTE_KNI_VHOST_DEBUG_RX
-   #define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
+   #define KNI_DBG_RX(args...) pr_debug(args)
 #else
#define KNI_DBG_RX(args...)
 #endif

 #ifdef RTE_KNI_VHOST_DEBUG_TX
-   #define KNI_DBG_TX(args...) printk(KERN_DEBUG "KNI TX: " args)
+   #define KNI_DBG_TX(args...) pr_debug(args)
 #else
#define KNI_DBG_TX(args...)
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 53f2dfd..6947483 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -154,10 +154,10 @@ kni_init(void)
 {
int rc;

-   KNI_PRINT(" DPDK kni module loading \n");
+   pr_debug(" DPDK kni module loading \n");

if (kni_parse_kthread_mode() < 0) {
-   KNI_ERR("Invalid parameter for kthread_mode\n");
+   pr_err("Invalid parameter for kthread_mode\n");
return -EINVAL;
}

@@ -171,14 +171,14 @@ kni_init(void)

rc = misc_register(_misc);
if (rc != 0) {
-   KNI_ERR("Misc registration failed\n");
+   pr_err("Misc registration failed\n");
goto out;
}

/* Configure the lo mode according to the input parameter */
kni_net_config_lo_mode(lo_mode);

-   KNI_PRINT(" DPDK kni module loaded  \n");
+   pr_debug(" DPDK kni module loaded  \n");

return 0;

@@ -200,7 +200,7 @@ kni_exit(void)
 #else
unregister_pernet_gen_subsys(kni_net_id, _net_ops);
 #endif
-   KNI_PRINT("### DPDK kni module unloaded  ###\n");
+   pr_debug("### DPDK kni module unloaded  ###\n");
 }

 static int __init
@@ -231,19 +231,19 @@ kni_open(struct inode *inode, struct file *file)

/* Create kernel thread for single mode */
if (multiple_kthread_on == 0) {
-   KNI_PRINT("Single kernel thread for all KNI devices\n");
+   pr_debug("Single kernel thread for all KNI devices\n");
/* Create kernel thread for RX */
knet->kni_kthread = kthread_run(kni_thread_single, (void *)knet,
"kni_single");
if (IS_ERR(knet->kni_kthread)) {
-   KNI_ERR("Unable to create kernel threaed\n");
+   pr_err("Unable to create kernel threaed\n");
return PTR_ERR(knet->kni_kthread);
}
} else
-   KNI_PRINT("Multiple kernel thread mode enabled\n");
+   pr_debug("Multiple kernel thread mode enabled\n");

file->private_data = get_net(net);
-   KNI_PRINT("/dev/kni opened\n");
+   pr_debug("/dev/kni opened\n");

return 0;
 }
@@ -282,7 +282,7 @@ kni_release(struct inode *inode, struct file *file)
clear_bit(KNI_DEV_IN_USE_BIT_NUM, >device_in_use);

put_net(net);
-   KNI_PRINT("/dev/kni closed\n");
+   pr_debug("/dev/kni closed\n");

return 0;
 }
@@ -370,7 +370,7 @@ kni_check_param(struct kni_dev *kni, struct 
rte_kni_device_info *dev)

/* Check if network name has been used */
if (!strncmp(kni->name, dev->name, RTE_KNI_NAMESIZE)) {
-   KNI_ERR("KNI name %s duplicated\n", dev->name);
+   pr_err("KNI name %s duplicated\n", dev->name);
return -1;
}

@@ -390,7 +390,7 @@ kni_ioctl_create(struct net *net,
struct 

[dpdk-dev] [PATCH v2 12/19] kni: prefer ether_addr_copy to memcpy

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/compat.h   | 4 
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h 
b/lib/librte_eal/linuxapp/kni/compat.h
index d79d626..9ae50a7 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -26,6 +26,10 @@
 #define HAVE_CHANGE_CARRIER_CB
 #endif

+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+#define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN)
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
 #define HAVE_IOV_ITER_MSGHDR
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 61a387e..53f2dfd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -527,7 +527,7 @@ kni_ioctl_create(struct net *net,
pci_dev_put(pci);

if (kni->lad_dev)
-   memcpy(net_dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
+   ether_addr_copy(net_dev->dev_addr, kni->lad_dev->dev_addr);
else
/*
 * Generate random mac address. eth_random_addr() is the newer
-- 
2.7.4



[dpdk-dev] [PATCH v2 11/19] kni: prefer min_t to min

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_net.c   | 6 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c 
b/lib/librte_eal/linuxapp/kni/kni_net.c
index 81d139e..a6458fa 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -139,7 +139,7 @@ kni_net_rx_normal(struct kni_dev *kni)
}

/* Calculate the number of entries to dequeue from rx_q */
-   num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
+   num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);

/* Burst dequeue from rx_q */
num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -236,7 +236,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
num = min(num_rq, num_tq);
num = min(num, num_aq);
num = min(num, num_fq);
-   num = min(num, (unsigned int)MBUF_BURST_SZ);
+   num = min_t(unsigned int, num, MBUF_BURST_SZ);

/* Return if no entry to dequeue from rx_q */
if (num == 0)
@@ -316,7 +316,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)

/* Calculate the number of entries to dequeue from rx_q */
num = min(num_rq, num_fq);
-   num = min(num, (unsigned int)MBUF_BURST_SZ);
+   num = min_t(unsigned int, num, MBUF_BURST_SZ);

/* Return if no entry to dequeue from rx_q */
if (num == 0)
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c 
b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index eacfe3f..e460dd6 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
nb_mbuf = kni_fifo_count(kni->rx_q);

nb_in = min(nb_mbuf, nb_skb);
-   nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
+   nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
nb_burst   = (nb_in & ~BURST_MASK);
nb_backlog = (nb_in & BURST_MASK);

-- 
2.7.4



[dpdk-dev] [PATCH v2 10/19] kni: macros with complex values should be enclosed in parentheses

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h 
b/lib/librte_eal/linuxapp/kni/compat.h
index 962a4e7..d79d626 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -19,7 +19,7 @@
 #endif

 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
-#define sk_sleep(s) (s)->sk_sleep
+#define sk_sleep(s) ((s)->sk_sleep)
 #endif

 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-- 
2.7.4



[dpdk-dev] [PATCH v2 09/19] kni: do not use assignment in if condition

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c 
b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index bef4889..eacfe3f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -410,13 +410,14 @@ kni_sock_rcvmsg(struct socket *sock,
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
if (likely(q->flags & IFF_VNET_HDR)) {
vnet_hdr_len = q->vnet_hdr_sz;
-   if ((len -= vnet_hdr_len) < 0)
+   len -= vnet_hdr_len;
+   if (len < 0)
return -EINVAL;
}
 #endif

-   if (unlikely(0 == (pkt_len = kni_vhost_net_rx(q->kni,
-   m, vnet_hdr_len, len
+   pkt_len = kni_vhost_net_rx(q->kni, m, vnet_hdr_len, len);
+   if (unlikely(pkt_len == 0))
return 0;

 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
@@ -567,7 +568,8 @@ kni_sock_release(struct socket *sock)
if (q == NULL)
return 0;

-   if (NULL != (kni = q->kni)) {
+   kni = q->kni;
+   if (kni != NULL) {
kni->vq_status = BE_STOP;
KNI_VHOST_WAIT_WQ_SAFE();
kni->vhost_queue = NULL;
-- 
2.7.4



[dpdk-dev] [PATCH v2 08/19] kni: trailing statements should be on next line

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c 
b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index ec39538..bef4889 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -244,11 +244,12 @@ kni_sock_poll(struct file *file, struct socket *sock, 
poll_table *wait)

if (sock_writeable(>sk) ||
 #ifdef SOCKWQ_ASYNC_NOSPACE
-   (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, >sock->flags) &&
+   (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, >sock->flags) &&
+   sock_writeable(>sk)))
 #else
-   (!test_and_set_bit(SOCK_ASYNC_NOSPACE, >sock->flags) &&
+   (!test_and_set_bit(SOCK_ASYNC_NOSPACE, >sock->flags) &&
+   sock_writeable(>sk)))
 #endif
-sock_writeable(>sk)))
mask |= POLLOUT | POLLWRNORM;

return mask;
-- 
2.7.4



[dpdk-dev] [PATCH v2 07/19] kni: comparisons should place the constant on the right

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c 
b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f1345c3..ec39538 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -169,7 +169,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,

/* free skb to cache */
skb->data = NULL;
-   if (unlikely(1 != kni_fifo_put(q->fifo, (void **), 1)))
+   if (unlikely(kni_fifo_put(q->fifo, (void **), 1) != 1))
/* Failing should not happen */
KNI_ERR("Fail to enqueue entries into rx cache fifo\n");

@@ -197,8 +197,8 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
kni->stats.rx_packets++;

/* enqueue mbufs into free_q */
-   va = (void*)kva - kni->mbuf_kva + kni->mbuf_va;
-   if (unlikely(1 != kni_fifo_put(kni->free_q, (void **), 1)))
+   va = (void *)kva - kni->mbuf_kva + kni->mbuf_va;
+   if (unlikely(kni_fifo_put(kni->free_q, (void **), 1) != 1))
/* Failing should not happen */
KNI_ERR("Fail to enqueue entries into free_q\n");

@@ -303,15 +303,13 @@ kni_chk_vhost_rx(struct kni_dev *kni)
nb_backlog = (nb_in & BURST_MASK);

/* enqueue skb_queue per BURST_SIZE bulk */
-   if (0 != nb_burst) {
-   if (unlikely(RX_BURST_SZ != kni_fifo_get(
-kni->rx_q, (void **),
-RX_BURST_SZ)))
+   if (nb_burst != 0) {
+   if (unlikely(kni_fifo_get(kni->rx_q, (void **), RX_BURST_SZ)
+   != RX_BURST_SZ))
goto except;

-   if (unlikely(RX_BURST_SZ != kni_fifo_get(
-q->fifo, (void **),
-RX_BURST_SZ)))
+   if (unlikely(kni_fifo_get(q->fifo, (void **), RX_BURST_SZ)
+   != RX_BURST_SZ))
goto except;

kni_vhost_enqueue_burst(kni, q, skb, va);
@@ -319,12 +317,10 @@ kni_chk_vhost_rx(struct kni_dev *kni)

/* all leftover, do one by one */
for (i = 0; i < nb_backlog; ++i) {
-   if (unlikely(1 != kni_fifo_get(
-kni->rx_q,(void **), 1)))
+   if (unlikely(kni_fifo_get(kni->rx_q, (void **), 1) != 1))
goto except;

-   if (unlikely(1 != kni_fifo_get(
-q->fifo, (void **), 1)))
+   if (unlikely(kni_fifo_get(q->fifo, (void **), 1) != 1))
goto except;

kni_vhost_enqueue(kni, q, *skb, *va);
@@ -797,7 +793,7 @@ set_sock_en(struct device *dev, struct device_attribute 
*attr,
unsigned long en;
int err = 0;

-   if (0 != kstrtoul(buf, 0, ))
+   if (kstrtoul(buf, 0, ) != 0)
return -EINVAL;

if (en)
-- 
2.7.4



[dpdk-dev] [PATCH v2 06/19] kni: remove useless return

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c 
b/lib/librte_eal/linuxapp/kni/kni_net.c
index f4afd83..81d139e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -512,7 +512,6 @@ kni_net_tx_timeout(struct net_device *dev)

kni->stats.tx_errors++;
netif_wake_queue(dev);
-   return;
 }

 /*
-- 
2.7.4



[dpdk-dev] [PATCH v2 05/19] kni: prefer unsigned int to unsigned

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  4 ++--
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 22 +++---
 lib/librte_eal/linuxapp/kni/kni_net.c   | 22 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 ++--
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h 
b/lib/librte_eal/linuxapp/kni/kni_dev.h
index faef2db..643df4b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -50,7 +50,7 @@ struct kni_dev {
struct net_device_stats stats;
int status;
uint16_t group_id;   /* Group ID of a group of KNI devices */
-   unsigned core_id;/* Core ID to bind */
+   unsigned int core_id;/* Core ID to bind */
char name[RTE_KNI_NAMESIZE]; /* Network device name */
struct task_struct *pthread;

@@ -91,7 +91,7 @@ struct kni_dev {
void *mbuf_va;

/* mbuf size */
-   unsigned mbuf_size;
+   unsigned int mbuf_size;

/* synchro for request processing */
unsigned long synchro;
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h 
b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 4006b1f..71bc2a9 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -31,12 +31,12 @@
  * Adds num elements into the fifo. Return the number actually written
  */
 static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-   unsigned i = 0;
-   unsigned fifo_write = fifo->write;
-   unsigned fifo_read = fifo->read;
-   unsigned new_write = fifo_write;
+   unsigned int i = 0;
+   unsigned int fifo_write = fifo->write;
+   unsigned int fifo_read = fifo->read;
+   unsigned int new_write = fifo_write;

for (i = 0; i < num; i++) {
new_write = (new_write + 1) & (fifo->len - 1);
@@ -55,11 +55,11 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, 
unsigned num)
  * Get up to num elements from the fifo. Return the number actully read
  */
 static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-   unsigned i = 0;
-   unsigned new_read = fifo->read;
-   unsigned fifo_write = fifo->write;
+   unsigned int i = 0;
+   unsigned int new_read = fifo->read;
+   unsigned int fifo_write = fifo->write;

for (i = 0; i < num; i++) {
if (new_read == fifo_write)
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned
+static inline unsigned int
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
+kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
 {
fifo->write = 0;
fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c 
b/lib/librte_eal/linuxapp/kni/kni_net.c
index aa17f2c..f4afd83 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -121,9 +121,9 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-   unsigned ret;
+   unsigned int ret;
uint32_t len;
-   unsigned i, num_rx, num_fq;
+   unsigned int i, num_rx, num_fq;
struct rte_kni_mbuf *kva;
struct rte_kni_mbuf *va[MBUF_BURST_SZ];
void *data_kva;
@@ -139,7 +139,7 @@ kni_net_rx_normal(struct kni_dev *kni)
}

/* Calculate the number of entries to dequeue from rx_q */
-   num_rx = min(num_fq, (unsigned)MBUF_BURST_SZ);
+   num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);

/* Burst dequeue from rx_q */
num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -209,9 +209,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-   unsigned ret;
+   unsigned int ret;
uint32_t len;
-   unsigned i, num, num_rq, num_tq, num_aq, num_fq;
+   unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
struct rte_kni_mbuf *kva;
struct rte_kni_mbuf *va[MBUF_BURST_SZ];
void *data_kva;
@@ -236,7 +236,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
num = min(num_rq, num_tq);
num = min(num, num_aq);
num = min(num, num_fq);
-   num = min(num, (unsigned)MBUF_BURST_SZ);
+   num = min(num, (unsigned int)MBUF_BURST_SZ);

/* Return if no entry to dequeue from rx_q */
if (num == 0)
@@ -298,9 +298,9 @@ 

[dpdk-dev] [PATCH v2 03/19] kni: make static struct const

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index cbb934d..4e09da4 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -65,7 +65,7 @@ static int kni_thread_single(void *unused);
 /* KNI processing for multiple kernel thread mode */
 static int kni_thread_multiple(void *param);

-static struct file_operations kni_fops = {
+static const struct file_operations kni_fops = {
.owner = THIS_MODULE,
.open = kni_open,
.release = kni_release,
-- 
2.7.4



[dpdk-dev] [PATCH v2 02/19] kni: uninitialize global variables

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index f52ef68..cbb934d 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -80,11 +80,11 @@ static struct miscdevice kni_misc = {
 };

 /* loopback mode */
-static char *lo_mode = NULL;
+static char *lo_mode;

 /* Kernel thread mode */
-static char *kthread_mode = NULL;
-static unsigned multiple_kthread_on = 0;
+static char *kthread_mode;
+static unsigned int multiple_kthread_on;

 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */

-- 
2.7.4



[dpdk-dev] [PATCH v2 01/19] kni: move externs to the header file

2016-09-16 Thread Ferruh Yigit
Signed-off-by: Ferruh Yigit 
---

v2:
keep variable externs in .c file
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 11 +++
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 14 ++
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 11 +--
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h 
b/lib/librte_eal/linuxapp/kni/kni_dev.h
index a0e5cb6..918a40c 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -134,6 +134,17 @@ struct kni_vhost_queue {

 #endif

+void kni_net_rx(struct kni_dev *kni);
+void kni_net_init(struct net_device *dev);
+void kni_net_config_lo_mode(char *lo_str);
+void kni_net_poll_resp(struct kni_dev *kni);
+void kni_set_ethtool_ops(struct net_device *netdev);
+
+int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void ixgbe_kni_remove(struct pci_dev *pdev);
+int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void igb_kni_remove(struct pci_dev *pdev);
+
 #ifdef RTE_KNI_VHOST_DEBUG_RX
#define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
 #else
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 3501dc1..f52ef68 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -47,18 +47,8 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");

 #define KNI_MAX_DEVICES 32

-extern void kni_net_rx(struct kni_dev *kni);
-extern void kni_net_init(struct net_device *dev);
-extern void kni_net_config_lo_mode(char *lo_str);
-extern void kni_net_poll_resp(struct kni_dev *kni);
-extern void kni_set_ethtool_ops(struct net_device *netdev);
-
-extern int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void ixgbe_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id ixgbe_pci_tbl[];
-extern int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void igb_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id igb_pci_tbl[];
+extern const struct pci_device_id ixgbe_pci_tbl[];
+extern const struct pci_device_id igb_pci_tbl[];

 static int kni_open(struct inode *inode, struct file *file);
 static int kni_release(struct inode *inode, struct file *file);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c 
b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index a3ca849..7aed96e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "compat.h"
 #include "kni_dev.h"
@@ -39,17 +40,7 @@

 #define RX_BURST_SZ 4

-extern void put_unused_fd(unsigned int fd);
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
-extern struct file*
-sock_alloc_file(struct socket *sock,
-   int flags, const char *dname);
-
-extern int get_unused_fd_flags(unsigned flags);
-
-extern void fd_install(unsigned int fd, struct file *file);
-
 static int kni_sock_map_fd(struct socket *sock)
 {
struct file *file;
-- 
2.7.4



[dpdk-dev] [PATCH v2 00/19] KNI checkpatch cleanup

2016-09-16 Thread Ferruh Yigit
KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
Only functional change is related logging, switched to kernel dynamic
logging and compile time KNI debug options removed, some log message
levels updated.

v2:
keep variable externs in .c file

Ferruh Yigit (19):
  kni: move externs to the header file
  kni: uninitialize global variables
  kni: make static struct const
  kni: whitespace, indentation, long line corrections
  kni: prefer unsigned int to unsigned
  kni: remove useless return
  kni: comparisons should place the constant on the right
  kni: trailing statements should be on next line
  kni: do not use assignment in if condition
  kni: macros with complex values should be enclosed in parentheses
  kni: prefer min_t to min
  kni: prefer ether_addr_copy to memcpy
  kni: update kernel logging
  kni: remove unnecessary 'out of memory' message
  kni: move functions to eliminate function declarations
  kni: remove compile time debug configuration
  kni: updated log messages
  kni: prefer uint32_t to unsigned int
  kni: move kernel version ifdefs to compat header

 config/common_base|   3 -
 lib/librte_eal/linuxapp/kni/compat.h  |  18 +-
 lib/librte_eal/linuxapp/kni/kni_dev.h |  51 ++--
 lib/librte_eal/linuxapp/kni/kni_ethtool.c |  39 ++-
 lib/librte_eal/linuxapp/kni/kni_fifo.h|  24 +-
 lib/librte_eal/linuxapp/kni/kni_misc.c| 399 ++
 lib/librte_eal/linuxapp/kni/kni_net.c | 365 +--
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 199 +++
 8 files changed, 537 insertions(+), 561 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v3 04/15] eal: introduce --no-soc option

2016-09-16 Thread Shreyansh Jain
Hello Jan,

On Friday 16 September 2016 05:06 PM, Jan Viktorin wrote:
> Hello Shreyansh,
>
> there was an objection to reverse this option from negative
> to positive semantics:
>
> http://dpdk.org/ml/archives/dev/2016-May/038953.html

Ok. I wasn't aware of this. Sounds reasonable as SoC is experimental for 
some time.

>
> As SoC infrastructure would to be experimental for some time,
> I think it is a good idea to disable it as default.

Agree - I will update this in v4. Thanks for bringing it to notice.

>
> Regards
> Jan
>
> On Fri, 9 Sep 2016 14:13:48 +0530
> Shreyansh Jain  wrote:
>
>> This option has the same meaning for the SoC infra as the --no-pci
>> for the PCI infra.
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>> Signed-off-by: Hemant Agrawal 
>> ---
>>  lib/librte_eal/common/eal_common_options.c | 5 +
>>  lib/librte_eal/common/eal_internal_cfg.h   | 1 +
>>  lib/librte_eal/common/eal_options.h| 2 ++
>>  3 files changed, 8 insertions(+)
>>
>> diff --git a/lib/librte_eal/common/eal_common_options.c 
>> b/lib/librte_eal/common/eal_common_options.c
>> index 1a1bab3..d97cf0a 100644
>> --- a/lib/librte_eal/common/eal_common_options.c
>> +++ b/lib/librte_eal/common/eal_common_options.c
>> @@ -85,6 +85,7 @@ eal_long_options[] = {
>>  {OPT_NO_HPET,   0, NULL, OPT_NO_HPET_NUM  },
>>  {OPT_NO_HUGE,   0, NULL, OPT_NO_HUGE_NUM  },
>>  {OPT_NO_PCI,0, NULL, OPT_NO_PCI_NUM   },
>> +{OPT_NO_SOC,0, NULL, OPT_NO_SOC_NUM   },
>>  {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM},
>>  {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM},
>>  {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM},
>> @@ -855,6 +856,10 @@ eal_parse_common_option(int opt, const char *optarg,
>>  conf->no_pci = 1;
>>  break;
>>
>> +case OPT_NO_SOC_NUM:
>> +conf->no_soc = 1;
>> +break;
>> +
>>  case OPT_NO_HPET_NUM:
>>  conf->no_hpet = 1;
>>  break;
>> diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
>> b/lib/librte_eal/common/eal_internal_cfg.h
>> index 5f1367e..3a98e94 100644
>> --- a/lib/librte_eal/common/eal_internal_cfg.h
>> +++ b/lib/librte_eal/common/eal_internal_cfg.h
>> @@ -67,6 +67,7 @@ struct internal_config {
>>  unsigned hugepage_unlink; /**< true to unlink backing files */
>>  volatile unsigned xen_dom0_support; /**< support app running on Xen 
>> Dom0*/
>>  volatile unsigned no_pci; /**< true to disable PCI */
>> +volatile unsigned no_soc; /**< true to disable SoC */
>>  volatile unsigned no_hpet;/**< true to disable HPET */
>>  volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping
>>  
>> * instead of native TSC */
>> diff --git a/lib/librte_eal/common/eal_options.h 
>> b/lib/librte_eal/common/eal_options.h
>> index a881c62..ba1e704 100644
>> --- a/lib/librte_eal/common/eal_options.h
>> +++ b/lib/librte_eal/common/eal_options.h
>> @@ -69,6 +69,8 @@ enum {
>>  OPT_NO_HUGE_NUM,
>>  #define OPT_NO_PCI"no-pci"
>>  OPT_NO_PCI_NUM,
>> +#define OPT_NO_SOC"no-soc"
>> +OPT_NO_SOC_NUM,
>>  #define OPT_NO_SHCONF "no-shconf"
>>  OPT_NO_SHCONF_NUM,
>>  #define OPT_SOCKET_MEM"socket-mem"
>
>
>

-
Shreyansh


[dpdk-dev] [PATCH] kni: fix build with kernel < v3.0

2016-09-16 Thread Ferruh Yigit
Compile error:
  CC [M]  .../build/lib/librte_eal/linuxapp/kni/igb_main.o
.../build/lib/librte_eal/linuxapp/kni/igb_main.c:
In function ?igb_check_swap_media?:
.../build/lib/librte_eal/linuxapp/kni/igb_main.c:1556:7:
error: variable ?link? set but not used [-Werror=unused-but-set-variable]
  bool link;
   ^

With Linux kernel >= v3.0 this warning disabled:
Linux: 8417da6f2128 ("kbuild: Fix passing -Wno-* options to gcc 4.4+")

Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c 
b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
index 1bb2242..23e2d64 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
@@ -1558,6 +1558,7 @@ static void igb_check_swap_media(struct igb_adapter 
*adapter)
ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
connsw = E1000_READ_REG(hw, E1000_CONNSW);
link = igb_has_link(adapter);
+   (void) link;

/* need to live swap if current media is copper and we have fiber/serdes
 * to go to.
-- 
2.7.4



[dpdk-dev] How to include pre-build object file (.o) in DPDK makefile?

2016-09-16 Thread Lu, Patrick
Hi,

I'm trying to include some hand written assembly (compiled by yasm) in my DPDK 
program. I couldn't find any example linking the DPDK C code with pre-compiled 
.o file. I've searched the mk/ and found OBJS-y seems the right variable to 
include .o file, but when generating the final executable, OBJS-y contains only 
main.o (generating from main.c).

I've tried to put my .o file in both source directory as well as build/

Thanks,

Patrick


[dpdk-dev] [PATCH v10 00/25] Introducing rte_driver/rte_device generalization

2016-09-16 Thread David Marchand
Sorry dropped the ml.


On Fri, Sep 16, 2016 at 4:21 PM, David Marchand
 wrote:
> Commenting in the cover letter because these are details and it is
> easier to track down what is missing before push for Thomas.
>
>
>>   driver: init/uninit common wrappers for PCI drivers
>
> In this patch subject, init/uninit -> prove/remove.
>
>
>>   eal: define container macro
>
> This patch is fine, but not used in the patchset. I would postpone it
> until we actually need it.
>
>
>>   eal: extract vdev infra
>
> This patch commit log tells that the vdev register macro does not call
> DRIVER_EXPORT_NAME while it actually does so.
>
>
>>   eal: remove unused PMD types
>
> This patch commit log has some outdated note about pmdinfo.
>
> We still have a reference about PMD_REGISTER_DRIVER in the
> documentation that could be replaced with a note on
> DRIVER_REGISTER_PCI()
> But I would do this in "drivers: convert all phy drivers as PCI drivers".
>
>
>>   eal/pci: replace PCI devinit/devuninit with probe/remove
>
> This patch only replaces the init/uninit methods with prove/remove for pci.
> I would generalise this to vdev as well.


-- 
David Marchand


[dpdk-dev] [PATCH] drivers: advertise kmod dependencies in pmdinfo

2016-09-16 Thread David Marchand
On Thu, Sep 15, 2016 at 4:22 PM, Olivier Matz  wrote:
> Add a new macro DRIVER_REGISTER_KMOD_DEP() that allows a driver to
> declare the list of kernel modules required to run properly.
>
> Today, most PCI drivers require uio/vfio.
>
> Signed-off-by: Olivier Matz 

Thanks Olivier, this looks good to me.

Btw, I remember some issues with binding ixgbevf devices to
uio_pci_generic, so advertising should be carefully checked for each
driver.
Could drivers maintainers have a look at this ?


-- 
David Marchand


[dpdk-dev] [PATCH] mempool: fix corruption due to invalid handler

2016-09-16 Thread Thomas Monjalon
CC stable at dpdk.org

2016-09-08 10:29, Weiliang Luo:
> When using rte_mempool_create(), the mempool handler is selected
> depending on the flags given by the user:
>   - multi-consumer / multi-producer
>   - multi-consumer / single-producer
>   - single-consumer / multi-producer
>   - single-consumer / single-producer
> 
> The flags were not properly tested, resulting in the selection of sc/sp
> handler if sc/mp or mc/sp was asked. This can lead to corruption or
> crashes because the get/put operations are not atomic.
> 
> Fixes: 449c49b93a6b ("mempool: support handler operations")
> 
> Signed-off-by: Weiliang Luo 
> Acked-by: Olivier Matz 

Applied, thanks


[dpdk-dev] [PATCH v3] eal: restrict cores detection

2016-09-16 Thread Thomas Monjalon
2016-09-02 17:53, Bruce Richardson:
> On Thu, Sep 01, 2016 at 01:31:47AM +, Jianfeng Tan wrote:

It would help the discussion to have a problem statement here.

> > This patch uses pthread_getaffinity_np() to narrow down detected
> > cores before parsing coremask (-c), corelist (-l), and coremap
> > (--lcores).
> > 
> > The purpose of this patch is to leave out these core related options
> > when DPDK applications are deployed under container env, so that
> > users only specify core restriction as starting the instance.
> > 
> > Note: previously, some users are using isolated CPUs, which could
> > be excluded by default. Please add commands like taskset to use
> > those cores.
> > 
> > Test example:
> > $ taskset 0xc ./examples/helloworld/build/helloworld -m 1024
> > 
> 
> So, to be clear, does this patch mean that DPDK cannot use isolated cores
> any more unless you explicitly run the app using taskset?
> Is so, NAK, since isolating cores has been part of standard DPDK setup since
> the first versions, and I don't believe that we should break that behaviour.

So how could we help the container use-case?
Any suggestions?


[dpdk-dev] [PATCH] crypto/null: fix key size increment value

2016-09-16 Thread Trahe, Fiona


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Deepak Kumar Jain
> Sent: Friday, September 16, 2016 11:50 AM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo ; Jain, Deepak K
> 
> Subject: [dpdk-dev] [PATCH] crypto/null: fix key size increment value
> 
> This patch fixes the values of increment in key size.
> 
> Fixes:94b0ad8e0a ("null_crypto_pmd: PMD to support null crypto
>   operations")
> 
> Signed-off-by: Deepak Kumar Jain 

Acked-by: Fiona Trahe 



[dpdk-dev] [PATCH] app/test: improve error message in crypto test code

2016-09-16 Thread Trahe, Fiona


> -Original Message-
> From: Trahe, Fiona
> Sent: Friday, September 16, 2016 3:37 PM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo ; Trahe, Fiona
> 
> Subject: [PATCH] app/test: improve error message in crypto test code
> 
> Resending patch as first send got to mailing list but didn't get to pachwork
> 
> 
> Improve error message if crypto PMD build is not enabled in config file
> 
> Signed-off-by: Fiona Trahe 


Nack -  This patch will need rebasing after the libcrypto patchset.


[dpdk-dev] [PATCH] app/test: improve error message in crypto test code

2016-09-16 Thread Fiona Trahe
Resending patch as first send got to mailing list but didn't get to pachwork


Improve error message if crypto PMD build is not enabled in config file

Signed-off-by: Fiona Trahe 
---
 app/test/test_cryptodev.c  | 37 +
 app/test/test_cryptodev_perf.c | 23 +++
 2 files changed, 60 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index f17c84c..c30a421 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -189,6 +189,11 @@ testsuite_setup(void)

/* Create 2 AESNI MB devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
+#ifndef RTE_LIBRTE_PMD_AESNI_MB
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_AESNI_MB_PMD);
if (nb_devs < 2) {
@@ -206,6 +211,11 @@ testsuite_setup(void)

/* Create 2 LIBCRYPTO devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_LIBCRYPTO_PMD) {
+#ifndef RTE_LIBRTE_PMD_LIBCRYPTO
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_LIBCRYPTO_PMD);
if (nb_devs < 2) {
@@ -223,6 +233,11 @@ testsuite_setup(void)

/* Create 2 AESNI GCM devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
+#ifndef RTE_LIBRTE_PMD_AESNI_GCM
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_AESNI_GCM_PMD);
if (nb_devs < 2) {
@@ -238,6 +253,11 @@ testsuite_setup(void)

/* Create 2 Snow3G devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
+#ifndef RTE_LIBRTE_PMD_SNOW3G
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
if (nb_devs < 2) {
for (i = nb_devs; i < 2; i++) {
@@ -252,6 +272,11 @@ testsuite_setup(void)

/* Create 2 KASUMI devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
+#ifndef RTE_LIBRTE_PMD_KASUMI
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
if (nb_devs < 2) {
for (i = nb_devs; i < 2; i++) {
@@ -266,6 +291,11 @@ testsuite_setup(void)

/* Create 2 NULL devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
+#ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_NULL_PMD);
if (nb_devs < 2) {
@@ -281,6 +311,13 @@ testsuite_setup(void)
}
}

+#ifndef RTE_LIBRTE_PMD_QAT
+   if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
+   "in config file to run this testsuite.\n");
+   return TEST_FAILED;
+   }
+#endif

nb_devs = rte_cryptodev_count();
if (nb_devs < 1) {
diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index 0a0085d..c80c335 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -261,6 +261,11 @@ testsuite_setup(void)

/* Create 2 AESNI MB devices if required */
if (gbl_cryptodev_perftest_devtype == RTE_CRYPTODEV_AESNI_MB_PMD) {
+#ifndef RTE_LIBRTE_PMD_AESNI_MB
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = 
rte_cryptodev_count_devtype(RTE_CRYPTODEV_AESNI_MB_PMD);
if (nb_devs < 2) {
for (i = nb_devs; i < 2; i++) 

[dpdk-dev] [PATCH v1]:rte_timer:timer lag issue correction

2016-09-16 Thread Karmarkar Suyash
Thanks Reshma for the comments, the issue is a day one bug.  I will correct the 
fixes line and submit v2 of the patch. 

-Original Message-
From: Pattan, Reshma [mailto:reshma.pat...@intel.com] 
Sent: Thursday, September 15, 2016 5:28 AM
To: Karmarkar Suyash 
Cc: dev at dpdk.org; thomas.monjalon at 6wind.com; rsanford at akamai.com
Subject: RE: [PATCH v1]:rte_timer:timer lag issue correction

Hi,


> 
> For Periodic timers ,if the lag gets introduced, the current code 
> added additional delay when the next peridoc timer was initialized by 
> not taking into account the delay added, with this fix the code would 
> start the next occurrence of timer keeping in account the lag added.Corrected 
> the behavior.
> 
> Fixes:rte_timer: timer lag issue

Fixes line format is not corerct. Fixes line should contain  commit hash that 
introduced the bug and its subject line. For your case below should be added.

Fixes: 9b15ba89 ("timer: use a skip list")

Thanks,
Reshma


[dpdk-dev] [PATCH] pci: fix one device probing

2016-09-16 Thread Thomas Monjalon
2016-08-04 14:50, Igor Ryzhov:
> The rte_eal_pci_probe_one function could return false positive result if
> no driver is found for the device.
> 
> Signed-off-by: Igor Ryzhov 
[...]
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -344,7 +344,7 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
>   continue;
>  
>   ret = pci_probe_all_drivers(dev);
> - if (ret < 0)
> + if (ret)
>   goto err_return;
>   return 0;
>   }

This patch was discussed in another thread:
http://dpdk.org/ml/archives/dev/2016-August/045127.html
Is there anyone thinking this patch is not a step forward?


[dpdk-dev] [PATCH v3 2/2] crypto/qat: adding support for 3DES cipher algorithm

2016-09-16 Thread Fiona Trahe
3DES support added to QuickAssist PMD
With CTR and CBC mode.
Both cipher-only and chained with HMAC_SHAx

This patch depends on following patch :
  crypto/qat: enable support of Kasumi F8 in QAT cryptodev
  http://dpdk.org/dev/patchwork/patch/15813/

Signed-off-by: Fiona Trahe 
---
 doc/guides/cryptodevs/qat.rst|  4 +-
 doc/guides/rel_notes/release_16_11.rst   |  1 +
 drivers/crypto/qat/qat_adf/qat_algs.h|  5 ++
 drivers/crypto/qat/qat_adf/qat_algs_build_desc.c | 25 +-
 drivers/crypto/qat/qat_crypto.c  | 59 +++-
 5 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/doc/guides/cryptodevs/qat.rst b/doc/guides/cryptodevs/qat.rst
index 3528499..16e5937 100644
--- a/doc/guides/cryptodevs/qat.rst
+++ b/doc/guides/cryptodevs/qat.rst
@@ -42,6 +42,8 @@ The QAT PMD has support for:

 Cipher algorithms:

+* ``RTE_CRYPTO_CIPHER_3DES_CBC``
+* ``RTE_CRYPTO_CIPHER_3DES_CTR``
 * ``RTE_CRYPTO_CIPHER_AES128_CBC``
 * ``RTE_CRYPTO_CIPHER_AES192_CBC``
 * ``RTE_CRYPTO_CIPHER_AES256_CBC``
@@ -72,7 +74,7 @@ Limitations

 * Chained mbufs are not supported.
 * Hash only is not supported except Snow3G UIA2 and Kasumi F9.
-* Cipher only is not supported except Snow3G UEA2 and Kasumi F8.
+* Cipher only is not supported except Snow3G UEA2, Kasumi F8 and 3DES.
 * Only supports the session-oriented API implementation (session-less APIs are 
not supported).
 * Not performance tuned.
 * Snow3g(UEA2) and Kasumi(F8) supported only if cipher length, cipher offset 
fields are byte-aligned.
diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index 1dd0e6a..4eedc0e 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -51,6 +51,7 @@ New Features
   * Added support for SHA384-HMAC algorithm.
   * Added support for NULL algorithm.
   * Added support for KASUMI (F8 and F9) algorithm.
+  * Added support for 3DES block cipher algorithm.

 Resolved Issues
 ---
diff --git a/drivers/crypto/qat/qat_adf/qat_algs.h 
b/drivers/crypto/qat/qat_adf/qat_algs.h
index 429f44f..530b9cc 100644
--- a/drivers/crypto/qat/qat_adf/qat_algs.h
+++ b/drivers/crypto/qat/qat_adf/qat_algs.h
@@ -59,6 +59,10 @@

 #define KASUMI_F8_KEY_MODIFIER_4_BYTES   0x

+/* 3DES key sizes */
+#define QAT_3DES_KEY_SZ_OPT1 24 /* Keys are independent */
+#define QAT_3DES_KEY_SZ_OPT2 16 /* K3=K1 */
+
 #define QAT_AES_HW_CONFIG_CBC_ENC(alg) \
ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_CBC_MODE, alg, \
ICP_QAT_HW_CIPHER_NO_CONVERT, \
@@ -138,4 +142,5 @@ void qat_alg_ablkcipher_init_dec(struct 
qat_alg_ablkcipher_cd *cd,
 int qat_alg_validate_aes_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
 int qat_alg_validate_snow3g_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
 int qat_alg_validate_kasumi_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
+int qat_alg_validate_3des_key(int key_len, enum icp_qat_hw_cipher_algo *alg);
 #endif
diff --git a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c 
b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
index 8ca422f..b46702f 100644
--- a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
+++ b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
@@ -512,6 +512,10 @@ int qat_alg_aead_session_create_content_desc_cipher(struct 
qat_session *cdesc,
cipher_cd_ctrl->cipher_state_sz = ICP_QAT_HW_KASUMI_BLK_SZ >> 3;
cipher_cd_ctrl->cipher_padding_sz =
(2 * ICP_QAT_HW_KASUMI_BLK_SZ) >> 3;
+   } else if (cdesc->qat_cipher_alg == ICP_QAT_HW_CIPHER_ALGO_3DES) {
+   total_key_size = ICP_QAT_HW_3DES_KEY_SZ;
+   cipher_cd_ctrl->cipher_state_sz = ICP_QAT_HW_3DES_BLK_SZ >> 3;
+   proto = ICP_QAT_FW_LA_PROTO_GET(header->serv_specif_flags);
} else {
total_key_size = cipherkeylen;
cipher_cd_ctrl->cipher_state_sz = ICP_QAT_HW_AES_BLK_SZ >> 3;
@@ -553,8 +557,12 @@ int qat_alg_aead_session_create_content_desc_cipher(struct 
qat_session *cdesc,

if (total_key_size > cipherkeylen) {
uint32_t padding_size =  total_key_size-cipherkeylen;
-
-   memset(cdesc->cd_cur_ptr, 0, padding_size);
+   if ((cdesc->qat_cipher_alg == ICP_QAT_HW_CIPHER_ALGO_3DES)
+   && (cipherkeylen == QAT_3DES_KEY_SZ_OPT2))
+   /* K3 not provided so use K1 = K3*/
+   memcpy(cdesc->cd_cur_ptr, cipherkey, padding_size);
+   else
+   memset(cdesc->cd_cur_ptr, 0, padding_size);
cdesc->cd_cur_ptr += padding_size;
}
cd_size = cdesc->cd_cur_ptr-(uint8_t *)>cd;
@@ -845,3 +853,16 @@ int qat_alg_validate_kasumi_key(int key_len, enum 
icp_qat_hw_cipher_algo *alg)
}
return 0;
 }
+
+int qat_alg_validate_3des_key(int key_len, enum 

[dpdk-dev] [PATCH v3 1/2] crypto/qat: code cleanup

2016-09-16 Thread Fiona Trahe
Cleanup of unused code.
Rename and simplify a badly named struct element, was aes, but
used for all types of ciphers
Print correct error msg (Unsupported rather than Undefined)
for all ciphers not supported by qat PMD.

Signed-off-by: Fiona Trahe 
---
 drivers/crypto/qat/qat_adf/icp_qat_hw.h  | 10 ++--
 drivers/crypto/qat/qat_adf/qat_algs.h|  1 -
 drivers/crypto/qat/qat_adf/qat_algs_build_desc.c | 63 +++-
 drivers/crypto/qat/qat_crypto.c  |  6 ++-
 4 files changed, 16 insertions(+), 64 deletions(-)

diff --git a/drivers/crypto/qat/qat_adf/icp_qat_hw.h 
b/drivers/crypto/qat/qat_adf/icp_qat_hw.h
index 4d4d8e4..a08094f 100644
--- a/drivers/crypto/qat/qat_adf/icp_qat_hw.h
+++ b/drivers/crypto/qat/qat_adf/icp_qat_hw.h
@@ -293,14 +293,12 @@ enum icp_qat_hw_cipher_convert {
 #define ICP_QAT_HW_ZUC_3G_EEA3_KEY_SZ 16
 #define ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ 16
 #define ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR 2
-#define INIT_SHRAM_CONSTANTS_TABLE_SZ 1024

-struct icp_qat_hw_cipher_aes256_f8 {
-   struct icp_qat_hw_cipher_config cipher_config;
-   uint8_t key[ICP_QAT_HW_AES_256_F8_KEY_SZ];
-};
+#define ICP_QAT_HW_CIPHER_MAX_KEY_SZ ICP_QAT_HW_AES_256_F8_KEY_SZ

 struct icp_qat_hw_cipher_algo_blk {
-   struct icp_qat_hw_cipher_aes256_f8 aes;
+   struct icp_qat_hw_cipher_config cipher_config;
+   uint8_t key[ICP_QAT_HW_CIPHER_MAX_KEY_SZ];
 } __rte_cache_aligned;
+
 #endif
diff --git a/drivers/crypto/qat/qat_adf/qat_algs.h 
b/drivers/crypto/qat/qat_adf/qat_algs.h
index fad8471..429f44f 100644
--- a/drivers/crypto/qat/qat_adf/qat_algs.h
+++ b/drivers/crypto/qat/qat_adf/qat_algs.h
@@ -100,7 +100,6 @@ struct qat_session {
struct icp_qat_fw_la_bulk_req fw_req;
uint8_t aad_len;
struct qat_crypto_instance *inst;
-   uint8_t salt[ICP_QAT_HW_AES_BLK_SZ];
rte_spinlock_t lock;/* protects this struct */
 };

diff --git a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c 
b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
index 198b551..8ca422f 100644
--- a/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
+++ b/drivers/crypto/qat/qat_adf/qat_algs_build_desc.c
@@ -525,7 +525,8 @@ int qat_alg_aead_session_create_content_desc_cipher(struct 
qat_session *cdesc,
qat_alg_init_common_hdr(header, proto);

cipher = (struct icp_qat_hw_cipher_algo_blk *)cdesc->cd_cur_ptr;
-   cipher->aes.cipher_config.val =
+
+   cipher->cipher_config.val =
ICP_QAT_HW_CIPHER_CONFIG_BUILD(cdesc->qat_mode,
cdesc->qat_cipher_alg, key_convert,
cdesc->qat_dir);
@@ -534,7 +535,7 @@ int qat_alg_aead_session_create_content_desc_cipher(struct 
qat_session *cdesc,
temp_key = (uint32_t *)(cdesc->cd_cur_ptr +
sizeof(struct icp_qat_hw_cipher_config)
+ cipherkeylen);
-   memcpy(cipher->aes.key, cipherkey, cipherkeylen);
+   memcpy(cipher->key, cipherkey, cipherkeylen);
memcpy(temp_key, cipherkey, cipherkeylen);

/* XOR Key with KASUMI F8 key modifier at 4 bytes level */
@@ -545,7 +546,7 @@ int qat_alg_aead_session_create_content_desc_cipher(struct 
qat_session *cdesc,
cdesc->cd_cur_ptr += sizeof(struct icp_qat_hw_cipher_config) +
cipherkeylen + cipherkeylen;
} else {
-   memcpy(cipher->aes.key, cipherkey, cipherkeylen);
+   memcpy(cipher->key, cipherkey, cipherkeylen);
cdesc->cd_cur_ptr += sizeof(struct icp_qat_hw_cipher_config) +
cipherkeylen;
}
@@ -727,13 +728,13 @@ int qat_alg_aead_session_create_content_desc_auth(struct 
qat_session *cdesc,

cipherconfig = (struct icp_qat_hw_cipher_algo_blk *)
(cdesc->cd_cur_ptr + state1_size + state2_size);
-   cipherconfig->aes.cipher_config.val =
+   cipherconfig->cipher_config.val =
ICP_QAT_HW_CIPHER_CONFIG_BUILD(ICP_QAT_HW_CIPHER_ECB_MODE,
ICP_QAT_HW_CIPHER_ALGO_SNOW_3G_UEA2,
ICP_QAT_HW_CIPHER_KEY_CONVERT,
ICP_QAT_HW_CIPHER_ENCRYPT);
-   memcpy(cipherconfig->aes.key, authkey, authkeylen);
-   memset(cipherconfig->aes.key + authkeylen,
+   memcpy(cipherconfig->key, authkey, authkeylen);
+   memset(cipherconfig->key + authkeylen,
0, ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ);
cdesc->cd_cur_ptr += sizeof(struct icp_qat_hw_cipher_config) +
authkeylen + ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ;
@@ -803,56 +804,6 @@ int qat_alg_aead_session_create_content_desc_auth(struct 
qat_session *cdesc,
return 0;
 }

-static void 

[dpdk-dev] [PATCH v3 0/2] Add 3DES support to Quickassist PMD

2016-09-16 Thread Fiona Trahe
resend of v3 patchset as first send didn't get to patchwork, just to mailing 
list.


Some preparatory cleanup done in QAT PMD for adding 3DES 
3DES support added to QuickAssist PMD With CTR and CBC mode.
Both cipher-only and chained with HMAC_SHAx

3DES test code is included in the libcrypto patch, 
which will be sent separately.

Changes since v1:
* rebased qat.rst against Kasumi patch changes
  http://dpdk.org/dev/patchwork/patch/15320/
  http://dpdk.org/dev/patchwork/patch/15322/

Changes since v2:
* added 3DES to QAT PMD capabilities
* added 3DES to 16.11 release notes.

Fiona Trahe (2):
  crypto/qat: code cleanup
  crypto/qat: adding support for 3DES cipher algorithm

 doc/guides/cryptodevs/qat.rst|  4 +-
 doc/guides/rel_notes/release_16_11.rst   |  1 +
 drivers/crypto/qat/qat_adf/icp_qat_hw.h  | 10 ++-
 drivers/crypto/qat/qat_adf/qat_algs.h|  6 +-
 drivers/crypto/qat/qat_adf/qat_algs_build_desc.c | 88 
 drivers/crypto/qat/qat_crypto.c  | 65 -
 6 files changed, 105 insertions(+), 69 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v3 3/3] app/test_pmd: add tests for new API's

2016-09-16 Thread Bernard Iremonger
add test for vf vlan anti spoof
add test for vf mac anti spoof
add test for vf ping
add test for vf vlan strip
add test for vf vlan insert
add test for tx loopback
add test for all queues drop enable bit
add test for vf split drop enable bit
add test for vf mac address
add new API's to the testpmd guide

Signed-off-by: Bernard Iremonger 
---
 app/test-pmd/cmdline.c  | 707 
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  70 ++-
 2 files changed, 774 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f90befc..264aa90 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -10585,6 +10585,704 @@ cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
},
 };

+/* vf vlan anti spoof configuration */
+
+/* Common result structure for vf vlan anti spoof */
+struct cmd_vf_vlan_anti_spoof_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vf;
+   cmdline_fixed_string_t vlan;
+   cmdline_fixed_string_t antispoof;
+   uint8_t port_id;
+   uint32_t vf_id;
+   cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf vlan anti spoof enable disable */
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+set, "set");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+vf, "vf");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+vlan, "vlan");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+antispoof, "antispoof");
+cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+vf_id, UINT32);
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+on_off, "on#off");
+
+static void
+cmd_set_vf_vlan_anti_spoof_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
+   int ret = 0;
+   int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+   return;
+
+   if (res->vf_id > 63) {
+   printf("vf_id must be less than 64.\n");
+   return;
+   }
+   ret = rte_eth_dev_set_vf_vlan_anti_spoof(res->port_id, res->vf_id, 
is_on);
+   if (ret < 0)
+   printf("vf vlan anti spoofing programming error: (%s)\n",
+  strerror(-ret));
+}
+
+cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
+   .f = cmd_set_vf_vlan_anti_spoof_parsed,
+   .data = NULL,
+   .help_str = "set vf vlan antispoof port_id vf_id on|off",
+   .tokens = {
+   (void *)_vf_vlan_anti_spoof_set,
+   (void *)_vf_vlan_anti_spoof_vf,
+   (void *)_vf_vlan_anti_spoof_vlan,
+   (void *)_vf_vlan_anti_spoof_antispoof,
+   (void *)_vf_vlan_anti_spoof_port_id,
+   (void *)_vf_vlan_anti_spoof_vf_id,
+   (void *)_vf_vlan_anti_spoof_on_off,
+   NULL,
+   },
+};
+
+/* vf mac anti spoof configuration */
+
+/* Common result structure for vf mac anti spoof */
+struct cmd_vf_mac_anti_spoof_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vf;
+   cmdline_fixed_string_t mac;
+   cmdline_fixed_string_t antispoof;
+   uint8_t port_id;
+   uint32_t vf_id;
+   cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf mac anti spoof enable disable */
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+set, "set");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+vf, "vf");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+mac, "mac");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+antispoof, 

[dpdk-dev] [PATCH v3 2/3] net/ixgbe: add functions for VF management

2016-09-16 Thread Bernard Iremonger
Add new functions to configure and manage VF's on an Intel 82559 NIC.

add ixgbe_vf_ping function.
add ixgbe_set_vf_vlan_anti_spoof function.
add ixgbe_set_vf_mac_anti_spoof function.

Signed-off-by: azelezniak 

add ixgbe_set_vf_vlan_insert function.
add ixgbe_set_tx_loopback function.
add ixgbe_set_all_queues_drop function.
add ixgbe_set_vf_split_drop_en function.
add ixgbe_set_vf_mac_addr function.

Signed-off-by: Bernard Iremonger 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 166 +++
 1 file changed, 166 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index fb618ef..9875290 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -240,6 +240,8 @@ static void ixgbe_add_rar(struct rte_eth_dev *dev, struct 
ether_addr *mac_addr,
 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
   struct ether_addr *mac_addr);
+static int ixgbe_set_vf_mac_addr(struct rte_eth_dev *dev, uint16_t vf,
+   struct ether_addr *mac_addr);
 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config 
*dcb_config);

 /* For Virtual Function support */
@@ -280,6 +282,17 @@ static int ixgbe_set_pool_rx(struct rte_eth_dev *dev, 
uint16_t pool, uint8_t on)
 static int ixgbe_set_pool_tx(struct rte_eth_dev *dev, uint16_t pool, uint8_t 
on);
 static int ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
uint64_t pool_mask, uint8_t vlan_on);
+static void ixgbe_set_vf_vlan_anti_spoof(struct rte_eth_dev *dev,
+   uint16_t vf, uint8_t on);
+static void ixgbe_set_vf_mac_anti_spoof(struct rte_eth_dev *dev,
+   uint16_t vf, uint8_t on);
+static int ixgbe_vf_ping(struct rte_eth_dev *dev, int32_t vf);
+static void ixgbe_set_vf_vlan_insert(struct rte_eth_dev *dev, uint16_t vf,
+   int vlan);
+static void ixgbe_set_tx_loopback(struct rte_eth_dev *dev, int on);
+static void ixgbe_set_all_queues_drop_en(struct rte_eth_dev *dev, int state);
+static void ixgbe_set_vf_split_drop_en(struct rte_eth_dev *dev, uint16_t vf,
+   int state);
 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
struct rte_eth_mirror_conf *mirror_conf,
uint8_t rule_id, uint8_t on);
@@ -562,6 +575,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.mac_addr_add = ixgbe_add_rar,
.mac_addr_remove  = ixgbe_remove_rar,
.mac_addr_set = ixgbe_set_default_mac_addr,
+   .set_vf_mac_addr  = ixgbe_set_vf_mac_addr,
.uc_hash_table_set= ixgbe_uc_hash_table_set,
.uc_all_hash_table_set  = ixgbe_uc_all_hash_table_set,
.mirror_rule_set  = ixgbe_mirror_rule_set,
@@ -570,6 +584,13 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.set_vf_rx= ixgbe_set_pool_rx,
.set_vf_tx= ixgbe_set_pool_tx,
.set_vf_vlan_filter   = ixgbe_set_pool_vlan_filter,
+   .set_vf_vlan_anti_spoof  = ixgbe_set_vf_vlan_anti_spoof,
+   .set_vf_mac_anti_spoof   = ixgbe_set_vf_mac_anti_spoof,
+   .vf_ping  = ixgbe_vf_ping,
+   .set_vf_vlan_insert   = ixgbe_set_vf_vlan_insert,
+   .set_tx_loopback  = ixgbe_set_tx_loopback,
+   .set_all_queues_drop_en = ixgbe_set_all_queues_drop_en,
+   .set_vf_split_drop_en = ixgbe_set_vf_split_drop_en,
.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
.set_vf_rate_limit= ixgbe_set_vf_rate_limit,
.reta_update  = ixgbe_dev_rss_reta_update,
@@ -4069,6 +4090,22 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, 
struct ether_addr *addr)
 }

 static int
+ixgbe_set_vf_mac_addr(struct rte_eth_dev *dev, uint16_t vf, struct ether_addr 
*mac_addr)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_vf_info *vfinfo =
+   *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
+   int rar_entry = hw->mac.num_rar_entries - (vf + 1);
+   uint8_t *new_mac = (uint8_t *)(mac_addr);
+
+   if (is_valid_assigned_ether_addr((struct ether_addr *)new_mac)) {
+   rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 
ETHER_ADDR_LEN);
+   return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, 
IXGBE_RAH_AV);
+   }
+   return -1;
+}
+
+static int
 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
uint32_t hlreg0;
@@ -4661,6 +4698,135 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, 
uint16_t vlan,
return ret;
 }

+static void
+ixgbe_set_vf_vlan_anti_spoof(struct rte_eth_dev *dev,
+   uint16_t vf, uint8_t on)
+{
+   struct ixgbe_hw *hw =
+   IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   struct ixgbe_mac_info *mac = 

[dpdk-dev] [PATCH v3 1/3] librte_ether: add API's for VF management

2016-09-16 Thread Bernard Iremonger
Add new API functions to configure and manage VF's on a NIC.

add rte_eth_dev_vf_ping function.
add rte_eth_dev_set_vf_vlan_anti_spoof function.
add rte_eth_dev_set_vf_mac_anti_spoof function.
add rte_eth_dev_set_vf_vlan_strip function.

Signed-off-by: azelezniak 

add rte_eth_dev_set_vf_vlan_insert function.
add rte_eth_dev_set_loopback function.
add rte_eth_dev_set_all_queues_drop function.
add rte_eth_dev_set_vf_split_drop_en function
add rte_eth_dev_set_vf_mac_addr function.

Signed-off-by: Bernard Iremonger 
---
 lib/librte_ether/rte_ethdev.c  | 192 +
 lib/librte_ether/rte_ethdev.h  | 217 -
 lib/librte_ether/rte_ether_version.map |  14 +++
 3 files changed, 422 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 382c959..4f83c29 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2305,6 +2305,30 @@ rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct 
ether_addr *addr)
 }

 int
+rte_eth_dev_set_vf_mac_addr(uint8_t port_id, uint16_t vf, struct ether_addr 
*addr)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   if (!is_valid_assigned_ether_addr(addr))
+   return -EINVAL;
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF mac addr: invalid VF %d\n", vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_mac_addr, -ENOTSUP);
+
+   return (*dev->dev_ops->set_vf_mac_addr)(dev, vf, addr);
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
uint16_t rx_mode, uint8_t on)
 {
@@ -2489,6 +2513,174 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, 
uint16_t vlan_id,
   vf_mask, vlan_on);
 }

+int
+rte_eth_dev_set_vf_vlan_anti_spoof(uint8_t port_id,
+  uint16_t vf, uint8_t on)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF VLAN anti spoof: invalid VF %d\n", 
vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_anti_spoof, 
-ENOTSUP);
+   (*dev->dev_ops->set_vf_vlan_anti_spoof)(dev, vf, on);
+   return 0;
+}
+
+int
+rte_eth_dev_set_vf_mac_anti_spoof(uint8_t port_id,
+  uint16_t vf, uint8_t on)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF MAC anti spoof:invalid VF %d\n", 
vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_mac_anti_spoof, -ENOTSUP);
+   (*dev->dev_ops->set_vf_mac_anti_spoof)(dev, vf, on);
+   return 0;
+}
+
+int
+rte_eth_dev_vf_ping(uint8_t port_id, int32_t vf)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("VF ping: invalid VF %d\n", vf);
+   return -EINVAL;
+   } else if (vf < -1) {
+   RTE_PMD_DEBUG_TRACE("VF ping: invalid value %d\n", vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vf_ping, -ENOTSUP);
+   return (*dev->dev_ops->vf_ping)(dev, vf);
+}
+
+int
+rte_eth_dev_set_vf_vlan_strip(uint8_t port_id, uint16_t vf, int on)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+   uint16_t queues_per_pool;
+   uint32_t q;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF vlan strip: invalid VF %d\n", vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
+
+   queues_per_pool = dev_info.vmdq_queue_num/dev_info.max_vmdq_pools;
+
+   for (q = 0; q < queues_per_pool; q++)
+   (*dev->dev_ops->vlan_strip_queue_set)(dev, q + vf * 
queues_per_pool, on);
+   return 0;
+}
+
+int
+rte_eth_dev_set_vf_vlan_insert(uint8_t port_id, 

[dpdk-dev] [PATCH v3 0/3] add API's for VF management

2016-09-16 Thread Bernard Iremonger
This patchset contains new DPDK API's requested by AT for use
with the Virtual Function Daemon (VFD).

The need to configure and manage VF's on a NIC has grown to the
point where AT have devloped a DPDK based tool, VFD, to do this.

This patch set adds API extensions to DPDK VF configuration.

Nine new functions have been added to the eth_dev_ops structure.
Corresponding functions have been added to the ixgbe PMD for the
Intel 82559 NIC.

Changes have been made to testpmd to facilitate testing of the new API's.
The testpmd documentation has been updated to document the testpmd changes.

Note:
Adding new functions to the eth_dev_ops structure will cause an
ABI breakage.

Changes in v3:
rebase to latest master branch.
drop patches for callback functions
revise VF id checks in new librte_ether functions
revise testpmd commands for new API's

Changes in V2:
rebase to latest master branch.
fix compile  error with clang.

Bernard Iremonger (3):
  librte_ether: add API's for VF management
  net/ixgbe: add functions for VF management
  app/test_pmd: add tests for new API's

 app/test-pmd/cmdline.c  | 707 
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  70 ++-
 drivers/net/ixgbe/ixgbe_ethdev.c| 166 +++
 lib/librte_ether/rte_ethdev.c   | 192 
 lib/librte_ether/rte_ethdev.h   | 217 -
 lib/librte_ether/rte_ether_version.map  |  14 +
 6 files changed, 1362 insertions(+), 4 deletions(-)

-- 
2.9.0



[dpdk-dev] [PATCH v2 0/2] lpm6: speed improvement on delete rule

2016-09-16 Thread Nikita Kozlov
On 08/25/2016 00:59, Nikita Kozlov wrote:
> This serie of pathes focus on improving the speed of deleting rules in lpm6.
>
> It also contains some other improvement like having a dynamic number of
> rules in lpm6 and increasing the lpm6 nexthop size to 16bit for matching
> the nexthop size in lpm4.
>
> The performances improvement can be seen by running test_lpm6_perf but
> because of the limited number of rules added (1000) the improvement seen is
> just about a x10 with this test.
>
> For testing it further we have tested it with a full ipv6 bgp view which 
> represent 29296 routes in our test:
> * With the dpdk 16.04 it tooks an average of 8.46095e+09 cycles to delete a 
> rule
> (calculated with mesuring rte_rdtsc before and after the delete, the
> average is calculated by the first 10 delete, it represents several
> seconds on a E5-2650 v2)
> * With the patch it tooks 10077.1 cycles (same number of deleted rules,
> same machine, same rules inserted) for the same test.
>
> This patch was written in collaboration with Baptiste Daroussin from Gandi.
>
> Changes since V1:
> - use system bsd-tree.h
> - fix a bug when valid_group field was overwritten 
>
> Nikita Kozlov (2):
>   lpm6: speed inmprovement on delete rule
>   test_lpm6: make test_lpm6* compatible with the new rte_lpm6.c lib
>
>  app/test/test_lpm6.c  | 244 +
>  app/test/test_lpm6_perf.c |   6 +-
>  lib/librte_lpm/Makefile   |   2 +-
>  lib/librte_lpm/rte_lpm6.c | 626 
> +-
>  lib/librte_lpm/rte_lpm6.h |  50 ++-
>  lib/librte_lpm/rte_lpm_version.map|  12 +
>  lib/librte_table/rte_table_lpm_ipv6.c |   7 +-
>  7 files changed, 609 insertions(+), 338 deletions(-)
>
Hello,
If someone have some time, I feel that this patch needs some polishing
so any comments on the code are more than welcome, even if they are not
directly related to the lpm part itself.

thanks.


[dpdk-dev] [PATCH] eal/linux: use more restrictive perms in hugedir

2016-09-16 Thread Thomas Monjalon
2016-08-10 16:52, Robin Jarry:
> There is no need for the page files to be readable (and executable) by
> other users. This can be exploited by non-privileged users to access the
> working memory of a DPDK app.
> 
> Open the files with 0600.
> 
> Signed-off-by: Robin Jarry 

Applied, thanks

I thought there were some comments about this.
Tip of the day: August is a good month to avoid comments on your patch ;)



[dpdk-dev] [PATCH 3/3] drivers/net:build support for new tap device driver

2016-09-16 Thread Wiles, Keith

Regards,
Keith

> On Sep 16, 2016, at 2:36 AM, Panu Matilainen  wrote:
> 
> On 09/15/2016 05:10 PM, Keith Wiles wrote:
>> Signed-off-by: Keith Wiles 
>> ---
>> config/common_linuxapp | 3 +++
>> drivers/net/Makefile   | 1 +
>> mk/rte.app.mk  | 1 +
>> 3 files changed, 5 insertions(+)
>> 
>> diff --git a/config/common_linuxapp b/config/common_linuxapp
>> index 2483dfa..704c01c 100644
>> --- a/config/common_linuxapp
>> +++ b/config/common_linuxapp
>> @@ -44,3 +44,6 @@ CONFIG_RTE_LIBRTE_PMD_VHOST=y
>> CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
>> CONFIG_RTE_LIBRTE_POWER=y
>> CONFIG_RTE_VIRTIO_USER=y
>> +CONFIG_RTE_LIBRTE_PMD_TAP=y
>> +CONFIG_RTE_PMD_TAP_MAX_QUEUES=32
>> +
>> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
>> index bc93230..b4afa98 100644
>> --- a/drivers/net/Makefile
>> +++ b/drivers/net/Makefile
>> @@ -55,6 +55,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += thunderx
>> DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
>> DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
>> DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
>> +DIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += tap
>> 
>> ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
>> DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
>> diff --git a/mk/rte.app.mk b/mk/rte.app.mk
>> index 1a0095b..bd1d10f 100644
>> --- a/mk/rte.app.mk
>> +++ b/mk/rte.app.mk
>> @@ -129,6 +129,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
>> _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST)  += -lrte_pmd_vhost
>> endif # $(CONFIG_RTE_LIBRTE_VHOST)
>> _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD)+= -lrte_pmd_vmxnet3_uio
>> +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)+= -lrte_pmd_tap
>> 
>> ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)
>> _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB)   += -lrte_pmd_aesni_mb
>> 
> 
> Splitting the Makefile and config changes into a separate patch makes no 
> sense at all in this case. Just do it in the patch introducing the driver.
> 
> And actually, ditto for documentation.

OK, will do, but I thought other patches followed something like this as I had 
thought I was following the normally process. Without some place defining the 
real process it is hard to decide the real way to send patches. :-(

I will send a new single patch later today with one little typo I fixed.

> 
>   - Panu -



[dpdk-dev] [PATCH v3 06/15] eal/soc: implement probing of drivers

2016-09-16 Thread Jan Viktorin
On Fri, 9 Sep 2016 14:13:50 +0530
Shreyansh Jain  wrote:

> Each SoC PMD registers a set of callback for scanning its own bus/infra and
> matching devices to drivers when probe is called.
> This patch introduces the infra for calls to SoC scan on rte_eal_soc_init()
> and match on rte_eal_soc_probe().
> 
> Patch also adds test case for scan and probe.
> 
> Signed-off-by: Jan Viktorin 
> Signed-off-by: Shreyansh Jain 
> Signed-off-by: Hemant Agrawal 
> ---
>  app/test/test_soc.c | 138 ++-
>  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   4 +
>  lib/librte_eal/common/eal_common_soc.c  | 215 
> 
>  lib/librte_eal/common/include/rte_soc.h |  51 ++
>  lib/librte_eal/linuxapp/eal/eal.c   |   5 +
>  lib/librte_eal/linuxapp/eal/eal_soc.c   |  16 ++
>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |   4 +
>  7 files changed, 432 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test/test_soc.c b/app/test/test_soc.c
> index ac03e64..d2b9462 100644
> --- a/app/test/test_soc.c
> +++ b/app/test/test_soc.c
> @@ -87,14 +87,45 @@ static int test_compare_addr(void)
>   */
>  struct test_wrapper {
>   struct rte_soc_driver soc_drv;
> + struct rte_soc_device soc_dev;
>  };
>  
> +static int empty_pmd0_devinit(struct rte_soc_driver *drv,
> +   struct rte_soc_device *dev);
> +static int empty_pmd0_devuninit(struct rte_soc_device *dev);

I prefer an empty line here.


What is the prupose of the scan here? What device does it provide
to the test? I'd prefer to call it e.g. "allways_find_device0" or
something describing the purpose and explaining what is the goal
of the related test.

Probably a comment explaining "provide a device named 'empty_pmd0_dev'
would be helpful.

> +static void test_soc_scan_dev0_cb(void);

Similar here, something like "match_by_name".

> +static int test_soc_match_dev0_cb(struct rte_soc_driver *drv,
> +   struct rte_soc_device *dev);

I prefer an empty line here.


ditto...

> +static void test_soc_scan_dev1_cb(void);

ditto...

> +static int test_soc_match_dev1_cb(struct rte_soc_driver *drv,
> +   struct rte_soc_device *dev);
> +
> +static int
> +empty_pmd0_devinit(struct rte_soc_driver *drv __rte_unused,
> +struct rte_soc_device *dev __rte_unused)
> +{
> + return 0;
> +}
> +
> +static int
> +empty_pmd0_devuninit(struct rte_soc_device *dev)
> +{
> + /* Release the memory associated with dev->addr.name */
> + free(dev->addr.name);
> +
> + return 0;
> +}
> +
>  struct test_wrapper empty_pmd0 = {
>   .soc_drv = {
>   .driver = {
>   .name = "empty_pmd0"
>   },
> - },
> + .devinit = empty_pmd0_devinit,
> + .devuninit = empty_pmd0_devuninit,
> + .scan_fn = test_soc_scan_dev0_cb,
> + .match_fn = test_soc_match_dev0_cb,
> + }
>  };
>  
>  struct test_wrapper empty_pmd1 = {
> @@ -102,9 +133,54 @@ struct test_wrapper empty_pmd1 = {
>   .driver = {
>   .name = "empty_pmd1"
>   },
> + .scan_fn = test_soc_scan_dev1_cb,
> + .match_fn = test_soc_match_dev1_cb,
>   },
>  };
>  
> +static void
> +test_soc_scan_dev0_cb(void)
> +{
> + /* SoC's scan would scan devices on its bus and add to
> +  * soc_device_list
> +  */
> + empty_pmd0.soc_dev.addr.name = strdup("empty_pmd0_dev");
> +
> + TAILQ_INSERT_TAIL(_device_list, _pmd0.soc_dev, next);
> +}
> +
> +static int
> +test_soc_match_dev0_cb(struct rte_soc_driver *drv __rte_unused,
> +struct rte_soc_device *dev)
> +{
> + if (!dev->addr.name || strcmp(dev->addr.name, "empty_pmd0_dev"))
> + return 0;
> +
> + return 1;
> +}
> +
> +
> +static void
> +test_soc_scan_dev1_cb(void)
> +{
> + /* SoC's scan would scan devices on its bus and add to
> +  * soc_device_list
> +  */
> + empty_pmd0.soc_dev.addr.name = strdup("empty_pmd1_dev");
> +
> + TAILQ_INSERT_TAIL(_device_list, _pmd1.soc_dev, next);
> +}
> +
> +static int
> +test_soc_match_dev1_cb(struct rte_soc_driver *drv __rte_unused,
> +struct rte_soc_device *dev)
> +{
> + if (!dev->addr.name || strcmp(dev->addr.name, "empty_pmd1_dev"))
> + return 0;
> +
> + return 1;
> +}
> +
>  static int
>  count_registered_socdrvs(void)
>  {
> @@ -148,13 +224,54 @@ test_register_unregister(void)
>   return 0;
>  }
>  
> +/* Test Probe (scan and match) functionality */
> +static int
> +test_soc_init_and_probe(void)

You say to test scan and match. I'd prefer to reflect this in the name
of the test. Otherwise, it seems you are testing init and probe which
is not true, I think.

Do you test that "match principle works" or that "match functions are OK"
or "match functions are called as expected", ...?

> +{
> + struct 

[dpdk-dev] [PATCH v10 05/25] crypto: no need for a crypto pmd type

2016-09-16 Thread Jan Viktorin
On Fri, 16 Sep 2016 09:59:40 +0530
Shreyansh Jain  wrote:

> From: David Marchand 
> 
> This information is not used and just adds noise.
> 
> Signed-off-by: David Marchand 
> Signed-off-by: Shreyansh Jain 

Reviewed-by: Jan Viktorin 


[dpdk-dev] [PATCH 01/17] qede/base: update base driver

2016-09-16 Thread Ferruh Yigit
Hi Rasesh,

On 8/27/2016 7:26 AM, Rasesh Mody wrote:
> This patch updates the base driver and incorporates neccessary changes
> required to bring in the new firmware 8.10.9.0.
> 
> In addition, it would allow driver to add new functionalities that might
> be needed in future.
> 
> Signed-off-by: Rasesh Mody 
> ---
<...>
>  65 files changed, 14653 insertions(+), 8536 deletions(-)
<...>

Sorry for late review.

This is base driver update, but still a big single patch with 14K lines
insertions, it is too hard to both review or contribute.

Is it possible to split patch into more smaller ones, ideally it should
be one patch for one feature/fix, but please do whatever can be done.

I can see there are some big chunk of whitespace updates, or new files
for debug (hsi_debug_tools.h), those can be easy to target.

Thanks,
ferruh


[dpdk-dev] [PATCH v10 02/25] eal: remove duplicate function declaration

2016-09-16 Thread Jan Viktorin
On Fri, 16 Sep 2016 09:59:37 +0530
Shreyansh Jain  wrote:

> From: David Marchand 
> 
> rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its
> introduction.
> This function has been exported in ABI, so remove it from eal_private.h
> 
> Fixes: e57f20e05177 ("eal: make vdev init path generic for both virtual and 
> pci devices")
> 
> Signed-off-by: David Marchand 
> Signed-off-by: Shreyansh Jain 

Reviewed-by: Jan Viktorin 


[dpdk-dev] [PATCH v3 04/15] eal: introduce --no-soc option

2016-09-16 Thread Jan Viktorin
Hello Shreyansh,

there was an objection to reverse this option from negative
to positive semantics:

http://dpdk.org/ml/archives/dev/2016-May/038953.html

As SoC infrastructure would to be experimental for some time,
I think it is a good idea to disable it as default.

Regards
Jan

On Fri, 9 Sep 2016 14:13:48 +0530
Shreyansh Jain  wrote:

> This option has the same meaning for the SoC infra as the --no-pci
> for the PCI infra.
> 
> Signed-off-by: Jan Viktorin 
> Signed-off-by: Shreyansh Jain 
> Signed-off-by: Hemant Agrawal 
> ---
>  lib/librte_eal/common/eal_common_options.c | 5 +
>  lib/librte_eal/common/eal_internal_cfg.h   | 1 +
>  lib/librte_eal/common/eal_options.h| 2 ++
>  3 files changed, 8 insertions(+)
> 
> diff --git a/lib/librte_eal/common/eal_common_options.c 
> b/lib/librte_eal/common/eal_common_options.c
> index 1a1bab3..d97cf0a 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -85,6 +85,7 @@ eal_long_options[] = {
>   {OPT_NO_HPET,   0, NULL, OPT_NO_HPET_NUM  },
>   {OPT_NO_HUGE,   0, NULL, OPT_NO_HUGE_NUM  },
>   {OPT_NO_PCI,0, NULL, OPT_NO_PCI_NUM   },
> + {OPT_NO_SOC,0, NULL, OPT_NO_SOC_NUM   },
>   {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM},
>   {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM},
>   {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM},
> @@ -855,6 +856,10 @@ eal_parse_common_option(int opt, const char *optarg,
>   conf->no_pci = 1;
>   break;
>  
> + case OPT_NO_SOC_NUM:
> + conf->no_soc = 1;
> + break;
> +
>   case OPT_NO_HPET_NUM:
>   conf->no_hpet = 1;
>   break;
> diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
> b/lib/librte_eal/common/eal_internal_cfg.h
> index 5f1367e..3a98e94 100644
> --- a/lib/librte_eal/common/eal_internal_cfg.h
> +++ b/lib/librte_eal/common/eal_internal_cfg.h
> @@ -67,6 +67,7 @@ struct internal_config {
>   unsigned hugepage_unlink; /**< true to unlink backing files */
>   volatile unsigned xen_dom0_support; /**< support app running on Xen 
> Dom0*/
>   volatile unsigned no_pci; /**< true to disable PCI */
> + volatile unsigned no_soc; /**< true to disable SoC */
>   volatile unsigned no_hpet;/**< true to disable HPET */
>   volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping
>   
> * instead of native TSC */
> diff --git a/lib/librte_eal/common/eal_options.h 
> b/lib/librte_eal/common/eal_options.h
> index a881c62..ba1e704 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -69,6 +69,8 @@ enum {
>   OPT_NO_HUGE_NUM,
>  #define OPT_NO_PCI"no-pci"
>   OPT_NO_PCI_NUM,
> +#define OPT_NO_SOC"no-soc"
> + OPT_NO_SOC_NUM,
>  #define OPT_NO_SHCONF "no-shconf"
>   OPT_NO_SHCONF_NUM,
>  #define OPT_SOCKET_MEM"socket-mem"



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


[dpdk-dev] [PATCH v5]net/virtio: add mtu set in virtio

2016-09-16 Thread souvikdey33

Virtio interfaces should also support setting of mtu, as in case of cloud
it is expected to have the consistent mtu across the infrastructure that
the dhcp server sends and not hardcoded to 1500(default).
In case when GRE/VXLAN tunneling is used, it adds overheads to the total
size of 1518, and in that cases the DHCP server corrects the L3 MTU to 1454
to take care of the overhead. BUt since virtio interfaces was not having the 
mtu set that mtu sent by dhcp was ignored and teh instance will still send
packets with 1500 mtu which afetr encapsulation will become more than 1518 
and eventually gets dropped in the infrastructure. This issue can be solved
by honoring the mtu 1454 sent by dhcp server, which this below patch will
take care.


Changes in v5: Incorporated review comments.
Changes in v4: Incorporated review comments.
Changes in v3: Corrected few style errors as reported by sys-stv.
Changes in v2: Incorporated review comments.

Signed-off-by: Souvik Dey 

---
 drivers/net/virtio/virtio_ethdev.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 07d6449..da16ad4 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -653,12 +653,20 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
PMD_INIT_LOG(ERR, "Failed to disable allmulticast");
 }

+#define VLAN_TAG_SIZE   4/* 802.3ac tag (not DMA'd) */
+
+static int  virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+   struct rte_eth_dev_info dev_info;
+   uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE;
+   uint32_t frame_size = mtu + ether_hdr_len;
+
+   virtio_dev_info_get(dev, _info);
+
+   if (frame_size < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) {
+   PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n",
+   (ETHER_MIN_MTU - ether_hdr_len),
+   (dev_info.max_rx_pktlen - ether_hdr_len));
+   return -EINVAL;
+   }
+   return 0;
+}
@@ -677,7 +685,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
.allmulticast_enable = virtio_dev_allmulticast_enable,
.allmulticast_disable= virtio_dev_allmulticast_disable,
+   .mtu_set = virtio_mtu_set,
.dev_infos_get   = virtio_dev_info_get,
.stats_get   = virtio_dev_stats_get,
.xstats_get  = virtio_dev_xstats_get,
-- 
2.9.3.windows.1


[dpdk-dev] [PATCH] app/test: improve error message in crypto test code

2016-09-16 Thread Fiona Trahe (fiona.tr...@intel.com)
From: Fiona Trahe 

Improve error message if crypto PMD build is not enabled in config file

Signed-off-by: Fiona Trahe 
---
 app/test/test_cryptodev.c  | 37 +
 app/test/test_cryptodev_perf.c | 23 +++
 2 files changed, 60 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index f17c84c..c30a421 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -189,6 +189,11 @@ testsuite_setup(void)

/* Create 2 AESNI MB devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
+#ifndef RTE_LIBRTE_PMD_AESNI_MB
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_AESNI_MB_PMD);
if (nb_devs < 2) {
@@ -206,6 +211,11 @@ testsuite_setup(void)

/* Create 2 LIBCRYPTO devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_LIBCRYPTO_PMD) {
+#ifndef RTE_LIBRTE_PMD_LIBCRYPTO
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_LIBCRYPTO_PMD);
if (nb_devs < 2) {
@@ -223,6 +233,11 @@ testsuite_setup(void)

/* Create 2 AESNI GCM devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
+#ifndef RTE_LIBRTE_PMD_AESNI_GCM
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_AESNI_GCM_PMD);
if (nb_devs < 2) {
@@ -238,6 +253,11 @@ testsuite_setup(void)

/* Create 2 Snow3G devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
+#ifndef RTE_LIBRTE_PMD_SNOW3G
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
if (nb_devs < 2) {
for (i = nb_devs; i < 2; i++) {
@@ -252,6 +272,11 @@ testsuite_setup(void)

/* Create 2 KASUMI devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
+#ifndef RTE_LIBRTE_PMD_KASUMI
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
if (nb_devs < 2) {
for (i = nb_devs; i < 2; i++) {
@@ -266,6 +291,11 @@ testsuite_setup(void)

/* Create 2 NULL devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
+#ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = rte_cryptodev_count_devtype(
RTE_CRYPTODEV_NULL_PMD);
if (nb_devs < 2) {
@@ -281,6 +311,13 @@ testsuite_setup(void)
}
}

+#ifndef RTE_LIBRTE_PMD_QAT
+   if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
+   "in config file to run this testsuite.\n");
+   return TEST_FAILED;
+   }
+#endif

nb_devs = rte_cryptodev_count();
if (nb_devs < 1) {
diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index 0a0085d..c80c335 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -261,6 +261,11 @@ testsuite_setup(void)

/* Create 2 AESNI MB devices if required */
if (gbl_cryptodev_perftest_devtype == RTE_CRYPTODEV_AESNI_MB_PMD) {
+#ifndef RTE_LIBRTE_PMD_AESNI_MB
+   RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
+   " enabled in config file to run this testsuite.\n");
+   return TEST_FAILED;
+#endif
nb_devs = 
rte_cryptodev_count_devtype(RTE_CRYPTODEV_AESNI_MB_PMD);
if (nb_devs < 2) {
for (i = nb_devs; i < 2; i++) {
@@ -276,6 +281,11 @@ 

[dpdk-dev] [PATCH v2] net/kni: add KNI PMD

2016-09-16 Thread Ferruh Yigit
Add KNI PMD which wraps librte_kni for ease of use.

KNI PMD can be used as any regular PMD to send / receive packets to the
Linux networking stack.

Signed-off-by: Ferruh Yigit 
---

v2:
* updated driver name eth_kni -> net_kni
---
 config/common_base  |   1 +
 config/common_linuxapp  |   1 +
 drivers/net/Makefile|   1 +
 drivers/net/kni/Makefile|  63 +
 drivers/net/kni/rte_eth_kni.c   | 463 
 drivers/net/kni/rte_pmd_kni_version.map |   4 +
 mk/rte.app.mk   |  10 +-
 7 files changed, 538 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/kni/Makefile
 create mode 100644 drivers/net/kni/rte_eth_kni.c
 create mode 100644 drivers/net/kni/rte_pmd_kni_version.map

diff --git a/config/common_base b/config/common_base
index 7830535..f8f309a 100644
--- a/config/common_base
+++ b/config/common_base
@@ -531,6 +531,7 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n
 # Compile librte_kni
 #
 CONFIG_RTE_LIBRTE_KNI=n
+CONFIG_RTE_LIBRTE_PMD_KNI=n
 CONFIG_RTE_KNI_KMOD=n
 CONFIG_RTE_KNI_PREEMPT_DEFAULT=y
 CONFIG_RTE_KNI_KO_DEBUG=n
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 2483dfa..2ecd510 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -39,6 +39,7 @@ CONFIG_RTE_EAL_IGB_UIO=y
 CONFIG_RTE_EAL_VFIO=y
 CONFIG_RTE_KNI_KMOD=y
 CONFIG_RTE_LIBRTE_KNI=y
+CONFIG_RTE_LIBRTE_PMD_KNI=y
 CONFIG_RTE_LIBRTE_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index bc93230..c4771cd 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic
 DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += kni
 DIRS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4
 DIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5
 DIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += mpipe
diff --git a/drivers/net/kni/Makefile b/drivers/net/kni/Makefile
new file mode 100644
index 000..0b7cf91
--- /dev/null
+++ b/drivers/net/kni/Makefile
@@ -0,0 +1,63 @@
+#   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 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_kni.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+LDLIBS += -lpthread
+
+EXPORT_MAP := rte_pmd_kni_version.map
+
+LIBABIVER := 1
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += rte_eth_kni.c
+
+#
+# Export include files
+#
+SYMLINK-y-include +=
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_kni
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_mempool
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
new file mode 100644
index 000..ae541e6
--- /dev/null
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -0,0 +1,463 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   

[dpdk-dev] [PATCH v2] nfp: unregister interrupt callback when closing

2016-09-16 Thread Alejandro Lucero
With an app using hotplug feature, when a device is unplugged without
unregistering makes the interrupt handling unstable.

Fixes: 6c53f87b3497 ("nfp: add link status interrupt")

Signed-off-by: Alejandro Lucero 
---
 drivers/net/nfp/nfp_net.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index d79f0a1..f78eb82 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -733,6 +733,11 @@ nfp_net_close(struct rte_eth_dev *dev)
rte_intr_disable(>pci_dev->intr_handle);
nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);

+   /* unregister callback func from eal lib */
+   rte_intr_callback_unregister(>pci_dev->intr_handle,
+nfp_net_dev_interrupt_handler,
+(void *)dev);
+
/*
 * The ixgbe PMD driver disables the pcie master on the
 * device. The i40e does not...
-- 
1.9.1



[dpdk-dev] [PATCH v2] nfp: fixing bug when copying MAC address

2016-09-16 Thread Alejandro Lucero
Fixes: defb9a5dd156 ("nfp: introduce driver initialization")

Signed-off-by: Alejandro Lucero 
---
 drivers/net/nfp/nfp_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 1948a12..d79f0a1 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -2421,8 +2421,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
eth_random_addr(>mac_addr[0]);

/* Copying mac address to DPDK eth_dev struct */
-   ether_addr_copy(_dev->data->mac_addrs[0],
-   (struct ether_addr *)hw->mac_addr);
+   ether_addr_copy((struct ether_addr *)hw->mac_addr,
+   _dev->data->mac_addrs[0]);

PMD_INIT_LOG(INFO, "port %d VendorID=0x%x DeviceID=0x%x "
 "mac=%02x:%02x:%02x:%02x:%02x:%02x",
-- 
1.9.1



[dpdk-dev] [PATCH v2] nfp: using random MAC address if not configured

2016-09-16 Thread Alejandro Lucero
Signed-off-by: Alejandro Lucero 
---
 drivers/net/nfp/nfp_net.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 82e3e4e..1948a12 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -607,18 +607,8 @@ nfp_net_rx_freelist_setup(struct rte_eth_dev *dev)
 static void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-   uint32_t *mac_address;
-
nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
-
-   /* A MAC address is 8 bytes long */
-   mac_address = (uint32_t *)(hw->mac_addr);
-
-   nn_cfg_writel(hw, NFP_NET_CFG_MACADDR,
- rte_cpu_to_be_32(*mac_address));
-   nn_cfg_writel(hw, NFP_NET_CFG_MACADDR + 4,
- rte_cpu_to_be_32(*(mac_address + 4)));
 }

 static void
@@ -627,6 +617,17 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }

+static void nfp_net_read_mac(struct nfp_net_hw *hw)
+{
+   uint32_t tmp;
+
+   tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+   memcpy(>mac_addr[0], , sizeof(struct ether_addr));
+
+   tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+   memcpy(>mac_addr[4], , 2);
+}
+
 static int
 nfp_net_start(struct rte_eth_dev *dev)
 {
@@ -2413,8 +2414,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
return -ENOMEM;
}

-   /* Using random mac addresses for VFs */
-   eth_random_addr(>mac_addr[0]);
+   nfp_net_read_mac(hw);
+
+   if (!is_valid_assigned_ether_addr((struct ether_addr *)>mac_addr))
+   /* Using random mac addresses for VFs */
+   eth_random_addr(>mac_addr[0]);

/* Copying mac address to DPDK eth_dev struct */
ether_addr_copy(_dev->data->mac_addrs[0],
-- 
1.9.1



[dpdk-dev] [PATCH v3 3/3] app/test_pmd: add tests for new API's

2016-09-16 Thread Bernard Iremonger
add test for vf vlan anti spoof
add test for vf mac anti spoof
add test for vf ping
add test for vf vlan strip
add test for vf vlan insert
add test for tx loopback
add test for all queues drop enable bit
add test for vf split drop enable bit
add test for vf mac address
add new API's to the testpmd guide

Signed-off-by: Bernard Iremonger 
---
 app/test-pmd/cmdline.c  | 707 
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  70 ++-
 2 files changed, 774 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f90befc..264aa90 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -10585,6 +10585,704 @@ cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
},
 };

+/* vf vlan anti spoof configuration */
+
+/* Common result structure for vf vlan anti spoof */
+struct cmd_vf_vlan_anti_spoof_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vf;
+   cmdline_fixed_string_t vlan;
+   cmdline_fixed_string_t antispoof;
+   uint8_t port_id;
+   uint32_t vf_id;
+   cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf vlan anti spoof enable disable */
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+set, "set");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+vf, "vf");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+vlan, "vlan");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+antispoof, "antispoof");
+cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+vf_id, UINT32);
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_vlan_anti_spoof_result,
+on_off, "on#off");
+
+static void
+cmd_set_vf_vlan_anti_spoof_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
+   int ret = 0;
+   int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+   return;
+
+   if (res->vf_id > 63) {
+   printf("vf_id must be less than 64.\n");
+   return;
+   }
+   ret = rte_eth_dev_set_vf_vlan_anti_spoof(res->port_id, res->vf_id, 
is_on);
+   if (ret < 0)
+   printf("vf vlan anti spoofing programming error: (%s)\n",
+  strerror(-ret));
+}
+
+cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
+   .f = cmd_set_vf_vlan_anti_spoof_parsed,
+   .data = NULL,
+   .help_str = "set vf vlan antispoof port_id vf_id on|off",
+   .tokens = {
+   (void *)_vf_vlan_anti_spoof_set,
+   (void *)_vf_vlan_anti_spoof_vf,
+   (void *)_vf_vlan_anti_spoof_vlan,
+   (void *)_vf_vlan_anti_spoof_antispoof,
+   (void *)_vf_vlan_anti_spoof_port_id,
+   (void *)_vf_vlan_anti_spoof_vf_id,
+   (void *)_vf_vlan_anti_spoof_on_off,
+   NULL,
+   },
+};
+
+/* vf mac anti spoof configuration */
+
+/* Common result structure for vf mac anti spoof */
+struct cmd_vf_mac_anti_spoof_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vf;
+   cmdline_fixed_string_t mac;
+   cmdline_fixed_string_t antispoof;
+   uint8_t port_id;
+   uint32_t vf_id;
+   cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf mac anti spoof enable disable */
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+set, "set");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+vf, "vf");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+mac, "mac");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_vf_mac_anti_spoof_result,
+antispoof, 

[dpdk-dev] [PATCH v3 2/3] net/ixgbe: add functions for VF management

2016-09-16 Thread Bernard Iremonger
Add new functions to configure and manage VF's on an Intel 82559 NIC.

add ixgbe_vf_ping function.
add ixgbe_set_vf_vlan_anti_spoof function.
add ixgbe_set_vf_mac_anti_spoof function.

Signed-off-by: azelezniak 

add ixgbe_set_vf_vlan_insert function.
add ixgbe_set_tx_loopback function.
add ixgbe_set_all_queues_drop function.
add ixgbe_set_vf_split_drop_en function.
add ixgbe_set_vf_mac_addr function.

Signed-off-by: Bernard Iremonger 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 166 +++
 1 file changed, 166 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index fb618ef..9875290 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -240,6 +240,8 @@ static void ixgbe_add_rar(struct rte_eth_dev *dev, struct 
ether_addr *mac_addr,
 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
   struct ether_addr *mac_addr);
+static int ixgbe_set_vf_mac_addr(struct rte_eth_dev *dev, uint16_t vf,
+   struct ether_addr *mac_addr);
 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config 
*dcb_config);

 /* For Virtual Function support */
@@ -280,6 +282,17 @@ static int ixgbe_set_pool_rx(struct rte_eth_dev *dev, 
uint16_t pool, uint8_t on)
 static int ixgbe_set_pool_tx(struct rte_eth_dev *dev, uint16_t pool, uint8_t 
on);
 static int ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
uint64_t pool_mask, uint8_t vlan_on);
+static void ixgbe_set_vf_vlan_anti_spoof(struct rte_eth_dev *dev,
+   uint16_t vf, uint8_t on);
+static void ixgbe_set_vf_mac_anti_spoof(struct rte_eth_dev *dev,
+   uint16_t vf, uint8_t on);
+static int ixgbe_vf_ping(struct rte_eth_dev *dev, int32_t vf);
+static void ixgbe_set_vf_vlan_insert(struct rte_eth_dev *dev, uint16_t vf,
+   int vlan);
+static void ixgbe_set_tx_loopback(struct rte_eth_dev *dev, int on);
+static void ixgbe_set_all_queues_drop_en(struct rte_eth_dev *dev, int state);
+static void ixgbe_set_vf_split_drop_en(struct rte_eth_dev *dev, uint16_t vf,
+   int state);
 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
struct rte_eth_mirror_conf *mirror_conf,
uint8_t rule_id, uint8_t on);
@@ -562,6 +575,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.mac_addr_add = ixgbe_add_rar,
.mac_addr_remove  = ixgbe_remove_rar,
.mac_addr_set = ixgbe_set_default_mac_addr,
+   .set_vf_mac_addr  = ixgbe_set_vf_mac_addr,
.uc_hash_table_set= ixgbe_uc_hash_table_set,
.uc_all_hash_table_set  = ixgbe_uc_all_hash_table_set,
.mirror_rule_set  = ixgbe_mirror_rule_set,
@@ -570,6 +584,13 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.set_vf_rx= ixgbe_set_pool_rx,
.set_vf_tx= ixgbe_set_pool_tx,
.set_vf_vlan_filter   = ixgbe_set_pool_vlan_filter,
+   .set_vf_vlan_anti_spoof  = ixgbe_set_vf_vlan_anti_spoof,
+   .set_vf_mac_anti_spoof   = ixgbe_set_vf_mac_anti_spoof,
+   .vf_ping  = ixgbe_vf_ping,
+   .set_vf_vlan_insert   = ixgbe_set_vf_vlan_insert,
+   .set_tx_loopback  = ixgbe_set_tx_loopback,
+   .set_all_queues_drop_en = ixgbe_set_all_queues_drop_en,
+   .set_vf_split_drop_en = ixgbe_set_vf_split_drop_en,
.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
.set_vf_rate_limit= ixgbe_set_vf_rate_limit,
.reta_update  = ixgbe_dev_rss_reta_update,
@@ -4069,6 +4090,22 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, 
struct ether_addr *addr)
 }

 static int
+ixgbe_set_vf_mac_addr(struct rte_eth_dev *dev, uint16_t vf, struct ether_addr 
*mac_addr)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_vf_info *vfinfo =
+   *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
+   int rar_entry = hw->mac.num_rar_entries - (vf + 1);
+   uint8_t *new_mac = (uint8_t *)(mac_addr);
+
+   if (is_valid_assigned_ether_addr((struct ether_addr *)new_mac)) {
+   rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 
ETHER_ADDR_LEN);
+   return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, 
IXGBE_RAH_AV);
+   }
+   return -1;
+}
+
+static int
 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
uint32_t hlreg0;
@@ -4661,6 +4698,135 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, 
uint16_t vlan,
return ret;
 }

+static void
+ixgbe_set_vf_vlan_anti_spoof(struct rte_eth_dev *dev,
+   uint16_t vf, uint8_t on)
+{
+   struct ixgbe_hw *hw =
+   IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   struct ixgbe_mac_info *mac = 

[dpdk-dev] [PATCH v3 1/3] librte_ether: add API's for VF management

2016-09-16 Thread Bernard Iremonger
Add new API functions to configure and manage VF's on a NIC.

add rte_eth_dev_vf_ping function.
add rte_eth_dev_set_vf_vlan_anti_spoof function.
add rte_eth_dev_set_vf_mac_anti_spoof function.
add rte_eth_dev_set_vf_vlan_strip function.

Signed-off-by: azelezniak 

add rte_eth_dev_set_vf_vlan_insert function.
add rte_eth_dev_set_loopback function.
add rte_eth_dev_set_all_queues_drop function.
add rte_eth_dev_set_vf_split_drop_en function
add rte_eth_dev_set_vf_mac_addr function.

Signed-off-by: Bernard Iremonger 
---
 lib/librte_ether/rte_ethdev.c  | 192 +
 lib/librte_ether/rte_ethdev.h  | 217 -
 lib/librte_ether/rte_ether_version.map |  14 +++
 3 files changed, 422 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 382c959..4f83c29 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2305,6 +2305,30 @@ rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct 
ether_addr *addr)
 }

 int
+rte_eth_dev_set_vf_mac_addr(uint8_t port_id, uint16_t vf, struct ether_addr 
*addr)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   if (!is_valid_assigned_ether_addr(addr))
+   return -EINVAL;
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF mac addr: invalid VF %d\n", vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_mac_addr, -ENOTSUP);
+
+   return (*dev->dev_ops->set_vf_mac_addr)(dev, vf, addr);
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
uint16_t rx_mode, uint8_t on)
 {
@@ -2489,6 +2513,174 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, 
uint16_t vlan_id,
   vf_mask, vlan_on);
 }

+int
+rte_eth_dev_set_vf_vlan_anti_spoof(uint8_t port_id,
+  uint16_t vf, uint8_t on)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF VLAN anti spoof: invalid VF %d\n", 
vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_anti_spoof, 
-ENOTSUP);
+   (*dev->dev_ops->set_vf_vlan_anti_spoof)(dev, vf, on);
+   return 0;
+}
+
+int
+rte_eth_dev_set_vf_mac_anti_spoof(uint8_t port_id,
+  uint16_t vf, uint8_t on)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF MAC anti spoof:invalid VF %d\n", 
vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_mac_anti_spoof, -ENOTSUP);
+   (*dev->dev_ops->set_vf_mac_anti_spoof)(dev, vf, on);
+   return 0;
+}
+
+int
+rte_eth_dev_vf_ping(uint8_t port_id, int32_t vf)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("VF ping: invalid VF %d\n", vf);
+   return -EINVAL;
+   } else if (vf < -1) {
+   RTE_PMD_DEBUG_TRACE("VF ping: invalid value %d\n", vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vf_ping, -ENOTSUP);
+   return (*dev->dev_ops->vf_ping)(dev, vf);
+}
+
+int
+rte_eth_dev_set_vf_vlan_strip(uint8_t port_id, uint16_t vf, int on)
+{
+   struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
+   uint16_t queues_per_pool;
+   uint32_t q;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+   dev = _eth_devices[port_id];
+   rte_eth_dev_info_get(port_id, _info);
+
+   if (vf >= dev_info.max_vfs) {
+   RTE_PMD_DEBUG_TRACE("set VF vlan strip: invalid VF %d\n", vf);
+   return -EINVAL;
+   }
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
+
+   queues_per_pool = dev_info.vmdq_queue_num/dev_info.max_vmdq_pools;
+
+   for (q = 0; q < queues_per_pool; q++)
+   (*dev->dev_ops->vlan_strip_queue_set)(dev, q + vf * 
queues_per_pool, on);
+   return 0;
+}
+
+int
+rte_eth_dev_set_vf_vlan_insert(uint8_t port_id, 

[dpdk-dev] [PATCH v3 0/3] add API's for VF management

2016-09-16 Thread Bernard Iremonger
This patchset contains new DPDK API's requested by AT for use
with the Virtual Function Daemon (VFD).

The need to configure and manage VF's on a NIC has grown to the
point where AT have devloped a DPDK based tool, VFD, to do this.

This patch set adds API extensions to DPDK VF configuration.

Nine new functions have been added to the eth_dev_ops structure.
Corresponding functions have been added to the ixgbe PMD for the
Intel 82559 NIC.

Changes have been made to testpmd to facilitate testing of the new API's.
The testpmd documentation has been updated to document the testpmd changes.

Note:
Adding new functions to the eth_dev_ops structure will cause an
ABI breakage.

Changes in v3:
rebase to latest master branch.
drop patches for callback functions
revise VF id checks in new librte_ether functions
revise testpmd commands for new API's

Changes in V2:
rebase to latest master branch.
fix compile  error with clang.

Bernard Iremonger (3):
  librte_ether: add API's for VF management
  net/ixgbe: add functions for VF management
  app/test_pmd: add tests for new API's

 app/test-pmd/cmdline.c  | 707 
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  70 ++-
 drivers/net/ixgbe/ixgbe_ethdev.c| 166 +++
 lib/librte_ether/rte_ethdev.c   | 192 
 lib/librte_ether/rte_ethdev.h   | 217 -
 lib/librte_ether/rte_ether_version.map  |  14 +
 6 files changed, 1362 insertions(+), 4 deletions(-)

-- 
2.9.0



[dpdk-dev] [PATCH v2]:rte_timer:timer lag issue correction

2016-09-16 Thread Karmarkar Suyash
For Periodic timers ,if the lag gets introduced, the current code 
added additional delay when the next peridoc timer was initialized 
by not taking into account the delay added, with this fix the code 
would start the next occurrence of timer keeping in account the 
lag added.Corrected the behavior.

Fixes:ba885531ac26 ("rte_timer: timer lag issue")

Karmarkar Suyash (1):
  Signed-off-by: Karmarkar Suyash 

 lib/librte_timer/rte_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
 lib/librte_timer/rte_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 43da836..18782fa 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -613,7 +613,7 @@ void rte_timer_manage(void)
status.owner = (int16_t)lcore_id;
rte_wmb();
tim->status.u32 = status.u32;
-   __rte_timer_reset(tim, cur_time + tim->period,
+   __rte_timer_reset(tim, tim->expire + tim->period,
tim->period, lcore_id, tim->f, tim->arg, 1);
rte_spinlock_unlock(_timer[lcore_id].list_lock);
}

-- 
2.9.3.windows.1



[dpdk-dev] [PATCH v2]:rte_timer:timer lag issue correction

2016-09-16 Thread Karmarkar Suyash
For Periodic timers ,if the lag gets introduced, the current code 
added additional delay when the next peridoc timer was initialized 
by not taking into account the delay added, with this fix the code 
would start the next occurrence of timer keeping in account the 
lag added.Corrected the behavior.

Fixes:ba885531ac26 ("rte_timer: timer lag issue")

Karmarkar Suyash (1):
  Signed-off-by: Karmarkar Suyash 

 lib/librte_timer/rte_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
 lib/librte_timer/rte_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 43da836..18782fa 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -613,7 +613,7 @@ void rte_timer_manage(void)
status.owner = (int16_t)lcore_id;
rte_wmb();
tim->status.u32 = status.u32;
-   __rte_timer_reset(tim, cur_time + tim->period,
+   __rte_timer_reset(tim, tim->expire + tim->period,
tim->period, lcore_id, tim->f, tim->arg, 1);
rte_spinlock_unlock(_timer[lcore_id].list_lock);
}

-- 
2.9.3.windows.1



[dpdk-dev] [PATCH] drivers: make driver names consistent

2016-09-16 Thread Thomas Monjalon
2016-08-24 22:37, Mcnamara, John:
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Pablo de Lara
> >
> > ...
> >
> > -$RTE_TARGET/app/testpmd -c '0xf' -n 4 --vdev 
> > 'eth_pcap0,rx_pcap=/path/to/ file_rx.pcap,tx_pcap=/path/to/file_tx.pcap' -- 
> > --port-topology=chained
> > +$RTE_TARGET/app/testpmd -c '0xf' -n 4 --vdev 
> > 'net_pcap0,rx_pcap=/path/to/ file_rx.pcap,tx_pcap=/path/to/file_tx.pcap' -- 
> > --port-topology=chained
> 
> 
> I know that this is an existing issue but there shouldn't be a space in
> "/path/to/ file". Perhaps you could fix that (in a number of places) as part
> of this patch. You could probably leave out the "/path/to/" part altogether 
> as 
> it may be clearer, see below.
> 
> Also, could you wrap the long code lines in the sections that you change at 
> 80 chars using "\" to keep them on the page in the PDF docs, like:
> 
> $RTE_TARGET/app/testpmd -c '0xf' -n 4 \
> --vdev 
> 'net_pcap0,rx_pcap=/path/to/file_rx.pcap,tx_pcap=/path/to/file_tx.pcap' \
> -- --port-topology=chained
> 
> Or without the path part:
> 
> $RTE_TARGET/app/testpmd -c '0xf' -n 4 \
> --vdev 'net_pcap0,rx_pcap=file_rx.pcap,tx_pcap=file_tx.pcap' \
> -- --port-topology=chained

Applied with above comments fixed and release notes updated, thanks.


[dpdk-dev] [PATCH] crypto/null: fix key size increment value

2016-09-16 Thread Deepak Kumar Jain
This patch fixes the values of increment in key size.

Fixes:  94b0ad8e0a ("null_crypto_pmd: PMD to support null crypto
operations")

Signed-off-by: Deepak Kumar Jain 
---
 drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c 
b/drivers/crypto/null/null_crypto_pmd_ops.c
index cf1a519..26ff631 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -70,7 +70,7 @@ static const struct rte_cryptodev_capabilities 
null_crypto_pmd_capabilities[] =
.key_size = {
.min = 0,
.max = 0,
-   .increment = 8
+   .increment = 0
},
.iv_size = {
.min = 0,
-- 
2.5.5



[dpdk-dev] [PATCH v2] drivers/net:new PMD using tun/tap host interface

2016-09-16 Thread Keith Wiles
The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces
on the local host. The PMD allows for DPDK and the host to
communicate using a raw device interface on the host and in
the DPDK application. The device created is a Tap device with
a L2 packet header.

v2 - merge all of the patches into one patch.
 Fix a typo on naming the tap device.
 Update the maintainers list

Signed-off-by: Keith Wiles 
---
 MAINTAINERS |   5 +
 config/common_linuxapp  |   2 +
 doc/guides/nics/tap.rst |  84 +++
 drivers/net/Makefile|   1 +
 drivers/net/tap/Makefile|  60 +++
 drivers/net/tap/rte_eth_tap.c   | 872 
 drivers/net/tap/rte_pmd_tap_version.map |   4 +
 mk/rte.app.mk   |   1 +
 8 files changed, 1029 insertions(+)
 create mode 100644 doc/guides/nics/tap.rst
 create mode 100644 drivers/net/tap/Makefile
 create mode 100644 drivers/net/tap/rte_eth_tap.c
 create mode 100644 drivers/net/tap/rte_pmd_tap_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 7c33ad4..fad74e4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -392,6 +392,11 @@ F: doc/guides/nics/pcap_ring.rst
 F: app/test/test_pmd_ring.c
 F: app/test/test_pmd_ring_perf.c

+Tap PMD
+M: Keith Wiles 
+F: drivers/net/tap
+F: doc/guides/nics/tap.rst
+
 Null Networking PMD
 M: Tetsuya Mukawa 
 F: drivers/net/null/
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 2483dfa..59a2053 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -44,3 +44,5 @@ CONFIG_RTE_LIBRTE_PMD_VHOST=y
 CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
 CONFIG_RTE_LIBRTE_POWER=y
 CONFIG_RTE_VIRTIO_USER=y
+CONFIG_RTE_LIBRTE_PMD_TAP=y
+CONFIG_RTE_PMD_TAP_MAX_QUEUES=32
diff --git a/doc/guides/nics/tap.rst b/doc/guides/nics/tap.rst
new file mode 100644
index 000..072def8
--- /dev/null
+++ b/doc/guides/nics/tap.rst
@@ -0,0 +1,84 @@
+..  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, 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.
+
+Tun/Tap Poll Mode Driver
+
+
+The rte_eth_tap.c PMD creates a device using TUN/TAP interfaces on the local
+host. The PMD allows for DPDK and the host to communicate using a raw device
+interface on the host and in the DPDK application.
+
+The device created is a TAP device, which sends/receives packet in a raw format
+with a L2 header. The usage for a TAP PMD is for connectivity to the local host
+using a TAP interface. When the TAP PMD is initialized it will create a number
+of tap devices in the host accessed via 'ifconfig -a' or 'ip' command. The
+commands can be used to assign and query the virtual like device.
+
+These TAP interfaces can be used with wireshark or tcpdump or Pktgen-DPDK along
+with being able to be used as a network connection to the DPDK application. The
+method enable one or more interfaces is to use the --vdev=eth_tap option on the
+DPDK application  command line. Each --vdev=eth_tap option give will create an
+interface named dtap0, dtap1, ... and so forth.
+
+.. code-block:: console
+
+   The interfaced name can be changed by adding the iface=foo0
+   e.g. --vedv=eth_tap,iface=foo0 --vdev=eth_tap,iface=foo1, ...
+
+.. code-block:: console
+
+   Also the speed of the interface can be changed from 10G to whatever number
+   needed, but the interface does not enforce that speed.
+   e.g. 

[dpdk-dev] [PATCH 3/3] drivers/net:build support for new tap device driver

2016-09-16 Thread Panu Matilainen
On 09/15/2016 05:10 PM, Keith Wiles wrote:
> Signed-off-by: Keith Wiles 
> ---
>  config/common_linuxapp | 3 +++
>  drivers/net/Makefile   | 1 +
>  mk/rte.app.mk  | 1 +
>  3 files changed, 5 insertions(+)
>
> diff --git a/config/common_linuxapp b/config/common_linuxapp
> index 2483dfa..704c01c 100644
> --- a/config/common_linuxapp
> +++ b/config/common_linuxapp
> @@ -44,3 +44,6 @@ CONFIG_RTE_LIBRTE_PMD_VHOST=y
>  CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
>  CONFIG_RTE_LIBRTE_POWER=y
>  CONFIG_RTE_VIRTIO_USER=y
> +CONFIG_RTE_LIBRTE_PMD_TAP=y
> +CONFIG_RTE_PMD_TAP_MAX_QUEUES=32
> +
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index bc93230..b4afa98 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -55,6 +55,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += thunderx
>  DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
>  DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
>  DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
> +DIRS-$(CONFIG_RTE_LIBRTE_PMD_TAP) += tap
>
>  ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
>  DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
> diff --git a/mk/rte.app.mk b/mk/rte.app.mk
> index 1a0095b..bd1d10f 100644
> --- a/mk/rte.app.mk
> +++ b/mk/rte.app.mk
> @@ -129,6 +129,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
>  _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_VHOST)  += -lrte_pmd_vhost
>  endif # $(CONFIG_RTE_LIBRTE_VHOST)
>  _LDLIBS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD)+= -lrte_pmd_vmxnet3_uio
> +_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_TAP)+= -lrte_pmd_tap
>
>  ifeq ($(CONFIG_RTE_LIBRTE_CRYPTODEV),y)
>  _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB)   += -lrte_pmd_aesni_mb
>

Splitting the Makefile and config changes into a separate patch makes no 
sense at all in this case. Just do it in the patch introducing the driver.

And actually, ditto for documentation.

- Panu -


[dpdk-dev] [PATCH v3 02/15] eal/soc: add rte_eal_soc_register/unregister logic

2016-09-16 Thread Panu Matilainen
On 09/15/2016 05:09 PM, Thomas Monjalon wrote:
> 2016-09-15 15:09, Jan Viktorin:
>> On Thu, 15 Sep 2016 14:00:25 +0100
>> "Hunt, David"  wrote:
>>
 new file mode 100644
 index 000..56135ed
 --- /dev/null
 +++ b/lib/librte_eal/common/eal_common_soc.c
 @@ -0,0 +1,56 @@
 +/*-
 + *   BSD LICENSE
 + *
 + *   Copyright(c) 2016 RehiveTech. All rights reserved.
 + *   All rights reserved.
>>>
>>> Duplicate "All rights reserved"
>>
>> This is present in many source files in DPDK... I don't know why.
>>
>> lib/librte_eal/common/eal_common_pci.c
>> lib/librte_eal/common/eal_common_dev.c
>> ...
>
> It would deserve a dedicated thread to discuss legal sense of these things.
> I'm not a lawyer but I think "All rights reserved." has no real sense.
>

 From a layman (such as myself) perspective it indeed seems totally 
ludicrous in the context of this particular license :) Whether it makes 
more sense to lawyers I wouldn't know, but as for the background: it's 
present in both 2- and 3-clause BSD licenses so *one* of them is 
probably best left alone.

According to https://fedoraproject.org/wiki/Licensing:BSD, in the 
3-clause BSD license "All rights reserved" is on a line of its own. In 
the other variants it follows the copyright holder. So that's probably 
where the duplicates originate from.

- Panu -


[dpdk-dev] [PATCH v9 08/25] drivers: convert all pdev drivers as pci drivers

2016-09-16 Thread Shreyansh Jain
Hi David,

On Monday 12 September 2016 12:46 PM, David Marchand wrote:
> On Wed, Sep 7, 2016 at 4:08 PM, Shreyansh Jain  
> wrote:
>> Simplify crypto and ethdev pci drivers init by using newly introduced
>> init macros and helpers.
>> Those drivers then don't need to register as "rte_driver"s anymore.
>>
>> Exceptions:
>> - virtio and mlx* use RTE_INIT directly as they have custom initialization
>>   steps.
>
> Afaics, we are missing some DRIVER_EXPORT_NAME for those.

I have updated this in v10 based on the patches you sent me.

>
>> - VDEV devices are not modified - they continue to use PMD_REGISTER_DRIVER.
>>
>> Signed-off-by: David Marchand 
>> Signed-off-by: Shreyansh Jain 
>
>

-
Shreyansh


[dpdk-dev] [PATCH v9 22/25] eal/pci: inherit rte_driver by rte_pci_driver

2016-09-16 Thread Shreyansh Jain
On Thursday 08 September 2016 07:55 PM, Ferruh Yigit wrote:
> On 9/7/2016 3:08 PM, Shreyansh Jain wrote:
>> Remove the 'name' member from rte_pci_driver and move to generic rte_driver.
>>
>> Most of the PMD drivers were initially using DRIVER_REGISTER_PCI(..)
>> as well as assigning a name to eth_driver.pci_drv.name member.
>> In this patch, only the original DRIVER_REGISTER_PCI(..) name has been
>> populated into the rte_driver.name member - assignments through eth_driver
>> has been removed.
>>
>> Signed-off-by: Jan Viktorin 
>> Signed-off-by: Shreyansh Jain 
>
> 
>
>> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
>> b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
>> index c0bd391..b8bfd4b 100644
>> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
>> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
>> @@ -172,4 +172,7 @@ DPDK_16.11 {
>>
>>  rte_eal_dev_attach;
>>  rte_eal_dev_detach;
>> +rte_eal_vdrv_register;
>> +rte_eal_vdrv_unregister;
>> +
>>  } DPDK_16.07;
>
> This needs to be part of patch 15, where these functions implemented.
>
> Missing these in .map files cause patch 17,18,19,20,21 fail to compile
> for shared lib config.
>

Updated the map file in Patch 16 of v10 posted. Thanks for comment.

-- 
-
Shreyansh


[dpdk-dev] [PATCH v3 12/15] ether: extract function eth_dev_get_intr_handle

2016-09-16 Thread Panu Matilainen
On 09/15/2016 05:05 PM, Thomas Monjalon wrote:
> 2016-09-15 14:02, Hunt, David:
>> On 9/9/2016 9:43 AM, Shreyansh Jain wrote:
>>> +static inline
>>> +struct rte_intr_handle *eth_dev_get_intr_handle(struct rte_eth_dev *dev)
>>> +{
>>> +   if (dev->pci_dev) {
>>> +   return >pci_dev->intr_handle;
>>> +   }
>>> +
>>> +   RTE_VERIFY(0);
>>
>> Rather than RTE_VERIFY(0), might I suggest using rte_panic with a more
>> relevant error message?
>
> RTE_ASSERT is preferred.
> We must stop adding some rte_panic calls except for debug.

+1

It wouldn't hurt to make that a hard rule.

- Panu -




[dpdk-dev] [PATCH v2] maintainers: claim responsability for crypto subtree

2016-09-16 Thread Thomas Monjalon
2016-09-16 00:25, Pablo de Lara:
> From 16.07, I will be the maintainer of the crypto subtree.
> 
> This will include:
> - app/test/test_cryptodev*
> - doc/guides/cryptodevs/
> - drivers/crypto/
> - examples/l2fwd-crypto/
> - examples/ipsec-secgw/
> - lib/librte_cryptodev/
> 
> Signed-off-by: Pablo de Lara 

Acked-by: Thomas Monjalon 

Applied, thanks for your involvement Pablo!


[dpdk-dev] [PATCH v2 1/2] eal/mempool: introduce check for external mempool availability

2016-09-16 Thread Hunt, David
Hi Hemant,

On 15/9/2016 6:13 PM, Hemant Agrawal wrote:
> External offloaded mempool may not be available always. This check enables
> run time verification of the presence of external mempool before the
> mempool ops are installed.
>
> An application built with a specific external mempool may work fine
> on host. But, may not work on VM, specificaly if non-hw specific interfaces
> are used e.g. virtio-net.
>
> This is required to make sure that same application can work in all
> environment for a given hw platform.
>
> The solution proposed here is that rte_mempool_set_ops_byname should return
> specific error in case the current execution environment is not supporting
> the given mempool. Thereby allowing it to fallback on software mempool
> implementation e.g. "ring_mp_mc"
>
> This patch introduces new optional "pool_verify" as mempool ops function
> to check if external mempool instance is available or not.

I've a small suggestion around the naming of the new functions. It seems 
to me that this patch is more about mempool handler 'support' than 
'verification'.
Could I suggest a different name for this new function? I think maybe 
"supported" may be more appropriate than "pool_verify". The return code 
that's returned when a mempool handler is not available is -EOPNOTSUPP, 
which is what suggested the word "supported" to me. I think that:

if (ops->supported)
return ops->supported(mp);

makes for slightly easier reading. The wrapper function would logically 
then be called  rte_mempool_ops_supported().


> Signed-off-by: Hemant Agrawal 
> ---
> Changes in v2:
> * fixed the pool_verify copy in rte_mempool_register_ops
> ---
>   lib/librte_mempool/rte_mempool.h   | 21 +
>   lib/librte_mempool/rte_mempool_ops.c   | 19 +++
>   lib/librte_mempool/rte_mempool_ring.c  |  4 
>   lib/librte_mempool/rte_mempool_stack.c |  3 ++-
>   4 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_mempool/rte_mempool.h 
> b/lib/librte_mempool/rte_mempool.h
> index 0243f9e..8599df1 100644
> --- a/lib/librte_mempool/rte_mempool.h
> +++ b/lib/librte_mempool/rte_mempool.h
> @@ -387,6 +387,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool 
> *mp,
>*/
>   typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
>   
> +/**
> + * Return if the given external mempool is available for this instance.
> + * it is optional to implement for mempools
> + */
> +typedef int (*rte_mempool_pool_verify)(const struct rte_mempool *mp);
> +
>   /** Structure defining mempool operations structure */
>   struct rte_mempool_ops {
>   char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */
> @@ -395,6 +401,8 @@ struct rte_mempool_ops {
>   rte_mempool_enqueue_t enqueue;   /**< Enqueue an object. */
>   rte_mempool_dequeue_t dequeue;   /**< Dequeue an object. */
>   rte_mempool_get_count get_count; /**< Get qty of available objs. */
> + rte_mempool_pool_verify pool_verify;
> + /**< Verify if external mempool is available for usages*/
>   } __rte_cache_aligned;
>   
>   #define RTE_MEMPOOL_MAX_OPS_IDX 16  /**< Max registered ops structs */
> @@ -516,6 +524,18 @@ void
>   rte_mempool_ops_free(struct rte_mempool *mp);
>   
>   /**
> + * @internal wrapper to verify the external mempool availability
> + *
> + * @param mp
> + *   Pointer to the memory pool.
> + * @return
> + *   0: Success; external mempool instance is available
> + * - <0: Error; external mempool instance is not available
> + */
> +int
> +rte_mempool_ops_pool_verify(const struct rte_mempool *mp);
> +
> +/**
>* Set the ops of a mempool.
>*
>* This can only be done on a mempool that is not populated, i.e. just after
> @@ -531,6 +551,7 @@ rte_mempool_ops_free(struct rte_mempool *mp);
>*   - 0: Success; the mempool is now using the requested ops functions.
>*   - -EINVAL - Invalid ops struct name provided.
>*   - -EEXIST - mempool already has an ops struct assigned.
> + *   - -EOPNOTSUPP  - mempool instance not available.
>*/
>   int
>   rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
> diff --git a/lib/librte_mempool/rte_mempool_ops.c 
> b/lib/librte_mempool/rte_mempool_ops.c
> index 5f24de2..c2e765f 100644
> --- a/lib/librte_mempool/rte_mempool_ops.c
> +++ b/lib/librte_mempool/rte_mempool_ops.c
> @@ -85,6 +85,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
>   ops->enqueue = h->enqueue;
>   ops->dequeue = h->dequeue;
>   ops->get_count = h->get_count;
> + ops->pool_verify = h->pool_verify;
>   
>   rte_spinlock_unlock(_mempool_ops_table.sl);
>   
> @@ -123,6 +124,18 @@ rte_mempool_ops_get_count(const struct rte_mempool *mp)
>   return ops->get_count(mp);
>   }
>   
> +/* wrapper to check if given external mempool is available for this 
> instance.*/
> +int
> +rte_mempool_ops_pool_verify(const struct rte_mempool *mp)
> +{
> + struct 

[dpdk-dev] [PATCH] remove unused ring includes

2016-09-16 Thread Thomas Monjalon
2016-08-31 10:34, Amine Kherbouche:
> This patch removes all unused  headers.
> 
> Signed-off-by: Amine Kherbouche 
[...]
> --- a/examples/performance-thread/common/lthread_int.h
> +++ b/examples/performance-thread/common/lthread_int.h
> @@ -72,7 +72,6 @@
>  #include 
>  #include 
>  #include 
> -#include 

It must be replaced by rte_memory.h for __rte_cache_aligned definition.
You didn't see it because this example is not built by default.

Applied with above fix, thanks




[dpdk-dev] [PATCH v10 25/25] eal/pci: create RTE device list and fallback on its members

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

Now that rte_device is available, drivers can start using its members
(numa, name) as well as link themselves into another rte_device list.

As of now no one is using this list, but can be used for moving over all
devices (pdev/vdev/Xdev) and perform bulk actions (like cleanup).

Signed-off-by: Jan Viktorin 
[Shreyansh: Reword commit log for extra rte_device list]
Signed-off-by: Shreyansh Jain 
---
 app/test/virtual_pmd.c  |  4 ++--
 drivers/net/fm10k/fm10k_ethdev.c|  6 +++---
 drivers/net/i40e/i40e_ethdev.c  |  6 --
 drivers/net/mlx5/mlx5.c |  2 +-
 drivers/net/virtio/virtio_pci.c |  5 +++--
 lib/librte_eal/bsdapp/eal/eal_pci.c |  2 +-
 lib/librte_eal/common/eal_common_pci.c  | 11 ++-
 lib/librte_eal/common/include/rte_pci.h |  3 +--
 lib/librte_eal/linuxapp/eal/eal_pci.c   |  7 +--
 lib/librte_ether/rte_ethdev.c   |  2 +-
 10 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 56eeb99..4831113 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -585,7 +585,7 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
if (eth_dev == NULL)
goto err;

-   pci_dev->numa_node = socket_id;
+   pci_dev->device.numa_node = socket_id;
pci_drv->driver.name = virtual_ethdev_driver_name;
pci_drv->id_table = id_table;

@@ -626,7 +626,7 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
eth_dev->dev_ops = _private->dev_ops;

eth_dev->pci_dev = pci_dev;
-   eth_dev->pci_dev->driver = _drv->pci_drv;
+   eth_dev->pci_dev->device.driver = _drv->pci_drv.driver;

eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success;
eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c6b5acd..645b8cd 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -675,7 +675,7 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev)
/* Enable use of FTAG bit in TX descriptor, PFVTCTL
 * register is read-only for VF.
 */
-   if (fm10k_check_ftag(dev->pci_dev->devargs)) {
+   if (fm10k_check_ftag(dev->pci_dev->device.devargs)) {
if (hw->mac.type == fm10k_mac_pf) {
FM10K_WRITE_REG(hw, FM10K_PFVTCTL(i),
FM10K_PFVTCTL_FTAG_DESC_ENABLE);
@@ -2731,7 +2731,7 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
int use_sse = 1;
uint16_t tx_ftag_en = 0;

-   if (fm10k_check_ftag(dev->pci_dev->devargs))
+   if (fm10k_check_ftag(dev->pci_dev->device.devargs))
tx_ftag_en = 1;

for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -2762,7 +2762,7 @@ fm10k_set_rx_function(struct rte_eth_dev *dev)
uint16_t i, rx_using_sse;
uint16_t rx_ftag_en = 0;

-   if (fm10k_check_ftag(dev->pci_dev->devargs))
+   if (fm10k_check_ftag(dev->pci_dev->device.devargs))
rx_ftag_en = 1;

/* In order to allow Vector Rx there are a few configuration
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4dfc92a..e8cf909 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -905,8 +905,10 @@ config_floating_veb(struct rte_eth_dev *dev)
memset(pf->floating_veb_list, 0, sizeof(pf->floating_veb_list));

if (hw->aq.fw_maj_ver >= FLOATING_VEB_SUPPORTED_FW_MAJ) {
-   pf->floating_veb = is_floating_veb_supported(pci_dev->devargs);
-   config_vf_floating_veb(pci_dev->devargs, pf->floating_veb,
+   pf->floating_veb =
+   is_floating_veb_supported(pci_dev->device.devargs);
+   config_vf_floating_veb(pci_dev->device.devargs,
+  pf->floating_veb,
   pf->floating_veb_list);
} else {
pf->floating_veb = false;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 063f1d0..68bdc46 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -511,7 +511,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)
priv->mtu = ETHER_MTU;
priv->mps = mps; /* Enable MPW by default if supported. */
priv->cqe_comp = 1; /* Enable compression by default. */
-   err = mlx5_args(priv, pci_dev->devargs);
+   err = mlx5_args(priv, pci_dev->device.devargs);
if (err) {
ERROR("failed to process device arguments: %s",
  strerror(err));
diff --git a/drivers/net/virtio/virtio_pci.c 

[dpdk-dev] [PATCH v10 24/25] eal: introduce generalized RTE device

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_dev.c  | 13 +
 lib/librte_eal/common/include/rte_dev.h | 31 +++
 2 files changed, 44 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index afa33fa..d1f0ad8 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -48,6 +48,9 @@
 /** Global list of device drivers. */
 static struct rte_driver_list dev_driver_list =
TAILQ_HEAD_INITIALIZER(dev_driver_list);
+/** Global list of device drivers. */
+static struct rte_device_list dev_device_list =
+   TAILQ_HEAD_INITIALIZER(dev_device_list);

 /* register a driver */
 void
@@ -63,6 +66,16 @@ rte_eal_driver_unregister(struct rte_driver *driver)
TAILQ_REMOVE(_driver_list, driver, next);
 }

+void rte_eal_device_insert(struct rte_device *dev)
+{
+   TAILQ_INSERT_TAIL(_device_list, dev, next);
+}
+
+void rte_eal_device_remove(struct rte_device *dev)
+{
+   TAILQ_REMOVE(_device_list, dev, next);
+}
+
 int
 rte_eal_dev_init(void)
 {
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 5c314bf..d159991 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -111,6 +111,37 @@ struct rte_mem_resource {

 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
+/** Double linked list of devices. */
+TAILQ_HEAD(rte_device_list, rte_device);
+
+/* Forward declaration */
+struct rte_driver;
+
+/**
+ * A structure describing a generic device.
+ */
+struct rte_device {
+   TAILQ_ENTRY(rte_device) next; /**< Next device */
+   struct rte_driver *driver;/**< Associated driver */
+   int numa_node;/**< NUMA node connection */
+   struct rte_devargs *devargs;  /**< Device user arguments */
+};
+
+/**
+ * Insert a device detected by a bus scanning.
+ *
+ * @param dev
+ *   A pointer to a rte_device structure describing the detected device.
+ */
+void rte_eal_device_insert(struct rte_device *dev);
+
+/**
+ * Remove a device (e.g. when being unplugged).
+ *
+ * @param dev
+ *   A pointer to a rte_device structure describing the device to be removed.
+ */
+void rte_eal_device_remove(struct rte_device *dev);

 /**
  * A structure describing a device driver.
-- 
2.7.4



[dpdk-dev] [PATCH v10 23/25] eal: register EAL drivers explicitly

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

To register both vdev and pci drivers into the list of all rte_driver,
we have to call rte_eal_driver_register explicitly.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_pci.c  | 2 ++
 lib/librte_eal/common/eal_common_vdev.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 79f5526..0b032d6 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -471,11 +471,13 @@ void
 rte_eal_pci_register(struct rte_pci_driver *driver)
 {
TAILQ_INSERT_TAIL(_driver_list, driver, next);
+   rte_eal_driver_register(>driver);
 }

 /* unregister a driver */
 void
 rte_eal_pci_unregister(struct rte_pci_driver *driver)
 {
+   rte_eal_driver_unregister(>driver);
TAILQ_REMOVE(_driver_list, driver, next);
 }
diff --git a/lib/librte_eal/common/eal_common_vdev.c 
b/lib/librte_eal/common/eal_common_vdev.c
index 1a4dec6..6dab782 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -48,12 +48,14 @@ void
 rte_eal_vdrv_register(struct rte_vdev_driver *driver)
 {
TAILQ_INSERT_TAIL(_driver_list, driver, next);
+   rte_eal_driver_register(>driver);
 }

 /* unregister a driver */
 void
 rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
 {
+   rte_eal_driver_unregister(>driver);
TAILQ_REMOVE(_driver_list, driver, next);
 }

-- 
2.7.4



[dpdk-dev] [PATCH v10 22/25] eal/pci: inherit RTE driver in PCI driver

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

Remove the 'name' member from rte_pci_driver and move to generic
rte_driver.

Most of the PMD drivers were initially using DRIVER_REGISTER_PCI(..)
as well as assigning a name to eth_driver.pci_drv.name member.
In this patch, only the original DRIVER_REGISTER_PCI(..) name has
been populated into the rte_driver.name member - assignments through
eth_driver has been removed.

Signed-off-by: Jan Viktorin 
[Shreyansh: Rebase and expand changes to newly added files]
Signed-off-by: Shreyansh Jain 
---
 app/test/test_pci.c | 10 +++---
 app/test/virtual_pmd.c  |  2 +-
 drivers/crypto/qat/qat_qp.c |  2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c|  2 --
 drivers/net/bnx2x/bnx2x_rxtx.c  |  3 ++-
 drivers/net/bnxt/bnxt_ethdev.c  |  1 -
 drivers/net/cxgbe/cxgbe_ethdev.c|  1 -
 drivers/net/cxgbe/sge.c |  7 ---
 drivers/net/e1000/em_ethdev.c   |  1 -
 drivers/net/e1000/igb_ethdev.c  |  2 --
 drivers/net/ena/ena_ethdev.c|  1 -
 drivers/net/enic/enic_ethdev.c  |  1 -
 drivers/net/fm10k/fm10k_ethdev.c|  1 -
 drivers/net/i40e/i40e_ethdev.c  |  1 -
 drivers/net/i40e/i40e_ethdev_vf.c   |  1 -
 drivers/net/i40e/i40e_fdir.c|  2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c|  2 --
 drivers/net/mlx4/mlx4.c |  4 +++-
 drivers/net/mlx5/mlx5.c |  4 +++-
 drivers/net/nfp/nfp_net.c   |  5 ++---
 drivers/net/qede/qede_ethdev.c  |  2 --
 drivers/net/szedata2/rte_eth_szedata2.c |  1 -
 drivers/net/thunderx/nicvf_ethdev.c |  1 -
 drivers/net/virtio/virtio_ethdev.c  |  3 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c|  4 ++--
 drivers/net/vmxnet3/vmxnet3_rxtx.c  |  2 +-
 lib/librte_cryptodev/rte_cryptodev.c|  4 ++--
 lib/librte_eal/common/eal_common_pci.c  |  4 ++--
 lib/librte_eal/common/include/rte_pci.h |  4 ++--
 lib/librte_ether/rte_ethdev.c   |  6 +++---
 30 files changed, 37 insertions(+), 47 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index f1b988a..cda186d 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -78,14 +78,18 @@ struct rte_pci_id my_driver_id2[] = {
 };

 struct rte_pci_driver my_driver = {
-   .name = "test_driver",
+   .driver = {
+   .name = "test_driver"
+   },
.probe = my_driver_init,
.id_table = my_driver_id,
.drv_flags = 0,
 };

 struct rte_pci_driver my_driver2 = {
-   .name = "test_driver2",
+   .driver = {
+   .name = "test_driver2"
+   },
.probe = my_driver_init,
.id_table = my_driver_id2,
.drv_flags = 0,
@@ -95,7 +99,7 @@ static int
 my_driver_init(__attribute__((unused)) struct rte_pci_driver *dr,
   struct rte_pci_device *dev)
 {
-   printf("My driver init called in %s\n", dr->name);
+   printf("My driver init called in %s\n", dr->driver.name);
printf("%x:%x:%x.%d", dev->addr.domain, dev->addr.bus,
   dev->addr.devid, dev->addr.function);
printf(" - vendor:%x device:%x\n", dev->id.vendor_id, 
dev->id.device_id);
diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 8a1f0d0..56eeb99 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -586,7 +586,7 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
goto err;

pci_dev->numa_node = socket_id;
-   pci_drv->name = virtual_ethdev_driver_name;
+   pci_drv->driver.name = virtual_ethdev_driver_name;
pci_drv->id_table = id_table;

if (isr_support)
diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index 5de47e3..2e7188b 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -300,7 +300,7 @@ qat_queue_create(struct rte_cryptodev *dev, struct 
qat_queue *queue,
 * Allocate a memzone for the queue - create a unique name.
 */
snprintf(queue->memz_name, sizeof(queue->memz_name), "%s_%s_%d_%d_%d",
-   dev->driver->pci_drv.name, "qp_mem", dev->data->dev_id,
+   dev->driver->pci_drv.driver.name, "qp_mem", dev->data->dev_id,
queue->hw_bundle_number, queue->hw_queue_number);
qp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes,
socket_id);
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 4bd5142..a576ef6 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -618,7 +618,6 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)

 static struct eth_driver rte_bnx2x_pmd = {
.pci_drv = {
-   .name = "rte_bnx2x_pmd",
.id_table = pci_id_bnx2x_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
.probe = rte_eth_dev_pci_probe,
@@ -633,7 

[dpdk-dev] [PATCH v10 21/25] eal: rename and move RTE PCI Resources

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

There is no need to have a custom memory resource representation for
each infrastructure (PCI, ...) as it would always have the same members.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 drivers/net/szedata2/rte_eth_szedata2.c |  4 ++--
 lib/librte_eal/common/include/rte_dev.h |  8 
 lib/librte_eal/common/include/rte_pci.h | 12 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/szedata2/rte_eth_szedata2.c 
b/drivers/net/szedata2/rte_eth_szedata2.c
index bbf97a2..ad5f74c 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1416,7 +1416,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
int ret;
uint32_t szedata2_index;
struct rte_pci_addr *pci_addr = >pci_dev->addr;
-   struct rte_pci_resource *pci_rsc =
+   struct rte_mem_resource *pci_rsc =
>pci_dev->mem_resource[PCI_RESOURCE_NUMBER];
char rsc_filename[PATH_MAX];
void *pci_resource_ptr = NULL;
@@ -1473,7 +1473,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)

rte_eth_copy_pci_info(dev, dev->pci_dev);

-   /* mmap pci resource0 file to rte_pci_resource structure */
+   /* mmap pci resource0 file to rte_mem_resource structure */
if (dev->pci_dev->mem_resource[PCI_RESOURCE_NUMBER].phys_addr ==
0) {
RTE_LOG(ERR, PMD, "Missing resource%u file\n",
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 3d0d2b8..5c314bf 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -100,6 +100,14 @@ rte_pmd_debug_trace(const char *func_name, const char 
*fmt, ...)
} \
 } while (0)

+/**
+ * A generic memory resource representation.
+ */
+struct rte_mem_resource {
+   uint64_t phys_addr; /**< Physical address, 0 if not resource. */
+   uint64_t len;   /**< Length of the resource. */
+   void *addr; /**< Virtual address, NULL when not mapped. */
+};

 /** Double linked list of device drivers. */
 TAILQ_HEAD(rte_driver_list, rte_driver);
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index bb03d41..67f6ee7 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -108,15 +108,6 @@ const char *pci_get_sysfs_path(void);
 /** Nb. of values in PCI resource format. */
 #define PCI_RESOURCE_FMT_NVAL 3

-/**
- * A structure describing a PCI resource.
- */
-struct rte_pci_resource {
-   uint64_t phys_addr;   /**< Physical address, 0 if no resource. */
-   uint64_t len; /**< Length of the resource. */
-   void *addr;   /**< Virtual address, NULL when not mapped. */
-};
-
 /** Maximum number of PCI resources. */
 #define PCI_MAX_RESOURCE 6

@@ -160,7 +151,8 @@ struct rte_pci_device {
TAILQ_ENTRY(rte_pci_device) next;   /**< Next probed PCI device. */
struct rte_pci_addr addr;   /**< PCI location. */
struct rte_pci_id id;   /**< PCI ID. */
-   struct rte_pci_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI 
Memory Resource */
+   struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+   /**< PCI Memory Resource */
struct rte_intr_handle intr_handle; /**< Interrupt handle */
struct rte_pci_driver *driver;  /**< Associated driver */
uint16_t max_vfs;   /**< sriov enable if not zero */
-- 
2.7.4



[dpdk-dev] [PATCH v10 20/25] eal: include dev headers in place of PCI headers

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

Further refactoring and generalization of PCI infrastructure will
require access to the rte_dev.h contents.

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

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index e1f695f..bb03d41 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -84,6 +84,7 @@ extern "C" {

 #include 
 #include 
+#include 

 TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */
 TAILQ_HEAD(pci_driver_list, rte_pci_driver); /**< PCI drivers in D-linked Q. */
-- 
2.7.4



[dpdk-dev] [PATCH v10 19/25] eal: remove unused PMD types

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

- All devices register themselfs by calling a kind of DRIVER_REGISTER_XXX.
  The PMD_REGISTER_DRIVER is not used anymore.
- PMD_VDEV type is also not being used - can be removed from all VDEVs.

Note: PMD_REGISTER_DRIVER usage by PMDINFO tool and its documentation has
  not yet been removed.

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   |  3 ---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c |  3 ---
 drivers/crypto/kasumi/rte_kasumi_pmd.c |  3 ---
 drivers/crypto/null/null_crypto_pmd.c  |  3 ---
 drivers/crypto/snow3g/rte_snow3g_pmd.c |  3 ---
 drivers/net/af_packet/rte_eth_af_packet.c  |  3 ---
 drivers/net/bonding/rte_eth_bond_pmd.c |  3 ---
 drivers/net/mpipe/mpipe_tilegx.c   |  6 --
 drivers/net/null/rte_eth_null.c|  3 ---
 drivers/net/pcap/rte_eth_pcap.c|  3 ---
 drivers/net/ring/rte_eth_ring.c|  3 ---
 drivers/net/vhost/rte_eth_vhost.c  |  3 ---
 drivers/net/virtio/virtio_user_ethdev.c|  3 ---
 drivers/net/xenvirt/rte_eth_xenvirt.c  |  3 ---
 lib/librte_eal/common/include/rte_dev.h| 18 --
 15 files changed, 63 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c 
b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index c93ebfe..fc939fa 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -515,9 +515,6 @@ aesni_gcm_uninit(const char *name)
 }

 static struct rte_vdev_driver aesni_gcm_pmd_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = aesni_gcm_init,
.uninit = aesni_gcm_uninit
 };
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 30c0706..2047269 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -715,9 +715,6 @@ cryptodev_aesni_mb_uninit(const char *name)
 }

 static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = cryptodev_aesni_mb_init,
.uninit = cryptodev_aesni_mb_uninit
 };
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c 
b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index ba2829d..d1b0b99 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -651,9 +651,6 @@ cryptodev_kasumi_uninit(const char *name)
 }

 static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = cryptodev_kasumi_init,
.uninit = cryptodev_kasumi_uninit
 };
diff --git a/drivers/crypto/null/null_crypto_pmd.c 
b/drivers/crypto/null/null_crypto_pmd.c
index 4c12faa..bd139b4 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -269,9 +269,6 @@ cryptodev_null_uninit(const char *name)
 }

 static struct rte_vdev_driver cryptodev_null_pmd_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = cryptodev_null_init,
.uninit = cryptodev_null_uninit
 };
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c 
b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 10c6b83..c46d7e5 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -639,9 +639,6 @@ cryptodev_snow3g_uninit(const char *name)
 }

 static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = cryptodev_snow3g_init,
.uninit = cryptodev_snow3g_uninit
 };
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index 9a9a2ee..810ec48 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -890,9 +890,6 @@ rte_pmd_af_packet_devuninit(const char *name)
 }

 static struct rte_vdev_driver pmd_af_packet_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = rte_pmd_af_packet_devinit,
.uninit = rte_pmd_af_packet_devuninit
 };
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5fa2a93..1496cdf 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2509,9 +2509,6 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 }

 static struct rte_vdev_driver bond_drv = {
-   .driver = {
-   .type = PMD_VDEV,
-   },
.init = bond_init,
.uninit = bond_uninit
 };
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index efb000b..9382bcf 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1624,16 +1624,10 @@ rte_pmd_mpipe_devinit(const char *ifname,
 }

 static struct rte_vdev_driver pmd_mpipe_xgbe_drv = {
-   .driver = {
-  

[dpdk-dev] [PATCH v10 18/25] drivers: convert VDRV to use RTE VDEV Driver

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

All PMD_VDEV drivers can now use rte_vdev_driver instead of the
rte_driver (which is embedded in the rte_vdev_driver).

Signed-off-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   | 10 ++
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 10 ++
 drivers/crypto/kasumi/rte_kasumi_pmd.c | 10 ++
 drivers/crypto/null/null_crypto_pmd.c  | 10 ++
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 10 ++
 drivers/net/af_packet/rte_eth_af_packet.c  | 12 +++-
 drivers/net/bonding/rte_eth_bond_pmd.c | 12 +++-
 drivers/net/mpipe/mpipe_tilegx.c   | 22 +-
 drivers/net/null/rte_eth_null.c| 12 +++-
 drivers/net/pcap/rte_eth_pcap.c| 12 +++-
 drivers/net/ring/rte_eth_ring.c| 12 +++-
 drivers/net/vhost/rte_eth_vhost.c  | 12 +++-
 drivers/net/virtio/virtio_user_ethdev.c| 11 +++
 drivers/net/xenvirt/rte_eth_xenvirt.c  | 12 +++-
 lib/librte_eal/common/eal_common_vdev.c|  4 ++--
 lib/librte_eal/common/include/rte_dev.h| 12 
 lib/librte_eal/common/include/rte_vdev.h   | 12 
 17 files changed, 113 insertions(+), 82 deletions(-)

diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c 
b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index dc0b033..c93ebfe 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 

@@ -514,13 +514,15 @@ aesni_gcm_uninit(const char *name)
return 0;
 }

-static struct rte_driver aesni_gcm_pmd_drv = {
-   .type = PMD_VDEV,
+static struct rte_vdev_driver aesni_gcm_pmd_drv = {
+   .driver = {
+   .type = PMD_VDEV,
+   },
.init = aesni_gcm_init,
.uninit = aesni_gcm_uninit
 };

-PMD_REGISTER_DRIVER(aesni_gcm_pmd_drv, CRYPTODEV_NAME_AESNI_GCM_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_GCM_PMD, aesni_gcm_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_GCM_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index b2d0c8c..30c0706 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 

@@ -714,13 +714,15 @@ cryptodev_aesni_mb_uninit(const char *name)
return 0;
 }

-static struct rte_driver cryptodev_aesni_mb_pmd_drv = {
-   .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_aesni_mb_pmd_drv = {
+   .driver = {
+   .type = PMD_VDEV,
+   },
.init = cryptodev_aesni_mb_init,
.uninit = cryptodev_aesni_mb_uninit
 };

-PMD_REGISTER_DRIVER(cryptodev_aesni_mb_pmd_drv, CRYPTODEV_NAME_AESNI_MB_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_AESNI_MB_PMD, cryptodev_aesni_mb_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_AESNI_MB_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd.c 
b/drivers/crypto/kasumi/rte_kasumi_pmd.c
index 4e21743..ba2829d 100644
--- a/drivers/crypto/kasumi/rte_kasumi_pmd.c
+++ b/drivers/crypto/kasumi/rte_kasumi_pmd.c
@@ -35,7 +35,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 

@@ -650,13 +650,15 @@ cryptodev_kasumi_uninit(const char *name)
return 0;
 }

-static struct rte_driver cryptodev_kasumi_pmd_drv = {
-   .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
+   .driver = {
+   .type = PMD_VDEV,
+   },
.init = cryptodev_kasumi_init,
.uninit = cryptodev_kasumi_uninit
 };

-PMD_REGISTER_DRIVER(cryptodev_kasumi_pmd_drv, CRYPTODEV_NAME_KASUMI_PMD);
+DRIVER_REGISTER_VDEV(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd_drv);
 DRIVER_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
"max_nb_queue_pairs= "
"max_nb_sessions= "
diff --git a/drivers/crypto/null/null_crypto_pmd.c 
b/drivers/crypto/null/null_crypto_pmd.c
index 909b04f..4c12faa 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -33,7 +33,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 

 #include "null_crypto_pmd_private.h"
@@ -268,13 +268,15 @@ cryptodev_null_uninit(const char *name)
return 0;
 }

-static struct rte_driver cryptodev_null_pmd_drv = {
-   .type = PMD_VDEV,
+static struct rte_vdev_driver cryptodev_null_pmd_drv = {
+   .driver = {
+   .type = PMD_VDEV,
+   },
.init = cryptodev_null_init,
.uninit = cryptodev_null_uninit
 };

-PMD_REGISTER_DRIVER(cryptodev_null_pmd_drv, CRYPTODEV_NAME_NULL_PMD);

[dpdk-dev] [PATCH v10 17/25] eal: remove PDEV/VDEV unused code

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

- Remove checks for VDEV from rte_eal_vdev_(init/uninint) as all devices
  are inherently virtual here.
- PDEVs perform PCI specific inits - rte_eal_dev_init() need not call
  rte_driver->init();

Signed-off-by: Jan Viktorin 
[Shreyansh: Reword commit log]
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_dev.c  | 8 
 lib/librte_eal/common/eal_common_vdev.c | 6 --
 2 files changed, 14 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 555e0d9..afa33fa 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -67,7 +67,6 @@ int
 rte_eal_dev_init(void)
 {
struct rte_devargs *devargs;
-   struct rte_driver *driver;

/*
 * Note that the dev_driver_list is populated here
@@ -89,13 +88,6 @@ rte_eal_dev_init(void)
}
}

-   /* Once the vdevs are initalized, start calling all the pdev drivers */
-   TAILQ_FOREACH(driver, _driver_list, next) {
-   if (driver->type != PMD_PDEV)
-   continue;
-   /* PDEV drivers don't get passed any parameters */
-   driver->init(NULL, NULL);
-   }
return 0;
 }

diff --git a/lib/librte_eal/common/eal_common_vdev.c 
b/lib/librte_eal/common/eal_common_vdev.c
index 462517f..67cb397 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -66,9 +66,6 @@ rte_eal_vdev_init(const char *name, const char *args)
return -EINVAL;

TAILQ_FOREACH(driver, _driver_list, next) {
-   if (driver->driver.type != PMD_VDEV)
-   continue;
-
/*
 * search a driver prefix in virtual device name.
 * For example, if the driver is pcap PMD, driver->name
@@ -93,9 +90,6 @@ rte_eal_vdev_uninit(const char *name)
return -EINVAL;

TAILQ_FOREACH(driver, _driver_list, next) {
-   if (driver->driver.type != PMD_VDEV)
-   continue;
-
/*
 * search a driver prefix in virtual device name.
 * For example, if the driver is pcap PMD, driver->name
-- 
2.7.4



[dpdk-dev] [PATCH v10 16/25] eal: extract vdev infra

2016-09-16 Thread Shreyansh Jain
From: Jan Viktorin 

Move all PMD_VDEV-specific code into a separate module and header
file to not polute the generic code anymore. There is now a list
of virtual devices available.

The rte_vdev_driver integrates the original rte_driver inside
(C inheritance). The rte_driver will be however change in the
future to serve as a common base for all other types of drivers.

The existing PMDs (PMD_VDEV) are to be modified later (there is
no change for them at the moment).

Unlike DRIVER_REGISTER_PCI, DRIVER_EXPORT_NAME is not being called on vdev
registration.

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

---
Changes since v9:
 - Add DRIVER_EXPORT_NAME() to DRIVER_REGISTER_* macro.
   Patch for change from David Marchand 
---
 lib/librte_eal/bsdapp/eal/Makefile  |   1 +
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   3 +
 lib/librte_eal/common/Makefile  |   2 +-
 lib/librte_eal/common/eal_common_dev.c  |  54 +---
 lib/librte_eal/common/eal_common_vdev.c | 112 
 lib/librte_eal/common/include/rte_vdev.h|  85 ++
 lib/librte_eal/linuxapp/eal/Makefile|   1 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   3 +
 8 files changed, 207 insertions(+), 54 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_vdev.c
 create mode 100644 lib/librte_eal/common/include/rte_vdev.h

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 7a0fea5..5a3fc1d 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -69,6 +69,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memzone.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_log.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_launch.c
+SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_vdev.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_pci_uio.c
 SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_common_memory.c
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 7b3d409..ec61017 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -168,4 +168,7 @@ DPDK_16.11 {

rte_eal_dev_attach;
rte_eal_dev_detach;
+   rte_eal_vdrv_register;
+   rte_eal_vdrv_unregister;
+
 } DPDK_16.07;
diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index bb9810d..dfd64aa 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -38,7 +38,7 @@ INC += rte_per_lcore.h rte_random.h
 INC += rte_tailq.h rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_version.h
 INC += rte_eal_memconfig.h rte_malloc_heap.h
-INC += rte_hexdump.h rte_devargs.h rte_dev.h
+INC += rte_hexdump.h rte_devargs.h rte_dev.h rte_vdev.h
 INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h
 INC += rte_malloc.h rte_keepalive.h rte_time.h

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 88f9d3f..555e0d9 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -64,32 +64,6 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_vdev_init(const char *name, const char *args)
-{
-   struct rte_driver *driver;
-
-   if (name == NULL)
-   return -EINVAL;
-
-   TAILQ_FOREACH(driver, _driver_list, next) {
-   if (driver->type != PMD_VDEV)
-   continue;
-
-   /*
-* search a driver prefix in virtual device name.
-* For example, if the driver is pcap PMD, driver->name
-* will be "eth_pcap", but "name" will be "eth_pcapN".
-* So use strncmp to compare.
-*/
-   if (!strncmp(driver->name, name, strlen(driver->name)))
-   return driver->init(name, args);
-   }
-
-   RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-   return -EINVAL;
-}
-
-int
 rte_eal_dev_init(void)
 {
struct rte_devargs *devargs;
@@ -98,7 +72,7 @@ rte_eal_dev_init(void)
/*
 * Note that the dev_driver_list is populated here
 * from calls made to rte_eal_driver_register from constructor functions
-* embedded into PMD modules via the PMD_REGISTER_DRIVER macro
+* embedded into PMD modules via the DRIVER_REGISTER_VDEV macro
 */

/* call the init function for each virtual device */
@@ -125,32 +99,6 @@ rte_eal_dev_init(void)
return 0;
 }

-int
-rte_eal_vdev_uninit(const char *name)
-{
-   struct rte_driver *driver;
-
-   if (name == NULL)
-   return -EINVAL;
-
-   TAILQ_FOREACH(driver, _driver_list, next) {
-   if 

[dpdk-dev] [PATCH v10 15/25] ethdev: get rid of device type

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Now that hotplug has been moved to eal, there is no reason to keep the
device type in this layer.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 app/test/virtual_pmd.c|  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c|  2 +-
 drivers/net/cxgbe/cxgbe_main.c|  2 +-
 drivers/net/mlx4/mlx4.c   |  2 +-
 drivers/net/mlx5/mlx5.c   |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c  |  2 +-
 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/vhost/rte_eth_vhost.c |  2 +-
 drivers/net/virtio/virtio_user_ethdev.c   |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c |  2 +-
 examples/ip_pipeline/init.c   | 22 --
 lib/librte_ether/rte_ethdev.c |  5 ++---
 lib/librte_ether/rte_ethdev.h | 15 +--
 16 files changed, 16 insertions(+), 52 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index b4bd2f2..8a1f0d0 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -581,7 +581,7 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
goto err;

/* reserve an ethdev entry */
-   eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+   eth_dev = rte_eth_dev_allocate(name);
if (eth_dev == NULL)
goto err;

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index f795566..d629ee3 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -666,7 +666,7 @@ rte_pmd_init_internals(const char *name,
}

/* reserve an ethdev entry */
-   *eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+   *eth_dev = rte_eth_dev_allocate(name);
if (*eth_dev == NULL)
goto error;

diff --git a/drivers/net/bonding/rte_eth_bond_api.c 
b/drivers/net/bonding/rte_eth_bond_api.c
index 203ebe9..8514652 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -189,7 +189,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
}

/* reserve an ethdev entry */
-   eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+   eth_dev = rte_eth_dev_allocate(name);
if (eth_dev == NULL) {
RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
goto err;
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index ceaf5ab..922155b 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -1150,7 +1150,7 @@ int cxgbe_probe(struct adapter *adapter)
 */

/* reserve an ethdev entry */
-   pi->eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+   pi->eth_dev = rte_eth_dev_allocate(name);
if (!pi->eth_dev)
goto out_free;

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index ebb55b2..172ff86 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5803,7 +5803,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)

snprintf(name, sizeof(name), "%s port %u",
 ibv_get_device_name(ibv_dev), port);
-   eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+   eth_dev = rte_eth_dev_allocate(name);
}
if (eth_dev == NULL) {
ERROR("can not allocate rte ethdev");
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 42d7fa8..f1bc7a1 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -617,7 +617,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct 
rte_pci_device *pci_dev)

snprintf(name, sizeof(name), "%s port %u",
 ibv_get_device_name(ibv_dev), port);
-   eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+   eth_dev = rte_eth_dev_allocate(name);
}
if (eth_dev == NULL) {
ERROR("can not allocate rte ethdev");
diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 93f8730..c0d0e3b 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1587,7 +1587,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
return -ENODEV;
}

-   eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+   eth_dev = rte_eth_dev_allocate(ifname);
if (!eth_dev) {
RTE_LOG(ERR, PMD, "%s: Failed 

[dpdk-dev] [PATCH v10 14/25] ethdev: convert to EAL hotplug

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the
  application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some
mechanism to inform applications of port creation/removal to substitute
for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as
is, but this information is not needed anymore and is removed in the
following commit.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 

--
v10:
 - Update incorrect language of log message
 - Checkpatch issues fixed
---
 lib/librte_ether/rte_ethdev.c | 207 +++---
 1 file changed, 35 insertions(+), 172 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 3ef5c84..bec0c2c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;

 /* spinlock for eth device callbacks */
@@ -216,6 +217,7 @@ rte_eth_dev_allocate(const char *name, enum 
rte_eth_dev_type type)
eth_dev->data->port_id = port_id;
eth_dev->attached = DEV_ATTACHED;
eth_dev->dev_type = type;
+   eth_dev_last_created_port = port_id;
nb_ports++;
return eth_dev;
 }
@@ -347,27 +349,6 @@ rte_eth_dev_count(void)
return nb_ports;
 }

-static enum rte_eth_dev_type
-rte_eth_dev_get_device_type(uint8_t port_id)
-{
-   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, RTE_ETH_DEV_UNKNOWN);
-   return rte_eth_devices[port_id].dev_type;
-}
-
-static int
-rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
-{
-   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
-
-   if (addr == NULL) {
-   RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-   return -EINVAL;
-   }
-
-   *addr = rte_eth_devices[port_id].pci_dev->addr;
-   return 0;
-}
-
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
@@ -413,34 +394,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t 
*port_id)
 }

 static int
-rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id)
-{
-   int i;
-   struct rte_pci_device *pci_dev = NULL;
-
-   if (addr == NULL) {
-   RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-   return -EINVAL;
-   }
-
-   *port_id = RTE_MAX_ETHPORTS;
-
-   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-
-   pci_dev = rte_eth_devices[i].pci_dev;
-
-   if (pci_dev &&
-   !rte_eal_compare_pci_addr(_dev->addr, addr)) {
-
-   *port_id = i;
-
-   return 0;
-   }
-   }
-   return -ENODEV;
-}
-
-static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
uint32_t dev_flags;
@@ -465,124 +418,49 @@ rte_eth_dev_is_detachable(uint8_t port_id)
return 1;
 }

-/* attach the new physical device, then store port_id of the device */
-static int
-rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
+/* attach the new device, then store port_id of the device */
+int
+rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-   /* Invoke probe func of the driver can handle the new device. */
-   if (rte_eal_pci_probe_one(addr))
-   goto err;
+   int ret = -1;
+   int current = eth_dev_last_created_port;
+   char *name = NULL;
+   char *args = NULL;

-   if (rte_eth_dev_get_port_by_addr(addr, port_id))
+   if ((devargs == NULL) || (port_id == NULL)) {
+   ret = -EINVAL;
goto err;
+   }

-   return 0;
-err:
-   return -1;
-}
-
-/* detach the new physical device, then store pci_addr of the device */
-static int
-rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr)
-{
-   struct rte_pci_addr freed_addr;
-   struct rte_pci_addr vp;
-
-   /* get pci address by port id */
-   if (rte_eth_dev_get_addr_by_port(port_id, _addr))
+   /* parse devargs, then retrieve device name and args */
+   if (rte_eal_parse_devargs_str(devargs, , ))
goto err;

-   /* Zeroed pci addr means the port comes from virtual device */
-   vp.domain = vp.bus = vp.devid = vp.function = 0;
-   if (rte_eal_compare_pci_addr(, _addr) == 0)
+   ret = rte_eal_dev_attach(name, args);
+   if (ret < 0)
goto err;

-   /* invoke remove func of the pci driver,
-* also remove the device from pci_device_list */
-   if 

[dpdk-dev] [PATCH v10 13/25] eal: add hotplug operations for PCI and VDEV

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Hotplug invocations, which deals with devices, should come from the layer
that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus
that will handle the request.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 
 lib/librte_eal/common/eal_common_dev.c  | 48 +
 lib/librte_eal/common/include/rte_dev.h | 26 ++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 
 4 files changed, 88 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index a335e04..7b3d409 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -162,3 +162,10 @@ DPDK_16.07 {
rte_thread_setname;

 } DPDK_16.04;
+
+DPDK_16.11 {
+   global:
+
+   rte_eal_dev_attach;
+   rte_eal_dev_detach;
+} DPDK_16.07;
diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index a8a4146..88f9d3f 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -150,3 +150,51 @@ 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;
+
+   if (name == NULL || devargs == NULL) {
+   RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
+   return -EINVAL;
+   }
+
+   if (eal_parse_pci_DomBDF(name, ) == 0) {
+   if (rte_eal_pci_probe_one() < 0)
+   goto err;
+
+   } else {
+   if (rte_eal_vdev_init(name, devargs))
+   goto err;
+   }
+
+   return 0;
+
+err:
+   RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", name);
+   return -EINVAL;
+}
+
+int rte_eal_dev_detach(const char *name)
+{
+   struct rte_pci_addr addr;
+
+   if (name == NULL) {
+   RTE_LOG(ERR, EAL, "Invalid device provided.\n");
+   return -EINVAL;
+   }
+
+   if (eal_parse_pci_DomBDF(name, ) == 0) {
+   if (rte_eal_pci_detach() < 0)
+   goto err;
+   } else {
+   if (rte_eal_vdev_uninit(name))
+   goto err;
+   }
+   return 0;
+
+err:
+   RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", name);
+   return -EINVAL;
+}
diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 94ae14e..6cc9b01 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -178,6 +178,32 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);

+/**
+ * Attach a device to a registered driver.
+ *
+ * @param name
+ *   The device name, that refers to a pci device (or some private
+ *   way of designating a vdev device). Based on this device name, eal
+ *   will identify a driver capable of handling it and pass it 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 device from its driver.
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[]

 #define DRIVER_EXPORT_NAME(name, idx) \
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index db8c984..c0bd391 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -166,3 +166,10 @@ DPDK_16.07 {
rte_thread_setname;

 } DPDK_16.04;
+
+DPDK_16.11 {
+   global:
+
+   rte_eal_dev_attach;
+   rte_eal_dev_detach;
+} DPDK_16.07;
-- 
2.7.4



[dpdk-dev] [PATCH v10 12/25] ethdev: do not scan all PCI devices on attach

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

No need to scan all devices, we only need to update the device being
attached.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_common_pci.c | 12 +---
 lib/librte_ether/rte_ethdev.c  |  3 ---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index db8cba0..bef7ee8 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -341,6 +341,12 @@ 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_update_device(addr) < 0)
+   goto err_return;
+
TAILQ_FOREACH(dev, _device_list, next) {
if (rte_eal_compare_pci_addr(>addr, addr))
continue;
@@ -353,9 +359,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_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e80cab4..3ef5c84 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -469,9 +469,6 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-   /* re-construct pci_device_list */
-   if (rte_eal_pci_scan())
-   goto err;
/* Invoke probe func of the driver can handle the new device. */
if (rte_eal_pci_probe_one(addr))
goto err;
-- 
2.7.4



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

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

- Move rte_eth_dev_create_unique_device_name() from ether/rte_ethdev.c to
  common/include/rte_pci.h as rte_eal_pci_device_name(). Being a common
  method, can be used across crypto/net PCI PMDs.
- Remove crypto specific routine and fallback to common name function.
- Introduce a eal private Update function for PCI device naming.

Signed-off-by: David Marchand 
[Shreyansh: Merge crypto/pci helper patches]
Signed-off-by: Shreyansh Jain 
---
 lib/librte_cryptodev/rte_cryptodev.c| 27 +++---
 lib/librte_eal/bsdapp/eal/eal_pci.c | 49 +
 lib/librte_eal/common/eal_private.h | 13 +
 lib/librte_eal/common/include/rte_pci.h | 24 
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +
 lib/librte_ether/rte_ethdev.c   | 24 +++-
 6 files changed, 107 insertions(+), 43 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index 2a3b649..c81e366 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -365,23 +365,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
return cryptodev;
 }

-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-   struct rte_pci_device *pci_dev)
-{
-   int ret;
-
-   if ((name == NULL) || (pci_dev == NULL))
-   return -EINVAL;
-
-   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_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -444,9 +427,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
if (cryptodrv == NULL)
return -ENODEV;

-   /* Create unique Crypto device name using PCI address */
-   rte_cryptodev_create_unique_device_name(cryptodev_name,
-   sizeof(cryptodev_name), pci_dev);
+   rte_eal_pci_device_name(_dev->addr, cryptodev_name,
+   sizeof(cryptodev_name));

cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
if (cryptodev == NULL)
@@ -501,9 +483,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
if (pci_dev == NULL)
return -EINVAL;

-   /* Create unique device name using PCI address */
-   rte_cryptodev_create_unique_device_name(cryptodev_name,
-   sizeof(cryptodev_name), pci_dev);
+   rte_eal_pci_device_name(_dev->addr, cryptodev_name,
+   sizeof(cryptodev_name));

cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
if (cryptodev == NULL)
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index a73cbb0..1d91c78 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -406,6 +406,55 @@ error:
return -1;
 }

+int
+pci_update_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 ca1aec6..431d6c2 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -130,6 +130,19 @@ struct rte_pci_driver;
 struct rte_pci_device;

 /**
+ * Update a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param 

[dpdk-dev] [PATCH v10 10/25] drivers: remove driver register callbacks for crypto/net

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Now that all pdev are pci drivers, we don't need to register crypto and
ethdev drivers through a dedicated channel.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_cryptodev/rte_cryptodev.c   | 23 
 lib/librte_cryptodev/rte_cryptodev_pmd.h   | 30 --
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 -
 lib/librte_ether/rte_ethdev.c  | 22 ---
 lib/librte_ether/rte_ethdev.h  | 12 ---
 lib/librte_ether/rte_ether_version.map |  1 -
 6 files changed, 89 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index 910c841..2a3b649 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -533,29 +533,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
return 0;
 }

-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-   enum pmd_type type)
-{
-   /* Call crypto device initialization directly if device is virtual */
-   if (type == PMD_VDEV)
-   return rte_cryptodev_pci_probe(
-   (struct rte_pci_driver *)cryptodrv,
-   NULL);
-
-   /*
-* Register PCI driver for physical device intialisation during
-* PCI probing
-*/
-   cryptodrv->pci_drv.probe = rte_cryptodev_pci_probe;
-   cryptodrv->pci_drv.remove = rte_cryptodev_pci_remove;
-
-   rte_eal_pci_register(>pci_drv);
-
-   return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h 
b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 450a376..abfe2dc 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -493,36 +493,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, 
size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);

-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- * a - register itself as PCI driver if the crypto device is a physical
- * device, by invoking the rte_eal_pci_register() function to
- * register the *pci_drv* structure embedded in the *crypto_drv*
- * structure, after having stored the address of the
- * rte_cryptodev_init() function in the *probe* field of the
- * *pci_drv* structure.
- *
- * During the PCI probing phase, the rte_cryptodev_init()
- * function is invoked for each PCI [device] matching the
- * embedded PCI identifiers provided by the driver.
- *
- * b, complete the initialization sequence if the device is a virtual
- * device by calling the rte_cryptodev_init() directly passing a
- * NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv crypto_driver structure associated with the crypto
- * driver.
- *   @param type   pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-   enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map 
b/lib/librte_cryptodev/rte_cryptodev_version.map
index 1fc0d57..9627ac4 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -14,7 +14,6 @@ DPDK_16.04 {
rte_cryptodev_info_get;
rte_cryptodev_pmd_allocate;
rte_cryptodev_pmd_callback_process;
-   rte_cryptodev_pmd_driver_register;
rte_cryptodev_pmd_release_device;
rte_cryptodev_pmd_virtual_dev_init;
rte_cryptodev_sym_session_create;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f534967..11eecaf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -340,28 +340,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
return 0;
 }

-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver.
- * Invokes the rte_eal_pci_register() function to register the *pci_drv*
- * structure embedded in the *eth_drv* structure, after having stored the
- * address of the rte_eth_dev_init() function in the *probe* field of
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_init() function is
- * invoked for each PCI [Ethernet device] 

[dpdk-dev] [PATCH v10 09/25] drivers: convert all phy drivers as PCI drivers

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Simplify crypto and ethdev pci drivers init by using newly introduced
init macros and helpers.
Those drivers then don't need to register as "rte_driver"s anymore.

Exceptions:
- virtio and mlx* use RTE_INIT directly as they have custom initialization
  steps.
- VDEV devices are not modified - they continue to use PMD_REGISTER_DRIVER.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
Changes since v9:
 - Add DRIVER_EXPORT_NAME to DRIVER_REGISTER_PCI
 - For mlx4/mlx5/virtio_ethdev, use DRIVER_EXPORT_NAME directly as they
   don't use DRIVER_REGISTER_PCI
 - Modify PMDINFO matching from PMD_REGISTER_* to DRIVER_REGISTER_*
 All changes above suggested by David Marchand 
 - Change PCI devinit/devuninit to prove/remove
---
 drivers/crypto/qat/rte_qat_cryptodev.c  | 16 +++-
 drivers/net/bnx2x/bnx2x_ethdev.c| 34 +---
 drivers/net/bnxt/bnxt_ethdev.c  | 16 +++-
 drivers/net/cxgbe/cxgbe_ethdev.c| 24 +++--
 drivers/net/e1000/em_ethdev.c   | 16 +++-
 drivers/net/e1000/igb_ethdev.c  | 39 +---
 drivers/net/ena/ena_ethdev.c| 17 +++-
 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 | 16 +++-
 drivers/net/mlx5/mlx5.c | 15 +++
 drivers/net/nfp/nfp_net.c   | 21 +++
 drivers/net/qede/qede_ethdev.c  | 40 ++--
 drivers/net/szedata2/rte_eth_szedata2.c | 24 +++--
 drivers/net/thunderx/nicvf_ethdev.c | 20 +++---
 drivers/net/virtio/virtio_ethdev.c  | 26 ++-
 drivers/net/vmxnet3/vmxnet3_ethdev.c| 23 +++--
 mk/internal/rte.compile-pre.mk  |  2 +-
 21 files changed, 82 insertions(+), 408 deletions(-)

diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c 
b/drivers/crypto/qat/rte_qat_cryptodev.c
index 1e9e0ba..170ae78 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -116,23 +116,13 @@ static struct rte_cryptodev_driver rte_qat_pmd = {
.pci_drv = {
.id_table = pci_id_qat_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .probe = rte_cryptodev_pci_probe,
+   .remove = rte_cryptodev_pci_remove,
},
.cryptodev_init = crypto_qat_dev_init,
.dev_private_size = sizeof(struct qat_pmd_private),
 };

-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);
-}
-
-static struct rte_driver pmd_qat_drv = {
-   .type = PMD_PDEV,
-   .init = rte_qat_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(pmd_qat_drv, CRYPTODEV_NAME_QAT_SYM_PMD);
+DRIVER_REGISTER_PCI(CRYPTODEV_NAME_QAT_SYM_PMD, rte_qat_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(CRYPTODEV_NAME_QAT_SYM_PMD, pci_id_qat_map);

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index f3ab355..4bd5142 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -621,6 +621,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,
+   .probe = rte_eth_dev_pci_probe,
+   .remove = rte_eth_dev_pci_remove,
},
.eth_dev_init = eth_bnx2x_dev_init,
.dev_private_size = sizeof(struct bnx2x_softc),
@@ -634,38 +636,14 @@ static struct eth_driver rte_bnx2xvf_pmd = {
.name = "rte_bnx2xvf_pmd",
.id_table = pci_id_bnx2xvf_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .probe = rte_eth_dev_pci_probe,
+   .remove = 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)
-{
-   PMD_INIT_FUNC_TRACE();
-   rte_eth_driver_register(_bnx2x_pmd);
-
-   return 0;
-}
-
-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);
-
-   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,
-   

[dpdk-dev] [PATCH v10 08/25] driver: init/uninit common wrappers for PCI drivers

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

crypto and ethdev drivers aligned to PCI probe/remove. These wrappers are
mapped directly to PCI resources.
Existing handlers for init/uninit can be easily reused for this.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_cryptodev/rte_cryptodev.c   | 17 +
 lib/librte_cryptodev/rte_cryptodev_pmd.h   | 12 
 lib/librte_cryptodev/rte_cryptodev_version.map |  7 +++
 lib/librte_ether/rte_ethdev.c  | 14 +++---
 lib/librte_ether/rte_ethdev.h  | 13 +
 lib/librte_ether/rte_ether_version.map |  9 +
 6 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index dca368d..910c841 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -429,9 +429,9 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t 
dev_private_size,
return cryptodev;
 }

-static int
-rte_cryptodev_init(struct rte_pci_driver *pci_drv,
-   struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+   struct rte_pci_device *pci_dev)
 {
struct rte_cryptodev_driver *cryptodrv;
struct rte_cryptodev *cryptodev;
@@ -490,8 +490,8 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
return -ENXIO;
 }

-static int
-rte_cryptodev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 {
const struct rte_cryptodev_driver *cryptodrv;
struct rte_cryptodev *cryptodev;
@@ -539,15 +539,16 @@ rte_cryptodev_pmd_driver_register(struct 
rte_cryptodev_driver *cryptodrv,
 {
/* Call crypto device initialization directly if device is virtual */
if (type == PMD_VDEV)
-   return rte_cryptodev_init((struct rte_pci_driver *)cryptodrv,
+   return rte_cryptodev_pci_probe(
+   (struct rte_pci_driver *)cryptodrv,
NULL);

/*
 * Register PCI driver for physical device intialisation during
 * PCI probing
 */
-   cryptodrv->pci_drv.probe = rte_cryptodev_init;
-   cryptodrv->pci_drv.remove = rte_cryptodev_uninit;
+   cryptodrv->pci_drv.probe = rte_cryptodev_pci_probe;
+   cryptodrv->pci_drv.remove = rte_cryptodev_pci_remove;

rte_eal_pci_register(>pci_drv);

diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h 
b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 9a9174f..450a376 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -536,6 +536,18 @@ rte_cryptodev_pmd_driver_register(struct 
rte_cryptodev_driver *crypto_drv,
 void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
enum rte_cryptodev_event_type event);

+/**
+ * Wrapper for use by pci drivers as a .probe function to attach to a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+   struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .remove function to detach a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev);

 #ifdef __cplusplus
 }
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map 
b/lib/librte_cryptodev/rte_cryptodev_version.map
index a08fd20..1fc0d57 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -39,3 +39,10 @@ DPDK_16.07 {
rte_cryptodev_parse_vdev_init_params;

 } DPDK_16.04;
+
+DPDK_16.11 {
+   global:
+
+   rte_cryptodev_pci_probe;
+   rte_cryptodev_pci_remove;
+} DPDK_16.07;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index d07348e..f534967 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -245,9 +245,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
return 0;
 }

-static int
-rte_eth_dev_init(struct rte_pci_driver *pci_drv,
-struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+ struct rte_pci_device *pci_dev)
 {
struct eth_driver*eth_drv;
struct rte_eth_dev *eth_dev;
@@ -299,8 +299,8 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
return diag;
 }

-static int
-rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 {
const struct eth_driver *eth_drv;
struct rte_eth_dev *eth_dev;
@@ -357,8 +357,8 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 void
 rte_eth_driver_register(struct eth_driver *eth_drv)
 {
-   eth_drv->pci_drv.probe = rte_eth_dev_init;
-   eth_drv->pci_drv.remove = 

[dpdk-dev] [PATCH v10 07/25] eal: introduce PCI device init macros

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Introduce a RTE_INIT macro used to mark an init function as a constructor.
Current eal macros have been converted to use this (no functional impact).
DRIVER_REGISTER_PCI is added as a helper for pci drivers.

Suggested-by: Jan Viktorin 
Signed-off-by: David Marchand 
[Shreyansh: Update PCI Registration macro name]
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/include/rte_dev.h   |  4 ++--
 lib/librte_eal/common/include/rte_eal.h   |  3 +++
 lib/librte_eal/common/include/rte_pci.h   | 10 ++
 lib/librte_eal/common/include/rte_tailq.h |  4 ++--
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index 8233a2a..94ae14e 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -185,8 +185,8 @@ static const char DRIVER_EXPORT_NAME_ARRAY(this_pmd_name, 
idx) \
 __attribute__((used)) = RTE_STR(name)

 #define PMD_REGISTER_DRIVER(drv, nm)\
-void probefn_ ##drv(void);\
-void __attribute__((constructor, used)) probefn_ ##drv(void)\
+RTE_INIT(probefn_ ##drv);\
+static void probefn_ ##drv(void)\
 {\
(drv).name = RTE_STR(nm);\
rte_eal_driver_register();\
diff --git a/lib/librte_eal/common/include/rte_eal.h 
b/lib/librte_eal/common/include/rte_eal.h
index 98d20db..d150b9d 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -253,6 +253,9 @@ static inline int rte_gettid(void)
return RTE_PER_LCORE(_thread_id);
 }

+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 803c78a..cf81898 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -470,6 +470,16 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);

+/** Helper for PCI device registration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, pci_drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{\
+   (pci_drv).name = RTE_STR(nm);\
+   rte_eal_pci_register(_drv); \
+} \
+DRIVER_EXPORT_NAME(nm, __COUNTER__)
+
 /**
  * Unregister a PCI driver.
  *
diff --git a/lib/librte_eal/common/include/rte_tailq.h 
b/lib/librte_eal/common/include/rte_tailq.h
index cc3c0f1..cc386e4 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char 
*name);
 int rte_eal_tailq_register(struct rte_tailq_elem *t);

 #define EAL_REGISTER_TAILQ(t) \
-void tailqinitfn_ ##t(void); \
-void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
+RTE_INIT(tailqinitfn_ ##t); \
+static void tailqinitfn_ ##t(void) \
 { \
if (rte_eal_tailq_register() < 0) \
rte_panic("Cannot initialize tailq: %s\n", t.name); \
-- 
2.7.4



[dpdk-dev] [PATCH v10 06/25] drivers: align PCI driver definitions

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

Pure coding style, but it might make it easier later if we want to move
fields in rte_cryptodev_driver and eth_driver structures.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 drivers/crypto/qat/rte_qat_cryptodev.c | 2 +-
 drivers/net/ena/ena_ethdev.c   | 2 +-
 drivers/net/nfp/nfp_net.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c 
b/drivers/crypto/qat/rte_qat_cryptodev.c
index 82ab047..1e9e0ba 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -113,7 +113,7 @@ crypto_qat_dev_init(__attribute__((unused)) struct 
rte_cryptodev_driver *crypto_
 }

 static struct rte_cryptodev_driver rte_qat_pmd = {
-   {
+   .pci_drv = {
.id_table = pci_id_qat_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
},
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index ac0803d..9418d50 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1685,7 +1685,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct 
rte_mbuf **tx_pkts,
 }

 static struct eth_driver rte_ena_pmd = {
-   {
+   .pci_drv = {
.name = "rte_ena_pmd",
.id_table = pci_id_ena_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 82e3e4e..99a258a 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -2459,7 +2459,7 @@ static struct rte_pci_id pci_id_nfp_net_map[] = {
 };

 static struct eth_driver rte_nfp_net_pmd = {
-   {
+   .pci_drv = {
.name = "rte_nfp_net_pmd",
.id_table = pci_id_nfp_net_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
-- 
2.7.4



[dpdk-dev] [PATCH v10 05/25] crypto: no need for a crypto pmd type

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

This information is not used and just adds noise.

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_cryptodev/rte_cryptodev.c | 8 +++-
 lib/librte_cryptodev/rte_cryptodev.h | 2 --
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 3 +--
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index da5ad73..dca368d 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -319,7 +319,7 @@ rte_cryptodev_find_free_device_index(void)
 }

 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
+rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 {
struct rte_cryptodev *cryptodev;
uint8_t dev_id;
@@ -358,7 +358,6 @@ rte_cryptodev_pmd_allocate(const char *name, enum pmd_type 
type, int socket_id)
cryptodev->data->dev_started = 0;

cryptodev->attached = RTE_CRYPTODEV_ATTACHED;
-   cryptodev->pmd_type = type;

cryptodev_globals.nb_devs++;
}
@@ -407,7 +406,7 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t 
dev_private_size,
struct rte_cryptodev *cryptodev;

/* allocate device structure */
-   cryptodev = rte_cryptodev_pmd_allocate(name, PMD_VDEV, socket_id);
+   cryptodev = rte_cryptodev_pmd_allocate(name, socket_id);
if (cryptodev == NULL)
return NULL;

@@ -449,8 +448,7 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
rte_cryptodev_create_unique_device_name(cryptodev_name,
sizeof(cryptodev_name), pci_dev);

-   cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, PMD_PDEV,
-   rte_socket_id());
+   cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
if (cryptodev == NULL)
return -ENOMEM;

diff --git a/lib/librte_cryptodev/rte_cryptodev.h 
b/lib/librte_cryptodev/rte_cryptodev.h
index d047ba8..1555678 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -620,8 +620,6 @@ struct rte_cryptodev {

enum rte_cryptodev_type dev_type;
/**< Crypto device type */
-   enum pmd_type pmd_type;
-   /**< PMD type - PDEV / VDEV */

struct rte_cryptodev_cb_list link_intr_cbs;
/**< User application callback for interrupts if present */
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h 
b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 130290e..9a9174f 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -456,13 +456,12 @@ struct rte_cryptodev_ops {
  * to that slot for the driver to use.
  *
  * @param  nameUnique identifier name for each device
- * @param  typeDevice type of this Crypto device
  * @param  socket_id   Socket to allocate resources on.
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int 
socket_id);
+rte_cryptodev_pmd_allocate(const char *name, int socket_id);

 /**
  * Creates a new virtual crypto device and returns the pointer
-- 
2.7.4



[dpdk-dev] [PATCH v10 04/25] eal/pci: replace PCI devinit/devuninit with probe/remove

2016-09-16 Thread Shreyansh Jain
Probe and Remove are more appropriate names for PCI init and uninint
operations. This is a cosmetic change.

Only MLX* uses the PCI direct registeration, bypassing PMD_* macro. The
calls backs for this too have been updated.

VDEV are left out. For them, init/uninit are more appropriate.

Suggested-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 app/test/test_pci.c  |  8 
 drivers/net/mlx4/mlx4.c  |  4 ++--
 drivers/net/mlx5/mlx5.c  |  4 ++--
 lib/librte_cryptodev/rte_cryptodev.c |  4 ++--
 lib/librte_cryptodev/rte_cryptodev_pmd.h |  2 +-
 lib/librte_eal/common/eal_common_pci.c   | 16 
 lib/librte_eal/common/include/rte_dev.h  |  4 ++--
 lib/librte_eal/common/include/rte_pci.h  | 10 +-
 lib/librte_ether/rte_ethdev.c|  8 
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 69f78d9..f1b988a 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -52,11 +52,11 @@
  * PCI test
  * 
  *
- * - Register a driver with a ``devinit()`` function.
+ * - Register a driver with a ``probe()`` function.
  *
  * - Dump all PCI devices.
  *
- * - Check that the ``devinit()`` function is called at least once.
+ * - Check that the ``probe()`` function is called at least once.
  */

 int test_pci_run = 0; /* value checked by the multiprocess test */
@@ -79,14 +79,14 @@ struct rte_pci_id my_driver_id2[] = {

 struct rte_pci_driver my_driver = {
.name = "test_driver",
-   .devinit = my_driver_init,
+   .probe = my_driver_init,
.id_table = my_driver_id,
.drv_flags = 0,
 };

 struct rte_pci_driver my_driver2 = {
.name = "test_driver2",
-   .devinit = my_driver_init,
+   .probe = my_driver_init,
.id_table = my_driver_id2,
.drv_flags = 0,
 };
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 304c846..5c709ee 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5544,7 +5544,7 @@ static struct eth_driver mlx4_driver;
  *   0 on success, negative errno value on failure.
  */
 static int
-mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device 
*pci_dev)
+mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 {
struct ibv_device **list;
struct ibv_device *ibv_dev;
@@ -5913,7 +5913,7 @@ static struct eth_driver mlx4_driver = {
.pci_drv = {
.name = MLX4_DRIVER_NAME,
.id_table = mlx4_pci_id_map,
-   .devinit = mlx4_pci_devinit,
+   .probe = mlx4_pci_probe,
.drv_flags = RTE_PCI_DRV_INTR_LSC,
},
.dev_private_size = sizeof(struct priv)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index d96a9af..7768231 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -355,7 +355,7 @@ static struct eth_driver mlx5_driver;
  *   0 on success, negative errno value on failure.
  */
 static int
-mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device 
*pci_dev)
+mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 {
struct ibv_device **list;
struct ibv_device *ibv_dev;
@@ -730,7 +730,7 @@ static struct eth_driver mlx5_driver = {
.pci_drv = {
.name = MLX5_DRIVER_NAME,
.id_table = mlx5_pci_id_map,
-   .devinit = mlx5_pci_devinit,
+   .probe = mlx5_pci_probe,
.drv_flags = RTE_PCI_DRV_INTR_LSC,
},
.dev_private_size = sizeof(struct priv)
diff --git a/lib/librte_cryptodev/rte_cryptodev.c 
b/lib/librte_cryptodev/rte_cryptodev.c
index fc4123b..da5ad73 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -548,8 +548,8 @@ rte_cryptodev_pmd_driver_register(struct 
rte_cryptodev_driver *cryptodrv,
 * Register PCI driver for physical device intialisation during
 * PCI probing
 */
-   cryptodrv->pci_drv.devinit = rte_cryptodev_init;
-   cryptodrv->pci_drv.devuninit = rte_cryptodev_uninit;
+   cryptodrv->pci_drv.probe = rte_cryptodev_init;
+   cryptodrv->pci_drv.remove = rte_cryptodev_uninit;

rte_eal_pci_register(>pci_drv);

diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h 
b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index cd46674..130290e 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -505,7 +505,7 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev 
*cryptodev);
  * device, by invoking the rte_eal_pci_register() function to
  * register the *pci_drv* structure embedded in the *crypto_drv*
  * structure, after having stored the address of the
- * rte_cryptodev_init() function in the *devinit* field of the
+ * rte_cryptodev_init() 

[dpdk-dev] [PATCH v10 03/25] pci: no need for dynamic tailq init

2016-09-16 Thread Shreyansh Jain
From: 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 
Reviewed-by: Jan Viktorin 
Signed-off-by: Shreyansh Jain 
---
 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 374b68f..a73cbb0 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -623,9 +623,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 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 7248c38..6a0f6ac 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);

 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index cd9de7c..f0215ee 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -743,9 +743,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 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;
-- 
2.7.4



[dpdk-dev] [PATCH v10 02/25] eal: remove duplicate function declaration

2016-09-16 Thread Shreyansh Jain
From: David Marchand 

rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its
introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes: e57f20e05177 ("eal: make vdev init path generic for both virtual and pci 
devices")

Signed-off-by: David Marchand 
Signed-off-by: Shreyansh Jain 
---
 lib/librte_eal/common/eal_private.h | 7 ---
 lib/librte_eal/linuxapp/eal/eal.c   | 1 +
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 19f7535..ca1aec6 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -237,13 +237,6 @@ int rte_eal_intr_init(void);
 int rte_eal_alarm_init(void);

 /**
- * This function initialises any virtual devices
- *
- * This function is private to the EAL.
- */
-int rte_eal_dev_init(void);
-
-/**
  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
  * etc.) loaded.
  *
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index d5b81a3..9412983 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.7.4



  1   2   >