Re: [dpdk-dev] [PATCH v4 2/5] app/testpmd: add Rx buffer size display in queue info query

2020-09-20 Thread Chengchang Tang



On 2020/9/18 16:54, Ferruh Yigit wrote:
> On 9/5/2020 10:07 AM, Chengchang Tang wrote:
>> Add Rx buffer size to queue info querry cmd so that the user can get the
>> buffer length used by HW queue for receiving packets.
>>
>> Signed-off-by: Chengchang Tang 
>> Reviewed-by: Wei Hu (Xavier) 
>> ---
>>   app/test-pmd/config.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
>> index 30bee33..b432ac6 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -452,6 +452,7 @@ rx_queue_infos_display(portid_t port_id, uint16_t 
>> queue_id)
>>   (qinfo.conf.rx_deferred_start != 0) ? "on" : "off");
>>   printf("\nRX scattered packets: %s",
>>   (qinfo.scattered_rx != 0) ? "on" : "off");
>> +printf("\nRX buffer size: %hu", qinfo.rx_buf_size);
> 
> Since this field is optional for PMD to fill, it may be confusing to display 
> buffer size as "0".
> What do you think print this value when "qinfo.rx_buf_size != 0"?

Agree, it will be modified in the next version.
> 
> .
> 



Re: [dpdk-dev] [PATCH] devtools: fix ninja break under default DESTDIR path

2020-09-20 Thread Phil Yang
Juraj Linkeš  writes:

> > Subject: [dpdk-dev] [PATCH] devtools: fix ninja break under default
> DESTDIR
> > path
> >
> > If DPDK_ABI_REF_DIR is not set, the default DESTDIR is a relative path.
> > This will break ninja in the ABI check test.
> >
> 
> The commit message is not very clear. The problem is we're specifying ninja's
> destination dir in variable DESTDIR when invoking ninja install. If the 
> DESTDIR
> is not an absolute path, ninja complains (when invoking install). This isn't
Yes, this defect is due to 'ninja install' not happy with the relative path. 
Will reword the commit message in the next version.

> directly related to DPDK_ABI_REF_DIR, it's more a problem with how we call
> install_target.
If we have set 'DPDK_ABI_REF_DIR' before the test, 'abiref' should be an 
absolute path, but the default 'abiref' value is a relative path.
So should we keep them align?

> 
> > Fixes: 777014e56d07 ("devtools: add ABI checks")
> >
> > Signed-off-by: Phil Yang 
> > ---
> >  devtools/test-meson-builds.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-
> builds.sh index
> > a87de63..2bfcaca 100755
> > --- a/devtools/test-meson-builds.sh
> > +++ b/devtools/test-meson-builds.sh
> > @@ -143,7 +143,7 @@ build () #  
> > 
> > config $srcdir $builds_dir/$targetdir $cross --werror $*
> > compile $builds_dir/$targetdir
> > if [ -n "$DPDK_ABI_REF_VERSION" ]; then
> > -   abirefdir=${DPDK_ABI_REF_DIR:-
> > reference}/$DPDK_ABI_REF_VERSION
> > +   abirefdir=${DPDK_ABI_REF_DIR:-
> > $(pwd)/reference}/$DPDK_ABI_REF_VERSION
> > if [ ! -d $abirefdir/$targetdir ]; then
> > # clone current sources
> > if [ ! -d $abirefdir/src ]; then
> > --
> > 2.7.4
> >
> 
> install_target on line 160 is called improperly. Let's fix it so that it 
> matches line
> 169:
> install_target $abirefdir/build $(readlink -f $abirefdir/$targetdir)

If so we need to call readlink at line #161 as well as it does at line #171.

> 
> This way we don't need to add $(pwd).

If you don't prefer $(pwd), we can do it like this:
abirefdir=$(readlink -f ${DPDK_ABI_REF_DIR:- reference}/$DPDK_ABI_REF_VERSION)

Thanks,
Phil




[dpdk-dev] [PATCH v6 2/7] test/ring: fix wrong number of enq/deq elements

2020-09-20 Thread Feifei Wang
The ring capacity is (RING_SIZE - 1), thus only (RING_SIZE - 1) number of
elements can be enqueued into the ring.

Fixes: af75078fece3 ("first public release")
Cc: sta...@dpdk.org

Signed-off-by: Feifei Wang 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 0ae97d341..04bdc9b69 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -811,7 +811,7 @@ test_ring_basic_ex(void)
printf("%u ring entries are now free\n",
rte_ring_free_count(rp));
 
-   for (j = 0; j < RING_SIZE; j++) {
+   for (j = 0; j < RING_SIZE - 1; j++) {
test_ring_enqueue(rp, obj, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
}
@@ -822,7 +822,7 @@ test_ring_basic_ex(void)
goto fail_test;
}
 
-   for (j = 0; j < RING_SIZE; j++) {
+   for (j = 0; j < RING_SIZE - 1; j++) {
test_ring_dequeue(rp, obj, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
}
-- 
2.17.1



[dpdk-dev] [PATCH v6 3/7] test/ring: fix wrong size used in memcmp

2020-09-20 Thread Feifei Wang
When using memcmp function to check data, the third param should be the
size of all elements, rather than the number of the elements.

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagaraha...@arm.com
Cc: sta...@dpdk.org

Signed-off-by: Feifei Wang 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Dharmik Thakkar 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 04bdc9b69..51bae0d48 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -444,7 +444,12 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
TEST_RING_VERIFY(rte_ring_empty(r));
 
/* check data */
-   TEST_RING_VERIFY(memcmp(src, dst, rsz) == 0);
+   if (esize[i] == -1) {
+   TEST_RING_VERIFY(memcmp(src, dst,
+   rsz * sizeof(void *)) == 0);
+   } else
+   TEST_RING_VERIFY(memcmp(src, dst,
+   rsz * esize[i]) == 0);
}
 
/* Free memory before test completed */
@@ -538,9 +543,11 @@ test_ring_burst_bulk_tests2(unsigned int test_idx)
cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK);
 
/* check data */
-   if (memcmp(src, dst, cur_dst - dst)) {
-   rte_hexdump(stdout, "src", src, cur_src - src);
-   rte_hexdump(stdout, "dst", dst, cur_dst - dst);
+   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+   rte_hexdump(stdout, "src", src,
+   RTE_PTR_DIFF(cur_src, src));
+   rte_hexdump(stdout, "dst", dst,
+   RTE_PTR_DIFF(cur_dst, dst));
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -614,9 +621,11 @@ test_ring_burst_bulk_tests3(unsigned int test_idx)
}
 
/* check data */
-   if (memcmp(src, dst, cur_dst - dst)) {
-   rte_hexdump(stdout, "src", src, cur_src - src);
-   rte_hexdump(stdout, "dst", dst, cur_dst - dst);
+   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+   rte_hexdump(stdout, "src", src,
+   RTE_PTR_DIFF(cur_src, src));
+   rte_hexdump(stdout, "dst", dst,
+   RTE_PTR_DIFF(cur_dst, dst));
printf("data after dequeue is not the same\n");
goto fail;
}
@@ -747,9 +756,11 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)
goto fail;
 
/* check data */
-   if (memcmp(src, dst, cur_dst - dst)) {
-   rte_hexdump(stdout, "src", src, cur_src - src);
-   rte_hexdump(stdout, "dst", dst, cur_dst - dst);
+   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+   rte_hexdump(stdout, "src", src,
+   RTE_PTR_DIFF(cur_src, src));
+   rte_hexdump(stdout, "dst", dst,
+   RTE_PTR_DIFF(cur_dst, dst));
printf("data after dequeue is not the same\n");
goto fail;
}
-- 
2.17.1



[dpdk-dev] [PATCH v6 1/7] test/ring: fix wrong parameter passed to the enqueue APIs

2020-09-20 Thread Feifei Wang
When enqueue one element to ring in the performance test, a pointer
should be passed to rte_ring_[sp|mp]enqueue APIs, not the pointer
to a table of void *pointers.

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagaraha...@arm.com
Cc: sta...@dpdk.org

Signed-off-by: Feifei Wang 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test/test_ring.h b/app/test/test_ring.h
index aa6ae67ca..d4b15af7c 100644
--- a/app/test/test_ring.h
+++ b/app/test/test_ring.h
@@ -50,11 +50,11 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int 
esize, unsigned int n,
if ((esize) == -1)
switch (api_type) {
case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):
-   return rte_ring_enqueue(r, obj);
+   return rte_ring_enqueue(r, *obj);
case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):
-   return rte_ring_sp_enqueue(r, obj);
+   return rte_ring_sp_enqueue(r, *obj);
case (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):
-   return rte_ring_mp_enqueue(r, obj);
+   return rte_ring_mp_enqueue(r, *obj);
case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):
return rte_ring_enqueue_bulk(r, obj, n, NULL);
case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):
-- 
2.17.1



[dpdk-dev] [PATCH v6 4/7] test/ring: add check to validate dequeued objects

2020-09-20 Thread Feifei Wang
Add check in test_ring_basic_ex and test_ring_with_exact_size for single
element enqueue and dequeue operations to validate the dequeued objects.

Signed-off-by: Feifei Wang 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Dharmik Thakkar 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.c | 135 +++
 1 file changed, 99 insertions(+), 36 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 51bae0d48..c9017793a 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -791,15 +791,9 @@ test_ring_basic_ex(void)
int ret = -1;
unsigned int i, j;
struct rte_ring *rp = NULL;
-   void *obj = NULL;
+   void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 
for (i = 0; i < RTE_DIM(esize); i++) {
-   obj = test_ring_calloc(RING_SIZE, esize[i]);
-   if (obj == NULL) {
-   printf("%s: failed to alloc memory\n", __func__);
-   goto fail_test;
-   }
-
rp = test_ring_create("test_ring_basic_ex", esize[i], RING_SIZE,
SOCKET_ID_ANY,
RING_F_SP_ENQ | RING_F_SC_DEQ);
@@ -808,6 +802,23 @@ test_ring_basic_ex(void)
goto fail_test;
}
 
+   /* alloc dummy object pointers */
+   src = test_ring_calloc(RING_SIZE, esize[i]);
+   if (src == NULL) {
+   printf("%s: failed to alloc src memory\n", __func__);
+   goto fail_test;
+   }
+   test_ring_mem_init(src, RING_SIZE, esize[i]);
+   cur_src = src;
+
+   /* alloc some room for copied objects */
+   dst = test_ring_calloc(RING_SIZE, esize[i]);
+   if (dst == NULL) {
+   printf("%s: failed to alloc dst memory\n", __func__);
+   goto fail_test;
+   }
+   cur_dst = dst;
+
if (rte_ring_lookup("test_ring_basic_ex") != rp) {
printf("%s: failed to find ring\n", __func__);
goto fail_test;
@@ -823,8 +834,9 @@ test_ring_basic_ex(void)
rte_ring_free_count(rp));
 
