[dpdk-dev] [PATCH] ixgbe: use rte_mbuf_prefetch_part2 for cacheline1 access

2016-06-17 Thread Jerin Jacob
made second cache line access behavior same as IA

Signed-off-by: Jerin Jacob 
---
 drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
index 9c1d124..64a329e 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_neon.c
@@ -280,10 +280,10 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
vst1q_u64((uint64_t *)_pkts[pos + 2], mbp2);

if (split_packet) {
-   rte_prefetch_non_temporal(_pkts[pos]->cacheline1);
-   rte_prefetch_non_temporal(_pkts[pos + 
1]->cacheline1);
-   rte_prefetch_non_temporal(_pkts[pos + 
2]->cacheline1);
-   rte_prefetch_non_temporal(_pkts[pos + 
3]->cacheline1);
+   rte_mbuf_prefetch_part2(rx_pkts[pos]);
+   rte_mbuf_prefetch_part2(rx_pkts[pos + 1]);
+   rte_mbuf_prefetch_part2(rx_pkts[pos + 2]);
+   rte_mbuf_prefetch_part2(rx_pkts[pos + 3]);
}

/* D.1 pkt 3,4 convert format from desc to pktmbuf */
-- 
2.5.5



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

2016-06-17 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 be09a98..e41ce13 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -343,6 +343,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 v6 26/27] net/thunderx: updated driver documentation and release notes

2016-06-17 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 ffe011e..99ee7f1 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -51,6 +51,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 29a6163..c1ee67b 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 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 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 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 t 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 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 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 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 t 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 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 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 Y
-   MTU update Y Y Y   Y   Y Y Y Y Y Y
-   Jumbo frameY 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 Y
+   MTU update Y Y Y   Y   Y Y Y Y Y Y  
   Y
+   Jumbo frameY Y Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y  
 Y Y Y

[dpdk-dev] [PATCH v6 25/27] net/thunderx: add device start, stop and close support

2016-06-17 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 fd5751e..d534312 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 v6 24/27] net/thunderx: add Tx queue start and stop support

2016-06-17 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 ed69147..fd5751e 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 v6 23/27] net/thunderx: add Rx queue start and stop support

2016-06-17 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 33d5fba..ed69147 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 v6 22/27] net/thunderx: add Rx queue count support

2016-06-17 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 | 1 +
 drivers/net/thunderx/nicvf_rxtx.c   | 9 +
 drivers/net/thunderx/nicvf_rxtx.h   | 2 ++
 3 files changed, 12 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 46f0d7b..33d5fba 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -935,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 v6 20/27] net/thunderx: add single and multi segment Rx functions

2016-06-17 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 v6 19/27] net/thunderx: add single and multi segment Tx functions

2016-06-17 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 e20f0d9..c727ce0 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 v6 18/27] net/thunderx: add stats support

2016-06-17 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 9c95ce8..e20f0d9 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 v6 17/27] net/thunderx: add promiscuous enable support

2016-06-17 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 | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 65b14c8..9c95ce8 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -211,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)
 {
@@ -811,6 +817,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,
+   .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,
-- 
2.5.5



[dpdk-dev] [PATCH v6 16/27] net/thunderx: add MTU set support

2016-06-17 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 | 44 +
 drivers/net/thunderx/nicvf_ethdev.h |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 08f65b3..65b14c8 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();
@@ -769,6 +812,7 @@ 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,
+   .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 v6 15/27] net/thunderx: add RSS and reta query and update support

2016-06-17 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 e786481..08f65b3 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 v6 14/27] net/thunderx: add Tx queue setup and release support

2016-06-17 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 52856ab..e786481 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 v6 13/27] net/thunderx: add Rx queue setup and release support

2016-06-17 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 1bea851..52856ab 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 v6 12/27] net/thunderx: add get device info support

2016-06-17 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 33344fd..1bea851 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 v6 11/27] net/thunderx: add ethdev configure support

2016-06-17 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 6811718..33344fd 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 v6 10/27] net/thunderx: add registers dump support

2016-06-17 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 ec5407b..6811718 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 v6 09/27] net/thunderx: add link status and link update support

2016-06-17 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 ba78ff2..ec5407b 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 v6 08/27] net/thunderx: add pmd skeleton

2016-06-17 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| 253 +
 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  |   1 +
 10 files changed, 597 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 d6e7a16..ead5984 100644
--- a/config/common_base
+++ b/config/common_base
@@ -264,6 +264,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 9818a2e..a5b1e24 100644
--- a/config/defconfig_arm64-thunderx-linuxapp-gcc
+++ b/config/defconfig_arm64-thunderx-linuxapp-gcc
@@ -36,3 +36,13 @@ 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
+#
+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 3832706..bc93230 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -51,6 +51,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 

[dpdk-dev] [PATCH v6 07/27] net/thunderx/base: add statistics get HW APIs

2016-06-17 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/base/nicvf_hw.c | 45 
 drivers/net/thunderx/base/nicvf_hw.h | 44 +++
 2 files changed, 89 insertions(+)

diff --git a/drivers/net/thunderx/base/nicvf_hw.c 
b/drivers/net/thunderx/base/nicvf_hw.c
index 3366aa5..001b0ed 100644
--- a/drivers/net/thunderx/base/nicvf_hw.c
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -858,3 +858,48 @@ nicvf_loopback_config(struct nicvf *nic, bool enable)

return nicvf_mbox_loopback_config(nic, enable);
 }
+
+void
+nicvf_hw_get_stats(struct nicvf *nic, struct nicvf_hw_stats *stats)
+{
+   stats->rx_bytes = NICVF_GET_RX_STATS(RX_OCTS);
+   stats->rx_ucast_frames = NICVF_GET_RX_STATS(RX_UCAST);
+   stats->rx_bcast_frames = NICVF_GET_RX_STATS(RX_BCAST);
+   stats->rx_mcast_frames = NICVF_GET_RX_STATS(RX_MCAST);
+   stats->rx_fcs_errors = NICVF_GET_RX_STATS(RX_FCS);
+   stats->rx_l2_errors = NICVF_GET_RX_STATS(RX_L2ERR);
+   stats->rx_drop_red = NICVF_GET_RX_STATS(RX_RED);
+   stats->rx_drop_red_bytes = NICVF_GET_RX_STATS(RX_RED_OCTS);
+   stats->rx_drop_overrun = NICVF_GET_RX_STATS(RX_ORUN);
+   stats->rx_drop_overrun_bytes = NICVF_GET_RX_STATS(RX_ORUN_OCTS);
+   stats->rx_drop_bcast = NICVF_GET_RX_STATS(RX_DRP_BCAST);
+   stats->rx_drop_mcast = NICVF_GET_RX_STATS(RX_DRP_MCAST);
+   stats->rx_drop_l3_bcast = NICVF_GET_RX_STATS(RX_DRP_L3BCAST);
+   stats->rx_drop_l3_mcast = NICVF_GET_RX_STATS(RX_DRP_L3MCAST);
+
+   stats->tx_bytes_ok = NICVF_GET_TX_STATS(TX_OCTS);
+   stats->tx_ucast_frames_ok = NICVF_GET_TX_STATS(TX_UCAST);
+   stats->tx_bcast_frames_ok = NICVF_GET_TX_STATS(TX_BCAST);
+   stats->tx_mcast_frames_ok = NICVF_GET_TX_STATS(TX_MCAST);
+   stats->tx_drops = NICVF_GET_TX_STATS(TX_DROP);
+}
+
+void
+nicvf_hw_get_rx_qstats(struct nicvf *nic, struct nicvf_hw_rx_qstats *qstats,
+  uint16_t qidx)
+{
+   qstats->q_rx_bytes =
+   nicvf_queue_reg_read(nic, NIC_QSET_RQ_0_7_STATUS0, qidx);
+   qstats->q_rx_packets =
+   nicvf_queue_reg_read(nic, NIC_QSET_RQ_0_7_STATUS1, qidx);
+}
+
+void
+nicvf_hw_get_tx_qstats(struct nicvf *nic, struct nicvf_hw_tx_qstats *qstats,
+  uint16_t qidx)
+{
+   qstats->q_tx_bytes =
+   nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS0, qidx);
+   qstats->q_tx_packets =
+   nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS1, qidx);
+}
diff --git a/drivers/net/thunderx/base/nicvf_hw.h 
b/drivers/net/thunderx/base/nicvf_hw.h
index a7ae531..9db1d30 100644
--- a/drivers/net/thunderx/base/nicvf_hw.h
+++ b/drivers/net/thunderx/base/nicvf_hw.h
@@ -45,6 +45,11 @@

 #define NICVF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

+#define NICVF_GET_RX_STATS(reg) \
+   nicvf_reg_read(nic, NIC_VNIC_RX_STAT_0_13 | (reg << 3))
+#define NICVF_GET_TX_STATS(reg) \
+   nicvf_reg_read(nic, NIC_VNIC_TX_STAT_0_4 | (reg << 3))
+
 #define NICVF_PASS1(PCI_SUB_DEVICE_ID_THUNDERX_PASS1_NICVF)
 #define NICVF_PASS2(PCI_SUB_DEVICE_ID_THUNDERX_PASS2_NICVF)

@@ -82,6 +87,39 @@ enum nicvf_err_e {

 typedef nicvf_phys_addr_t (*rbdr_pool_get_handler)(void *opaque);

+struct nicvf_hw_rx_qstats {
+   uint64_t q_rx_bytes;
+   uint64_t q_rx_packets;
+};
+
+struct nicvf_hw_tx_qstats {
+   uint64_t q_tx_bytes;
+   uint64_t q_tx_packets;
+};
+
+struct nicvf_hw_stats {
+   uint64_t rx_bytes;
+   uint64_t rx_ucast_frames;
+   uint64_t rx_bcast_frames;
+   uint64_t rx_mcast_frames;
+   uint64_t rx_fcs_errors;
+   uint64_t rx_l2_errors;
+   uint64_t rx_drop_red;
+   uint64_t rx_drop_red_bytes;
+   uint64_t rx_drop_overrun;
+   uint64_t rx_drop_overrun_bytes;
+   uint64_t rx_drop_bcast;
+   uint64_t rx_drop_mcast;
+   uint64_t rx_drop_l3_bcast;
+   uint64_t rx_drop_l3_mcast;
+
+   uint64_t tx_bytes_ok;
+   uint64_t tx_ucast_frames_ok;
+   uint64_t tx_bcast_frames_ok;
+   uint64_t tx_mcast_frames_ok;
+   uint64_t tx_drops;
+};
+
 struct nicvf_rss_reta_info {
uint8_t hash_bits;
uint16_t rss_size;
@@ -193,4 +231,10 @@ uint64_t nicvf_rss_get_cfg(struct nicvf *nic);

 int nicvf_loopback_config(struct nicvf *nic, bool enable);

+void nicvf_hw_get_stats(struct nicvf *nic, struct nicvf_hw_stats *stats);
+void nicvf_hw_get_rx_qstats(struct nicvf *nic,
+   struct nicvf_hw_rx_qstats *qstats, uint16_t qidx);
+void nicvf_hw_get_tx_qstats(struct nicvf *nic,
+   struct nicvf_hw_tx_qstats *qstats, uint16_t qidx);
+
 #endif /* _THUNDERX_NICVF_HW_H */
-- 
2.5.5



[dpdk-dev] [PATCH v6 06/27] net/thunderx/base: add RSS and reta configuration HW APIs

2016-06-17 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/base/nicvf_hw.c | 129 +++
 drivers/net/thunderx/base/nicvf_hw.h |  20 ++
 2 files changed, 149 insertions(+)

diff --git a/drivers/net/thunderx/base/nicvf_hw.c 
b/drivers/net/thunderx/base/nicvf_hw.c
index ec24f9c..3366aa5 100644
--- a/drivers/net/thunderx/base/nicvf_hw.c
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -721,6 +721,135 @@ nicvf_vlan_hw_strip(struct nicvf *nic, bool enable)
nicvf_reg_write(nic, NIC_VNIC_RQ_GEN_CFG, val);
 }

+void
+nicvf_rss_set_key(struct nicvf *nic, uint8_t *key)
+{
+   int idx;
+   uint64_t addr, val;
+   uint64_t *keyptr = (uint64_t *)key;
+
+   addr = NIC_VNIC_RSS_KEY_0_4;
+   for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++) {
+   val = nicvf_cpu_to_be_64(*keyptr);
+   nicvf_reg_write(nic, addr, val);
+   addr += sizeof(uint64_t);
+   keyptr++;
+   }
+}
+
+void
+nicvf_rss_get_key(struct nicvf *nic, uint8_t *key)
+{
+   int idx;
+   uint64_t addr, val;
+   uint64_t *keyptr = (uint64_t *)key;
+
+   addr = NIC_VNIC_RSS_KEY_0_4;
+   for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++) {
+   val = nicvf_reg_read(nic, addr);
+   *keyptr = nicvf_be_to_cpu_64(val);
+   addr += sizeof(uint64_t);
+   keyptr++;
+   }
+}
+
+void
+nicvf_rss_set_cfg(struct nicvf *nic, uint64_t val)
+{
+   nicvf_reg_write(nic, NIC_VNIC_RSS_CFG, val);
+}
+
+uint64_t
+nicvf_rss_get_cfg(struct nicvf *nic)
+{
+   return nicvf_reg_read(nic, NIC_VNIC_RSS_CFG);
+}
+
+int
+nicvf_rss_reta_update(struct nicvf *nic, uint8_t *tbl, uint32_t max_count)
+{
+   uint32_t idx;
+   struct nicvf_rss_reta_info *rss = >rss_info;
+
+   /* result will be stored in nic->rss_info.rss_size */
+   if (nicvf_mbox_get_rss_size(nic))
+   return NICVF_ERR_RSS_GET_SZ;
+
+   assert(rss->rss_size > 0);
+   rss->hash_bits = (uint8_t)log2(rss->rss_size);
+   for (idx = 0; idx < rss->rss_size && idx < max_count; idx++)
+   rss->ind_tbl[idx] = tbl[idx];
+
+   if (nicvf_mbox_config_rss(nic))
+   return NICVF_ERR_RSS_TBL_UPDATE;
+
+   return NICVF_OK;
+}
+
+int
+nicvf_rss_reta_query(struct nicvf *nic, uint8_t *tbl, uint32_t max_count)
+{
+   uint32_t idx;
+   struct nicvf_rss_reta_info *rss = >rss_info;
+
+   /* result will be stored in nic->rss_info.rss_size */
+   if (nicvf_mbox_get_rss_size(nic))
+   return NICVF_ERR_RSS_GET_SZ;
+
+   assert(rss->rss_size > 0);
+   rss->hash_bits = (uint8_t)log2(rss->rss_size);
+   for (idx = 0; idx < rss->rss_size && idx < max_count; idx++)
+   tbl[idx] = rss->ind_tbl[idx];
+
+   return NICVF_OK;
+}
+
+int
+nicvf_rss_config(struct nicvf *nic, uint32_t  qcnt, uint64_t cfg)
+{
+   uint32_t idx;
+   uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE];
+   uint8_t default_key[RSS_HASH_KEY_BYTE_SIZE] = {
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD
+   };
+
+   if (nic->cpi_alg != CPI_ALG_NONE)
+   return -EINVAL;
+
+   if (cfg == 0)
+   return -EINVAL;
+
+   /* Update default RSS key and cfg */
+   nicvf_rss_set_key(nic, default_key);
+   nicvf_rss_set_cfg(nic, cfg);
+
+   /* Update default RSS RETA */
+   for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++)
+   default_reta[idx] = idx % qcnt;
+
+   return nicvf_rss_reta_update(nic, default_reta,
+   NIC_MAX_RSS_IDR_TBL_SIZE);
+}
+
+int
+nicvf_rss_term(struct nicvf *nic)
+{
+   uint32_t idx;
+   uint8_t disable_rss[NIC_MAX_RSS_IDR_TBL_SIZE];
+
+   nicvf_rss_set_cfg(nic, 0);
+   /* Redirect the output to 0th queue  */
+   for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++)
+   disable_rss[idx] = 0;
+
+   return nicvf_rss_reta_update(nic, disable_rss,
+   NIC_MAX_RSS_IDR_TBL_SIZE);
+}
+
 int
 nicvf_loopback_config(struct nicvf *nic, bool enable)
 {
diff --git a/drivers/net/thunderx/base/nicvf_hw.h 
b/drivers/net/thunderx/base/nicvf_hw.h
index dc9f4f1..a7ae531 100644
--- a/drivers/net/thunderx/base/nicvf_hw.h
+++ b/drivers/net/thunderx/base/nicvf_hw.h
@@ -76,10 +76,18 @@ enum nicvf_err_e {
NICVF_ERR_SQ_PF_CFG, /* -8175 */
NICVF_ERR_LOOPBACK_CFG,  /* -8174 */
NICVF_ERR_BASE_INIT, /* -8173 */
+   NICVF_ERR_RSS_TBL_UPDATE,/* -8172 */
+   NICVF_ERR_RSS_GET_SZ,/* -8171 */
 };

 typedef 

[dpdk-dev] [PATCH v6 05/27] net/thunderx/base: add hardware API

2016-06-17 Thread Jerin Jacob
add nicvf hardware specific APIs for initialization and configuration.

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   | 731 +
 drivers/net/thunderx/base/nicvf_hw.h   | 176 
 drivers/net/thunderx/base/nicvf_plat.h |   1 +
 3 files changed, 908 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_hw.c
 create mode 100644 drivers/net/thunderx/base/nicvf_hw.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..ec24f9c
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -0,0 +1,731 @@
+/*
+ *   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"},
+   {NIC_VNIC_RX_STAT_0_13 + 80, "NIC_VNIC_STAT_RX_DRP_BCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 88, "NIC_VNIC_STAT_RX_DRP_MCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 96, "NIC_VNIC_STAT_RX_DRP_L3BCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 104, "NIC_VNIC_STAT_RX_DRP_L3MCAST"},
+};
+
+static const struct nicvf_reg_info nicvf_qset_cq_reg_tbl[] = {
+   NICVF_REG_INFO(NIC_QSET_CQ_0_7_CFG),
+   NICVF_REG_INFO(NIC_QSET_CQ_0_7_CFG2),
+   NICVF_REG_INFO(NIC_QSET_CQ_0_7_THRESH),

[dpdk-dev] [PATCH v6 03/27] net/thunderx/base: implement DPDK based platform abstraction

2016-06-17 Thread Jerin Jacob
implement DPDK based platform abstraction for base code

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_plat.h | 129 +
 1 file changed, 129 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_plat.h

diff --git a/drivers/net/thunderx/base/nicvf_plat.h 
b/drivers/net/thunderx/base/nicvf_plat.h
new file mode 100644
index 000..33fef08
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_plat.h
@@ -0,0 +1,129 @@
+/*
+ *   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.
+ */
+
+#ifndef _THUNDERX_NICVF_H
+#define _THUNDERX_NICVF_H
+
+/* Platform/OS/arch specific abstractions */
+
+/* log */
+#include 
+#include "../nicvf_logs.h"
+
+#define nicvf_log_error(s, ...) PMD_DRV_LOG(ERR, s, ##__VA_ARGS__)
+
+#define nicvf_log_debug(s, ...) PMD_DRV_LOG(DEBUG, s, ##__VA_ARGS__)
+
+#define nicvf_mbox_log(s, ...) PMD_MBOX_LOG(DEBUG, s, ##__VA_ARGS__)
+
+#define nicvf_log(s, ...) fprintf(stderr, s, ##__VA_ARGS__)
+
+/* delay */
+#include 
+#define nicvf_delay_us(x) rte_delay_us(x)
+
+/* barrier */
+#include 
+#define nicvf_smp_wmb() rte_smp_wmb()
+#define nicvf_smp_rmb() rte_smp_rmb()
+
+/* utils */
+#include 
+#define nicvf_min(x, y) RTE_MIN(x, y)
+
+/* byte order */
+#include 
+#define nicvf_cpu_to_be_64(x) rte_cpu_to_be_64(x)
+#define nicvf_be_to_cpu_64(x) rte_be_to_cpu_64(x)
+
+/* Constants */
+#include 
+#define NICVF_MAC_ADDR_SIZE ETHER_ADDR_LEN
+
+/* ARM64 specific functions */
+#if defined(RTE_ARCH_ARM64)
+#define nicvf_prefetch_store_keep(_ptr) ({\
+   asm volatile("prfm pstl1keep, %a0\n" : : "p" (_ptr)); })
+
+static inline void __attribute__((always_inline))
+nicvf_addr_write(uintptr_t addr, uint64_t val)
+{
+   asm volatile(
+   "str %x[val], [%x[addr]]"
+   :
+   : [val] "r" (val), [addr] "r" (addr));
+}
+
+static inline uint64_t __attribute__((always_inline))
+nicvf_addr_read(uintptr_t addr)
+{
+   uint64_t val;
+
+   asm volatile(
+   "ldr %x[val], [%x[addr]]"
+   : [val] "=r" (val)
+   : [addr] "r" (addr));
+   return val;
+}
+
+#define NICVF_LOAD_PAIR(reg1, reg2, addr) ({   \
+   asm volatile(   \
+   "ldp %x[x1], %x[x0], [%x[p1]]"  \
+   : [x1]"=r"(reg1), [x0]"=r"(reg2)\
+   : [p1]"r"(addr) \
+   ); })
+
+#else /* non optimized functions for building on non arm64 arch */
+
+#define nicvf_prefetch_store_keep(_ptr) do {} while (0)
+
+static inline void __attribute__((always_inline))
+nicvf_addr_write(uintptr_t addr, uint64_t val)
+{
+   *(volatile uint64_t *)addr = val;
+}
+
+static inline uint64_t __attribute__((always_inline))
+nicvf_addr_read(uintptr_t addr)
+{
+   return  *(volatile uint64_t *)addr;
+}
+
+#define NICVF_LOAD_PAIR(reg1, reg2, addr)  \
+do {   \
+   reg1 = nicvf_addr_read((uintptr_t)addr);\
+   reg2 = nicvf_addr_read((uintptr_t)addr + 8);\
+} while (0)
+
+#endif
+
+#endif /* _THUNDERX_NICVF_H */
-- 
2.5.5



[dpdk-dev] [PATCH v6 02/27] net/thunderx/base: add HW register definitions

2016-06-17 Thread Jerin Jacob
add HW register definitions of ThunderX inbuilt NIC

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_defs.h | 668 ++
 1 file changed, 668 insertions(+)

diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h 
b/drivers/net/thunderx/base/nicvf_hw_defs.h
index 8a58f03..88ecd17 100644
--- a/drivers/net/thunderx/base/nicvf_hw_defs.h
+++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
@@ -548,4 +548,672 @@ enum nic_stat_vnic_tx_e {
TX_DROP,
 };

