[dpdk-dev] [PATCH v2] virtio: fix crash loading virtio driver when devargs isn't specified

2016-06-13 Thread Huawei Xie
We skip kernel managed virtio devices, if it isn't whitelisted.
Before checking if the virtio device is whitelisted, check if devargs is
specified.

Fixes: ac5e1d838dc1 ("virtio: skip error when probing kernel managed device")

Signed-off-by: Huawei Xie 
Reported-by: Vincent Li 
---
v2: - add reported-by
- reword subject
- reword commit message
---
 drivers/net/virtio/virtio_pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index d0f2428..60ec4da 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -626,6 +626,7 @@ next:
  * Return -1:
  *   if there is error mapping with VFIO/UIO.
  *   if port map error when driver type is KDRV_NONE.
+ *   if whitelisted but driver type is KDRV_UNKNOWN.
  * Return 1 if kernel driver is managing the device.
  * Return 0 on success.
  */
@@ -651,7 +652,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw,
PMD_INIT_LOG(INFO, "trying with legacy virtio pci.");
if (legacy_virtio_resource_init(dev, hw, dev_flags) < 0) {
if (dev->kdrv == RTE_KDRV_UNKNOWN &&
-   dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) {
+   (!dev->devargs ||
+dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)) {
PMD_INIT_LOG(INFO,
"skip kernel managed virtio device.");
return 1;
-- 
1.8.1.4



[dpdk-dev] [PATCH v4 0/4] app/test: rework crypto AES unit test

2016-06-13 Thread Thomas Monjalon
> Fan Zhang (4):
>   app/test: categorize crypto AES test vectors into new file
>   app/test: add unified crypto aes test
>   app/test: utilize new unified crypto AES test function
>   app/test: add crypto AES-CBC-128 HMAC-SHA224 and HMAC-SHA384 unit
> tests

My first comment on v1 was:
"
The first three patches have no real meaning separately.
As they move and rework some code, it is better to not split
with some patches which add code from nowhere and others which
remove old code.
Please squash.
"

Do you agree I squash the first 3 patches?

Any other reviewer for this big patchset?



[dpdk-dev] [PATCH v2] test: fix mempool perf test enq_count wraparound of 32-bit uint

2016-06-13 Thread Thomas Monjalon
> > recent CPU's can easily wrap around a 32-bit unsigned int in
> > the mempool perf test. Increase to a 64-bit uint.
> > 
> > v2: change from %lu to %"PRIu64"
> > 
> > Signed-off-by: David Hunt 
> 
> Acked-by: Olivier Matz 

Applied, thanks


[dpdk-dev] [PATCH] app/test: fix bond device name too long

2016-06-13 Thread Thomas Monjalon
> > Bond device name was too long (grather than 32 signs) that cause mempool
> > allocation to fail.
> > 
> > Fixes: 92073ef961ee ("bond: unit tests")
> > 
> > Signed-off-by: Michal Jastrzebski 
> 
> Acked-by: Bernard Iremonger

Applied, thanks


[dpdk-dev] [PATCH] app/test: fix array overflow warning with gcc 4.5

2016-06-13 Thread Thomas Monjalon
2016-06-09 13:14, Tomasz Kulasek:
> DPDK/app/test/test_cryptodev.c: In function ?create_snow3g_cipher_operation
> _oop.clone.15?: DPDK/x86_64-native-linuxapp-gcc/include/rte_memcpy.h:796:14
> error: array subscript is above array bounds.
> 
> In test_cryptodev.c:
> 2429  rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
> 
> When iv_len is declared as 'unsigned int', rte_memcpy evaluates code for
> buffer size bigger than 255, but while 'iv' array is 64 bytes long, it
> causes 'above array bounds' warning in gcc 4.5 and breaks compilation.
> 
> Using uint8_t as a size of copied block prevents to evaluate in rte_memcpy
> code for length bigger than 255, causing the problem.
> 
> The root of this issue and solution is the same as for commit 2c007ea10616
> ("app/test: fix array overflow warning with gcc 4.5")
> 
> Fixes: 9727af14b032 ("app/test: add out-of-place symmetric crypto
>operations")
> 
> Signed-off-by: Tomasz Kulasek 

Applied, thanks


[dpdk-dev] [PATCH v5 00/10] Include resources in tests

2016-06-13 Thread Thomas Monjalon
> Jan Viktorin (10):
>   app/test: introduce resources for tests
>   mk: define objcopy-specific target and arch
>   app/test: support resources externally linked
>   app/test: add functions to create files from resources
>   app/test: support resources archived by tar
>   app/test: use linked list to store PCI drivers
>   app/test: extract test_pci_setup and test_pci_cleanup
>   app/test: convert current pci_test into a single test case
>   eal/pci: allow to override sysfs
>   app/test: do not dump PCI devices in blacklist test

Applied, thanks


[dpdk-dev] [PATCH] vhost: remove internal lockless enqueue

2016-06-13 Thread Huawei Xie
All other DPDK PMDs doesn't support concurrent receiving or sending
packets to the same queue. The upper application should deal with
this, normally through queue and core bindings.

Due to historical reason, vhost internally supports concurrent lockless
enqueuing packets to the same virtio queue through costly cmpset operation.
This patch removes this internal lockless implementation and should improve
performance a bit.

Luckily DPDK OVS doesn't rely on this behavior.

Signed-off-by: Huawei Xie 
---
 doc/guides/rel_notes/release_16_07.rst |   3 +
 lib/librte_vhost/rte_virtio_net.h  |   3 +-
 lib/librte_vhost/vhost_rxtx.c  | 106 +++--
 lib/librte_vhost/virtio-net.c  |   1 -
 4 files changed, 24 insertions(+), 89 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..e96250f 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -112,6 +112,9 @@ API Changes
* Add a short 1-2 sentence description of the API change. Use fixed width
  quotes for ``rte_function_names`` or ``rte_struct_names``. Use the past 
tense.

+* The function ``rte_vhost_enqueue_burst`` no longer supports concurrent 
enqueuing
+  packets to the same queue.
+
 * The following counters are removed from ``rte_eth_stats`` structure:
   ibadcrc, ibadlen, imcasts, fdirmatch, fdirmiss,
   tx_pause_xon, rx_pause_xon, tx_pause_xoff, rx_pause_xoff.
diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 600b20b..dbba24e 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -88,7 +88,6 @@ struct vhost_virtqueue {
uint32_tbackend;/**< Backend value to 
determine if device should started/stopped. */
uint16_tvhost_hlen; /**< Vhost header 
length (varies depending on RX merge buffers. */
volatile uint16_t   last_used_idx;  /**< Last index used on 
the available ring */
-   volatile uint16_t   last_used_idx_res;  /**< Used for multiple 
devices reserving buffers. */
 #define VIRTIO_INVALID_EVENTFD (-1)
 #define VIRTIO_UNINITIALIZED_EVENTFD   (-2)
int callfd; /**< Used to notify the 
guest (trigger interrupt). */
@@ -192,7 +191,7 @@ rte_vring_available_entries(struct virtio_net *dev, 
uint16_t queue_id)
if (!vq->enabled)
return 0;

-   return *(volatile uint16_t *)>avail->idx - vq->last_used_idx_res;
+   return *(volatile uint16_t *)>avail->idx - vq->last_used_idx;
 }

 /**
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 750821a..3fa75cb 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -205,49 +205,6 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
return 0;
 }

-/*
- * As many data cores may want to access available buffers
- * they need to be reserved.
- */
-static inline uint32_t
-reserve_avail_buf(struct vhost_virtqueue *vq, uint32_t count,
- uint16_t *start, uint16_t *end)
-{
-   uint16_t res_start_idx;
-   uint16_t res_end_idx;
-   uint16_t avail_idx;
-   uint16_t free_entries;
-   int success;
-
-   count = RTE_MIN(count, (uint32_t)MAX_PKT_BURST);
-
-again:
-   res_start_idx = vq->last_used_idx_res;
-   avail_idx = *((volatile uint16_t *)>avail->idx);
-
-   free_entries = avail_idx - res_start_idx;
-   count = RTE_MIN(count, free_entries);
-   if (count == 0)
-   return 0;
-
-   res_end_idx = res_start_idx + count;
-
-   /*
-* update vq->last_used_idx_res atomically; try again if failed.
-*
-* TODO: Allow to disable cmpset if no concurrency in application.
-*/
-   success = rte_atomic16_cmpset(>last_used_idx_res,
- res_start_idx, res_end_idx);
-   if (unlikely(!success))
-   goto again;
-
-   *start = res_start_idx;
-   *end   = res_end_idx;
-
-   return count;
-}
-
 /**
  * This function adds buffers to the virtio devices RX virtqueue. Buffers can
  * be received from the physical port or from another virtio device. A packet
@@ -260,7 +217,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
  struct rte_mbuf **pkts, uint32_t count)
 {
struct vhost_virtqueue *vq;
-   uint16_t res_start_idx, res_end_idx;
+   uint16_t avail_idx, free_entries, res_start_idx;
uint16_t desc_indexes[MAX_PKT_BURST];
uint32_t i;

@@ -276,13 +233,19 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
if (unlikely(vq->enabled == 0))
return 0;

-   count = reserve_avail_buf(vq, count, _start_idx, _end_idx);
+
+   count = RTE_MIN(count, (uint32_t)MAX_PKT_BURST);
+   avail_idx = 

[dpdk-dev] Performance hit - NICs on different CPU sockets

2016-06-13 Thread Wiles, Keith

On 6/13/16, 9:07 AM, "dev on behalf of Take Ceara"  wrote:

>Hi,
>
>I'm reposting here as I didn't get any answers on the dpdk-users mailing list.
>
>We're working on a stateful traffic generator (www.warp17.net) using
>DPDK and we would like to control two XL710 NICs (one on each socket)
>to maximize CPU usage. It looks that we run into the following
>limitation:
>
>http://dpdk.org/doc/guides/linux_gsg/nic_perf_intel_platform.html
>section 7.2, point 3
>
>We completely split memory/cpu/NICs across the two sockets. However,
>the performance with a single CPU and both NICs on the same socket is
>better.
>Why do all the NICs have to be on the same socket, is there a
>driver/hw limitation?

Normally the limitation is in the hardware, basically how the PCI bus is 
connected to the CPUs (or sockets). How the PCI buses are connected to the 
system depends on the Mother board design. I normally see the buses attached to 
socket 0, but you could have some of the buses attached to the other sockets or 
all on one socket via a PCI bridge device.

No easy way around the problem if some of your PCI buses are split or all on a 
single socket. Need to look at your system docs or look at lspci it has an 
option to dump the PCI bus as an ASCII tree, at least on Ubuntu.
>
>Thanks,
>Dumitru Ceara
>





[dpdk-dev] [PATCH] config: thunderx: select maximum supported numa nodes and lcores

2016-06-13 Thread Jerin Jacob
ThunderX platform can support dual sockets numa configuration and 48
cores per socket.

Signed-off-by: Jerin Jacob 
---
 config/defconfig_arm64-thunderx-linuxapp-gcc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/config/defconfig_arm64-thunderx-linuxapp-gcc 
b/config/defconfig_arm64-thunderx-linuxapp-gcc
index 7940bbd..a5b1e24 100644
--- a/config/defconfig_arm64-thunderx-linuxapp-gcc
+++ b/config/defconfig_arm64-thunderx-linuxapp-gcc
@@ -34,6 +34,8 @@
 CONFIG_RTE_MACHINE="thunderx"

 CONFIG_RTE_CACHE_LINE_SIZE=128
+CONFIG_RTE_MAX_NUMA_NODES=2
+CONFIG_RTE_MAX_LCORE=96

 #
 # Compile Cavium Thunderx NICVF PMD driver
-- 
2.5.5



[dpdk-dev] [PATCH v4 19/19] maintainers: claim responsibility for the ThunderX nicvf PMD

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3e8558f..625423f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -336,6 +336,12 @@ M: Sony Chacko 
 F: drivers/net/qede/
 F: doc/guides/nics/qede.rst

+Cavium ThunderX nicvf
+M: Jerin Jacob 
+M: Maciej Czekaj 
+F: drivers/net/thunderx/
+F: doc/guides/nics/thunderx.rst
+
 RedHat virtio
 M: Huawei Xie 
 M: Yuanhan Liu 
-- 
2.5.5



[dpdk-dev] [PATCH v4 18/19] net/thunderx: updated driver documentation and release notes

2016-06-13 Thread Jerin Jacob
Updated doc/guides/nics/overview.rst, doc/guides/nics/thunderx.rst
and release notes

Changed "*" to "P" in overview.rst to capture the partially supported
feature as "*" creating alignment issues with Sphinx table

Signed-off-by: Jerin Jacob 
Signed-off-by: Slawomir Rosek 
Acked-by: John McNamara 
---
 doc/guides/nics/index.rst  |   1 +
 doc/guides/nics/overview.rst   |  96 -
 doc/guides/nics/thunderx.rst   | 354 +
 doc/guides/rel_notes/release_16_07.rst |   1 +
 4 files changed, 404 insertions(+), 48 deletions(-)
 create mode 100644 doc/guides/nics/thunderx.rst

diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 0b13698..ddf75f4 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -50,6 +50,7 @@ Network Interface Controller Drivers
 nfp
 qede
 szedata2
+thunderx
 virtio
 vhost
 vmxnet3
diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index 0bd8fae..df28510 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -74,40 +74,40 @@ Most of these differences are summarized below.

 .. table:: Features availability in networking drivers

-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = =
-   Feature  a b b b c e e e i i i i i i i i i i f f f f m m m n n 
p q q r s v v v v x
-f n n o x 1 n n 4 4 4 4 g g x x x x m m m m l l p f u 
c e e i z h i i m e
-p x x n g 0 a i 0 0 0 0 b b g g g g 1 1 1 1 x x i p l 
a d d n e o r r x n
-a 2 2 d b 0   c e e e e   v b b b b 0 0 0 0 4 5 p   l 
p e e g d s t t n v
-c x x i e 0   . v v   f e e e e k k k k e  
   v   a t i i e i
-k   v n   . f f   . v v   . v v
   f   t   o o t r
-e   f g   .   .   . f f   . f f
   a . 3 t
-t v   v   v   v   v   v
   2 v
-  e   e   e   e   e   e
 e
-  c   c   c   c   c   c
 c
-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = =
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = = =
+   Feature  a b b b c e e e i i i i i i i i i i f f f f m m m n n 
p q q r s t v v v v x
+f n n o x 1 n n 4 4 4 4 g g x x x x m m m m l l p f u 
c e e i z h h i i m e
+p x x n g 0 a i 0 0 0 0 b b g g g g 1 1 1 1 x x i p l 
a d d n e u o r r x n
+a 2 2 d b 0   c e e e e   v b b b b 0 0 0 0 4 5 p   l 
p e e g d n s t t n v
+c x x i e 0   . v v   f e e e e k k k k e  
   v   a d t i i e i
+k   v n   . f f   . v v   . v v
   f   t e   o o t r
+e   f g   .   .   . f f   . f f
   a r . 3 t
+t v   v   v   v   v   v
   2 x v
+  e   e   e   e   e   e
   e
+  c   c   c   c   c   c
   c
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = = =
Speed capabilities
-   Link statusY Y   Y Y   Y Y Y Y   Y Y Y Y Y Y
 Y Y   Y Y Y Y
-   Link status event  Y Y Y Y Y Y   Y Y Y Y
 Y Y Y
-   Queue status event  
 Y
+   Link statusY Y   Y Y   Y Y Y Y   Y Y Y Y Y Y
 Y Y   Y Y Y Y Y
+   Link status event  Y Y Y Y Y Y   Y Y Y Y
 Y Y Y Y
+   Queue status event  
   Y
Rx interrupt   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
-   Queue start/stop Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y   Y Y
-   MTU update   Y Y Y   Y   Y Y Y Y Y Y
-   Jumbo frame  Y Y Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y   
Y Y Y
-   Scattered Rx Y Y Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y   Y
+   Queue start/stop Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y Y   Y Y
+   MTU update   Y Y Y   Y   Y Y Y Y Y Y
 Y
+   Jumbo frame  Y Y Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y   
Y Y Y Y
+   Scattered Rx Y Y Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 

[dpdk-dev] [PATCH v4 17/19] net/thunderx: add device start, stop and close support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 467 
 1 file changed, 467 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 3c88290..7d545f9 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -69,6 +69,8 @@
 #include "nicvf_rxtx.h"
 #include "nicvf_logs.h"

+static void nicvf_dev_stop(struct rte_eth_dev *dev);
+
 static inline int
 nicvf_atomic_write_link_status(struct rte_eth_dev *dev,
   struct rte_eth_link *link)
@@ -534,6 +536,82 @@ nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq 
*sq, uint16_t qidx,
return 0;
 }

+static int
+nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
+{
+   struct nicvf_rbdr *rbdr;
+   const struct rte_memzone *rz;
+   uint32_t ring_size;
+
+   assert(nic->rbdr == NULL);
+   rbdr = rte_zmalloc_socket("rbdr", sizeof(struct nicvf_rbdr),
+ RTE_CACHE_LINE_SIZE, nic->node);
+   if (rbdr == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr");
+   return -ENOMEM;
+   }
+
+   ring_size = sizeof(struct rbdr_entry_t) * desc_cnt;
+   rz = rte_eth_dma_zone_reserve(nic->eth_dev, "rbdr", 0, ring_size,
+  NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
+   if (rz == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr desc ring");
+   return -ENOMEM;
+   }
+
+   memset(rz->addr, 0, ring_size);
+
+   rbdr->phys = rz->phys_addr;
+   rbdr->tail = 0;
+   rbdr->next_tail = 0;
+   rbdr->desc = rz->addr;
+   rbdr->buffsz = buffsz;
+   rbdr->qlen_mask = desc_cnt - 1;
+   rbdr->rbdr_status =
+   nicvf_qset_base(nic, 0) + NIC_QSET_RBDR_0_1_STATUS0;
+   rbdr->rbdr_door =
+   nicvf_qset_base(nic, 0) + NIC_QSET_RBDR_0_1_DOOR;
+
+   nic->rbdr = rbdr;
+   return 0;
+}
+
+static void
+nicvf_rbdr_release_mbuf(struct nicvf *nic, nicvf_phys_addr_t phy)
+{
+   uint16_t qidx;
+   void *obj;
+   struct nicvf_rxq *rxq;
+
+   for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+   rxq = nic->eth_dev->data->rx_queues[qidx];
+   if (rxq->precharge_cnt) {
+   obj = (void *)nicvf_mbuff_phy2virt(phy,
+  rxq->mbuf_phys_off);
+   rte_mempool_put(rxq->pool, obj);
+   rxq->precharge_cnt--;
+   break;
+   }
+   }
+}
+
+static inline void
+nicvf_rbdr_release_mbufs(struct nicvf *nic)
+{
+   uint32_t qlen_mask, head;
+   struct rbdr_entry_t *entry;
+   struct nicvf_rbdr *rbdr = nic->rbdr;
+
+   qlen_mask = rbdr->qlen_mask;
+   head = rbdr->head;
+   while (head != rbdr->tail) {
+   entry = rbdr->desc + head;
+   nicvf_rbdr_release_mbuf(nic, entry->full_addr);
+   head++;
+   head = head & qlen_mask;
+   }
+}
+
 static inline void
 nicvf_tx_queue_release_mbufs(struct nicvf_txq *txq)
 {
@@ -629,6 +707,31 @@ nicvf_configure_cpi(struct rte_eth_dev *dev)
return ret;
 }

+static inline int
+nicvf_configure_rss(struct rte_eth_dev *dev)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint64_t rsshf;
+   int ret = -EINVAL;
+
+   rsshf = nicvf_rss_ethdev_to_nic(nic,
+   dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
+   PMD_DRV_LOG(INFO, "mode=%d rx_queues=%d loopback=%d rsshf=0x%" PRIx64,
+   dev->data->dev_conf.rxmode.mq_mode,
+   nic->eth_dev->data->nb_rx_queues,
+   nic->eth_dev->data->dev_conf.lpbk_mode, rsshf);
+
+   if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_NONE)
+   ret = nicvf_rss_term(nic);
+   else if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS)
+   ret = nicvf_rss_config(nic,
+  nic->eth_dev->data->nb_rx_queues, rsshf);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to configure RSS %d", ret);
+
+   return ret;
+}
+
 static int
 nicvf_configure_rss_reta(struct rte_eth_dev *dev)
 {
@@ -673,6 +776,48 @@ nicvf_dev_tx_queue_release(void *sq)
}
 }

+static void
+nicvf_set_tx_function(struct rte_eth_dev *dev)
+{
+   struct nicvf_txq *txq;
+   size_t i;
+   bool multiseg = false;
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   if ((txq->txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) {
+   multiseg = true;
+   

[dpdk-dev] [PATCH v4 16/19] net/thunderx: add tx queue start and stop support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 59 +
 1 file changed, 59 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 7a58cb3..3c88290 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -562,6 +562,51 @@ nicvf_tx_queue_reset(struct nicvf_txq *txq)
txq->xmit_bufs = 0;
 }

+static inline int
+nicvf_start_tx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf_txq *txq;
+   int ret;
+
+   if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
+   return 0;
+
+   txq = dev->data->tx_queues[qidx];
+   txq->pool = NULL;
+   ret = nicvf_qset_sq_config(nicvf_pmd_priv(dev), qidx, txq);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Failed to configure sq %d %d", qidx, ret);
+   goto config_sq_error;
+   }
+
+   dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+   return ret;
+
+config_sq_error:
+   nicvf_qset_sq_reclaim(nicvf_pmd_priv(dev), qidx);
+   return ret;
+}
+
+static inline int
+nicvf_stop_tx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf_txq *txq;
+   int ret;
+
+   if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
+   return 0;
+
+   ret = nicvf_qset_sq_reclaim(nicvf_pmd_priv(dev), qidx);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to reclaim sq %d %d", qidx, ret);
+
+   txq = dev->data->tx_queues[qidx];
+   nicvf_tx_queue_release_mbufs(txq);
+   nicvf_tx_queue_reset(txq);
+
+   dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+   return ret;
+}

 static inline int
 nicvf_configure_cpi(struct rte_eth_dev *dev)
@@ -872,6 +917,18 @@ nicvf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t 
qidx)
 }

 static int
+nicvf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   return nicvf_start_tx_queue(dev, qidx);
+}
+
+static int
+nicvf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   return nicvf_stop_tx_queue(dev, qidx);
+}
+
+static int
 nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 uint16_t nb_desc, unsigned int socket_id,
 const struct rte_eth_rxconf *rx_conf,
@@ -1100,6 +1157,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
.rss_hash_conf_get= nicvf_dev_rss_hash_conf_get,
.rx_queue_start   = nicvf_dev_rx_queue_start,
.rx_queue_stop= nicvf_dev_rx_queue_stop,
+   .tx_queue_start   = nicvf_dev_tx_queue_start,
+   .tx_queue_stop= nicvf_dev_tx_queue_stop,
.rx_queue_setup   = nicvf_dev_rx_queue_setup,
.rx_queue_release = nicvf_dev_rx_queue_release,
.rx_queue_count   = nicvf_dev_rx_queue_count,
-- 
2.5.5



[dpdk-dev] [PATCH v4 15/19] net/thunderx: add rx queue start and stop support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 167 
 drivers/net/thunderx/nicvf_rxtx.c   |  18 
 drivers/net/thunderx/nicvf_rxtx.h   |   1 +
 3 files changed, 186 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 8b8d9d9..7a58cb3 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -562,6 +562,54 @@ nicvf_tx_queue_reset(struct nicvf_txq *txq)
txq->xmit_bufs = 0;
 }

+
+static inline int
+nicvf_configure_cpi(struct rte_eth_dev *dev)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint16_t qidx, qcnt;
+   int ret;
+
+   /* Count started rx queues */
+   for (qidx = qcnt = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++)
+   if (dev->data->rx_queue_state[qidx] ==
+   RTE_ETH_QUEUE_STATE_STARTED)
+   qcnt++;
+
+   nic->cpi_alg = CPI_ALG_NONE;
+   ret = nicvf_mbox_config_cpi(nic, qcnt);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to configure CPI %d", ret);
+
+   return ret;
+}
+
+static int
+nicvf_configure_rss_reta(struct rte_eth_dev *dev)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   unsigned int idx, qmap_size;
+   uint8_t qmap[RTE_MAX_QUEUES_PER_PORT];
+   uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE];
+
+   if (nic->cpi_alg != CPI_ALG_NONE)
+   return -EINVAL;
+
+   /* Prepare queue map */
+   for (idx = 0, qmap_size = 0; idx < dev->data->nb_rx_queues; idx++) {
+   if (dev->data->rx_queue_state[idx] ==
+   RTE_ETH_QUEUE_STATE_STARTED)
+   qmap[qmap_size++] = idx;
+   }
+
+   /* Update default RSS RETA */
+   for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++)
+   default_reta[idx] = qmap[idx % qmap_size];
+
+   return nicvf_rss_reta_update(nic, default_reta,
+NIC_MAX_RSS_IDR_TBL_SIZE);
+}
+
 static void
 nicvf_dev_tx_queue_release(void *sq)
 {
@@ -687,6 +735,33 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
qidx,
return 0;
 }

+static inline void
+nicvf_rx_queue_release_mbufs(struct nicvf_rxq *rxq)
+{
+   uint32_t rxq_cnt;
+   uint32_t nb_pkts, released_pkts = 0;
+   uint32_t refill_cnt = 0;
+   struct rte_eth_dev *dev = rxq->nic->eth_dev;
+   struct rte_mbuf *rx_pkts[NICVF_MAX_RX_FREE_THRESH];
+
+   if (dev->rx_pkt_burst == NULL)
+   return;
+
+   while ((rxq_cnt = nicvf_dev_rx_queue_count(dev, rxq->queue_id))) {
+   nb_pkts = dev->rx_pkt_burst(rxq, rx_pkts,
+   NICVF_MAX_RX_FREE_THRESH);
+   PMD_DRV_LOG(INFO, "nb_pkts=%d  rxq_cnt=%d", nb_pkts, rxq_cnt);
+   while (nb_pkts) {
+   rte_pktmbuf_free_seg(rx_pkts[--nb_pkts]);
+   released_pkts++;
+   }
+   }
+
+   refill_cnt += nicvf_dev_rbdr_refill(dev, rxq->queue_id);
+   PMD_DRV_LOG(INFO, "free_cnt=%d  refill_cnt=%d",
+   released_pkts, refill_cnt);
+}
+
 static void
 nicvf_rx_queue_reset(struct nicvf_rxq *rxq)
 {
@@ -695,6 +770,69 @@ nicvf_rx_queue_reset(struct nicvf_rxq *rxq)
rxq->recv_buffers = 0;
 }

+static inline int
+nicvf_start_rx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   struct nicvf_rxq *rxq;
+   int ret;
+
+   if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
+   return 0;
+
+   /* Update rbdr pointer to all rxq */
+   rxq = dev->data->rx_queues[qidx];
+   rxq->shared_rbdr = nic->rbdr;
+
+   ret = nicvf_qset_rq_config(nic, qidx, rxq);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Failed to configure rq %d %d", qidx, ret);
+   goto config_rq_error;
+   }
+   ret = nicvf_qset_cq_config(nic, qidx, rxq);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Failed to configure cq %d %d", qidx, ret);
+   goto config_cq_error;
+   }
+
+   dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+   return 0;
+
+config_cq_error:
+   nicvf_qset_cq_reclaim(nic, qidx);
+config_rq_error:
+   nicvf_qset_rq_reclaim(nic, qidx);
+   return ret;
+}
+
+static inline int
+nicvf_stop_rx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   struct nicvf_rxq *rxq;
+   int ret, other_error;
+
+   if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
+   return 0;
+
+   ret = nicvf_qset_rq_reclaim(nic, qidx);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to reclaim rq %d 

