[dpdk-dev] Free up completed TX buffers

2015-06-01 Thread Zoltan Kiss


On 01/06/15 09:50, Andriy Berestovskyy wrote:
> Hi Zoltan,
>
> On Fri, May 29, 2015 at 7:00 PM, Zoltan Kiss  
> wrote:
>> The easy way is just to increase your buffer pool's size to make
>> sure that doesn't happen.
>
> Go for it!

I went for it, my question is whether is it a good and worthwhile idea 
to give the applications a last resort option for rainy days? It's a 
problem which probably won't occur very often, but when it does, I think 
it can take painfully long until you figure out what's wrong.
>
>>   But there is no bulletproof way to calculate such
>> a number
>
> Yeah, there are many places for mbufs to stay :( I would try:
>
> Mempool size = sum(numbers of all TX descriptors)
>  + sum(rx_free_thresh)
>  + (mempool cache size * (number of lcores - 1))
>  + (burst size * number of lcores)

It heavily depends on what your application does, and I think it's easy 
to make a mistake in these calculations.

>
>> I'm thinking about a foolproof way, which is exposing functions like
>> ixgbe_tx_free_bufs from the PMDs, so the application can call it as a last
>> resort to avoid deadlock.
>
> Have a look at rte_eth_dev_tx_queue_stop()/start(). Some NICs (i.e.
> ixgbe) do reset the queue and free all the mbufs.

That's a bit drastic, I just want to flush the finished TX buffers, even 
if tx_free_thresh were not reached.
An easy option would be to use rte_eth_tx_burst(..., nb_pkts=0), I'm 
already using this to enforce TX completion if it's really needed. It 
checks for tx_free_thresh, like this:

/* Check if the descriptor ring needs to be cleaned. */
if ((txq->nb_tx_desc - txq->nb_tx_free) > txq->tx_free_thresh)
i40e_xmit_cleanup(txq);

My idea is to extend this condition and add " || nb_pkts == 0", so you 
can force cleanup. But there might be others who uses this same way to 
do manual TX completion, and they expect that it only happens when 
tx_free_thresh is reached.

>
> Regards,
> Andriy
>


[dpdk-dev] [PATCH] ixgbe: fix checking for tx_free_thresh

2015-06-01 Thread Zoltan Kiss
Hi,

Anyone would like to review this patch? Venky sent a NAK, but I've 
explained to him why it is a bug.

Regards,

Zoltan

On 27/05/15 21:12, Zoltan Kiss wrote:
> This check doesn't do what's required by rte_eth_tx_burst:
> "When the number of previously sent packets reached the "minimum transmit
> packets to free" threshold"
>
> This can cause problems when txq->tx_free_thresh + [number of elements in the
> pool] < txq->nb_tx_desc.
>
> Signed-off-by: Zoltan Kiss 
> ---
>   drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++--
>   drivers/net/ixgbe/ixgbe_rxtx_vec.c | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
> index 4f9ab22..b70ed8c 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> @@ -250,10 +250,10 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
>
>   /*
>* Begin scanning the H/W ring for done descriptors when the
> -  * number of available descriptors drops below tx_free_thresh.  For
> +  * number of in flight descriptors reaches tx_free_thresh. For
>* each done descriptor, free the associated buffer.
>*/
> - if (txq->nb_tx_free < txq->tx_free_thresh)
> + if ((txq->nb_tx_desc - txq->nb_tx_free) > txq->tx_free_thresh)
>   ixgbe_tx_free_bufs(txq);
>
>   /* Only use descriptors that are available */
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec.c 
> b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
> index abd10f6..f91c698 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx_vec.c
> +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
> @@ -598,7 +598,7 @@ ixgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf 
> **tx_pkts,
>   if (unlikely(nb_pkts > RTE_IXGBE_VPMD_TX_BURST))
>   nb_pkts = RTE_IXGBE_VPMD_TX_BURST;
>
> - if (txq->nb_tx_free < txq->tx_free_thresh)
> + if ((txq->nb_tx_desc - txq->nb_tx_free) > txq->tx_free_thresh)
>   ixgbe_tx_free_bufs(txq);
>
>   nb_commit = nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
>


[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-06-01 Thread Liang, Cunming
Hi Stephen,

On 5/29/2015 11:27 PM, Stephen Hemminger wrote:
> On Fri, 29 May 2015 16:45:25 +0800
> Cunming Liang  wrote:
>
>> +#ifdef RTE_EAL_RX_INTR
>> +extern int
>>   rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data);
>> +#else
>> +static inline int
>> +rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
>> +{
>> +RTE_SET_USED(port_id);
>> +RTE_SET_USED(epfd);
>> +RTE_SET_USED(op);
>> +RTE_SET_USED(data);
>> +return -1;
>> +}
>> +#endif
> Doing ABI compatibility is good but hard.
>
> I think it would be better not to provide the functions for rx_intr_ctl unless
> the feature was configured on. That way anyone using them with incorrect 
> config
> would detect failure at build time, rather than run time.
I tend to not agree. For rx_intr_ctl/rx_intr_ctl_q, no matter w/ or w/o 
RTE_EAL_RX_INTR, it's necessary to check the return value.
The failure return shall cause application give up using epoll waiting 
on the specified epfd for the port, and then degraded to pure polling mode.
So I think these failure should be handled by the caller.
>
> Also, doesn't some doc file have to be updated for the announcement?
Yes, the ABI section in release note (doc/guides/rel_notes/abi.rst) 
shall update for the announcement.


[dpdk-dev] [PATCH v3 4/4] lib_vhost: Remove unnecessary vring descriptor length updating

2015-06-01 Thread Ouyang Changchun
Remove these unnecessary vring descriptor length updating, vhost should not 
change them.
virtio in front end should assign value to desc.len for both rx and tx.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_vhost/vhost_rxtx.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 647a0c1..9a81095 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -136,7 +136,6 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
 * placed in separate buffers.
 */
if (desc->flags & VRING_DESC_F_NEXT) {
-   desc->len = vq->vhost_hlen;
desc = >desc[desc->next];
/* Buffer address translation. */
buff_addr = gpa_to_vva(dev, desc->addr);
@@ -292,7 +291,6 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,
if (vb_avail == 0) {
uint32_t desc_idx =
vq->buf_vec[vec_idx].desc_idx;
-   vq->desc[desc_idx].len = vq->vhost_hlen;

if ((vq->desc[desc_idx].flags
& VRING_DESC_F_NEXT) == 0) {
@@ -376,7 +374,6 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,
 */
uint32_t desc_idx =
vq->buf_vec[vec_idx].desc_idx;
-   vq->desc[desc_idx].len = vb_offset;

if ((vq->desc[desc_idx].flags &
VRING_DESC_F_NEXT) == 0) {
@@ -411,26 +408,13 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,
/*
 * This whole packet completes.
 */
-   uint32_t desc_idx =
-   vq->buf_vec[vec_idx].desc_idx;
-   vq->desc[desc_idx].len = vb_offset;
-
-   while (vq->desc[desc_idx].flags &
-   VRING_DESC_F_NEXT) {
-   desc_idx = vq->desc[desc_idx].next;
-vq->desc[desc_idx].len = 0;
-   }
-
/* Update used ring with desc information */
vq->used->ring[cur_idx & (vq->size - 1)].id
= vq->buf_vec[vec_idx].desc_idx;
vq->used->ring[cur_idx & (vq->size - 1)].len
= entry_len;
-   entry_len = 0;
-   cur_idx++;
entry_success++;
-   seg_avail = 0;
-   cpy_len = RTE_MIN(vb_avail, seg_avail);
+   break;
}
}
}
-- 
1.8.4.2



[dpdk-dev] [PATCH v3 3/4] lib_vhost: Extract function

2015-06-01 Thread Ouyang Changchun
Extract codes into 2 common functions:
update_secure_len which is used to accumulate the buffer len in the vring 
descriptors.
and fill_buf_vec which is used to fill struct buf_vec.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_vhost/vhost_rxtx.c | 79 +--
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index de60e9b..647a0c1 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -438,6 +438,49 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,
return entry_success;
 }

+static inline void __attribute__((always_inline))
+update_secure_len(struct vhost_virtqueue *vq, uint32_t idx,
+   uint32_t *secure_len)
+{
+   uint8_t next_desc = 0;
+   uint32_t len = *secure_len;
+
+   do {
+   next_desc = 0;
+   len += vq->desc[idx].len;
+   if (vq->desc[idx].flags & VRING_DESC_F_NEXT) {
+   idx = vq->desc[idx].next;
+   next_desc = 1;
+   }
+   } while (next_desc);
+
+   *secure_len = len;
+}
+
+static inline void __attribute__((always_inline))
+fill_buf_vec(struct vhost_virtqueue *vq, uint16_t id, uint32_t *vec_idx)
+{
+   uint16_t wrapped_idx = id & (vq->size - 1);
+   uint32_t idx = vq->avail->ring[wrapped_idx];
+   uint8_t next_desc;
+   uint32_t vec_id = *vec_idx;
+
+   do {
+   next_desc = 0;
+   vq->buf_vec[vec_id].buf_addr = vq->desc[idx].addr;
+   vq->buf_vec[vec_id].buf_len = vq->desc[idx].len;
+   vq->buf_vec[vec_id].desc_idx = idx;
+   vec_id++;
+
+   if (vq->desc[idx].flags & VRING_DESC_F_NEXT) {
+   idx = vq->desc[idx].next;
+   next_desc = 1;
+   }
+   } while (next_desc);
+
+   *vec_idx = vec_id;
+}
+
 /*
  * This function works for mergeable RX.
  */
@@ -468,7 +511,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
uint16_t need_cnt;
uint32_t vec_idx = 0;
uint32_t pkt_len = pkts[pkt_idx]->pkt_len + vq->vhost_hlen;
-   uint16_t i, id;
+   uint16_t i;

do {
/*
@@ -492,18 +535,8 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
(res_cur_idx) & (vq->size - 1);
uint32_t idx =
vq->avail->ring[wrapped_idx];
-   uint8_t next_desc;
-
-   do {
-   next_desc = 0;
-   secure_len += vq->desc[idx].len;
-   if (vq->desc[idx].flags &
-   VRING_DESC_F_NEXT) {
-   idx = 
vq->desc[idx].next;
-   next_desc = 1;
-   }
-   } while (next_desc);

+   update_secure_len(vq, idx, _len);
res_cur_idx++;
}
} while (pkt_len > secure_len);
@@ -514,28 +547,10 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
res_cur_idx);
} while (success == 0);

-   id = res_base_idx;
need_cnt = res_cur_idx - res_base_idx;

-   for (i = 0; i < need_cnt; i++, id++) {
-   uint16_t wrapped_idx = id & (vq->size - 1);
-   uint32_t idx = vq->avail->ring[wrapped_idx];
-   uint8_t next_desc;
-   do {
-   next_desc = 0;
-   vq->buf_vec[vec_idx].buf_addr =
-   vq->desc[idx].addr;
-   vq->buf_vec[vec_idx].buf_len =
-   vq->desc[idx].len;
-   vq->buf_vec[vec_idx].desc_idx = idx;
-   vec_idx++;
-
-   if (vq->desc[idx].flags & VRING_DESC_F_NEXT) {
-   idx = vq->desc[idx].next;
-   next_desc = 1;
-   }
-   } while (next_desc);
-   }
+   for (i = 0; i < need_cnt; i++)
+   fill_buf_vec(vq, res_base_idx + i, _idx);

res_end_idx = res_cur_idx;

-- 
1.8.4.2



[dpdk-dev] [PATCH v3 2/4] lib_vhost: Refine code style

2015-06-01 Thread Ouyang Changchun
Remove unnecessary new line.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_vhost/vhost_rxtx.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 5fe1b6c..de60e9b 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -267,8 +267,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,
 * (guest physical addr -> vhost virtual addr)
 */
vq = dev->virtqueue[VIRTIO_RXQ];
-   vb_addr =
-   gpa_to_vva(dev, vq->buf_vec[vec_idx].buf_addr);
+   vb_addr = gpa_to_vva(dev, vq->buf_vec[vec_idx].buf_addr);
vb_hdr_addr = vb_addr;

/* Prefetch buffer address. */
@@ -286,8 +285,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,

seg_avail = rte_pktmbuf_data_len(pkt);
vb_offset = vq->vhost_hlen;
-   vb_avail =
-   vq->buf_vec[vec_idx].buf_len - vq->vhost_hlen;
+   vb_avail = vq->buf_vec[vec_idx].buf_len - vq->vhost_hlen;

entry_len = vq->vhost_hlen;

@@ -310,8 +308,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t 
res_base_idx,
}

vec_idx++;
-   vb_addr =
-   gpa_to_vva(dev, vq->buf_vec[vec_idx].buf_addr);
+   vb_addr = gpa_to_vva(dev, vq->buf_vec[vec_idx].buf_addr);

/* Prefetch buffer address. */
rte_prefetch0((void *)(uintptr_t)vb_addr);
-- 
1.8.4.2



[dpdk-dev] [PATCH v3 1/4] lib_vhost: Fix enqueue/dequeue can't handle chained vring descriptors

2015-06-01 Thread Ouyang Changchun
Vring enqueue need consider the 2 cases:
 1. use separate descriptors to contain virtio header and actual data, e.g. the 
first descriptor
is for virtio header, and then followed by descriptors for actual data.
 2. virtio header and some data are put together in one descriptor, e.g. the 
first descriptor contain both
virtio header and part of actual data, and then followed by more 
descriptors for rest of packet data,
current DPDK based virtio-net pmd implementation is this case;

So does vring dequeue, it should not assume vring descriptor is chained or not 
chained, it should use
desc->flags to check whether it is chained or not. this patch also fixes TX 
corrupt issue in fedora 21
which uses one single vring descriptor(header and data are in one descriptor) 
for virtio tx process on default.

Changes in v3
  - support scattered mbuf, check the mbuf has 'next' pointer or not and copy 
all segments to vring buffer.

Changes in v2
  - drop the uncompleted packet
  - refine code logic

Signed-off-by: Changchun Ouyang 
---
 lib/librte_vhost/vhost_rxtx.c | 88 ++-
 1 file changed, 71 insertions(+), 17 deletions(-)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 4809d32..5fe1b6c 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -46,7 +46,8 @@
  * This function adds buffers to the virtio devices RX virtqueue. Buffers can
  * be received from the physical port or from another virtio device. A packet
  * count is returned to indicate the number of packets that are succesfully
- * added to the RX queue. This function works when mergeable is disabled.
+ * added to the RX queue. This function works when the mbuf is scattered, but
+ * it doesn't support the mergeable feature.
  */
 static inline uint32_t __attribute__((always_inline))
 virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
@@ -59,7 +60,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, 0, 0, 0, 0, 0}, 0};
uint64_t buff_addr = 0;
uint64_t buff_hdr_addr = 0;
-   uint32_t head[MAX_PKT_BURST], packet_len = 0;
+   uint32_t head[MAX_PKT_BURST];
uint32_t head_idx, packet_success = 0;
uint16_t avail_idx, res_cur_idx;
uint16_t res_base_idx, res_end_idx;
@@ -113,6 +114,10 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
rte_prefetch0(>desc[head[packet_success]]);

while (res_cur_idx != res_end_idx) {
+   uint32_t offset = 0, vb_offset = 0;
+   uint32_t pkt_len, len_to_cpy, data_len, total_copied = 0;
+   uint8_t hdr = 0, uncompleted_pkt = 0;
+
/* Get descriptor from available ring */
desc = >desc[head[packet_success]];

@@ -125,7 +130,6 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,

/* Copy virtio_hdr to packet and increment buffer address */
buff_hdr_addr = buff_addr;
-   packet_len = rte_pktmbuf_data_len(buff) + vq->vhost_hlen;

/*
 * If the descriptors are chained the header and data are
@@ -136,28 +140,73 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
desc = >desc[desc->next];
/* Buffer address translation. */
buff_addr = gpa_to_vva(dev, desc->addr);
-   desc->len = rte_pktmbuf_data_len(buff);
} else {
-   buff_addr += vq->vhost_hlen;
-   desc->len = packet_len;
+   vb_offset += vq->vhost_hlen;
+   hdr = 1;
}