for (j = 0; j < RING_SIZE - 1; j++) {
-   test_ring_enqueue(rp, obj, esize[i], 1,
+   test_ring_enqueue(rp, cur_src, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+   cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
}
 
if (rte_ring_full(rp) != 1) {
@@ -834,8 +846,9 @@ test_ring_basic_ex(void)
}
 
for (j = 0; j < RING_SIZE - 1; j++) {
-   test_ring_dequeue(rp, obj, esize[i], 1,
+   test_ring_dequeue(rp, cur_dst, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+   cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);
}
 
if (rte_ring_empty(rp) != 1) {
@@ -844,52 +857,80 @@ test_ring_basic_ex(void)
goto fail_test;
}
 
+   /* check data */
+   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+   rte_hexdump(stdout, "src", src, RTE_PTR_DIFF(cur_src, 
src));
+   rte_hexdump(stdout, "dst", dst, RTE_PTR_DIFF(cur_dst, 
dst));
+   printf("data after dequeue is not the same\n");
+   goto fail_test;
+   }
+
/* Following tests use the configured flags to decide
 * SP/SC or MP/MC.
 */
+   /* reset memory of dst */
+   memset(dst, 0, RTE_PTR_DIFF(cur_dst, dst));
+
+   /* reset cur_src and cur_dst */
+   cur_src = src;
+   cur_dst = dst;
+
/* Covering the ring burst operation */
-   ret = test_ring_enqueue(rp, obj, esize[i], 2,
+   ret = test_ring_enqueue(rp, cur_src, esize[i], 2,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
if (ret != 2) {
printf("%s: rte_ring_enqueue_burst fails\n", __func__);
goto fail_test;
}
+   cur_src = test_ring_inc_ptr(cur_src, esize[i], 2);
 
-   ret = test_ring_dequeue(rp, obj, esize[i], 2,
+   ret = test_ring_dequeue(rp, cur_dst, esize[i], 2,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
if (ret != 2) {
printf("%s: rte_ring_dequeue_burst fails\n", __func__);
goto fail_test;
}
+   cur_dst = 

[dpdk-dev] [PATCH v6 0/7]

2020-09-20 Thread Feifei Wang
Several bugs in ring unit tests were identified and fixed.

Added data validation on objects after enqueue/dequeue operations for
data integration check.

Unit tests were enhanced by checking return value of enqueue/dequeue
operations and validating data integrity of objects.

v2:
1. add check to validate the dequeued objects in test_ring.c and fix
some bugs of it. (David/Honnappa)
2. remove the patch to change the description for the param of
rte_ring_[sp/mp]_enqueue APIs. (David/Konstantin/Honnappa)

v3:
1. Adjust the 'check dequeued objects' patch from the last to the first
in the series. (Honnappa)
2. Add the new function 'test_ring_mem_cmp to replace 'memset' and print
information of enqueue/dequeue elements if validation fails. (Honnappa)
3. Add test to validate the whether the enqueue and dequeue operation is
successful for each time. (Honnappa)
4. Expand the scope of application for the macro TEST_RING_VERIF, and
replace all ring APIs check with this macro. (Honnappa)

v4:
1. Split the 'memcmp' bug fix patch into two patches, one is memcmp
issue patch, the other is to add new function 'test_ring_mem_cmp'.
(Honnappa)

v5:
1. Adjust bug fixed patches to the first of the series, to ensure that
the back porting will go smooth. (Honnappa)

v6:
1. Add extra parameter to the macro. (Konstantin)

Feifei Wang (7):
  test/ring: fix wrong parameter passed to the enqueue APIs
  test/ring: fix wrong number of enq/deq elements
  test/ring: fix wrong size used in memcmp
  test/ring: add check to validate dequeued objects
  test/ring: validate the return value of enq/deq elements
  test/ring: add new function to validate dequeue data
  test/ring: improve the application of macro

 app/test/test_ring.c | 362 ++-
 app/test/test_ring.h |   6 +-
 2 files changed, 192 insertions(+), 176 deletions(-)

-- 
2.17.1



[dpdk-dev] [PATCH v6 7/7] test/ring: improve the application of macro

2020-09-20 Thread Feifei Wang
Add more parameters into the macro TEST_RING_VERIFY and expand the scope
of application for it. Then replace all ring APIs check with
TEST_RING_VERIFY to facilitate debugging.

Furthermore, correct a spelling mistakes of the macro
TEST_RING_FULL_EMTPY_ITER.

Suggested-by: Honnappa Nagarahalli 
Signed-off-by: Feifei Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Dharmik Thakkar 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.c | 240 ---
 1 file changed, 90 insertions(+), 150 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index fb46614f8..a62cb263b 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -46,15 +46,25 @@
 #define RING_SIZE 4096
 #define MAX_BULK 32
 
-#defineTEST_RING_VERIFY(exp)   
\
+/*
+ * Validate the return value of test cases and print details of the
+ * ring if validation fails
+ *
+ * @param exp
+ *   Expression to validate return value.
+ * @param r
+ *   A pointer to the ring structure.
+ */
+#define TEST_RING_VERIFY(exp, r, errst) do {   \
if (!(exp)) {   \
printf("error at %s:%d\tcondition " #exp " failed\n",   \
__func__, __LINE__);\
-   rte_ring_dump(stdout, r);   \
-   return -1;  \
-   }
+   rte_ring_dump(stdout, (r)); \
+   errst;  \
+   }   \
+} while (0)
 
-#defineTEST_RING_FULL_EMTPY_ITER   8
+#define TEST_RING_FULL_EMPTY_ITER  8
 
 static const int esize[] = {-1, 4, 8, 16, 20};
 
@@ -360,13 +370,10 @@ test_ring_negative_tests(void)
goto test_fail;
}
 
-   if (rte_ring_lookup("test_ring_negative") != rp)
-   goto test_fail;
+   TEST_RING_VERIFY(rte_ring_lookup("test_ring_negative") == rp,
+   rp, goto test_fail);
 
-   if (rte_ring_empty(rp) != 1) {
-   printf("test_ring_nagative ring is not empty but it 
should be\n");
-   goto test_fail;
-   }
+   TEST_RING_VERIFY(rte_ring_empty(rp) == 1, rp, goto test_fail);
 
/* Tests if it would always fail to create ring with an used
 * ring name.
@@ -426,44 +433,45 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
 
printf("Random full/empty test\n");
 
-   for (j = 0; j != TEST_RING_FULL_EMTPY_ITER; j++) {
+   for (j = 0; j != TEST_RING_FULL_EMPTY_ITER; j++) {
/* random shift in the ring */
rand = RTE_MAX(rte_rand() % RING_SIZE, 1UL);
printf("%s: iteration %u, random shift: %u;\n",
__func__, i, rand);
ret = test_ring_enq_impl(r, cur_src, esize[i], rand,
test_idx);
-   TEST_RING_VERIFY(ret != 0);
+   TEST_RING_VERIFY(ret != 0, r, goto fail);
 
ret = test_ring_deq_impl(r, cur_dst, esize[i], rand,
test_idx);
-   TEST_RING_VERIFY(ret == rand);
+   TEST_RING_VERIFY(ret == rand, r, goto fail);
 
/* fill the ring */
ret = test_ring_enq_impl(r, cur_src, esize[i], rsz,
test_idx);
-   TEST_RING_VERIFY(ret != 0);
+   TEST_RING_VERIFY(ret != 0, r, goto fail);
 
-   TEST_RING_VERIFY(rte_ring_free_count(r) == 0);
-   TEST_RING_VERIFY(rsz == rte_ring_count(r));
-   TEST_RING_VERIFY(rte_ring_full(r));
-   TEST_RING_VERIFY(rte_ring_empty(r) == 0);
+   TEST_RING_VERIFY(rte_ring_free_count(r) == 0, r, goto 
fail);
+   TEST_RING_VERIFY(rsz == rte_ring_count(r), r, goto 
fail);
+   TEST_RING_VERIFY(rte_ring_full(r), r, goto fail);
+   TEST_RING_VERIFY(rte_ring_empty(r) == 0, r, goto fail);
 
/* empty the ring */
ret = test_ring_deq_impl(r, cur_dst, esize[i], rsz,
test_idx);
-   TEST_RING_VERIFY(ret == (int)rsz);
-   TEST_RING_VERIFY(rsz == rte_ring_free_count(r));
-   TEST_RING_VERIFY(rte_ring_count(r) == 0);
-   TEST_RING_VERIF

[dpdk-dev] [PATCH v6 6/7] test/ring: add new function to validate dequeue data

2020-09-20 Thread Feifei Wang
Do code clean up by moving repeated code inside 'test_ring_mem_cmp'
function to validate data and print information of enqueue/dequeue
elements if validation fails.

Signed-off-by: Feifei Wang 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Dharmik Thakkar 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.c | 70 +---
 1 file changed, 27 insertions(+), 43 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index da57032c7..fb46614f8 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -258,6 +258,21 @@ test_ring_mem_init(void *obj, unsigned int count, int 
esize)
((uint32_t *)obj)[i] = i;
 }
 
+static int
+test_ring_mem_cmp(void *src, void *dst, unsigned int size)
+{
+   int ret;
+
+   ret = memcmp(src, dst, size);
+   if (ret) {
+   rte_hexdump(stdout, "src", src, size);
+   rte_hexdump(stdout, "dst", dst, size);
+   printf("data after dequeue is not the same\n");
+   }
+
+   return ret;
+}
+
 static void
 test_ring_print_test_string(const char *istr, unsigned int api_type, int esize)
 {
@@ -383,7 +398,7 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
struct rte_ring *r;
void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
int ret;
-   unsigned int i, j;
+   unsigned int i, j, temp_sz;
int rand;
const unsigned int rsz = RING_SIZE - 1;
 
@@ -444,12 +459,11 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
TEST_RING_VERIFY(rte_ring_empty(r));
 
/* check data */
-   if (esize[i] == -1) {
-   TEST_RING_VERIFY(memcmp(src, dst,
-   rsz * sizeof(void *)) == 0);
-   } else
-   TEST_RING_VERIFY(memcmp(src, dst,
-   rsz * esize[i]) == 0);
+   temp_sz = rsz * sizeof(void *);
+   if (esize[i] != -1)
+   temp_sz = rsz * esize[i];
+   TEST_RING_VERIFY(test_ring_mem_cmp(src, dst,
+   temp_sz) == 0);
}
 
/* Free memory before test completed */
@@ -543,14 +557,8 @@ test_ring_burst_bulk_tests2(unsigned int test_idx)
cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK);
 
/* check data */
-   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
-   rte_hexdump(stdout, "src", src,
-   RTE_PTR_DIFF(cur_src, src));
-   rte_hexdump(stdout, "dst", dst,
-   RTE_PTR_DIFF(cur_dst, dst));
-   printf("data after dequeue is not the same\n");
+   if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst)))
goto fail;
-   }
 
/* Free memory before test completed */
rte_ring_free(r);
@@ -621,14 +629,8 @@ test_ring_burst_bulk_tests3(unsigned int test_idx)
}
 
/* check data */
-   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
-   rte_hexdump(stdout, "src", src,
-   RTE_PTR_DIFF(cur_src, src));
-   rte_hexdump(stdout, "dst", dst,
-   RTE_PTR_DIFF(cur_dst, dst));
-   printf("data after dequeue is not the same\n");
+   if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst)))
goto fail;
-   }
 
/* Free memory before test completed */
rte_ring_free(r);
@@ -756,14 +758,8 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)
goto fail;
 
/* check data */
-   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
-   rte_hexdump(stdout, "src", src,
-   RTE_PTR_DIFF(cur_src, src));
-   rte_hexdump(stdout, "dst", dst,
-   RTE_PTR_DIFF(cur_dst, dst));
-   printf("data after dequeue is not the same\n");
+   if (test_ring_mem_cmp(src, dst, RTE_PTR_DIFF(cur_dst, dst)))
goto fail;
-   }
 
/* Free memory before test completed */
rte_ring_free(r);
@@ -868,12 +864,8 @@ test_ring_basic_ex(void)
}
 