[dpdk-dev] [PATCH v4 14/19] net/thunderx: add dev_supported_ptypes_get and rx_queue_count support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 41 +
 drivers/net/thunderx/nicvf_rxtx.c   |  9 
 drivers/net/thunderx/nicvf_rxtx.h   |  2 ++
 3 files changed, 52 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 15f5cfc..8b8d9d9 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -260,6 +260,45 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->oerrors = port_stats.tx_drops;
 }

+static const uint32_t *
+nicvf_dev_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+   size_t copied;
+   static uint32_t ptypes[32];
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   static const uint32_t ptypes_pass1[] = {
+   RTE_PTYPE_L3_IPV4,
+   RTE_PTYPE_L3_IPV4_EXT,
+   RTE_PTYPE_L3_IPV6,
+   RTE_PTYPE_L3_IPV6_EXT,
+   RTE_PTYPE_L4_TCP,
+   RTE_PTYPE_L4_UDP,
+   RTE_PTYPE_L4_FRAG,
+   };
+   static const uint32_t ptypes_pass2[] = {
+   RTE_PTYPE_TUNNEL_GRE,
+   RTE_PTYPE_TUNNEL_GENEVE,
+   RTE_PTYPE_TUNNEL_VXLAN,
+   RTE_PTYPE_TUNNEL_NVGRE,
+   };
+   static const uint32_t ptypes_end = RTE_PTYPE_UNKNOWN;
+
+   copied = sizeof(ptypes_pass1);
+   memcpy(ptypes, ptypes_pass1, copied);
+   if (nicvf_hw_version(nic) == NICVF_PASS2) {
+   memcpy((char *)ptypes + copied, ptypes_pass2,
+   sizeof(ptypes_pass2));
+   copied += sizeof(ptypes_pass2);
+   }
+
+   memcpy((char *)ptypes + copied, _end, sizeof(ptypes_end));
+   if (dev->rx_pkt_burst == nicvf_recv_pkts ||
+   dev->rx_pkt_burst == nicvf_recv_pkts_multiseg)
+   return ptypes;
+
+   return NULL;
+}
+
 static void
 nicvf_dev_stats_reset(struct rte_eth_dev *dev)
 {
@@ -888,6 +927,7 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
.stats_reset  = nicvf_dev_stats_reset,
.promiscuous_enable   = nicvf_dev_promisc_enable,
.dev_infos_get= nicvf_dev_info_get,
+   .dev_supported_ptypes_get = nicvf_dev_supported_ptypes_get,
.mtu_set  = nicvf_dev_set_mtu,
.reta_update  = nicvf_dev_reta_update,
.reta_query   = nicvf_dev_reta_query,
@@ -895,6 +935,7 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
.rss_hash_conf_get= nicvf_dev_rss_hash_conf_get,
.rx_queue_setup   = nicvf_dev_rx_queue_setup,
.rx_queue_release = nicvf_dev_rx_queue_release,
+   .rx_queue_count   = nicvf_dev_rx_queue_count,
.tx_queue_setup   = nicvf_dev_tx_queue_setup,
.tx_queue_release = nicvf_dev_tx_queue_release,
.get_reg_length   = nicvf_dev_get_reg_length,
diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
index fed0859..1c6d6a8 100644
--- a/drivers/net/thunderx/nicvf_rxtx.c
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -570,3 +570,12 @@ nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf 
**rx_pkts,

return to_process;
 }
+
+uint32_t
+nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx)
+{
+   struct nicvf_rxq *rxq;
+
+   rxq = dev->data->rx_queues[queue_idx];
+   return nicvf_addr_read(rxq->cq_status) & NICVF_CQ_CQE_COUNT_MASK;
+}
diff --git a/drivers/net/thunderx/nicvf_rxtx.h 
b/drivers/net/thunderx/nicvf_rxtx.h
index d2ca2c9..ded87f3 100644
--- a/drivers/net/thunderx/nicvf_rxtx.h
+++ b/drivers/net/thunderx/nicvf_rxtx.h
@@ -84,6 +84,8 @@ fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf 
*pkt)
 }
 #endif

+uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx);
+
 uint16_t nicvf_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t pkts);
 uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts,
  uint16_t nb_pkts);
-- 
2.5.5



[dpdk-dev] [PATCH v4 13/19] net/thunderx: add single and multi segment rx functions

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.h |  33 
 drivers/net/thunderx/nicvf_rxtx.c   | 317 
 drivers/net/thunderx/nicvf_rxtx.h   |   5 +
 3 files changed, 355 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index b1af468..59fa19c 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -70,4 +70,37 @@ nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
return eth_dev->data->dev_private;
 }

+static inline uint64_t
+nicvf_mempool_phy_offset(struct rte_mempool *mp)
+{
+   struct rte_mempool_memhdr *hdr;
+
+   hdr = STAILQ_FIRST(>mem_list);
+   assert(hdr != NULL);
+   return (uint64_t)((uintptr_t)hdr->addr - hdr->phys_addr);
+}
+
+static inline uint16_t
+nicvf_mbuff_meta_length(struct rte_mbuf *mbuf)
+{
+   return (uint16_t)((uintptr_t)mbuf->buf_addr - (uintptr_t)mbuf);
+}
+
+/*
+ * Simple phy2virt functions assuming mbufs are in a single huge page
+ * V = P + offset
+ * P = V - offset
+ */
+static inline uintptr_t
+nicvf_mbuff_phy2virt(phys_addr_t phy, uint64_t mbuf_phys_off)
+{
+   return (uintptr_t)(phy + mbuf_phys_off);
+}
+
+static inline uintptr_t
+nicvf_mbuff_virt2phy(uintptr_t virt, uint64_t mbuf_phys_off)
+{
+   return (phys_addr_t)(virt - mbuf_phys_off);
+}
+
 #endif /* __THUNDERX_NICVF_ETHDEV_H__  */
diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
index 88a5152..fed0859 100644
--- a/drivers/net/thunderx/nicvf_rxtx.c
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -253,3 +253,320 @@ nicvf_xmit_pkts_multiseg(void *tx_queue, struct rte_mbuf 
**tx_pkts,
nicvf_addr_write(sq->sq_door, used_desc);
return nb_pkts;
 }
+
+static const uint32_t ptype_table[16][16] __rte_cache_aligned = {
+   [L3_NONE][L4_NONE] = RTE_PTYPE_UNKNOWN,
+   [L3_NONE][L4_IPSEC_ESP] = RTE_PTYPE_UNKNOWN,
+   [L3_NONE][L4_IPFRAG] = RTE_PTYPE_L4_FRAG,
+   [L3_NONE][L4_IPCOMP] = RTE_PTYPE_UNKNOWN,
+   [L3_NONE][L4_TCP] = RTE_PTYPE_L4_TCP,
+   [L3_NONE][L4_UDP_PASS1] = RTE_PTYPE_L4_UDP,
+   [L3_NONE][L4_GRE] = RTE_PTYPE_TUNNEL_GRE,
+   [L3_NONE][L4_UDP_PASS2] = RTE_PTYPE_L4_UDP,
+   [L3_NONE][L4_UDP_GENEVE] = RTE_PTYPE_TUNNEL_GENEVE,
+   [L3_NONE][L4_UDP_VXLAN] = RTE_PTYPE_TUNNEL_VXLAN,
+   [L3_NONE][L4_NVGRE] = RTE_PTYPE_TUNNEL_NVGRE,
+
+   [L3_IPV4][L4_NONE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4][L4_IPSEC_ESP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV4,
+   [L3_IPV4][L4_IPFRAG] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG,
+   [L3_IPV4][L4_IPCOMP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4][L4_TCP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+   [L3_IPV4][L4_UDP_PASS1] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [L3_IPV4][L4_GRE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GRE,
+   [L3_IPV4][L4_UDP_PASS2] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [L3_IPV4][L4_UDP_GENEVE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GENEVE,
+   [L3_IPV4][L4_UDP_VXLAN] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_VXLAN,
+   [L3_IPV4][L4_NVGRE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_NVGRE,
+
+   [L3_IPV4_OPT][L4_NONE] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4_OPT][L4_IPSEC_ESP] =  RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_L3_IPV4,
+   [L3_IPV4_OPT][L4_IPFRAG] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_FRAG,
+   [L3_IPV4_OPT][L4_IPCOMP] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4_OPT][L4_TCP] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_TCP,
+   [L3_IPV4_OPT][L4_UDP_PASS1] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_UDP,
+   [L3_IPV4_OPT][L4_GRE] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_GRE,
+   [L3_IPV4_OPT][L4_UDP_PASS2] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_UDP,
+   [L3_IPV4_OPT][L4_UDP_GENEVE] = RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_TUNNEL_GENEVE,
+   [L3_IPV4_OPT][L4_UDP_VXLAN] = RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_TUNNEL_VXLAN,
+   [L3_IPV4_OPT][L4_NVGRE] = RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_TUNNEL_NVGRE,
+
+   [L3_IPV6][L4_NONE] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV6][L4_IPSEC_ESP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L3_IPV4,
+   [L3_IPV6][L4_IPFRAG] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG,
+   [L3_IPV6][L4_IPCOMP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV6][L4_TCP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+   [L3_IPV6][L4_UDP_PASS1] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   [L3_IPV6][L4_GRE] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GRE,
+   [L3_IPV6][L4_UDP_PASS2] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   

[dpdk-dev] [PATCH v4 12/19] net/thunderx: add single and multi segment tx functions

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/Makefile   |   2 +
 drivers/net/thunderx/nicvf_ethdev.c |   5 +-
 drivers/net/thunderx/nicvf_rxtx.c   | 255 
 drivers/net/thunderx/nicvf_rxtx.h   |  93 +
 4 files changed, 354 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/thunderx/nicvf_rxtx.c
 create mode 100644 drivers/net/thunderx/nicvf_rxtx.h

diff --git a/drivers/net/thunderx/Makefile b/drivers/net/thunderx/Makefile
index eb9f100..9079b5b 100644
--- a/drivers/net/thunderx/Makefile
+++ b/drivers/net/thunderx/Makefile
@@ -51,10 +51,12 @@ VPATH += $(SRCDIR)/base
 #
 # all source are stored in SRCS-y
 #
+SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_hw.c
 SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_mbox.c
 SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_ethdev.c

+CFLAGS_nicvf_rxtx.o += -fno-prefetch-loop-arrays -Ofast

 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += lib/librte_eal 
lib/librte_ether
diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 19ad85a..15f5cfc 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -66,7 +66,7 @@
 #include "base/nicvf_plat.h"

 #include "nicvf_ethdev.h"
-
+#include "nicvf_rxtx.h"
 #include "nicvf_logs.h"

 static inline int
@@ -617,6 +617,9 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
qidx,
(tx_conf->tx_free_thresh == NICVF_DEFAULT_TX_FREE_THRESH ?
NICVF_TX_FREE_MPOOL_THRESH :
tx_conf->tx_free_thresh);
+   txq->pool_free = nicvf_multi_pool_free_xmited_buffers;
+   } else {
+   txq->pool_free = nicvf_single_pool_free_xmited_buffers;
}

/* Allocate software ring */
diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
new file mode 100644
index 000..88a5152
--- /dev/null
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -0,0 +1,255 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   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 Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "base/nicvf_plat.h"
+
+#include "nicvf_ethdev.h"
+#include "nicvf_rxtx.h"
+#include "nicvf_logs.h"
+
+static inline void __hot
+fill_sq_desc_header(union sq_entry_t *entry, struct rte_mbuf *pkt)
+{
+   /* Local variable sqe to avoid read from sq desc memory*/
+   union sq_entry_t sqe;
+   uint64_t ol_flags;
+
+   /* Fill SQ header descriptor */
+   sqe.buff[0] = 0;
+   sqe.hdr.subdesc_type = SQ_DESC_TYPE_HEADER;
+   /* Number of sub-descriptors following this one */
+   sqe.hdr.subdesc_cnt = pkt->nb_segs;
+   sqe.hdr.tot_len = pkt->pkt_len;
+
+   ol_flags = pkt->ol_flags & NICVF_TX_OFFLOAD_MASK;
+   if (unlikely(ol_flags)) {
+   /* L4 cksum */
+   if (ol_flags & PKT_TX_TCP_CKSUM)
+   sqe.hdr.csum_l4 = SEND_L4_CSUM_TCP;
+   else if (ol_flags 

[dpdk-dev] [PATCH v4 11/19] net/thunderx: add stats support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 66 +
 1 file changed, 66 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index f0e3371..19ad85a 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -211,6 +211,70 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static void
+nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+   uint16_t qidx;
+   struct nicvf_hw_rx_qstats rx_qstats;
+   struct nicvf_hw_tx_qstats tx_qstats;
+   struct nicvf_hw_stats port_stats;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   /* Reading per RX ring stats */
+   for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
+   if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+   break;
+
+   nicvf_hw_get_rx_qstats(nic, _qstats, qidx);
+   stats->q_ibytes[qidx] = rx_qstats.q_rx_bytes;
+   stats->q_ipackets[qidx] = rx_qstats.q_rx_packets;
+   }
+
+   /* Reading per TX ring stats */
+   for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++) {
+   if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+   break;
+
+   nicvf_hw_get_tx_qstats(nic, _qstats, qidx);
+   stats->q_obytes[qidx] = tx_qstats.q_tx_bytes;
+   stats->q_opackets[qidx] = tx_qstats.q_tx_packets;
+   }
+
+   nicvf_hw_get_stats(nic, _stats);
+   stats->ibytes = port_stats.rx_bytes;
+   stats->ipackets = port_stats.rx_ucast_frames;
+   stats->ipackets += port_stats.rx_bcast_frames;
+   stats->ipackets += port_stats.rx_mcast_frames;
+   stats->ierrors = port_stats.rx_l2_errors;
+   stats->imissed = port_stats.rx_drop_red;
+   stats->imissed += port_stats.rx_drop_overrun;
+   stats->imissed += port_stats.rx_drop_bcast;
+   stats->imissed += port_stats.rx_drop_mcast;
+   stats->imissed += port_stats.rx_drop_l3_bcast;
+   stats->imissed += port_stats.rx_drop_l3_mcast;
+
+   stats->obytes = port_stats.tx_bytes_ok;
+   stats->opackets = port_stats.tx_ucast_frames_ok;
+   stats->opackets += port_stats.tx_bcast_frames_ok;
+   stats->opackets += port_stats.tx_mcast_frames_ok;
+   stats->oerrors = port_stats.tx_drops;
+}
+
+static void
+nicvf_dev_stats_reset(struct rte_eth_dev *dev)
+{
+   int i;
+   uint16_t rxqs = 0, txqs = 0;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   rxqs |= (0x3 << (i * 2));
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   txqs |= (0x3 << (i * 2));
+
+   nicvf_mbox_reset_stat_counters(nic, 0x3FFF, 0x1F, rxqs, txqs);
+}
+
 /* Promiscuous mode enabled by default in LMAC to VF 1:1 map configuration */
 static void
 nicvf_dev_promisc_enable(struct rte_eth_dev *dev __rte_unused)
@@ -817,6 +881,8 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
+   .stats_get= nicvf_dev_stats_get,
+   .stats_reset  = nicvf_dev_stats_reset,
.promiscuous_enable   = nicvf_dev_promisc_enable,
.dev_infos_get= nicvf_dev_info_get,
.mtu_set  = nicvf_dev_set_mtu,
-- 
2.5.5



[dpdk-dev] [PATCH v4 10/19] net/thunderx: add mtu_set and promiscuous_enable support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 51 +
 drivers/net/thunderx/nicvf_ethdev.h |  2 ++
 2 files changed, 53 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 1d5bea7..f0e3371 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -144,6 +144,49 @@ nicvf_dev_link_update(struct rte_eth_dev *dev,
 }

 static int
+nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint32_t buffsz, frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (frame_size > NIC_HW_MAX_FRS)
+   return -EINVAL;
+
+   if (frame_size < NIC_HW_MIN_FRS)
+   return -EINVAL;
+
+   buffsz = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
+
+   /*
+* Refuse mtu that requires the support of scattered packets
+* when this feature has not been enabled before.
+*/
+   if (!dev->data->scattered_rx &&
+   (frame_size + 2 * VLAN_TAG_SIZE > buffsz))
+   return -EINVAL;
+
+   /* check  *   >= max_frame */
+   if (dev->data->scattered_rx &&
+   (frame_size + 2 * VLAN_TAG_SIZE > buffsz * NIC_HW_MAX_SEGS))
+   return -EINVAL;
+
+   if (frame_size > ETHER_MAX_LEN)
+   dev->data->dev_conf.rxmode.jumbo_frame = 1;
+   else
+   dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
+   if (nicvf_mbox_update_hw_max_frs(nic, frame_size))
+   return -EINVAL;
+
+   /* Update max frame size */
+   dev->data->dev_conf.rxmode.max_rx_pkt_len = (uint32_t)frame_size;
+   nic->mtu = mtu;
+   return 0;
+}
+
+static int
 nicvf_dev_get_reg_length(struct rte_eth_dev *dev  __rte_unused)
 {
return nicvf_reg_get_count();
@@ -168,6 +211,12 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+/* Promiscuous mode enabled by default in LMAC to VF 1:1 map configuration */
+static void
+nicvf_dev_promisc_enable(struct rte_eth_dev *dev __rte_unused)
+{
+}
+
 static inline uint64_t
 nicvf_rss_ethdev_to_nic(struct nicvf *nic, uint64_t ethdev_rss)
 {
@@ -768,7 +817,9 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
+   .promiscuous_enable   = nicvf_dev_promisc_enable,
.dev_infos_get= nicvf_dev_info_get,
+   .mtu_set  = nicvf_dev_set_mtu,
.reta_update  = nicvf_dev_reta_update,
.reta_query   = nicvf_dev_reta_query,
.rss_hash_update  = nicvf_dev_rss_hash_update,
diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index afb875a..b1af468 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -62,6 +62,8 @@
 #define NICVF_MAX_RX_FREE_THRESH1024
 #define NICVF_MAX_TX_FREE_THRESH1024

+#define VLAN_TAG_SIZE   4  /* 802.3ac tag */
+
 static inline struct nicvf *
 nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
 {
-- 
2.5.5



[dpdk-dev] [PATCH v4 09/19] net/thunderx: add rss and reta query and update support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 172 
 1 file changed, 172 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 167149e..1d5bea7 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,6 +168,174 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static inline uint64_t
+nicvf_rss_ethdev_to_nic(struct nicvf *nic, uint64_t ethdev_rss)
+{
+   uint64_t nic_rss = 0;
+
+   if (ethdev_rss & ETH_RSS_IPV4)
+   nic_rss |= RSS_IP_ENA;
+
+   if (ethdev_rss & ETH_RSS_IPV6)
+   nic_rss |= RSS_IP_ENA;
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV4_UDP)
+   nic_rss |= (RSS_IP_ENA | RSS_UDP_ENA);
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV4_TCP)
+   nic_rss |= (RSS_IP_ENA | RSS_TCP_ENA);
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV6_UDP)
+   nic_rss |= (RSS_IP_ENA | RSS_UDP_ENA);
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV6_TCP)
+   nic_rss |= (RSS_IP_ENA | RSS_TCP_ENA);
+
+   if (ethdev_rss & ETH_RSS_PORT)
+   nic_rss |= RSS_L2_EXTENDED_HASH_ENA;
+
+   if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING) {
+   if (ethdev_rss & ETH_RSS_VXLAN)
+   nic_rss |= RSS_TUN_VXLAN_ENA;
+
+   if (ethdev_rss & ETH_RSS_GENEVE)
+   nic_rss |= RSS_TUN_GENEVE_ENA;
+
+   if (ethdev_rss & ETH_RSS_NVGRE)
+   nic_rss |= RSS_TUN_NVGRE_ENA;
+   }
+
+   return nic_rss;
+}
+
+static inline uint64_t
+nicvf_rss_nic_to_ethdev(struct nicvf *nic,  uint64_t nic_rss)
+{
+   uint64_t ethdev_rss = 0;
+
+   if (nic_rss & RSS_IP_ENA)
+   ethdev_rss |= (ETH_RSS_IPV4 | ETH_RSS_IPV6);
+
+   if ((nic_rss & RSS_IP_ENA) && (nic_rss & RSS_TCP_ENA))
+   ethdev_rss |= (ETH_RSS_NONFRAG_IPV4_TCP |
+   ETH_RSS_NONFRAG_IPV6_TCP);
+
+   if ((nic_rss & RSS_IP_ENA) && (nic_rss & RSS_UDP_ENA))
+   ethdev_rss |= (ETH_RSS_NONFRAG_IPV4_UDP |
+   ETH_RSS_NONFRAG_IPV6_UDP);
+
+   if (nic_rss & RSS_L2_EXTENDED_HASH_ENA)
+   ethdev_rss |= ETH_RSS_PORT;
+
+   if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING) {
+   if (nic_rss & RSS_TUN_VXLAN_ENA)
+   ethdev_rss |= ETH_RSS_VXLAN;
+
+   if (nic_rss & RSS_TUN_GENEVE_ENA)
+   ethdev_rss |= ETH_RSS_GENEVE;
+
+   if (nic_rss & RSS_TUN_NVGRE_ENA)
+   ethdev_rss |= ETH_RSS_NVGRE;
+   }
+   return ethdev_rss;
+}
+
+static int
+nicvf_dev_reta_query(struct rte_eth_dev *dev,
+struct rte_eth_rss_reta_entry64 *reta_conf,
+uint16_t reta_size)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint8_t tbl[NIC_MAX_RSS_IDR_TBL_SIZE];
+   int ret, i, j;
+
+   if (reta_size != NIC_MAX_RSS_IDR_TBL_SIZE) {
+   RTE_LOG(ERR, PMD, "The size of hash lookup table configured "
+   "(%d) doesn't match the number hardware can supported "
+   "(%d)", reta_size, NIC_MAX_RSS_IDR_TBL_SIZE);
+   return -EINVAL;
+   }
+
+   ret = nicvf_rss_reta_query(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE);
+   if (ret)
+   return ret;
+
+   /* Copy RETA table */
+   for (i = 0; i < (NIC_MAX_RSS_IDR_TBL_SIZE / RTE_RETA_GROUP_SIZE); i++) {
+   for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
+   if ((reta_conf[i].mask >> j) & 0x01)
+   reta_conf[i].reta[j] = tbl[j];
+   }
+
+   return 0;
+}
+
+static int
+nicvf_dev_reta_update(struct rte_eth_dev *dev,
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t reta_size)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint8_t tbl[NIC_MAX_RSS_IDR_TBL_SIZE];
+   int ret, i, j;
+
+   if (reta_size != NIC_MAX_RSS_IDR_TBL_SIZE) {
+   RTE_LOG(ERR, PMD, "The size of hash lookup table configured "
+   "(%d) doesn't match the number hardware can supported "
+   "(%d)", reta_size, NIC_MAX_RSS_IDR_TBL_SIZE);
+   return -EINVAL;
+   }
+
+   ret = nicvf_rss_reta_query(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE);
+   if (ret)
+   return ret;
+
+   /* Copy RETA table */
+   for (i = 0; i < (NIC_MAX_RSS_IDR_TBL_SIZE / RTE_RETA_GROUP_SIZE); i++) {
+   for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
+   if ((reta_conf[i].mask >> j) & 

[dpdk-dev] [PATCH v4 08/19] net/thunderx: add tx_queue_setup/release support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 175 
 1 file changed, 175 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 4652438..167149e 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -191,6 +191,179 @@ nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq 
*rxq, uint16_t qidx,
return 0;
 }

+static int
+nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq *sq, uint16_t qidx,
+   uint32_t desc_cnt)
+{
+   const struct rte_memzone *rz;
+   uint32_t ring_size = desc_cnt * sizeof(union sq_entry_t);
+
+   rz = rte_eth_dma_zone_reserve(nic->eth_dev, "sq", qidx, ring_size,
+   NICVF_SQ_BASE_ALIGN_BYTES, nic->node);
+   if (rz == NULL) {
+   PMD_INIT_LOG(ERR, "Failed allocate mem for sq hw ring");
+   return -ENOMEM;
+   }
+
+   memset(rz->addr, 0, ring_size);
+
+   sq->phys = rz->phys_addr;
+   sq->desc = rz->addr;
+   sq->qlen_mask = desc_cnt - 1;
+
+   return 0;
+}
+
+static inline void
+nicvf_tx_queue_release_mbufs(struct nicvf_txq *txq)
+{
+   uint32_t head;
+
+   head = txq->head;
+   while (head != txq->tail) {
+   if (txq->txbuffs[head]) {
+   rte_pktmbuf_free_seg(txq->txbuffs[head]);
+   txq->txbuffs[head] = NULL;
+   }
+   head++;
+   head = head & txq->qlen_mask;
+   }
+}
+
+static void
+nicvf_tx_queue_reset(struct nicvf_txq *txq)
+{
+   uint32_t txq_desc_cnt = txq->qlen_mask + 1;
+
+   memset(txq->desc, 0, sizeof(union sq_entry_t) * txq_desc_cnt);
+   memset(txq->txbuffs, 0, sizeof(struct rte_mbuf *) * txq_desc_cnt);
+   txq->tail = 0;
+   txq->head = 0;
+   txq->xmit_bufs = 0;
+}
+
+static void
+nicvf_dev_tx_queue_release(void *sq)
+{
+   struct nicvf_txq *txq;
+
+   PMD_INIT_FUNC_TRACE();
+
+   txq = (struct nicvf_txq *)sq;
+   if (txq) {
+   if (txq->txbuffs != NULL) {
+   nicvf_tx_queue_release_mbufs(txq);
+   rte_free(txq->txbuffs);
+   txq->txbuffs = NULL;
+   }
+   rte_free(txq);
+   }
+}
+
+static int
+nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
+uint16_t nb_desc, unsigned int socket_id,
+const struct rte_eth_txconf *tx_conf)
+{
+   uint16_t tx_free_thresh;
+   uint8_t is_single_pool;
+   struct nicvf_txq *txq;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* Socket id check */
+   if (socket_id != (unsigned int)SOCKET_ID_ANY && socket_id != nic->node)
+   PMD_DRV_LOG(WARNING, "socket_id expected %d, configured %d",
+   socket_id, nic->node);
+
+   /* Tx deferred start is not supported */
+   if (tx_conf->tx_deferred_start) {
+   PMD_INIT_LOG(ERR, "Tx deferred start not supported");
+   return -EINVAL;
+   }
+
+   /* Roundup nb_desc to available qsize and validate max number of desc */
+   nb_desc = nicvf_qsize_sq_roundup(nb_desc);
+   if (nb_desc == 0) {
+   PMD_INIT_LOG(ERR, "Value of nb_desc beyond available sq qsize");
+   return -EINVAL;
+   }
+
+   /* Validate tx_free_thresh */
+   tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
+   tx_conf->tx_free_thresh :
+   NICVF_DEFAULT_TX_FREE_THRESH);
+
+   if (tx_free_thresh > (nb_desc) ||
+   tx_free_thresh > NICVF_MAX_TX_FREE_THRESH) {
+   PMD_INIT_LOG(ERR,
+   "tx_free_thresh must be less than the number of TX "
+   "descriptors. (tx_free_thresh=%u port=%d "
+   "queue=%d)", (unsigned int)tx_free_thresh,
+   (int)dev->data->port_id, (int)qidx);
+   return -EINVAL;
+   }
+
+   /* Free memory prior to re-allocation if needed. */
+   if (dev->data->tx_queues[qidx] != NULL) {
+   PMD_TX_LOG(DEBUG, "Freeing memory prior to re-allocation %d",
+   qidx);
+   nicvf_dev_tx_queue_release(dev->data->tx_queues[qidx]);
+   dev->data->tx_queues[qidx] = NULL;
+   }
+
+   /* Allocating tx queue data structure */
+   txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nicvf_txq),
+   RTE_CACHE_LINE_SIZE, nic->node);
+   if (txq == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate txq=%d", qidx);
+   return 

[dpdk-dev] [PATCH v4 07/19] net/thunderx: add rx_queue_setup/release support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 136 
 drivers/net/thunderx/nicvf_ethdev.h |   2 +
 2 files changed, 138 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 109c6cb..4652438 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,6 +168,140 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static int
+nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx,
+   uint32_t desc_cnt)
+{
+   const struct rte_memzone *rz;
+   uint32_t ring_size = desc_cnt * sizeof(union cq_entry_t);
+
+   rz = rte_eth_dma_zone_reserve(nic->eth_dev, "cq_ring", qidx, ring_size,
+   NICVF_CQ_BASE_ALIGN_BYTES, nic->node);
+   if (rz == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate mem for cq hw ring");
+   return -ENOMEM;
+   }
+
+   memset(rz->addr, 0, ring_size);
+
+   rxq->phys = rz->phys_addr;
+   rxq->desc = rz->addr;
+   rxq->qlen_mask = desc_cnt - 1;
+
+   return 0;
+}
+
+static void
+nicvf_rx_queue_reset(struct nicvf_rxq *rxq)
+{
+   rxq->head = 0;
+   rxq->available_space = 0;
+   rxq->recv_buffers = 0;
+}
+
+static void
+nicvf_dev_rx_queue_release(void *rx_queue)
+{
+   struct nicvf_rxq *rxq = rx_queue;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (rxq)
+   rte_free(rxq);
+}
+
+static int
+nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
+uint16_t nb_desc, unsigned int socket_id,
+const struct rte_eth_rxconf *rx_conf,
+struct rte_mempool *mp)
+{
+   uint16_t rx_free_thresh;
+   struct nicvf_rxq *rxq;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* Socket id check */
+   if (socket_id != (unsigned int)SOCKET_ID_ANY && socket_id != nic->node)
+   PMD_DRV_LOG(WARNING, "socket_id expected %d, configured %d",
+   socket_id, nic->node);
+
+   /* Mempool memory should be contiguous */
+   if (mp->nb_mem_chunks != 1) {
+   PMD_INIT_LOG(ERR, "Non contiguous mempool, check huge page sz");
+   return -EINVAL;
+   }
+
+   /* Rx deferred start is not supported */
+   if (rx_conf->rx_deferred_start) {
+   PMD_INIT_LOG(ERR, "Rx deferred start not supported");
+   return -EINVAL;
+   }
+
+   /* Roundup nb_desc to available qsize and validate max number of desc */
+   nb_desc = nicvf_qsize_cq_roundup(nb_desc);
+   if (nb_desc == 0) {
+   PMD_INIT_LOG(ERR, "Value nb_desc beyond available hw cq qsize");
+   return -EINVAL;
+   }
+
+   /* Check rx_free_thresh upper bound */
+   rx_free_thresh = (uint16_t)((rx_conf->rx_free_thresh) ?
+   rx_conf->rx_free_thresh :
+   NICVF_DEFAULT_RX_FREE_THRESH);
+   if (rx_free_thresh > NICVF_MAX_RX_FREE_THRESH ||
+   rx_free_thresh >= nb_desc * .75) {
+   PMD_INIT_LOG(ERR, "rx_free_thresh greater than expected %d",
+   rx_free_thresh);
+   return -EINVAL;
+   }
+
+   /* Free memory prior to re-allocation if needed */
+   if (dev->data->rx_queues[qidx] != NULL) {
+   PMD_RX_LOG(DEBUG, "Freeing memory prior to re-allocation %d",
+   qidx);
+   nicvf_dev_rx_queue_release(dev->data->rx_queues[qidx]);
+   dev->data->rx_queues[qidx] = NULL;
+   }
+
+   /* Allocate rxq memory */
+   rxq = rte_zmalloc_socket("ethdev rx queue", sizeof(struct nicvf_rxq),
+   RTE_CACHE_LINE_SIZE, nic->node);
+   if (rxq == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate rxq=%d", qidx);
+   return -ENOMEM;
+   }
+
+   rxq->nic = nic;
+   rxq->pool = mp;
+   rxq->queue_id = qidx;
+   rxq->port_id = dev->data->port_id;
+   rxq->rx_free_thresh = rx_free_thresh;
+   rxq->rx_drop_en = rx_conf->rx_drop_en;
+   rxq->cq_status = nicvf_qset_base(nic, qidx) + NIC_QSET_CQ_0_7_STATUS;
+   rxq->cq_door = nicvf_qset_base(nic, qidx) + NIC_QSET_CQ_0_7_DOOR;
+   rxq->precharge_cnt = 0;
+   rxq->rbptr_offset = NICVF_CQE_RBPTR_WORD;
+
+   /* Alloc completion queue */
+   if (nicvf_qset_cq_alloc(nic, rxq, rxq->queue_id, nb_desc)) {
+   PMD_INIT_LOG(ERR, "failed to allocate cq %u", rxq->queue_id);
+   nicvf_dev_rx_queue_release(rxq);
+   

[dpdk-dev] [PATCH v4 06/19] net/thunderx: add dev_infos_get support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 45 +
 drivers/net/thunderx/nicvf_ethdev.h | 17 ++
 2 files changed, 62 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 1814341..109c6cb 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,6 +168,50 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static void
+nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   dev_info->min_rx_bufsize = ETHER_MIN_MTU;
+   dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
+   dev_info->max_rx_queues = (uint16_t)MAX_RCV_QUEUES_PER_QS;
+   dev_info->max_tx_queues = (uint16_t)MAX_SND_QUEUES_PER_QS;
+   dev_info->max_mac_addrs = 1;
+   dev_info->max_vfs = dev->pci_dev->max_vfs;
+
+   dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP;
+   dev_info->tx_offload_capa =
+   DEV_TX_OFFLOAD_IPV4_CKSUM  |
+   DEV_TX_OFFLOAD_UDP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_TSO |
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+   dev_info->reta_size = nic->rss_info.rss_size;
+   dev_info->hash_key_size = RSS_HASH_KEY_BYTE_SIZE;
+   dev_info->flow_type_rss_offloads = NICVF_RSS_OFFLOAD_PASS1;
+   if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING)
+   dev_info->flow_type_rss_offloads |= NICVF_RSS_OFFLOAD_TUNNEL;
+
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_free_thresh = NICVF_DEFAULT_RX_FREE_THRESH,
+   .rx_drop_en = 0,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_free_thresh = NICVF_DEFAULT_TX_FREE_THRESH,
+   .txq_flags =
+   ETH_TXQ_FLAGS_NOMULTSEGS  |
+   ETH_TXQ_FLAGS_NOREFCOUNT  |
+   ETH_TXQ_FLAGS_NOMULTMEMP  |
+   ETH_TXQ_FLAGS_NOVLANOFFL  |
+   ETH_TXQ_FLAGS_NOXSUMSCTP,
+   };
+}
+
 static int
 nicvf_dev_configure(struct rte_eth_dev *dev)
 {
@@ -249,6 +293,7 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
+   .dev_infos_get= nicvf_dev_info_get,
.get_reg_length   = nicvf_dev_get_reg_length,
.get_reg  = nicvf_dev_get_regs,
 };
diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index 8189856..e31657d 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -42,6 +42,23 @@
 #define NICVF_FULL_DUPLEX  0x01
 #define NICVF_UNKNOWN_DUPLEX   0xff

+#define NICVF_RSS_OFFLOAD_PASS1 ( \
+   ETH_RSS_PORT | \
+   ETH_RSS_IPV4 | \
+   ETH_RSS_NONFRAG_IPV4_TCP | \
+   ETH_RSS_NONFRAG_IPV4_UDP | \
+   ETH_RSS_IPV6 | \
+   ETH_RSS_NONFRAG_IPV6_TCP | \
+   ETH_RSS_NONFRAG_IPV6_UDP)
+
+#define NICVF_RSS_OFFLOAD_TUNNEL ( \
+   ETH_RSS_VXLAN | \
+   ETH_RSS_GENEVE | \
+   ETH_RSS_NVGRE)
+
+#define NICVF_DEFAULT_RX_FREE_THRESH224
+#define NICVF_DEFAULT_TX_FREE_THRESH224
+#define NICVF_TX_FREE_MPOOL_THRESH  16

 static inline struct nicvf *
 nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
-- 
2.5.5



[dpdk-dev] [PATCH v4 05/19] net/thunderx: add dev_configure support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 78 +
 1 file changed, 78 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 5c066e2..1814341 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,8 +168,86 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static int
+nicvf_dev_configure(struct rte_eth_dev *dev)
+{
+   struct rte_eth_conf *conf = >data->dev_conf;
+   struct rte_eth_rxmode *rxmode = >rxmode;
+   struct rte_eth_txmode *txmode = >txmode;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (!rte_eal_has_hugepages()) {
+   PMD_INIT_LOG(INFO, "Huge page is not configured");
+   return -EINVAL;
+   }
+
+   if (txmode->mq_mode) {
+   PMD_INIT_LOG(INFO, "Tx mq_mode DCB or VMDq not supported");
+   return -EINVAL;
+   }
+
+   if (rxmode->mq_mode != ETH_MQ_RX_NONE &&
+   rxmode->mq_mode != ETH_MQ_RX_RSS) {
+   PMD_INIT_LOG(INFO, "Unsupported rx qmode %d", rxmode->mq_mode);
+   return -EINVAL;
+   }
+
+   if (!rxmode->hw_strip_crc) {
+   PMD_INIT_LOG(NOTICE, "Can't disable hw crc strip");
+   rxmode->hw_strip_crc = 1;
+   }
+
+   if (rxmode->hw_ip_checksum) {
+   PMD_INIT_LOG(NOTICE, "Rxcksum not supported");
+   rxmode->hw_ip_checksum = 0;
+   }
+
+   if (rxmode->split_hdr_size) {
+   PMD_INIT_LOG(INFO, "Rxmode does not support split header");
+   return -EINVAL;
+   }
+
+   if (rxmode->hw_vlan_filter) {
+   PMD_INIT_LOG(INFO, "VLAN filter not supported");
+   return -EINVAL;
+   }
+
+   if (rxmode->hw_vlan_extend) {
+   PMD_INIT_LOG(INFO, "VLAN extended not supported");
+   return -EINVAL;
+   }
+
+   if (rxmode->enable_lro) {
+   PMD_INIT_LOG(INFO, "LRO not supported");
+   return -EINVAL;
+   }
+
+   if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
+   PMD_INIT_LOG(INFO, "Setting link speed/duplex not supported");
+   return -EINVAL;
+   }
+
+   if (conf->dcb_capability_en) {
+   PMD_INIT_LOG(INFO, "DCB enable not supported");
+   return -EINVAL;
+   }
+
+   if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
+   PMD_INIT_LOG(INFO, "Flow director not supported");
+   return -EINVAL;
+   }
+
+   PMD_INIT_LOG(DEBUG, "Configured ethdev port%d hwcap=0x%" PRIx64,
+   dev->data->port_id, nicvf_hw_cap(nic));
+
+   return 0;
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
+   .dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
.get_reg_length   = nicvf_dev_get_reg_length,
.get_reg  = nicvf_dev_get_regs,
-- 
2.5.5



[dpdk-dev] [PATCH v4 04/19] net/thunderx: add get_reg and get_reg_length support

2016-06-13 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 6fa486a..5c066e2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -143,9 +143,36 @@ nicvf_dev_link_update(struct rte_eth_dev *dev,
return nicvf_atomic_write_link_status(dev, );
 }

+static int
+nicvf_dev_get_reg_length(struct rte_eth_dev *dev  __rte_unused)
+{
+   return nicvf_reg_get_count();
+}
+
+static int
+nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs)
+{
+   uint64_t *data = regs->data;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   if (data == NULL)
+   return -EINVAL;
+
+   /* Support only full register dump */
+   if ((regs->length == 0) ||
+   (regs->length == (uint32_t)nicvf_reg_get_count())) {
+   regs->version = nic->vendor_id << 16 | nic->device_id;
+   nicvf_reg_dump(nic, data);
+   return 0;
+   }
+   return -ENOTSUP;
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.link_update  = nicvf_dev_link_update,
+   .get_reg_length   = nicvf_dev_get_reg_length,
+   .get_reg  = nicvf_dev_get_regs,
 };

 static int
-- 
2.5.5



[dpdk-dev] [PATCH v4 03/19] net/thunderx: add link status and link update support

2016-06-13 Thread Jerin Jacob
Extended the nicvf_interrupt function to respond
NIC_MBOX_MSG_BGX_LINK_CHANGE mbox message from PF and update
struct rte_eth_link accordingly.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 53 -
 drivers/net/thunderx/nicvf_ethdev.h |  4 +++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 3ca5a2b..6fa486a 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -69,12 +69,45 @@

 #include "nicvf_logs.h"

+static inline int
+nicvf_atomic_write_link_status(struct rte_eth_dev *dev,
+  struct rte_eth_link *link)
+{
+   struct rte_eth_link *dst = >data->dev_link;
+   struct rte_eth_link *src = link;
+
+   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+   *(uint64_t *)src) == 0)
+   return -1;
+
+   return 0;
+}
+
+static inline void
+nicvf_set_eth_link_status(struct nicvf *nic, struct rte_eth_link *link)
+{
+   link->link_status = nic->link_up;
+   link->link_duplex = ETH_LINK_AUTONEG;
+   if (nic->duplex == NICVF_HALF_DUPLEX)
+   link->link_duplex = ETH_LINK_HALF_DUPLEX;
+   else if (nic->duplex == NICVF_FULL_DUPLEX)
+   link->link_duplex = ETH_LINK_FULL_DUPLEX;
+   link->link_speed = nic->speed;
+   link->link_autoneg = ETH_LINK_SPEED_AUTONEG;
+}
+
 static void
 nicvf_interrupt(void *arg)
 {
struct nicvf *nic = arg;

-   nicvf_reg_poll_interrupts(nic);
+   if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) {
+   if (nic->eth_dev->data->dev_conf.intr_conf.lsc)
+   nicvf_set_eth_link_status(nic,
+   >eth_dev->data->dev_link);
+   _rte_eth_dev_callback_process(nic->eth_dev,
+   RTE_ETH_EVENT_INTR_LSC);
+   }

rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
nicvf_interrupt, nic);
@@ -93,8 +126,26 @@ nicvf_periodic_alarm_stop(struct nicvf *nic)
return rte_eal_alarm_cancel(nicvf_interrupt, nic);
 }

+/*
+ * Return 0 means link status changed, -1 means not changed
+ */
+static int
+nicvf_dev_link_update(struct rte_eth_dev *dev,
+ int wait_to_complete __rte_unused)
+{
+   struct rte_eth_link link;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   memset(, 0, sizeof(link));
+   nicvf_set_eth_link_status(nic, );
+   return nicvf_atomic_write_link_status(dev, );
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
+   .link_update  = nicvf_dev_link_update,
 };

 static int
diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index d4d2071..8189856 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -38,6 +38,10 @@
 #define THUNDERX_NICVF_PMD_VERSION  "1.0"

 #define NICVF_INTR_POLL_INTERVAL_MS50
+#define NICVF_HALF_DUPLEX  0x00
+#define NICVF_FULL_DUPLEX  0x01
+#define NICVF_UNKNOWN_DUPLEX   0xff
+

 static inline struct nicvf *
 nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
-- 
2.5.5



[dpdk-dev] [PATCH v4 02/19] net/thunderx: add pmd skeleton

2016-06-13 Thread Jerin Jacob
Introduce driver initialization and enable build infrastructure for
nicvf pmd driver.

By default, It is enabled only for defconfig_arm64-thunderx-*
config as it is an inbuilt NIC device.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 config/common_base |  10 +
 config/defconfig_arm64-thunderx-linuxapp-gcc   |  10 +
 drivers/net/Makefile   |   1 +
 drivers/net/thunderx/Makefile  |  63 ++
 drivers/net/thunderx/nicvf_ethdev.c| 251 +
 drivers/net/thunderx/nicvf_ethdev.h|  48 
 drivers/net/thunderx/nicvf_logs.h  |  83 +++
 drivers/net/thunderx/nicvf_struct.h| 124 ++
 .../thunderx/rte_pmd_thunderx_nicvf_version.map|   4 +
 mk/rte.app.mk  |   2 +
 10 files changed, 596 insertions(+)
 create mode 100644 drivers/net/thunderx/Makefile
 create mode 100644 drivers/net/thunderx/nicvf_ethdev.c
 create mode 100644 drivers/net/thunderx/nicvf_ethdev.h
 create mode 100644 drivers/net/thunderx/nicvf_logs.h
 create mode 100644 drivers/net/thunderx/nicvf_struct.h
 create mode 100644 drivers/net/thunderx/rte_pmd_thunderx_nicvf_version.map

diff --git a/config/common_base b/config/common_base
index 47c26f6..ad5686b 100644
--- a/config/common_base
+++ b/config/common_base
@@ -259,6 +259,16 @@ CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2_AS=0

 #
+# Compile burst-oriented Cavium Thunderx NICVF PMD driver
+#
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_MBOX=n
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
diff --git a/config/defconfig_arm64-thunderx-linuxapp-gcc 
b/config/defconfig_arm64-thunderx-linuxapp-gcc
index fe5e987..7940bbd 100644
--- a/config/defconfig_arm64-thunderx-linuxapp-gcc
+++ b/config/defconfig_arm64-thunderx-linuxapp-gcc
@@ -34,3 +34,13 @@
 CONFIG_RTE_MACHINE="thunderx"

 CONFIG_RTE_CACHE_LINE_SIZE=128
+
+#
+# Compile Cavium Thunderx NICVF PMD driver
+#
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD=y
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_MBOX=n
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6ba7658..0e29a33 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -50,6 +50,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += pcap
 DIRS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += ring
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
+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
diff --git a/drivers/net/thunderx/Makefile b/drivers/net/thunderx/Makefile
new file mode 100644
index 000..eb9f100
--- /dev/null
+++ b/drivers/net/thunderx/Makefile
@@ -0,0 +1,63 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Cavium Networks. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Cavium Networks 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 

[dpdk-dev] [PATCH v4 01/19] net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC

2016-06-13 Thread Jerin Jacob
Adds hardware specific API for ThunderX nicvf inbuilt NIC device under
drivers/net/thunderx/nicvf/base directory.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_hw.c  |  905 +
 drivers/net/thunderx/base/nicvf_hw.h  |  240 ++
 drivers/net/thunderx/base/nicvf_hw_defs.h | 1219 +
 drivers/net/thunderx/base/nicvf_mbox.c|  418 ++
 drivers/net/thunderx/base/nicvf_mbox.h|  232 ++
 drivers/net/thunderx/base/nicvf_plat.h|  132 
 6 files changed, 3146 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_hw.c
 create mode 100644 drivers/net/thunderx/base/nicvf_hw.h
 create mode 100644 drivers/net/thunderx/base/nicvf_hw_defs.h
 create mode 100644 drivers/net/thunderx/base/nicvf_mbox.c
 create mode 100644 drivers/net/thunderx/base/nicvf_mbox.h
 create mode 100644 drivers/net/thunderx/base/nicvf_plat.h

diff --git a/drivers/net/thunderx/base/nicvf_hw.c 
b/drivers/net/thunderx/base/nicvf_hw.c
new file mode 100644
index 000..001b0ed
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -0,0 +1,905 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   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 Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nicvf_plat.h"
+
+struct nicvf_reg_info {
+   uint32_t offset;
+   const char *name;
+};
+
+#define NICVF_REG_POLL_ITER_NR   (10)
+#define NICVF_REG_POLL_DELAY_US  (2000)
+#define NICVF_REG_INFO(reg) {reg, #reg}
+
+static const struct nicvf_reg_info nicvf_reg_tbl[] = {
+   NICVF_REG_INFO(NIC_VF_CFG),
+   NICVF_REG_INFO(NIC_VF_PF_MAILBOX_0_1),
+   NICVF_REG_INFO(NIC_VF_INT),
+   NICVF_REG_INFO(NIC_VF_INT_W1S),
+   NICVF_REG_INFO(NIC_VF_ENA_W1C),
+   NICVF_REG_INFO(NIC_VF_ENA_W1S),
+   NICVF_REG_INFO(NIC_VNIC_RSS_CFG),
+   NICVF_REG_INFO(NIC_VNIC_RQ_GEN_CFG),
+};
+
+static const struct nicvf_reg_info nicvf_multi_reg_tbl[] = {
+   {NIC_VNIC_RSS_KEY_0_4 + 0,  "NIC_VNIC_RSS_KEY_0"},
+   {NIC_VNIC_RSS_KEY_0_4 + 8,  "NIC_VNIC_RSS_KEY_1"},
+   {NIC_VNIC_RSS_KEY_0_4 + 16, "NIC_VNIC_RSS_KEY_2"},
+   {NIC_VNIC_RSS_KEY_0_4 + 24, "NIC_VNIC_RSS_KEY_3"},
+   {NIC_VNIC_RSS_KEY_0_4 + 32, "NIC_VNIC_RSS_KEY_4"},
+   {NIC_VNIC_TX_STAT_0_4 + 0,  "NIC_VNIC_STAT_TX_OCTS"},
+   {NIC_VNIC_TX_STAT_0_4 + 8,  "NIC_VNIC_STAT_TX_UCAST"},
+   {NIC_VNIC_TX_STAT_0_4 + 16,  "NIC_VNIC_STAT_TX_BCAST"},
+   {NIC_VNIC_TX_STAT_0_4 + 24,  "NIC_VNIC_STAT_TX_MCAST"},
+   {NIC_VNIC_TX_STAT_0_4 + 32,  "NIC_VNIC_STAT_TX_DROP"},
+   {NIC_VNIC_RX_STAT_0_13 + 0,  "NIC_VNIC_STAT_RX_OCTS"},
+   {NIC_VNIC_RX_STAT_0_13 + 8,  "NIC_VNIC_STAT_RX_UCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 16, "NIC_VNIC_STAT_RX_BCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 24, "NIC_VNIC_STAT_RX_MCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 32, "NIC_VNIC_STAT_RX_RED"},
+   {NIC_VNIC_RX_STAT_0_13 + 40, "NIC_VNIC_STAT_RX_RED_OCTS"},
+   {NIC_VNIC_RX_STAT_0_13 + 48, "NIC_VNIC_STAT_RX_ORUN"},
+   {NIC_VNIC_RX_STAT_0_13 + 56, "NIC_VNIC_STAT_RX_ORUN_OCTS"},
+   {NIC_VNIC_RX_STAT_0_13 + 64, "NIC_VNIC_STAT_RX_FCS"},
+   {NIC_VNIC_RX_STAT_0_13 + 72, "NIC_VNIC_STAT_RX_L2ERR"},
+   

[dpdk-dev] [PATCH v4 00/19] DPDK PMD for ThunderX NIC device

2016-06-13 Thread Jerin Jacob
This patch set provides the initial version of DPDK PMD for the
built-in NIC device in Cavium ThunderX SoC family.

Implemented features and ThunderX nicvf PMD documentation added
in doc/guides/nics/overview.rst and doc/guides/nics/thunderx.rst
respectively in this patch set.

These patches are checked using checkpatch.sh with following
additional ignore option:
options="$options --ignore=CAMELCASE,BRACKET_SPACE"
CAMELCASE - To accommodate PRIx64
BRACKET_SPACE - To accommodate AT inline line assembly in two places

This patch set is based on DPDK 16.07-RC1
and tested with git HEAD change-set
ca173a909538a2f1082cd0dcb4d778a97dab69c3 along with
following depended patch

http://dpdk.org/dev/patchwork/patch/11826/
ethdev: add tunnel and port RSS offload types

V1->V2

http://dpdk.org/dev/patchwork/patch/12609/
-- added const for the const struct tables
-- remove multiple blank lines
-- addressed style comments
http://dpdk.org/dev/patchwork/patch/12610/
-- removed DEPDIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += lib/librte_net 
lib/librte_malloc
-- add const for table structs
-- addressed style comments
http://dpdk.org/dev/patchwork/patch/12614/
-- s/DEFAULT_*/NICVF_DEFAULT_*/gc
http://dpdk.org/dev/patchwork/patch/12615/
-- Fix typos
-- addressed style comments
http://dpdk.org/dev/patchwork/patch/12616/
-- removed redundant txq->tail = 0 and txq->head = 0
http://dpdk.org/dev/patchwork/patch/12627/
-- fixed the documentation changes

-- fixed TAB+space occurrences in functions
-- rebased to c8c33ad7f94c59d1c0676af0cfd61207b3e808db

V2->V3

http://dpdk.org/dev/patchwork/patch/13060/
-- Changed polling infrastructure to use rte_eal_alarm* instead of 
timerfd_create API
-- rebased to ca173a909538a2f1082cd0dcb4d778a97dab69c3

V3->V4

ddressed review comments of Ferruh's review

http://dpdk.org/dev/patchwork/patch/13314/
-- s/avilable/available
http://dpdk.org/dev/patchwork/patch/13323/
-- s/witout/without

http://dpdk.org/dev/patchwork/patch/13318/
-- s/nicvf_free_xmittted_buffers/nicvf_free_xmitted_buffers
-- fix checkpatch errors
http://dpdk.org/dev/patchwork/patch/13307/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13308/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13320/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13321/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13322/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13324/
-- addressed review comments and created separated patch for
platform specific config change

-- update change log to net/thunderx: 

Jerin Jacob (19):
  net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC
  net/thunderx: add pmd skeleton
  net/thunderx: add link status and link update support
  net/thunderx: add get_reg and get_reg_length support
  net/thunderx: add dev_configure support
  net/thunderx: add dev_infos_get support
  net/thunderx: add rx_queue_setup/release support
  net/thunderx: add tx_queue_setup/release support
  net/thunderx: add rss and reta query and update support
  net/thunderx: add mtu_set and promiscuous_enable support
  net/thunderx: add stats support
  net/thunderx: add single and multi segment tx functions
  net/thunderx: add single and multi segment rx functions
  net/thunderx: add dev_supported_ptypes_get and rx_queue_count support
  net/thunderx: add rx queue start and stop support
  net/thunderx: add tx queue start and stop support
  net/thunderx: add device start,stop and close support
  net/thunderx: updated driver documentation and release notes
  maintainers: claim responsibility for the ThunderX nicvf PMD

 MAINTAINERS|6 +
 config/common_base |   10 +
 config/defconfig_arm64-thunderx-linuxapp-gcc   |   10 +
 doc/guides/nics/index.rst  |1 +
 doc/guides/nics/overview.rst   |   96 +-
 doc/guides/nics/thunderx.rst   |  354 
 doc/guides/rel_notes/release_16_07.rst |1 +
 drivers/net/Makefile   |1 +
 drivers/net/thunderx/Makefile  |   65 +
 drivers/net/thunderx/base/nicvf_hw.c   |  905 ++
 drivers/net/thunderx/base/nicvf_hw.h   |  240 +++
 drivers/net/thunderx/base/nicvf_hw_defs.h  | 1219 +
 drivers/net/thunderx/base/nicvf_mbox.c |  418 +
 drivers/net/thunderx/base/nicvf_mbox.h |  232 +++
 drivers/net/thunderx/base/nicvf_plat.h |  132 ++
 drivers/net/thunderx/nicvf_ethdev.c| 1789 
 drivers/net/thunderx/nicvf_ethdev.h|  106 ++
 drivers/net/thunderx/nicvf_logs.h  |   83 +
 drivers/net/thunderx/nicvf_rxtx.c  |  599 +++
 drivers/net/thunderx/nicvf_rxtx.h  |  101 ++
 drivers/net/thunderx/nicvf_struct.h|  124 ++
 

[dpdk-dev] Duplicate config symbols

2016-06-13 Thread Thomas Monjalon
2016-06-13 17:09, Christian Ehrhardt:
> On Mon, Jun 13, 2016 at 3:47 PM, Thomas Monjalon  6wind.com>
> wrote:
> 
> > 2016-06-13 13:50, Christian Ehrhardt:
> > > I wondered multiple times now when changing a config symbol that some of
> > > them are in the .config file multiple times.
> > > I totally feel like I'm overlooking something, but still it might be
> > worth
> > > to ask.
> > [...]
> > > Is there any reason to do so or is this an issue in make config?
> >
> > It is an issue in "make config" which has never been considered important.
> 
> I didn't want to make it more important :-)
> I'm fine with the second occurrence overwriting as it did a while now and
> knowing it is not a totally unknown issue.

Being a known issue doesn't mean we should not fix it ;)

> I had seen the old argument for not moving them out completely in the old
> thread - thanks for the link - that was important to understand why they
> are still there.
> Also found related patches from Keith about that now.

There were not enough strong opinions or consensus to move them.

> > We could remove the first - overridden - occurences.
> > I think it can be fixed in mk/rte.sdkconfig.mk.
> 
> You mean just filtering them eventually while keeping them where they are
> so that the old request to have "the base config shows all config options"
> still fulfilled - yeah that could be an approach to make everybody happy.

I would say it is not really related. We may decide any defconfig hierarchy,
and there still will be some cases where values are overriden.

> But then it would make for some evil unreadable sed or such, I could live
> with it as is knowing it is accepted as-is.
> I'll submit an RFC, but hope for someone with more dark magic to make it
> nicer.

There is an awk command in mk/rte.app.mk which could give you some ideas.



[dpdk-dev] [PATCH] port: add kni interface support

2016-06-13 Thread Ethan
Hi Cristian,

I've got your comments. Thank you for review the code from a DPDK newbie.
:-)
I plan to submit a new patch to fix all during this week hopefully.

There are four places I'd like to discuss further:

1. Dedicated lcore for kni kernel thread
First of all, it is a bug to add kni kernel core to the user space core
mask. What I want is just to check if the kni kernel thread has a dedicated
core.
The reason I prefer to allocate a dedicated core to kni kernel thread is
that my application is latency sensitive. I worry the context switch and
cache miss will cause the latency increasing if the kni kernel thread and
application thread share one core.
Anyway, I think I should remove the hard coded check because it will be
more generic. Users who has the similar usage like mine can achieve so
through configuration file.

2. The compiler error of the Macro RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD
Actually I implements the macro similar
to RTE_PORT_RING_READER_STATS_PKTS_IN_ADD first. But the
scripts/checkpatches.sh fails: ERROR:COMPLEX_MACRO: Macros with complex
values should be enclosed in parentheses
I'm not share either I have done something wrong or the checkpatches script
need an update.

3. KNI kernel operations callback
To be  honest, I made reference to the the KNI sample application.
Since there is very little docs tell the difference between link up call
and device start call, I am not sure which one is better here.
Any help will be appreciate. :-)