+/* vNIC HW Register structures */
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t cqe_type:4;
+   uint64_t stdn_fault:1;
+   uint64_t rsvd0:1;
+   uint64_t rq_qs:7;
+   uint64_t rq_idx:3;
+   uint64_t rsvd1:12;
+   uint64_t rss_alg:4;
+   uint64_t rsvd2:4;
+   uint64_t rb_cnt:4;
+   uint64_t vlan_found:1;
+   uint64_t vlan_stripped:1;
+   uint64_t vlan2_found:1;
+   uint64_t vlan2_stripped:1;
+   uint64_t l4_type:4;
+   uint64_t l3_type:4;
+   uint64_t l2_present:1;
+   uint64_t err_level:3;
+   uint64_t err_opcode:8;
+#else
+   uint64_t err_opcode:8;
+   uint64_t err_level:3;
+   uint64_t l2_present:1;
+   uint64_t l3_type:4;
+   uint64_t l4_type:4;
+   uint64_t vlan2_stripped:1;
+   uint64_t vlan2_found:1;
+   uint64_t vlan_stripped:1;
+   uint64_t vlan_found:1;
+   uint64_t rb_cnt:4;
+   uint64_t rsvd2:4;
+   uint64_t rss_alg:4;
+   uint64_t rsvd1:12;
+   uint64_t rq_idx:3;
+   uint64_t rq_qs:7;
+   uint64_t rsvd0:1;
+   uint64_t stdn_fault:1;
+   uint64_t cqe_type:4;
+#endif
+   };
+} cqe_rx_word0_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t pkt_len:16;
+   uint64_t l2_ptr:8;
+   uint64_t l3_ptr:8;
+   uint64_t l4_ptr:8;
+   uint64_t cq_pkt_len:8;
+   uint64_t align_pad:3;
+   uint64_t rsvd3:1;
+   uint64_t chan:12;
+#else
+   uint64_t chan:12;
+   uint64_t rsvd3:1;
+   uint64_t align_pad:3;
+   uint64_t cq_pkt_len:8;
+   uint64_t l4_ptr:8;
+   uint64_t l3_ptr:8;
+   uint64_t l2_ptr:8;
+   uint64_t pkt_len:16;
+#endif
+   };
+} cqe_rx_word1_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t rss_tag:32;
+   uint64_t vlan_tci:16;
+   uint64_t vlan_ptr:8;
+   uint64_t vlan2_ptr:8;
+#else
+   uint64_t vlan2_ptr:8;
+   uint64_t vlan_ptr:8;
+   uint64_t vlan_tci:16;
+   uint64_t rss_tag:32;
+#endif
+   };
+} cqe_rx_word2_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint16_t rb3_sz;
+   uint16_t rb2_sz;
+   uint16_t rb1_sz;
+   uint16_t rb0_sz;
+#else
+   uint16_t rb0_sz;
+   uint16_t rb1_sz;
+   uint16_t rb2_sz;
+   uint16_t rb3_sz;
+#endif
+   };
+} cqe_rx_word3_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint16_t rb7_sz;
+   uint16_t rb6_sz;
+   uint16_t rb5_sz;
+   uint16_t rb4_sz;
+#else
+   uint16_t rb4_sz;
+   uint16_t rb5_sz;
+   uint16_t rb6_sz;
+   uint16_t rb7_sz;
+#endif
+   };
+} cqe_rx_word4_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint16_t rb11_sz;
+   uint16_t rb10_sz;
+   uint16_t rb9_sz;
+   uint16_t rb8_sz;
+#else
+   uint16_t rb8_sz;
+   uint16_t rb9_sz;
+   uint16_t rb10_sz;
+   uint16_t rb11_sz;
+#endif
+   };
+} cqe_rx_word5_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t vlan_found:1;
+   uint64_t vlan_stripped:1;
+   uint64_t vlan2_found:1;
+   uint64_t vlan2_stripped:1;
+   uint64_t rsvd2:3;
+   uint64_t inner_l2:1;
+   uint64_t inner_l4type:4;
+   uint64_t 

[dpdk-dev] [PATCH v6 01/27] net/thunderx/base: add HW constants

2016-06-17 Thread Jerin Jacob
add HW constants of ThunderX inbuilt NIC

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_defs.h | 551 ++
 1 file changed, 551 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_hw_defs.h

diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h 
b/drivers/net/thunderx/base/nicvf_hw_defs.h
new file mode 100644
index 000..8a58f03
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
@@ -0,0 +1,551 @@
+/*
+ *   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.
+ */
+
+#ifndef _THUNDERX_NICVF_HW_DEFS_H
+#define _THUNDERX_NICVF_HW_DEFS_H
+
+#include 
+#include 
+
+/* Virtual function register offsets */
+
+#define NIC_VF_CFG  (0x20)
+#define NIC_VF_PF_MAILBOX_0_1   (0x000130)
+#define NIC_VF_INT  (0x000200)
+#define NIC_VF_INT_W1S  (0x000220)
+#define NIC_VF_ENA_W1C  (0x000240)
+#define NIC_VF_ENA_W1S  (0x000260)
+
+#define NIC_VNIC_RSS_CFG(0x0020E0)
+#define NIC_VNIC_RSS_KEY_0_4(0x002200)
+#define NIC_VNIC_TX_STAT_0_4(0x004000)
+#define NIC_VNIC_RX_STAT_0_13   (0x004100)
+#define NIC_VNIC_RQ_GEN_CFG (0x010010)
+
+#define NIC_QSET_CQ_0_7_CFG (0x010400)
+#define NIC_QSET_CQ_0_7_CFG2(0x010408)
+#define NIC_QSET_CQ_0_7_THRESH  (0x010410)
+#define NIC_QSET_CQ_0_7_BASE(0x010420)
+#define NIC_QSET_CQ_0_7_HEAD(0x010428)
+#define NIC_QSET_CQ_0_7_TAIL(0x010430)
+#define NIC_QSET_CQ_0_7_DOOR(0x010438)
+#define NIC_QSET_CQ_0_7_STATUS  (0x010440)
+#define NIC_QSET_CQ_0_7_STATUS2 (0x010448)
+#define NIC_QSET_CQ_0_7_DEBUG   (0x010450)
+
+#define NIC_QSET_RQ_0_7_CFG (0x010600)
+#define NIC_QSET_RQ_0_7_STATUS0 (0x010700)
+#define NIC_QSET_RQ_0_7_STATUS1 (0x010708)
+
+#define NIC_QSET_SQ_0_7_CFG (0x010800)
+#define NIC_QSET_SQ_0_7_THRESH  (0x010810)
+#define NIC_QSET_SQ_0_7_BASE(0x010820)
+#define NIC_QSET_SQ_0_7_HEAD(0x010828)
+#define NIC_QSET_SQ_0_7_TAIL(0x010830)
+#define NIC_QSET_SQ_0_7_DOOR(0x010838)
+#define NIC_QSET_SQ_0_7_STATUS  (0x010840)
+#define NIC_QSET_SQ_0_7_DEBUG   (0x010848)
+#define NIC_QSET_SQ_0_7_STATUS0 (0x010900)
+#define NIC_QSET_SQ_0_7_STATUS1 (0x010908)
+
+#define NIC_QSET_RBDR_0_1_CFG   (0x010C00)
+#define NIC_QSET_RBDR_0_1_THRESH(0x010C10)
+#define NIC_QSET_RBDR_0_1_BASE  (0x010C20)
+#define NIC_QSET_RBDR_0_1_HEAD  (0x010C28)
+#define NIC_QSET_RBDR_0_1_TAIL  (0x010C30)
+#define NIC_QSET_RBDR_0_1_DOOR  (0x010C38)
+#define NIC_QSET_RBDR_0_1_STATUS0   (0x010C40)
+#define NIC_QSET_RBDR_0_1_STATUS1   (0x010C48)
+#define NIC_QSET_RBDR_0_1_PRFCH_STATUS  (0x010C50)
+
+/* vNIC HW Constants */
+
+#define NIC_Q_NUM_SHIFT 18
+
+#define MAX_QUEUE_SET   128
+#define MAX_RCV_QUEUES_PER_QS   8
+#define MAX_RCV_BUF_DESC_RINGS_PER_QS   2
+#define MAX_SND_QUEUES_PER_QS   8
+#define MAX_CMP_QUEUES_PER_QS   8
+
+#define 

[dpdk-dev] [PATCH v6 00/27] DPDK PMD for ThunderX NIC device

2016-06-17 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
ad00c7ec23e3b7723217bc29e03eb40409aaf617(in dpdk-next-net/rel_16_07)
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

addressed 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: 

V4->V5
-- splitting up drivers/net/thunderx/nicvf/base files to following
patches as suggested by Bruce

net/thunderx/base: add HW constants for ThunderX inbuilt NIC
net/thunderx/base: add register definition for ThunderX inbuilt NIC
net/thunderx/base: implement DPDK based platform abstraction for base code
net/thunderx/base: add mbox API for ThunderX PF/VF driver communication
net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC
net/thunderx/base: add RSS and reta configuration HW APIs
net/thunderx/base: add statistics get HW APIs

-- Corrected wrong git commit log messages flagged by check-git-log.sh

V5->V6
-- Rebased to dpdk-next-net/rel_16_07(ad00c7ec23e3b7723217bc29e03eb40409aaf617)
-- Splitted following patches in v5 to two logical patches
[dpdk-dev,v5,16/25] net/thunderx: add MTU set and promiscuous enable support
[dpdk-dev,v5,20/25] net/thunderx: implement supported ptype get and Rx queue 
count
-- Fixed check-git-logs.sh for "commit messages being too long"

Jerin Jacob (27):
  net/thunderx/base: add HW constants
  net/thunderx/base: add HW register definitions
  net/thunderx/base: implement DPDK based platform abstraction
  net/thunderx/base: add mbox APIs for PF/VF communication
  net/thunderx/base: add hardware API
  net/thunderx/base: add RSS and reta configuration HW APIs
  net/thunderx/base: add statistics get HW APIs
  net/thunderx: add pmd skeleton
  net/thunderx: add link status and link update support
  net/thunderx: add registers dump support
  net/thunderx: add ethdev configure support
  net/thunderx: add get device info support
  net/thunderx: add Rx queue setup and release support
  net/thunderx: add Tx queue setup and release support
  net/thunderx: add RSS and reta query and update support
  net/thunderx: add MTU set support
  net/thunderx: add 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 supported packet type get
  net/thunderx: add 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 

[dpdk-dev] [PATCH v2] eal: fix thread naming on FreeBSD

2016-06-17 Thread Thomas Monjalon
2016-06-17 18:04, David Marchand:
> On Fri, Jun 17, 2016 at 6:02 PM, Thomas Monjalon
>  wrote:
> > rte_thread_setname was a macro defined only for Linux.
> > The function rte_thread_setname() can now be used on FreeBSD
> > as well on Linux.
> > It is required to build librte_pdump.
> >
> > The macro was 0 for old glibc. The function is now returning -1.
> > The related logs are decreased from error to debug level because
> > it is not an important failure, just a debug inconvenience.
> >
> > Fixes: 278f945402c5 ("pdump: add new library for packet capture")
> >
> > Signed-off-by: Thomas Monjalon 
> 
> Acked-by: David Marchand 

Applied


[dpdk-dev] [PATCH v2] eal: fix thread naming on FreeBSD

2016-06-17 Thread David Marchand
On Fri, Jun 17, 2016 at 6:02 PM, Thomas Monjalon
 wrote:
> rte_thread_setname was a macro defined only for Linux.
> The function rte_thread_setname() can now be used on FreeBSD
> as well on Linux.
> It is required to build librte_pdump.
>
> The macro was 0 for old glibc. The function is now returning -1.
> The related logs are decreased from error to debug level because
> it is not an important failure, just a debug inconvenience.
>
> Fixes: 278f945402c5 ("pdump: add new library for packet capture")
>
> Signed-off-by: Thomas Monjalon 

Acked-by: David Marchand 


-- 
David Marchand


[dpdk-dev] [PATCH] eal: fix thread naming on FreeBSD

2016-06-17 Thread David Marchand
On Fri, Jun 17, 2016 at 5:25 PM, Thomas Monjalon
 wrote:
> rte_thread_setname was a macro defined only for Linux.
> The function rte_thread_setname() can now be used on FreeBSD
> as well on Linux.
> It is required to build librte_pdump.
>
> The macro was 0 for old glibc. The function is now returning -1.
> The related logs are decreased from error to debug level because
> it is not an important failure, just a debug inconvenience.
>
> Fixes: 278f945402c5 ("pdump: add new library for packet capture")
>
> Signed-off-by: Thomas Monjalon 

[snip]

> diff --git a/lib/librte_eal/common/include/rte_lcore.h 
> b/lib/librte_eal/common/include/rte_lcore.h
> index ac15130..1dcfba7 100644
> --- a/lib/librte_eal/common/include/rte_lcore.h
> +++ b/lib/librte_eal/common/include/rte_lcore.h
> @@ -250,23 +250,16 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
>  /**
>   * Set thread names.
>   *
> - * Macro to wrap `pthread_setname_np()` with a glibc version check.
> - * Only glibc >= 2.12 supports this feature.
> + * @note Only glibc >= 2.12 supports this feature.

This comment is a bit weird since, this only applies to Linux and not
BSD, right ?

The rest looks good to me.


-- 
David Marchand


[dpdk-dev] [PATCH] keepalive: fix exported symbols

2016-06-17 Thread Thomas Monjalon
2016-06-17 17:02, Thomas Monjalon:
> The function rte_keepalive_register_alive_callback do not exist.
> The function rte_keepalive_register_relay_callback was missing for BSD.
> 
> Fixes: 90c622f35679 ("keepalive: add liveness callback")
> 
> Signed-off-by: Thomas Monjalon 

Applied


[dpdk-dev] [PATCH] mlx: fix compilation with older Glibc

2016-06-17 Thread Ferruh Yigit
On 6/14/2016 10:22 AM, Adrien Mazarguil wrote:
> A missing define in the previous patch causes additional compilation
> issues.
> 
> Fixes: 3025206f5060 ("mlx: fix compilation with recent Glibc")
> 
> Signed-off-by: Adrien Mazarguil 

"older Glibc" or "recent Glibc" can be very hard to trace from git
history later.

Does it make sense to add glibc version info for the failing ones or
fixed one?

Thanks,
ferruh


[dpdk-dev] [PATCH] bnx2x: Correctly determine MSIX vector count

2016-06-17 Thread Ferruh Yigit
On 6/10/2016 11:18 PM, Chas Williams wrote:
> From: "Charles (Chas) Williams" 
> 
> If MSIX is available, the vector count given by the table size is one
> less than the actual count.  This count also limits the receive and
> transmit queue resources the VF can support.
> 
> Fixes: 540a211084a7 ("bnx2x: driver core")
> 
> Signed-off-by: Chas Williams 
> ---

Since this patch not acked yet, adding all maintainers to cc



[dpdk-dev] [PATCH] eal: fix thread naming on FreeBSD

2016-06-17 Thread Thomas Monjalon
rte_thread_setname was a macro defined only for Linux.
The function rte_thread_setname() can now be used on FreeBSD
as well on Linux.
It is required to build librte_pdump.

The macro was 0 for old glibc. The function is now returning -1.
The related logs are decreased from error to debug level because
it is not an important failure, just a debug inconvenience.

Fixes: 278f945402c5 ("pdump: add new library for packet capture")

Signed-off-by: Thomas Monjalon 
---
 examples/tep_termination/main.c|  2 +-
 examples/vhost/main.c  |  2 +-
 examples/vhost_xen/main.c  |  2 +-
 lib/librte_eal/bsdapp/eal/eal.c|  2 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c |  7 +++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map  |  1 +
 lib/librte_eal/common/include/rte_lcore.h  | 23 --
 lib/librte_eal/linuxapp/eal/eal.c  |  2 +-
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   |  2 +-
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c |  2 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c   | 11 +++
 lib/librte_eal/linuxapp/eal/eal_timer.c|  4 ++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|  1 +
 13 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index b8297dd..aa67a6b 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -1246,7 +1246,7 @@ main(int argc, char *argv[])
snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
ret = rte_thread_setname(tid, thread_name);
if (ret != 0)
-   RTE_LOG(ERR, VHOST_CONFIG, "Cannot set print-stats 
name\n");
+   RTE_LOG(DEBUG, VHOST_CONFIG, "Cannot set print-stats 
name\n");
}

/* Launch all data cores. */
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 665886e..f849571 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1474,7 +1474,7 @@ main(int argc, char *argv[])
snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
ret = rte_thread_setname(tid, thread_name);
if (ret != 0)
-   RTE_LOG(ERR, VHOST_CONFIG,
+   RTE_LOG(DEBUG, VHOST_CONFIG,
"Cannot set print-stats name\n");
}

diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
index 2b04c95..2e40357 100644
--- a/examples/vhost_xen/main.c
+++ b/examples/vhost_xen/main.c
@@ -1494,7 +1494,7 @@ main(int argc, char *argv[])
snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, 
"print-xen-stats");
ret = rte_thread_setname(tid, thread_name);
if (ret != 0)
-   RTE_LOG(ERR, VHOST_CONFIG,
+   RTE_LOG(DEBUG, VHOST_CONFIG,
"Cannot set print-stats name\n");
}

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 06bfd4e..a0c8f8c 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -605,7 +605,7 @@ rte_eal_init(int argc, char **argv)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
"lcore-slave-%d", i);
-   pthread_set_name_np(lcore_config[i].thread_id, thread_name);
+   rte_thread_setname(lcore_config[i].thread_id, thread_name);
}

/*
diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index 9a03437..1b8cd8a 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -199,3 +199,10 @@ int rte_sys_gettid(void)
thr_self();
return (int)lwpid;
 }
+
+int rte_thread_setname(pthread_t id, const char *name)
+{
+   /* this BSD function returns no error */
+   pthread_set_name_np(id, name);
+   return 0;
+}
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 97d091b..3b4dd3b 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -157,5 +157,6 @@ DPDK_16.07 {

pci_get_sysfs_path;
rte_keepalive_register_relay_callback;
+   rte_thread_setname;

 } DPDK_16.04;
diff --git a/lib/librte_eal/common/include/rte_lcore.h 
b/lib/librte_eal/common/include/rte_lcore.h
index ac15130..1dcfba7 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -250,23 +250,16 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
 /**
  * Set thread names.
  *
- * Macro to wrap `pthread_setname_np()` with a glibc version check.
- * Only glibc >= 2.12 supports this feature.
+ * 

[dpdk-dev] [PATCH] keepalive: fix exported symbols

2016-06-17 Thread Remy Horton
rte_keepalive_mark_sleep is also missing from both.

On 17/06/2016 16:02, Thomas Monjalon wrote:
> The function rte_keepalive_register_alive_callback do not exist.
> The function rte_keepalive_register_relay_callback was missing for BSD.
>
> Fixes: 90c622f35679 ("keepalive: add liveness callback")
>
> Signed-off-by: Thomas Monjalon 

Acked-by: Remy Horton 


[dpdk-dev] [PATCH 00/24] Refactor mlx5 to improve performance

2016-06-17 Thread Ferruh Yigit
On 6/8/2016 10:47 AM, Nelio Laranjeiro wrote:
> Enhance mlx5 with a data path that bypasses Verbs.
> 
> The first half of this patchset removes support for functionality completely
> rewritten in the second half (scatter/gather, inline send), while the data
> path is refactored without Verbs.
> 
> The PMD remains usable during the transition.
> 
> This patchset must be applied after "Miscellaneous fixes for mlx4 and mlx5".
> 
> Adrien Mazarguil (8):
>   mlx5: replace countdown with threshold for TX completions
>   mlx5: add debugging information about TX queues capabilities
>   mlx5: check remaining space while processing TX burst
>   mlx5: resurrect TX gather support
>   mlx5: work around spurious compilation errors
>   mlx5: remove redundant RX queue initialization code
>   mlx5: make RX queue reinitialization safer
>   mlx5: resurrect RX scatter support
> 
> Nelio Laranjeiro (15):
>   mlx5: split memory registration function for better performance
>   mlx5: remove TX gather support
>   mlx5: remove RX scatter support
>   mlx5: remove configuration variable for maximum number of segments
>   mlx5: remove inline TX support
>   mlx5: split TX queue structure
>   mlx5: split RX queue structure
>   mlx5: update prerequisites for upcoming enhancements
>   mlx5: add definitions for data path without Verbs
>   mlx5: add support for configuration through kvargs
>   mlx5: add TX/RX burst function selection wrapper
>   mlx5: refactor RX data path
>   mlx5: refactor TX data path
>   mlx5: handle RX CQE compression
>   mlx5: add support for multi-packet send
> 
> Yaacov Hazan (1):
>   mlx5: add support for inline send
> 

I run basic checks to the patchset:

There are various checkpatch warnings, all are warning or check level

Patch 8 and 13 failed to apply with via git, -looks line line numbers
shifted a little, this is not a problem since eventually it applies but
just for your information.

check-git-log is giving following errors, it is mainly case issue in Rx/Tx:
Wrong headline lowercase:
mlx5: resurrect RX scatter support
mlx5: make RX queue reinitialization safer
mlx5: remove redundant RX queue initialization code
mlx5: resurrect TX gather support
mlx5: check remaining space while processing TX burst
mlx5: add debugging information about TX queues capabilities
mlx5: replace countdown with threshold for TX completions
mlx5: handle RX CQE compression
mlx5: refactor RX data path
mlx5: add TX/RX burst function selection wrapper
mlx5: split RX queue structure
mlx5: split TX queue structure
mlx5: remove inline TX support
mlx5: remove RX scatter support
mlx5: remove TX gather support
Headline too long:
mlx5: remove configuration variable for maximum number of segments
mlx5: split memory registration function for better performance


It compiles fine.

Regards,
ferruh


[dpdk-dev] [PATCH] keepalive: fix exported symbols

2016-06-17 Thread Thomas Monjalon
The function rte_keepalive_register_alive_callback do not exist.
The function rte_keepalive_register_relay_callback was missing for BSD.

Fixes: 90c622f35679 ("keepalive: add liveness callback")

Signed-off-by: Thomas Monjalon 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   | 2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 0fb1cf2..97d091b 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -156,6 +156,6 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
-   rte_keepalive_register_alive_callback;
+   rte_keepalive_register_relay_callback;

 } DPDK_16.04;
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index cacf9e1..4874c92 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -159,7 +159,6 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
-   rte_keepalive_register_alive_callback;
rte_keepalive_register_relay_callback;

 } DPDK_16.04;
-- 
2.7.0



[dpdk-dev] [PATCH v14 3/3] mbuf: make default mempool ops configurable at build

2016-06-17 Thread Jan Viktorin
On Fri, 17 Jun 2016 14:53:38 +0100
David Hunt  wrote:

> By default, the mempool ops used for mbuf allocations is a multi
> producer and multi consumer ring. We could imagine a target (maybe some
> network processors?) that provides an hardware-assisted pool
> mechanism. In this case, the default configuration for this architecture
> would contain a different value for RTE_MBUF_DEFAULT_MEMPOOL_OPS.
> 
> Signed-off-by: Olivier Matz 
> Signed-off-by: David Hunt 
> Acked-by: Shreyansh Jain 
> Acked-by: Olivier Matz 
> ---
Reviewed-by: Jan Viktorin 


[dpdk-dev] [PATCH v14 2/3] app/test: test mempool handler

2016-06-17 Thread Jan Viktorin
On Fri, 17 Jun 2016 14:53:37 +0100
David Hunt  wrote:

> Create a minimal custom mempool handler and check that it
> passes basic mempool autotests.
> 
> Signed-off-by: Olivier Matz 
> Signed-off-by: David Hunt 
> Acked-by: Shreyansh Jain 
> Acked-by: Olivier Matz 
> ---
Reviewed-by: Jan Viktorin 


[dpdk-dev] [PATCH v14 1/3] mempool: support mempool handler operations

2016-06-17 Thread Jan Viktorin
Hi David,

still few nits... Do you like the upstreaming process? :) I hope finish this
patchset soon. The major issues seem to be OK.

[...]

> +
> +/**
> + * @internal Get the mempool ops struct from its index.
> + *
> + * @param ops_index
> + *   The index of the ops struct in the ops struct table. It must be a valid
> + *   index: (0 <= idx < num_ops).
> + * @return
> + *   The pointer to the ops struct in the table.
> + */
> +static inline struct rte_mempool_ops *
> +rte_mempool_ops_get(int ops_index)

What about to rename the ops_get to get_ops to not confuse
with the ops wrappers? The thread on this topic has not
been finished. I think, we can live with this name, it's
just a bit weird...

Olivier? Thomas?

> +{
> + RTE_VERIFY(ops_index < RTE_MEMPOOL_MAX_OPS_IDX);

According to the doc comment:

RTE_VERIFY(ops_index >= 0);

> +
> + return _mempool_ops_table.ops[ops_index];
> +}

[...]