/* check data */
-   if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
-   rte_hexdump(stdout, "src", src, RTE_PTR_DIFF(cur_src, 
src));
-   rte_hexdump(stdout, "dst", dst, RTE_PTR_DIFF(cur_

[dpdk-dev] [PATCH v6 5/7] test/ring: validate the return value of enq/deq elements

2020-09-20 Thread Feifei Wang
Validate the return value of single element enqueue/dequeue operation in
the test.

Suggested-by: Honnappa Nagarahalli 
Signed-off-by: Feifei Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Honnappa Nagarahalli 
---
 app/test/test_ring.c | 26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index c9017793a..da57032c7 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -834,8 +834,13 @@ test_ring_basic_ex(void)
rte_ring_free_count(rp));
 
for (j = 0; j < RING_SIZE - 1; j++) {
-   test_ring_enqueue(rp, cur_src, esize[i], 1,
+   ret = test_ring_enqueue(rp, cur_src, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+   if (ret != 0) {
+   printf("%s: rte_ring_enqueue fails\n",
+   __func__);
+   goto fail_test;
+   }
cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
}
 
@@ -846,8 +851,13 @@ test_ring_basic_ex(void)
}
 
for (j = 0; j < RING_SIZE - 1; j++) {
-   test_ring_dequeue(rp, cur_dst, esize[i], 1,
+   ret = test_ring_dequeue(rp, cur_dst, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+   if (ret != 0) {
+   printf("%s: rte_ring_dequeue fails\n",
+   __func__);
+   goto fail_test;
+   }
cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);
}
 
@@ -1001,10 +1011,18 @@ test_ring_with_exact_size(void)
 * than the standard ring. (16 vs 15 elements)
 */
for (j = 0; j < ring_sz - 1; j++) {
-   test_ring_enqueue(std_r, cur_src, esize[i], 1,
+   ret = test_ring_enqueue(std_r, cur_src, esize[i], 1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
-   test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1,
+   if (ret != 0) {
+   printf("%s: error, enqueue failed\n", __func__);
+   goto test_fail;
+   }
+   ret = test_ring_enqueue(exact_sz_r, cur_src, esize[i], 
1,
TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+   if (ret != 0) {
+   printf("%s: error, enqueue failed\n", __func__);
+   goto test_fail;
+   }
cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
}
ret = test_ring_enqueue(std_r, cur_src, esize[i], 1,
-- 
2.17.1



[dpdk-dev] 回复: [PATCH v5 7/7] test/ring: improve the application of macro

2020-09-20 Thread Feifei Wang
Hi, Konstantin

> -邮件原件-
> 发件人: Ananyev, Konstantin 
> 发送时间: 2020年9月18日 0:26
> 收件人: Feifei Wang ; Honnappa Nagarahalli
> 
> 抄送: dev@dpdk.org; nd 
> 主题: RE: [PATCH v5 7/7] test/ring: improve the application of macro
> 
> 
> 
> > Add more parameters into the macro TEST_RING_VERIFY and expand the
> > scope of application for it. Then replace all ring APIs check with
> > TEST_RING_VERIFY to facilitate debugging.
> >
> > Furthermore, correct a spelling mistakes of the macro
> > TEST_RING_FULL_EMTPY_ITER.
> >
> > Suggested-by: Honnappa Nagarahalli 
> > Signed-off-by: Feifei Wang 
> > Reviewed-by: Phil Yang 
> > Reviewed-by: Dharmik Thakkar 
> > Reviewed-by: Honnappa Nagarahalli 
> > ---
> >  app/test/test_ring.c | 266
> > ---
> >  1 file changed, 99 insertions(+), 167 deletions(-)
> >
> > diff --git a/app/test/test_ring.c b/app/test/test_ring.c index
> > fb46614f8..605b620ce 100644
> > --- a/app/test/test_ring.c
> > +++ b/app/test/test_ring.c
> > @@ -46,15 +46,25 @@
> >  #define RING_SIZE 4096
> >  #define MAX_BULK 32
> >
> > -#defineTEST_RING_VERIFY(exp)
>   \
> > +/*
> > + * Validate the return value of test cases and print details of the
> > + * ring if validation fails
> > + *
> > + * @param exp
> > + *   Expression to validate return value.
> > + * @param r
> > + *   A pointer to the ring structure.
> > + */
> > +#define TEST_RING_VERIFY(exp, r) do {
>   \
> > if (!(exp)) {   \
> > printf("error at %s:%d\tcondition " #exp " failed\n",   \
> > __func__, __LINE__);\
> > -   rte_ring_dump(stdout, r);   \
> > -   return -1;  \
> > -   }
> > +   rte_ring_dump(stdout, (r)); \
> > +   goto fail;  \
> > +   }   \
> > +} while (0)
> 
> LGTM, just one suggestion for the macro above:
> Instead of arrange the whole code with the same label, why not to simply add
> control transfer statement as extra parameter to the macro:
> 
> #define TEST_RING_VERIFY(exp, r, errst) do {
>   \
>   if (!(exp)) {   \
>   printf("error at %s:%d\tcondition " #exp " failed\n",   \
>   __func__, __LINE__);\
>   rte_ring_dump(stdout, r);   \
>   errst;  \
>   }
>   \
> } while (0)
> 
> Ans then just:
> TEST_RING_VERIFY(rte_ring_free_count(r) == 0, r, return -1); or
> TEST_RING_VERIFY(rte_ring_free_count(r) == 0, r, goto fail); or whatever is
> appropriate.
> 
> With that said:
> Series acked-by: Konstantin Ananyev 
> 
Thanks for your advice,  the new version with this change  has just been 
updated.
> >
> > -#defineTEST_RING_FULL_EMTPY_ITER   8
> > +#define TEST_RING_FULL_EMPTY_ITER  8
> >
> >  static const int esize[] = {-1, 4, 8, 16, 20};
> >
> > @@ -316,7 +326,7 @@ test_ring_negative_tests(void)
> > RING_SIZE + 1, SOCKET_ID_ANY, 0);
> > if (rp != NULL) {
> > printf("Test failed to detect invalid element size\n");
> > -   goto test_fail;
> > +   goto fail;
> > }
> >
> >
> > @@ -326,7 +336,7 @@ test_ring_negative_tests(void)
> > RING_SIZE + 1, SOCKET_ID_ANY, 0);
> > if (rp != NULL) {
> > printf("Test failed to detect odd count\n");
> > -   goto test_fail;
> > +   goto fail;
> > }
> >
> > /* Test if ring size is exceeding the limit */ @@ -334,14
> +344,14
> > @@ test_ring_negative_tests(void)
> > RTE_RING_SZ_MASK + 1,
> SOCKET_ID_ANY, 0);
> > if (rp != NULL) {
> > printf("Test failed to detect limits\n");
> > -   goto test_fail;
> > +   goto fail;
> > }
> >
> > /* Tests if lookup returns NULL on non-existing ring */
> > rp = rte_ring_lookup("ring_not_found");
> > if (rp != NULL && rte_errno != ENOENT) {
> > printf("Test failed to detect NULL ring lookup\n");
> > -   goto test_fail;
> > +   goto fail;
> > }
> >
> > /* Test to if a non-power of 2 count causes the create @@ -
> 350,23
> > +360,19 @@ test_ring_negative_tests(void)
> > rp = test_ring_create("test_ring_count", esize[i], 4097,
> > SOCKET_ID_ANY, 0);
> > if (rp != NULL)
> > -   goto test_fail;
> > +   goto

Re: [dpdk-dev] 18.11.10 (LTS) patches review and test

2020-09-20 Thread Ali Alnubani
Hi,

> -Original Message-
> From: Kevin Traynor 
> Sent: Monday, September 7, 2020 1:12 PM
> To: sta...@dpdk.org
> Cc: dev@dpdk.org; Abhishek Marathe ;
> Akhil Goyal ; Ali Alnubani ;
> benjamin.wal...@intel.com; David Christensen ;
> Hemant Agrawal ; Ian Stokes
> ; Jerin Jacob ; John McNamara
> ; Ju-Hyoung Lee ;
> Kevin Traynor ; Luca Boccassi ;
> Pei Zhang ; pingx...@intel.com;
> qian.q...@intel.com; Raslan Darawsheh ; NBU-
> Contact-Thomas Monjalon ; yuan.p...@intel.com;
> zhaoyan.c...@intel.com
> Subject: 18.11.10 (LTS) patches review and test
> 
> Hi all,
> 
> Here is a list of patches targeted for LTS release 18.11.10.
> 
> The planned date for the final release is 21 September.
> 
> Please help with testing and validation of your use cases and report any
> issues/results with reply-all to this mail. For the final release the fixes 
> and
> reported validations will be added to the release notes.
> 

The following covers the functional tests that we ran on Mellanox hardware for 
this release:
- Basic functionality:
  Send and receive multiple types of traffic.
- testpmd xstats counter tests.
- testpmd timestamp tests.
- Changing/checking link status through testpmd.
- RTE flow and flow_director tests:
  Items: eth / vlan / ipv4 / ipv6 / tcp / udp / gre
  Actions: drop / queue / rss / mark / flag
- Some RSS tests.
- VLAN stripping and insertion tests.
- Checksum and TSO tests.
- ptype tests.
- l3fwd-power example application tests.
- Multi-process example applications tests.

Testing matrix:
- NIC: ConnectX-4 Lx / OS: RHEL7.4 / Driver: MLNX_OFED_LINUX-5.1-0.6.6.0 / 
Firmware: 14.28.1002
- NIC: ConnectX-4 Lx / OS: RHEL7.4 / Driver: MLNX_OFED_LINUX-5.1-2.3.7.1 / 
Firmware: 14.28.2006
- NIC: ConnectX-5 / OS: RHEL7.4 / Driver: MLNX_OFED_LINUX-5.1-0.6.6.0 / 
Firmware: 16.28.1002
- NIC: ConnectX-5 / OS: RHEL7.4 / Driver: MLNX_OFED_LINUX-5.1-2.3.7.1 / 
Firmware: 16.28.2006

We don't see any critical issues blocking the release.

Regards,
Ali


Re: [dpdk-dev] [PATCH v6 0/7]

2020-09-20 Thread Ananyev, Konstantin


> Several bugs in ring unit tests were identified and fixed.
> 
> Added data validation on objects after enqueue/dequeue operations for
> data integration check.
> 
> Unit tests were enhanced by checking return value of enqueue/dequeue
> operations and validating data integrity of objects.
> 
> v2:
> 1. add check to validate the dequeued objects in test_ring.c and fix
> some bugs of it. (David/Honnappa)
> 2. remove the patch to change the description for the param of
> rte_ring_[sp/mp]_enqueue APIs. (David/Konstantin/Honnappa)
> 
> v3:
> 1. Adjust the 'check dequeued objects' patch from the last to the first
> in the series. (Honnappa)
> 2. Add the new function 'test_ring_mem_cmp to replace 'memset' and print
> information of enqueue/dequeue elements if validation fails. (Honnappa)
> 3. Add test to validate the whether the enqueue and dequeue operation is
> successful for each time. (Honnappa)
> 4. Expand the scope of application for the macro TEST_RING_VERIF, and
> replace all ring APIs check with this macro. (Honnappa)
> 
> v4:
> 1. Split the 'memcmp' bug fix patch into two patches, one is memcmp
> issue patch, the other is to add new function 'test_ring_mem_cmp'.
> (Honnappa)
> 
> v5:
> 1. Adjust bug fixed patches to the first of the series, to ensure that
> the back porting will go smooth. (Honnappa)
> 
> v6:
> 1. Add extra parameter to the macro. (Konstantin)
> 
> Feifei Wang (7):
>   test/ring: fix wrong parameter passed to the enqueue APIs
>   test/ring: fix wrong number of enq/deq elements
>   test/ring: fix wrong size used in memcmp
>   test/ring: add check to validate dequeued objects
>   test/ring: validate the return value of enq/deq elements
>   test/ring: add new function to validate dequeue data
>   test/ring: improve the application of macro
> 
>  app/test/test_ring.c | 362 ++-
>  app/test/test_ring.h |   6 +-
>  2 files changed, 192 insertions(+), 176 deletions(-)

Series acked-by: Konstantin Ananyev 

> --
> 2.17.1



Re: [dpdk-dev] [PATCH] net/bnxt: fix compilation error on Redhat 8

2020-09-20 Thread Xia, Chenbo
Hi, David & Ajit

Yes, I will submit a patch to change all eth port id to uint16_t
this week as I promised. Is this ok for you?

Thanks,
Chenbo

> -Original Message-
> From: Ajit Khaparde 
> Sent: Saturday, September 19, 2020 12:16 AM
> To: David Marchand 
> Cc: Somnath Kotur ; Thierry Herbelot
> ; Xia, Chenbo ; dev
> ; Thomas Monjalon 
> Subject: Re: [dpdk-dev] [PATCH] net/bnxt: fix compilation error on Redhat
> 8
> 
> ::snip::
> > >
> >
> > This patch rang a bell.
> > There is the exact same patch proposed by Xia with a comment, so I
> > guess Xia is still working on it?
> > https://patchwork.dpdk.org/patch/75177/#117201
> Xia,
> Will you submit the changes that Thomas asked for?
> Otherwise I will apply the bnxt patch and you can work on the rest.
> 
> Thanks
> Ajit


[dpdk-dev] [PATCH v1] net/i40e: fix virtual channel confiliction issue

2020-09-20 Thread Yuying Zhang
i40evf_execute_vf_cmd() uses _atomic_set_cmd() to execute virtual
channel commands safely in multi-process mode. However, it returns -1
when one process is pending. Add a spinlock to wait for the virtual
channel will handle this issue in concurrent scenarios.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Cc: sta...@dpdk.org

Signed-off-by: Yuying Zhang 
---
 drivers/net/i40e/i40e_ethdev.h| 1 +
 drivers/net/i40e/i40e_ethdev_vf.c | 8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 19f821829..514c0988b 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1199,6 +1199,7 @@ struct i40e_vf {
uint16_t max_pkt_len; /* Maximum packet length */
bool promisc_unicast_enabled;
bool promisc_multicast_enabled;
+   rte_spinlock_t cmd_send_lock;
 
uint32_t version_major; /* Major version number */
uint32_t version_minor; /* Minor version number */
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 69cab8e73..7fdc58649 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -326,8 +326,11 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct 
vf_cmd_info *args)
enum i40evf_aq_result ret;
int err, i = 0;
 
-   if (_atomic_set_cmd(vf, args->ops))
+   rte_spinlock_lock(&vf->cmd_send_lock);
+   if (_atomic_set_cmd(vf, args->ops)) {
+   rte_spinlock_unlock(&vf->cmd_send_lock);
return -1;
+   }
 
info.msg = args->out_buffer;
info.buf_len = args->out_size;
@@ -339,6 +342,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct 
vf_cmd_info *args)
if (err) {
PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
_clear_cmd(vf);
+   rte_spinlock_unlock(&vf->cmd_send_lock);
return err;
}
 
@@ -406,6 +410,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct 
vf_cmd_info *args)
break;
}
 
+   rte_spinlock_unlock(&vf->cmd_send_lock);
return err | vf->cmd_retval;
 }
 
@@ -1249,6 +1254,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
 
vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
vf->dev_data = dev->data;
+   rte_spinlock_init(&vf->cmd_send_lock);
err = i40e_set_mac_type(hw);
if (err) {
PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err);
-- 
2.25.1



Re: [dpdk-dev] [PATCH v4 05/11] baseband/acc100: add LDPC processing functions

2020-09-20 Thread Liu, Tianjiao


On Fri,  4 Sep 2020 10:54:01 -0700, Nicolas Chautru wrote:

> Adding LDPC decode and encode processing operations

> Signed-off-by: Nicolas Chautru 
> ---
>  drivers/baseband/acc100/rte_acc100_pmd.c | 1625 
> +-
>  drivers/baseband/acc100/rte_acc100_pmd.h |3 +
>  2 files changed, 1626 insertions(+), 2 deletions(-)

Acked-by: Liu Tianjiao 


Re: [dpdk-dev] [PATCH v4 06/11] baseband/acc100: add HARQ loopback support

2020-09-20 Thread Liu, Tianjiao
On Fri,  4 Sep 2020 10:54:02 -0700, Nicolas Chautru wrote:

> Additional support for HARQ memory loopback

> Signed-off-by: Nicolas Chautru 
> ---
>  drivers/baseband/acc100/rte_acc100_pmd.c | 158 
> +++
>  1 file changed, 158 insertions(+)

Acked-by: Liu Tianjiao 



Re: [dpdk-dev] [PATCH v4 07/11] baseband/acc100: add support for 4G processing

2020-09-20 Thread Liu, Tianjiao
On Fri,  4 Sep 2020 10:54:03 -0700, Nicolas Chautru wrote:

> Adding capability for 4G encode and decoder processing

> Signed-off-by: Nicolas Chautru 
> ---
>  drivers/baseband/acc100/rte_acc100_pmd.c | 1010 
> --
>  1 file changed, 943 insertions(+), 67 deletions(-)


Acked-by: Liu Tianjiao 


Re: [dpdk-dev] [PATCH v4 08/11] baseband/acc100: add interrupt support to PMD

2020-09-20 Thread Liu, Tianjiao
On Fri,  4 Sep 2020 10:54:04 -0700, Nicolas Chautru wrote:



> Adding capability and functions to support MSI interrupts, call backs and 
> inforing.



> Signed-off-by: Nicolas Chautru 
> mailto:nicolas.chau...@intel.com>>

> ---

>  drivers/baseband/acc100/rte_acc100_pmd.c | 288 
> ++-  drivers/baseband/acc100/rte_acc100_pmd.h |  
> 15 ++

>  2 files changed, 300 insertions(+), 3 deletions(-)



Acked-by: Liu Tianjiao 


Re: [dpdk-dev] [PATCH v4 09/11] baseband/acc100: add debug function to validate input

2020-09-20 Thread Liu, Tianjiao
On Fri,  4 Sep 2020 10:54:05 -0700, Nicolas Chautru wrote:

> Debug functions to validate the input API from user Only enabled in DEBUG 
> mode at build time

> Signed-off-by: Nicolas Chautru 
> ---
>  drivers/baseband/acc100/rte_acc100_pmd.c | 424 
> +++
>  1 file changed, 424 insertions(+)

Acked-by: Liu Tianjiao 


Re: [dpdk-dev] [PATCH v4 10/11] baseband/acc100: add configure function

2020-09-20 Thread Liu, Tianjiao
On Fri,  4 Sep 2020 10:54:06 -0700, Nicolas Chautru wrote:

> Add configure function to configure the PF from within the bbdev-test itself 
> without external application configuration the device.
> 
> Signed-off-by: Nicolas Chautru 
> ---
>  app/test-bbdev/test_bbdev_perf.c   |  72 +++
>  drivers/baseband/acc100/Makefile   |   3 +
>  drivers/baseband/acc100/meson.build|   2 +
>  drivers/baseband/acc100/rte_acc100_cfg.h   |  17 +
>  drivers/baseband/acc100/rte_acc100_pmd.c   | 505 
> +
>  .../acc100/rte_pmd_bbdev_acc100_version.map|   7 +
>  6 files changed, 606 insertions(+)


Acked-by: Liu Tianjiao 


Re: [dpdk-dev] [PATCH v4 11/11] doc: update bbdev feature table

2020-09-20 Thread Liu, Tianjiao
On Fri,  4 Sep 2020 10:54:07 -0700, Nicolas Chautru wrote:

> Correcting overview matrix to use acc100 name
> 
> Signed-off-by: Nicolas Chautru 
> ---
>  doc/guides/bbdevs/features/acc100.ini | 14 ++
>  doc/guides/bbdevs/features/mbc.ini| 14 --
>  2 files changed, 14 insertions(+), 14 deletions(-)  create mode 100644 
> doc/guides/bbdevs/features/acc100.ini
>  delete mode 100644 doc/guides/bbdevs/features/mbc.ini

Acked-by: Liu Tianjiao 


Re: [dpdk-dev] [dpdk-stable] [PATCH v2] net/i40e: fix incorrect byte counters

2020-09-20 Thread Jiang, JunyuX
Hi Ferruh,

