[PATCH v2] test/bpf: skip test if libpcap is unavailable

2022-03-22 Thread Tyler Retzlaff
test_bpf_convert is being conditionally registered depending on the
presence of RTE_HAS_LIBPCAP except the UT unconditionally lists it as a
test to run.

when the UT runs test_bpf_convert test-dpdk can't find the registration
and assumes the DPDK_TEST environment variable hasn't been defined
resulting in test-dpdk dropping to interactive mode and subsequently
waiting for the remainder of the UT fast-test timeout period before
reporting the test as having timed out.

* unconditionally register test_bpf_convert
* if ! RTE_HAS_LIBPCAP provide a stub test_bpf_convert that reports the
  test is skipped similar to that done with the test_bpf test.

Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
Cc: step...@networkplumber.org
Cc: anatoly.bura...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Tyler Retzlaff 
---
 app/test/test_bpf.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index 805cce6..97f5008 100644
--- a/app/test/test_bpf.c
+++ b/app/test/test_bpf.c
@@ -3264,7 +3264,16 @@ struct bpf_test {
 
 REGISTER_TEST_COMMAND(bpf_autotest, test_bpf);
 
-#ifdef RTE_HAS_LIBPCAP
+#ifndef RTE_HAS_LIBPCAP
+
+static int
+test_bpf_convert(void)
+{
+   printf("BPF convert RTE_HAS_LIBPCAP is undefined, skipping test\n");
+   return TEST_SKIPPED;
+}
+
+#else
 #include 
 
 static void
@@ -3462,5 +3471,6 @@ struct bpf_test {
return rc;
 }
 
-REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);
 #endif /* RTE_HAS_LIBPCAP */
+
+REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);
-- 
1.8.3.1



RE: [RFC,v2 1/3] ethdev: introduce protocol type based header split

2022-03-22 Thread Zhang, Qi Z



> -Original Message-
> From: Ding, Xuan 
> Sent: Tuesday, March 22, 2022 11:56 AM
> To: tho...@monjalon.net; Yigit, Ferruh ;
> andrew.rybche...@oktetlabs.ru
> Cc: dev@dpdk.org; step...@networkplumber.org;
> m...@smartsharesystems.com; viachesl...@nvidia.com; Zhang, Qi Z
> ; Yu, Ping ; Wu, WenxuanX
> ; Ding, Xuan ; Wang,
> YuanX 
> Subject: [RFC,v2 1/3] ethdev: introduce protocol type based header split
> 
> From: Xuan Ding 
> 
> Header split consists of splitting a received packet into two separate regions
> based on the packet content. The split happens after the packet header and
> before the packet payload. Splitting is usually between the packet header
> that can be posted to a dedicated buffer and the packet payload that can be
> posted to a different buffer.
> 
> Currently, Rx buffer split supports length and offset based packet split.
> Although header split is a subset of buffer split, configure buffer split 
> based
> on length and offset is not suitable for NICs that do split based on header
> protocol types. And tunneling makes the conversion from offset to protocol
> impossible.
> 
> This patch extends the current buffer split to support protocol based header
> split. A new proto field is introduced in the rte_eth_rxseg_split structure
> reserved field to specify header protocol type. With Rx offload flag
> RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type
> configured, PMD will split the ingress packets into two separate regions.
> Currently, both inner and outer L2/L3/L4 level header split can be supported.
> 
> For example, let's suppose we configured the Rx queue with the following
> segments:
> seg0 - pool0
> seg1 - pool1
> 
> With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP,
> the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
> seg0 - pool0, udp_header
> seg1 - pool1, payload
> 
> The memory attributes for the split parts may differ either - for example the
> mempool0 and mempool1 belong to dpdk memory and external memory,
> respectively.
> 
> Signed-off-by: Xuan Ding 
> Signed-off-by: Yuan Wang 
> ---
>  lib/ethdev/rte_ethdev.c | 24 +--
> lib/ethdev/rte_ethdev.h | 43
> +++--
>  2 files changed, 55 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index
> 70c850a2f1..49c8fef1c3 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
> rte_eth_rxseg_split *rx_seg,
>   struct rte_mempool *mpl = rx_seg[seg_idx].mp;
>   uint32_t length = rx_seg[seg_idx].length;
>   uint32_t offset = rx_seg[seg_idx].offset;
> + uint16_t proto = rx_seg[seg_idx].proto;
> 
>   if (mpl == NULL) {
>   RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
> @@ -1692,15 +1693,17 @@ rte_eth_rx_queue_check_split(const struct
> rte_eth_rxseg_split *rx_seg,
>   (struct rte_pktmbuf_pool_private));
>   return -ENOSPC;
>   }
> - offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
> - *mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
> - length = length != 0 ? length : *mbp_buf_size;
> - if (*mbp_buf_size < length + offset) {
> - RTE_ETHDEV_LOG(ERR,
> -"%s mbuf_data_room_size %u < %u
> (segment length=%u + segment offset=%u)\n",
> -mpl->name, *mbp_buf_size,
> -length + offset, length, offset);
> - return -EINVAL;
> + if (proto == 0) {
> + offset += seg_idx != 0 ? 0 :
> RTE_PKTMBUF_HEADROOM;
> + *mbp_buf_size =
> rte_pktmbuf_data_room_size(mpl);
> + length = length != 0 ? length : *mbp_buf_size;
> + if (*mbp_buf_size < length + offset) {
> + RTE_ETHDEV_LOG(ERR,
> + "%s mbuf_data_room_size %u < %u
> (segment length=%u + segment offset=%u)\n",
> + mpl->name, *mbp_buf_size,
> + length + offset, length, offset);
> + return -EINVAL;
> + }
>   }

As the length and proto is exclusive, it better also check the length when 
proto!=0

.

> @@ -1197,12 +1197,26 @@ struct rte_eth_txmode {
>   * - pool from the last valid element
>   * - the buffer size from this pool
>   * - zero offset
> + *
> + * Header split is a subset of buffer split. The split happens after
> + the
> + * packet header and before the packet payload. For PMDs that do not
> + * support header split configuration by length and offset, the
> + location
> + * of the split needs to be spec

[PATCH] app/testpmd: fix quit testpmd with vfs and pf

2022-03-22 Thread Ke Zhang
When testpmd startups with pf and vfs,this error occurs when quitting,
results in pf is released before vfs ,so the vf would access an
freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Signed-off-by: Ke Zhang 
---
 app/test-pmd/testpmd.c | 28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f7e18aee25..ca6c77b14b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3378,8 +3378,11 @@ detach_devargs(char *identifier)
 void
 pmd_test_exit(void)
 {
+   unsigned int ports[RTE_MAX_ETHPORTS];
+   unsigned int count = 0;
portid_t pt_id;
unsigned int i;
+   int index;
int ret;
 
if (test_done == 0)
@@ -3396,15 +3399,30 @@ pmd_test_exit(void)
 #endif
if (ports != NULL) {
no_link_check = 1;
+   i = 0;
+
+   /* Fetch the valid port id from port list*/
RTE_ETH_FOREACH_DEV(pt_id) {
-   printf("\nStopping port %d...\n", pt_id);
+   ports[i] = pt_id;
+   i++;
+   }
+
+   count = i;
+   /*
+* Free the port from Reverse order, as general,
+* PF port < VF port, VF should be free before PF
+* be free.
+*/
+   for (index = count - 1 ; index >= 0 ; index--) {
+   printf("\nStopping port %d...\n", ports[index]);
fflush(stdout);
-   stop_port(pt_id);
+   stop_port(ports[index]);
}
-   RTE_ETH_FOREACH_DEV(pt_id) {
-   printf("\nShutting down port %d...\n", pt_id);
+
+   for (index = count - 1 ; index >= 0 ; index--) {
+   printf("\nShutting down port %d...\n", ports[index]);
fflush(stdout);
-   close_port(pt_id);
+   close_port(ports[index]);
}
}
 
-- 
2.25.1



RE: [RFC,v2 1/3] ethdev: introduce protocol type based header split

2022-03-22 Thread Ding, Xuan
Hi Qi,

> -Original Message-
> From: Zhang, Qi Z 
> Sent: Tuesday, March 22, 2022 3:14 PM
> To: Ding, Xuan ; tho...@monjalon.net; Yigit, Ferruh
> ; andrew.rybche...@oktetlabs.ru
> Cc: dev@dpdk.org; step...@networkplumber.org;
> m...@smartsharesystems.com; viachesl...@nvidia.com; Yu, Ping
> ; Wu, WenxuanX ; Wang,
> YuanX 
> Subject: RE: [RFC,v2 1/3] ethdev: introduce protocol type based header split
> 
> 
> 
> > -Original Message-
> > From: Ding, Xuan 
> > Sent: Tuesday, March 22, 2022 11:56 AM
> > To: tho...@monjalon.net; Yigit, Ferruh ;
> > andrew.rybche...@oktetlabs.ru
> > Cc: dev@dpdk.org; step...@networkplumber.org;
> > m...@smartsharesystems.com; viachesl...@nvidia.com; Zhang, Qi Z
> > ; Yu, Ping ; Wu, WenxuanX
> > ; Ding, Xuan ; Wang,
> YuanX
> > 
> > Subject: [RFC,v2 1/3] ethdev: introduce protocol type based header
> > split
> >
> > From: Xuan Ding 
> >
> > Header split consists of splitting a received packet into two separate
> > regions based on the packet content. The split happens after the
> > packet header and before the packet payload. Splitting is usually
> > between the packet header that can be posted to a dedicated buffer and
> > the packet payload that can be posted to a different buffer.
> >
> > Currently, Rx buffer split supports length and offset based packet split.
> > Although header split is a subset of buffer split, configure buffer
> > split based on length and offset is not suitable for NICs that do
> > split based on header protocol types. And tunneling makes the
> > conversion from offset to protocol impossible.
> >
> > This patch extends the current buffer split to support protocol based
> > header split. A new proto field is introduced in the
> > rte_eth_rxseg_split structure reserved field to specify header
> > protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT
> > enabled and protocol type configured, PMD will split the ingress packets
> into two separate regions.
> > Currently, both inner and outer L2/L3/L4 level header split can be
> supported.
> >
> > For example, let's suppose we configured the Rx queue with the
> > following
> > segments:
> > seg0 - pool0
> > seg1 - pool1
> >
> > With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP,
> > the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
> > seg0 - pool0, udp_header
> > seg1 - pool1, payload
> >
> > The memory attributes for the split parts may differ either - for
> > example the
> > mempool0 and mempool1 belong to dpdk memory and external memory,
> > respectively.
> >
> > Signed-off-by: Xuan Ding 
> > Signed-off-by: Yuan Wang 
> > ---
> >  lib/ethdev/rte_ethdev.c | 24 +--
> > lib/ethdev/rte_ethdev.h | 43
> > +++--
> >  2 files changed, 55 insertions(+), 12 deletions(-)
> >
> > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index
> > 70c850a2f1..49c8fef1c3 100644
> > --- a/lib/ethdev/rte_ethdev.c
> > +++ b/lib/ethdev/rte_ethdev.c
> > @@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
> > rte_eth_rxseg_split *rx_seg,  struct rte_mempool *mpl =
> > rx_seg[seg_idx].mp;  uint32_t length = rx_seg[seg_idx].length;
> > uint32_t offset = rx_seg[seg_idx].offset;
> > +uint16_t proto = rx_seg[seg_idx].proto;
> >
> >  if (mpl == NULL) {
> >  RTE_ETHDEV_LOG(ERR, "null mempool pointer\n"); @@ -1692,15
> +1693,17
> > @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split
> > *rx_seg,  (struct rte_pktmbuf_pool_private));  return -ENOSPC;  }
> > -offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; -*mbp_buf_size =
> > rte_pktmbuf_data_room_size(mpl); -length = length != 0 ? length :
> > *mbp_buf_size; -if (*mbp_buf_size < length + offset) {
> > -RTE_ETHDEV_LOG(ERR,
> > -   "%s mbuf_data_room_size %u < %u
> > (segment length=%u + segment offset=%u)\n",
> > -   mpl->name, *mbp_buf_size,
> > -   length + offset, length, offset);
> > -return -EINVAL;
> > +if (proto == 0) {
> > +offset += seg_idx != 0 ? 0 :
> > RTE_PKTMBUF_HEADROOM;
> > +*mbp_buf_size =
> > rte_pktmbuf_data_room_size(mpl);
> > +length = length != 0 ? length : *mbp_buf_size; if (*mbp_buf_size <
> > +length + offset) { RTE_ETHDEV_LOG(ERR, "%s mbuf_data_room_size %u <
> > +%u
> > (segment length=%u + segment offset=%u)\n",
> > +mpl->name, *mbp_buf_size,
> > +length + offset, length, offset);
> > +return -EINVAL;
> > +}
> >  }
> 
> As the length and proto is exclusive, it better also check the length when
> proto!=0

Thanks for your comments, will fix it in next version.

> 
> .
> 
> > @@ -1197,12 +1197,26 @@ struct rte_eth_txmode {
> >   * - pool from the last valid element
> >   * - the buffer size from this pool
> >   * - zero offset
> > + *
> > + * Header split is a subset of buffer split. The split happens after
> > + the
> > + * packet header and before the packet payload. For PMDs that do not
> > + * support header split configuration by length and offset, the
> > + l

[PATCH] app/testpmd: fix quit testpmd with vfs and pf

2022-03-22 Thread Ke Zhang
When testpmd startups with pf and vfs,this error occurs when quitting,
results in pf is released before vfs ,so the vf would access an
freed heap memory.

The solution is two steps:
1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
2. free the port in reverse order.

Signed-off-by: Ke Zhang 
---
 app/test-pmd/testpmd.c | 28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f7e18aee25..2299aef3dd 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3378,8 +3378,11 @@ detach_devargs(char *identifier)
 void
 pmd_test_exit(void)
 {
+   unsigned int ethports[RTE_MAX_ETHPORTS];
+   unsigned int count = 0;
portid_t pt_id;
unsigned int i;
+   int index;
int ret;
 
if (test_done == 0)
@@ -3396,15 +3399,30 @@ pmd_test_exit(void)
 #endif
if (ports != NULL) {
no_link_check = 1;
+   i = 0;
+
+   /* Fetch the valid port id from port list*/
RTE_ETH_FOREACH_DEV(pt_id) {
-   printf("\nStopping port %d...\n", pt_id);
+   ethports[i] = pt_id;
+   i++;
+   }
+
+   count = i;
+   /*
+* Free the port from Reverse order, as general,
+* PF port < VF port, VF should be free before PF
+* be free.
+*/
+   for (index = count - 1 ; index >= 0 ; index--) {
+   printf("\nStopping port %d...\n", ethports[index]);
fflush(stdout);
-   stop_port(pt_id);
+   stop_port(ethports[index]);
}
-   RTE_ETH_FOREACH_DEV(pt_id) {
-   printf("\nShutting down port %d...\n", pt_id);
+
+   for (index = count - 1 ; index >= 0 ; index--) {
+   printf("\nShutting down port %d...\n", ethports[index]);
fflush(stdout);
-   close_port(pt_id);
+   close_port(ethports[index]);
}
}
 
-- 
2.25.1



[RFC PATCH 2/2] test: add proper pkcs1 signature tests for rsa

2022-03-22 Thread Arek Kusztal
This commit adds example pkcs1 signature tests.

Signed-off-by: Arek Kusztal 
---
 app/test/test_cryptodev_asym.c   | 249 +--
 drivers/crypto/openssl/rte_openssl_pmd.c |  34 -
 lib/cryptodev/rte_crypto_asym.h  |   6 +-
 3 files changed, 270 insertions(+), 19 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 71378cbdb2..512eb34377 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 #include "test_cryptodev.h"
 #include "test_cryptodev_dh_test_vectors.h"
@@ -163,6 +164,222 @@ queue_ops_rsa_sign_verify(void *sess)
return status;
 }
 
+/* DPDK RFC RSA 22.07 */
+
+static uint8_t
+rsa_sign_pkcs_15_pt[] = {
+   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+   0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+   0x11, 0x12, 0x13, 0x14,
+};
+
+static uint8_t
+rsa_sign_pkcs_15_pt_sha256[] = {
+   0xB1, 0xB2, 0xB3, 0xB4, 0xA1, 0xA2, 0xA3, 0xA4,
+   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+   0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+   0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+};
+
+static uint8_t
+rsa_sign_pkcs_15_padded[] = {
+   0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04,
+   0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
+   0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+};
+
+static uint8_t
+rsa_sign_pkcs_15_padded_digestinfo_sha1[] = {
+   0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x30, 0x21, 0x30,
+   0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a,
+   0x05, 0x00, 0x04, 0x14, 0x01, 0x02, 0x03, 0x04,
+   0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
+   0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
+};
+
+static uint8_t
+rsa_sign_pkcs_15_padded_digestinfo_sha256[] = {
+   0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x30, 0x31, 0x30,
+   0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 
+   0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20,
+   0xB1, 0xB2, 0xB3, 0xB4, 0xA1, 0xA2, 0xA3, 0xA4,
+   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+   0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+   0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+};
+
+static void*
+rfc2207_rsa_sign_pkcs_15_sesscreat(void)
+{
+   struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
+   struct rte_mempool *sess_mpool = ts_params->session_mpool;
+   uint8_t dev_id = ts_params->valid_devs[0];
+   static void *sess = NULL;
+   int ret;
+
+   if (sess)
+   return sess;
+   ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform, sess_mpool, 
&sess);
+
+   if (ret < 0) {
+   RTE_LOG(ERR, USER1, "Session creation failed for "
+   "sign_verify\n");
+   return NULL;
+   }
+   return sess;
+}
+
+struct rfc2207_rsa_test_data
+{
+   enum rte_crypto_rsa_padding_type type;
+   rte_crypto_param input;
+   enum rte_crypto_auth_algorithm hash;
+};
+
+struct rfc2207_rsa_test_data
+rfc2207_rsa_test_data_ssl23 = {
+   .type =

[RFC PATCH 1/2] cryptodev: rsa improvements

2022-03-22 Thread Arek Kusztal
This commit reworks rsa implementation.

Signed-off-by: Arek Kusztal 
---
 app/test/test_cryptodev_asym.c |  90 +++--
 app/test/test_cryptodev_asym_util.h|   4 +-
 drivers/crypto/meson.build |   4 +-
 drivers/crypto/openssl/rte_openssl_pmd.c   |  36 ++---
 drivers/crypto/qat/dev/qat_asym_pmd_gen1.c |   2 +
 drivers/crypto/qat/qat_asym.c  |  28 ++--
 lib/cryptodev/rte_crypto_asym.h| 202 +
 7 files changed, 235 insertions(+), 131 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 573af2a537..71378cbdb2 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -75,6 +75,7 @@ queue_ops_rsa_sign_verify(void *sess)
struct rte_crypto_op *op, *result_op;
struct rte_crypto_asym_op *asym_op;
uint8_t output_buf[TEST_DATA_SIZE];
+   uint8_t input_sign[TEST_DATA_SIZE];
int status = TEST_SUCCESS;
 
/* Set up crypto op data structure */
@@ -90,14 +91,14 @@ queue_ops_rsa_sign_verify(void *sess)
/* Compute sign on the test vector */
asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
 
-   asym_op->rsa.message.data = rsaplaintext.data;
-   asym_op->rsa.message.length = rsaplaintext.len;
-   asym_op->rsa.sign.length = 0;
-   asym_op->rsa.sign.data = output_buf;
-   asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+   asym_op->rsa.input.data = rsaplaintext.data;
+   asym_op->rsa.input.length = rsaplaintext.len;
+   asym_op->rsa.output.length = 0;
+   asym_op->rsa.output.data = output_buf;
+   asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
-   debug_hexdump(stdout, "message", asym_op->rsa.message.data,
- asym_op->rsa.message.length);
+   debug_hexdump(stdout, "message", asym_op->rsa.input.data,
+ asym_op->rsa.input.length);
 
/* Attach asymmetric crypto session to crypto operations */
rte_crypto_op_attach_asym_session(op, sess);
@@ -120,13 +121,18 @@ queue_ops_rsa_sign_verify(void *sess)
goto error_exit;
}
 
-   debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
- asym_op->rsa.sign.length);
+   debug_hexdump(stdout, "signed message", asym_op->rsa.output.data,
+ asym_op->rsa.output.length);
asym_op = result_op->asym;
 
/* Verify sign */
+   memcpy(input_sign, asym_op->rsa.output.data, 
asym_op->rsa.output.length);
+   asym_op->rsa.input.data = input_sign;
+   asym_op->rsa.input.length = asym_op->rsa.output.length;
+   asym_op->rsa.message.data = rsaplaintext.data;
+   asym_op->rsa.message.length = rsaplaintext.len;
asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
-   asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+   asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
/* Process crypto operation */
if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
@@ -181,14 +187,14 @@ queue_ops_rsa_enc_dec(void *sess)
/* Compute encryption on the test vector */
asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
 
-   asym_op->rsa.message.data = rsaplaintext.data;
-   asym_op->rsa.cipher.data = cipher_buf;
-   asym_op->rsa.cipher.length = 0;
-   asym_op->rsa.message.length = rsaplaintext.len;
-   asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+   asym_op->rsa.input.data = rsaplaintext.data;
+   asym_op->rsa.output.data = cipher_buf;
+   asym_op->rsa.output.length = 0;
+   asym_op->rsa.input.length = rsaplaintext.len;
+   asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
-   debug_hexdump(stdout, "message", asym_op->rsa.message.data,
- asym_op->rsa.message.length);
+   debug_hexdump(stdout, "message", asym_op->rsa.input.data,
+ asym_op->rsa.input.length);
 
/* Attach asymmetric crypto session to crypto operations */
rte_crypto_op_attach_asym_session(op, sess);
@@ -210,14 +216,14 @@ queue_ops_rsa_enc_dec(void *sess)
status = TEST_FAILED;
goto error_exit;
}
-   debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,
- asym_op->rsa.message.length);
+   debug_hexdump(stdout, "encrypted message", asym_op->rsa.input.data,
+ asym_op->rsa.input.length);
 
/* Use the resulted output as decryption Input vector*/
asym_op = result_op->asym;
-   asym_op->rsa.message.length = 0;
+   asym_op->rsa.input.length = 0;
asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
-   asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
+   asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
/* Process crypto operation */
if (rte_cryptodev_enqueue_burst(dev_id, 0, &op

Re: [PATCH] net/i40e: Populate error in flow_parse_fdir_pattern

2022-03-22 Thread David Marchand
Hello Mike,

On Tue, Mar 22, 2022 at 4:20 AM Mike Pattrick  wrote:
>
> Errors from i40e_flow_parse_fdir_pattern() can bubble up to
> rte_flow_create. If rte_flow_error is not initialized a caller may
> dereference error->message. This may be uninitialized memory, leading
> to a segemntation fault.
>
> Signed-off-by: Mike Pattrick 
> Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow validate")
> Cc: sta...@dpdk.org

Nit: the convention in DPDK is to have a block with the Fixes: and Cc:
lines together first, then the rest of the tags in a second block.

Fixes: 4a072ad43442 ("net/i40e: fix flow director config after flow validate")
Cc: sta...@dpdk.org

Signed-off-by: Mike Pattrick 


> ---
>  drivers/net/i40e/i40e_flow.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index e0cf996200..4f3808cb5f 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -3142,8 +3142,11 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
> /* Check if the input set is valid */
> if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
> input_set) != 0) {
> -   PMD_DRV_LOG(ERR, "Invalid input set");
> -   return -EINVAL;
> +   rte_flow_error_set(error, EINVAL,
> +  RTE_FLOW_ERROR_TYPE_ITEM,
> +  item,
> +  "Invalid input set");
> +   return -rte_errno;
> }
>
> filter->input.flow_ext.input_set = input_set;
> --
> 2.27.0
>

Reviewed-by: David Marchand 


-- 
David Marchand



RE: [RFC PATCH 1/2] cryptodev: rsa improvements

2022-03-22 Thread Kusztal, ArkadiuszX
Hi,

> -Original Message-
> From: Kusztal, ArkadiuszX 
> Sent: Tuesday, March 22, 2022 9:11 AM
> To: dev@dpdk.org
> Cc: gak...@marvell.com; Zhang, Roy Fan ;
> ano...@marvell.com; Kusztal, ArkadiuszX 
> Subject: [RFC PATCH 1/2] cryptodev: rsa improvements
> 
> This commit reworks rsa implementation.
> 
> Signed-off-by: Arek Kusztal 
> ---
>  app/test/test_cryptodev_asym.c |  90 +++--
>  app/test/test_cryptodev_asym_util.h|   4 +-
>  drivers/crypto/meson.build |   4 +-
>  drivers/crypto/openssl/rte_openssl_pmd.c   |  36 ++---
>  drivers/crypto/qat/dev/qat_asym_pmd_gen1.c |   2 +
>  drivers/crypto/qat/qat_asym.c  |  28 ++--
>  lib/cryptodev/rte_crypto_asym.h| 202 
> +
>  7 files changed, 235 insertions(+), 131 deletions(-)
> 
> diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
> index 573af2a537..71378cbdb2 100644
> --- a/app/test/test_cryptodev_asym.c
> +++ b/app/test/test_cryptodev_asym.c
> @@ -75,6 +75,7 @@ queue_ops_rsa_sign_verify(void *sess)
>   struct rte_crypto_op *op, *result_op;
>   struct rte_crypto_asym_op *asym_op;
>   uint8_t output_buf[TEST_DATA_SIZE];
> + uint8_t input_sign[TEST_DATA_SIZE];
>   int status = TEST_SUCCESS;
> 
>   /* Set up crypto op data structure */
> @@ -90,14 +91,14 @@ queue_ops_rsa_sign_verify(void *sess)
>   /* Compute sign on the test vector */
>   asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
> 
> - asym_op->rsa.message.data = rsaplaintext.data;
> - asym_op->rsa.message.length = rsaplaintext.len;
> - asym_op->rsa.sign.length = 0;
> - asym_op->rsa.sign.data = output_buf;
> - asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
> + asym_op->rsa.input.data = rsaplaintext.data;
> + asym_op->rsa.input.length = rsaplaintext.len;
> + asym_op->rsa.output.length = 0;
> + asym_op->rsa.output.data = output_buf;
> + asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
> 
> - debug_hexdump(stdout, "message", asym_op->rsa.message.data,
> -   asym_op->rsa.message.length);
> + debug_hexdump(stdout, "message", asym_op->rsa.input.data,
> +   asym_op->rsa.input.length);
> 
>   /* Attach asymmetric crypto session to crypto operations */
>   rte_crypto_op_attach_asym_session(op, sess); @@ -120,13 +121,18
> @@ queue_ops_rsa_sign_verify(void *sess)
>   goto error_exit;
>   }
> 
> - debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
> -   asym_op->rsa.sign.length);
> + debug_hexdump(stdout, "signed message", asym_op->rsa.output.data,
> +   asym_op->rsa.output.length);
>   asym_op = result_op->asym;
> 
>   /* Verify sign */
> + memcpy(input_sign, asym_op->rsa.output.data, asym_op-
> >rsa.output.length);
> + asym_op->rsa.input.data = input_sign;
> + asym_op->rsa.input.length = asym_op->rsa.output.length;
> + asym_op->rsa.message.data = rsaplaintext.data;
> + asym_op->rsa.message.length = rsaplaintext.len;
>   asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
> - asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
> + asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
> 
>   /* Process crypto operation */
>   if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) { @@ -181,14
> +187,14 @@ queue_ops_rsa_enc_dec(void *sess)
>   /* Compute encryption on the test vector */
>   asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
> 
> - asym_op->rsa.message.data = rsaplaintext.data;
> - asym_op->rsa.cipher.data = cipher_buf;
> - asym_op->rsa.cipher.length = 0;
> - asym_op->rsa.message.length = rsaplaintext.len;
> - asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
> + asym_op->rsa.input.data = rsaplaintext.data;
> + asym_op->rsa.output.data = cipher_buf;
> + asym_op->rsa.output.length = 0;
> + asym_op->rsa.input.length = rsaplaintext.len;
> + asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
> 
> - debug_hexdump(stdout, "message", asym_op->rsa.message.data,
> -   asym_op->rsa.message.length);
> + debug_hexdump(stdout, "message", asym_op->rsa.input.data,
> +   asym_op->rsa.input.length);
> 
>   /* Attach asymmetric crypto session to crypto operations */
>   rte_crypto_op_attach_asym_session(op, sess); @@ -210,14 +216,14
> @@ queue_ops_rsa_enc_dec(void *sess)
>   status = TEST_FAILED;
>   goto error_exit;
>   }
> - debug_hexdump(stdout, "encrypted message", asym_op-
> >rsa.message.data,
> -   asym_op->rsa.message.length);
> + debug_hexdump(stdout, "encrypted message", asym_op-
> >rsa.input.data,
> +   asym_op->rsa.input.length);
> 
>   /* Use the resulted output as decryption Input vector*/
>   asym_op = result_op->asym;
> - asym_op->rsa.message.