> +
> +/**
> + * @internal Wrapper for mempool_ops get callback.

This comment is obsolete "get callback" vs. dequeue_bulk.

> + *
> + * @param mp
> + *   Pointer to the memory pool.
> + * @param obj_table
> + *   Pointer to a table of void * pointers (objects).
> + * @param n
> + *   Number of objects to get.
> + * @return
> + *   - 0: Success; got n objects.
> + *   - <0: Error; code of get function.

"get function" seems to be obsolete, too...

> + */
> +static inline int
> +rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
> + void **obj_table, unsigned n)
> +{
> + struct rte_mempool_ops *ops;
> +
> + ops = rte_mempool_ops_get(mp->ops_index);
> + return ops->dequeue(mp, obj_table, n);
> +}
> +
> +/**
> + * @internal wrapper for mempool_ops put callback.

similar: "put callback"

> + *
> + * @param mp
> + *   Pointer to the memory pool.
> + * @param obj_table
> + *   Pointer to a table of void * pointers (objects).
> + * @param n
> + *   Number of objects to put.
> + * @return
> + *   - 0: Success; n objects supplied.
> + *   - <0: Error; code of put function.

similar: "put function"

> + */
> +static inline int
> +rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
> + unsigned n)
> +{
> + struct rte_mempool_ops *ops;
> +
> + ops = rte_mempool_ops_get(mp->ops_index);
> + return ops->enqueue(mp, obj_table, n);
> +}
> +

[...]

> +
> +/* add a new ops struct in rte_mempool_ops_table, return its index. */
> +int
> +rte_mempool_ops_register(const struct rte_mempool_ops *h)
> +{
> + struct rte_mempool_ops *ops;
> + int16_t ops_index;
> +
> + rte_spinlock_lock(_mempool_ops_table.sl);
> +
> + if (rte_mempool_ops_table.num_ops >=
> + RTE_MEMPOOL_MAX_OPS_IDX) {
> + rte_spinlock_unlock(_mempool_ops_table.sl);
> + RTE_LOG(ERR, MEMPOOL,
> + "Maximum number of mempool ops structs exceeded\n");
> + return -ENOSPC;
> + }
> +
> + if (h->alloc == NULL || h->enqueue == NULL ||
> + h->dequeue == NULL || h->get_count == NULL) {
> + rte_spinlock_unlock(_mempool_ops_table.sl);
> + RTE_LOG(ERR, MEMPOOL,
> + "Missing callback while registering mempool ops\n");
> + return -EINVAL;
> + }
> +
> + if (strlen(h->name) >= sizeof(ops->name) - 1) {
> + RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n",
> + __func__, h->name);

The unlock is missing here, isn't?

> + rte_errno = EEXIST;
> + return -EEXIST;
> + }
> +
> + ops_index = rte_mempool_ops_table.num_ops++;
> + ops = _mempool_ops_table.ops[ops_index];
> + snprintf(ops->name, sizeof(ops->name), "%s", h->name);
> + ops->alloc = h->alloc;
> + ops->enqueue = h->enqueue;
> + ops->dequeue = h->dequeue;
> + ops->get_count = h->get_count;
> +
> + rte_spinlock_unlock(_mempool_ops_table.sl);
> +
> + return ops_index;
> +}
> +
> +/* wrapper to allocate an external mempool's private (pool) data. */
> +int
> +rte_mempool_ops_alloc(struct rte_mempool *mp)
> +{
> + struct rte_mempool_ops *ops;
> +
> + ops = rte_mempool_ops_get(mp->ops_index);
> + return ops->alloc(mp);
> +}
> +
> +/* wrapper to free an external pool ops. */
> +void
> +rte_mempool_ops_free(struct rte_mempool *mp)
> +{
> + struct rte_mempool_ops *ops;
> +
> + ops = rte_mempool_ops_get(mp->ops_index);

I assume there would never be an rte_mempool_ops_unregister. Otherwise this 
function can
return NULL and may lead to a NULL pointer exception.

> + if (ops->free == NULL)
> + return;
> + return ops->free(mp);

This return statement here is redundant (void).

> +}
> +
> +/* wrapper to get available objects in an external mempool. */
> +unsigned int
> +rte_mempool_ops_get_count(const struct rte_mempool *mp)

[...]

Regards
Jan


[dpdk-dev] [PATCH] app/test: call objdump in platform-independent way

2016-06-17 Thread Thomas Monjalon
2016-06-17 15:19, Thomas Monjalon:
> 2016-06-17 14:52, Jan Viktorin:
> > Using of the /dev/stdin generates a warning when compiling on FreeBSD:
> > 
> >  objcopy: Warning: '/dev/stdin' is not an ordinary file
> >  app/test/Makefile:78: recipe for target 'test_resource_c.res.o' failed
> >  # ls -l /dev/stdin
> >  lrwxr-xr-x  1 root  wheel  4 Jun 17 12:24 /dev/stdin -> fd/0
> > 
> > Replace /dev/stdin by a temporary file.
> > 
> > Signed-off-by: Jan Viktorin 
> > Reported-by: Thomas Monjalon 
> 
> Tested-by: Thomas Monjalon 
> 
> Looks good, thanks

Applied with title fixed: objdump -> objcopy ;)


[dpdk-dev] [PATCH] mk: fix build clean

2016-06-17 Thread Thomas Monjalon
2016-06-17 15:22, Thomas Monjalon:
> The variables AESNI_MULTI_BUFFER_LIB_PATH and LIBSSO_PATH
> are not required for "make clean".
> It is the same fix as in the commit e277b2397.

Fixes: eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto operations")
Fixes: 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")

> Signed-off-by: Thomas Monjalon 

Applied


[dpdk-dev] [PATCH v3] bond: inherit maximum rx packet length

2016-06-17 Thread Declan Doherty
On 07/05/16 04:45, Eric Kinzie wrote:
>   Instead of a hard-coded maximum receive length, allow the bond interface
>   to inherit this limit from the slave interfaces.  This allows
>   an application that uses jumbo frames to pass realistic values to
>   rte_eth_dev_configure without causing an error.
>
>   Before the bond interface is configured, allow slaves with any
>   max_rx_pktlen to be added and remember the lowest of these values as
>   a candidate value.  During dev_configure, set the bond device's
>   max_rx_pktlen to the candidate value.  After this point only slaves
>   with a max_rx_pktlen greater or equal to that of the bonding device
>   can be added.
>
>   If all slaves are removed, the bond device's pktlen is cleared.
>
> Signed-off-by: Eric Kinzie 
> ---
>

>

Acked-by: Declan Dohetry 


[dpdk-dev] [PATCH] mk: fix build clean

2016-06-17 Thread Thomas Monjalon
The variables AESNI_MULTI_BUFFER_LIB_PATH and LIBSSO_PATH
are not required for "make clean".
It is the same fix as in the commit e277b2397.

Signed-off-by: Thomas Monjalon 
---
 drivers/crypto/aesni_gcm/Makefile | 2 ++
 drivers/crypto/snow3g/Makefile| 2 ++
 2 files changed, 4 insertions(+)

diff --git a/drivers/crypto/aesni_gcm/Makefile 
b/drivers/crypto/aesni_gcm/Makefile
index aa2621b..3c70ee8 100644
--- a/drivers/crypto/aesni_gcm/Makefile
+++ b/drivers/crypto/aesni_gcm/Makefile
@@ -30,9 +30,11 @@

 include $(RTE_SDK)/mk/rte.vars.mk

+ifneq ($(MAKECMDGOALS),clean)
 ifeq ($(AESNI_MULTI_BUFFER_LIB_PATH),)
 $(error "Please define AESNI_MULTI_BUFFER_LIB_PATH environment variable")
 endif
+endif

 # library name
 LIB = librte_pmd_aesni_gcm.a
diff --git a/drivers/crypto/snow3g/Makefile b/drivers/crypto/snow3g/Makefile
index ee58270..17b15ef 100644
--- a/drivers/crypto/snow3g/Makefile
+++ b/drivers/crypto/snow3g/Makefile
@@ -30,9 +30,11 @@

 include $(RTE_SDK)/mk/rte.vars.mk

+ifneq ($(MAKECMDGOALS),clean)
 ifeq ($(LIBSSO_PATH),)
 $(error "Please define LIBSSO_PATH environment variable")
 endif
+endif

 # library name
 LIB = librte_pmd_snow3g.a
-- 
2.7.0



[dpdk-dev] [PATCH] app/test: call objdump in platform-independent way

2016-06-17 Thread Thomas Monjalon
2016-06-17 14:52, Jan Viktorin:
> Using of the /dev/stdin generates a warning when compiling on FreeBSD:
> 
>  objcopy: Warning: '/dev/stdin' is not an ordinary file
>  app/test/Makefile:78: recipe for target 'test_resource_c.res.o' failed
>  # ls -l /dev/stdin
>  lrwxr-xr-x  1 root  wheel  4 Jun 17 12:24 /dev/stdin -> fd/0
> 
> Replace /dev/stdin by a temporary file.
> 
> Signed-off-by: Jan Viktorin 
> Reported-by: Thomas Monjalon 

Tested-by: Thomas Monjalon 

Looks good, thanks


[dpdk-dev] [PATCH v2 1/3] mempool: add stack (lifo) mempool handler

2016-06-17 Thread Hunt, David
Hi Olivier,

On 23/5/2016 1:55 PM, Olivier Matz wrote:
> Hi David,
>
> Please find some comments below.
>
> On 05/19/2016 04:48 PM, David Hunt wrote:
>> [...]
>> +++ b/lib/librte_mempool/rte_mempool_stack.c
>> @@ -0,0 +1,145 @@
>> +/*-
>> + *   BSD LICENSE
>> + *
>> + *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
>> + *   All rights reserved.
> Should be 2016?

Yes, fixed.

>> ...
>> +
>> +static void *
>> +common_stack_alloc(struct rte_mempool *mp)
>> +{
>> +struct rte_mempool_common_stack *s;
>> +unsigned n = mp->size;
>> +int size = sizeof(*s) + (n+16)*sizeof(void *);
>> +
>> +/* Allocate our local memory structure */
>> +s = rte_zmalloc_socket("common-stack",
> "mempool-stack" ?

Done

>> +size,
>> +RTE_CACHE_LINE_SIZE,
>> +mp->socket_id);
>> +if (s == NULL) {
>> +RTE_LOG(ERR, MEMPOOL, "Cannot allocate stack!\n");
>> +return NULL;
>> +}
>> +
>> +rte_spinlock_init(>sl);
>> +
>> +s->size = n;
>> +mp->pool = s;
>> +rte_mempool_set_handler(mp, "stack");
> rte_mempool_set_handler() is a user function, it should be called here

Removed.

>> +
>> +return s;
>> +}
>> +
>> +static int common_stack_put(void *p, void * const *obj_table,
>> +unsigned n)
>> +{
>> +struct rte_mempool_common_stack *s = p;
>> +void **cache_objs;
>> +unsigned index;
>> +
>> +rte_spinlock_lock(>sl);
>> +cache_objs = >objs[s->len];
>> +
>> +/* Is there sufficient space in the stack ? */
>> +if ((s->len + n) > s->size) {
>> +rte_spinlock_unlock(>sl);
>> +return -ENOENT;
>> +}
> The usual return value for a failing put() is ENOBUFS (see in rte_ring).

Done.

>
> After reading it, I realize that it's nearly exactly the same code than
> in "app/test: test external mempool handler".
> http://patchwork.dpdk.org/dev/patchwork/patch/12896/
>
> We should drop one of them. If this stack handler is really useful for
> a performance use-case, it could go in librte_mempool. At the first
> read, the code looks like a demo example : it uses a simple spinlock for
> concurrent accesses to the common pool. Maybe the mempool cache hides
> this cost, in this case we could also consider removing the use of the
> rte_ring.

While I agree that the code is similar, the handler in the test is a 
ring based handler,
where as this patch adds an array based handler.

I think that the case for leaving it in as a test for the standard 
handler as part of the
previous mempool handler is valid, but maybe there is a case for 
removing it if
we add the stack handler. Maybe a future patch?

> Do you have some some performance numbers? Do you know if it scales
> with the number of cores?

For the mempool_perf_autotest, I'm seeing a 30% increase in performance 
for the
local cache use-case for 1 - 36 cores (results vary within those tests 
between
10-45% gain, but with an average of 30% gain over all the tests.).

However, for the tests with no local cache configured, throughput of the 
enqueue/dequeue
drops by about 30%, with the 36 core yelding the largest drop of 40%. So 
this handler would
not be recommended in no-cache applications.

> If we can identify the conditions where this mempool handler
> overperforms the default handler, it would be valuable to have them
> in the documentation.
>


Regards,
Dave.





[dpdk-dev] [PATCH] qat: fix for VFs not getting recognized

2016-06-17 Thread Jerin Jacob
On Fri, Jun 17, 2016 at 10:18:30AM +0200, Thomas Monjalon wrote:
> 2016-06-16 16:25, Jain, Deepak K:
> > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > > 2016-06-16 16:29, Jain, Deepak K:
> > > > Due to addition of CLASS_ID in EAL, class_id is amended into the code.
> > > 
> > > Why the VF is not recognized?
> > > The class id should not be mandatory.
> > 
> > Without the change proposed, QuickAssist Devices were not visible and hence 
> > tests were not running.
> > Seems like changes in EAL especially where class_id is added affected the 
> > QuickAssist tests.
> > With this change, QuickAssist devices are visible during tests and tests 
> > working fine.
> 
> Which tests?
> Have you investigated why?

Thunderx nicvf also got the same problem when I rebased to
dpdk-next-net/rel_16_07.

The root cause for this issue is that, PCI CLASS_ID EAL add
changeset(701c8d80c820461e8255dfb7387a09f0e54399f0)
has taken care only the pci devices where id table is created
with RTE_PCI_DEVICE

For other devices, class_id comes as 0 instread of RTE_CLASS_ANY_ID and
probe failes. To fix it,

one option is to add RTE_CLASS_ANY_ID for the devices where pci id table is not
created with RTE_PCI_DEVICE

or

somewhere in common-code in the initaization set if class_id = 0 then make it as
RTE_CLASS_ANY_ID(Thats would be a hack).

Seems like first option is correct-way to fix the problem? Any thoughts?

looks like following devices does not exhibit this issue

[dpdk-thunderx] $ grep -r "RTE_PCI_DEVICE" drivers/
drivers/net/szedata2/rte_eth_szedata2.c:
drivers/net/bnx2x/bnx2x_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
drivers/net/enic/enic_ethdev.c
drivers/net/e1000/em_ethdev.c
drivers/net/ena/ena_ethdev.c
drivers/net/qede/qede_ethdev.c
drivers/net/ixgbe/ixgbe_ethdev.c:#define RTE_PCI_DEV_ID_DECL_IXGBE(vend,
drivers/net/virtio/virtio_ethdev.c:#define
drivers/net/i40e/i40e_ethdev.c:vend,

Jerin


[dpdk-dev] [PATCH v14 3/3] mbuf: make default mempool ops configurable at build

2016-06-17 Thread David Hunt
By default, the mempool ops used for mbuf allocations is a multi
producer and multi consumer ring. We could imagine a target (maybe some
network processors?) that provides an hardware-assisted pool
mechanism. In this case, the default configuration for this architecture
would contain a different value for RTE_MBUF_DEFAULT_MEMPOOL_OPS.

Signed-off-by: Olivier Matz 
Signed-off-by: David Hunt 
Acked-by: Shreyansh Jain 
Acked-by: Olivier Matz 
---
 config/common_base |  1 +
 lib/librte_mbuf/rte_mbuf.c | 26 ++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/config/common_base b/config/common_base
index 11ac81e..5f230db 100644
--- a/config/common_base
+++ b/config/common_base
@@ -394,6 +394,7 @@ CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n
 #
 CONFIG_RTE_LIBRTE_MBUF=y
 CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
+CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="ring_mp_mc"
 CONFIG_RTE_MBUF_REFCNT_ATOMIC=y
 CONFIG_RTE_PKTMBUF_HEADROOM=128

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 2ece742..8cf5436 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -153,6 +153,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
unsigned cache_size, uint16_t priv_size, uint16_t data_room_size,
int socket_id)
 {
+   struct rte_mempool *mp;
struct rte_pktmbuf_pool_private mbp_priv;
unsigned elt_size;

@@ -167,10 +168,27 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
mbp_priv.mbuf_data_room_size = data_room_size;
mbp_priv.mbuf_priv_size = priv_size;

-   return rte_mempool_create(name, n, elt_size,
-   cache_size, sizeof(struct rte_pktmbuf_pool_private),
-   rte_pktmbuf_pool_init, _priv, rte_pktmbuf_init, NULL,
-   socket_id, 0);
+   mp = rte_mempool_create_empty(name, n, elt_size, cache_size,
+sizeof(struct rte_pktmbuf_pool_private), socket_id, 0);
+   if (mp == NULL)
+   return NULL;
+
+   rte_errno = rte_mempool_set_ops_byname(mp,
+   RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
+   if (rte_errno != 0) {
+   RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+   return NULL;
+   }
+   rte_pktmbuf_pool_init(mp, _priv);
+
+   if (rte_mempool_populate_default(mp) < 0) {
+   rte_mempool_free(mp);
+   return NULL;
+   }
+
+   rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL);
+
+   return mp;
 }

 /* do some sanity checks on a mbuf: panic if it fails */
-- 
2.5.5



[dpdk-dev] [PATCH v14 2/3] app/test: test mempool handler

2016-06-17 Thread David Hunt
Create a minimal custom mempool handler and check that it
passes basic mempool autotests.

Signed-off-by: Olivier Matz 
Signed-off-by: David Hunt 
Acked-by: Shreyansh Jain 
Acked-by: Olivier Matz 
---
 app/test/test_mempool.c | 122 +++-
 1 file changed, 120 insertions(+), 2 deletions(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index b586249..31582d8 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -83,6 +83,99 @@
 static rte_atomic32_t synchro;

 /*
+ * Simple example of custom mempool structure. Holds pointers to all the
+ * elements which are simply malloc'd in this example.
+ */
+struct custom_mempool {
+   rte_spinlock_t lock;
+   unsigned count;
+   unsigned size;
+   void *elts[];
+};
+
+/*
+ * Loop through all the element pointers and allocate a chunk of memory, then
+ * insert that memory into the ring.
+ */
+static int
+custom_mempool_alloc(struct rte_mempool *mp)
+{
+   struct custom_mempool *cm;
+
+   cm = rte_zmalloc("custom_mempool",
+   sizeof(struct custom_mempool) + mp->size * sizeof(void *), 0);
+   if (cm == NULL)
+   return -ENOMEM;
+
+   rte_spinlock_init(>lock);
+   cm->count = 0;
+   cm->size = mp->size;
+   mp->pool_data = cm;
+   return 0;
+}
+
+static void
+custom_mempool_free(struct rte_mempool *mp)
+{
+   rte_free((void *)(mp->pool_data));
+}
+
+static int
+custom_mempool_enqueue(struct rte_mempool *mp, void * const *obj_table,
+   unsigned n)
+{
+   struct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);
+   int ret = 0;
+
+   rte_spinlock_lock(>lock);
+   if (cm->count + n > cm->size) {
+   ret = -ENOBUFS;
+   } else {
+   memcpy(>elts[cm->count], obj_table, sizeof(void *) * n);
+   cm->count += n;
+   }
+   rte_spinlock_unlock(>lock);
+   return ret;
+}
+
+
+static int
+custom_mempool_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n)
+{
+   struct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);
+   int ret = 0;
+
+   rte_spinlock_lock(>lock);
+   if (n > cm->count) {
+   ret = -ENOENT;
+   } else {
+   cm->count -= n;
+   memcpy(obj_table, >elts[cm->count], sizeof(void *) * n);
+   }
+   rte_spinlock_unlock(>lock);
+   return ret;
+}
+
+static unsigned
+custom_mempool_get_count(const struct rte_mempool *mp)
+{
+   struct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);
+
+   return cm->count;
+}
+
+static struct rte_mempool_ops mempool_ops_custom = {
+   .name = "custom_handler",
+   .alloc = custom_mempool_alloc,
+   .free = custom_mempool_free,
+   .enqueue = custom_mempool_enqueue,
+   .dequeue = custom_mempool_dequeue,
+   .get_count = custom_mempool_get_count,
+};
+
+MEMPOOL_REGISTER_OPS(mempool_ops_custom);
+
+/*
  * save the object number in the first 4 bytes of object data. All
  * other bytes are set to 0.
  */
@@ -292,12 +385,14 @@ static int test_mempool_single_consumer(void)
  * test function for mempool test based on singple consumer and single 
producer,
  * can run on one lcore only
  */
-static int test_mempool_launch_single_consumer(__attribute__((unused)) void 
*arg)
+static int
+test_mempool_launch_single_consumer(__attribute__((unused)) void *arg)
 {
return test_mempool_single_consumer();
 }