4. Shall I use DPDK_16.07 in the  librte_port/rte_port_version.map file?



2016-06-10 7:42 GMT+08:00 Dumitrescu, Cristian <
cristian.dumitrescu at intel.com>:

> Hi Ethan,
>
> Great work! There are still several comments below that need to be
> addressed, but I am confident we can close on them quickly. Thank you!
>
> Please rebase the next version on top of the latest code on master branch.
>
> Please also update librte_port/rte_port_version.map file.
>
> Shall I use DPDK_16.07 in the  librte_port/rte_port_version.map file?


>
> > -Original Message-
> > From: WeiJie Zhuang [mailto:zhuangwj at gmail.com]
> > Sent: Saturday, May 28, 2016 12:26 PM
> > To: Dumitrescu, Cristian 
> > Cc: dev at dpdk.org; WeiJie Zhuang 
> > Subject: [PATCH] port: add kni interface support
> >
> > 1. add KNI port type to the packet framework
> > 2. add KNI support to the IP Pipeline sample Application
> >
> > Signed-off-by: WeiJie Zhuang 
> > ---
> > v2:
> > * Fix check patch error.
> > ---
> >  doc/api/doxy-api-index.md   |   1 +
> >  examples/ip_pipeline/Makefile   |   6 +-
> >  examples/ip_pipeline/app.h  |  74 +
> >  examples/ip_pipeline/config/kni.cfg |  12 ++
> >  examples/ip_pipeline/config_check.c |  34 
> >  examples/ip_pipeline/config_parse.c | 130 +++
> >  examples/ip_pipeline/init.c |  79 +
> >  examples/ip_pipeline/kni/kni.c  |  80 +
> >  examples/ip_pipeline/kni/kni.h  |  16 ++
> >  examples/ip_pipeline/pipeline_be.h  |  13 ++
> >  examples/ip_pipeline/thread.c   |   9 +
> >  lib/librte_port/Makefile|   7 +
> >  lib/librte_port/rte_port_kni.c  | 316
> > 
> >  lib/librte_port/rte_port_kni.h  |  81 +
> >  14 files changed, 856 insertions(+), 2 deletions(-)
> >  create mode 100644 examples/ip_pipeline/config/kni.cfg
> >  create mode 100644 examples/ip_pipeline/kni/kni.c
> >  create mode 100644 examples/ip_pipeline/kni/kni.h
> >  create mode 100644 lib/librte_port/rte_port_kni.c
> >  create mode 100644 lib/librte_port/rte_port_kni.h
> >
> > diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
> > index f626386..e38a959 100644
> > --- a/doc/api/doxy-api-index.md
> > +++ b/doc/api/doxy-api-index.md
> > @@ -119,6 +119,7 @@ There are many libraries, so their headers may be
> > grouped by topics:
> >  [reass](@ref rte_port_ras.h),
> >  [sched](@ref rte_port_sched.h),
> >  [src/sink] (@ref rte_port_source_sink.h)
> > +[kni]  (@ref rte_port_kni.h)
> >* [table](@ref rte_table.h):
> >  [lpm IPv4] (@ref rte_table_lpm.h),
> >  [lpm IPv6] (@ref rte_table_lpm_ipv6.h),
> > diff --git a/examples/ip_pipeline/Makefile
> b/examples/ip_pipeline/Makefile
> > index 10fe1ba..848c2aa 100644
> > --- a/examples/ip_pipeline/Makefile
> > +++ b/examples/ip_pipeline/Makefile
> > @@ -43,9 +43,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
> >  # binary name
> >  APP = ip_pipeline
> >
> > +VPATH += $(SRCDIR)/kni
> >  VPATH += $(SRCDIR)/pipeline
> >
> > -INC += $(wildcard *.h) $(wildcard pipeline/*.h)
> > +INC += $(wildcard *.h) $(wildcard pipeline/*.h) $(wildcard kni/*.h)
> >
> >  # all source are stored in SRCS-y
> >  SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
> > @@ -56,6 +57,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
> >  SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c
> >  SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread_fe.c
> >  

[dpdk-dev] [PATCH v3 18/20] thunderx/config: set max numa node to two

2016-06-13 Thread Jerin Jacob
On Wed, Jun 08, 2016 at 06:54:43PM +0100, Ferruh Yigit wrote:
> On 6/7/2016 5:40 PM, Jerin Jacob wrote:
> > Signed-off-by: Jerin Jacob 
> > ---
> >  config/defconfig_arm64-thunderx-linuxapp-gcc | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/config/defconfig_arm64-thunderx-linuxapp-gcc 
> > b/config/defconfig_arm64-thunderx-linuxapp-gcc
> > index 7940bbd..cc12cee 100644
> > --- a/config/defconfig_arm64-thunderx-linuxapp-gcc
> > +++ b/config/defconfig_arm64-thunderx-linuxapp-gcc
> > @@ -34,6 +34,7 @@
> >  CONFIG_RTE_MACHINE="thunderx"
> >  
> >  CONFIG_RTE_CACHE_LINE_SIZE=128
> > +CONFIG_RTE_MAX_NUMA_NODES=2
> Isn't this platform level configuration? And sets max numa nodes
> independent from driver, right?
> 

Yes

> Can you please add some more information why this is required?
> 
> Also does it make sense to separate this patch from driver patchset?

Yes, I will separate this patch from the series.

Thanks Ferruh for the comprehensive review of this patch series.
I will send the v4, addressing all of your review comments.

Jerin

> 
> >  
> >  #
> >  # Compile Cavium Thunderx NICVF PMD driver
> > 
> 


[dpdk-dev] [PATCH] virtio: fix allocating virtnet_rx not mem aligned

2016-06-13 Thread Yuanhan Liu
On Mon, Jun 13, 2016 at 10:06:22AM +, Tan, Jianfeng wrote:
> 
> 
> > -Original Message-
> > From: Yuanhan Liu [mailto:yuanhan.liu at linux.intel.com]
> > Sent: Monday, June 13, 2016 5:52 PM
> > To: Tan, Jianfeng
> > Cc: dev at dpdk.org; Xie, Huawei
> > Subject: Re: [dpdk-dev] [PATCH] virtio: fix allocating virtnet_rx not mem
> > aligned
> > 
> > On Mon, Jun 13, 2016 at 05:21:01PM +0800, Yuanhan Liu wrote:
> > > On Sun, Jun 12, 2016 at 02:29:42PM +, Jianfeng Tan wrote:
> > > > Compile DPDK with clang, below line in virtio_rxtx.c could be
> > > > optimized with four "VMOVAPS ymm, m256".
> > > >   memset(>fake_mbuf, 0, sizeof(rxvq->fake_mbuf));
> > > >
> > > > This instruction requires memory address is 32-byte aligned.
> > > > Or, it leads to segfault.
> > >
> > > That looks like a dangerous optimization to me. If that's the case,
> > > doesn't it mean we have to make sure the address is always aligned
> > > properly while calling memset?
> > 
> > Above is just a side note. Anyway, I think making sure vq is cache
> > aligned is good here. So, I will apply it. BTW, do you mind if I
> > squash your 2 fixes into Huawei's Rx/Tx split commit? His commit is
> > not pushed to upstream yet, therefore I can still do rebase: I'm
> > thinking it's better to have one working commit other than one broken
> > commit followed with several fixing commits. And of course, I will
> > mention your contribution in the commit log.
> 
> Not a problem from my side. But Huawei seems to have concerns on this fix. 
> You can do that for the other fix firstly.

What's the concern? Despite the clang issue (I still have no idea why
clang would go that aggressively), I think making vq cache aligned is
generically a good idea.

--yliu


[dpdk-dev] [PATCH v2 1/4] virtio-user: use virtual address in cq

2016-06-13 Thread Yuanhan Liu
On Mon, Jun 13, 2016 at 06:43:40AM +, Jianfeng Tan wrote:
> Change to use virtio_net_hdr_mem instead of physical addr of memzone
> when sending contrl queue commands. The virtio_net_hdr_mem has been
> initialized to use virtual address under the case of virtio-user.

I'd suggest to squash this patch to "[PATCH v8 2/6] virtio: enable use
virtual address to fill desc". There is really no good reason to make 2
patches to do same/similar thing.

--yliu


[dpdk-dev] [PATCH] virtio: fix allocating virtnet_rx not mem aligned

2016-06-13 Thread Tan, Jianfeng


On 6/13/2016 5:21 PM, Yuanhan Liu wrote:
> On Sun, Jun 12, 2016 at 02:29:42PM +, Jianfeng Tan wrote:
>> Compile DPDK with clang, below line in virtio_rxtx.c could be
>> optimized with four "VMOVAPS ymm, m256".
>>memset(>fake_mbuf, 0, sizeof(rxvq->fake_mbuf));
>>
>> This instruction requires memory address is 32-byte aligned.
>> Or, it leads to segfault.
> That looks like a dangerous optimization to me.If that's the case,
> doesn't it mean we have to make sure the address is always aligned
> properly while calling memset?

I guess clang does such optimization when length is a 32-byte aligned 
immediate number. May need more information here.

Thanks,
Jianfeng

>
>   --yliu



[dpdk-dev] [PATCH v2 4/4] virtio-user: handle ctrl-q in driver

2016-06-13 Thread Yuanhan Liu
On Mon, Jun 13, 2016 at 06:43:43AM +, Jianfeng Tan wrote:
> In virtio-user driver, when notify ctrl-queue, invoke API of
> virtio-user device emulation to handle ctrl-q command.
> 
> Besides, multi-queue requires ctrl-queue and ctrl-queue will be
> enabled automatically when multi-queue is specified.
> 
> Signed-off-by: Jianfeng Tan 
> ---
>  drivers/net/virtio/virtio_user_ethdev.c | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 8f401a3..4c9279e 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -42,6 +42,7 @@
>  #include "virtio_logs.h"
>  #include "virtio_pci.h"
>  #include "virtqueue.h"
> +#include "virtio_rxtx.h"

What's this include for?

--yliu


[dpdk-dev] [PATCH v2] mbuf: new flag when Vlan is stripped

2016-06-13 Thread Olivier Matz
Hi Konstantin,

On 06/13/2016 04:42 PM, Ananyev, Konstantin wrote:
>> The behavior of PKT_RX_VLAN_PKT was not very well defined, resulting in
>> PMDs not advertising the same flags in similar conditions.
>>
>> Following discussion in [1], introduce 2 new flags PKT_RX_VLAN_STRIPPED
>> and PKT_RX_QINQ_STRIPPED that are better defined:
>>
>>   PKT_RX_VLAN_STRIPPED: a vlan has been stripped by the hardware and its
>>   tci is saved in mbuf->vlan_tci. This can only happen if vlan stripping
>>   is enabled in the RX configuration of the PMD.
>>
>> For now, the old flag PKT_RX_VLAN_PKT is kept but marked as deprecated.
>> It should be removed from applications and PMDs in a future revision.
> 
> I am not sure it has to be deprecated & removed.
> ixgbe (and igb as I can read the specs) devices can provide information is 
> that
> a vlan packet or not even when vlan stripping is disabled. 
> Right now ixgbe PMD do carry thins information to the user,
> and I suppose igb could be improved to carry it too.
> So obviously we need a way to pass that information to the upper layer.
> I remember it was a discussion about introducing new packet_type
> instead of ol_flag value PKT_RX_VLAN_PKT.
> But right now it is not there, and again I don't know how easy it would be to 
> replace
> one with another without performance considering that packet_type is not 
> supported
> now by ixgbe vRX.
> If we would be able to replace it, then yes we can deprecate and drop the   
> PKT_RX_VLAN_PKT.
> But till then, I think we'd better keep it.

I think the packet_type feature would be more appropriate than a flag
for carrying this kind of info.

Currently the behavior of PKT_RX_VLAN_PKT is not properly defined,
and it is not the same on all PMDs. So, from an application
perspective, it's not usable except if it knows that the underlying
PMD is an ixgbe. This is not acceptable for a generic API and that's
why I think this flag, as it is today, should be deprecated.

It won't prevent an application from using the flag right after my
commit, but it will warn the user that the flag should not be used
as is. If someone is willing to work on this feature for 16.11, why
not but again, I think using the packet_type is more appropriate.

The problem is that I don't want to have this flag in this state
forever, and I also don't want to add in rte_mbuf.h a comment
saying "this flag does this on ixgbe and that on other drivers".

If we decide to generalize the ixgbe behavior for all PMDs for this
flag, it will break the applications relying on this flag but with
other PMDs. So for the same reason we added a new PKT_RX_VLAN_STRIPPED
we cannot change the behavior of an existing flag.



>> @@ -270,6 +277,11 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct 
>> rte_mbuf **rx_pkts,
>>   */
>>  sw_ring = >sw_ring[rxq->rx_tail];
>>
>> +/* ensure these 2 flags are in the lower 8 bits */
>> +RTE_BUILD_BUG_ON(((PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED) &
>> +0xff00ULL) != 0ULL);
> 
> 
> I suppose your need here:
> RTE_BUILD_BUG_ON(((PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED) & UINT8_MAX) == 
> PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED));
> 
> To make sure both flags are inside first 8 bits?

Yes, indeed that's much better than 14 'f' :)

>> +vlan_flags = rxq->vlan_flags & 0xff;
>> +
> 
> Probably better to do that check/ AND at setup  phase, not run-time?
> As a nit: s/0xff/UINT8_MAX/.

Yep, agree, I'll change that.


Thanks for reviewing
Olivier


[dpdk-dev] [PATCH v3 08/20] vhost: introduce new API to export numa node

2016-06-13 Thread Yuanhan Liu
On Thu, Jun 09, 2016 at 12:45:00PM +0800, Yuanhan Liu wrote:
> On Wed, Jun 08, 2016 at 02:51:33PM -0700, Rich Lane wrote:
> > On Mon, Jun 6, 2016 at 8:51 PM, Yuanhan Liu 
> > wrote:
> > 
> > @@ -248,14 +248,9 @@ new_device(struct virtio_net *dev)
> > ? ? ? ? internal = eth_dev->data->dev_private;
> > 
> > ?#ifdef RTE_LIBRTE_VHOST_NUMA
> > -? ? ? ?ret? = get_mempolicy(, NULL, 0, dev,
> > -? ? ? ? ? ? ? ? ? ? ? ?MPOL_F_NODE | MPOL_F_ADDR);
> > -? ? ? ?if (ret < 0) {
> > -? ? ? ? ? ? ? ?RTE_LOG(ERR, PMD, "Unknown numa node\n");
> > -? ? ? ? ? ? ? ?return -1;
> > -? ? ? ?}
> > -
> > -? ? ? ?eth_dev->data->numa_node = newnode;
> > +? ? ? ?newnode = rte_vhost_get_numa_node(dev->vid);
> > +? ? ? ?if (newnode > 0)
> > 
> > 
> > Should be "newnode >= 0".?
> 
> Nice catch! Thanks.

Here is the update patch that includes the fix of two issues reported by
Rich and Panu.

And if there is no objection, I'd like to apply this series plus some
other series on virtio/vhost from mine in one or two days: it's close
to the RC1 deadline now.

--yliu

---
>From f378af61f6ba7dcfcd20ab180fba166619ea3d88 Mon Sep 17 00:00:00 2001
From: Yuanhan Liu 
Date: Wed, 11 May 2016 06:12:57 +0800
Subject: [PATCH] vhost: introduce new API to export numa node

Introduce a new API rte_vhost_get_numa_node() to get the numa node
from which the virtio_net struct is allocated.

Signed-off-by: Yuanhan Liu 
Tested-by: Rich Lane 
Acked-by: Rich Lane 
---

v4: - fix build error in shared configuration reported by Panu
- fix numa node check reported by Rich
---
 drivers/net/vhost/rte_eth_vhost.c  | 13 -
 lib/librte_vhost/rte_vhost_version.map |  7 +++
 lib/librte_vhost/rte_virtio_net.h  | 12 
 lib/librte_vhost/virtio-net.c  | 26 ++
 4 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 63538c1..a00351b 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -230,7 +230,7 @@ new_device(struct virtio_net *dev)
struct vhost_queue *vq;
unsigned i;
 #ifdef RTE_LIBRTE_VHOST_NUMA
-   int newnode, ret;
+   int newnode;
 #endif

if (dev == NULL) {
@@ -248,14 +248,9 @@ new_device(struct virtio_net *dev)
internal = eth_dev->data->dev_private;

 #ifdef RTE_LIBRTE_VHOST_NUMA
-   ret  = get_mempolicy(, NULL, 0, dev,
-   MPOL_F_NODE | MPOL_F_ADDR);
-   if (ret < 0) {
-   RTE_LOG(ERR, PMD, "Unknown numa node\n");
-   return -1;
-   }
-
-   eth_dev->data->numa_node = newnode;
+   newnode = rte_vhost_get_numa_node(dev->vid);
+   if (newnode >= 0)
+   eth_dev->data->numa_node = newnode;
 #endif

for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
diff --git a/lib/librte_vhost/rte_vhost_version.map 
b/lib/librte_vhost/rte_vhost_version.map
index 3d8709e..a323fa0 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -20,3 +20,10 @@ DPDK_2.1 {
rte_vhost_driver_unregister;

 } DPDK_2.0;
+
+DPDK_16.07 {
+   global:
+
+   rte_vhost_get_numa_node;
+
+} DPDK_2.1;
diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index bc64e89..b8e9b02 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -245,6 +245,18 @@ int rte_vhost_driver_callback_register(struct 
virtio_net_device_ops const * cons
 int rte_vhost_driver_session_start(void);

 /**
+ * Get the numa node from which the virtio net device's memory
+ * is allocated.
+ *
+ * @param vid
+ *  virtio-net device ID
+ *
+ * @return
+ *  The numa node, -1 on failure
+ */
+int rte_vhost_get_numa_node(int vid);
+
+/**
  * This function adds buffers to the virtio devices RX virtqueue. Buffers can
  * be received from the physical port or from another virtual device. A packet
  * count is returned to indicate the number of packets that were succesfully
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index c6d3829..25b6515 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -730,6 +730,32 @@ vhost_set_backend(int vid, struct vhost_vring_file *file)
return 0;
 }

+int
+rte_vhost_get_numa_node(int vid)
+{
+#ifdef RTE_LIBRTE_VHOST_NUMA
+   struct virtio_net *dev = get_device(vid);
+   int numa_node;
+   int ret;
+
+   if (dev == NULL)
+   return -1;
+
+   ret = get_mempolicy(_node, NULL, 0, dev,
+   MPOL_F_NODE | MPOL_F_ADDR);
+   if (ret < 0) {
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "(%d) failed to query numa node: %d\n", vid, ret);
+   return -1;
+   }
+
+   return numa_node;
+#else
+   RTE_SET_USED(vid);
+   return -1;
+#endif
+}
+
 

[dpdk-dev] [PATCH] examples/vhost: fix corrupted vdev tailq list

2016-06-13 Thread Yuanhan Liu
On Tue, Jun 07, 2016 at 11:32:56AM +0800, Yuanhan Liu wrote:
> There are two tailq lists, one for logging all vhost devices, another
> one for logging vhost devices distributed on a specific core. However,
> there is just one tailq entry, named "next", to chain the two list,
> which is wrong and could result to a corrupted tailq list, that the
> tailq list might always be non-empty: the entry is still there even
> after you have invoked TAILQ_REMOVE several times.
> 
> Fix it by introducing two tailq entries, one for each list.
> 
> Fixes: 45657a5c6861 ("examples/vhost: use tailq to link vhost devices")
> 
> Signed-off-by: Yuanhan Liu 

Applied to dpdk-next-virtio.

--yliu


[dpdk-dev] [PATCH] virtio: fix allocating virtnet_rx not mem aligned

2016-06-13 Thread Yuanhan Liu
On Mon, Jun 13, 2016 at 05:21:01PM +0800, Yuanhan Liu wrote:
> On Sun, Jun 12, 2016 at 02:29:42PM +, Jianfeng Tan wrote:
> > Compile DPDK with clang, below line in virtio_rxtx.c could be
> > optimized with four "VMOVAPS ymm, m256".
> >   memset(>fake_mbuf, 0, sizeof(rxvq->fake_mbuf));
> > 
> > This instruction requires memory address is 32-byte aligned.
> > Or, it leads to segfault.
> 
> That looks like a dangerous optimization to me. If that's the case,
> doesn't it mean we have to make sure the address is always aligned
> properly while calling memset?

Above is just a side note. Anyway, I think making sure vq is cache
aligned is good here. So, I will apply it. BTW, do you mind if I
squash your 2 fixes into Huawei's Rx/Tx split commit? His commit is
not pushed to upstream yet, therefore I can still do rebase: I'm
thinking it's better to have one working commit other than one broken
commit followed with several fixing commits. And of course, I will
mention your contribution in the commit log.

--yliu  


[dpdk-dev] dpdk and sriov nic without igb_uio

2016-06-13 Thread nirmoy das
Hi ..,

I am trying to find a way to use dpdk in a VM with sriov nic
without using igb_uio.

uio_pci_generic: failed with  "No IRQ assigned to device: no support for
interrupts?".
vfio-pci also doesn't work on linux < 4.5 and need dpdk > 16.04.

Is this a deadend  for dpdk+sriov If I have linux < 4.5 and/or dpdk < 16.04?

Regards,
Nirmoy


[dpdk-dev] [PATCH] virito: fix reuse index in nested loop

2016-06-13 Thread Yuanhan Liu
On Mon, Jun 13, 2016 at 09:11:57AM +, Tan, Jianfeng wrote:
> 
> 
> > -Original Message-
> > From: Yuanhan Liu [mailto:yuanhan.liu at linux.intel.com]
> > Sent: Monday, June 13, 2016 4:58 PM
> > To: Tan, Jianfeng
> > Cc: dev at dpdk.org; Xie, Huawei
> > Subject: Re: [PATCH] virito: fix reuse index in nested loop
> > 
> > On Sun, Jun 12, 2016 at 10:05:45AM +, Jianfeng Tan wrote:
> > > This patches fixes problem of reusing index of outmost loop in nested
> > > loops. This bug will lead to failure when starting a multi queue
> > > virtio device: rx queues (except from the first one) cannot be started,
> > > expecially their vq_ring cannot be initialized, so that when invoking
> > > rx func on these queues, segment fault happens.
> > >
> > > Fixes: a900472aedef ("virtio: split virtio Rx/Tx queue")
> > 
> > Good catch!
> > 
> > > Signed-off-by: Jianfeng Tan 
> > > ---
> > >  drivers/net/virtio/virtio_rxtx.c | 36 
> > > 
> > >  1 file changed, 20 insertions(+), 16 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio/virtio_rxtx.c 
> > > b/drivers/net/virtio/virtio_rxtx.c
> > > index 2e7205b..b96d0cb 100644
> > > --- a/drivers/net/virtio/virtio_rxtx.c
> > > +++ b/drivers/net/virtio/virtio_rxtx.c
> > > @@ -331,7 +331,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev)
> > >* -Allocate blank mbufs for the each rx descriptor
> > >*
> > >*/
> > > - int i;
> > > + int i, j;
> > 
> > However, I don't quite like using "i, j, k" stuff. So, how about
> > renaming "j" to "ring_idx"?
> > 
> > >   PMD_INIT_FUNC_TRACE();
> > >
> > > @@ -352,15 +352,18 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev)
> > >   error = ENOSPC;
> > >
> > >  #ifdef RTE_MACHINE_CPUFLAG_SSSE3
> > > - if (use_simple_rxtx)
> > > - for (i = 0; i < vq->vq_nentries; i++) {
> > > - vq->vq_ring.avail->ring[i] = i;
> > > - vq->vq_ring.desc[i].flags =
> > VRING_DESC_F_WRITE;
> > > + if (use_simple_rxtx) {
> > > + uint16_t k;
> > 
> > We could reuse "ring_idx" here; no need to define yet another iterate var
> > for that.
> 
> Make sense. Besides, since comparison between unsigned and signed is a 
> violation to static code analyzer, I'll redefine these variables as unsigned.
> Such as,
> int i -> uint16_t q_idx
> int j -> uint16_t r_idx
> k -> r_idx

It's nothing big deal, but if I were you, I would keep the var name "i"
unchanged (yes, we need define it to uint16_t), and introduce "ring_idx"
but not "r_idx": I will not sacrifice the readability by saving few
typings.

--yliu


[dpdk-dev] [PATCH 29/29] ixgbe/base: update README

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> update README.
It can be good to give some context here, like updated base driver
version and new base driver features listed...

> Besides, update release notes.
> 
> Signed-off-by: Beilei Xing 
> ---
>  doc/guides/rel_notes/release_16_07.rst | 11 +++
>  drivers/net/ixgbe/base/README  |  2 +-
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guides/rel_notes/release_16_07.rst 
> b/doc/guides/rel_notes/release_16_07.rst
> index 83c841b..77d53a0 100644
> --- a/doc/guides/rel_notes/release_16_07.rst
> +++ b/doc/guides/rel_notes/release_16_07.rst
> @@ -34,6 +34,17 @@ This section should contain new features added in this 
> release. Sample format:
>  
>Refer to the previous release notes for examples.
>  
> +* **Updated the ixgbe base driver.**
> +  The i40e base driver was updated with changes including the
Is it i40e or ixgbe base driver updated?

> +  following:
> +
> +  * Added sgmii link for X550.
> +  * Added mac link setup for x550a SFP and SFP+.
> +  * Added KR support for x550em_a.
> +  * Added new phy definitions for M88E1500.
> +  * Added support for the VLVF to be bypassed when adding/removing a VFTA 
> entry.
> +  * Added x550a flow control auto negotiation support.

...



[dpdk-dev] [PATCH 18/29] ixgbe/base: update swfw semaphore function

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> For X540 and forward it is possible if a system reset occur at the
> right time to leave the SWFW semaphore high. This new function will
> attempt to grab and release the semaphore. If the grab times out it
> will still release the semaphore placing it in a known good state.
> The idea is to call this when you know no one should be holding the
> semaphore (i.e. probe time)
> This patch alse fixes possible race issue between ports when issuing
> host interface command by acquiring/releasing the management host
> interface semaphore in ixgbe_host_interface_command.
> 
> Signed-off-by: Beilei Xing 
> ---
Does it make sense to separate this patch into two.

...

> +/**
> + *  ixgbe_init_swfw_semaphore - Clean up SWFW semaphore
> + *  @hw: pointer to hardware structure
> + *
> + *  Attempts to acquire the SWFW semaphore through SW_FW_SYNC register.
> + *  Regardless of whether is succeeds or not it then release the semaphore.
> + *  This is function is called to recover from catastrophic failures that
> + *  may have left the semaphore locked.
> + **/
> +void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw)
> +{
> + if (hw->mac.ops.init_swfw_sync)
> + hw->mac.ops.init_swfw_sync(hw);
> +}
One add ixgbe_init_swfw_semaphore related code (init_swfw_sync,
ixgbe_init_swfw_sync_X540)

...

> @@ -4390,6 +4392,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
> u32 *buffer,
>   DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
>   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
>   }
> + /* Take management host interface semaphore */
> + status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
> +
> + if (status)
> + return status;
> +
Second is fix in ixgbe_host_interface_command, they are unrelated as far
as I can see.

>   /* Set bit 9 of FWSTS clearing FW reset indication */
>   fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
>   IXGBE_WRITE_REG(hw, IXGBE_FWSTS, fwsts | IXGBE_FWSTS_FWRI);
...


[dpdk-dev] [PATCH 28/29] ixgbe/base: define if enable crosstalk work around

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> A work around for a new crosstalk erratum that causes link flap in
> emtry cages has beed introduced. So this patch defines the bit in
typo: emtry, beed

> NVM that will tell software if this work around is needed.
> 
> Signed-off-by: Beilei Xing 
> ---
...



[dpdk-dev] [PATCH 21/29] ixgbe/base: smplify add/remove VLANs

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> This patch simplifies the adding and removing VLANs from
> VFTA/VLVF/VLVFB registers. The logic to determine registers has
> been simplified to (vid / 32) and (1 - vid / 32). Many conditional
> paths and checks are no longer needed with this patch.
> 
> Signed-off-by: Beilei Xing 
> ---
typo on patch subject: smplify

...


[dpdk-dev] [PATCH 18/29] ixgbe/base: update swfw semaphore function

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> For X540 and forward it is possible if a system reset occur at the
> right time to leave the SWFW semaphore high. This new function will
> attempt to grab and release the semaphore. If the grab times out it
> will still release the semaphore placing it in a known good state.
> The idea is to call this when you know no one should be holding the
> semaphore (i.e. probe time)
> This patch alse fixes possible race issue between ports when issuing
typo: alse

> host interface command by acquiring/releasing the management host
> interface semaphore in ixgbe_host_interface_command.
> 
> Signed-off-by: Beilei Xing 
> ---

...


[dpdk-dev] [PATCH] virtio: fix allocating virtnet_rx not mem aligned

2016-06-13 Thread Yuanhan Liu
On Sun, Jun 12, 2016 at 02:29:42PM +, Jianfeng Tan wrote:
> Compile DPDK with clang, below line in virtio_rxtx.c could be
> optimized with four "VMOVAPS ymm, m256".
>   memset(>fake_mbuf, 0, sizeof(rxvq->fake_mbuf));
> 
> This instruction requires memory address is 32-byte aligned.
> Or, it leads to segfault.

That looks like a dangerous optimization to me. If that's the case,
doesn't it mean we have to make sure the address is always aligned
properly while calling memset?

--yliu


[dpdk-dev] [RFC] mk: filter duplicate configuration entries

2016-06-13 Thread Christian Ehrhardt
Due to the hierarchy and the demand to keep the base config shoing all
options some options end up multiple times in the .config file.

A suggested solution was to filter for duplicates at the end of the
actual config step which is implemented here.

Signed-off-by: Christian Ehrhardt 
---
 mk/rte.sdkconfig.mk | 5 +
 1 file changed, 5 insertions(+)

diff --git a/mk/rte.sdkconfig.mk b/mk/rte.sdkconfig.mk
index a3acfe6..734aa06 100644
--- a/mk/rte.sdkconfig.mk
+++ b/mk/rte.sdkconfig.mk
@@ -70,6 +70,11 @@ config: notemplate
 else
 config: $(RTE_OUTPUT)/include/rte_config.h $(RTE_OUTPUT)/Makefile
$(Q)$(MAKE) depdirs
+   tac $(RTE_OUTPUT)/.config | awk --field-separator '=' '!/^#/ {print 
$$1}' | while read config; do \
+   if [ $$(grep "^$${config}=" $(RTE_OUTPUT)/.config | wc -l) -gt 
1 ]; then \
+   sed -i "0,/$${config}/{//d}" $(RTE_OUTPUT)/.config; \
+   fi; \
+   done
@echo "Configuration done"
 endif