+   pkt_len = rte_pktmbuf_pkt_len(buff);
+   data_len = rte_pktmbuf_data_len(buff);
+   len_to_cpy = RTE_MIN(data_len,
+   hdr ? desc->len - vq->vhost_hlen : desc->len);
+   while (len_to_cpy > 0) {
+   /* Copy mbuf data to buffer */
+   rte_memcpy((void *)(uintptr_t)(buff_addr + vb_offset),
+   (const void *)(rte_pktmbuf_mtod(buff, const 
char *) + offset),
+   len_to_cpy);
+   PRINT_PACKET(dev, (uintptr_t)(buff_addr + vb_offset),
+   len_to_cpy, 0);
+
+   offset += len_to_cpy;
+   vb_offset += len_to_cpy;
+   total_copied += len_to_cpy;
+
+   /* The whole packet completes */
+   if (total_copied == pkt_len)
+   break;
+
+   /* The current segment completes */
+   if (offset == data_len) {
+   buff = buff->next;
+   if (buff != NULL) {
+   offset = 0;
+

[dpdk-dev] [PATCH v3 0/4] Fix vhost enqueue/dequeue issue

2015-06-01 Thread Ouyang Changchun
Fix enqueue/dequeue can't handle chained vring descriptors;
Remove unnecessary vring descriptor length updating;
Add support copying scattered mbuf to vring;

Changchun Ouyang (4):
  lib_vhost: Fix enqueue/dequeue can't handle chained vring descriptors
  lib_vhost: Refine code style
  lib_vhost: Extract function
  lib_vhost: Remove unnecessary vring descriptor length updating

 lib/librte_vhost/vhost_rxtx.c | 194 ++
 1 file changed, 122 insertions(+), 72 deletions(-)

-- 
1.8.4.2



[dpdk-dev] [PATCH] librte_pmd_fm10k: Fix max_vfs issue in fm10k PMD

2015-06-01 Thread Thomas Monjalon
2015-05-12 05:30, Qiu, Michael:
> Hi, thomas
> 
> What about this patch?

It seems this patch was not *really* sent to dev at dpdk.org.
Please re-send, keeping the Acked-by line.

> On 4/16/2015 4:09 PM, Chen, Jing D wrote:
> > From: Michael Qiu [mailto:qiudayu at cn.ibm.com]
> >> From: Michael Qiu 
> >>
> >> In DPDK, max_vfs means vf numbers created, not the max number vfs
> >> the device supported.
> >>
> >> Signed-off-by: Michael Qiu 
> >> ---
> >>  lib/librte_pmd_fm10k/fm10k_ethdev.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c
> >> b/lib/librte_pmd_fm10k/fm10k_ethdev.c
> >> index 0312fad..297ff88 100644
> >> --- a/lib/librte_pmd_fm10k/fm10k_ethdev.c
> >> +++ b/lib/librte_pmd_fm10k/fm10k_ethdev.c
> >> @@ -770,7 +770,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> >>dev_info->max_tx_queues  = hw->mac.max_queues;
> >>dev_info->max_mac_addrs  = 1;
> >>dev_info->max_hash_mac_addrs = 0;
> >> -  dev_info->max_vfs= FM10K_MAX_VF_NUM;
> >> +  dev_info->max_vfs= dev->pci_dev->max_vfs;
> >>dev_info->max_vmdq_pools = ETH_64_POOLS;
> >>dev_info->rx_offload_capa =
> >>DEV_RX_OFFLOAD_IPV4_CKSUM |
> >> --
> >> 1.9.3
> > Acked-by Jing Chen 




[dpdk-dev] [PATCH v6 18/18] mbuf: remove old packet type bit masks

2015-06-01 Thread Helin Zhang
As unified packet types are used instead, those old bit masks and
the relevant macros for packet type indication need to be removed.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 lib/librte_mbuf/rte_mbuf.c | 4 
 lib/librte_mbuf/rte_mbuf.h | 4 
 2 files changed, 8 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.
* Redefined the bit masks for packet RX offload flags.

v5 changes:
* Rolled back the bit masks of RX flags, for ABI compatibility.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index f506517..0b3a4fc 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -251,14 +251,18 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
/* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW"; */
/* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */
/* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */
+#ifndef RTE_UNIFIED_PKT_TYPE
case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR";
case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT";
case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR";
case PKT_RX_IPV6_HDR_EXT: return "PKT_RX_IPV6_HDR_EXT";
+#endif /* RTE_UNIFIED_PKT_TYPE */
case PKT_RX_IEEE1588_PTP: return "PKT_RX_IEEE1588_PTP";
case PKT_RX_IEEE1588_TMST: return "PKT_RX_IEEE1588_TMST";
+#ifndef RTE_UNIFIED_PKT_TYPE
case PKT_RX_TUNNEL_IPV4_HDR: return "PKT_RX_TUNNEL_IPV4_HDR";
case PKT_RX_TUNNEL_IPV6_HDR: return "PKT_RX_TUNNEL_IPV6_HDR";
+#endif /* RTE_UNIFIED_PKT_TYPE */
default: return NULL;
}
 }
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 94e51cd..d82fc8e 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -91,14 +91,18 @@ extern "C" {
 #define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer overflow. */
 #define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing error. */
 #define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
+#ifndef RTE_UNIFIED_PKT_TYPE
 #define PKT_RX_IPV4_HDR  (1ULL << 5)  /**< RX packet with IPv4 header. */
 #define PKT_RX_IPV4_HDR_EXT  (1ULL << 6)  /**< RX packet with extended IPv4 
header. */
 #define PKT_RX_IPV6_HDR  (1ULL << 7)  /**< RX packet with IPv6 header. */
 #define PKT_RX_IPV6_HDR_EXT  (1ULL << 8)  /**< RX packet with extended IPv6 
header. */
+#endif /* RTE_UNIFIED_PKT_TYPE */
 #define PKT_RX_IEEE1588_PTP  (1ULL << 9)  /**< RX IEEE1588 L2 Ethernet PT 
Packet. */
 #define PKT_RX_IEEE1588_TMST (1ULL << 10) /**< RX IEEE1588 L2/L4 timestamped 
packet.*/
+#ifndef RTE_UNIFIED_PKT_TYPE
 #define PKT_RX_TUNNEL_IPV4_HDR (1ULL << 11) /**< RX tunnel packet with IPv4 
header.*/
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
+#endif /* RTE_UNIFIED_PKT_TYPE */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
 /* add new RX flags here */
-- 
1.9.3



[dpdk-dev] [PATCH v6 17/18] examples/l3fwd: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 examples/l3fwd/main.c | 123 --
 1 file changed, 120 insertions(+), 3 deletions(-)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v3 changes:
* Minor bug fixes and enhancements.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index e32512e..72d9ab7 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -955,7 +955,11 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, 
struct lcore_conf *qcon

eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
+#else
if (m->ol_flags & PKT_RX_IPV4_HDR) {
+#endif
/* Handle IPv4 headers.*/
ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned 
char *) +
sizeof(struct ether_hdr));
@@ -989,8 +993,11 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, 
struct lcore_conf *qcon
ether_addr_copy(_eth_addr[dst_port], _hdr->s_addr);

send_single_packet(m, dst_port);
-
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
+#else
} else {
+#endif
/* Handle IPv6 headers.*/
struct ipv6_hdr *ipv6_hdr;

@@ -1011,8 +1018,13 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, 
struct lcore_conf *qcon
ether_addr_copy(_eth_addr[dst_port], _hdr->s_addr);

send_single_packet(m, dst_port);
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else
+   /* Free the mbuf that contains non-IPV4/IPV6 packet */
+   rte_pktmbuf_free(m);
+#else
}
-
+#endif
 }

 #ifdef DO_RFC_1812_CHECKS
@@ -1036,12 +1048,19 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t 
portid, struct lcore_conf *qcon
  * to BAD_PORT value.
  */
 static inline __attribute__((always_inline)) void
+#ifdef RTE_UNIFIED_PKT_TYPE
+rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype)
+#else
 rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t flags)