-static void my_mp_init(struct rte_mempool * mp, __attribute__((unused)) void * 
arg)
+static void
+my_mp_init(struct rte_mempool *mp, __attribute__((unused)) void *arg)
 {
printf("mempool name is %s\n", mp->name);
/* nothing to be implemented here*/
@@ -477,6 +572,7 @@ test_mempool(void)
 {
struct rte_mempool *mp_cache = NULL;
struct rte_mempool *mp_nocache = NULL;
+   struct rte_mempool *mp_ext = NULL;

rte_atomic32_init();

@@ -505,6 +601,27 @@ test_mempool(void)
goto err;
}

+   /* create a mempool with an external handler */
+   mp_ext = rte_mempool_create_empty("test_ext",
+   MEMPOOL_SIZE,
+   MEMPOOL_ELT_SIZE,
+   RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
+   SOCKET_ID_ANY, 0);
+
+   if (mp_ext == NULL) {
+   printf("cannot allocate mp_ext mempool\n");
+   goto err;
+   }
+   if (rte_mempool_set_ops_byname(mp_ext, "custom_handler", NULL) < 0) {
+   printf("cannot set custom handler\n");
+   goto err;
+   }
+   if (rte_mempool_populate_default(mp_ext) < 0) {
+   printf("cannot populate mp_ext mempool\n");
+   goto err;
+   }
+   rte_mempool_obj_iter(mp_ext, my_obj_init, NULL);
+
/* retrieve the mempool from its name */
if (rte_mempool_lookup("test_nocache") != mp_nocache) {
printf("Cannot lookup mempool from its name\n");

[dpdk-dev] [PATCH v14 1/3] mempool: support mempool handler operations

2016-06-17 Thread David Hunt
Until now, the objects stored in a mempool were internally stored in a
ring. This patch introduces the possibility to register external handlers
replacing the ring.

The default behavior remains unchanged, but calling the new function
rte_mempool_set_ops_byname() right after rte_mempool_create_empty() allows
the user to change the handler that will be used when populating
the mempool.

This patch also adds a set of default ops (function callbacks) based
on rte_ring.

Signed-off-by: Olivier Matz 
Signed-off-by: David Hunt 
Acked-by: Shreyansh Jain 
Acked-by: Olivier Matz 
---
 app/test/test_mempool_perf.c   |   1 -
 doc/guides/prog_guide/mempool_lib.rst  |  32 +++-
 doc/guides/rel_notes/deprecation.rst   |   9 -
 lib/librte_mempool/Makefile|   2 +
 lib/librte_mempool/rte_mempool.c   |  67 +++-
 lib/librte_mempool/rte_mempool.h   | 255 ++---
 lib/librte_mempool/rte_mempool_ops.c   | 150 +
 lib/librte_mempool/rte_mempool_ring.c  | 161 ++
 lib/librte_mempool/rte_mempool_version.map |  13 +-
 9 files changed, 609 insertions(+), 81 deletions(-)
 create mode 100644 lib/librte_mempool/rte_mempool_ops.c
 create mode 100644 lib/librte_mempool/rte_mempool_ring.c

diff --git a/app/test/test_mempool_perf.c b/app/test/test_mempool_perf.c
index c5e3576..c5f8455 100644
--- a/app/test/test_mempool_perf.c
+++ b/app/test/test_mempool_perf.c
@@ -161,7 +161,6 @@ per_lcore_mempool_test(__attribute__((unused)) void *arg)
   n_get_bulk);
if (unlikely(ret < 0)) {
rte_mempool_dump(stdout, mp);
-   rte_ring_dump(stdout, mp->ring);
/* in this case, objects are lost... */
return -1;
}
diff --git a/doc/guides/prog_guide/mempool_lib.rst 
b/doc/guides/prog_guide/mempool_lib.rst
index c3afc2e..1943fc4 100644
--- a/doc/guides/prog_guide/mempool_lib.rst
+++ b/doc/guides/prog_guide/mempool_lib.rst
@@ -34,7 +34,8 @@ Mempool Library
 ===

 A memory pool is an allocator of a fixed-sized object.
-In the DPDK, it is identified by name and uses a ring to store free objects.
+In the DPDK, it is identified by name and uses a mempool handler to store free 
objects.
+The default mempool handler is ring based.
 It provides some other optional services such as a per-core object cache and
 an alignment helper to ensure that objects are padded to spread them equally 
on all DRAM or DDR3 channels.

@@ -127,6 +128,35 @@ The maximum size of the cache is static and is defined at 
compilation time (CONF
A mempool in Memory with its Associated Ring


+Mempool Handlers
+
+
+This allows external memory subsystems, such as external hardware memory
+management systems and software based memory allocators, to be used with DPDK.
+
+There are two aspects to a mempool handler.
+
+* Adding the code for your new mempool operations (ops). This is achieved by
+  adding a new mempool ops code, and using the ``REGISTER_MEMPOOL_OPS`` macro.
+
+* Using the new API to call ``rte_mempool_create_empty()`` and
+  ``rte_mempool_set_ops_byname()`` to create a new mempool and specifying which
+  ops to use.
+
+Several different mempool handlers may be used in the same application. A new
+mempool can be created by using the ``rte_mempool_create_empty()`` function,
+then using ``rte_mempool_set_ops_byname()`` to point the mempool to the
+relevant mempool handler callback (ops) structure.
+
+Legacy applications may continue to use the old ``rte_mempool_create()`` API
+call, which uses a ring based mempool handler by default. These applications
+will need to be modified to use a new mempool handler.
+
+For applications that use ``rte_pktmbuf_create()``, there is a config setting
+(``RTE_MBUF_DEFAULT_MEMPOOL_OPS``) that allows the application to make use of
+an alternative mempool handler.
+
+
 Use Cases
 -

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index f75183f..3cbc19e 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -34,15 +34,6 @@ Deprecation Notices
   compact API. The ones that remain are backwards compatible and use the
   per-lcore default cache if available. This change targets release 16.07.

-* The rte_mempool struct will be changed in 16.07 to facilitate the new
-  external mempool manager functionality.
-  The ring element will be replaced with a more generic 'pool' opaque pointer
-  to allow new mempool handlers to use their own user-defined mempool
-  layout. Also newly added to rte_mempool is a handler index.
-  The existing API will be backward compatible, but there will be new API
-  functions added to facilitate the creation of mempools 

[dpdk-dev] [PATCH v14 0/3] mempool: add mempool handler feature

2016-06-17 Thread David Hunt
Here's the latest version of the Mempool Handler feature (previously
known as the External Mempool Manager.

It's re-based on top of the latest head as of 17/6/2016, including
Olivier's 35-part patch series on mempool re-org [1]

[1] http://dpdk.org/ml/archives/dev/2016-May/039229.html

v14 changes:

 * set MEMPOOL_F_RING_CREATED flag after rte_mempool_ring_create() is called.
 * Changed name of feature from "external mempool manager" to "mempool handler"
   and updated comments and release notes accordingly.
 * Added a comment for newly added pool_config param in
   rte_mempool_set_ops_byname.

v13 changes:

 * Added in extra opaque data (pool_config) to mempool struct for mempool
   configuration by the ops functions. For example, this can be used to pass
  device names or device flags to the underlying alloc function.
 * Added mempool_config param to rte_mempool_set_ops_byname()

v12 changes:

 * Fixed a comment (function pram h -> ops)
 * fixed a typo (callbacki)

v11 changes:

 * Fixed comments (added '.' where needed for consistency)
 * removed ABI breakage notice for mempool manager in deprecation.rst
 * Added description of the external mempool manager functionality to
   doc/guides/prog_guide/mempool_lib.rst (John Mc reviewed)
 * renamed rte_mempool_default.c to rte_mempool_ring.c

v10 changes:

 * changed the _put/_get op names to _enqueue/_dequeue to be consistent
   with the function names
 * some rte_errno cleanup
 * comment tweaks about when to set pool_data
 * removed an un-needed check for ops->alloc == NULL

v9 changes:

 * added a check for NULL alloc in rte_mempool_ops_register
 * rte_mempool_alloc_t now returns int instead of void*
 * fixed some comment typo's
 * removed some unneeded typecasts
 * changed a return NULL to return -EEXIST in rte_mempool_ops_register
 * fixed rte_mempool_version.map file so builds ok as shared libs
 * moved flags check from rte_mempool_create_empty to rte_mempool_create

v8 changes:

 * merged first three patches in the series into one.
 * changed parameters to ops callback to all be rte_mempool pointer
   rather than than pointer to opaque data or uint64.
 * comment fixes.
 * fixed parameter to _free function (was inconsistent).
 * changed MEMPOOL_F_RING_CREATED to MEMPOOL_F_POOL_CREATED

v7 changes:

 * Changed rte_mempool_handler_table to rte_mempool_ops_table
 * Changed hander_idx to ops_index in rte_mempool struct
 * Reworked comments in rte_mempool.h around ops functions
 * Changed rte_mempool_hander.c to rte_mempool_ops.c
 * Changed all functions containing _handler_ to _ops_
 * Now there is no mention of 'handler' left
 * Other small changes out of review of mailing list

v6 changes:

 * Moved the flags handling from rte_mempool_create_empty to
   rte_mempool_create, as it's only there for backward compatibility
 * Various comment additions and cleanup
 * Renamed rte_mempool_handler to rte_mempool_ops
 * Added a union for *pool and u64 pool_id in struct rte_mempool
 * split the original patch into a few parts for easier review.
 * rename functions with _ext_ to _ops_.
 * addressed review comments
 * renamed put and get functions to enqueue and dequeue
 * changed occurences of rte_mempool_ops to const, as they
   contain function pointers (security)
 * split out the default external mempool handler into a separate
   patch for easier review

v5 changes:
 * rebasing, as it is dependent on another patch series [1]

v4 changes (Olivier Matz):
 * remove the rte_mempool_create_ext() function. To change the handler, the
   user has to do the following:
   - mp = rte_mempool_create_empty()
   - rte_mempool_set_handler(mp, "my_handler")
   - rte_mempool_populate_default(mp)
   This avoids to add another function with more than 10 arguments, duplicating
   the doxygen comments
 * change the api of rte_mempool_alloc_t: only the mempool pointer is required
   as all information is available in it
 * change the api of rte_mempool_free_t: remove return value
 * move inline wrapper functions from the .c to the .h (else they won't be
   inlined). This implies to have one header file (rte_mempool.h), or it
   would have generate cross dependencies issues.
 * remove now unused MEMPOOL_F_INT_HANDLER (note: it was misused anyway due
   to the use of && instead of &)
 * fix build in debug mode (__MEMPOOL_STAT_ADD(mp, put_pool, n) remaining)
 * fix build with shared libraries (global handler has to be declared in
   the .map file)
 * rationalize #include order
 * remove unused function rte_mempool_get_handler_name()
 * rename some structures, fields, functions
 * remove the static in front of rte_tailq_elem rte_mempool_tailq (comment
   from Yuanhan)
 * test the ext mempool handler in the same file than standard mempool tests,
   avoiding to duplicate the code
 * rework the custom handler in mempool_test
 * rework a bit the patch selecting default mbuf pool handler
 * fix some doxygen comments

v3 changes:
 * simplified the file layout, renamed to 

[dpdk-dev] [PATCH] app/test: call objdump in platform-independent way

2016-06-17 Thread Jan Viktorin
Using of the /dev/stdin generates a warning when compiling on FreeBSD:

 objcopy: Warning: '/dev/stdin' is not an ordinary file
 app/test/Makefile:78: recipe for target 'test_resource_c.res.o' failed
 # ls -l /dev/stdin
 lrwxr-xr-x  1 root  wheel  4 Jun 17 12:24 /dev/stdin -> fd/0

Replace /dev/stdin by a temporary file.

Signed-off-by: Jan Viktorin 
Reported-by: Thomas Monjalon 
---
 app/test/Makefile | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/app/test/Makefile b/app/test/Makefile
index 5e3ebdc..36ff089 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -43,13 +43,14 @@ define linked_resource
 SRCS-y += $(1).res.o
 $(1).res.o: $(2)
@  echo '  MKRES $$@'
+   $Q ln -fs $$< resource.tmp
$Q $(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 $$@ < $$<
+   --redefine-sym _binary_resource_tmp_start=beg_$(1)   \
+   --redefine-sym _binary_resource_tmp_end=end_$(1) \
+   --redefine-sym _binary_resource_tmp_size=siz_$(1)\
+   resource.tmp $$@ && rm -f resource.tmp
 endef

 ifeq ($(CONFIG_RTE_APP_TEST_RESOURCE_TAR),y)
-- 
2.8.0



[dpdk-dev] [PATCHv8 6/6] doc: Add prog_guide section documenting pmdinfo script

2016-06-17 Thread Neil Horman
Information on pmdinfogen may be useful to 3rd party driver developers.
Include documentation on what it does

Signed-off-by: Neil Horman 
Acked-by: Panu Matilainen 
Acked-by: John McNamara 
CC: Bruce Richardson 
CC: Thomas Monjalon 
CC: Stephen Hemminger 
CC: Panu Matilainen 
---
 doc/guides/prog_guide/dev_kit_build_system.rst | 43 --
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/doc/guides/prog_guide/dev_kit_build_system.rst 
b/doc/guides/prog_guide/dev_kit_build_system.rst
index 3e89eae..1dc1388 100644
--- a/doc/guides/prog_guide/dev_kit_build_system.rst
+++ b/doc/guides/prog_guide/dev_kit_build_system.rst
@@ -70,7 +70,7 @@ Each build directory contains include files, libraries, and 
applications:
 ...
 ~/DEV/DPDK$ ls i686-native-linuxapp-gcc

-app build hostapp include kmod lib Makefile
+app build buildtools include kmod lib Makefile


 ~/DEV/DPDK$ ls i686-native-linuxapp-gcc/app/
@@ -264,7 +264,7 @@ These Makefiles generate a binary application.

 *   rte.extapp.mk: External application

-*   rte.hostapp.mk: Host application in the development kit framework
+*   rte.hostapp.mk: prerequisite tool to build dpdk

 Library
 ^^^
@@ -304,6 +304,45 @@ Misc

 *   rte.subdir.mk: Build several directories in the development kit framework.

+.. _Internally_Generated_Build_Tools:
+
+Internally Generated Build Tools
+
+
+``app/pmdinfogen``
+
+
+``pmdinfogen`` scans an object (.o) file for various well known symbol names.  
These
+well known symbol names are defined by various macros and used to export
+important information about hardware support and usage for pmd files.  For
+instance the macro:
+
+.. code-block:: c
+
+PMD_REGISTER_DRIVER(drv, name)
+
+
+Creates the following symbol:
+
+.. code-block:: c
+
+   static char this_pmd_name0[] __attribute__((used)) = "";
+
+
+Which pmdinfogen scans for.  Using this information other relevant bits of data
+can be exported from the object file and used to produce a hardware support
+description, that pmdinfogen then encodes into a json formatted string in the
+following format:
+
+.. code-block:: C
+
+   static char ="PMD_INFO_STRING=\"{'name' : '', 
...}\"";
+
+
+These strings can then be searched for by external tools to determine the
+hardware support of a given library or application.
+
+
 .. _Useful_Variables_Provided_by_the_Build_System:

 Useful Variables Provided by the Build System
-- 
2.5.5



[dpdk-dev] [PATCHv8 5/6] pmdinfo.py: Add tool to query binaries for hw and other support information

2016-06-17 Thread Neil Horman
This tool searches for the primer sting PMD_DRIVER_INFO= in any ELF binary,
and, if found parses the remainder of the string as a json encoded string,
outputting the results in either a human readable or raw, script parseable
format

Note that, in the case of dynamically linked applications, pmdinfo.py will
scan for implicitly linked PMDs by searching the specified binaries
.dynamic section for DT_NEEDED entries that contain the substring
librte_pmd.  The DT_RUNPATH, LD_LIBRARY_PATH, /usr/lib and /lib are
searched for these libraries, in that order

If a file is specified with no path, it is assumed to be a PMD DSO, and the
LD_LIBRARY_PATH, /usr/lib[64]/ and /lib[64] is searched for it

Currently the tool can output data in 3 formats:

a) raw, suitable for scripting, where the raw JSON strings are dumped out
b) table format (default) where hex pci ids are dumped in a table format
c) pretty, where a user supplied pci.ids file is used to print out vendor
and device strings

Signed-off-by: Neil Horman 
Acked-by: Panu Matilainen 
CC: Bruce Richardson 
CC: Thomas Monjalon 
CC: Stephen Hemminger 
CC: Panu Matilainen 
---
 mk/rte.sdkinstall.mk |   2 +
 tools/pmdinfo.py | 629 +++
 2 files changed, 631 insertions(+)
 create mode 100755 tools/pmdinfo.py

diff --git a/mk/rte.sdkinstall.mk b/mk/rte.sdkinstall.mk
index 1f3b59c..b0d985c 100644
--- a/mk/rte.sdkinstall.mk
+++ b/mk/rte.sdkinstall.mk
@@ -128,6 +128,8 @@ install-runtime:
   $(DESTDIR)$(sbindir)/dpdk_nic_bind)
$(Q)$(call rte_symlink,$(DESTDIR)$(bindir)/pmdinfogen, \
   $(DESTDIR)$(bindir)/dpdk_pmdinfogen)
+   $(Q)$(call rte_symlink,$(DESTDIR)$(datadir)/tools/pmdinfo.py, \
+  $(DESTDIR)$(bindir)/dpdk_pmdinfo)

 install-kmod:
 ifneq ($(wildcard $O/kmod/*),)
diff --git a/tools/pmdinfo.py b/tools/pmdinfo.py
new file mode 100755
index 000..e531154
--- /dev/null
+++ b/tools/pmdinfo.py
@@ -0,0 +1,629 @@
+#!/usr/bin/python
+# -
+# scripts/pmdinfo.py
+#
+# Utility to dump PMD_INFO_STRING support from an object file
+#
+# -
+import os
+import sys
+from optparse import OptionParser
+import string
+import json
+
+# For running from development directory. It should take precedence over the
+# installed pyelftools.
+sys.path.insert(0, '.')
+
+
+from elftools import __version__
+from elftools.common.exceptions import ELFError
+from elftools.common.py3compat import (
+ifilter, byte2int, bytes2str, itervalues, str2bytes)
+from elftools.elf.elffile import ELFFile
+from elftools.elf.dynamic import DynamicSection, DynamicSegment
+from elftools.elf.enums import ENUM_D_TAG
+from elftools.elf.segments import InterpSegment
+from elftools.elf.sections import SymbolTableSection
+from elftools.elf.gnuversions import (
+GNUVerSymSection, GNUVerDefSection,
+GNUVerNeedSection,
+)
+from elftools.elf.relocation import RelocationSection
+from elftools.elf.descriptions import (
+describe_ei_class, describe_ei_data, describe_ei_version,
+describe_ei_osabi, describe_e_type, describe_e_machine,
+describe_e_version_numeric, describe_p_type, describe_p_flags,
+describe_sh_type, describe_sh_flags,
+describe_symbol_type, describe_symbol_bind, describe_symbol_visibility,
+describe_symbol_shndx, describe_reloc_type, describe_dyn_tag,
+describe_ver_flags,
+)
+from elftools.elf.constants import E_FLAGS
+from elftools.dwarf.dwarfinfo import DWARFInfo
+from elftools.dwarf.descriptions import (
+describe_reg_name, describe_attr_value, set_global_machine_arch,
+describe_CFI_instructions, describe_CFI_register_rule,
+describe_CFI_CFA_rule,
+)
+from elftools.dwarf.constants import (
+DW_LNS_copy, DW_LNS_set_file, DW_LNE_define_file)
+from elftools.dwarf.callframe import CIE, FDE
+
+raw_output = False
+pcidb = None
+
+# ===
+
+
+class Vendor:
+"""
+Class for vendors. This is the top level class
+for the devices belong to a specific vendor.
+self.devices is the device dictionary
+subdevices are in each device.
+"""
+
+def __init__(self, vendorStr):
+"""
+Class initializes with the raw line from pci.ids
+Parsing takes place inside __init__
+"""
+self.ID = vendorStr.split()[0]
+self.name = vendorStr.replace("%s " % self.ID, "").rstrip()
+self.devices = {}
+
+def addDevice(self, deviceStr):
+"""
+Adds a device to self.devices
+takes the raw line from pci.ids
+"""
+s = deviceStr.strip()
+devID = s.split()[0]
+if devID in self.devices:
+pass
+else:
+self.devices[devID] = Device(deviceStr)
+
+def report(self):
+print self.ID, 

[dpdk-dev] [PATCHv8 4/6] Makefile: Do post processing on objects that register a driver

2016-06-17 Thread Neil Horman
Modify the compilation makefile to identify C files that export PMD
information, and use that to trigger execution of the pmdinfo binary.  If
the execution of pmdinfo is successful, compile the output C file to an
object, and use the linker to do relocatable linking on the resultant
object file into the parent object that it came from.  This effectively
just adds the json string into the string table of the object that defines
the PMD to the outside world.

Signed-off-by: Neil Horman 
Acked-by: Panu Matilainen 
CC: Bruce Richardson 
CC: Thomas Monjalon 
CC: Stephen Hemminger 
CC: Panu Matilainen 
---
 mk/internal/rte.compile-pre.mk | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/mk/internal/rte.compile-pre.mk b/mk/internal/rte.compile-pre.mk
index b9bff4a..5632d6e 100644
--- a/mk/internal/rte.compile-pre.mk
+++ b/mk/internal/rte.compile-pre.mk
@@ -88,10 +88,24 @@ C_TO_O_CMD = 'cmd_$@ = $(C_TO_O_STR)'
 C_TO_O_DO = @set -e; \
echo $(C_TO_O_DISP); \
$(C_TO_O) && \
+   sh -c "grep -q \"PMD_REGISTER_DRIVER(.*)\" $<; \
+   if [ \$$? -eq 0 ]; then \
+   echo \"  PMDINFOGEN\" $@; \
+   OBJF=`readlink -f $@`; \
+   ${RTE_OUTPUT}/app/pmdinfogen \$$OBJF \$$OBJF.pmd.c; \
+   if [ \$$? -eq 0 ]; \
+   then \
+   echo \"  PMDINFOBUILD\" $@; \
+   $(CC) $(CFLAGS) -c -o \$$OBJF.pmd.o \$$OBJF.pmd.c; \
+   $(CROSS)ld $(LDFLAGS) -r -o \$$OBJF.o \$$OBJF.pmd.o 
\$$OBJF; \
+   mv -f \$$OBJF.o \$$OBJF; \
+   fi; \
+   fi;" && \
echo $(C_TO_O_CMD) > $(call obj2cmd,$(@)) && \
sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call 
obj2dep,$(@)) && \
rm -f $(call obj2dep,$(@)).tmp

+
 # return an empty string if string are equal
 compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1)))

-- 
2.5.5



[dpdk-dev] [PATCHv8 3/6] eal: Add an export symbol to expose the autoload path to external tools

2016-06-17 Thread Neil Horman
Export a symbol containing the string:
DPDK_PLUGIN_PATH="$(CONFIG_RTE_EAL_PMD_PATH)"

Where the latter half of the string is set at build time to a location from
which autoloaded DSO's will be found.  This string is used by pmdinfo in
'plugin' mode, whereby a user can specify a dpdk installation directory (or
static binary), and scan the associated path (if found) for pmd DSO's and
report on their hardware support.

Signed-off-by: Neil Horman 
Acked-by: Panu Matilainen 
CC: Bruce Richardson 
CC: Thomas Monjalon 
CC: Stephen Hemminger 
CC: Panu Matilainen 
---
 lib/librte_eal/common/eal_common_options.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 3efc90f..0a594d7 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -115,6 +115,15 @@ TAILQ_HEAD_INITIALIZER(solib_list);
 /* Default path of external loadable drivers */
 static const char *default_solib_dir = RTE_EAL_PMD_PATH;

+/*
+ * Stringified version of solib path used by pmdinfo.py
+ * Note: PLEASE DO NOT ALTER THIS without making a corresponding
+ * change to tools/pmdinfo.py
+ */
+static const char dpdk_solib_path[] __attribute__((used)) =
+"DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
+
+
 static int master_lcore_parsed;
 static int mem_parsed;

-- 
2.5.5



[dpdk-dev] [PATCHv8 2/6] drivers: Update driver registration macro usage

2016-06-17 Thread Neil Horman
Modify the PMD_REGISTER_DRIVER macro, adding a name argument to it.  The
addition of a name argument creates a token that can be used for subsequent
macros in the creation of unique symbol names to export additional bits of
information for use by the pmdinfogen tool.  For example:

PMD_REGISTER_DRIVER(ena_driver, ena);

registers the ena_driver struct as it always did, and creates a symbol
const char this_pmd_name0[] __attribute__((used)) = "ena";

which pmdinfogen can search for and extract.  The subsequent macro

DRIVER_REGISTER_PCI_TABLE(ena, ena_pci_id_map);

creates a symbol const char ena_pci_tbl_export[] __attribute__((used)) =
"ena_pci_id_map";

Which allows pmdinfogen to find the pci table of this driver

Using this pattern, we can export arbitrary bits of information.

pmdinfo uses this information to extract hardware support from an object
file and create a json string to make hardware support info discoverable
later.

Signed-off-by: Neil Horman 
Acked-by: Panu Matilainen 
CC: Bruce Richardson 
CC: Thomas Monjalon 
CC: Stephen Hemminger 
CC: Panu Matilainen 
---
 drivers/Makefile   |  2 ++
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c   |  4 +++-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c |  4 +++-
 drivers/crypto/null/null_crypto_pmd.c  |  4 +++-
 drivers/crypto/qat/rte_qat_cryptodev.c |  4 +++-
 drivers/crypto/snow3g/rte_snow3g_pmd.c |  4 +++-
 drivers/net/af_packet/rte_eth_af_packet.c  |  4 +++-
 drivers/net/bnx2x/bnx2x_ethdev.c   |  6 --
 drivers/net/bonding/rte_eth_bond_pmd.c |  7 ++-
 drivers/net/cxgbe/cxgbe_ethdev.c   |  4 +++-
 drivers/net/e1000/em_ethdev.c  |  3 ++-
 drivers/net/e1000/igb_ethdev.c |  6 --
 drivers/net/ena/ena_ethdev.c   |  3 ++-
 drivers/net/enic/enic_ethdev.c |  3 ++-
 drivers/net/fm10k/fm10k_ethdev.c   |  3 ++-
 drivers/net/i40e/i40e_ethdev.c |  3 ++-
 drivers/net/i40e/i40e_ethdev_vf.c  |  3 ++-
 drivers/net/ixgbe/ixgbe_ethdev.c   |  6 --
 drivers/net/mlx4/mlx4.c|  3 ++-
 drivers/net/mlx5/mlx5.c|  3 ++-
 drivers/net/mpipe/mpipe_tilegx.c   |  4 ++--
 drivers/net/nfp/nfp_net.c  |  3 ++-
 drivers/net/null/rte_eth_null.c|  3 ++-
 drivers/net/pcap/rte_eth_pcap.c|  4 +++-
 drivers/net/qede/qede_ethdev.c |  6 --
 drivers/net/ring/rte_eth_ring.c|  3 ++-
 drivers/net/szedata2/rte_eth_szedata2.c|  3 ++-
 drivers/net/vhost/rte_eth_vhost.c  |  3 ++-
 drivers/net/virtio/virtio_ethdev.c |  3 ++-
 drivers/net/vmxnet3/vmxnet3_ethdev.c   |  3 ++-
 drivers/net/xenvirt/rte_eth_xenvirt.c  |  2 +-
 lib/librte_eal/common/include/rte_dev.h| 30 --
 32 files changed, 105 insertions(+), 41 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 81c03a8..75a3168 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -34,4 +34,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 DIRS-y += net
 DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += crypto

+DEPDIRS-y += buildtools/pmdinfo
+
 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c 
b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index 2987ef6..f43e407 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -521,4 +521,6 @@ static struct rte_driver aesni_gcm_pmd_drv = {
.uninit = aesni_gcm_uninit
 };

-PMD_REGISTER_DRIVER(aesni_gcm_pmd_drv);
+PMD_REGISTER_DRIVER(aesni_gcm_pmd_drv, aesni_gcm);
+DRIVER_REGISTER_PARAM_STRING(aesni_gcm, "max_nb_queue_pairs= "
+"max_nb_sessions= socket_id=");
diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c 
b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 6554fc4..db3e562 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -721,4 +721,6 @@ static struct rte_driver cryptodev_aesni_mb_pmd_drv = {
.uninit = cryptodev_aesni_mb_uninit
 };

-PMD_REGISTER_DRIVER(cryptodev_aesni_mb_pmd_drv);
+PMD_REGISTER_DRIVER(cryptodev_aesni_mb_pmd_drvi, aesni_mb);
+DRIVER_REGISTER_PARAM_STRING(aesni_gcm, "max_nb_queue_pairs= "
+"max_nb_sessions= socket_id=");
diff --git a/drivers/crypto/null/null_crypto_pmd.c 
b/drivers/crypto/null/null_crypto_pmd.c
index bdaf13c..0a195ed 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -275,4 +275,6 @@ static struct rte_driver cryptodev_null_pmd_drv = {
.uninit = cryptodev_null_uninit
 };

-PMD_REGISTER_DRIVER(cryptodev_null_pmd_drv);
+PMD_REGISTER_DRIVER(cryptodev_null_pmd_drv, cryptodev_null_pmd);
+DRIVER_REGISTER_PARAM_STRING(aesni_gcm, "max_nb_queue_pairs= "
+"max_nb_sessions= socket_id=");
diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c 
b/drivers/crypto/qat/rte_qat_cryptodev.c
index a7912f5..d2de6a6 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ 

[dpdk-dev] [PATCHv8 1/6] pmdinfogen: Add buildtools and pmdinfogen utility

2016-06-17 Thread Neil Horman
pmdinfogen is a tool used to parse object files and build json strings for
use in later determining hardware support in a dso or application binary.
pmdinfo looks for the non-exported symbol names this_pmd_name and
this_pmd_tbl (where n is a integer counter).  It records the name of
each of these tuples, using the later to find the symbolic name of the
pci_table for physical devices that the object supports.  With this
information, it outputs a C file with a single line of the form:

static char *_driver_info[] __attribute__((used)) = " \
PMD_DRIVER_INFO=";

Where  is the arbitrary name of the pmd, and  is the
json encoded string that hold relevant pmd information, including the pmd
name, type and optional array of pci device/vendor ids that the driver
supports.

This c file is suitable for compiling to object code, then relocatably
linking into the parent file from which the C was generated.  This creates
an entry in the string table of the object that can inform a later tool
about hardware support.

Signed-off-by: Neil Horman 
CC: Bruce Richardson 
CC: Thomas Monjalon 
CC: Stephen Hemminger 
CC: Panu Matilainen 
Acked-by: Panu Matilainen 
---
 GNUmakefile|   2 +-
 buildtools/Makefile|  36 +++
 buildtools/pmdinfogen/Makefile |  49 +
 buildtools/pmdinfogen/pmdinfogen.c | 439 +
 buildtools/pmdinfogen/pmdinfogen.h | 120 ++
 mk/rte.hostapp.mk  |   8 +-
 mk/rte.sdkbuild.mk |   3 +-
 mk/rte.sdkinstall.mk   |   2 +
 8 files changed, 653 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/Makefile
 create mode 100644 buildtools/pmdinfogen/Makefile
 create mode 100644 buildtools/pmdinfogen/pmdinfogen.c
 create mode 100644 buildtools/pmdinfogen/pmdinfogen.h

diff --git a/GNUmakefile b/GNUmakefile
index b59e4b6..00fe0db 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -40,6 +40,6 @@ export RTE_SDK
 # directory list
 #

-ROOTDIRS-y := lib drivers app
+ROOTDIRS-y := buildtools lib drivers app

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

[dpdk-dev] [PATCHv8 0/6] Implement pmd hardware support exports

2016-06-17 Thread Neil Horman
Hey all-
So heres attempt number 2 at a method for exporting PMD hardware support
information.  As we discussed previously, the consensus seems to be that pmd
information should be:

1) Able to be interrogated on any ELF binary (application binary or individual
DSO)
2) Equally functional on statically linked applications or on DSO's
3) Resilient to symbol stripping
4) Script friendly
5) Show kernel dependencies
6) List driver options
7) Show driver name
8) Offer human readable output
9) Show DPDK version
10) Show driver version
11) Allow for expansion
12) Not place additional build environment dependencies on an application