-- 
2.7.4



[dpdk-dev] Duplicate config symbols

2016-06-13 Thread Christian Ehrhardt
On Mon, Jun 13, 2016 at 3:47 PM, Thomas Monjalon 
wrote:

> 2016-06-13 13:50, Christian Ehrhardt:
> > I wondered multiple times now when changing a config symbol that some of
> > them are in the .config file multiple times.
> > I totally feel like I'm overlooking something, but still it might be
> worth
> > to ask.
> [...]
> > Is there any reason to do so or is this an issue in make config?
>
> It is an issue in "make config" which has never been considered important.
>

I didn't want to make it more important :-)
I'm fine with the second occurrence overwriting as it did a while now and
knowing it is not a totally unknown issue.

I had seen the old argument for not moving them out completely in the old
thread - thanks for the link - that was important to understand why they
are still there.
Also found related patches from Keith about that now.


> We could remove the first - overridden - occurences.
> I think it can be fixed in mk/rte.sdkconfig.mk.
>

You mean just filtering them eventually while keeping them where they are
so that the old request to have "the base config shows all config options"
still fulfilled - yeah that could be an approach to make everybody happy.
But then it would make for some evil unreadable sed or such, I could live
with it as is knowing it is accepted as-is.
I'll submit an RFC, but hope for someone with more dark magic to make it
nicer.

Kind Regards,
Christian


[dpdk-dev] [PATCH v5 10/10] app/test: do not dump PCI devices in blacklist test

2016-06-13 Thread Jan Viktorin
Dumping of devices in a unittest is useless. Instead, test whether
the test has been set up well - i.e. there are no devices.

Signed-off-by: Jan Viktorin 
---
 app/test/test_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 362ae3e..8051e53 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -238,7 +238,8 @@ test_pci_blacklist(void)
struct rte_devargs_list save_devargs_list;

printf("Dump all devices\n");
-   rte_eal_pci_dump(stdout);
+   TEST_ASSERT(TAILQ_EMPTY(_driver_list),
+   "pci_driver_list not empty");

rte_eal_pci_register(_driver);
rte_eal_pci_register(_driver2);
-- 
2.8.0



[dpdk-dev] [PATCH v5 09/10] eal/pci: allow to override sysfs

2016-06-13 Thread Jan Viktorin
The SYSFS_PCI_DEVICES is a constant that makes the PCI testing
difficult as it points to an absolute path. We remove using this
constant and introducing a function pci_get_sysfs_path that gives
the same value. However, the user can pass a SYSFS_PCI_DEVICES env
variable to override the path. It is now possible to create a fake
sysfs hierarchy for testing.

Signed-off-by: Jan Viktorin 
---
v3:
* changed subject
* test_pci_sysfs has been slightly modified to be more understandable
* fixed whitespace in *version.map files
v4:
* fixed checkpatch whitespace issue
---
 app/test/Makefile  |   1 +
 app/test/test_pci.c|  88 -
 .../bus/pci/devices/:01:00.0/class |   1 +
 .../bus/pci/devices/:01:00.0/config| Bin 0 -> 64 bytes
 .../devices/:01:00.0/consistent_dma_mask_bits  |   1 +
 .../bus/pci/devices/:01:00.0/device|   1 +
 .../bus/pci/devices/:01:00.0/dma_mask_bits |   1 +
 .../bus/pci/devices/:01:00.0/enable|   1 +
 .../bus/pci/devices/:01:00.0/irq   |   1 +
 .../bus/pci/devices/:01:00.0/modalias  |   1 +
 .../bus/pci/devices/:01:00.0/msi_bus   |   1 +
 .../bus/pci/devices/:01:00.0/numa_node |   1 +
 .../bus/pci/devices/:01:00.0/resource  |  13 +++
 .../bus/pci/devices/:01:00.0/sriov_numvfs  |   1 +
 .../bus/pci/devices/:01:00.0/sriov_totalvfs|   1 +
 .../bus/pci/devices/:01:00.0/subsystem_device  |   1 +
 .../bus/pci/devices/:01:00.0/subsystem_vendor  |   1 +
 .../bus/pci/devices/:01:00.0/uevent|   6 ++
 .../bus/pci/devices/:01:00.0/vendor|   1 +
 drivers/net/szedata2/rte_eth_szedata2.c|   2 +-
 drivers/net/virtio/virtio_pci.c|   2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map  |   7 ++
 lib/librte_eal/common/eal_common_pci.c |  13 +++
 lib/librte_eal/common/include/rte_pci.h|   2 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  |  10 +--
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|   7 ++
 28 files changed, 159 insertions(+), 15 deletions(-)
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/class
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/config
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/consistent_dma_mask_bits
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/device
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/dma_mask_bits
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/enable
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/irq
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/modalias
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/msi_bus
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/numa_node
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/resource
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/sriov_numvfs
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/sriov_totalvfs
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/subsystem_device
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/subsystem_vendor
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/uevent
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/vendor

diff --git a/app/test/Makefile b/app/test/Makefile
index 1cc6258..7e4d484 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -73,6 +73,7 @@ SRCS-y += test_resource.c
 $(eval $(call linked_resource,test_resource_c,resource.c))
 $(eval $(call linked_tar_resource,test_resource_tar,test_resource.c))
 SRCS-y += test_pci.c
+$(eval $(call linked_tar_resource,test_pci_sysfs,test_pci_sysfs))
 SRCS-y += test_prefetch.c
 SRCS-y += test_byteorder.c
 SRCS-y += test_per_lcore.c
diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 28d710b..362ae3e 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -43,6 +43,7 @@
 #include 

 #include "test.h"
+#include "resource.h"

 /* Generic maximum number of drivers to have room to allocate all drivers */
 #define NUM_MAX_DRIVERS 256
@@ -144,37 +145,90 @@ static void free_devargs_list(void)
}
 }

-/* backup real drivers (not used for testing) */
+/* backup real devices & drivers (not used for testing) */
 struct pci_driver_list real_pci_driver_list =
TAILQ_HEAD_INITIALIZER(real_pci_driver_list);
+struct pci_device_list real_pci_device_list =
+   TAILQ_HEAD_INITIALIZER(real_pci_device_list);
+

[dpdk-dev] [PATCH v5 08/10] app/test: convert current pci_test into a single test case

2016-06-13 Thread Jan Viktorin
The current test_pci is just a single test case that tests the
blacklisting of devices. Rename it to test_pci_blacklist and call it
from the test_pci. The setup and cleanup are moved out of the
test_pci_blacklist entirely to cover all other tests.

Signed-off-by: Jan Viktorin 
---
v4
* the definitions of setup and cleanup functions are NOT moved (T. Monjalon)
---
 app/test/test_pci.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 50078a0..28d710b 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -178,17 +178,14 @@ test_pci_cleanup(void)
return 0;
 }

-int
-test_pci(void)
+static int
+test_pci_blacklist(void)
 {
struct rte_devargs_list save_devargs_list;

printf("Dump all devices\n");
rte_eal_pci_dump(stdout);

-   if (test_pci_setup())
-   return -1;
-
rte_eal_pci_register(_driver);
rte_eal_pci_register(_driver2);

@@ -224,6 +221,18 @@ test_pci(void)
rte_eal_pci_unregister(_driver);
rte_eal_pci_unregister(_driver2);

+   return 0;
+}
+
+int
+test_pci(void)
+{
+   if (test_pci_setup())
+   return -1;
+
+   if (test_pci_blacklist())
+   return -1;
+
if (test_pci_cleanup())
return -1;

-- 
2.8.0



[dpdk-dev] [PATCH v5 07/10] app/test: extract test_pci_setup and test_pci_cleanup

2016-06-13 Thread Jan Viktorin
Signed-off-by: Jan Viktorin 
---
 app/test/test_pci.c | 47 ++-
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 8b7c8bb..50078a0 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -148,21 +148,46 @@ static void free_devargs_list(void)
 struct pci_driver_list real_pci_driver_list =
TAILQ_HEAD_INITIALIZER(real_pci_driver_list);

+static int
+test_pci_setup(void)
+{
+   struct rte_pci_driver *dr;
+
+   /* Unregister original driver list */
+   while (!TAILQ_EMPTY(_driver_list)) {
+   dr = TAILQ_FIRST(_driver_list);
+   rte_eal_pci_unregister(dr);
+   TAILQ_INSERT_TAIL(_pci_driver_list, dr, next);
+   }
+
+   return 0;
+}
+
+static int
+test_pci_cleanup(void)
+{
+   struct rte_pci_driver *dr;
+
+   /* Restore original driver list */
+   while (!TAILQ_EMPTY(_pci_driver_list)) {
+   dr = TAILQ_FIRST(_pci_driver_list);
+   TAILQ_REMOVE(_pci_driver_list, dr, next);
+   rte_eal_pci_register(dr);
+   }
+
+   return 0;
+}
+
 int
 test_pci(void)
 {
struct rte_devargs_list save_devargs_list;
-   struct rte_pci_driver *dr = NULL;

printf("Dump all devices\n");
rte_eal_pci_dump(stdout);

-   /* Unregister all previous drivers */
-   while (!TAILQ_EMPTY(_driver_list)) {
-   dr = TAILQ_FIRST(_driver_list);
-   rte_eal_pci_unregister(dr);
-   TAILQ_INSERT_TAIL(_pci_driver_list, dr, next);
-   }
+   if (test_pci_setup())
+   return -1;

rte_eal_pci_register(_driver);
rte_eal_pci_register(_driver2);
@@ -199,12 +224,8 @@ test_pci(void)
rte_eal_pci_unregister(_driver);
rte_eal_pci_unregister(_driver2);

-   /* Restore original driver list */
-   while (!TAILQ_EMPTY(_pci_driver_list)) {
-   dr = TAILQ_FIRST(_pci_driver_list);
-   TAILQ_REMOVE(_pci_driver_list, dr, next);
-   rte_eal_pci_register(dr);
-   }
+   if (test_pci_cleanup())
+   return -1;

return 0;
 }
-- 
2.8.0



[dpdk-dev] [PATCH v5 06/10] app/test: use linked list to store PCI drivers

2016-06-13 Thread Jan Viktorin
The test unregisters all drivers before start. The drivers were stored
into a fixed-sized array. This is inflexible. This patch change this to
utilize a linked list for the same purpose.

Signed-off-by: Jan Viktorin 
---
v3:
* fixed commit message
* used "backup" to describe the real_pci_driver_list
---
 app/test/test_pci.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 0ed357e..8b7c8bb 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -144,21 +144,24 @@ static void free_devargs_list(void)
}
 }

+/* backup real drivers (not used for testing) */
+struct pci_driver_list real_pci_driver_list =
+   TAILQ_HEAD_INITIALIZER(real_pci_driver_list);
+
 int
 test_pci(void)
 {
struct rte_devargs_list save_devargs_list;
struct rte_pci_driver *dr = NULL;
-   struct rte_pci_driver *save_pci_driver_list[NUM_MAX_DRIVERS];
-   unsigned i, num_drivers = 0;

printf("Dump all devices\n");
rte_eal_pci_dump(stdout);

/* Unregister all previous drivers */
-   TAILQ_FOREACH(dr, _driver_list, next) {
+   while (!TAILQ_EMPTY(_driver_list)) {
+   dr = TAILQ_FIRST(_driver_list);
rte_eal_pci_unregister(dr);
-   save_pci_driver_list[num_drivers++] = dr;
+   TAILQ_INSERT_TAIL(_pci_driver_list, dr, next);
}

rte_eal_pci_register(_driver);
@@ -197,8 +200,11 @@ test_pci(void)
rte_eal_pci_unregister(_driver2);

/* Restore original driver list */
-   for (i = 0; i < num_drivers; i++)
-   rte_eal_pci_register(save_pci_driver_list[i]);
+   while (!TAILQ_EMPTY(_pci_driver_list)) {
+   dr = TAILQ_FIRST(_pci_driver_list);
+   TAILQ_REMOVE(_pci_driver_list, dr, next);
+   rte_eal_pci_register(dr);
+   }

return 0;
 }
-- 
2.8.0



[dpdk-dev] [PATCH v5 05/10] app/test: support resources archived by tar

2016-06-13 Thread Jan Viktorin
When a more complex resource (a file hierarchy) is needed, packing
every single file as a single resource would be very ineffective. For
that purpose, it is possible to pack the files into a tar archive,
extract it before test from the resource and finally clean up all the
created files.

This patch introduces functions resource_untar and resource_rm_by_tar
to perform those tasks. An example of using those functions is included
as a test.

A new dependency is required to build the app/test: libarchive.

Signed-off-by: Jan Viktorin 
---
v5:
* fix archive_read_data_block, more info:
  https://github.com/libarchive/libarchive/blob/master/examples/untar.c#L205
  http://markmail.org/message/y4pgi44gqjd4jfuc
---
 app/test/Makefile|   9 +++
 app/test/resource.c  | 200 +++
 app/test/resource.h  |  13 +++
 app/test/test_resource.c |  29 +++
 4 files changed, 251 insertions(+)

diff --git a/app/test/Makefile b/app/test/Makefile
index fe67eee..1cc6258 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -51,6 +51,13 @@ $(1).res.o: $(2)
/dev/stdin $$@ < $$<
 endef

+define linked_tar_resource
+$(1).tar: $(2)
+   tar -C $$(dir $$<) -cf $$@ $$(notdir $$<)
+
+$(call linked_resource,$(1),$(1).tar)
+endef
+
 #
 # library name
 #
@@ -64,6 +71,7 @@ SRCS-y += test.c
 SRCS-y += resource.c
 SRCS-y += test_resource.c
 $(eval $(call linked_resource,test_resource_c,resource.c))
+$(eval $(call linked_tar_resource,test_resource_tar,test_resource.c))
 SRCS-y += test_pci.c
 SRCS-y += test_prefetch.c
 SRCS-y += test_byteorder.c
@@ -185,6 +193,7 @@ CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -D_GNU_SOURCE

 LDLIBS += -lm
+LDLIBS += -larchive

 # Disable VTA for memcpy test
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
diff --git a/app/test/resource.c b/app/test/resource.c
index acb63c1..8c42eea 100644
--- a/app/test/resource.c
+++ b/app/test/resource.c
@@ -33,6 +33,8 @@

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

@@ -95,6 +97,204 @@ int resource_fwrite_file(const struct resource *r, const 
char *fname)
return ret;
 }

+static int do_copy(struct archive *r, struct archive *w)
+{
+   const void *buf;
+   size_t len;
+#if ARCHIVE_VERSION_NUMBER >= 300
+   int64_t off;
+#else
+   off_t off;
+#endif
+   int ret;
+
+   while (1) {
+   ret = archive_read_data_block(r, , , );
+   if (ret == ARCHIVE_RETRY)
+   continue;
+
+   if (ret == ARCHIVE_EOF)
+   return 0;
+
+   if (ret != ARCHIVE_OK)
+   return ret;
+
+   do {
+   ret = archive_write_data_block(w, buf, len, off);
+   if (ret != ARCHIVE_OK && ret != ARCHIVE_RETRY)
+   return ret;
+   } while (ret != ARCHIVE_OK);
+   }
+}
+
+int resource_untar(const struct resource *res)
+{
+   struct archive *r;
+   struct archive *w;
+   struct archive_entry *e;
+   void *p;
+   int flags = 0;
+   int ret;
+
+   p = malloc(resource_size(res));
+   if (p == NULL)
+   rte_panic("Failed to malloc %zu B\n", resource_size(res));
+
+   memcpy(p, res->begin, resource_size(res));
+
+   r = archive_read_new();
+   if (r == NULL) {
+   free(p);
+   return -1;
+   }
+
+   archive_read_support_format_all(r);
+   archive_read_support_filter_all(r);
+
+   w = archive_write_disk_new();
+   if (w == NULL) {
+   archive_read_free(r);
+   free(p);
+   return -1;
+   }
+
+   flags |= ARCHIVE_EXTRACT_PERM;
+   flags |= ARCHIVE_EXTRACT_FFLAGS;
+   archive_write_disk_set_options(w, flags);
+   archive_write_disk_set_standard_lookup(w);
+
+   ret = archive_read_open_memory(r, p, resource_size(res));
+   if (ret != ARCHIVE_OK)
+   goto fail;
+
+   while (1) {
+   ret = archive_read_next_header(r, );
+   if (ret == ARCHIVE_EOF)
+   break;
+   if (ret != ARCHIVE_OK)
+   goto fail;
+
+   ret = archive_write_header(w, e);
+   if (ret == ARCHIVE_EOF)
+   break;
+   if (ret != ARCHIVE_OK)
+   goto fail;
+
+   if (archive_entry_size(e) == 0)
+   continue;
+
+   ret = do_copy(r, w);
+   if (ret != ARCHIVE_OK)
+   goto fail;
+
+   ret = archive_write_finish_entry(w);
+   if (ret != ARCHIVE_OK)
+   goto fail;
+   }
+
+   archive_write_free(w);
+   archive_read_free(r);
+   free(p);
+   return 0;
+
+fail:
+   archive_write_free(w);
+   archive_read_free(r);
+   free(p);
+   rte_panic("Failed: %s\n", archive_error_string(r));
+  

[dpdk-dev] [PATCH v5 04/10] app/test: add functions to create files from resources

2016-06-13 Thread Jan Viktorin
A resource can be written into the target filesystem by calling
resource_fwrite or resource_fwrite_file. Such file can be created
before a test is started and removed after the test finishes.

Signed-off-by: Jan Viktorin 
---
 app/test/resource.c  | 35 +++
 app/test/resource.h  | 14 ++
 app/test/test_resource.c | 10 ++
 3 files changed, 59 insertions(+)

diff --git a/app/test/resource.c b/app/test/resource.c
index 30513db..acb63c1 100644
--- a/app/test/resource.c
+++ b/app/test/resource.c
@@ -31,6 +31,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

+#include 
 #include 
 #include 
 #include 
@@ -60,6 +61,40 @@ const struct resource *resource_find(const char *name)
return NULL;
 }