Re: [PATCH v3 01/15] vdpa/ifc: add support for virtio blk device

2022-03-22 Thread Maxime Coquelin




On 1/29/22 04:03, Andy Pei wrote:

Re-use the vdpa/ifc code, distinguish blk and net device by pci_device_id.
Blk and net device are implemented with proper feature and ops.

Signed-off-by: Andy Pei 
---
  drivers/vdpa/ifc/base/ifcvf.h | 16 +++-
  drivers/vdpa/ifc/ifcvf_vdpa.c | 92 +++
  2 files changed, 98 insertions(+), 10 deletions(-)



Reviewed-by: Maxime Coquelin 

Thanks,
Maxime



Re: [PATCH v3 02/15] vhost: add vdpa ops for blk device

2022-03-22 Thread Maxime Coquelin




On 1/29/22 04:03, Andy Pei wrote:

Get_config and set_config are necessary ops for blk device.
Add get_config and set_config ops to vdpa ops.

Signed-off-by: Andy Pei 
---
  lib/vhost/vdpa_driver.h | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/vhost/vdpa_driver.h b/lib/vhost/vdpa_driver.h
index fc2d6ac..9a23db9 100644
--- a/lib/vhost/vdpa_driver.h
+++ b/lib/vhost/vdpa_driver.h
@@ -65,8 +65,12 @@ struct rte_vdpa_dev_ops {
/** Reset statistics of the queue */
int (*reset_stats)(struct rte_vdpa_device *dev, int qid);
  
-	/** Reserved for future extension */

-   void *reserved[2];
+   /** Get the device configuration space */
+   int (*get_config)(int vid, uint8_t *config, uint32_t len);
+
+   /** Set the device configuration space */
+   int (*set_config)(int vid, uint8_t *config, uint32_t offset,
+ uint32_t size, uint32_t flags);
  };
  
  /**


Reviewed-by: Maxime Coquelin 

Thanks,
Maxime



RE: [RFC PATCH 2/2] test: add proper pkcs1 signature tests for rsa

2022-03-22 Thread Kusztal, ArkadiuszX
Hi,

> -Original Message-
> From: Kusztal, ArkadiuszX 
> Sent: Tuesday, March 22, 2022 9:11 AM
> To: dev@dpdk.org
> Cc: gak...@marvell.com; Zhang, Roy Fan ;
> ano...@marvell.com; Kusztal, ArkadiuszX 
> Subject: [RFC PATCH 2/2] test: add proper pkcs1 signature tests for rsa
> 
> This commit adds example pkcs1 signature tests.
> 
> Signed-off-by: Arek Kusztal 
> ---
>  app/test/test_cryptodev_asym.c   | 249
> +--
>  drivers/crypto/openssl/rte_openssl_pmd.c |  34 -
>  lib/cryptodev/rte_crypto_asym.h  |   6 +-
>  3 files changed, 270 insertions(+), 19 deletions(-)
> 
> diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
> index 71378cbdb2..512eb34377 100644
> --- a/app/test/test_cryptodev_asym.c
> +++ b/app/test/test_cryptodev_asym.c
> @@ -15,6 +15,7 @@
> 
>  #include 
>  #include 
> +#include 
> 
>  #include "test_cryptodev.h"
>  #include "test_cryptodev_dh_test_vectors.h"
> @@ -163,6 +164,222 @@ queue_ops_rsa_sign_verify(void *sess)
>   return status;
>  }
> 
> +/* DPDK RFC RSA 22.07 */
> +
> +static uint8_t
> +rsa_sign_pkcs_15_pt[] = {
> + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
> + 0x11, 0x12, 0x13, 0x14,
> +};
> +
> +static uint8_t
> +rsa_sign_pkcs_15_pt_sha256[] = {
> + 0xB1, 0xB2, 0xB3, 0xB4, 0xA1, 0xA2, 0xA3, 0xA4,
> + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
> + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, };
> +
> +static uint8_t
> +rsa_sign_pkcs_15_padded[] = {
> + 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04,
> + 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
> + 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
> +};
> +
> +static uint8_t
> +rsa_sign_pkcs_15_padded_digestinfo_sha1[] = {
> + 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x30, 0x21, 0x30,
> + 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a,
> + 0x05, 0x00, 0x04, 0x14, 0x01, 0x02, 0x03, 0x04,
> + 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
> + 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
> +};
> +
> +static uint8_t
> +rsa_sign_pkcs_15_padded_digestinfo_sha256[] = {
> + 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x30, 0x31, 0x30,
> + 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
> + 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20,
> + 0xB1, 0xB2, 0xB3, 0xB4, 0xA1, 0xA2, 0xA3, 0xA4,
> + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
> + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, };
> +
> +static void*
> +rfc2207_rsa_sign_pkcs_15_sesscreat(void)
> +{
> + struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
> + struct rte_mempool *sess_mpool = ts_params->session_mpool;
> + uint8_t dev_id = ts_params->valid_devs[0];
> + static void *sess = NULL;
> + int ret;
> +
> + if (sess)
> + return sess;
> + ret = rte_cryptodev_asym_session_create(dev_id, &rsa_xform,
> +sess_mpool, &sess);
> +
> + if (ret < 0) {
> + RTE_LOG(ERR, USER1, "Sessio

Re: [PATCH] version: 22.07-rc0

2022-03-22 Thread Ray Kinsella


David Marchand  writes:

> On Mon, Mar 21, 2022 at 2:01 PM Thomas Monjalon  wrote:
>>
>> 18/03/2022 15:35, David Marchand:
>> > +ABI Changes
>> > +---
>> > +
>> > +.. This section should contain ABI changes. Sample format:
>> > +
>> > +   * sample: Add a short 1-2 sentence description of the ABI change
>> > + which was announced in the previous releases and made in this 
>> > release.
>> > + Start with a scope label like "ethdev:".
>> > + Use fixed width quotes for ``function_names`` or ``struct_names``.
>> > + Use the past tense.
>> > +
>> > +   This section is a comment. Do not overwrite or remove it.
>> > +   Also, make sure to start the actual text at the margin.
>> > +   ===
>> > +
>> > +* No ABI change that would break compatibility with 21.11.
>>
>> Should we say 21.11 and 22.03?
>
> In practice, compatibility is probably maintained, but we are
> committed to maintain ABI compatibility with v21.11 only.
> So I would leave this as is.
>
> http://inbox.dpdk.org/dev/27c97b09-0b78-ccbc-db1e-860ac6012...@ashroe.eu/

Agreed  +1 - our only commitment is to v21.11.
Otherwise things would start to get very complicated. :-)


-- 
Regards, Ray K


DPDK for Windows with MSVC compiler

2022-03-22 Thread Tarun Badnora

Hello DPDK Team,

Hope you are doing good !!

We are evaluating DPDK for windows and planning to integrate in existing 
application/project that uses MSVC compiler.
DPDK Documentations covers the compilation steps using Clang (LLVM) only.

We'd like to know whether DPDK supports MSVC compiler ?
If yes, please guide us to the references & compatible versions else share plan 
of its availability if it's in roadmap.

DPDK Versions: 21.11, 22.03_rc2
Windows:Server 2019 x64
Adapter:  Mellanox ConnectX-6Dx

PS: We tried to compile using MSVC (VS 2019) but didn't worked.

Regards,
Tarun Badnora



[PATCH] net/nfp: add the restrict of setting the mtu

2022-03-22 Thread Peng Zhang
1.When the setting mtu is higher than flbufsz, the mtu doesn't work.
But it doesn't have any notice about this restrict.
2.when the setting mtu isn't in the range, it doesn't have any notice.

This patch will add the notice about these restrict.

Signed-off-by: Peng Zhang 
Signed-off-by: Chaoyong He 
Signed-off-by: Louis Peens 
---
 drivers/net/nfp/nfp_common.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index f8978e803a..2ea9853548 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -956,6 +956,20 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
return -EBUSY;
}
 
+   /* the setting mtu is in the range */
+   if (mtu < 68 || mtu > hw->max_mtu) {
+   PMD_DRV_LOG(ERR, "the setting mtu cannot be less than 68 or 
more than %d",
+   hw->max_mtu);
+   return -ERANGE;
+   }
+
+   /* the setting mtu is lower than flbufsz */
+   if (mtu > hw->flbufsz) {
+   PMD_DRV_LOG(ERR, "the setting mtu must be lower than current 
mbufsize of %d",
+   hw->flbufsz);
+   return -ERANGE;
+   }
+
/* writing to configuration space */
nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
 
-- 
2.27.0



[PATCH] net/mlx5: fix linux stats gathering function

2022-03-22 Thread Geoffrey Le Gourriérec
This patch encompasses a few fixes carried by a previous patch
that aimed to support bonding device stats counting.

- If mlx5_os_read_dev_stat fails, it returns 1 instead of a
  negative value, causing mlx5_xstats_get to return an invalid
  number of counters. Since this error is not blocking, do not
  mess ret value with mlx5_os_read_dev_stat returned value.

  This allows avoiding the very annoying log:
  "n_xstats != n_xstats_names => skipping"

- Invert the check for mlx5_os_read_dev_stat(), currently leading
  us to store the result if the function failed, and use a
  backup value if it succeeded, which is the opposite of what we
  actually want. Revert to the original (correct) test.

- Add missing test on _mlx5_os_read_dev_counters() to prevent
  using trash stats values.

Fixes: 7ed15acdcd69 ("net/mlx5: improve xstats of bonding port")
Signed-off-by: Didier Pallard 
Signed-off-by: Geoffrey Le Gourriérec 
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c 
b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 8fe73f1adb58..b5819cc656ff 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -1386,15 +1386,16 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, 
uint64_t *stats)
}
} else {
ret = _mlx5_os_read_dev_counters(dev, -1, stats);
+   if (ret)
+   return ret;
}
/* Read IB counters. */
for (i = 0; i != xstats_ctrl->mlx5_stats_n; ++i) {
if (!xstats_ctrl->info[i].dev)
continue;
-   ret = mlx5_os_read_dev_stat(priv, xstats_ctrl->info[i].ctr_name,
-   &stats[i]);
/* return last xstats counter if fail to read. */
-   if (ret != 0)
+   if (mlx5_os_read_dev_stat(priv, xstats_ctrl->info[i].ctr_name,
+   &stats[i]) == 0)
xstats_ctrl->xstats[i] = stats[i];
else
stats[i] = xstats_ctrl->xstats[i];
-- 
2.30.2



[PATCH] ethtool: added list command to list all available commands

2022-03-22 Thread Huzaifa696
help command is needed so user can see all the available commands directly
from the command line along with the formats.

Signed-off-by: Huzaifa696 
---
 doc/guides/sample_app_ug/ethtool.rst  |  1 +
 examples/ethtool/ethtool-app/ethapp.c | 38 +++
 2 files changed, 39 insertions(+)

diff --git a/doc/guides/sample_app_ug/ethtool.rst 
b/doc/guides/sample_app_ug/ethtool.rst
index 159e9e0639..6e57015170 100644
--- a/doc/guides/sample_app_ug/ethtool.rst
+++ b/doc/guides/sample_app_ug/ethtool.rst
@@ -58,6 +58,7 @@ they do as follows:
 * ``validate``: Check that given MAC address is valid unicast address
 * ``vlan``: Add/remove VLAN id
 * ``quit``: Exit program
+* ``help``: List all available commands
 
 
 Explanation
diff --git a/examples/ethtool/ethtool-app/ethapp.c 
b/examples/ethtool/ethtool-app/ethapp.c
index 78e86534e8..361e2daf9b 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -57,6 +57,8 @@ cmdline_parse_token_string_t pcmd_stats_token_cmd =
TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "stats");
 cmdline_parse_token_string_t pcmd_drvinfo_token_cmd =
TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "drvinfo");
+cmdline_parse_token_string_t pcmd_list_token_cmd =
+   TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "help");
 cmdline_parse_token_string_t pcmd_link_token_cmd =
TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "link");
 
@@ -133,6 +135,11 @@ cmdline_parse_token_string_t pcmd_vlan_token_mode =
 cmdline_parse_token_num_t pcmd_vlan_token_vid =
TOKEN_NUM_INITIALIZER(struct pcmd_vlan_params, vid, RTE_UINT16);
 
+void
+list_cmd(unsigned int sr, const char *name, const char *format, const char 
*description)
+{
+   printf("%-4d%-17s%-45s%-50s\n", sr, name, format, description);
+}
 
 static void
 pcmd_quit_callback(__rte_unused void *ptr_params,
@@ -142,6 +149,30 @@ pcmd_quit_callback(__rte_unused void *ptr_params,
cmdline_quit(ctx);
 }
 
+static void
+pcmd_list_callback(__rte_unused void *ptr_params,
+   struct cmdline *ctx,
+   __rte_unused void *ptr_data)
+{
+   printf("%-4s%-17s%-45s%-50s\n\n", "Sr.", "Name", "Format", 
"Description");
+   list_cmd(1, "drvinfo", "drvinfo", "Print driver info");
+   list_cmd(2, "open", "open ", "Open port");
+   list_cmd(3, "pause", "pause  ", "Get/set port 
pause state");
+   list_cmd(4, "stop", "stop ", "Stop port");
+   list_cmd(5, "portstats", "portstats ", "Print port 
statistics");
+   list_cmd(6, "link", "link", "Print port link states");
+   list_cmd(7, "macaddr", "macaddr  ", "Gets/sets MAC 
address");
+   list_cmd(8, "mtu", "mtu  ", "Set NIC MTU");
+   list_cmd(9, "regs", "regs  ", "Dump port register(s) 
to file");
+   list_cmd(10, "ringparam", "ringparam   ", 
"Get/set ring parameters");
+   list_cmd(11, "rxmode", "rxmode ", "Toggle port Rx mode");
+   list_cmd(12, "validate", "validate ", "Check that given MAC 
address is valid unicast address");
+   list_cmd(13, "vlan", "vlan   ", "Add/remove 
VLAN id");
+   list_cmd(14, "eeprom", "eeprom  ", "Dump EEPROM to 
file");
+   list_cmd(15, "module-eeprom", "module-eeprom  ", 
"Dump plugin module EEPROM to file");
+   list_cmd(16, "quit", "quit", "Exit program");
+   list_cmd(17, "help", "help", "List all available commands");
+}
 
 static void
 pcmd_drvinfo_callback(__rte_unused void *ptr_params,
@@ -680,6 +711,12 @@ cmdline_parse_inst_t pcmd_drvinfo = {
.help_str = "drvinfo\n Print driver info",
.tokens = {(void *)&pcmd_drvinfo_token_cmd, NULL},
 };
+cmdline_parse_inst_t pcmd_list_cmds = {
+   .f = pcmd_list_callback,
+   .data = NULL,
+   .help_str = "help\n List all available commands",
+   .tokens = {(void *)&pcmd_list_token_cmd, NULL},
+};
 cmdline_parse_inst_t pcmd_link = {
.f = pcmd_link_callback,
.data = NULL,
@@ -871,6 +908,7 @@ cmdline_parse_inst_t pcmd_vlan = {
 
 
 cmdline_parse_ctx_t list_prompt_commands[] = {
+   (cmdline_parse_inst_t *)&pcmd_list_cmds,
(cmdline_parse_inst_t *)&pcmd_drvinfo,
(cmdline_parse_inst_t *)&pcmd_eeprom,
(cmdline_parse_inst_t *)&pcmd_module_eeprom,
-- 
2.25.1



[PATCH v2] ethtool: added help command to list all available

2022-03-22 Thread huzaifa.rahman
Help command is not available for ethtool example. It is needed so user
can see all the available commands directly from the command line along
with the formats.

Signed-off-by: huzaifa.rahman 
---
 doc/guides/sample_app_ug/ethtool.rst  |  1 +
 examples/ethtool/ethtool-app/ethapp.c | 38 +++
 examples/ethtool/ethtool-app/ethapp.h |  1 +
 3 files changed, 40 insertions(+)

diff --git a/doc/guides/sample_app_ug/ethtool.rst 
b/doc/guides/sample_app_ug/ethtool.rst
index 159e9e0639..6e57015170 100644
--- a/doc/guides/sample_app_ug/ethtool.rst
+++ b/doc/guides/sample_app_ug/ethtool.rst
@@ -58,6 +58,7 @@ they do as follows:
 * ``validate``: Check that given MAC address is valid unicast address
 * ``vlan``: Add/remove VLAN id
 * ``quit``: Exit program
+* ``help``: List all available commands
 
 
 Explanation
diff --git a/examples/ethtool/ethtool-app/ethapp.c 
b/examples/ethtool/ethtool-app/ethapp.c
index 78e86534e8..1c0e6c050f 100644
--- a/examples/ethtool/ethtool-app/ethapp.c
+++ b/examples/ethtool/ethtool-app/ethapp.c
@@ -57,6 +57,8 @@ cmdline_parse_token_string_t pcmd_stats_token_cmd =
TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "stats");
 cmdline_parse_token_string_t pcmd_drvinfo_token_cmd =
TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "drvinfo");
+cmdline_parse_token_string_t pcmd_list_token_cmd =
+   TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "help");
 cmdline_parse_token_string_t pcmd_link_token_cmd =
TOKEN_STRING_INITIALIZER(struct pcmd_get_params, cmd, "link");
 
@@ -133,6 +135,11 @@ cmdline_parse_token_string_t pcmd_vlan_token_mode =
 cmdline_parse_token_num_t pcmd_vlan_token_vid =
TOKEN_NUM_INITIALIZER(struct pcmd_vlan_params, vid, RTE_UINT16);
 
+void
+print_cmd_info(unsigned int sr, const char *name, const char *format, const 
char *description)
+{
+   printf("%-4u%-17s%-45s%-50s\n", sr, name, format, description);
+}
 
 static void
 pcmd_quit_callback(__rte_unused void *ptr_params,
@@ -142,6 +149,30 @@ pcmd_quit_callback(__rte_unused void *ptr_params,
cmdline_quit(ctx);
 }
 
+static void
+pcmd_help_callback(__rte_unused void *ptr_params,
+   __rte_unused struct cmdline *ctx,
+   __rte_unused void *ptr_data)
+{
+   printf("%-4s%-17s%-45s%-50s\n\n", "Sr.", "Name", "Format", 
"Description");
+   print_cmd_info(1, "drvinfo", "drvinfo", "Print driver info");
+   print_cmd_info(2, "open", "open ", "Open port");
+   print_cmd_info(3, "pause", "pause  []", 
"Get/set port pause state");
+   print_cmd_info(4, "stop", "stop ", "Stop port");
+   print_cmd_info(5, "portstats", "portstats ", "Print port 
statistics");
+   print_cmd_info(6, "link", "link", "Print port link states");
+   print_cmd_info(7, "macaddr", "macaddr  []", 
"Gets/sets MAC address");
+   print_cmd_info(8, "mtu", "mtu  ", "Set NIC MTU");
+   print_cmd_info(9, "regs", "regs  ", "Dump port 
register(s) to file");
+   print_cmd_info(10, "ringparam", "ringparam  [ 
]", "Get/set ring parameters");
+   print_cmd_info(11, "rxmode", "rxmode ", "Toggle port Rx mode");
+   print_cmd_info(12, "validate", "validate ", "Check that given 
MAC address is valid unicast address");
+   print_cmd_info(13, "vlan", "vlan   ", 
"Add/remove VLAN id");
+   print_cmd_info(14, "eeprom", "eeprom  ", "Dump 
EEPROM to file");
+   print_cmd_info(15, "module-eeprom", "module-eeprom  
", "Dump plugin module EEPROM to file");
+   print_cmd_info(16, "quit", "quit", "Exit program");
+   print_cmd_info(17, "help", "help", "List all available commands");
+}
 
 static void
 pcmd_drvinfo_callback(__rte_unused void *ptr_params,
@@ -680,6 +711,12 @@ cmdline_parse_inst_t pcmd_drvinfo = {
.help_str = "drvinfo\n Print driver info",
.tokens = {(void *)&pcmd_drvinfo_token_cmd, NULL},
 };
+cmdline_parse_inst_t pcmd_help_cmds = {
+   .f = pcmd_help_callback,
+   .data = NULL,
+   .help_str = "help\n List all available commands",
+   .tokens = {(void *)&pcmd_list_token_cmd, NULL},
+};
 cmdline_parse_inst_t pcmd_link = {
.f = pcmd_link_callback,
.data = NULL,
@@ -871,6 +908,7 @@ cmdline_parse_inst_t pcmd_vlan = {
 
 
 cmdline_parse_ctx_t list_prompt_commands[] = {
+   (cmdline_parse_inst_t *)&pcmd_help_cmds,
(cmdline_parse_inst_t *)&pcmd_drvinfo,
(cmdline_parse_inst_t *)&pcmd_eeprom,
(cmdline_parse_inst_t *)&pcmd_module_eeprom,
diff --git a/examples/ethtool/ethtool-app/ethapp.h 
b/examples/ethtool/ethtool-app/ethapp.h
index 7a70480c88..4db09ed771 100644
--- a/examples/ethtool/ethtool-app/ethapp.h
+++ b/examples/ethtool/ethtool-app/ethapp.h
@@ -10,3 +10,4 @@ void unlock_port(int idx_port);
 void mark_port_inactive(int idx_port);
 void mark_port_active(int idx_port);
 void mark_port_newmac(int idx_port);
+void print_cmd_info(unsigned int sr, const char *name, const char *format, 
const char *description);
-- 
2.25.1



Re: [PATCH v3 03/15] vdpa/ifc: add blk ops for ifc device

2022-03-22 Thread Maxime Coquelin




On 1/29/22 04:03, Andy Pei wrote:

For virtio blk device, re-use part of ifc driver ops.
Implement ifcvf_blk_get_config for virtio blk device.
Support VHOST_USER_PROTOCOL_F_CONFIG feature for virtio
blk device.

Signed-off-by: Andy Pei 
---
  drivers/vdpa/ifc/base/ifcvf.h |  4 ++
  drivers/vdpa/ifc/ifcvf_vdpa.c | 85 ++-
  2 files changed, 88 insertions(+), 1 deletion(-)



Reviewed-by: Maxime Coquelin 

Thanks,
Maxime



Re: [PATCH v3 04/15] vdpa/ifc: add vdpa interrupt for blk device

2022-03-22 Thread Maxime Coquelin




On 1/29/22 04:03, Andy Pei wrote:

For the blk we need to relay all the cmd of each queue.


The message is not clear to me, do you mean "For the block device type,
we have to relay the commands on all queues."?



Signed-off-by: Andy Pei 
---
  drivers/vdpa/ifc/ifcvf_vdpa.c | 46 ---
  1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 778e1fd..4f99bb3 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -372,24 +372,48 @@ struct rte_vdpa_dev_info {
irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
irq_set->start = 0;
fd_ptr = (int *)&irq_set->data;
+   /* The first interrupt is for the configure space change notification */
fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] =
rte_intr_fd_get(internal->pdev->intr_handle);
  
  	for (i = 0; i < nr_vring; i++)

internal->intr_fd[i] = -1;
  
-	for (i = 0; i < nr_vring; i++) {

-   rte_vhost_get_vhost_vring(internal->vid, i, &vring);
-   fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
-   if ((i & 1) == 0 && m_rx == true) {
-   fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
-   if (fd < 0) {
-   DRV_LOG(ERR, "can't setup eventfd: %s",
-   strerror(errno));
-   return -1;
+   if (internal->device_type == IFCVF_NET) {
+   for (i = 0; i < nr_vring; i++) {
+   rte_vhost_get_vhost_vring(internal->vid, i, &vring);
+   fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
+   if ((i & 1) == 0 && m_rx == true) {
+   /* For the net we only need to relay rx queue,
+* which will change the mem of VM.
+*/
+   fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+   if (fd < 0) {
+   DRV_LOG(ERR, "can't setup eventfd: %s",
+   strerror(errno));
+   return -1;
+   }
+   internal->intr_fd[i] = fd;
+   fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = fd;
+   }
+   }
+   } else if (internal->device_type == IFCVF_BLK) {
+   for (i = 0; i < nr_vring; i++) {
+   rte_vhost_get_vhost_vring(internal->vid, i, &vring);
+   fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
+   if (m_rx == true) {
+   /* For the blk we need to relay all the read cmd
+* of each queue
+*/
+   fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+   if (fd < 0) {
+   DRV_LOG(ERR, "can't setup eventfd: %s",
+   strerror(errno));
+   return -1;
+   }
+   internal->intr_fd[i] = fd;
+   fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = fd;




}
-   internal->intr_fd[i] = fd;
-   fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = fd;
}
}
  




RE: [RFC PATCH 2/2] test: add proper pkcs1 signature tests for rsa

2022-03-22 Thread Kusztal, ArkadiuszX
More explanation below.

> -Original Message-
> From: Kusztal, ArkadiuszX
> Sent: Tuesday, March 22, 2022 10:14 AM
> To: dev@dpdk.org
> Cc: gak...@marvell.com; Zhang, Roy Fan ;
> ano...@marvell.com
> Subject: RE: [RFC PATCH 2/2] test: add proper pkcs1 signature tests for rsa
> 
> Hi,
> 
> > -Original Message-
> > From: Kusztal, ArkadiuszX 
> > Sent: Tuesday, March 22, 2022 9:11 AM
> > To: dev@dpdk.org
> > Cc: gak...@marvell.com; Zhang, Roy Fan ;
> > ano...@marvell.com; Kusztal, ArkadiuszX 
> > Subject: [RFC PATCH 2/2] test: add proper pkcs1 signature tests for
> > rsa
> >
> > This commit adds example pkcs1 signature tests.
> >
> > Signed-off-by: Arek Kusztal 
> > ---
> >  app/test/test_cryptodev_asym.c   | 249
> > +--
> >  drivers/crypto/openssl/rte_openssl_pmd.c |  34 -
> >  lib/cryptodev/rte_crypto_asym.h  |   6 +-
> >  3 files changed, 270 insertions(+), 19 deletions(-)
> >
> > diff --git a/app/test/test_cryptodev_asym.c
> > b/app/test/test_cryptodev_asym.c index 71378cbdb2..512eb34377 100644
> > --- a/app/test/test_cryptodev_asym.c
> > +++ b/app/test/test_cryptodev_asym.c
> > @@ -15,6 +15,7 @@
> >
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include "test_cryptodev.h"
> >  #include "test_cryptodev_dh_test_vectors.h"
> > @@ -163,6 +164,222 @@ queue_ops_rsa_sign_verify(void *sess)
> > return status;
> >  }
> >
> > +/* DPDK RFC RSA 22.07 */
> > +
> > +static uint8_t
> > +rsa_sign_pkcs_15_pt[] = {
> > +   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> > +   0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
> > +   0x11, 0x12, 0x13, 0x14,
> > +};
> > +
> > +static uint8_t
> > +rsa_sign_pkcs_15_pt_sha256[] = {
> > +   0xB1, 0xB2, 0xB3, 0xB4, 0xA1, 0xA2, 0xA3, 0xA4,
> > +   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> > +   0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
> > +   0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, };
> > +
> > +static uint8_t
> > +rsa_sign_pkcs_15_padded[] = {
> > +   0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04,
> > +   0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
> > +   0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
> > +};
> > +
> > +static uint8_t
> > +rsa_sign_pkcs_15_padded_digestinfo_sha1[] = {
> > +   0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x30, 0x21, 0x30,
> > +   0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a,
> > +   0x05, 0x00, 0x04, 0x14, 0x01, 0x02, 0x03, 0x04,
> > +   0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
> > +   0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
> > +};
> > +
> > +static uint8_t
> > +rsa_sign_pkcs_15_padded_digestinfo_sha256[] = {
> > +   0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
> > +   0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x30, 0x31, 0x30,
> > +   0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
> > +   0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20,
> > +   0xB1, 0xB2, 0xB3, 0xB4, 0xA1, 0xA2, 0xA3, 0xA4,
> > +   0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
> > +   0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
> > +   0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, };
> > +
> > +static void*
> > +rfc2207_rsa_sign_pkcs_15_sesscreat(void)
> > +{
> > +   struct crypto_testsuite_params_asym *ts_params =

Re: [PATCH] version: 22.07-rc0

2022-03-22 Thread Thomas Monjalon
22/03/2022 10:15, Ray Kinsella:
> David Marchand  writes:
> > On Mon, Mar 21, 2022 at 2:01 PM Thomas Monjalon  wrote:
> >> 18/03/2022 15:35, David Marchand:
> >> > +* No ABI change that would break compatibility with 21.11.
> >>
> >> Should we say 21.11 and 22.03?
> >
> > In practice, compatibility is probably maintained, but we are
> > committed to maintain ABI compatibility with v21.11 only.
> > So I would leave this as is.
> >
> > http://inbox.dpdk.org/dev/27c97b09-0b78-ccbc-db1e-860ac6012...@ashroe.eu/
> 
> Agreed  +1 - our only commitment is to v21.11.
> Otherwise things would start to get very complicated. :-)

I don't think it would be more complicated.
In reality, we are already testing compatibility with minor versions,
and there is no issue.




Re: [PATCH v3 05/15] vdpa/ifc: add blk dev sw live migration

2022-03-22 Thread Maxime Coquelin

Hi Andy,

"vdpa/ifc: add block device SW live-migration"

On 1/29/22 04:03, Andy Pei wrote:

Enable virtio blk sw live migration relay callfd and log the dirty page.


Please try to make the above sentence simpler. Also, it seems that below
patch changes behaviour for net devices, so the commit message should
explain that.


In this version we ignore the write cmd and still mark it dirty.

Signed-off-by: Andy Pei 
---
  drivers/vdpa/ifc/base/ifcvf.c |   4 +-
  drivers/vdpa/ifc/base/ifcvf.h |   6 ++
  drivers/vdpa/ifc/ifcvf_vdpa.c | 128 +++---
  3 files changed, 116 insertions(+), 22 deletions(-)

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index 721cb1d..3a69e53 100644
--- a/drivers/vdpa/ifc/base/ifcvf.c
+++ b/drivers/vdpa/ifc/base/ifcvf.c
@@ -189,7 +189,7 @@
IFCVF_WRITE_REG32(val >> 32, hi);
  }
  
-STATIC int

+int
  ifcvf_hw_enable(struct ifcvf_hw *hw)
  {
struct ifcvf_pci_common_cfg *cfg;
@@ -238,7 +238,7 @@
return 0;
  }
  
-STATIC void

+void
  ifcvf_hw_disable(struct ifcvf_hw *hw)
  {
u32 i;
diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h
index 769c603..6dd7925 100644
--- a/drivers/vdpa/ifc/base/ifcvf.h
+++ b/drivers/vdpa/ifc/base/ifcvf.h
@@ -179,4 +179,10 @@ struct ifcvf_hw {
  u64
  ifcvf_get_queue_notify_off(struct ifcvf_hw *hw, int qid);
  
+int

+ifcvf_hw_enable(struct ifcvf_hw *hw);
+
+void
+ifcvf_hw_disable(struct ifcvf_hw *hw);
+
  #endif /* _IFCVF_H_ */
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 4f99bb3..a930825 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -332,10 +332,67 @@ struct rte_vdpa_dev_info {
  
  	rte_vhost_get_negotiated_features(vid, &features);

if (RTE_VHOST_NEED_LOG(features)) {
-   ifcvf_disable_logging(hw);
-   rte_vhost_get_log_base(internal->vid, &log_base, &log_size);
-   rte_vfio_container_dma_unmap(internal->vfio_container_fd,
-   log_base, IFCVF_LOG_BASE, log_size);
+   if (internal->device_type == IFCVF_NET) {
+   ifcvf_disable_logging(hw);
+   rte_vhost_get_log_base(internal->vid, &log_base,
+   &log_size);
+   rte_vfio_container_dma_unmap(
+   internal->vfio_container_fd, log_base,
+   IFCVF_LOG_BASE, log_size);
+   }
+   /* IFCVF marks dirty memory pages for only packet buffer,
+* SW helps to mark the used ring as dirty after device stops.
+*/
+   for (i = 0; i < hw->nr_vring; i++) {
+   len = IFCVF_USED_RING_LEN(hw->vring[i].size);
+   rte_vhost_log_used_vring(vid, i, 0, len);
+   }
+   }
+}
+
+static void
+vdpa_ifcvf_blk_pause(struct ifcvf_internal *internal)
+{
+   struct ifcvf_hw *hw = &internal->hw;
+   struct rte_vhost_vring vq;
+   int i, vid;
+   uint64_t features = 0;
+   uint64_t log_base = 0, log_size = 0;
+   uint64_t len;
+
+   vid = internal->vid;
+
+   if (internal->device_type == IFCVF_BLK) {
+   for (i = 0; i < hw->nr_vring; i++) {
+   rte_vhost_get_vhost_vring(internal->vid, i, &vq);
+   while (vq.avail->idx != vq.used->idx) {
+   ifcvf_notify_queue(hw, i);
+   usleep(10);
+   }
+   hw->vring[i].last_avail_idx = vq.avail->idx;
+   hw->vring[i].last_used_idx = vq.used->idx;
+   }
+   }
+
+   ifcvf_hw_disable(hw);
+
+   for (i = 0; i < hw->nr_vring; i++)
+   rte_vhost_set_vring_base(vid, i, hw->vring[i].last_avail_idx,
+   hw->vring[i].last_used_idx);
+
+   if (internal->sw_lm)
+   return;
+
+   rte_vhost_get_negotiated_features(vid, &features);
+   if (RTE_VHOST_NEED_LOG(features)) {
+   if (internal->device_type == IFCVF_NET) {
+   ifcvf_disable_logging(hw);
+   rte_vhost_get_log_base(internal->vid, &log_base,
+   &log_size);
+   rte_vfio_container_dma_unmap(
+   internal->vfio_container_fd, log_base,
+   IFCVF_LOG_BASE, log_size);
+   }
/*
 * IFCVF marks dirty memory pages for only packet buffer,
 * SW helps to mark the used ring as dirty after device stops.
@@ -661,15 +718,17 @@ struct rte_vdpa_dev_info {
}
hw->vring[i].avail = gpa;
  
-		/* Direct I/O for Tx queue, relay for Rx queue */

-   if (i & 1) {
+   /* NETWORK: Direct I/O for Tx queue, relay 

Re: [PATCH v3 06/15] example/vdpa:add vdpa blk support in example

2022-03-22 Thread Maxime Coquelin




On 1/29/22 04:03, Andy Pei wrote:

Add virtio blk device support to vdpa example.

Signed-off-by: Andy Pei 
---
  examples/vdpa/Makefile   |   2 +-
  examples/vdpa/main.c |   8 ++
  examples/vdpa/meson.build|   1 +
  examples/vdpa/vdpa_blk_compact.c | 150 +++
  examples/vdpa/vdpa_blk_compact.h | 117 
  examples/vdpa/vhost_user.h   | 189 +++
  6 files changed, 466 insertions(+), 1 deletion(-)
  create mode 100644 examples/vdpa/vdpa_blk_compact.c
  create mode 100644 examples/vdpa/vdpa_blk_compact.h
  create mode 100644 examples/vdpa/vhost_user.h

diff --git a/examples/vdpa/Makefile b/examples/vdpa/Makefile
index d974db4..9d0479b 100644
--- a/examples/vdpa/Makefile
+++ b/examples/vdpa/Makefile
@@ -5,7 +5,7 @@
  APP = vdpa
  
  # all source are stored in SRCS-y

-SRCS-y := main.c
+SRCS-y := main.c vdpa_blk_compact.c
  CFLAGS += -DALLOW_EXPERIMENTAL_API
  
  PKGCONF ?= pkg-config

diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index 5ab0765..924ad7b 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -20,6 +20,7 @@
  #include 
  #include 
  #include 
+#include "vdpa_blk_compact.h"
  
  #define MAX_PATH_LEN 128

  #define MAX_VDPA_SAMPLE_PORTS 1024
@@ -156,6 +157,7 @@ struct vdpa_port {
  static const struct rte_vhost_device_ops vdpa_sample_devops = {
.new_device = new_device,
.destroy_device = destroy_device,
+   .new_connection = rte_vhost_blk_session_install_rte_compat_hooks,
  };
  
  static int

@@ -192,6 +194,12 @@ struct vdpa_port {
"attach vdpa device failed: %s\n",
socket_path);
  
+	if (vdpa_blk_device_set_features_and_protocol(socket_path, vport->dev)

+   < 0)
+   rte_exit(EXIT_FAILURE,
+   "set vhost blk driver features and protocol features failed: 
%s\n",
+   socket_path);
+


That does not look right, blk devices specitic functions shuold be
called only for block devices.


if (rte_vhost_driver_start(socket_path) < 0)
rte_exit(EXIT_FAILURE,
"start vhost driver failed: %s\n",
diff --git a/examples/vdpa/meson.build b/examples/vdpa/meson.build
index bd08605..f0d111c 100644
--- a/examples/vdpa/meson.build
+++ b/examples/vdpa/meson.build
@@ -15,4 +15,5 @@ deps += 'vhost'
  allow_experimental_apis = true
  sources = files(
  'main.c',
+   'vdpa_blk_compact.c',
  )
diff --git a/examples/vdpa/vdpa_blk_compact.c b/examples/vdpa/vdpa_blk_compact.c
new file mode 100644
index 000..0c4d3ee
--- /dev/null
+++ b/examples/vdpa/vdpa_blk_compact.c
@@ -0,0 +1,150 @@
+/*INTEL CONFIDENTIAL
+ *
+ *Copyright (c) Intel Corporation.
+ *All rights reserved.
+ *
+ *The source code contained or described herein and all documents related
+ *to the source code ("Material") are owned by Intel Corporation or its
+ *suppliers or licensors.  Title to the Material remains with Intel
+ *Corporation or its suppliers and licensors.  The Material contains trade
+ *secrets and proprietary and confidential information of Intel or its
+ *suppliers and licensors.  The Material is protected by worldwide
+ *copyright and trade secret laws and treaty provisions.  No part of the
+ *Material may be used, copied, reproduced, modified, published, uploaded,
+ *posted, transmitted, distributed, or disclosed in any way without Intel's
+ *prior express written permission.
+ *
+ *No license under any patent, copyright, trade secret or other
+ *intellectual property right is granted to or conferred upon you by
+ *disclosure or delivery of the Materials, either expressly, by
+ *implication, inducement, estoppel or otherwise.  Any license under such
+ *intellectual property rights must be express and approved by Intel in
+ *writing.
+ */
+
+/* @file
+ *
+ * Block device specific vhost lib
+ */
+
+#include 
+
+#include 
+#include 


That's wrong, the application is not supposed to include the driver
APIs.


+#include 
+#include "vdpa_blk_compact.h"
+#include "vhost_user.h"
+
+#define VHOST_USER_GET_CONFIG  24
+#define VHOST_USER_SET_CONFIG  25
+
+#ifndef VHOST_USER_PROTOCOL_F_CONFIG
+#define VHOST_USER_PROTOCOL_F_CONFIG   9
+#endif
+
+/*
+ * Function to handle vhost user blk message
+ */
+static enum rte_vhost_msg_result
+rte_vhost_blk_extern_vhost_pre_msg_handler(int vid, void *_msg)
+{
+   struct VhostUserMsg *msg = _msg;
+   struct rte_vdpa_device *vdev = NULL;
+
+   vdev = rte_vhost_get_vdpa_device(vid);
+   if (vdev == NULL)
+   return RTE_VHOST_MSG_RESULT_ERR;
+
+   fprintf(stderr, "msg is %d\n", msg->request.master);
+   switch (msg->request.master) {
+   case VHOST_USER_GET_CONFIG: {
+   int rc = 0;
+
+   fprintf(stdout, "read message VHOST_USER_GET_CONFIG\n");
+
+ 

RE: [PATCH v2] test/bpf: skip test if libpcap is unavailable

2022-03-22 Thread Ananyev, Konstantin
> test_bpf_convert is being conditionally registered depending on the
> presence of RTE_HAS_LIBPCAP except the UT unconditionally lists it as a
> test to run.
> 
> when the UT runs test_bpf_convert test-dpdk can't find the registration
> and assumes the DPDK_TEST environment variable hasn't been defined
> resulting in test-dpdk dropping to interactive mode and subsequently
> waiting for the remainder of the UT fast-test timeout period before
> reporting the test as having timed out.
> 
> * unconditionally register test_bpf_convert
> * if ! RTE_HAS_LIBPCAP provide a stub test_bpf_convert that reports the
>   test is skipped similar to that done with the test_bpf test.
> 
> Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
> Cc: step...@networkplumber.org
> Cc: anatoly.bura...@intel.com
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Tyler Retzlaff 
> ---
>  app/test/test_bpf.c | 14 --
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
> index 805cce6..97f5008 100644
> --- a/app/test/test_bpf.c
> +++ b/app/test/test_bpf.c
> @@ -3264,7 +3264,16 @@ struct bpf_test {
> 
>  REGISTER_TEST_COMMAND(bpf_autotest, test_bpf);
> 
> -#ifdef RTE_HAS_LIBPCAP
> +#ifndef RTE_HAS_LIBPCAP
> +
> +static int
> +test_bpf_convert(void)
> +{
> + printf("BPF convert RTE_HAS_LIBPCAP is undefined, skipping test\n");
> + return TEST_SKIPPED;
> +}
> +
> +#else
>  #include 
> 
>  static void
> @@ -3462,5 +3471,6 @@ struct bpf_test {
>   return rc;
>  }
> 
> -REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);
>  #endif /* RTE_HAS_LIBPCAP */
> +
> +REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);
> --

Acked-by: Konstantin Ananyev 

> 1.8.3.1



Re: DPDK for Windows with MSVC compiler

2022-03-22 Thread Dmitry Kozlyuk
2022-03-21 10:26 (UTC+), Tarun Badnora:
> We'd like to know whether DPDK supports MSVC compiler ?
> If yes, please guide us to the references & compatible versions else share 
> plan of its availability if it's in roadmap.

Hello Tarun,

DPDK does not support MSVC.
There is a very long term intention to build DPDK with MSVC
(adding Omar and Daniel if they have any more comments),
but for now it's only clang and MinGW-w64.
There is a significant gap in language features support from MSVC side
and some issues (e.g. GCC-isms) from DPDK side.


RE: [PATCH] net/pcap: support MTU set

2022-03-22 Thread Ido Goshen
This test 
https://doc.dpdk.org/dts/test_plans/jumboframes_test_plan.html#test-case-jumbo-frames-with-no-jumbo-frame-support
 fails for pcap pmd 
Jumbo packet is unexpectedly received and transmitted


without patch:

root@u18c_3nbp:/home/cgs/workspace/master/jumbo# ./dpdk-testpmd --no-huge 
-m1024 -l 0-2  
--vdev='net_pcap0,rx_pcap=rx_pcap=jumbo_9000.pcap,tx_pcap=file_tx.pcap' -- 
--no-flush-rx --total-num-mbufs=2048 -i
...
testpmd> start
...
testpmd> show port stats 0

   NIC statistics for port 0  
  RX-packets: 1  RX-missed: 0  RX-bytes:  8996
  RX-errors: 0
  RX-nombuf:  0 
  TX-packets: 1  TX-errors: 0  TX-bytes:  8996

  Throughput (since last show)
  Rx-pps:0  Rx-bps:0
  Tx-pps:0  Tx-bps:0
  


While with the patch it will fail unless --max-pkt-len is used to support jumbo

root@u18c_3nbp:/home/cgs/workspace/master/jumbo# ./dpdk-testpmd-patch --no-huge 
-m1024 -l 0-2  
--vdev='net_pcap0,rx_pcap=rx_pcap=jumbo_9000.pcap,tx_pcap=file_tx.pcap' -- 
--no-flush-rx --total-num-mbufs=2048 -i
...
testpmd> start
...
testpmd> show port stats 0

   NIC statistics for port 0  
  RX-packets: 0  RX-missed: 0  RX-bytes:  0
  RX-errors: 1
  RX-nombuf:  0 
  TX-packets: 0  TX-errors: 0  TX-bytes:  0

  Throughput (since last show)
  Rx-pps:0  Rx-bps:0
  Tx-pps:0  Tx-bps:0
  

root@u18c_3nbp:/home/cgs/workspace/master/jumbo# ./dpdk-testpmd-patch --no-huge 
-m1024 -l 0-2  
--vdev='net_pcap0,rx_pcap=rx_pcap=jumbo_9000.pcap,tx_pcap=file_tx.pcap' -- 
--no-flush-rx --total-num-mbufs=2048 -i --max-pkt-len 9400
...
testpmd> start
...
testpmd> show port stats 0

   NIC statistics for port 0  
  RX-packets: 1  RX-missed: 0  RX-bytes:  8996
  RX-errors: 0
  RX-nombuf:  0 
  TX-packets: 1  TX-errors: 0  TX-bytes:  8996

  Throughput (since last show)
  Rx-pps:0  Rx-bps:0
  Tx-pps:0  Tx-bps:0
  

> -Original Message-
> From: Ido Goshen
> Sent: Thursday, 17 March 2022 21:12
> To: Stephen Hemminger 
> Cc: Ferruh Yigit ; dev@dpdk.org
> Subject: RE: [PATCH] net/pcap: support MTU set
> 
> As far as I can see the initial device MTU is derived from port *RX* 
> configuration
> in struct rte_eth_rxmode https://doc.dpdk.org/api-
> 21.11/structrte__eth__rxmode.html
> Couple of real NICs I've tested (ixgbe, i40e based) don't allow oversized, 
> tests
> details can be seen in https://bugs.dpdk.org/show_bug.cgi?id=961
> 
> > -Original Message-
> > From: Stephen Hemminger 
> > Sent: Thursday, 17 March 2022 20:21
> > To: Ido Goshen 
> > Cc: Ferruh Yigit ; dev@dpdk.org
> > Subject: Re: [PATCH] net/pcap: support MTU set
> >
> > On Thu, 17 Mar 2022 19:43:47 +0200
> > ido g  wrote:
> >
> > > + if (unlikely(header.caplen > dev->data->mtu)) {
> > > + pcap_q->rx_stat.err_pkts++;
> > > + rte_pktmbuf_free(mbuf);
> > > + break;
> > > + }
> >
> > MTU should only be enforced on transmit.
> > Other real network devices allow oversized packets.
> >
> > Since the pcap file is something user provides, if you don't want that
> > then use something to filter the file.


[PATCH v3] examples/vm_power: add support for list_foreach_safe

2022-03-22 Thread Shibin Koikkara Reeny
Asan tool reported LIST_FOREACH should be replaced with
LIST_FOREACH_SAFE. Added support for LIST_FOREACH_SAFE
macro in rte_os.h file as Linux header file sys/queue.h
don't support LIST_FOREACH_SAFE macro.
RTE_LIST_FOREACH_SAFE is alias for LIST_FOREACH_SAFE.

Fixes: e8ae9b662506 ("examples/vm_power: channel manager and monitor in host")
Cc: alan.ca...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Shibin Koikkara Reeny 

---
v3: add blank line after declaration
v2: add support for list_foreach_safe
---
 examples/vm_power_manager/channel_manager.c | 10 ++
 lib/eal/linux/include/rte_os.h  | 11 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/examples/vm_power_manager/channel_manager.c 
b/examples/vm_power_manager/channel_manager.c
index 838465ab4b..2d54641f2e 100644
--- a/examples/vm_power_manager/channel_manager.c
+++ b/examples/vm_power_manager/channel_manager.c
@@ -66,8 +66,9 @@ LIST_HEAD(, virtual_machine_info) vm_list_head;
 static struct virtual_machine_info *
 find_domain_by_name(const char *name)
 {
-   struct virtual_machine_info *info;
-   LIST_FOREACH(info, &vm_list_head, vms_info) {
+   struct virtual_machine_info *info, *t_info;
+
+   RTE_LIST_FOREACH_SAFE(info, &vm_list_head, vms_info, t_info) {
if (!strncmp(info->name, name, CHANNEL_MGR_MAX_NAME_LEN-1))
return info;
}
@@ -1005,9 +1006,9 @@ channel_manager_exit(void)
 {
unsigned i;
char mask[RTE_MAX_LCORE];
-   struct virtual_machine_info *vm_info;
+   struct virtual_machine_info *vm_info, *t_info;
 
-   LIST_FOREACH(vm_info, &vm_list_head, vms_info) {
+   RTE_LIST_FOREACH_SAFE(vm_info, &vm_list_head, vms_info, t_info) {
 
rte_spinlock_lock(&(vm_info->config_spinlock));
 
@@ -1024,6 +1025,7 @@ channel_manager_exit(void)
 
LIST_REMOVE(vm_info, vms_info);
rte_free(vm_info);
+
}
 
if (global_hypervisor_available) {
diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h
index c72bf5b7e6..3acff49360 100644
--- a/lib/eal/linux/include/rte_os.h
+++ b/lib/eal/linux/include/rte_os.h
@@ -25,6 +25,8 @@ extern "C" {
 #define RTE_TAILQ_NEXT(elem, field) TAILQ_NEXT(elem, field)
 #define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
 #define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
+#define RTE_LIST_FIRST(head) LIST_FIRST(head)
+#define RTE_LIST_NEXT(elem, field) LIST_NEXT(elem, field)
 
 #ifdef CPU_SETSIZE /* may require _GNU_SOURCE */
 typedef cpu_set_t rte_cpuset_t;
@@ -46,6 +48,15 @@ typedef cpu_set_t rte_cpuset_t;
 } while (0)
 #endif
 
+#ifndef LIST_FOREACH_SAFE
+#define LIST_FOREACH_SAFE(var, head, field, tvar) \
+   for ((var) = RTE_LIST_FIRST(head); \
+   (var) && ((tvar) = RTE_LIST_NEXT((var), field), 1); \
+   (var) = (tvar))
+#endif
+#define RTE_LIST_FOREACH_SAFE(var, head, field, tvar) \
+   LIST_FOREACH_SAFE(var, head, field, tvar)
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.25.1



[PATCH v2] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs

2022-03-22 Thread jeffd
From: Stephen Douthit 

Some XGS-PON SFPs have been observed ACKing I2C reads and returning
uninitialized garbage while their uC boots.  This can lead to the SFP ID
code marking an otherwise working SFP module as unsupported if a bogus
ID value is read while its internal PHY/microcontroller is still
booting.

Retry the ID read several times looking not just for NAK, but also for a
valid ID field.

Since the device isn't NAKing the trasanction the existing longer retry
code in ixgbe_read_i2c_byte_generic_int() doesn't apply here.

Signed-off-by: Stephen Douthit 
Signed-off-by: Jeff Daly 
---
v2:
* Removed superfluous DEBUGOUT
* Renamed id_reads to retries
* Don't assume status == 0 means IXGBE_SUCCESS

 drivers/net/ixgbe/base/ixgbe_phy.c | 30 ++
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index 8d4d9bbfef..657f404fe8 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -1267,6 +1267,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
u8 cable_tech = 0;
u8 cable_spec = 0;
u16 enforce_sfp = 0;
+   u8 retries;
 
DEBUGFUNC("ixgbe_identify_sfp_module_generic");
 
@@ -1279,12 +1280,33 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw 
*hw)
/* LAN ID is needed for I2C access */
hw->mac.ops.set_lan_id(hw);
 
-   status = hw->phy.ops.read_i2c_eeprom(hw,
-IXGBE_SFF_IDENTIFIER,
-&identifier);
+   /* Need to check this a couple of times for a sane value.
+*
+* SFPs that have a uC slaved to the I2C bus (vs. a dumb EEPROM) can be
+* poorly designed such that they will ACK I2C reads and return
+* whatever bogus data is in the SRAM (or whatever is backing the target
+* device) before things are truly initialized.
+*
+* In a perfect world devices would NAK I2C requests until they were
+* sane, but here we are.
+*
+* Give such devices a couple tries to get their act together before
+* marking the device as unsupported.
+*/
+   for (retries = 0; retries < 5; retries++) {
+   status = hw->phy.ops.read_i2c_eeprom(hw,
+IXGBE_SFF_IDENTIFIER,
+&identifier);
 
-   if (status != IXGBE_SUCCESS)
+   DEBUGOUT("status %d, SFF identifier 0x%x\n", status, 
identifier);
+   if (status == IXGBE_SUCCESS &&
+   identifier == IXGBE_SFF_IDENTIFIER_SFP)
+   break;
+   }
+
+   if (status != IXGBE_SUCCESS) {
goto err_read_i2c_eeprom;
+   }
 
if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
hw->phy.type = ixgbe_phy_sfp_unsupported;
-- 
2.25.1



DPDK seqlock

2022-03-22 Thread Mattias Rönnblom
Hi.

Would it make sense to have a seqlock implementation in DPDK?

I think so, since it's a very useful synchronization primitive in data 
plane applications.

Regards,
     Mattias



Re: [PATCH] lib/power: power pmd errata with RTM and gcc-9

2022-03-22 Thread David Hunt



On 16/3/2022 7:44 PM, Thomas Monjalon wrote:

09/03/2022 14:22, David Hunt:

An errata exists where users may see reduced power savings when using
PMD Power Management. This issue occurs when compiling DPDK applications
with gcc-9 on platforms with TSX enabled. In rte_power_monitor_multi(),
the function may return without successfully starting the RTM
transaction (the _xbegin() fails).

Signed-off-by: David Hunt 

Applied, thanks.

Is there a way to fix it or should we keep this errata forever?



If it's a gcc-9 issue, then we'll have to get the assistance to fix. 
I've send the relevant information on to the gcc folks for analysis, and 
I'll follow up at regular intervals.


I would hope to be able to remove the errata within the next one or two 
releases.





RE: DPDK seqlock

2022-03-22 Thread Ananyev, Konstantin


Hi Mattias,

> 
> Would it make sense to have a seqlock implementation in DPDK?
> 
> I think so, since it's a very useful synchronization primitive in data
> plane applications.
> 

Agree, it might be useful.
As I remember rte_hash '_lf' functions do use something similar to seqlock,
but in hand-made manner.
Probably some other entities within DPDK itself or related projects 
will benefit from it too...
   
Konstantin


Re: [PATCH 2/6] net/hns3: fix inconsistent enabled RSS behavior

2022-03-22 Thread Thomas Monjalon
21/03/2022 08:14, lihuisong (C):
> 2022/3/10 16:08, lihuisong (C):
> > 2022/3/9 17:55, Ori Kam:
> >> From: lihuisong (C) 
> >>> 2022/3/3 10:47, lihuisong (C):
>  2022/3/2 22:07, Ori Kam:
> > From: lihuisong (C) 
> >> 2022/3/1 0:42, Ferruh Yigit:
> >>> On 2/28/2022 3:21 AM, Min Hu (Connor) wrote:
>  From: Huisong Li 
> 
>  RSS will not be enabled if the RTE_ETH_MQ_RX_RSS_FLAG isn't be 
>  set in
>  dev_configure phase. However, if this flag isn't set, RSS can be
>  enabled
>  through the ethdev ops and rte_flow API. This behavior is 
>  contrary to
>  each
>  other.
> 
>  Fixes: c37ca66f2b27 ("net/hns3: support RSS")
>  Cc: sta...@dpdk.org
> 
>  Signed-off-by: Huisong Li 
> >>> Hi Huisong, Connor,
> >>>
> >>> Let's get a little more feedback for this patch, cc'ed more people.
> >>>
> >>> To enable RSS, multi queue mode should be set to
> >>> 'RTE_ETH_MQ_RX_RSS_FLAG'.
> >>>
> >>> But I wonder if it is required to configure RSS via flow API,
> >> I do not know the original purpose of adding the RSS 
> >> configuration in
> >> flow API.
> >>
> > The purpose is simple, this allow to create RSS per rule and not a
> > global one.
> > For example create RSS that sends TCP to some queues while othe RSS
> > will send
> > UDP traffic to different queues.
>  I'm a little confused now. The "per rule" also seems to be a global
>  configuration.
>  Example:
>    - start PMD with 0,1,2,3
>    - create TCP packets to 2,3 queues. At this moment, only 2,3 queues
>  can be received for other types of packets.
>  Because this rule is implemented by modifying the entry of the
>  redirection table which is global for this device.
> >>> Hi, Ori and Stephen.
> >>> Can you help me clear up the confusion above? If some NICs behave like
> >>> this, what should we do about it?
> >> I'm not sure I understand the issue, maybe it is releated to some 
> >> HW/PMD limitation.
> >> In your example non TCP traffic will be routed to one of the 4 queues 
> >> (0,1,2,3),
> >> While TCP traffic will only be routed to queues 2,3.
> >>
> >> Now I can add new rule that matches on UDP packet and RSS to queue 0 
> >> and 3 in this case:
> >> TCP packets will be routed to queues 0,3.
> >> UDP packets will be routed to queues 2,3.
> >> All the rest of the traffic will be routed to queues 0,1,2,3
> >>
> >> And just to be clear if now I add a rule to match all packets in 
> >> higher priority,
> >> with RSS to queues 1,2. Then all traffic will be routed to queues 1,2.
> >>
> >> At least this is what is expected, from API point of view.
> >>
> >> Best,
> >> Ori
> > Thank you for your answer. I understand it.
> > hns3 PMD cannot implement the above functions due to hardware limitation.
> > we may need add a check that specified RSS queues cannot be supported 
> > when specified packets types.
> > And only the packet type is specified, which meets the requirements of 
> > rte_flow API.
> > The check for the RTE_ETH_MQ_RX_RSS_FLAG flag in rte_flow is not correct.
> > Thanks, Ori and Stephen😁
> >
> > But, I think, it is necessary for the '.rss_hash_update' and 
> > '.reta_update' APIs
> > in eth_dev_ops to verify this flag. What do you think? @Thomas, 
> > @Ferruh, @Ori and @Stephen.
> What's your take on it? I am looking forward to your reply. Thanks!

I am not sure why you want to check this flag.
I can imagine we configure the hash and the table before enabling RSS
with the RTE_ETH_MQ_RX_RSS_FLAG flag.




[PATCH 1/7] examples/ipsec-secgw: disable Tx chksum offload for inline

2022-03-22 Thread Nithin Dabilpuram
Enable Tx IPv4 checksum offload only when Tx inline crypto, lookaside
crypto/protocol or cpu crypto is needed.
For Tx Inline protocol offload, checksum computation
is implicitly taken care by HW.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c |  3 ---
 examples/ipsec-secgw/sa.c  | 32 +---
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index 42b5081..76919e5 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -2330,9 +2330,6 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, 
uint64_t req_tx_offloads)
local_port_conf.txmode.offloads |=
RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
-   if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
-   local_port_conf.txmode.offloads |= 
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
-
printf("port %u configuring rx_offloads=0x%" PRIx64
", tx_offloads=0x%" PRIx64 "\n",
portid, local_port_conf.rxmode.offloads,
diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 1839ac7..36d890f 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -1785,13 +1785,31 @@ sa_check_offloads(uint16_t port_id, uint64_t 
*rx_offloads,
for (idx_sa = 0; idx_sa < nb_sa_out; idx_sa++) {
rule = &sa_out[idx_sa];
rule_type = ipsec_get_action_type(rule);
-   if ((rule_type == RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO ||
-   rule_type ==
-   RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL)
-   && rule->portid == port_id) {
-   *tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
-   if (rule->mss)
-   *tx_offloads |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
+   switch (rule_type) {
+   case RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL:
+   /* Checksum offload is not needed for inline protocol as
+* all processing for Outbound IPSec packets will be
+* implicitly taken care and for non-IPSec packets,
+* there is no need of IPv4 Checksum offload.
+*/
+   if (rule->portid == port_id)
+   *tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
+   break;
+   case RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO:
+   if (rule->portid == port_id) {
+   *tx_offloads |= RTE_ETH_TX_OFFLOAD_SECURITY;
+   if (rule->mss)
+   *tx_offloads |=
+   RTE_ETH_TX_OFFLOAD_TCP_TSO;
+   *tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+   }
+   break;
+   default:
+   /* Enable IPv4 checksum offload even if one of lookaside
+* SA's are present.
+*/
+   *tx_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+   break;
}
}
return 0;
-- 
2.8.4



[PATCH 2/7] examples/ipsec-secgw: use HW parsed packet type in poll mode

2022-03-22 Thread Nithin Dabilpuram
Use HW parsed packet type when ethdev supports necessary protocols.
If packet type is not supported, then register ethdev callbacks
for parse packet in SW. This is better for performance as it
effects fast path.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c | 259 +++--
 1 file changed, 194 insertions(+), 65 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index 76919e5..e8f9e90 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -374,53 +374,30 @@ print_stats_cb(__rte_unused void *param)
 static inline void
 prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)
 {
+   uint32_t ptype = pkt->packet_type;
const struct rte_ether_hdr *eth;
const struct rte_ipv4_hdr *iph4;
const struct rte_ipv6_hdr *iph6;
-   const struct rte_udp_hdr *udp;
-   uint16_t ip4_hdr_len;
-   uint16_t nat_port;
+   uint32_t tun_type, l3_type;
+
+   tun_type = ptype & RTE_PTYPE_TUNNEL_MASK;
+   l3_type = ptype & RTE_PTYPE_L3_MASK;
 
eth = rte_pktmbuf_mtod(pkt, const struct rte_ether_hdr *);
-   if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
-
+   if (l3_type == RTE_PTYPE_L3_IPV4) {
iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
RTE_ETHER_HDR_LEN);
adjust_ipv4_pktlen(pkt, iph4, 0);
 
-   switch (iph4->next_proto_id) {
-   case IPPROTO_ESP:
+   if (tun_type == RTE_PTYPE_TUNNEL_ESP) {
t->ipsec.pkts[(t->ipsec.num)++] = pkt;
-   break;
-   case IPPROTO_UDP:
-   if (app_sa_prm.udp_encap == 1) {
-   ip4_hdr_len = ((iph4->version_ihl &
-   RTE_IPV4_HDR_IHL_MASK) *
-   RTE_IPV4_IHL_MULTIPLIER);
-   udp = rte_pktmbuf_mtod_offset(pkt,
-   struct rte_udp_hdr *, ip4_hdr_len);
-   nat_port = rte_cpu_to_be_16(IPSEC_NAT_T_PORT);
-   if (udp->src_port == nat_port ||
-   udp->dst_port == nat_port){
-   t->ipsec.pkts[(t->ipsec.num)++] = pkt;
-   pkt->packet_type |=
-   MBUF_PTYPE_TUNNEL_ESP_IN_UDP;
-   break;
-   }
-   }
-   /* Fall through */
-   default:
+   } else {
t->ip4.data[t->ip4.num] = &iph4->next_proto_id;
t->ip4.pkts[(t->ip4.num)++] = pkt;
}
pkt->l2_len = 0;
pkt->l3_len = sizeof(*iph4);
-   pkt->packet_type |= RTE_PTYPE_L3_IPV4;
-   if  (pkt->packet_type & RTE_PTYPE_L4_TCP)
-   pkt->l4_len = sizeof(struct rte_tcp_hdr);
-   else if (pkt->packet_type & RTE_PTYPE_L4_UDP)
-   pkt->l4_len = sizeof(struct rte_udp_hdr);
-   } else if (eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
+   } else if (l3_type & RTE_PTYPE_L3_IPV6) {
int next_proto;
size_t l3len, ext_len;
uint8_t *p;
@@ -430,47 +407,37 @@ prepare_one_packet(struct rte_mbuf *pkt, struct 
ipsec_traffic *t)
RTE_ETHER_HDR_LEN);
adjust_ipv6_pktlen(pkt, iph6, 0);
 
-   next_proto = iph6->proto;
-
-   /* determine l3 header size up to ESP extension */
l3len = sizeof(struct ip6_hdr);
-   p = rte_pktmbuf_mtod(pkt, uint8_t *);
-   while (next_proto != IPPROTO_ESP && l3len < pkt->data_len &&
-   (next_proto = rte_ipv6_get_next_ext(p + l3len,
-   next_proto, &ext_len)) >= 0)
-   l3len += ext_len;
 
-   /* drop packet when IPv6 header exceeds first segment length */
-   if (unlikely(l3len > pkt->data_len)) {
-   free_pkts(&pkt, 1);
-   return;
-   }
-
-   switch (next_proto) {
-   case IPPROTO_ESP:
+   if (tun_type == RTE_PTYPE_TUNNEL_ESP) {
t->ipsec.pkts[(t->ipsec.num)++] = pkt;
-   break;
-   case IPPROTO_UDP:
-   if (app_sa_prm.udp_encap == 1) {
-   udp = rte_pktmbuf_mtod_offset(pkt,
-   struct rte_udp_hdr *, l3len);
-   nat_port = rte_cpu_to_be_16(IPSEC_NAT_T_PORT);
-   if (udp

[PATCH 3/7] examples/ipsec-secgw: allow larger burst size for vectors

2022-03-22 Thread Nithin Dabilpuram
Allow larger burst size of vector event mode instead of restricting
to 32. Also restructure traffic type struct to have num pkts first
so that it is always in first cacheline. Also cache align
traffic type struct. Since MAX_PKT_BURST is not used by
vector event mode worker, define another macro for its burst
size so that poll mode perf is not effected.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c |  2 +-
 examples/ipsec-secgw/ipsec-secgw.h | 15 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index e8f9e90..7e01495 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1858,7 +1858,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf 
*eh_conf)
case CMD_LINE_OPT_VECTOR_SIZE_NUM:
ret = parse_decimal(optarg);
 
-   if (ret > MAX_PKT_BURST) {
+   if (ret > MAX_PKT_BURST_VEC) {
printf("Invalid argument for \'%s\': %s\n",
CMD_LINE_OPT_VECTOR_SIZE, optarg);
print_usage(prgname);
diff --git a/examples/ipsec-secgw/ipsec-secgw.h 
b/examples/ipsec-secgw/ipsec-secgw.h
index 24f11ad..c347175 100644
--- a/examples/ipsec-secgw/ipsec-secgw.h
+++ b/examples/ipsec-secgw/ipsec-secgw.h
@@ -10,6 +10,11 @@
 #define NB_SOCKETS 4
 
 #define MAX_PKT_BURST 32
+#define MAX_PKT_BURST_VEC 256
+
+#define MAX_PKTS  \
+   ((MAX_PKT_BURST_VEC > MAX_PKT_BURST ? \
+ MAX_PKT_BURST_VEC : MAX_PKT_BURST) * 2)
 
 #define RTE_LOGTYPE_IPSEC RTE_LOGTYPE_USER1
 
@@ -48,12 +53,12 @@
 #define MBUF_PTYPE_TUNNEL_ESP_IN_UDP (RTE_PTYPE_TUNNEL_ESP | RTE_PTYPE_L4_UDP)
 
 struct traffic_type {
-   const uint8_t *data[MAX_PKT_BURST * 2];
-   struct rte_mbuf *pkts[MAX_PKT_BURST * 2];
-   void *saptr[MAX_PKT_BURST * 2];
-   uint32_t res[MAX_PKT_BURST * 2];
uint32_t num;
-};
+   struct rte_mbuf *pkts[MAX_PKTS];
+   const uint8_t *data[MAX_PKTS];
+   void *saptr[MAX_PKTS];
+   uint32_t res[MAX_PKTS];
+} __rte_cache_aligned;
 
 struct ipsec_traffic {
struct traffic_type ipsec;
-- 
2.8.4



[PATCH 4/7] examples/ipsec-secgw: move fast path helper functions

2022-03-22 Thread Nithin Dabilpuram
Move fast path helper functions to header file for easy access.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c   | 547 +-
 examples/ipsec-secgw/ipsec-secgw.h   |   4 +
 examples/ipsec-secgw/ipsec.h |  34 +++
 examples/ipsec-secgw/ipsec_process.c |  49 +--
 examples/ipsec-secgw/ipsec_worker.h  | 560 +++
 5 files changed, 602 insertions(+), 592 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index 7e01495..1d0ce3a 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -70,11 +70,6 @@ volatile bool force_quit;
 
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
 
-/* Configure how many packets ahead to prefetch, when reading packets */
-#define PREFETCH_OFFSET3
-
-#define MAX_RX_QUEUE_PER_LCORE 16
-
 #define MAX_LCORE_PARAMS 1024
 
 /*
@@ -191,9 +186,9 @@ static uint64_t dev_tx_offload = UINT64_MAX;
 /*
  * global values that determine multi-seg policy
  */
-static uint32_t frag_tbl_sz;
+uint32_t frag_tbl_sz;
 static uint32_t frame_buf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
-static uint32_t mtu_size = RTE_ETHER_MTU;
+uint32_t mtu_size = RTE_ETHER_MTU;
 static uint64_t frag_ttl_ns = MAX_FRAG_TTL_NS;
 static uint32_t stats_interval;
 
@@ -205,11 +200,6 @@ struct app_sa_prm app_sa_prm = {
};
 static const char *cfgfile;
 
-struct lcore_rx_queue {
-   uint16_t port_id;
-   uint8_t queue_id;
-} __rte_cache_aligned;
-
 struct lcore_params {
uint16_t port_id;
uint8_t queue_id;
@@ -224,28 +214,7 @@ static uint16_t nb_lcore_params;
 static struct rte_hash *cdev_map_in;
 static struct rte_hash *cdev_map_out;
 
-struct buffer {
-   uint16_t len;
-   struct rte_mbuf *m_table[MAX_PKT_BURST] __rte_aligned(sizeof(void *));
-};
-
-struct lcore_conf {
-   uint16_t nb_rx_queue;
-   struct lcore_rx_queue rx_queue_list[MAX_RX_QUEUE_PER_LCORE];
-   uint16_t tx_queue_id[RTE_MAX_ETHPORTS];
-   struct buffer tx_mbufs[RTE_MAX_ETHPORTS];
-   struct ipsec_ctx inbound;
-   struct ipsec_ctx outbound;
-   struct rt_ctx *rt4_ctx;
-   struct rt_ctx *rt6_ctx;
-   struct {
-   struct rte_ip_frag_tbl *tbl;
-   struct rte_mempool *pool_indir;
-   struct rte_ip_frag_death_row dr;
-   } frag;
-} __rte_cache_aligned;
-
-static struct lcore_conf lcore_conf[RTE_MAX_LCORE];
+struct lcore_conf lcore_conf[RTE_MAX_LCORE];
 
 static struct rte_eth_conf port_conf = {
.rxmode = {
@@ -281,32 +250,6 @@ multi_seg_required(void)
frame_buf_size || frag_tbl_sz != 0);
 }
 
-static inline void
-adjust_ipv4_pktlen(struct rte_mbuf *m, const struct rte_ipv4_hdr *iph,
-   uint32_t l2_len)
-{
-   uint32_t plen, trim;
-
-   plen = rte_be_to_cpu_16(iph->total_length) + l2_len;
-   if (plen < m->pkt_len) {
-   trim = m->pkt_len - plen;
-   rte_pktmbuf_trim(m, trim);
-   }
-}
-
-static inline void
-adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph,
-   uint32_t l2_len)
-{
-   uint32_t plen, trim;
-
-   plen = rte_be_to_cpu_16(iph->payload_len) + sizeof(*iph) + l2_len;
-   if (plen < m->pkt_len) {
-   trim = m->pkt_len - plen;
-   rte_pktmbuf_trim(m, trim);
-   }
-}
-
 
 struct ipsec_core_statistics core_statistics[RTE_MAX_LCORE];
 
@@ -371,341 +314,6 @@ print_stats_cb(__rte_unused void *param)
rte_eal_alarm_set(stats_interval * US_PER_S, print_stats_cb, NULL);
 }
 
-static inline void
-prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)
-{
-   uint32_t ptype = pkt->packet_type;
-   const struct rte_ether_hdr *eth;
-   const struct rte_ipv4_hdr *iph4;
-   const struct rte_ipv6_hdr *iph6;
-   uint32_t tun_type, l3_type;
-
-   tun_type = ptype & RTE_PTYPE_TUNNEL_MASK;
-   l3_type = ptype & RTE_PTYPE_L3_MASK;
-
-   eth = rte_pktmbuf_mtod(pkt, const struct rte_ether_hdr *);
-   if (l3_type == RTE_PTYPE_L3_IPV4) {
-   iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
-   RTE_ETHER_HDR_LEN);
-   adjust_ipv4_pktlen(pkt, iph4, 0);
-
-   if (tun_type == RTE_PTYPE_TUNNEL_ESP) {
-   t->ipsec.pkts[(t->ipsec.num)++] = pkt;
-   } else {
-   t->ip4.data[t->ip4.num] = &iph4->next_proto_id;
-   t->ip4.pkts[(t->ip4.num)++] = pkt;
-   }
-   pkt->l2_len = 0;
-   pkt->l3_len = sizeof(*iph4);
-   } else if (l3_type & RTE_PTYPE_L3_IPV6) {
-   int next_proto;
-   size_t l3len, ext_len;
-   uint8_t *p;
-
-   /* get protocol type */
-   iph6 = (const struct rte_ipv6_hdr *)rte_pktmbuf_adj(pkt,
-   RTE_ETHER_HDR_LEN);
-   adjust_ipv6_

[PATCH 5/7] examples/ipsec-secgw: get security context from lcore conf

2022-03-22 Thread Nithin Dabilpuram
Store security context pointer in lcore Rx queue config and
get it from there in fast path for better performance.
Currently rte_eth_dev_get_sec_ctx() which is meant to be control
path API is called per packet basis. For every call to that
API, ethdev port status is checked.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c  | 22 +++---
 examples/ipsec-secgw/ipsec.h|  1 +
 examples/ipsec-secgw/ipsec_worker.h | 17 +++--
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index 1d0ce3a..a04b5e8 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -544,11 +544,11 @@ process_pkts_outbound_nosp(struct ipsec_ctx *ipsec_ctx,
 
 static inline void
 process_pkts(struct lcore_conf *qconf, struct rte_mbuf **pkts,
-   uint8_t nb_pkts, uint16_t portid)
+uint8_t nb_pkts, uint16_t portid, struct rte_security_ctx *ctx)
 {
struct ipsec_traffic traffic;
 
-   prepare_traffic(pkts, &traffic, nb_pkts);
+   prepare_traffic(ctx, pkts, &traffic, nb_pkts);
 
if (unlikely(single_sa)) {
if (is_unprotected_port(portid))
@@ -740,7 +740,8 @@ ipsec_poll_mode_worker(void)
 
if (nb_rx > 0) {
core_stats_update_rx(nb_rx);
-   process_pkts(qconf, pkts, nb_rx, portid);
+   process_pkts(qconf, pkts, nb_rx, portid,
+rxql->sec_ctx);
}
 
/* dequeue and process completed crypto-ops */
@@ -3060,6 +3061,21 @@ main(int32_t argc, char **argv)
 
flow_init();
 
+   /* Get security context if available and only if dynamic field is
+* registered for fast path access.
+*/
+   if (!rte_security_dynfield_is_registered())
+   goto skip_sec_ctx;
+
+   for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+   for (i = 0; i < lcore_conf[lcore_id].nb_rx_queue; i++) {
+   portid = lcore_conf[lcore_id].rx_queue_list[i].port_id;
+   lcore_conf[lcore_id].rx_queue_list[i].sec_ctx =
+   rte_eth_dev_get_sec_ctx(portid);
+   }
+   }
+skip_sec_ctx:
+
check_all_ports_link_status(enabled_port_mask);
 
if (stats_interval > 0)
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index 9a4e7ea..ecad262 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -269,6 +269,7 @@ struct cnt_blk {
 struct lcore_rx_queue {
uint16_t port_id;
uint8_t queue_id;
+   struct rte_security_ctx *sec_ctx;
 } __rte_cache_aligned;
 
 struct buffer {
diff --git a/examples/ipsec-secgw/ipsec_worker.h 
b/examples/ipsec-secgw/ipsec_worker.h
index eb966a6..838b3f6 100644
--- a/examples/ipsec-secgw/ipsec_worker.h
+++ b/examples/ipsec-secgw/ipsec_worker.h
@@ -115,7 +115,8 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct 
rte_ipv6_hdr *iph,
 }
 
 static __rte_always_inline void
-prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t)
+prepare_one_packet(struct rte_security_ctx *ctx, struct rte_mbuf *pkt,
+  struct ipsec_traffic *t)
 {
uint32_t ptype = pkt->packet_type;
const struct rte_ether_hdr *eth;
@@ -201,13 +202,9 @@ prepare_one_packet(struct rte_mbuf *pkt, struct 
ipsec_traffic *t)
 * with the security session.
 */
 
-   if (pkt->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD &&
-   rte_security_dynfield_is_registered()) {
+   if (ctx && pkt->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD) {
struct ipsec_sa *sa;
struct ipsec_mbuf_metadata *priv;
-   struct rte_security_ctx *ctx = (struct rte_security_ctx *)
-   rte_eth_dev_get_sec_ctx(
-   pkt->port);
 
/* Retrieve the userdata registered. Here, the userdata
 * registered is the SA pointer.
@@ -229,8 +226,8 @@ prepare_one_packet(struct rte_mbuf *pkt, struct 
ipsec_traffic *t)
 }
 
 static __rte_always_inline void
-prepare_traffic(struct rte_mbuf **pkts, struct ipsec_traffic *t,
-   uint16_t nb_pkts)
+prepare_traffic(struct rte_security_ctx *ctx, struct rte_mbuf **pkts,
+   struct ipsec_traffic *t, uint16_t nb_pkts)
 {
int32_t i;
 
@@ -241,11 +238,11 @@ prepare_traffic(struct rte_mbuf **pkts, struct 
ipsec_traffic *t,
for (i = 0; i < (nb_pkts - PREFETCH_OFFSET); i++) {
rte_prefetch0(rte_pktmbuf_mtod(pkts[i + PREFETCH_OFFSET],
void *));
-   prepare_one_packet(pkts[i], t);
+   prepare_one_packet(ctx, pkts[i], t);
}

[PATCH 6/7] examples/ipsec-secgw: update eth header during route lookup

2022-03-22 Thread Nithin Dabilpuram
Update ethernet header during route lookup instead of doing
way later while performing Tx burst. Advantages to doing
is at route lookup is that no additional IP version checks
based on packet data are needed and packet data is already
in cache as route lookup is already consuming that data.

This is also useful for inline protocol offload cases
of v4inv6 or v6inv4 outbound tunnel operations as
packet data will not have any info about what is the tunnel
protocol.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c  |   9 +-
 examples/ipsec-secgw/ipsec_worker.h | 197 ++--
 2 files changed, 129 insertions(+), 77 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index a04b5e8..84f6150 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -562,7 +562,8 @@ process_pkts(struct lcore_conf *qconf, struct rte_mbuf 
**pkts,
process_pkts_outbound(&qconf->outbound, &traffic);
}
 
-   route4_pkts(qconf->rt4_ctx, traffic.ip4.pkts, traffic.ip4.num);
+   route4_pkts(qconf->rt4_ctx, traffic.ip4.pkts, traffic.ip4.num,
+   qconf->outbound.ipv4_offloads, true);
route6_pkts(qconf->rt6_ctx, traffic.ip6.pkts, traffic.ip6.num);
 }
 
@@ -613,7 +614,8 @@ drain_inbound_crypto_queues(const struct lcore_conf *qconf,
if (trf.ip4.num != 0) {
inbound_sp_sa(ctx->sp4_ctx, ctx->sa_ctx, &trf.ip4, 0,
&core_statistics[lcoreid].inbound.spd4);
-   route4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num);
+   route4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num,
+   qconf->outbound.ipv4_offloads, true);
}
 
/* process ipv6 packets */
@@ -647,7 +649,8 @@ drain_outbound_crypto_queues(const struct lcore_conf *qconf,
 
/* process ipv4 packets */
if (trf.ip4.num != 0)
-   route4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num);
+   route4_pkts(qconf->rt4_ctx, trf.ip4.pkts, trf.ip4.num,
+   qconf->outbound.ipv4_offloads, true);
 
/* process ipv6 packets */
if (trf.ip6.num != 0)
diff --git a/examples/ipsec-secgw/ipsec_worker.h 
b/examples/ipsec-secgw/ipsec_worker.h
index 838b3f6..b183248 100644
--- a/examples/ipsec-secgw/ipsec_worker.h
+++ b/examples/ipsec-secgw/ipsec_worker.h
@@ -245,60 +245,6 @@ prepare_traffic(struct rte_security_ctx *ctx, struct 
rte_mbuf **pkts,
prepare_one_packet(ctx, pkts[i], t);
 }
 
-static __rte_always_inline void
-prepare_tx_pkt(struct rte_mbuf *pkt, uint16_t port,
-   const struct lcore_conf *qconf)
-{
-   struct ip *ip;
-   struct rte_ether_hdr *ethhdr;
-
-   ip = rte_pktmbuf_mtod(pkt, struct ip *);
-
-   ethhdr = (struct rte_ether_hdr *)
-   rte_pktmbuf_prepend(pkt, RTE_ETHER_HDR_LEN);
-
-   if (ip->ip_v == IPVERSION) {
-   pkt->ol_flags |= qconf->outbound.ipv4_offloads;
-   pkt->l3_len = sizeof(struct ip);
-   pkt->l2_len = RTE_ETHER_HDR_LEN;
-
-   ip->ip_sum = 0;
-
-   /* calculate IPv4 cksum in SW */
-   if ((pkt->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) == 0)
-   ip->ip_sum = rte_ipv4_cksum((struct rte_ipv4_hdr *)ip);
-
-   ethhdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
-   } else {
-   pkt->ol_flags |= qconf->outbound.ipv6_offloads;
-   pkt->l3_len = sizeof(struct ip6_hdr);
-   pkt->l2_len = RTE_ETHER_HDR_LEN;
-
-   ethhdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
-   }
-
-   memcpy(ðhdr->src_addr, ðaddr_tbl[port].src,
-   sizeof(struct rte_ether_addr));
-   memcpy(ðhdr->dst_addr, ðaddr_tbl[port].dst,
-   sizeof(struct rte_ether_addr));
-}
-
-static __rte_always_inline void
-prepare_tx_burst(struct rte_mbuf *pkts[], uint16_t nb_pkts, uint16_t port,
-   const struct lcore_conf *qconf)
-{
-   int32_t i;
-   const int32_t prefetch_offset = 2;
-
-   for (i = 0; i < (nb_pkts - prefetch_offset); i++) {
-   rte_mbuf_prefetch_part2(pkts[i + prefetch_offset]);
-   prepare_tx_pkt(pkts[i], port, qconf);
-   }
-   /* Process left packets */
-   for (; i < nb_pkts; i++)
-   prepare_tx_pkt(pkts[i], port, qconf);
-}
-
 /* Send burst of packets on an output interface */
 static __rte_always_inline int32_t
 send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t port)
@@ -310,8 +256,6 @@ send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t 
port)
queueid = qconf->tx_queue_id[port];
m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
 
-   prepare_tx_burst(m_table, n, port, qconf);
-
ret = rte_eth_tx_burst(port, queueid, m_table, n);
 
core_stat

[PATCH 7/7] examples/ipsec-secgw: add poll mode worker for inline proto

2022-03-22 Thread Nithin Dabilpuram
Add separate worker thread when all SA's are of type
inline protocol offload and librte_ipsec is enabled
in order to make it more optimal for that case.
Current default worker supports all kinds of SA leading
to doing lot of per-packet checks and branching based on
SA type which can be of 5 types of SA's.

Also make a provision for choosing different poll mode workers
for different combinations of SA types with default being
existing poll mode worker that supports all kinds of SA's.

Signed-off-by: Nithin Dabilpuram 
---
 examples/ipsec-secgw/ipsec-secgw.c  |   6 +-
 examples/ipsec-secgw/ipsec-secgw.h  |  10 +
 examples/ipsec-secgw/ipsec_worker.c | 378 +++-
 examples/ipsec-secgw/ipsec_worker.h |   4 +
 examples/ipsec-secgw/sa.c   |   9 +
 5 files changed, 403 insertions(+), 4 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index 84f6150..515b344 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -68,8 +68,6 @@ volatile bool force_quit;
 #define CDEV_MP_CACHE_MULTIPLIER 1.5 /* from rte_mempool.c */
 #define MAX_QUEUE_PAIRS 1
 
-#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
-
 #define MAX_LCORE_PARAMS 1024
 
 /*
@@ -173,7 +171,7 @@ static uint64_t enabled_cryptodev_mask = UINT64_MAX;
 static int32_t promiscuous_on = 1;
 static int32_t numa_on = 1; /**< NUMA is enabled by default. */
 static uint32_t nb_lcores;
-static uint32_t single_sa;
+uint32_t single_sa;
 uint32_t nb_bufs_in_pool;
 
 /*
@@ -238,6 +236,7 @@ struct socket_ctx socket_ctx[NB_SOCKETS];
 
 bool per_port_pool;
 
+uint16_t wrkr_flags;
 /*
  * Determine is multi-segment support required:
  *  - either frame buffer size is smaller then mtu
@@ -1233,6 +1232,7 @@ parse_args(int32_t argc, char **argv, struct eh_conf 
*eh_conf)
single_sa = 1;
single_sa_idx = ret;
eh_conf->ipsec_mode = EH_IPSEC_MODE_TYPE_DRIVER;
+   wrkr_flags |= SS_F;
printf("Configured with single SA index %u\n",
single_sa_idx);
break;
diff --git a/examples/ipsec-secgw/ipsec-secgw.h 
b/examples/ipsec-secgw/ipsec-secgw.h
index 2edf631..f027360 100644
--- a/examples/ipsec-secgw/ipsec-secgw.h
+++ b/examples/ipsec-secgw/ipsec-secgw.h
@@ -135,6 +135,7 @@ extern uint32_t unprotected_port_mask;
 
 /* Index of SA in single mode */
 extern uint32_t single_sa_idx;
+extern uint32_t single_sa;
 
 extern volatile bool force_quit;
 
@@ -145,6 +146,15 @@ extern bool per_port_pool;
 extern uint32_t mtu_size;
 extern uint32_t frag_tbl_sz;
 
+#define SS_F   (1U << 0)   /* Single SA mode */
+#define INL_PR_F   (1U << 1)   /* Inline Protocol */
+#define INL_CR_F   (1U << 2)   /* Inline Crypto */
+#define LA_PR_F(1U << 3)   /* Lookaside Protocol */
+#define LA_ANY_F   (1U << 4)   /* Lookaside Any */
+#define MAX_F  (LA_ANY_F << 1)
+
+extern uint16_t wrkr_flags;
+
 static inline uint8_t
 is_unprotected_port(uint16_t port_id)
 {
diff --git a/examples/ipsec-secgw/ipsec_worker.c 
b/examples/ipsec-secgw/ipsec_worker.c
index 8639426..2b96951 100644
--- a/examples/ipsec-secgw/ipsec_worker.c
+++ b/examples/ipsec-secgw/ipsec_worker.c
@@ -17,6 +17,8 @@ struct port_drv_mode_data {
struct rte_security_ctx *ctx;
 };
 
+typedef void (*ipsec_worker_fn_t)(void);
+
 static inline enum pkt_type
 process_ipsec_get_pkt_type(struct rte_mbuf *pkt, uint8_t **nlp)
 {
@@ -1004,6 +1006,380 @@ ipsec_eventmode_worker(struct eh_conf *conf)
eh_launch_worker(conf, ipsec_wrkr, nb_wrkr_param);
 }
 
+static __rte_always_inline void
+outb_inl_pro_spd_process(struct sp_ctx *sp,
+struct sa_ctx *sa_ctx,
+struct traffic_type *ip,
+struct traffic_type *match,
+struct traffic_type *mismatch,
+bool match_flag,
+struct ipsec_spd_stats *stats)
+{
+   uint32_t prev_sa_idx = UINT32_MAX;
+   struct rte_mbuf *ipsec[MAX_PKT_BURST];
+   struct rte_ipsec_session *ips;
+   uint32_t i, j, j_mis, sa_idx;
+   struct ipsec_sa *sa = NULL;
+   uint32_t ipsec_num = 0;
+   struct rte_mbuf *m;
+   uint64_t satp;
+
+   if (ip->num == 0 || sp == NULL)
+   return;
+
+   rte_acl_classify((struct rte_acl_ctx *)sp, ip->data, ip->res,
+   ip->num, DEFAULT_MAX_CATEGORIES);
+
+   j = match->num;
+   j_mis = mismatch->num;
+
+   for (i = 0; i < ip->num; i++) {
+   m = ip->pkts[i];
+   sa_idx = ip->res[i] - 1;
+
+   if (unlikely(ip->res[i] == DISCARD)) {
+   free_pkts(&m, 1);
+
+   stats->discard++;
+   } else if (unlikely(ip->res[i] == BYPASS)) {
+   

RE: [PATCH v2] net/ixgbe: Retry SFP ID read field to handle misbehaving SFPs

2022-03-22 Thread Wang, Haiyue
> -Original Message-
> From: je...@silicom-usa.com 
> Sent: Tuesday, March 22, 2022 23:24
> To: dev@dpdk.org
> Cc: Stephen Douthit ; Daly, Jeff 
> ; Wang, Haiyue
> 
> Subject: [PATCH v2] net/ixgbe: Retry SFP ID read field to handle misbehaving 
> SFPs
> 
> From: Stephen Douthit 
> 
> Some XGS-PON SFPs have been observed ACKing I2C reads and returning
> uninitialized garbage while their uC boots.  This can lead to the SFP ID
> code marking an otherwise working SFP module as unsupported if a bogus
> ID value is read while its internal PHY/microcontroller is still
> booting.
> 
> Retry the ID read several times looking not just for NAK, but also for a
> valid ID field.
> 
> Since the device isn't NAKing the trasanction the existing longer retry
> code in ixgbe_read_i2c_byte_generic_int() doesn't apply here.
> 
> Signed-off-by: Stephen Douthit 
> Signed-off-by: Jeff Daly 
> ---
> v2:
> * Removed superfluous DEBUGOUT
> * Renamed id_reads to retries
> * Don't assume status == 0 means IXGBE_SUCCESS
> 
>  drivers/net/ixgbe/base/ixgbe_phy.c | 30 ++
>  1 file changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
> b/drivers/net/ixgbe/base/ixgbe_phy.c
> index 8d4d9bbfef..657f404fe8 100644
> --- a/drivers/net/ixgbe/base/ixgbe_phy.c
> +++ b/drivers/net/ixgbe/base/ixgbe_phy.c
> @@ -1267,6 +1267,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw 
> *hw)
>   u8 cable_tech = 0;
>   u8 cable_spec = 0;
>   u16 enforce_sfp = 0;
> + u8 retries;
> 
>   DEBUGFUNC("ixgbe_identify_sfp_module_generic");
> 
> @@ -1279,12 +1280,33 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw 
> *hw)
>   /* LAN ID is needed for I2C access */
>   hw->mac.ops.set_lan_id(hw);
> 
> - status = hw->phy.ops.read_i2c_eeprom(hw,
> -  IXGBE_SFF_IDENTIFIER,
> -  &identifier);
> + /* Need to check this a couple of times for a sane value.
> +  *
> +  * SFPs that have a uC slaved to the I2C bus (vs. a dumb EEPROM) can be
> +  * poorly designed such that they will ACK I2C reads and return
> +  * whatever bogus data is in the SRAM (or whatever is backing the target
> +  * device) before things are truly initialized.
> +  *
> +  * In a perfect world devices would NAK I2C requests until they were
> +  * sane, but here we are.
> +  *
> +  * Give such devices a couple tries to get their act together before
> +  * marking the device as unsupported.
> +  */
> + for (retries = 0; retries < 5; retries++) {
> + status = hw->phy.ops.read_i2c_eeprom(hw,
> +  IXGBE_SFF_IDENTIFIER,
> +  &identifier);
> 
> - if (status != IXGBE_SUCCESS)
> + DEBUGOUT("status %d, SFF identifier 0x%x\n", status, 
> identifier);
> + if (status == IXGBE_SUCCESS &&
> + identifier == IXGBE_SFF_IDENTIFIER_SFP)
> + break;
> + }
> +
> + if (status != IXGBE_SUCCESS) {
>   goto err_read_i2c_eeprom;
> + }
> 

Just one line, no need {}

if (status != IXGBE_SUCCESS)
goto err_read_i2c_eeprom;

>   if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
>   hw->phy.type = ixgbe_phy_sfp_unsupported;
> --
> 2.25.1



RE: [PATCH 1/1] ethdev: add packet expiry event subtype

2022-03-22 Thread Vamsi Krishna Attunuru
Ping..

> -Original Message-
> From: Vamsi Attunuru 
> Sent: Thursday, March 17, 2022 1:28 PM
> To: dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran ; Nithin Kumar
> Dabilpuram ; Akhil Goyal
> ; Vamsi Krishna Attunuru 
> Subject: [PATCH 1/1] ethdev: add packet expiry event subtype
> 
> Patch adds a new event subtype for notifying expiry event upon soft packet
> limit expiry.
> 
> Signed-off-by: Vamsi Attunuru 
> ---
>  lib/ethdev/rte_ethdev.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index
> 04cff8ee10..07d1f02bae 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -3828,6 +3828,8 @@ enum rte_eth_event_ipsec_subtype {
>   RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY,
>   /** Soft byte expiry of SA */
>   RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY,
> + /** Soft packet expiry of SA */
> + RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY,
>   /** Max value of this enum */
>   RTE_ETH_EVENT_IPSEC_MAX
>  };
> @@ -3849,6 +3851,7 @@ struct rte_eth_event_ipsec_desc {
>* - @ref RTE_ETH_EVENT_IPSEC_ESN_OVERFLOW
>* - @ref RTE_ETH_EVENT_IPSEC_SA_TIME_EXPIRY
>* - @ref RTE_ETH_EVENT_IPSEC_SA_BYTE_EXPIRY
> +  * - @ref RTE_ETH_EVENT_IPSEC_SA_PKT_EXPIRY
>*
>* @see struct rte_security_session_conf
>*
> --
> 2.25.1



[PATCH] net/netvsc: fix the calculation of checksums based on mbuf flag

2022-03-22 Thread longli
From: Long Li 

The netvsc should use RTE_MBUF_F_TX_L4_MASK and check the value to decide
the correct way to calculate checksums.

Signed-off-by: Long Li 
---
 drivers/net/netvsc/hn_rxtx.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 028f176c7e..34f40be5b8 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -1348,8 +1348,11 @@ static void hn_encap(struct rndis_packet_msg *pkt,
*pi_data = NDIS_LSO2_INFO_MAKEIPV4(hlen,
   m->tso_segsz);
}
-   } else if (m->ol_flags &
-  (RTE_MBUF_F_TX_TCP_CKSUM | RTE_MBUF_F_TX_UDP_CKSUM | 
RTE_MBUF_F_TX_IP_CKSUM)) {
+   } else if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+   RTE_MBUF_F_TX_TCP_CKSUM ||
+  (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+   RTE_MBUF_F_TX_UDP_CKSUM ||
+  (m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM)) {
pi_data = hn_rndis_pktinfo_append(pkt, NDIS_TXCSUM_INFO_SIZE,
  NDIS_PKTINFO_TYPE_CSUM);
*pi_data = 0;
@@ -1363,9 +1366,11 @@ static void hn_encap(struct rndis_packet_msg *pkt,
*pi_data |= NDIS_TXCSUM_INFO_IPCS;
}
 
-   if (m->ol_flags & RTE_MBUF_F_TX_TCP_CKSUM)
+   if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+   RTE_MBUF_F_TX_TCP_CKSUM)
*pi_data |= NDIS_TXCSUM_INFO_MKTCPCS(hlen);
-   else if (m->ol_flags & RTE_MBUF_F_TX_UDP_CKSUM)
+   else if ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) ==
+   RTE_MBUF_F_TX_UDP_CKSUM)
*pi_data |= NDIS_TXCSUM_INFO_MKUDPCS(hlen);
}
 
-- 
2.32.0



[PATCH] net/netvsc: report correct stats values

2022-03-22 Thread longli
From: Long Li 

The netvsc should add to the values from the VF and report the sum.

Signed-off-by: Long Li 
---
 drivers/net/netvsc/hn_ethdev.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 9b8d2f770a..53e8cc675c 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -800,8 +800,8 @@ static int hn_dev_stats_get(struct rte_eth_dev *dev,
stats->oerrors += txq->stats.errors;
 
if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
-   stats->q_opackets[i] = txq->stats.packets;
-   stats->q_obytes[i] = txq->stats.bytes;
+   stats->q_opackets[i] += txq->stats.packets;
+   stats->q_obytes[i] += txq->stats.bytes;
}
}
 
@@ -817,12 +817,12 @@ static int hn_dev_stats_get(struct rte_eth_dev *dev,
stats->imissed += rxq->stats.ring_full;
 
if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
-   stats->q_ipackets[i] = rxq->stats.packets;
-   stats->q_ibytes[i] = rxq->stats.bytes;
+   stats->q_ipackets[i] += rxq->stats.packets;
+   stats->q_ibytes[i] += rxq->stats.bytes;
}
}
 
-   stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
+   stats->rx_nombuf += dev->data->rx_mbuf_alloc_failed;
return 0;
 }
 
-- 
2.32.0