I added item 12 myself, because I don't think its reasonable to require
applications to use a specific linker script to get hardware support information
(which precludes the use of a special .modinfo section like the kernel uses)

However, we still can use some tricks from the kernel to make this work.  In
this approach, what I've done is the following:

A) Modified the driver registration macro to also define a variable:
this_pmd_name= "name"

Based on the unique name string pointed to by the above variable, we can
query for an arbitrary number of other symbols following the pattern:
_

Where tag is some well known identifier for information we wish to export

B) Added a utility called pmdinfogen.  This utility is not meant for general 
use,
but rather is used by the dpdk build environment itself when compiling pmds.
for each object that uses the PMD_REGISTER_DRIVER macro, this utiity is run.  It
searches for the symbols in (A), and using those, extracts the hardware support
info, and module name from the object, using that to produce a new c file
containing a single variable in the following format:

static const char [] __attribute__((used)) = "PMD_DRIVER_INFO=";

The  is arbitrary, as its static and not referenced.  The relevant bit is
the string value assigned to it.  The  is a json encoded string of the
extracted hardware support information pmdinfo found for the corresponding
object.  This C file is suitable for compilation and relocatable linking back
into the parent object file.  The result of this operation is that the object
string table now contains a string that will not e removed by stripping, whos
leading text (PMD_DRIVER_INFO) can be easily searched for at any time weather
the symbol referring to it is stripped or not.

C) Added a utilty called pmdinfo.py.  This python script, searches the
string table of the .rodata section of any provided ELF file looking for the
PMD_DRIVER_INFO prefix on a string.  When found, it will interpret the remainder
of the string as json, and output the hardware support for that ELF file (if
any).


This approach ticks most of the above boxes:
1) Impervious to stripping
2) Works on static and dynamic binaries
3) Human and script friendly
4) Allows for expansion

Because of (4) the other items should be pretty easy to implement, as its just a
matter of modifying the macros to export the info, pmdinfo to encode it to json,
and pmd_hw_support.py to read it.  I'm not adding them now, as theres alot of
rote work to do to get some of them in place (e.g. DPDK has no current global
VERSION macro, drivers don't have a consistent version scheme, command line
strings have to be built for each driver, etc).  But once this is accepted,
those items can be done as time allows and should be fairly easy to implement.

Change Notes:
v2)
 * Made the export macros a bit easier to expand
 * Added a macro to optionally export command line strings
 * Renamed utilties to be more appropriate
   (pmdinfo -> pmdinfogen, pmd_hw_support.py -> pmdinfo.py)
 * Added search capabilities to pmdinfo.py so that we search for libraries
   linked using DT_NEEDINFO entries.  We search DT_RUNPATH, LD_LIBRARY_PATH,
   /usr/lib and /lib
 * Added serch abilities if the specified binary to pmdinfo isn't found, we
   search LD_LIBRARY_PATH, /usr/lib and /lib
 * Added an option to pmdinfo.py to pretty-print hardware support info using the
   pci.ids database

v3)
 * Made table mode printing the default mode
 * Added a default path to the pci.ids file
 * Modifed pmdinfo to use python rather than python3
 * Cleaned up some changelog entries
 * Added an export for RTE_EAL_PMD_PATH
 * Added a plugin option to pmdinfo to scan for autoloaded DSO's

v4)
 * Modified the operation of the -p option. As much as I don't like implying
that autoloaded pmds are guaranteed to be there at run time, I'm having a hard
time seeing how we can avoid specifying the application file to scan for the
autoload directory.  Without it we can't determine which library the user means
in a multiversion installation
 * Cleaned up the help text
 * Added a rule for an install target for pmdinfo
 * Guarded against some tracebacks in pmdinfo
 * Use DT_NEEDED entries to get versioned libraries in -p mode
 * Fixed traceback that occurs on lack of input arguments
 * Fixed some erroneous macro usage in drivers that 

[dpdk-dev] [PATCH v2] eal: Fix resource leak while secondary process maps pci devices

2016-06-17 Thread David Marchand
On Thu, Jun 16, 2016 at 4:33 AM, Tetsuya Mukawa  wrote:
> This patch fixes resource leak of pci_uio_map_secondary().
> If pci_map_resource() succeeds but mapped address is different from an
> address primary process mapped, this should be error.
> Then the addresses secondary process mapped should be freed.
>
> Signed-off-by: Tetsuya Mukawa 

scripts/check-git-log.sh is not happy :

Wrong headline uppercase:
eal: Fix resource leak while secondary process maps pci devices
Wrong headline lowercase:
eal: Fix resource leak while secondary process maps pci devices
Headline too long:
eal: Fix resource leak while secondary process maps pci devices
Missing 'Fixes' tag:
eal: Fix resource leak while secondary process maps pci devices


checkpatch is not happy, but I think we can ignore it.

WARNING:LONG_LINE: line over 80 characters
#48: FILE: lib/librte_eal/common/eal_common_pci_uio.c:93:
+(size_t)uio_res->maps[j].size);


Anyways, looks good to me, Thomas, can you fix the commit logs of
those last 3 patches on eal ?
Thanks.

-- 
David Marchand


[dpdk-dev] [PATCH v2] eal: Fix wrong resource release while unmapping pci devices

2016-06-17 Thread David Marchand
On Thu, Jun 16, 2016 at 4:33 AM, Tetsuya Mukawa  wrote:
> This patch fixes wrong resource release of pci_uio_unmap().
> The 'path' member of mapped_pci_resource structure is allocated by
> primary process, but currently it will be freed by both primary
> and secondary process.
> The patch fixes to be freed by only primary process.
>
> Signed-off-by: Tetsuya Mukawa 

Wrong headline uppercase:
eal: Fix wrong resource release while unmapping pci devices
Wrong headline lowercase:
eal: Fix wrong resource release while unmapping pci devices
Missing 'Fixes' tag:
eal: Fix wrong resource release while unmapping pci devices

Then you can add my ack.


-- 
David Marchand


[dpdk-dev] [PATCH v2] eal: Fix wrong error checking while parsing device arguments

2016-06-17 Thread David Marchand
On Thu, Jun 16, 2016 at 4:33 AM, Tetsuya Mukawa  wrote:
> This patch fixes wrong error checking of rte_eal_parse_devargs_str().
> Currently, a return value of strdup() is wrongly checked.
>
> Fixes: 0fe11ec592b2 ("eal: add vdev init and uninit")
> Signed-off-by: Tetsuya Mukawa 

Forgot to pass this patch through scripts/check-git-log.sh script :

Wrong headline uppercase:
eal: Fix wrong error checking while parsing device arguments


With this fixed, you can add my ack.

-- 
David Marchand


[dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support

2016-06-17 Thread Jain, Deepak K


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Pablo de Lara
> Sent: Friday, June 17, 2016 12:25 PM
> To: dev at dpdk.org
> Cc: Doherty, Declan ; De Lara Guarch, Pablo
> 
> Subject: [dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support
> 
> The underlying library libsso for Snow3G PMD will be updated, to support bit-
> level operations.
> 
> This patchset updates the PMD to allow the user to perform crypto operation
> at bit-level. It also add some unit tests and updates the documentation.
> 
> This patchset depends on the following patchset:
> "Add new KASUMI SW PMD"
> (http://dpdk.org/ml/archives/dev/2016-June/041906.html)
> 
> NOTE: The library necessary for this PMD is not available yet, but it will be
> released in the next few days.
> 
> Changes in v2:
> - Include macros for IV/digest lengths
> - Refactored enqueue burst function to avoid duplication
> - Added cpu flags in crypto feature flags
> - Removed/refactored functions in unit tests
> 
> Pablo de Lara (11):
>   snow3g: rename libsso reference due to library update
>   doc: update build instructions for libsso_snow3g
>   snow3g: define IV/digest length macros
>   snow3g: support bit-level operations
>   snow3g: add missing feature flags
>   test: use new bit-level memcmp macro
>   test: fix buffer lengths for snow3G tests
>   test: add out-of-place crypto op tests for Snow3G PMD
>   test: add bit-level Snow3G UIA2 tests
>   test: add Snow3G UEA2 test with offset
>   test: refactor snow3g/kasumi tests
> 
>  app/test/test_cryptodev.c  | 803 
> ++---
>  app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++
>  config/common_base |   4 +-
>  doc/guides/cryptodevs/snow3g.rst   |  40 +-
>  drivers/crypto/snow3g/Makefile |  10 +-
>  drivers/crypto/snow3g/rte_snow3g_pmd.c | 216 --
>  mk/rte.app.mk  |   2 +-
>  scripts/test-build.sh  |   6 +-
>  8 files changed, 677 insertions(+), 511 deletions(-)
> 
> --
> 2.5.0

Series Acked-by: Jain, Deepak K 


[dpdk-dev] [PATCH v2 0/3] Add new KASUMI SW PMD

2016-06-17 Thread Jain, Deepak K


> -Original Message-
> From: De Lara Guarch, Pablo
> Sent: Friday, June 17, 2016 11:33 AM
> To: dev at dpdk.org
> Cc: Doherty, Declan ; De Lara Guarch, Pablo
> 
> Subject: [PATCH v2 0/3] Add new KASUMI SW PMD
> 
> Added new SW PMD which makes use of the libsso SW library, which
> provides wireless algorithms KASUMI F8 and F9 in software.
> 
> This PMD supports cipher-only, hash-only and chained operations ("cipher
> then hash" and "hash then cipher") of the following
> algorithms:
> - RTE_CRYPTO_SYM_CIPHER_KASUMI_F8
> - RTE_CRYPTO_SYM_AUTH_KASUMI_F9
> 
> The patchset also adds new macros to compare buffers at bit-level, since the
> PMD supports bit-level hash/cipher operations, and unit tests.
> 
> The patchset should be merged after the following patches/patchsets, as
> they are making changes in some of the files of this patchset:
> - rework crypto AES unit test
>   ("http://dpdk.org/ml/archives/dev/2016-June/041572.html;)
> - Refactor of debug information on cryptodev tests
>   ("http://dpdk.org/ml/archives/dev/2016-June/041623.html;)
> - doc: fix wrong supported feature table
>   ("http://dpdk.org/dev/patchwork/patch/13413/;)
> 
> NOTE: The library necessary for this PMD is not available yet, but it will be
> released in the next few days.
> 
> Changes in v2:
> - Fixed key length
> - Refactored enqueue burst function to avoid duplication
> - Added CPU flags in crypto feature flags
> - Added extra unit tets
> - Added documentation
> - Merged last patch in v1 into the first patch
> - Added new driver in MAINTAINERS
> 
> Pablo de Lara (3):
>   kasumi: add new KASUMI PMD
>   test: add new buffer comparison macros
>   test: add unit tests for KASUMI PMD
> 
> 
> --
> 2.5.0

Series Acked-by: Jain, Deepak K 


[dpdk-dev] [PATCH v2] mempool: replace c memcpy code semantics with optimized rte_memcpy

2016-06-17 Thread Olivier Matz
Hi Jerin,

On 06/03/2016 09:02 AM, Jerin Jacob wrote:
> On Thu, Jun 02, 2016 at 11:16:16PM +0200, Olivier MATZ wrote:
> Hi Olivier,
> 
>> This is probably more a measure of the pure CPU cost of the mempool
>> function, without considering the memory cache aspect. So, of course,
>> a real use-case test should be done to confirm or not that it increases
>> the performance. I'll manage to do a test and let you know the result.
> 
> OK
> 
> IMO, put rte_memcpy makes sense(this patch) as their no behavior change.
> However, if get rte_memcpy with behavioral changes makes sense some platform
> then we can enable it on conditional basics(I am OK with that)
> 
>>
>> By the way, not all drivers are allocating or freeing the mbufs by
>> bulk, so this modification would only affect these ones. What driver
>> are you using for your test?
> 
> I have tested with ThunderX nicvf pmd(uses the bulk mode).
> Recently sent out driver in ml for review

Just to let you know I do not forget this. I still need to
find some time to do a performance test.

Regards,
Olivier


[dpdk-dev] [PATCH v3 3/3] mempool: allow for user-owned mempool caches

2016-06-17 Thread Olivier Matz


On 06/16/2016 01:02 PM, Lazaros Koromilas wrote:
> The mempool cache is only available to EAL threads as a per-lcore
> resource. Change this so that the user can create and provide their own
> cache on mempool get and put operations. This works with non-EAL threads
> too. This commit introduces the new API calls:
> 
> rte_mempool_cache_create(size, socket_id)
> rte_mempool_cache_free(cache)
> rte_mempool_cache_flush(cache, mp)
> rte_mempool_default_cache(mp, lcore_id)

These new functions should be added in the .map file, else it will
break the compilation in with shared_lib=y.

> Changes the API calls:
> 
> rte_mempool_generic_put(mp, obj_table, n, cache, flags)
> rte_mempool_generic_get(mp, obj_table, n, cache, flags)
> 
> The cache-oblivious API calls use the per-lcore default local cache.
> 
> Signed-off-by: Lazaros Koromilas 
> ---
>  app/test/test_mempool.c  |  94 --
>  app/test/test_mempool_perf.c |  70 ++---
>  lib/librte_mempool/rte_mempool.c |  66 +++-
>  lib/librte_mempool/rte_mempool.h | 163 
> ---
>  4 files changed, 310 insertions(+), 83 deletions(-)
> 
> diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
> index 10d706f..723cd39 100644
> --- a/app/test/test_mempool.c
> +++ b/app/test/test_mempool.c
> @@ -79,6 +79,9 @@
>   printf("test failed at %s():%d\n", __func__, __LINE__); \
>   return -1;  \
>   } while (0)
> +#define LOG_ERR() do {   
> \
> + printf("test failed at %s():%d\n", __func__, __LINE__); \
> + } while (0)
>  

I see that the usage of this macro is always like this:

LOG_ERR();
ret = -1;
goto out;

What do you think of having:

#define LOG_ERR() do {  \
printf("test failed at %s():%d\n", __func__, __LINE__); \
} while (0)
#define RET_ERR() do { LOG_ERR(); return -1; } while (0)
#define GOTO_ERR() do { LOG_ERR(); ret = -1; goto out; } while (0)

Then use GOTO_ERR() when appropriate. It would also factorize
the printf.



[dpdk-dev] [PATCH v3 2/3] mempool: use bit flags instead of is_mp and is_mc

2016-06-17 Thread Olivier Matz
On 06/16/2016 01:02 PM, Lazaros Koromilas wrote:
> Re: [PATCH v3 2/3] mempool: use bit flags instead of is_mp and is_mc

There is a script to check the format of title. The underscores are
now forbidden, because it often reference function or variable names,
which is not ideal in titles.

$ ./scripts/check-git-log.sh
Wrong headline format:
mempool: use bit flags instead of is_mp and is_mc

I suggest something like:
mempool: use bit flags to set multi consumers or producers



[dpdk-dev] [PATCH v3 0/3] mempool: user-owned mempool caches

2016-06-17 Thread Olivier Matz
Hi Lazaros,


On 06/16/2016 01:02 PM, Lazaros Koromilas wrote:
> Updated version of the user-owned cache patchset.  It applies on top of
> the latest external mempool manager patches from David Hunt [1].
> 
> [1] http://dpdk.org/ml/archives/dev/2016-June/041479.html
> 
> v3 changes:
> 
>  * Deprecate specific mempool API calls instead of removing them.
>  * Split deprecation into a separate commit to limit noise.
>  * Fix cache flush by setting cache->len = 0 and make it inline.
>  * Remove cache->size == 0 checks and ensure size != 0 at creation.
>  * Fix tests to check if cache creation succeeded.
>  * Fix tests to free allocated resources on error.

Thanks for the update. The patchset looks good to me.
I have some minor comments for patch 2/3 and 3/3.

One more thing: would you mind adding some words in
doc/guides/prog_guide/mempool_lib.rst ?

Thanks,
Olivier


[dpdk-dev] [PATCH] arm64: change rte_memcpy to inline function

2016-06-17 Thread Thomas Monjalon
2016-05-19 17:56, Thomas Monjalon:
> 2016-05-19 21:48, Jianbo Liu:
> > On 13 May 2016 at 23:49, Thomas Monjalon  
> > wrote:
> > > 2016-05-10 14:01, Jianbo Liu:
> > >> Other APP may call rte_memcpy by function pointer,
> > >> so change it to an inline function.
> > >
> > > Any example in mind?
> > >
> > It's for ODP-DPDK.
> 
> Given that ODP is open (dataplane), you should also consider ppc64 and tile.
> 
> > >> --- a/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> > >> +++ b/lib/librte_eal/common/include/arch/arm/rte_memcpy_64.h
> > >> -#define rte_memcpy(d, s, n)  memcpy((d), (s), (n))
> > >> +static inline void *
> > >> +rte_memcpy(void *dst, const void *src, size_t n)
> > >> +{
> > >> + return memcpy(dst, src, n);
> > >> +}
> > >
> > > It has no sense if other archs (arm32, ppc64, tile) are not updated.
> > >
> > But it also an inline function on x86.
> 
> In x86, it was implemented as a function because there is some code.
> If you want to make sure it is always a function, even in the case
> of just calling memcpy from libc, you should put a doxygen comment in
> the generic part and adapt every archs.

no news?
a v2 would be welcome


[dpdk-dev] [PATCH v2 11/11] test: refactor snow3g/kasumi tests

2016-06-17 Thread Pablo de Lara
SNOW3G and KASUMI unit tests are very similar and
they were using duplicated code, so this commit
refactor and remove some of the duplicated functions.

Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c | 440 --
 config/common_base|   4 +-
 2 files changed, 152 insertions(+), 292 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7a8fda0..5039128 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1091,10 +1091,11 @@ test_AES_qat_all(void)

 /* * Snow3G Tests * */
 static int
-create_snow3g_hash_session(uint8_t dev_id,
+create_snow3g_kasumi_hash_session(uint8_t dev_id,
const uint8_t *key, const uint8_t key_len,
const uint8_t aad_len, const uint8_t auth_len,
-   enum rte_crypto_auth_operation op)
+   enum rte_crypto_auth_operation op,
+   enum rte_crypto_auth_algorithm algo)
 {
uint8_t hash_key[key_len];

@@ -1109,7 +1110,7 @@ create_snow3g_hash_session(uint8_t dev_id,
ut_params->auth_xform.next = NULL;

ut_params->auth_xform.auth.op = op;
-   ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
+   ut_params->auth_xform.auth.algo = algo;
ut_params->auth_xform.auth.key.length = key_len;
ut_params->auth_xform.auth.key.data = hash_key;
ut_params->auth_xform.auth.digest_length = auth_len;
@@ -1121,36 +1122,9 @@ create_snow3g_hash_session(uint8_t dev_id,
 }

 static int
-create_kasumi_hash_session(uint8_t dev_id,
-   const uint8_t *key, const uint8_t key_len,
-   const uint8_t aad_len, const uint8_t auth_len,
-   enum rte_crypto_auth_operation op)
-{
-   uint8_t hash_key[key_len];
-
-   struct crypto_unittest_params *ut_params = _params;
-
-   memcpy(hash_key, key, key_len);
-   TEST_HEXDUMP(stdout, "key:", key, key_len);
-   /* Setup Authentication Parameters */
-   ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
-   ut_params->auth_xform.next = NULL;
-
-   ut_params->auth_xform.auth.op = op;
-   ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_KASUMI_F9;
-   ut_params->auth_xform.auth.key.length = key_len;
-   ut_params->auth_xform.auth.key.data = hash_key;
-   ut_params->auth_xform.auth.digest_length = auth_len;
-   ut_params->auth_xform.auth.add_auth_data_length = aad_len;
-   ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
-   _params->auth_xform);
-   TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-   return 0;
-}
-
-static int
-create_kasumi_cipher_session(uint8_t dev_id,
+create_snow3g_kasumi_cipher_session(uint8_t dev_id,
enum rte_crypto_cipher_operation op,
+   enum rte_crypto_cipher_algorithm algo,
const uint8_t *key, const uint8_t key_len)
 {
uint8_t cipher_key[key_len];
@@ -1163,7 +1137,7 @@ create_kasumi_cipher_session(uint8_t dev_id,
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
ut_params->cipher_xform.next = NULL;

-   ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_KASUMI_F8;
+   ut_params->cipher_xform.cipher.algo = algo;
ut_params->cipher_xform.cipher.op = op;
ut_params->cipher_xform.cipher.key.data = cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;
@@ -1179,9 +1153,10 @@ create_kasumi_cipher_session(uint8_t dev_id,
 }

 static int
-create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
+create_snow3g_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
const unsigned cipher_len,
-   const unsigned cipher_offset)
+   const unsigned cipher_offset,
+   enum rte_crypto_cipher_algorithm algo)
 {
struct crypto_testsuite_params *ts_params = _params;
struct crypto_unittest_params *ut_params = _params;
@@ -1202,7 +1177,11 @@ create_kasumi_cipher_operation(const uint8_t *iv, const 
unsigned iv_len,
sym_op->m_src = ut_params->ibuf;

/* iv */
-   iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+   if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
+   iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
+   else
+   iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
+
sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
, iv_pad_len);

@@ -1219,9 +1198,10 @@ create_kasumi_cipher_operation(const uint8_t *iv, const 
unsigned iv_len,
 }

 static int
-create_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
+create_snow3g_kasumi_cipher_operation_oop(const uint8_t *iv, const uint8_t 
iv_len,
const unsigned cipher_len,
-   const unsigned cipher_offset)
+   const unsigned cipher_offset,
+   enum 

[dpdk-dev] [PATCH v2 10/11] test: add Snow3G UEA2 test with offset

2016-06-17 Thread Pablo de Lara
With the new libsso library, buffers can be encrypted/decrypted,
providing an offset in bits, so an extra unit test has been
added to cover this case.

Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c | 121 ++
 1 file changed, 121 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 546ae92..7a8fda0 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2553,6 +2553,118 @@ test_snow3g_encryption_oop(const struct 
snow3g_test_data *tdata)
return 0;
 }

+/* Shift right a buffer by "offset" bits, "offset" < 8 */
+static void
+buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
+{
+   uint8_t curr_byte, prev_byte;
+   uint32_t length_in_bytes = ceil_byte_length(length + offset);
+   uint8_t lower_byte_mask = (1 << offset) - 1;
+   unsigned i;
+
+   prev_byte = buffer[0];
+   buffer[0] >>= offset;
+
+   for (i = 1; i < length_in_bytes; i++) {
+   curr_byte = buffer[i];
+   buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
+   (curr_byte >> offset);
+   prev_byte = curr_byte;
+   }
+}
+
+static int
+test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
+{
+   struct crypto_testsuite_params *ts_params = _params;
+   struct crypto_unittest_params *ut_params = _params;
+   uint8_t *plaintext, *ciphertext;
+   int retval;
+   uint32_t plaintext_len;
+   uint32_t plaintext_pad_len;
+   uint8_t extra_offset = 4;
+   uint8_t *expected_ciphertext_shifted;
+
+   /* Create SNOW3G session */
+   retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
+   RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+   tdata->key.data, tdata->key.len);
+   if (retval < 0)
+   return retval;
+
+   ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+   ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+   TEST_ASSERT_NOT_NULL(ut_params->ibuf,
+   "Failed to allocate input buffer in mempool");
+   TEST_ASSERT_NOT_NULL(ut_params->obuf,
+   "Failed to allocate output buffer in mempool");
+
+   /* Clear mbuf payload */
+   memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+  rte_pktmbuf_tailroom(ut_params->ibuf));
+
+   plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
+   /*
+* Append data which is padded to a
+* multiple of the algorithms block size
+*/
+   plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+
+   plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
+   plaintext_pad_len);
+
+   rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
+
+   memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+   buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
+
+#ifdef RTE_APP_TEST_DEBUG
+   rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
+#endif
+   /* Create SNOW3G operation */
+   retval = create_snow3g_cipher_operation_oop(tdata->iv.data,
+   tdata->iv.len,
+   tdata->validCipherLenInBits.len,
+   tdata->validCipherOffsetLenInBits.len +
+   extra_offset);
+   if (retval < 0)
+   return retval;
+
+   ut_params->op = process_crypto_request(ts_params->valid_devs[0],
+   ut_params->op);
+   TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
+
+   ut_params->obuf = ut_params->op->sym->m_dst;
+   if (ut_params->obuf)
+   ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+   + tdata->iv.len;
+   else
+   ciphertext = plaintext;
+
+#ifdef RTE_APP_TEST_DEBUG
+   rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
+#endif
+
+   expected_ciphertext_shifted = rte_malloc(NULL,
+   ceil_byte_length(plaintext_len + extra_offset), 0);
+
+   TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
+   "failed to reserve memory for ciphertext shifted\n");
+
+   memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
+   ceil_byte_length(tdata->ciphertext.len));
+   buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
+   extra_offset);
+   /* Validate obuf */
+   TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
+   ciphertext,
+   expected_ciphertext_shifted,
+   tdata->validDataLenInBits.len,
+   extra_offset,
+   

[dpdk-dev] [PATCH v2 09/11] test: add bit-level Snow3G UIA2 tests

2016-06-17 Thread Pablo de Lara
Snow3G PMD supports now buffers that are non byte multiple,
so tests to cover this case have been added.

Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c  |  50 ++
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +
 2 files changed, 157 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 803f1f6..546ae92 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2048,6 +2048,24 @@ test_snow3g_hash_generate_test_case_3(void)
 }

 static int