+int resource_fwrite(const struct resource *r, FILE *f)
+{
+   const size_t goal = resource_size(r);
+   size_t total = 0;
+
+   while (total < goal) {
+   size_t wlen = fwrite(r->begin + total, 1, goal - total, f);
+   if (wlen == 0) {
+   perror(__func__);
+   return -1;
+   }
+
+   total += wlen;
+   }
+
+   return 0;
+}
+
+int resource_fwrite_file(const struct resource *r, const char *fname)
+{
+   FILE *f;
+   int ret;
+
+   f = fopen(fname, "w");
+   if (f == NULL) {
+   perror(__func__);
+   return -1;
+   }
+
+   ret = resource_fwrite(r, f);
+   fclose(f);
+   return ret;
+}
+
 void resource_register(struct resource *r)
 {
TAILQ_INSERT_TAIL(_list, r, next);
diff --git a/app/test/resource.h b/app/test/resource.h
index 966fc24..ac9cae6 100644
--- a/app/test/resource.h
+++ b/app/test/resource.h
@@ -45,6 +45,7 @@
  */

 #include 
+#include 
 #include 

 #include 
@@ -75,6 +76,19 @@ size_t resource_size(const struct resource *r);
 const struct resource *resource_find(const char *name);

 /**
+ * Write the raw data of the resource to the given file.
+ * @return 0 on success
+ */
+int resource_fwrite(const struct resource *r, FILE *f);
+
+/**
+ * Write the raw data of the resource to the given file given by name.
+ * The name is relative to the current working directory.
+ * @return 0 on success
+ */
+int resource_fwrite_file(const struct resource *r, const char *fname);
+
+/**
  * Register a resource in the global list of resources.
  * Not intended for direct use, please check the REGISTER_RESOURCE
  * macro.
diff --git a/app/test/test_resource.c b/app/test/test_resource.c
index b397fa8..3d1bf00 100644
--- a/app/test/test_resource.c
+++ b/app/test/test_resource.c
@@ -65,6 +65,7 @@ REGISTER_LINKED_RESOURCE(test_resource_c);
 static int test_resource_c(void)
 {
const struct resource *r;
+   FILE *f;

r = resource_find("test_resource_c");
TEST_ASSERT_NOT_NULL(r, "No test_resource_c found");
@@ -72,6 +73,15 @@ static int test_resource_c(void)
"Found resource %s, expected test_resource_c",
r->name);

+   TEST_ASSERT_SUCCESS(resource_fwrite_file(r, "test_resource.c"),
+   "Failed to to write file %s", r->name);
+
+   f = fopen("test_resource.c", "r");
+   TEST_ASSERT_NOT_NULL(f,
+   "Missing extracted file resource.c");
+   fclose(f);
+   remove("test_resource.c");
+
return 0;
 }

-- 
2.8.0



[dpdk-dev] [PATCH v5 03/10] app/test: support resources externally linked

2016-06-13 Thread Jan Viktorin
To include resources from other source that the C source code we
can take advantage of the objcopy behaviour, i.e. packing of an
arbitrary file as an object file that is linked to the target program.

A linked object file is always accessible as a pair

extern const char beg_;
extern const char end_;
(extern const char siz_;)

A unit test that packs the resource.c source file is included.

Signed-off-by: Jan Viktorin 
---
v4
* fixed trailing semicolon in REGISTER_LINKED_RESOURCE
---
 app/test/Makefile| 19 +++
 app/test/resource.h  | 10 ++
 app/test/test_resource.c | 18 ++
 3 files changed, 47 insertions(+)

diff --git a/app/test/Makefile b/app/test/Makefile
index 1a13fb2..fe67eee 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -33,6 +33,24 @@ include $(RTE_SDK)/mk/rte.vars.mk

 ifeq ($(CONFIG_RTE_APP_TEST),y)

+# Define an externally linked resource. A linked resource is an arbitrary
+# file that is linked into the test binary. The application refers to this
+# resource by name. The linked generates identifiers beg_ and end_
+# for referencing by the C code.
+#
+# Parameters: , 
+define linked_resource
+SRCS-y += $(1).res.o
+$(1).res.o: $(2)
+   $(OBJCOPY) -I binary -B $(RTE_OBJCOPY_ARCH) -O $(RTE_OBJCOPY_TARGET) \
+   --rename-section \
+   .data=.rodata,alloc,load,data,contents,readonly  \
+   --redefine-sym _binary__dev_stdin_start=beg_$(1) \
+   --redefine-sym _binary__dev_stdin_end=end_$(1)   \
+   --redefine-sym _binary__dev_stdin_size=siz_$(1)  \
+   /dev/stdin $$@ < $$<
+endef
+
 #
 # library name
 #
@@ -45,6 +63,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c
 SRCS-y += test.c
 SRCS-y += resource.c
 SRCS-y += test_resource.c
+$(eval $(call linked_resource,test_resource_c,resource.c))
 SRCS-y += test_pci.c
 SRCS-y += test_prefetch.c
 SRCS-y += test_byteorder.c
diff --git a/app/test/resource.h b/app/test/resource.h
index 9af8415..966fc24 100644
--- a/app/test/resource.h
+++ b/app/test/resource.h
@@ -82,6 +82,16 @@ const struct resource *resource_find(const char *name);
 void resource_register(struct resource *r);

 /**
+ * Definition of a resource linked externally (by means of the used toolchain).
+ * Only the base name of the resource is expected. The name refers to the
+ * linked pointers beg_ and end_ provided externally.
+ */
+#define REGISTER_LINKED_RESOURCE(n) \
+extern const char beg_ ##n; \
+extern const char end_ ##n; \
+REGISTER_RESOURCE(n, _ ##n, _ ##n) \
+
+/**
  * Definition of a resource described by its name, and pointers begin, end.
  */
 #define REGISTER_RESOURCE(n, b, e) \
diff --git a/app/test/test_resource.c b/app/test/test_resource.c
index 69391ad..b397fa8 100644
--- a/app/test/test_resource.c
+++ b/app/test/test_resource.c
@@ -60,11 +60,29 @@ static int test_resource_dpdk(void)
return 0;
 }

+REGISTER_LINKED_RESOURCE(test_resource_c);
+
+static int test_resource_c(void)
+{
+   const struct resource *r;
+
+   r = resource_find("test_resource_c");
+   TEST_ASSERT_NOT_NULL(r, "No test_resource_c found");
+   TEST_ASSERT(!strcmp(r->name, "test_resource_c"),
+   "Found resource %s, expected test_resource_c",
+   r->name);
+
+   return 0;
+}
+
 static int test_resource(void)
 {
if (test_resource_dpdk())
return -1;

+   if (test_resource_c())
+   return -1;
+
return 0;
 }

-- 
2.8.0



[dpdk-dev] [PATCH v5 02/10] mk: define objcopy-specific target and arch

2016-06-13 Thread Jan Viktorin
The program objcopy uses non-standard conventions to name the
target and arch. Define the values for supported architecturesi
(tile and ppc_64 are missing).

Signed-off-by: Jan Viktorin 
---
v4:
* fixed commit message (removed FIXME)
---
 mk/arch/arm/rte.vars.mk | 5 +
 mk/arch/arm64/rte.vars.mk   | 5 +
 mk/arch/i686/rte.vars.mk| 5 +
 mk/arch/x86_64/rte.vars.mk  | 5 +
 mk/arch/x86_x32/rte.vars.mk | 5 +
 5 files changed, 25 insertions(+)

diff --git a/mk/arch/arm/rte.vars.mk b/mk/arch/arm/rte.vars.mk
index bd85140..2f8cf7c 100644
--- a/mk/arch/arm/rte.vars.mk
+++ b/mk/arch/arm/rte.vars.mk
@@ -37,3 +37,8 @@ CPU_LDFLAGS ?=
 CPU_ASFLAGS ?= -felf

 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
+
+RTE_OBJCOPY_TARGET = elf32-littlearm
+RTE_OBJCOPY_ARCH = arm
+
+export RTE_OBJCOPY_TARGET RTE_OBJCOPY_ARCH
diff --git a/mk/arch/arm64/rte.vars.mk b/mk/arch/arm64/rte.vars.mk
index 32e3a5f..c168426 100644
--- a/mk/arch/arm64/rte.vars.mk
+++ b/mk/arch/arm64/rte.vars.mk
@@ -56,3 +56,8 @@ CPU_LDFLAGS ?=
 CPU_ASFLAGS ?= -felf

 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
+
+RTE_OBJCOPY_TARGET = elf64-littleaarch64
+RTE_OBJCOPY_ARCH = aarch64
+
+export RTE_OBJCOPY_TARGET RTE_OBJCOPY_ARCH
diff --git a/mk/arch/i686/rte.vars.mk b/mk/arch/i686/rte.vars.mk
index 8ba9a23..6a25312 100644
--- a/mk/arch/i686/rte.vars.mk
+++ b/mk/arch/i686/rte.vars.mk
@@ -57,3 +57,8 @@ CPU_LDFLAGS ?= -melf_i386
 CPU_ASFLAGS ?= -felf

 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
+
+RTE_OBJCOPY_TARGET = elf32-i386
+RTE_OBJCOPY_ARCH = i386
+
+export RTE_OBJCOPY_TARGET RTE_OBJCOPY_ARCH
diff --git a/mk/arch/x86_64/rte.vars.mk b/mk/arch/x86_64/rte.vars.mk
index b986f04..83723c8 100644
--- a/mk/arch/x86_64/rte.vars.mk
+++ b/mk/arch/x86_64/rte.vars.mk
@@ -57,3 +57,8 @@ CPU_LDFLAGS ?=
 CPU_ASFLAGS ?= -felf64

 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
+
+RTE_OBJCOPY_TARGET = elf64-x86-64
+RTE_OBJCOPY_ARCH = i386:x86-64
+
+export RTE_OBJCOPY_TARGET RTE_OBJCOPY_ARCH
diff --git a/mk/arch/x86_x32/rte.vars.mk b/mk/arch/x86_x32/rte.vars.mk
index 3103dfc..676f316 100644
--- a/mk/arch/x86_x32/rte.vars.mk
+++ b/mk/arch/x86_x32/rte.vars.mk
@@ -61,3 +61,8 @@ ifneq ($(shell echo | $(CC) $(CPU_CFLAGS) -E - 2>/dev/null 
1>/dev/null && echo 0
 endif

 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
+
+RTE_OBJCOPY_TARGET = elf32-x86-64
+RTE_OBJCOPY_ARCH = i386:x86-64
+
+export RTE_OBJCOPY_TARGET RTE_OBJCOPY_ARCH
-- 
2.8.0



[dpdk-dev] [PATCH v5 01/10] app/test: introduce resources for tests

2016-06-13 Thread Jan Viktorin
Certain internal mechanisms of DPDK access different file system
structures (e.g. /sys/bus/pci/devices). It is difficult to test
those cases automatically by a unit test when such path is not
hard-coded and there is no simple way how to distribute fake ones
with the current testing environment.

This patch adds a possibility to declare a resource embedded in
the test binary itself. The structure resource cover the generic
situation - it provides a name for lookup and pointers to the
embedded data blob. A resource is registered in a constructor by
the macro REGISTER_RESOURCE.

Some initial tests of simple resources is included and added into
the group_1.

Signed-off-by: Jan Viktorin 
---
v3:
* fixed doc comments
---
 app/test/Makefile |  2 +
 app/test/autotest_data.py |  6 +++
 app/test/resource.c   | 66 +++
 app/test/resource.h   | 98 +++
 app/test/test_resource.c  | 75 
 5 files changed, 247 insertions(+)
 create mode 100644 app/test/resource.c
 create mode 100644 app/test/resource.h
 create mode 100644 app/test/test_resource.c

diff --git a/app/test/Makefile b/app/test/Makefile
index 6df9c40..1a13fb2 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -43,6 +43,8 @@ APP = test
 #
 SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c
 SRCS-y += test.c
+SRCS-y += resource.c
+SRCS-y += test_resource.c
 SRCS-y += test_pci.c
 SRCS-y += test_prefetch.c
 SRCS-y += test_byteorder.c
diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 6c87809..1e6b422 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -94,6 +94,12 @@ parallel_test_group_list = [
 "Report" : None,
},
{
+"Name" :   "Resource autotest",
+"Command" :"resource_autotest",
+"Func" :   default_autotest,
+"Report" : None,
+   },
+   {
 "Name" :   "Dump rings",
 "Command" :"dump_ring",
 "Func" :   dump_autotest,
diff --git a/app/test/resource.c b/app/test/resource.c
new file mode 100644
index 000..30513db
--- /dev/null
+++ b/app/test/resource.c
@@ -0,0 +1,66 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "resource.h"
+
+struct resource_list resource_list = TAILQ_HEAD_INITIALIZER(resource_list);
+
+size_t resource_size(const struct resource *r)
+{
+   return r->end - r->begin;
+}
+
+const struct resource *resource_find(const char *name)
+{
+   struct resource *r;
+
+   TAILQ_FOREACH(r, _list, next) {
+   RTE_VERIFY(r->name);
+
+   if (!strcmp(r->name, name))
+   return r;
+   }
+
+   return NULL;
+}
+
+void resource_register(struct resource *r)
+{
+   TAILQ_INSERT_TAIL(_list, r, next);
+}
diff --git a/app/test/resource.h b/app/test/resource.h
new file mode 100644
index 000..9af8415
--- /dev/null
+++ b/app/test/resource.h
@@ -0,0 +1,98 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or 

[dpdk-dev] [PATCH v5 00/10] Include resources in tests

2016-06-13 Thread Jan Viktorin
Hello,

the fifth version fixing the libarchive API usage.

Regards
Jan

---
v1:
* included 5 patches improving the PCI tests
* fixed using of non-existing RTE_INIT macro

v2:
* Makefile macro resource renamed to linked_resource
* introduced macro linked_tar_resource
* added more comments
* clarified relation between REGISTER_LINKED_RESOURCE and the Makefile
* untar is checked to not loop infinitely
* improved commit messages
* objcopy params extracted to a separated patcha (missing tile and ppc)
* few random bits (usually suggested by T. Monjalon)
* included a note about the new dependency libarchive in the particular 
commit

v3:
* resource_autotest added to autotest_data.py
* improved test of affecting pci_get_sysfs_path() by setenv
* few other bits...

v4:
* fix checkpatch issues
* state that tile and ppc_64 are not supported in patch 0002
* avoid moving functions test_pci_setup and test_pci_cleanup in patch 0008

v5:
* fixed off argument of archive_read_data_block


Jan Viktorin (10):
  app/test: introduce resources for tests
  mk: define objcopy-specific target and arch
  app/test: support resources externally linked
  app/test: add functions to create files from resources
  app/test: support resources archived by tar
  app/test: use linked list to store PCI drivers
  app/test: extract test_pci_setup and test_pci_cleanup
  app/test: convert current pci_test into a single test case
  eal/pci: allow to override sysfs
  app/test: do not dump PCI devices in blacklist test

 app/test/Makefile  |  31 +++
 app/test/autotest_data.py  |   6 +
 app/test/resource.c| 301 +
 app/test/resource.h| 135 +
 app/test/test_pci.c| 147 +-
 .../bus/pci/devices/:01:00.0/class |   1 +
 .../bus/pci/devices/:01:00.0/config| Bin 0 -> 64 bytes
 .../devices/:01:00.0/consistent_dma_mask_bits  |   1 +
 .../bus/pci/devices/:01:00.0/device|   1 +
 .../bus/pci/devices/:01:00.0/dma_mask_bits |   1 +
 .../bus/pci/devices/:01:00.0/enable|   1 +
 .../bus/pci/devices/:01:00.0/irq   |   1 +
 .../bus/pci/devices/:01:00.0/modalias  |   1 +
 .../bus/pci/devices/:01:00.0/msi_bus   |   1 +
 .../bus/pci/devices/:01:00.0/numa_node |   1 +
 .../bus/pci/devices/:01:00.0/resource  |  13 +
 .../bus/pci/devices/:01:00.0/sriov_numvfs  |   1 +
 .../bus/pci/devices/:01:00.0/sriov_totalvfs|   1 +
 .../bus/pci/devices/:01:00.0/subsystem_device  |   1 +
 .../bus/pci/devices/:01:00.0/subsystem_vendor  |   1 +
 .../bus/pci/devices/:01:00.0/uevent|   6 +
 .../bus/pci/devices/:01:00.0/vendor|   1 +
 app/test/test_resource.c   | 132 +
 drivers/net/szedata2/rte_eth_szedata2.c|   2 +-
 drivers/net/virtio/virtio_pci.c|   2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map  |   7 +
 lib/librte_eal/common/eal_common_pci.c |  13 +
 lib/librte_eal/common/include/rte_pci.h|   2 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  |  10 +-
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|   7 +
 mk/arch/arm/rte.vars.mk|   5 +
 mk/arch/arm64/rte.vars.mk  |   5 +
 mk/arch/i686/rte.vars.mk   |   5 +
 mk/arch/x86_64/rte.vars.mk |   5 +
 mk/arch/x86_x32/rte.vars.mk|   5 +
 37 files changed, 836 insertions(+), 26 deletions(-)
 create mode 100644 app/test/resource.c
 create mode 100644 app/test/resource.h
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/class
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/config
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/consistent_dma_mask_bits
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/device
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/dma_mask_bits
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/enable
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/irq
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/modalias
 create mode 100644 app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/msi_bus
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/numa_node
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/resource
 create mode 100644 
app/test/test_pci_sysfs/bus/pci/devices/:01:00.0/sriov_numvfs
 create mode 100644 

[dpdk-dev] [PATCH 0/7] Miscellaneous fixes for mlx4 and mlx5

2016-06-13 Thread Bruce Richardson
On Wed, Jun 08, 2016 at 11:43:24AM +0200, Nelio Laranjeiro wrote:
> Various minor fixes for mlx4 (ConnectX-3) and mlx5 (ConnectX-4).
> 
> Adrien Mazarguil (4):
>   mlx: ensure MTU update is effective
>   mlx: retrieve mbuf size through proper API
>   mlx5: fix RX VLAN stripping capability check
>   mlx5: cosmetic changes (coding style)
> 
> Nelio Laranjeiro (3):
>   mlx: remove unused memory region property
>   mlx5: enhance SR-IOV detection
>   mlx5: update documentation part related to features and limitations
> 
>  doc/guides/nics/mlx5.rst   |  2 +-
>  drivers/net/mlx4/mlx4.c| 43 --
>  drivers/net/mlx5/mlx5.c| 14 +++--
>  drivers/net/mlx5/mlx5.h|  3 ++-
>  drivers/net/mlx5/mlx5_ethdev.c | 47 
> --
>  drivers/net/mlx5/mlx5_rxq.c| 23 +++--
>  drivers/net/mlx5/mlx5_rxtx.c   |  7 +++
>  drivers/net/mlx5/mlx5_rxtx.h   | 16 ++
>  drivers/net/mlx5/mlx5_txq.c|  2 +-
>  drivers/net/mlx5/mlx5_vlan.c   |  2 +-
>  10 files changed, 98 insertions(+), 61 deletions(-)
>
Applied to dpdk-next-net/rel_16_07

/Bruce


[dpdk-dev] [PATCH] virito: fix reuse index in nested loop

2016-06-13 Thread Yuanhan Liu
On Sun, Jun 12, 2016 at 10:05:45AM +, Jianfeng Tan wrote:
> This patches fixes problem of reusing index of outmost loop in nested
> loops. This bug will lead to failure when starting a multi queue
> virtio device: rx queues (except from the first one) cannot be started,
> expecially their vq_ring cannot be initialized, so that when invoking
> rx func on these queues, segment fault happens.
> 
> Fixes: a900472aedef ("virtio: split virtio Rx/Tx queue")

Good catch!

> Signed-off-by: Jianfeng Tan 
> ---
>  drivers/net/virtio/virtio_rxtx.c | 36 
>  1 file changed, 20 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_rxtx.c 
> b/drivers/net/virtio/virtio_rxtx.c
> index 2e7205b..b96d0cb 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -331,7 +331,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev)
>* -Allocate blank mbufs for the each rx descriptor
>*
>*/
> - int i;
> + int i, j;

However, I don't quite like using "i, j, k" stuff. So, how about
renaming "j" to "ring_idx"?

>   PMD_INIT_FUNC_TRACE();
>  
> @@ -352,15 +352,18 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev)
>   error = ENOSPC;
>  
>  #ifdef RTE_MACHINE_CPUFLAG_SSSE3
> - if (use_simple_rxtx)
> - for (i = 0; i < vq->vq_nentries; i++) {
> - vq->vq_ring.avail->ring[i] = i;
> - vq->vq_ring.desc[i].flags = VRING_DESC_F_WRITE;
> + if (use_simple_rxtx) {
> + uint16_t k;

We could reuse "ring_idx" here; no need to define yet another iterate var
for that.

--yliu


[dpdk-dev] [PATCH v4 8/8] doc: update xstats documentation

2016-06-13 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 doc/guides/prog_guide/poll_mode_drv.rst | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/doc/guides/prog_guide/poll_mode_drv.rst 
b/doc/guides/prog_guide/poll_mode_drv.rst
index 7698692..802fb8f 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -299,10 +299,27 @@ Extended Statistics API
 ~~~

 The extended statistics API allows each individual PMD to expose a unique set
-of statistics. The client of the API provides an array of
-``struct rte_eth_xstats`` type. Each ``struct rte_eth_xstats`` contains a
-string and value pair. The amount of xstats exposed, and position of the
-statistic in the array must remain constant during runtime.
+of statistics. Accessing these from application programs is done via two
+functions:
+
+* ``rte_eth_xstats_get``: Fills in an array of ``struct rte_eth_xstat``
+  with extended statistics.
+* ``rte_eth_xstats_get_names``: Fills in an array of
+  ``struct rte_eth_xstat_name`` with extended statistic name lookup
+  information.
+
+Each ``struct rte_eth_xstat`` contains an identifier and value pair, and
+each ``struct rte_eth_xstat_name`` contains an identifier and string pair.
+Each identifier within ``struct rte_eth_xstat`` must have a corresponding
+entry in ``struct rte_eth_xstat_name`` with a matching identifier. These
+identifiers, as well as the number of extended statistic exposed, must
+remain constant during runtime.
+
+Note that extended statistic identifiers are driver-specific, and hence
+might not be the same for different ports. Although it is expected that
+drivers will make the identifiers used within ``struct rte_eth_xstat`` and
+``struct rte_eth_xstat_name`` entries match the entries' array index, this
+property should not be relied on by applications for lookups.

 A naming scheme exists for the strings exposed to clients of the API. This is
 to allow scraping of the API for statistics of interest. The naming scheme uses
-- 
2.5.5



[dpdk-dev] [PATCH v4 7/8] rte: change xstats usage to new API

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the test-pmd
and proc_info applications to use the new xstats API, and removes
deprecated code associated with the old API.

Signed-off-by: Remy Horton 
---
 app/proc_info/main.c   | 29 +---
 app/test-pmd/config.c  | 54 +-
 drivers/net/e1000/igb_ethdev.c | 10 +++
 drivers/net/fm10k/fm10k_ethdev.c   |  5 +---
 drivers/net/i40e/i40e_ethdev.c |  8 ++
 drivers/net/i40e/i40e_ethdev_vf.c  |  5 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c   | 11 +++-
 drivers/net/virtio/virtio_ethdev.c |  6 ++---
 lib/librte_ether/rte_ethdev.c  |  5 +---
 lib/librte_ether/rte_ethdev.h  |  7 +++--
 10 files changed, 85 insertions(+), 55 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 5f83092..f2063fa 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -1,7 +1,7 @@
 /*
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -243,11 +243,13 @@ nic_stats_clear(uint8_t port_id)
 static void
 nic_xstats_display(uint8_t port_id)
 {
-   struct rte_eth_xstats *xstats;
+   struct rte_eth_xstat_name *xstats_names;
+   struct rte_eth_xstat *xstats;
int len, ret, i;
+   int idx_name;
static const char *nic_stats_border = "";

-   len = rte_eth_xstats_get(port_id, NULL, 0);
+   len = rte_eth_xstats_get_names(port_id, NULL, 0);
if (len < 0) {
printf("Cannot get xstats count\n");
return;
@@ -258,6 +260,18 @@ nic_xstats_display(uint8_t port_id)
return;
}

+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
+   if (xstats_names == NULL) {
+   printf("Cannot allocate memory for xstat names\n");
+   free(xstats);
+   return;
+   }
+   if (len != rte_eth_xstats_get_names(
+   port_id, xstats_names, len)) {
+   printf("Cannot get xstat names\n");
+   return;
+   }
+
printf("## NIC extended statistics for port %-2d #\n",
   port_id);
printf("%s\n",
@@ -270,11 +284,18 @@ nic_xstats_display(uint8_t port_id)
}

for (i = 0; i < len; i++)
-   printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value);
+   for (idx_name = 0; idx_name < len; idx_name++)
+   if (xstats_names[idx_name].id == xstats[i].id) {
+   printf("%s: %"PRIu64"\n",
+   xstats_names[idx_name].name,
+   xstats[i].value);
+   break;
+   }

printf("%s\n",
   nic_stats_border);
free(xstats);
+   free(xstats_names);
 }

 static void
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..8ddec07 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -232,29 +232,57 @@ nic_stats_clear(portid_t port_id)
 void
 nic_xstats_display(portid_t port_id)
 {
-   struct rte_eth_xstats *xstats;
-   int len, ret, i;
+   struct rte_eth_xstat *xstats;
+   int cnt_xstats, idx_xstat, idx_name;
+   struct rte_eth_xstat_name *xstats_names;

printf("## NIC extended statistics for port %-2d\n", port_id);
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   printf("Error: Invalid port number %i\n", port_id);
+   return;
+   }
+
+   /* Get count */
+   cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0);
+   if (cnt_xstats  < 0) {
+   printf("Error: Cannot get count of xstats\n");
+   return;
+   }

-   len = rte_eth_xstats_get(port_id, NULL, 0);
-   if (len < 0) {
-   printf("Cannot get xstats count\n");
+   /* Get id-name lookup table */
+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats);
+   if (xstats_names == NULL) {
+   printf("Cannot allocate memory for xstats lookup\n");
return;
}
-   xstats = malloc(sizeof(xstats[0]) * len);
+   if (cnt_xstats != 

[dpdk-dev] [PATCH v4 6/8] drivers/net/virtio: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the virtio driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/virtio/virtio_ethdev.c | 62 +-
 1 file changed, 55 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index c3fb628..83df025 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,9 @@ static void virtio_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats);
 static int virtio_dev_xstats_get(struct rte_eth_dev *dev,
 struct rte_eth_xstats *xstats, unsigned n);
+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  unsigned limit);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
 static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
@@ -615,6 +618,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
.dev_infos_get   = virtio_dev_info_get,
.stats_get   = virtio_dev_stats_get,
.xstats_get  = virtio_dev_xstats_get,
+   .xstats_get_names= virtio_dev_xstats_get_names,
.stats_reset = virtio_dev_stats_reset,
.xstats_reset= virtio_dev_stats_reset,
.link_update = virtio_dev_link_update,
@@ -708,6 +712,52 @@ virtio_update_stats(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 }

+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  __rte_unused unsigned limit)
+{
+   unsigned i;
+   unsigned count = 0;
+   unsigned t;
+
+   unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_Q_XSTATS +
+   dev->data->nb_rx_queues * VIRTIO_NB_Q_XSTATS;
+
+   if (xstats_names == NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct virtqueue *rxvq = dev->data->rx_queues[i];
+   if (rxvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct virtqueue *txvq = dev->data->tx_queues[i];
+   if (txvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+   }
+   return nstats;
+}
+
 static int
 virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
  unsigned n)
@@ -730,9 +780,8 @@ virtio_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
unsigned t;

for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", i,
-rte_virtio_q_stat_strings[t].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)rxvq) +

[dpdk-dev] [PATCH v4 5/8] drivers/net/i40e: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the i40e driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/i40e/i40e_ethdev.c| 82 ---
 drivers/net/i40e/i40e_ethdev_vf.c | 26 +++--
 2 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..d712bbe 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -306,6 +306,9 @@ static void i40e_dev_stats_get(struct rte_eth_dev *dev,
   struct rte_eth_stats *stats);
 static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
   struct rte_eth_xstats *xstats, unsigned n);
+static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+unsigned limit);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
uint16_t queue_id,
@@ -467,6 +470,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.link_update  = i40e_dev_link_update,
.stats_get= i40e_dev_stats_get,
.xstats_get   = i40e_dev_xstats_get,
+   .xstats_get_names = i40e_dev_xstats_get_names,
.stats_reset  = i40e_dev_stats_reset,
.xstats_reset = i40e_dev_stats_reset,
.queue_stats_mapping_set  = i40e_dev_queue_stats_mapping_set,
@@ -2205,6 +2209,60 @@ i40e_xstats_calc_num(void)
(I40E_NB_TXQ_PRIO_XSTATS * 8);
 }

+static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned count = 0;
+   unsigned i, prio;
+
+   if (xstats_names == NULL)
+   return i40e_xstats_calc_num();
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Get stats from i40e_eth_stats struct */
+   for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"%s", rte_i40e_stats_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* Get individiual stats from i40e_hw_port struct */
+   for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+"%s", rte_i40e_hw_port_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"rx_priority%u_%s", prio,
+rte_i40e_rxq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"tx_priority%u_%s", prio,
+rte_i40e_txq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+}
+
 static int
 i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
unsigned n)
@@ -2227,8 +2285,8 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Get stats from i40e_eth_stats struct */
for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", rte_i40e_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count;
xstats[count].value = *(uint64_t 

[dpdk-dev] [PATCH v4 4/8] drivers/net/fm10k: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the fm10k driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/fm10k/fm10k_ethdev.c | 55 +---
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c2d377f..e07c1ec 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -1256,6 +1256,47 @@ fm10k_link_update(struct rte_eth_dev *dev,
return 0;
 }

+static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   unsigned i, q;
+   unsigned count = 0;
+
+   if (xstats_names != NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Global stats */
+   for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s", fm10k_hw_stats_strings[count].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* PF queue stats */
+   for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
+   for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", q,
+   fm10k_hw_stats_rx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", q,
+   fm10k_hw_stats_tx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   }
+   return FM10K_NB_XSTATS;
+}
+
 static int
 fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 unsigned n)
@@ -1269,8 +1310,7 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Global stats */
for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", fm10k_hw_stats_strings[count].name);
+   xstats[count].name[0] = '\0';
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
fm10k_hw_stats_strings[count].offset);
count++;
@@ -1279,18 +1319,14 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
/* PF queue stats */
for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", q,
-fm10k_hw_stats_rx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_rx_q_strings[i].offset);
count++;
}
for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"tx_q%u_%s", q,
-fm10k_hw_stats_tx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_tx_q_strings[i].offset);
@@ -2629,6 +2665,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.allmulticast_disable   = fm10k_dev_allmulticast_disable,
.stats_get  = fm10k_stats_get,
.xstats_get = fm10k_xstats_get,
+   .xstats_get_names   = 