+#endif
 {
uint8_t ihl;

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(ptype)) {
+#else
if ((flags & PKT_RX_IPV4_HDR) != 0) {
-
+#endif
ihl = ipv4_hdr->version_ihl - IPV4_MIN_VER_IHL;

ipv4_hdr->time_to_live--;
@@ -1071,11 +1090,19 @@ get_dst_port(const struct lcore_conf *qconf, struct 
rte_mbuf *pkt,
struct ipv6_hdr *ipv6_hdr;
struct ether_hdr *eth_hdr;

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
+#else
if (pkt->ol_flags & PKT_RX_IPV4_HDR) {
+#endif
if (rte_lpm_lookup(qconf->ipv4_lookup_struct, dst_ipv4,
_hop) != 0)
next_hop = portid;
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
+#else
} else if (pkt->ol_flags & PKT_RX_IPV6_HDR) {
+#endif
eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1);
if (rte_lpm6_lookup(qconf->ipv6_lookup_struct,
@@ -1109,12 +1136,52 @@ process_packet(struct lcore_conf *qconf, struct 
rte_mbuf *pkt,
ve = val_eth[dp];

dst_port[0] = dp;
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rfc1812_process(ipv4_hdr, dst_port, pkt->packet_type);
+#else
rfc1812_process(ipv4_hdr, dst_port, pkt->ol_flags);
+#endif

te =  _mm_blend_epi16(te, ve, MASK_ETH);
_mm_store_si128((__m128i *)eth_hdr, te);
 }

+#ifdef RTE_UNIFIED_PKT_TYPE
+/*
+ * Read packet_type and destination IPV4 addresses from 4 mbufs.
+ */
+static inline void
+processx4_step1(struct rte_mbuf *pkt[FWDSTEP],
+   __m128i *dip,
+   uint32_t *ipv4_flag)
+{
+   struct ipv4_hdr *ipv4_hdr;
+   struct ether_hdr *eth_hdr;
+   uint32_t x0, x1, x2, x3;
+
+   eth_hdr = rte_pktmbuf_mtod(pkt[0], struct ether_hdr *);
+   ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+   x0 = ipv4_hdr->dst_addr;
+   ipv4_flag[0] = pkt[0]->packet_type & RTE_PTYPE_L3_IPV4;
+
+   eth_hdr = rte_pktmbuf_mtod(pkt[1], struct ether_hdr *);
+   ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+   x1 = ipv4_hdr->dst_addr;
+   ipv4_flag[0] &= pkt[1]->packet_type;
+
+   eth_hdr = rte_pktmbuf_mtod(pkt[2], struct ether_hdr *);
+   ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
+   x2 = ipv4_hdr->dst_addr;
+   ipv4_flag[0] &= 

[dpdk-dev] [PATCH v6 16/18] examples/l3fwd-power: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 examples/l3fwd-power/main.c | 8 
 1 file changed, 8 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 6ac342b..e27ad4e 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -635,7 +635,11 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,

eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
+#else
if (m->ol_flags & PKT_RX_IPV4_HDR) {
+#endif
/* Handle IPv4 headers.*/
ipv4_hdr =
(struct ipv4_hdr *)(rte_pktmbuf_mtod(m, unsigned char*)
@@ -670,8 +674,12 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,
ether_addr_copy(_eth_addr[dst_port], _hdr->s_addr);

send_single_packet(m, dst_port);
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
+#else
}
else {
+#endif
/* Handle IPv6 headers.*/
 #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH)
struct ipv6_hdr *ipv6_hdr;
-- 
1.9.3



[dpdk-dev] [PATCH v6 15/18] examples/l3fwd-acl: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 examples/l3fwd-acl/main.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index a5d4f25..2da8bf1 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -645,10 +645,13 @@ prepare_one_packet(struct rte_mbuf **pkts_in, struct 
acl_search_t *acl,
struct ipv4_hdr *ipv4_hdr;
struct rte_mbuf *pkt = pkts_in[index];

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
+#else
int type = pkt->ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_IPV6_HDR);

if (type == PKT_RX_IPV4_HDR) {
-
+#endif
ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt,
unsigned char *) + sizeof(struct ether_hdr));

@@ -667,9 +670,11 @@ prepare_one_packet(struct rte_mbuf **pkts_in, struct 
acl_search_t *acl,
/* Not a valid IPv4 packet */
rte_pktmbuf_free(pkt);
}
-
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
+#else
} else if (type == PKT_RX_IPV6_HDR) {
-
+#endif
/* Fill acl structure */
acl->data_ipv6[acl->num_ipv6] = MBUF_IPV6_2PROTO(pkt);
acl->m_ipv6[(acl->num_ipv6)++] = pkt;
@@ -687,17 +692,22 @@ prepare_one_packet(struct rte_mbuf **pkts_in, struct 
acl_search_t *acl,
 {
struct rte_mbuf *pkt = pkts_in[index];

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) {
+#else
int type = pkt->ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_IPV6_HDR);

if (type == PKT_RX_IPV4_HDR) {
-
+#endif
/* Fill acl structure */
acl->data_ipv4[acl->num_ipv4] = MBUF_IPV4_2PROTO(pkt);
acl->m_ipv4[(acl->num_ipv4)++] = pkt;

-
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) {
+#else
} else if (type == PKT_RX_IPV6_HDR) {
-
+#endif
/* Fill acl structure */
acl->data_ipv6[acl->num_ipv6] = MBUF_IPV6_2PROTO(pkt);
acl->m_ipv6[(acl->num_ipv6)++] = pkt;
@@ -745,10 +755,17 @@ send_one_packet(struct rte_mbuf *m, uint32_t res)
/* in the ACL list, drop it */
 #ifdef L3FWDACL_DEBUG
if ((res & ACL_DENY_SIGNATURE) != 0) {
+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(m->packet_type))
+   dump_acl4_rule(m, res);
+   else if (RTE_ETH_IS_IPV6_HDR(m->packet_type))
+   dump_acl6_rule(m, res);
+#else
if (m->ol_flags & PKT_RX_IPV4_HDR)
dump_acl4_rule(m, res);
else
dump_acl6_rule(m, res);
+#endif /* RTE_UNIFIED_PKT_TYPE */
}
 #endif
rte_pktmbuf_free(m);
-- 
1.9.3



[dpdk-dev] [PATCH v6 14/18] examples/ip_reassembly: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 examples/ip_reassembly/main.c | 9 +
 1 file changed, 9 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index 9ecb6f9..cb131f6 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -356,7 +356,11 @@ reassemble(struct rte_mbuf *m, uint8_t portid, uint32_t 
queue,
dst_port = portid;

/* if packet is IPv4 */
+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
+#else
if (m->ol_flags & (PKT_RX_IPV4_HDR)) {
+#endif
struct ipv4_hdr *ip_hdr;
uint32_t ip_dst;

@@ -396,9 +400,14 @@ reassemble(struct rte_mbuf *m, uint8_t portid, uint32_t 
queue,
}

eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
+   /* if packet is IPv6 */
+#else
}
/* if packet is IPv6 */
else if (m->ol_flags & (PKT_RX_IPV6_HDR | PKT_RX_IPV6_HDR_EXT)) {
+#endif
struct ipv6_extension_fragment *frag_hdr;
struct ipv6_hdr *ip_hdr;

-- 
1.9.3



[dpdk-dev] [PATCH v6 13/18] examples/ip_fragmentation: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 examples/ip_fragmentation/main.c | 9 +
 1 file changed, 9 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 0922ba6..5eccecc 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -283,7 +283,11 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct 
lcore_queue_conf *qconf,
len = qconf->tx_mbufs[port_out].len;

/* if this is an IPv4 packet */
+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
+#else
if (m->ol_flags & PKT_RX_IPV4_HDR) {
+#endif
struct ipv4_hdr *ip_hdr;
uint32_t ip_dst;
/* Read the lookup key (i.e. ip_dst) from the input packet */
@@ -317,9 +321,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct 
lcore_queue_conf *qconf,
if (unlikely (len2 < 0))
return;
}
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
+   /* if this is an IPv6 packet */
+#else
}
/* if this is an IPv6 packet */
else if (m->ol_flags & PKT_RX_IPV6_HDR) {
+#endif
struct ipv6_hdr *ip_hdr;

ipv6 = 1;
-- 
1.9.3



[dpdk-dev] [PATCH v6 12/18] app/test: Remove useless code

2015-06-01 Thread Helin Zhang
Severl useless code lines are added accidently, which blocks packet
type unification. They should be deleted at all.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 app/test/packet_burst_generator.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

v4 changes:
* Removed several useless code lines which block packet type unification.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/app/test/packet_burst_generator.c 
b/app/test/packet_burst_generator.c
index b46eed7..6b1bbb5 100644
--- a/app/test/packet_burst_generator.c
+++ b/app/test/packet_burst_generator.c
@@ -272,19 +272,21 @@ nomore_mbuf:
if (ipv4) {
pkt->vlan_tci  = ETHER_TYPE_IPv4;
pkt->l3_len = sizeof(struct ipv4_hdr);
-
+#ifndef RTE_UNIFIED_PKT_TYPE
if (vlan_enabled)
pkt->ol_flags = PKT_RX_IPV4_HDR | 
PKT_RX_VLAN_PKT;
else
pkt->ol_flags = PKT_RX_IPV4_HDR;
+#endif
} else {
pkt->vlan_tci  = ETHER_TYPE_IPv6;
pkt->l3_len = sizeof(struct ipv6_hdr);
-
+#ifndef RTE_UNIFIED_PKT_TYPE
if (vlan_enabled)
pkt->ol_flags = PKT_RX_IPV6_HDR | 
PKT_RX_VLAN_PKT;
else
pkt->ol_flags = PKT_RX_IPV6_HDR;
+#endif
}

pkts_burst[nb_pkt] = pkt;
-- 
1.9.3



[dpdk-dev] [PATCH v6 11/18] app/testpmd: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |  14 
 app/test-pmd/rxonly.c   | 183 
 2 files changed, 197 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v4 changes:
* Added printing logs of packet types of each received packet in rxonly mode.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index c180ff2..43ab6f8 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -202,8 +202,14 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct 
testpmd_offload_info *info)

 /* Parse a vxlan header */
 static void
+#ifdef RTE_UNIFIED_PKT_TYPE
+parse_vxlan(struct udp_hdr *udp_hdr,
+   struct testpmd_offload_info *info,
+   uint32_t pkt_type)
+#else
 parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info,
uint64_t mbuf_olflags)
+#endif
 {
struct ether_hdr *eth_hdr;

@@ -211,8 +217,12 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct 
testpmd_offload_info *info,
 * (rfc7348) or that the rx offload flag is set (i40e only
 * currently) */
if (udp_hdr->dst_port != _htons(4789) &&
+#ifdef RTE_UNIFIED_PKT_TYPE
+   RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0)
+#else
(mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR |
PKT_RX_TUNNEL_IPV6_HDR)) == 0)
+#endif
return;

info->is_tunnel = 1;
@@ -549,7 +559,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct udp_hdr *udp_hdr;
udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
info.l3_len);
+#ifdef RTE_UNIFIED_PKT_TYPE
+   parse_vxlan(udp_hdr, , m->packet_type);
+#else
parse_vxlan(udp_hdr, , m->ol_flags);
+#endif
} else if (info.l4_proto == IPPROTO_GRE) {
struct simple_gre_hdr *gre_hdr;
gre_hdr = (struct simple_gre_hdr *)
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index ac56090..e6767be 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -91,7 +91,11 @@ pkt_burst_receive(struct fwd_stream *fs)
uint64_t ol_flags;
uint16_t nb_rx;
uint16_t i, packet_type;
+#ifdef RTE_UNIFIED_PKT_TYPE
+   uint16_t is_encapsulation;
+#else
uint64_t is_encapsulation;
+#endif

 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t start_tsc;
@@ -135,8 +139,12 @@ pkt_burst_receive(struct fwd_stream *fs)
ol_flags = mb->ol_flags;
packet_type = mb->packet_type;

+#ifdef RTE_UNIFIED_PKT_TYPE
+   is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+#else
is_encapsulation = ol_flags & (PKT_RX_TUNNEL_IPV4_HDR |
PKT_RX_TUNNEL_IPV6_HDR);
+#endif

print_ether_addr("  src=", _hdr->s_addr);
print_ether_addr(" - dst=", _hdr->d_addr);
@@ -160,6 +168,177 @@ pkt_burst_receive(struct fwd_stream *fs)
}
if (ol_flags & PKT_RX_VLAN_PKT)
printf(" - VLAN tci=0x%x", mb->vlan_tci);
+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (mb->packet_type) {
+   uint32_t ptype;
+
+   /* (outer) L2 packet type */
+   ptype = mb->packet_type & RTE_PTYPE_L2_MASK;
+   switch (ptype) {
+   case RTE_PTYPE_L2_MAC:
+   printf(" - (outer) L2 type: MAC");
+   break;
+   case RTE_PTYPE_L2_MAC_TIMESYNC:
+   printf(" - (outer) L2 type: MAC Timesync");
+   break;
+   case RTE_PTYPE_L2_ARP:
+   printf(" - (outer) L2 type: ARP");
+   break;
+   case RTE_PTYPE_L2_LLDP:
+   printf(" - (outer) L2 type: LLDP");
+   break;
+   default:
+   printf(" - (outer) L2 type: Unknown");
+   break;
+   }
+
+   /* (outer) L3 packet type */
+   ptype = mb->packet_type & RTE_PTYPE_L3_MASK;
+   switch (ptype) {
+   case RTE_PTYPE_L3_IPV4:
+

[dpdk-dev] [PATCH v6 10/18] app/test-pipeline: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 app/test-pipeline/pipeline_hash.c | 13 +
 1 file changed, 13 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/app/test-pipeline/pipeline_hash.c 
b/app/test-pipeline/pipeline_hash.c
index 4598ad4..bc84920 100644
--- a/app/test-pipeline/pipeline_hash.c
+++ b/app/test-pipeline/pipeline_hash.c
@@ -459,20 +459,33 @@ app_main_loop_rx_metadata(void) {
signature = RTE_MBUF_METADATA_UINT32_PTR(m, 0);
key = RTE_MBUF_METADATA_UINT8_PTR(m, 32);

+#ifdef RTE_UNIFIED_PKT_TYPE
+   if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
+#else
if (m->ol_flags & PKT_RX_IPV4_HDR) {
+#endif
ip_hdr = (struct ipv4_hdr *)
_data[sizeof(struct ether_hdr)];
ip_dst = ip_hdr->dst_addr;

k32 = (uint32_t *) key;
k32[0] = ip_dst & 0xFF00;
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
+#else
} else {
+#endif
ipv6_hdr = (struct ipv6_hdr *)
_data[sizeof(struct ether_hdr)];
ipv6_dst = ipv6_hdr->dst_addr;

memcpy(key, ipv6_dst, 16);
+#ifdef RTE_UNIFIED_PKT_TYPE
+   } else
+   continue;
+#else
}
+#endif

*signature = test_hash(key, 0, 0);
}
-- 
1.9.3



[dpdk-dev] [PATCH v6 09/18] fm10k: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 drivers/net/fm10k/fm10k_rxtx.c | 27 +++
 1 file changed, 27 insertions(+)

v4 changes:
* Supported unified packet type of fm10k from v4.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c
index 56df6cd..71a7f5d 100644
--- a/drivers/net/fm10k/fm10k_rxtx.c
+++ b/drivers/net/fm10k/fm10k_rxtx.c
@@ -68,12 +68,37 @@ static inline void dump_rxd(union fm10k_rx_desc *rxd)
 static inline void
 rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d)
 {
+#ifdef RTE_UNIFIED_PKT_TYPE
+   static const uint32_t
+   ptype_table[FM10K_RXD_PKTTYPE_MASK >> FM10K_RXD_PKTTYPE_SHIFT]
+   __rte_cache_aligned = {
+   [FM10K_PKTTYPE_OTHER] = RTE_PTYPE_L2_MAC,
+   [FM10K_PKTTYPE_IPV4] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4,
+   [FM10K_PKTTYPE_IPV4_EX] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4_EXT,
+   [FM10K_PKTTYPE_IPV6] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV6,
+   [FM10K_PKTTYPE_IPV6_EX] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT,
+   [FM10K_PKTTYPE_IPV4 | FM10K_PKTTYPE_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+   [FM10K_PKTTYPE_IPV6 | FM10K_PKTTYPE_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+   [FM10K_PKTTYPE_IPV4 | FM10K_PKTTYPE_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [FM10K_PKTTYPE_IPV6 | FM10K_PKTTYPE_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   };
+
+   m->packet_type = ptype_table[(d->w.pkt_info & FM10K_RXD_PKTTYPE_MASK)
+   >> FM10K_RXD_PKTTYPE_SHIFT];
+#else /* RTE_UNIFIED_PKT_TYPE */
uint16_t ptype;
static const uint16_t pt_lut[] = { 0,
PKT_RX_IPV4_HDR, PKT_RX_IPV4_HDR_EXT,
PKT_RX_IPV6_HDR, PKT_RX_IPV6_HDR_EXT,
0, 0, 0
};
+#endif /* RTE_UNIFIED_PKT_TYPE */

if (d->w.pkt_info & FM10K_RXD_RSSTYPE_MASK)
m->ol_flags |= PKT_RX_RSS_HASH;
@@ -97,9 +122,11 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union 
fm10k_rx_desc *d)
if (unlikely(d->d.staterr & FM10K_RXD_STATUS_RXE))
m->ol_flags |= PKT_RX_RECIP_ERR;

+#ifndef RTE_UNIFIED_PKT_TYPE
ptype = (d->d.data & FM10K_RXD_PKTTYPE_MASK_L3) >>
FM10K_RXD_PKTTYPE_SHIFT;
m->ol_flags |= pt_lut[(uint8_t)ptype];
+#endif
 }

 uint16_t
-- 
1.9.3



[dpdk-dev] [PATCH v6 08/18] vmxnet3: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 8 
 1 file changed, 8 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c 
b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index a1eac45..89b600b 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -649,9 +649,17 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
struct ipv4_hdr *ip = (struct ipv4_hdr *)(eth + 1);

if (((ip->version_ihl & 0xf) << 2) > (int)sizeof(struct 
ipv4_hdr))
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rxm->packet_type = RTE_PTYPE_L3_IPV4_EXT;
+#else
rxm->ol_flags |= PKT_RX_IPV4_HDR_EXT;
+#endif
else
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rxm->packet_type = RTE_PTYPE_L3_IPV4;
+#else
rxm->ol_flags |= PKT_RX_IPV4_HDR;
+#endif

if (!rcd->cnc) {
if (!rcd->ipc)
-- 
1.9.3



[dpdk-dev] [PATCH v6 07/18] enic: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 drivers/net/enic/enic_main.c | 26 ++
 1 file changed, 26 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 15313c2..50cd8c9 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -423,7 +423,11 @@ static int enic_rq_indicate_buf(struct vnic_rq *rq,
rx_pkt->pkt_len = bytes_written;

if (ipv4) {
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rx_pkt->packet_type = RTE_PTYPE_L3_IPV4;
+#else
rx_pkt->ol_flags |= PKT_RX_IPV4_HDR;
+#endif
if (!csum_not_calc) {
if (unlikely(!ipv4_csum_ok))
rx_pkt->ol_flags |= PKT_RX_IP_CKSUM_BAD;
@@ -432,7 +436,11 @@ static int enic_rq_indicate_buf(struct vnic_rq *rq,
rx_pkt->ol_flags |= PKT_RX_L4_CKSUM_BAD;
}
} else if (ipv6)
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rx_pkt->packet_type = RTE_PTYPE_L3_IPV6;
+#else
rx_pkt->ol_flags |= PKT_RX_IPV6_HDR;
+#endif
} else {
/* Header split */
if (sop && !eop) {
@@ -445,7 +453,11 @@ static int enic_rq_indicate_buf(struct vnic_rq *rq,
*rx_pkt_bucket = rx_pkt;
rx_pkt->pkt_len = bytes_written;
if (ipv4) {
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rx_pkt->packet_type = RTE_PTYPE_L3_IPV4;
+#else
rx_pkt->ol_flags |= PKT_RX_IPV4_HDR;
+#endif
if (!csum_not_calc) {
if (unlikely(!ipv4_csum_ok))
rx_pkt->ol_flags |=
@@ -457,13 +469,22 @@ static int enic_rq_indicate_buf(struct vnic_rq *rq,
PKT_RX_L4_CKSUM_BAD;
}
} else if (ipv6)
+#ifdef RTE_UNIFIED_PKT_TYPE
+   rx_pkt->packet_type = RTE_PTYPE_L3_IPV6;
+#else
rx_pkt->ol_flags |= PKT_RX_IPV6_HDR;
+#endif
} else {
/* Payload */
hdr_rx_pkt = *rx_pkt_bucket;
hdr_rx_pkt->pkt_len += bytes_written;
if (ipv4) {
+#ifdef RTE_UNIFIED_PKT_TYPE
+   hdr_rx_pkt->packet_type =
+   RTE_PTYPE_L3_IPV4;
+#else
hdr_rx_pkt->ol_flags |= PKT_RX_IPV4_HDR;
+#endif
if (!csum_not_calc) {
if (unlikely(!ipv4_csum_ok))
hdr_rx_pkt->ol_flags |=
@@ -475,7 +496,12 @@ static int enic_rq_indicate_buf(struct vnic_rq *rq,
PKT_RX_L4_CKSUM_BAD;
}
} else if (ipv6)
+#ifdef RTE_UNIFIED_PKT_TYPE
+   hdr_rx_pkt->packet_type =
+   RTE_PTYPE_L3_IPV6;
+#else
hdr_rx_pkt->ol_flags |= PKT_RX_IPV6_HDR;
+#endif

}
}
-- 
1.9.3



[dpdk-dev] [PATCH v6 06/18] i40e: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_rxtx.c | 528 +++
 1 file changed, 528 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 787f0bd..e20c98d 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -151,6 +151,514 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
return flags;
 }

+#ifdef RTE_UNIFIED_PKT_TYPE
+/* For each value it means, datasheet of hardware can tell more details */
+static inline uint32_t
+i40e_rxd_pkt_type_mapping(uint8_t ptype)
+{
+   static const uint32_t ptype_table[UINT8_MAX] __rte_cache_aligned = {
+   /* L2 types */
+   /* [0] reserved */
+   [1] = RTE_PTYPE_L2_MAC,
+   [2] = RTE_PTYPE_L2_MAC_TIMESYNC,
+   /* [3] - [5] reserved */
+   [6] = RTE_PTYPE_L2_LLDP,
+   /* [7] - [10] reserved */
+   [11] = RTE_PTYPE_L2_ARP,
+   /* [12] - [21] reserved */
+
+   /* Non tunneled IPv4 */
+   [22] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_L4_FRAG,
+   [23] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_L4_NONFRAG,
+   [24] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_L4_UDP,
+   /* [25] reserved */
+   [26] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_L4_TCP,
+   [27] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_L4_SCTP,
+   [28] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_L4_ICMP,
+
+   /* IPv4 --> IPv4 */
+   [29] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_FRAG,
+   [30] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_NONFRAG,
+   [31] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_UDP,
+   /* [32] reserved */
+   [33] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_TCP,
+   [34] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_SCTP,
+   [35] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_ICMP,
+
+   /* IPv4 --> IPv6 */
+   [36] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_FRAG,
+   [37] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_NONFRAG,
+   [38] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_UDP,
+   /* [39] reserved */
+   [40] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_TCP,
+   [41] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+   RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+   RTE_PTYPE_INNER_L4_SCTP,
+   

[dpdk-dev] [PATCH v6 05/18] ixgbe: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet type among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.
Note that around 2.5% performance drop (64B) was observed of doing
4 ports (1 port per 82599 card) IO forwarding on the same SNB core.

Signed-off-by: Helin Zhang 
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 163 +
 1 file changed, 163 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 4f9ab22..c4d9b02 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -855,6 +855,110 @@ end_of_tx:
  *  RX functions
  *
  **/
+#ifdef RTE_UNIFIED_PKT_TYPE
+#define IXGBE_PACKET_TYPE_IPV4  0X01
+#define IXGBE_PACKET_TYPE_IPV4_TCP  0X11
+#define IXGBE_PACKET_TYPE_IPV4_UDP  0X21
+#define IXGBE_PACKET_TYPE_IPV4_SCTP 0X41
+#define IXGBE_PACKET_TYPE_IPV4_EXT  0X03
+#define IXGBE_PACKET_TYPE_IPV4_EXT_SCTP 0X43
+#define IXGBE_PACKET_TYPE_IPV6  0X04
+#define IXGBE_PACKET_TYPE_IPV6_TCP  0X14
+#define IXGBE_PACKET_TYPE_IPV6_UDP  0X24
+#define IXGBE_PACKET_TYPE_IPV6_EXT  0X0C
+#define IXGBE_PACKET_TYPE_IPV6_EXT_TCP  0X1C
+#define IXGBE_PACKET_TYPE_IPV6_EXT_UDP  0X2C
+#define IXGBE_PACKET_TYPE_IPV4_IPV6 0X05
+#define IXGBE_PACKET_TYPE_IPV4_IPV6_TCP 0X15
+#define IXGBE_PACKET_TYPE_IPV4_IPV6_UDP 0X25
+#define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT 0X0D
+#define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_TCP 0X1D
+#define IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_UDP 0X2D
+#define IXGBE_PACKET_TYPE_MAX   0X80
+#define IXGBE_PACKET_TYPE_MASK  0X7F
+#define IXGBE_PACKET_TYPE_SHIFT 0X04
+static inline uint32_t
+ixgbe_rxd_pkt_info_to_pkt_type(uint16_t pkt_info)
+{
+   static const uint32_t
+   ptype_table[IXGBE_PACKET_TYPE_MAX] __rte_cache_aligned = {
+   [IXGBE_PACKET_TYPE_IPV4] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4,
+   [IXGBE_PACKET_TYPE_IPV4_EXT] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4_EXT,
+   [IXGBE_PACKET_TYPE_IPV6] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6,
+   [IXGBE_PACKET_TYPE_IPV4_IPV6] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6,
+   [IXGBE_PACKET_TYPE_IPV6_EXT] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT,
+   [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT,
+   [IXGBE_PACKET_TYPE_IPV4_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+   [IXGBE_PACKET_TYPE_IPV6_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+   [IXGBE_PACKET_TYPE_IPV4_IPV6_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_TCP,
+   [IXGBE_PACKET_TYPE_IPV6_EXT_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_TCP,
+   [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_TCP,
+   [IXGBE_PACKET_TYPE_IPV4_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [IXGBE_PACKET_TYPE_IPV6_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   [IXGBE_PACKET_TYPE_IPV4_IPV6_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_UDP,
+   [IXGBE_PACKET_TYPE_IPV6_EXT_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_UDP,
+   [IXGBE_PACKET_TYPE_IPV4_IPV6_EXT_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_UDP,
+   [IXGBE_PACKET_TYPE_IPV4_SCTP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP,
+   [IXGBE_PACKET_TYPE_IPV4_EXT_SCTP] = RTE_PTYPE_L2_MAC |
+ 

[dpdk-dev] [PATCH v6 04/18] e1000: replace bit mask based packet type with unified packet type

2015-06-01 Thread Helin Zhang
To unify packet types among all PMDs, bit masks of packet type for
'ol_flags' are replaced by unified packet type.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 drivers/net/e1000/igb_rxtx.c | 102 +++
 1 file changed, 102 insertions(+)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index f586311..112b876 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -590,6 +590,99 @@ eth_igb_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
  *  RX functions
  *
  **/
+#ifdef RTE_UNIFIED_PKT_TYPE
+#define IGB_PACKET_TYPE_IPV4  0X01
+#define IGB_PACKET_TYPE_IPV4_TCP  0X11
+#define IGB_PACKET_TYPE_IPV4_UDP  0X21
+#define IGB_PACKET_TYPE_IPV4_SCTP 0X41
+#define IGB_PACKET_TYPE_IPV4_EXT  0X03
+#define IGB_PACKET_TYPE_IPV4_EXT_SCTP 0X43
+#define IGB_PACKET_TYPE_IPV6  0X04
+#define IGB_PACKET_TYPE_IPV6_TCP  0X14
+#define IGB_PACKET_TYPE_IPV6_UDP  0X24
+#define IGB_PACKET_TYPE_IPV6_EXT  0X0C
+#define IGB_PACKET_TYPE_IPV6_EXT_TCP  0X1C
+#define IGB_PACKET_TYPE_IPV6_EXT_UDP  0X2C
+#define IGB_PACKET_TYPE_IPV4_IPV6 0X05
+#define IGB_PACKET_TYPE_IPV4_IPV6_TCP 0X15
+#define IGB_PACKET_TYPE_IPV4_IPV6_UDP 0X25
+#define IGB_PACKET_TYPE_IPV4_IPV6_EXT 0X0D
+#define IGB_PACKET_TYPE_IPV4_IPV6_EXT_TCP 0X1D
+#define IGB_PACKET_TYPE_IPV4_IPV6_EXT_UDP 0X2D
+#define IGB_PACKET_TYPE_MAX   0X80
+#define IGB_PACKET_TYPE_MASK  0X7F
+#define IGB_PACKET_TYPE_SHIFT 0X04
+static inline uint32_t
+igb_rxd_pkt_info_to_pkt_type(uint16_t pkt_info)
+{
+   static const uint32_t
+   ptype_table[IGB_PACKET_TYPE_MAX] __rte_cache_aligned = {
+   [IGB_PACKET_TYPE_IPV4] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV4,
+   [IGB_PACKET_TYPE_IPV4_EXT] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4_EXT,
+   [IGB_PACKET_TYPE_IPV6] = RTE_PTYPE_L2_MAC | RTE_PTYPE_L3_IPV6,
+   [IGB_PACKET_TYPE_IPV4_IPV6] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6,
+   [IGB_PACKET_TYPE_IPV6_EXT] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT,
+   [IGB_PACKET_TYPE_IPV4_IPV6_EXT] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT,
+   [IGB_PACKET_TYPE_IPV4_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+   [IGB_PACKET_TYPE_IPV6_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+   [IGB_PACKET_TYPE_IPV4_IPV6_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_TCP,
+   [IGB_PACKET_TYPE_IPV6_EXT_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_TCP,
+   [IGB_PACKET_TYPE_IPV4_IPV6_EXT_TCP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_TCP,
+   [IGB_PACKET_TYPE_IPV4_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [IGB_PACKET_TYPE_IPV6_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   [IGB_PACKET_TYPE_IPV4_IPV6_UDP] =  RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_UDP,
+   [IGB_PACKET_TYPE_IPV6_EXT_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_UDP,
+   [IGB_PACKET_TYPE_IPV4_IPV6_EXT_UDP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
+   RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_UDP,
+   [IGB_PACKET_TYPE_IPV4_SCTP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP,
+   [IGB_PACKET_TYPE_IPV4_EXT_SCTP] = RTE_PTYPE_L2_MAC |
+   RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_SCTP,
+   };
+   if (unlikely(pkt_info & E1000_RXDADV_PKTTYPE_ETQF))
+   return RTE_PTYPE_UNKNOWN;
+
+   pkt_info = (pkt_info >> 

[dpdk-dev] [PATCH v6 03/18] mbuf: add definitions of unified packet types

2015-06-01 Thread Helin Zhang
As there are only 6 bit flags in ol_flags for indicating packet
types, which is not enough to describe all the possible packet
types hardware can recognize. For example, i40e hardware can
recognize more than 150 packet types. Unified packet type is
composed of L2 type, L3 type, L4 type, tunnel type, inner L2 type,
inner L3 type and inner L4 type fields, and can be stored in
'struct rte_mbuf' of 32 bits field 'packet_type'.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
---
 lib/librte_mbuf/rte_mbuf.h | 487 +
 1 file changed, 487 insertions(+)

v3 changes:
* Put the definitions of unified packet type into a single patch.

v4 changes:
* Added detailed description of each packet types.

v5 changes:
* Re-worded the commit logs.
* Added more detailed description for all packet types, together with examples.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index a8662c2..94e51cd 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -195,6 +195,493 @@ extern "C" {
 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG   (1ULL << 63) /**< Mbuf contains control data */

+#ifdef RTE_UNIFIED_PKT_TYPE
+/*
+ * 32 bits are divided into several fields to mark packet types. Note that
+ * each field is indexical.
+ * - Bit 3:0 is for L2 types.
+ * - Bit 7:4 is for L3 or outer L3 (for tunneling case) types.
+ * - Bit 11:8 is for L4 or outer L4 (for tunneling case) types.
+ * - Bit 15:12 is for tunnel types.
+ * - Bit 19:16 is for inner L2 types.
+ * - Bit 23:20 is for inner L3 types.
+ * - Bit 27:24 is for inner L4 types.
+ * - Bit 31:28 is reserved.
+ *
+ * To be compatible with Vector PMD, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV4_EXT,
+ * RTE_PTYPE_L3_IPV6, RTE_PTYPE_L3_IPV6_EXT, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP
+ * and RTE_PTYPE_L4_SCTP should be kept as below in a contiguous 7 bits.
+ *
+ * Note that L3 types values are selected for checking IPV4/IPV6 header from
+ * performance point of view. Reading annotations of RTE_ETH_IS_IPV4_HDR and
+ * RTE_ETH_IS_IPV6_HDR is needed for any future changes of L3 type values.
+ *
+ * Note that the packet types of the same packet recognized by different
+ * hardware may be different, as different hardware may have different
+ * capability of packet type recognition.
+ *
+ * examples:
+ * <'ether type'=0x0800
+ * | 'version'=4, 'protocol'=0x29
+ * | 'version'=6, 'next header'=0x3A
+ * | 'ICMPv6 header'>
+ * will be recognized on i40e hardware as packet type combination of,
+ * RTE_PTYPE_L2_MAC |
+ * RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
+ * RTE_PTYPE_TUNNEL_IP |
+ * RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+ * RTE_PTYPE_INNER_L4_ICMP.
+ *
+ * <'ether type'=0x86DD
+ * | 'version'=6, 'next header'=0x2F
+ * | 'GRE header'
+ * | 'version'=6, 'next header'=0x11
+ * | 'UDP header'>
+ * will be recognized on i40e hardware as packet type combination of,
+ * RTE_PTYPE_L2_MAC |
+ * RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
+ * RTE_PTYPE_TUNNEL_GRENAT |
+ * RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
+ * RTE_PTYPE_INNER_L4_UDP.
+ */
+#define RTE_PTYPE_UNKNOWN   0x
+/**
+ * MAC (Media Access Control) packet type.
+ * It is used for outer packet for tunneling cases.
+ *
+ * Packet format:
+ * <'ether type'=[0x0800|0x86DD|others]>
+ */
+#define RTE_PTYPE_L2_MAC0x0001
+/**
+ * MAC (Media Access Control) packet type for time sync.
+ *
+ * Packet format:
+ * <'ether type'=0x88F7>
+ */
+#define RTE_PTYPE_L2_MAC_TIMESYNC   0x0002
+/**
+ * ARP (Address Resolution Protocol) packet type.
+ *
+ * Packet format:
+ * <'ether type'=0x0806>
+ */
+#define RTE_PTYPE_L2_ARP0x0003
+/**
+ * LLDP (Link Layer Discovery Protocol) packet type.
+ *
+ * Packet format:
+ * <'ether type'=0x88CC>
+ */
+#define RTE_PTYPE_L2_LLDP   0x0004
+/**
+ * Mask of layer 2 packet types.
+ * It is used for outer packet for tunneling cases.
+ */
+#define RTE_PTYPE_L2_MASK   0x000f
+/**
+ * IP (Internet Protocol) version 4 packet type.
+ * It is used for outer packet for tunneling cases, and does not contain any
+ * header option.
+ *
+ * Packet format:
+ * <'ether type'=0x0800
+ * | 'version'=4, 'ihl'=5>
+ */
+#define RTE_PTYPE_L3_IPV4   0x0010
+/**
+ * IP (Internet Protocol) version 4 packet type.
+ * It is used for outer packet for tunneling cases, and contains header
+ * options.
+ *
+ * Packet format:
+ * <'ether type'=0x0800
+ * | 'version'=4, 'ihl'=[6-15], 'options'>
+ */
+#define RTE_PTYPE_L3_IPV4_EXT   0x0030
+/**
+ * IP (Internet Protocol) version 6 packet type.
+ * It is used for outer packet for tunneling cases, and does not contain any
+ * extension header.
+ *

[dpdk-dev] [PATCH v6 02/18] ixgbe: support unified packet type in vectorized PMD

2015-06-01 Thread Helin Zhang
To unify the packet type, bit masks of packet type for ol_flags are
replaced. In addition, more packet types (UDP, TCP and SCTP) are
supported in vectorized ixgbe PMD.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.
Note that around 2% performance drop (64B) was observed of doing 4
ports (1 port per 82599 card) IO forwarding on the same SNB core.

Signed-off-by: Cunming Liang 
Signed-off-by: Helin Zhang 
---
 config/common_linuxapp |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx_vec.c | 75 +-
 2 files changed, 74 insertions(+), 3 deletions(-)

v2 changes:
* Used redefined packet types and enlarged packet_type field in mbuf.

v3 changes:
* Put vector ixgbe changes right after mbuf changes.
* Enabled vector ixgbe PMD by default together with changes for updated
  vector PMD.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 6b067c7..0078dc9 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -167,7 +167,7 @@ CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX_FREE=n
 CONFIG_RTE_LIBRTE_IXGBE_DEBUG_DRIVER=n
 CONFIG_RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC=n
 CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
-CONFIG_RTE_IXGBE_INC_VECTOR=n
+CONFIG_RTE_IXGBE_INC_VECTOR=y
 CONFIG_RTE_IXGBE_RX_OLFLAGS_ENABLE=y

 #
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
index abd10f6..382c949 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec.c
@@ -134,6 +134,12 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
  */
 #ifdef RTE_IXGBE_RX_OLFLAGS_ENABLE

+#ifdef RTE_UNIFIED_PKT_TYPE
+#define OLFLAGS_MASK_V  (((uint64_t)PKT_RX_VLAN_PKT << 48) | \
+   ((uint64_t)PKT_RX_VLAN_PKT << 32) | \
+   ((uint64_t)PKT_RX_VLAN_PKT << 16) | \
+   ((uint64_t)PKT_RX_VLAN_PKT))
+#else
 #define OLFLAGS_MASK ((uint16_t)(PKT_RX_VLAN_PKT | PKT_RX_IPV4_HDR |\
 PKT_RX_IPV4_HDR_EXT | PKT_RX_IPV6_HDR |\
 PKT_RX_IPV6_HDR_EXT))
@@ -142,11 +148,26 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)
  ((uint64_t)OLFLAGS_MASK << 16) | \
  ((uint64_t)OLFLAGS_MASK))
 #define PTYPE_SHIFT(1)
+#endif /* RTE_UNIFIED_PKT_TYPE */
+
 #define VTAG_SHIFT (3)

 static inline void
 desc_to_olflags_v(__m128i descs[4], struct rte_mbuf **rx_pkts)
 {
+#ifdef RTE_UNIFIED_PKT_TYPE
+   __m128i vtag0, vtag1;
+   union {
+   uint16_t e[4];
+   uint64_t dword;
+   } vol;
+
+   vtag0 = _mm_unpackhi_epi16(descs[0], descs[1]);
+   vtag1 = _mm_unpackhi_epi16(descs[2], descs[3]);
+   vtag1 = _mm_unpacklo_epi32(vtag0, vtag1);
+   vtag1 = _mm_srli_epi16(vtag1, VTAG_SHIFT);
+   vol.dword = _mm_cvtsi128_si64(vtag1) & OLFLAGS_MASK_V;
+#else
__m128i ptype0, ptype1, vtag0, vtag1;
union {
uint16_t e[4];
@@ -166,6 +187,7 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)

ptype1 = _mm_or_si128(ptype1, vtag1);
vol.dword = _mm_cvtsi128_si64(ptype1) & OLFLAGS_MASK_V;
+#endif /* RTE_UNIFIED_PKT_TYPE */

rx_pkts[0]->ol_flags = vol.e[0];
rx_pkts[1]->ol_flags = vol.e[1];
@@ -196,6 +218,18 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
int pos;
uint64_t var;
__m128i shuf_msk;
+#ifdef RTE_UNIFIED_PKT_TYPE
+   __m128i crc_adjust = _mm_set_epi16(
+   0, 0, 0,/* ignore non-length fields */
+   -rxq->crc_len, /* sub crc on data_len */
+   0,  /* ignore high-16bits of pkt_len */
+   -rxq->crc_len, /* sub crc on pkt_len */
+   0, 0/* ignore pkt_type field */
+   );
+   __m128i dd_check, eop_check;
+   __m128i desc_mask = _mm_set_epi32(0x, 0x,
+ 0x, 0x07F0);
+#else
__m128i crc_adjust = _mm_set_epi16(
0, 0, 0, 0, /* ignore non-length fields */
0,  /* ignore high-16bits of pkt_len */
@@ -204,6 +238,7 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
0/* ignore pkt_type field */
);
__m128i dd_check, eop_check;
+#endif /* RTE_UNIFIED_PKT_TYPE */

if (unlikely(nb_pkts < RTE_IXGBE_VPMD_RX_BURST))
return 0;
@@ -232,6 +267,18 @@ _recv_raw_pkts_vec(struct ixgbe_rx_queue *rxq, struct 
rte_mbuf **rx_pkts,
eop_check = 

[dpdk-dev] [PATCH v6 01/18] mbuf: redefine packet_type in rte_mbuf

2015-06-01 Thread Helin Zhang
In order to unify the packet type, the field of 'packet_type' in
'struct rte_mbuf' needs to be extended from 16 to 32 bits.
Accordingly, some fields in 'struct rte_mbuf' are re-organized to
support this change for Vector PMD. As 'struct rte_kni_mbuf' for
KNI should be right mapped to 'struct rte_mbuf', it should be
modified accordingly. In addition, Vector PMD of ixgbe is disabled
by default, as 'struct rte_mbuf' changed.
To avoid breaking ABI compatibility, all the changes would be
enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

Signed-off-by: Helin Zhang 
Signed-off-by: Cunming Liang 
---
 config/common_linuxapp |  2 +-
 .../linuxapp/eal/include/exec-env/rte_kni_common.h |  6 ++
 lib/librte_mbuf/rte_mbuf.h | 23 ++
 3 files changed, 30 insertions(+), 1 deletion(-)

v2 changes:
* Enlarged the packet_type field from 16 bits to 32 bits.
* Redefined the packet type sub-fields.
* Updated the 'struct rte_kni_mbuf' for KNI according to the mbuf changes.

v3 changes:
* Put the mbuf layout changes into a single patch.
* Disabled vector ixgbe PMD by default, as mbuf layout changed.

v5 changes:
* Re-worded the commit logs.

v6 changes:
* Disabled the code changes for unified packet type by default, to
  avoid breaking ABI compatibility.

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..6b067c7 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -167,7 +167,7 @@ CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX_FREE=n
 CONFIG_RTE_LIBRTE_IXGBE_DEBUG_DRIVER=n
 CONFIG_RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC=n
 CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
-CONFIG_RTE_IXGBE_INC_VECTOR=y
+CONFIG_RTE_IXGBE_INC_VECTOR=n
 CONFIG_RTE_IXGBE_RX_OLFLAGS_ENABLE=y

 #
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h 
b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index 1e55c2d..7a2abbb 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -117,9 +117,15 @@ struct rte_kni_mbuf {
uint16_t data_off;  /**< Start address of data in segment buffer. */
char pad1[4];
uint64_t ol_flags;  /**< Offload features. */
+#ifdef RTE_UNIFIED_PKT_TYPE
+   char pad2[4];
+   uint32_t pkt_len;   /**< Total pkt len: sum of all segment 
data_len. */
+   uint16_t data_len;  /**< Amount of data in segment buffer. */
+#else
char pad2[2];
uint16_t data_len;  /**< Amount of data in segment buffer. */
uint32_t pkt_len;   /**< Total pkt len: sum of all segment 
data_len. */
+#endif

/* fields on second cache line */
char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ab6de67..a8662c2 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -269,6 +269,28 @@ struct rte_mbuf {
/* remaining bytes are set on RX when pulling packet from descriptor */
MARKER rx_descriptor_fields1;

+#ifdef RTE_UNIFIED_PKT_TYPE
+   /*
+* The packet type, which is the combination of outer/inner L2, L3, L4
+* and tunnel types.
+*/
+   union {
+   uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
+   struct {
+   uint32_t l2_type:4; /**< (Outer) L2 type. */
+   uint32_t l3_type:4; /**< (Outer) L3 type. */
+   uint32_t l4_type:4; /**< (Outer) L4 type. */
+   uint32_t tun_type:4; /**< Tunnel type. */
+   uint32_t inner_l2_type:4; /**< Inner L2 type. */
+   uint32_t inner_l3_type:4; /**< Inner L3 type. */
+   uint32_t inner_l4_type:4; /**< Inner L4 type. */
+   };
+   };
+
+   uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
+   uint16_t data_len;/**< Amount of data in segment buffer. */
+   uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
+#else
/**
 * The packet type, which is used to indicate ordinary packet and also
 * tunneled packet format, i.e. each number is represented a type of
@@ -280,6 +302,7 @@ struct rte_mbuf {
uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
uint16_t reserved;
+#endif
union {
uint32_t rss; /**< RSS hash result if RSS enabled */
struct {
-- 
1.9.3



[dpdk-dev] 答复: How to set timestamp in 82599 NICs in DPDK?

2015-06-01 Thread 科来 谭春海
Hi Keunhong,



Thanks for your response. Seems ixgbe only supports hw timestamping for PTP 
packets. But I still don?t understand why igb and e1000 support hw timestamping 
all packets while ixgbe does not.



???: Keunhong Lee [mailto:dlrmsghd at gmail.com] 
: 2015?6?1? 11:51
???: ?? ???
??: dev at dpdk.org
??: Re: [dpdk-dev] How to set timestamp in 82599 NICs in DPDK?



http://dpdk.org/browse/dpdk/tree/app/test-pmd/ieee1588fwd.c



This code example contains enabling PTP with intel NICs.



Keunhong.







2015-06-01 12:48 GMT+09:00 Keunhong Lee :

82599 supports hw timestamping for PTP packets.

I don't know whether it supports timestamping for general packets.





http://lxr.free-electrons.com/source/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c#L640

says that

 

 640 default:
 

 641 /*
 

 642  * register RXMTRL must be set in order to do V1 packets,
 

 643  * therefore it is not possible to time stamp both V1 Sync 
and
 

 644  * Delay_Req messages and hardware does not support
 

 645  * timestamping all packets => return error
 

 646  */
 

 647   
config->rx_filter = HWTSTAMP_FILTER_NONE;
 

 648 return -  
ERANGE;
 

 649 }



Keunhong.



2015-06-01 11:38 GMT+09:00 ?? ??? :

Hi



I noticed that there is a patch which can set hardware timestamp for the
received
packets(http://www.wand.net.nz/trac/libtrace/browser/Intel%20DPDK%20Patches/ 

 
hardware_timestamp.patch?rev=ce7153dbc6a13c18bf8033af08c1249527754168), but
it only works in e1000 and igb NICs. I want to capture packets with
timestamp info in 82599 NICs, what should I do? Could you give me some help?



Thanks.



Chunhai Tan












[dpdk-dev] [PATCH v2] lib_vhost:reset secure_len when rte_atomic16_cmpset failed

2015-06-01 Thread Wei li
when rte_atomic16_cmpset return 0 in first loop, secure_len
 should be reset to 0 in second loop, otherwise (pkt_len > secure_len) always
 be false, the num of desc maybe not enough

Signed-off-by: Wei li 
---
 lib/librte_vhost/vhost_rxtx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

v1->v2
add more descriotion
delete unnecessary variable assignment

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 4809d32..b7e356c 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -418,7 +418,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
return 0;

for (pkt_idx = 0; pkt_idx < count; pkt_idx++) {
-   uint32_t secure_len = 0;
+   uint32_t secure_len;
uint16_t need_cnt;
uint32_t vec_idx = 0;
uint32_t pkt_len = pkts[pkt_idx]->pkt_len + vq->vhost_hlen;
@@ -431,6 +431,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
 */
res_base_idx = vq->last_used_idx_res;
res_cur_idx = res_base_idx;
+   secure_len = 0;

do {
avail_idx = *((volatile uint16_t 
*)>avail->idx);
-- 
1.9.5.msysgit.1




[dpdk-dev] [PATCH] app/testpmd: fix default RX/TX flow control values

2015-06-01 Thread David Marchand
From: Ding Zhi 

This variable has undefined values in some cases.

Fixes: 422a20a4e62d ("app/testpmd: fix uninitialized flow control variables")
Signed-off-by: Ding Zhi 
Signed-off-by: David Marchand 
---
 app/test-pmd/cmdline.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f01db2a..aec7a0b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4743,7 +4743,7 @@ cmd_link_flow_ctrl_set_parsed(void *parsed_result,
struct cmd_link_flow_ctrl_set_result *res = parsed_result;
cmdline_parse_inst_t *cmd = data;
struct rte_eth_fc_conf fc_conf;
-   int rx_fc_en, tx_fc_en = 0;
+   int rx_fc_en = 0, tx_fc_en = 0;
int ret;

/*
-- 
1.7.10.4



[dpdk-dev] [PATCH] app/test: fix default memory assignment

2015-06-01 Thread David Marchand
From: Gaetan Rivet 

Each test requires a certain minimal amount of memory.
Spreading memory on all sockets means that the test will get less memory than
what it wanted on multi sockets system.
So replace all_sockets() with per_sockets().

Also doubled memory on group_5 as current requirement is not enough.

Signed-off-by: Gaetan Rivet 
Signed-off-by: David Marchand 
---
 app/test/autotest_data.py |   61 ++---
 1 file changed, 30 insertions(+), 31 deletions(-)

diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 618a946..0c3802b 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -43,11 +43,10 @@ def num_sockets():
return 1
return result

-# spread given number for all sockets
-# e.g. 32 becomes 16,16 or 8,8,8,8 etc.
-def all_sockets(num):
-   mem_per_socket = num / num_sockets()
-   return ",".join([str(mem_per_socket)] * num_sockets())
+# Assign given number to each socket
+# e.g. 32 becomes 32,32 or 32,32,32,32
+def per_sockets(num):
+return ",".join([str(num)] * num_sockets())

 # groups of tests that can be run in parallel
 # the grouping has been found largely empirically
@@ -55,8 +54,8 @@ parallel_test_group_list = [

 {
"Prefix":   "group_1",
-   "Memory" :  all_sockets(8),
-   "Tests" :   
+   "Memory" :  per_sockets(8),
+   "Tests" :
[
{
 "Name" :   "Timer autotest",
@@ -69,7 +68,7 @@ parallel_test_group_list = [
 "Command" :"debug_autotest",
 "Func" :   default_autotest,
 "Report" : None,
-   },  
+   },
{
 "Name" :   "Errno autotest",
 "Command" :"errno_autotest",
@@ -87,7 +86,7 @@ parallel_test_group_list = [
 "Command" :"common_autotest",
 "Func" :   default_autotest,
 "Report" : None,
-   },  
+   },
{
 "Name" :   "Dump log history",
 "Command" :"dump_log_history",
@@ -111,7 +110,7 @@ parallel_test_group_list = [
 {
"Prefix":   "group_2",
"Memory" :  "32",
-   "Tests" :   
+   "Tests" :
[
{
 "Name" :   "Memory autotest",
@@ -165,8 +164,8 @@ parallel_test_group_list = [
 },
 {
"Prefix":   "group_3",
-   "Memory" :  all_sockets(1024),
-   "Tests" :   
+   "Memory" :  per_sockets(1024),
+   "Tests" :
[
{
 "Name" :   "LPM autotest",
@@ -208,8 +207,8 @@ parallel_test_group_list = [
 },
 {
"Prefix":   "group_4",
-   "Memory" :  all_sockets(128),
-   "Tests" :   
+   "Memory" :  per_sockets(128),
+   "Tests" :
[
{
 "Name" :   "PCI autotest",
@@ -251,8 +250,8 @@ parallel_test_group_list = [
 },
 {
"Prefix":   "group_5",
-   "Memory" :  "16",
-   "Tests" :   
+   "Memory" :  "32",
+   "Tests" :
[
{
 "Name" :   "Spinlock autotest",
@@ -288,8 +287,8 @@ parallel_test_group_list = [
 },
 {
"Prefix":   "group_6",
-   "Memory" :  all_sockets(620),
-   "Tests" :   
+   "Memory" :  per_sockets(620),
+   "Tests" :
[
{
 "Name" :   "Function reentrancy autotest",
@@ -368,8 +367,8 @@ non_parallel_test_group_list = [
 },
 {
"Prefix":   "mempool_perf",
-   "Memory" :  all_sockets(256),
-   "Tests" :   
+   "Memory" :  per_sockets(256),
+   "Tests" :
[
{
 "Name" :   "Cycles autotest",
@@ -387,8 +386,8 @@ non_parallel_test_group_list = [
 },
 {
"Prefix":   "memcpy_perf",
-   "Memory" :  all_sockets(512),
-   "Tests" :   
+   "Memory" :  per_sockets(512),
+   "Tests" :
[
{
 "Name" :   "Memcpy performance autotest",
@@ -400,8 +399,8 @@ non_parallel_test_group_list = [
 },
 {
"Prefix":   "hash_perf",
-   "Memory" :  all_sockets(512),
-   "Tests" :   
+   "Memory" :  per_sockets(512),
+   "Tests" :
[
{
 "Name" :   "Hash performance autotest",
@@ -413,7 +412,7 @@ non_parallel_test_group_list = [
 },
 {
"Prefix" :  "power",
-   "Memory" :  all_sockets(512),
+   "Memory" :  per_sockets(512),
"Tests" :
[
{
@@ -426,7 +425,7 @@ non_parallel_test_group_list = [
 },
 {
"Prefix" :  "power_acpi_cpufreq",
-   "Memory" :  all_sockets(512),
+   "Memory" :  per_sockets(512),

[dpdk-dev] How to set timestamp in 82599 NICs in DPDK?

2015-06-01 Thread Keunhong Lee
http://dpdk.org/browse/dpdk/tree/app/test-pmd/ieee1588fwd.c

This code example contains enabling PTP with intel NICs.

Keunhong.



2015-06-01 12:48 GMT+09:00 Keunhong Lee :

> 82599 supports hw timestamping for PTP packets.
> I don't know whether it supports timestamping for general packets.
>
>
>
> http://lxr.free-electrons.com/source/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c#L640
> says that
>
> 640 
> *
>  default:
> *641 
> *
>  /**642 
> *
>   * register RXMTRL must be set in order to do V1 
> packets,*643 
> *
>   * therefore it is not possible to time stamp both V1 Sync 
> and*644 
> 
>  * * Delay_Req messages and hardware does not support**
> 645 
> 
>   * timestamping all packets => return error
> *646 
> *
>   */*647 
> 
>  config 
> *->rx_filter = 
> HWTSTAMP_FILTER_NONE;
> *648 
> *
>  return -*ERANGE 
> *;
> *649 
> *
>  }*
>
>
> Keunhong.
>
> 2015-06-01 11:38 GMT+09:00 ?? ??? :
>
>> Hi
>>
>>
>>
>> I noticed that there is a patch which can set hardware timestamp for the
>> received
>> packets(
>> http://www.wand.net.nz/trac/libtrace/browser/Intel%20DPDK%20Patches/
>> hardware_timestamp.patch?rev=ce7153dbc6a13c18bf8033af08c1249527754168
>> ),
>> but
>> it only works in e1000 and igb NICs. I want to capture packets with
>> timestamp info in 82599 NICs, what should I do? Could you give me some
>> help?
>>
>>
>>
>> Thanks.
>>
>>
>>
>> Chunhai Tan
>>
>>
>>
>>
>>
>>
>


[dpdk-dev] How to set timestamp in 82599 NICs in DPDK?

2015-06-01 Thread Keunhong Lee
82599 supports hw timestamping for PTP packets.
I don't know whether it supports timestamping for general packets.


http://lxr.free-electrons.com/source/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c#L640
says that

640 
*
default:
*641 
*
/**642
*
 * register RXMTRL must be set in order to do V1
packets,*643 
*
 * therefore it is not possible to time stamp both V1
Sync and*644 

* * Delay_Req messages and hardware does not support**
645 

 * timestamping all packets => return error
*646 
*
 */*647

config
*->rx_filter =
HWTSTAMP_FILTER_NONE;
*648 
*
return -*ERANGE
*;
*649 
*
}*


Keunhong.

2015-06-01 11:38 GMT+09:00 ?? ??? :

> Hi
>
>
>
> I noticed that there is a patch which can set hardware timestamp for the
> received
> packets(
> http://www.wand.net.nz/trac/libtrace/browser/Intel%20DPDK%20Patches/
> hardware_timestamp.patch?rev=ce7153dbc6a13c18bf8033af08c1249527754168),
> but
> it only works in e1000 and igb NICs. I want to capture packets with
> timestamp info in 82599 NICs, what should I do? Could you give me some
> help?
>
>
>
> Thanks.
>
>
>
> Chunhai Tan
>
>
>
>
>
>


[dpdk-dev] [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs

2015-06-01 Thread David Harton (dharton)
Acked-by: David Harton (dharton) 

> -Original Message-
> From: Liang-Min Larry Wang [mailto:liang-min.wang at intel.com]
> Sent: Friday, May 29, 2015 8:38 PM
> To: dev at dpdk.org
> Cc: bruce.richardson at intel.com; konstantin.ananyev at intel.com; David 
> Harton
> (dharton); Andrew Harvey (agh); Liang-Min Larry Wang
> Subject: [PATCH 2/2] ethtool: add new library to provide ethtool-alike
> APIs
> 
> adding a new library based upon ethdev APIs to provide API's that bear
> the same functionality as ethtool_ops (linux/ethtool.h) and net_device_ops
> (linux/netdevice.h).
> 
> Signed-off-by: Liang-Min Larry Wang 
> ---
>  MAINTAINERS|   4 +
>  config/common_linuxapp |   5 +
>  lib/Makefile   |   1 +
>  lib/librte_ethtool/Makefile|  56 +++
>  lib/librte_ethtool/rte_ethtool.c   | 155 +
>  lib/librte_ethtool/rte_ethtool.h   | 257
> +
>  lib/librte_ethtool/rte_ethtool_version.map |  18 ++
>  mk/rte.app.mk  |   1 +
>  8 files changed, 497 insertions(+)
>  create mode 100644 lib/librte_ethtool/Makefile
>  create mode 100644 lib/librte_ethtool/rte_ethtool.c
>  create mode 100644 lib/librte_ethtool/rte_ethtool.h
>  create mode 100644 lib/librte_ethtool/rte_ethtool_version.map
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9362c19..b8b481f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -186,6 +186,10 @@ M: Thomas Monjalon 
>  F: lib/librte_ether/
>  F: scripts/test-null.sh
> 
> +Ethtool API
> +M: Liang-Min Larry Wang 
> +F: lib/librte_ethtool/
> +
> 
>  Drivers
>  ---
> diff --git a/config/common_linuxapp b/config/common_linuxapp
> index 0078dc9..f5759fd 100644
> --- a/config/common_linuxapp
> +++ b/config/common_linuxapp
> @@ -129,6 +129,11 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
>  CONFIG_RTE_LIBRTE_KVARGS=y
> 
>  #
> +# Compile user-space ethtool library
> +#
> +CONFIG_RTE_LIBRTE_ETHTOOL=y
> +
> +#
>  # Compile generic ethernet library
>  #
>  CONFIG_RTE_LIBRTE_ETHER=y
> diff --git a/lib/Makefile b/lib/Makefile
> index 5f480f9..a6c7375 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer
>  DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
>  DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
>  DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
> +DIRS-$(CONFIG_RTE_LIBRTE_ETHTOOL) += librte_ethtool
>  DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
>  DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
>  DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
> diff --git a/lib/librte_ethtool/Makefile b/lib/librte_ethtool/Makefile
> new file mode 100644
> index 000..1d981f6
> --- /dev/null
> +++ b/lib/librte_ethtool/Makefile
> @@ -0,0 +1,56 @@
> +#   BSD LICENSE
> +#
> +#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> +#   All rights reserved.
> +#
> +#   Redistribution and use in source and binary forms, with or without
> +#   modification, are permitted provided that the following conditions
> +#   are met:
> +#
> +# * Redistributions of source code must retain the above copyright
> +#   notice, this list of conditions and the following disclaimer.
> +# * Redistributions in binary form must reproduce the above copyright
> +#   notice, this list of conditions and the following disclaimer in
> +#   the documentation and/or other materials provided with the
> +#   distribution.
> +# * Neither the name of Intel Corporation nor the names of its
> +#   contributors may be used to endorse or promote products derived
> +#   from this software without specific prior written permission.
> +#
> +#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> +#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> +#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> +#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> +#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> +#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> +#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> +#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> +#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> +#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> +#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> +
> +include $(RTE_SDK)/mk/rte.vars.mk
> +
> +#
> +# library name
> +#
> +LIB = librte_ethtool.a
> +
> +CFLAGS += -O3
> +CFLAGS += $(WERROR_FLAGS)
> +
> +EXPORT_MAP := rte_ethtool_version.map
> +
> +LIBABIVER := 1
> +
> +SRCS-y += rte_ethtool.c
> +
> +#
> +# Export include files
> +#
> +SYMLINK-y-include += rte_ethtool.h
> +
> +# this lib depends upon:
> +DEPDIRS-y += lib/librte_ether
> +
> 

[dpdk-dev] [PATCH v2] log: Properly reset log_history_size in rte_log_dump_history()

2015-06-01 Thread Olivier MATZ

On 06/01/2015 11:30 AM, Jan Blunck wrote:
> In rte_log_dump_history() the log_history list is reinitialized without
> resetting the log_history_size. In the next call to rte_log_add_in_history()
> the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
> to remove the first entry:
> 
> Program received signal SIGSEGV, Segmentation fault.
> rte_log_add_in_history (
> buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK 
> [dp0s7] \nCAST,LOWER_UP>\n", 
> size=size at entry=86)
> at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122
> 
> Signed-off-by: Jan Blunck 

Acked-by: Olivier Matz 



> ---
>  lib/librte_eal/common/eal_common_log.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_log.c 
> b/lib/librte_eal/common/eal_common_log.c
> index fe3d7d5..39d6e3f 100644
> --- a/lib/librte_eal/common/eal_common_log.c
> +++ b/lib/librte_eal/common/eal_common_log.c
> @@ -119,7 +119,10 @@ rte_log_add_in_history(const char *buf, size_t size)
>   /* get a buffer for adding in history */
>   if (log_history_size > RTE_LOG_HISTORY) {
>   hist_buf = STAILQ_FIRST(_history);
> - STAILQ_REMOVE_HEAD(_history, next);
> + if (hist_buf) {
> + STAILQ_REMOVE_HEAD(_history, next);
> + log_history_size--;
> + }
>   }
>   else {
>   if (rte_mempool_mc_get(log_history_mp, ) < 0)
> @@ -234,6 +237,7 @@ rte_log_dump_history(FILE *out)
>   rte_spinlock_lock(_list_lock);
>   tmp_log_history = log_history;
>   STAILQ_INIT(_history);
> + log_history_size = 0;
>   rte_spinlock_unlock(_list_lock);
>  
>   for (i=0; i 


[dpdk-dev] [PATCH] log: Properly reset log_history_size in rte_log_dump_history()

2015-06-01 Thread Jan Blunck
On Mon, Jun 1, 2015 at 10:31 AM, Olivier MATZ 
wrote:

> Hi Jan,
>
> On 05/29/2015 12:34 PM, Jan Blunck wrote:
> > In rte_log_dump_history() the log_history list is reinitialized without
> > resetting the log_history_size. In the next call to
> rte_log_add_in_history()
> > the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
> > to remove the first entry:
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > rte_log_add_in_history (
> > buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK
> [dp0s7] \nCAST,LOWER_UP>\n",
> size=size at entry=86)
> > at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122
> >
> > Signed-off-by: Jan Blunck 
> > ---
> >  lib/librte_eal/common/eal_common_log.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/common/eal_common_log.c
> b/lib/librte_eal/common/eal_common_log.c
> > index fe3d7d5..cb4311c 100644
> > --- a/lib/librte_eal/common/eal_common_log.c
> > +++ b/lib/librte_eal/common/eal_common_log.c
> > @@ -119,7 +119,8 @@ rte_log_add_in_history(const char *buf, size_t size)
> >   /* get a buffer for adding in history */
> >   if (log_history_size > RTE_LOG_HISTORY) {
> >   hist_buf = STAILQ_FIRST(_history);
> > - STAILQ_REMOVE_HEAD(_history, next);
> > + if (hist_buf)
> > + STAILQ_REMOVE_HEAD(_history, next);
>
> Shouldn't we decrease log_history_size here?
>
>
Thanks for catching that one.


>
>
> Also, it's probably a bit off-topic, but I think the function that
> adds in history could be optimized a bit to avoid doing the copy with
> the lock held. Maybe something like this is feasible:
>
> rte_mempool_mc_get() into hist_buf
> memcpy(hist_buf->buf, buf, size);
> rte_spinlock_lock(_list_lock
> if (log_history_size > RTE_LOG_HISTORY) {
> STAILQ_REMOVE_HEAD
> log_history_size --
> }
> STAILQ_INSERT_TAIL
> log_history_size ++
> rte_spinlock_unlock(_list_lock)
>
> Feel free to implement it if you feel it's better. It would also
> require to increase the number of objects in the pool to
> RTE_LOG_HISTORY*2 + RTE_MAX_LCORE
>
>
Makes sense. I'll take a look into that one later.

Thanks,
Jan


> Regards,
> Olivier
>
>
>
> >   }
> >   else {
> >   if (rte_mempool_mc_get(log_history_mp, ) < 0)
> > @@ -234,6 +235,7 @@ rte_log_dump_history(FILE *out)
> >   rte_spinlock_lock(_list_lock);
> >   tmp_log_history = log_history;
> >   STAILQ_INIT(_history);
> > + log_history_size = 0;
> >   rte_spinlock_unlock(_list_lock);
> >
> >   for (i=0; i >
>


[dpdk-dev] [PATCH] mbuf: optimize first reference increment in rte_pktmbuf_attach

2015-06-01 Thread Olivier Matz
As it's done in __rte_pktmbuf_prefree_seg(), we can avoid using an
atomic increment in rte_pktmbuf_attach() by checking if we are the
only owner of the mbuf first.

Signed-off-by: Olivier Matz 
---
 lib/librte_mbuf/rte_mbuf.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ab6de67..cea35b7 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -838,7 +838,11 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, 
struct rte_mbuf *m)
else
md = rte_mbuf_from_indirect(m);

-   rte_mbuf_refcnt_update(md, 1);
+   /* optimize the case where we are the only owner */
+   if (likely(rte_mbuf_refcnt_read(md) == 1))
+   rte_mbuf_refcnt_set(md, 2);
+   else
+   rte_mbuf_refcnt_update(md, 1);
mi->priv_size = m->priv_size;
mi->buf_physaddr = m->buf_physaddr;
mi->buf_addr = m->buf_addr;
-- 
2.1.4



[dpdk-dev] [PATCH v2] log: Properly reset log_history_size in rte_log_dump_history()

2015-06-01 Thread Jan Blunck
In rte_log_dump_history() the log_history list is reinitialized without
resetting the log_history_size. In the next call to rte_log_add_in_history()
the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
to remove the first entry:

Program received signal SIGSEGV, Segmentation fault.
rte_log_add_in_history (
buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK 
[dp0s7] \nCAST,LOWER_UP>\n", size=size 
at entry=86)
at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122

Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/eal_common_log.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_log.c 
b/lib/librte_eal/common/eal_common_log.c
index fe3d7d5..39d6e3f 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -119,7 +119,10 @@ rte_log_add_in_history(const char *buf, size_t size)
/* get a buffer for adding in history */
if (log_history_size > RTE_LOG_HISTORY) {
hist_buf = STAILQ_FIRST(_history);
-   STAILQ_REMOVE_HEAD(_history, next);
+   if (hist_buf) {
+   STAILQ_REMOVE_HEAD(_history, next);
+   log_history_size--;
+   }
}
else {
if (rte_mempool_mc_get(log_history_mp, ) < 0)
@@ -234,6 +237,7 @@ rte_log_dump_history(FILE *out)
rte_spinlock_lock(_list_lock);
tmp_log_history = log_history;
STAILQ_INIT(_history);
+   log_history_size = 0;
rte_spinlock_unlock(_list_lock);

for (i=0; i

[dpdk-dev] [PATCH 3/3] mempool: fix typos, indentation, and doxygen style

2015-06-01 Thread Olivier Matz
Do some cosmetic clean-up.

Signed-off-by: Olivier Matz 
---
 lib/librte_mempool/rte_dom0_mempool.c | 36 
 lib/librte_mempool/rte_mempool.c  | 10 ++---
 lib/librte_mempool/rte_mempool.h  | 80 ++-
 3 files changed, 73 insertions(+), 53 deletions(-)

diff --git a/lib/librte_mempool/rte_dom0_mempool.c 
b/lib/librte_mempool/rte_dom0_mempool.c
index 8900171..a313b3f 100644
--- a/lib/librte_mempool/rte_dom0_mempool.c
+++ b/lib/librte_mempool/rte_dom0_mempool.c
@@ -61,30 +61,30 @@

 static void
 get_phys_map(void *va, phys_addr_t pa[], uint32_t pg_num,
-uint32_t pg_sz, uint32_t memseg_id)
+   uint32_t pg_sz, uint32_t memseg_id)
 {
-uint32_t i;
-uint64_t virt_addr, mfn_id;
-struct rte_mem_config *mcfg;
-uint32_t page_size = getpagesize();
-
-/* get pointer to global configuration */
-mcfg = rte_eal_get_configuration()->mem_config;
-virt_addr =(uintptr_t) mcfg->memseg[memseg_id].addr;
-
-for (i = 0; i != pg_num; i++) {
-mfn_id = ((uintptr_t)va + i * pg_sz - virt_addr) / RTE_PGSIZE_2M;
-pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
-}
+   uint32_t i;
+   uint64_t virt_addr, mfn_id;
+   struct rte_mem_config *mcfg;
+   uint32_t page_size = getpagesize();
+
+   /* get pointer to global configuration */
+   mcfg = rte_eal_get_configuration()->mem_config;
+   virt_addr =(uintptr_t) mcfg->memseg[memseg_id].addr;
+
+   for (i = 0; i != pg_num; i++) {
+   mfn_id = ((uintptr_t)va + i * pg_sz - virt_addr) / 
RTE_PGSIZE_2M;
+   pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
+   }
 }

 /* create the mempool for supporting Dom0 */
 struct rte_mempool *
 rte_dom0_mempool_create(const char *name, unsigned elt_num, unsigned elt_size,
-   unsigned cache_size, unsigned private_data_size,
-   rte_mempool_ctor_t *mp_init, void *mp_init_arg,
-   rte_mempool_obj_ctor_t *obj_init, void *obj_init_arg,
-   int socket_id, unsigned flags)
+   unsigned cache_size, unsigned private_data_size,
+   rte_mempool_ctor_t *mp_init, void *mp_init_arg,
+   rte_mempool_obj_ctor_t *obj_init, void *obj_init_arg,
+   int socket_id, unsigned flags)
 {
struct rte_mempool *mp = NULL;
phys_addr_t *pa;
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 60369cf..f592dc7 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -347,9 +347,9 @@ rte_mempool_xmem_size(uint32_t elt_num, size_t elt_sz, 
uint32_t pg_shift)
  */
 static void
 mempool_lelem_iter(void *arg, __rte_unused void *start, void *end,
-__rte_unused uint32_t idx)
+   __rte_unused uint32_t idx)
 {
-*(uintptr_t *)arg = (uintptr_t)end;
+   *(uintptr_t *)arg = (uintptr_t)end;
 }

 ssize_t
@@ -521,8 +521,8 @@ rte_mempool_xmem_create(const char *name, unsigned n, 
unsigned elt_size,

/*
 * If user provided an external memory buffer, then use it to
-* store mempool objects. Otherwise reserve memzone big enough to
-* hold mempool header and metadata plus mempool objects.
+* store mempool objects. Otherwise reserve a memzone that is large
+* enough to hold mempool header and metadata plus mempool objects.
 */
mempool_size = MEMPOOL_HEADER_SIZE(mp, pg_num) + private_data_size;
if (vaddr == NULL)
@@ -543,7 +543,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, 
unsigned elt_size,

/*
 * no more memory: in this case we loose previously reserved
-* space for the as we cannot free it
+* space for the ring as we cannot free it
 */
if (mz == NULL) {
rte_free(te);
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index cdb8f67..649c27d 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -109,6 +109,9 @@ struct rte_mempool_cache {
 } __rte_cache_aligned;
 #endif /* RTE_MEMPOOL_CACHE_MAX_SIZE > 0 */

+/**
+ * A structure that stores the size of mempool elements.
+ */
 struct rte_mempool_objsz {
uint32_t elt_size; /**< Size of an element. */
uint32_t header_size;  /**< Size of header (before elt). */
@@ -206,7 +209,7 @@ struct rte_mempool {
uintptr_t   elt_va_end;
/**< Virtual address of the  mempool object. */
phys_addr_t elt_pa[MEMPOOL_PG_NUM_DEFAULT];
-   /**< Array of physical pages addresses for the mempool objects buffer. 
*/
+   /**< Array of physical page addresses for the mempool objects buffer. */

 }  __rte_cache_aligned;

@@ -217,6 +220,7 @@ struct rte_mempool {

 /**
  * @internal When debug is enabled, store some statistics.
+ *
  * @param mp
  *   Pointer to the memory pool.
  * @param name
@@ -237,18 +241,19 @@ struct rte_mempool {
 #endif

 /**
- * Calculates size of the mempool header.

[dpdk-dev] [PATCH 2/3] mempool: introduce objtlr structure for object trailers

2015-06-01 Thread Olivier Matz
Each object stored in mempools are suffixed by a trailer, storing
a cookie in debug mode which help to detect memory corruptions.

Like for headers, introduce a structure that materializes the content of
this trailer.

Signed-off-by: Olivier Matz 
---
 lib/librte_mempool/rte_mempool.c |  4 +++-
 lib/librte_mempool/rte_mempool.h | 42 +---
 2 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index b2d8700..60369cf 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -131,6 +131,7 @@ mempool_add_elem(struct rte_mempool *mp, void *obj, 
uint32_t obj_idx,
rte_mempool_obj_ctor_t *obj_init, void *obj_init_arg)
 {
struct rte_mempool_objhdr *hdr;
+   struct rte_mempool_objtlr *tlr __rte_unused;

obj = (char *)obj + mp->header_size;

@@ -140,7 +141,8 @@ mempool_add_elem(struct rte_mempool *mp, void *obj, 
uint32_t obj_idx,

 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2;
-   __mempool_write_trailer_cookie(obj);
+   tlr = __mempool_get_trailer(obj);
+   tlr->cookie = RTE_MEMPOOL_TRAILER_COOKIE;
 #endif
/* call the initializer */
if (obj_init)
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 5058940..cdb8f67 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -155,6 +155,18 @@ struct rte_mempool_objhdr {
 };

 /**
+ * Mempool object trailer structure
+ *
+ * In debug mode, each object stored in mempools are suffixed by this
+ * trailer structure containing a cookie preventing memory corruptions.
+ */
+struct rte_mempool_objtlr {
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   uint64_t cookie; /**< Debug cookie. */
+#endif
+};
+
+/**
  * The RTE mempool structure.
  */
 struct rte_mempool {
@@ -249,6 +261,13 @@ static inline struct rte_mempool_objhdr 
*__mempool_get_header(void *obj)
sizeof(struct rte_mempool_objhdr));
 }

+/* return the trailer of a mempool object (internal) */
+static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
+{
+   return (struct rte_mempool_objtlr *)((char *)obj -
+   sizeof(struct rte_mempool_objtlr));
+}
+
 /**
  * Return a pointer to the mempool owning this object.
  *
@@ -264,25 +283,6 @@ static inline struct rte_mempool 
*rte_mempool_from_obj(void *obj)
return hdr->mp;
 }

-#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-/* get trailer cookie value */
-static inline uint64_t __mempool_read_trailer_cookie(void *obj)
-{
-   struct rte_mempool **mpp = __mempool_from_obj(obj);
-   return *(uint64_t *)((char *)obj + (*mpp)->elt_size);
-
-}
-
-/* write trailer cookie value */
-static inline void __mempool_write_trailer_cookie(void *obj)
-{
-   uint64_t *cookie_p;
-   struct rte_mempool **mpp = __mempool_from_obj(obj);
-   cookie_p = (uint64_t *)((char *)obj + (*mpp)->elt_size);
-   *cookie_p = RTE_MEMPOOL_TRAILER_COOKIE;
-}
-#endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
-
 /**
  * @internal Check and update cookies or panic.
  *
@@ -306,6 +306,7 @@ static inline void __mempool_check_cookies(const struct 
rte_mempool *mp,
   unsigned n, int free)
 {
struct rte_mempool_objhdr *hdr;
+   struct rte_mempool_objtlr *tlr;
uint64_t cookie;
void *tmp;
void *obj;
@@ -356,7 +357,8 @@ static inline void __mempool_check_cookies(const struct 
rte_mempool *mp,
rte_panic("MEMPOOL: bad header cookie 
(audit)\n");
}
}
-   cookie = __mempool_read_trailer_cookie(obj);
+   tlr = __mempool_get_trailer(obj);
+   cookie = tlr->cookie;
if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) {
rte_log_set_history(0);
RTE_LOG(CRIT, MEMPOOL,
-- 
2.1.4



[dpdk-dev] [PATCH 1/3] mempool: introduce objhdr structure for object headers

2015-06-01 Thread Olivier Matz
Each object stored in mempools are prefixed by a header, allowing for
instance to retrieve the mempool pointer from the object. When debug is
enabled, a cookie is also added in this header that helps to detect
corruptions and double-frees.

Introduce a structure that materializes the content of this header,
and will simplify future patches adding things in this header.

Signed-off-by: Olivier Matz 
---
 lib/librte_mempool/rte_mempool.c |  8 ++---
 lib/librte_mempool/rte_mempool.h | 68 
 2 files changed, 31 insertions(+), 45 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 190cfd9..b2d8700 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -130,16 +130,16 @@ static void
 mempool_add_elem(struct rte_mempool *mp, void *obj, uint32_t obj_idx,
rte_mempool_obj_ctor_t *obj_init, void *obj_init_arg)
 {
-   struct rte_mempool **mpp;
+   struct rte_mempool_objhdr *hdr;

obj = (char *)obj + mp->header_size;

/* set mempool ptr in header */
-   mpp = __mempool_from_obj(obj);
-   *mpp = mp;
+   hdr = (struct rte_mempool_objhdr *)((char *)obj - sizeof(*hdr));
+   hdr->mp = mp;

 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-   __mempool_write_header_cookie(obj, 1);
+   hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2;
__mempool_write_trailer_cookie(obj);
 #endif
/* call the initializer */
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index a4a9610..5058940 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -140,6 +140,21 @@ struct rte_mempool_objsz {
 #defineMEMPOOL_PG_NUM_DEFAULT  1

 /**
+ * Mempool object header structure
+ *
+ * Each object stored in mempools are prefixed by this header structure,
+ * it allows to retrieve the mempool pointer from the object. When debug
+ * is enabled, a cookie is also added in this structure preventing
+ * corruptions and double-frees.
+ */
+struct rte_mempool_objhdr {
+   struct rte_mempool *mp;  /**< The mempool owning the object. */
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   uint64_t cookie; /**< Debug cookie. */
+#endif
+};
+
+/**
  * The RTE mempool structure.
  */
 struct rte_mempool {
@@ -227,24 +242,11 @@ struct rte_mempool {
((mp)->pg_num == MEMPOOL_PG_NUM_DEFAULT && \
(mp)->phys_addr == (mp)->elt_pa[0])

-/**
- * @internal Get a pointer to a mempool pointer in the object header.
- * @param obj
- *   Pointer to object.
- * @return
- *   The pointer to the mempool from which the object was allocated.
- */
-static inline struct rte_mempool **__mempool_from_obj(void *obj)
+/* return the header of a mempool object (internal) */
+static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
 {
-   struct rte_mempool **mpp;
-   unsigned off;
-
-   off = sizeof(struct rte_mempool *);
-#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-   off += sizeof(uint64_t);
-#endif
-   mpp = (struct rte_mempool **)((char *)obj - off);
-   return mpp;
+   return (struct rte_mempool_objhdr *)((char *)obj -
+   sizeof(struct rte_mempool_objhdr));
 }

 /**
@@ -256,36 +258,18 @@ static inline struct rte_mempool 
**__mempool_from_obj(void *obj)
  * @return
  *   A pointer to the mempool structure.
  */
-static inline const struct rte_mempool *rte_mempool_from_obj(void *obj)
+static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
 {
-   struct rte_mempool * const *mpp;
-   mpp = __mempool_from_obj(obj);
-   return *mpp;
+   struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
+   return hdr->mp;
 }

 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-/* get header cookie value */
-static inline uint64_t __mempool_read_header_cookie(const void *obj)
-{
-   return *(const uint64_t *)((const char *)obj - sizeof(uint64_t));
-}
-
 /* get trailer cookie value */
 static inline uint64_t __mempool_read_trailer_cookie(void *obj)
 {
struct rte_mempool **mpp = __mempool_from_obj(obj);
return *(uint64_t *)((char *)obj + (*mpp)->elt_size);
-}
-
-/* write header cookie value */
-static inline void __mempool_write_header_cookie(void *obj, int free)
-{
-   uint64_t *cookie_p;
-   cookie_p = (uint64_t *)((char *)obj - sizeof(uint64_t));
-   if (free == 0)
-   *cookie_p = RTE_MEMPOOL_HEADER_COOKIE1;
-   else
-   *cookie_p = RTE_MEMPOOL_HEADER_COOKIE2;

 }

@@ -321,6 +305,7 @@ static inline void __mempool_check_cookies(const struct 
rte_mempool *mp,
   void * const *obj_table_const,
   unsigned n, int free)
 {
+   struct rte_mempool_objhdr *hdr;
uint64_t cookie;
void *tmp;
void *obj;
@@ -338,7 +323,8 @@ static inline void __mempool_check_cookies(const struct 
rte_mempool *mp,

[dpdk-dev] [PATCH 0/3] mempool: clean-up

2015-06-01 Thread Olivier Matz
These 3 patches try to make mempool code easier to read, they
have no functional impact.

Olivier Matz (3):
  mempool: introduce objhdr structure for object headers
  mempool: introduce objtlr structure for object trailers
  mempool: fix typos, indentation, and doxygen style

 lib/librte_mempool/rte_dom0_mempool.c |  36 +++
 lib/librte_mempool/rte_mempool.c  |  22 ++--
 lib/librte_mempool/rte_mempool.h  | 188 ++
 3 files changed, 128 insertions(+), 118 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH] lib_vhost:reset secure_len when rte_atomic16_cmpset failed

2015-06-01 Thread Wei li
---
 lib/librte_vhost/vhost_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 4809d32..fb3e72a 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -431,6 +431,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
 */
res_base_idx = vq->last_used_idx_res;
res_cur_idx = res_base_idx;
+   secure_len = 0;

do {
avail_idx = *((volatile uint16_t 
*)>avail->idx);
-- 
1.9.5.msysgit.1




[dpdk-dev] [PATCH 2/5] mbuf: use the reserved 16 bits for double vlan

2015-06-01 Thread Olivier MATZ
Hi Helin,

On 05/26/2015 10:36 AM, Helin Zhang wrote:
> Use the reserved 16 bits in rte_mbuf structure for the outer vlan,
> also add QinQ offloading flags for both RX and TX sides.
> 
> Signed-off-by: Helin Zhang 
> ---
>  lib/librte_mbuf/rte_mbuf.h | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index ab6de67..4551df9 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -101,11 +101,17 @@ extern "C" {
>  #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
> header. */
>  #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. 
> */
>  #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if 
> FDIR match. */
> +#define PKT_RX_QINQ_PKT (1ULL << 15)  /**< RX packet with double VLAN 
> stripped. */
>  /* add new RX flags here */

There's a small indent typo here: (1ULL << 15) is not aligned
with the lines above


>  
>  /* add new TX flags here */
>  
>  /**
> + * Second VLAN insertion (QinQ) flag.
> + */
> +#define PKT_TX_QINQ_PKT(1ULL << 49)   /**< TX packet with double VLAN 
> inserted. */
> +
> +/**
>   * TCP segmentation offload. To enable this offload feature for a
>   * packet to be transmitted on hardware supporting TSO:
>   *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies
> @@ -279,7 +285,7 @@ struct rte_mbuf {
>   uint16_t data_len;/**< Amount of data in segment buffer. */
>   uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
>   uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
> */
> - uint16_t reserved;
> + uint16_t vlan_tci_outer;  /**< Outer VLAN Tag Control Identifier (CPU 
> order) */
>   union {
>   uint32_t rss; /**< RSS hash result if RSS enabled */
>   struct {
> @@ -777,6 +783,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
>   m->pkt_len = 0;
>   m->tx_offload = 0;
>   m->vlan_tci = 0;
> + m->vlan_tci_outer = 0;
>   m->nb_segs = 1;
>   m->port = 0xff;
>  
> @@ -849,6 +856,7 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf 
> *mi, struct rte_mbuf *m)
>   mi->data_len = m->data_len;
>   mi->port = m->port;
>   mi->vlan_tci = m->vlan_tci;
> + mi->vlan_tci_outer = m->vlan_tci_outer;
>   mi->tx_offload = m->tx_offload;
>   mi->hash = m->hash;
>  
> 

Maybe some more affectations are missing. For instance in
examples/ipv4_multicast/main.c or in examples/vhost/main.c.
You can grep "->vlan_tci =" to find them all.

Do we need to update rte_vlan_insert() and rte_vlan_strip() to
support QinQ?

Regards,
Olivier


[dpdk-dev] [PATCH 1/5] ixgbe: remove a discarded source line

2015-06-01 Thread Olivier MATZ
Hi Helin,

On 05/26/2015 10:36 AM, Helin Zhang wrote:
> Little endian to CPU order conversion had been added for reading
> vlan tag from RX descriptor, while its original source line was
> forgotten to delete. That's a discarded source line and should be
> deleted.
> 
> Signed-off-by: Helin Zhang 
> ---
>  drivers/net/ixgbe/ixgbe_rxtx.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
> index 4f9ab22..041c544 100644
> --- a/drivers/net/ixgbe/ixgbe_rxtx.c
> +++ b/drivers/net/ixgbe/ixgbe_rxtx.c
> @@ -981,7 +981,6 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq)
>   pkt_len = (uint16_t)(rxdp[j].wb.upper.length - 
> rxq->crc_len);
>   mb->data_len = pkt_len;
>   mb->pkt_len = pkt_len;
> - mb->vlan_tci = rxdp[j].wb.upper.vlan;
>   mb->vlan_tci = rte_le_to_cpu_16(rxdp[j].wb.upper.vlan);
>  
>   /* convert descriptor fields to rte mbuf flags */
> 

Maybe the following should be added in the commit log:
Fixes: 23fcffe8ffac ("ixgbe: fix id and hash with flow director")

Acked-by: Olivier Matz 


[dpdk-dev] Free up completed TX buffers

2015-06-01 Thread Andriy Berestovskyy
Hi Zoltan,

On Fri, May 29, 2015 at 7:00 PM, Zoltan Kiss  wrote:
> The easy way is just to increase your buffer pool's size to make
> sure that doesn't happen.

Go for it!

>  But there is no bulletproof way to calculate such
> a number

Yeah, there are many places for mbufs to stay :( I would try:

Mempool size = sum(numbers of all TX descriptors)
+ sum(rx_free_thresh)
+ (mempool cache size * (number of lcores - 1))
+ (burst size * number of lcores)

> I'm thinking about a foolproof way, which is exposing functions like
> ixgbe_tx_free_bufs from the PMDs, so the application can call it as a last
> resort to avoid deadlock.

Have a look at rte_eth_dev_tx_queue_stop()/start(). Some NICs (i.e.
ixgbe) do reset the queue and free all the mbufs.

Regards,
Andriy


[dpdk-dev] How to set timestamp in 82599 NICs in DPDK?

2015-06-01 Thread 科来 谭春海
Hi 



I noticed that there is a patch which can set hardware timestamp for the
received
packets(http://www.wand.net.nz/trac/libtrace/browser/Intel%20DPDK%20Patches/
hardware_timestamp.patch?rev=ce7153dbc6a13c18bf8033af08c1249527754168), but
it only works in e1000 and igb NICs. I want to capture packets with
timestamp info in 82599 NICs, what should I do? Could you give me some help?



Thanks.



Chunhai Tan







[dpdk-dev] [PATCH] log: Properly reset log_history_size in rte_log_dump_history()

2015-06-01 Thread Olivier MATZ
Hi Jan,

On 05/29/2015 12:34 PM, Jan Blunck wrote:
> In rte_log_dump_history() the log_history list is reinitialized without
> resetting the log_history_size. In the next call to rte_log_add_in_history()
> the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
> to remove the first entry:
> 
> Program received signal SIGSEGV, Segmentation fault.
> rte_log_add_in_history (
> buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK 
> [dp0s7] \nCAST,LOWER_UP>\n", 
> size=size at entry=86)
> at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122
> 
> Signed-off-by: Jan Blunck 
> ---
>  lib/librte_eal/common/eal_common_log.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_log.c 
> b/lib/librte_eal/common/eal_common_log.c
> index fe3d7d5..cb4311c 100644
> --- a/lib/librte_eal/common/eal_common_log.c
> +++ b/lib/librte_eal/common/eal_common_log.c
> @@ -119,7 +119,8 @@ rte_log_add_in_history(const char *buf, size_t size)
>   /* get a buffer for adding in history */
>   if (log_history_size > RTE_LOG_HISTORY) {
>   hist_buf = STAILQ_FIRST(_history);
> - STAILQ_REMOVE_HEAD(_history, next);
> + if (hist_buf)
> + STAILQ_REMOVE_HEAD(_history, next);

Shouldn't we decrease log_history_size here?



Also, it's probably a bit off-topic, but I think the function that
adds in history could be optimized a bit to avoid doing the copy with
the lock held. Maybe something like this is feasible:

rte_mempool_mc_get() into hist_buf
memcpy(hist_buf->buf, buf, size);
rte_spinlock_lock(_list_lock
if (log_history_size > RTE_LOG_HISTORY) {
STAILQ_REMOVE_HEAD
log_history_size --
}
STAILQ_INSERT_TAIL
log_history_size ++
rte_spinlock_unlock(_list_lock)

Feel free to implement it if you feel it's better. It would also
require to increase the number of objects in the pool to
RTE_LOG_HISTORY*2 + RTE_MAX_LCORE

Regards,
Olivier



>   }
>   else {
>   if (rte_mempool_mc_get(log_history_mp, ) < 0)
> @@ -234,6 +235,7 @@ rte_log_dump_history(FILE *out)
>   rte_spinlock_lock(_list_lock);
>   tmp_log_history = log_history;
>   STAILQ_INIT(_history);
> + log_history_size = 0;
>   rte_spinlock_unlock(_list_lock);
>  
>   for (i=0; i 


[dpdk-dev] [PATCH v6 01/18] mbuf: redefine packet_type in rte_mbuf

2015-06-01 Thread Olivier MATZ
Hi Helin,

+CC Neil

On 06/01/2015 09:33 AM, Helin Zhang wrote:
> In order to unify the packet type, the field of 'packet_type' in
> 'struct rte_mbuf' needs to be extended from 16 to 32 bits.
> Accordingly, some fields in 'struct rte_mbuf' are re-organized to
> support this change for Vector PMD. As 'struct rte_kni_mbuf' for
> KNI should be right mapped to 'struct rte_mbuf', it should be
> modified accordingly. In addition, Vector PMD of ixgbe is disabled
> by default, as 'struct rte_mbuf' changed.
> To avoid breaking ABI compatibility, all the changes would be
> enabled by RTE_UNIFIED_PKT_TYPE, which is disabled by default.

What are the plans for this compile-time option in the future?

I wonder what are the benefits of having this option in terms
of ABI compatibility: when it is disabled, it is ABI-compatible but
the packet-type feature is not present, and when it is enabled we
have the feature but it breaks the compatibility.

In my opinion, the v5 is preferable: for this kind of features, I
don't see how the ABI can be preserved, and I think packet-type
won't be the only feature that will modify the mbuf structure. I think
the process described here should be applied:
http://dpdk.org/browse/dpdk/tree/doc/guides/rel_notes/abi.rst

(starting from "Some ABI changes may be too significant to reasonably
maintain multiple versions of").


Regards,
Olivier



> 
> Signed-off-by: Helin Zhang 
> Signed-off-by: Cunming Liang 
> ---
>  config/common_linuxapp |  2 +-
>  .../linuxapp/eal/include/exec-env/rte_kni_common.h |  6 ++
>  lib/librte_mbuf/rte_mbuf.h | 23 
> ++
>  3 files changed, 30 insertions(+), 1 deletion(-)
> 
> v2 changes:
> * Enlarged the packet_type field from 16 bits to 32 bits.
> * Redefined the packet type sub-fields.
> * Updated the 'struct rte_kni_mbuf' for KNI according to the mbuf changes.
> 
> v3 changes:
> * Put the mbuf layout changes into a single patch.
> * Disabled vector ixgbe PMD by default, as mbuf layout changed.
> 
> v5 changes:
> * Re-worded the commit logs.
> 
> v6 changes:
> * Disabled the code changes for unified packet type by default, to
>   avoid breaking ABI compatibility.
> 
> diff --git a/config/common_linuxapp b/config/common_linuxapp
> index 0078dc9..6b067c7 100644
> --- a/config/common_linuxapp
> +++ b/config/common_linuxapp
> @@ -167,7 +167,7 @@ CONFIG_RTE_LIBRTE_IXGBE_DEBUG_TX_FREE=n
>  CONFIG_RTE_LIBRTE_IXGBE_DEBUG_DRIVER=n
>  CONFIG_RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC=n
>  CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
> -CONFIG_RTE_IXGBE_INC_VECTOR=y
> +CONFIG_RTE_IXGBE_INC_VECTOR=n
>  CONFIG_RTE_IXGBE_RX_OLFLAGS_ENABLE=y
>  
>  #
> diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h 
> b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
> index 1e55c2d..7a2abbb 100644
> --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
> +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
> @@ -117,9 +117,15 @@ struct rte_kni_mbuf {
>   uint16_t data_off;  /**< Start address of data in segment buffer. */
>   char pad1[4];
>   uint64_t ol_flags;  /**< Offload features. */
> +#ifdef RTE_UNIFIED_PKT_TYPE
> + char pad2[4];
> + uint32_t pkt_len;   /**< Total pkt len: sum of all segment 
> data_len. */
> + uint16_t data_len;  /**< Amount of data in segment buffer. */
> +#else
>   char pad2[2];
>   uint16_t data_len;  /**< Amount of data in segment buffer. */
>   uint32_t pkt_len;   /**< Total pkt len: sum of all segment 
> data_len. */
> +#endif
>  
>   /* fields on second cache line */
>   char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index ab6de67..a8662c2 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -269,6 +269,28 @@ struct rte_mbuf {
>   /* remaining bytes are set on RX when pulling packet from descriptor */
>   MARKER rx_descriptor_fields1;
>  
> +#ifdef RTE_UNIFIED_PKT_TYPE
> + /*
> +  * The packet type, which is the combination of outer/inner L2, L3, L4
> +  * and tunnel types.
> +  */
> + union {
> + uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
> + struct {
> + uint32_t l2_type:4; /**< (Outer) L2 type. */
> + uint32_t l3_type:4; /**< (Outer) L3 type. */
> + uint32_t l4_type:4; /**< (Outer) L4 type. */
> + uint32_t tun_type:4; /**< Tunnel type. */
> + uint32_t inner_l2_type:4; /**< Inner L2 type. */
> + uint32_t inner_l3_type:4; /**< Inner L3 type. */
> + uint32_t inner_l4_type:4; /**< Inner L4 type. */
> + };
> + };
> +
> + uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
> + uint16_t 

[dpdk-dev] mempool destroy

2015-06-01 Thread Olivier MATZ
Hi,

On 05/29/2015 11:04 PM, Dax Rawal wrote:
> Hi,
> How does one return (or destroy)  ret_mempool that was created by
> rte_mempool_create() ?

Currently it's not possible but it seems it would be a nice improvement
to mempool library.

Sergio recently submitted a patch to delete memzones, it would probably
solve your issue. See:

http://dpdk.org/ml/archives/dev/2015-May/017470.html

Regards,
Olivier



> 
> Thanks.
> 


[dpdk-dev] [PATCH 0/3] librte_cfgfile rework and extension

2015-06-01 Thread Dumitrescu, Cristian


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Maciej Gajdzica
> Sent: Friday, May 29, 2015 4:27 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH 0/3] librte_cfgfile rework and extension
> 
> From: Pawel Wodkowski 
> 
> This patchset provide extension to librte_cfgfile to overcome limit of 64
> characters for entry value and add line continue feature.
> 
> Pawel Wodkowski (3):
>   librte_cfgfile: fix code formating in header file
>   librte_compat: fix macro deffinition
>   librte_cfgfile: rework
> 
>  lib/librte_cfgfile/Makefile|   2 +-
>  lib/librte_cfgfile/rte_cfgfile.c   | 792 
> ++---
>  lib/librte_cfgfile/rte_cfgfile.h   |  52 +-
>  lib/librte_cfgfile/rte_cfgfile_version.map |   8 +
>  lib/librte_compat/rte_compat.h |   2 +-
>  5 files changed, 649 insertions(+), 207 deletions(-)
> 
> --
> 1.9.1

Acked-by: Cristian Dumitrescu 



[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-06-01 Thread Stephen Hemminger
Never mind, had wrong version of one of the patches.

On Mon, Jun 1, 2015 at 7:11 AM, Stephen Hemminger 
wrote:

> On Fri, 29 May 2015 16:45:25 +0800
> Cunming Liang  wrote:
>
> > RTE_EAL_RX_INTR will be removed from v2.2. It's only used to avoid
> ABI(unannounced) broken in v2.1.
> > The usrs should make sure understand the impact before turning on the
> feature.
> > There are two abi changes required in this interrupt patch set.
> > They're 1) struct rte_intr_handle; 2) struct rte_intr_conf.
> >
> > Signed-off-by: Cunming Liang 
> > ---
>
> While merging for testing I discovered another minor issue.
>
> The patch order here is a problem. The intermediate steps won't build
> until
> this last patch is applied.
>
> In order to allow git bisect to be useful, it is important that every
> commit
> done in the upstream version build and work. This series does not seem to
> build until this last patch is applied. Maybe it should just be first?
>


[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-06-01 Thread Stephen Hemminger
On Fri, 29 May 2015 16:45:25 +0800
Cunming Liang  wrote:

> RTE_EAL_RX_INTR will be removed from v2.2. It's only used to avoid 
> ABI(unannounced) broken in v2.1.
> The usrs should make sure understand the impact before turning on the feature.
> There are two abi changes required in this interrupt patch set.
> They're 1) struct rte_intr_handle; 2) struct rte_intr_conf.
> 
> Signed-off-by: Cunming Liang 
> ---

While merging for testing I discovered another minor issue.

The patch order here is a problem. The intermediate steps won't build  until
this last patch is applied.

In order to allow git bisect to be useful, it is important that every commit
done in the upstream version build and work. This series does not seem to
build until this last patch is applied. Maybe it should just be first?


[dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config files with new syntax

2015-06-01 Thread Stephen Hemminger
On Fri, 29 May 2015 17:43:08 +0200
Maciej Gajdzica  wrote:

> +/**
> + * Find object of name *name* in *obj_array* which is constant size array of
> + * elements that have field *name*.
> + *
> + * @param obj_array
> + *  Constant size array
> + * @param name
> + *  name of object to find.
> + * @return
> + *  Pointer to object in *obj_array* or NULL if not found.
> + */
> +#define APP_PARAM_FIND(obj_array, key)  \
> +({  \
> + ssize_t obj_idx;\
> + const ssize_t obj_count = RTE_DIM(obj_array);   \
> +\
> + for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
> + if (!APP_PARAM_VALID(&((obj_array)[obj_idx])))  \
> + continue;   \
> + \
> + if (strcmp(key, (obj_array)[obj_idx].name) == 0)\
> + break;  \
> + }   \
> + obj_idx < obj_count ? obj_idx : -ENOENT;\
> +})

Converting all the functions to macro's is a step backwards in several ways.
 * macro's are hard to support
 * macro's lead to lots of programming errors
 * macro's look ugly

Why not use real functions, or make the example into C++ if you have
to do generic programming.


[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-06-01 Thread Stephen Hemminger
On Mon, 1 Jun 2015 16:48:01 +0800
"Liang, Cunming"  wrote:

> Hi Stephen,
> 
> On 5/29/2015 11:27 PM, Stephen Hemminger wrote:
> > On Fri, 29 May 2015 16:45:25 +0800
> > Cunming Liang  wrote:
> >  
> >> +#ifdef RTE_EAL_RX_INTR
> >> +extern int
> >>   rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data);
> >> +#else
> >> +static inline int
> >> +rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
> >> +{
> >> +  RTE_SET_USED(port_id);
> >> +  RTE_SET_USED(epfd);
> >> +  RTE_SET_USED(op);
> >> +  RTE_SET_USED(data);
> >> +  return -1;
> >> +}
> >> +#endif  
> > Doing ABI compatibility is good but hard.
> >
> > I think it would be better not to provide the functions for rx_intr_ctl 
> > unless
> > the feature was configured on. That way anyone using them with incorrect 
> > config
> > would detect failure at build time, rather than run time.  
> I tend to not agree. For rx_intr_ctl/rx_intr_ctl_q, no matter w/ or w/o 
> RTE_EAL_RX_INTR, it's necessary to check the return value.
> The failure return shall cause application give up using epoll waiting 
> on the specified epfd for the port, and then degraded to pure polling mode.
> So I think these failure should be handled by the caller.

It is always best to fail as early in the development process as possible.
What possible benefit could there be from allowing application to be linked
and run with incorrect configuration.


[dpdk-dev] [PATCH v2] lib_vhost:reset secure_len when rte_atomic16_cmpset failed

2015-06-01 Thread Ouyang, Changchun


> -Original Message-
> From: Wei li [mailto:liw at dtdream.com]
> Sent: Monday, June 1, 2015 2:12 PM
> To: dev at dpdk.org
> Cc: Ouyang, Changchun; liw at dtdream.com
> Subject: [PATCH v2] lib_vhost:reset secure_len when rte_atomic16_cmpset
> failed
> 
> when rte_atomic16_cmpset return 0 in first loop, secure_len  should be
> reset to 0 in second loop, otherwise (pkt_len > secure_len) always  be false,
> the num of desc maybe not enough
> 
> Signed-off-by: Wei li 

Acked-by: Changchun Ouyang



[dpdk-dev] [PATCH] lib_vhost:reset secure_len when rte_atomic16_cmpset failed

2015-06-01 Thread Ouyang, Changchun


> -Original Message-
> From: Wei li [mailto:liw at dtdream.com]
> Sent: Monday, June 1, 2015 11:00 AM
> To: dev at dpdk.org
> Cc: Ouyang, Changchun
> Subject: [PATCH] lib_vhost:reset secure_len when rte_atomic16_cmpset
> failed
> 

The one line change is ok, but need more description.

> ---
>  lib/librte_vhost/vhost_rxtx.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
> index 4809d32..fb3e72a 100644
> --- a/lib/librte_vhost/vhost_rxtx.c
> +++ b/lib/librte_vhost/vhost_rxtx.c
> @@ -431,6 +431,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t
> queue_id,
>*/
>   res_base_idx = vq->last_used_idx_res;
>   res_cur_idx = res_base_idx;
> + secure_len = 0;
> 
>   do {
>   avail_idx = *((volatile uint16_t *)>avail-
> >idx);
> --
> 1.9.5.msysgit.1
> 



[dpdk-dev] [PATCH] vhost: enable live migration

2015-06-01 Thread Ouyang, Changchun


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Huawei Xie
> Sent: Wednesday, May 27, 2015 11:02 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH] vhost: enable live migration
> 
> When we migrate VM, without this feature, qemu will report error:
> "migrate: Migration disabled: vhost lacks VHOST_F_LOG_ALL feature".
> 

Is this enough for vhost to support  migrate VM?
I remember Claire has another patch, possibly need refer to that patch.

> Signed-off-by: Krishna Murthy  
> ---
>  lib/librte_vhost/virtio-net.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c 
> index
> 4672e67..fced2ab 100644
> --- a/lib/librte_vhost/virtio-net.c
> +++ b/lib/librte_vhost/virtio-net.c
> @@ -66,7 +66,8 @@ static struct virtio_net_config_ll *ll_root;
>  /* Features supported by this lib. */
>  #define VHOST_SUPPORTED_FEATURES ((1ULL <<
> VIRTIO_NET_F_MRG_RXBUF) | \
>   (1ULL << VIRTIO_NET_F_CTRL_VQ) | \
> - (1ULL << VIRTIO_NET_F_CTRL_RX))
> + (1ULL << VIRTIO_NET_F_CTRL_RX) | \
> + (1ULL << VHOST_F_LOG_ALL))
>  static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;
> 
> 
> --
> 1.8.1.4



[dpdk-dev] [PATCH] kni: ignore double calls to rte_kni_init()

2015-06-01 Thread Marc Sune
Prevent double initialization of the KNI subsytem.

Signed-off-by: Marc Sune 
---
 lib/librte_kni/rte_kni.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index c5a0089..df0449f 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -201,6 +201,10 @@ rte_kni_init(unsigned int max_kni_ifaces)
char obj_name[OBJNAMSIZ];
char mz_name[RTE_MEMZONE_NAMESIZE];

+   /* Immediately return if KNI is already initialized */
+   if (kni_memzone_pool.initialized)
+   return;
+
if (max_kni_ifaces == 0) {
RTE_LOG(ERR, KNI, "Invalid number of max_kni_ifaces %d\n",
max_kni_ifaces);
-- 
2.1.4



[dpdk-dev] [PATCH] kni: Passing virtual PID to get_net_ns_by_pid(), so we can create kni interfaces in containers like docker

2015-06-01 Thread Wenfeng Liu
Signed-off-by: Wenfeng Liu 
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 1935d32..18fb677 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -359,7 +359,7 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long 
ioctl_param)
return -EBUSY;
}

-   net = get_net_ns_by_pid(current->pid);
+   net = get_net_ns_by_pid(task_pid_vnr(current));
if (IS_ERR(net)) {
free_netdev(net_dev);
return PTR_ERR(net);
-- 
1.8.3.1



[dpdk-dev] [PATCH] config:enlarge the default value of RTE_MAX_QUEUES_PER_PORT to 1024

2015-06-01 Thread Zhang, Helin


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jijiang Liu
> Sent: Thursday, May 28, 2015 9:36 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH] config:enlarge the default value of
> RTE_MAX_QUEUES_PER_PORT to 1024
> 
> The default value of RTE_MAX_QUEUES_PER_PORT is 256, which is too small for
> some configurations for i40e. There will return an error when configured queue
> number is larger than 256 in
> 
> rte_eth_dev_configure().
> 
> For example, in vHost sample, PF queue number: 64, configured vmdq pool
> number: 63, each vmdq pool has 4 queues, there will be required 316 queues in 
> a
> port.
> 
> 
> Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 

> ---
>  config/common_bsdapp   |2 +-
>  config/common_linuxapp |2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/config/common_bsdapp b/config/common_bsdapp index
> c2374c0..0b169c8 100644
> --- a/config/common_bsdapp
> +++ b/config/common_bsdapp
> @@ -137,7 +137,7 @@ CONFIG_RTE_LIBRTE_KVARGS=y
> CONFIG_RTE_LIBRTE_ETHER=y  CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n
>  CONFIG_RTE_MAX_ETHPORTS=32
> -CONFIG_RTE_MAX_QUEUES_PER_PORT=256
> +CONFIG_RTE_MAX_QUEUES_PER_PORT=1024
>  CONFIG_RTE_LIBRTE_IEEE1588=n
>  CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16
>  CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y
> diff --git a/config/common_linuxapp b/config/common_linuxapp index
> 0078dc9..5deb55a 100644
> --- a/config/common_linuxapp
> +++ b/config/common_linuxapp
> @@ -134,7 +134,7 @@ CONFIG_RTE_LIBRTE_KVARGS=y
> CONFIG_RTE_LIBRTE_ETHER=y  CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n
>  CONFIG_RTE_MAX_ETHPORTS=32
> -CONFIG_RTE_MAX_QUEUES_PER_PORT=256
> +CONFIG_RTE_MAX_QUEUES_PER_PORT=1024
>  CONFIG_RTE_LIBRTE_IEEE1588=n
>  CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16
>  CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y
> --
> 1.7.7.6