+test_snow3g_hash_generate_test_case_4(void)
+{
+   return test_snow3g_authentication(_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_generate_test_case_5(void)
+{
+   return test_snow3g_authentication(_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_generate_test_case_6(void)
+{
+   return test_snow3g_authentication(_hash_test_case_6);
+}
+
+static int
 test_snow3g_hash_verify_test_case_1(void)
 {
return test_snow3g_authentication_verify(_hash_test_case_1);
@@ -2067,6 +2085,24 @@ test_snow3g_hash_verify_test_case_3(void)
 }

 static int
+test_snow3g_hash_verify_test_case_4(void)
+{
+   return test_snow3g_authentication_verify(_hash_test_case_4);
+}
+
+static int
+test_snow3g_hash_verify_test_case_5(void)
+{
+   return test_snow3g_authentication_verify(_hash_test_case_5);
+}
+
+static int
+test_snow3g_hash_verify_test_case_6(void)
+{
+   return test_snow3g_authentication_verify(_hash_test_case_6);
+}
+
+static int
 test_kasumi_hash_generate_test_case_1(void)
 {
return test_kasumi_authentication(_hash_test_case_1);
@@ -4079,12 +4115,26 @@ static struct unit_test_suite 
cryptodev_sw_snow3g_testsuite  = {
test_snow3g_hash_generate_test_case_2),
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_hash_generate_test_case_3),
+   /* Tests with buffers which length is not byte-aligned */
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_hash_generate_test_case_4),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_hash_generate_test_case_5),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_hash_generate_test_case_6),
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_hash_verify_test_case_1),
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_hash_verify_test_case_2),
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_hash_verify_test_case_3),
+   /* Tests with buffers which length is not byte-aligned */
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_hash_verify_test_case_4),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_hash_verify_test_case_5),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_hash_verify_test_case_6),
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_authenticated_encryption_test_case_1),
TEST_CASE_ST(ut_setup, ut_teardown,
diff --git a/app/test/test_cryptodev_snow3g_hash_test_vectors.h 
b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
index fe4906b..a8a47db 100644
--- a/app/test/test_cryptodev_snow3g_hash_test_vectors.h
+++ b/app/test/test_cryptodev_snow3g_hash_test_vectors.h
@@ -438,4 +438,111 @@ struct snow3g_hash_test_data snow3g_hash_test_case_3 = {
}
 };

+struct snow3g_hash_test_data snow3g_hash_test_case_4 = {
+   .key = {
+   .data = {
+   0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00,
+   0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48
+   },
+   .len = 16
+   },
+   .aad = {
+   .data = {
+   0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+   0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+   },
+   .len = 16
+   },
+   .plaintext = {
+   .data = {
+   0x6B, 0x22, 0x77, 0x37, 0x29, 0x6F, 0x39, 0x3C,
+   0x80, 0x79, 0x35, 0x3E, 0xDC, 0x87, 0xE2, 0xE8,
+   0x05, 0xD2, 0xEC, 0x49, 0xA4, 0xF2, 0xD8, 0xE0
+   },
+   .len = 189
+   },
+   .validAuthLenInBits = {
+   .len = 189
+   },
+   .validAuthOffsetLenInBits = {
+   .len = 128
+   },
+   .digest = {
+   .data = {0x2B, 0xCE, 0x18, 0x20},
+   .len  = 4
+   }
+};
+
+struct snow3g_hash_test_data snow3g_hash_test_case_5 = {
+   .key = {
+   .data = {
+   0xD4, 0x2F, 0x68, 0x24, 0x28, 0x20, 0x1C, 0xAF,
+   0xCD, 0x9F, 0x97, 0x94, 0x5E, 0x6D, 0xE7, 

[dpdk-dev] [PATCH v2 08/11] test: add out-of-place crypto op tests for Snow3G PMD

2016-06-17 Thread Pablo de Lara
Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 7dc5648..803f1f6 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4057,6 +4057,11 @@ static struct unit_test_suite 
cryptodev_sw_snow3g_testsuite  = {
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_encryption_test_case_5),

+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_encryption_test_case_1_oop),
+   TEST_CASE_ST(ut_setup, ut_teardown,
+   test_snow3g_decryption_test_case_1_oop),
+
/** Snow3G decrypt only (UEA2) */
TEST_CASE_ST(ut_setup, ut_teardown,
test_snow3g_decryption_test_case_1),
-- 
2.5.0



[dpdk-dev] [PATCH v2 07/11] test: fix buffer lengths for snow3G tests

2016-06-17 Thread Pablo de Lara
No padding was added in the input buffers for snow3G tests,
due to a wrong calculation of the length (should be multiple
of the block size). This fix takes into account the case
where the length is not byte multiple.

Fixes: 8bdf665fe6c0 ("app/test: add SNOW 3G")

Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c | 139 ++
 1 file changed, 66 insertions(+), 73 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3ff74cd..7dc5648 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1801,6 +1801,7 @@ test_snow3g_authentication(const struct 
snow3g_hash_test_data *tdata)

int retval;
unsigned plaintext_pad_len;
+   unsigned plaintext_len;
uint8_t *plaintext;

/* Create SNOW3G session */
@@ -1817,12 +1818,13 @@ test_snow3g_authentication(const struct 
snow3g_hash_test_data *tdata)
memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
rte_pktmbuf_tailroom(ut_params->ibuf));

+   plaintext_len = ceil_byte_length(tdata->plaintext.len);
/* Append data which is padded to a multiple of */
/* the algorithms block size */
-   plaintext_pad_len = tdata->plaintext.len >> 3;
+   plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
-   memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+   memcpy(plaintext, tdata->plaintext.data, plaintext_len);

/* Create SNOW3G opertaion */
retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
@@ -1858,6 +1860,7 @@ test_snow3g_authentication_verify(const struct 
snow3g_hash_test_data *tdata)

int retval;
unsigned plaintext_pad_len;
+   unsigned plaintext_len;
uint8_t *plaintext;

/* Create SNOW3G session */
@@ -1873,12 +1876,13 @@ test_snow3g_authentication_verify(const struct 
snow3g_hash_test_data *tdata)
memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
rte_pktmbuf_tailroom(ut_params->ibuf));

-   /* Append data which is padded to a multiple */
-   /* of the algorithms block size */
-   plaintext_pad_len = tdata->plaintext.len >> 3;
+   plaintext_len = ceil_byte_length(tdata->plaintext.len);
+   /* Append data which is padded to a multiple of */
+   /* the algorithms block size */
+   plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-   plaintext_pad_len);
-   memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
+   plaintext_pad_len);
+   memcpy(plaintext, tdata->plaintext.data, plaintext_len);

/* Create SNOW3G operation */
retval = create_snow3g_hash_operation(tdata->digest.data,
@@ -2386,7 +2390,8 @@ test_snow3g_encryption(const struct snow3g_test_data 
*tdata)

int retval;
uint8_t *plaintext, *ciphertext;
-   uint8_t plaintext_pad_len;
+   unsigned plaintext_pad_len;
+   unsigned plaintext_len;

/* Create SNOW3G session */
retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2401,16 +2406,13 @@ test_snow3g_encryption(const struct snow3g_test_data 
*tdata)
memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
   rte_pktmbuf_tailroom(ut_params->ibuf));

-   /*
-* Append data which is padded to a
-* multiple of the algorithms block size
-*/
-   /*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
-   plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
-
-   plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
-   plaintext_pad_len);
-   memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
+   plaintext_len = ceil_byte_length(tdata->plaintext.len);
+   /* Append data which is padded to a multiple of */
+   /* the algorithms block size */
+   plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+   plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+   plaintext_pad_len);
+   memcpy(plaintext, tdata->plaintext.data, plaintext_len);

TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);

@@ -2452,7 +2454,8 @@ test_snow3g_encryption_oop(const struct snow3g_test_data 
*tdata)
uint8_t *plaintext, *ciphertext;

int retval;
-   uint8_t plaintext_pad_len;
+   unsigned plaintext_pad_len;
+   unsigned plaintext_len;

/* Create SNOW3G session */
retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2473,20 +2476,14 @@ test_snow3g_encryption_oop(const struct 
snow3g_test_data *tdata)

[dpdk-dev] [PATCH v2 06/11] test: use new bit-level memcmp macro

2016-06-17 Thread Pablo de Lara
Instead of modifying the content of the buffers, to compare them
at bit-level, use the new macro TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT,
which does not make any modifications in the buffers.

Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c | 68 +--
 1 file changed, 12 insertions(+), 56 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 3199d6e..3ff74cd 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2387,8 +2387,6 @@ test_snow3g_encryption(const struct snow3g_test_data 
*tdata)
int retval;
uint8_t *plaintext, *ciphertext;
uint8_t plaintext_pad_len;
-   uint8_t lastByteValidBits = 8;
-   uint8_t lastByteMask = 0xFF;

/* Create SNOW3G session */
retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2434,19 +2432,13 @@ test_snow3g_encryption(const struct snow3g_test_data 
*tdata)
else
ciphertext = plaintext;

-   lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-   if (lastByteValidBits == 0)
-   lastByteValidBits = 8;
-   lastByteMask = lastByteMask << (8 - lastByteValidBits);
-   (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);

/* Validate obuf */
-   TEST_ASSERT_BUFFERS_ARE_EQUAL(
+   TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
ciphertext,
tdata->ciphertext.data,
-   tdata->ciphertext.len >> 3,
+   tdata->validDataLenInBits.len,
"Snow3G Ciphertext data not as expected");
return 0;
 }
@@ -2461,8 +2453,6 @@ test_snow3g_encryption_oop(const struct snow3g_test_data 
*tdata)

int retval;
uint8_t plaintext_pad_len;
-   uint8_t lastByteValidBits = 8;
-   uint8_t lastByteMask = 0xFF;

/* Create SNOW3G session */
retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2519,19 +2509,13 @@ test_snow3g_encryption_oop(const struct 
snow3g_test_data *tdata)
else
ciphertext = plaintext;

-   lastByteValidBits = (tdata->validDataLenInBits.len % 8);
-   if (lastByteValidBits == 0)
-   lastByteValidBits = 8;
-   lastByteMask = lastByteMask << (8 - lastByteValidBits);
-   (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
-
TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);

/* Validate obuf */
-   TEST_ASSERT_BUFFERS_ARE_EQUAL(
+   TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
ciphertext,
tdata->ciphertext.data,
-   tdata->ciphertext.len >> 3,
+   tdata->validDataLenInBits.len,
"Snow3G Ciphertext data not as expected");
return 0;
 }
@@ -2546,8 +2530,6 @@ static int test_snow3g_decryption(const struct 
snow3g_test_data *tdata)

uint8_t *plaintext, *ciphertext;
uint8_t ciphertext_pad_len;
-   uint8_t lastByteValidBits = 8;
-   uint8_t lastByteMask = 0xFF;

/* Create SNOW3G session */
retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2590,18 +2572,13 @@ static int test_snow3g_decryption(const struct 
snow3g_test_data *tdata)
+ tdata->iv.len;
else
plaintext = ciphertext;
-   lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-   if (lastByteValidBits == 0)
-   lastByteValidBits = 8;
-   lastByteMask = lastByteMask << (8 - lastByteValidBits);
-   (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;

TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);

/* Validate obuf */
-   TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
+   TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
tdata->plaintext.data,
-   tdata->plaintext.len >> 3,
+   tdata->validDataLenInBits.len,
"Snow3G Plaintext data not as expected");
return 0;
 }
@@ -2615,8 +2592,6 @@ static int test_snow3g_decryption_oop(const struct 
snow3g_test_data *tdata)

uint8_t *plaintext, *ciphertext;
uint8_t ciphertext_pad_len;
-   uint8_t lastByteValidBits = 8;
-   uint8_t lastByteMask = 0xFF;

/* Create SNOW3G session */
retval = create_snow3g_cipher_session(ts_params->valid_devs[0],
@@ -2673,18 +2648,13 @@ static int test_snow3g_decryption_oop(const struct 
snow3g_test_data *tdata)
+ tdata->iv.len;
else
plaintext = ciphertext;
-   lastByteValidBits = (tdata->validDataLenInBits.len  % 8);
-   if (lastByteValidBits == 0)
-   lastByteValidBits = 8;
-   lastByteMask = lastByteMask << (8 - 

[dpdk-dev] [PATCH v2 04/11] snow3g: support bit-level operations

2016-06-17 Thread Pablo de Lara
Underlying libsso_snow3g library now supports bit-level
operations, so PMD has been updated to allow them.

Signed-off-by: Pablo de Lara 
---
 doc/guides/cryptodevs/snow3g.rst   |   5 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 193 -
 2 files changed, 142 insertions(+), 56 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index a084cad..65628c6 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -51,8 +51,9 @@ Limitations
 ---

 * Chained mbufs are not supported.
-* Snow3g(UEA2) supported only if cipher length, cipher offset fields are 
byte-aligned.
-* Snow3g(UIA2) supported only if hash length, hash offset fields are 
byte-aligned.
+* Snow3g(UIA2) supported only if hash offset field is byte-aligned.
+* In-place bit-level operations for Snow3g(UEA2) are not supported
+  (if length and/or offset of data to be ciphered is not byte-aligned).

 Installation
 
diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c 
b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index 8bbee8a..b90d27d 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -206,14 +206,6 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
break;
}

-   if (((ops[i]->sym->cipher.data.length % BYTE_LEN) != 0)
-   || ((ops[i]->sym->cipher.data.offset
-   % BYTE_LEN) != 0)) {
-   ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-   SNOW3G_LOG_ERR("Data Length or offset");
-   break;
-   }
-
src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
(ops[i]->sym->cipher.data.offset >> 3);
dst[i] = ops[i]->sym->m_dst ?
@@ -233,6 +225,39 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,
return processed_ops;
 }