[dpdk-dev] [PATCH v4 3/8] drivers/net/e1000: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the e1000 driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/e1000/igb_ethdev.c | 52 ++
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..dffa04f 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -100,6 +100,9 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igb_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
@@ -165,6 +168,9 @@ static void eth_igbvf_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igbvf_xstats_get(struct rte_eth_dev *dev,
struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igbvf_xstats_get_names(struct rte_eth_dev *dev,
+ struct rte_eth_xstat_name *xstats_names,
+ unsigned limit);
 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
@@ -324,6 +330,7 @@ static const struct eth_dev_ops eth_igb_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igb_stats_get,
.xstats_get   = eth_igb_xstats_get,
+   .xstats_get_names = eth_igb_xstats_get_names,
.stats_reset  = eth_igb_stats_reset,
.xstats_reset = eth_igb_xstats_reset,
.dev_infos_get= eth_igb_infos_get,
@@ -385,6 +392,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igbvf_stats_get,
.xstats_get   = eth_igbvf_xstats_get,
+   .xstats_get_names = eth_igbvf_xstats_get_names,
.stats_reset  = eth_igbvf_stats_reset,
.xstats_reset = eth_igbvf_stats_reset,
.vlan_filter_set  = igbvf_vlan_filter_set,
@@ -1691,6 +1699,26 @@ eth_igb_xstats_reset(struct rte_eth_dev *dev)
memset(stats, 0, sizeof(*stats));
 }

+static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   __rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names == NULL)
+   return IGB_NB_XSTATS;
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < IGB_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
+"%s", rte_igb_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+
+   return IGB_NB_XSTATS;
+}
+
 static int
 eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
   unsigned n)
@@ -1713,8 +1741,8 @@ eth_igb_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Extended stats */
for (i = 0; i < IGB_NB_XSTATS; i++) {
-   snprintf(xstats[i].name, sizeof(xstats[i].name),
-"%s", rte_igb_stats_strings[i].name);
+   xstats[i].name[0] = '\0';
+   xstats[i].id = i;
xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
rte_igb_stats_strings[i].offset);
}
@@ -1762,6 +1790,22 @@ igbvf_read_stats_registers(struct e1000_hw *hw, struct 
e1000_vf_stats *hw_stats)
hw_stats->last_gotlbc, hw_stats->gotlbc);
 }

+static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names != NULL)
+   for (i = 0; i < IGBVF_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name,
+   sizeof(xstats_names[i].name), "%s",
+   rte_igbvf_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+   return IGBVF_NB_XSTATS;
+}
+
 static int
 eth_igbvf_xstats_get(struct rte_eth_dev *dev, 

[dpdk-dev] [PATCH v4 2/8] drivers/net/ixgbe: change xstats to use integer ids

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patch changes the ixgbe driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 101 +--
 1 file changed, 86 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a2b170b..9e73492 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -179,6 +179,10 @@ static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
+static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 uint16_t queue_id,
 uint8_t stat_idx,
@@ -466,6 +470,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.xstats_get   = ixgbe_dev_xstats_get,
.stats_reset  = ixgbe_dev_stats_reset,
.xstats_reset = ixgbe_dev_xstats_reset,
+   .xstats_get_names = ixgbe_dev_xstats_get_names,
.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
.dev_infos_get= ixgbe_dev_info_get,
.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
@@ -555,6 +560,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.xstats_get   = ixgbevf_dev_xstats_get,
.stats_reset  = ixgbevf_dev_stats_reset,
.xstats_reset = ixgbevf_dev_stats_reset,
+   .xstats_get_names = ixgbevf_dev_xstats_get_names,
.dev_close= ixgbevf_dev_close,
.allmulticast_enable  = ixgbevf_dev_allmulticast_enable,
.allmulticast_disable = ixgbevf_dev_allmulticast_disable,
@@ -685,6 +691,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_rxq_strings[] = {

 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
   sizeof(rte_ixgbe_rxq_strings[0]))
+#define IXGBE_NB_RXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
{"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
@@ -695,6 +702,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_txq_strings[] = {

 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
   sizeof(rte_ixgbe_txq_strings[0]))
+#define IXGBE_NB_TXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
{"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
@@ -2695,8 +2703,75 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
 /* This function calculates the number of xstats based on the current config */
 static unsigned
 ixgbe_xstats_calc_num(void) {
-   return IXGBE_NB_HW_STATS + (IXGBE_NB_RXQ_PRIO_STATS * 8) +
-   (IXGBE_NB_TXQ_PRIO_STATS * 8);
+   return IXGBE_NB_HW_STATS +
+   (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
+   (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
+}
+
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   const unsigned cnt_stats = ixgbe_xstats_calc_num();
+   unsigned stat, i, count;
+
+   if (xstats_names != NULL) {
+   count = 0;
+
+   /* Note: limit >= cnt_stats checked upstream
+* in rte_eth_xstats_names()
+*/
+
+   /* Extended stats from ixgbe_hw_stats */
+   for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s",
+   rte_ixgbe_stats_strings[i].name);
+   count++;
+   }
+
+   /* RX Priority Stats */
+   for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
+   for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   

[dpdk-dev] [PATCH v4 1/8] rte: change xstats to use integer ids

2016-06-13 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 lib/librte_ether/rte_ethdev.c  | 94 +++---
 lib/librte_ether/rte_ethdev.h  | 35 +
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 128 insertions(+), 8 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..79a01cc 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1502,6 +1502,86 @@ rte_eth_stats_reset(uint8_t port_id)
dev->data->rx_mbuf_alloc_failed = 0;
 }

+static int
+get_xstats_count(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int count;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   count = (*dev->dev_ops->xstats_get_names)(dev, NULL, 0);
+   if (count < 0)
+   return count;
+   } else
+   count = 0;
+   count += RTE_NB_STATS;
+   count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+   count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
+   return count;
+}
+
+int
+rte_eth_xstats_get_names(uint8_t port_id,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned size)
+{
+   struct rte_eth_dev *dev;
+   int cnt_used_entries;
+   int cnt_expected_entries;
+   uint32_t idx, id_queue;
+
+   cnt_expected_entries = get_xstats_count(port_id);
+   if (xstats_names == NULL || cnt_expected_entries < 0)
+   return cnt_expected_entries;
+   if ((int)size < cnt_expected_entries)
+   return -ERANGE;
+
+   /* port_id checked in get_xstats_count() */
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   cnt_used_entries = (*dev->dev_ops->xstats_get_names)(
+   dev, xstats_names, size);
+   if (cnt_used_entries < 0)
+   return cnt_used_entries;
+   } else
+   /* Driver itself does not support extended stats, but
+* still have basic stats.
+*/
+   cnt_used_entries = 0;
+
+   for (idx = 0; idx < RTE_NB_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "%s", rte_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+   for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) {
+   for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "rx_q%u%s",
+   id_queue, rte_rxq_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+
+   }
+   for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) {
+   for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "tx_q%u%s",
+   id_queue, rte_txq_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+   }
+   return cnt_used_entries;
+}
+
 /* retrieve ethdev extended statistics */
 int
 rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
@@ -1546,8 +1626,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats 
*xstats,
stats_ptr = RTE_PTR_ADD(_stats,
rte_stats_strings[i].offset);
val = *stats_ptr;
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-   "%s", rte_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count + xcount;
xstats[count++].value = val;
}

@@ -1558,9 +1638,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats 
*xstats,
rte_rxq_stats_strings[i].offset +
q * sizeof(uint64_t));
val = *stats_ptr;
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-   "rx_q%u_%s", q,
-   rte_rxq_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count + xcount;
xstats[count++].value = val;
}
}
@@ -1572,9 

[dpdk-dev] [PATCH v4 0/8] Remove string operations from xstats

2016-06-13 Thread Remy Horton
The current extended ethernet statistics fetching involve doing several
string operations, which causes performance issues if there are lots of
statistics and/or network interfaces. This patchset changes the API for
xstats to use integer identifiers instead of strings and implements
this new API for the ixgbe, i40e, e1000, fm10k, and virtio drivers.

--

v4 changes:
* rte_eth_xstats_count() removed
* rte_eth_xstats_names() changed to rte_eth_xstats_get_names()
* struct rte_eth_xstats_name renamed to rte_eth_xstat_name
* struct rte_eth_xstats renamed to rte_eth_xstat
* struct rte_eth_dev: .xstats_names renamed to .xstats_get_names
* Other minor local variable name changes
* Documentation updates due to renames
* API changeover patches squashed

v3 changes:
* Corrected ixgbe vf xstats fetching
* Added xstats changes to e1000, f10k, and virtio drivers
* Added cleanup patch that removes now-redundant name field
* Removed ethtool xstats command 
* Removed unused .xstats_count from eth-dev_ops
* Changed test-pmd & proc_info to use new API
* Added documentation update
* Added missing changes to .map file (affected shared lib builds)

v2 changes:
* Fetching xstats count now seperate API function
* Added #define constants for some magic numbers
* Fixed bug with virtual function count fetching
* For non-xstats-supporting drivers, queue stats returned
* Some refactoring/cleanups
* Removed index assumption from example

Remy Horton (8):
  rte: change xstats to use integer ids
  drivers/net/ixgbe: change xstats to use integer ids
  drivers/net/e1000: change xstats to use integer ids
  drivers/net/fm10k: change xstats to use integer ids
  drivers/net/i40e: change xstats to use integer ids
  drivers/net/virtio: change xstats to use integer ids
  rte: change xstats usage to new API
  doc: update xstats documentation

 app/proc_info/main.c|  29 +++--
 app/test-pmd/config.c   |  54 
 doc/guides/prog_guide/poll_mode_drv.rst |  25 ++--
 drivers/net/e1000/igb_ethdev.c  |  58 ++---
 drivers/net/fm10k/fm10k_ethdev.c|  54 +---
 drivers/net/i40e/i40e_ethdev.c  |  82 +++-
 drivers/net/i40e/i40e_ethdev_vf.c   |  29 +++--
 drivers/net/ixgbe/ixgbe_ethdev.c| 106 ++--
 drivers/net/virtio/virtio_ethdev.c  |  64 ---
 lib/librte_ether/rte_ethdev.c   |  93 +---
 lib/librte_ether/rte_ethdev.h   |  42 +++--
 lib/librte_ether/rte_ether_version.map  |   7 +++
 12 files changed, 542 insertions(+), 101 deletions(-)

-- 
2.5.5



[dpdk-dev] [PATCH v3 1/2] ethdev: add callback to get register size in bytes

2016-06-13 Thread Remy Horton


On 12/06/2016 15:51, Zyta Szpak wrote:
> I would prefer having only one function rte_eth_dev_get_regs()
> which returns length and width if data is NULL.
> The first call is a parameter request before buffer allocation,
> and the second call fills the buffer.
>
> We can deprecate the old API and introduce this new one.
>
> Opinions?
>
> In my opinion as it is now it works fine. Gathering all parameters in
> one callback might be a good idea if the maintainer also agrees to that
> because as I mentioned, it interferes.

 From my perspective changing rte_eth_dev_get_regs() isn't a problem, as 
it isn't used directly rather than through rte_ethtool_get_regs()..

..Remy


[dpdk-dev] dpdk and sriov nic without igb_uio

2016-06-13 Thread Bruce Richardson
On Mon, Jun 13, 2016 at 05:40:39PM +0200, nirmoy das wrote:
> Hi ..,
> 
> I am trying to find a way to use dpdk in a VM with sriov nic
> without using igb_uio.
> 
> uio_pci_generic: failed with  "No IRQ assigned to device: no support for
> interrupts?".
> vfio-pci also doesn't work on linux < 4.5 and need dpdk > 16.04.
> 
> Is this a deadend  for dpdk+sriov If I have linux < 4.5 and/or dpdk < 16.04?
>
I believe so, yes.

/Bruce


[dpdk-dev] [PATCH v4 00/19] DPDK PMD for ThunderX NIC device

2016-06-13 Thread Bruce Richardson
On Mon, Jun 13, 2016 at 07:25:24PM +0530, Jerin Jacob wrote:
> This patch set provides the initial version of DPDK PMD for the
> built-in NIC device in Cavium ThunderX SoC family.
> 
> Implemented features and ThunderX nicvf PMD documentation added
> in doc/guides/nics/overview.rst and doc/guides/nics/thunderx.rst
> respectively in this patch set.
> 
> These patches are checked using checkpatch.sh with following
> additional ignore option:
> options="$options --ignore=CAMELCASE,BRACKET_SPACE"
> CAMELCASE - To accommodate PRIx64
> BRACKET_SPACE - To accommodate AT inline line assembly in two places
> 
Hi Jerin,

other than the fact that patch 1 is very big, this set looks pretty ok to me.
However, as a general comment on the series: the commit titles are overly
low-level, as they refer too much to function/structure names e.g. patches 4
through 10. If you run the script "check-git-log.sh" on your patchset this will
be flagged. What is expected in commit titles is that the change introduced by
the path is explained without directly using the function names.

Regards,
/Bruce


[dpdk-dev] [PATCH v4 05/10] app/test: support resources archived by tar

2016-06-13 Thread Jan Viktorin
On Mon, 13 Jun 2016 16:40:09 +0200
Thomas Monjalon  wrote:

> 2016-06-13 10:12, Jan Viktorin:
> > +static int do_copy(struct archive *r, struct archive *w)
> > +{
> > +   const void *buf;
> > +   size_t len;
> > +   off_t off;
> > +   int ret;
> > +
> > +   while (1) {
> > +   ret = archive_read_data_block(r, , , );  
> 
> There is an error in 32-bit compilation:
> 
> app/test/resource.c:108:48: error:
> passing argument 4 of ?archive_read_data_block? from incompatible pointer type
>ret = archive_read_data_block(r, , , );
> ^

Hello Thomas,

confirmed in my Jenkins build. But it's strange as I've built it successfully
for 32b many times before by using Buildroot...

So, I am going to resend v5.

Regards
Jan


[dpdk-dev] [PATCH v4 05/10] app/test: support resources archived by tar

2016-06-13 Thread Thomas Monjalon
2016-06-13 10:12, Jan Viktorin:
> +static int do_copy(struct archive *r, struct archive *w)
> +{
> + const void *buf;
> + size_t len;
> + off_t off;
> + int ret;
> +
> + while (1) {
> + ret = archive_read_data_block(r, , , );

There is an error in 32-bit compilation:

app/test/resource.c:108:48: error:
passing argument 4 of ?archive_read_data_block? from incompatible pointer type
   ret = archive_read_data_block(r, , , );
^


[dpdk-dev] [PATCH v2] mbuf: new flag when Vlan is stripped

2016-06-13 Thread Ananyev, Konstantin

Hi Olivier,

>   
> Hi Konstantin,
> 
> On 06/13/2016 04:42 PM, Ananyev, Konstantin wrote:
> >> The behavior of PKT_RX_VLAN_PKT was not very well defined, resulting in
> >> PMDs not advertising the same flags in similar conditions.
> >>
> >> Following discussion in [1], introduce 2 new flags PKT_RX_VLAN_STRIPPED
> >> and PKT_RX_QINQ_STRIPPED that are better defined:
> >>
> >>   PKT_RX_VLAN_STRIPPED: a vlan has been stripped by the hardware and its
> >>   tci is saved in mbuf->vlan_tci. This can only happen if vlan stripping
> >>   is enabled in the RX configuration of the PMD.
> >>
> >> For now, the old flag PKT_RX_VLAN_PKT is kept but marked as deprecated.
> >> It should be removed from applications and PMDs in a future revision.
> >
> > I am not sure it has to be deprecated & removed.
> > ixgbe (and igb as I can read the specs) devices can provide information is 
> > that
> > a vlan packet or not even when vlan stripping is disabled.
> > Right now ixgbe PMD do carry thins information to the user,
> > and I suppose igb could be improved to carry it too.
> > So obviously we need a way to pass that information to the upper layer.
> > I remember it was a discussion about introducing new packet_type
> > instead of ol_flag value PKT_RX_VLAN_PKT.
> > But right now it is not there, and again I don't know how easy it would be 
> > to replace
> > one with another without performance considering that packet_type is not 
> > supported
> > now by ixgbe vRX.
> > If we would be able to replace it, then yes we can deprecate and drop the   
> > PKT_RX_VLAN_PKT.
> > But till then, I think we'd better keep it.
> 
> I think the packet_type feature would be more appropriate than a flag
> for carrying this kind of info.
> 
> Currently the behavior of PKT_RX_VLAN_PKT is not properly defined,
> and it is not the same on all PMDs. So, from an application
> perspective, it's not usable except if it knows that the underlying
> PMD is an ixgbe.

Yes, but it might be apps which do use that ixgbe functionality.

> This is not acceptable for a generic API and that's
> why I think this flag, as it is today, should be deprecated.

I suppose we can't deprecate existing functionality without
providing working alternative.
I agree there is no proper way to know right now which device
supports it, which not, but to me it means we should add such ability,
not deprecate existing and (I believe) useful functionality.

> 
> It won't prevent an application from using the flag right after my
> commit, but it will warn the user that the flag should not be used
> as is. If someone is willing to work on this feature for 16.11, why
> not but again, I think using the packet_type is more appropriate.

I am not against providing that information via packet_type.
What I am saying:
1) right now it is not here.
2) it might not that easy in terms of performance.

> The problem is that I don't want to have this flag in this state
> forever, and I also don't want to add in rte_mbuf.h a comment
> saying "this flag does this on ixgbe and that on other drivers".

Then we need either:
- implement it as ptype
- add user ability to query is that flag is supported by the underlying device.

> 
> If we decide to generalize the ixgbe behavior for all PMDs for this
> flag, it will break the applications relying on this flag but with
> other PMDs. So for the same reason we added a new PKT_RX_VLAN_STRIPPED
> we cannot change the behavior of an existing flag.

Ok, then let's make PKT_RX_VLAN_STRIPPED == PKT_RX_VLAN,
and assign new value to the  PKT_RX_VLAN.
Or have PKT_RX_VLAN_STRIPPED == PKT_RX_VLAN and create a new one:
PKT_RX_VLAN_PRESENT or so.
?

Konstantin



[dpdk-dev] [PATCH v1 19/28] eal/soc: add drv_flags

2016-06-13 Thread Jan Viktorin
On Mon, 13 Jun 2016 14:21:40 +
Shreyansh Jain  wrote:

> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jan Viktorin
> > Sent: Friday, May 06, 2016 7:18 PM
> > To: dev at dpdk.org
> > Cc: Jan Viktorin ; David Marchand
> > ; Thomas Monjalon  > 6wind.com>;
> > Bruce Richardson ; Declan Doherty
> > ; jianbo.liu at linaro.org;
> > jerin.jacob at caviumnetworks.com; Keith Wiles ; 
> > Stephen
> > Hemminger 
> > Subject: [dpdk-dev] [PATCH v1 19/28] eal/soc: add drv_flags
> > 
> > The flags are copied from the PCI ones. They should be refactorized into a
> > general set of flags in the future.
> > 
> > Signed-off-by: Jan Viktorin 
> > ---
> >  lib/librte_eal/common/include/rte_soc.h | 10 ++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/lib/librte_eal/common/include/rte_soc.h
> > b/lib/librte_eal/common/include/rte_soc.h
> > index 49cfeb7..50a3b35 100644
> > --- a/lib/librte_eal/common/include/rte_soc.h
> > +++ b/lib/librte_eal/common/include/rte_soc.h
> > @@ -125,8 +125,18 @@ struct rte_soc_driver {
> > soc_devinit_t *devinit;/**< Device initialization */
> > soc_devuninit_t *devuninit;/**< Device uninitialization */
> > const struct rte_soc_id *id_table; /**< ID table, NULL terminated */
> > +   uint32_t drv_flags;/**< Control handling of device */
> >  };
> > 
> > +/** Device needs to map its resources by EAL */
> > +#define RTE_SOC_DRV_NEED_MAPPING 0x0001
> > +/** Device needs to be unbound event if no module is provieded */  
> 
> Comment should read "Device needs to be unbound even if no module is provided"

OK, thanks.

> 
> > +#define RTE_SOC_DRV_FORCE_UNBIND 0x0004
> > +/** Device driver supports link state interrupt */
> > +#define RTE_SOC_DRV_INTR_LSC0x0008
> > +/** Device driver supports detaching capability */
> > +#define RTE_SOC_DRV_DETACHABLE  0x0010
> > +
> >  /**
> >   * A structure describing a SoC mapping.
> >   */
> > --
> > 2.8.0  
> 


[dpdk-dev] [PATCH v1 07/28] eal/soc: add rte_eal_soc_register/unregister logic

2016-06-13 Thread Jan Viktorin
On Mon, 13 Jun 2016 14:19:39 +
Shreyansh Jain  wrote:

> Another trivial comment inlined:
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jan Viktorin
> > Sent: Friday, May 06, 2016 7:18 PM
> > To: dev at dpdk.org
> > Cc: Jan Viktorin ; David Marchand
> > ; Thomas Monjalon  > 6wind.com>;
> > Bruce Richardson ; Declan Doherty
> > ; jianbo.liu at linaro.org;
> > jerin.jacob at caviumnetworks.com; Keith Wiles ; 
> > Stephen
> > Hemminger 
> > Subject: [dpdk-dev] [PATCH v1 07/28] eal/soc: add
> > rte_eal_soc_register/unregister logic
> > 
> > Signed-off-by: Jan Viktorin 
> > ---
> >  app/test/test_soc.c | 106
> > 
> >  lib/librte_eal/bsdapp/eal/Makefile  |   1 +
> >  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   3 +
> >  lib/librte_eal/common/eal_common_soc.c  |  55 
> >  lib/librte_eal/common/include/rte_soc.h |  23 +
> >  lib/librte_eal/linuxapp/eal/Makefile|   1 +
> >  lib/librte_eal/linuxapp/eal/rte_eal_version.map |   4 +
> >  7 files changed, 193 insertions(+)
> >  create mode 100644 lib/librte_eal/common/eal_common_soc.c
> > 
> > diff --git a/app/test/test_soc.c b/app/test/test_soc.c
> > index a49fc9b..f6288dc 100644
> > --- a/app/test/test_soc.c
> > +++ b/app/test/test_soc.c
> > @@ -74,6 +74,103 @@ static int test_compare_addr(void)
> > free(a2.name);
> > free(a1.name);
> > free(a0.name);
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * Empty PMD driver based on the SoC infra.
> > + *
> > + * The rte_soc_device is usually wrapped in some higher-level struct
> > + * (eth_driver). We simulate such a wrapper with an anonymous struct here.
> > + */
> > +struct test_wrapper {
> > +   struct rte_soc_driver soc_drv;
> > +};
> > +
> > +struct test_wrapper empty_pmd0 = {
> > +   .soc_drv = {
> > +   .name = "empty_pmd0",
> > +   },
> > +};
> > +
> > +struct test_wrapper empty_pmd1 = {
> > +   .soc_drv = {
> > +   .name = "empty_pmd1",
> > +   },
> > +};
> > +
> > +static int
> > +count_registered_socdrvs(void)
> > +{
> > +   int i;
> > +   struct rte_soc_driver *drv;
> > +
> > +   i = 0;
> > +   TAILQ_FOREACH(drv, _driver_list, next)
> > +   i += 1;
> > +
> > +   return i;
> > +}
> > +
> > +static int
> > +test_register_unregister(void)
> > +{
> > +   struct rte_soc_driver *drv;
> > +   int count;
> > +
> > +   rte_eal_soc_register(_pmd0.soc_drv);
> > +
> > +   TEST_ASSERT(!TAILQ_EMPTY(_driver_list),
> > +   "No PMD is present but the empty_pmd0 should be there");
> > +   drv = TAILQ_FIRST(_driver_list);
> > +   TEST_ASSERT(!strcmp(drv->name, "empty_pmd0"),
> > +   "The registered PMD is not empty_pmd but '%s'", drv->name);  
> 
> Trivial: TEST_ASSERT Message should be: "... is not empty_pmd0 but..."

OK, thanks.

> 
[...]


[dpdk-dev] [PATCH v1 02/28] eal: extract function eal_parse_sysfs_valuef

2016-06-13 Thread Jan Viktorin
On Mon, 13 Jun 2016 14:18:40 +
Shreyansh Jain  wrote:

> Hi Jan,
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jan Viktorin
> > Sent: Friday, May 06, 2016 7:18 PM
> > To: dev at dpdk.org
> > Cc: Jan Viktorin ; David Marchand
> > ; Thomas Monjalon  > 6wind.com>;
> > Bruce Richardson ; Declan Doherty
> > ; jianbo.liu at linaro.org;
> > jerin.jacob at caviumnetworks.com; Keith Wiles ; 
> > Stephen
> > Hemminger 
> > Subject: [dpdk-dev] [PATCH v1 02/28] eal: extract function
> > eal_parse_sysfs_valuef
> > 
> > The eal_parse_sysfs_value function accepts a filename however, such 
> > interface
> > introduces race-conditions to the code. Introduce the variant of this
> > function
> > that accepts an already opened file instead of a filename.
> > 
> > Signed-off-by: Jan Viktorin 
> > ---
> >  lib/librte_eal/common/eal_filesystem.h |  5 +
> >  lib/librte_eal/linuxapp/eal/eal.c  | 36 
> > +++-
> > --
> >  2 files changed, 30 insertions(+), 11 deletions(-)
> > 
> > diff --git a/lib/librte_eal/common/eal_filesystem.h
> > b/lib/librte_eal/common/eal_filesystem.h
> > index fdb4a70..7875454 100644
> > --- a/lib/librte_eal/common/eal_filesystem.h
> > +++ b/lib/librte_eal/common/eal_filesystem.h
> > @@ -43,6 +43,7 @@
> >  /** Path of rte config file. */
> >  #define RUNTIME_CONFIG_FMT "%s/.%s_config"
> > 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -115,4 +116,8 @@ eal_get_hugefile_temp_path(char *buffer, size_t buflen,
> > const char *hugedir, int
> >   * Used to read information from files on /sys */
> >  int eal_parse_sysfs_value(const char *filename, unsigned long *val);
> > 
> > +/** Function to read a single numeric value from a file on the filesystem.
> > + * Used to read information from files on /sys */
> > +int eal_parse_sysfs_valuef(FILE *f, unsigned long *val);
> > +
> >  #endif /* EAL_FILESYSTEM_H */
> > diff --git a/lib/librte_eal/linuxapp/eal/eal.c
> > b/lib/librte_eal/linuxapp/eal/eal.c
> > index 4b28197..e8fce6b 100644
> > --- a/lib/librte_eal/linuxapp/eal/eal.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal.c
> > @@ -126,13 +126,30 @@ rte_eal_get_configuration(void)
> > return _config;
> >  }
> > 
> > +int
> > +eal_parse_sysfs_valuef(FILE *f, unsigned long *val)  

Hi Shreyansh,

> 
> Trivial Comment: Maybe it is just me, but this function name is too close to 
> its caller 'eal_parse_sysfs_value'. Probably, the name of the caller can be 
> changed to 'eal_parse_sysfs' because anyways value parsing is being done in 
> this ('eal_parse_sysfs_valuef()) function now. And, of course, dropping the 
> '..f' in this name.

I don't like the idea of renaming the orignal function eal_parse_sysfs_value. 
The function
name is not related to its actual body but to its semantics. And the semantics 
are still
the same. This would introduce many other unneeded changes...

> 
> I almost skipped the '..f' in the name and wondered how two functions having 
> same name exist :D

I agree that a better name would be nice here. This convention was based on the 
libc naming
(fopen, fclose) but the "f" letter could not be at the beginning.

What about one of those?

* eal_parse_sysfs_fd_value
* eal_parse_sysfs_file_value

Regards
Jan

[...]


[dpdk-dev] [PATCH v2 0/2] mk: fix more library underlinking

2016-06-13 Thread Thomas Monjalon
2016-06-13 13:06, Christian Ehrhardt:
> After several cleanups libraries are now linked against the libs they
> refer as DEPDIR which is great.
> But that now also made it visible that some references where still missing.
> 
> The following two patches try to fix that:
> [PATCH v2 1/2] mk: fix missing vhost dependency to pthread to avoid
> [PATCH v2 2/2] mk: fix missing DEPDIRS to avoid libarary underlinking

Applied, thanks


[dpdk-dev] [PATCH v2 0/6] reduce overlinking in applications

2016-06-13 Thread Thomas Monjalon
2016-06-10 15:19, Thomas Monjalon:
> This is a respin of the ideas of Christian and Ferruh to limit
> the static application size or dynamic links to shared libraries.
> 
> It also brings some clean-up in rte.app.mk.
> 
> Ferruh Yigit (2):
>   mk: prevent overlinking in applications
>   mk: reduce scope of whole-archive static linking
> 
> Thomas Monjalon (4):
>   mk: sort drivers in static application link list
>   mk: fix driver dependencies order for static application
>   mk: remove library grouping during application linking
>   mk: sort libraries in level order when linking

Applied


[dpdk-dev] [PATCH v4 01/19] net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC

2016-06-13 Thread Bruce Richardson
On Mon, Jun 13, 2016 at 07:25:25PM +0530, Jerin Jacob wrote:
> Adds hardware specific API for ThunderX nicvf inbuilt NIC device under
> drivers/net/thunderx/nicvf/base directory.
> 

Hi Jerin,

we are trying to move away from huge drops of shared code in a single patchfile,
so as to make the commits smaller and then easier to review. Can you split this
patch into e.g. 3+ smaller commits based around logical functionality. For
example, the base code mailbox functionality in the mbox.[ch] files could be
its own commit. Obviously, the finer-grained the breakdown the better :-), but
I'd rather not see patches >1 kloc looking to be merged in.

Regards,
/Bruce


[dpdk-dev] [PATCH v3 4/9] app/testpmd: remove fwd_config_setup from fwd_config_display

2016-06-13 Thread Iremonger, Bernard
Hi Pablo,



> > Subject: [PATCH v3 4/9] app/testpmd: remove fwd_config_setup from
> > fwd_config_display
> >
> > Remove fwd_config_setup from fwd_config_display and check that
> > forwarding has been setup before displaying forwarding configuration.
> > Add call to fwd_config_setup for corelist, coremask, nbcore setup.
> > Add call to fwd_config_setup for portlist, portmask, nbport setup.
> 
> Probably we need to add that call to the commands that change number of
> RX/TX queues, as well.

I will check this.

> > Signed-off-by: Bernard Iremonger 
> > ---
> >  app/test-pmd/cmdline.c | 23 ---
> > app/test-pmd/config.c  |  6 --
> >  2 files changed, 20 insertions(+), 9 deletions(-)
> >
> 
>  [...]
> 
> > --- a/app/test-pmd/config.c
> > +++ b/app/test-pmd/config.c
> > @@ -1424,8 +1424,10 @@ pkt_fwd_config_display(struct fwd_config *cfg)
> > void
> >  fwd_config_display(void)
> >  {
> > -   fwd_config_setup();
> > -   pkt_fwd_config_display(_fwd_config);
> > +   if (cur_fwd_config.nb_fwd_ports)
> > +   pkt_fwd_config_display(_fwd_config);
> > +   else
> > +   printf("Please set portlist first\n");
> 
> I think this is not necessary. I would call fwd_config_setup() at startup, so
> everything is setup when this is called (even if it is the first command when
> the prompt comes up).
> I think at the end of init_config() is a good place.

Ok, I will try this. 



Regards,

Bernard.



[dpdk-dev] Performance hit - NICs on different CPU sockets

2016-06-13 Thread Take Ceara
Hi,

I'm reposting here as I didn't get any answers on the dpdk-users mailing list.

We're working on a stateful traffic generator (www.warp17.net) using
DPDK and we would like to control two XL710 NICs (one on each socket)
to maximize CPU usage. It looks that we run into the following
limitation:

http://dpdk.org/doc/guides/linux_gsg/nic_perf_intel_platform.html
section 7.2, point 3

We completely split memory/cpu/NICs across the two sockets. However,
the performance with a single CPU and both NICs on the same socket is
better.
Why do all the NICs have to be on the same socket, is there a
driver/hw limitation?

Thanks,
Dumitru Ceara


[dpdk-dev] [PATCH v10 3/3] i40e: add floating VEB extension support

2016-06-13 Thread Zhe Tao
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the 
PMD
will use the floating VEB feature for all the VFs created by this PF device.

Also you can specifiy which VF need to connect to this floating veb using
"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the VF0 
connect
to the floating VEB, VF1 connect to the legacy VEB.

The current implementation only support one floating VEB and one legacy
VEB. VF can connect to floating VEB or legacy VEB according to the
configuration.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  8 ++
 drivers/net/i40e/i40e_ethdev.c | 56 --
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_pf.c |  3 ++-
 4 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index aae78ca..d3196ad 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -372,6 +372,14 @@ FVL can support floating VEB feature.
 To enable this feature, the user should pass a devargs parameter to the EAL
 like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
 PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
+Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the VF0
+connect to the floating VEB, VF1 connect to the legacy VEB.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration. 

 The floating VEB means the VEB doesn't has some uplink connection to the 
outside
 world, so all the switching belong to this VEB cannot go to outside, the
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 025d498..17aaa08 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,52 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_fbitmap_handler(__rte_unused const char *key,
+ const char *value,
+ void *opaque)
+{
+   errno = 0;
+   *(uint16_t *)opaque = strtoul(value, NULL, 0);
+   if (errno)
+   return -1;
+   return 0;
+}
+
+static uint16_t i40e_check_fbitmap(struct rte_devargs *devargs,
+  uint16_t floating)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_bitmap = "floating_bitmap";
+   /* default value for vf floating bitmap is -1 */
+   uint16_t vf_fbitmap = (uint16_t)-1;
+   uint16_t new_vf_fbitmap;
+
+   if (floating == false)
+   return 0;
+
+   if (devargs == NULL)
+   return vf_fbitmap;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return vf_fbitmap;
+
+   if (!rte_kvargs_count(kvlist, floating_bitmap)) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_bitmap,
+  i40e_check_fbitmap_handler,
+  _vf_fbitmap) < 0) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   rte_kvargs_free(kvlist);
+
+   return new_vf_fbitmap;
+}
+
 static int i40e_check_floating_handler(__rte_unused const char *key,
   const char *value,
   __rte_unused void *opaque)
@@ -884,8 +930,11 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Need the special FW version support floating VEB */
if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
pf->floating = i40e_check_floating(pci_dev->devargs);
+   pf->vf_fbitmap = i40e_check_fbitmap(pci_dev->devargs,
+   pf->floating);
} else {
pf->floating = false;
+   pf->vf_fbitmap = 0;
}
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);
@@ -3855,6 +3904,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
struct i40e_vsi_list *vsi_list;
int ret;
struct i40e_mac_filter *f;
+   uint16_t user_param = vsi->user_param;