> -Original Message-
> From: Ferruh Yigit 
> Sent: Friday, September 18, 2020 9:42 PM
> To: Igor Ryzhov ; Jiang, JunyuX
> 
> Cc: dev@dpdk.org; Guo, Jia ; Xing, Beilei
> ; sta...@dpdk.org
> Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v2] net/i40e: fix incorrect byte
> counters
> 
> On 9/18/2020 10:23 AM, Igor Ryzhov wrote:
> > Hi,
> >
> > Your code will work only if stats are updated at least once between
> > two overflows.
>  >
> 
> In this case it will have problems in 'i40e_stat_update_48()' too.
> It seems there is no way to detect if the increase in stats is N or MAX_48+N
> by the software.
> And obviously there is no way to detect if the overflow occurred more than
> once.
> 
> > So it's still up to the application to handle this properly. I think
> > it should be mentioned in the docs.
> >
> 
> +1 to document.
> 
I will fix in V3.
> > Igor
> >
> > On Fri, Sep 18, 2020 at 6:45 AM Jiang, JunyuX  > > wrote:
> >
> > Hi Ferruh,
> >
> >  > -Original Message-
> >  > From: Ferruh Yigit  > >
> >  > Sent: Wednesday, September 16, 2020 8:31 PM
> >  > To: Jiang, JunyuX  > >; dev@dpdk.org
> 
> >  > Cc: Guo, Jia mailto:jia@intel.com>>;
> > Xing, Beilei mailto:beilei.x...@intel.com>>;
> >  > sta...@dpdk.org 
> >  > Subject: Re: [dpdk-stable] [PATCH v2] net/i40e: fix incorrect
> > byte counters
> >  >
> >  > On 9/16/2020 2:51 AM, Junyu Jiang wrote:
> >  > > This patch fixed the issue that rx/tx bytes overflowed
> >  >
> >  > "Rx/Tx statistics counters overflowed"?
> >  >
> > Yes, the rx_bytes and tx_bytes counter in X710 cards is 48-bit long,
> > if keep sending packets for a log time, the register will overflow.
> >
> >  > > on 48 bit limitation by enlarging the limitation.
> >  > >
> >  > > Fixes: 4861cde46116 ("i40e: new poll mode driver")
> >  > > Cc: sta...@dpdk.org 
> >  > >
> >  > > Signed-off-by: Junyu Jiang  > >
> >  > > ---
> >  > >   drivers/net/i40e/i40e_ethdev.c | 47
> >  > ++
> >  > >   drivers/net/i40e/i40e_ethdev.h |  9 +++
> >  > >   2 files changed, 56 insertions(+)
> >  > >
> >  > > diff --git a/drivers/net/i40e/i40e_ethdev.c
> >  > > b/drivers/net/i40e/i40e_ethdev.c index 563f21d9d..4d4ea9861
> 100644
> >  > > --- a/drivers/net/i40e/i40e_ethdev.c
> >  > > +++ b/drivers/net/i40e/i40e_ethdev.c
> >  > > @@ -3073,6 +3073,13 @@ i40e_update_vsi_stats(struct i40e_vsi *vsi)
> >  > >     i40e_stat_update_48(hw, I40E_GLV_BPRCH(idx),
> >  > I40E_GLV_BPRCL(idx),
> >  > >                         vsi->offset_loaded, &oes->rx_broadcast,
> >  > >                         &nes->rx_broadcast);
> >  > > +   /* enlarge the limitation when rx_bytes overflowed */
> >  > > +   if (vsi->offset_loaded) {
> >  > > +           if (I40E_RXTX_BYTES_LOW(vsi->old_rx_bytes) > nes-
> >  > >rx_bytes)
> >  > > +                   nes->rx_bytes += (uint64_t)1 <<
> > I40E_48_BIT_WIDTH;
> >  > > +           nes->rx_bytes += I40E_RXTX_BYTES_HIGH(vsi-
> >  > >old_rx_bytes);
> >  > > +   }
> >  > > +   vsi->old_rx_bytes = nes->rx_bytes;
> >  >
> >  >
> >  > Can you please describe this logic? (indeed better to describe it
> > in the
> >  > commit log)
> >  >
> >  > 'nes->rx_bytes' is diff in the stats register since last read.
> >  > 'old_rx_bytes' is the previous stats diff.
> >  >
> >  > Why/how "I40E_RXTX_BYTES_LOW(vsi->old_rx_bytes) > nes-
> >rx_bytes" has
> >  > a meaning? Isn't this very depends on the read frequency?
> >  >
> >  > I guess I am missing something but please help me understand.
> >  >
> > This patch fixes the issue of rx/tx bytes counter register overflow:
> > The counter register in i40e is 48-bit long, when overflow,
> > nes->rx_bytes becomes less than old_rx_bytes, the correct value of
> > nes->rx_bytes should be plused 1 << 48.
> > Use I40E_RXTX_BYTES_HIGH() to remember the MSB, nes->rx_bytes
> plus
> > the MSB is the correct value, So that using uint64_t to enlarge the
> > 48 bit  limitation of register .
> >
> >  > Also can you please confirm the initial value of the
> > "vsi->offset_loaded" is
> >  > correct.
> >  >
> > offset_loaded will be true when get statistics of  port and
> > offset_loaded will be false when reset or clear the statistics,
> > so if  offset_loaded is false, shouldn't to calculate the value of
> > nes->rx_bytes, it will be 0.
> >
> >  > <>
> >  >
> >  > > @@ -282,6 +282,9 @@ struct rte_flow {
> >  > >   #define I40E_ETH_OVERHEAD \
> >  > >     (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +
> >   

Re: [dpdk-dev] [PATCH v4 3/5] app/procinfo: add Rx buffer size to --show-port

2020-09-20 Thread Chengchang Tang
Hi, All
These Patches improved procinfo was stuck in patchwork:
https://patchwork.dpdk.org/patch/74960/

These patches look good for me. Will these be applied?

I'm not sure what to do next. If these will be applied, I need modified
the code.

On 2020/9/19 6:11, Stephen Hemminger wrote:
> On Mon, 7 Sep 2020 17:14:48 +0800
> Chengchang Tang  wrote:
> 
>> On 2020/9/6 0:59, Stephen Hemminger wrote:
>>> On Sat, 5 Sep 2020 17:07:32 +0800
>>> Chengchang Tang  wrote:
>>>   
printf("\t  -- queue %d rx scatter %d"
" descriptors %d"
 +  " rx buffer size %d"
" offloads 0x%"PRIx64
" mempool socket %d\n",
j,
queue_info.scattered_rx,
queue_info.nb_desc,
 +  queue_info.rx_buf_size,
queue_info.conf.offloads,
queue_info.mp->socket_id);
}  
>>>
>>> These should be using %u and need space after " for PRIx64
>>> Why not:
>>> printf("\t  -- queue %u rx scatter %u"
>>> " descriptors %u"
>>> " rx buffer size %u"
>>> " offloads %#" PRIx64
>>> " mempool socket %d\n",
>>>   
>>
>> OK, I will fix these in next version.
>>
>> Thanks
> 
> NAK, these is superseded by.
> 
> Please look at the new improved procinfo still stuck in patchwork
> https://patchwork.dpdk.org/patch/74960/
> 
> Let's put the buffer size there.
> 
> .
> 



[dpdk-dev] [PATCH V8 1/3] ethdev: introduce FEC API

2020-09-20 Thread Min Hu (Connor)
This patch adds Forward error correction(FEC) support for ethdev.
Introduce APIs which support query and config FEC information in
hardware.

Signed-off-by: Min Hu (Connor) 
Reviewed-by: Wei Hu (Xavier) 
Reviewed-by: Chengwen Feng 
Reviewed-by: Chengchang Tang 
---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage.
add new macro to indicate translation from fec mode
to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 
 lib/librte_ethdev/rte_ethdev.c   | 49 ++
 lib/librte_ethdev/rte_ethdev.h   | 85 
 lib/librte_ethdev/rte_ethdev_core.h  | 79 +
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)

diff --git a/doc/guides/rel_notes/release_20_11.rst 
b/doc/guides/rel_notes/release_20_11.rst
index cc72609..e19b037 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -55,6 +55,16 @@ New Features
  Also, make sure to start the actual text at the margin.
  ===
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also 
provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also 
provided.
+
 
 Removed Items
 -
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5..d7cd737 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3642,6 +3642,55 @@ rte_eth_led_off(uint16_t port_id)
return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));
 }
 
+int
+rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap)
+{
+   struct rte_eth_dev *dev;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+   dev = &rte_eth_devices[port_id];
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_get_capability, -ENOTSUP);
+   return eth_err(port_id, (*dev->dev_ops->fec_get_capability)(dev,
+   fec_cap));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, enum rte_eth_fec_mode *mode)
+{
+   struct rte_eth_dev *dev;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+   dev = &rte_eth_devices[port_id];
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_get, -ENOTSUP);
+   return eth_err(port_id, (*dev->dev_ops->fec_get)(dev, mode));
+}
+
+int
+rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode)
+{
+   struct rte_eth_dev *dev;
+   uint32_t fec_mode_mask;
+   int ret;
+
+   ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask);
+   if (ret != 0)
+   return ret;
+
+   /*
+* Check whether the configured mode is within the FEC capability.
+* If not, the configured mode will not be supported.
+*/
+   if (!(fec_mode_mask & RTE_ETH_FEC_MODE_TO_CAPA(mode))) {
+   RTE_ETHDEV_LOG(ERR, "unsupported FEC mode = %d, port_id = %u\n",
+  mode, port_id);
+   return -EINVAL;
+   }
+
+   dev = &rte_eth_devices[port_id];
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_set, -ENOTSUP);
+   return eth_err(port_id, (*dev->dev_ops->fec_set)(dev, mode));
+}
+
 /*
  * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
  * an empty spot.
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 70295d7..7d5e81b 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1310,6 +1310,9 @@ struct rte_eth_conf {
 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
 
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)(1U << (x))
+
 /**
  * Preferred Rx/Tx port parameters.
  * There are separate instances of this structure for transmission
@@ -1511,6 +1514,24 @@ struct rte_eth_dcb_info {
struct rte_eth_dcb_tc_queue_mapping tc_queue;
 };
 
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_eth_fec_mode {
+   RTE_ETH_FEC_NOFEC = 0,  /**< FEC is off */
+   RTE_ETH_FEC_AUTO,   /**< FEC autonegotiation modes */
+   RTE_ETH_FEC_BASE

[dpdk-dev] [PATCH V8 0/3] add FEC support

2020-09-20 Thread Min Hu (Connor)
This series add FEC support for ethdev.

Min Hu (Connor) (3):
  ethdev: introduce FEC API
  net/hns3: support FEC
  app/testpmd: add FEC command

 app/test-pmd/cmdline.c   | 219 +++
 app/test-pmd/config.c|  54 
 app/test-pmd/testpmd.h   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h  |  19 ++-
 drivers/net/hns3/hns3_ethdev.c   | 183 ++
 drivers/net/hns3/hns3_ethdev.h   |   1 +
 lib/librte_ethdev/rte_ethdev.c   |  49 +++
 lib/librte_ethdev/rte_ethdev.h   |  85 
 lib/librte_ethdev/rte_ethdev_core.h  |  79 +++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 705 insertions(+), 1 deletion(-)

-- 
2.7.4



[dpdk-dev] [PATCH V8 2/3] net/hns3: support FEC

2020-09-20 Thread Min Hu (Connor)
Forward error correction (FEC) is a bit error correction mode.
It adds error correction information to data packets at the
transmit end, and uses the error correction information to correct
the bit errors generated during data packet transmission at the
receive end. This improves signal quality but also brings a delay
to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev
operations which support query and config FEC information in
hardware.

Signed-off-by: Min Hu (Connor) 
Reviewed-by: Wei Hu (Xavier) 
Reviewed-by: Chengwen Feng 
Reviewed-by: Chengchang Tang 
---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with
that defined in the ethdev library. So the sequence needs
to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h|  19 -
 drivers/net/hns3/hns3_ethdev.c | 183 +
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 202 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index d70f42e..8b80353 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
HNS3_OPC_CONFIG_MAX_FRM_SIZE= 0x0308,
HNS3_OPC_CONFIG_SPEED_DUP   = 0x0309,
HNS3_MAC_COMMON_INT_EN  = 0x030E,
+   HNS3_OPC_CONFIG_FEC_MODE= 0x031A,
 
/* PFC/Pause commands */
HNS3_OPC_CFG_MAC_PAUSE_EN   = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B 0
+#define HNS3_MAC_CFG_FEC_MODE_S1
+#define HNS3_MAC_CFG_FEC_MODE_MGENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF   0
+#define HNS3_MAC_FEC_BASER 1
+#define HNS3_MAC_FEC_RS2
+
 struct hns3_sfp_speed_cmd {
uint32_t  sfp_speed;
-   uint32_t  rsv[5];
+   uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+   uint8_t   active_fec; /* current FEC mode */
+   uint16_t  rsv1;
+   uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+   uint8_t fec_mode;
+   uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B   BIT(0)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 81e7730..3fc2525 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,6 +60,11 @@
 #define HNS3_RESET_WAIT_MS 100
 #define HNS3_RESET_WAIT_CNT200
 
+/* FEC mode order defined in HNS3 hardware */
+#define HNS3_HW_FEC_MODE_NOFEC  0
+#define HNS3_HW_FEC_MODE_BASER  1
+#define HNS3_HW_FEC_MODE_RS 2
+
 enum hns3_evt_cause {
HNS3_VECTOR0_EVENT_RST,
HNS3_VECTOR0_EVENT_MBX,
@@ -78,6 +83,8 @@ static int hns3_add_mc_addr(struct hns3_hw *hw,
struct rte_ether_addr *mac_addr);
 static int hns3_remove_mc_addr(struct hns3_hw *hw,
struct rte_ether_addr *mac_addr);
+static int hns3_restore_fec(struct hns3_hw *hw);
+static int hns3_query_dev_fec_info(struct rte_eth_dev *dev);
 
 static void
 hns3_pf_disable_irq0(struct hns3_hw *hw)
@@ -2819,6 +2826,13 @@ hns3_get_capability(struct hns3_hw *hw)
device_id == HNS3_DEV_ID_200G_RDMA)
hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1);
 
+   ret = hns3_query_dev_fec_info(eth_dev);
+   if (ret) {
+   PMD_INIT_LOG(ERR,
+"failed to query FEC information, ret = %d", ret);
+   return ret;
+   }
+
/* Get PCI revision id */
ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
  HNS3_PCI_REVISION_ID);
@@ -5311,6 +5325,10 @@ hns3_restore_conf(struct hns3_adapter *hns)
if (ret)
goto err_promisc;
 