+/** Encrypt/decrypt mbuf (bit level function). */
+static uint8_t
+process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
+   struct snow3g_session *session)
+{
+   uint8_t *src, *dst;
+   uint8_t *IV;
+   uint32_t length_in_bits, offset_in_bits;
+
+   /* Sanity checks. */
+   if (unlikely(op->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
+   op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+   SNOW3G_LOG_ERR("iv");
+   return 0;
+   }
+
+   offset_in_bits = op->sym->cipher.data.offset;
+   src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
+   if (op->sym->m_dst == NULL) {
+   op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+   SNOW3G_LOG_ERR("bit-level in-place not supported\n");
+   return 0;
+   }
+   dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
+   IV = op->sym->cipher.iv.data;
+   length_in_bits = op->sym->cipher.data.length;
+
+   sso_snow3g_f8_1_buffer_bit(>pKeySched_cipher, IV,
+   src, dst, length_in_bits, offset_in_bits);
+
+   return 1;
+}
+
 /** Generate/verify hash from mbufs with same hash key. */
 static int
 process_snow3g_hash_op(struct rte_crypto_op **ops,
@@ -257,11 +282,10 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
break;
}

-   if (((ops[i]->sym->auth.data.length % BYTE_LEN) != 0)
-   || ((ops[i]->sym->auth.data.offset
-   % BYTE_LEN) != 0)) {
+   /* Data must be byte aligned */
+   if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
-   SNOW3G_LOG_ERR("Data Length or offset");
+   SNOW3G_LOG_ERR("Offset");
break;
}

@@ -301,10 +325,11 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
 /** Process a batch of crypto ops which shares the same session. */
 static int
 process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
-   struct snow3g_qp *qp, uint8_t num_ops)
+   struct snow3g_qp *qp, uint8_t num_ops,
+   uint16_t *accumulated_enqueued_ops)
 {
unsigned i;
-   unsigned processed_ops;
+   unsigned enqueued_ops, processed_ops;

switch (session->op) {
case SNOW3G_OP_ONLY_CIPHER:
@@ -344,7 +369,63 @@ process_ops(struct rte_crypto_op **ops, struct 
snow3g_session *session,
}
}

-   return processed_ops;
+   enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
+   (void **)ops, processed_ops);
+   qp->qp_stats.enqueued_count += enqueued_ops;
+   *accumulated_enqueued_ops += enqueued_ops;
+
+   return enqueued_ops;
+}
+
+/** Process a crypto op with length/offset 

[dpdk-dev] [PATCH v2 03/11] snow3g: define IV/digest length macros

2016-06-17 Thread Pablo de Lara
In order to avoid using magic numbers, macros for
the IV and digest lengths for Snow3G have been added.

Signed-off-by: Pablo de Lara 
---
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c 
b/drivers/crypto/snow3g/rte_snow3g_pmd.c
index f3e0e66..8bbee8a 100644
--- a/drivers/crypto/snow3g/rte_snow3g_pmd.c
+++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c
@@ -42,6 +42,8 @@

 #include "rte_snow3g_pmd_private.h"

+#define SNOW3G_IV_LENGTH 16
+#define SNOW3G_DIGEST_LENGTH 4
 #define SNOW3G_MAX_BURST 8
 #define BYTE_LEN 8

@@ -198,7 +200,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops,

for (i = 0; i < num_ops; i++) {
/* Sanity checks. */
-   if (ops[i]->sym->cipher.iv.length != 16) {
+   if (unlikely(ops[i]->sym->cipher.iv.length != 
SNOW3G_IV_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
SNOW3G_LOG_ERR("iv");
break;
@@ -243,13 +245,13 @@ process_snow3g_hash_op(struct rte_crypto_op **ops,
uint32_t length_in_bits;

for (i = 0; i < num_ops; i++) {
-   if (ops[i]->sym->auth.aad.length != 16) {
+   if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) 
{
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
SNOW3G_LOG_ERR("aad");
break;
}

-   if (ops[i]->sym->auth.digest.length != 4) {
+   if (unlikely(ops[i]->sym->auth.digest.length != 
SNOW3G_DIGEST_LENGTH)) {
ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
SNOW3G_LOG_ERR("digest");
break;
-- 
2.5.0



[dpdk-dev] [PATCH v2 02/11] doc: update build instructions for libsso_snow3g

2016-06-17 Thread Pablo de Lara
With the library update, the way to compile the library
has changed, so documentation reflects this change.
Also, the patch to fix the compilation issues present with gcc > 5.0
has been removed, as the issues have been fixed in the library.

Signed-off-by: Pablo de Lara 
---
 doc/guides/cryptodevs/snow3g.rst | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index 8564c9f..a084cad 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -62,34 +62,7 @@ the export controlled ``libsso_snow3g`` library, by 
requesting it from
 ``_,
 and compiling it on their system before building DPDK::

-   make -f Makefile_snow3g
-
-**Note**: If using a gcc version higher than 5.0, and compilation fails, apply 
the following patch:
-
-.. code-block:: diff
-
-   /libsso/src/snow3g/sso_snow3g.c
-
-   static inline void ClockFSM_4(sso_snow3gKeyState4_t *pCtx, __m128i *data)
-   {
-   __m128i F, R;
-   -uint32_t K, L;
-   +uint32_t K;
-   +/* Declare unused if SNOW3G_WSM/SNB are defined */
-   +uint32_t L __attribute__ ((unused)) = 0;
-
-F = _mm_add_epi32(pCtx->LFSR_X[15], pCtx->FSM_X[0]);
-R = _mm_xor_si128(pCtx->LFSR_X[5], pCtx->FSM_X[2]);
-
-   /libsso/include/sso_snow3g_internal.h
-
-   -inline void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   -inline void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   -inline void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, 
sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-   +void ClockFSM_1(sso_snow3gKeyState1_t *pCtx, uint32_t *data);
-   +void ClockLFSR_1(sso_snow3gKeyState1_t *pCtx);
-   +void sso_snow3gStateInitialize_1(sso_snow3gKeyState1_t * pCtx, 
sso_snow3g_key_schedule_t *pKeySched, uint8_t *pIV);
-
+   make snow3G

 Initialization
 --
-- 
2.5.0



[dpdk-dev] [PATCH v2 01/11] snow3g: rename libsso reference due to library update

2016-06-17 Thread Pablo de Lara
The underlying libsso library that SNOW3G PMD uses has been updated,
so now it is called libsso_snow3g. Also, the path to the library
has been renamed to reflect this changes (now called LIBSSO_SNOW3G_PATH).

Signed-off-by: Pablo de Lara 
---
 doc/guides/cryptodevs/snow3g.rst |  6 +++---
 drivers/crypto/snow3g/Makefile   | 10 +-
 mk/rte.app.mk|  2 +-
 scripts/test-build.sh|  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/doc/guides/cryptodevs/snow3g.rst b/doc/guides/cryptodevs/snow3g.rst
index c1098b1..8564c9f 100644
--- a/doc/guides/cryptodevs/snow3g.rst
+++ b/doc/guides/cryptodevs/snow3g.rst
@@ -58,7 +58,7 @@ Installation
 

 To build DPDK with the SNOW3G_PMD the user is required to download
-the export controlled ``libsso`` library, by requesting it from
+the export controlled ``libsso_snow3g`` library, by requesting it from
 ``_,
 and compiling it on their system before building DPDK::

@@ -96,10 +96,10 @@ Initialization

 In order to enable this virtual crypto PMD, user must:

-* Export the environmental variable LIBSSO_PATH with the path where
+* Export the environmental variable LIBSSO_SNOW3G_PATH with the path where
   the library was extracted.

-* Build the LIBSSO library (explained in Installation section).
+* Build the LIBSSO_SNOW3G library (explained in Installation section).

 * Set CONFIG_RTE_LIBRTE_PMD_SNOW3G=y in config/common_base.

diff --git a/drivers/crypto/snow3g/Makefile b/drivers/crypto/snow3g/Makefile
index ee58270..b86e608 100644
--- a/drivers/crypto/snow3g/Makefile
+++ b/drivers/crypto/snow3g/Makefile
@@ -30,8 +30,8 @@

 include $(RTE_SDK)/mk/rte.vars.mk

-ifeq ($(LIBSSO_PATH),)
-$(error "Please define LIBSSO_PATH environment variable")
+ifeq ($(LIBSSO_SNOW3G_PATH),)
+$(error "Please define LIBSSO_SNOW3G_PATH environment variable")
 endif

 # library name
@@ -48,9 +48,9 @@ LIBABIVER := 1
 EXPORT_MAP := rte_pmd_snow3g_version.map

 # external library include paths
-CFLAGS += -I$(LIBSSO_PATH)
-CFLAGS += -I$(LIBSSO_PATH)/include
-CFLAGS += -I$(LIBSSO_PATH)/build
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/include
+CFLAGS += -I$(LIBSSO_SNOW3G_PATH)/build

 # library source files
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += rte_snow3g_pmd.c
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 21bed09..0844115 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -133,7 +133,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_GCM)  += 
-L$(AESNI_MULTI_BUFFER_LIB_PATH)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO) += -lrte_pmd_null_crypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT)+= -lrte_pmd_qat -lcrypto
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -lrte_pmd_snow3g
-_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -L$(LIBSSO_PATH)/build -lsso
+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SNOW3G) += -L$(LIBSSO_SNOW3G_PATH)/build 
-lsso_snow3g
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -lrte_pmd_kasumi
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KASUMI) += -L$(LIBSSO_KASUMI_PATH)/build 
-lsso_kasumi
 endif # CONFIG_RTE_LIBRTE_CRYPTODEV
diff --git a/scripts/test-build.sh b/scripts/test-build.sh
index 0cfbdbc..31d5583 100755
--- a/scripts/test-build.sh
+++ b/scripts/test-build.sh
@@ -45,7 +45,7 @@ default_path=$PATH
 # - DPDK_DEP_ZLIB (y/[n])
 # - DPDK_MAKE_JOBS (int)
 # - DPDK_NOTIFY (notify-send)
-# - LIBSSO_PATH
+# - LIBSSO_SNOW3G_PATH
 # - LIBSSO_KASUMI_PATH
 . $(dirname $(readlink -e $0))/load-devel-config.sh

@@ -122,7 +122,7 @@ reset_env ()
unset DPDK_DEP_SZE
unset DPDK_DEP_ZLIB
unset AESNI_MULTI_BUFFER_LIB_PATH
-   unset LIBSSO_PATH
+   unset LIBSSO_SNOW3G_PATH
unset LIBSSO_KASUMI_PATH
unset PQOS_INSTALL_PATH
 }
@@ -168,7 +168,7 @@ config () #   
sed -ri   's,(PMD_AESNI_MB=)n,\1y,' $1/.config
test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
sed -ri  's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
-   test -z "$LIBSSO_PATH" || \
+   test -z "$LIBSSO_SNOW3G_PATH" || \
sed -ri 's,(PMD_SNOW3G=)n,\1y,' $1/.config
test -z "$LIBSSO_KASUMI_PATH" || \
sed -ri 's,(PMD_KASUMI=)n,\1y,' $1/.config
-- 
2.5.0



[dpdk-dev] [PATCH v2 00/11] Snow3G bit-level support

2016-06-17 Thread Pablo de Lara
The underlying library libsso for Snow3G PMD will be updated,
to support bit-level operations.

This patchset updates the PMD to allow the user to perform
crypto operation at bit-level. It also add some unit tests and
updates the documentation.

This patchset depends on the following patchset:
"Add new KASUMI SW PMD"
(http://dpdk.org/ml/archives/dev/2016-June/041906.html)

NOTE: The library necessary for this PMD is not available yet,
but it will be released in the next few days.

Changes in v2:
- Include macros for IV/digest lengths
- Refactored enqueue burst function to avoid duplication
- Added cpu flags in crypto feature flags
- Removed/refactored functions in unit tests

Pablo de Lara (11):
  snow3g: rename libsso reference due to library update
  doc: update build instructions for libsso_snow3g
  snow3g: define IV/digest length macros
  snow3g: support bit-level operations
  snow3g: add missing feature flags
  test: use new bit-level memcmp macro
  test: fix buffer lengths for snow3G tests
  test: add out-of-place crypto op tests for Snow3G PMD
  test: add bit-level Snow3G UIA2 tests
  test: add Snow3G UEA2 test with offset
  test: refactor snow3g/kasumi tests

 app/test/test_cryptodev.c  | 803 ++---
 app/test/test_cryptodev_snow3g_hash_test_vectors.h | 107 +++
 config/common_base |   4 +-
 doc/guides/cryptodevs/snow3g.rst   |  40 +-
 drivers/crypto/snow3g/Makefile |  10 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c | 216 --
 mk/rte.app.mk  |   2 +-
 scripts/test-build.sh  |   6 +-
 8 files changed, 677 insertions(+), 511 deletions(-)

-- 
2.5.0



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

2016-06-17 Thread Thomas Monjalon
2016-06-13 16:51, 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()..

Zyta, would you like to make a v4?


[dpdk-dev] [PATCH v13 1/3] mempool: support external mempool operations

2016-06-17 Thread Olivier Matz
Hi David,

 If you plan to do a v14 for this API comment, I'm wondering if the
 documentation could be slightly modified too. I think "external mempool
 manager" was the legacy name for the feature, but maybe it could be
 changed in "alternative mempool handlers" or "changing the mempool
 handler". I mean the word "external" is probably not appropriate now,
 especially if we add other handlers in the mempool lib.

 My 2 cents,
 Olivier
>>> I had not planned on doing another revision. And I think the term
>>> "External
>>> Mempool Manager" accurately describes the functionality, so I'd really
>>> prefer to leave it as it is.
>> I think there is no manager, just a default handler which can be changed.
>> I agree the documentation must be fixed.
> 
> OK, I have two suggestions to add into the mix.
> 1. mempool handler framework
> or simply
> 2. mempool handlers. (the alternative is implied). "The mempool handler
> feature", etc.

Option 2 is fine for me.

Thanks!



[dpdk-dev] [PATCH v13 1/3] mempool: support external mempool operations

2016-06-17 Thread Olivier Matz
Hi David,

While testing Lazaros' patch, I found an issue in this series.
I the test application is started with --no-huge, it does not work,
the mempool_autotest does not work. Please find the exaplanation
below:

On 06/16/2016 02:30 PM, David Hunt wrote:
> @@ -386,9 +352,9 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char 
> *vaddr,
>   int ret;
>  
>   /* create the internal ring if not already done */
> - if ((mp->flags & MEMPOOL_F_RING_CREATED) == 0) {
> - ret = rte_mempool_ring_create(mp);
> - if (ret < 0)
> + if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) {
> + ret = rte_mempool_ops_alloc(mp);
> + if (ret != 0)
>   return ret;
>   }
>  

Previously, the function rte_mempool_ring_create(mp) was setting the
MEMPOOL_F_RING_CREATED flag. Now it is not set. I think we could
set it just after the "return ret".

When started with --no-huge, the mempool memory is allocated in
several chunks (one per page), so it tries to allocate the ring for
each chunk.

Regards,
Olivier


[dpdk-dev] [PATCH] mk: mute build of test resources

2016-06-17 Thread Thomas Monjalon
> > The objcopy and tar commands were printed even in quiet mode.
> > They are now replaced by a simple line and still visible in verbose mode.
> > 
> > Fixes: ab64f5df8004 ("app/test: support resources externally linked")
> > Fixes: 66819e6c11d8 ("app/test: support resources archived by tar")
> > 
> > Signed-off-by: Thomas Monjalon 
> > ---
> Acked-by: Bruce Richardson 

Applied


[dpdk-dev] [PATCH v13 1/3] mempool: support external mempool operations

2016-06-17 Thread Hunt, David

On 17/6/2016 11:18 AM, Olivier Matz wrote:
> Hi David,
>
> While testing Lazaros' patch, I found an issue in this series.
> I the test application is started with --no-huge, it does not work,
> the mempool_autotest does not work. Please find the exaplanation
> below:
>
> On 06/16/2016 02:30 PM, David Hunt wrote:
>> @@ -386,9 +352,9 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char 
>> *vaddr,
>>  int ret;
>>   
>>  /* create the internal ring if not already done */
>> -if ((mp->flags & MEMPOOL_F_RING_CREATED) == 0) {
>> -ret = rte_mempool_ring_create(mp);
>> -if (ret < 0)
>> +if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) {
>> +ret = rte_mempool_ops_alloc(mp);
>> +if (ret != 0)
>>  return ret;
>>  }
>>   
> Previously, the function rte_mempool_ring_create(mp) was setting the
> MEMPOOL_F_RING_CREATED flag. Now it is not set. I think we could
> set it just after the "return ret".
>
> When started with --no-huge, the mempool memory is allocated in
> several chunks (one per page), so it tries to allocate the ring for
> each chunk.
>
> Regards,
> Olivier

OK, Will do.

 ret = rte_mempool_ops_alloc(mp);
 if (ret != 0)
 return ret;
+   mp->flags |= MEMPOOL_F_POOL_CREATED;

Rgds,
Dave.




[dpdk-dev] [PATCH v2 3/3] test: add unit tests for KASUMI PMD

2016-06-17 Thread Pablo de Lara
Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev.c  | 995 +++--
 app/test/test_cryptodev.h  |   1 +
 app/test/test_cryptodev_kasumi_hash_test_vectors.h | 260 ++
 app/test/test_cryptodev_kasumi_test_vectors.h  | 308 +++
 4 files changed, 1475 insertions(+), 89 deletions(-)
 create mode 100644 app/test/test_cryptodev_kasumi_hash_test_vectors.h
 create mode 100644 app/test/test_cryptodev_kasumi_test_vectors.h

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 1acb324..3199d6e 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -44,6 +44,8 @@
 #include "test_cryptodev.h"

 #include "test_cryptodev_aes.h"
+#include "test_cryptodev_kasumi_test_vectors.h"
+#include "test_cryptodev_kasumi_hash_test_vectors.h"
 #include "test_cryptodev_snow3g_test_vectors.h"
 #include "test_cryptodev_snow3g_hash_test_vectors.h"
 #include "test_cryptodev_gcm_test_vectors.h"
@@ -112,6 +114,16 @@ setup_test_string(struct rte_mempool *mpool,
return m;
 }

+/* Get number of bytes in X bits (rounding up) */
+static uint32_t
+ceil_byte_length(uint32_t num_bits)
+{
+   if (num_bits % 8)
+   return ((num_bits >> 3) + 1);
+   else
+   return (num_bits >> 3);
+}
+
 static struct rte_crypto_op *
 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
 {
@@ -213,6 +225,20 @@ testsuite_setup(void)
}
}

+   /* Create 2 KASUMI devices if required */
+   if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
+   nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
+   if (nb_devs < 2) {
+   for (i = nb_devs; i < 2; i++) {
+   TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
+   CRYPTODEV_NAME_KASUMI_PMD, NULL),
+   "Failed to create instance %u of"
+   " pmd : %s",
+   i, CRYPTODEV_NAME_KASUMI_PMD);
+   }
+   }
+   }
+
/* Create 2 NULL devices if required */
if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
nb_devs = rte_cryptodev_count_devtype(
@@ -1093,6 +1119,146 @@ create_snow3g_hash_session(uint8_t dev_id,
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
return 0;
 }
+
+static int
+create_kasumi_hash_session(uint8_t dev_id,
+   const uint8_t *key, const uint8_t key_len,
+   const uint8_t aad_len, const uint8_t auth_len,
+   enum rte_crypto_auth_operation op)
+{
+   uint8_t hash_key[key_len];
+
+   struct crypto_unittest_params *ut_params = _params;
+
+   memcpy(hash_key, key, key_len);
+   TEST_HEXDUMP(stdout, "key:", key, key_len);
+   /* Setup Authentication Parameters */
+   ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
+   ut_params->auth_xform.next = NULL;
+
+   ut_params->auth_xform.auth.op = op;
+   ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_KASUMI_F9;
+   ut_params->auth_xform.auth.key.length = key_len;
+   ut_params->auth_xform.auth.key.data = hash_key;
+   ut_params->auth_xform.auth.digest_length = auth_len;
+   ut_params->auth_xform.auth.add_auth_data_length = aad_len;
+   ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
+   _params->auth_xform);
+   TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+   return 0;
+}
+
+static int
+create_kasumi_cipher_session(uint8_t dev_id,
+   enum rte_crypto_cipher_operation op,
+   const uint8_t *key, const uint8_t key_len)
+{
+   uint8_t cipher_key[key_len];
+
+   struct crypto_unittest_params *ut_params = _params;
+
+   memcpy(cipher_key, key, key_len);
+
+   /* Setup Cipher Parameters */
+   ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
+   ut_params->cipher_xform.next = NULL;
+
+   ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_KASUMI_F8;
+   ut_params->cipher_xform.cipher.op = op;
+   ut_params->cipher_xform.cipher.key.data = cipher_key;
+   ut_params->cipher_xform.cipher.key.length = key_len;
+
+   TEST_HEXDUMP(stdout, "key:", key, key_len);
+
+   /* Create Crypto session */
+   ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
+   _params->
+   cipher_xform);
+   TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
+   return 0;
+}
+
+static int
+create_kasumi_cipher_operation(const uint8_t *iv, const unsigned iv_len,
+   const unsigned cipher_len,
+   const unsigned cipher_offset)
+{
+   struct crypto_testsuite_params *ts_params = _params;
+   

[dpdk-dev] [PATCH v2 2/3] test: add new buffer comparison macros

2016-06-17 Thread Pablo de Lara
In order to compare buffers with length and offset in bits,
new macros have been created, which use the previous compare function
to compare full bytes and then, compare first and last bytes of
each buffer separately.

Signed-off-by: Pablo de Lara 
---
 app/test/test.h | 57 -
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/app/test/test.h b/app/test/test.h
index 8ddde23..81828be 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -65,7 +65,7 @@
}\
 } while (0)

-
+/* Compare two buffers (length in bytes) */
 #define TEST_ASSERT_BUFFERS_ARE_EQUAL(a, b, len,  msg, ...) do {   \
if (memcmp(a, b, len)) {\
printf("TestCase %s() line %d failed: "  \
@@ -75,6 +75,61 @@
}\
 } while (0)