if (!vsi)
return I40E_SUCCESS;
@@ -3886,7 +3936,8 @@ i40e_vsi_release(struct i40e_vsi *vsi)
rte_free(f);

if (vsi->type != I40E_VSI_MAIN &&
-   ((vsi->type != I40E_VSI_SRIOV) || 

[dpdk-dev] [PATCH v10 2/3] i40e: add floating VEB support in i40e

2016-06-13 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable for the FW version which
newer than 5.0 (FW major version number > 5).

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  17 +
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 109 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 120 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..aae78ca 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,20 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
+PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..686b683 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst. 

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8c4ae1c..025d498 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3762,21 +3762,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3788,9 +3794,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3802,11 +3808,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false,
+ >seid, false, 

[dpdk-dev] [PATCH v10 1/3] i40e: support floating VEB config

2016-06-13 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the 
PMD
will use the floating VEB feature for all the VFs created by this PF device.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

But for floating VEB, it has two major difference.
1. doesn't has a up link connection which means
the traffic cannot go to ouside world.
2. doesn't need to connect to the phsical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..8c4ae1c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floatingVEB";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -843,6 +881,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..8297c5f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -450,6 +455,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH v10 0/3] i40e: add floating VEB support for i40e

2016-06-13 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (3):
  Support floating VEB config
  Add floating VEB support in i40e
  Add floating VEB extention support for i40e

 doc/guides/nics/i40e.rst   |  25 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 205 +
 drivers/net/i40e/i40e_ethdev.h |   9 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 232 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 

-- 
2.1.4



[dpdk-dev] [PATCH v3 4/9] app/testpmd: remove fwd_config_setup from fwd_config_display

2016-06-13 Thread De Lara Guarch, Pablo
Hi Bernard,

> -Original Message-
> From: Iremonger, Bernard
> Sent: Sunday, June 12, 2016 4:23 PM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo; Iremonger, Bernard
> Subject: [PATCH v3 4/9] app/testpmd: remove fwd_config_setup from
> fwd_config_display
> 
> Remove fwd_config_setup from fwd_config_display and check that
> forwarding has been setup before displaying forwarding configuration.
> Add call to fwd_config_setup for corelist, coremask, nbcore setup.
> Add call to fwd_config_setup for portlist, portmask, nbport setup.

Probably we need to add that call to the commands that change number of RX/TX 
queues, as well.

> 
> Signed-off-by: Bernard Iremonger 
> ---
>  app/test-pmd/cmdline.c | 23 ---
>  app/test-pmd/config.c  |  6 --
>  2 files changed, 20 insertions(+), 9 deletions(-)
> 

 [...]

> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -1424,8 +1424,10 @@ pkt_fwd_config_display(struct fwd_config *cfg)
>  void
>  fwd_config_display(void)
>  {
> - fwd_config_setup();
> - pkt_fwd_config_display(_fwd_config);
> + if (cur_fwd_config.nb_fwd_ports)
> + pkt_fwd_config_display(_fwd_config);
> + else
> + printf("Please set portlist first\n");

I think this is not necessary. I would call fwd_config_setup() at startup,
so everything is setup when this is called (even if it is the first command 
when the prompt comes up).
I think at the end of init_config() is a good place.


>  }
> 
>  int
> --
> 2.6.3



[dpdk-dev] [PATCH] mbuf: remove unused Rx error flags

2016-06-13 Thread Thomas Monjalon
> > > Just a note, I think you'll need to rebase your patch with latest code.
> > > enic PMD fails to compile.
> > 
> > Indeed, this patch should be applied after John's enic series. Latest
> > one is there:
> > http://dpdk.org/ml/archives/dev/2016-June/040183.html
> > 
> > Please Bruce/Thomas, check this dependency before applying.
> > 
> That patchset is already applied to next-net so this patch applies cleanly and
> compiles ok there.
> Thomas, you ok for me just to apply this patch to next-net also?

No problem


[dpdk-dev] Duplicate config symbols

2016-06-13 Thread Thomas Monjalon
2016-06-13 13:50, Christian Ehrhardt:
> I wondered multiple times now when changing a config symbol that some of
> them are in the .config file multiple times.
> I totally feel like I'm overlooking something, but still it might be worth
> to ask.
[...]
> Is there any reason to do so or is this an issue in make config?

It is an issue in "make config" which has never been considered important.
We could remove the first - overridden - occurences.
I think it can be fixed in mk/rte.sdkconfig.mk.



[dpdk-dev] [PATCH 22/29] ixgbe/base: add bypassing VLVF

2016-06-13 Thread Ferruh Yigit
On 5/6/2016 7:07 AM, Beilei Xing wrote:
> This patch adds support for the VLVF to be bypassed when adding or
> removing a VFTA entry.  The PF can utilize the default pool while
> preserving the VLVF for the VFs use.
> Meanwhile, update corresponding VF ops and drivers where corresponding
> ops is invoked.
> 
> Signed-off-by: Beilei Xing 
> ---
>  drivers/net/ixgbe/base/ixgbe_82598.c  |  5 ++-
>  drivers/net/ixgbe/base/ixgbe_82598.h  |  3 +-
>  drivers/net/ixgbe/base/ixgbe_api.c| 11 --
>  drivers/net/ixgbe/base/ixgbe_api.h|  5 ++-
>  drivers/net/ixgbe/base/ixgbe_common.c | 71 
> +++
>  drivers/net/ixgbe/base/ixgbe_common.h |  7 ++--
>  drivers/net/ixgbe/base/ixgbe_type.h   |  5 ++-
>  drivers/net/ixgbe/base/ixgbe_vf.c |  6 ++-
>  drivers/net/ixgbe/base/ixgbe_vf.h |  3 +-
>  drivers/net/ixgbe/ixgbe_ethdev.c  | 11 --
>  drivers/net/ixgbe/ixgbe_pf.c  |  2 +-
>  11 files changed, 76 insertions(+), 53 deletions(-)
> 

Hi Beilei,

This patch failing to apply to latest dpdk-next-net/rel_16_07

Applying: ixgbe/base: add bypassing VLVF
Using index info to reconstruct a base tree...
M   drivers/net/ixgbe/ixgbe_ethdev.c
M   drivers/net/ixgbe/ixgbe_pf.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/net/ixgbe/ixgbe_pf.c
Auto-merging drivers/net/ixgbe/ixgbe_ethdev.c
CONFLICT (content): Merge conflict in drivers/net/ixgbe/ixgbe_ethdev.c
Failed to merge in the changes.
Patch failed at 0001 ixgbe/base: add bypassing VLVF




[dpdk-dev] [PATCH] ethdev: clarify the origin of mbufs

2016-06-13 Thread Olivier Matz
Following the discussion on dpdk-users [1], enhance the API
documentation of rte_eth_tx_burst() to specify that the mbufs have to be
allocated from a pool.

[1] http://dpdk.org/ml/archives/users/2016-June/000618.html

Reported-by: Wu Xiaoban 
Signed-off-by: Olivier Matz 
---
 lib/librte_ether/rte_ethdev.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2757510..e5e91e4 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2683,7 +2683,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t 
queue_id, uint16_t offset)
  * on the output queue *queue_id* of the Ethernet device designated by its
  * *port_id*.
  * The *nb_pkts* parameter is the number of packets to send which are
- * supplied in the *tx_pkts* array of *rte_mbuf* structures.
+ * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them
+ * allocated from a pool created with rte_pktmbuf_pool_create().
  * The rte_eth_tx_burst() function loops, sending *nb_pkts* packets,
  * up to the number of transmit descriptors available in the TX ring of the
  * transmit queue.
-- 
2.8.0.rc3



[dpdk-dev] Performance hit - NICs on different CPU sockets

2016-06-13 Thread Bruce Richardson
On Mon, Jun 13, 2016 at 04:07:37PM +0200, Take Ceara wrote:
> Hi,
> 
> I'm reposting here as I didn't get any answers on the dpdk-users mailing list.
> 
> We're working on a stateful traffic generator (www.warp17.net) using
> DPDK and we would like to control two XL710 NICs (one on each socket)
> to maximize CPU usage. It looks that we run into the following
> limitation:
> 
> http://dpdk.org/doc/guides/linux_gsg/nic_perf_intel_platform.html
> section 7.2, point 3
> 
> We completely split memory/cpu/NICs across the two sockets. However,
> the performance with a single CPU and both NICs on the same socket is
> better.
> Why do all the NICs have to be on the same socket, is there a
> driver/hw limitation?
> 
Hi,

so long as each thread only ever accesses the NIC on it's own local socket, then
there is no performance penalty. It's only when a thread on one socket works
using a NIC on a remote socket that you start seeing a penalty, with all
NIC-core communication having to go across QPI.

/Bruce


[dpdk-dev] [PATCH v4 1/2] enic: fix seg fault when releasing queues

2016-06-13 Thread Bruce Richardson
On Sat, Jun 11, 2016 at 10:27:04AM -0700, John Daley wrote:
> If device configuration failed due to a lack of resources, such as
> if more queues are requested than are available, the queue release
> functions are called with NULL pointers which were being dereferenced.
> 
> Skip releasing queues if they are NULL pointers.
> 
> Fixes: fefed3d1e62c ("enic: new driver")
> Signed-off-by: John Daley 
Patchset applied to dpdk-next-net/rel_16_07

/Bruce


[dpdk-dev] [PATCH v4 4/4] app/test: add crypto AES-CBC-128 HMAC-SHA224 and HMAC-SHA384 unit tests

2016-06-13 Thread Fan Zhang
This patch adds the HMAC-SHA224 and HMAC-SHA384 digest generation and
verification tests to crypto

Signed-off-by: Fan Zhang 
---
 app/test/test_cryptodev_aes.c |  26 
 app/test/test_cryptodev_aes.h | 296 ++
 2 files changed, 322 insertions(+)

diff --git a/app/test/test_cryptodev_aes.c b/app/test/test_cryptodev_aes.c
index 3b5f005..c4e35e9 100755
--- a/app/test/test_cryptodev_aes.c
+++ b/app/test/test_cryptodev_aes.c
@@ -211,6 +211,32 @@ static const struct aes_test_case aes_test_cases[] = {
.feature_mask = AES_TEST_FEATURE_OOP,
.pmd_mask = AES_TEST_TARGET_PMD_QAT
},
+   {
+   .test_descr = "AES-128-CBC HMAC-SHA224 Encryption Digest",
+   .test_data = _test_data_8,
+   .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
+   .pmd_mask = AES_TEST_TARGET_PMD_MB
+   },
+   {
+   .test_descr = "AES-128-CBC HMAC-SHA224 Decryption Digest "
+   "Verify",
+   .test_data = _test_data_8,
+   .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
+   .pmd_mask = AES_TEST_TARGET_PMD_MB
+   },
+   {
+   .test_descr = "AES-128-CBC HMAC-SHA384 Encryption Digest",
+   .test_data = _test_data_9,
+   .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
+   .pmd_mask = AES_TEST_TARGET_PMD_MB
+   },
+   {
+   .test_descr = "AES-128-CBC HMAC-SHA384 Decryption Digest "
+   "Verify",
+   .test_data = _test_data_9,
+   .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
+   .pmd_mask = AES_TEST_TARGET_PMD_MB
+   },
 };

 static int
diff --git a/app/test/test_cryptodev_aes.h b/app/test/test_cryptodev_aes.h
index c3b439b..ef518e0 100755
--- a/app/test/test_cryptodev_aes.h
+++ b/app/test/test_cryptodev_aes.h
@@ -825,4 +825,300 @@ static const struct aes_test_data aes_test_data_7 = {
}
 };

+/** AES-128-CBC SHA224 test vector */
+static const struct aes_test_data aes_test_data_8 = {
+   .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
+   .cipher_key = {
+   .data = {
+   0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
+   0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
+   },
+   .len = 16
+   },
+   .iv = {
+   .data = {
+   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+   0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+   },
+   .len = 16
+   },
+   .plaintext = {
+   .data = {
+   "What a lousy earth! He wondered how many people "
+   "were destitute that same night even in his own "
+   "prosperous country, how many homes were "
+   "shanties, how many husbands were drunk and "
+   "wives socked, and how many children were "
+   "bullied, abused, or abandoned. How many "
+   "families hungered for food they could not "
+   "afford to buy? How many hearts were broken? How "
+   "many suicides would take place that same night, "
+   "how many people would go insane? How many "
+   "cockroaches and landlords would triumph? How "
+   "many winners were losers, successes failures, "
+   "and rich men poor men? How many wise guys were "
+   "stupid? How many happy endings were unhappy "
+   "endings? How many honest men were liars, brave "
+   "men cowards, loyal men traitors, how many "
+   "sainted men were corrupt, how many people in "
+   "positions of trust had sold their souls to "
+   "bodyguards, how many had never had souls? How "
+   "many straight-and-narrow paths were crooked "
+   "paths? How many best families were worst "
+   "families and how many good people were bad "
+   "people? When you added them all up and then "
+   "subtracted, you might be left with only the "
+   "children, and perhaps with Albert Einstein and "
+   "an old violinist or sculptor somewhere."
+   },
+   .len = 512
+   },
+   .ciphertext = {
+   .data = {
+   0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
+   0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
+   0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
+   0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
+   0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
+  

[dpdk-dev] [PATCH v4 3/4] app/test: utilize new unified crypto AES test function

2016-06-13 Thread Fan Zhang
This patch replaces the AES test code with new unified crypto AES test
function.

Signed-off-by: Fan Zhang 
---
 app/test/test_cryptodev.c  | 1613 ++--
 app/test/test_cryptodev_aes_ctr_test_vectors.h |  257 
 2 files changed, 122 insertions(+), 1748 deletions(-)
 delete mode 100644 app/test/test_cryptodev_aes_ctr_test_vectors.h

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 45e6daa..1730022 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -43,7 +43,7 @@
 #include "test.h"
 #include "test_cryptodev.h"

-#include "test_cryptodev_aes_ctr_test_vectors.h"
+#include "test_cryptodev_aes.h"
 #include "test_cryptodev_snow3g_test_vectors.h"
 #include "test_cryptodev_snow3g_hash_test_vectors.h"
 #include "test_cryptodev_gcm_test_vectors.h"
@@ -111,19 +111,6 @@ setup_test_string(struct rte_mempool *mpool,

return m;
 }
-static int
-setup_oop_test_mbufs(struct rte_mbuf **ibuf, struct rte_mbuf **obuf,
-   struct rte_mempool *mpool,  const char *string, size_t len,
-   uint8_t blocksize) {
-   *ibuf = setup_test_string(mpool, string, len, blocksize);
-   if (*ibuf == NULL)
-   return -(EFAULT);
-   *obuf = setup_test_string(mpool, NULL, len, blocksize);
-   if (*obuf == NULL)
-   return -(EFAULT);
-
-   return 0;
-}

 #if HEX_DUMP
 static void
@@ -890,1316 +877,80 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;

-   rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
-   CIPHER_IV_LENGTH_AES_CBC);
-
-   sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
-   sym_op->cipher.data.length = QUOTE_512_BYTES;
-
-   /* Process crypto operation */
-   TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
-   ut_params->op), "failed to process sym crypto op");
-
-   TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
-   "crypto op processing failed");
-
-   /* Validate obuf */
-   uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
-   uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
-
-   TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
-   catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
-   QUOTE_512_BYTES,
-   "ciphertext data not as expected");
-
-   uint8_t *digest = ciphertext + QUOTE_512_BYTES;
-
-   TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
-   catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
-   gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
-   TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
-   DIGEST_BYTE_LENGTH_SHA1,
-   "Generated digest data not as expected");
-
-   return TEST_SUCCESS;
-}
-
-
-static int
-test_AES_CBC_HMAC_SHA1_encrypt_digest_oop(void)
-{
-   struct crypto_testsuite_params *ts_params = _params;
-   struct crypto_unittest_params *ut_params = _params;
-
-   /* Generate test mbuf data and space for digest */
-
-   TEST_ASSERT_EQUAL(setup_oop_test_mbufs(_params->ibuf,
-   _params->obuf, ts_params->mbuf_pool, catch_22_quote,
-   QUOTE_512_BYTES, 0), 0,
-   "Allocation of rte_mbuf failed");
-
-   ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->obuf,
-   DIGEST_BYTE_LENGTH_SHA1);
-
-   TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
-
-   ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
-   ut_params->cipher_xform.next = _params->auth_xform;
-
-   ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
-   ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
-   ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
-   ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
-
-   ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
-   ut_params->auth_xform.next = NULL;
-
-   ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
-   ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
-   ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
-   ut_params->auth_xform.auth.key.data = hmac_sha1_key;
-   ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
-
-   ut_params->sess = rte_cryptodev_sym_session_create(
-   ts_params->valid_devs[0],
-   _params->cipher_xform);
-
-   TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-
-   ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
-   

[dpdk-dev] [PATCH v4 2/4] app/test: add unified crypto aes test

2016-06-13 Thread Fan Zhang
This patch adds a new crypto AES unified test function.

Signed-off-by: Fan Zhang 
---
 app/test/Makefile |   1 +
 app/test/test_cryptodev_aes.c | 663 ++
 app/test/test_cryptodev_aes.h |   6 +
 3 files changed, 670 insertions(+)
 create mode 100755 app/test/test_cryptodev_aes.c

diff --git a/app/test/Makefile b/app/test/Makefile
index f269fe0..fd193df 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -153,6 +153,7 @@ endif
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c

+SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_aes.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c

diff --git a/app/test/test_cryptodev_aes.c b/app/test/test_cryptodev_aes.c
new file mode 100755
index 000..3b5f005
--- /dev/null
+++ b/app/test/test_cryptodev_aes.c
@@ -0,0 +1,663 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2015-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 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "test.h"
+#include "test_cryptodev_aes.h"
+
+#ifndef MAX_N_AES_TESTS
+#define MAX_N_AES_TESTS256
+#endif
+
+#ifndef AES_TEST_MSG_LEN
+#define AES_TEST_MSG_LEN   256
+#endif
+
+#define AES_TEST_OP_ENCRYPT0x01
+#define AES_TEST_OP_DECRYPT0x02
+#define AES_TEST_OP_AUTH_GEN   0x04
+#define AES_TEST_OP_AUTH_VERIFY0x08
+
+#define AES_TEST_FEATURE_OOP   0x01
+#define AES_TEST_FEATURE_SESSIONLESS   0x02
+#define AES_TEST_FEATURE_STOPPER   0x04 /* stop upon failing */
+
+#define AES_TEST_TARGET_PMD_MB 0x0001 /* Multi-buffer flag */
+#define AES_TEST_TARGET_PMD_QAT0x0002 /* QAT flag */
+
+#define AES_TEST_OP_CIPHER (AES_TEST_OP_ENCRYPT |  \
+   AES_TEST_OP_DECRYPT)
+
+#define AES_TEST_OP_AUTH   (AES_TEST_OP_AUTH_GEN | \
+   AES_TEST_OP_AUTH_VERIFY)
+
+#define AES_TEST_OP_ENC_AUTH_GEN   (AES_TEST_OP_ENCRYPT |  \
+   AES_TEST_OP_AUTH_GEN)
+
+#define AES_TEST_OP_AUTH_VERIFY_DEC(AES_TEST_OP_DECRYPT |  \
+   AES_TEST_OP_AUTH_VERIFY)
+
+struct aes_test_case {
+   const char *test_descr; /* test description */
+   const struct aes_test_data *test_data;
+   uint8_t op_mask; /* operation mask */
+   uint8_t feature_mask;
+   uint32_t pmd_mask;
+};
+
+static const struct aes_test_case aes_test_cases[] = {
+   {
+   .test_descr = "AES-128-CTR HMAC-SHA1 Encryption Digest",
+   .test_data = _test_data_1,
+   .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
+   .pmd_mask = AES_TEST_TARGET_PMD_MB |
+   AES_TEST_TARGET_PMD_QAT
+   },
+   {
+   .test_descr = "AES-128-CTR HMAC-SHA1 Decryption Digest "
+   "Verify",
+   .test_data = _test_data_1,
+   .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
+   .pmd_mask = AES_TEST_TARGET_PMD_MB |
+   AES_TEST_TARGET_PMD_QAT
+   },
+   {
+   .test_descr = 

  1   2   3   >