+   ret = hns3_restore_fec(hw);
+   if (ret)
+   goto err_promisc;
+
if (hns->hw.adapter_state == HNS3_NIC_STARTED) {
ret = hns3_do_start(hns, false);
if (ret)
@@ -5389,6 +5407,168 @@ hns3_reset_service(void *param)
hns3_msix_process(hns, reset_level);
 }
 
+static int
+hns3_fec_get_capability(struct rte_eth_dev *dev, uint32_t *fec_cap)
+{
+   struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct hns3_mac *mac = &hw->mac;
+   uint32_t mode;
+
+   switch (mac->link_speed) {
+   case ETH_SPEED_NUM_10G:
+   case ETH_SPEED_NUM_40G:
+   mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER |
+   RTE_ETH_FEC_CAPA_AUTO;
+   break;
+   case ETH_SPEED_NUM_

[dpdk-dev] [PATCH V8 3/3] app/testpmd: add FEC command

2020-09-20 Thread Min Hu (Connor)
This commit adds testpmd capability to query and config FEC
function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port  0 

where:

auto|off|rs|baser are four kinds of FEC mode which dev
support according to MAC link speed.

Signed-off-by: Min Hu (Connor) 
Reviewed-by: Wei Hu (Xavier) 
Reviewed-by: Chengwen Feng 
Reviewed-by: Chengchang Tang 
---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +
 app/test-pmd/config.c  |  54 
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0a6ed85..3394bea 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+   cmdline_fixed_string_t cmd_show;
+   cmdline_fixed_string_t cmd_port;
+   cmdline_fixed_string_t cmd_fec;
+   cmdline_fixed_string_t cmd_keyword;
+   portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+   __rte_unused struct cmdline *cl,
+   __rte_unused void *data)
+{
+   struct cmd_show_fec_capability_result *res = parsed_result;
+   uint32_t fec_cap;
+   int ret;
+
+   if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+   printf("Invalid port id %u\n", res->cmd_pid);
+   return;
+   }
+
+   ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+   if (ret == -ENOTSUP) {
+   printf("Function not implemented\n");
+   return;
+   } else if (ret < 0) {
+   printf("Get FEC capability failed\n");
+   return;
+   }
+
+   show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+   TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+   .f = cmd_show_fec_capability_parsed,
+   .data = NULL,
+   .help_str = "show port  fec capabilities",
+   .tokens = {
+   (void *)&cmd_show_fec_capability_show,
+   (void *)&cmd_show_fec_capability_port,
+   (void *)&cmd_show_fec_capability_pid,
+   (void *)&cmd_show_fec_capability_fec,
+   (void *)&cmd_show_fec_capability_keyword,
+   NULL,
+   },
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+   cmdline_fixed_string_t cmd_show;
+   cmdline_fixed_string_t cmd_port;
+   cmdline_fixed_string_t cmd_keyword;
+   portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+   __rte_unused struct cmdline *cl,
+   __rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+   struct cmd_show_fec_metadata_result *res = parsed_result;
+   enum rte_eth_fec_mode mode;
+   char buf[FEC_NAME_SIZE];
+   int ret;
+
+   if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+   printf("Invalid port id %u\n", res->cmd_pid);
+   return;
+   }
+   ret = rte_eth_fec_get(res->cmd_pid, &mode);
+   if (ret == -ENOTSUP) {
+   printf("Function not implemented\n");
+   return;
+   } else if (ret < 0) {
+   printf("Get FEC mode failed\n");
+   return;
+   }
+
+   switch (mode) {
+   case RTE_ETH_FEC_NOFEC:
+   strlcpy(buf, "off", sizeof(buf));
+   break;
+   case RTE_ETH_FEC_AUTO:
+   strlcpy(buf, "auto", sizeof(buf));
+   break;
+   case RTE_E

Re: [dpdk-dev] [PATCH] vhost: return ready when at least 1 vring is configured

2020-09-20 Thread Liu, Changpeng
Hi Maxime,

> -Original Message-
> From: Maxime Coquelin 
> Sent: Friday, September 18, 2020 5:54 PM
> To: Liu, Changpeng ; dev@dpdk.org
> Cc: ma...@mellanox.com; Xia, Chenbo ; Zawadzki,
> Tomasz 
> Subject: Re: [PATCH] vhost: return ready when at least 1 vring is configured
> 
> Hi Changpeng,
> 
> On 9/1/20 9:07 AM, Changpeng Liu wrote:
> > Commit d0fcc38f "vhost: improve device readiness notifications"
> > needs at least 2 vrings before changing the device state to
> > ready, this is fine for NET device but not correct for BLK
> > device.
> >
> > The number of vring required should be based on the device
> > type, e.g. virtio_scsi device needs at least 3 vrings, and
> > virtio_net needs at least 2 vrings, virtio_blk needs at least
> > 1 vring. So instead of doing it in vhost library it's better
> > that the application who uses this library do this check.
> >
> > Signed-off-by: Changpeng Liu 
> > ---
> >  lib/librte_vhost/vhost_user.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> > index c3c924f..4d1883c 100644
> > --- a/lib/librte_vhost/vhost_user.c
> > +++ b/lib/librte_vhost/vhost_user.c
> > @@ -1343,7 +1343,7 @@
> >vq->enabled;
> >  }
> >
> > -#define VIRTIO_DEV_NUM_VQS_TO_BE_READY 2u
> > +#define VIRTIO_DEV_NUM_VQS_TO_BE_READY 1u
> 
> I think it would be better to rely on VIRTIO_DEV_BUILTIN_VIRTIO_NET to
> know whether it should wait for 1 or 2 queues to determine if ready.
virtio_scsi needs at least 3 vrings, so both 1 and 2 can't work for virtio_scsi 
device.
Can we expose an API to let the caller to set the minimum number of vrings 
required by
virtio device?
> 
> 
> >  static int
> >  virtio_is_ready(struct virtio_net *dev)
> >



[dpdk-dev] [PATCH V9 2/3] net/hns3: support FEC

2020-09-20 Thread Min Hu (Connor)
Forward error correction (FEC) is a bit error correction mode.
It adds error correction information to data packets at the
transmit end, and uses the error correction information to correct
the bit errors generated during data packet transmission at the
receive end. This improves signal quality but also brings a delay
to signals. This function can be enabled or disabled as required.

This patch adds FEC support for ethdev.Introduce ethdev
operations which support query and config FEC information in
hardware.

Signed-off-by: Min Hu (Connor) 
Reviewed-by: Wei Hu (Xavier) 
Reviewed-by: Chengwen Feng 
Reviewed-by: Chengchang Tang 
---
v7->v8:
FEC mode order defined in hns3 hardware is inconsistend with
that defined in the ethdev library. So the sequence needs
to be converted.

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Data type for fec_cap is changed from uint8_t
to uint32_t for possible future expansion.

---
v2->v3:
adjust the return value of function.

---
 drivers/net/hns3/hns3_cmd.h|  19 -
 drivers/net/hns3/hns3_ethdev.c | 183 +
 drivers/net/hns3/hns3_ethdev.h |   1 +
 3 files changed, 202 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index d70f42e..8b80353 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -99,6 +99,7 @@ enum hns3_opcode_type {
HNS3_OPC_CONFIG_MAX_FRM_SIZE= 0x0308,
HNS3_OPC_CONFIG_SPEED_DUP   = 0x0309,
HNS3_MAC_COMMON_INT_EN  = 0x030E,
+   HNS3_OPC_CONFIG_FEC_MODE= 0x031A,
 
/* PFC/Pause commands */
HNS3_OPC_CFG_MAC_PAUSE_EN   = 0x0701,
@@ -653,9 +654,25 @@ struct hns3_config_auto_neg_cmd {
uint8_t   rsv[20];
 };
 
+#define HNS3_MAC_CFG_FEC_AUTO_EN_B 0
+#define HNS3_MAC_CFG_FEC_MODE_S1
+#define HNS3_MAC_CFG_FEC_MODE_MGENMASK(3, 1)
+#define HNS3_MAC_FEC_OFF   0
+#define HNS3_MAC_FEC_BASER 1
+#define HNS3_MAC_FEC_RS2
+
 struct hns3_sfp_speed_cmd {
uint32_t  sfp_speed;
-   uint32_t  rsv[5];
+   uint8_t   query_type; /* 0: sfp speed, 1: active fec */
+   uint8_t   active_fec; /* current FEC mode */
+   uint16_t  rsv1;
+   uint32_t  rsv2[4];
+};
+
+/* Configure FEC mode, opcode:0x031A */
+struct hns3_config_fec_cmd {
+   uint8_t fec_mode;
+   uint8_t rsv[23];
 };
 
 #define HNS3_MAC_MGR_MASK_VLAN_B   BIT(0)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 81e7730..3fc2525 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -60,6 +60,11 @@
 #define HNS3_RESET_WAIT_MS 100
 #define HNS3_RESET_WAIT_CNT200
 
+/* FEC mode order defined in HNS3 hardware */
+#define HNS3_HW_FEC_MODE_NOFEC  0
+#define HNS3_HW_FEC_MODE_BASER  1
+#define HNS3_HW_FEC_MODE_RS 2
+
 enum hns3_evt_cause {
HNS3_VECTOR0_EVENT_RST,
HNS3_VECTOR0_EVENT_MBX,
@@ -78,6 +83,8 @@ static int hns3_add_mc_addr(struct hns3_hw *hw,
struct rte_ether_addr *mac_addr);
 static int hns3_remove_mc_addr(struct hns3_hw *hw,
struct rte_ether_addr *mac_addr);
+static int hns3_restore_fec(struct hns3_hw *hw);
+static int hns3_query_dev_fec_info(struct rte_eth_dev *dev);
 
 static void
 hns3_pf_disable_irq0(struct hns3_hw *hw)
@@ -2819,6 +2826,13 @@ hns3_get_capability(struct hns3_hw *hw)
device_id == HNS3_DEV_ID_200G_RDMA)
hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1);
 
+   ret = hns3_query_dev_fec_info(eth_dev);
+   if (ret) {
+   PMD_INIT_LOG(ERR,
+"failed to query FEC information, ret = %d", ret);
+   return ret;
+   }
+
/* Get PCI revision id */
ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
  HNS3_PCI_REVISION_ID);
@@ -5311,6 +5325,10 @@ hns3_restore_conf(struct hns3_adapter *hns)
if (ret)
goto err_promisc;
 
+   ret = hns3_restore_fec(hw);
+   if (ret)
+   goto err_promisc;
+
if (hns->hw.adapter_state == HNS3_NIC_STARTED) {
ret = hns3_do_start(hns, false);
if (ret)
@@ -5389,6 +5407,168 @@ hns3_reset_service(void *param)
hns3_msix_process(hns, reset_level);
 }
 