+/* Compare two buffers with offset (length and offset in bytes) */
+#define TEST_ASSERT_BUFFERS_ARE_EQUAL_OFFSET(a, b, len, off, msg, ...) do { \
+   const uint8_t *_a_with_off = (const uint8_t *)a + off;  \
+   const uint8_t *_b_with_off = (const uint8_t *)b + off;  \
+   TEST_ASSERT_BUFFERS_ARE_EQUAL(_a_with_off, _b_with_off, len, msg);  \
+} while (0)
+
+/* Compare two buffers (length in bits) */
+#define TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(a, b, len, msg, ...) do {\
+   uint8_t _last_byte_a, _last_byte_b;   \
+   uint8_t _last_byte_mask, _last_byte_bits;  \
+   TEST_ASSERT_BUFFERS_ARE_EQUAL(a, b, (len >> 3), msg); \
+   if (len % 8) {  \
+   _last_byte_bits = len % 8;   \
+   _last_byte_mask = ~((1 << (8 - _last_byte_bits)) - 1); \
+   _last_byte_a = ((const uint8_t *)a)[len >> 3];\
+   _last_byte_b = ((const uint8_t *)b)[len >> 3];\
+   _last_byte_a &= _last_byte_mask; \
+   _last_byte_b &= _last_byte_mask;\
+   if (_last_byte_a != _last_byte_b) {  \
+   printf("TestCase %s() line %d failed: "  \
+   msg "\n", __func__, __LINE__, ##__VA_ARGS__);\
+   TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__);\
+   return TEST_FAILED;  \
+   }\
+   }\
+} while (0)
+
+/* Compare two buffers with offset (length and offset in bits) */
+#define TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(a, b, len, off, msg, ...) do 
{\
+   uint8_t _first_byte_a, _first_byte_b; \
+   uint8_t _first_byte_mask, _first_byte_bits;   \
+   uint32_t _len_without_first_byte = (off % 8) ?   \
+   len - (8 - (off % 8)) :   \
+   len;  \
+   uint32_t _off_in_bytes = (off % 8) ? (off >> 3) + 1 : (off >> 3); \
+   const uint8_t *_a_with_off = (const uint8_t *)a + _off_in_bytes;  \
+   const uint8_t *_b_with_off = (const uint8_t *)b + _off_in_bytes;  \
+   TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(_a_with_off, _b_with_off,   \
+   _len_without_first_byte, msg);\
+   if (off % 8) {\
+   _first_byte_bits = 8 - (off % 8); \
+   _first_byte_mask = (1 << _first_byte_bits) - 1;   \
+   _first_byte_a = *(_a_with_off - 1);   \
+   _first_byte_b = *(_b_with_off - 1);   \
+   _first_byte_a &= _first_byte_mask;\
+   _first_byte_b &= _first_byte_mask;\
+   if (_first_byte_a != _first_byte_b) { \
+   printf("TestCase %s() line %d failed: "   \
+   msg "\n", __func__, __LINE__, ##__VA_ARGS__); \
+   TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \
+   return TEST_FAILED;   \
+   } \
+   } \
+} while (0)

 #define TEST_ASSERT_NOT_EQUAL(a, b, msg, ...) do {   \
if (!(a != b)) { \
-- 
2.5.0



[dpdk-dev] [PATCH v2 1/3] kasumi: add new KASUMI PMD

2016-06-17 Thread Pablo de Lara
Added new SW PMD which makes use of the libsso_kasumi SW library,
which provides wireless algorithms KASUMI F8 and F9
in software.

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

Signed-off-by: Pablo de Lara 
---
 MAINTAINERS  |   5 +
 config/common_base   |   6 +
 config/defconfig_i686-native-linuxapp-gcc|   5 +
 config/defconfig_i686-native-linuxapp-icc|   5 +
 doc/guides/cryptodevs/index.rst  |   3 +-
 doc/guides/cryptodevs/kasumi.rst |  97 
 doc/guides/cryptodevs/overview.rst   |  79 +--
 doc/guides/rel_notes/release_16_07.rst   |   5 +
 drivers/crypto/Makefile  |   1 +
 drivers/crypto/kasumi/Makefile   |  64 +++
 drivers/crypto/kasumi/rte_kasumi_pmd.c   | 658 +++
 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c   | 344 
 drivers/crypto/kasumi/rte_kasumi_pmd_private.h   | 106 
 drivers/crypto/kasumi/rte_pmd_kasumi_version.map |   3 +
 examples/l2fwd-crypto/main.c |  10 +-
 lib/librte_cryptodev/rte_crypto_sym.h|   6 +-
 lib/librte_cryptodev/rte_cryptodev.h |   3 +
 mk/rte.app.mk|   2 +
 scripts/test-build.sh|   4 +
 19 files changed, 1362 insertions(+), 44 deletions(-)
 create mode 100644 doc/guides/cryptodevs/kasumi.rst
 create mode 100644 drivers/crypto/kasumi/Makefile
 create mode 100644 drivers/crypto/kasumi/rte_kasumi_pmd.c
 create mode 100644 drivers/crypto/kasumi/rte_kasumi_pmd_ops.c
 create mode 100644 drivers/crypto/kasumi/rte_kasumi_pmd_private.h
 create mode 100644 drivers/crypto/kasumi/rte_pmd_kasumi_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 3e6b70c..2e0270f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -396,6 +396,11 @@ M: Pablo de Lara 
 F: drivers/crypto/snow3g/
 F: doc/guides/cryptodevs/snow3g.rst

+KASUMI PMD
+M: Pablo de Lara 
+F: drivers/crypto/kasumi/
+F: doc/guides/cryptodevs/kasumi.rst
+
 Null Crypto PMD
 M: Declan Doherty 
 F: drivers/crypto/null/
diff --git a/config/common_base b/config/common_base
index b9ba405..fcf91c6 100644
--- a/config/common_base
+++ b/config/common_base
@@ -370,6 +370,12 @@ CONFIG_RTE_LIBRTE_PMD_SNOW3G=n
 CONFIG_RTE_LIBRTE_PMD_SNOW3G_DEBUG=n

 #
+# Compile PMD for KASUMI device
+#
+CONFIG_RTE_LIBRTE_PMD_KASUMI=n
+CONFIG_RTE_LIBRTE_PMD_KASUMI_DEBUG=n
+
+#
 # Compile PMD for NULL Crypto device
 #
 CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y
diff --git a/config/defconfig_i686-native-linuxapp-gcc 
b/config/defconfig_i686-native-linuxapp-gcc
index c32859f..ba07259 100644
--- a/config/defconfig_i686-native-linuxapp-gcc
+++ b/config/defconfig_i686-native-linuxapp-gcc
@@ -60,3 +60,8 @@ CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n
 # AES-NI GCM PMD is not supported on 32-bit
 #
 CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n
+
+#
+# KASUMI PMD is not supported on 32-bit
+#
+CONFIG_RTE_LIBRTE_PMD_KASUMI=n
diff --git a/config/defconfig_i686-native-linuxapp-icc 
b/config/defconfig_i686-native-linuxapp-icc
index cde9d96..850e536 100644
--- a/config/defconfig_i686-native-linuxapp-icc
+++ b/config/defconfig_i686-native-linuxapp-icc
@@ -60,3 +60,8 @@ CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n
 # AES-NI GCM PMD is not supported on 32-bit
 #
 CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n
+
+#
+# KASUMI PMD is not supported on 32-bit
+#
+CONFIG_RTE_LIBRTE_PMD_KASUMI=n
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index a3f11f3..9616de1 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -38,6 +38,7 @@ Crypto Device Drivers
 overview
 aesni_mb
 aesni_gcm
+kasumi
 null
 snow3g
-qat
\ No newline at end of file
+qat
diff --git a/doc/guides/cryptodevs/kasumi.rst b/doc/guides/cryptodevs/kasumi.rst
new file mode 100644
index 000..407dbe2
--- /dev/null
+++ b/doc/guides/cryptodevs/kasumi.rst
@@ -0,0 +1,97 @@
+..  BSD LICENSE
+Copyright(c) 2016 Intel Corporation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the
+distribution.
+* Neither the name of Intel Corporation nor the names of its
+contributors may be used to endorse or promote products derived
+from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE 

[dpdk-dev] [RFC] librte_vhost: Add unix domain socket fd registration

2016-06-17 Thread Aaron Conole
Prior to this commit, the only way to add a vhost-user socket to the
system is by relying on librte_vhost to open the unix domain socket and
add it to the unix socket list.  This is problematic for applications
which would like to set the permissions, or applications which are not
directly allowed to open sockets due to policy restrictions.

This patch provides a new API and ABI to allow application developers to
acquire the unix domain socket via whatever mechanism fits and pass it
to the vhost driver registration process.

Signed-off-by: Aaron Conole 
---
 doc/guides/prog_guide/vhost_lib.rst  |  8 +
 lib/librte_vhost/rte_vhost_version.map   |  6 
 lib/librte_vhost/rte_virtio_net.h|  6 
 lib/librte_vhost/vhost_user/vhost-net-user.c | 47 ++--
 4 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/doc/guides/prog_guide/vhost_lib.rst 
b/doc/guides/prog_guide/vhost_lib.rst
index 48e1fff..22d0c6d 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -49,6 +49,14 @@ Vhost API Overview
   For vhost-user, a Unix domain socket server will be created with the 
parameter as
   the local socket path.

+  Alternately, rte_vhost_driver_register_socket registers a unix domain
+  socket into the system.
+  This socket descriptor should be acquired by the host application through
+  some mechanism (either fd passing or by performing the unix domain socket
+  allocation).
+  The file descriptor passed in this way must still be a Unix domain socket
+  server.
+
 *   Vhost session start

   rte_vhost_driver_session_start starts the vhost session loop.
diff --git a/lib/librte_vhost/rte_vhost_version.map 
b/lib/librte_vhost/rte_vhost_version.map
index 3d8709e..fe58967 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -20,3 +20,9 @@ DPDK_2.1 {
rte_vhost_driver_unregister;

 } DPDK_2.0;
+
+DPDK_16.7 {
+   global:
+
+   rte_vhost_driver_register_socket;
+} DPDK_2.1;
diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 600b20b..d2959ff 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -236,6 +236,12 @@ int rte_vhost_enable_guest_notification(struct virtio_net 
*dev, uint16_t queue_i
 /* Register vhost driver. dev_name could be different for multiple instance 
support. */
 int rte_vhost_driver_register(const char *dev_name);

+/* Register vhost driver using the provided unix domain socket. The socket MUST
+ * already be fully created and in a listening state (by calling listen()).
+ */
+int rte_vhost_driver_register_socket(const char *dev_name,
+   int vhost_unix_socket);
+
 /* Unregister vhost driver. This is only meaningful to vhost user. */
 int rte_vhost_driver_unregister(const char *dev_name);

diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c 
b/lib/librte_vhost/vhost_user/vhost-net-user.c
index df2bd64..0fe72db 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -446,45 +446,58 @@ vserver_message_handler(int connfd, void *dat, int 
*remove)
}
 }

+
 /**
- * Creates and initialise the vhost server.
+ * Appends a socket to the vhost server polling list
  */
 int
-rte_vhost_driver_register(const char *path)
+rte_vhost_driver_register_socket(const char *dev_name, int vhost_unix_socket)
 {
struct vhost_server *vserver;

-   pthread_mutex_lock(_vhost_server.server_mutex);
-
-   if (g_vhost_server.vserver_cnt == MAX_VHOST_SERVER) {
-   RTE_LOG(ERR, VHOST_CONFIG,
-   "error: the number of servers reaches maximum\n");
-   pthread_mutex_unlock(_vhost_server.server_mutex);
-   return -1;
-   }
-
vserver = calloc(sizeof(struct vhost_server), 1);
if (vserver == NULL) {
-   pthread_mutex_unlock(_vhost_server.server_mutex);
return -1;
}

-   vserver->listenfd = uds_socket(path);
-   if (vserver->listenfd < 0) {
+   vserver->listenfd = vhost_unix_socket;
+   vserver->path = strdup(dev_name);
+   if (!vserver->path) {
free(vserver);
-   pthread_mutex_unlock(_vhost_server.server_mutex);
return -1;
}

-   vserver->path = strdup(path);
+   pthread_mutex_lock(_vhost_server.server_mutex);
+
+   if (g_vhost_server.vserver_cnt == MAX_VHOST_SERVER) {
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "error: the number of servers reaches maximum\n");
+   pthread_mutex_unlock(_vhost_server.server_mutex);
+   free(vserver->path);
+   free(vserver);
+   return -1;
+   }

fdset_add(_vhost_server.fdset, vserver->listenfd,
vserver_new_vq_conn, NULL, vserver);


[dpdk-dev] [PATCH] fm10k: fix VF cannot receive broadcast traffic

2016-06-17 Thread Bruce Richardson
On Tue, Jun 14, 2016 at 05:03:57AM +, Chen, Jing D wrote:
> Hi,
> 
> > -Original Message-
> > From: Wang, Xiao W
> > Sent: Monday, June 06, 2016 5:01 PM
> > To: Chen, Jing D 
> > Cc: dev at dpdk.org; Wang, Xiao W 
> > Subject: [PATCH] fm10k: fix VF cannot receive broadcast traffic
> > 
> > When app tries promisc/allmulti setting, fm10k will check if a valid glort
> > is acquired, if not then exit without doing anything. It's a long journey
> > for VF to acquire glort info from VF to PF mailbox, PF to switch mailbox.
> > It could be a long interval that's out of DPDK's control. Thus, app may
> > fail on promisc/allmulti setting in VF. In fact, we don't need a valid
> > glort value in VF, so this patch just skips the glort check for VF.
> > 
> > Fixes: df02ba864695 ("fm10k: support promiscuous mode")
> > 
> > Signed-off-by: Wang Xiao W 
> Acked-by: Jing Chen 

Applied to dpdk-next-net/rel_16_07

/Bruce


[dpdk-dev] [PATCH v3] ethdev: fix DCB config issue on ixgbe

2016-06-17 Thread De Lara Guarch, Pablo


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Wenzhuo Lu
> Sent: Thursday, May 05, 2016 10:34 PM
> To: dev at dpdk.org
> Cc: Lu, Wenzhuo
> Subject: [dpdk-dev] [PATCH v3] ethdev: fix DCB config issue on ixgbe
> 
> An issue is found that DCB cannot be configured on ixgbe
> NICs. It's said the TX queue number is not right.
> On ixgbe the max TX queue number is not fixed, it depends
> on the multi-queue mode. The API rte_eth_dev_configure
> should be used to configure this mode. But the input of
> this API includes TX queue number. The problem is before
> the mode is configured, we cannot decide the TX queue
> number.
> 
> This patch adds an API to configure RX & TX multi-queue mode
> separately. After the mode is configured, the max RX & TX
> queue number is decided. Then we can set the appropriate
> RX & TX queue number.
> 
> Fixes: 96c0450dff86 (ixgbe: fix dropping packets from unsupported Tx
> queues)
> Signed-off-by: Wenzhuo Lu 

Acked-by: Pablo de Lara 


[dpdk-dev] [PATCH] fm10k: fix VF cannot receive broadcast traffic

2016-06-17 Thread Bruce Richardson
On Mon, Jun 06, 2016 at 05:00:47PM +0800, Wang Xiao W wrote:
> When app tries promisc/allmulti setting, fm10k will check if a valid glort
> is acquired, if not then exit without doing anything. It's a long journey
> for VF to acquire glort info from VF to PF mailbox, PF to switch mailbox.
> It could be a long interval that's out of DPDK's control. Thus, app may

I think the use of "thus" here is wrong, as I suspect that the failure is not
due to the "long interval that's out of DPDK's control", but instead due to
not having a valid glort.

> fail on promisc/allmulti setting in VF. In fact, we don't need a valid
> glort value in VF, so this patch just skips the glort check for VF.
> 
> Fixes: df02ba864695 ("fm10k: support promiscuous mode")
> 
> Signed-off-by: Wang Xiao W 

I rework this commit message for you on apply. Please check the updated version
when done.

/Bruce



[dpdk-dev] [PATCH v13 1/3] mempool: support external mempool operations

2016-06-17 Thread Thomas Monjalon
2016-06-17 09:42, Hunt, David:
> 
> On 17/6/2016 9:08 AM, Olivier Matz wrote:
> > Hi David,
> >
> > On 06/17/2016 08:58 AM, Hunt, David wrote:
> >> A comment below:
> >>
> >> On 16/6/2016 1:30 PM, David Hunt wrote:
> >>> +/**
> >>> + * Set the ops of a mempool.
> >>> + *
> >>> + * This can only be done on a mempool that is not populated, i.e.
> >>> just after
> >>> + * a call to rte_mempool_create_empty().
> >>> + *
> >>> + * @param mp
> >>> + *   Pointer to the memory pool.
> >>> + * @param name
> >>> + *   Name of the ops structure to use for this mempool.
> >> + * @param pool_config
> >> + *   Opaque data that can be used by the ops functions.
> >>> + * @return
> >>> + *   - 0: Success; the mempool is now using the requested ops functions.
> >>> + *   - -EINVAL - Invalid ops struct name provided.
> >>> + *   - -EEXIST - mempool already has an ops struct assigned.
> >>> + */
> >>> +int
> >>> +rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
> >>> +void *pool_config);
> >>> +
> >>
> > The changes related to the pool_config look good to me.
> >
> > If you plan to do a v14 for this API comment, I'm wondering if the
> > documentation could be slightly modified too. I think "external mempool
> > manager" was the legacy name for the feature, but maybe it could be
> > changed in "alternative mempool handlers" or "changing the mempool
> > handler". I mean the word "external" is probably not appropriate now,
> > especially if we add other handlers in the mempool lib.
> >
> > My 2 cents,
> > Olivier
> 
> I had not planned on doing another revision. And I think the term "External
> Mempool Manager" accurately describes the functionality, so I'd really
> prefer to leave it as it is.

I think there is no manager, just a default handler which can be changed.
I agree the documentation must be fixed.


[dpdk-dev] [PATCH] ixgbe: avoid unnessary break when checking at the tail of rx hwring

2016-06-17 Thread Bruce Richardson
On Mon, Mar 28, 2016 at 04:48:17PM +0800, Jianbo Liu wrote:
> Hi Qian,
> 
> On 28 March 2016 at 10:30, Xu, Qian Q  wrote:
> > Jianbo
> > Could you tell me the case that can reproduce the issue? We can help 
> > evaluate the impact of performance on ixgbe, but I'm not sure how to check 
> > if your patch really fix a problem because I don?t know how to reproduce 
> > the problem! Could you first teach me on how to reproduce your issue? Or 
> > you may not reproduce it by yourself?
> >
> It is more an refactoring to original design than fixing an issue. So
> I don't know how to reproduce either.
> Can you use your usual performance testing cases first, and see if
> there is any impact or improvement?
> 

Since there is no further discussion or update on this patch, I'm going to mark
it as rejected in patchwork, rather than have it live on as a zombie patch.

If this change is wanted for 16.11 or any subsequent release, please resubmit
it for consideration with any performance data justifications (and a reference
back to this thread).

Thanks,
/Bruce


[dpdk-dev] [PATCH] mk: mute build of test resources

2016-06-17 Thread Bruce Richardson
On Fri, Jun 17, 2016 at 12:01:09AM +0200, Thomas Monjalon wrote:
> The objcopy and tar commands were printed even in quiet mode.
> They are now replaced by a simple line and still visible in verbose mode.
> 
> Fixes: ab64f5df8004 ("app/test: support resources externally linked")
> Fixes: 66819e6c11d8 ("app/test: support resources archived by tar")
> 
> Signed-off-by: Thomas Monjalon 
> ---
Acked-by: Bruce Richardson 



[dpdk-dev] [PATCH v13 1/3] mempool: support external mempool operations

2016-06-17 Thread Hunt, David


On 17/6/2016 10:09 AM, Thomas Monjalon wrote:
> 2016-06-17 09:42, Hunt, David:
>> On 17/6/2016 9:08 AM, Olivier Matz wrote:
>>> Hi David,
>>>
>>> On 06/17/2016 08:58 AM, Hunt, David wrote:
 A comment below:

 On 16/6/2016 1:30 PM, David Hunt wrote:
> +/**
> + * Set the ops of a mempool.
> + *
> + * This can only be done on a mempool that is not populated, i.e.
> just after
> + * a call to rte_mempool_create_empty().
> + *
> + * @param mp
> + *   Pointer to the memory pool.
> + * @param name
> + *   Name of the ops structure to use for this mempool.
 + * @param pool_config
 + *   Opaque data that can be used by the ops functions.
> + * @return
> + *   - 0: Success; the mempool is now using the requested ops functions.
> + *   - -EINVAL - Invalid ops struct name provided.
> + *   - -EEXIST - mempool already has an ops struct assigned.
> + */
> +int
> +rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
> +void *pool_config);
> +
>>> The changes related to the pool_config look good to me.
>>>
>>> If you plan to do a v14 for this API comment, I'm wondering if the
>>> documentation could be slightly modified too. I think "external mempool
>>> manager" was the legacy name for the feature, but maybe it could be
>>> changed in "alternative mempool handlers" or "changing the mempool
>>> handler". I mean the word "external" is probably not appropriate now,
>>> especially if we add other handlers in the mempool lib.
>>>
>>> My 2 cents,
>>> Olivier
>> I had not planned on doing another revision. And I think the term "External
>> Mempool Manager" accurately describes the functionality, so I'd really
>> prefer to leave it as it is.
> I think there is no manager, just a default handler which can be changed.
> I agree the documentation must be fixed.

OK, I have two suggestions to add into the mix.
1. mempool handler framework
or simply
2. mempool handlers. (the alternative is implied). "The mempool handler 
feature", etc.

Thoughts?
David.







[dpdk-dev] [PATCH] qat: fix for VFs not getting recognized

2016-06-17 Thread Thomas Monjalon
2016-06-16 16:25, Jain, Deepak K:
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > 2016-06-16 16:29, Jain, Deepak K:
> > > Due to addition of CLASS_ID in EAL, class_id is amended into the code.
> > 
> > Why the VF is not recognized?
> > The class id should not be mandatory.
> 
> Without the change proposed, QuickAssist Devices were not visible and hence 
> tests were not running.
> Seems like changes in EAL especially where class_id is added affected the 
> QuickAssist tests.
> With this change, QuickAssist devices are visible during tests and tests 
> working fine.

Which tests?
Have you investigated why?


[dpdk-dev] [PATCH] igb_uio: fix build with backported kernel

2016-06-17 Thread Ferruh Yigit
On 6/16/2016 4:45 PM, Martinx - ? wrote:
> On 15 June 2016 at 11:59, Ferruh Yigit  > wrote:
> 
> On 6/15/2016 4:57 PM, Ferruh Yigit wrote:
> > Following compile error observed with CentOS 6.8, which uses kernel
> > kernel-devel-2.6.32-642.el6.x86_64:
> >
> > CC eal_thread.o
> > .../build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:
> > In function 'igbuio_msix_mask_irq':
> > .../build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:157:
> > error: 'PCI_MSIX_ENTRY_CTRL_MASKBIT' undeclared (first use in this
> > function)
> >
> > Reported-by: Thiago  >
> > Signed-off-by: Ferruh Yigit  >
> 
> Hi Thiago,
> 
> Can you please test this patch?
> 
> Thanks,
> ferruh
> 
> 
> Hi Ferruh,
> 
> That patch applied and worked (kind of):
> 
> ---
> [root at centos6-1 dpdk-16.04]# patch -p1 < ../dpdk-centos6.patch 
> patching file lib/librte_eal/linuxapp/igb_uio/compat.h
> Hunk #1 succeeded at 24 with fuzz 2.
> ---
> 
>  It passed that broken step, however, it is failing in a different part
> of build process now, as follows:
> 
> ---
> [root at centos6-1 ~]# time rpmbuild --ba /root/rpmbuild/SPECS/dpdk.spec 
> ...
> ...
>   LD librte_eal.so.2
>   INSTALL-LIB librte_eal.so.2
> == Build lib/librte_eal/linuxapp/kni
>   LD
>  
> /root/rpmbuild/BUILD/dpdk-16.04/x86_64-default-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/built-in.o
>   CC [M]
>  
> /root/rpmbuild/BUILD/dpdk-16.04/x86_64-default-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/ixgbe_main.o
>   CC [M]
>  
> /root/rpmbuild/BUILD/dpdk-16.04/x86_64-default-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/ixgbe_api.o
> In file included from
> /root/rpmbuild/BUILD/dpdk-16.04/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_osdep.h:41,
>  from
> /root/rpmbuild/BUILD/dpdk-16.04/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_type.h:31,
>  from
> /root/rpmbuild/BUILD/dpdk-16.04/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_api.h:31,
>  from
> /root/rpmbuild/BUILD/dpdk-16.04/x86_64-default-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/ixgbe_api.c:28:
> /root/rpmbuild/BUILD/dpdk-16.04/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/kcompat.h:
> In function '__kc_vlan_get_protocol':
> /root/rpmbuild/BUILD/dpdk-16.04/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/kcompat.h:2836:
> error: implicit declaration of function 'vlan_tx_tag_present'

Because skb_vlan_tag_present renamed in Linux 3.19 (commit: df8a39d) and
this commit backported in this kernel.
This error can be also fixed, but another compile error pops up.

This is hard to keep up, because kernel version is old (2.6.32) but
backported latest commits. We are not able to rely on kernel version
checks or define checks.

If you don't need KNI you can either:
1- Disable it from configuration file
2- Compile kernel modules against newer kernel version using
RTE_KERNELDIR, like: "make RTE_KERNELDIR=/tmp/latest_linux_version"

As far as I can see you are using spec file to compile, is this spec
file distributed with DPDK? If so, perhaps you can share your updates to
spec file?


> 
> Might be a totally different problem now, I don't know...   :-)
> 
> Best,
> Thiago



[dpdk-dev] [PATCH v13 1/3] mempool: support external mempool operations

2016-06-17 Thread Olivier Matz
Hi David,

On 06/17/2016 08:58 AM, Hunt, David wrote:
> A comment below:
> 
> On 16/6/2016 1:30 PM, David Hunt wrote:
>> +/**
>> + * Set the ops of a mempool.
>> + *
>> + * This can only be done on a mempool that is not populated, i.e.
>> just after
>> + * a call to rte_mempool_create_empty().
>> + *
>> + * @param mp
>> + *   Pointer to the memory pool.
>> + * @param name
>> + *   Name of the ops structure to use for this mempool.
> + * @param pool_config
> + *   Opaque data that can be used by the ops functions.
>> + * @return
>> + *   - 0: Success; the mempool is now using the requested ops functions.
>> + *   - -EINVAL - Invalid ops struct name provided.
>> + *   - -EEXIST - mempool already has an ops struct assigned.
>> + */
>> +int
>> +rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
>> +void *pool_config);
>> +
> 
> 

The changes related to the pool_config look good to me.

If you plan to do a v14 for this API comment, I'm wondering if the
documentation could be slightly modified too. I think "external mempool
manager" was the legacy name for the feature, but maybe it could be
changed in "alternative mempool handlers" or "changing the mempool
handler". I mean the word "external" is probably not appropriate now,
especially if we add other handlers in the mempool lib.

My 2 cents,
Olivier


[dpdk-dev] [PATCH] qat: fix for VFs not getting recognized

2016-06-17 Thread Jain, Deepak K


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Friday, June 17, 2016 9:19 AM
> To: Jain, Deepak K 
> Cc: dev at dpdk.org; Griffin, John ; De Lara 
> Guarch,
> Pablo ; Doherty, Declan
> 
> Subject: Re: [dpdk-dev] [PATCH] qat: fix for VFs not getting recognized
> 
> 2016-06-16 16:25, Jain, Deepak K:
> > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > > 2016-06-16 16:29, Jain, Deepak K:
> > > > Due to addition of CLASS_ID in EAL, class_id is amended into the code.
> > >
> > > Why the VF is not recognized?
> > > The class id should not be mandatory.
> >
> > Without the change proposed, QuickAssist Devices were not visible and
> hence tests were not running.
> > Seems like changes in EAL especially where class_id is added affected the
> QuickAssist tests.
> > With this change, QuickAssist devices are visible during tests and tests
> working fine.
> 
> Which tests?
> Have you investigated why?

Hi Thomas,

On investigation, I found that when class_id is not set in the 
rte_qat_cryptodev.c, the value of id_table->class_id defaults to 0.

Hence the following code snippet always executes and the probing of driver is 
never done.
if (id_table->class_id != dev->id.class_id &&
id_table->class_id != RTE_CLASS_ANY_ID
continue;   

If value of id_table->class_id is set, as shown in patch which was submitted, 
the id_table->class_ID is set to RTE_CLASS_ANY_ID and hence its probes the 
driver and fixes the issues.

Other fix would be to set default value of class_id equal to RTE_CLASS_ANY_ID 
instead of 0.




  1   2   >