[dpdk-dev] [PATCH v2 0/4] support async dequeue for split ring

2021-09-17 Thread Wenwu Ma
This patch implements asynchronous dequeue data path for split ring.
A new asynchronous dequeue function is introduced. With this function,
the application can try to receive packets from the guest with offloading
copies to the DMA engine, thus saving precious CPU cycles.

v2:
- Removed struct async_nethdr in 1/4.
- Removed a useless function declaration in 2/4,
  and fixed some coding style in 4/4.

Wenwu Ma (3):
  examples/vhost: refactor vhost enqueue and dequeue datapaths
  examples/vhost: use a new API to query remaining ring space
  examples/vhost: support vhost async dequeue data path

Yuan Wang (1):
  vhost: support async dequeue for split ring

 doc/guides/prog_guide/vhost_lib.rst |   9 +
 doc/guides/sample_app_ug/vhost.rst  |   9 +-
 examples/vhost/ioat.c   |  67 +++-
 examples/vhost/ioat.h   |  25 ++
 examples/vhost/main.c   | 269 +-
 examples/vhost/main.h   |  34 +-
 examples/vhost/virtio_net.c |  16 +-
 lib/vhost/rte_vhost_async.h |  33 +-
 lib/vhost/version.map   |   3 +
 lib/vhost/vhost.h   |   3 +-
 lib/vhost/virtio_net.c  | 530 
 11 files changed, 877 insertions(+), 121 deletions(-)

-- 
2.25.1



[dpdk-dev] [PATCH v2 1/4] vhost: support async dequeue for split ring

2021-09-17 Thread Wenwu Ma
From: Yuan Wang 

This patch implements asynchronous dequeue data path for split ring.
A new asynchronous dequeue function is introduced. With this function,
the application can try to receive packets from the guest with
offloading copies to the async channel, thus saving precious CPU
cycles.

Signed-off-by: Yuan Wang 
Signed-off-by: Jiayu Hu 
Signed-off-by: Wenwu Ma 
Tested-by: Yinan Wang 
Tested-by: Yvonne Yang 
---
 doc/guides/prog_guide/vhost_lib.rst |   9 +
 lib/vhost/rte_vhost_async.h |  33 +-
 lib/vhost/version.map   |   3 +
 lib/vhost/vhost.h   |   3 +-
 lib/vhost/virtio_net.c  | 530 
 5 files changed, 575 insertions(+), 3 deletions(-)

diff --git a/doc/guides/prog_guide/vhost_lib.rst 
b/doc/guides/prog_guide/vhost_lib.rst
index 171e0096f6..9ed544db7a 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -303,6 +303,15 @@ The following is an overview of some key Vhost API 
functions:
   Clear inflight packets which are submitted to DMA engine in vhost async data
   path. Completed packets are returned to applications through ``pkts``.
 
+* ``rte_vhost_async_try_dequeue_burst(vid, queue_id, mbuf_pool, pkts, count, 
nr_inflight)``
+
+  This function tries to receive packets from the guest with offloading
+  copies to the async channel. The packets that are transfer completed
+  are returned in ``pkts``. The other packets that their copies are submitted
+  to the async channel but not completed are called "in-flight packets".
+  This function will not return in-flight packets until their copies are
+  completed by the async channel.
+
 Vhost-user Implementations
 --
 
diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
index ad71555a7f..973efa19b1 100644
--- a/lib/vhost/rte_vhost_async.h
+++ b/lib/vhost/rte_vhost_async.h
@@ -84,11 +84,12 @@ struct rte_vhost_async_channel_ops {
 };
 
 /**
- * inflight async packet information
+ * in-flight async packet information
  */
 struct async_inflight_info {
struct rte_mbuf *mbuf;
-   uint16_t descs; /* num of descs inflight */
+   struct virtio_net_hdr nethdr;
+   uint16_t descs; /* num of descs in-flight */
uint16_t nr_buffers; /* num of buffers inflight for packed ring */
 };
 
@@ -255,5 +256,33 @@ int rte_vhost_async_get_inflight(int vid, uint16_t 
queue_id);
 __rte_experimental
 uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,
struct rte_mbuf **pkts, uint16_t count);
+/**
+ * This function tries to receive packets from the guest with offloading
+ * copies to the async channel. The packets that are transfer completed
+ * are returned in "pkts". The other packets that their copies are submitted to
+ * the async channel but not completed are called "in-flight packets".
+ * This function will not return in-flight packets until their copies are
+ * completed by the async channel.
+ *
+ * @param vid
+ *  id of vhost device to dequeue data
+ * @param queue_id
+ *  queue id to dequeue data
+ * @param mbuf_pool
+ *  mbuf_pool where host mbuf is allocated.
+ * @param pkts
+ *  blank array to keep successfully dequeued packets
+ * @param count
+ *  size of the packet array
+ * @param nr_inflight
+ *  the amount of in-flight packets. If error occurred, its value is set to -1.
+ * @return
+ *  num of successfully dequeued packets
+ */
+__rte_experimental
+uint16_t
+rte_vhost_async_try_dequeue_burst(int vid, uint16_t queue_id,
+   struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count,
+   int *nr_inflight);
 
 #endif /* _RTE_VHOST_ASYNC_H_ */
diff --git a/lib/vhost/version.map b/lib/vhost/version.map
index c92a9d4962..1e033ad8e2 100644
--- a/lib/vhost/version.map
+++ b/lib/vhost/version.map
@@ -85,4 +85,7 @@ EXPERIMENTAL {
rte_vhost_async_channel_register_thread_unsafe;
rte_vhost_async_channel_unregister_thread_unsafe;
rte_vhost_clear_queue_thread_unsafe;
+
+   # added in 21.11
+   rte_vhost_async_try_dequeue_burst;
 };
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index 1e56311725..89a31e4ca8 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -49,7 +49,8 @@
 #define MAX_PKT_BURST 32
 
 #define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST * 2)
-#define VHOST_MAX_ASYNC_VEC (BUF_VECTOR_MAX * 4)
+#define MAX_ASYNC_COPY_VECTOR 1024
+#define VHOST_MAX_ASYNC_VEC (MAX_ASYNC_COPY_VECTOR * 2)
 
 #define PACKED_DESC_ENQUEUE_USED_FLAG(w)   \
((w) ? (VRING_DESC_F_AVAIL | VRING_DESC_F_USED | VRING_DESC_F_WRITE) : \
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 0350f6fcce..e7a802688f 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -3170,3 +3170,533 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
 
return count;
 }
+
+static __rte_always_inline int
+async_desc_to_mbuf(struct virtio_net *dev,
+ struct buf_vector *buf_vec, uin

[dpdk-dev] [PATCH v2 2/4] examples/vhost: refactor vhost enqueue and dequeue datapaths

2021-09-17 Thread Wenwu Ma
Previously, by judging the flag, we call different enqueue/dequeue
functions in data path.

Now, we use an ops that was initialized when Vhost was created,
so that we can call ops directly in Vhost data path without any more
flag judgment.

Signed-off-by: Wenwu Ma 
Reviewed-by: Maxime Coquelin 
Tested-by: Yvonne Yang 
---
 examples/vhost/main.c   | 100 +---
 examples/vhost/main.h   |  28 --
 examples/vhost/virtio_net.c |  16 +-
 3 files changed, 98 insertions(+), 46 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index d0bf1f31e3..254f7097bc 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -106,6 +106,8 @@ static uint32_t burst_rx_retry_num = BURST_RX_RETRIES;
 static char *socket_files;
 static int nb_sockets;
 
+static struct vhost_queue_ops vdev_queue_ops[MAX_VHOST_DEVICE];
+
 /* empty vmdq configuration structure. Filled in programatically */
 static struct rte_eth_conf vmdq_conf_default = {
.rxmode = {
@@ -879,22 +881,8 @@ drain_vhost(struct vhost_dev *vdev)
uint16_t nr_xmit = vhost_txbuff[buff_idx]->len;
struct rte_mbuf **m = vhost_txbuff[buff_idx]->m_table;
 
-   if (builtin_net_driver) {
-   ret = vs_enqueue_pkts(vdev, VIRTIO_RXQ, m, nr_xmit);
-   } else if (async_vhost_driver) {
-   uint16_t enqueue_fail = 0;
-
-   complete_async_pkts(vdev);
-   ret = rte_vhost_submit_enqueue_burst(vdev->vid, VIRTIO_RXQ, m, 
nr_xmit);
-   __atomic_add_fetch(&vdev->pkts_inflight, ret, __ATOMIC_SEQ_CST);
-
-   enqueue_fail = nr_xmit - ret;
-   if (enqueue_fail)
-   free_pkts(&m[ret], nr_xmit - ret);
-   } else {
-   ret = rte_vhost_enqueue_burst(vdev->vid, VIRTIO_RXQ,
-   m, nr_xmit);
-   }
+   ret = vdev_queue_ops[vdev->vid].enqueue_pkt_burst(vdev,
+   VIRTIO_RXQ, m, nr_xmit);
 
if (enable_stats) {
__atomic_add_fetch(&vdev->stats.rx_total_atomic, nr_xmit,
@@ -1173,6 +1161,33 @@ drain_mbuf_table(struct mbuf_table *tx_q)
}
 }
 
+uint16_t
+async_enqueue_pkts(struct vhost_dev *vdev, uint16_t queue_id,
+   struct rte_mbuf **pkts, uint32_t rx_count)
+{
+   uint16_t enqueue_count;
+   uint16_t enqueue_fail = 0;
+
+   complete_async_pkts(vdev);
+   enqueue_count = rte_vhost_submit_enqueue_burst(vdev->vid,
+   queue_id, pkts, rx_count);
+   __atomic_add_fetch(&vdev->pkts_inflight, enqueue_count,
+   __ATOMIC_SEQ_CST);
+
+   enqueue_fail = rx_count - enqueue_count;
+   if (enqueue_fail)
+   free_pkts(&pkts[enqueue_count], enqueue_fail);
+
+   return enqueue_count;
+}
+
+uint16_t
+sync_enqueue_pkts(struct vhost_dev *vdev, uint16_t queue_id,
+   struct rte_mbuf **pkts, uint32_t rx_count)
+{
+   return rte_vhost_enqueue_burst(vdev->vid, queue_id, pkts, rx_count);
+}
+
 static __rte_always_inline void
 drain_eth_rx(struct vhost_dev *vdev)
 {
@@ -1203,25 +1218,8 @@ drain_eth_rx(struct vhost_dev *vdev)
}
}
 
-   if (builtin_net_driver) {
-   enqueue_count = vs_enqueue_pkts(vdev, VIRTIO_RXQ,
-   pkts, rx_count);
-   } else if (async_vhost_driver) {
-   uint16_t enqueue_fail = 0;
-
-   complete_async_pkts(vdev);
-   enqueue_count = rte_vhost_submit_enqueue_burst(vdev->vid,
-   VIRTIO_RXQ, pkts, rx_count);
-   __atomic_add_fetch(&vdev->pkts_inflight, enqueue_count, 
__ATOMIC_SEQ_CST);
-
-   enqueue_fail = rx_count - enqueue_count;
-   if (enqueue_fail)
-   free_pkts(&pkts[enqueue_count], enqueue_fail);
-
-   } else {
-   enqueue_count = rte_vhost_enqueue_burst(vdev->vid, VIRTIO_RXQ,
-   pkts, rx_count);
-   }
+   enqueue_count = vdev_queue_ops[vdev->vid].enqueue_pkt_burst(vdev,
+   VIRTIO_RXQ, pkts, rx_count);
 
if (enable_stats) {
__atomic_add_fetch(&vdev->stats.rx_total_atomic, rx_count,
@@ -1234,6 +1232,14 @@ drain_eth_rx(struct vhost_dev *vdev)
free_pkts(pkts, rx_count);
 }
 
+uint16_t sync_dequeue_pkts(struct vhost_dev *dev, uint16_t queue_id,
+   struct rte_mempool *mbuf_pool,
+   struct rte_mbuf **pkts, uint16_t count)
+{
+   return rte_vhost_dequeue_burst(dev->vid, queue_id,
+   mbuf_pool, pkts, count);
+}
+
 static __rte_always_inline void
 drain_virtio_tx(struct vhost_dev *vdev)
 {
@@ -1241,13 +1247,8 @@ drain_virtio_tx(struct vhost_dev *vdev)
uint16_t count;
uint16_t i;
 
-  

[dpdk-dev] [PATCH v2 3/4] examples/vhost: use a new API to query remaining ring space

2021-09-17 Thread Wenwu Ma
A new API for querying the remaining descriptor ring capacity
is available, so we use the new one instead of the old one.

Signed-off-by: Wenwu Ma 
Reviewed-by: Maxime Coquelin 
Reviewed-by: Chenbo Xia 
Tested-by: Yvonne Yang 
---
 examples/vhost/ioat.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
index 457f8171f0..6adc30b622 100644
--- a/examples/vhost/ioat.c
+++ b/examples/vhost/ioat.c
@@ -17,7 +17,6 @@ struct packet_tracker {
unsigned short next_read;
unsigned short next_write;
unsigned short last_remain;
-   unsigned short ioat_space;
 };
 
 struct packet_tracker cb_tracker[MAX_VHOST_DEVICE];
@@ -113,7 +112,6 @@ open_ioat(const char *value)
goto out;
}
rte_rawdev_start(dev_id);
-   cb_tracker[dev_id].ioat_space = IOAT_RING_SIZE - 1;
dma_info->nr++;
i++;
}
@@ -140,7 +138,7 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id,
src = descs[i_desc].src;
dst = descs[i_desc].dst;
i_seg = 0;
-   if (cb_tracker[dev_id].ioat_space < src->nr_segs)
+   if (rte_ioat_burst_capacity(dev_id) < src->nr_segs)
break;
while (i_seg < src->nr_segs) {
rte_ioat_enqueue_copy(dev_id,
@@ -155,7 +153,6 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id,
}
write &= mask;
cb_tracker[dev_id].size_track[write] = src->nr_segs;
-   cb_tracker[dev_id].ioat_space -= src->nr_segs;
write++;
}
} else {
@@ -194,7 +191,6 @@ ioat_check_completed_copies_cb(int vid, uint16_t queue_id,
if (n_seg == 0)
return 0;
 
-   cb_tracker[dev_id].ioat_space += n_seg;
n_seg += cb_tracker[dev_id].last_remain;
 
read = cb_tracker[dev_id].next_read;
-- 
2.25.1



[dpdk-dev] [PATCH v2 4/4] examples/vhost: support vhost async dequeue data path

2021-09-17 Thread Wenwu Ma
This patch is to add vhost async dequeue data-path in vhost sample.
vswitch can leverage IOAT to accelerate vhost async dequeue data-path.

Signed-off-by: Wenwu Ma 
Reviewed-by: Maxime Coquelin 
Tested-by: Yvonne Yang 
---
 doc/guides/sample_app_ug/vhost.rst |   9 +-
 examples/vhost/ioat.c  |  61 +++--
 examples/vhost/ioat.h  |  25 
 examples/vhost/main.c  | 201 +++--
 examples/vhost/main.h  |   6 +-
 5 files changed, 219 insertions(+), 83 deletions(-)

diff --git a/doc/guides/sample_app_ug/vhost.rst 
b/doc/guides/sample_app_ug/vhost.rst
index 9afde9c7f5..63dcf181e1 100644
--- a/doc/guides/sample_app_ug/vhost.rst
+++ b/doc/guides/sample_app_ug/vhost.rst
@@ -169,9 +169,12 @@ demonstrates how to use the async vhost APIs. It's used in 
combination with dmas
 **--dmas**
 This parameter is used to specify the assigned DMA device of a vhost device.
 Async vhost-user net driver will be used if --dmas is set. For example
---dmas [txd0@00:04.0,txd1@00:04.1] means use DMA channel 00:04.0 for vhost
-device 0 enqueue operation and use DMA channel 00:04.1 for vhost device 1
-enqueue operation.
+--dmas [txd0@00:04.0,txd1@00:04.1,rxd0@00:04.2,rxd1@00:04.3] means use
+DMA channel 00:04.0/00:04.2 for vhost device 0 enqueue/dequeue operation
+and use DMA channel 00:04.1/00:04.3 for vhost device 1 enqueue/dequeue
+operation. The index of the device corresponds to the socket file in order,
+that means vhost device 0 is created through the first socket file, vhost
+device 1 is created through the second socket file, and so on.
 
 Common Issues
 -
diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
index 6adc30b622..3a256b0f4c 100644
--- a/examples/vhost/ioat.c
+++ b/examples/vhost/ioat.c
@@ -21,6 +21,8 @@ struct packet_tracker {
 
 struct packet_tracker cb_tracker[MAX_VHOST_DEVICE];
 
+int vid2socketid[MAX_VHOST_DEVICE];
+
 int
 open_ioat(const char *value)
 {
@@ -29,7 +31,7 @@ open_ioat(const char *value)
char *addrs = input;
char *ptrs[2];
char *start, *end, *substr;
-   int64_t vid, vring_id;
+   int64_t socketid, vring_id;
struct rte_ioat_rawdev_config config;
struct rte_rawdev_info info = { .dev_private = &config };
char name[32];
@@ -60,6 +62,7 @@ open_ioat(const char *value)
goto out;
}
while (i < args_nr) {
+   bool is_txd;
char *arg_temp = dma_arg[i];
uint8_t sub_nr;
sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@');
@@ -68,27 +71,39 @@ open_ioat(const char *value)
goto out;
}
 
-   start = strstr(ptrs[0], "txd");
-   if (start == NULL) {
+   int async_flag;
+   char *txd, *rxd;
+   txd = strstr(ptrs[0], "txd");
+   rxd = strstr(ptrs[0], "rxd");
+   if (txd) {
+   is_txd = true;
+   start = txd;
+   async_flag = ASYNC_ENQUEUE_VHOST;
+   } else if (rxd) {
+   is_txd = false;
+   start = rxd;
+   async_flag = ASYNC_DEQUEUE_VHOST;
+   } else {
ret = -1;
goto out;
}
 
start += 3;
-   vid = strtol(start, &end, 0);
+   socketid = strtol(start, &end, 0);
if (end == start) {
ret = -1;
goto out;
}
 
-   vring_id = 0 + VIRTIO_RXQ;
+   vring_id = is_txd ? VIRTIO_RXQ : VIRTIO_TXQ;
+
if (rte_pci_addr_parse(ptrs[1],
-   &(dma_info + vid)->dmas[vring_id].addr) < 0) {
+   &(dma_info + socketid)->dmas[vring_id].addr) < 0) {
ret = -1;
goto out;
}
 
-   rte_pci_device_name(&(dma_info + vid)->dmas[vring_id].addr,
+   rte_pci_device_name(&(dma_info + socketid)->dmas[vring_id].addr,
name, sizeof(name));
dev_id = rte_rawdev_get_dev_id(name);
if (dev_id == (uint16_t)(-ENODEV) ||
@@ -103,8 +118,9 @@ open_ioat(const char *value)
goto out;
}
 
-   (dma_info + vid)->dmas[vring_id].dev_id = dev_id;
-   (dma_info + vid)->dmas[vring_id].is_valid = true;
+   (dma_info + socketid)->dmas[vring_id].dev_id = dev_id;
+   (dma_info + socketid)->dmas[vring_id].is_valid = true;
+   (dma_info + socketid)->async_flag |= async_flag;
config.ring_size = IOAT_RING_SIZE;
config.hdls_disable = true;
if (rte_rawdev_configure(dev_id, &info, sizeof(config)) < 0) {
@@ -126,13 +142,16 @@ io

Re: [dpdk-dev] [PATCH 1/4] ethdev: fix max Rx packet length

2021-09-17 Thread Ferruh Yigit
On 9/17/2021 2:08 AM, Min Hu (Connor) wrote:
> Hi, Ferruh,
> What is the status of this set of your patches ?
> Could they be merged?
> 

Hi Connor,

I should send a new version of it, will do soon.

> 
> 在 2021/7/22 22:43, Stephen Hemminger 写道:
>> On Thu, 22 Jul 2021 13:15:04 +0300
>> Andrew Rybchenko  wrote:
>>
 I don't think we care about type of transmission in this level, I assume we
 define min MTU mainly for the HW limitation and configuration. That is why 
 it
 makes sense to me to use Ethernet frame lenght limitation (not IPv4 one).
>>>
>>> +1
>>
>> Also it is important that DPDK follow the conventions of other software
>> such as Linux and BSD. Cisco and Juniper already disagree about whether
>> header should be included in what is defined as MTU; i.e Cisco says 1514
>> and Juniper says 1500.
>> .
>>



Re: [dpdk-dev] [PATCH v5 0/3] net/i40e: remove i40evf

2021-09-17 Thread Ferruh Yigit
On 9/17/2021 2:55 AM, Zhang, RobinX wrote:
> Hi, Ferruh
> 
>> -Original Message-
>> From: Yigit, Ferruh 
>> Sent: Friday, September 17, 2021 12:28 AM
>> To: Zhang, RobinX ; dev@dpdk.org
>> Cc: Wang, Haiyue ; Xing, Beilei
>> ; m...@ashroe.eu; Wu, Jingjing
>> ; Burakov, Anatoly ;
>> Zhang, Qi Z ; Guo, Junfeng ;
>> Yang, SteveX 
>> Subject: Re: [dpdk-dev] [PATCH v5 0/3] net/i40e: remove i40evf
>>
>> On 9/15/2021 4:09 AM, Robin Zhang wrote:
>>> In DPDK 21.05, iavf already became the default VF for i40e devices.
>>> So remove i40evf due to it's no need to maintain now.
>>>
>>> v5:
>>> - rebase code.
>>>
>>> v4:
>>> - resolve compile warning issue.
>>>
>>> v3:
>>> - remove VF related code in i40e_rxtx.c.
>>>
>>> v2:
>>> - update 21.11 release note, remove some missed documentation.
>>>
>>> Robin Zhang (3):
>>>   net/i40e: remove i40evf
>>>   net/iavf: remove i40evf devargs option
>>>   doc: remove i40evf related documentation
>>>
>>
>> Just to double check, searching 'i40evf' within driver still yields some 
>> results
>> [1]. Is this expected? Why they should remain?
> 
> git grep -i i40evf drivers/net/:
> 
> i40e/base/i40e_osdep.h:#define I40EVF_WRITE_FLUSH(a) I40E_READ_REG(a, 
> I40E_VFGEN_RSTAT)
>   This macro is defined in i40e share code.
> 
> i40e/i40e_ethdev.h:/* I40EVF_DEV_PRIVATE_TO */
> i40e/i40e_ethdev.h:#define I40EVF_DEV_PRIVATE_TO_VF(adapter) \
> i40e/i40e_ethdev.h: struct i40e_vf *vf = 
> I40EVF_DEV_PRIVATE_TO_VF(adapter);
>   This is a helper function "i40e_get_vsi_from_adapter", we still keep 
> the i40e_vf member in i40e_adapter structure for some future possibilities.
> 

What do you mean by "future possibilities"?

> i40e/i40e_vf_representor.c:i40evf_stat_update_48(uint64_t *offset,
> i40e/i40e_vf_representor.c:i40evf_stat_update_32(uint64_t *offset,
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_32(
> i40e/i40e_vf_representor.c: i40evf_stat_update_32(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_48(
> i40e/i40e_vf_representor.c: i40evf_stat_update_32(
> i40e/i40e_vf_representor.c: i40evf_stat_update_32(
>   These are ops for VF representor ports of i40e
> 
>>
>>
>> Thanks,
>> ferruh
>>
>>
>> [1]
>> git grep -i i40evf drivers/net/



Re: [dpdk-dev] [PATCH 1/4] ethdev: fix max Rx packet length

2021-09-17 Thread Min Hu (Connor)




在 2021/9/17 16:04, Ferruh Yigit 写道:

On 9/17/2021 2:08 AM, Min Hu (Connor) wrote:

Hi, Ferruh,
 What is the status of this set of your patches ?
 Could they be merged?



Hi Connor,

I should send a new version of it, will do soon.


Thanks Ferruh.



在 2021/7/22 22:43, Stephen Hemminger 写道:

On Thu, 22 Jul 2021 13:15:04 +0300
Andrew Rybchenko  wrote:


I don't think we care about type of transmission in this level, I assume we
define min MTU mainly for the HW limitation and configuration. That is why it
makes sense to me to use Ethernet frame lenght limitation (not IPv4 one).


+1


Also it is important that DPDK follow the conventions of other software
such as Linux and BSD. Cisco and Juniper already disagree about whether
header should be included in what is defined as MTU; i.e Cisco says 1514
and Juniper says 1500.
.



.



Re: [dpdk-dev] [PATCH 1/4] ethdev: fix max Rx packet length

2021-09-17 Thread Min Hu (Connor)




在 2021/9/17 16:04, Ferruh Yigit 写道:

On 9/17/2021 2:08 AM, Min Hu (Connor) wrote:

Hi, Ferruh,
 What is the status of this set of your patches ?
 Could they be merged?



Hi Connor,

I should send a new version of it, will do soon.


Please Cc me next time your send the new version, thanks.


在 2021/7/22 22:43, Stephen Hemminger 写道:

On Thu, 22 Jul 2021 13:15:04 +0300
Andrew Rybchenko  wrote:


I don't think we care about type of transmission in this level, I assume we
define min MTU mainly for the HW limitation and configuration. That is why it
makes sense to me to use Ethernet frame lenght limitation (not IPv4 one).


+1


Also it is important that DPDK follow the conventions of other software
such as Linux and BSD. Cisco and Juniper already disagree about whether
header should be included in what is defined as MTU; i.e Cisco says 1514
and Juniper says 1500.
.



.



Re: [dpdk-dev] [PATCH v2] Enable AddressSanitizer feature on DPDK

2021-09-17 Thread David Marchand
On Thu, Sep 16, 2021 at 3:47 AM  wrote:
>
> From: Zhihong Peng 
>
> AddressSanitizer (ASan) is a google memory error detect
> standard tool. It could help to detect use-after-free and
> {heap,stack,global}-buffer overflow bugs in C/C++ programs,
> print detailed error information when error happens, large
> improve debug efficiency.
>
> By referring to its implementation algorithm
> (https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm),
> enable heap-buffer-overflow and use-after-free functions on dpdk.
> DPDK ASAN function currently only supports on Linux x86_64.
>
> Here is an example of heap-buffer-overflow bug:
> ..
> char *p = rte_zmalloc(NULL, 7, 0);
> p[7] = 'a';
> ..
>
> Here is an example of use-after-free bug:
> ..
> char *p = rte_zmalloc(NULL, 7, 0);
> rte_free(p);
> *p = 'a';
> ..
>

Unfortunately, this won't build with some (too smart) compilers.
Can you look at the CI report?
Thanks.


> If you want to use this feature,
> you need to add below compilation options when compiling code:
> -Dbuildtype=debug -Db_lundef=false -Db_sanitize=address
> "-Dbuildtype=debug": Display code information when coredump occurs
> in the program.
> "-Db_lundef=false": It is enabled by default, and needs to be
> disabled when using asan.
>
> Signed-off-by: Xueqin Lin 
> Signed-off-by: Zhihong Peng 



-- 
David Marchand



[dpdk-dev] [PATCH 0/3] Experiment ASAN in GHA

2021-09-17 Thread David Marchand
Following fixes for ASAN, I added ASAN in GHA to see where we stand.
Here are two fixes that can be merged.

The last patch enables ASAN, but as we can see, there are still some
unit tests who fails because of ASAN:
- multiprocess is broken, we could flag the ut requiring/testing mp,
- hash tests have a lot of issues, I suspect bugs in the hash library,


-- 
David Marchand

David Marchand (3):
  bus/vmbus: fix leak on device scan
  test/latencystats: fix incorrect loop boundary
  ci: run unit tests with ASAN

 .ci/linux-build.sh  | 9 -
 app/test/test_latencystats.c| 2 +-
 drivers/bus/vmbus/linux/vmbus_bus.c | 5 -
 drivers/bus/vmbus/rte_bus_vmbus.h   | 1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

-- 
2.23.0



[dpdk-dev] [PATCH 1/3] bus/vmbus: fix leak on device scan

2021-09-17 Thread David Marchand
Caught running ASAN.

The device name is leaked on scan.
rte_device name field being a const, use the private vmbus struct to
store the device name and point at it.

Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/bus/vmbus/linux/vmbus_bus.c | 5 -
 drivers/bus/vmbus/rte_bus_vmbus.h   | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c 
b/drivers/bus/vmbus/linux/vmbus_bus.c
index 3c924eee14..d8eb07d398 100644
--- a/drivers/bus/vmbus/linux/vmbus_bus.c
+++ b/drivers/bus/vmbus/linux/vmbus_bus.c
@@ -242,7 +242,7 @@ vmbus_scan_one(const char *name)
return -1;
 
dev->device.bus = &rte_vmbus_bus.bus;
-   dev->device.name = strdup(name);
+   dev->device.name = dev->name = strdup(name);
if (!dev->device.name)
goto error;
 
@@ -261,6 +261,7 @@ vmbus_scan_one(const char *name)
 
/* skip non-network devices */
if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) {
+   free(dev->name);
free(dev);
return 0;
}
@@ -312,6 +313,7 @@ vmbus_scan_one(const char *name)
} else { /* already registered */
VMBUS_LOG(NOTICE,
"%s already registered", name);
+   free(dev->name);
free(dev);
}
return 0;
@@ -322,6 +324,7 @@ vmbus_scan_one(const char *name)
 error:
VMBUS_LOG(DEBUG, "failed");
 
+   free(dev->name);
free(dev);
return -1;
 }
diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h 
b/drivers/bus/vmbus/rte_bus_vmbus.h
index 4cf73ce815..438eb481fc 100644
--- a/drivers/bus/vmbus/rte_bus_vmbus.h
+++ b/drivers/bus/vmbus/rte_bus_vmbus.h
@@ -65,6 +65,7 @@ struct rte_vmbus_device {
TAILQ_ENTRY(rte_vmbus_device) next;/**< Next probed VMBUS device */
const struct rte_vmbus_driver *driver; /**< Associated driver */
struct rte_device device;  /**< Inherit core device */
+   char *name;/**< Device name */
rte_uuid_t device_id;  /**< VMBUS device id */
rte_uuid_t class_id;   /**< VMBUS device type */
uint32_t relid;/**< id for primary */
-- 
2.23.0



[dpdk-dev] [PATCH 2/3] test/latencystats: fix incorrect loop boundary

2021-09-17 Thread David Marchand
Caught running ASAN.

lat_stats_strings[] is an array containing NUM_STATS strings.

Fixes: 1e3676a06e4c ("test/latency: add unit tests for latencystats library")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 app/test/test_latencystats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c
index 427339904d..724acbc315 100644
--- a/app/test/test_latencystats.c
+++ b/app/test/test_latencystats.c
@@ -80,7 +80,7 @@ static int test_latencystats_get_names(void)
/* Success Test: Valid names and size */
size = NUM_STATS;
ret = rte_latencystats_get_names(names, size);
-   for (i = 0; i <= NUM_STATS; i++) {
+   for (i = 0; i < NUM_STATS; i++) {
if (strcmp(lat_stats_strings[i].name, names[i].name) == 0)
printf(" %s\n", names[i].name);
else
-- 
2.23.0



[dpdk-dev] [PATCH v2 0/2] support to clear in-flight packets for async

2021-09-17 Thread Yuan Wang
This patch supports to clear in-flight packets for aysnc dequeue and
introduces thread-safe version of this function.

note: This patch depends on the following vhost patch
(http://patchwork.dpdk.org/project/dpdk/patch/20210917192703.385510-2-wenwux...@intel.com/)

v2:
- Update release note.
- Add check on queue id and split queue.

Yuan Wang (2):
  vhost: support to clear in-flight packets for async dequeue
  vhost: add thread-safe API for clearing in-flight packets in async
vhost

 doc/guides/prog_guide/vhost_lib.rst |  8 +++-
 lib/vhost/rte_vhost_async.h | 21 +
 lib/vhost/version.map   |  1 +
 lib/vhost/virtio_net.c  | 68 -
 4 files changed, 95 insertions(+), 3 deletions(-)

-- 
2.25.1



[dpdk-dev] [PATCH v2 1/2] vhost: support to clear in-flight packets for async dequeue

2021-09-17 Thread Yuan Wang
rte_vhost_clear_queue_thread_unsafe() supports to clear
in-flight packets for async enqueue only. But after
supporting async dequeue, this API should support async dequeue too.

Signed-off-by: Yuan Wang 
---
 lib/vhost/virtio_net.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 4bc69b9081..cc84a9d21e 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -27,6 +27,11 @@
 
 #define VHOST_ASYNC_BATCH_THRESHOLD 32
 
+static __rte_always_inline uint16_t
+async_poll_dequeue_completed_split(struct virtio_net *dev,
+   struct vhost_virtqueue *vq, uint16_t queue_id,
+   struct rte_mbuf **pkts, uint16_t count, bool legacy_ol_flags);
+
 static  __rte_always_inline bool
 rxvq_is_mergeable(struct virtio_net *dev)
 {
@@ -2120,7 +2125,7 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t 
queue_id,
return 0;
 
VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
-   if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {
+   if (unlikely(queue_id >= dev->nr_vring)) {
VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",
dev->vid, __func__, queue_id);
return 0;
@@ -2134,7 +2139,17 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t 
queue_id,
return 0;
}
 
-   n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count);
+   if (queue_id % 2 == 0)
+   n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, 
count);
+   else {
+   if (unlikely(vq_is_packed(dev)))
+   VHOST_LOG_DATA(ERR,
+   "(%d) %s: async dequeue does not support packed 
ring.\n",
+   dev->vid, __func__);
+   else
+   n_pkts_cpl = async_poll_dequeue_completed_split(dev, 
vq, queue_id, pkts,
+   count, dev->flags & 
VIRTIO_DEV_LEGACY_OL_FLAGS);
+   }
 
return n_pkts_cpl;
 }
-- 
2.25.1



[dpdk-dev] [PATCH 3/3] ci: run unit tests with ASAN

2021-09-17 Thread David Marchand
Enable ASAN for clang jobs.
This can greatly help identify leaks and buffer overflows.
This patch is more a fyi, as some unit tests stil have issues.

Signed-off-by: David Marchand 
---
 .ci/linux-build.sh | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
index 91e43a975b..a961d9b92d 100755
--- a/.ci/linux-build.sh
+++ b/.ci/linux-build.sh
@@ -79,7 +79,14 @@ fi
 
 OPTS="$OPTS -Dmachine=default"
 OPTS="$OPTS --default-library=$DEF_LIB"
-OPTS="$OPTS --buildtype=debugoptimized"
+
+if [ "$CC" != "${CC%%clang}" ] && [ "$RUN_TESTS" = 'true' ]; then
+# Let's run tests with ASAN
+OPTS="$OPTS -Db_sanitize=address -Db_lundef=false --buildtype=debug"
+else
+OPTS="$OPTS --buildtype=debugoptimized"
+fi
+
 OPTS="$OPTS -Dcheck_includes=true"
 meson build --werror $OPTS
 ninja -C build
-- 
2.23.0



[dpdk-dev] [PATCH v2 2/2] vhost: add thread-safe API for clearing in-flight packets in async vhost

2021-09-17 Thread Yuan Wang
This patch adds thread safe version for
clearing in-flight packets function.

Signed-off-by: Yuan Wang 
---
 doc/guides/prog_guide/vhost_lib.rst |  8 -
 lib/vhost/rte_vhost_async.h | 21 +
 lib/vhost/version.map   |  1 +
 lib/vhost/virtio_net.c  | 49 +
 4 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/doc/guides/prog_guide/vhost_lib.rst 
b/doc/guides/prog_guide/vhost_lib.rst
index 9ed544db7a..bc21c879f3 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -300,7 +300,13 @@ The following is an overview of some key Vhost API 
functions:
 
 * ``rte_vhost_clear_queue_thread_unsafe(vid, queue_id, **pkts, count)``
 
-  Clear inflight packets which are submitted to DMA engine in vhost async data
+  Clear in-flight packets which are submitted to async channel in vhost
+  async data path without performing any locking. Completed packets are
+  returned to applications through ``pkts``.
+
+* ``rte_vhost_clear_queue(vid, queue_id, **pkts, count)``
+
+  Clear in-flight packets which are submitted to async channel in vhost async 
data
   path. Completed packets are returned to applications through ``pkts``.
 
 * ``rte_vhost_async_try_dequeue_burst(vid, queue_id, mbuf_pool, pkts, count, 
nr_inflight)``
diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
index 973efa19b1..887fc2fa47 100644
--- a/lib/vhost/rte_vhost_async.h
+++ b/lib/vhost/rte_vhost_async.h
@@ -256,6 +256,27 @@ int rte_vhost_async_get_inflight(int vid, uint16_t 
queue_id);
 __rte_experimental
 uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,
struct rte_mbuf **pkts, uint16_t count);
+
+/**
+ * This function checks async completion status and clear packets for
+ * a specific vhost device queue. Packets which are inflight will be
+ * returned in an array.
+ *
+ * @param vid
+ *  ID of vhost device to clear data
+ * @param queue_id
+ *  Queue id to clear data
+ * @param pkts
+ *  Blank array to get return packet pointer
+ * @param count
+ *  Size of the packet array
+ * @return
+ *  Number of packets returned
+ */
+__rte_experimental
+uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id,
+   struct rte_mbuf **pkts, uint16_t count);
+
 /**
  * This function tries to receive packets from the guest with offloading
  * copies to the async channel. The packets that are transfer completed
diff --git a/lib/vhost/version.map b/lib/vhost/version.map
index 8eb7e92c32..b87d5906b8 100644
--- a/lib/vhost/version.map
+++ b/lib/vhost/version.map
@@ -88,4 +88,5 @@ EXPERIMENTAL {
 
# added in 21.11
rte_vhost_async_try_dequeue_burst;
+   rte_vhost_clear_queue;
 };
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index cc84a9d21e..e7292332a8 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -2154,6 +2154,55 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t 
queue_id,
return n_pkts_cpl;
 }
 
+uint16_t
+rte_vhost_clear_queue(int vid, uint16_t queue_id, struct rte_mbuf **pkts, 
uint16_t count)
+{
+   struct virtio_net *dev = get_device(vid);
+   struct vhost_virtqueue *vq;
+   uint16_t n_pkts_cpl;
+
+   if (!dev)
+   return 0;
+
+   VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
+   if (unlikely(queue_id >= dev->nr_vring)) {
+   VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",
+   dev->vid, __func__, queue_id);
+   return 0;
+   }
+
+   vq = dev->virtqueue[queue_id];
+
+   if (unlikely(!vq->async_registered)) {
+   VHOST_LOG_DATA(ERR, "(%d) %s: async not registered for queue id 
%d.\n",
+   dev->vid, __func__, queue_id);
+   return 0;
+   }
+
+   if (!rte_spinlock_trylock(&vq->access_lock)) {
+   VHOST_LOG_DATA(ERR,
+   "(%d) %s: failed to clear async queue id %d, virtqueue 
busy.\n",
+   dev->vid, __func__, queue_id);
+   return 0;
+   }
+
+   if (queue_id % 2 == 0)
+   n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, 
count);
+   else {
+   if (unlikely(vq_is_packed(dev)))
+   VHOST_LOG_DATA(ERR,
+   "(%d) %s: async dequeue does not support packed 
ring.\n",
+   dev->vid, __func__);
+   else
+   n_pkts_cpl = async_poll_dequeue_completed_split(dev, 
vq, queue_id, pkts,
+   count, dev->flags & 
VIRTIO_DEV_LEGACY_OL_FLAGS);
+   }
+
+   rte_spinlock_unlock(&vq->access_lock);
+
+   return n_pkts_cpl;
+}
+
 static __rte_always_inline uint32_t
 virtio_dev_rx_async_submit(struct virtio_net *dev, uint16_t queue_id,
struct rte_mbuf **pkts, uint32_t count)
-- 
2.25.1



Re: [dpdk-dev] [PATCH v5 1/9] bbdev: add big endian processing data capability

2021-09-17 Thread Nipun Gupta



> -Original Message-
> From: Chautru, Nicolas 
> Sent: Tuesday, September 14, 2021 12:10 AM
> To: Nipun Gupta ; dev@dpdk.org; gak...@marvell.com
> Cc: david.march...@redhat.com; Hemant Agrawal
> ; Tom Rix 
> Subject: RE: [PATCH v5 1/9] bbdev: add big endian processing data capability
> 
> 
> 
> > -Original Message-
> > From: Nipun Gupta 
> > Sent: Sunday, September 12, 2021 5:15 AM
> > To: dev@dpdk.org; gak...@marvell.com; Chautru, Nicolas
> > 
> > Cc: david.march...@redhat.com; hemant.agra...@nxp.com; Nipun Gupta
> > 
> > Subject: [PATCH v5 1/9] bbdev: add big endian processing data capability
> >
> > This patch intoduces a new capability of the bbdev device to process the
> > LDPC data in big endian order.
> 
> Hi Gupta,
> 
> As mentioned in previous patch iteration earlier this year I believe this is 
> not
> really an operation flag but more a different device capability.
> ie. you would have the same formalism for all operation (5GDL, 5GUL, 4GDL, 
> ...)
> for that PMD/hw and that is not something you will change dynamically as an
> option.
> I would suggest to add this under "struct rte_bbdev_driver_info" which can be
> used to capture device specific capability and information. In term of 
> processing
> and operation, everything is the same except endianness assumption for the
> input/output data.

Okay, it can be done this way. Then it would be assumption of the driver, that 
the
operation is in the format as per the driver info. Ill change it in respin.

> 
> 
> >
> > Signed-off-by: Hemant Agrawal 
> > Signed-off-by: Nipun Gupta 
> > ---
> >  doc/guides/bbdevs/features/default.ini |  1 +
> >  doc/guides/prog_guide/bbdev.rst|  6 ++
> >  lib/bbdev/rte_bbdev_op.h   | 14 --
> >  3 files changed, 19 insertions(+), 2 deletions(-)
> >
> > diff --git a/doc/guides/bbdevs/features/default.ini
> > b/doc/guides/bbdevs/features/default.ini
> > index 5fe267a625..ae5aacf8f7 100644
> > --- a/doc/guides/bbdevs/features/default.ini
> > +++ b/doc/guides/bbdevs/features/default.ini
> > @@ -14,3 +14,4 @@ LLR/HARQ Compression   =
> >  External DDR Access=
> >  HW Accelerated =
> >  BBDEV API  =
> > +Big Endian Processing  =
> > diff --git a/doc/guides/prog_guide/bbdev.rst
> > b/doc/guides/prog_guide/bbdev.rst index 9619280ffc..6540b514bb 100644
> > --- a/doc/guides/prog_guide/bbdev.rst
> > +++ b/doc/guides/prog_guide/bbdev.rst
> > @@ -747,6 +747,9 @@ given below.
> >  |RTE_BBDEV_LDPC_ENC_CONCATENATION|
> >  | Set if a device supports concatenation of non byte aligned output  |  
> > +--
> > --+
> > +|RTE_BBDEV_LDPC_ENC_BIG_ENDIAN   |
> > +| Set if a device supports Big Endian data processing|
> > +++
> >
> >  The structure passed for each LDPC encode operation is given below,  with
> > the operation flags forming a bitmask in the ``op_flags`` field.
> > @@ -942,6 +945,9 @@ given below.
> >  |RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK|
> >  | Set if a device supports loopback access to HARQ internal memory   |
> >  ++
> > +|RTE_BBDEV_LDPC_DEC_BIG_ENDIAN   |
> > +| Set if a device supports Big Endian data processing|
> > +++
> >
> >  The structure passed for each LDPC decode operation is given below,  with
> > the operation flags forming a bitmask in the ``op_flags`` field.
> > diff --git a/lib/bbdev/rte_bbdev_op.h b/lib/bbdev/rte_bbdev_op.h index
> > f946842727..9e9b5be81f 100644
> > --- a/lib/bbdev/rte_bbdev_op.h
> > +++ b/lib/bbdev/rte_bbdev_op.h
> > @@ -186,7 +186,12 @@ enum rte_bbdev_op_ldpcdec_flag_bitmasks {
> >  *  for HARQ memory. If not set, it is assumed the filler bits are not
> >  *  in HARQ memory and handled directly by the LDPC decoder.
> >  */
> > -   RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS = (1ULL <<
> > 18)
> > +   RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS = (1ULL <<
> > 18),
> > +   /** Set if a device supports Big Endian data processing.
> > +*  If not set Little Endian data processing is supported by
> > +*  default.
> > +*/
> > +   RTE_BBDEV_LDPC_DEC_BIG_ENDIAN = (1ULL << 8)
> >  };
> >
> >  /** Flags for LDPC encoder operation and capability structure */ @@ -206,7
> > +211,12 @@ enum rte_bbdev_op_ldpcenc_flag_bitmasks {
> > /** Set if a device supports scatter-gather functionality. */
> > RTE_BBDEV_LDPC_ENC_SCATTER_GATHER = (1ULL << 6),
> > /** Set if a device supports concatenation of non byte aligned output
> > */
> > -   RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7)
> > +   RTE_BBDEV_LDPC_ENC_CONCATENATION = (1ULL << 7),
> > +   /** Set if a device

Re: [dpdk-dev] [PATCH v5 5/9] baseband/la12xx: add queue and modem config support

2021-09-17 Thread Nipun Gupta



> -Original Message-
> From: Chautru, Nicolas 
> Sent: Tuesday, September 14, 2021 12:26 AM
> To: Nipun Gupta ; dev@dpdk.org; gak...@marvell.com
> Cc: david.march...@redhat.com; Hemant Agrawal 
> Subject: RE: [PATCH v5 5/9] baseband/la12xx: add queue and modem config
> support
> 
> 
> 
> > -Original Message-
> > From: Nipun Gupta 
> > Sent: Sunday, September 12, 2021 5:15 AM
> > To: dev@dpdk.org; gak...@marvell.com; Chautru, Nicolas
> > 
> > Cc: david.march...@redhat.com; hemant.agra...@nxp.com; Nipun Gupta
> > 
> > Subject: [PATCH v5 5/9] baseband/la12xx: add queue and modem config
> > support
> >
> > From: Hemant Agrawal 
> >
> > This patch add support for connecting with modem and creating the ipc
> > channel as queues with modem for the exchange of data.
> >
> > Signed-off-by: Nipun Gupta 
> > Signed-off-by: Hemant Agrawal 
> > ---
> >  MAINTAINERS|   1 +
> >  doc/guides/bbdevs/index.rst|   1 +
> >  doc/guides/bbdevs/la12xx.rst   |  81 +++
> >  doc/guides/rel_notes/release_21_11.rst |   5 +
> >  drivers/baseband/la12xx/bbdev_la12xx.c | 553 -
> >  drivers/baseband/la12xx/bbdev_la12xx.h |  11 +-
> >  drivers/baseband/la12xx/bbdev_la12xx_ipc.h | 189 ++-
> >  7 files changed, 831 insertions(+), 10 deletions(-)  create mode 100644
> > doc/guides/bbdevs/la12xx.rst
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index a63e672c9e..2c243c10fe 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -1295,6 +1295,7 @@ NXP LA12xx driver
> >  M: Hemant Agrawal 
> >  M: Nipun Gupta 
> >  F: drivers/baseband/la12xx/
> > +F: doc/guides/bbdevs/la12xx.rst
> >
> >
> >  Rawdev Drivers
> > diff --git a/doc/guides/bbdevs/index.rst b/doc/guides/bbdevs/index.rst
> > index 4445cbd1b0..cedd706fa6 100644
> > --- a/doc/guides/bbdevs/index.rst
> > +++ b/doc/guides/bbdevs/index.rst
> > @@ -14,3 +14,4 @@ Baseband Device Drivers
> >  fpga_lte_fec
> >  fpga_5gnr_fec
> >  acc100
> > +la12xx
> > diff --git a/doc/guides/bbdevs/la12xx.rst b/doc/guides/bbdevs/la12xx.rst
> > new file mode 100644 index 00..3c9ac5c047
> > --- /dev/null
> > +++ b/doc/guides/bbdevs/la12xx.rst
> > @@ -0,0 +1,81 @@
> > +..  SPDX-License-Identifier: BSD-3-Clause
> > +Copyright 2021 NXP
> > +
> > +NXP LA12xx Poll Mode Driver
> > +===
> > +
> > +The BBDEV LA12xx poll mode driver (PMD) supports an implementation for
> > +offloading High Phy processing functions like LDPC Encode / Decode 5GNR
> > +wireless acceleration function, using PCI based LA12xx Software defined
> > radio.
> > +
> > +More information can be found at `NXP Official Website
> >
> + nxp.com%2Fproducts%2Fprocessors-and-microcontrollers%2Farm-
> &data=04%7C01%7Cnipun.gupta%40nxp.com%7C92cc367c64324a156f730
> 8d976e8373d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6376715
> 62002990761%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjo
> iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4HYKiRKBu
> Y4VkVvN73UKM8ZP13NcBEx81ZbME9LiWhI%3D&reserved=0
> > processors/layerscape-processors/layerscape-access-la1200-programmable-
> > baseband-processor:LA1200>`_.
> > +
> > +Features
> > +
> > +
> > +LA12xx PMD supports the following features:
> > +
> > +- Maximum of 8 UL queues
> > +- Maximum of 8 DL queues
> > +- PCIe Gen-3 x8 Interface
> > +- MSI-X
> > +
> > +Installation
> > +
> > +
> > +Section 3 of the DPDK manual provides instructions on installing and
> > compiling DPDK.
> > +
> > +DPDK requires hugepages to be configured as detailed in section 2 of the
> > DPDK manual.
> > +
> > +Initialization
> > +--
> > +
> > +The device can be listed on the host console with:
> > +
> > +
> > +Use the following lspci command to get the multiple LA12xx processor
> > +ids. The device ID of the LA12xx baseband processor is "1c30".
> > +
> > +.. code-block:: console
> > +
> > +  sudo lspci -nn
> > +
> > +...
> > +0001:01:00.0 Power PC [0b20]: Freescale Semiconductor Inc Device
> > +[1957:1c30] ( rev 10) ...
> > +0002:01:00.0 Power PC [0b20]: Freescale Semiconductor Inc Device
> > +[1957:1c30] ( rev 10)
> > +
> > +
> > +Prerequisites
> > +-
> > +
> > +Currently supported by DPDK:
> > +
> > +- NXP LA1224 BSP **1.0+**.
> > +- NXP LA1224 PCIe Modem card connected to ARM host.
> > +
> > +- Follow the DPDK :ref:`Getting Started Guide for Linux ` to
> > setup the basic DPDK environment.
> > +
> > +* Use dev arg option ``modem=0`` to identify the modem instance for a
> > +given
> > +  device. This is required only if more than 1 modem cards are attached to
> > host.
> > +  this is optional and the default value is 0.
> > +  e.g. ``--vdev=baseband_la12xx,modem=0``
> > +
> > +* Use dev arg option ``max_nb_queues=x`` to specify the maximum
> > number
> > +of queues
> > +  to be used for communication with offload device i.e. modem.

Re: [dpdk-dev] [PATCH v5 9/9] app/bbdev: add test vectors for transport blocks

2021-09-17 Thread Nipun Gupta



> -Original Message-
> From: Chautru, Nicolas 
> Sent: Tuesday, September 14, 2021 12:32 AM
> To: Nipun Gupta ; dev@dpdk.org; gak...@marvell.com
> Cc: david.march...@redhat.com; Hemant Agrawal 
> Subject: RE: [PATCH v5 9/9] app/bbdev: add test vectors for transport blocks
> 
> 
> 
> > -Original Message-
> > From: Nipun Gupta 
> > Sent: Sunday, September 12, 2021 5:15 AM
> > To: dev@dpdk.org; gak...@marvell.com; Chautru, Nicolas
> > 
> > Cc: david.march...@redhat.com; hemant.agra...@nxp.com; Nipun Gupta
> > 
> > Subject: [PATCH v5 9/9] app/bbdev: add test vectors for transport blocks
> >
> > This patch adds two test vectors for transport block in network byte
> > order:
> > - LDPC encode for Transport Block
> > - LDPC decode for Transport block
> 
> See comments on previous patchsets related to the same topic:
>  - This test vector includes Ratematching hence previous pmd exposed 
> capability
> were not correct

It is supported in our driver, I will add it in the capabilities.

> - This is really is a single CB vector (not a TB made of multiple CBs). More
> generally I don't believe there is new functionality here compared to existing
> vectors. (keep in mind that the endianness can be managed as a device
> capability and would not require new vectors).

I agree, it is a single CB, otherwise the test vector file becomes large.
But all the TB parameters are supported, which is not the case with the previous
tests.

I prefer to add a bigger test vector with multiple CBs. But then I hear that 
file
size is a problem. I don't think it should be a problem. Let me respin with a 
larger
size TB.

> 
> Thanks
> Nic
> 
> >
> > Signed-off-by: Nipun Gupta 
> > ---
> >  app/test-bbdev/test_vectors/ldpc_dec_tb.data | 122
> > +++  app/test-bbdev/test_vectors/ldpc_enc_tb.data |
> > 60 +
> >  2 files changed, 182 insertions(+)
> >  create mode 100644 app/test-bbdev/test_vectors/ldpc_dec_tb.data
> >  create mode 100644 app/test-bbdev/test_vectors/ldpc_enc_tb.data
> >
> > diff --git a/app/test-bbdev/test_vectors/ldpc_dec_tb.data b/app/test-
> > bbdev/test_vectors/ldpc_dec_tb.data
> > new file mode 100644
> > index 00..b991e8f305
> > --- /dev/null
> > +++ b/app/test-bbdev/test_vectors/ldpc_dec_tb.data
> > @@ -0,0 +1,122 @@
> > +# SPDX-License-Identifier: BSD-3-Clause # Copyright 2020 NXP
> > +
> > +op_type =
> > +RTE_BBDEV_OP_LDPC_DEC
> > +
> > +input0 =
> > +0x817f8181, 0x7f7f8181, 0x817f7f81, 0x81817f81, 0x81817f81, 0x817f7f81,
> > +0x7f7f7f7f, 0x7f7f7f81, 0x817f7f81, 0x817f7f81, 0x7f7f817f, 0x7f7f7f81,
> > +0x81817f7f, 0x81818181, 0x817f8181, 0x7f817f81, 0x81817f7f, 0x7f7f817f,
> > +0x81817f81, 0x817f8181, 0x7f7f7f81, 0x817f817f, 0x7f817f7f, 0x7f817f7f,
> > +0x7f817f7f, 0x81817f7f, 0x7f818181, 0x817f7f7f, 0x8181817f, 0x81817f7f,
> > +0x7f817f81, 0x7f7f7f7f, 0x7f817f7f, 0x81817f7f, 0x81818181, 0x817f817f,
> > +0x81817f7f, 0x7f81817f, 0x7f7f7f7f, 0x7f7f7f7f, 0x7f818181, 0x7f7f7f81,
> > +0x81817f81, 0x7f817f7f, 0x7f7f7f7f, 0x817f817f, 0x817f817f, 0x7f7f817f,
> > +0x81817f81, 0x7f7f7f7f, 0x7f81817f, 0x817f817f, 0x7f7f8181, 0x7f7f7f7f,
> > +0x817f7f7f, 0x81818181, 0x817f8181, 0x7f7f817f, 0x7f7f8181, 0x7f7f7f7f,
> > +0x7f818181, 0x817f8181, 0x817f7f81, 0x817f8181, 0x817f7f81, 0x81817f7f,
> > +0x7f7f8181, 0x81818181, 0x817f817f, 0x817f7f7f, 0x81818181, 0x7f817f81,
> > +0x7f7f7f81, 0x81817f81, 0x7f817f7f, 0x7f818181, 0x7f7f7f81, 0x817f817f,
> > +0x81818181, 0x81818181, 0x81817f81, 0x81817f81, 0x7f7f8181, 0x817f7f7f,
> > +0x7f81817f, 0x817f817f, 0x81817f7f, 0x817f7f81, 0x81817f7f, 0x7f7f7f81,
> > +0x7f817f81, 0x7f817f81, 0x817f7f7f, 0x7f818181, 0x81818181, 0x7f7f7f7f,
> > +0x7f7f7f7f, 0x8181817f, 0x7f7f7f81, 0x7f817f81, 0x81817f81, 0x7f7f817f,
> > +0x7f81817f, 0x817f8181, 0x7f81817f, 0x7f81817f, 0x817f7f7f, 0x7f81817f,
> > +0x817f7f81, 0x817f7f81, 0x7f817f7f, 0x8181817f, 0x7f81817f, 0x7f7f8181,
> > +0x817f8181, 0x817f7f7f, 0x817f7f81, 0x7f81817f, 0x7f7f817f, 0x7f817f7f,
> > +0x7f7f8181, 0x81818181, 0x7f818181, 0x7f7f817f, 0x7f818181, 0x81818181,
> > +0x7f817f7f, 0x817f817f, 0x817f817f, 0x817f7f7f, 0x81817f81, 0x81817f7f,
> > +0x81817f81, 0x7f817f81, 0x7f817f7f, 0x7f817f7f, 0x817f7f7f, 0x817f7f7f,
> > +0x7f7f7f7f, 0x7f7f7f81, 0x7f7f8181, 0x7f817f81, 0x7f817f7f, 0x817f7f7f,
> > +0x7f7f8181, 0x8181817f, 0x7f7f8181, 0x7f7f7f81, 0x817f7f7f, 0x7f7f7f81,
> > +0x817f8181, 0x7f7f817f, 0x7f81817f, 0x817f817f, 0x7f817f81, 0x7f7f8181,
> > +0x7f818181, 0x7f817f81, 0x81818181, 0x81817f7f, 0x7f81817f, 0x7f81817f,
> > +0x7f7f8181, 0x81818181, 0x817f8181, 0x7f7f817f, 0x7f817f7f, 0x7f7f8181,
> > +0x7f81817f, 0x7f7f817f, 0x7f7f7f7f, 0x7f818181, 0x81817f7f, 0x8181817f,
> > +0x7f81817f, 0x8181817f, 0x81817f81, 0x7f7f7f7f, 0x81818181, 0x7f7f817f,
> > +0x7f81817f, 0x7f7f7f7f, 0x81817f81, 0x817f7f81, 0x817f7f81, 0x817f7f81,
> > +0x81818181, 0x7f7f7f7f, 0x81817f81, 0x817f7f7f, 0x8181817f, 0x7f7f7f81,
> > +0x81817f81, 0x817f7f81, 0x81818181, 0x7f7f7f7f, 0x81817f7f, 0x81817f81,
> > +0x7f7f7f81, 0x7f7f7f7f, 

Re: [dpdk-dev] [PATCH 00/12] ice base code batch 2 for DPDK 21.11

2021-09-17 Thread Zhang, Qi Z



> -Original Message-
> From: Guo, Junfeng 
> Sent: Friday, September 17, 2021 10:14 AM
> To: Zhang, Qi Z ; Yang, Qiming
> 
> Cc: dev@dpdk.org
> Subject: RE: [PATCH 00/12] ice base code batch 2 for DPDK 21.11
> 
> 
> 
> > -Original Message-
> > From: Zhang, Qi Z 
> > Sent: Thursday, September 16, 2021 17:53
> > To: Yang, Qiming 
> > Cc: Guo, Junfeng ; dev@dpdk.org; Zhang, Qi Z
> > 
> > Subject: [PATCH 00/12] ice base code batch 2 for DPDK 21.11
> >
> > Qi Zhang (12):
> >   net/ice/base: calculate logical PF ID
> >   net/ice/base: include more E810T adapters
> >   net/ice/base: use macro instead of open-coded division
> >   net/ice/base: allow to enable LAN and loopback in switch
> >   net/ice/base: change addr param to u16
> >   net/ice/base: allow tool access to MNG register
> >   net/ice/base: add package segment ID
> >   net/ice/base: add a helper to check for 100M speed support
> >   net/ice/base: add GCO defines and new GCO flex descriptor
> >   net/ice/base: add get/set functions for shared parameters
> >   net/ice/base: implement support for SMA controller
> >   net/ice/base: update auto generated hardware register
> >
> >  drivers/net/ice/base/ice_adminq_cmd.h |  10 +
> >  drivers/net/ice/base/ice_common.c | 134 -
> >  drivers/net/ice/base/ice_common.h |   7 +
> >  drivers/net/ice/base/ice_devids.h |   1 +
> >  drivers/net/ice/base/ice_flex_pipe.c  |  11 +-
> >  drivers/net/ice/base/ice_flex_type.h  |   2 +-
> >  drivers/net/ice/base/ice_hw_autogen.h | 148 +++---
> > drivers/net/ice/base/ice_lan_tx_rx.h  |  49 -
> >  drivers/net/ice/base/ice_nvm.c|   7 +-
> >  drivers/net/ice/base/ice_nvm.h|  13 --
> >  drivers/net/ice/base/ice_ptp_hw.c | 270 +++--
> > -
> >  drivers/net/ice/base/ice_ptp_hw.h |  11 ++
> >  drivers/net/ice/base/ice_switch.c |   7 +-
> >  drivers/net/ice/base/ice_switch.h |  11 ++
> >  drivers/net/ice/base/ice_type.h   |   3 +
> >  15 files changed, 569 insertions(+), 115 deletions(-)
> >
> > --
> > 2.26.2
> 
> Acked-by: Junfeng Guo 

Applied to dpdk-next-net-intel.

Thanks
Qi
> 
> Regards,
> Junfeng Guo
> 



Re: [dpdk-dev] [PATCH v2] Enable AddressSanitizer feature on DPDK

2021-09-17 Thread Peng, ZhihongX

> -Original Message-
> From: David Marchand 
> Sent: Friday, September 17, 2021 4:23 PM
> To: Peng, ZhihongX 
> Cc: Burakov, Anatoly ; Ananyev, Konstantin
> ; Stephen Hemminger
> ; dev ; Lin, Xueqin
> 
> Subject: Re: [dpdk-dev] [PATCH v2] Enable AddressSanitizer feature on DPDK
> 
> On Thu, Sep 16, 2021 at 3:47 AM  wrote:
> >
> > From: Zhihong Peng 
> >
> > AddressSanitizer (ASan) is a google memory error detect standard tool.
> > It could help to detect use-after-free and {heap,stack,global}-buffer
> > overflow bugs in C/C++ programs, print detailed error information when
> > error happens, large improve debug efficiency.
> >
> > By referring to its implementation algorithm
> > (https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm),
> > enable heap-buffer-overflow and use-after-free functions on dpdk.
> > DPDK ASAN function currently only supports on Linux x86_64.
> >
> > Here is an example of heap-buffer-overflow bug:
> > ..
> > char *p = rte_zmalloc(NULL, 7, 0);
> > p[7] = 'a';
> > ..
> >
> > Here is an example of use-after-free bug:
> > ..
> > char *p = rte_zmalloc(NULL, 7, 0);
> > rte_free(p);
> > *p = 'a';
> > ..
> >
> 
> Unfortunately, this won't build with some (too smart) compilers.
> Can you look at the CI report?
> Thanks.

I am trying to solve this issue.If there is no good solution, this test case 
will be removed.
Thanks.

> 
> 
> > If you want to use this feature,
> > you need to add below compilation options when compiling code:
> > -Dbuildtype=debug -Db_lundef=false -Db_sanitize=address
> > "-Dbuildtype=debug": Display code information when coredump occurs in
> > the program.
> > "-Db_lundef=false": It is enabled by default, and needs to be disabled
> > when using asan.
> >
> > Signed-off-by: Xueqin Lin 
> > Signed-off-by: Zhihong Peng 
> 
> 
> 
> --
> David Marchand



[dpdk-dev] [PATCH v6 01/10] security: add support for TSO on IPsec session

2021-09-17 Thread Radu Nicolau
Allow user to provision a per security session maximum segment size
(MSS) for use when Transmit Segmentation Offload (TSO) is supported.
The MSS value will be used when PKT_TX_TCP_SEG or PKT_TX_UDP_SEG
ol_flags are specified in mbuf.

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/security/rte_security.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h
index 2e136d7929..495a228915 100644
--- a/lib/security/rte_security.h
+++ b/lib/security/rte_security.h
@@ -181,6 +181,19 @@ struct rte_security_ipsec_sa_options {
 * * 0: Disable per session security statistics collection for this SA.
 */
uint32_t stats : 1;
+
+   /** Transmit Segmentation Offload (TSO)
+*
+* * 1: Enable per session security TSO support, use MSS value provide
+*  in IPsec security session when PKT_TX_TCP_SEG or PKT_TX_UDP_SEG
+*  ol_flags are set in mbuf.
+*  this SA, if supported by the driver.
+* * 0: No TSO support for offload IPsec packets. Hardware will not
+*  attempt to segment packet, and packet transmission will fail if
+*  larger than MTU of interface
+*/
+   uint32_t tso : 1;
+
 };
 
 /** IPSec security association direction */
@@ -217,6 +230,8 @@ struct rte_security_ipsec_xform {
/**< Anti replay window size to enable sequence replay attack handling.
 * replay checking is disabled if the window size is 0.
 */
+   uint32_t mss;
+   /**< IPsec payload Maximum Segment Size */
 };
 
 /**
-- 
2.25.1



[dpdk-dev] [PATCH v6 00/10] new features for ipsec and security libraries

2021-09-17 Thread Radu Nicolau
Add support for:
TSO, NAT-T/UDP encapsulation, ESN
AES_CCM, CHACHA20_POLY1305 and AES_GMAC
SA telemetry
mbuf offload flags
Initial SQN value

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 

Radu Nicolau (10):
  security: add support for TSO on IPsec session
  security: add UDP params for IPsec NAT-T
  security: add ESN field to ipsec_xform
  mbuf: add IPsec ESP tunnel type
  ipsec: add support for AEAD algorithms
  ipsec: add transmit segmentation offload support
  ipsec: add support for NAT-T
  ipsec: add support for SA telemetry
  ipsec: add support for initial SQN value
  ipsec: add ol_flags support

 lib/ipsec/crypto.h  | 137 
 lib/ipsec/esp_inb.c |  88 +++-
 lib/ipsec/esp_outb.c| 262 +++
 lib/ipsec/iph.h |  27 ++-
 lib/ipsec/meson.build   |   2 +-
 lib/ipsec/rte_ipsec.h   |  23 ++
 lib/ipsec/rte_ipsec_sa.h|  11 +-
 lib/ipsec/sa.c  | 406 ++--
 lib/ipsec/sa.h  |  43 
 lib/ipsec/version.map   |   9 +
 lib/mbuf/rte_mbuf_core.h|   1 +
 lib/security/rte_security.h |  31 +++
 12 files changed, 967 insertions(+), 73 deletions(-)

-- 
v2: fixed lib/ipsec/version.map updates to show correct version
v3: fixed build error and corrected misspelled email address
v4: add doxygen comments for the IPsec telemetry APIs
update inline comments refering to the wrong RFC
v5: update commit messages after feedback
update the UDP encapsulation patch to actually use the configured ports
v6: fix initial SQN value

2.25.1



[dpdk-dev] [PATCH v6 02/10] security: add UDP params for IPsec NAT-T

2021-09-17 Thread Radu Nicolau
Add support for specifying UDP port params for UDP encapsulation option.
RFC3948 section-2.1 does not enforce using specific the UDP ports for
UDP-Encapsulated ESP Header

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/security/rte_security.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h
index 495a228915..84ba1b08f8 100644
--- a/lib/security/rte_security.h
+++ b/lib/security/rte_security.h
@@ -112,6 +112,12 @@ struct rte_security_ipsec_tunnel_param {
};
 };
 
+struct rte_security_ipsec_udp_param {
+
+   uint16_t sport;
+   uint16_t dport;
+};
+
 /**
  * IPsec Security Association option flags
  */
@@ -224,6 +230,8 @@ struct rte_security_ipsec_xform {
/**< IPsec SA Mode - transport/tunnel */
struct rte_security_ipsec_tunnel_param tunnel;
/**< Tunnel parameters, NULL for transport mode */
+   struct rte_security_ipsec_udp_param udp;
+   /**< UDP parameters, ignored when udp_encap option not specified */
uint64_t esn_soft_limit;
/**< ESN for which the overflow event need to be raised */
uint32_t replay_win_sz;
-- 
2.25.1



[dpdk-dev] [PATCH v6 03/10] security: add ESN field to ipsec_xform

2021-09-17 Thread Radu Nicolau
Update ipsec_xform definition to include ESN field.
This allows the application to control the ESN starting value.

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
Acked-by: Anoob Joseph 
---
 lib/security/rte_security.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/security/rte_security.h b/lib/security/rte_security.h
index 84ba1b08f8..1bd09e3cc2 100644
--- a/lib/security/rte_security.h
+++ b/lib/security/rte_security.h
@@ -240,6 +240,14 @@ struct rte_security_ipsec_xform {
 */
uint32_t mss;
/**< IPsec payload Maximum Segment Size */
+   union {
+   uint64_t value;
+   struct {
+   uint32_t low;
+   uint32_t hi;
+   };
+   } esn;
+   /**< Extended Sequence Number */
 };
 
 /**
-- 
2.25.1



[dpdk-dev] [PATCH v6 04/10] mbuf: add IPsec ESP tunnel type

2021-09-17 Thread Radu Nicolau
Add tunnel type for IPsec ESP tunnels

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
Acked-by: Akhil Goyal 
Acked-by: Olivier Matz 
---
 lib/mbuf/rte_mbuf_core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index bb38d7f581..a4d95deee6 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -253,6 +253,7 @@ extern "C" {
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
 #define PKT_TX_TUNNEL_VXLAN_GPE (0x6ULL << 45)
 #define PKT_TX_TUNNEL_GTP   (0x7ULL << 45)
+#define PKT_TX_TUNNEL_ESP   (0x8ULL << 45)
 /**
  * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
  * It can be used for tunnels which are not standards or listed above.
-- 
2.25.1



[dpdk-dev] [PATCH v6 05/10] ipsec: add support for AEAD algorithms

2021-09-17 Thread Radu Nicolau
Add support for AES_CCM, CHACHA20_POLY1305 and AES_GMAC.

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/ipsec/crypto.h   | 137 +++
 lib/ipsec/esp_inb.c  |  66 -
 lib/ipsec/esp_outb.c |  70 +-
 lib/ipsec/sa.c   |  54 +++--
 lib/ipsec/sa.h   |   6 ++
 5 files changed, 322 insertions(+), 11 deletions(-)

diff --git a/lib/ipsec/crypto.h b/lib/ipsec/crypto.h
index 3d03034590..93d200 100644
--- a/lib/ipsec/crypto.h
+++ b/lib/ipsec/crypto.h
@@ -21,6 +21,37 @@ struct aesctr_cnt_blk {
uint32_t cnt;
 } __rte_packed;
 
+ /*
+  * CHACHA20-POLY1305 devices have some specific requirements
+  * for IV and AAD formats.
+  * Ideally that to be done by the driver itself.
+  */
+
+struct aead_chacha20_poly1305_iv {
+   uint32_t salt;
+   uint64_t iv;
+   uint32_t cnt;
+} __rte_packed;
+
+struct aead_chacha20_poly1305_aad {
+   uint32_t spi;
+   /*
+* RFC 4106, section 5:
+* Two formats of the AAD are defined:
+* one for 32-bit sequence numbers, and one for 64-bit ESN.
+*/
+   union {
+   uint32_t u32[2];
+   uint64_t u64;
+   } sqn;
+   uint32_t align0; /* align to 16B boundary */
+} __rte_packed;
+
+struct chacha20_poly1305_esph_iv {
+   struct rte_esp_hdr esph;
+   uint64_t iv;
+} __rte_packed;
+
  /*
   * AES-GCM devices have some specific requirements for IV and AAD formats.
   * Ideally that to be done by the driver itself.
@@ -51,6 +82,47 @@ struct gcm_esph_iv {
uint64_t iv;
 } __rte_packed;
 
+ /*
+  * AES-CCM devices have some specific requirements for IV and AAD formats.
+  * Ideally that to be done by the driver itself.
+  */
+union aead_ccm_salt {
+   uint32_t salt;
+   struct inner {
+   uint8_t salt8[3];
+   uint8_t ccm_flags;
+   } inner;
+} __rte_packed;
+
+
+struct aead_ccm_iv {
+   uint8_t ccm_flags;
+   uint8_t salt[3];
+   uint64_t iv;
+   uint32_t cnt;
+} __rte_packed;
+
+struct aead_ccm_aad {
+   uint8_t padding[18];
+   uint32_t spi;
+   /*
+* RFC 4309, section 5:
+* Two formats of the AAD are defined:
+* one for 32-bit sequence numbers, and one for 64-bit ESN.
+*/
+   union {
+   uint32_t u32[2];
+   uint64_t u64;
+   } sqn;
+   uint32_t align0; /* align to 16B boundary */
+} __rte_packed;
+
+struct ccm_esph_iv {
+   struct rte_esp_hdr esph;
+   uint64_t iv;
+} __rte_packed;
+
+
 static inline void
 aes_ctr_cnt_blk_fill(struct aesctr_cnt_blk *ctr, uint64_t iv, uint32_t nonce)
 {
@@ -59,6 +131,16 @@ aes_ctr_cnt_blk_fill(struct aesctr_cnt_blk *ctr, uint64_t 
iv, uint32_t nonce)
ctr->cnt = rte_cpu_to_be_32(1);
 }
 
+static inline void
+aead_chacha20_poly1305_iv_fill(struct aead_chacha20_poly1305_iv
+  *chacha20_poly1305,
+  uint64_t iv, uint32_t salt)
+{
+   chacha20_poly1305->salt = salt;
+   chacha20_poly1305->iv = iv;
+   chacha20_poly1305->cnt = rte_cpu_to_be_32(1);
+}
+
 static inline void
 aead_gcm_iv_fill(struct aead_gcm_iv *gcm, uint64_t iv, uint32_t salt)
 {
@@ -67,6 +149,21 @@ aead_gcm_iv_fill(struct aead_gcm_iv *gcm, uint64_t iv, 
uint32_t salt)
gcm->cnt = rte_cpu_to_be_32(1);
 }
 
+static inline void
+aead_ccm_iv_fill(struct aead_ccm_iv *ccm, uint64_t iv, uint32_t salt)
+{
+   union aead_ccm_salt tsalt;
+
+   tsalt.salt = salt;
+   ccm->ccm_flags = tsalt.inner.ccm_flags;
+   ccm->salt[0] = tsalt.inner.salt8[0];
+   ccm->salt[1] = tsalt.inner.salt8[1];
+   ccm->salt[2] = tsalt.inner.salt8[2];
+   ccm->iv = iv;
+   ccm->cnt = rte_cpu_to_be_32(1);
+}
+
+
 /*
  * RFC 4106, 5 AAD Construction
  * spi and sqn should already be converted into network byte order.
@@ -86,6 +183,25 @@ aead_gcm_aad_fill(struct aead_gcm_aad *aad, rte_be32_t spi, 
rte_be64_t sqn,
aad->align0 = 0;
 }
 
+/*
+ * RFC 4309, 5 AAD Construction
+ * spi and sqn should already be converted into network byte order.
+ * Make sure that not used bytes are zeroed.
+ */
+static inline void
+aead_ccm_aad_fill(struct aead_ccm_aad *aad, rte_be32_t spi, rte_be64_t sqn,
+   int esn)
+{
+   aad->spi = spi;
+   if (esn)
+   aad->sqn.u64 = sqn;
+   else {
+   aad->sqn.u32[0] = sqn_low32(sqn);
+   aad->sqn.u32[1] = 0;
+   }
+   aad->align0 = 0;
+}
+
 static inline void
 gen_iv(uint64_t iv[IPSEC_MAX_IV_QWORD], rte_be64_t sqn)
 {
@@ -93,6 +209,27 @@ gen_iv(uint64_t iv[IPSEC_MAX_IV_QWORD], rte_be64_t sqn)
iv[1] = 0;
 }
 
+
+/*
+ * RFC 7634, 2.1 AAD Construction
+ * spi and sqn should already be converted into network byte order.
+ * Make sure that not used bytes are zeroed.
+ */
+static inline void
+ae

[dpdk-dev] [PATCH v6 06/10] ipsec: add transmit segmentation offload support

2021-09-17 Thread Radu Nicolau
Add support for transmit segmentation offload to inline crypto processing
mode. This offload is not supported by other offload modes, as at a
minimum it requires inline crypto for IPsec to be supported on the
network interface.

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/ipsec/esp_inb.c  |   4 +-
 lib/ipsec/esp_outb.c | 115 +++
 lib/ipsec/iph.h  |  10 +++-
 lib/ipsec/sa.c   |   6 +++
 lib/ipsec/sa.h   |   4 ++
 5 files changed, 114 insertions(+), 25 deletions(-)

diff --git a/lib/ipsec/esp_inb.c b/lib/ipsec/esp_inb.c
index d66c88f05d..a6ab8fbdd5 100644
--- a/lib/ipsec/esp_inb.c
+++ b/lib/ipsec/esp_inb.c
@@ -668,8 +668,8 @@ trs_process(const struct rte_ipsec_sa *sa, struct rte_mbuf 
*mb[],
/* modify packet's layout */
np = trs_process_step2(mb[i], ml[i], hl[i], cofs,
to[i], tl, sqn + k);
-   update_trs_l3hdr(sa, np + l2, mb[i]->pkt_len,
-   l2, hl[i] - l2, espt[i].next_proto);
+   update_trs_l34hdrs(sa, np + l2, mb[i]->pkt_len,
+   l2, hl[i] - l2, espt[i].next_proto, 0);
 
/* update mbuf's metadata */
trs_process_step3(mb[i]);
diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
index a3f77469c3..9fc7075796 100644
--- a/lib/ipsec/esp_outb.c
+++ b/lib/ipsec/esp_outb.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2018-2020 Intel Corporation
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -156,11 +158,20 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t 
sqc,
 
/* number of bytes to encrypt */
clen = plen + sizeof(*espt);
-   clen = RTE_ALIGN_CEIL(clen, sa->pad_align);
+
+   /* We don't need to pad/ailgn packet when using TSO offload */
+   if (likely(!(mb->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG
+   clen = RTE_ALIGN_CEIL(clen, sa->pad_align);
+
 
/* pad length + esp tail */
pdlen = clen - plen;
-   tlen = pdlen + sa->icv_len + sqh_len;
+
+   /* We don't append ICV length when using TSO offload */
+   if (likely(!(mb->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG
+   tlen = pdlen + sa->icv_len + sqh_len;
+   else
+   tlen = pdlen + sqh_len;
 
/* do append and prepend */
ml = rte_pktmbuf_lastseg(mb);
@@ -337,6 +348,7 @@ outb_trs_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t 
sqc,
char *ph, *pt;
uint64_t *iv;
uint32_t l2len, l3len;
+   uint8_t tso = mb->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG) ? 1 : 0;
 
l2len = mb->l2_len;
l3len = mb->l3_len;
@@ -349,11 +361,19 @@ outb_trs_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t 
sqc,
 
/* number of bytes to encrypt */
clen = plen + sizeof(*espt);
-   clen = RTE_ALIGN_CEIL(clen, sa->pad_align);
+
+   /* We don't need to pad/ailgn packet when using TSO offload */
+   if (likely(!tso))
+   clen = RTE_ALIGN_CEIL(clen, sa->pad_align);
 
/* pad length + esp tail */
pdlen = clen - plen;
-   tlen = pdlen + sa->icv_len + sqh_len;
+
+   /* We don't append ICV length when using TSO offload */
+   if (likely(!tso))
+   tlen = pdlen + sa->icv_len + sqh_len;
+   else
+   tlen = pdlen + sqh_len;
 
/* do append and insert */
ml = rte_pktmbuf_lastseg(mb);
@@ -375,8 +395,8 @@ outb_trs_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t 
sqc,
insert_esph(ph, ph + hlen, uhlen);
 
/* update ip  header fields */
-   np = update_trs_l3hdr(sa, ph + l2len, mb->pkt_len - sqh_len, l2len,
-   l3len, IPPROTO_ESP);
+   np = update_trs_l34hdrs(sa, ph + l2len, mb->pkt_len - sqh_len, l2len,
+   l3len, IPPROTO_ESP, tso);
 
/* update spi, seqn and iv */
esph = (struct rte_esp_hdr *)(ph + uhlen);
@@ -651,6 +671,33 @@ inline_outb_mbuf_prepare(const struct rte_ipsec_session 
*ss,
}
 }
 
+/* check if packet will exceed MSS and segmentation is required */
+static inline int
+esn_outb_nb_segments(const struct rte_ipsec_sa *sa, struct rte_mbuf *m) {
+   uint16_t segments = 1;
+   uint16_t pkt_l3len = m->pkt_len - m->l2_len;
+
+   /* Only support segmentation for UDP/TCP flows */
+   if (!(m->packet_type & (RTE_PTYPE_L4_UDP | RTE_PTYPE_L4_TCP)))
+   return segments;
+
+   if (sa->tso.enabled && pkt_l3len > sa->tso.mss) {
+   segments = ceil((float)pkt_l3len / sa->tso.mss);
+
+   if  (m->packet_type & RTE_PTYPE_L4_TCP) {
+   m->ol_flags |= (PKT_TX_TCP_SEG | PKT_TX_TCP_CKSUM);
+   m->l4_len = sizeof(struct rte_tcp_hdr);
+   } else {
+   

[dpdk-dev] [PATCH v6 07/10] ipsec: add support for NAT-T

2021-09-17 Thread Radu Nicolau
Add support for the IPsec NAT-Traversal use case for Tunnel mode
packets.

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/ipsec/iph.h  | 17 +
 lib/ipsec/rte_ipsec_sa.h |  8 +++-
 lib/ipsec/sa.c   | 13 -
 lib/ipsec/sa.h   |  4 
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/lib/ipsec/iph.h b/lib/ipsec/iph.h
index 2d223199ac..c5c213a2b4 100644
--- a/lib/ipsec/iph.h
+++ b/lib/ipsec/iph.h
@@ -251,6 +251,7 @@ update_tun_outb_l3hdr(const struct rte_ipsec_sa *sa, void 
*outh,
 {
struct rte_ipv4_hdr *v4h;
struct rte_ipv6_hdr *v6h;
+   struct rte_udp_hdr *udph;
uint8_t is_outh_ipv4;
 
if (sa->type & RTE_IPSEC_SATP_MODE_TUNLV4) {
@@ -258,11 +259,27 @@ update_tun_outb_l3hdr(const struct rte_ipsec_sa *sa, void 
*outh,
v4h = outh;
v4h->packet_id = pid;
v4h->total_length = rte_cpu_to_be_16(plen - l2len);
+
+   if (sa->type & RTE_IPSEC_SATP_NATT_ENABLE) {
+   udph = (struct rte_udp_hdr *)(v4h + 1);
+   udph->dst_port = sa->natt.dport;
+   udph->src_port = sa->natt.sport;
+   udph->dgram_len = rte_cpu_to_be_16(plen - l2len -
+   (sizeof(*v4h) + sizeof(*udph)));
+   }
} else {
is_outh_ipv4 = 0;
v6h = outh;
v6h->payload_len = rte_cpu_to_be_16(plen - l2len -
sizeof(*v6h));
+
+   if (sa->type & RTE_IPSEC_SATP_NATT_ENABLE) {
+   udph = (struct rte_udp_hdr *)(v6h + 1);
+   udph->dst_port = sa->natt.dport;
+   udph->src_port = sa->natt.sport;
+   udph->dgram_len = rte_cpu_to_be_16(plen - l2len -
+   (sizeof(*v6h) + sizeof(*udph)));
+   }
}
 
if (sa->type & TUN_HDR_MSK)
diff --git a/lib/ipsec/rte_ipsec_sa.h b/lib/ipsec/rte_ipsec_sa.h
index cf51ad8338..40d1e70d45 100644
--- a/lib/ipsec/rte_ipsec_sa.h
+++ b/lib/ipsec/rte_ipsec_sa.h
@@ -76,6 +76,7 @@ struct rte_ipsec_sa_prm {
  * - inbound/outbound
  * - mode (TRANSPORT/TUNNEL)
  * - for TUNNEL outer IP version (IPv4/IPv6)
+ * - NAT-T UDP encapsulated (TUNNEL mode only)
  * - are SA SQN operations 'atomic'
  * - ESN enabled/disabled
  * ...
@@ -86,7 +87,8 @@ enum {
RTE_SATP_LOG2_PROTO,
RTE_SATP_LOG2_DIR,
RTE_SATP_LOG2_MODE,
-   RTE_SATP_LOG2_SQN = RTE_SATP_LOG2_MODE + 2,
+   RTE_SATP_LOG2_NATT = RTE_SATP_LOG2_MODE + 2,
+   RTE_SATP_LOG2_SQN,
RTE_SATP_LOG2_ESN,
RTE_SATP_LOG2_ECN,
RTE_SATP_LOG2_DSCP
@@ -109,6 +111,10 @@ enum {
 #define RTE_IPSEC_SATP_MODE_TUNLV4 (1ULL << RTE_SATP_LOG2_MODE)
 #define RTE_IPSEC_SATP_MODE_TUNLV6 (2ULL << RTE_SATP_LOG2_MODE)
 
+#define RTE_IPSEC_SATP_NATT_MASK   (1ULL << RTE_SATP_LOG2_NATT)
+#define RTE_IPSEC_SATP_NATT_DISABLE(0ULL << RTE_SATP_LOG2_NATT)
+#define RTE_IPSEC_SATP_NATT_ENABLE (1ULL << RTE_SATP_LOG2_NATT)
+
 #define RTE_IPSEC_SATP_SQN_MASK(1ULL << RTE_SATP_LOG2_SQN)
 #define RTE_IPSEC_SATP_SQN_RAW (0ULL << RTE_SATP_LOG2_SQN)
 #define RTE_IPSEC_SATP_SQN_ATOM(1ULL << RTE_SATP_LOG2_SQN)
diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c
index 2ecbbce0a4..8e369e4618 100644
--- a/lib/ipsec/sa.c
+++ b/lib/ipsec/sa.c
@@ -217,6 +217,10 @@ fill_sa_type(const struct rte_ipsec_sa_prm *prm, uint64_t 
*type)
} else
return -EINVAL;
 
+   /* check for UDP encapsulation flag */
+   if (prm->ipsec_xform.options.udp_encap == 1)
+   tp |= RTE_IPSEC_SATP_NATT_ENABLE;
+
/* check for ESN flag */
if (prm->ipsec_xform.options.esn == 0)
tp |= RTE_IPSEC_SATP_ESN_DISABLE;
@@ -372,7 +376,8 @@ esp_sa_init(struct rte_ipsec_sa *sa, const struct 
rte_ipsec_sa_prm *prm,
const struct crypto_xform *cxf)
 {
static const uint64_t msk = RTE_IPSEC_SATP_DIR_MASK |
-   RTE_IPSEC_SATP_MODE_MASK;
+   RTE_IPSEC_SATP_MODE_MASK |
+   RTE_IPSEC_SATP_NATT_MASK;
 
if (prm->ipsec_xform.options.ecn)
sa->tos_mask |= RTE_IPV4_HDR_ECN_MASK;
@@ -475,10 +480,16 @@ esp_sa_init(struct rte_ipsec_sa *sa, const struct 
rte_ipsec_sa_prm *prm,
case (RTE_IPSEC_SATP_DIR_IB | RTE_IPSEC_SATP_MODE_TRANS):
esp_inb_init(sa);
break;
+   case (RTE_IPSEC_SATP_DIR_OB | RTE_IPSEC_SATP_MODE_TUNLV4 |
+   RTE_IPSEC_SATP_NATT_ENABLE):
+   case (RTE_IPSEC_SATP_DIR_OB | RTE_IPSEC_SATP_MODE_TUNLV6 |
+   RTE_IPSEC_SATP_NATT_ENABLE):
case (RTE_IPSEC_SATP_DIR_OB | RTE_IPSEC_SATP_MODE_TUNLV4):
  

[dpdk-dev] [PATCH v6 08/10] ipsec: add support for SA telemetry

2021-09-17 Thread Radu Nicolau
Add telemetry support for ipsec SAs

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/ipsec/esp_inb.c   |   1 +
 lib/ipsec/esp_outb.c  |  12 +-
 lib/ipsec/meson.build |   2 +-
 lib/ipsec/rte_ipsec.h |  23 
 lib/ipsec/sa.c| 255 +-
 lib/ipsec/sa.h|  21 
 lib/ipsec/version.map |   9 ++
 7 files changed, 317 insertions(+), 6 deletions(-)

diff --git a/lib/ipsec/esp_inb.c b/lib/ipsec/esp_inb.c
index a6ab8fbdd5..8cb4c16302 100644
--- a/lib/ipsec/esp_inb.c
+++ b/lib/ipsec/esp_inb.c
@@ -722,6 +722,7 @@ esp_inb_pkt_process(struct rte_ipsec_sa *sa, struct 
rte_mbuf *mb[],
 
/* process packets, extract seq numbers */
k = process(sa, mb, sqn, dr, num, sqh_len);
+   sa->statistics.count += k;
 
/* handle unprocessed mbufs */
if (k != num && k != 0)
diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
index 9fc7075796..2c02c3bb12 100644
--- a/lib/ipsec/esp_outb.c
+++ b/lib/ipsec/esp_outb.c
@@ -617,7 +617,7 @@ uint16_t
 esp_outb_sqh_process(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
uint16_t num)
 {
-   uint32_t i, k, icv_len, *icv;
+   uint32_t i, k, icv_len, *icv, bytes;
struct rte_mbuf *ml;
struct rte_ipsec_sa *sa;
uint32_t dr[num];
@@ -626,10 +626,12 @@ esp_outb_sqh_process(const struct rte_ipsec_session *ss, 
struct rte_mbuf *mb[],
 
k = 0;
icv_len = sa->icv_len;
+   bytes = 0;
 
for (i = 0; i != num; i++) {
if ((mb[i]->ol_flags & PKT_RX_SEC_OFFLOAD_FAILED) == 0) {
ml = rte_pktmbuf_lastseg(mb[i]);
+   bytes += mb[i]->data_len;
/* remove high-order 32 bits of esn from packet len */
mb[i]->pkt_len -= sa->sqh_len;
ml->data_len -= sa->sqh_len;
@@ -640,6 +642,8 @@ esp_outb_sqh_process(const struct rte_ipsec_session *ss, 
struct rte_mbuf *mb[],
} else
dr[i - k] = i;
}
+   sa->statistics.count += k;
+   sa->statistics.bytes += bytes - (sa->hdr_len * k);
 
/* handle unprocessed mbufs */
if (k != num) {
@@ -659,16 +663,19 @@ static inline void
 inline_outb_mbuf_prepare(const struct rte_ipsec_session *ss,
struct rte_mbuf *mb[], uint16_t num)
 {
-   uint32_t i, ol_flags;
+   uint32_t i, ol_flags, bytes = 0;
 
ol_flags = ss->security.ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA;
for (i = 0; i != num; i++) {
 
mb[i]->ol_flags |= PKT_TX_SEC_OFFLOAD;
+   bytes += mb[i]->data_len;
if (ol_flags != 0)
rte_security_set_pkt_metadata(ss->security.ctx,
ss->security.ses, mb[i], NULL);
}
+   ss->sa->statistics.count += num;
+   ss->sa->statistics.bytes += bytes - (ss->sa->hdr_len * num);
 }
 
 /* check if packet will exceed MSS and segmentation is required */
@@ -752,6 +759,7 @@ inline_outb_tun_pkt_process(const struct rte_ipsec_session 
*ss,
sqn += nb_segs[i] - 1;
}
 
+
/* copy not processed mbufs beyond good ones */
if (k != num && k != 0)
move_bad_mbufs(mb, dr, num, num - k);
diff --git a/lib/ipsec/meson.build b/lib/ipsec/meson.build
index 1497f573bb..f5e44cfe47 100644
--- a/lib/ipsec/meson.build
+++ b/lib/ipsec/meson.build
@@ -6,4 +6,4 @@ sources = files('esp_inb.c', 'esp_outb.c', 'sa.c', 'ses.c', 
'ipsec_sad.c')
 headers = files('rte_ipsec.h', 'rte_ipsec_sa.h', 'rte_ipsec_sad.h')
 indirect_headers += files('rte_ipsec_group.h')
 
-deps += ['mbuf', 'net', 'cryptodev', 'security', 'hash']
+deps += ['mbuf', 'net', 'cryptodev', 'security', 'hash', 'telemetry']
diff --git a/lib/ipsec/rte_ipsec.h b/lib/ipsec/rte_ipsec.h
index dd60d95915..2bb52f4b8f 100644
--- a/lib/ipsec/rte_ipsec.h
+++ b/lib/ipsec/rte_ipsec.h
@@ -158,6 +158,29 @@ rte_ipsec_pkt_process(const struct rte_ipsec_session *ss, 
struct rte_mbuf *mb[],
return ss->pkt_func.process(ss, mb, num);
 }
 
+
+struct rte_ipsec_telemetry;
+
+/**
+ * Initialize IPsec library telemetry.
+ * @return
+ *   0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_ipsec_telemetry_init(void);
+
+/**
+ * Enable per SA telemetry for a specific SA.
+ * @param sa
+ *   Pointer to the *rte_ipsec_sa* object that will have telemetry enabled.
+ * @return
+ *   0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_ipsec_telemetry_sa_add(struct rte_ipsec_sa *sa);
+
 #include 
 
 #ifdef __cplusplus
diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c
index 8e369e4618..5b55bbc098 100644
--- a/lib/ipsec/sa.c
+++ b/lib/ipsec/sa.c
@@ -7,7 +7,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include "sa.h"
 #include "ipsec_sqn.h"
 #include "crypto.h"
@@ -25,6 +25,7 @@ struct 

[dpdk-dev] [PATCH v6 09/10] ipsec: add support for initial SQN value

2021-09-17 Thread Radu Nicolau
Update IPsec library to support initial SQN value.

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
Acked-by: Fan Zhang 
---
 lib/ipsec/esp_outb.c | 19 ---
 lib/ipsec/sa.c   | 29 ++---
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
index 2c02c3bb12..8a6d09558f 100644
--- a/lib/ipsec/esp_outb.c
+++ b/lib/ipsec/esp_outb.c
@@ -661,7 +661,7 @@ esp_outb_sqh_process(const struct rte_ipsec_session *ss, 
struct rte_mbuf *mb[],
  */
 static inline void
 inline_outb_mbuf_prepare(const struct rte_ipsec_session *ss,
-   struct rte_mbuf *mb[], uint16_t num)
+   struct rte_mbuf *mb[], uint16_t num, uint64_t *sqn)
 {
uint32_t i, ol_flags, bytes = 0;
 
@@ -672,7 +672,7 @@ inline_outb_mbuf_prepare(const struct rte_ipsec_session *ss,
bytes += mb[i]->data_len;
if (ol_flags != 0)
rte_security_set_pkt_metadata(ss->security.ctx,
-   ss->security.ses, mb[i], NULL);
+   ss->security.ses, mb[i], sqn);
}
ss->sa->statistics.count += num;
ss->sa->statistics.bytes += bytes - (ss->sa->hdr_len * num);
@@ -764,7 +764,10 @@ inline_outb_tun_pkt_process(const struct rte_ipsec_session 
*ss,
if (k != num && k != 0)
move_bad_mbufs(mb, dr, num, num - k);
 
-   inline_outb_mbuf_prepare(ss, mb, k);
+   if (sa->sqn_mask > UINT32_MAX)
+   inline_outb_mbuf_prepare(ss, mb, k, &sqn);
+   else
+   inline_outb_mbuf_prepare(ss, mb, k, NULL);
return k;
 }
 
@@ -799,8 +802,7 @@ inline_outb_trs_pkt_process(const struct rte_ipsec_session 
*ss,
if (nb_sqn_alloc != nb_sqn)
rte_errno = EOVERFLOW;
 
-   k = 0;
-   for (i = 0; i != num; i++) {
+   for (i = 0, k = 0; i != num; i++) {
 
sqc = rte_cpu_to_be_64(sqn + i);
gen_iv(iv, sqc);
@@ -828,7 +830,10 @@ inline_outb_trs_pkt_process(const struct rte_ipsec_session 
*ss,
if (k != num && k != 0)
move_bad_mbufs(mb, dr, num, num - k);
 
-   inline_outb_mbuf_prepare(ss, mb, k);
+   if (sa->sqn_mask > UINT32_MAX)
+   inline_outb_mbuf_prepare(ss, mb, k, &sqn);
+   else
+   inline_outb_mbuf_prepare(ss, mb, k, NULL);
return k;
 }
 
@@ -840,6 +845,6 @@ uint16_t
 inline_proto_outb_pkt_process(const struct rte_ipsec_session *ss,
struct rte_mbuf *mb[], uint16_t num)
 {
-   inline_outb_mbuf_prepare(ss, mb, num);
+   inline_outb_mbuf_prepare(ss, mb, num, NULL);
return num;
 }
diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c
index 5b55bbc098..d94684cf96 100644
--- a/lib/ipsec/sa.c
+++ b/lib/ipsec/sa.c
@@ -294,11 +294,11 @@ esp_inb_tun_init(struct rte_ipsec_sa *sa, const struct 
rte_ipsec_sa_prm *prm)
  * Init ESP outbound specific things.
  */
 static void
-esp_outb_init(struct rte_ipsec_sa *sa, uint32_t hlen)
+esp_outb_init(struct rte_ipsec_sa *sa, uint32_t hlen, uint64_t sqn)
 {
uint8_t algo_type;
 
-   sa->sqn.outb = 1;
+   sa->sqn.outb = sqn;
 
algo_type = sa->algo_type;
 
@@ -356,6 +356,8 @@ esp_outb_init(struct rte_ipsec_sa *sa, uint32_t hlen)
 static void
 esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct rte_ipsec_sa_prm *prm)
 {
+   uint64_t sqn = prm->ipsec_xform.esn.value > 0 ?
+   prm->ipsec_xform.esn.value : 1;
sa->proto = prm->tun.next_proto;
sa->hdr_len = prm->tun.hdr_len;
sa->hdr_l3_off = prm->tun.hdr_l3_off;
@@ -366,7 +368,7 @@ esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct 
rte_ipsec_sa_prm *prm)
 
memcpy(sa->hdr, prm->tun.hdr, sa->hdr_len);
 
-   esp_outb_init(sa, sa->hdr_len);
+   esp_outb_init(sa, sa->hdr_len, sqn);
 }
 
 /*
@@ -376,6 +378,8 @@ static int
 esp_sa_init(struct rte_ipsec_sa *sa, const struct rte_ipsec_sa_prm *prm,
const struct crypto_xform *cxf)
 {
+   uint64_t sqn = prm->ipsec_xform.esn.value > 0 ?
+   prm->ipsec_xform.esn.value : 1;
static const uint64_t msk = RTE_IPSEC_SATP_DIR_MASK |
RTE_IPSEC_SATP_MODE_MASK |
RTE_IPSEC_SATP_NATT_MASK;
@@ -492,7 +496,7 @@ esp_sa_init(struct rte_ipsec_sa *sa, const struct 
rte_ipsec_sa_prm *prm,
case (RTE_IPSEC_SATP_DIR_OB | RTE_IPSEC_SATP_MODE_TRANS |
RTE_IPSEC_SATP_NATT_ENABLE):
case (RTE_IPSEC_SATP_DIR_OB | RTE_IPSEC_SATP_MODE_TRANS):
-   esp_outb_init(sa, 0);
+   esp_outb_init(sa, 0, sqn);
break;
}
 
@@ -503,15 +507,19 @@ esp_sa_init(struct rte_ipsec_sa *sa, const struct 
rte_ipsec_sa_prm *prm,
  * helper function, init SA replay structure.
  */
 static void
-fill_sa_replay(struct rte_ipsec_sa *sa, uint32_t wnd_sz,

[dpdk-dev] [PATCH v6 10/10] ipsec: add ol_flags support

2021-09-17 Thread Radu Nicolau
Update the IPsec library to set mbuff->ol_flags and use the configured
L3 header length when setting the mbuff->tx_offload fields

Signed-off-by: Declan Doherty 
Signed-off-by: Radu Nicolau 
Signed-off-by: Abhijit Sinha 
Signed-off-by: Daniel Martin Buckley 
---
 lib/ipsec/esp_inb.c  | 17 --
 lib/ipsec/esp_outb.c | 48 ++-
 lib/ipsec/rte_ipsec_sa.h |  3 ++-
 lib/ipsec/sa.c   | 49 ++--
 lib/ipsec/sa.h   |  8 +++
 5 files changed, 109 insertions(+), 16 deletions(-)

diff --git a/lib/ipsec/esp_inb.c b/lib/ipsec/esp_inb.c
index 8cb4c16302..5fcb41297e 100644
--- a/lib/ipsec/esp_inb.c
+++ b/lib/ipsec/esp_inb.c
@@ -559,7 +559,8 @@ trs_process_step3(struct rte_mbuf *mb)
  * - tx_offload
  */
 static inline void
-tun_process_step3(struct rte_mbuf *mb, uint64_t txof_msk, uint64_t txof_val)
+tun_process_step3(struct rte_mbuf *mb, uint8_t is_ipv4, uint64_t txof_msk,
+   uint64_t txof_val)
 {
/* reset mbuf metatdata: L2/L3 len, packet type */
mb->packet_type = RTE_PTYPE_UNKNOWN;
@@ -567,6 +568,14 @@ tun_process_step3(struct rte_mbuf *mb, uint64_t txof_msk, 
uint64_t txof_val)
 
/* clear the PKT_RX_SEC_OFFLOAD flag if set */
mb->ol_flags &= ~PKT_RX_SEC_OFFLOAD;
+
+   if (is_ipv4) {
+   mb->l3_len = sizeof(struct rte_ipv4_hdr);
+   mb->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+   } else {
+   mb->l3_len = sizeof(struct rte_ipv6_hdr);
+   mb->ol_flags |= PKT_TX_IPV6;
+   }
 }
 
 /*
@@ -618,8 +627,12 @@ tun_process(const struct rte_ipsec_sa *sa, struct rte_mbuf 
*mb[],
update_tun_inb_l3hdr(sa, outh, inh);
 
/* update mbuf's metadata */
-   tun_process_step3(mb[i], sa->tx_offload.msk,
+   tun_process_step3(mb[i],
+   (sa->type & RTE_IPSEC_SATP_IPV_MASK) ==
+   RTE_IPSEC_SATP_IPV4 ? 1 : 0,
+   sa->tx_offload.msk,
sa->tx_offload.val);
+
k++;
} else
dr[i - k] = i;
diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
index 8a6d09558f..d8e261e6fb 100644
--- a/lib/ipsec/esp_outb.c
+++ b/lib/ipsec/esp_outb.c
@@ -19,7 +19,7 @@
 
 typedef int32_t (*esp_outb_prepare_t)(struct rte_ipsec_sa *sa, rte_be64_t sqc,
const uint64_t ivp[IPSEC_MAX_IV_QWORD], struct rte_mbuf *mb,
-   union sym_op_data *icv, uint8_t sqh_len);
+   union sym_op_data *icv, uint8_t sqh_len, uint8_t icrypto);
 
 /*
  * helper function to fill crypto_sym op for cipher+auth algorithms.
@@ -140,9 +140,9 @@ outb_cop_prepare(struct rte_crypto_op *cop,
 static inline int32_t
 outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t sqc,
const uint64_t ivp[IPSEC_MAX_IV_QWORD], struct rte_mbuf *mb,
-   union sym_op_data *icv, uint8_t sqh_len)
+   union sym_op_data *icv, uint8_t sqh_len, uint8_t icrypto)
 {
-   uint32_t clen, hlen, l2len, pdlen, pdofs, plen, tlen;
+   uint32_t clen, hlen, l2len, l3len, pdlen, pdofs, plen, tlen;
struct rte_mbuf *ml;
struct rte_esp_hdr *esph;
struct rte_esp_tail *espt;
@@ -154,6 +154,8 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t 
sqc,
 
/* size of ipsec protected data */
l2len = mb->l2_len;
+   l3len = mb->l3_len;
+
plen = mb->pkt_len - l2len;
 
/* number of bytes to encrypt */
@@ -190,8 +192,26 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa, rte_be64_t 
sqc,
pt = rte_pktmbuf_mtod_offset(ml, typeof(pt), pdofs);
 
/* update pkt l2/l3 len */
-   mb->tx_offload = (mb->tx_offload & sa->tx_offload.msk) |
-   sa->tx_offload.val;
+   if (icrypto) {
+   mb->tx_offload =
+   (mb->tx_offload & sa->inline_crypto.tx_offload.msk) |
+   sa->inline_crypto.tx_offload.val;
+   mb->l3_len = l3len;
+
+   mb->ol_flags |= sa->inline_crypto.tx_ol_flags;
+
+   /* set ip checksum offload for inner */
+   if ((sa->type & RTE_IPSEC_SATP_IPV_MASK) == RTE_IPSEC_SATP_IPV4)
+   mb->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+   else if ((sa->type & RTE_IPSEC_SATP_IPV_MASK)
+   == RTE_IPSEC_SATP_IPV6)
+   mb->ol_flags |= PKT_TX_IPV6;
+   } else {
+   mb->tx_offload = (mb->tx_offload & sa->tx_offload.msk) |
+   sa->tx_offload.val;
+
+   mb->ol_flags |= sa->tx_ol_flags;
+   }
 
/* copy tunnel pkt header */
rte_memcpy(ph, sa->hdr, sa->hdr_len);
@@ -311,7 +331,7 @@ esp_outb_tun_prepare(const struct rte_ipsec_session *ss, 
struct rte_mbuf *mb[],
 
/* try to update the packet itself */
  

[dpdk-dev] [PATCH] net/virtio: fix virtio-user init when using existing tap

2021-09-17 Thread David Marchand
When attaching to an existing mono queue tap, the virtio-user was not
reporting that the virtio device was not properly initialised which
prevented from starting the port later.

$ ip tuntap add test mode tap
$ dpdk-testpmd --vdev \
  net_virtio_user0,iface=test,path=/dev/vhost-net,queues=2 -- -i

...
virtio_user_dev_init_mac(): (/dev/vhost-net) No valid MAC in devargs or
device, use random
vhost_kernel_open_tap(): TUNSETIFF failed: Invalid argument
vhost_kernel_enable_queue_pair(): fail to open tap for vhost kernel
virtio_user_start_device(): (/dev/vhost-net) Failed to start device
...
Configuring Port 0 (socket 0)
vhost_kernel_open_tap(): TUNSETIFF failed: Invalid argument
vhost_kernel_enable_queue_pair(): fail to open tap for vhost kernel
virtio_set_multiple_queues(): Multiqueue configured but send command
failed, this is too late now...
Fail to start port 0: Invalid argument
Please stop the ports first
Done

The virtio-user with vhost-kernel backend was going through a lot
of complications to initialise tap fds only when using them.

For each qp enabled for the first time, a tapfd was created via
TUNSETIFF with unneeded additional steps (see below) and then mapped to
the right qp in the vhost-net backend.
Unneeded steps (as long as it has been done once for the port):
- tap features were queried while this is a constant on a running
  system,
- the device name in DPDK was updated,
- the mac address of the tap was set,

On subsequent qps state change, the vhost-net backend fd mapping was
updated and the associated queue/tapfd were disabled/enabled via
TUNSETQUEUE.

Now, this patch simplifies the whole logic by keeping all tapfds opened
and in enabled state (from the tap point of view) at all time.

Unused ioctl defines are removed.

Tap features are validated earlier to fail initialisation asap.
Tap name discovery and mac address configuration are moved when
configuring qp 0.

To support attaching to mono queue tap, the virtio-user driver now tries
to attach in multi queue first, then fallbacks to mono queue.

Finally (but this is more for consistency), VIRTIO_NET_F_MQ feature is
exposed only if the underlying tap supports multi queue.

Signed-off-by: David Marchand 
---
 drivers/net/virtio/virtio_user/vhost_kernel.c |  89 +
 .../net/virtio/virtio_user/vhost_kernel_tap.c | 173 +-
 .../net/virtio/virtio_user/vhost_kernel_tap.h |  16 +-
 3 files changed, 143 insertions(+), 135 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c 
b/drivers/net/virtio/virtio_user/vhost_kernel.c
index d65f89e1fc..91c523df76 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -120,9 +120,9 @@ vhost_kernel_set_owner(struct virtio_user_dev *dev)
 static int
 vhost_kernel_get_features(struct virtio_user_dev *dev, uint64_t *features)
 {
-   int ret;
-   unsigned int tap_features;
struct vhost_kernel_data *data = dev->backend_data;
+   unsigned int tap_flags;
+   int ret;
 
ret = vhost_kernel_ioctl(data->vhostfds[0], VHOST_GET_FEATURES, 
features);
if (ret < 0) {
@@ -130,7 +130,7 @@ vhost_kernel_get_features(struct virtio_user_dev *dev, 
uint64_t *features)
return -1;
}
 
-   ret = tap_support_features(&tap_features);
+   ret = tap_get_flags(data->tapfds[0], &tap_flags);
if (ret < 0) {
PMD_DRV_LOG(ERR, "Failed to get TAP features");
return -1;
@@ -140,7 +140,7 @@ vhost_kernel_get_features(struct virtio_user_dev *dev, 
uint64_t *features)
 * but not claimed by vhost-net, so we add them back when
 * reporting to upper layer.
 */
-   if (tap_features & IFF_VNET_HDR) {
+   if (tap_flags & IFF_VNET_HDR) {
*features |= VHOST_KERNEL_GUEST_OFFLOADS_MASK;
*features |= VHOST_KERNEL_HOST_OFFLOADS_MASK;
}
@@ -148,7 +148,7 @@ vhost_kernel_get_features(struct virtio_user_dev *dev, 
uint64_t *features)
/* vhost_kernel will not declare this feature, but it does
 * support multi-queue.
 */
-   if (tap_features & IFF_MULTI_QUEUE)
+   if (tap_flags & IFF_MULTI_QUEUE)
*features |= (1ull << VIRTIO_NET_F_MQ);
 
return 0;
@@ -380,9 +380,20 @@ vhost_kernel_set_status(struct virtio_user_dev *dev 
__rte_unused, uint8_t status
 static int
 vhost_kernel_setup(struct virtio_user_dev *dev)
 {
-   int vhostfd;
-   uint32_t q, i;
struct vhost_kernel_data *data;
+   unsigned int tap_features;
+   unsigned int tap_flags;
+   const char *ifname;
+   uint32_t q, i;
+   int vhostfd;
+
+   if (tap_support_features(&tap_features) < 0)
+   return -1;
+
+   if ((tap_features & IFF_VNET_HDR) == 0) {
+   PMD_INIT_LOG(ERR, "TAP does not support IFF_VNET_HDR");
+   return -1;
+   }
 
data = malloc(sizeof(*data));
if (!data) {
@@ -414,18

[dpdk-dev] [PATCH v2 1/2] common/cnxk: update roc models

2021-09-17 Thread Ashwin Sekhar T K
Make following updates to roc models.
 - Use consistent upper/lower case in macros defining different
   ROC models.
 - Add api to detect cn96 Cx stepping.
 - Make all current cn10k models as A0 stepping.

Signed-off-by: Ashwin Sekhar T K 
---
 drivers/common/cnxk/roc_model.c | 51 +++
 drivers/common/cnxk/roc_model.h | 53 +
 2 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/drivers/common/cnxk/roc_model.c b/drivers/common/cnxk/roc_model.c
index bc255b53cc..e5aeabe2e2 100644
--- a/drivers/common/cnxk/roc_model.c
+++ b/drivers/common/cnxk/roc_model.c
@@ -13,14 +13,14 @@ struct roc_model *roc_model;
 
 #define SOC_PART_CN10K 0xD49
 
-#define PART_106XX  0xB9
-#define PART_105XX  0xBA
-#define PART_105XXN 0xBC
-#define PART_98XX   0xB1
-#define PART_96XX   0xB2
-#define PART_95XX   0xB3
-#define PART_95XXN  0xB4
-#define PART_95XXMM 0xB5
+#define PART_106xx  0xB9
+#define PART_105xx  0xBA
+#define PART_105xxN 0xBC
+#define PART_98xx   0xB1
+#define PART_96xx   0xB2
+#define PART_95xx   0xB3
+#define PART_95xxN  0xB4
+#define PART_95xxMM 0xB5
 #define PART_95O0xB6
 
 #define MODEL_IMPL_BITS  8
@@ -44,20 +44,21 @@ static const struct model_db {
uint64_t flag;
char name[ROC_MODEL_STR_LEN_MAX];
 } model_db[] = {
-   {VENDOR_ARM, PART_106XX, 0, 0, ROC_MODEL_CN106XX, "cn10ka"},
-   {VENDOR_ARM, PART_105XX, 0, 0, ROC_MODEL_CNF105XX, "cnf10ka"},
-   {VENDOR_ARM, PART_105XXN, 0, 0, ROC_MODEL_CNF105XXN, "cnf10kb"},
-   {VENDOR_CAVIUM, PART_98XX, 0, 0, ROC_MODEL_CN98xx_A0, "cn98xx_a0"},
-   {VENDOR_CAVIUM, PART_96XX, 0, 0, ROC_MODEL_CN96xx_A0, "cn96xx_a0"},
-   {VENDOR_CAVIUM, PART_96XX, 0, 1, ROC_MODEL_CN96xx_B0, "cn96xx_b0"},
-   {VENDOR_CAVIUM, PART_96XX, 2, 0, ROC_MODEL_CN96xx_C0, "cn96xx_c0"},
-   {VENDOR_CAVIUM, PART_95XX, 0, 0, ROC_MODEL_CNF95xx_A0, "cnf95xx_a0"},
-   {VENDOR_CAVIUM, PART_95XX, 1, 0, ROC_MODEL_CNF95xx_B0, "cnf95xx_b0"},
-   {VENDOR_CAVIUM, PART_95XXN, 0, 0, ROC_MODEL_CNF95XXN_A0, "cnf95xxn_a0"},
-   {VENDOR_CAVIUM, PART_95O, 0, 0, ROC_MODEL_CNF95XXO_A0, "cnf95O_a0"},
-   {VENDOR_CAVIUM, PART_95XXMM, 0, 0, ROC_MODEL_CNF95XXMM_A0,
-"cnf95xxmm_a0"}
-};
+   {VENDOR_ARM, PART_106xx, 0, 0, ROC_MODEL_CN106xx_A0, "cn10ka_a0"},
+   {VENDOR_ARM, PART_105xx, 0, 0, ROC_MODEL_CNF105xx_A0, "cnf10ka_a0"},
+   {VENDOR_ARM, PART_105xxN, 0, 0, ROC_MODEL_CNF105xxN_A0, "cnf10kb_a0"},
+   {VENDOR_CAVIUM, PART_98xx, 0, 0, ROC_MODEL_CN98xx_A0, "cn98xx_a0"},
+   {VENDOR_CAVIUM, PART_96xx, 0, 0, ROC_MODEL_CN96xx_A0, "cn96xx_a0"},
+   {VENDOR_CAVIUM, PART_96xx, 0, 1, ROC_MODEL_CN96xx_B0, "cn96xx_b0"},
+   {VENDOR_CAVIUM, PART_96xx, 2, 0, ROC_MODEL_CN96xx_C0, "cn96xx_c0"},
+   {VENDOR_CAVIUM, PART_96xx, 2, 1, ROC_MODEL_CN96xx_C0, "cn96xx_c1"},
+   {VENDOR_CAVIUM, PART_95xx, 0, 0, ROC_MODEL_CNF95xx_A0, "cnf95xx_a0"},
+   {VENDOR_CAVIUM, PART_95xx, 1, 0, ROC_MODEL_CNF95xx_B0, "cnf95xx_b0"},
+   {VENDOR_CAVIUM, PART_95xxN, 0, 0, ROC_MODEL_CNF95xxN_A0, "cnf95xxn_a0"},
+   {VENDOR_CAVIUM, PART_95xxN, 0, 1, ROC_MODEL_CNF95xxN_A0, "cnf95xxn_a1"},
+   {VENDOR_CAVIUM, PART_95O, 0, 0, ROC_MODEL_CNF95xxO_A0, "cnf95O_a0"},
+   {VENDOR_CAVIUM, PART_95xxMM, 0, 0, ROC_MODEL_CNF95xxMM_A0,
+"cnf95xxmm_a0"}};
 
 static uint32_t
 cn10k_part_get(void)
@@ -85,11 +86,11 @@ cn10k_part_get(void)
}
ptr++;
if (strcmp("cn10ka", ptr) == 0) {
-   soc = PART_106XX;
+   soc = PART_106xx;
} else if (strcmp("cnf10ka", ptr) == 0) {
-   soc = PART_105XX;
+   soc = PART_105xx;
} else if (strcmp("cnf10kb", ptr) == 0) {
-   soc = PART_105XXN;
+   soc = PART_105xxN;
} else {
plt_err("Unidentified 'CPU compatible': <%s>", ptr);
goto fclose;
diff --git a/drivers/common/cnxk/roc_model.h b/drivers/common/cnxk/roc_model.h
index c1d11b77c6..a54f435b46 100644
--- a/drivers/common/cnxk/roc_model.h
+++ b/drivers/common/cnxk/roc_model.h
@@ -15,13 +15,14 @@ struct roc_model {
 #define ROC_MODEL_CN96xx_C0BIT_ULL(2)
 #define ROC_MODEL_CNF95xx_A0   BIT_ULL(4)
 #define ROC_MODEL_CNF95xx_B0   BIT_ULL(6)
-#define ROC_MODEL_CNF95XXMM_A0 BIT_ULL(8)
-#define ROC_MODEL_CNF95XXN_A0  BIT_ULL(12)
-#define ROC_MODEL_CNF95XXO_A0  BIT_ULL(13)
+#define ROC_MODEL_CNF95xxMM_A0 BIT_ULL(8)
+#define ROC_MODEL_CNF95xxN_A0  BIT_ULL(12)
+#define ROC_MODEL_CNF95xxO_A0  BIT_ULL(13)
+#define ROC_MODEL_CNF95xxN_A1  BIT_ULL(14)
 #define ROC_MODEL_CN98xx_A0BIT_ULL(16)
-#define ROC_MODEL_CN106XX  BIT_ULL(20)
-#define ROC_MODEL_CNF105XX BIT_ULL(21)
-#define ROC_MODEL_CNF105XXNBIT_ULL(22)
+#define ROC_MODEL_CN106xx_A0   BIT_ULL(20)
+#define ROC_MODEL_CNF105xx_A0  BIT_ULL(21)
+#define ROC_MODEL_CNF105xxN_A0 BIT_ULL(22)
 
uint64_t flag;
 #define ROC_MODEL_STR_LEN_MAX 128
@@ -31,11 +32,15 @@ struct roc_model {
 #d

[dpdk-dev] [PATCH v2 2/2] common/cnxk: avoid using stashing option of stype

2021-09-17 Thread Ashwin Sekhar T K
Avoid using stashing option of stype in NPA in cn10k-a0 stepping.

This is a workaround for a HW Errata due to which NPA stashing operations
will never result in writing the data into L2 cache. But instead, it will
be written into LLC.

Signed-off-by: Ashwin Sekhar T K 
Acked-by: Jerin Jacob 
---
 drivers/common/cnxk/roc_nix_queue.c  | 4 
 drivers/common/cnxk/roc_nix_tm_ops.c | 7 +++
 drivers/common/cnxk/roc_npa.h| 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/common/cnxk/roc_nix_queue.c 
b/drivers/common/cnxk/roc_nix_queue.c
index 7e2f86eca7..76e439e7a9 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -585,6 +585,10 @@ sqb_pool_populate(struct roc_nix *roc_nix, struct 
roc_nix_sq *sq)
 
memset(&aura, 0, sizeof(aura));
aura.fc_ena = 1;
+   if (roc_model_is_cn9k() || roc_model_is_cn10ka_a0())
+   aura.fc_stype = 0x0; /* STF */
+   else
+   aura.fc_stype = 0x3; /* STSTP */
aura.fc_addr = (uint64_t)sq->fc;
aura.fc_hyst_bits = 0; /* Store count on all updates */
rc = roc_npa_pool_create(&sq->aura_handle, blk_sz, NIX_MAX_SQB, &aura,
diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c 
b/drivers/common/cnxk/roc_nix_tm_ops.c
index ed244d4214..f2173c9a58 100644
--- a/drivers/common/cnxk/roc_nix_tm_ops.c
+++ b/drivers/common/cnxk/roc_nix_tm_ops.c
@@ -38,6 +38,13 @@ roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable)
 
req->aura.fc_ena = enable;
req->aura_mask.fc_ena = 1;
+   if (roc_model_is_cn9k() || roc_model_is_cn10ka_a0()) {
+   req->aura.fc_stype = 0x0;  /* STF */
+   req->aura_mask.fc_stype = 0x0; /* STF */
+   } else {
+   req->aura.fc_stype = 0x3;  /* STSTP */
+   req->aura_mask.fc_stype = 0x3; /* STSTP */
+   }
 
rc = mbox_process(mbox);
if (rc)
diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h
index 3fc6192e57..1cf50e5c4e 100644
--- a/drivers/common/cnxk/roc_npa.h
+++ b/drivers/common/cnxk/roc_npa.h
@@ -214,7 +214,7 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, 
uint64_t *buf,
cmp.u = 0;
cmp.compare_s.aura = roc_npa_aura_handle_to_aura(aura_handle);
cmp.compare_s.drop = drop;
-   cmp.compare_s.stype = ALLOC_STYPE_STSTP;
+   cmp.compare_s.stype = ALLOC_STYPE_STF;
cmp.compare_s.dis_wait = dis_wait;
cmp.compare_s.count = num;
 
-- 
2.32.0



Re: [dpdk-dev] [PATCH v2] ethdev: change queue release callback

2021-09-17 Thread Xueming(Steven) Li
On Thu, 2021-09-16 at 17:50 +0200, Thomas Monjalon wrote:
> 16/09/2021 17:43, Xueming(Steven) Li:
> > On Thu, 2021-09-16 at 10:09 +0200, Thomas Monjalon wrote:
> > > 15/09/2021 15:02, Xueming Li:
> > > > --- a/lib/ethdev/rte_ethdev.c
> > > > +++ b/lib/ethdev/rte_ethdev.c
> > > > -   
> > > > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
> > > 
> > > Why removing this check?
> > > It is changing the behaviour.
> > 
> > Some PMD implemented a dummy callback, so I think maybe it good to make
> > this callback optional to make PMD clean, how do you think?
> 
> I agree but it should be a separate patch.
> 
Looks good, v3 posted.

> 





[dpdk-dev] [PATCH v1] devtools: add acronyms in dictionary for commit checks

2021-09-17 Thread Ashwin Sekhar T K
Update word list with Marvell specific acronyms.

CPT  -> Cryptographic Accelerator Unit
LBK  -> Loopback Interface Unit
LMT  -> Large Atomic Store Unit
MCAM -> Match Content Addressable Memory
NIX  -> Network Interface Controller Unit
NPA  -> Network Pool Allocator
NPC  -> Network Parser and CAM Unit
ROC  -> Rest Of Chip
RVU  -> Resource Virtualization Unit
SSO  -> Schedule Syncronize Order Unit
TIM  -> Timer Unit

Signed-off-by: Ashwin Sekhar T K 
---
 devtools/words-case.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/devtools/words-case.txt b/devtools/words-case.txt
index 0bbad48626..713d47c081 100644
--- a/devtools/words-case.txt
+++ b/devtools/words-case.txt
@@ -6,6 +6,7 @@ Arm
 armv7
 armv8
 BAR
+CPT
 CRC
 DCB
 DevX
@@ -33,10 +34,12 @@ L2
 L3
 L4
 LACP
+LBK
 Linux
 LRO
 LSC
 MAC
+MCAM
 MPLS
 MSI
 MSI-X
@@ -44,6 +47,9 @@ MSS
 MTU
 NEON
 NIC
+NIX
+NPA
+NPC
 null
 NUMA
 NVGRE
@@ -57,11 +63,13 @@ PVID
 QinQ
 RDMA
 RETA
+ROC
 RSS
 Rx
 SCTP
 SMP
 SoC
+SSO
 SW
 TC
 TCAM
-- 
2.32.0



[dpdk-dev] [PATCH v2] devtools: add acronyms in dictionary for commit checks

2021-09-17 Thread Ashwin Sekhar T K
Update word list with Marvell specific acronyms.

CPT  -> Cryptographic Accelerator Unit
LBK  -> Loopback Interface Unit
LMT  -> Large Atomic Store Unit
MCAM -> Match Content Addressable Memory
NIX  -> Network Interface Controller Unit
NPA  -> Network Pool Allocator
NPC  -> Network Parser and CAM Unit
ROC  -> Rest Of Chip
RVU  -> Resource Virtualization Unit
SSO  -> Schedule Synchronize Order Unit
TIM  -> Timer Unit

Signed-off-by: Ashwin Sekhar T K 
---
 devtools/words-case.txt | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/devtools/words-case.txt b/devtools/words-case.txt
index 0bbad48626..50aded9ce8 100644
--- a/devtools/words-case.txt
+++ b/devtools/words-case.txt
@@ -6,6 +6,7 @@ Arm
 armv7
 armv8
 BAR
+CPT
 CRC
 DCB
 DevX
@@ -33,10 +34,13 @@ L2
 L3
 L4
 LACP
+LBK
 Linux
+LMT
 LRO
 LSC
 MAC
+MCAM
 MPLS
 MSI
 MSI-X
@@ -44,6 +48,9 @@ MSS
 MTU
 NEON
 NIC
+NIX
+NPA
+NPC
 null
 NUMA
 NVGRE
@@ -57,15 +64,19 @@ PVID
 QinQ
 RDMA
 RETA
+ROC
 RSS
+RVU
 Rx
 SCTP
 SMP
 SoC
+SSO
 SW
 TC
 TCAM
 Thor
+TIM
 TOS
 TPID
 TSO
-- 
2.32.0



Re: [dpdk-dev] [PATCH v8 2/2] app/testpmd: fix testpmd doesn't show RSS hash offload

2021-09-17 Thread Ferruh Yigit
On 9/9/2021 4:31 AM, Li, Xiaoyun wrote:
> Hi
> 
>> -Original Message-
>> From: Yigit, Ferruh 
>> Sent: Thursday, September 9, 2021 00:51
>> To: Wang, Jie1X ; dev@dpdk.org; Li, Xiaoyun
>> 
>> Cc: andrew.rybche...@oktetlabs.ru; tho...@monjalon.net
>> Subject: Re: [PATCH v8 2/2] app/testpmd: fix testpmd doesn't show RSS hash
>> offload
>>
>> On 8/27/2021 9:17 AM, Jie Wang wrote:
>>> The driver may change offloads info into dev->data->dev_conf in
>>> dev_configure which may cause port->dev_conf and port->rx_conf contain
>>> outdated values.
>>>
>>> This patch updates the offloads info if it changes to fix this issue.
>>>
>>> Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings")
>>>
>>> Signed-off-by: Jie Wang 
>>> ---
>>>  app/test-pmd/testpmd.c | 34 ++
>>>  app/test-pmd/testpmd.h |  2 ++
>>>  app/test-pmd/util.c| 15 +++
>>>  3 files changed, 51 insertions(+)
>>>
>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>>> 6cbe9ba3c8..bd67291160 100644
>>> --- a/app/test-pmd/testpmd.c
>>> +++ b/app/test-pmd/testpmd.c
>>> @@ -2461,6 +2461,9 @@ start_port(portid_t pid)
>>> }
>>>
>>> if (port->need_reconfig > 0) {
>>> +   struct rte_eth_conf dev_conf_info;
>>> +   int k;
>>> +
>>> port->need_reconfig = 0;
>>>
>>> if (flow_isolate_all) {
>>> @@ -2498,6 +2501,37 @@ start_port(portid_t pid)
>>> port->need_reconfig = 1;
>>> return -1;
>>> }
>>> +   /* get rte_eth_conf info */
>>> +   if (0 !=
>>> +   eth_dev_conf_info_get_print_err(pi,
>>> +   &dev_conf_info)) {
>>> +   fprintf(stderr,
>>> +   "port %d can not get device
>> configuration info\n",
>>> +   pi);
>>> +   return -1;
>>> +   }
>>> +   /* Apply Rx offloads configuration */
>>> +   if (dev_conf_info.rxmode.offloads !=
>>> +   port->dev_conf.rxmode.offloads) {
>>> +   port->dev_conf.rxmode.offloads =
>>> +   dev_conf_info.rxmode.offloads;
>>> +   for (k = 0;
>>> +k < port->dev_info.max_rx_queues;
>>> +k++)
>>> +   port->rx_conf[k].offloads =
>>> +
>>  dev_conf_info.rxmode.offloads;
>>> +   }
>>> +   /* Apply Tx offloads configuration */
>>> +   if (dev_conf_info.txmode.offloads !=
>>> +   port->dev_conf.txmode.offloads) {
>>> +   port->dev_conf.txmode.offloads =
>>> +   dev_conf_info.txmode.offloads;
>>> +   for (k = 0;
>>> +k < port->dev_info.max_tx_queues;
>>> +k++)
>>> +   port->tx_conf[k].offloads =
>>> +
>>  dev_conf_info.txmode.offloads;
>>> +   }
>>> }
>>
>> Above implementation gets the configuration from device and applies it to the
>> testpmd configuration.
>>
>> Instead, what about a long level target to get rid of testpmd specific copy 
>> of the
>> configuration and rely and the config provided by devices. @Xiaoyun, what do
>> you think, does this make sense?
> 
> You mean remove port->dev_conf and rx/tx_conf completely in the future? Or 
> keep it in initial stage?
> 
> Now, port->dev_conf will take global tx/rx_mode, fdir_conf and change some 
> based on dev_info capabilities. And then use dev_configure to apply them for 
> device.
> After this, actually, dev->data->dev_conf contains all device configuration.
> 
> So It seems it's OK to remove port->dev_conf completely. Just testpmd needs 
> to be refactored a lot and regression test in case of issues.
> But from long term view, it's good to keep one source and avoid copy.
> 

Yes, this is the intention I have for long term. I expect that testpmd still
will keep some configuration in application level but we can prevent some
duplication.

And the main point is, by cleaning up testpmd we can recognize blockers and fix
them in libraries to help user applications.

> As for rx/tx_conf, it takes device default tx/rx_conf in dev_info and some 
> settings in testpmd parameters also offloads from dev_conf.
> So keep port->rx/tx_conf? But then it still needs copy from dev_conf since 
> this may change.
> 

I am not very clear what is suggested above, can you please elaborate?

And 'struct rte_port' seems has following structs that can be get from library:
struct rte_eth_dev_info dev_info;
struct rte_eth_conf dev_

[dpdk-dev] [PATCH v6 0/3] net/i40e: remove i40evf

2021-09-17 Thread Robin Zhang
In DPDK 21.05, iavf already became the default VF for i40e devices.
So remove i40evf due to it's no need to maintain now.

v6:
- remove i40e_vf struct and related code, remove doc i40e_vf.ini.

v5:
- rebase code.

v4:
- resolve compile warning issue.

v3:
- remove VF related code in i40e_rxtx.c.

v2:
- update 21.11 release note, remove some missed documentation.

Robin Zhang (3):
  net/i40e: remove i40evf
  net/iavf: remove i40evf devargs option
  doc: remove i40evf related documentation

 doc/guides/howto/lm_bond_virtio_sriov.rst |4 +-
 doc/guides/nics/features/i40e_vf.ini  |   40 -
 doc/guides/nics/intel_vf.rst  |8 +-
 doc/guides/rel_notes/deprecation.rst  |8 -
 doc/guides/rel_notes/release_21_11.rst|2 +
 drivers/net/i40e/base/i40e_osdep.h|1 -
 drivers/net/i40e/i40e_ethdev.h|   78 +-
 drivers/net/i40e/i40e_ethdev_vf.c | 3006 -
 drivers/net/i40e/i40e_rxtx.c  |   50 +-
 drivers/net/i40e/meson.build  |1 -
 drivers/net/i40e/rte_pmd_i40e.c   |9 +-
 drivers/net/iavf/iavf_ethdev.c|   52 +-
 12 files changed, 31 insertions(+), 3228 deletions(-)
 delete mode 100644 doc/guides/nics/features/i40e_vf.ini
 delete mode 100644 drivers/net/i40e/i40e_ethdev_vf.c

-- 
2.25.1



[dpdk-dev] [PATCH v6 1/3] net/i40e: remove i40evf

2021-09-17 Thread Robin Zhang
The default VF driver for Intel 700 Series Ethernet Controller already
switch to iavf in DPDK 21.05. And i40evf is no need to maintain now,
so remove i40evf related code.

Signed-off-by: Robin Zhang 
---
 drivers/net/i40e/base/i40e_osdep.h |1 -
 drivers/net/i40e/i40e_ethdev.h |   78 +-
 drivers/net/i40e/i40e_ethdev_vf.c  | 3006 
 drivers/net/i40e/i40e_rxtx.c   |   50 +-
 drivers/net/i40e/meson.build   |1 -
 drivers/net/i40e/rte_pmd_i40e.c|9 +-
 6 files changed, 24 insertions(+), 3121 deletions(-)
 delete mode 100644 drivers/net/i40e/i40e_ethdev_vf.c

diff --git a/drivers/net/i40e/base/i40e_osdep.h 
b/drivers/net/i40e/base/i40e_osdep.h
index 230d400149..51537c5cf3 100644
--- a/drivers/net/i40e/base/i40e_osdep.h
+++ b/drivers/net/i40e/base/i40e_osdep.h
@@ -162,7 +162,6 @@ static inline uint64_t i40e_read64_addr(volatile void *addr)
rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg)
 
 #define I40E_WRITE_FLUSH(a) I40E_READ_REG(a, I40E_GLGEN_STAT)
-#define I40EVF_WRITE_FLUSH(a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
 
 #define I40E_READ_REG(hw, reg) i40e_read_addr(I40E_PCI_REG_ADDR((hw), (reg)))
 #define I40E_WRITE_REG(hw, reg, value) \
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cd6deabd60..2258bbed1e 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1229,55 +1229,6 @@ struct i40e_vsi_vlan_pvid_info {
} config;
 };
 
-struct i40e_vf_rx_queues {
-   uint64_t rx_dma_addr;
-   uint32_t rx_ring_len;
-   uint32_t buff_size;
-};
-
-struct i40e_vf_tx_queues {
-   uint64_t tx_dma_addr;
-   uint32_t tx_ring_len;
-};
-
-/*
- * Structure to store private data specific for VF instance.
- */
-struct i40e_vf {
-   struct i40e_adapter *adapter; /* The adapter this VF associate to */
-   struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
-   uint16_t num_queue_pairs;
-   uint16_t max_pkt_len; /* Maximum packet length */
-   bool promisc_unicast_enabled;
-   bool promisc_multicast_enabled;
-
-   rte_spinlock_t cmd_send_lock;
-   uint32_t version_major; /* Major version number */
-   uint32_t version_minor; /* Minor version number */
-   uint16_t promisc_flags; /* Promiscuous setting */
-   uint32_t vlan[I40E_VFTA_SIZE]; /* VLAN bit map */
-
-   /* Multicast addrs */
-   struct rte_ether_addr mc_addrs[I40E_NUM_MACADDR_MAX];
-   uint16_t mc_addrs_num;   /* Multicast mac addresses number */
-
-   /* Event from pf */
-   bool dev_closed;
-   bool link_up;
-   enum virtchnl_link_speed link_speed;
-   bool vf_reset;
-   volatile uint32_t pend_cmd; /* pending command not finished yet */
-   int32_t cmd_retval; /* return value of the cmd response from PF */
-   u16 pend_msg; /* flags indicates events from pf not handled yet */
-   uint8_t *aq_resp; /* buffer to store the adminq response from PF */
-
-   /* VSI info */
-   struct virtchnl_vf_resource *vf_res; /* All VSIs */
-   struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
-   struct i40e_vsi vsi;
-   uint64_t flags;
-};
-
 #define I40E_MAX_PKT_TYPE  256
 #define I40E_FLOW_TYPE_MAX 64
 
@@ -1288,11 +1239,8 @@ struct i40e_adapter {
/* Common for both PF and VF */
struct i40e_hw hw;
 
-   /* Specific for PF or VF */
-   union {
-   struct i40e_pf pf;
-   struct i40e_vf vf;
-   };
+   /* Specific for PF */
+   struct i40e_pf pf;
 
/* For vector PMD */
bool rx_bulk_alloc_allowed;
@@ -1461,7 +1409,6 @@ int i40e_add_macvlan_filters(struct i40e_vsi *vsi,
 int total);
 bool is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv);
 bool is_i40e_supported(struct rte_eth_dev *dev);
-bool is_i40evf_supported(struct rte_eth_dev *dev);
 void i40e_set_symmetric_hash_enable_per_port(struct i40e_hw *hw,
 uint8_t enable);
 int i40e_validate_input_set(enum i40e_filter_pctype pctype,
@@ -1507,26 +1454,15 @@ int i40e_vf_representor_uninit(struct rte_eth_dev 
*ethdev);
 #define I40E_DEV_PRIVATE_TO_ADAPTER(adapter) \
((struct i40e_adapter *)adapter)
 
-/* I40EVF_DEV_PRIVATE_TO */
-#define I40EVF_DEV_PRIVATE_TO_VF(adapter) \
-   (&((struct i40e_adapter *)adapter)->vf)
-
 static inline struct i40e_vsi *
 i40e_get_vsi_from_adapter(struct i40e_adapter *adapter)
 {
-   struct i40e_hw *hw;
-
 if (!adapter)
 return NULL;
 
-   hw = I40E_DEV_PRIVATE_TO_HW(adapter);
-   if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
-   struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(adapter);
-   return &vf->vsi;
-   } else {
-   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(adapter);
-   return pf->main_vsi;
-   }
+   struct i40e_pf *pf = I40E_DEV

[dpdk-dev] [PATCH v6 2/3] net/iavf: remove i40evf devargs option

2021-09-17 Thread Robin Zhang
Due to i40evf will be removed, so there's no need to keep the devargs
option "driver=i40evf" in iavf.

Signed-off-by: Robin Zhang 
---
 drivers/net/iavf/iavf_ethdev.c | 52 ++
 1 file changed, 2 insertions(+), 50 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index c131461517..493bc41da9 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2506,58 +2506,10 @@ iavf_dcf_cap_selected(struct rte_devargs *devargs)
return ret;
 }
 
-static int
-iavf_drv_i40evf_check_handler(__rte_unused const char *key,
- const char *value, __rte_unused void *opaque)
-{
-   if (strcmp(value, "i40evf"))
-   return -1;
-
-   return 0;
-}
-
-static int
-iavf_drv_i40evf_selected(struct rte_devargs *devargs, uint16_t device_id)
-{
-   struct rte_kvargs *kvlist;
-   int ret = 0;
-
-   if (device_id != IAVF_DEV_ID_VF &&
-   device_id != IAVF_DEV_ID_VF_HV &&
-   device_id != IAVF_DEV_ID_X722_VF &&
-   device_id != IAVF_DEV_ID_X722_A0_VF)
-   return 0;
-
-   if (devargs == NULL)
-   return 0;
-
-   kvlist = rte_kvargs_parse(devargs->args, NULL);
-   if (kvlist == NULL)
-   return 0;
-
-   if (!rte_kvargs_count(kvlist, RTE_DEVARGS_KEY_DRIVER))
-   goto exit;
-
-   /* i40evf driver selected when there's a key-value pair:
-* driver=i40evf
-*/
-   if (rte_kvargs_process(kvlist, RTE_DEVARGS_KEY_DRIVER,
-  iavf_drv_i40evf_check_handler, NULL) < 0)
-   goto exit;
-
-   ret = 1;
-
-exit:
-   rte_kvargs_free(kvlist);
-   return ret;
-}
-
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 struct rte_pci_device *pci_dev)
 {
-   if (iavf_dcf_cap_selected(pci_dev->device.devargs) ||
-   iavf_drv_i40evf_selected(pci_dev->device.devargs,
-pci_dev->id.device_id))
+   if (iavf_dcf_cap_selected(pci_dev->device.devargs))
return 1;
 
return rte_eth_dev_pci_generic_probe(pci_dev,
@@ -2580,7 +2532,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
-RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf driver=i40evf");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_LOG_REGISTER_SUFFIX(iavf_logtype_init, init, NOTICE);
 RTE_LOG_REGISTER_SUFFIX(iavf_logtype_driver, driver, NOTICE);
 #ifdef RTE_ETHDEV_DEBUG_RX
-- 
2.25.1



[dpdk-dev] [PATCH v6 3/3] doc: remove i40evf related documentation

2021-09-17 Thread Robin Zhang
As announced in the deprecation note, i40evf has been removed. So removing
deprecation notice and other i40evf related documentation.

Signed-off-by: Robin Zhang 
---
 doc/guides/howto/lm_bond_virtio_sriov.rst |  4 +--
 doc/guides/nics/features/i40e_vf.ini  | 40 ---
 doc/guides/nics/intel_vf.rst  |  8 +
 doc/guides/rel_notes/deprecation.rst  |  8 -
 doc/guides/rel_notes/release_21_11.rst|  2 ++
 5 files changed, 5 insertions(+), 57 deletions(-)
 delete mode 100644 doc/guides/nics/features/i40e_vf.ini

diff --git a/doc/guides/howto/lm_bond_virtio_sriov.rst 
b/doc/guides/howto/lm_bond_virtio_sriov.rst
index 3e25480316..e854ae214e 100644
--- a/doc/guides/howto/lm_bond_virtio_sriov.rst
+++ b/doc/guides/howto/lm_bond_virtio_sriov.rst
@@ -392,7 +392,7 @@ Set up Virtual Functions on host_server_1
cat /sys/bus/pci/devices/\:02\:00.0/sriov_numvfs
echo 1 > /sys/bus/pci/devices/\:02\:00.0/sriov_numvfs
cat /sys/bus/pci/devices/\:02\:00.0/sriov_numvfs
-   rmmod i40evf
+   rmmod iavf
 
 vm_virtio_vf_one_212_46.sh
 ~~
@@ -492,7 +492,7 @@ Set up Virtual Functions on host_server_2
cat /sys/bus/pci/devices/\:03\:00.0/sriov_numvfs
echo 1 > /sys/bus/pci/devices/\:03\:00.0/sriov_numvfs
cat /sys/bus/pci/devices/\:03\:00.0/sriov_numvfs
-   rmmod i40evf
+   rmmod iavf
 
 vm_virtio_one_migrate.sh
 
diff --git a/doc/guides/nics/features/i40e_vf.ini 
b/doc/guides/nics/features/i40e_vf.ini
deleted file mode 100644
index 36d7136d13..00
--- a/doc/guides/nics/features/i40e_vf.ini
+++ /dev/null
@@ -1,40 +0,0 @@
-;
-; Supported features of the 'i40e_vf' network poll mode driver.
-;
-; Refer to default.ini for the full list of available PMD features.
-;
-[Features]
-Rx interrupt = Y
-Link status  = Y
-Link status event= Y
-Fast mbuf free   = P
-Queue start/stop = Y
-Power mgmt address monitor = Y
-Jumbo frame  = Y
-Scattered Rx = Y
-TSO  = Y
-Promiscuous mode = Y
-Allmulticast mode= Y
-Unicast MAC filter   = Y
-Multicast MAC filter = Y
-RSS hash = Y
-RSS key update   = Y
-RSS reta update  = Y
-VLAN filter  = Y
-CRC offload  = Y
-VLAN offload = Y
-QinQ offload = P
-L3 checksum offload  = P
-L4 checksum offload  = P
-Inner L3 checksum= P
-Inner L4 checksum= P
-Packet type parsing  = Y
-Rx descriptor status = Y
-Tx descriptor status = Y
-Basic stats  = Y
-Extended stats   = Y
-Multiprocess aware   = Y
-FreeBSD  = Y
-Linux= Y
-x86-32   = Y
-x86-64   = Y
diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index fcea8151bf..b80c41809b 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -26,7 +26,7 @@ Refer to :numref:`figure_single_port_nic`.
 
 Therefore, a NIC is logically distributed among multiple virtual machines (as 
shown in :numref:`figure_single_port_nic`),
 while still having global data in common to share with the Physical Function 
and other Virtual Functions.
-The DPDK fm10kvf, i40evf, igbvf or ixgbevf as a Poll Mode Driver (PMD) serves 
for the Intel® 82576 Gigabit Ethernet Controller,
+The DPDK fm10kvf, iavf, igbvf or ixgbevf as a Poll Mode Driver (PMD) serves 
for the Intel® 82576 Gigabit Ethernet Controller,
 Intel® Ethernet Controller I350 family, Intel® 82599 10 Gigabit Ethernet 
Controller NIC,
 Intel® Fortville 10/40 Gigabit Ethernet Controller NIC's virtual PCI function, 
or PCIe host-interface of the Intel Ethernet Switch
 FM1 Series.
@@ -88,12 +88,6 @@ For more detail on SR-IOV, please refer to the following 
documents:
 assignment in hypervisor. Take qemu for example, the device assignment 
should carry the IAVF device id (0x1889) like
 ``-device vfio-pci,x-pci-device-id=0x1889,host=03:0a.0``.
 
-Starting from DPDK 21.05, the default VF driver for Intel® 700 Series 
Ethernet Controller will be IAVF. No new feature
-will be added into i40evf except bug fix until it's removed in DPDK 21.11. 
Between DPDK 21.05 and 21.11, by using the
-``devargs`` option ``driver=i40evf``, i40evf PMD still can be used on 
Intel® 700 Series Ethernet Controller, for example::
-
--a 81:02.0,driver=i40evf
-
 When IAVF is backed by an Intel® E810 device, the "Protocol Extraction" 
feature which is supported by ice PMD is also
 available for IAVF PMD. The same devargs with the same parameters can be 
applied to IAVF PMD, for detail please reference
 the section ``Protocol extraction for per queue`` of ice.rst.
diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 59445a6f42..d0a65d3f46 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -164,14 +164,6 @@ Deprecation Notices
   consistent with existing outer header checksum status fla

Re: [dpdk-dev] [PATCH] doc: remove template comments in old release notes

2021-09-17 Thread Mcnamara, John
> -Original Message-
> From: Thomas Monjalon 
> Sent: Wednesday, September 15, 2021 5:25 PM
> To: dev@dpdk.org
> Cc: Mcnamara, John ; david.march...@redhat.com;
> Yigit, Ferruh 
> Subject: [PATCH] doc: remove template comments in old release notes
> 
> The release notes comments mention how to generate the documentation
> with the old & removed build system.
> 
> Rather than fixing these comments, all old release notes comments
> are removed, because they are useful only for the current release.


Good point. We should remember to remove these how-to comments in the last pass 
of reviewing the release notes as well.

Acked-by: John McNamara 


Re: [dpdk-dev] [PATCH] net: fix checksum API documentation

2021-09-17 Thread Morten Brørup
> From: Lance Richardson [mailto:lance.richard...@broadcom.com]
> Sent: Thursday, 16 September 2021 18.11
> 
> Minor corrections and improvements to documentation
> for checksum APIs.
> 
> Fixes: 6006818cfb26 ("net: new checksum functions")
> Fixes: 45a08ef55e44 ("net: introduce functions to verify L4 checksums")
> Cc: sta...@dpdk.org
> Signed-off-by: Lance Richardson 
> ---
>  lib/net/rte_ip.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h
> index 05948b69b7..fd08ea31b2 100644
> --- a/lib/net/rte_ip.h
> +++ b/lib/net/rte_ip.h
> @@ -488,7 +488,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr
> *ipv6_hdr, uint64_t ol_flags)
>  }
> 
>  /**
> - * @internal Calculate the non-complemented IPv4 L4 checksum
> + * @internal Calculate the non-complemented IPv6 L4 checksum
>   */
>  static inline uint16_t
>  __rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const
> void *l4_hdr)
> @@ -509,15 +509,15 @@ __rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr
> *ipv6_hdr, const void *l4_hdr)
>  /**
>   * Process the IPv6 UDP or TCP checksum.
>   *
> - * The IPv4 header should not contains options. The layer 4 checksum
> - * must be set to 0 in the packet by the caller.
> + * The IPv6 header must not be followed by extension headers. The
> layer 4
> + * checksum must be set to 0 in the L4 header by the caller.
>   *
>   * @param ipv6_hdr
>   *   The pointer to the contiguous IPv6 header.
>   * @param l4_hdr
>   *   The pointer to the beginning of the L4 header.
>   * @return
> - *   The complemented checksum to set in the IP packet.
> + *   The complemented checksum to set in the L4 header.
>   */
>  static inline uint16_t
>  rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void
> *l4_hdr)
> --
> 2.25.1

Reviewed-by: Morten Brørup 



[dpdk-dev] [PATCH 00/20] ice/base: add parser module

2021-09-17 Thread Qi Zhang
Add the parser module that can parse on a raw packet then figure
out the low-level metadata to program the hardware packet process
pipeline for flow offloading(Switch/FDIR/RSS). This is the pre-step
to enable a protocol-agnostic flow offloading solution for ice devices
that leverage Intel DDP technology.

Qi Zhang (20):
  net/ice/base: add parser create and destroy skeleton
  net/ice/base: init imem table for parser
  net/ice/base: init metainit table for parser
  net/ice/base: init parse graph cam table for parser
  net/ice/base: init boost TCAM table for parser
  net/ice/base: init ptype marker TCAM table for parser
  net/ice/base: init marker group table for parser
  net/ice/base: init protocol group table for parser
  net/ice/base: init flag redirect table for parser
  net/ice/base: init XLT key builder for parser
  net/ice/base: add parser runtime skeleton
  net/ice/base: add helper function for boost TCAM match
  net/ice/base: add helper functions for parse graph key matching
  net/ice/base: add helper function for ptype markers match
  net/ice/base: add helper function to redirect flags
  net/ice/base: add helper function to aggregate flags
  net/ice/base: add parser execution main loop
  net/ice/base: support double VLAN mode configure for parser
  net/ice/base: add tunnel port support for parser
  net/ice/base: add API for parser profile initialization

 drivers/net/ice/base/ice_bst_tcam.c| 291 +
 drivers/net/ice/base/ice_bst_tcam.h|  35 +
 drivers/net/ice/base/ice_common.h  |   1 +
 drivers/net/ice/base/ice_flex_pipe.c   |   4 +-
 drivers/net/ice/base/ice_flex_pipe.h   |   8 +
 drivers/net/ice/base/ice_flex_type.h   |   2 +
 drivers/net/ice/base/ice_flg_rd.c  |  76 +++
 drivers/net/ice/base/ice_flg_rd.h  |  17 +
 drivers/net/ice/base/ice_imem.c| 244 +++
 drivers/net/ice/base/ice_imem.h| 109 
 drivers/net/ice/base/ice_metainit.c| 143 
 drivers/net/ice/base/ice_metainit.h|  46 ++
 drivers/net/ice/base/ice_mk_grp.c  |  55 ++
 drivers/net/ice/base/ice_mk_grp.h  |  15 +
 drivers/net/ice/base/ice_parser.c  | 556 
 drivers/net/ice/base/ice_parser.h  | 113 
 drivers/net/ice/base/ice_parser_rt.c   | 867 +
 drivers/net/ice/base/ice_parser_rt.h   |  48 ++
 drivers/net/ice/base/ice_parser_util.h |  36 +
 drivers/net/ice/base/ice_pg_cam.c  | 374 +++
 drivers/net/ice/base/ice_pg_cam.h  |  74 +++
 drivers/net/ice/base/ice_proto_grp.c   | 108 +++
 drivers/net/ice/base/ice_proto_grp.h   |  23 +
 drivers/net/ice/base/ice_ptype_mk.c|  76 +++
 drivers/net/ice/base/ice_ptype_mk.h|  21 +
 drivers/net/ice/base/ice_tmatch.h  |  44 ++
 drivers/net/ice/base/ice_type.h|   1 +
 drivers/net/ice/base/ice_xlt_kb.c  | 216 ++
 drivers/net/ice/base/ice_xlt_kb.h  |  34 +
 drivers/net/ice/base/meson.build   |  11 +
 30 files changed, 3646 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_bst_tcam.c
 create mode 100644 drivers/net/ice/base/ice_bst_tcam.h
 create mode 100644 drivers/net/ice/base/ice_flg_rd.c
 create mode 100644 drivers/net/ice/base/ice_flg_rd.h
 create mode 100644 drivers/net/ice/base/ice_imem.c
 create mode 100644 drivers/net/ice/base/ice_imem.h
 create mode 100644 drivers/net/ice/base/ice_metainit.c
 create mode 100644 drivers/net/ice/base/ice_metainit.h
 create mode 100644 drivers/net/ice/base/ice_mk_grp.c
 create mode 100644 drivers/net/ice/base/ice_mk_grp.h
 create mode 100644 drivers/net/ice/base/ice_parser.c
 create mode 100644 drivers/net/ice/base/ice_parser.h
 create mode 100644 drivers/net/ice/base/ice_parser_rt.c
 create mode 100644 drivers/net/ice/base/ice_parser_rt.h
 create mode 100644 drivers/net/ice/base/ice_parser_util.h
 create mode 100644 drivers/net/ice/base/ice_pg_cam.c
 create mode 100644 drivers/net/ice/base/ice_pg_cam.h
 create mode 100644 drivers/net/ice/base/ice_proto_grp.c
 create mode 100644 drivers/net/ice/base/ice_proto_grp.h
 create mode 100644 drivers/net/ice/base/ice_ptype_mk.c
 create mode 100644 drivers/net/ice/base/ice_ptype_mk.h
 create mode 100644 drivers/net/ice/base/ice_tmatch.h
 create mode 100644 drivers/net/ice/base/ice_xlt_kb.c
 create mode 100644 drivers/net/ice/base/ice_xlt_kb.h

-- 
2.26.2



[dpdk-dev] [PATCH 01/20] net/ice/base: add parser create and destroy skeleton

2021-09-17 Thread Qi Zhang
Add new parser module which can parse a packet in binary
and generate information like ptype, protocol/offset pairs
and flags which can be used to feed the FXP profile creation
directly.

The patch added skeleton of the parser instance create and
destroy APIs:
ice_parser_create
ice_parser_destroy

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_common.h|  1 +
 drivers/net/ice/base/ice_flex_pipe.c |  2 +-
 drivers/net/ice/base/ice_flex_pipe.h |  5 
 drivers/net/ice/base/ice_parser.c| 34 
 drivers/net/ice/base/ice_parser.h| 14 
 drivers/net/ice/base/meson.build |  1 +
 6 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ice/base/ice_parser.c
 create mode 100644 drivers/net/ice/base/ice_parser.h

diff --git a/drivers/net/ice/base/ice_common.h 
b/drivers/net/ice/base/ice_common.h
index 1d8882c279..a3cbf4fb05 100644
--- a/drivers/net/ice/base/ice_common.h
+++ b/drivers/net/ice/base/ice_common.h
@@ -8,6 +8,7 @@
 #include "ice_type.h"
 #include "ice_nvm.h"
 #include "ice_flex_pipe.h"
+#include "ice_parser.h"
 #include "ice_switch.h"
 #include "ice_fdir.h"
 
diff --git a/drivers/net/ice/base/ice_flex_pipe.c 
b/drivers/net/ice/base/ice_flex_pipe.c
index 3631ddba2c..703c3e0416 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -284,7 +284,7 @@ ice_pkg_enum_section(struct ice_seg *ice_seg, struct 
ice_pkg_enum *state,
  * indicates a base offset of 10, and the index for the entry is 2, then
  * section handler function should set the offset to 10 + 2 = 12.
  */
-static void *
+void *
 ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
   u32 sect_type, u32 *offset,
   void *(*handler)(u32 sect_type, void *section,
diff --git a/drivers/net/ice/base/ice_flex_pipe.h 
b/drivers/net/ice/base/ice_flex_pipe.h
index b690be75fc..045a77c607 100644
--- a/drivers/net/ice/base/ice_flex_pipe.h
+++ b/drivers/net/ice/base/ice_flex_pipe.h
@@ -94,4 +94,9 @@ void ice_pkg_buf_free(struct ice_hw *hw, struct ice_buf_build 
*bld);
 enum ice_status
 ice_set_key(u8 *key, u16 size, u8 *val, u8 *upd, u8 *dc, u8 *nm, u16 off,
u16 len);
+void *
+ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
+  u32 sect_type, u32 *offset,
+  void *(*handler)(u32 sect_type, void *section,
+   u32 index, u32 *offset));
 #endif /* _ICE_FLEX_PIPE_H_ */
diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
new file mode 100644
index 00..c08decaf0d
--- /dev/null
+++ b/drivers/net/ice/base/ice_parser.c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+
+/**
+ * ice_parser_create - create a parser instance
+ * @hw: pointer to the hardware structure
+ * @psr: output parameter for a new parser instance be created
+ */
+enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
+{
+   struct ice_parser *p;
+
+   p = (struct ice_parser *)ice_malloc(hw, sizeof(struct ice_parser));
+
+   if (!p)
+   return ICE_ERR_NO_MEMORY;
+
+   p->hw = hw;
+
+   *psr = p;
+   return ICE_SUCCESS;
+}
+
+/**
+ * ice_parser_destroy - destroy a parser instance
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_destroy(struct ice_parser *psr)
+{
+   ice_free(psr->hw, psr);
+}
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
new file mode 100644
index 00..a0e33bb867
--- /dev/null
+++ b/drivers/net/ice/base/ice_parser.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_PARSER_H_
+#define _ICE_PARSRR_H_
+
+struct ice_parser {
+   struct ice_hw *hw; /* pointer to the hardware structure */
+};
+
+enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
+void ice_parser_destroy(struct ice_parser *psr);
+#endif /* _ICE_PARSER_H_ */
diff --git a/drivers/net/ice/base/meson.build b/drivers/net/ice/base/meson.build
index be9713dfa1..2b0af54a5c 100644
--- a/drivers/net/ice/base/meson.build
+++ b/drivers/net/ice/base/meson.build
@@ -15,6 +15,7 @@ sources = [
 'ice_acl_ctrl.c',
 'ice_vlan_mode.c',
 'ice_ptp_hw.c',
+   'ice_parser.c',
 ]
 
 error_cflags = [
-- 
2.26.2



[dpdk-dev] [PATCH 02/20] net/ice/base: init imem table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of
struct ice_imem_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_imem.c| 244 +
 drivers/net/ice/base/ice_imem.h| 109 +++
 drivers/net/ice/base/ice_parser.c  | 100 ++
 drivers/net/ice/base/ice_parser.h  |   3 +
 drivers/net/ice/base/ice_parser_util.h |  25 +++
 drivers/net/ice/base/ice_type.h|   1 +
 drivers/net/ice/base/meson.build   |   1 +
 7 files changed, 483 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_imem.c
 create mode 100644 drivers/net/ice/base/ice_imem.h
 create mode 100644 drivers/net/ice/base/ice_parser_util.h

diff --git a/drivers/net/ice/base/ice_imem.c b/drivers/net/ice/base/ice_imem.c
new file mode 100644
index 00..ea77581199
--- /dev/null
+++ b/drivers/net/ice/base/ice_imem.c
@@ -0,0 +1,244 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_IMEM_TABLE_SIZE 192
+
+static void _imem_bst_bm_dump(struct ice_hw *hw, struct ice_bst_master *bm)
+{
+   ice_info(hw, "boost master:\n");
+   ice_info(hw, "\tal0 = %d\n", bm->al0);
+   ice_info(hw, "\tal1 = %d\n", bm->al1);
+   ice_info(hw, "\tal2 = %d\n", bm->al2);
+   ice_info(hw, "\tpg = %d\n", bm->pg);
+}
+
+static void _imem_bst_kb_dump(struct ice_hw *hw, struct ice_bst_keybuilder *kb)
+{
+   ice_info(hw, "boost key builder:\n");
+   ice_info(hw, "\tpriority = %d\n", kb->priority);
+   ice_info(hw, "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _imem_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
+{
+   ice_info(hw, "next proto key builder:\n");
+   ice_info(hw, "\tops = %d\n", kb->ops);
+   ice_info(hw, "\tstart_or_reg0 = %d\n", kb->start_or_reg0);
+   ice_info(hw, "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
+}
+
+static void _imem_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
+{
+   ice_info(hw, "parse graph key builder:\n");
+   ice_info(hw, "\tflag0_ena = %d\n", kb->flag0_ena);
+   ice_info(hw, "\tflag1_ena = %d\n", kb->flag1_ena);
+   ice_info(hw, "\tflag2_ena = %d\n", kb->flag2_ena);
+   ice_info(hw, "\tflag3_ena = %d\n", kb->flag3_ena);
+   ice_info(hw, "\tflag0_idx = %d\n", kb->flag0_idx);
+   ice_info(hw, "\tflag1_idx = %d\n", kb->flag1_idx);
+   ice_info(hw, "\tflag2_idx = %d\n", kb->flag2_idx);
+   ice_info(hw, "\tflag3_idx = %d\n", kb->flag3_idx);
+   ice_info(hw, "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
+{
+   ice_info(hw, "alu%d:\n", index);
+   ice_info(hw, "\topc = %d\n", alu->opc);
+   ice_info(hw, "\tsrc_start = %d\n", alu->src_start);
+   ice_info(hw, "\tsrc_len = %d\n", alu->src_len);
+   ice_info(hw, "\tshift_xlate_select = %d\n", alu->shift_xlate_select);
+   ice_info(hw, "\tshift_xlate_key = %d\n", alu->shift_xlate_key);
+   ice_info(hw, "\tsrc_reg_id = %d\n", alu->src_reg_id);
+   ice_info(hw, "\tdst_reg_id = %d\n", alu->dst_reg_id);
+   ice_info(hw, "\tinc0 = %d\n", alu->inc0);
+   ice_info(hw, "\tinc1 = %d\n", alu->inc1);
+   ice_info(hw, "\tproto_offset_opc = %d\n", alu->proto_offset_opc);
+   ice_info(hw, "\tproto_offset = %d\n", alu->proto_offset);
+   ice_info(hw, "\tbranch_addr = %d\n", alu->branch_addr);
+   ice_info(hw, "\timm = %d\n", alu->imm);
+   ice_info(hw, "\tdst_start = %d\n", alu->dst_start);
+   ice_info(hw, "\tdst_len = %d\n", alu->dst_len);
+   ice_info(hw, "\tflags_extr_imm = %d\n", alu->flags_extr_imm);
+   ice_info(hw, "\tflags_start_imm= %d\n", alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @ice_hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+   ice_info(hw, "index = %d\n", item->idx);
+   _imem_bst_bm_dump(hw, &item->b_m);
+   _imem_bst_kb_dump(hw, &item->b_kb);
+   ice_info(hw, "pg priority = %d\n", item->pg);
+   _imem_np_kb_dump(hw, &item->np_kb);
+   _imem_pg_kb_dump(hw, &item->pg_kb);
+   _imem_alu_dump(hw, &item->alu0, 0);
+   _imem_alu_dump(hw, &item->alu1, 1);
+   _imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Master with below format:
+ *  BIT 0: ALU 0 (bm->alu0)
+ *  BIT 1: ALU 1 (bm->alu1)
+ *  BIT 2: ALU 2 (bm->alu2)
+ *  BIT 3: Parge Graph (bm->pg)
+ */
+static void _imem_bm_init(struct ice_bst_master *bm, u8 data)
+{
+   bm->al0 = (data & 0x1) != 0;
+   bm->al1 = (data & 0x2) != 0;
+   bm->al2 = (data & 0x4) != 0;
+   bm->pg = (data & 0x8) != 0;
+}
+
+/** The function parses a 10 bits Boost Master Build with below format:
+ *  BIT 0-7:   Priority (bkb->priority)
+ *  BIT 8: TSR Control (bkb->tsr_ctrl)
+ *  BIT 9: R

[dpdk-dev] [PATCH 03/20] net/ice/base: init metainit table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array of
struct ice_metainit_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_metainit.c| 143 +
 drivers/net/ice/base/ice_metainit.h|  46 
 drivers/net/ice/base/ice_parser.c  |  15 ++-
 drivers/net/ice/base/ice_parser.h  |   2 +
 drivers/net/ice/base/ice_parser_util.h |   1 +
 drivers/net/ice/base/meson.build   |   1 +
 6 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_metainit.c
 create mode 100644 drivers/net/ice/base/ice_metainit.h

diff --git a/drivers/net/ice/base/ice_metainit.c 
b/drivers/net/ice/base/ice_metainit.c
new file mode 100644
index 00..5d49c6861d
--- /dev/null
+++ b/drivers/net/ice/base/ice_metainit.c
@@ -0,0 +1,143 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_METAINIT_TABLE_SIZE 16
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @ice_hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item *item)
+{
+   ice_info(hw, "index = %d\n", item->idx);
+   ice_info(hw, "tsr = %d\n", item->tsr);
+   ice_info(hw, "ho = %d\n", item->ho);
+   ice_info(hw, "pc = %d\n", item->pc);
+   ice_info(hw, "pg_rn = %d\n", item->pg_rn);
+   ice_info(hw, "cd = %d\n", item->cd);
+   ice_info(hw, "gpr_a_ctrl = %d\n", item->gpr_a_ctrl);
+   ice_info(hw, "gpr_a_data_mdid = %d\n", item->gpr_a_data_mdid);
+   ice_info(hw, "gpr_a_data_start = %d\n", item->gpr_a_data_start);
+   ice_info(hw, "gpr_a_data_len = %d\n", item->gpr_a_data_len);
+   ice_info(hw, "gpr_a_id = %d\n", item->gpr_a_id);
+   ice_info(hw, "gpr_b_ctrl = %d\n", item->gpr_b_ctrl);
+   ice_info(hw, "gpr_b_data_mdid = %d\n", item->gpr_b_data_mdid);
+   ice_info(hw, "gpr_b_data_start = %d\n", item->gpr_b_data_start);
+   ice_info(hw, "gpr_b_data_len = %d\n", item->gpr_b_data_len);
+   ice_info(hw, "gpr_b_id = %d\n", item->gpr_b_id);
+   ice_info(hw, "gpr_c_ctrl = %d\n", item->gpr_c_ctrl);
+   ice_info(hw, "gpr_c_data_mdid = %d\n", item->gpr_c_data_mdid);
+   ice_info(hw, "gpr_c_data_start = %d\n", item->gpr_c_data_start);
+   ice_info(hw, "gpr_c_data_len = %d\n", item->gpr_c_data_len);
+   ice_info(hw, "gpr_c_id = %d\n", item->gpr_c_id);
+   ice_info(hw, "gpr_d_ctrl = %d\n", item->gpr_d_ctrl);
+   ice_info(hw, "gpr_d_data_mdid = %d\n", item->gpr_d_data_mdid);
+   ice_info(hw, "gpr_d_data_start = %d\n", item->gpr_d_data_start);
+   ice_info(hw, "gpr_d_data_len = %d\n", item->gpr_d_data_len);
+   ice_info(hw, "gpr_d_id = %d\n", item->gpr_d_id);
+   ice_info(hw, "flags = 0x%016" PRIx64 "\n", item->flags);
+}
+
+/** The function parses a 192 bits Metadata Init entry with below format:
+ *  BIT 0-7:   TCAM Search Key Register (mi->tsr)
+ *  BIT 8-16:  Header Offset (mi->ho)
+ *  BIT 17-24: Program Counter (mi->pc)
+ *  BIT 25-35: Parse Graph Root Node (mi->pg_rn)
+ *  BIT 36-38: Control Domain (mi->cd)
+ *  BIT 39:GPR_A Data Control (mi->gpr_a_ctrl)
+ *  BIT 40-44: GPR_A MDID.ID (mi->gpr_a_data_mdid)
+ *  BIT 45-48: GPR_A MDID.START (mi->gpr_a_data_start)
+ *  BIT 49-53: GPR_A MDID.LEN (mi->gpr_a_data_len)
+ *  BIT 54-55: reserved
+ *  BIT 56-59: GPR_A ID (mi->gpr_a_id)
+ *  BIT 60:GPR_B Data Control (mi->gpr_b_ctrl)
+ *  BIT 61-65: GPR_B MDID.ID (mi->gpr_b_data_mdid)
+ *  BIT 66-69: GPR_B MDID.START (mi->gpr_b_data_start)
+ *  BIT 70-74: GPR_B MDID.LEN (mi->gpr_b_data_len)
+ *  BIT 75-76: reserved
+ *  BIT 77-80: GPR_B ID (mi->gpr_a_id)
+ *  BIT 81:GPR_C Data Control (mi->gpr_c_ctrl)
+ *  BIT 82-86: GPR_C MDID.ID (mi->gpr_c_data_mdid)
+ *  BIT 87-90: GPR_C MDID.START (mi->gpr_c_data_start)
+ *  BIT 91-95: GPR_C MDID.LEN (mi->gpr_c_data_len)
+ *  BIT 96-97: reserved
+ *  BIT 98-101:GPR_C ID (mi->gpr_c_id)
+ *  BIT 102:   GPR_D Data Control (mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID (mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START (mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN (mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID (mi->gpr_d_id)
+ *  BIT 123-186:Flags (mi->flags)
+ *  BIT 187-191:rserved
+ */
+static void _metainit_parse_item(struct ice_hw *hw, u16 idx, void *item,
+void *data, int size)
+{
+   struct ice_metainit_item *mi = (struct ice_metainit_item *)item;
+   u8 *buf = (u8 *)data;
+   u64 d64;
+
+   mi->idx = idx;
+   d64 = *(u64 *)buf;
+
+   mi->tsr = (u8)(d64 & 0xff);
+   mi->ho = (u16)((d64 >> 8) & 0x1ff);
+   mi->pc = (u16)((d64 >> 17) & 0xff);
+   mi->pg_rn = (u16)((d64 >> 25) & 0x3ff);
+   mi->cd = (u16)((d64 >> 36) & 0x7);
+   mi->gpr_a_ctrl = ((d64 >> 39) & 0x1) != 0;
+   mi->gpr_a_data_mdid = (u8)((d64 >

[dpdk-dev] [PATCH 04/20] net/ice/base: init parse graph cam table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_CAM or ICE_SID_RXPARSER_PG_SPILL
into an array of struct ice_pg_cam_item.
Parse DDP section ICE_SID_RXPARSER_NOMATCH_CAM or
ICE_SID_RXPARSER_NOMATCH_SPILL into an array of struct ice_pg_nm_cam_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser.c |  44 +
 drivers/net/ice/base/ice_parser.h |  12 ++
 drivers/net/ice/base/ice_pg_cam.c | 298 ++
 drivers/net/ice/base/ice_pg_cam.h |  68 +++
 drivers/net/ice/base/meson.build  |   1 +
 5 files changed, 423 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_pg_cam.c
 create mode 100644 drivers/net/ice/base/ice_pg_cam.h

diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index c12301727d..4c72e32fae 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -8,6 +8,10 @@
 #define ICE_SEC_DATA_OFFSET4
 #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE   48
 #define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE  24
+#define ICE_SID_RXPARSER_CAM_ENTRY_SIZE16
+#define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE   17
+#define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE12
+#define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE  13
 
 /**
  * ice_parser_sect_item_get - parse a item from a section
@@ -33,6 +37,18 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
case ICE_SID_RXPARSER_METADATA_INIT:
size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
break;
+   case ICE_SID_RXPARSER_CAM:
+   size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
+   break;
+   case ICE_SID_RXPARSER_PG_SPILL:
+   size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
+   break;
+   case ICE_SID_RXPARSER_NOMATCH_CAM:
+   size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
+   break;
+   case ICE_SID_RXPARSER_NOMATCH_SPILL:
+   size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
+   break;
default:
return NULL;
}
@@ -125,6 +141,30 @@ enum ice_status ice_parser_create(struct ice_hw *hw, 
struct ice_parser **psr)
goto err;
}
 
+   p->pg_cam_table = ice_pg_cam_table_get(hw);
+   if (!p->pg_cam_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
+   p->pg_sp_cam_table = ice_pg_sp_cam_table_get(hw);
+   if (!p->pg_sp_cam_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
+   p->pg_nm_cam_table = ice_pg_nm_cam_table_get(hw);
+   if (!p->pg_nm_cam_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
+   p->pg_nm_sp_cam_table = ice_pg_nm_sp_cam_table_get(hw);
+   if (!p->pg_nm_sp_cam_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
*psr = p;
return ICE_SUCCESS;
 err:
@@ -140,6 +180,10 @@ void ice_parser_destroy(struct ice_parser *psr)
 {
ice_free(psr->hw, psr->imem_table);
ice_free(psr->hw, psr->mi_table);
+   ice_free(psr->hw, psr->pg_cam_table);
+   ice_free(psr->hw, psr->pg_sp_cam_table);
+   ice_free(psr->hw, psr->pg_nm_cam_table);
+   ice_free(psr->hw, psr->pg_nm_sp_cam_table);
 
ice_free(psr->hw, psr);
 }
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index c06f19daa1..83246e49b3 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -5,6 +5,10 @@
 #ifndef _ICE_PARSER_H_
 #define _ICE_PARSRR_H_
 
+#include "ice_metainit.h"
+#include "ice_imem.h"
+#include "ice_pg_cam.h"
+
 struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
 
@@ -12,6 +16,14 @@ struct ice_parser {
struct ice_imem_item *imem_table;
/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
struct ice_metainit_item *mi_table;
+   /* load data from section ICE_SID_RXPARSER_CAM */
+   struct ice_pg_cam_item *pg_cam_table;
+   /* load data from section ICE_SID_RXPARSER_PG_SPILL */
+   struct ice_pg_cam_item *pg_sp_cam_table;
+   /* load data from section ICE_SID_RXPARSER_NOMATCH_CAM */
+   struct ice_pg_nm_cam_item *pg_nm_cam_table;
+   /* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL */
+   struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
 };
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
diff --git a/drivers/net/ice/base/ice_pg_cam.c 
b/drivers/net/ice/base/ice_pg_cam.c
new file mode 100644
index 00..171986bf3d
--- /dev/null
+++ b/drivers/net/ice/base/ice_pg_cam.c
@@ -0,0 +1,298 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _pg_cam_key_dump(struct ice_hw *hw, struct ice_

[dpdk-dev] [PATCH 05/20] net/ice/base: init boost TCAM table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_CAM into an array of
ice_bst_tcam_item.
Parse DDP section ICE_SID_LBL_RXPARSER_TMEM into an array of
ice_lbl_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_bst_tcam.c| 241 +
 drivers/net/ice/base/ice_bst_tcam.h|  28 +++
 drivers/net/ice/base/ice_imem.c|   2 +-
 drivers/net/ice/base/ice_metainit.c|   2 +-
 drivers/net/ice/base/ice_parser.c  |  48 -
 drivers/net/ice/base/ice_parser.h  |   5 +
 drivers/net/ice/base/ice_parser_util.h |  12 +-
 drivers/net/ice/base/ice_pg_cam.c  |   8 +-
 drivers/net/ice/base/meson.build   |   1 +
 9 files changed, 337 insertions(+), 10 deletions(-)
 create mode 100644 drivers/net/ice/base/ice_bst_tcam.c
 create mode 100644 drivers/net/ice/base/ice_bst_tcam.h

diff --git a/drivers/net/ice/base/ice_bst_tcam.c 
b/drivers/net/ice/base/ice_bst_tcam.c
new file mode 100644
index 00..1c82359681
--- /dev/null
+++ b/drivers/net/ice/base/ice_bst_tcam.c
@@ -0,0 +1,241 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_BST_TCAM_TABLE_SIZE 256
+
+static void _bst_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
+{
+   ice_info(hw, "next proto key builder:\n");
+   ice_info(hw, "\tops = %d\n", kb->ops);
+   ice_info(hw, "\tstart_or_reg0 = %d\n", kb->start_or_reg0);
+   ice_info(hw, "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
+}
+
+static void _bst_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
+{
+   ice_info(hw, "parse graph key builder:\n");
+   ice_info(hw, "\tflag0_ena = %d\n", kb->flag0_ena);
+   ice_info(hw, "\tflag1_ena = %d\n", kb->flag1_ena);
+   ice_info(hw, "\tflag2_ena = %d\n", kb->flag2_ena);
+   ice_info(hw, "\tflag3_ena = %d\n", kb->flag3_ena);
+   ice_info(hw, "\tflag0_idx = %d\n", kb->flag0_idx);
+   ice_info(hw, "\tflag1_idx = %d\n", kb->flag1_idx);
+   ice_info(hw, "\tflag2_idx = %d\n", kb->flag2_idx);
+   ice_info(hw, "\tflag3_idx = %d\n", kb->flag3_idx);
+   ice_info(hw, "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _bst_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
+{
+   ice_info(hw, "alu%d:\n", index);
+   ice_info(hw, "\topc = %d\n", alu->opc);
+   ice_info(hw, "\tsrc_start = %d\n", alu->src_start);
+   ice_info(hw, "\tsrc_len = %d\n", alu->src_len);
+   ice_info(hw, "\tshift_xlate_select = %d\n", alu->shift_xlate_select);
+   ice_info(hw, "\tshift_xlate_key = %d\n", alu->shift_xlate_key);
+   ice_info(hw, "\tsrc_reg_id = %d\n", alu->src_reg_id);
+   ice_info(hw, "\tdst_reg_id = %d\n", alu->dst_reg_id);
+   ice_info(hw, "\tinc0 = %d\n", alu->inc0);
+   ice_info(hw, "\tinc1 = %d\n", alu->inc1);
+   ice_info(hw, "\tproto_offset_opc = %d\n", alu->proto_offset_opc);
+   ice_info(hw, "\tproto_offset = %d\n", alu->proto_offset);
+   ice_info(hw, "\tbranch_addr = %d\n", alu->branch_addr);
+   ice_info(hw, "\timm = %d\n", alu->imm);
+   ice_info(hw, "\tdst_start = %d\n", alu->dst_start);
+   ice_info(hw, "\tdst_len = %d\n", alu->dst_len);
+   ice_info(hw, "\tflags_extr_imm = %d\n", alu->flags_extr_imm);
+   ice_info(hw, "\tflags_start_imm= %d\n", alu->flags_start_imm);
+}
+
+/**
+ * ice_bst_tcam_dump - dump a boost tcam info
+ * @ice_hw: pointer to the hardware structure
+ * @item: boost tcam to dump
+ */
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item)
+{
+   int i;
+
+   ice_info(hw, "address = %d\n", item->address);
+   ice_info(hw, "key:");
+   for (i = 0; i < 20; i++)
+   ice_info(hw, "%02x ", item->key[i]);
+   ice_info(hw, "\n");
+   ice_info(hw, "key_inv:");
+   for (i = 0; i < 20; i++)
+   ice_info(hw, "%02x ", item->key_inv[i]);
+   ice_info(hw, "\n");
+   ice_info(hw, "hit_idx_grp = %d\n", item->hit_idx_grp);
+   ice_info(hw, "pg_pri = %d\n", item->pg_pri);
+   _bst_np_kb_dump(hw, &item->np_kb);
+   _bst_pg_kb_dump(hw, &item->pg_kb);
+   _bst_alu_dump(hw, &item->alu0, 0);
+   _bst_alu_dump(hw, &item->alu1, 1);
+   _bst_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:   Opcode (alu->opc)
+ *  BIT 6-13:  Source Start (alu->src_start)
+ *  BIT 14-18: Source Length (alu->src_len)
+ *  BIT 19:Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23: Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30: Source Register ID (alu->src_reg_id)
+ *  BIT 31-37: Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:Inc0 (alu->inc0)
+ *  BIT 39:Inc1:(alu->inc1)
+ *  BIT 40:41  Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49  Protocol Offset (alu->proto_offset)
+ *  BIT 50:57  Branch Address (alu->branch_addr)
+ *  BIT 58:73  Immediate (alu->imm)
+ *  BIT 74 Dedicated 

[dpdk-dev] [PATCH 06/20] net/ice/base: init ptype marker TCAM table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_MARKER_PTYPE into an array of
ice_ptype_mk_tcam_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser.c   | 11 ++
 drivers/net/ice/base/ice_parser.h   |  3 ++
 drivers/net/ice/base/ice_ptype_mk.c | 54 +
 drivers/net/ice/base/ice_ptype_mk.h | 18 ++
 drivers/net/ice/base/meson.build|  1 +
 5 files changed, 87 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_ptype_mk.c
 create mode 100644 drivers/net/ice/base/ice_ptype_mk.h

diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index 3b5c5b7e48..7f6aa59c8f 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -13,6 +13,7 @@
 #define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE12
 #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE  13
 #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE 88
+#define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE24
 
 #define ICE_SEC_LBL_DATA_OFFSET2
 #define ICE_SID_LBL_ENTRY_SIZE 66
@@ -72,6 +73,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
data_off = ICE_SEC_LBL_DATA_OFFSET;
size = ICE_SID_LBL_ENTRY_SIZE;
break;
+   case ICE_SID_RXPARSER_MARKER_PTYPE:
+   size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
+   break;
default:
return NULL;
}
@@ -205,6 +209,12 @@ enum ice_status ice_parser_create(struct ice_hw *hw, 
struct ice_parser **psr)
goto err;
}
 
+   p->ptype_mk_tcam_table = ice_ptype_mk_tcam_table_get(hw);
+   if (!p->ptype_mk_tcam_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
*psr = p;
return ICE_SUCCESS;
 err:
@@ -226,6 +236,7 @@ void ice_parser_destroy(struct ice_parser *psr)
ice_free(psr->hw, psr->pg_nm_sp_cam_table);
ice_free(psr->hw, psr->bst_tcam_table);
ice_free(psr->hw, psr->bst_lbl_table);
+   ice_free(psr->hw, psr->ptype_mk_tcam_table);
 
ice_free(psr->hw, psr);
 }
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index a621d41ad0..eb9ea874ed 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -9,6 +9,7 @@
 #include "ice_imem.h"
 #include "ice_pg_cam.h"
 #include "ice_bst_tcam.h"
+#include "ice_ptype_mk.h"
 
 struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
@@ -29,6 +30,8 @@ struct ice_parser {
struct ice_bst_tcam_item *bst_tcam_table;
/* load data from section ICE_SID_LBL_RXPARSER_TMEM */
struct ice_lbl_item *bst_lbl_table;
+   /* load data from section ICE_SID_RXPARSER_MARKER_PTYPE */
+   struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table;
 };
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
diff --git a/drivers/net/ice/base/ice_ptype_mk.c 
b/drivers/net/ice/base/ice_ptype_mk.c
new file mode 100644
index 00..33623dcfbc
--- /dev/null
+++ b/drivers/net/ice/base/ice_ptype_mk.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_PTYPE_MK_TCAM_TABLE_SIZE 1024
+
+/**
+ * ice_ptype_mk_tcam_dump - dump an ptype marker tcam info_
+ * @ice_hw: pointer to the hardware structure
+ * @item: ptype marker tcam to dump
+ */
+void ice_ptype_mk_tcam_dump(struct ice_hw *hw,
+   struct ice_ptype_mk_tcam_item *item)
+{
+   int i;
+
+   ice_info(hw, "address = %d\n", item->address);
+   ice_info(hw, "ptype = %d\n", item->ptype);
+   ice_info(hw, "key:");
+   for (i = 0; i < 10; i++)
+   ice_info(hw, "%02x ", item->key[i]);
+   ice_info(hw, "\n");
+   ice_info(hw, "key_inv:");
+   for (i = 0; i < 10; i++)
+   ice_info(hw, "%02x ", item->key_inv[i]);
+   ice_info(hw, "\n");
+}
+
+static void _parse_ptype_mk_tcam_item(struct ice_hw *hw, u16 idx, void *item,
+ void *data, int size)
+{
+   ice_parse_item_dflt(hw, idx, item, data, size);
+
+   if (hw->debug_mask & ICE_DBG_PARSER)
+   ice_ptype_mk_tcam_dump(hw,
+  (struct ice_ptype_mk_tcam_item *)item);
+}
+
+/**
+ * ice_ptype_mk_tcam_table_get - create a ptype marker tcam table
+ * @ice_hw: pointer to the hardware structure
+ */
+struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw)
+{
+   return (struct ice_ptype_mk_tcam_item *)
+   ice_parser_create_table(hw, ICE_SID_RXPARSER_MARKER_PTYPE,
+   sizeof(struct ice_ptype_mk_tcam_item),
+   ICE_PTYPE_MK_TCAM_TABLE_SIZE,
+

[dpdk-dev] [PATCH 07/20] net/ice/base: init marker group table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_MARKER_GRP into an array of
ice_mk_grp_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_mk_grp.c | 55 +++
 drivers/net/ice/base/ice_mk_grp.h | 15 +
 drivers/net/ice/base/ice_parser.c | 11 +++
 drivers/net/ice/base/ice_parser.h |  3 ++
 drivers/net/ice/base/meson.build  |  1 +
 5 files changed, 85 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_mk_grp.c
 create mode 100644 drivers/net/ice/base/ice_mk_grp.h

diff --git a/drivers/net/ice/base/ice_mk_grp.c 
b/drivers/net/ice/base/ice_mk_grp.c
new file mode 100644
index 00..4e9ab5c13a
--- /dev/null
+++ b/drivers/net/ice/base/ice_mk_grp.c
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_MK_GRP_TABLE_SIZE 128
+#define ICE_MK_COUNT_PER_GRP 8
+
+/**
+ * ice_mk_grp_dump - dump an marker group item info
+ * @ice_hw: pointer to the hardware structure
+ * @item: marker group item to dump
+ */
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item *item)
+{
+   int i;
+
+   ice_info(hw, "index = %d\n", item->idx);
+   ice_info(hw, "markers: ");
+   for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+   ice_info(hw, "%d ", item->markers[i]);
+   ice_info(hw, "\n");
+}
+
+static void _mk_grp_parse_item(struct ice_hw *hw, u16 idx, void *item,
+  void *data, int size)
+{
+   struct ice_mk_grp_item *grp = (struct ice_mk_grp_item *)item;
+   u8 *buf = (u8 *)data;
+   int i;
+
+   grp->idx = idx;
+
+   for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+   grp->markers[i] = buf[i];
+
+   if (hw->debug_mask & ICE_DBG_PARSER)
+   ice_mk_grp_dump(hw, grp);
+}
+
+/**
+ * ice_mk_grp_table_get - create a marker group table
+ * @ice_hw: pointer to the hardware structure
+ */
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw)
+{
+   return (struct ice_mk_grp_item *)
+   ice_parser_create_table(hw, ICE_SID_RXPARSER_MARKER_GRP,
+   sizeof(struct ice_mk_grp_item),
+   ICE_MK_GRP_TABLE_SIZE,
+   ice_parser_sect_item_get,
+   _mk_grp_parse_item, false);
+}
diff --git a/drivers/net/ice/base/ice_mk_grp.h 
b/drivers/net/ice/base/ice_mk_grp.h
new file mode 100644
index 00..04d11b49c2
--- /dev/null
+++ b/drivers/net/ice/base/ice_mk_grp.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_MK_GRP_H_
+#define _ICE_MK_GRP_H_
+
+struct ice_mk_grp_item {
+   int idx;
+   u8 markers[8];
+};
+
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item *item);
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw);
+#endif /* _ICE_MK_GRP_H_ */
diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index 7f6aa59c8f..ed624d613a 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -14,6 +14,7 @@
 #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE  13
 #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE 88
 #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE24
+#define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE 8
 
 #define ICE_SEC_LBL_DATA_OFFSET2
 #define ICE_SID_LBL_ENTRY_SIZE 66
@@ -76,6 +77,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
case ICE_SID_RXPARSER_MARKER_PTYPE:
size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
break;
+   case ICE_SID_RXPARSER_MARKER_GRP:
+   size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
+   break;
default:
return NULL;
}
@@ -215,6 +219,12 @@ enum ice_status ice_parser_create(struct ice_hw *hw, 
struct ice_parser **psr)
goto err;
}
 
+   p->mk_grp_table = ice_mk_grp_table_get(hw);
+   if (!p->mk_grp_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
*psr = p;
return ICE_SUCCESS;
 err:
@@ -237,6 +247,7 @@ void ice_parser_destroy(struct ice_parser *psr)
ice_free(psr->hw, psr->bst_tcam_table);
ice_free(psr->hw, psr->bst_lbl_table);
ice_free(psr->hw, psr->ptype_mk_tcam_table);
+   ice_free(psr->hw, psr->mk_grp_table);
 
ice_free(psr->hw, psr);
 }
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index eb9ea874ed..4f224039c9 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -10,6 +10,7 @@
 #include "ice_pg_cam.h"
 #include "ice_bst_tcam.h"
 #include "ice_ptype_mk.h"
+#include "ice_mk_grp.h"
 
 struct ice_parser {
struc

[dpdk-dev] [PATCH 08/20] net/ice/base: init protocol group table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_PROTO_GRP into an array of
ice_proto_grp_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser.c|  11 +++
 drivers/net/ice/base/ice_parser.h|   3 +
 drivers/net/ice/base/ice_proto_grp.c | 108 +++
 drivers/net/ice/base/ice_proto_grp.h |  23 ++
 drivers/net/ice/base/meson.build |   1 +
 5 files changed, 146 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_proto_grp.c
 create mode 100644 drivers/net/ice/base/ice_proto_grp.h

diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index ed624d613a..a4ca7dd545 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -15,6 +15,7 @@
 #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE 88
 #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE24
 #define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE 8
+#define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE  24
 
 #define ICE_SEC_LBL_DATA_OFFSET2
 #define ICE_SID_LBL_ENTRY_SIZE 66
@@ -80,6 +81,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
case ICE_SID_RXPARSER_MARKER_GRP:
size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
break;
+   case ICE_SID_RXPARSER_PROTO_GRP:
+   size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
+   break;
default:
return NULL;
}
@@ -225,6 +229,12 @@ enum ice_status ice_parser_create(struct ice_hw *hw, 
struct ice_parser **psr)
goto err;
}
 
+   p->proto_grp_table = ice_proto_grp_table_get(hw);
+   if (!p->proto_grp_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
*psr = p;
return ICE_SUCCESS;
 err:
@@ -248,6 +258,7 @@ void ice_parser_destroy(struct ice_parser *psr)
ice_free(psr->hw, psr->bst_lbl_table);
ice_free(psr->hw, psr->ptype_mk_tcam_table);
ice_free(psr->hw, psr->mk_grp_table);
+   ice_free(psr->hw, psr->proto_grp_table);
 
ice_free(psr->hw, psr);
 }
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index 4f224039c9..20e59451a5 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -11,6 +11,7 @@
 #include "ice_bst_tcam.h"
 #include "ice_ptype_mk.h"
 #include "ice_mk_grp.h"
+#include "ice_proto_grp.h"
 
 struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
@@ -35,6 +36,8 @@ struct ice_parser {
struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table;
/* load data from section ICE_SID_RXPARSER_MARKER_GRP */
struct ice_mk_grp_item *mk_grp_table;
+   /* load data from section ICE_SID_RXPARSER_PROTO_GRP */
+   struct ice_proto_grp_item *proto_grp_table;
 };
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
diff --git a/drivers/net/ice/base/ice_proto_grp.c 
b/drivers/net/ice/base/ice_proto_grp.c
new file mode 100644
index 00..69d5d9a18a
--- /dev/null
+++ b/drivers/net/ice/base/ice_proto_grp.c
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_PROTO_GRP_TABLE_SIZE 192
+
+static void _proto_off_dump(struct ice_hw *hw, struct ice_proto_off *po,
+   int idx)
+{
+   ice_info(hw, "proto %d\n", idx);
+   ice_info(hw, "\tpolarity = %d\n", po->polarity);
+   ice_info(hw, "\tproto_id = %d\n", po->proto_id);
+   ice_info(hw, "\toffset = %d\n", po->offset);
+}
+
+/**
+ * ice_proto_grp_dump - dump a proto group item info
+ * @ice_hw: pointer to the hardware structure
+ * @item: proto group item to dump
+ */
+void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item)
+{
+   int i;
+
+   ice_info(hw, "index = %d\n", item->idx);
+
+   for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++)
+   _proto_off_dump(hw, &item->po[i], i);
+}
+
+/** The function parses a 22 bits Protocol entry with below format:
+ *  BIT 0: Polarity of Protocol Offset (po->polarity)
+ *  BIT 1-8:   Protocol ID (po->proto_id)
+ *  BIT 9-11:  reserved
+ *  BIT 12-21: Protocol Offset (po->offset)
+ */
+static void _proto_off_parse(struct ice_proto_off *po, u32 data)
+{
+   po->polarity = (data & 0x1) != 0;
+   po->proto_id = (u8)((data >> 1) & 0xff);
+   po->offset = (u16)((data >> 12) & 0x3ff);
+}
+
+/** The function parses a 192 bits Protocol Group Table entry with below
+ *  format:
+ *  BIT 0-21:  Protocol 0 (grp->po[0])
+ *  BIT 22-43: Protocol 1 (grp->po[1])
+ *  BIT 44-65: Protocol 2 (grp->po[2])
+ *  BIT 66-87: Protocol 3 (grp->po[3])
+ *  BIT 88-109:Protocol 4 (grp->po[4])
+ *  BIT 110-131:Protocol 5 (grp->po[5])
+ *  BIT 132-153:Protocol 6 (grp->po[6])
+ *  BIT 154-175:Protocol 7 (g

[dpdk-dev] [PATCH 09/20] net/ice/base: init flag redirect table for parser

2021-09-17 Thread Qi Zhang
Parse DDP section ICE_SID_RXPARSER_FLAG_REDIR into an array of
ice_flag_rd_item.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_flex_type.h |  2 ++
 drivers/net/ice/base/ice_flg_rd.c| 53 
 drivers/net/ice/base/ice_flg_rd.h| 16 +
 drivers/net/ice/base/ice_parser.c| 11 ++
 drivers/net/ice/base/ice_parser.h|  3 ++
 drivers/net/ice/base/meson.build |  1 +
 6 files changed, 86 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_flg_rd.c
 create mode 100644 drivers/net/ice/base/ice_flg_rd.h

diff --git a/drivers/net/ice/base/ice_flex_type.h 
b/drivers/net/ice/base/ice_flex_type.h
index 3f2038c931..59eeca0a30 100644
--- a/drivers/net/ice/base/ice_flex_type.h
+++ b/drivers/net/ice/base/ice_flex_type.h
@@ -198,6 +198,8 @@ struct ice_buf_hdr {
 #define ICE_SID_CDID_KEY_BUILDER_PE87
 #define ICE_SID_CDID_REDIR_PE  88
 
+#define ICE_SID_RXPARSER_FLAG_REDIR97
+
 /* Label Metadata section IDs */
 #define ICE_SID_LBL_FIRST  0x8010
 #define ICE_SID_LBL_RXPARSER_IMEM  0x8010
diff --git a/drivers/net/ice/base/ice_flg_rd.c 
b/drivers/net/ice/base/ice_flg_rd.c
new file mode 100644
index 00..292916d9a8
--- /dev/null
+++ b/drivers/net/ice/base/ice_flg_rd.c
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_FLG_RD_TABLE_SIZE 64
+
+/**
+ * ice_flg_rd_dump - dump a flag redirect item info
+ * @ice_hw: pointer to the hardware structure
+ * @item: flag redirect item to dump
+ */
+void ice_flg_rd_dump(struct ice_hw *hw, struct ice_flg_rd_item *item)
+{
+   ice_info(hw, "index = %d\n", item->idx);
+   ice_info(hw, "expose = %d\n", item->expose);
+   ice_info(hw, "intr_flg_id = %d\n", item->intr_flg_id);
+}
+
+/** The function parses a 8 bits Flag Redirect Table entry with below format:
+ *  BIT 0: Expose (rdi->expose)
+ *  BIT 1-6:   Internal Flag ID (rdi->intr_flg_id)
+ *  BIT 7: reserved
+ */
+static void _flg_rd_parse_item(struct ice_hw *hw, u16 idx, void *item,
+  void *data, int size)
+{
+   struct ice_flg_rd_item *rdi = (struct ice_flg_rd_item *)item;
+   u8 d8 = *(u8 *)data;
+
+   rdi->idx = idx;
+   rdi->expose = (d8 & 0x1) != 0;
+   rdi->intr_flg_id = (u8)((d8 >> 1) & 0x3f);
+
+   if (hw->debug_mask & ICE_DBG_PARSER)
+   ice_flg_rd_dump(hw, rdi);
+}
+
+/**
+ * ice_flg_rd_table_get - create a flag redirect table
+ * @ice_hw: pointer to the hardware structure
+ */
+struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw)
+{
+   return (struct ice_flg_rd_item *)
+   ice_parser_create_table(hw, ICE_SID_RXPARSER_FLAG_REDIR,
+   sizeof(struct ice_flg_rd_item),
+   ICE_FLG_RD_TABLE_SIZE,
+   ice_parser_sect_item_get,
+   _flg_rd_parse_item, false);
+}
diff --git a/drivers/net/ice/base/ice_flg_rd.h 
b/drivers/net/ice/base/ice_flg_rd.h
new file mode 100644
index 00..e65350f18c
--- /dev/null
+++ b/drivers/net/ice/base/ice_flg_rd.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_FLG_RD_H_
+#define _ICE_FLG_RD_H_
+
+struct ice_flg_rd_item {
+   u16 idx;
+   bool expose;
+   u8 intr_flg_id;
+};
+
+void ice_flg_rd_dump(struct ice_hw *hw, struct ice_flg_rd_item *item);
+struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw);
+#endif /* _ICE_FLG_RD_H_ */
diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index a4ca7dd545..437dc5b8f8 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -16,6 +16,7 @@
 #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE24
 #define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE 8
 #define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE  24
+#define ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE 1
 
 #define ICE_SEC_LBL_DATA_OFFSET2
 #define ICE_SID_LBL_ENTRY_SIZE 66
@@ -84,6 +85,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
case ICE_SID_RXPARSER_PROTO_GRP:
size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
break;
+   case ICE_SID_RXPARSER_FLAG_REDIR:
+   size = ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE;
+   break;
default:
return NULL;
}
@@ -235,6 +239,12 @@ enum ice_status ice_parser_create(struct ice_hw *hw, 
struct ice_parser **psr)
goto err;
}
 
+   p->flg_rd_table = ice_flg_rd_table_get(hw);
+   if (!p->flg_rd_table) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
*psr = p;
return ICE_

[dpdk-dev] [PATCH 10/20] net/ice/base: init XLT key builder for parser

2021-09-17 Thread Qi Zhang
Parse below DDP section into struct ice_xlt_kb:
ICE_SID_XLT_KEY_BUILDER_SW
ICE_SID_XLT_KEY_BUILDER_FD
ICE_SID_XLT_KEY_BUILDER_RSS

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_flex_pipe.c |   2 +-
 drivers/net/ice/base/ice_flex_pipe.h |   3 +
 drivers/net/ice/base/ice_parser.c|  28 
 drivers/net/ice/base/ice_parser.h|   9 ++
 drivers/net/ice/base/ice_xlt_kb.c| 189 +++
 drivers/net/ice/base/ice_xlt_kb.h|  33 +
 drivers/net/ice/base/meson.build |   1 +
 7 files changed, 264 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ice/base/ice_xlt_kb.c
 create mode 100644 drivers/net/ice/base/ice_xlt_kb.h

diff --git a/drivers/net/ice/base/ice_flex_pipe.c 
b/drivers/net/ice/base/ice_flex_pipe.c
index 703c3e0416..f35d59f4f5 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -218,7 +218,7 @@ ice_pkg_advance_sect(struct ice_seg *ice_seg, struct 
ice_pkg_enum *state)
  * When the function returns a NULL pointer, then the end of the matching
  * sections has been reached.
  */
-static void *
+void *
 ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
 u32 sect_type)
 {
diff --git a/drivers/net/ice/base/ice_flex_pipe.h 
b/drivers/net/ice/base/ice_flex_pipe.h
index 045a77c607..9733c4b214 100644
--- a/drivers/net/ice/base/ice_flex_pipe.h
+++ b/drivers/net/ice/base/ice_flex_pipe.h
@@ -99,4 +99,7 @@ ice_pkg_enum_entry(struct ice_seg *ice_seg, struct 
ice_pkg_enum *state,
   u32 sect_type, u32 *offset,
   void *(*handler)(u32 sect_type, void *section,
u32 index, u32 *offset));
+void *
+ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
+u32 sect_type);
 #endif /* _ICE_FLEX_PIPE_H_ */
diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index 437dc5b8f8..0b79b62e04 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -245,6 +245,30 @@ enum ice_status ice_parser_create(struct ice_hw *hw, 
struct ice_parser **psr)
goto err;
}
 
+   p->xlt_kb_sw = ice_xlt_kb_get_sw(hw);
+   if (!p->xlt_kb_sw) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
+   p->xlt_kb_acl = ice_xlt_kb_get_acl(hw);
+   if (!p->xlt_kb_acl) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
+   p->xlt_kb_fd = ice_xlt_kb_get_fd(hw);
+   if (!p->xlt_kb_fd) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
+   p->xlt_kb_rss = ice_xlt_kb_get_rss(hw);
+   if (!p->xlt_kb_rss) {
+   status = ICE_ERR_PARAM;
+   goto err;
+   }
+
*psr = p;
return ICE_SUCCESS;
 err:
@@ -270,6 +294,10 @@ void ice_parser_destroy(struct ice_parser *psr)
ice_free(psr->hw, psr->mk_grp_table);
ice_free(psr->hw, psr->proto_grp_table);
ice_free(psr->hw, psr->flg_rd_table);
+   ice_free(psr->hw, psr->xlt_kb_sw);
+   ice_free(psr->hw, psr->xlt_kb_acl);
+   ice_free(psr->hw, psr->xlt_kb_fd);
+   ice_free(psr->hw, psr->xlt_kb_rss);
 
ice_free(psr->hw, psr);
 }
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index f7c3c1a318..89cd714fbd 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -13,6 +13,7 @@
 #include "ice_mk_grp.h"
 #include "ice_proto_grp.h"
 #include "ice_flg_rd.h"
+#include "ice_xlt_kb.h"
 
 struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
@@ -41,6 +42,14 @@ struct ice_parser {
struct ice_proto_grp_item *proto_grp_table;
/* load data from section ICE_SID_RXPARSER_FLAG_REDIR */
struct ice_flg_rd_item *flg_rd_table;
+   /* load data from section ICE_SID_XLT_KEY_BUILDER_SW */
+   struct ice_xlt_kb *xlt_kb_sw;
+   /* load data from section ICE_SID_XLT_KEY_BUILDER_ACL */
+   struct ice_xlt_kb *xlt_kb_acl;
+   /* load data from section ICE_SID_XLT_KEY_BUILDER_FD */
+   struct ice_xlt_kb *xlt_kb_fd;
+   /* load data from section ICE_SID_XLT_KEY_BUILDER_RSS */
+   struct ice_xlt_kb *xlt_kb_rss;
 };
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
diff --git a/drivers/net/ice/base/ice_xlt_kb.c 
b/drivers/net/ice/base/ice_xlt_kb.c
new file mode 100644
index 00..8b4043a836
--- /dev/null
+++ b/drivers/net/ice/base/ice_xlt_kb.c
@@ -0,0 +1,189 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+
+#define ICE_XLT_KB_TBL_OFF 12
+#define ICE_XLT_KB_TBL_ENTRY_SIZE 24
+
+static void _xlt_kb_entry_dump(struct ice_hw *hw,
+  struct ice_xlt_kb_entry *entry, int idx)
+{
+   int i;
+
+   ice_info(hw, "key builder entry %d\n", idx);
+  

[dpdk-dev] [PATCH 11/20] net/ice/base: add parser runtime skeleton

2021-09-17 Thread Qi Zhang
Add parser runtime data struct ice_parser_rt.

Add below APIs for parser runtime preparation:
ice_parser_rt_reset
ice_parser_rt_pkt_buf_set

Add below API skeleton for parser runtime execution:
ice_parser_rt_execute

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser.c| 39 +++
 drivers/net/ice/base/ice_parser.h| 24 +++
 drivers/net/ice/base/ice_parser_rt.c | 98 
 drivers/net/ice/base/ice_parser_rt.h | 28 
 drivers/net/ice/base/meson.build |  1 +
 5 files changed, 190 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_parser_rt.c
 create mode 100644 drivers/net/ice/base/ice_parser_rt.h

diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index 0b79b62e04..a0c5c9989d 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -167,6 +167,8 @@ enum ice_status ice_parser_create(struct ice_hw *hw, struct 
ice_parser **psr)
struct ice_parser *p;
 
p = (struct ice_parser *)ice_malloc(hw, sizeof(struct ice_parser));
+   p->hw = hw;
+   p->rt.psr = p;
 
if (!p)
return ICE_ERR_NO_MEMORY;
@@ -301,3 +303,40 @@ void ice_parser_destroy(struct ice_parser *psr)
 
ice_free(psr->hw, psr);
 }
+
+/**
+ * ice_parser_run - parse on a packet in binary and return the result
+ * @psr: pointer to a parser instance
+ * @pkt_buf: packet data
+ * @pkt_len: packet length
+ * @rslt: input/output parameter to save parser result.
+ */
+enum ice_status ice_parser_run(struct ice_parser *psr, const u8 *pkt_buf,
+  int pkt_len, struct ice_parser_result *rslt)
+{
+   ice_parser_rt_reset(&psr->rt);
+   ice_parser_rt_pktbuf_set(&psr->rt, pkt_buf, pkt_len);
+
+   return ice_parser_rt_execute(&psr->rt, rslt);
+}
+
+/**
+ * ice_parser_result_dump - dump a parser result info
+ * @hw: pointer to the hardware structure
+ * @rslt: parser result info to dump
+ */
+void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
+{
+   int i;
+
+   ice_info(hw, "ptype = %d\n", rslt->ptype);
+   for (i = 0; i < rslt->po_num; i++)
+   ice_info(hw, "proto = %d, offset = %d\n",
+rslt->po[i].proto_id, rslt->po[i].offset);
+
+   ice_info(hw, "flags_psr = 0x%016" PRIx64 "\n", rslt->flags_psr);
+   ice_info(hw, "flags_pkt = 0x%016" PRIx64 "\n", rslt->flags_pkt);
+   ice_info(hw, "flags_sw = 0x%04x\n", rslt->flags_sw);
+   ice_info(hw, "flags_fd = 0x%04x\n", rslt->flags_fd);
+   ice_info(hw, "flags_rss = 0x%04x\n", rslt->flags_rss);
+}
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index 89cd714fbd..3a307e0344 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -14,6 +14,7 @@
 #include "ice_proto_grp.h"
 #include "ice_flg_rd.h"
 #include "ice_xlt_kb.h"
+#include "ice_parser_rt.h"
 
 struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
@@ -50,8 +51,31 @@ struct ice_parser {
struct ice_xlt_kb *xlt_kb_fd;
/* load data from section ICE_SID_XLT_KEY_BUILDER_RSS */
struct ice_xlt_kb *xlt_kb_rss;
+   struct ice_parser_rt rt; /* parser runtime */
 };
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
 void ice_parser_destroy(struct ice_parser *psr);
+
+struct ice_parser_proto_off {
+   u8 proto_id; /* hardware protocol ID */
+   u16 offset;  /* offset where the  protocol header start */
+};
+
+struct ice_parser_result {
+   u16 ptype; /* 16 bits hardware PTYPE */
+   /* protocol and header offset pairs */
+   struct ice_parser_proto_off po[16];
+   int po_num; /* number of pairs must <= 16 */
+   u64 flags_psr; /* 64 bits parser flags */
+   u64 flags_pkt; /* 64 bits packet flags */
+   u16 flags_sw; /* 16 bits key builder flag for SW */
+   u16 flags_acl; /* 16 bits key builder flag for ACL */
+   u16 flags_fd; /* 16 bits key builder flag for FD */
+   u16 flags_rss; /* 16 bits key builder flag for RSS */
+};
+
+enum ice_status ice_parser_run(struct ice_parser *psr, const u8 *pkt_buf,
+  int pkt_len, struct ice_parser_result *rslt);
+void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt);
 #endif /* _ICE_PARSER_H_ */
diff --git a/drivers/net/ice/base/ice_parser_rt.c 
b/drivers/net/ice/base/ice_parser_rt.c
new file mode 100644
index 00..d62d0170e5
--- /dev/null
+++ b/drivers/net/ice/base/ice_parser_rt.c
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+
+#define GPR_HB_IDX 64
+#define GPR_ERR_IDX84
+#define GPR_FLG_IDX104
+#define GPR_TSR_IDX108
+#define GPR_NN_IDX 109
+#define GPR_HO_IDX 110
+#define GPR_NP_IDX 111
+
+static void _rt_tsr_set(struct ice_parser_rt *rt, u16 tsr

[dpdk-dev] [PATCH 12/20] net/ice/base: add helper function for boost TCAM match

2021-09-17 Thread Qi Zhang
Add internal helper function ice_bst_tcam_match to perform ternary
match on boost TCAM.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_bst_tcam.c | 22 +++
 drivers/net/ice/base/ice_bst_tcam.h |  3 ++
 drivers/net/ice/base/ice_parser.h   |  1 +
 drivers/net/ice/base/ice_tmatch.h   | 44 +
 4 files changed, 70 insertions(+)
 create mode 100644 drivers/net/ice/base/ice_tmatch.h

diff --git a/drivers/net/ice/base/ice_bst_tcam.c 
b/drivers/net/ice/base/ice_bst_tcam.c
index 1c82359681..76b3a5c551 100644
--- a/drivers/net/ice/base/ice_bst_tcam.c
+++ b/drivers/net/ice/base/ice_bst_tcam.c
@@ -239,3 +239,25 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw 
*hw)
ice_parser_sect_item_get,
_parse_lbl_item, true);
 }
+
+/**
+ * ice_bst_tcam_match - match a pattern on the boost tcam table
+ * @tcam_table: boost tcam table to search
+ * @pat: pattern to match
+ */
+struct ice_bst_tcam_item *
+ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
+{
+   int i;
+
+   for (i = 0; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+   struct ice_bst_tcam_item *item = &tcam_table[i];
+
+   if (item->hit_idx_grp == 0)
+   continue;
+   if (ice_ternary_match(item->key, item->key_inv, pat, 20))
+   return item;
+   }
+
+   return NULL;
+}
diff --git a/drivers/net/ice/base/ice_bst_tcam.h 
b/drivers/net/ice/base/ice_bst_tcam.h
index a4ab40721f..3cba0bbf55 100644
--- a/drivers/net/ice/base/ice_bst_tcam.h
+++ b/drivers/net/ice/base/ice_bst_tcam.h
@@ -25,4 +25,7 @@ void ice_bst_tcam_dump(struct ice_hw *hw, struct 
ice_bst_tcam_item *item);
 struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw);
 
 struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
 #endif /*_ICE_BST_TCAM_H_ */
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index 3a307e0344..b2ab21728e 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -15,6 +15,7 @@
 #include "ice_flg_rd.h"
 #include "ice_xlt_kb.h"
 #include "ice_parser_rt.h"
+#include "ice_tmatch.h"
 
 struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
diff --git a/drivers/net/ice/base/ice_tmatch.h 
b/drivers/net/ice/base/ice_tmatch.h
new file mode 100644
index 00..178a084639
--- /dev/null
+++ b/drivers/net/ice/base/ice_tmatch.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_TMATCH_H_
+#define _ICE_TMATCH_H_
+
+static inline
+bool ice_ternary_match_byte(u8 key, u8 key_inv, u8 pat)
+{
+   u8 k1, k2, v;
+   int i;
+
+   for (i = 0; i < 8; i++) {
+   k1 = (u8)(key & (1 << i));
+   k2 = (u8)(key_inv & (1 << i));
+   v = (u8)(pat & (1 << i));
+
+   if (k1 != 0 && k2 != 0)
+   continue;
+   if (k1 == 0 && k2 == 0)
+   return false;
+
+   if (k1 == v)
+   return false;
+   }
+
+   return true;
+}
+
+static inline
+bool ice_ternary_match(const u8 *key, const u8 *key_inv,
+  const u8 *pat, int len)
+{
+   int i;
+
+   for (i = 0; i < len; i++)
+   if (!ice_ternary_match_byte(key[i], key_inv[i], pat[i]))
+   return false;
+
+   return true;
+}
+
+#endif /* _ICE_TMATCH_H_ */
-- 
2.26.2



[dpdk-dev] [PATCH 13/20] net/ice/base: add helper functions for parse graph key matching

2021-09-17 Thread Qi Zhang
Add below two internal helper functions for parse graph key matching
in cam table:

ice_pg_cam_match
ice_pg_nm_cam_match

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_pg_cam.c | 76 +++
 drivers/net/ice/base/ice_pg_cam.h |  6 +++
 2 files changed, 82 insertions(+)

diff --git a/drivers/net/ice/base/ice_pg_cam.c 
b/drivers/net/ice/base/ice_pg_cam.c
index 03484d6a91..fe461ad849 100644
--- a/drivers/net/ice/base/ice_pg_cam.c
+++ b/drivers/net/ice/base/ice_pg_cam.c
@@ -296,3 +296,79 @@ struct ice_pg_nm_cam_item 
*ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)
ice_parser_sect_item_get,
_pg_nm_sp_cam_parse_item, false);
 }
+
+static bool _pg_cam_match(struct ice_pg_cam_item *item,
+ struct ice_pg_cam_key *key)
+{
+   if (!item->key.valid ||
+   item->key.node_id != key->node_id ||
+   item->key.flag0 != key->flag0 ||
+   item->key.flag1 != key->flag1 ||
+   item->key.flag2 != key->flag2 ||
+   item->key.flag3 != key->flag3 ||
+   item->key.boost_idx != key->boost_idx ||
+   item->key.alu_reg != key->alu_reg ||
+   item->key.next_proto != key->next_proto)
+   return false;
+
+   return true;
+}
+
+static bool _pg_nm_cam_match(struct ice_pg_nm_cam_item *item,
+struct ice_pg_cam_key *key)
+{
+   if (!item->key.valid ||
+   item->key.node_id != key->node_id ||
+   item->key.flag0 != key->flag0 ||
+   item->key.flag1 != key->flag1 ||
+   item->key.flag2 != key->flag2 ||
+   item->key.flag3 != key->flag3 ||
+   item->key.boost_idx != key->boost_idx ||
+   item->key.alu_reg != key->alu_reg)
+   return false;
+
+   return true;
+}
+
+/**
+ * ice_pg_cam_match - search parse graph cam table by key
+ * @table: parse graph cam table to search
+ * @size: cam table size
+ * @key: search key
+ */
+struct ice_pg_cam_item *ice_pg_cam_match(struct ice_pg_cam_item *table,
+int size, struct ice_pg_cam_key *key)
+{
+   int i;
+
+   for (i = 0; i < size; i++) {
+   struct ice_pg_cam_item *item = &table[i];
+
+   if (_pg_cam_match(item, key))
+   return item;
+   }
+
+   return NULL;
+}
+
+/**
+ * ice_pg_nm_cam_match - search parse graph no match cam table by key
+ * @table: parse graph no match cam table to search
+ * @size: cam table size
+ * @key: search key
+ */
+struct ice_pg_nm_cam_item *
+ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,
+   struct ice_pg_cam_key *key)
+{
+   int i;
+
+   for (i = 0; i < size; i++) {
+   struct ice_pg_nm_cam_item *item = &table[i];
+
+   if (_pg_nm_cam_match(item, key))
+   return item;
+   }
+
+   return NULL;
+}
diff --git a/drivers/net/ice/base/ice_pg_cam.h 
b/drivers/net/ice/base/ice_pg_cam.h
index fcb2e11e54..aeadc20a77 100644
--- a/drivers/net/ice/base/ice_pg_cam.h
+++ b/drivers/net/ice/base/ice_pg_cam.h
@@ -65,4 +65,10 @@ struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct 
ice_hw *hw);
 
 struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw);
 struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw);
+
+struct ice_pg_cam_item *ice_pg_cam_match(struct ice_pg_cam_item *table,
+int size, struct ice_pg_cam_key *key);
+struct ice_pg_nm_cam_item *
+ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,
+   struct ice_pg_cam_key *key);
 #endif /* _ICE_PG_CAM_H_ */
-- 
2.26.2



[dpdk-dev] [PATCH 14/20] net/ice/base: add helper function for ptype markers match

2021-09-17 Thread Qi Zhang
Add internal helper function ice_ptype_mk_tcam_match for ptype markers
matching in tcam table.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_ptype_mk.c | 22 ++
 drivers/net/ice/base/ice_ptype_mk.h |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/drivers/net/ice/base/ice_ptype_mk.c 
b/drivers/net/ice/base/ice_ptype_mk.c
index 33623dcfbc..97c41cb586 100644
--- a/drivers/net/ice/base/ice_ptype_mk.c
+++ b/drivers/net/ice/base/ice_ptype_mk.c
@@ -52,3 +52,25 @@ struct ice_ptype_mk_tcam_item 
*ice_ptype_mk_tcam_table_get(struct ice_hw *hw)
ice_parser_sect_item_get,
_parse_ptype_mk_tcam_item, true);
 }
+
+/**
+ * ice_ptype_mk_tcam_match - match a pattern on a ptype marker tcam table
+ * @table: ptype marker tcam table to search
+ * @pat: pattern to match
+ * @len: length of the pattern
+ */
+struct ice_ptype_mk_tcam_item *
+ice_ptype_mk_tcam_match(struct ice_ptype_mk_tcam_item *table,
+   u8 *pat, int len)
+{
+   int i;
+
+   for (i = 0; i < ICE_PTYPE_MK_TCAM_TABLE_SIZE; i++) {
+   struct ice_ptype_mk_tcam_item *item = &table[i];
+
+   if (ice_ternary_match(item->key, item->key_inv, pat, len))
+   return item;
+   }
+
+   return NULL;
+}
diff --git a/drivers/net/ice/base/ice_ptype_mk.h 
b/drivers/net/ice/base/ice_ptype_mk.h
index c93cd8f0ad..2cd49b1b63 100644
--- a/drivers/net/ice/base/ice_ptype_mk.h
+++ b/drivers/net/ice/base/ice_ptype_mk.h
@@ -15,4 +15,7 @@ struct ice_ptype_mk_tcam_item {
 void ice_ptype_mk_tcam_dump(struct ice_hw *hw,
struct ice_ptype_mk_tcam_item *item);
 struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw);
+struct ice_ptype_mk_tcam_item *
+ice_ptype_mk_tcam_match(struct ice_ptype_mk_tcam_item *table,
+   u8 *pat, int len);
 #endif /* _ICE_PTYPE_MK_H_ */
-- 
2.26.2



[dpdk-dev] [PATCH 15/20] net/ice/base: add helper function to redirect flags

2021-09-17 Thread Qi Zhang
Add internal helper function ice_flg_redirect to redirect parser flags
to packet flags.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_flg_rd.c | 23 +++
 drivers/net/ice/base/ice_flg_rd.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/ice/base/ice_flg_rd.c 
b/drivers/net/ice/base/ice_flg_rd.c
index 292916d9a8..833986cac3 100644
--- a/drivers/net/ice/base/ice_flg_rd.c
+++ b/drivers/net/ice/base/ice_flg_rd.c
@@ -51,3 +51,26 @@ struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw 
*hw)
ice_parser_sect_item_get,
_flg_rd_parse_item, false);
 }
+
+/**
+ * ice_flg_redirect - redirect a parser flag to packet flag
+ * @table: flag redirect table
+ * @psr_flg: parser flag to redirect
+ */
+u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg)
+{
+   u64 flg = 0;
+   int i;
+
+   for (i = 0; i < 64; i++) {
+   struct ice_flg_rd_item *item = &table[i];
+
+   if (!item->expose)
+   continue;
+
+   if (psr_flg & (1ul << item->intr_flg_id))
+   flg |= (1ul << i);
+   }
+
+   return flg;
+}
diff --git a/drivers/net/ice/base/ice_flg_rd.h 
b/drivers/net/ice/base/ice_flg_rd.h
index e65350f18c..6c3e01b0fa 100644
--- a/drivers/net/ice/base/ice_flg_rd.h
+++ b/drivers/net/ice/base/ice_flg_rd.h
@@ -13,4 +13,5 @@ struct ice_flg_rd_item {
 
 void ice_flg_rd_dump(struct ice_hw *hw, struct ice_flg_rd_item *item);
 struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw);
+u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg);
 #endif /* _ICE_FLG_RD_H_ */
-- 
2.26.2



[dpdk-dev] [PATCH 16/20] net/ice/base: add helper function to aggregate flags

2021-09-17 Thread Qi Zhang
Add internal helper function ice_xlt_kb_flg_get to aggregate 64 bit
packet flag into 16 bit key builder flags.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_xlt_kb.c | 27 +++
 drivers/net/ice/base/ice_xlt_kb.h |  1 +
 2 files changed, 28 insertions(+)

diff --git a/drivers/net/ice/base/ice_xlt_kb.c 
b/drivers/net/ice/base/ice_xlt_kb.c
index 8b4043a836..4c1ab747cf 100644
--- a/drivers/net/ice/base/ice_xlt_kb.c
+++ b/drivers/net/ice/base/ice_xlt_kb.c
@@ -187,3 +187,30 @@ struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw)
 {
return _xlt_kb_get(hw, ICE_SID_XLT_KEY_BUILDER_RSS);
 }
+
+/**
+ * ice_xlt_kb_flag_get - aggregate 64 bits packet flag into 16 bits xlt flag
+ * @kb: xlt key build
+ * @pkt_flag: 64 bits packet flag
+ */
+u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag)
+{
+   struct ice_xlt_kb_entry *entry = &kb->entries[0];
+   u16 flg = 0;
+   int i;
+
+   /* check flag 15 */
+   if (kb->flag15 & pkt_flag)
+   flg = (u16)(1u << 15);
+
+   /* check flag 0 - 14 */
+   for (i = 0; i < 15; i++) {
+   /* only check first entry */
+   u16 idx = (u16)(entry->flg0_14_sel[i] & 0x3f);
+
+   if (pkt_flag & (1ul << idx))
+   flg |=  (u16)(1u << i);
+   }
+
+   return flg;
+}
diff --git a/drivers/net/ice/base/ice_xlt_kb.h 
b/drivers/net/ice/base/ice_xlt_kb.h
index a95d845f89..ec802b663a 100644
--- a/drivers/net/ice/base/ice_xlt_kb.h
+++ b/drivers/net/ice/base/ice_xlt_kb.h
@@ -30,4 +30,5 @@ struct ice_xlt_kb *ice_xlt_kb_get_sw(struct ice_hw *hw);
 struct ice_xlt_kb *ice_xlt_kb_get_acl(struct ice_hw *hw);
 struct ice_xlt_kb *ice_xlt_kb_get_fd(struct ice_hw *hw);
 struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw);
+u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag);
 #endif /* _ICE_XLT_KB_H */
-- 
2.26.2



[dpdk-dev] [PATCH 17/20] net/ice/base: add parser execution main loop

2021-09-17 Thread Qi Zhang
Implement function ice_parser_rt_execute which perform the main
loop of the parser.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser_rt.c | 777 ++-
 drivers/net/ice/base/ice_parser_rt.h |  20 +
 2 files changed, 793 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/base/ice_parser_rt.c 
b/drivers/net/ice/base/ice_parser_rt.c
index d62d0170e5..682e34e885 100644
--- a/drivers/net/ice/base/ice_parser_rt.c
+++ b/drivers/net/ice/base/ice_parser_rt.c
@@ -34,12 +34,40 @@ static void _rt_nn_set(struct ice_parser_rt *rt, u16 node)
rt->gpr[GPR_NN_IDX] = node;
 }
 
-static void _rt_flag_set(struct ice_parser_rt *rt, int idx)
+static void _rt_flag_set(struct ice_parser_rt *rt, int idx, bool val)
 {
int y = idx / 16;
int x = idx % 16;
 
-   rt->gpr[GPR_FLG_IDX + y] |= (u16)(1 << x);
+   if (val)
+   rt->gpr[GPR_FLG_IDX + y] |= (u16)(1 << x);
+   else
+   rt->gpr[GPR_FLG_IDX + y] &= ~(u16)(1 << x);
+
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Set parser flag %d value %d\n",
+ idx, val);
+}
+
+static void _rt_gpr_set(struct ice_parser_rt *rt, int idx, u16 val)
+{
+   if (idx == GPR_HO_IDX)
+   _rt_ho_set(rt, val);
+   else
+   rt->gpr[idx] = val;
+
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Set GPR %d value %d\n",
+ idx, val);
+}
+
+static void _rt_err_set(struct ice_parser_rt *rt, int idx, bool val)
+{
+   if (val)
+   rt->gpr[GPR_ERR_IDX] |= (u16)(1 << idx);
+   else
+   rt->gpr[GPR_ERR_IDX] &= ~(u16)(1 << idx);
+
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Set parser error %d value %d\n",
+ idx, val);
 }
 
 /**
@@ -61,7 +89,7 @@ void ice_parser_rt_reset(struct ice_parser_rt *rt)
 
for (i = 0; i < 64; i++) {
if ((mi->flags & (1ul << i)) != 0ul)
-   _rt_flag_set(rt, i);
+   _rt_flag_set(rt, i, true);
}
 
rt->psr = psr;
@@ -86,6 +114,650 @@ void ice_parser_rt_pktbuf_set(struct ice_parser_rt *rt, 
const u8 *pkt_buf,
   ICE_NONDMA_TO_NONDMA);
 }
 
+static void _bst_key_init(struct ice_parser_rt *rt, struct ice_imem_item *imem)
+{
+   u8 tsr = (u8)rt->gpr[GPR_TSR_IDX];
+   u16 ho = rt->gpr[GPR_HO_IDX];
+   u8 *key = rt->bst_key;
+   int i, j;
+
+   if (imem->b_kb.tsr_ctrl)
+   key[19] = (u8)tsr;
+   else
+   key[19] = imem->b_kb.priority;
+
+   for (i = 18; i >= 0; i--) {
+   j = ho + 18 - i;
+   if (j < ICE_PARSER_MAX_PKT_LEN)
+   key[i] = rt->pkt_buf[ho + 18 - i];
+   else
+   key[i] = 0;
+   }
+
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Generated Boost TCAM Key:\n");
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "%02X %02X %02X %02X %02X %02X 
%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
+ key[0], key[1], key[2], key[3], key[4],
+ key[5], key[6], key[7], key[8], key[9],
+ key[10], key[11], key[12], key[13], key[14],
+ key[15], key[16], key[17], key[18], key[19]);
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "\n");
+}
+
+static u8 _bit_rev_u8(u8 v)
+{
+   u8 r = 0;
+   int i;
+
+   for (i = 0; i < 8; i++) {
+   r |= (u8)((v & 0x1) << (7 - i));
+   v >>= 1;
+   }
+
+   return r;
+}
+
+static u8 _bit_rev_u16(u16 v, int len)
+{
+   u16 r = 0;
+   int i;
+
+   for (i = 0; i < len; i++) {
+   r |= (u16)((v & 0x1) << (len - 1 - i));
+   v >>= 1;
+   }
+
+   return r;
+}
+
+static u32 _bit_rev_u32(u32 v, int len)
+{
+   u32 r = 0;
+   int i;
+
+   for (i = 0; i < len; i++) {
+   r |= (u32)((v & 0x1) << (len - 1 - i));
+   v >>= 1;
+   }
+
+   return r;
+}
+
+static u32 _hv_bit_sel(struct ice_parser_rt *rt, int start, int len)
+{
+   u64 d64, msk;
+   u8 b[8];
+   int i;
+
+   int offset = GPR_HB_IDX + start / 16;
+
+   ice_memcpy(b, &rt->gpr[offset], 8, ICE_NONDMA_TO_NONDMA);
+
+   for (i = 0; i < 8; i++)
+   b[i] = _bit_rev_u8(b[i]);
+
+   d64 = *(u64 *)b;
+   msk = (1ul << len) - 1;
+
+   return _bit_rev_u32((u32)((d64 >> (start % 16)) & msk), len);
+}
+
+static u32 _pk_build(struct ice_parser_rt *rt, struct ice_np_keybuilder *kb)
+{
+   if (kb->ops == 0)
+   return _hv_bit_sel(rt, kb->start_or_reg0, kb->len_or_reg1);
+   else if (kb->ops == 1)
+   return rt->gpr[kb->start_or_reg0] |
+  ((u32)rt->gpr[kb->len_or_reg1] << 16);
+   else if (kb->ops == 2)
+   return 0;
+
+   ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Unsupported ops %d\n", kb->ops);
+   return 0x;
+}
+
+static bool _flag_get(struct ice_parser_rt *rt, int 

[dpdk-dev] [PATCH 18/20] net/ice/base: support double VLAN mode configure for parser

2021-09-17 Thread Qi Zhang
Add API ice_parser_dvm_set to support turn on/off parser's
double vlan mode.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_bst_tcam.c | 28 
 drivers/net/ice/base/ice_bst_tcam.h |  4 
 drivers/net/ice/base/ice_parser.c   | 27 +++
 drivers/net/ice/base/ice_parser.h   |  1 +
 4 files changed, 60 insertions(+)

diff --git a/drivers/net/ice/base/ice_bst_tcam.c 
b/drivers/net/ice/base/ice_bst_tcam.c
index 76b3a5c551..306f62db2a 100644
--- a/drivers/net/ice/base/ice_bst_tcam.c
+++ b/drivers/net/ice/base/ice_bst_tcam.c
@@ -261,3 +261,31 @@ ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, 
u8 *pat)
 
return NULL;
 }
+
+static bool _start_with(const char *prefix, const char *string)
+{
+   int len1 = strlen(prefix);
+   int len2 = strlen(string);
+
+   if (len2 < len1)
+   return false;
+
+   return !memcmp(prefix, string, len1);
+}
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+   struct ice_lbl_item *lbl_table,
+   const char *prefix, u16 *start)
+{
+   u16 i = *start;
+
+   for (; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+   if (_start_with(prefix, lbl_table[i].label)) {
+   *start = i;
+   return &tcam_table[lbl_table[i].idx];
+   }
+   }
+
+   return NULL;
+}
diff --git a/drivers/net/ice/base/ice_bst_tcam.h 
b/drivers/net/ice/base/ice_bst_tcam.h
index 3cba0bbf55..e4c96c439d 100644
--- a/drivers/net/ice/base/ice_bst_tcam.h
+++ b/drivers/net/ice/base/ice_bst_tcam.h
@@ -28,4 +28,8 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
 
 struct ice_bst_tcam_item *
 ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+   struct ice_lbl_item *lbl_table,
+   const char *prefix, u16 *start);
 #endif /*_ICE_BST_TCAM_H_ */
diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index a0c5c9989d..052bc67a4c 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -340,3 +340,30 @@ void ice_parser_result_dump(struct ice_hw *hw, struct 
ice_parser_result *rslt)
ice_info(hw, "flags_fd = 0x%04x\n", rslt->flags_fd);
ice_info(hw, "flags_rss = 0x%04x\n", rslt->flags_rss);
 }
+
+static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool on)
+{
+   struct ice_bst_tcam_item *item;
+   u16 i = 0;
+
+   while (true) {
+   item = ice_bst_tcam_search(psr->bst_tcam_table,
+  psr->bst_lbl_table,
+  prefix, &i);
+   if (!item)
+   break;
+   item->key[0] = (u8)(on ? 0xff : 0xfe);
+   item->key_inv[0] = (u8)(on ? 0xff : 0xfe);
+   i++;
+   }
+}
+
+/**
+ * ice_parser_dvm_set - configure double vlan mode for parser
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_dvm_set(struct ice_parser *psr, bool on)
+{
+   _bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
+   _bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
+}
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index b2ab21728e..74d72c26df 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -57,6 +57,7 @@ struct ice_parser {
 
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
 void ice_parser_destroy(struct ice_parser *psr);
+void ice_parser_dvm_set(struct ice_parser *psr, bool on);
 
 struct ice_parser_proto_off {
u8 proto_id; /* hardware protocol ID */
-- 
2.26.2



[dpdk-dev] [PATCH 19/20] net/ice/base: add tunnel port support for parser

2021-09-17 Thread Qi Zhang
UDP tunnel can be added/deleted for vxlan, geneve, ecpri through
below APIs:
ice_parser_vxlan_tunnel_set
ice_parser_geneve_tunnel_set
ice_parser_ecpri_tunnel_set

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser.c | 75 +++
 drivers/net/ice/base/ice_parser.h |  6 +++
 2 files changed, 81 insertions(+)

diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index 052bc67a4c..c8272cb9c2 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -367,3 +367,78 @@ void ice_parser_dvm_set(struct ice_parser *psr, bool on)
_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
 }
+
+static enum ice_status
+_tunnel_port_set(struct ice_parser *psr, const char *prefix, u16 udp_port,
+bool on)
+{
+   u8 *buf = (u8 *)&udp_port;
+   struct ice_bst_tcam_item *item;
+   u16 i = 0;
+
+   while (true) {
+   item = ice_bst_tcam_search(psr->bst_tcam_table,
+  psr->bst_lbl_table,
+  prefix, &i);
+   if (!item)
+   break;
+
+   /* found empty slot to add */
+   if (on && item->key[16] == 0xfe && item->key_inv[16] == 0xfe) {
+   item->key_inv[15] = buf[0];
+   item->key_inv[16] = buf[1];
+   item->key[15] = (u8)(0xff - buf[0]);
+   item->key[16] = (u8)(0xff - buf[1]);
+
+   return ICE_SUCCESS;
+   /* found a matched slot to delete */
+   } else if (!on && (item->key_inv[15] == buf[0] ||
+  item->key_inv[16] == buf[1])) {
+   item->key_inv[15] = 0xff;
+   item->key_inv[16] = 0xfe;
+   item->key[15] = 0xff;
+   item->key[16] = 0xfe;
+
+   return ICE_SUCCESS;
+   }
+   i++;
+   }
+
+   return ICE_ERR_PARAM;
+}
+
+/**
+ * ice_parser_vxlan_tunnel_set - configure vxlan tunnel for parser
+ * @psr: pointer to a parser instance
+ * @udp_port: vxlan tunnel port in UDP header
+ * @on: true to turn on; false to turn off
+ */
+enum ice_status ice_parser_vxlan_tunnel_set(struct ice_parser *psr,
+   u16 udp_port, bool on)
+{
+   return _tunnel_port_set(psr, "TNL_VXLAN", udp_port, on);
+}
+
+/**
+ * ice_parser_geneve_tunnel_set - configure geneve tunnel for parser
+ * @psr: pointer to a parser instance
+ * @udp_port: geneve tunnel port in UDP header
+ * @on: true to turn on; false to turn off
+ */
+enum ice_status ice_parser_geneve_tunnel_set(struct ice_parser *psr,
+u16 udp_port, bool on)
+{
+   return _tunnel_port_set(psr, "TNL_GENEVE", udp_port, on);
+}
+
+/**
+ * ice_parser_ecpri_tunnel_set - configure ecpri tunnel for parser
+ * @psr: pointer to a parser instance
+ * @udp_port: ecpri tunnel port in UDP header
+ * @on: true to turn on; false to turn off
+ */
+enum ice_status ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
+   u16 udp_port, bool on)
+{
+   return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
+}
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index 74d72c26df..5c77d7d98c 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -58,6 +58,12 @@ struct ice_parser {
 enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
 void ice_parser_destroy(struct ice_parser *psr);
 void ice_parser_dvm_set(struct ice_parser *psr, bool on);
+enum ice_status ice_parser_vxlan_tunnel_set(struct ice_parser *psr,
+   u16 udp_port, bool on);
+enum ice_status ice_parser_geneve_tunnel_set(struct ice_parser *psr,
+u16 udp_port, bool on);
+enum ice_status ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
+   u16 udp_port, bool on);
 
 struct ice_parser_proto_off {
u8 proto_id; /* hardware protocol ID */
-- 
2.26.2



[dpdk-dev] [PATCH 20/20] net/ice/base: add API for parser profile initialization

2021-09-17 Thread Qi Zhang
Add API ice_parser_profile_init to init a parser profile base on
a parser result and a mask buffer. The ice_parser_profile can feed to
low level FXP engine to create HW profile / field vector directly.

Signed-off-by: Qi Zhang 
---
 drivers/net/ice/base/ice_parser.c | 112 ++
 drivers/net/ice/base/ice_parser.h |  24 +++
 2 files changed, 136 insertions(+)

diff --git a/drivers/net/ice/base/ice_parser.c 
b/drivers/net/ice/base/ice_parser.c
index c8272cb9c2..9180b358eb 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -442,3 +442,115 @@ enum ice_status ice_parser_ecpri_tunnel_set(struct 
ice_parser *psr,
 {
return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
 }
+
+static bool _nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
+ u8 *proto_id, u16 *proto_off)
+{
+   u16 dist = 0x;
+   u8 p = 0;
+   int i;
+
+   for (i = 0; i < rslt->po_num; i++) {
+   if (offset < rslt->po[i].offset)
+   continue;
+   if (offset - rslt->po[i].offset < dist) {
+   p = rslt->po[i].proto_id;
+   dist = offset - rslt->po[i].offset;
+   }
+   }
+
+   if (dist % 2)
+   return false;
+
+   *proto_id = p;
+   *proto_off = dist;
+
+   return true;
+}
+
+/** default flag mask to cover GTP_EH_PDU, GTP_EH_PDU_LINK and TUN2
+ * In future, the flag masks should learn from DDP
+ */
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW  0x4002
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL 0x
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD  0x6080
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS 0x6010
+
+/**
+ * ice_parser_profile_init  - initialize a FXP profile base on parser result
+ * @rslt: a instance of a parser result
+ * @pkt_buf: packet data buffer
+ * @pkt_msk: packet mask buffer
+ * @pkt_len: packet length
+ * @blk: FXP pipeline stage
+ * @prefix_match: match protocol stack exactly or only prefix
+ * @prof: input/output parameter to save the profile
+ */
+enum ice_status ice_parser_profile_init(struct ice_parser_result *rslt,
+   const u8 *pkt_buf, const u8 *msk_buf,
+   int buf_len, enum ice_block blk,
+   bool prefix_match,
+   struct ice_parser_profile *prof)
+{
+   u8 proto_id = 0xff;
+   u16 proto_off = 0;
+   u16 off;
+
+   ice_memset(prof, 0, sizeof(*prof), ICE_NONDMA_MEM);
+   ice_set_bit(rslt->ptype, prof->ptypes);
+   if (blk == ICE_BLK_SW) {
+   prof->flags = rslt->flags_sw;
+   prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW;
+   } else if (blk == ICE_BLK_ACL) {
+   prof->flags = rslt->flags_acl;
+   prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL;
+   } else if (blk == ICE_BLK_FD) {
+   prof->flags = rslt->flags_fd;
+   prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD;
+   } else if (blk == ICE_BLK_RSS) {
+   prof->flags = rslt->flags_rss;
+   prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS;
+   } else {
+   return ICE_ERR_PARAM;
+   }
+
+   for (off = 0; off < buf_len - 1; off++) {
+   if (msk_buf[off] == 0 && msk_buf[off + 1] == 0)
+   continue;
+   if (!_nearest_proto_id(rslt, off, &proto_id, &proto_off))
+   continue;
+   if (prof->fv_num >= 32)
+   return ICE_ERR_PARAM;
+
+   prof->fv[prof->fv_num].proto_id = proto_id;
+   prof->fv[prof->fv_num].offset = proto_off;
+   prof->fv[prof->fv_num].spec = *(const u16 *)&pkt_buf[off];
+   prof->fv[prof->fv_num].msk = *(const u16 *)&msk_buf[off];
+   prof->fv_num++;
+   }
+
+   return ICE_SUCCESS;
+}
+
+/**
+ * ice_parser_profile_dump - dump an FXP profile info
+ * @hw: pointer to the hardware structure
+ * @prof: profile info to dump
+ */
+void ice_parser_profile_dump(struct ice_hw *hw, struct ice_parser_profile 
*prof)
+{
+   u16 i;
+
+   ice_info(hw, "ptypes:\n");
+   for (i = 0; i < ICE_FLOW_PTYPE_MAX; i++)
+   if (ice_is_bit_set(prof->ptypes, i))
+   ice_info(hw, "\t%d\n", i);
+
+   for (i = 0; i < prof->fv_num; i++)
+   ice_info(hw, "proto = %d, offset = %d spec = 0x%04x, mask = 
0x%04x\n",
+prof->fv[i].proto_id, prof->fv[i].offset,
+prof->fv[i].spec, prof->fv[i].msk);
+
+   ice_info(hw, "flags = 0x%04x\n", prof->flags);
+   ice_info(hw, "flags_msk = 0x%04x\n", prof->flags_msk);
+}
diff --git a/drivers/net/ice/base/ice_parser.h 
b/drivers/net/ice/base/ice_parser.h
index 5c77d7d98c..690144d77b 100644
--- a/drivers/n

[dpdk-dev] [PATCH v3] devtools: add acronyms in dictionary for commit checks

2021-09-17 Thread Ashwin Sekhar T K
Update word list with Marvell specific acronyms.

CPT  -> Cryptographic Accelerator Unit
CQ   -> Completion Queue
LBK  -> Loopback Interface Unit
LMT  -> Large Atomic Store Unit
MCAM -> Match Content Addressable Memory
NIX  -> Network Interface Controller Unit
NPA  -> Network Pool Allocator
NPC  -> Network Parser and CAM Unit
ROC  -> Rest Of Chip
RQ   -> Receive Queue
RVU  -> Resource Virtualization Unit
SQ   -> Send Queue
SSO  -> Schedule Synchronize Order Unit
TIM  -> Timer Unit

Signed-off-by: Ashwin Sekhar T K 
---
 devtools/words-case.txt | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/devtools/words-case.txt b/devtools/words-case.txt
index 0bbad48626..0ea23689f0 100644
--- a/devtools/words-case.txt
+++ b/devtools/words-case.txt
@@ -6,6 +6,8 @@ Arm
 armv7
 armv8
 BAR
+CPT
+CQ
 CRC
 DCB
 DevX
@@ -33,10 +35,13 @@ L2
 L3
 L4
 LACP
+LBK
 Linux
+LMT
 LRO
 LSC
 MAC
+MCAM
 MPLS
 MSI
 MSI-X
@@ -44,6 +49,9 @@ MSS
 MTU
 NEON
 NIC
+NIX
+NPA
+NPC
 null
 NUMA
 NVGRE
@@ -57,15 +65,21 @@ PVID
 QinQ
 RDMA
 RETA
+ROC
+RQ
 RSS
+RVU
 Rx
 SCTP
 SMP
 SoC
+SQ
+SSO
 SW
 TC
 TCAM
 Thor
+TIM
 TOS
 TPID
 TSO
-- 
2.32.0



Re: [dpdk-dev] [PATCH v3] devtools: add acronyms in dictionary for commit checks

2021-09-17 Thread Jerin Jacob
On Fri, Sep 17, 2021 at 4:32 PM Ashwin Sekhar T K  wrote:
>
> Update word list with Marvell specific acronyms.
>
> CPT  -> Cryptographic Accelerator Unit
> CQ   -> Completion Queue
> LBK  -> Loopback Interface Unit
> LMT  -> Large Atomic Store Unit
> MCAM -> Match Content Addressable Memory
> NIX  -> Network Interface Controller Unit
> NPA  -> Network Pool Allocator
> NPC  -> Network Parser and CAM Unit
> ROC  -> Rest Of Chip
> RQ   -> Receive Queue
> RVU  -> Resource Virtualization Unit
> SQ   -> Send Queue
> SSO  -> Schedule Synchronize Order Unit
> TIM  -> Timer Unit

Suggested-by: Ferruh Yigit 

> Signed-off-by: Ashwin Sekhar T K 

Reviewed-by: Jerin Jacob 


> ---
>  devtools/words-case.txt | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/devtools/words-case.txt b/devtools/words-case.txt
> index 0bbad48626..0ea23689f0 100644
> --- a/devtools/words-case.txt
> +++ b/devtools/words-case.txt
> @@ -6,6 +6,8 @@ Arm
>  armv7
>  armv8
>  BAR
> +CPT
> +CQ
>  CRC
>  DCB
>  DevX
> @@ -33,10 +35,13 @@ L2
>  L3
>  L4
>  LACP
> +LBK
>  Linux
> +LMT
>  LRO
>  LSC
>  MAC
> +MCAM
>  MPLS
>  MSI
>  MSI-X
> @@ -44,6 +49,9 @@ MSS
>  MTU
>  NEON
>  NIC
> +NIX
> +NPA
> +NPC
>  null
>  NUMA
>  NVGRE
> @@ -57,15 +65,21 @@ PVID
>  QinQ
>  RDMA
>  RETA
> +ROC
> +RQ
>  RSS
> +RVU
>  Rx
>  SCTP
>  SMP
>  SoC
> +SQ
> +SSO
>  SW
>  TC
>  TCAM
>  Thor
> +TIM
>  TOS
>  TPID
>  TSO
> --
> 2.32.0
>


[dpdk-dev] [PATCH] net/sfc: relax SW packets/bytes atomic ops memory ordering

2021-09-17 Thread Andrew Rybchenko
No barriers are required when stats are incremented or read.

Fixes: 96fd2bd69b58 ("net/sfc: support flow action count in transfer rules")
Cc: sta...@dpdk.org

Signed-off-by: Andrew Rybchenko 
---
 drivers/net/sfc/sfc_stats.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_stats.h b/drivers/net/sfc/sfc_stats.h
index 2d7ab71f14..aae8243c73 100644
--- a/drivers/net/sfc/sfc_stats.h
+++ b/drivers/net/sfc/sfc_stats.h
@@ -53,7 +53,7 @@ sfc_pkts_bytes_add(union sfc_pkts_bytes *st, uint64_t pkts, 
uint64_t bytes)
 * core sees both counter updates together.
 */
__atomic_store_n(&st->pkts_bytes.int128, result.pkts_bytes.int128,
-__ATOMIC_RELEASE);
+__ATOMIC_RELAXED);
 #else
st->pkts += pkts;
st->bytes += bytes;
@@ -68,7 +68,7 @@ sfc_pkts_bytes_get(const union sfc_pkts_bytes *st, union 
sfc_pkts_bytes *result)
 {
 #if SFC_SW_STATS_ATOMIC
result->pkts_bytes.int128 = __atomic_load_n(&st->pkts_bytes.int128,
-   __ATOMIC_ACQUIRE);
+   __ATOMIC_RELAXED);
 #else
*result = *st;
 #endif
-- 
2.30.2



[dpdk-dev] [PATCH 0/4] delete HW rings when releasing queues

2021-09-17 Thread Yunjian Wang
This series for deleting HW rings when releasing queues for
igb, ixgbe, i40e, ice & em drivers.

Yunjian Wang (4):
  net/e1000: delete HW rings when releasing queues
  net/ice: delete HW rings when releasing queues
  net/i40e: delete HW rings when releasing queues
  net/ixgbe: delete HW rings when releasing queues

 drivers/net/e1000/em_rxtx.c| 8 ++--
 drivers/net/e1000/igb_rxtx.c   | 9 +++--
 drivers/net/i40e/i40e_fdir.c   | 3 ---
 drivers/net/i40e/i40e_rxtx.c   | 8 ++--
 drivers/net/i40e/i40e_rxtx.h   | 2 ++
 drivers/net/ice/ice_rxtx.c | 6 --
 drivers/net/ice/ice_rxtx.h | 2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 9 files changed, 33 insertions(+), 13 deletions(-)

-- 
2.23.0



[dpdk-dev] [PATCH v2] common/cnxk: align NPA stack to ROC cache line size

2021-09-17 Thread Ashwin Sekhar T K
Network Pool accelerator (NPA) is part of ROC (Rest Of Chip). So
NPA structures should be aligned to ROC Cache line size and not
CPU cache line size.

Non alignment of NPA stack to ROC cache line will result in
undefined runtime NPA behaviour.

Fixes: f765f5611240 ("common/cnxk: add NPA pool HW operations")

Signed-off-by: Ashwin Sekhar T K 
Acked-by: Jerin Jacob 
---
 drivers/common/cnxk/roc_npa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index d064d125c1..a0d2cc8f19 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -194,7 +194,7 @@ npa_stack_dma_alloc(struct npa_lf *lf, char *name, int 
pool_id, size_t size)
 {
const char *mz_name = npa_stack_memzone_name(lf, pool_id, name);
 
-   return plt_memzone_reserve_cache_align(mz_name, size);
+   return plt_memzone_reserve_aligned(mz_name, size, 0, ROC_ALIGN);
 }
 
 static inline int
-- 
2.32.0



Re: [dpdk-dev] [PATCH v3 6/8] app/testpmd: add common fwd wrapper

2021-09-17 Thread Jerin Jacob
On Fri, Sep 17, 2021 at 1:33 PM Xueming Li  wrote:
>
> From: Xiaoyu Min 
>
> Added common forwarding wrapper function for all fwd engines
> which do the following in common:
>
> - record core cycles
> - call rte_eth_rx_burst(...,nb_pkt_per_burst)
> - update received packets
> - handle received mbufs with callback function
>
> For better performance, the function is defined as macro.
>
> Signed-off-by: Xiaoyu Min 
> Signed-off-by: Xueming Li 
> ---
>  app/test-pmd/5tswap.c   | 25 +
>  app/test-pmd/csumonly.c | 25 ++---
>  app/test-pmd/flowgen.c  | 20 +---
>  app/test-pmd/icmpecho.c | 30 --
>  app/test-pmd/iofwd.c| 24 +---
>  app/test-pmd/macfwd.c   | 24 +---
>  app/test-pmd/macswap.c  | 23 +--
>  app/test-pmd/rxonly.c   | 32 
>  app/test-pmd/testpmd.h  | 19 +++
>  9 files changed, 66 insertions(+), 156 deletions(-)
>
> diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c
> index e8cef9623b..8fe940294f 100644
> --- a/app/test-pmd/5tswap.c
> +++ b/app/test-pmd/5tswap.c
> @@ -82,18 +82,16 @@ swap_udp(struct rte_udp_hdr *udp_hdr)
>   * Parses each layer and swaps it. When the next layer doesn't match it 
> stops.
>   */

> +PKT_BURST_FWD(_5tuple_swap_stream);

Please make _5tuple_swap_stream aka "cb" as inline function to  make sure
compiler doesn't generate yet another function pointer.

>  struct fwd_engine mac_swap_engine = {
> .fwd_mode_name  = "macswap",
> .port_fwd_begin = NULL,
> .port_fwd_end   = NULL,
> -   .packet_fwd = pkt_burst_mac_swap,

See below

> +   .packet_fwd = pkt_burst_fwd,
>
> +#define PKT_BURST_FWD(cb)   \

Probably it can pass prefix too like PKT_BURST_FWD(cb, prefix)
to make a unique function and call PKT_BURST_FWD(_5tuple_swap_stream,
mac_swap) for better readability
and avoid diff above section.


> +static void \
> +pkt_burst_fwd(struct fwd_stream *fs)

pkt_burst_fwd##prefix(struct fwd_stream *fs)
\
> +{   \
> +   struct rte_mbuf *pkts_burst[nb_pkt_per_burst];  \
> +   uint16_t nb_rx; \
> +   uint64_t start_tsc = 0; \
> +   \
> +   get_start_cycles(&start_tsc);   \
> +   nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, \
> +   pkts_burst, nb_pkt_per_burst);  \
> +   inc_rx_burst_stats(fs, nb_rx);  \
> +   if (unlikely(nb_rx == 0))   \
> +   return; \
> +   fs->rx_packets += nb_rx;\
> +   cb(fs, nb_rx, pkts_burst);  \
> +   get_end_cycles(fs, start_tsc);  \
> +}
> +
>  /*
>   * Work-around of a compilation error with ICC on invocations of the
>   * rte_be_to_cpu_16() function.
> --
> 2.33.0
>


[dpdk-dev] [PATCH 1/4] net/e1000: delete HW rings when releasing queues

2021-09-17 Thread Yunjian Wang
Normally when closing the device the queue memzone should be
freed. But the memzone will be not freed, when device setup
ops like:
 - rte_eth_bond_slave_remove
 - rte_eth_dev_internal_reset
 - eth_dev_rx_queue_config
 - dev_rx_queue_release
 - dev_close
 - dev_free_queues

In order to free the memzone, we can release the memzone
when releasing queues.

Signed-off-by: Yunjian Wang 
---
 drivers/net/e1000/em_rxtx.c  | 8 ++--
 drivers/net/e1000/igb_rxtx.c | 9 +++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index dfd8f2fd00..82928083f5 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -104,6 +104,7 @@ struct em_rx_queue {
uint8_t hthresh;/**< Host threshold register. */
uint8_t wthresh;/**< Write-back threshold register. */
uint8_t crc_len;/**< 0 if CRC stripped, 4 otherwise. */
+   const struct rte_memzone *mz;
 };
 
 /**
@@ -173,6 +174,7 @@ struct em_tx_queue {
struct em_ctx_info ctx_cache;
/**< Hardware context history.*/
uint64_t   offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+   const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1116,6 +1118,7 @@ em_tx_queue_release(struct em_tx_queue *txq)
if (txq != NULL) {
em_tx_queue_release_mbufs(txq);
rte_free(txq->sw_ring);
+   rte_memzone_free(txq->mz);
rte_free(txq);
}
 }
@@ -1286,6 +1289,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
RTE_CACHE_LINE_SIZE)) == NULL)
return -ENOMEM;
 
+   txq->mz = tz;
/* Allocate software ring */
if ((txq->sw_ring = rte_zmalloc("txq->sw_ring",
sizeof(txq->sw_ring[0]) * nb_desc,
@@ -1338,6 +1342,7 @@ em_rx_queue_release(struct em_rx_queue *rxq)
if (rxq != NULL) {
em_rx_queue_release_mbufs(rxq);
rte_free(rxq->sw_ring);
+   rte_memzone_free(rxq->mz);
rte_free(rxq);
}
 }
@@ -1452,6 +1457,7 @@ eth_em_rx_queue_setup(struct rte_eth_dev *dev,
RTE_CACHE_LINE_SIZE)) == NULL)
return -ENOMEM;
 
+   rxq->mz = rz;
/* Allocate software ring. */
if ((rxq->sw_ring = rte_zmalloc("rxq->sw_ring",
sizeof (rxq->sw_ring[0]) * nb_desc,
@@ -1611,14 +1617,12 @@ em_dev_free_queues(struct rte_eth_dev *dev)
for (i = 0; i < dev->data->nb_rx_queues; i++) {
eth_em_rx_queue_release(dev->data->rx_queues[i]);
dev->data->rx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "rx_ring", i);
}
dev->data->nb_rx_queues = 0;
 
for (i = 0; i < dev->data->nb_tx_queues; i++) {
eth_em_tx_queue_release(dev->data->tx_queues[i]);
dev->data->tx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "tx_ring", i);
}
dev->data->nb_tx_queues = 0;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 278d5d2712..dc0de37246 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -112,6 +112,7 @@ struct igb_rx_queue {
uint8_t drop_en;  /**< If not 0, set SRRCTL.Drop_En. */
uint32_tflags;  /**< RX flags. */
uint64_toffloads;   /**< offloads of DEV_RX_OFFLOAD_* */
+   const struct rte_memzone *mz;
 };
 
 /**
@@ -186,6 +187,7 @@ struct igb_tx_queue {
struct igb_advctx_info ctx_cache[IGB_CTX_NUM];
/**< Hardware context history.*/
uint64_t   offloads; /**< offloads of DEV_TX_OFFLOAD_* */
+   const struct rte_memzone *mz;
 };
 
 #if 1
@@ -1276,6 +1278,7 @@ igb_tx_queue_release(struct igb_tx_queue *txq)
if (txq != NULL) {
igb_tx_queue_release_mbufs(txq);
rte_free(txq->sw_ring);
+   rte_memzone_free(txq->mz);
rte_free(txq);
}
 }
@@ -1545,6 +1548,7 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   txq->mz = tz;
txq->nb_tx_desc = nb_desc;
txq->pthresh = tx_conf->tx_thresh.pthresh;
txq->hthresh = tx_conf->tx_thresh.hthresh;
@@ -1601,6 +1605,7 @@ igb_rx_queue_release(struct igb_rx_queue *rxq)
if (rxq != NULL) {
igb_rx_queue_release_mbufs(rxq);
rte_free(rxq->sw_ring);
+   rte_memzone_free(rxq->mz);
rte_free(rxq);
}
 }
@@ -1746,6 +1751,8 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
igb_rx_queue_release(rxq);
return -ENOMEM;
}
+
+   rxq->mz = rz;
rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx));
rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx));
 

[dpdk-dev] [PATCH 2/4] net/ice: delete HW rings when releasing queues

2021-09-17 Thread Yunjian Wang
Normally when closing the device the queue memzone should be
freed. But the memzone will be not freed, when device setup
ops like:
 - rte_eth_bond_slave_remove
 - rte_eth_dev_internal_reset
 - eth_dev_rx_queue_config
 - dev_rx_queue_release
 - dev_close
 - dev_free_queues

In order to free the memzone, we can release the memzone
when releasing queues.

Signed-off-by: Yunjian Wang 
---
 drivers/net/ice/ice_rxtx.c | 6 --
 drivers/net/ice/ice_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 5d7ab4f047..472da6bf83 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -1135,6 +1135,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   rxq->mz = rz;
/* Zero all the descriptors in the ring. */
memset(rz->addr, 0, ring_size);
 
@@ -1190,6 +1191,7 @@ ice_rx_queue_release(void *rxq)
 
q->rx_rel_mbufs(q);
rte_free(q->sw_ring);
+   rte_memzone_free(q->mz);
rte_free(q);
 }
 
@@ -1336,6 +1338,7 @@ ice_tx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   txq->mz = tz;
txq->nb_tx_desc = nb_desc;
txq->tx_rs_thresh = tx_rs_thresh;
txq->tx_free_thresh = tx_free_thresh;
@@ -1386,6 +1389,7 @@ ice_tx_queue_release(void *txq)
 
q->tx_rel_mbufs(q);
rte_free(q->sw_ring);
+   rte_memzone_free(q->mz);
rte_free(q);
 }
 
@@ -2080,7 +2084,6 @@ ice_free_queues(struct rte_eth_dev *dev)
continue;
ice_rx_queue_release(dev->data->rx_queues[i]);
dev->data->rx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "rx_ring", i);
}
dev->data->nb_rx_queues = 0;
 
@@ -2089,7 +2092,6 @@ ice_free_queues(struct rte_eth_dev *dev)
continue;
ice_tx_queue_release(dev->data->tx_queues[i]);
dev->data->tx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "tx_ring", i);
}
dev->data->nb_tx_queues = 0;
 }
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index b10db0874d..903c99a640 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -89,6 +89,7 @@ struct ice_rx_queue {
ice_rxd_to_pkt_fields_t rxd_to_pkt_fields; /* handle FlexiMD by RXDID */
ice_rx_release_mbufs_t rx_rel_mbufs;
uint64_t offloads;
+   const struct rte_memzone *mz;
 };
 
 struct ice_tx_entry {
@@ -133,6 +134,7 @@ struct ice_tx_queue {
bool tx_deferred_start; /* don't start this queue in dev start */
bool q_set; /* indicate if tx queue has been configured */
ice_tx_release_mbufs_t tx_rel_mbufs;
+   const struct rte_memzone *mz;
 };
 
 /* Offload features */
-- 
2.23.0



[dpdk-dev] [PATCH 3/4] net/i40e: delete HW rings when releasing queues

2021-09-17 Thread Yunjian Wang
Normally when closing the device the queue memzone should be
freed. But the memzone will be not freed, when device setup
ops like:
 - rte_eth_bond_slave_remove
 - rte_eth_dev_internal_reset
 - eth_dev_rx_queue_config
 - dev_rx_queue_release
 - dev_close
 - dev_free_queues

In order to free the memzone, we can release the memzone
when releasing queues.

Signed-off-by: Yunjian Wang 
---
 drivers/net/i40e/i40e_fdir.c | 3 ---
 drivers/net/i40e/i40e_rxtx.c | 8 ++--
 drivers/net/i40e/i40e_rxtx.h | 2 ++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index af075fda2a..e910346e4d 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -284,7 +284,6 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 {
struct i40e_hw *hw = I40E_PF_TO_HW(pf);
struct i40e_vsi *vsi;
-   struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
 
vsi = pf->fdir.fdir_vsi;
if (!vsi)
@@ -301,10 +300,8 @@ i40e_fdir_teardown(struct i40e_pf *pf)
if (err)
PMD_DRV_LOG(DEBUG, "Failed to do FDIR RX switch off");
 
-   rte_eth_dma_zone_free(dev, "fdir_rx_ring", pf->fdir.rxq->queue_id);
i40e_dev_rx_queue_release(pf->fdir.rxq);
pf->fdir.rxq = NULL;
-   rte_eth_dma_zone_free(dev, "fdir_tx_ring", pf->fdir.txq->queue_id);
i40e_dev_tx_queue_release(pf->fdir.txq);
pf->fdir.txq = NULL;
i40e_vsi_release(vsi);
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8329cbdd4e..b67eb1ee94 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2034,6 +2034,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   rxq->mz = rz;
/* Zero all the descriptors in the ring. */
memset(rz->addr, 0, ring_size);
 
@@ -2113,6 +2114,7 @@ i40e_dev_rx_queue_release(void *rxq)
 
i40e_rx_queue_release_mbufs(q);
rte_free(q->sw_ring);
+   rte_memzone_free(q->mz);
rte_free(q);
 }
 
@@ -2433,6 +2435,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   txq->mz = tz;
txq->nb_tx_desc = nb_desc;
txq->tx_rs_thresh = tx_rs_thresh;
txq->tx_free_thresh = tx_free_thresh;
@@ -2506,6 +2509,7 @@ i40e_dev_tx_queue_release(void *txq)
 
i40e_tx_queue_release_mbufs(q);
rte_free(q->sw_ring);
+   rte_memzone_free(q->mz);
rte_free(q);
 }
 
@@ -3058,7 +3062,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
continue;
i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
dev->data->rx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "rx_ring", i);
}
 
for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -3066,7 +3069,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
continue;
i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
dev->data->tx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "tx_ring", i);
}
 }
 
@@ -3109,6 +3111,7 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
return I40E_ERR_NO_MEMORY;
}
 
+   txq->mz = tz;
txq->nb_tx_desc = I40E_FDIR_NUM_TX_DESC;
txq->queue_id = I40E_FDIR_QUEUE_ID;
txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
@@ -3167,6 +3170,7 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
return I40E_ERR_NO_MEMORY;
}
 
+   rxq->mz = rz;
rxq->nb_rx_desc = I40E_FDIR_NUM_RX_DESC;
rxq->queue_id = I40E_FDIR_QUEUE_ID;
rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 5ccf5773e8..3c1a2fab89 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -121,6 +121,7 @@ struct i40e_rx_queue {
uint16_t rx_using_sse; /**

[dpdk-dev] [PATCH 4/4] net/ixgbe: delete HW rings when releasing queues

2021-09-17 Thread Yunjian Wang
Normally when closing the device the queue memzone should be
freed. But the memzone will be not freed, when device setup
ops like:
 - rte_eth_bond_slave_remove
 - rte_eth_dev_internal_reset
 - eth_dev_rx_queue_config
 - dev_rx_queue_release
 - dev_close
 - dev_free_queues

In order to free the memzone, we can release the memzone
when releasing queues.

Signed-off-by: Yunjian Wang 
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 6 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index bfdfd5e755..1b6e0489f4 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2482,6 +2482,7 @@ ixgbe_tx_queue_release(struct ixgbe_tx_queue *txq)
if (txq != NULL && txq->ops != NULL) {
txq->ops->release_mbufs(txq);
txq->ops->free_swring(txq);
+   rte_memzone_free(txq->mz);
rte_free(txq);
}
 }
@@ -2763,6 +2764,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   txq->mz = tz;
txq->nb_tx_desc = nb_desc;
txq->tx_rs_thresh = tx_rs_thresh;
txq->tx_free_thresh = tx_free_thresh;
@@ -2887,6 +2889,7 @@ ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
ixgbe_rx_queue_release_mbufs(rxq);
rte_free(rxq->sw_ring);
rte_free(rxq->sw_sc_ring);
+   rte_memzone_free(rxq->mz);
rte_free(rxq);
}
 }
@@ -3162,6 +3165,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
 
+   rxq->mz = rz;
/*
 * Zero init all the descriptors in the ring.
 */
@@ -3433,14 +3437,12 @@ ixgbe_dev_free_queues(struct rte_eth_dev *dev)
for (i = 0; i < dev->data->nb_rx_queues; i++) {
ixgbe_dev_rx_queue_release(dev->data->rx_queues[i]);
dev->data->rx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "rx_ring", i);
}
dev->data->nb_rx_queues = 0;
 
for (i = 0; i < dev->data->nb_tx_queues; i++) {
ixgbe_dev_tx_queue_release(dev->data->tx_queues[i]);
dev->data->tx_queues[i] = NULL;
-   rte_eth_dma_zone_free(dev, "tx_ring", i);
}
dev->data->nb_tx_queues = 0;
 }
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index 476ef62cfd..a1764f2b08 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -138,6 +138,7 @@ struct ixgbe_rx_queue {
struct rte_mbuf fake_mbuf;
/** hold packets to return to application */
struct rte_mbuf *rx_stage[RTE_PMD_IXGBE_RX_MAX_BURST*2];
+   const struct rte_memzone *mz;
 };
 
 /**
@@ -236,6 +237,7 @@ struct ixgbe_tx_queue {
uint8_t using_ipsec;
/**< indicates that IPsec TX feature is in use */
 #endif
+   const struct rte_memzone *mz;
 };
 
 struct ixgbe_txq_ops {
-- 
2.23.0



Re: [dpdk-dev] [PATCH v3 1/2] ethdev: queue release callback optional

2021-09-17 Thread Andrew Rybchenko
On 9/17/21 12:39 PM, Xueming Li wrote:
> Some drivers don't need Rx and Tx queue release callback, make it
> optional.
> 
> Signed-off-by: Xueming Li 

LGTM, but please, consider one nit below

Reviewed-by: Andrew Rybchenko 

> ---
>  lib/ethdev/rte_ethdev.c | 48 +
>  1 file changed, 20 insertions(+), 28 deletions(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index daf5ca9242..2f316d1646 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -905,12 +905,11 @@ eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
> uint16_t nb_queues)
>   return -(ENOMEM);
>   }
>   } else if (dev->data->rx_queues != NULL && nb_queues != 0) { /* 
> re-configure */
> - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, 
> -ENOTSUP);
> -
>   rxq = dev->data->rx_queues;
>  
> - for (i = nb_queues; i < old_nb_queues; i++)
> - (*dev->dev_ops->rx_queue_release)(rxq[i]);
> + if (dev->dev_ops->rx_queue_release != NULL)
> + for (i = nb_queues; i < old_nb_queues; i++)
> + (*dev->dev_ops->rx_queue_release)(rxq[i]);

Since 'if' body has more than one line, I'd add curly brackets
around to make it a bit easier to read and more robust against
future changes.

Similar note is applicable to many similar cases in the patch.



Re: [dpdk-dev] [PATCH v3 2/2] ethdev: change queue release callback

2021-09-17 Thread Andrew Rybchenko
On 9/17/21 12:39 PM, Xueming Li wrote:
> Currently, most ethdev callback api use queue ID as parameter, but Rx

api -> API

> and Tx queue release callback use queue object which is used in Rx and
> Tx burst data plane callback.
> 
> To align with other eth device queue configuration callbacks:
> - queue release callbacks are changed to used queue ID
> - all drivers are adapted
> - empty drivers are removed in some drivers

Empty drivers? If you mean empty callbacks, I think it should
belong to the first changeset in the series.

> 
> Signed-off-by: Xueming Li 




Re: [dpdk-dev] [PATCH v3 1/2] ethdev: queue release callback optional

2021-09-17 Thread Andrew Rybchenko
On 9/17/21 2:29 PM, Andrew Rybchenko wrote:
> On 9/17/21 12:39 PM, Xueming Li wrote:
>> Some drivers don't need Rx and Tx queue release callback, make it
>> optional.
>>
>> Signed-off-by: Xueming Li 
> 
> LGTM, but please, consider one nit below
> 
> Reviewed-by: Andrew Rybchenko 
> 
>> ---
>>  lib/ethdev/rte_ethdev.c | 48 +
>>  1 file changed, 20 insertions(+), 28 deletions(-)
>>
>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>> index daf5ca9242..2f316d1646 100644
>> --- a/lib/ethdev/rte_ethdev.c
>> +++ b/lib/ethdev/rte_ethdev.c
>> @@ -905,12 +905,11 @@ eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
>> uint16_t nb_queues)
>>  return -(ENOMEM);
>>  }
>>  } else if (dev->data->rx_queues != NULL && nb_queues != 0) { /* 
>> re-configure */
>> -RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, 
>> -ENOTSUP);
>> -
>>  rxq = dev->data->rx_queues;
>>  
>> -for (i = nb_queues; i < old_nb_queues; i++)
>> -(*dev->dev_ops->rx_queue_release)(rxq[i]);
>> +if (dev->dev_ops->rx_queue_release != NULL)
>> +for (i = nb_queues; i < old_nb_queues; i++)
>> +(*dev->dev_ops->rx_queue_release)(rxq[i]);
> 
> Since 'if' body has more than one line, I'd add curly brackets
> around to make it a bit easier to read and more robust against
> future changes.
> 
> Similar note is applicable to many similar cases in the patch.
> 

Reviewed the next patch I realize one thing:
Who is responsible for setting dev->data->rxq[rx_queue_id] to
NULL if release callback is not specified. IMHO, it is
inconsistent to keep it filled in after release. I think that
the generic code in ethdev must care about it regardless
callback presence. It means that we need helper function
which cares about it in single place. Also it means that
we can't optimize loops like this. We need the loop anyway
to set all queue pointers to NULL.


Re: [dpdk-dev] [PATCH 6/8] examples/ip_pipeline: remove setting of PCI ID and address

2021-09-17 Thread David Marchand
Hi Chenbo,

On Fri, Sep 17, 2021 at 5:09 AM Xia, Chenbo  wrote:
> > > PCI ID and address in structure rte_kni_conf are never used and
> > > will be removed in kni library. So remove the setting of them
> > > first in the example.
> > >
> > > Signed-off-by: Chenbo Xia 
> >
> > (forgot to Cc: Ferruh in previous comment)
> > Ditto patch 5.
> >
> > I would tag with a Fixes: on ethtool removal.
> > Plus, this is the same kind of cleanup wrt kni, you can squash those
> > two patches together.
>
> A question about squash patch 5 and 6, then how should I title the combined
> patch? Because there're both test change and example change. I'd like know
> your suggestion.
> >

This is a cleanup on unused fields wrt KNI.
"kni: remove unused PCI info from test and example" lgtm.

Ferruh, opinion?

And mark with:
Fixes: ea6b39b5b847 ("kni: remove ethtool support")


-- 
David Marchand



[dpdk-dev] [PATCH v3 0/8] ethdev: introduce shared Rx queue

2021-09-17 Thread Xueming Li
In current DPDK framework, all RX queues is pre-loaded with mbufs for
incoming packets. When number of representors scale out in a switch
domain, the memory consumption became significant. Further more,
polling all ports leads to high cache miss, high latency and low
throughputs.

This patch introduces shared RX queue. PF and representors with same
configuration in same switch domain could share RX queue set by
specifying shared Rx queue offloading flag and sharing group.

All ports that Shared Rx queue actually shares One Rx queue and only
pre-load mbufs to one Rx queue, memory is saved.

Polling any queue using same shared RX queue receives packets from all
member ports. Source port is identified by mbuf->port.

Multiple groups is supported by group ID. Port queue number in a shared
group should be identical. Queue index is 1:1 mapped in shared group.
An example of polling two share groups:
  core  group   queue
  0 0   0
  1 0   1
  2 0   2
  3 0   3
  4 1   0
  5 1   1
  6 1   2
  7 1   3

Shared RX queue must be polled on single thread or core. If both PF0 and
representor0 joined same share group, can't poll pf0rxq0 on core1 and
rep0rxq0 on core2. Actually, polling one port within share group is
sufficient since polling any port in group will return packets for any
port in group.

v1:
  - initial version
v2:
  - add testpmd patches
v3:
  - change common forwarding api to macro for performance, thanks Jerin.
  - save global variable accessed in forwarding to flowstream to minimize
cache miss
  - combined patches for each forwarding engine
  - support multiple groups in testpmd "--share-rxq" parameter
  - new api to aggerate shared rxq group

Xiaoyu Min (1):
  app/testpmd: add common fwd wrapper

Xueming Li (7):
  ethdev: introduce shared Rx queue
  ethdev: new API to aggregate shared Rx queue group
  app/testpmd: dump port and queue info for each packet
  app/testpmd: new parameter to enable shared Rx queue
  app/testpmd: force shared Rx queue polled on same core
  app/testpmd: improve forwarding cache miss
  app/testpmd: support shared Rx queue forwarding

 app/test-pmd/5tswap.c |  25 +---
 app/test-pmd/config.c | 120 +-
 app/test-pmd/csumonly.c   |  25 +---
 app/test-pmd/flowgen.c|  26 ++--
 app/test-pmd/icmpecho.c   |  30 ++---
 app/test-pmd/ieee1588fwd.c|  30 +++--
 app/test-pmd/iofwd.c  |  24 +---
 app/test-pmd/macfwd.c |  24 +---
 app/test-pmd/macswap.c|  23 +---
 app/test-pmd/noisy_vnf.c  |   2 +-
 app/test-pmd/parameters.c |  13 ++
 app/test-pmd/rxonly.c |  32 ++---
 app/test-pmd/testpmd.c|  91 -
 app/test-pmd/testpmd.h|  47 ++-
 app/test-pmd/txonly.c |   8 +-
 app/test-pmd/util.c   |   1 +
 doc/guides/nics/features.rst  |  11 ++
 doc/guides/nics/features/default.ini  |   1 +
 .../prog_guide/switch_representation.rst  |  10 ++
 doc/guides/testpmd_app_ug/run_app.rst |   5 +
 lib/ethdev/ethdev_driver.h|  23 +++-
 lib/ethdev/rte_ethdev.c   |  23 
 lib/ethdev/rte_ethdev.h   |  23 
 lib/ethdev/version.map|   3 +
 24 files changed, 432 insertions(+), 188 deletions(-)

-- 
2.33.0



[dpdk-dev] [PATCH v3 1/8] ethdev: introduce shared Rx queue

2021-09-17 Thread Xueming Li
In current DPDK framework, each RX queue is pre-loaded with mbufs for
incoming packets. When number of representors scale out in a switch
domain, the memory consumption became significant. Most important,
polling all ports leads to high cache miss, high latency and low
throughput.

This patch introduces shared RX queue. Ports with same configuration in
a switch domain could share RX queue set by specifying sharing group.
Polling any queue using same shared RX queue receives packets from all
member ports. Source port is identified by mbuf->port.

Port queue number in a shared group should be identical. Queue index is
1:1 mapped in shared group.

Share RX queue must be polled on single thread or core.

Multiple groups is supported by group ID.

Signed-off-by: Xueming Li 
Cc: Jerin Jacob 
---
Rx queue object could be used as shared Rx queue object, it's important
to clear all queue control callback api that using queue object:
  https://mails.dpdk.org/archives/dev/2021-July/215574.html
---
 doc/guides/nics/features.rst| 11 +++
 doc/guides/nics/features/default.ini|  1 +
 doc/guides/prog_guide/switch_representation.rst | 10 ++
 lib/ethdev/rte_ethdev.c |  1 +
 lib/ethdev/rte_ethdev.h |  7 +++
 5 files changed, 30 insertions(+)

diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index a96e12d155..2e2a9b1554 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -624,6 +624,17 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_shared_rx_queue:
+
+Shared Rx queue
+---
+
+Supports shared Rx queue for ports in same switch domain.
+
+* **[uses] rte_eth_rxconf,rte_eth_rxmode**: 
``offloads:RTE_ETH_RX_OFFLOAD_SHARED_RXQ``.
+* **[provides] mbuf**: ``mbuf.port``.
+
+
 .. _nic_features_packet_type_parsing:
 
 Packet type parsing
diff --git a/doc/guides/nics/features/default.ini 
b/doc/guides/nics/features/default.ini
index 754184ddd4..ebeb4c1851 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -19,6 +19,7 @@ Free Tx mbuf on demand =
 Queue start/stop =
 Runtime Rx queue setup =
 Runtime Tx queue setup =
+Shared Rx queue  =
 Burst mode info  =
 Power mgmt address monitor =
 MTU update   =
diff --git a/doc/guides/prog_guide/switch_representation.rst 
b/doc/guides/prog_guide/switch_representation.rst
index ff6aa91c80..45bf5a3a10 100644
--- a/doc/guides/prog_guide/switch_representation.rst
+++ b/doc/guides/prog_guide/switch_representation.rst
@@ -123,6 +123,16 @@ thought as a software "patch panel" front-end for 
applications.
 .. [1] `Ethernet switch device driver model (switchdev)
`_
 
+- Memory usage of representors is huge when number of representor grows,
+  because PMD always allocate mbuf for each descriptor of Rx queue.
+  Polling the large number of ports brings more CPU load, cache miss and
+  latency. Shared Rx queue can be used to share Rx queue between PF and
+  representors in same switch domain. ``RTE_ETH_RX_OFFLOAD_SHARED_RXQ``
+  is present in Rx offloading capability of device info. Setting the
+  offloading flag in device Rx mode or Rx queue configuration to enable
+  shared Rx queue. Polling any member port of shared Rx queue can return
+  packets of all ports in group, port ID is saved in ``mbuf.port``.
+
 Basic SR-IOV
 
 
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a7c090ce79..b3a58d5e65 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -127,6 +127,7 @@ static const struct {
RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
RTE_ETH_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
+   RTE_ETH_RX_OFFLOAD_BIT2STR(SHARED_RXQ),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index d2b27c351f..a578c9db9d 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -1047,6 +1047,7 @@ struct rte_eth_rxconf {
uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. 
*/
uint8_t rx_deferred_start; /**< Do not start queue with 
rte_eth_dev_start(). */
uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
+   uint32_t shared_group; /**< Shared port group index in switch domain. */
/**
 * Per-queue Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
@@ -1373,6 +1374,12 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x0004
 #define DEV_RX_OFFLOAD_RSS_HASH0x0008
 #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT 0x0010
+/**
+ * Rx queue is shared among ports in same switch domain to save memory,
+ * avoid p

[dpdk-dev] [PATCH v3 3/8] app/testpmd: dump port and queue info for each packet

2021-09-17 Thread Xueming Li
In case of shared Rx queue, port number of mbufs returned from one rx
burst could be different.

To support shared Rx queue, this patch dumps mbuf->port and queue for
each packet.

Signed-off-by: Xueming Li 
---
 app/test-pmd/util.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 14a9a251fb..b85fbf75a5 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -100,6 +100,7 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct 
rte_mbuf *pkts[],
struct rte_flow_restore_info info = { 0, };
 
mb = pkts[i];
+   MKDUMPSTR(print_buf, buf_size, cur_len, "port %u, ", mb->port);
eth_hdr = rte_pktmbuf_read(mb, 0, sizeof(_eth_hdr), &_eth_hdr);
eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
packet_type = mb->packet_type;
-- 
2.33.0



[dpdk-dev] [PATCH v3 2/8] ethdev: new API to aggregate shared Rx queue group

2021-09-17 Thread Xueming Li
This patch introduces new api to aggreated ports among same shared Rx
queue group.  Only queues with specified share group is aggregated.
Rx burst and device close are expected to be supported by new device.

Signed-off-by: Xueming Li 
---
 lib/ethdev/ethdev_driver.h | 23 ++-
 lib/ethdev/rte_ethdev.c| 22 ++
 lib/ethdev/rte_ethdev.h| 16 
 lib/ethdev/version.map |  3 +++
 4 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 524757cf6f..72156a4153 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -786,10 +786,28 @@ typedef int (*eth_get_monitor_addr_t)(void *rxq,
  * @return
  *   Negative errno value on error, number of info entries otherwise.
  */
-
 typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
struct rte_eth_representor_info *info);
 
+/**
+ * @internal
+ * Aggregate shared Rx queue.
+ *
+ * Create a new port used for shared Rx queue polling.
+ *
+ * Only queues with specified share group are aggregated.
+ * At least Rx burst and device close should be supported.
+ *
+ * @param dev
+ *   Ethdev handle of port.
+ * @param group
+ *   Shared Rx queue group to aggregate.
+ * @return
+ *   UINT16_MAX if failed, otherwise aggregated port number.
+ */
+typedef int (*eth_shared_rxq_aggregate_t)(struct rte_eth_dev *dev,
+ uint32_t group);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet 
driver.
  */
@@ -950,6 +968,9 @@ struct eth_dev_ops {
 
eth_representor_info_get_t representor_info_get;
/**< Get representor info. */
+
+   eth_shared_rxq_aggregate_t shared_rxq_aggregate;
+   /**< Aggregate shared Rx queue. */
 };
 
 /**
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index b3a58d5e65..9f2ef58309 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6301,6 +6301,28 @@ rte_eth_representor_info_get(uint16_t port_id,
return eth_err(port_id, (*dev->dev_ops->representor_info_get)(dev, 
info));
 }
 
+uint16_t
+rte_eth_shared_rxq_aggregate(uint16_t port_id, uint32_t group)
+{
+   struct rte_eth_dev *dev;
+   uint64_t offloads;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+   dev = &rte_eth_devices[port_id];
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->shared_rxq_aggregate,
+   UINT16_MAX);
+
+   offloads = dev->data->dev_conf.rxmode.offloads;
+   if ((offloads & RTE_ETH_RX_OFFLOAD_SHARED_RXQ) == 0) {
+   RTE_ETHDEV_LOG(ERR, "port_id=%u doesn't support Rx offload\n",
+  port_id);
+   return UINT16_MAX;
+   }
+
+   return (*dev->dev_ops->shared_rxq_aggregate)(dev, group);
+}
+
 RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
 
 RTE_INIT(ethdev_init_telemetry)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index a578c9db9d..f15d2142b2 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -4895,6 +4895,22 @@ __rte_experimental
 int rte_eth_representor_info_get(uint16_t port_id,
 struct rte_eth_representor_info *info);
 
+/**
+ * Aggregate shared Rx queue ports to one port for polling.
+ *
+ * Only queues with specified share group is aggregated.
+ * Any operation besides Rx burst and device close is unexpected.
+ *
+ * @param port_id
+ *   The port identifier of the device from shared Rx queue group.
+ * @param group
+ *   Shared Rx queue group to aggregate.
+ * @return
+ *   UINT16_MAX if failed, otherwise aggregated port number.
+ */
+__rte_experimental
+uint16_t rte_eth_shared_rxq_aggregate(uint16_t port_id, uint32_t group);
+
 #include 
 
 /**
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 3eece75b72..97a2233508 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -249,6 +249,9 @@ EXPERIMENTAL {
rte_mtr_meter_policy_delete;
rte_mtr_meter_policy_update;
rte_mtr_meter_policy_validate;
+
+   # added in 21.11
+   rte_eth_shared_rxq_aggregate;
 };
 
 INTERNAL {
-- 
2.33.0



[dpdk-dev] [PATCH v3 5/8] app/testpmd: force shared Rx queue polled on same core

2021-09-17 Thread Xueming Li
Shared rxqs shares one set rx queue of groups zero. Shared Rx queue must
must be polled from one core.

Checks and stops forwarding if shared rxq being scheduled on multiple
cores.

Signed-off-by: Xueming Li 
---
 app/test-pmd/config.c  | 96 ++
 app/test-pmd/testpmd.c |  4 +-
 app/test-pmd/testpmd.h |  2 +
 3 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 8ec5f87ef3..035247c33f 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2883,6 +2883,102 @@ port_rss_hash_key_update(portid_t port_id, char 
rss_type[], uint8_t *hash_key,
}
 }
 
+/*
+ * Check whether a shared rxq scheduled on other lcores.
+ */
+static bool
+fwd_stream_on_other_lcores(uint16_t domain_id, portid_t src_port,
+  queueid_t src_rxq, lcoreid_t src_lc,
+  uint32_t shared_group)
+{
+   streamid_t sm_id;
+   streamid_t nb_fs_per_lcore;
+   lcoreid_t  nb_fc;
+   lcoreid_t  lc_id;
+   struct fwd_stream *fs;
+   struct rte_port *port;
+   struct rte_eth_rxconf *rxq_conf;
+
+   nb_fc = cur_fwd_config.nb_fwd_lcores;
+   for (lc_id = src_lc + 1; lc_id < nb_fc; lc_id++) {
+   sm_id = fwd_lcores[lc_id]->stream_idx;
+   nb_fs_per_lcore = fwd_lcores[lc_id]->stream_nb;
+   for (; sm_id < fwd_lcores[lc_id]->stream_idx + nb_fs_per_lcore;
+sm_id++) {
+   fs = fwd_streams[sm_id];
+   port = &ports[fs->rx_port];
+   rxq_conf = &port->rx_conf[fs->rx_queue];
+   if ((rxq_conf->offloads & RTE_ETH_RX_OFFLOAD_SHARED_RXQ)
+   == 0)
+   /* Not shared rxq. */
+   continue;
+   if (domain_id != port->dev_info.switch_info.domain_id)
+   continue;
+   if (fs->rx_queue != src_rxq)
+   continue;
+   if (rxq_conf->shared_group != shared_group)
+   continue;
+   printf("Shared RX queue group %u can't be scheduled on 
different cores:\n",
+  shared_group);
+   printf("  lcore %hhu Port %hu queue %hu\n",
+  src_lc, src_port, src_rxq);
+   printf("  lcore %hhu Port %hu queue %hu\n",
+  lc_id, fs->rx_port, fs->rx_queue);
+   printf("  please use --nb-cores=%hu to limit forwarding 
cores\n",
+  nb_rxq);
+   return true;
+   }
+   }
+   return false;
+}
+
+/*
+ * Check shared rxq configuration.
+ *
+ * Shared group must not being scheduled on different core.
+ */
+bool
+pkt_fwd_shared_rxq_check(void)
+{
+   streamid_t sm_id;
+   streamid_t nb_fs_per_lcore;
+   lcoreid_t  nb_fc;
+   lcoreid_t  lc_id;
+   struct fwd_stream *fs;
+   uint16_t domain_id;
+   struct rte_port *port;
+   struct rte_eth_rxconf *rxq_conf;
+
+   nb_fc = cur_fwd_config.nb_fwd_lcores;
+   /*
+* Check streams on each core, make sure the same switch domain +
+* group + queue doesn't get scheduled on other cores.
+*/
+   for (lc_id = 0; lc_id < nb_fc; lc_id++) {
+   sm_id = fwd_lcores[lc_id]->stream_idx;
+   nb_fs_per_lcore = fwd_lcores[lc_id]->stream_nb;
+   for (; sm_id < fwd_lcores[lc_id]->stream_idx + nb_fs_per_lcore;
+sm_id++) {
+   fs = fwd_streams[sm_id];
+   /* Update lcore info stream being scheduled. */
+   fs->lcore = fwd_lcores[lc_id];
+   port = &ports[fs->rx_port];
+   rxq_conf = &port->rx_conf[fs->rx_queue];
+   if ((rxq_conf->offloads & RTE_ETH_RX_OFFLOAD_SHARED_RXQ)
+   == 0)
+   /* Not shared rxq. */
+   continue;
+   /* Check shared rxq not scheduled on remaining cores. */
+   domain_id = port->dev_info.switch_info.domain_id;
+   if (fwd_stream_on_other_lcores(domain_id, fs->rx_port,
+  fs->rx_queue, lc_id,
+  rxq_conf->shared_group))
+   return false;
+   }
+   }
+   return true;
+}
+
 /*
  * Setup forwarding configuration for each logical core.
  */
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 417e92ade1..cab4b36b04 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2241,10 +2241,12 @@ start_packet_forwarding(int with_tx_first)
 
  

[dpdk-dev] [PATCH v3 4/8] app/testpmd: new parameter to enable shared Rx queue

2021-09-17 Thread Xueming Li
Adds "--rxq-share" parameter to enable shared rxq for each rxq.

Default shared rxq group 0 is used, RX queues in same switch domain
shares same rxq according to queue index.

Shared Rx queue is enabled only if device support offloading flag
RTE_ETH_RX_OFFLOAD_SHARED_RXQ.

Signed-off-by: Xueming Li 
---
 app/test-pmd/config.c |  6 +-
 app/test-pmd/parameters.c | 13 +
 app/test-pmd/testpmd.c| 18 ++
 app/test-pmd/testpmd.h|  2 ++
 doc/guides/testpmd_app_ug/run_app.rst |  5 +
 5 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index f5765b34f7..8ec5f87ef3 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2707,7 +2707,11 @@ rxtx_config_display(void)
printf("  RX threshold registers: pthresh=%d 
hthresh=%d "
" wthresh=%d\n",
pthresh_tmp, hthresh_tmp, wthresh_tmp);
-   printf("  RX Offloads=0x%"PRIx64"\n", offloads_tmp);
+   printf("  RX Offloads=0x%"PRIx64, offloads_tmp);
+   if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_SHARED_RXQ)
+   printf(" share group=%u",
+  rx_conf->shared_group);
+   printf("\n");
}
 
/* per tx queue config only for first queue to be less verbose 
*/
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 3f94a82e32..de0f1d28cc 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -167,6 +167,7 @@ usage(char* progname)
printf("  --tx-ip=src,dst: IP addresses in Tx-only mode\n");
printf("  --tx-udp=src[,dst]: UDP ports in Tx-only mode\n");
printf("  --eth-link-speed: force link speed.\n");
+   printf("  --rxq-share: number of ports per shared rxq groups\n");
printf("  --disable-link-check: disable check on link status when "
   "starting/stopping ports.\n");
printf("  --disable-device-start: do not automatically start port\n");
@@ -607,6 +608,7 @@ launch_args_parse(int argc, char** argv)
{ "rxpkts", 1, 0, 0 },
{ "txpkts", 1, 0, 0 },
{ "txonly-multi-flow",  0, 0, 0 },
+   { "rxq-share",  0, 0, 0 },
{ "eth-link-speed", 1, 0, 0 },
{ "disable-link-check", 0, 0, 0 },
{ "disable-device-start",   0, 0, 0 },
@@ -1271,6 +1273,17 @@ launch_args_parse(int argc, char** argv)
}
if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow"))
txonly_multi_flow = 1;
+   if (!strcmp(lgopts[opt_idx].name, "rxq-share")) {
+   if (optarg == NULL) {
+   rxq_share = UINT32_MAX;
+   } else {
+   n = atoi(optarg);
+   if (n >= 0)
+   rxq_share = (uint32_t)n;
+   else
+   rte_exit(EXIT_FAILURE, 
"rxq-share must be >= 0\n");
+   }
+   }
if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
no_flush_rx = 1;
if (!strcmp(lgopts[opt_idx].name, "eth-link-speed")) {
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 97ae52e17e..417e92ade1 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -498,6 +498,11 @@ uint8_t record_core_cycles;
  */
 uint8_t record_burst_stats;
 
+/*
+ * Number of ports per shared Rx queue group, 0 disable.
+ */
+uint32_t rxq_share;
+
 unsigned int num_sockets = 0;
 unsigned int socket_ids[RTE_MAX_NUMA_NODES];
 
@@ -1506,6 +1511,11 @@ init_config_port_offloads(portid_t pid, uint32_t 
socket_id)
port->dev_conf.txmode.offloads &=
~DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+   if (rxq_share > 0 &&
+   (port->dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_SHARED_RXQ))
+   port->dev_conf.rxmode.offloads |=
+   RTE_ETH_RX_OFFLOAD_SHARED_RXQ;
+
/* Apply Rx offloads configuration */
for (i = 0; i < port->dev_info.max_rx_queues; i++)
port->rx_conf[i].offloads = port->dev_conf.rxmode.offloads;
@@ -3401,6 +3411,14 @@ rxtx_port_config(struct rte_port *port)
for (qid = 0; qid < nb_rxq; qid++) {
offloads = port->rx_conf[qid].offloads;
port->rx_conf[qid] = port->dev_info.default_rxconf;
+
+   if (rxq_s

[dpdk-dev] [PATCH v3 6/8] app/testpmd: add common fwd wrapper

2021-09-17 Thread Xueming Li
From: Xiaoyu Min 

Added common forwarding wrapper function for all fwd engines
which do the following in common:

- record core cycles
- call rte_eth_rx_burst(...,nb_pkt_per_burst)
- update received packets
- handle received mbufs with callback function

For better performance, the function is defined as macro.

Signed-off-by: Xiaoyu Min 
Signed-off-by: Xueming Li 
---
 app/test-pmd/5tswap.c   | 25 +
 app/test-pmd/csumonly.c | 25 ++---
 app/test-pmd/flowgen.c  | 20 +---
 app/test-pmd/icmpecho.c | 30 --
 app/test-pmd/iofwd.c| 24 +---
 app/test-pmd/macfwd.c   | 24 +---
 app/test-pmd/macswap.c  | 23 +--
 app/test-pmd/rxonly.c   | 32 
 app/test-pmd/testpmd.h  | 19 +++
 9 files changed, 66 insertions(+), 156 deletions(-)

diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c
index e8cef9623b..8fe940294f 100644
--- a/app/test-pmd/5tswap.c
+++ b/app/test-pmd/5tswap.c
@@ -82,18 +82,16 @@ swap_udp(struct rte_udp_hdr *udp_hdr)
  * Parses each layer and swaps it. When the next layer doesn't match it stops.
  */
 static void
-pkt_burst_5tuple_swap(struct fwd_stream *fs)
+_5tuple_swap_stream(struct fwd_stream *fs, uint16_t nb_rx,
+   struct rte_mbuf **pkts_burst)
 {
-   struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
struct rte_port  *txp;
struct rte_mbuf *mb;
uint16_t next_proto;
uint64_t ol_flags;
uint16_t proto;
-   uint16_t nb_rx;
uint16_t nb_tx;
uint32_t retry;
-
int i;
union {
struct rte_ether_hdr *eth;
@@ -105,20 +103,6 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
uint8_t *byte;
} h;
 
-   uint64_t start_tsc = 0;
-
-   get_start_cycles(&start_tsc);
-
-   /*
-* Receive a burst of packets and forward them.
-*/
-   nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
-nb_pkt_per_burst);
-   inc_rx_burst_stats(fs, nb_rx);
-   if (unlikely(nb_rx == 0))
-   return;
-
-   fs->rx_packets += nb_rx;
txp = &ports[fs->tx_port];
ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
vlan_qinq_set(pkts_burst, nb_rx, ol_flags,
@@ -182,12 +166,13 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
rte_pktmbuf_free(pkts_burst[nb_tx]);
} while (++nb_tx < nb_rx);
}
-   get_end_cycles(fs, start_tsc);
 }
 
+PKT_BURST_FWD(_5tuple_swap_stream);
+
 struct fwd_engine five_tuple_swap_fwd_engine = {
.fwd_mode_name  = "5tswap",
.port_fwd_begin = NULL,
.port_fwd_end   = NULL,
-   .packet_fwd = pkt_burst_5tuple_swap,
+   .packet_fwd = pkt_burst_fwd,
 };
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 38cc256533..9bfc7d10dc 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -763,7 +763,7 @@ pkt_copy_split(const struct rte_mbuf *pkt)
 }
 
 /*
- * Receive a burst of packets, and for each packet:
+ * For each packet in received mbuf:
  *  - parse packet, and try to recognize a supported packet type (1)
  *  - if it's not a supported packet type, don't touch the packet, else:
  *  - reprocess the checksum of all supported layers. This is done in SW
@@ -792,9 +792,9 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  * OUTER_IP is only useful for tunnel packets.
  */
 static void
-pkt_burst_checksum_forward(struct fwd_stream *fs)
+checksum_forward_stream(struct fwd_stream *fs, uint16_t nb_rx,
+   struct rte_mbuf **pkts_burst)
 {
-   struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
struct rte_mbuf *gso_segments[GSO_MAX_PKT_BURST];
struct rte_gso_ctx *gso_ctx;
struct rte_mbuf **tx_pkts_burst;
@@ -805,7 +805,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
void **gro_ctx;
uint16_t gro_pkts_num;
uint8_t gro_enable;
-   uint16_t nb_rx;
uint16_t nb_tx;
uint16_t nb_prep;
uint16_t i;
@@ -820,18 +819,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t nb_segments = 0;
int ret;
 
-   uint64_t start_tsc = 0;
-
-   get_start_cycles(&start_tsc);
-
-   /* receive a burst of packet */
-   nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
-nb_pkt_per_burst);
-   inc_rx_burst_stats(fs, nb_rx);
-   if (unlikely(nb_rx == 0))
-   return;
-
-   fs->rx_packets += nb_rx;
rx_bad_ip_csum = 0;
rx_bad_l4_csum = 0;
rx_bad_outer_l4_csum = 0;
@@ -1138,13 +1125,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
rte_pktmbuf_free(tx_pkts_burst[nb_tx]);
} while (++nb_tx < nb_rx);
}
-
-   get_end_cycles(fs, start_tsc);
 }
 

[dpdk-dev] [PATCH v3 8/8] app/testpmd: support shared Rx queue forwarding

2021-09-17 Thread Xueming Li
By enabling shared Rx queue, received packets come from all member ports
in same shared Rx queue.

This patch adds a common forwarding function for shared Rx queue, groups
source forwarding stream by looking into local streams on current lcore
with packet source port(mbuf->port) and queue, then invokes callback to
handle received packets for each source stream.

Signed-off-by: Xueming Li 
---
 app/test-pmd/ieee1588fwd.c | 30 +++--
 app/test-pmd/testpmd.c | 69 ++
 app/test-pmd/testpmd.h |  9 -
 3 files changed, 97 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 034f238c34..0151d6de74 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -90,23 +90,17 @@ port_ieee1588_tx_timestamp_check(portid_t pi)
 }
 
 static void
-ieee1588_packet_fwd(struct fwd_stream *fs)
+ieee1588_fwd_stream(struct fwd_stream *fs, uint16_t nb_rx,
+   struct rte_mbuf **pkt)
 {
-   struct rte_mbuf  *mb;
+   struct rte_mbuf *mb = (*pkt);
struct rte_ether_hdr *eth_hdr;
struct rte_ether_addr addr;
struct ptpv2_msg *ptp_hdr;
uint16_t eth_type;
uint32_t timesync_index;
 
-   /*
-* Receive 1 packet at a time.
-*/
-   if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0)
-   return;
-
-   fs->rx_packets += 1;
-
+   RTE_SET_USED(nb_rx);
/*
 * Check that the received packet is a PTP packet that was detected
 * by the hardware.
@@ -198,6 +192,22 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
port_ieee1588_tx_timestamp_check(fs->rx_port);
 }
 
+/*
+ * Wrapper of real fwd ingine.
+ */
+static void
+ieee1588_packet_fwd(struct fwd_stream *fs)
+{
+   struct rte_mbuf *mb;
+
+   if (rte_eth_rx_burst(fs->rx_port, fs->rx_queue, &mb, 1) == 0)
+   return;
+   if (unlikely(fs->rxq_share > 0))
+   forward_shared_rxq(fs, 1, &mb, ieee1588_fwd_stream);
+   else
+   ieee1588_fwd_stream(fs, 1, &mb);
+}
+
 static void
 port_ieee1588_fwd_begin(portid_t pi)
 {
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index cab4b36b04..1d82397831 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2106,6 +2106,75 @@ flush_fwd_rx_queues(void)
}
 }
 
+/**
+ * Get packet source stream by source port and queue.
+ * All streams of same shared Rx queue locates on same core.
+ */
+static struct fwd_stream *
+forward_stream_get(struct fwd_stream *fs, uint16_t port)
+{
+   streamid_t sm_id;
+   struct fwd_lcore *fc;
+   struct fwd_stream **fsm;
+   streamid_t nb_fs;
+
+   fc = fs->lcore;
+   fsm = &fwd_streams[fc->stream_idx];
+   nb_fs = fc->stream_nb;
+   for (sm_id = 0; sm_id < nb_fs; sm_id++) {
+   if (fsm[sm_id]->rx_port == port &&
+   fsm[sm_id]->rx_queue == fs->rx_queue)
+   return fsm[sm_id];
+   }
+   return NULL;
+}
+
+/**
+ * Forward packet by source port and queue.
+ */
+static void
+forward_by_port(struct fwd_stream *src_fs, uint16_t port, uint16_t nb_rx,
+   struct rte_mbuf **pkts, packet_fwd_cb fwd)
+{
+   struct fwd_stream *fs = forward_stream_get(src_fs, port);
+
+   if (fs != NULL) {
+   fs->rx_packets += nb_rx;
+   fwd(fs, nb_rx, pkts);
+   } else {
+   /* Source stream not found, drop all packets. */
+   src_fs->fwd_dropped += nb_rx;
+   while (nb_rx > 0)
+   rte_pktmbuf_free(pkts[--nb_rx]);
+   }
+}
+
+/**
+ * Forward packets from shared Rx queue.
+ *
+ * Source port of packets are identified by mbuf->port.
+ */
+void
+forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx,
+  struct rte_mbuf **pkts_burst, packet_fwd_cb fwd)
+{
+   uint16_t i, nb_fs_rx = 1, port;
+
+   /* Locate real source fs according to mbuf->port. */
+   for (i = 0; i < nb_rx; ++i) {
+   rte_prefetch0(pkts_burst[i + 1]);
+   port = pkts_burst[i]->port;
+   if (i + 1 == nb_rx || pkts_burst[i + 1]->port != port) {
+   /* Forward packets with same source port. */
+   forward_by_port(fs, port, nb_fs_rx,
+   &pkts_burst[i + 1 - nb_fs_rx], fwd);
+   nb_fs_rx = 1;
+   } else {
+   nb_fs_rx++;
+   }
+   }
+}
+
 static void
 run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
 {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 3b8796a7a5..7869f61f74 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -276,6 +276,8 @@ struct fwd_lcore {
 typedef void (*port_fwd_begin_t)(portid_t pi);
 typedef void (*port_fwd_end_t)(portid_t pi);
 typedef void (*packet_fwd_t)(struct fwd_stream *fs);
+typedef void

[dpdk-dev] [PATCH v3 7/8] app/testpmd: improve forwarding cache miss

2021-09-17 Thread Xueming Li
To minimize cache miss, adds flags and burst size used in forwarding to
stream, moves condition tests in forwarding to flags in stream.

Signed-off-by: Xueming Li 
---
 app/test-pmd/config.c| 18 ++
 app/test-pmd/flowgen.c   |  6 +++---
 app/test-pmd/noisy_vnf.c |  2 +-
 app/test-pmd/testpmd.h   | 21 -
 app/test-pmd/txonly.c|  8 
 5 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 035247c33f..5cdf8fa082 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3050,6 +3050,16 @@ fwd_topology_tx_port_get(portid_t rxp)
}
 }
 
+static void
+fwd_stream_set_common(struct fwd_stream *fs)
+{
+   fs->nb_pkt_per_burst = nb_pkt_per_burst;
+   fs->record_burst_stats = !!record_burst_stats;
+   fs->record_core_cycles = !!record_core_cycles;
+   fs->retry_enabled = !!retry_enabled;
+   fs->rxq_share = !!rxq_share;
+}
+
 static void
 simple_fwd_config_setup(void)
 {
@@ -3079,7 +3089,7 @@ simple_fwd_config_setup(void)
fwd_ports_ids[fwd_topology_tx_port_get(i)];
fwd_streams[i]->tx_queue  = 0;
fwd_streams[i]->peer_addr = fwd_streams[i]->tx_port;
-   fwd_streams[i]->retry_enabled = retry_enabled;
+   fwd_stream_set_common(fwd_streams[i]);
}
 }
 
@@ -3140,7 +3150,7 @@ rss_fwd_config_setup(void)
fs->tx_port = fwd_ports_ids[txp];
fs->tx_queue = rxq;
fs->peer_addr = fs->tx_port;
-   fs->retry_enabled = retry_enabled;
+   fwd_stream_set_common(fs);
rxp++;
if (rxp < nb_fwd_ports)
continue;
@@ -3255,7 +3265,7 @@ dcb_fwd_config_setup(void)
fs->tx_port = fwd_ports_ids[txp];
fs->tx_queue = txq + j % nb_tx_queue;
fs->peer_addr = fs->tx_port;
-   fs->retry_enabled = retry_enabled;
+   fwd_stream_set_common(fs);
}
fwd_lcores[lc_id]->stream_nb +=
rxp_dcb_info.tc_queue.tc_rxq[i][tc].nb_queue;
@@ -3326,7 +3336,7 @@ icmp_echo_config_setup(void)
fs->tx_port = fs->rx_port;
fs->tx_queue = rxq;
fs->peer_addr = fs->tx_port;
-   fs->retry_enabled = retry_enabled;
+   fwd_stream_set_common(fs);
if (verbose_level > 0)
printf("  stream=%d port=%d rxq=%d txq=%d\n",
   sm_id, fs->rx_port, fs->rx_queue,
diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
index aa45948b4c..c282f3bcb1 100644
--- a/app/test-pmd/flowgen.c
+++ b/app/test-pmd/flowgen.c
@@ -97,12 +97,12 @@ flow_gen_stream(struct fwd_stream *fs, uint16_t nb_rx,
if (tx_offloads & DEV_TX_OFFLOAD_MACSEC_INSERT)
ol_flags |= PKT_TX_MACSEC;
 
-   for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
+   for (nb_pkt = 0; nb_pkt < fs->nb_pkt_per_burst; nb_pkt++) {
if (!nb_pkt || !nb_clones) {
nb_clones = nb_pkt_flowgen_clones;
/* Logic limitation */
-   if (nb_clones > nb_pkt_per_burst)
-   nb_clones = nb_pkt_per_burst;
+   if (nb_clones > fs->nb_pkt_per_burst)
+   nb_clones = fs->nb_pkt_per_burst;
 
pkt = rte_mbuf_raw_alloc(mbp);
if (!pkt)
diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c
index 382a4c2aae..56bf6a4e70 100644
--- a/app/test-pmd/noisy_vnf.c
+++ b/app/test-pmd/noisy_vnf.c
@@ -153,7 +153,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs)
uint64_t now;
 
nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue,
-   pkts_burst, nb_pkt_per_burst);
+   pkts_burst, fs->nb_pkt_per_burst);
inc_rx_burst_stats(fs, nb_rx);
if (unlikely(nb_rx == 0))
goto flush;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 4792bef03b..3b8796a7a5 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -128,12 +128,17 @@ struct fwd_stream {
queueid_t  tx_queue;  /**< TX queue to send forwarded packets */
streamid_t peer_addr; /**< index of peer ethernet address of packets */
 
-   unsigned int retry_enabled;
+   uint16_t nb_pkt_per_burst;
+   unsigned int record_burst_stats:1;
+   unsigned int record_core_cycles:1;
+   unsigned int retry_enabled:1;
+   unsigned int rxq_share:1;
 
/* "read-write" results */
uint64_t rx_packets;  /**< received packets */
uint64_t tx_packets;  /**< receive

[dpdk-dev] [PATCH] kni: Fix request overwritten

2021-09-17 Thread Elad Nachman


Fix lack of multiple KNI requests handling support by introducing a 
rotating ring mechanism for the sync buffer.

Prevent kni_net_change_rx_flags() from calling kni_net_process_request()
with a malformed request.

Bugzilla ID: 809

Signed-off-by: Elad Nachman 
---
 kernel/linux/kni/kni_dev.h  |  2 ++
 kernel/linux/kni/kni_misc.c |  2 ++
 kernel/linux/kni/kni_net.c  | 25 +
 lib/kni/rte_kni.c   | 14 +++---
 lib/kni/rte_kni_common.h|  1 +
 5 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h
index c15da311ba..b9e8b3d10d 100644
--- a/kernel/linux/kni/kni_dev.h
+++ b/kernel/linux/kni/kni_dev.h
@@ -74,6 +74,8 @@ struct kni_dev {
 
void *sync_kva;
void *sync_va;
+   unsigned int sync_ring_size;
+   atomic_t sync_ring_idx;
 
void *mbuf_kva;
void *mbuf_va;
diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index 2b464c4381..f3cee97818 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -345,6 +345,8 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
 
kni->net_dev = net_dev;
kni->core_id = dev_info.core_id;
+   kni->sync_ring_size = dev_info.sync_ring_size;
+   kni->sync_ring_idx.counter = 0;
strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE);
 
/* Translate user space info into kernel space info */
diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 611719b5ee..dc066cdd98 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -110,6 +110,8 @@ kni_net_process_request(struct net_device *dev, struct 
rte_kni_request *req)
void *resp_va;
uint32_t num;
int ret_val;
+   unsigned int idx;
+   char *k_reqptr, *v_reqptr;
 
ASSERT_RTNL();
 
@@ -122,10 +124,17 @@ kni_net_process_request(struct net_device *dev, struct 
rte_kni_request *req)
}
 
mutex_lock(&kni->sync_lock);
-
+   idx = atomic_read(&kni->sync_ring_idx);
+   atomic_cmpxchg(&kni->sync_ring_idx, idx,
+   (idx + 1) % kni->sync_ring_size);
/* Construct data */
-   memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
-   num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
+   k_reqptr = (char *)((uintptr_t)kni->sync_kva +
+   sizeof(struct rte_kni_request) * idx);
+   v_reqptr = (char *)((uintptr_t)kni->sync_va +
+   sizeof(struct rte_kni_request) * idx);
+
+   memcpy(k_reqptr, req, sizeof(struct rte_kni_request));
+   num = kni_fifo_put(kni->req_q, (void **)&v_reqptr, 1);
if (num < 1) {
pr_err("Cannot send to req_q\n");
ret = -EBUSY;
@@ -147,14 +156,14 @@ kni_net_process_request(struct net_device *dev, struct 
rte_kni_request *req)
goto fail;
}
num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
-   if (num != 1 || resp_va != kni->sync_va) {
+   if (num != 1) {
/* This should never happen */
pr_err("No data in resp_q\n");
ret = -ENODATA;
goto fail;
}
 
-   memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
+   memcpy(req, k_reqptr, sizeof(struct rte_kni_request));
 async:
ret = 0;
 
@@ -681,13 +690,12 @@ kni_net_change_mtu(struct net_device *dev, int new_mtu)
 static void
 kni_net_change_rx_flags(struct net_device *netdev, int flags)
 {
-   struct rte_kni_request req;
+   struct rte_kni_request req = { 0 };
 
memset(&req, 0, sizeof(req));
 
if (flags & IFF_ALLMULTI) {
req.req_id = RTE_KNI_REQ_CHANGE_ALLMULTI;
-
if (netdev->flags & IFF_ALLMULTI)
req.allmulti = 1;
else
@@ -703,7 +711,8 @@ kni_net_change_rx_flags(struct net_device *netdev, int 
flags)
req.promiscusity = 0;
}
 
-   kni_net_process_request(netdev, &req);
+   if (req.req_id)
+   kni_net_process_request(netdev, &req);
 }
 
 /*
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index d3e236005e..e921d41ce8 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -31,6 +31,9 @@
 #define KNI_FIFO_COUNT_MAX 1024
 #define KNI_FIFO_SIZE  (KNI_FIFO_COUNT_MAX * sizeof(void *) + \
sizeof(struct rte_kni_fifo))
+#define KNI_REQS_SIZE  (KNI_FIFO_COUNT_MAX * \
+   sizeof(struct rte_kni_request) + \
+   sizeof(struct rte_kni_fifo))
 
 #define KNI_REQUEST_MBUF_NUM_MAX  32
 
@@ -175,8 +178,8 @@ kni_reserve_mz(struct rte_kni *kni)
KNI_MEM_CHECK(kni->m_resp_q == NULL, resp_q_fail);
 
snprintf(mz_name, RTE_MEMZONE_NAMESIZE, KNI_SYNC_ADDR_MZ_NAME_FMT, 
kni->name);
-   kni->m_sync_addr = rte_memzone_reserve(mz_name

[dpdk-dev] [PATCH v2] efd: change data type of parameter

2021-09-17 Thread Pablo de Lara
rte_efd_create() function was using uint8_t for a socket bitmask,
for one of its parameters.
This limits the maximum of NUMA sockets to be 8.
Changing to to uint64_t increases it to 64, which should be
more future-proof.

Coverity issue: 366390
Fixes: 56b6ef874f8 ("efd: new Elastic Flow Distributor library")

Signed-off-by: Pablo de Lara 
Acked-by: John McNamara 
---

v2: Fixed EFD tests

 app/test/test_efd.c  | 4 ++--
 app/test/test_efd_perf.c | 4 ++--
 lib/efd/rte_efd.c| 2 +-
 lib/efd/rte_efd.h| 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index 180dc4748e..581519c1e0 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -91,9 +91,9 @@ static struct flow_key keys[5] = {
 /* Array to store the data */
 static efd_value_t data[5];
 
-static inline uint8_t efd_get_all_sockets_bitmask(void)
+static inline uint64_t efd_get_all_sockets_bitmask(void)
 {
-   uint8_t all_cpu_sockets_bitmask = 0;
+   uint64_t all_cpu_sockets_bitmask = 0;
unsigned int i;
unsigned int next_lcore = rte_get_main_lcore();
const int val_true = 1, val_false = 0;
diff --git a/app/test/test_efd_perf.c b/app/test/test_efd_perf.c
index 1c47704475..f3fe3b1736 100644
--- a/app/test/test_efd_perf.c
+++ b/app/test/test_efd_perf.c
@@ -29,9 +29,9 @@
 #endif
 static unsigned int test_socket_id;
 
-static inline uint8_t efd_get_all_sockets_bitmask(void)
+static inline uint64_t efd_get_all_sockets_bitmask(void)
 {
-   uint8_t all_cpu_sockets_bitmask = 0;
+   uint64_t all_cpu_sockets_bitmask = 0;
unsigned int i;
unsigned int next_lcore = rte_get_main_lcore();
const int val_true = 1, val_false = 0;
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 77f46809f8..68a2378e88 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -495,7 +495,7 @@ efd_search_hash(struct rte_efd_table * const table,
 
 struct rte_efd_table *
 rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
-   uint8_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket)
+   uint64_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket)
 {
struct rte_efd_table *table = NULL;
uint8_t *key_array = NULL;
diff --git a/lib/efd/rte_efd.h b/lib/efd/rte_efd.h
index c2be4c09ae..d3d7befd0c 100644
--- a/lib/efd/rte_efd.h
+++ b/lib/efd/rte_efd.h
@@ -139,7 +139,7 @@ typedef uint16_t efd_hashfunc_t;
  */
 struct rte_efd_table *
 rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
-   uint8_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket);
+   uint64_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket);
 
 /**
  * Releases the resources from an EFD table
-- 
2.25.1



Re: [dpdk-dev] [RFC V1] examples/l3fwd-power: fix memory leak for rte_pci_device

2021-09-17 Thread Thomas Monjalon
17/09/2021 04:13, Huisong Li:
> 在 2021/9/16 18:36, Thomas Monjalon 写道:
> > 16/09/2021 10:01, Huisong Li:
> >> 在 2021/9/8 15:20, Thomas Monjalon 写道:
> >>> 08/09/2021 04:01, Huisong Li:
>  在 2021/9/7 16:53, Thomas Monjalon 写道:
> > 07/09/2021 05:41, Huisong Li:
> >> Calling rte_eth_dev_close() will release resources of eth device and 
> >> close
> >> it. But rte_pci_device struct isn't released when app exit, which will 
> >> lead
> >> to memory leak.
> > That's a PMD issue.
> > When the last port of a PCI device is closed, the device should be 
> > freed.
>  Why is this a PMD problem? I don't understand.
> >>> In the PMD close function, freeing of PCI device must be managed,
> >>> so the app doesn't have to bother.
> >> I know what you mean. Currently, there are two ways to close PMD device
> >> (rte_eth_dev_close() and rte_dev_remove()).
> >>
> >> For rte_dev_remove(), eth device can be closed and rte_pci_device also
> >> can be freed, so it can make app not care about that.
> >>
> >> But dev_close() is only used to close eth device, and nothing about
> >> rte_pci_device is involved in the framework layer
> >>
> >> call stack of dev_close(). The rte_pci_device is allocated and
> >> initialized when the rte_pci_bus scans "/sys/bus/pci/devices" directory.
> >>
> >> Generally, the PMD of eth devices operates on the basis of eth devices,
> >> and rarely on rte_pci_device.
> > 
> > No. The PMD is doing the relation between the PCI device and the ethdev 
> > port.
> 
> It seems that the ethdev layer can create eth devices based on 
> rte_pci_device, but does not release rte_pci_device.

No, the ethdev layer does not manage any bus.
Only the PMD does that.

> >> And the rte_pci_device corresponding to the eth devices managed and
> >> processed by rte_pci_bus.
> >>
> >> So, PMD is closed only based on the port ID of the eth device, whilch
> >> only shuts down eth devices, not frees rte_pci_device
> >> and remove it from rte_pci_bus.
> > Not really.
> I do not see any PMD driver releasing rte_pci_device in dev_close().

Maybe not but we should.

> > If there is no port using the PCI device, it should be released.
> 
> Yes.
> >
>  As far as I know, most apps or examples in the DPDK project have only
>  one port for a pci device.
> >>> The number of ports per PCI device is driver-specific.
> >>>
>  When the port is closed, the rte_pci_device should be freed. But none of
>  the apps seem to do this.
> >>> That's because from the app point of view, only ports should be managed.
> >>> The hardware device is managed by the PMD.
> >>> Only drivers (PMDs) have to do the relation between class ports
> >>> and hardware devices.
> >> 
> >> Yes. But the current app only closes the port to disable the PMD, and
> >> the rte_pci_device cannot be freed.
> > 
> > Why not?
> 
> Because most apps in DPDK call dev_close() to close the eth device 
> corresponding to a port.

You don't say why the underlying PCI device could not be freed.

> >> Because rte_pci_device cannot be released in dev_close() of PMD, and is
> >> managed by framework layer.
> > 
> > No
> >
> >> Btw. Excluding rte_dev_probe() and rte_dev_remove(),  it seems that the
> >> DPDK framework only automatically
> >> scans PCI devices, but does not automatically release PCI devices when
> >> the process exits.
> > 
> > Indeed, because such freeing is the responsibility of the PMD.
> 
> Do you mean to free rte_pci_device in the dev_close() API?

I mean free the PCI device in the PMD implementation of dev_close.

> How should PMD free it? What should we do? Any good suggestions?

Check that there is no other port sharing the same PCI device,
then call the PMD callback for rte_pci_remove_t.

> Would it be more appropriate to do this in rte_eal_cleanup() if it 
> cann't be done in the API above?

rte_eal_cleanup is a last cleanup for what was not done earlier.
We could do that but first we should properly free devices when closed.




Re: [dpdk-dev] [EXT] [PATCH v2 4/9] examples/ipsec-secgw: add stats interval argument

2021-09-17 Thread Anoob Joseph
Hi Radu,

Please see inline.

Thanks,
Anoob

> Subject: Re: [EXT] [dpdk-dev] [PATCH v2 4/9] examples/ipsec-secgw: add
> stats interval argument
> 
> Hi Anoob,
> 
> On 9/16/2021 10:30 AM, Anoob Joseph wrote:
> > Hi Radu,
> >
> > Making stats dynamic would have a perf cost. That was the reason it was
> introduced as a compile time option. Why do we need it changed?
> We changed it for two reasons, for a better UX and for the telemetry feature
> that is introduced with patch 3.
> >
> > Also, it looks like this patch is only disabling stats printing when 
> > timeout is 0.
> I don't see stats collection being conditional. Stats collection would also 
> have
> perf impact, right?
> I don't think there is a measurable performance impact because these are
> per burst calls.

[Anoob] Agreed. If it was done intentionally, then I don’t see any problem.

Acked-by: Anoob Joseph 
 
[snip]


Re: [dpdk-dev] [PATCH] doc: remove template comments in old release notes

2021-09-17 Thread Thomas Monjalon
17/09/2021 12:56, Mcnamara, John:
> > -Original Message-
> > From: Thomas Monjalon 
> > Sent: Wednesday, September 15, 2021 5:25 PM
> > To: dev@dpdk.org
> > Cc: Mcnamara, John ; david.march...@redhat.com;
> > Yigit, Ferruh 
> > Subject: [PATCH] doc: remove template comments in old release notes
> > 
> > The release notes comments mention how to generate the documentation
> > with the old & removed build system.
> > 
> > Rather than fixing these comments, all old release notes comments
> > are removed, because they are useful only for the current release.
> 
> 
> Good point. We should remember to remove these how-to comments in the last 
> pass of reviewing the release notes as well.

Yes, basically removing in your patch at the end of a release.
And then add it back for the next release.




Re: [dpdk-dev] [PATCH v3] devtools: add acronyms in dictionary for commit checks

2021-09-17 Thread Thomas Monjalon
17/09/2021 12:58, Ashwin Sekhar T K:
> Update word list with Marvell specific acronyms.
> 
> CPT  -> Cryptographic Accelerator Unit
> CQ   -> Completion Queue
> LBK  -> Loopback Interface Unit
> LMT  -> Large Atomic Store Unit

How LMT means that?

> MCAM -> Match Content Addressable Memory

Is it specific to a device?

> NIX  -> Network Interface Controller Unit

Where is it used? Is it different of NIC?

> NPA  -> Network Pool Allocator
> NPC  -> Network Parser and CAM Unit
> ROC  -> Rest Of Chip

All these stuff look device-specific. Please add details.

> RQ   -> Receive Queue
> RVU  -> Resource Virtualization Unit
> SQ   -> Send Queue
> SSO  -> Schedule Synchronize Order Unit
> TIM  -> Timer Unit







[dpdk-dev] [PATCH v3] efd: change data type of parameter

2021-09-17 Thread Pablo de Lara
rte_efd_create() function was using uint8_t for a socket bitmask,
for one of its parameters.
This limits the maximum of NUMA sockets to be 8.
Changing to uint64_t increases it to 64, which should be
more future-proof.

Coverity issue: 366390
Fixes: 56b6ef874f8 ("efd: new Elastic Flow Distributor library")

Signed-off-by: Pablo de Lara 
Acked-by: John McNamara 
---

v3: Fixed commit message

v2: Fixed EFD tests

---

 app/test/test_efd.c  | 4 ++--
 app/test/test_efd_perf.c | 4 ++--
 lib/efd/rte_efd.c| 2 +-
 lib/efd/rte_efd.h| 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_efd.c b/app/test/test_efd.c
index 180dc4748e..581519c1e0 100644
--- a/app/test/test_efd.c
+++ b/app/test/test_efd.c
@@ -91,9 +91,9 @@ static struct flow_key keys[5] = {
 /* Array to store the data */
 static efd_value_t data[5];
 
-static inline uint8_t efd_get_all_sockets_bitmask(void)
+static inline uint64_t efd_get_all_sockets_bitmask(void)
 {
-   uint8_t all_cpu_sockets_bitmask = 0;
+   uint64_t all_cpu_sockets_bitmask = 0;
unsigned int i;
unsigned int next_lcore = rte_get_main_lcore();
const int val_true = 1, val_false = 0;
diff --git a/app/test/test_efd_perf.c b/app/test/test_efd_perf.c
index 1c47704475..f3fe3b1736 100644
--- a/app/test/test_efd_perf.c
+++ b/app/test/test_efd_perf.c
@@ -29,9 +29,9 @@
 #endif
 static unsigned int test_socket_id;
 
-static inline uint8_t efd_get_all_sockets_bitmask(void)
+static inline uint64_t efd_get_all_sockets_bitmask(void)
 {
-   uint8_t all_cpu_sockets_bitmask = 0;
+   uint64_t all_cpu_sockets_bitmask = 0;
unsigned int i;
unsigned int next_lcore = rte_get_main_lcore();
const int val_true = 1, val_false = 0;
diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 77f46809f8..68a2378e88 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -495,7 +495,7 @@ efd_search_hash(struct rte_efd_table * const table,
 
 struct rte_efd_table *
 rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
-   uint8_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket)
+   uint64_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket)
 {
struct rte_efd_table *table = NULL;
uint8_t *key_array = NULL;
diff --git a/lib/efd/rte_efd.h b/lib/efd/rte_efd.h
index c2be4c09ae..d3d7befd0c 100644
--- a/lib/efd/rte_efd.h
+++ b/lib/efd/rte_efd.h
@@ -139,7 +139,7 @@ typedef uint16_t efd_hashfunc_t;
  */
 struct rte_efd_table *
 rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
-   uint8_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket);
+   uint64_t online_cpu_socket_bitmask, uint8_t offline_cpu_socket);
 
 /**
  * Releases the resources from an EFD table
-- 
2.25.1



[dpdk-dev] [PATCH v4 0/5] Add lookaside IPsec tests

2021-09-17 Thread Anoob Joseph
Add lookaside IPsec functional tests. Known vector tests and
combined mode framework is added.

Known vectors are outbound vectors based on
https://datatracker.ietf.org/doc/html/draft-mcgrew-gcm-test-01

The vectors are updated to have sequence number as 1 & L4 checksum
computed correctly. And they have following properties,
1. ESP
2. Tunnel mode
3. IPv4
4. IPv4 tunnel

Known vector tests for inbound operation would generate test vectors by
reversing outbound known vectors. The input_text would become encrypted
packet and output_text would be the plain packet. Tests would then validate
the operation by comparing against plain packet.

Combined mode tests are used to test all IPsec features against all ciphers
supported by the PMD. The framework is introduced to avoid testing
with any specific algo, thereby making it mandatory to be supported. Also,
testing with all supported combinations will help with increasing coverage
as well.

Four test cases use combined mode,
1. Display algo coverage and basic in + out tests
2. Negative test for ICV corruption
3. IV generation
4. UDP encapsulation

IV generation test case compares IV generated for a batch of packets and returns
failure if IV is repeated.

Upcoming additions,
1. AES-CBC-SHA1-HMAC known vectors & combined mode
2. IPv6
3. Transport
4. Mixed mode (IPv4-in-IPv6 etc, all combinations)

Tested with following PMDs
1. crypto_octeontx2
2. crypto_cn10k
3. crypto_cn9k

Changes in v4:
- Fixed lack of device stop in case capability check fails (comment from Ciara)
- Rebased and updated release notes

Changes in v3
- Added UDP encapsulation tests

Changes in v2
- Dropped outbound known vector tests as lookaside protocol would require IV
  generated by PMD. The tests would be introduced with spec change to allow user
  to specify IV.
- Added IV generation tests
- Minor fixes in combined mode tests to handle multiple packets

Anoob Joseph (2):
  test/crypto: add lookaside IPsec tests
  test/crypto: add combined mode tests

Tejasree Kondoj (3):
  test/crypto: add lookaside IPsec ICV corrupt test case
  test/crypto: add IV gen tests
  test/crypto: add UDP encapsulation test cases

 app/test/meson.build   |   1 +
 app/test/test.h|   6 +
 app/test/test_cryptodev.c  | 351 ++
 app/test/test_cryptodev_security_ipsec.c   | 401 +
 app/test/test_cryptodev_security_ipsec.h   | 119 ++
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +
 doc/guides/rel_notes/release_21_11.rst |   7 +
 7 files changed, 1206 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h

-- 
2.7.4



[dpdk-dev] [PATCH v4 1/5] test/crypto: add lookaside IPsec tests

2021-09-17 Thread Anoob Joseph
Added test case for lookaside IPsec. Inbound known vector
tests are added.

Cipher list: AES-GCM 128, 192 & 256

Signed-off-by: Anoob Joseph 
Signed-off-by: Tejasree Kondoj 

---
 app/test/meson.build   |   1 +
 app/test/test.h|   6 +
 app/test/test_cryptodev.c  | 232 +++
 app/test/test_cryptodev_security_ipsec.c   | 212 ++
 app/test/test_cryptodev_security_ipsec.h   |  66 +
 .../test_cryptodev_security_ipsec_test_vectors.h   | 321 +
 6 files changed, 838 insertions(+)
 create mode 100644 app/test/test_cryptodev_security_ipsec.c
 create mode 100644 app/test/test_cryptodev_security_ipsec.h
 create mode 100644 app/test/test_cryptodev_security_ipsec_test_vectors.h

diff --git a/app/test/meson.build b/app/test/meson.build
index a761168..f144d8b 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -38,6 +38,7 @@ test_sources = files(
 'test_cryptodev.c',
 'test_cryptodev_asym.c',
 'test_cryptodev_blockcipher.c',
+'test_cryptodev_security_ipsec.c',
 'test_cryptodev_security_pdcp.c',
 'test_cycles.c',
 'test_debug.c',
diff --git a/app/test/test.h b/app/test/test.h
index c3b2a87..7115edf 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -124,6 +124,12 @@ struct unit_test_case {
 #define TEST_CASE_WITH_DATA(setup, teardown, testcase, data) \
{ setup, teardown, NULL, testcase, #testcase, 1, data }
 
+#define TEST_CASE_NAMED_ST(name, setup, teardown, testcase) \
+   { setup, teardown, NULL, testcase, name, 1, NULL }
+
+#define TEST_CASE_NAMED_WITH_DATA(name, setup, teardown, testcase, data) \
+   { setup, teardown, NULL, testcase, name, 1, data }
+
 #define TEST_CASE_DISABLED(fn) { NULL, NULL, fn, NULL, #fn, 0, NULL }
 
 #define TEST_CASE_ST_DISABLED(setup, teardown, testcase) \
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 16d770a..9c7875c 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #ifdef RTE_CRYPTO_SCHEDULER
@@ -41,6 +42,8 @@
 #include "test_cryptodev_hmac_test_vectors.h"
 #include "test_cryptodev_mixed_test_vectors.h"
 #ifdef RTE_LIB_SECURITY
+#include "test_cryptodev_security_ipsec.h"
+#include "test_cryptodev_security_ipsec_test_vectors.h"
 #include "test_cryptodev_security_pdcp_test_vectors.h"
 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
 #include "test_cryptodev_security_pdcp_test_func.h"
@@ -123,6 +126,13 @@ test_AES_CBC_HMAC_SHA512_decrypt_perform(struct 
rte_cryptodev_sym_session *sess,
const uint8_t *digest,
const uint8_t *iv);
 
+static int
+security_proto_supported(enum rte_security_session_action_type action,
+   enum rte_security_session_protocol proto);
+
+static int
+dev_configure_and_start(uint64_t ff_disable);
+
 static struct rte_mbuf *
 setup_test_string(struct rte_mempool *mpool,
const char *string, size_t len, uint8_t blocksize)
@@ -753,6 +763,43 @@ crypto_gen_testsuite_setup(void)
 
 #ifdef RTE_LIB_SECURITY
 static int
+ipsec_proto_testsuite_setup(void)
+{
+   struct crypto_testsuite_params *ts_params = &testsuite_params;
+   struct crypto_unittest_params *ut_params = &unittest_params;
+   struct rte_cryptodev_info dev_info;
+   int ret = 0;
+
+   rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
+
+   if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
+   RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto 
"
+   "testsuite not met\n");
+   return TEST_SKIPPED;
+   }
+
+   /* Reconfigure to enable security */
+   dev_configure_and_start(RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+   RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO);
+
+   /* Set action type */
+   ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
+
+   if (security_proto_supported(
+   RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
+   RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
+   RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
+   "test not met\n");
+   ret = TEST_SKIPPED;
+   }
+
+   /* Stop the device */
+   rte_cryptodev_stop(ts_params->valid_devs[0]);
+
+   return ret;
+}
+
+static int
 pdcp_proto_testsuite_setup(void)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
@@ -8854,6 +8901,170 @@ test_PDCP_SDAP_PROTO_decap_all(void)
 }
 
 static int
+test_ipsec_proto_process(const struct ipsec_test_data td[],
+struct ipsec_test_data res_d[],
+int nb_td,
+bool silent)
+{
+   struct crypto_testsuite_params *ts_params = &t

[dpdk-dev] [PATCH v4 2/5] test/crypto: add combined mode tests

2021-09-17 Thread Anoob Joseph
Add framework to test IPsec features with all supported
combinations of ciphers.

Signed-off-by: Anoob Joseph 
Signed-off-by: Tejasree Kondoj 

---
 app/test/test_cryptodev.c|  73 +++--
 app/test/test_cryptodev_security_ipsec.c | 107 +--
 app/test/test_cryptodev_security_ipsec.h |  52 ++-
 3 files changed, 223 insertions(+), 9 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 9c7875c..7fd246e 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -8904,7 +8904,8 @@ static int
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 struct ipsec_test_data res_d[],
 int nb_td,
-bool silent)
+bool silent,
+const struct ipsec_test_flags *flags)
 {
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
@@ -9021,7 +9022,7 @@ test_ipsec_proto_process(const struct ipsec_test_data 
td[],
/* Process crypto operation */
process_crypto_request(dev_id, ut_params->op);
 
-   ret = test_ipsec_status_check(ut_params->op, dir);
+   ret = test_ipsec_status_check(ut_params->op, flags, dir);
if (ret != TEST_SUCCESS)
goto crypto_op_free;
 
@@ -9029,7 +9030,7 @@ test_ipsec_proto_process(const struct ipsec_test_data 
td[],
res_d_tmp = &res_d[i];
 
ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
- res_d_tmp, silent);
+ res_d_tmp, silent, flags);
if (ret != TEST_SUCCESS)
goto crypto_op_free;
 
@@ -9057,11 +9058,71 @@ test_ipsec_proto_process(const struct ipsec_test_data 
td[],
 static int
 test_ipsec_proto_known_vec_inb(const void *td_outb)
 {
+   struct ipsec_test_flags flags;
struct ipsec_test_data td_inb;
 
+   memset(&flags, 0, sizeof(flags));
+
test_ipsec_td_in_from_out(td_outb, &td_inb);
 
-   return test_ipsec_proto_process(&td_inb, NULL, 1, false);
+   return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
+}
+
+static int
+test_ipsec_proto_all(const struct ipsec_test_flags *flags)
+{
+   struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
+   struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
+   unsigned int i, nb_pkts = 1, pass_cnt = 0;
+   int ret;
+
+   for (i = 0; i < RTE_DIM(aead_list); i++) {
+   test_ipsec_td_prepare(&aead_list[i],
+ NULL,
+ flags,
+ td_outb,
+ nb_pkts);
+
+   ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
+  flags);
+   if (ret == TEST_SKIPPED)
+   continue;
+
+   if (ret == TEST_FAILED)
+   return TEST_FAILED;
+
+   test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
+
+   ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
+  flags);
+   if (ret == TEST_SKIPPED)
+   continue;
+
+   if (ret == TEST_FAILED)
+   return TEST_FAILED;
+
+   if (flags->display_alg)
+   test_ipsec_display_alg(&aead_list[i], NULL);
+
+   pass_cnt++;
+   }
+
+   if (pass_cnt > 0)
+   return TEST_SUCCESS;
+   else
+   return TEST_SKIPPED;
+}
+
+static int
+test_ipsec_proto_display_list(const void *data __rte_unused)
+{
+   struct ipsec_test_flags flags;
+
+   memset(&flags, 0, sizeof(flags));
+
+   flags.display_alg = true;
+
+   return test_ipsec_proto_all(&flags);
 }
 
 static int
@@ -13971,6 +14032,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = 
{
"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 
256)",
ut_setup_security, ut_teardown,
test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
+   TEST_CASE_NAMED_ST(
+   "Combined test alg list",
+   ut_setup_security, ut_teardown,
+   test_ipsec_proto_display_list),
TEST_CASES_END() /**< NULL terminate unit test array */
}
 };
diff --git a/app/test/test_cryptodev_security_ipsec.c 
b/app/test/test_cryptodev_security_ipsec.c
index 2431fcb..d08e093 100644
--- a/app/test/test_cryptodev_security_ipsec.c
+++ b/app/test/test_cryptodev_security_ipsec.c
@@ -10,6 +10,8 @@
 #include "test.h"
 #include "test_cryptodev_s

  1   2   3   >