+static int
+hns3_fec_get_capability(struct rte_eth_dev *dev, uint32_t *fec_cap)
+{
+   struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct hns3_mac *mac = &hw->mac;
+   uint32_t mode;
+
+   switch (mac->link_speed) {
+   case ETH_SPEED_NUM_10G:
+   case ETH_SPEED_NUM_40G:
+   mode = RTE_ETH_FEC_CAPA_NOFEC | RTE_ETH_FEC_CAPA_BASER |
+   RTE_ETH_FEC_CAPA_AUTO;
+   break;
+   case ETH_SPEED_NUM_

[dpdk-dev] [PATCH V9 1/3] ethdev: introduce FEC API

2020-09-20 Thread Min Hu (Connor)
This patch adds Forward error correction(FEC) support for ethdev.
Introduce APIs which support query and config FEC information in
hardware.

Signed-off-by: Min Hu (Connor) 
Reviewed-by: Wei Hu (Xavier) 
Reviewed-by: Chengwen Feng 
Reviewed-by: Chengchang Tang 
Reviewed-by: Ajit Khaparde 
Acked-by: Konstantin Ananyev 
---
v8->v9:
added reviewed-by and acked-by.

---
v7->v8:
put AUTO just after NOFEC in rte_fec_mode definition.

---
v6->v7:
deleted RTE_ETH_FEC_NUM to prevent ABI breakage.
add new macro to indicate translation from fec mode
to capa.

---
v5->v6:
modified release notes.
deleted check duplicated for FEC API
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Modifies FEC capa definitions using macros.
Add RTE_ prefix for public FEC mode enum.
add release notes about FEC for dpdk20_11.

---
v2->v3:
add function return value "-ENOTSUP" for API

---
 doc/guides/rel_notes/release_20_11.rst   | 10 
 lib/librte_ethdev/rte_ethdev.c   | 49 ++
 lib/librte_ethdev/rte_ethdev.h   | 85 
 lib/librte_ethdev/rte_ethdev_core.h  | 79 +
 lib/librte_ethdev/rte_ethdev_version.map |  5 ++
 5 files changed, 228 insertions(+)

diff --git a/doc/guides/rel_notes/release_20_11.rst 
b/doc/guides/rel_notes/release_20_11.rst
index cc72609..e19b037 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -55,6 +55,16 @@ New Features
  Also, make sure to start the actual text at the margin.
  ===
 
+* **Added the FEC API, for a generic FEC query and config.**
+
+  Added the FEC API which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, API for configuring FEC mode is also 
provided.
+
+* **Added hns3 FEC PMD, for supporting query and config FEC mode.**
+
+  Added the FEC PMD which provides functions for query FEC capabilities and
+  current FEC mode from device. Also, PMD for configuring FEC mode is also 
provided.
+
 
 Removed Items
 -
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5..d7cd737 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3642,6 +3642,55 @@ rte_eth_led_off(uint16_t port_id)
return eth_err(port_id, (*dev->dev_ops->dev_led_off)(dev));
 }
 
+int
+rte_eth_fec_get_capability(uint16_t port_id, uint32_t *fec_cap)
+{
+   struct rte_eth_dev *dev;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+   dev = &rte_eth_devices[port_id];
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_get_capability, -ENOTSUP);
+   return eth_err(port_id, (*dev->dev_ops->fec_get_capability)(dev,
+   fec_cap));
+}
+
+int
+rte_eth_fec_get(uint16_t port_id, enum rte_eth_fec_mode *mode)
+{
+   struct rte_eth_dev *dev;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+   dev = &rte_eth_devices[port_id];
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_get, -ENOTSUP);
+   return eth_err(port_id, (*dev->dev_ops->fec_get)(dev, mode));
+}
+
+int
+rte_eth_fec_set(uint16_t port_id, enum rte_eth_fec_mode mode)
+{
+   struct rte_eth_dev *dev;
+   uint32_t fec_mode_mask;
+   int ret;
+
+   ret = rte_eth_fec_get_capability(port_id, &fec_mode_mask);
+   if (ret != 0)
+   return ret;
+
+   /*
+* Check whether the configured mode is within the FEC capability.
+* If not, the configured mode will not be supported.
+*/
+   if (!(fec_mode_mask & RTE_ETH_FEC_MODE_TO_CAPA(mode))) {
+   RTE_ETHDEV_LOG(ERR, "unsupported FEC mode = %d, port_id = %u\n",
+  mode, port_id);
+   return -EINVAL;
+   }
+
+   dev = &rte_eth_devices[port_id];
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fec_set, -ENOTSUP);
+   return eth_err(port_id, (*dev->dev_ops->fec_set)(dev, mode));
+}
+
 /*
  * Returns index into MAC address array of addr. Use 00:00:00:00:00:00 to find
  * an empty spot.
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 70295d7..7d5e81b 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1310,6 +1310,9 @@ struct rte_eth_conf {
 #define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
 #define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
 
+/* Translate from FEC mode to FEC capa */
+#define RTE_ETH_FEC_MODE_TO_CAPA(x)(1U << (x))
+
 /**
  * Preferred Rx/Tx port parameters.
  * There are separate instances of this structure for transmission
@@ -1511,6 +1514,24 @@ struct rte_eth_dcb_info {
struct rte_eth_dcb_tc_queue_mapping tc_queue;
 };
 
+/**
+ * This enum indicates the possible (forward error correction)FEC modes
+ * of an ethdev port.
+ */
+enum rte_eth_fec_mode {
+   RTE_ETH_FEC_NOFEC = 0,  /**< FEC i

[dpdk-dev] [PATCH V9 3/3] app/testpmd: add FEC command

2020-09-20 Thread Min Hu (Connor)
This commit adds testpmd capability to query and config FEC
function of device. This includes:
- show FEC capabilities, example:
testpmd> show port 0 fec capabilities
- show FEC mode, example:
testpmd> show port 0 fec_mode
- config FEC mode, example:
testpmd> set port  0 

where:

auto|off|rs|baser are four kinds of FEC mode which dev
support according to MAC link speed.

Signed-off-by: Min Hu (Connor) 
Reviewed-by: Wei Hu (Xavier) 
Reviewed-by: Chengwen Feng 
Reviewed-by: Chengchang Tang 
Acked-by: Ajit Khaparde 
---
v8->v9:
added acked-by.

---
v6->v7:
used RTE_DIM(fec_mode_name) instead of RTE_ETH_FEC_NUM

---
v5->v6:
fixed code styles according to DPDK coding style.
added _eth prefix.

---
v4->v5:
Add RTE_ prefix for public FEC mode enum.

---
v3->v4:
adjust the display format of FEC mode

---
v2->v3:
adjust the display format of FEC capability.

---
 app/test-pmd/cmdline.c | 219 +
 app/test-pmd/config.c  |  54 
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 275 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0a6ed85..3394bea 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -19054,6 +19054,222 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
},
 };
 
+/* *** show fec capability per port configuration *** */
+struct cmd_show_fec_capability_result {
+   cmdline_fixed_string_t cmd_show;
+   cmdline_fixed_string_t cmd_port;
+   cmdline_fixed_string_t cmd_fec;
+   cmdline_fixed_string_t cmd_keyword;
+   portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_capability_parsed(void *parsed_result,
+   __rte_unused struct cmdline *cl,
+   __rte_unused void *data)
+{
+   struct cmd_show_fec_capability_result *res = parsed_result;
+   uint32_t fec_cap;
+   int ret;
+
+   if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+   printf("Invalid port id %u\n", res->cmd_pid);
+   return;
+   }
+
+   ret = rte_eth_fec_get_capability(res->cmd_pid, &fec_cap);
+   if (ret == -ENOTSUP) {
+   printf("Function not implemented\n");
+   return;
+   } else if (ret < 0) {
+   printf("Get FEC capability failed\n");
+   return;
+   }
+
+   show_fec_capability(fec_cap);
+}
+
+cmdline_parse_token_string_t cmd_show_fec_capability_show =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_fec_capability_port =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_fec_capability_pid =
+   TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_pid, UINT16);
+cmdline_parse_token_string_t cmd_show_fec_capability_fec =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_fec, "fec");
+cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
+   TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
+   cmd_keyword, "capabilities");
+
+cmdline_parse_inst_t cmd_show_capability = {
+   .f = cmd_show_fec_capability_parsed,
+   .data = NULL,
+   .help_str = "show port  fec capabilities",
+   .tokens = {
+   (void *)&cmd_show_fec_capability_show,
+   (void *)&cmd_show_fec_capability_port,
+   (void *)&cmd_show_fec_capability_pid,
+   (void *)&cmd_show_fec_capability_fec,
+   (void *)&cmd_show_fec_capability_keyword,
+   NULL,
+   },
+};
+
+/* *** show fec mode per port configuration *** */
+struct cmd_show_fec_metadata_result {
+   cmdline_fixed_string_t cmd_show;
+   cmdline_fixed_string_t cmd_port;
+   cmdline_fixed_string_t cmd_keyword;
+   portid_t cmd_pid;
+};
+
+static void
+cmd_show_fec_mode_parsed(void *parsed_result,
+   __rte_unused struct cmdline *cl,
+   __rte_unused void *data)
+{
+#define FEC_NAME_SIZE 16
+   struct cmd_show_fec_metadata_result *res = parsed_result;
+   enum rte_eth_fec_mode mode;
+   char buf[FEC_NAME_SIZE];
+   int ret;
+
+   if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+   printf("Invalid port id %u\n", res->cmd_pid);
+   return;
+   }
+   ret = rte_eth_fec_get(res->cmd_pid, &mode);
+   if (ret == -ENOTSUP) {
+   printf("Function not implemented\n");
+   return;
+   } else if (ret < 0) {
+   printf("Get FEC mode failed\n");
+   return;
+   }
+
+   switch (mode) {
+   case RTE_ETH_FEC_NOFEC:
+   strlcpy(buf, "off", sizeof(buf));
+   break;
+   case RTE_ETH_FEC_AUTO:
+   strlcpy(buf, "auto", s

[dpdk-dev] [PATCH V9 0/3] add FEC support

2020-09-20 Thread Min Hu (Connor)
This series add FEC support for ethdev.

Min Hu (Connor) (3):
  ethdev: introduce FEC API
  net/hns3: support FEC
  app/testpmd: add FEC command

 app/test-pmd/cmdline.c   | 219 +++
 app/test-pmd/config.c|  54 
 app/test-pmd/testpmd.h   |   2 +
 doc/guides/rel_notes/release_20_11.rst   |  10 ++
 drivers/net/hns3/hns3_cmd.h  |  19 ++-
 drivers/net/hns3/hns3_ethdev.c   | 183 ++
 drivers/net/hns3/hns3_ethdev.h   |   1 +
 lib/librte_ethdev/rte_ethdev.c   |  49 +++
 lib/librte_ethdev/rte_ethdev.h   |  85 
 lib/librte_ethdev/rte_ethdev_core.h  |  79 +++
 lib/librte_ethdev/rte_ethdev_version.map |   5 +
 11 files changed, 705 insertions(+), 1 deletion(-)

-- 
2.7.4



Re: [dpdk-dev] [PATCH] devtools: fix ninja break under default DESTDIR path

2020-09-20 Thread Juraj Linkeš



> -Original Message-
> From: Phil Yang 
> Sent: Sunday, September 20, 2020 11:32 AM
> To: Juraj Linkeš ; david.march...@redhat.com;
> dev@dpdk.org
> Cc: Honnappa Nagarahalli ; Ruifeng Wang
> ; nd ; nd 
> Subject: RE: [dpdk-dev] [PATCH] devtools: fix ninja break under default 
> DESTDIR
> path
> 
> Juraj Linkeš  writes:
> 
> > > Subject: [dpdk-dev] [PATCH] devtools: fix ninja break under default
> > DESTDIR
> > > path
> > >
> > > If DPDK_ABI_REF_DIR is not set, the default DESTDIR is a relative path.
> > > This will break ninja in the ABI check test.
> > >
> >
> > The commit message is not very clear. The problem is we're specifying
> > ninja's destination dir in variable DESTDIR when invoking ninja
> > install. If the DESTDIR is not an absolute path, ninja complains (when
> > invoking install). This isn't
> Yes, this defect is due to 'ninja install' not happy with the relative path.
> Will reword the commit message in the next version.
> 
> > directly related to DPDK_ABI_REF_DIR, it's more a problem with how we
> > call install_target.
> If we have set 'DPDK_ABI_REF_DIR' before the test, 'abiref' should be an
> absolute path, but the default 'abiref' value is a relative path.
> So should we keep them align?
> 
> >
> > > Fixes: 777014e56d07 ("devtools: add ABI checks")
> > >
> > > Signed-off-by: Phil Yang 
> > > ---
> > >  devtools/test-meson-builds.sh | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-
> > builds.sh index
> > > a87de63..2bfcaca 100755
> > > --- a/devtools/test-meson-builds.sh
> > > +++ b/devtools/test-meson-builds.sh
> > > @@ -143,7 +143,7 @@ build () #   > > file> 
> > >   config $srcdir $builds_dir/$targetdir $cross --werror $*
> > >   compile $builds_dir/$targetdir
> > >   if [ -n "$DPDK_ABI_REF_VERSION" ]; then
> > > - abirefdir=${DPDK_ABI_REF_DIR:-
> > > reference}/$DPDK_ABI_REF_VERSION
> > > + abirefdir=${DPDK_ABI_REF_DIR:-
> > > $(pwd)/reference}/$DPDK_ABI_REF_VERSION
> > >   if [ ! -d $abirefdir/$targetdir ]; then
> > >   # clone current sources
> > >   if [ ! -d $abirefdir/src ]; then
> > > --
> > > 2.7.4
> > >
> >
> > install_target on line 160 is called improperly. Let's fix it so that
> > it matches line
> > 169:
> > install_target $abirefdir/build $(readlink -f $abirefdir/$targetdir)
> 
> If so we need to call readlink at line #161 as well as it does at line #171.
> 
> >
> > This way we don't need to add $(pwd).
> 
> If you don't prefer $(pwd), we can do it like this:
> abirefdir=$(readlink -f ${DPDK_ABI_REF_DIR:-
> reference}/$DPDK_ABI_REF_VERSION)
> 

I mostly wanted the code to be consistent and since readlink was already in the 
code I pointed that out. I think your last proposal is the best of the two 
worlds, but let's change the code everywhere (i.e. lines 170-174 as well).

> Thanks,
> Phil
> 
> 




Re: [dpdk-dev] [PATCH v6 1/3] gro: add UDP/IPv4 GRO support

2020-09-20 Thread Hu, Jiayu
> -Original Message-
> From: yang_y...@163.com 
> Sent: Thursday, September 17, 2020 11:50 AM
> To: dev@dpdk.org
> Cc: Hu, Jiayu ; tho...@monjalon.net;
> yangy...@inspur.com; yang_y...@163.com
> Subject: [PATCH v6 1/3] gro: add UDP/IPv4 GRO support
> 
> From: Yi Yang 
> 
> UDP/IPv4 GRO can help improve VM-to-VM UDP performance
> when UFO or GSO is enabled in VM, GRO must be supported
> if UFO or GSO is enabled, otherwise, performance can't
> get big improvement if only GSO is there.
> 
> With this enabled in DPDK, OVS DPDK can leverage it
> to improve VM-to-VM UDP performance, it will reassemble
> UDP fragments immediate after they are received from
> a physical NIC. It is very helpful in OVS DPDK VLAN use
> case.
> 
> Signed-off-by: Yi Yang 

Acked-by: Jiayu Hu 

> ---
>  lib/librte_gro/gro_udp4.c  | 430
> +
>  lib/librte_gro/gro_udp4.h  | 281 +
>  lib/librte_gro/meson.build |   2 +-
>  lib/librte_gro/rte_gro.c   |  92 --
>  lib/librte_gro/rte_gro.h   |   5 +-
>  5 files changed, 794 insertions(+), 16 deletions(-)
>  create mode 100644 lib/librte_gro/gro_udp4.c
>  create mode 100644 lib/librte_gro/gro_udp4.h
> 


Re: [dpdk-dev] [PATCH v1 4/5] vhost: add packed ring vectorized dequeue

2020-09-20 Thread Liu, Yong


> -Original Message-
> From: Maxime Coquelin 
> Sent: Friday, September 18, 2020 9:45 PM
> To: Liu, Yong ; Xia, Chenbo ;
> Wang, Zhihong 
> Cc: dev@dpdk.org
> Subject: Re: [PATCH v1 4/5] vhost: add packed ring vectorized dequeue
> 
> 
> 
> On 8/19/20 5:24 AM, Marvin Liu wrote:
> > Optimize vhost packed ring dequeue path with SIMD instructions. Four
> > descriptors status check and writeback are batched handled with AVX512
> > instructions. Address translation operations are also accelerated by
> > AVX512 instructions.
> >
> > If platform or compiler not support vectorization, will fallback to
> > default path.
> >
> > Signed-off-by: Marvin Liu 
> >
> > diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
> > index 4f2f3e47da..c0cd7d498f 100644
> > --- a/lib/librte_vhost/Makefile
> > +++ b/lib/librte_vhost/Makefile
> > @@ -31,6 +31,13 @@ CFLAGS += -DVHOST_ICC_UNROLL_PRAGMA
> >  endif
> >  endif
> >
> > +ifneq ($(FORCE_DISABLE_AVX512), y)
> > +CC_AVX512_SUPPORT=\
> > +$(shell $(CC) -march=native -dM -E - &1 | \
> > +sed '/./{H;$$!d} ; x ; /AVX512F/!d; /AVX512BW/!d; /AVX512VL/!d' | \
> > +grep -q AVX512 && echo 1)
> > +endif
> > +
> >  ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
> >  LDLIBS += -lnuma
> >  endif
> > @@ -40,6 +47,12 @@ LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -
> lrte_ethdev -lrte_net
> >  SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := fd_man.c iotlb.c socket.c vhost.c \
> > vhost_user.c virtio_net.c vdpa.c
> >
> > +ifeq ($(CC_AVX512_SUPPORT), 1)
> > +CFLAGS += -DCC_AVX512_SUPPORT
> > +SRCS-$(CONFIG_RTE_LIBRTE_VHOST) += vhost_vec_avx.c
> > +CFLAGS_vhost_vec_avx.o += -mavx512f -mavx512bw -mavx512vl
> > +endif
> > +
> >  # install includes
> >  SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_vhost.h
> rte_vdpa.h \
> > rte_vdpa_dev.h
> rte_vhost_async.h
> > diff --git a/lib/librte_vhost/meson.build b/lib/librte_vhost/meson.build
> > index cc9aa65c67..c1481802d7 100644
> > --- a/lib/librte_vhost/meson.build
> > +++ b/lib/librte_vhost/meson.build
> > @@ -8,6 +8,22 @@ endif
> >  if has_libnuma == 1
> > dpdk_conf.set10('RTE_LIBRTE_VHOST_NUMA', true)
> >  endif
> > +
> > +if arch_subdir == 'x86'
> > +if not machine_args.contains('-mno-avx512f')
> > +if cc.has_argument('-mavx512f') and cc.has_argument('-
> mavx512vl') and cc.has_argument('-mavx512bw')
> > +cflags += ['-DCC_AVX512_SUPPORT']
> > +vhost_avx512_lib = 
> > static_library('vhost_avx512_lib',
> > +  'vhost_vec_avx.c',
> > +  dependencies: 
> > [static_rte_eal,
> static_rte_mempool,
> > +  static_rte_mbuf, 
> > static_rte_ethdev,
> static_rte_net],
> > +  include_directories: 
> > includes,
> > +  c_args: [cflags, 
> > '-mavx512f', '-mavx512bw', '-
> mavx512vl'])
> > +objs += 
> > vhost_avx512_lib.extract_objects('vhost_vec_avx.c')
> > +endif
> > +endif
> > +endif
> > +
> >  if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
> > cflags += '-DVHOST_GCC_UNROLL_PRAGMA'
> >  elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0'))
> > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> > index 4a81f18f01..fc7daf2145 100644
> > --- a/lib/librte_vhost/vhost.h
> > +++ b/lib/librte_vhost/vhost.h
> > @@ -1124,4 +1124,12 @@ virtio_dev_pktmbuf_alloc(struct virtio_net
> *dev, struct rte_mempool *mp,
> > return NULL;
> >  }
> >
> > +int
> > +vhost_reserve_avail_batch_packed_avx(struct virtio_net *dev,
> > +struct vhost_virtqueue *vq,
> > +struct rte_mempool *mbuf_pool,
> > +struct rte_mbuf **pkts,
> > +uint16_t avail_idx,
> > +uintptr_t *desc_addrs,
> > +uint16_t *ids);
> >  #endif /* _VHOST_NET_CDEV_H_ */
> > diff --git a/lib/librte_vhost/vhost_vec_avx.c
> b/lib/librte_vhost/vhost_vec_avx.c
> > new file mode 100644
> > index 00..e8361d18fa
> > --- /dev/null
> > +++ b/lib/librte_vhost/vhost_vec_avx.c
> > @@ -0,0 +1,152 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2010-2016 Intel Corporation
> > + */
> > +#include 
> > +
> > +#include "vhost.h"
> > +
> > +#define BYTE_SIZE 8
> > +/* reference count offset in mbuf rearm data */
> > +#define REFCNT_BITS_OFFSET ((offsetof(struct rte_mbuf, refcnt) - \
> > +   offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
> > +/* segment number offset in mbuf rearm data */
> > +#define SEG_NUM_BITS_OFFSET ((offsetof(struct rte_mbuf, nb_segs) - \
> > +   offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
> 

[dpdk-dev] [PATCH v2 2/5] vhost: reuse packed ring functions

2020-09-20 Thread Marvin Liu
Move parse_ethernet, offload, extbuf functions to header file. These
functions will be reused by vhost vectorized path.

Signed-off-by: Marvin Liu 

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index b556eb3bf6..5a5c945551 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -20,6 +20,10 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
 #include "rte_vhost.h"
 #include "rte_vdpa.h"
 #include "rte_vdpa_dev.h"
@@ -905,4 +909,215 @@ put_zmbuf(struct zcopy_mbuf *zmbuf)
zmbuf->in_use = 0;
 }
 
+static  __rte_always_inline bool
+virtio_net_is_inorder(struct virtio_net *dev)
+{
+   return dev->features & (1ULL << VIRTIO_F_IN_ORDER);
+}
+
+static __rte_always_inline void
+parse_ethernet(struct rte_mbuf *m, uint16_t *l4_proto, void **l4_hdr)
+{
+   struct rte_ipv4_hdr *ipv4_hdr;
+   struct rte_ipv6_hdr *ipv6_hdr;
+   void *l3_hdr = NULL;
+   struct rte_ether_hdr *eth_hdr;
+   uint16_t ethertype;
+
+   eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+
+   m->l2_len = sizeof(struct rte_ether_hdr);
+   ethertype = rte_be_to_cpu_16(eth_hdr->ether_type);
+
+   if (ethertype == RTE_ETHER_TYPE_VLAN) {
+   struct rte_vlan_hdr *vlan_hdr =
+   (struct rte_vlan_hdr *)(eth_hdr + 1);
+
+   m->l2_len += sizeof(struct rte_vlan_hdr);
+   ethertype = rte_be_to_cpu_16(vlan_hdr->eth_proto);
+   }
+
+   l3_hdr = (char *)eth_hdr + m->l2_len;
+
+   switch (ethertype) {
+   case RTE_ETHER_TYPE_IPV4:
+   ipv4_hdr = l3_hdr;
+   *l4_proto = ipv4_hdr->next_proto_id;
+   m->l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4;
+   *l4_hdr = (char *)l3_hdr + m->l3_len;
+   m->ol_flags |= PKT_TX_IPV4;
+   break;
+   case RTE_ETHER_TYPE_IPV6:
+   ipv6_hdr = l3_hdr;
+   *l4_proto = ipv6_hdr->proto;
+   m->l3_len = sizeof(struct rte_ipv6_hdr);
+   *l4_hdr = (char *)l3_hdr + m->l3_len;
+   m->ol_flags |= PKT_TX_IPV6;
+   break;
+   default:
+   m->l3_len = 0;
+   *l4_proto = 0;
+   *l4_hdr = NULL;
+   break;
+   }
+}
+
+static __rte_always_inline bool
+virtio_net_with_host_offload(struct virtio_net *dev)
+{
+   if (dev->features &
+   ((1ULL << VIRTIO_NET_F_CSUM) |
+(1ULL << VIRTIO_NET_F_HOST_ECN) |
+(1ULL << VIRTIO_NET_F_HOST_TSO4) |
+(1ULL << VIRTIO_NET_F_HOST_TSO6) |
+(1ULL << VIRTIO_NET_F_HOST_UFO)))
+   return true;
+
+   return false;
+}
+
+static __rte_always_inline void
+vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m)
+{
+   uint16_t l4_proto = 0;
+   void *l4_hdr = NULL;
+   struct rte_tcp_hdr *tcp_hdr = NULL;
+
+   if (hdr->flags == 0 && hdr->gso_type == VIRTIO_NET_HDR_GSO_NONE)
+   return;
+
+   parse_ethernet(m, &l4_proto, &l4_hdr);
+   if (hdr->flags == VIRTIO_NET_HDR_F_NEEDS_CSUM) {
+   if (hdr->csum_start == (m->l2_len + m->l3_len)) {
+   switch (hdr->csum_offset) {
+   case (offsetof(struct rte_tcp_hdr, cksum)):
+   if (l4_proto == IPPROTO_TCP)
+   m->ol_flags |= PKT_TX_TCP_CKSUM;
+   break;
+   case (offsetof(struct rte_udp_hdr, dgram_cksum)):
+   if (l4_proto == IPPROTO_UDP)
+   m->ol_flags |= PKT_TX_UDP_CKSUM;
+   break;
+   case (offsetof(struct rte_sctp_hdr, cksum)):
+   if (l4_proto == IPPROTO_SCTP)
+   m->ol_flags |= PKT_TX_SCTP_CKSUM;
+   break;
+   default:
+   break;
+   }
+   }
+   }
+
+   if (l4_hdr && hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
+   switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
+   case VIRTIO_NET_HDR_GSO_TCPV4:
+   case VIRTIO_NET_HDR_GSO_TCPV6:
+   tcp_hdr = l4_hdr;
+   m->ol_flags |= PKT_TX_TCP_SEG;
+   m->tso_segsz = hdr->gso_size;
+   m->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
+   break;
+   case VIRTIO_NET_HDR_GSO_UDP:
+   m->ol_flags |= PKT_TX_UDP_SEG;
+   m->tso_segsz = hdr->gso_size;
+   m->l4_len = sizeof(struct rte_udp_hdr);
+   break;
+   default:
+   VHOST_LOG_DATA(WARNING,
+   "unsupporte

[dpdk-dev] [PATCH v2 1/5] vhost: add vectorized data path

2020-09-20 Thread Marvin Liu
Packed ring operations are split into batch and single functions for
performance perspective. Ring operations in batch function can be
accelerated by SIMD instructions like AVX512.

So introduce vectorized parameter in vhost. Vectorized data path can be
selected if platform and ring format matched requirements. Otherwise
will fallback to original data path.

Signed-off-by: Marvin Liu 

diff --git a/doc/guides/nics/vhost.rst b/doc/guides/nics/vhost.rst
index d36f3120b2..efdaf4de09 100644
--- a/doc/guides/nics/vhost.rst
+++ b/doc/guides/nics/vhost.rst
@@ -64,6 +64,11 @@ The user can specify below arguments in `--vdev` option.
 It is used to enable external buffer support in vhost library.
 (Default: 0 (disabled))
 
+#.  ``vectorized``:
+
+It is used to enable vectorized data path support in vhost library.
+(Default: 0 (disabled))
+
 Vhost PMD event handling
 
 
diff --git a/doc/guides/prog_guide/vhost_lib.rst 
b/doc/guides/prog_guide/vhost_lib.rst
index b892eec67a..d5d421441c 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -162,6 +162,18 @@ The following is an overview of some key Vhost API 
functions:
 
 It is disabled by default.
 
+ - ``RTE_VHOST_USER_VECTORIZED``
+Vectorized data path will used when this flag is set. When packed ring
+enabled, available descriptors are stored from frontend driver in sequence.
+SIMD instructions like AVX can be used to handle multiple descriptors
+simultaneously. Thus can accelerate the throughput of ring operations.
+
+* Only packed ring has vectorized data path.
+
+* Will fallback to normal datapath if no vectorization support.
+
+It is disabled by default.
+
 * ``rte_vhost_driver_set_features(path, features)``
 
   This function sets the feature bits the vhost-user driver supports. The
diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index e55278af69..2ba5a2a076 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -35,6 +35,7 @@ enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
 #define ETH_VHOST_VIRTIO_NET_F_HOST_TSO "tso"
 #define ETH_VHOST_LINEAR_BUF  "linear-buffer"
 #define ETH_VHOST_EXT_BUF  "ext-buffer"
+#define ETH_VHOST_VECTORIZED "vectorized"
 #define VHOST_MAX_PKT_BURST 32
 
 static const char *valid_arguments[] = {
@@ -47,6 +48,7 @@ static const char *valid_arguments[] = {
ETH_VHOST_VIRTIO_NET_F_HOST_TSO,
ETH_VHOST_LINEAR_BUF,
ETH_VHOST_EXT_BUF,
+   ETH_VHOST_VECTORIZED,
NULL
 };
 
@@ -1507,6 +1509,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
int tso = 0;
int linear_buf = 0;
int ext_buf = 0;
+   int vectorized = 0;
struct rte_eth_dev *eth_dev;
const char *name = rte_vdev_device_name(dev);
 
@@ -1626,6 +1629,17 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
flags |= RTE_VHOST_USER_EXTBUF_SUPPORT;
}
 
+   if (rte_kvargs_count(kvlist, ETH_VHOST_VECTORIZED) == 1) {
+   ret = rte_kvargs_process(kvlist,
+   ETH_VHOST_VECTORIZED,
+   &open_int, &vectorized);
+   if (ret < 0)
+   goto out_free;
+
+   if (vectorized == 1)
+   flags |= RTE_VHOST_USER_VECTORIZED;
+   }
+
if (dev->device.numa_node == SOCKET_ID_ANY)
dev->device.numa_node = rte_socket_id();
 
@@ -1679,4 +1693,5 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
"postcopy-support=<0|1> "
"tso=<0|1> "
"linear-buffer=<0|1> "
-   "ext-buffer=<0|1>");
+   "ext-buffer=<0|1> "
+   "vectorized=<0|1>");
diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index a94c84134d..c7f946c6c1 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -36,6 +36,7 @@ extern "C" {
 /* support only linear buffers (no chained mbufs) */
 #define RTE_VHOST_USER_LINEARBUF_SUPPORT   (1ULL << 6)
 #define RTE_VHOST_USER_ASYNC_COPY  (1ULL << 7)
+#define RTE_VHOST_USER_VECTORIZED  (1ULL << 8)
 
 /* Features. */
 #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 73e1dca95e..cc11244693 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -43,6 +43,7 @@ struct vhost_user_socket {
bool extbuf;
bool linearbuf;
bool async_copy;
+   bool vectorized;
 
/*
 * The "supported_features" indicates the feature bits the
@@ -245,6 +246,9 @@ vhost_user_add_connection(int fd, struct vhost_user_socket 
*vsocket)
dev->async_copy = 1;
}
 
+   if (vsocket->vectorized)
+   vhost_enable_vectorized(vid);
+
VHOST_LOG_CONFIG(INFO, "new device, handle is %d\n", vid);
 
if (vsocket->notify_ops->new_connection) {
@@ -881,6 +885,7 @@ r

[dpdk-dev] [PATCH v2 0/5] vhost add vectorized data path

2020-09-20 Thread Marvin Liu
Packed ring format is imported since virtio spec 1.1. All descriptors
are compacted into one single ring when packed ring format is on. It is
straight forward that ring operations can be accelerated by utilizing
SIMD instructions. 

This patch set will introduce vectorized data path in vhost library. If
vectorized option is on, operations like descs check, descs writeback,
address translation will be accelerated by SIMD instructions. Vhost
application can choose whether using vectorized acceleration, it is 
like external buffer and zero copy features. 

If platform or ring format not support vectorized function, vhost will
fallback to use default batch function. There will be no impact in current
data path.

v2:
* add vIOMMU support
* add dequeue offloading
* rebase code

Marvin Liu (5):
  vhost: add vectorized data path
  vhost: reuse packed ring functions
  vhost: prepare memory regions addresses
  vhost: add packed ring vectorized dequeue
  vhost: add packed ring vectorized enqueue

 doc/guides/nics/vhost.rst   |   5 +
 doc/guides/prog_guide/vhost_lib.rst |  12 +
 drivers/net/vhost/rte_eth_vhost.c   |  17 +-
 lib/librte_vhost/meson.build|  16 ++
 lib/librte_vhost/rte_vhost.h|   1 +
 lib/librte_vhost/socket.c   |   5 +
 lib/librte_vhost/vhost.c|  11 +
 lib/librte_vhost/vhost.h| 235 +++
 lib/librte_vhost/vhost_user.c   |  11 +
 lib/librte_vhost/vhost_vec_avx.c| 338 
 lib/librte_vhost/virtio_net.c   | 257 -
 11 files changed, 692 insertions(+), 216 deletions(-)
 create mode 100644 lib/librte_vhost/vhost_vec_avx.c

-- 
2.17.1



[dpdk-dev] [PATCH v2 5/5] vhost: add packed ring vectorized enqueue

2020-09-20 Thread Marvin Liu
Optimize vhost packed ring enqueue path with SIMD instructions. Four
descriptors status and length are batched handled with AVX512
instructions. Address translation operations are also accelerated
by AVX512 instructions.

Signed-off-by: Marvin Liu 

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index fc7daf2145..b78b2c5c1b 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -1132,4 +1132,10 @@ vhost_reserve_avail_batch_packed_avx(struct virtio_net 
*dev,
 uint16_t avail_idx,
 uintptr_t *desc_addrs,
 uint16_t *ids);
+
+int
+virtio_dev_rx_batch_packed_avx(struct virtio_net *dev,
+  struct vhost_virtqueue *vq,
+  struct rte_mbuf **pkts);
+
 #endif /* _VHOST_NET_CDEV_H_ */
diff --git a/lib/librte_vhost/vhost_vec_avx.c b/lib/librte_vhost/vhost_vec_avx.c
index dc5322d002..7d2250ed86 100644
--- a/lib/librte_vhost/vhost_vec_avx.c
+++ b/lib/librte_vhost/vhost_vec_avx.c
@@ -35,9 +35,15 @@
 #define PACKED_AVAIL_FLAG ((0ULL | VRING_DESC_F_AVAIL) << FLAGS_BITS_OFFSET)
 #define PACKED_AVAIL_FLAG_WRAP ((0ULL | VRING_DESC_F_USED) << \
FLAGS_BITS_OFFSET)
+#define PACKED_WRITE_AVAIL_FLAG (PACKED_AVAIL_FLAG | \
+   ((0ULL | VRING_DESC_F_WRITE) << FLAGS_BITS_OFFSET))
+#define PACKED_WRITE_AVAIL_FLAG_WRAP (PACKED_AVAIL_FLAG_WRAP | \
+   ((0ULL | VRING_DESC_F_WRITE) << FLAGS_BITS_OFFSET))
 
 #define DESC_FLAGS_POS 0xaa
 #define MBUF_LENS_POS 0x
+#define DESC_LENS_POS 0x
+#define DESC_LENS_FLAGS_POS 0xB0B0B0B0
 
 int
 vhost_reserve_avail_batch_packed_avx(struct virtio_net *dev,
@@ -179,3 +185,154 @@ vhost_reserve_avail_batch_packed_avx(struct virtio_net 
*dev,
 
return -1;
 }
+
+int
+virtio_dev_rx_batch_packed_avx(struct virtio_net *dev,
+  struct vhost_virtqueue *vq,
+  struct rte_mbuf **pkts)
+{
+   struct vring_packed_desc *descs = vq->desc_packed;
+   uint16_t avail_idx = vq->last_avail_idx;
+   uint64_t desc_addrs[PACKED_BATCH_SIZE];
+   uint32_t buf_offset = dev->vhost_hlen;
+   uint32_t desc_status;
+   uint64_t lens[PACKED_BATCH_SIZE];
+   uint16_t i;
+   void *desc_addr;
+   uint8_t cmp_low, cmp_high, cmp_result;
+
+   if (unlikely(avail_idx & PACKED_BATCH_MASK))
+   return -1;
+
+   /* check refcnt and nb_segs */
+   __m256i mbuf_ref = _mm256_set1_epi64x(DEFAULT_REARM_DATA);
+
+   /* load four mbufs rearm data */
+   __m256i mbufs = _mm256_set_epi64x(
+   *pkts[3]->rearm_data,
+   *pkts[2]->rearm_data,
+   *pkts[1]->rearm_data,
+   *pkts[0]->rearm_data);
+
+   uint16_t cmp = _mm256_cmpneq_epu16_mask(mbufs, mbuf_ref);
+   if (cmp & MBUF_LENS_POS)
+   return -1;
+
+   /* check desc status */
+   desc_addr = &vq->desc_packed[avail_idx];
+   __m512i desc_vec = _mm512_loadu_si512(desc_addr);
+
+   __m512i avail_flag_vec;
+   __m512i used_flag_vec;
+   if (vq->avail_wrap_counter) {
+#if defined(RTE_ARCH_I686)
+   avail_flag_vec = _mm512_set4_epi64(PACKED_WRITE_AVAIL_FLAG,
+   0x0, PACKED_WRITE_AVAIL_FLAG, 0x0);
+   used_flag_vec = _mm512_set4_epi64(PACKED_FLAGS_MASK, 0x0,
+   PACKED_FLAGS_MASK, 0x0);
+#else
+   avail_flag_vec = _mm512_maskz_set1_epi64(DESC_FLAGS_POS,
+   PACKED_WRITE_AVAIL_FLAG);
+   used_flag_vec = _mm512_maskz_set1_epi64(DESC_FLAGS_POS,
+   PACKED_FLAGS_MASK);
+#endif
+   } else {
+#if defined(RTE_ARCH_I686)
+   avail_flag_vec = _mm512_set4_epi64(
+   PACKED_WRITE_AVAIL_FLAG_WRAP, 0x0,
+   PACKED_WRITE_AVAIL_FLAG, 0x0);
+   used_flag_vec = _mm512_set4_epi64(0x0, 0x0, 0x0, 0x0);
+#else
+   avail_flag_vec = _mm512_maskz_set1_epi64(DESC_FLAGS_POS,
+   PACKED_WRITE_AVAIL_FLAG_WRAP);
+   used_flag_vec = _mm512_setzero_epi32();
+#endif
+   }
+
+   desc_status = _mm512_mask_cmp_epu16_mask(BATCH_FLAGS_MASK, desc_vec,
+   avail_flag_vec, _MM_CMPINT_NE);
+   if (desc_status)
+   return -1;
+
+   if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) {
+   vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
+   uint64_t size = (uint64_t)descs[avail_idx + i].len;
+   desc_addrs[i] = __vhost_iova_to_vva(dev, vq,
+   descs[avail_idx + i].addr, &size,
+   VHOST_ACCESS_RW);
+
+   if (!desc_addrs[i])
+ 

[dpdk-dev] [PATCH v2 3/5] vhost: prepare memory regions addresses

2020-09-20 Thread Marvin Liu
Prepare memory regions guest physical addresses for vectorized data
path. These information will be utilized by SIMD instructions to find
matched region index.

Signed-off-by: Marvin Liu 

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 5a5c945551..4a81f18f01 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -52,6 +52,8 @@
 
 #define ASYNC_MAX_POLL_SEG 255
 
+#define MAX_NREGIONS 8
+
 #define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST * 2)
 #define VHOST_MAX_ASYNC_VEC (BUF_VECTOR_MAX * 2)
 
@@ -375,6 +377,8 @@ struct inflight_mem_info {
 struct virtio_net {
/* Frontend (QEMU) memory and memory region information */
struct rte_vhost_memory *mem;
+   uint64_tregions_low_addrs[MAX_NREGIONS];
+   uint64_tregions_high_addrs[MAX_NREGIONS];
uint64_tfeatures;
uint64_tprotocol_features;
int vid;
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index c3c924faec..89e75e9e71 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1291,6 +1291,17 @@ vhost_user_set_mem_table(struct virtio_net **pdev, 
struct VhostUserMsg *msg,
}
}
 
+   RTE_BUILD_BUG_ON(VHOST_MEMORY_MAX_NREGIONS != 8);
+   if (dev->vectorized) {
+   for (i = 0; i < memory->nregions; i++) {
+   dev->regions_low_addrs[i] =
+   memory->regions[i].guest_phys_addr;
+   dev->regions_high_addrs[i] =
+   memory->regions[i].guest_phys_addr +
+   memory->regions[i].memory_size;
+   }
+   }
+
for (i = 0; i < dev->nr_vring; i++) {
struct vhost_virtqueue *vq = dev->virtqueue[i];
 
-- 
2.17.1



[dpdk-dev] [PATCH v2 4/5] vhost: add packed ring vectorized dequeue

2020-09-20 Thread Marvin Liu
Optimize vhost packed ring dequeue path with SIMD instructions. Four
descriptors status check and writeback are batched handled with AVX512
instructions. Address translation operations are also accelerated by
AVX512 instructions.

If platform or compiler not support vectorization, will fallback to
default path.

Signed-off-by: Marvin Liu 

diff --git a/lib/librte_vhost/meson.build b/lib/librte_vhost/meson.build
index cc9aa65c67..c1481802d7 100644
--- a/lib/librte_vhost/meson.build
+++ b/lib/librte_vhost/meson.build
@@ -8,6 +8,22 @@ endif
 if has_libnuma == 1
dpdk_conf.set10('RTE_LIBRTE_VHOST_NUMA', true)
 endif
+
+if arch_subdir == 'x86'
+if not machine_args.contains('-mno-avx512f')
+if cc.has_argument('-mavx512f') and 
cc.has_argument('-mavx512vl') and cc.has_argument('-mavx512bw')
+cflags += ['-DCC_AVX512_SUPPORT']
+vhost_avx512_lib = static_library('vhost_avx512_lib',
+  'vhost_vec_avx.c',
+  dependencies: [static_rte_eal, 
static_rte_mempool,
+  static_rte_mbuf, 
static_rte_ethdev, static_rte_net],
+  include_directories: includes,
+  c_args: [cflags, '-mavx512f', 
'-mavx512bw', '-mavx512vl'])
+objs += 
vhost_avx512_lib.extract_objects('vhost_vec_avx.c')
+endif
+endif
+endif
+
 if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
cflags += '-DVHOST_GCC_UNROLL_PRAGMA'
 elif (toolchain == 'clang' and cc.version().version_compare('>=3.7.0'))
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 4a81f18f01..fc7daf2145 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -1124,4 +1124,12 @@ virtio_dev_pktmbuf_alloc(struct virtio_net *dev, struct 
rte_mempool *mp,
return NULL;
 }
 
+int
+vhost_reserve_avail_batch_packed_avx(struct virtio_net *dev,
+struct vhost_virtqueue *vq,
+struct rte_mempool *mbuf_pool,
+struct rte_mbuf **pkts,
+uint16_t avail_idx,
+uintptr_t *desc_addrs,
+uint16_t *ids);
 #endif /* _VHOST_NET_CDEV_H_ */
diff --git a/lib/librte_vhost/vhost_vec_avx.c b/lib/librte_vhost/vhost_vec_avx.c
new file mode 100644
index 00..dc5322d002
--- /dev/null
+++ b/lib/librte_vhost/vhost_vec_avx.c
@@ -0,0 +1,181 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation
+ */
+#include 
+
+#include "vhost.h"
+
+#define BYTE_SIZE 8
+/* reference count offset in mbuf rearm data */
+#define REFCNT_BITS_OFFSET ((offsetof(struct rte_mbuf, refcnt) - \
+   offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
+/* segment number offset in mbuf rearm data */
+#define SEG_NUM_BITS_OFFSET ((offsetof(struct rte_mbuf, nb_segs) - \
+   offsetof(struct rte_mbuf, rearm_data)) * BYTE_SIZE)
+
+/* default rearm data */
+#define DEFAULT_REARM_DATA (1ULL << SEG_NUM_BITS_OFFSET | \
+   1ULL << REFCNT_BITS_OFFSET)
+
+#define DESC_FLAGS_SHORT_OFFSET (offsetof(struct vring_packed_desc, flags) / \
+   sizeof(uint16_t))
+
+#define DESC_FLAGS_SHORT_SIZE (sizeof(struct vring_packed_desc) / \
+   sizeof(uint16_t))
+#define BATCH_FLAGS_MASK (1 << DESC_FLAGS_SHORT_OFFSET | \
+   1 << (DESC_FLAGS_SHORT_OFFSET + DESC_FLAGS_SHORT_SIZE) | \
+   1 << (DESC_FLAGS_SHORT_OFFSET + DESC_FLAGS_SHORT_SIZE * 2)  | \
+   1 << (DESC_FLAGS_SHORT_OFFSET + DESC_FLAGS_SHORT_SIZE * 3))
+
+#define FLAGS_BITS_OFFSET ((offsetof(struct vring_packed_desc, flags) - \
+   offsetof(struct vring_packed_desc, len)) * BYTE_SIZE)
+
+#define PACKED_FLAGS_MASK ((0ULL | VRING_DESC_F_AVAIL | VRING_DESC_F_USED) \
+   << FLAGS_BITS_OFFSET)
+#define PACKED_AVAIL_FLAG ((0ULL | VRING_DESC_F_AVAIL) << FLAGS_BITS_OFFSET)
+#define PACKED_AVAIL_FLAG_WRAP ((0ULL | VRING_DESC_F_USED) << \
+   FLAGS_BITS_OFFSET)
+
+#define DESC_FLAGS_POS 0xaa
+#define MBUF_LENS_POS 0x
+
+int
+vhost_reserve_avail_batch_packed_avx(struct virtio_net *dev,
+struct vhost_virtqueue *vq,
+struct rte_mempool *mbuf_pool,
+struct rte_mbuf **pkts,
+uint16_t avail_idx,
+uintptr_t *desc_addrs,
+uint16_t *ids)
+{
+   struct vring_packed_desc *descs = vq->desc_packed;
+   uint32_t descs_status;
+   void *desc_addr;
+   uint16_t i;
+   uint8_t cmp_low, cmp_high, cmp_result;
+   uint64_t lens[PACKED_BATCH_SIZE];
+   struct virtio_net_hdr *hdr;
+
+   if (unlikely(avail_idx & PACKED_BATCH_MASK))
+   return -1