Re: [dpdk-dev] The type string in the malloc library is unused

2019-09-14 Thread Morten Brørup
Hi Alexander,

That was exactly what I was looking for, thanks!

Med venlig hilsen / kind regards
- Morten Brørup

> -Original Message-
> From: Alexander Pshenichnikov [mailto:aps...@gmail.com]
> Sent: Friday, September 13, 2019 9:38 PM
> To: Morten Brørup
> Cc: Anatoly Burakov; Olivier Matz; Andrew Rybchenko; dev@dpdk.org
> Subject: Re: [dpdk-dev] The type string in the malloc library is unused
> 
> Hi Morten,
> 
> Look rte_memzone_reserve/rte_memzone_lookup
> 
> 
> 
> On Fri, Sep 13, 2019 at 4:32 PM Morten Brørup 
> wrote:
> >
> > Hi Anatoly,
> >
> >
> >
> > The functions in the DPDK malloc library takes a "type" parameter (a
> string, supposedly for debug purposes), but the underlying malloc_heap
> functions (which take the same string parameter) don't store or use this
> string for anything.
> >
> >
> >
> > Is the intention to implement this sometime in the future, or should it
> be considered for removal?
> >
> >
> >
> > I was originally looking for a function for my primary process to
> allocate a block of named memory in the huge-page area, so my secondary
> process could look it up and use it. And I would simply use a unique type
> string for this, and add an rte_malloc_lookup function. However, that
> obviously doesn't work when the type parameter is not used during
> allocation.
> >
> >
> >
> >
> >
> > The simplest workaround I can come up with is using a named mempool with
> a single element, where this element is my memory block. I get an element
> from this mempool to find the address of my memory block, store the
> address, and put the element back in the mempool, so the secondary process
> can get the address the same way, i.e. by getting and putting the element
> back into the mempool while storing the element's address underway.
> >
> >
> >
> > Any better ideas?
> >
> >
> >
> >
> >
> > Med venlig hilsen / kind regards
> >
> >
> >
> > Morten Brørup
> >
> > CTO
> >
> >
> >
> >
> >
> > SmartShare Systems A/S
> >
> > Tonsbakken 16-18
> >
> > DK-2740 Skovlunde
> >
> > Denmark
> >
> >
> >
> > Office  +45 70 20 00 93
> >
> > Direct  +45 89 93 50 22
> >
> > Mobile +45 25 40 82 12
> >
> >
> >
> > m...@smartsharesystems.com 
> >
> > www.smartsharesystems.com 
> >
> >
> >



Re: [dpdk-dev] The type string in the malloc library is unused

2019-09-14 Thread Morten Brørup
I tend to agree with Stephen here, although it will break the API/ABI.

 

Another argument supporting its removal is the fact that it has remained 
non-implemented for many years, so a function for dumping information about 
rte_malloc'ed memory using the "type" string for debugging purposes has 
apparently not been in very high demand.

 

Med venlig hilsen / kind regards

- Morten Brørup

 

From: Stephen Hemminger [mailto:step...@networkplumber.org] 
Sent: Saturday, September 14, 2019 8:24 AM
To: Morten Brørup
Subject: Re: [dpdk-dev] The type string in the malloc library is unused

 

I would vote for removing it.

It is too late to implement it without breaking existing code.

 

 

On Fri, Sep 13, 2019, 3:32 PM Morten Brørup  wrote:

Hi Anatoly,



The functions in the DPDK malloc library takes a "type" parameter (a 
string, supposedly for debug purposes), but the underlying malloc_heap 
functions (which take the same string parameter) don't store or use this string 
for anything.



Is the intention to implement this sometime in the future, or should it 
be considered for removal?






[dpdk-dev] [PATCH] devtools: fix test of ninja install

2019-09-14 Thread Thomas Monjalon
When trying to compile some examples with libdpdk.pc,
the right environment (for default target) was not loaded.
The consequence is to not detect some dependencies because
of missing directories in PKG_CONFIG_PATH.

The environment preparation is moved to a dedicate function,
and called for the default target (cc),
before testing the install output of the default build.

Signed-off-by: Thomas Monjalon 
---
 devtools/test-meson-builds.sh | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index 2eb9b23b0..08e83eb5c 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -37,11 +37,15 @@ fi
 default_path=$PATH
 default_pkgpath=$PKG_CONFIG_PATH
 
-reset_env ()
+load_env () # 
 {
+   targetcc=$1
export PATH=$default_path
export PKG_CONFIG_PATH=$default_pkgpath
unset DPDK_MESON_OPTIONS
+   command -v $targetcc >/dev/null 2>&1 || return 1
+   DPDK_TARGET=$($targetcc -v 2>&1 | sed -n 's,^Target: ,,p')
+   . $srcdir/devtools/load-devel-config
 }
 
 build () #   
@@ -52,10 +56,7 @@ build () #   
shift
# skip build if compiler not available
command -v ${CC##* } >/dev/null 2>&1 || return 0
-   command -v $targetcc >/dev/null 2>&1 || return 0
-   reset_env
-   DPDK_TARGET=$($targetcc -v 2>&1 | sed -n 's,^Target: ,,p')
-   . $srcdir/devtools/load-devel-config
+   load_env $targetcc || return 0
if [ ! -f "$builddir/build.ninja" ] ; then
options="--werror -Dexamples=all"
for option in $DPDK_MESON_OPTIONS ; do
@@ -128,6 +129,7 @@ build_path=build-x86-default
 export DESTDIR=$(pwd)/$build_path/install-root
 $ninja_cmd -C $build_path install
 
+load_env cc
 pc_file=$(find $DESTDIR -name libdpdk.pc)
 export PKG_CONFIG_PATH=$(dirname $pc_file):$PKG_CONFIG_PATH
 
-- 
2.23.0



[dpdk-dev] [PATCH] devtools: test nfb and AF_XDP build with make

2019-09-14 Thread Thomas Monjalon
The nfb PMD is disabled by default because of its dependency
on netcope-common package.
The variable DPDK_DEP_NFB was introduced but not used to notify
the dependency availability in the build test script.

The AF_XDP PMD is disabled by default because of its dependency
on libbpf on Linux.
An option was missing to notify the dependency availability
in the build test script.

Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
Cc: sta...@dpdk.org

Signed-off-by: Thomas Monjalon 
---
 devtools/test-build.sh | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/devtools/test-build.sh b/devtools/test-build.sh
index 3c029ce31..2bedbdb98 100755
--- a/devtools/test-build.sh
+++ b/devtools/test-build.sh
@@ -8,18 +8,19 @@ default_path=$PATH
 # - ARMV8_CRYPTO_LIB_PATH
 # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
 # - DPDK_DEP_ARCHIVE
+# - DPDK_DEP_BPF (y/[n])
 # - DPDK_DEP_CFLAGS
 # - DPDK_DEP_ELF (y/[n])
 # - DPDK_DEP_ISAL (y/[n])
 # - DPDK_DEP_JSON (y/[n])
 # - DPDK_DEP_LDFLAGS
 # - DPDK_DEP_MLX (y/[n])
+# - DPDK_DEP_NFB (y/[n])
 # - DPDK_DEP_NUMA ([y]/n)
 # - DPDK_DEP_PCAP (y/[n])
 # - DPDK_DEP_SSL (y/[n])
 # - DPDK_DEP_IPSEC_MB (y/[n])
 # - DPDK_DEP_SZE (y/[n])
-# - DPDK_DEP_NFB (y/[n])
 # - DPDK_DEP_ZLIB (y/[n])
 # - DPDK_MAKE_JOBS (int)
 # - DPDK_NOTIFY (notify-send)
@@ -101,12 +102,14 @@ reset_env ()
export PATH=$default_path
unset CROSS
unset DPDK_DEP_ARCHIVE
+   unset DPDK_DEP_BPF
unset DPDK_DEP_CFLAGS
unset DPDK_DEP_ELF
unset DPDK_DEP_ISAL
unset DPDK_DEP_JSON
unset DPDK_DEP_LDFLAGS
unset DPDK_DEP_MLX
+   unset DPDK_DEP_NFB
unset DPDK_DEP_NUMA
unset DPDK_DEP_PCAP
unset DPDK_DEP_SSL
@@ -154,10 +157,14 @@ config () #   
sed -ri="" 's,(BYPASS=)n,\1y,' $1/.config
test "$DPDK_DEP_ARCHIVE" != y || \
sed -ri=""   's,(RESOURCE_TAR=)n,\1y,' $1/.config
+   test "$DPDK_DEP_BPF" != y || \
+   sed -ri="" 's,(PMD_AF_XDP=)n,\1y,' $1/.config
test "$DPDK_DEP_ISAL" != y || \
sed -ri=""   's,(PMD_ISAL=)n,\1y,' $1/.config
test "$DPDK_DEP_MLX" != y || \
sed -ri=""   's,(MLX._PMD=)n,\1y,' $1/.config
+   test "$DPDK_DEP_NFB" != y || \
+   sed -ri=""'s,(NFB_PMD=)n,\1y,' $1/.config
test "$DPDK_DEP_SZE" != y || \
sed -ri=""   's,(PMD_SZEDATA2=)n,\1y,' $1/.config
test "$DPDK_DEP_ZLIB" != y || \
-- 
2.23.0



[dpdk-dev] [PATCH 0/2] use pkg-config to find Netcope dependencies

2019-09-14 Thread Thomas Monjalon
The libraries required for Netcope PMDs can be found in
https://www.netcope.com/en/company/community-support/dpdk-libsze2

These libraries are compatible with pkg-config, which is a better solution
than directly looking for libraries and includes.
These patches are using exclusively pkg-config with meson.


Thomas Monjalon (2):
  net/nfb: fix dependency check
  net/szedata2: fix dependency check

 drivers/net/nfb/meson.build  | 9 ++---
 drivers/net/szedata2/meson.build | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

-- 
2.23.0



[dpdk-dev] [PATCH 2/2] net/szedata2: fix dependency check

2019-09-14 Thread Thomas Monjalon
The library libsze2 provides a pkg-config file: libsze2.pc.
Looking for this .pc file - with dependency() - is preferred
than looking for the library - with cc.find_library().

If the library is not installed in a standard path,
it can be found thanks to PKG_CONFIG_PATH variable.
The previous solution required to use CFLAGS and LDFLAGS
environment variables.

Fixes: 508cfe6be9f1 ("net/szedata2: add to meson build")
Cc: sta...@dpdk.org

Signed-off-by: Thomas Monjalon 
---
 drivers/net/szedata2/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/szedata2/meson.build b/drivers/net/szedata2/meson.build
index 032b42518..b53fcbc59 100644
--- a/drivers/net/szedata2/meson.build
+++ b/drivers/net/szedata2/meson.build
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
-dep = cc.find_library('sze2', required: false)
+dep = dependency('libsze2', required: false)
 build = dep.found()
 reason = 'missing dependency, "libsze2"'
 ext_deps += dep
-- 
2.23.0



[dpdk-dev] [PATCH 1/2] net/nfb: fix dependency check

2019-09-14 Thread Thomas Monjalon
The library libnfb is part of netcope-common which provides
a pkg-config file: netcope-common.pc.
Looking for this .pc file - with dependency() - is preferred
than looking for the library - with cc.find_library().

If the library is not installed in a standard path,
it can be found thanks to PKG_CONFIG_PATH variable.
The previous solution required to use CFLAGS and LDFLAGS
environment variables.

Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
Cc: sta...@dpdk.org

Signed-off-by: Thomas Monjalon 
---
 drivers/net/nfb/meson.build | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/nfb/meson.build b/drivers/net/nfb/meson.build
index 4502c3f76..d53e8eca7 100644
--- a/drivers/net/nfb/meson.build
+++ b/drivers/net/nfb/meson.build
@@ -3,14 +3,9 @@
 # Copyright(c) 2019 Netcope Technologies, a.s. 
 # All rights reserved.
 
-dep = cc.find_library('nfb', required: false)
+dep = dependency('netcope-common', required: false)
 reason = 'missing dependency, "libnfb"'
-
-build = dep.found() and cc.has_header('nfb/nfb.h', dependencies: dep)
-
-nc = dependency('netcope-common', required: false)
-
+build = dep.found()
 ext_deps += dep
-ext_deps += nc
 
 sources = files('nfb_rx.c', 'nfb_tx.c', 'nfb_stats.c', 'nfb_ethdev.c', 
'nfb_rxmode.c')
-- 
2.23.0



Re: [dpdk-dev] [RFC 19.11 v2 1/3] ethdev: hide key ethdev structures from public API

2019-09-14 Thread Jerin Jacob
On Mon, Sep 9, 2019 at 3:54 PM Ferruh Yigit  wrote:
>
> On 9/9/2019 11:02 AM, Zapolski, MarcinX A wrote:
> >> -Original Message-
> >> From: Yigit, Ferruh
> >> Sent: Monday, September 9, 2019 12:00 PM
> >> To: Zapolski, MarcinX A ; dev@dpdk.org
> >> Subject: Re: [dpdk-dev] [RFC 19.11 v2 1/3] ethdev: hide key ethdev
> >> structures from public API
> >>
> >> On 9/9/2019 9:07 AM, Zapolski, MarcinX A wrote:
>  -Original Message-
>  From: Yigit, Ferruh
>  Sent: Friday, September 6, 2019 4:38 PM
>  To: Zapolski, MarcinX A ; dev@dpdk.org
>  Subject: Re: [dpdk-dev] [RFC 19.11 v2 1/3] ethdev: hide key ethdev
>  structures from public API
> 
>  On 9/6/2019 2:18 PM, Marcin Zapolski wrote:
> > Split rte_eth_dev structure to two parts: head that is available for
> > user applications, and rest which is DPDK internal.
> > Make an array of pointers to rte_eth_dev structures available for
> > user applications.
> >
> > Signed-off-by: Marcin Zapolski 
> 
>  <...>
> 
> > diff --git a/lib/librte_bitratestats/rte_bitrate.c
> > b/lib/librte_bitratestats/rte_bitrate.c
> > index 639e47547..82d469514 100644
> > --- a/lib/librte_bitratestats/rte_bitrate.c
> > +++ b/lib/librte_bitratestats/rte_bitrate.c
> > @@ -3,7 +3,7 @@
> >   */
> >
> >  #include 
> > -#include 
> > +#include 
> 
>  This is in the library, not sure if libraries should include the
>  header file for the drivers, can you please explain why this change is
> >> needed?
> 
> >>> It is needed to make rte_eth_dev structure available. But yes, I agree 
> >>> that
> >> it will be more appropriate to include rte_ethdev.h and rte_ethdev_core.h
> >> separately. I probably wanted less includes, silly me.
>  <...>
> 
> > @@ -6,6 +6,7 @@
> >  #define _RTE_ETHDEV_PROFILE_H_
> >
> >  #include "rte_ethdev.h"
> > +#include "rte_ethdev_core.h"
> >
> >  /**
> >   * Initialization of the Ethernet device profiling.
> > diff --git a/lib/librte_ethdev/rte_ethdev.c
> > b/lib/librte_ethdev/rte_ethdev.c index 17d183e1f..5c6cc640a 100644
> > --- a/lib/librte_ethdev/rte_ethdev.c
> > +++ b/lib/librte_ethdev/rte_ethdev.c
> > @@ -40,6 +40,7 @@
> >
> >  #include "rte_ether.h"
> >  #include "rte_ethdev.h"
> > +#include "rte_ethdev_core.h"
> >  #include "rte_ethdev_driver.h"
> >  #include "ethdev_profile.h"
> >  #include "ethdev_private.h"
> 
>  I was hoping "rte_ethdev_core.h" can be removed completely by
>  distributing its content to "ethdev_private.h", "rte_ethdev_driver.h"
>  and perhaps even to "rte_ethdev.h".
> 
>  Can you please explain what prevents removing "rte_ethdev_core.h"?
> >>> I could rename it to rte_ethdev_private. There is just rte_eth_dev and
> >> rte_eth_dev_data left in it.
> >>>
> >>
> >> I think drivers access to both 'rte_eth_dev' and 'rte_eth_dev_data' so 
> >> can't
> >> move them to 'ethdev_private.h' why not move it to 'rte_ethdev_driver.h'?
> >
> > Because the libraries use them as well.
> >
>
> These are 'librte_ethdev' library internal data, I think other libraries
> shouldn't access them directly.
>
> As far as I can see,
> librte_eventdev  => rte_eth_dev_data
> librte_eventdev  => rte_eth_dev
> librte_telemetry => rte_eth_dev
>
> Can you see any other library accessing 'rte_eth_dev' and 'rte_eth_dev_data' ?
>
>
> I am not sure about 'eventdev', specially because of the Rx/Tx adapters of it,
> perhaps they can include the "rte_ethdev_driver.h", cc'ed Jerin.

Yes.

Overall this patch theme looks good to me. I will wait for v3 to
change PMDs I maintains.

My only comment is, We should make rte_ethdev_driver.h as private
i.e it should not be included by applications.

Currently. On dpdk install, the private header file is copied to prefix

ie

make install T=x86_64-native-linux-gcc DESTDIR=install

[master][dpdk.org] $ ls install/include/dpdk/rte_ethdev_driver.h
install/include/dpdk/rte_ethdev_driver.h

The internal libraries can access the header file through the
following scheme without exposing it as public.

CFLAGS += -I$(RTE_SDK)/lib/librte_ethdev/

in .c file

#include "ethdev_driver.h"


[dpdk-dev] [PATCH v3 02/13] net/failsafe: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across net/failsafe according to new return type.

Try to keep promiscuous mode consistent across all active
devices in the case of failure.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
Acked-by: Gaetan Rivet 
---
 drivers/net/failsafe/failsafe_ether.c |  8 +++--
 drivers/net/failsafe/failsafe_ops.c   | 44 ---
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/drivers/net/failsafe/failsafe_ether.c 
b/drivers/net/failsafe/failsafe_ether.c
index 504c76edb..bd38f1c1e 100644
--- a/drivers/net/failsafe/failsafe_ether.c
+++ b/drivers/net/failsafe/failsafe_ether.c
@@ -126,9 +126,13 @@ fs_eth_dev_conf_apply(struct rte_eth_dev *dev,
if (dev->data->promiscuous != edev->data->promiscuous) {
DEBUG("Configuring promiscuous");
if (dev->data->promiscuous)
-   rte_eth_promiscuous_enable(PORT_ID(sdev));
+   ret = rte_eth_promiscuous_enable(PORT_ID(sdev));
else
-   rte_eth_promiscuous_disable(PORT_ID(sdev));
+   ret = rte_eth_promiscuous_disable(PORT_ID(sdev));
+   if (ret != 0) {
+   ERROR("Failed to apply promiscuous mode");
+   return ret;
+   }
} else {
DEBUG("promiscuous already set");
}
diff --git a/drivers/net/failsafe/failsafe_ops.c 
b/drivers/net/failsafe/failsafe_ops.c
index 2683b8fe5..af2c216f3 100644
--- a/drivers/net/failsafe/failsafe_ops.c
+++ b/drivers/net/failsafe/failsafe_ops.c
@@ -659,10 +659,28 @@ fs_promiscuous_enable(struct rte_eth_dev *dev)
 {
struct sub_device *sdev;
uint8_t i;
+   int ret = 0;
 
fs_lock(dev, 0);
-   FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
-   rte_eth_promiscuous_enable(PORT_ID(sdev));
+   FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+   ret = rte_eth_promiscuous_enable(PORT_ID(sdev));
+   ret = fs_err(sdev, ret);
+   if (ret != 0) {
+   ERROR("Promiscuous mode enable failed for subdevice %d",
+   PORT_ID(sdev));
+   break;
+   }
+   }
+   if (ret != 0) {
+   /* Rollback in the case of failure */
+   FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+   ret = rte_eth_promiscuous_disable(PORT_ID(sdev));
+   ret = fs_err(sdev, ret);
+   if (ret != 0)
+   ERROR("Promiscuous mode disable during rollback 
failed for subdevice %d",
+   PORT_ID(sdev));
+   }
+   }
fs_unlock(dev, 0);
 }
 
@@ -671,10 +689,28 @@ fs_promiscuous_disable(struct rte_eth_dev *dev)
 {
struct sub_device *sdev;
uint8_t i;
+   int ret = 0;
 
fs_lock(dev, 0);
-   FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE)
-   rte_eth_promiscuous_disable(PORT_ID(sdev));
+   FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+   ret = rte_eth_promiscuous_disable(PORT_ID(sdev));
+   ret = fs_err(sdev, ret);
+   if (ret != 0) {
+   ERROR("Promiscuous mode disable failed for subdevice 
%d",
+   PORT_ID(sdev));
+   break;
+   }
+   }
+   if (ret != 0) {
+   /* Rollback in the case of failure */
+   FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
+   ret = rte_eth_promiscuous_enable(PORT_ID(sdev));
+   ret = fs_err(sdev, ret);
+   if (ret != 0)
+   ERROR("Promiscuous mode enable during rollback 
failed for subdevice %d",
+   PORT_ID(sdev));
+   }
+   }
fs_unlock(dev, 0);
 }
 
-- 
2.17.1



[dpdk-dev] [PATCH v3 01/13] ethdev: change promiscuous mode controllers to return errors

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

Change rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable()
return value from void to int and return negative errno values
in case of error conditions.
Modify usage of these functions across the ethdev according
to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 doc/guides/rel_notes/deprecation.rst|  1 -
 doc/guides/rel_notes/release_19_11.rst  |  4 ++
 doc/guides/sample_app_ug/flow_classify.rst  |  6 ++-
 doc/guides/sample_app_ug/flow_filtering.rst | 15 +-
 doc/guides/sample_app_ug/rxtx_callbacks.rst |  5 +-
 doc/guides/sample_app_ug/skeleton.rst   |  6 ++-
 lib/librte_ethdev/rte_ethdev.c  | 52 -
 lib/librte_ethdev/rte_ethdev.h  | 14 +-
 8 files changed, 80 insertions(+), 23 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index cbb4c34ef..b2e0a1fc7 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -88,7 +88,6 @@ Deprecation Notices
   negative errno values to indicate various error conditions (e.g.
   invalid port ID, unsupported operation, failed operation):
 
-  - ``rte_eth_promiscuous_enable`` and ``rte_eth_promiscuous_disable``
   - ``rte_eth_allmulticast_enable`` and ``rte_eth_allmulticast_disable``
   - ``rte_eth_link_get`` and ``rte_eth_link_get_nowait``
   - ``rte_eth_dev_stop``
diff --git a/doc/guides/rel_notes/release_19_11.rst 
b/doc/guides/rel_notes/release_19_11.rst
index c8d97f16e..90c03cb8f 100644
--- a/doc/guides/rel_notes/release_19_11.rst
+++ b/doc/guides/rel_notes/release_19_11.rst
@@ -97,6 +97,10 @@ API Changes
 * ethdev: changed ``rte_eth_dev_infos_get`` return value from ``void`` to
   ``int`` to provide a way to report various error conditions.
 
+* ethdev: changed ``rte_eth_promiscuous_enable`` and
+  ``rte_eth_promiscuous_disable`` return value from ``void`` to ``int`` to
+  provide a way to report various error conditions.
+
 
 ABI Changes
 ---
diff --git a/doc/guides/sample_app_ug/flow_classify.rst 
b/doc/guides/sample_app_ug/flow_classify.rst
index 96a5c66d0..7c2b6dcf8 100644
--- a/doc/guides/sample_app_ug/flow_classify.rst
+++ b/doc/guides/sample_app_ug/flow_classify.rst
@@ -315,7 +315,9 @@ Forwarding application is shown below:
addr.addr_bytes[4], addr.addr_bytes[5]);
 
 /* Enable RX in promiscuous mode for the Ethernet device. */
-rte_eth_promiscuous_enable(port);
+retval = rte_eth_promiscuous_enable(port);
+if (retval != 0)
+return retval;
 
 return 0;
 }
@@ -343,7 +345,7 @@ Finally the RX port is set in promiscuous mode:
 
 .. code-block:: c
 
-rte_eth_promiscuous_enable(port);
+retval = rte_eth_promiscuous_enable(port);
 
 The Add Rules function
 ~~
diff --git a/doc/guides/sample_app_ug/flow_filtering.rst 
b/doc/guides/sample_app_ug/flow_filtering.rst
index 02fc67550..de3e4ab0b 100644
--- a/doc/guides/sample_app_ug/flow_filtering.rst
+++ b/doc/guides/sample_app_ug/flow_filtering.rst
@@ -193,7 +193,13 @@ application is shown below:
}
   }
 
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0) {
+   rte_exit(EXIT_FAILURE,
+   ":: cannot enable promiscuous mode: err=%d, 
port=%u\n",
+   ret, port_id);
+   }
+
ret = rte_eth_dev_start(port_id);
if (ret < 0) {
rte_exit(EXIT_FAILURE,
@@ -278,7 +284,12 @@ We are setting the RX port to promiscuous mode:
 
 .. code-block:: c
 
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0) {
+rte_exit(EXIT_FAILURE,
+ ":: cannot enable promiscuous mode: err=%d, port=%u\n",
+ ret, port_id);
+   }
 
 The last step is to start the port.
 
diff --git a/doc/guides/sample_app_ug/rxtx_callbacks.rst 
b/doc/guides/sample_app_ug/rxtx_callbacks.rst
index 32c120992..0a69ec71a 100644
--- a/doc/guides/sample_app_ug/rxtx_callbacks.rst
+++ b/doc/guides/sample_app_ug/rxtx_callbacks.rst
@@ -117,8 +117,9 @@ comments:
 return retval;
 
 /* Enable RX in promiscuous mode for the Ethernet device. */
-rte_eth_promiscuous_enable(port);
-
+retval = rte_eth_promiscuous_enable(port);
+if (retval != 0)
+return retval;
 
 /* Add the callbacks for RX and TX.*/
 rte_eth_add_rx_callback(port, 0, add_timestamps, NULL);
diff --git a/doc/guides/sample_app_ug/skeleton.rst 
b/doc/guides/sample_app_ug/skeleton.rst
index 59ca511d3..1d0a2760d 100644
--- a/doc/guides/sample_app_ug/skeleton.rst
+++ b/doc/guides/sample_app_ug/skeleton.rst
@@ -149,7 +149,9 @@ Forwarding application is shown below:
 return retval;
 
 /* Enable RX in promiscuous mode

[dpdk-dev] [PATCH v3 03/13] net/bonding: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across net/bonding according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 17 ++--
 drivers/net/bonding/rte_eth_bond_pmd.c| 34 +++
 2 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c 
b/drivers/net/bonding/rte_eth_bond_8023ad.c
index fbc69051a..7189a8458 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -913,6 +913,8 @@ bond_mode_8023ad_periodic_cb(void *arg)
 static int
 bond_mode_8023ad_register_lacp_mac(uint16_t slave_id)
 {
+   int ret;
+
rte_eth_allmulticast_enable(slave_id);
if (rte_eth_allmulticast_get(slave_id)) {
RTE_BOND_LOG(DEBUG, "forced allmulti for port %u",
@@ -922,7 +924,12 @@ bond_mode_8023ad_register_lacp_mac(uint16_t slave_id)
return 0;
}
 
-   rte_eth_promiscuous_enable(slave_id);
+   ret = rte_eth_promiscuous_enable(slave_id);
+   if (ret != 0) {
+   RTE_BOND_LOG(ERR,
+   "failed to enable promiscuous mode for port %u: %s",
+   slave_id, rte_strerror(-ret));
+   }
if (rte_eth_promiscuous_get(slave_id)) {
RTE_BOND_LOG(DEBUG, "forced promiscuous for port %u",
 slave_id);
@@ -937,6 +944,8 @@ bond_mode_8023ad_register_lacp_mac(uint16_t slave_id)
 static void
 bond_mode_8023ad_unregister_lacp_mac(uint16_t slave_id)
 {
+   int ret;
+
switch (bond_mode_8023ad_ports[slave_id].forced_rx_flags) {
case BOND_8023AD_FORCED_ALLMULTI:
RTE_BOND_LOG(DEBUG, "unset allmulti for port %u", slave_id);
@@ -945,7 +954,11 @@ bond_mode_8023ad_unregister_lacp_mac(uint16_t slave_id)
 
case BOND_8023AD_FORCED_PROMISC:
RTE_BOND_LOG(DEBUG, "unset promisc for port %u", slave_id);
-   rte_eth_promiscuous_disable(slave_id);
+   ret = rte_eth_promiscuous_disable(slave_id);
+   if (ret != 0)
+   RTE_BOND_LOG(ERR,
+   "failed to disable promiscuous mode for port 
%u: %s",
+   slave_id, rte_strerror(-ret));
break;
 
default:
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index a994c9abd..edf660db3 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2487,6 +2487,8 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev 
*eth_dev)
 {
struct bond_dev_private *internals = eth_dev->data->dev_private;
int i;
+   int ret = 0;
+   uint16_t port_id;
 
switch (internals->mode) {
/* Promiscuous mode is propagated to all slaves */
@@ -2495,9 +2497,13 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev 
*eth_dev)
case BONDING_MODE_BROADCAST:
case BONDING_MODE_8023AD:
for (i = 0; i < internals->slave_count; i++) {
-   uint16_t port_id = internals->slaves[i].port_id;
+   port_id = internals->slaves[i].port_id;
 
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0)
+   RTE_BOND_LOG(ERR,
+   "Failed to enable promiscuous mode for 
port %u: %s",
+   port_id, rte_strerror(-ret));
}
break;
/* Promiscuous mode is propagated only to primary slave */
@@ -2508,7 +2514,12 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev 
*eth_dev)
/* Do not touch promisc when there cannot be primary ports */
if (internals->slave_count == 0)
break;
-   rte_eth_promiscuous_enable(internals->current_primary_port);
+   port_id = internals->current_primary_port;
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0)
+   RTE_BOND_LOG(ERR,
+   "Failed to enable promiscuous mode for port %u: 
%s",
+   port_id, rte_strerror(-ret));
}
 }
 
@@ -2517,6 +2528,8 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
 {
struct bond_dev_private *internals = dev->data->dev_private;
int i;
+   int ret;
+   uint16_t port_id;
 
switch (internals->mode) {
/* Promiscuous mode is propagated to all slaves */
@@ -2525,13 +2538,17 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)
case BONDING_MODE_BROADCAST:
ca

[dpdk-dev] [PATCH v3 00/13] ethdev: change promiscuous mode functions to return status

2019-09-14 Thread Andrew Rybchenko
It is the second patch series to get rid of void returning functions
in ethdev in accordance with deprecation notice [1].

It should be applied on top of the first one [2] which is already
applied to dpdk-next-net, but not in main DPDK repo.
It could be applied separately, but few simple conflicts should
be resolved.

Functions which return void are bad since they do not provide explicit
information to the caller if everything is OK or not.
It is especially painful in the case of promiscuous mode since it is
not always supported, there are real cases when it fails to apply and
it affects traffic which is received by the port.

Driver maintainrs are encouraged to review the patch which changes
driver callbacks prototype. Changes are not always trivial when I tried
to provide real status of the operation. I used -EAGAIN when I failed
to choose better error code.

The following two drivers ignore status of internal functions and
definitely could be improved:

net/bnx2x: bnx2x_set_rx_mode() can report failure, but it is used in
other places and should be updated carefully.

net/igbvf: e1000_promisc_set_vf() provides return status, but it is
unclear how handle it properly.

[1] https://patches.dpdk.org/patch/56969/
[2] https://patches.dpdk.org/project/dpdk/list/?series=6391

v3:
 - list and describe return values of promiscuous mode enable/disalbe callbacks
 - improve net/failsafe logging in the case of rollback failure to
   distinguish operation and rollback failure cases
 - fix build issue in AF_XDP PMD
 - fix build issue in mlx4 PMD
 - do not use goto and return error directly in mlx5
 - return -E_RTE_SECONDARY in net/enic in the case of secondary process
 - fix examples/vm_power_manager build

v2:
 - minor style fix in app/testpmd
 - use fs_err() in net/failsafe in accordance with review from Gaetan
 - fix net/mvpp2 build
 - use eth_err() in ethdev


Andrew Rybchenko (2):
  ethdev: change promiscuous callbacks to return status
  ethdev: do nothing if promiscuous mode is applied again

Ivan Ilchenko (11):
  ethdev: change promiscuous mode controllers to return errors
  net/failsafe: check code of promiscuous mode switch
  net/bonding: check code of promiscuous mode switch
  app/pipeline: check code of promiscuous mode switch
  app/testpmd: check code of promiscuous mode switch
  app/eventdev: check code of promiscuous mode switch
  app/pdump: check code of promiscuous mode switch
  app/test: check code of promiscuous mode switch
  kni: check code of promiscuous mode switch
  test/bonding: check code of promiscuous mode switch
  examples: take promiscuous mode switch result into account

 app/pdump/main.c  |  8 +-
 app/test-eventdev/test_perf_common.c  |  7 +-
 app/test-eventdev/test_pipeline_common.c  |  7 +-
 app/test-pipeline/init.c  |  5 +-
 app/test-pmd/cmdline.c| 23 +++---
 app/test-pmd/testpmd.c| 14 +++-
 app/test-pmd/testpmd.h|  1 +
 app/test-pmd/util.c   | 16 
 app/test/test_event_eth_rx_adapter.c  |  4 +-
 app/test/test_event_eth_tx_adapter.c  |  4 +-
 app/test/test_kni.c   |  7 +-
 app/test/test_link_bonding.c  | 55 +++---
 app/test/test_link_bonding_mode4.c| 16 +++-
 app/test/test_pmd_perf.c  |  6 +-
 app/test/virtual_pmd.c| 12 ++-
 doc/guides/rel_notes/deprecation.rst  |  1 -
 doc/guides/rel_notes/release_19_11.rst|  4 +
 doc/guides/sample_app_ug/flow_classify.rst|  6 +-
 doc/guides/sample_app_ug/flow_filtering.rst   | 15 +++-
 doc/guides/sample_app_ug/rxtx_callbacks.rst   |  5 +-
 doc/guides/sample_app_ug/skeleton.rst |  6 +-
 drivers/net/af_packet/rte_eth_af_packet.c | 22 --
 drivers/net/af_xdp/rte_eth_af_xdp.c   | 22 --
 drivers/net/atlantic/atl_ethdev.c | 12 ++-
 drivers/net/avp/avp_ethdev.c  | 12 ++-
 drivers/net/axgbe/axgbe_ethdev.c  | 12 ++-
 drivers/net/bnx2x/bnx2x_ethdev.c  |  8 +-
 drivers/net/bnxt/bnxt_ethdev.c| 26 +--
 drivers/net/bonding/rte_eth_bond_8023ad.c | 17 -
 drivers/net/bonding/rte_eth_bond_pmd.c| 74 +++---
 drivers/net/cxgbe/cxgbe_ethdev.c  | 12 +--
 drivers/net/cxgbe/cxgbe_pfvf.h|  4 +-
 drivers/net/dpaa/dpaa_ethdev.c|  8 +-
 drivers/net/dpaa2/dpaa2_ethdev.c  | 12 ++-
 drivers/net/e1000/em_ethdev.c | 12 ++-
 drivers/net/e1000/igb_ethdev.c| 24 --
 drivers/net/enetc/enetc_ethdev.c  |  8 +-
 drivers/net/enic/enic.h   |  2 +-
 drivers/net/enic/enic_ethdev.c| 22 --
 drivers/net/enic/enic_main.c  |  4 +-
 drivers/net/failsafe/failsafe_ether.c |  8 +-
 drivers/net/failsafe/failsafe_ops.c   

[dpdk-dev] [PATCH v3 05/13] ethdev: do nothing if promiscuous mode is applied again

2019-09-14 Thread Andrew Rybchenko
Since driver callbacks return status code now, there is no necessity
to enable or disable promiscuous mode once again if it is already
successfully enabled or disabled.

Configuration restore at startup tries to ensure that configured
promiscuous mode is applied and start will return error if it fails.

Also it avoids theoretical cases when already configured promiscuous
mode is applied once again and fails. In this cases it is unclear
which value should be reported on get (configured or opposite).

Signed-off-by: Andrew Rybchenko 
---
 lib/librte_ethdev/rte_ethdev.c | 40 --
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index f2e6b4c83..98fe533c5 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1391,16 +1391,22 @@ rte_eth_dev_config_restore(struct rte_eth_dev *dev,
rte_eth_dev_mac_restore(dev, dev_info);
 
/* replay promiscuous configuration */
-   if (rte_eth_promiscuous_get(port_id) == 1) {
-   ret = rte_eth_promiscuous_enable(port_id);
+   /*
+* use callbacks directly since we don't need port_id check and
+* would like to bypass the same value set
+*/
+   if (rte_eth_promiscuous_get(port_id) == 1 &&
+   *dev->dev_ops->promiscuous_enable != NULL) {
+   ret = (*dev->dev_ops->promiscuous_enable)(dev);
if (ret != 0 && ret != -ENOTSUP) {
RTE_ETHDEV_LOG(ERR,
"Failed to enable promiscuous mode for device 
(port %u): %s\n",
port_id, rte_strerror(-ret));
return ret;
}
-   } else if (rte_eth_promiscuous_get(port_id) == 0) {
-   ret = rte_eth_promiscuous_disable(port_id);
+   } else if (rte_eth_promiscuous_get(port_id) == 0 &&
+  *dev->dev_ops->promiscuous_disable != NULL) {
+   ret = (*dev->dev_ops->promiscuous_disable)(dev);
if (ret != 0 && ret != -ENOTSUP) {
RTE_ETHDEV_LOG(ERR,
"Failed to disable promiscuous mode for device 
(port %u): %s\n",
@@ -1892,16 +1898,17 @@ int
 rte_eth_promiscuous_enable(uint16_t port_id)
 {
struct rte_eth_dev *dev;
-   uint8_t old_promiscuous;
-   int diag;
+   int diag = 0;
 
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->promiscuous_enable, -ENOTSUP);
-   old_promiscuous = dev->data->promiscuous;
-   diag = (*dev->dev_ops->promiscuous_enable)(dev);
-   dev->data->promiscuous = (diag == 0) ? 1 : old_promiscuous;
+
+   if (dev->data->promiscuous == 0) {
+   diag = (*dev->dev_ops->promiscuous_enable)(dev);
+   dev->data->promiscuous = (diag == 0) ? 1 : 0;
+   }
 
return eth_err(port_id, diag);
 }
@@ -1910,18 +1917,19 @@ int
 rte_eth_promiscuous_disable(uint16_t port_id)
 {
struct rte_eth_dev *dev;
-   uint8_t old_promiscuous;
-   int diag;
+   int diag = 0;
 
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->promiscuous_disable, -ENOTSUP);
-   old_promiscuous = dev->data->promiscuous;
-   dev->data->promiscuous = 0;
-   diag = (*dev->dev_ops->promiscuous_disable)(dev);
-   if (diag != 0)
-   dev->data->promiscuous = old_promiscuous;
+
+   if (dev->data->promiscuous == 1) {
+   dev->data->promiscuous = 0;
+   diag = (*dev->dev_ops->promiscuous_disable)(dev);
+   if (diag != 0)
+   dev->data->promiscuous = 1;
+   }
 
return eth_err(port_id, diag);
 }
-- 
2.17.1



[dpdk-dev] [PATCH v3 08/13] app/eventdev: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across app/eventdev
according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/test-eventdev/test_perf_common.c | 7 ++-
 app/test-eventdev/test_pipeline_common.c | 7 ++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/test-eventdev/test_perf_common.c 
b/app/test-eventdev/test_perf_common.c
index e75582b1a..e24519179 100644
--- a/app/test-eventdev/test_perf_common.c
+++ b/app/test-eventdev/test_perf_common.c
@@ -726,7 +726,12 @@ perf_ethdev_setup(struct evt_test *test, struct 
evt_options *opt)
return -EINVAL;
}
 
-   rte_eth_promiscuous_enable(i);
+   ret = rte_eth_promiscuous_enable(i);
+   if (ret != 0) {
+   evt_err("Failed to enable promiscuous mode for eth port 
[%d]: %s",
+   i, rte_strerror(-ret));
+   return ret;
+   }
}
 
return 0;
diff --git a/app/test-eventdev/test_pipeline_common.c 
b/app/test-eventdev/test_pipeline_common.c
index ef8ae28c9..616651681 100644
--- a/app/test-eventdev/test_pipeline_common.c
+++ b/app/test-eventdev/test_pipeline_common.c
@@ -233,7 +233,12 @@ pipeline_ethdev_setup(struct evt_test *test, struct 
evt_options *opt)
return -EINVAL;
}
 
-   rte_eth_promiscuous_enable(i);
+   ret = rte_eth_promiscuous_enable(i);
+   if (ret != 0) {
+   evt_err("Failed to enable promiscuous mode for eth port 
[%d]: %s",
+   i, rte_strerror(-ret));
+   return ret;
+   }
}
 
return 0;
-- 
2.17.1



[dpdk-dev] [PATCH v3 06/13] app/pipeline: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across app/pipeline
according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/test-pipeline/init.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c
index b75688a87..871d9fa2d 100644
--- a/app/test-pipeline/init.c
+++ b/app/test-pipeline/init.c
@@ -200,7 +200,10 @@ app_init_ports(void)
if (ret < 0)
rte_panic("Cannot init NIC port %u (%d)\n", port, ret);
 
-   rte_eth_promiscuous_enable(port);
+   ret = rte_eth_promiscuous_enable(port);
+   if (ret != 0)
+   rte_panic("Cannot enable promiscuous mode for port %u: 
%s\n",
+   port, rte_strerror(-ret));
 
/* Init RX queues */
ret = rte_eth_rx_queue_setup(
-- 
2.17.1



[dpdk-dev] [PATCH v3 07/13] app/testpmd: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across app/testpmd
according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/test-pmd/cmdline.c | 23 ++-
 app/test-pmd/testpmd.c | 14 +++---
 app/test-pmd/testpmd.h |  1 +
 app/test-pmd/util.c| 16 
 4 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b1be6b4c8..6b9444f42 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6082,6 +6082,7 @@ static void cmd_create_bonded_device_parsed(void 
*parsed_result,
struct cmd_create_bonded_device_result *res = parsed_result;
char ethdev_name[RTE_ETH_NAME_MAX_LEN];
int port_id;
+   int ret;
 
if (test_done == 0) {
printf("Please stop forwarding first\n");
@@ -6103,7 +6104,11 @@ static void cmd_create_bonded_device_parsed(void 
*parsed_result,
/* Update number of ports */
nb_ports = rte_eth_dev_count_avail();
reconfig(port_id, res->socket);
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0)
+   printf("Failed to enable promiscuous mode for port %u: 
%s - ignore\n",
+   port_id, rte_strerror(-ret));
+
ports[port_id].need_setup = 0;
ports[port_id].port_status = RTE_PORT_STOPPED;
}
@@ -6525,18 +6530,10 @@ static void cmd_set_promisc_mode_parsed(void 
*parsed_result,
 
/* all ports */
if (allports) {
-   RTE_ETH_FOREACH_DEV(i) {
-   if (enable)
-   rte_eth_promiscuous_enable(i);
-   else
-   rte_eth_promiscuous_disable(i);
-   }
-   }
-   else {
-   if (enable)
-   rte_eth_promiscuous_enable(res->port_num);
-   else
-   rte_eth_promiscuous_disable(res->port_num);
+   RTE_ETH_FOREACH_DEV(i)
+   eth_set_promisc_mode(i, enable);
+   } else {
+   eth_set_promisc_mode(res->port_num, enable);
}
 }
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index de91e1b72..2a57978fd 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2433,13 +2433,17 @@ static void
 setup_attached_port(portid_t pi)
 {
unsigned int socket_id;
+   int ret;
 
socket_id = (unsigned)rte_eth_dev_socket_id(pi);
/* if socket_id is invalid, set to the first available socket. */
if (check_socket_id(socket_id) < 0)
socket_id = socket_ids[0];
reconfig(pi, socket_id);
-   rte_eth_promiscuous_enable(pi);
+   ret = rte_eth_promiscuous_enable(pi);
+   if (ret != 0)
+   printf("Error during enabling promiscuous mode for port %u: %s 
- ignore\n",
+   pi, rte_strerror(-ret));
 
ports_ids[nb_ports++] = pi;
fwd_ports_ids[nb_fwd_ports++] = pi;
@@ -3373,8 +3377,12 @@ main(int argc, char** argv)
rte_exit(EXIT_FAILURE, "Start ports failed\n");
 
/* set all ports to promiscuous mode by default */
-   RTE_ETH_FOREACH_DEV(port_id)
-   rte_eth_promiscuous_enable(port_id);
+   RTE_ETH_FOREACH_DEV(port_id) {
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0)
+   printf("Error during enabling promiscuous mode for port 
%u: %s - ignore\n",
+   port_id, rte_strerror(-ret));
+   }
 
/* Init metrics library */
rte_metrics_init(rte_socket_id());
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index d73955da1..ab9306292 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -824,6 +824,7 @@ void show_gro(portid_t port_id);
 void setup_gso(const char *mode, portid_t port_id);
 int eth_dev_info_get_print_err(uint16_t port_id,
struct rte_eth_dev_info *dev_info);
+void eth_set_promisc_mode(uint16_t port_id, int enable);
 
 
 /* Functions to manage the set of filtered Multicast MAC addresses */
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 009d22676..462675134 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -245,3 +245,19 @@ eth_dev_info_get_print_err(uint16_t port_id,
 
return ret;
 }
+
+void
+eth_set_promisc_mode(uint16_t port, int enable)
+{
+   int ret;
+
+   if (enable)
+   ret = rte_eth_promiscuous_enable(port);
+   else
+   ret = rte_eth_promiscuous_disable(port);
+
+   if (ret != 0)
+   printf("Error during %s promiscuous mode for port 

[dpdk-dev] [PATCH v3 11/13] kni: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so modify usage of these
functions across lib/librte_kni according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/test/test_kni.c  |  7 ++-
 examples/kni/main.c  |  9 +++--
 lib/librte_kni/rte_kni.c | 14 +++---
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/app/test/test_kni.c b/app/test/test_kni.c
index 2c333748d..e47ab36e0 100644
--- a/app/test/test_kni.c
+++ b/app/test/test_kni.c
@@ -601,7 +601,12 @@ test_kni(void)
printf("fail to start port %d\n", port_id);
return -1;
}
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0) {
+   printf("fail to enable promiscuous mode for port %d: %s\n",
+   port_id, rte_strerror(-ret));
+   return -1;
+   }
 
/* basic test of kni processing */
fd = fopen(KNI_MODULE_PARAM_LO, "r");
diff --git a/examples/kni/main.c b/examples/kni/main.c
index e43f17447..1069fd08b 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -636,8 +636,13 @@ init_port(uint16_t port)
rte_exit(EXIT_FAILURE, "Could not start port%u (%d)\n",
(unsigned)port, ret);
 
-   if (promiscuous_on)
-   rte_eth_promiscuous_enable(port);
+   if (promiscuous_on) {
+   ret = rte_eth_promiscuous_enable(port);
+   if (ret != 0)
+   rte_exit(EXIT_FAILURE,
+   "Could not enable promiscuous mode for port%u: 
%s\n",
+   port, rte_strerror(-ret));
+   }
 }
 
 /* Check the link status of all ports in up to 9s, and print them finally */
diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 4b51fb4fe..04806ebb4 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -472,6 +472,8 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
 static int
 kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
 {
+   int ret;
+
if (!rte_eth_dev_is_valid_port(port_id)) {
RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
return -EINVAL;
@@ -481,11 +483,17 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on)
port_id, to_on);
 
if (to_on)
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
else
-   rte_eth_promiscuous_disable(port_id);
+   ret = rte_eth_promiscuous_disable(port_id);
 
-   return 0;
+   if (ret != 0)
+   RTE_LOG(ERR, KNI,
+   "Failed to %s promiscuous mode for port %u: %s\n",
+   to_on ? "enable" : "disable", port_id,
+   rte_strerror(-ret));
+
+   return ret;
 }
 
 int
-- 
2.17.1



[dpdk-dev] [PATCH v3 12/13] test/bonding: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across test/bonding
according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/test/test_link_bonding.c   | 55 --
 app/test/test_link_bonding_mode4.c | 16 +++--
 2 files changed, 58 insertions(+), 13 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 938fafca3..cbbbc98a1 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -1760,13 +1760,17 @@ static int
 test_roundrobin_verify_promiscuous_enable_disable(void)
 {
int i, promiscuous_en;
+   int ret;
 
/* Initialize bonded device with 4 slaves in round robin mode */
TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
BONDING_MODE_ROUND_ROBIN, 0, 4, 1),
"Failed to initialize bonded device with slaves");
 
-   rte_eth_promiscuous_enable(test_params->bonded_port_id);
+   ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+   TEST_ASSERT_SUCCESS(ret,
+   "Failed to enable promiscuous mode for port %d: %s",
+   test_params->bonded_port_id, rte_strerror(-ret));
 
promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
TEST_ASSERT_EQUAL(promiscuous_en, 1,
@@ -1781,7 +1785,10 @@ test_roundrobin_verify_promiscuous_enable_disable(void)
test_params->slave_port_ids[i]);
}
 
-   rte_eth_promiscuous_disable(test_params->bonded_port_id);
+   ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+   TEST_ASSERT_SUCCESS(ret,
+   "Failed to disable promiscuous mode for port %d: %s",
+   test_params->bonded_port_id, rte_strerror(-ret));
 
promiscuous_en = rte_eth_promiscuous_get(test_params->bonded_port_id);
TEST_ASSERT_EQUAL(promiscuous_en, 0,
@@ -2200,6 +2207,7 @@ static int
 test_activebackup_verify_promiscuous_enable_disable(void)
 {
int i, primary_port, promiscuous_en;
+   int ret;
 
/* Initialize bonded device with 4 slaves in round robin mode */
TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
@@ -2211,7 +2219,10 @@ test_activebackup_verify_promiscuous_enable_disable(void)
"failed to get primary slave for bonded port (%d)",
test_params->bonded_port_id);
 
-   rte_eth_promiscuous_enable(test_params->bonded_port_id);
+   ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+   TEST_ASSERT_SUCCESS(ret,
+   "Failed to enable promiscuous mode for port %d: %s",
+   test_params->bonded_port_id, rte_strerror(-ret));
 
TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 
1,
"Port (%d) promiscuous mode not enabled",
@@ -2232,7 +2243,10 @@ test_activebackup_verify_promiscuous_enable_disable(void)
 
}
 
-   rte_eth_promiscuous_disable(test_params->bonded_port_id);
+   ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+   TEST_ASSERT_SUCCESS(ret,
+   "Failed to disable promiscuous mode for port %d: %s",
+   test_params->bonded_port_id, rte_strerror(-ret));
 
TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 
0,
"Port (%d) promiscuous mode not disabled\n",
@@ -3110,13 +3124,17 @@ static int
 test_balance_verify_promiscuous_enable_disable(void)
 {
int i;
+   int ret;
 
/* Initialize bonded device with 4 slaves in round robin mode */
TEST_ASSERT_SUCCESS(initialize_bonded_device_with_slaves(
BONDING_MODE_BALANCE, 0, 4, 1),
"Failed to initialise bonded device");
 
-   rte_eth_promiscuous_enable(test_params->bonded_port_id);
+   ret = rte_eth_promiscuous_enable(test_params->bonded_port_id);
+   TEST_ASSERT_SUCCESS(ret,
+   "Failed to enable promiscuous mode for port %d: %s",
+   test_params->bonded_port_id, rte_strerror(-ret));
 
TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 
1,
"Port (%d) promiscuous mode not enabled",
@@ -3129,7 +3147,10 @@ test_balance_verify_promiscuous_enable_disable(void)
test_params->slave_port_ids[i]);
}
 
-   rte_eth_promiscuous_disable(test_params->bonded_port_id);
+   ret = rte_eth_promiscuous_disable(test_params->bonded_port_id);
+   TEST_ASSERT_SUCCESS(ret,
+   "Failed to disable promiscuous mode for port %d: %s",
+   test_params->bonded_port_id, rte_strerror(-ret));
 
TEST_ASSERT_EQUAL(rte_eth_promiscuous_get(test_params->bonded_port_id), 
0,
  

[dpdk-dev] [PATCH v3 09/13] app/pdump: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across app/pdump
according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/pdump/main.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index c1b901279..9d6be8ed1 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -614,7 +614,13 @@ configure_vdev(uint16_t port_id)
addr.addr_bytes[2], addr.addr_bytes[3],
addr.addr_bytes[4], addr.addr_bytes[5]);
 
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0) {
+   rte_exit(EXIT_FAILURE,
+"promiscuous mode enable failed: %s\n",
+rte_strerror(-ret));
+   return ret;
+   }
 
return 0;
 }
-- 
2.17.1



[dpdk-dev] [PATCH v3 10/13] app/test: check code of promiscuous mode switch

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across app/test/test_event_eth_rx_adapter.c
and app/test/test_event_eth_tx_adapter.c according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 app/test/test_event_eth_rx_adapter.c | 4 +++-
 app/test/test_event_eth_tx_adapter.c | 4 +++-
 app/test/test_pmd_perf.c | 6 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/app/test/test_event_eth_rx_adapter.c 
b/app/test/test_event_eth_rx_adapter.c
index 950bc67c2..6254fcd33 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -90,7 +90,9 @@ port_init_common(uint16_t port, const struct rte_eth_conf 
*port_conf,
addr.addr_bytes[4], addr.addr_bytes[5]);
 
/* Enable RX in promiscuous mode for the Ethernet device. */
-   rte_eth_promiscuous_enable(port);
+   retval = rte_eth_promiscuous_enable(port);
+   if (retval != 0)
+   return retval;
 
return 0;
 }
diff --git a/app/test/test_event_eth_tx_adapter.c 
b/app/test/test_event_eth_tx_adapter.c
index 208d20c53..73f6afea2 100644
--- a/app/test/test_event_eth_tx_adapter.c
+++ b/app/test/test_event_eth_tx_adapter.c
@@ -94,7 +94,9 @@ port_init_common(uint8_t port, const struct rte_eth_conf 
*port_conf,
addr.addr_bytes[4], addr.addr_bytes[5]);
 
/* Enable RX in promiscuous mode for the Ethernet device. */
-   rte_eth_promiscuous_enable(port);
+   retval = rte_eth_promiscuous_enable(port);
+   if (retval != 0)
+   return retval;
 
return 0;
 }
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 4f9fc0d87..85ef11899 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -745,7 +745,11 @@ test_pmd_perf(void)
ret, portid);
 
/* always eanble promiscuous */
-   rte_eth_promiscuous_enable(portid);
+   ret = rte_eth_promiscuous_enable(portid);
+   if (ret != 0)
+   rte_exit(EXIT_FAILURE,
+"rte_eth_promiscuous_enable: err=%s, 
port=%d\n",
+rte_strerror(-ret), portid);
 
lcore_conf[slave_id].portlist[num++] = portid;
lcore_conf[slave_id].nb_ports++;
-- 
2.17.1



[dpdk-dev] [PATCH v3 13/13] examples: take promiscuous mode switch result into account

2019-09-14 Thread Andrew Rybchenko
From: Ivan Ilchenko 

rte_eth_promiscuous_enable()/rte_eth_promiscuous_disable() return
value was changed from void to int, so this patch modify usage
of these functions across examples according to new return type.

Signed-off-by: Ivan Ilchenko 
Signed-off-by: Andrew Rybchenko 
---
 examples/bbdev_app/main.c|  7 ++-
 examples/bond/main.c |  8 +++-
 examples/distributor/main.c  |  4 +++-
 examples/eventdev_pipeline/main.c|  4 +++-
 examples/exception_path/main.c   |  5 -
 examples/flow_classify/flow_classify.c   |  4 +++-
 examples/flow_filtering/main.c   |  7 ++-
 examples/ip_fragmentation/main.c |  6 +-
 examples/ip_pipeline/link.c  |  7 +--
 examples/ip_reassembly/main.c|  6 +-
 examples/ipsec-secgw/ipsec-secgw.c   |  9 +++--
 examples/l2fwd-cat/l2fwd-cat.c   |  4 +++-
 examples/l2fwd-crypto/main.c |  7 ++-
 examples/l2fwd-jobstats/main.c   |  9 -
 examples/l2fwd-keepalive/main.c  |  6 +-
 examples/l2fwd/main.c|  6 +-
 examples/l3fwd-acl/main.c|  9 +++--
 examples/l3fwd-power/main.c  |  9 +++--
 examples/l3fwd/main.c|  9 +++--
 examples/link_status_interrupt/main.c|  6 +-
 examples/load_balancer/init.c|  6 +-
 .../multi_process/client_server_mp/mp_server/init.c  |  4 +++-
 examples/multi_process/symmetric_mp/main.c   |  4 +++-
 examples/netmap_compat/bridge/bridge.c   |  6 +-
 examples/packet_ordering/main.c  |  4 +++-
 examples/performance-thread/l3fwd-thread/main.c  |  9 +++--
 examples/ptpclient/ptpclient.c   |  7 ++-
 examples/qos_meter/main.c| 12 ++--
 examples/qos_sched/init.c|  6 +-
 examples/quota_watermark/qw/init.c   |  6 +-
 examples/rxtx_callbacks/main.c   |  5 -
 examples/server_node_efd/server/init.c   |  4 +++-
 examples/skeleton/basicfwd.c |  4 +++-
 examples/vhost/main.c| 11 +--
 examples/vm_power_manager/main.c |  4 +++-
 35 files changed, 181 insertions(+), 43 deletions(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 9acf666dc..3d36629a1 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -477,7 +477,12 @@ initialize_ports(struct app_config_params *app_params,
}
}
 
-   rte_eth_promiscuous_enable(port_id);
+   ret = rte_eth_promiscuous_enable(port_id);
+   if (ret != 0) {
+   printf("Cannot enable promiscuous mode: err=%s, port=%u\n",
+   rte_strerror(-ret), port_id);
+   return ret;
+   }
 
rte_eth_macaddr_get(port_id, &bbdev_port_eth_addr);
print_mac(port_id, &bbdev_port_eth_addr);
diff --git a/examples/bond/main.c b/examples/bond/main.c
index be62c1713..39214cfee 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -299,7 +299,13 @@ bond_port_init(struct rte_mempool *mbuf_pool)
rte_exit(-1, "\nFailed to activate slaves\n");
}
 
-   rte_eth_promiscuous_enable(BOND_PORT);
+   retval = rte_eth_promiscuous_enable(BOND_PORT);
+   if (retval != 0) {
+   rte_exit(EXIT_FAILURE,
+   "port %u: promiscuous mode enable failed: %s\n",
+   BOND_PORT, rte_strerror(-retval));
+   return;
+   }
 
struct rte_ether_addr addr;
 
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 8942f3607..125ee877f 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -194,7 +194,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
addr.addr_bytes[2], addr.addr_bytes[3],
addr.addr_bytes[4], addr.addr_bytes[5]);
 
-   rte_eth_promiscuous_enable(port);
+   retval = rte_eth_promiscuous_enable(port);
+   if (retval != 0)
+   return retval;
 
return 0;
 }
diff --git a/examples/eventdev_pipeline/main.c 
b/examples/eventdev_pipeline/main.c
index 3789fbfd7..c734c7750 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -333,7 +333,9 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
addr.addr_bytes[4], addr.addr_bytes[5]);
 
/* Enable RX in promiscuous mode for the Ethernet device. */
-   rte_eth_pr

[dpdk-dev] [PATCH v3 04/13] ethdev: change promiscuous callbacks to return status

2019-09-14 Thread Andrew Rybchenko
Enabling/disabling of promiscuous mode is not always successful and
it should be taken into account to be able to handle it properly.

When correct return status is unclear from driver code, -EAGAIN is used.

Signed-off-by: Andrew Rybchenko 
Acked-by: Matan Azrad 
Acked-by: Hyong Youb Kim 
---
 app/test/virtual_pmd.c| 12 --
 drivers/net/af_packet/rte_eth_af_packet.c | 22 ++
 drivers/net/af_xdp/rte_eth_af_xdp.c   | 22 ++
 drivers/net/atlantic/atl_ethdev.c | 12 --
 drivers/net/avp/avp_ethdev.c  | 12 --
 drivers/net/axgbe/axgbe_ethdev.c  | 12 --
 drivers/net/bnx2x/bnx2x_ethdev.c  |  8 +++-
 drivers/net/bnxt/bnxt_ethdev.c| 26 +---
 drivers/net/bonding/rte_eth_bond_pmd.c| 42 +++---
 drivers/net/cxgbe/cxgbe_ethdev.c  | 12 +++---
 drivers/net/cxgbe/cxgbe_pfvf.h|  4 +-
 drivers/net/dpaa/dpaa_ethdev.c|  8 +++-
 drivers/net/dpaa2/dpaa2_ethdev.c  | 12 --
 drivers/net/e1000/em_ethdev.c | 12 --
 drivers/net/e1000/igb_ethdev.c| 24 +++
 drivers/net/enetc/enetc_ethdev.c  |  8 +++-
 drivers/net/enic/enic.h   |  2 +-
 drivers/net/enic/enic_ethdev.c| 22 +++---
 drivers/net/enic/enic_main.c  |  4 +-
 drivers/net/failsafe/failsafe_ops.c   |  8 +++-
 drivers/net/fm10k/fm10k_ethdev.c  | 24 +++
 drivers/net/hinic/hinic_pmd_ethdev.c  | 16 ++-
 drivers/net/i40e/i40e_ethdev.c| 35 +++
 drivers/net/i40e/i40e_ethdev_vf.c | 20 ++---
 drivers/net/i40e/i40e_vf_representor.c|  8 ++--
 drivers/net/iavf/iavf_ethdev.c| 20 ++---
 drivers/net/ice/ice_ethdev.c  | 27 +---
 drivers/net/ipn3ke/ipn3ke_ethdev.h|  4 +-
 drivers/net/ipn3ke/ipn3ke_representor.c   |  8 +++-
 drivers/net/ixgbe/ixgbe_ethdev.c  | 50 +-
 drivers/net/liquidio/lio_ethdev.c | 30 -
 drivers/net/mlx4/mlx4.h   |  4 +-
 drivers/net/mlx4/mlx4_ethdev.c| 28 +---
 drivers/net/mlx5/mlx5.h   |  4 +-
 drivers/net/mlx5/mlx5_rxmode.c| 38 ++---
 drivers/net/mvneta/mvneta_ethdev.c| 22 +++---
 drivers/net/mvpp2/mrvl_ethdev.c   | 28 +---
 drivers/net/netvsc/hn_ethdev.c|  8 ++--
 drivers/net/netvsc/hn_var.h   |  4 +-
 drivers/net/netvsc/hn_vf.c| 22 --
 drivers/net/nfb/nfb_rxmode.c  | 10 +++--
 drivers/net/nfb/nfb_rxmode.h  |  8 +++-
 drivers/net/nfp/nfp_net.c | 30 -
 drivers/net/octeontx/octeontx_ethdev.c| 16 ---
 drivers/net/octeontx2/otx2_ethdev.h   |  4 +-
 drivers/net/octeontx2/otx2_ethdev_ops.c   |  8 +++-
 drivers/net/qede/qede_ethdev.c| 16 ---
 drivers/net/sfc/sfc_ethdev.c  | 14 +++---
 drivers/net/szedata2/rte_eth_szedata2.c   |  6 ++-
 drivers/net/tap/rte_eth_tap.c | 52 ++-
 drivers/net/thunderx/nicvf_ethdev.c   |  3 +-
 drivers/net/virtio/virtio_ethdev.c| 24 +++
 drivers/net/vmxnet3/vmxnet3_ethdev.c  | 12 --
 lib/librte_ethdev/rte_ethdev.c| 18 +---
 lib/librte_ethdev/rte_ethdev_core.h   | 52 +--
 55 files changed, 692 insertions(+), 265 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index e295891c0..b34df416a 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -210,13 +210,17 @@ virtual_ethdev_stats_reset(struct rte_eth_dev *dev)
memset(&dev_private->eth_stats, 0, sizeof(dev_private->eth_stats));
 }
 
-static void
+static int
 virtual_ethdev_promiscuous_mode_enable(struct rte_eth_dev *dev __rte_unused)
-{}
+{
+   return 0;
+}
 
-static void
+static int
 virtual_ethdev_promiscuous_mode_disable(struct rte_eth_dev *dev __rte_unused)
-{}
+{
+   return 0;
+}
 
 static int
 virtual_ethdev_mac_address_set(__rte_unused struct rte_eth_dev *dev,
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c 
b/drivers/net/af_packet/rte_eth_af_packet.c
index 66131b53e..049572728 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -458,41 +458,47 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
return 0;
 }
 
-static void
+static int
 eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask)
 {
struct ifreq ifr;
+   int ret = 0;
int s;
 
s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0)
-   return;
+   return -errno;
 
strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
-   if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
+   if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
+   ret = -errno;
goto out;
+   }
ifr.ifr_flags &= mask;
   

[dpdk-dev] [PATCH v6 1/7] bus/fslmc: fix the conflicting dmb function

2019-09-14 Thread Gavin Hu
There are two definitions conflicting each other, for more
details, refer to [1].

include/rte_atomic_64.h:19: error: "dmb" redefined [-Werror]
drivers/bus/fslmc/mc/fsl_mc_sys.h:36: note: this is the location of the
previous definition
 #define dmb() {__asm__ __volatile__("" : : : "memory"); }

The fix is to include the spinlock.h file before the other header files,
this is inline with the coding style[2] about the "header includes".
The fix changes the function to take the argument for arm to be
meaningful.

[1] http://inbox.dpdk.org/users/VI1PR08MB537631AB25F41B8880DCCA988FDF0@i
VI1PR08MB5376.eurprd08.prod.outlook.com/T/#u
[2] https://doc.dpdk.org/guides/contributing/coding_style.html

Fixes: 3af733ba8da8 ("bus/fslmc: introduce MC object functions")
Cc: sta...@dpdk.org

Signed-off-by: Gavin Hu 
Reviewed-by: Phil Yang 
---
 drivers/bus/fslmc/mc/fsl_mc_sys.h | 10 +++---
 drivers/bus/fslmc/mc/mc_sys.c |  3 +--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/fslmc/mc/fsl_mc_sys.h 
b/drivers/bus/fslmc/mc/fsl_mc_sys.h
index d0c7b39..fe9dc95 100644
--- a/drivers/bus/fslmc/mc/fsl_mc_sys.h
+++ b/drivers/bus/fslmc/mc/fsl_mc_sys.h
@@ -33,10 +33,14 @@ struct fsl_mc_io {
 #include 
 
 #ifndef dmb
-#define dmb() {__asm__ __volatile__("" : : : "memory"); }
+#ifdef RTE_ARCH_ARM64
+#define dmb(opt) {asm volatile("dmb " #opt : : : "memory"); }
+#else
+#define dmb(opt)
 #endif
-#define __iormb()  dmb()
-#define __iowmb()  dmb()
+#endif
+#define __iormb()  dmb(ld)
+#define __iowmb()  dmb(st)
 #define __arch_getq(a) (*(volatile uint64_t *)(a))
 #define __arch_putq(v, a)  (*(volatile uint64_t *)(a) = (v))
 #define __arch_putq32(v, a)(*(volatile uint32_t *)(a) = (v))
diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
index efafdc3..22143ef 100644
--- a/drivers/bus/fslmc/mc/mc_sys.c
+++ b/drivers/bus/fslmc/mc/mc_sys.c
@@ -4,11 +4,10 @@
  * Copyright 2017 NXP
  *
  */
+#include 
 #include 
 #include 
 
-#include 
-
 /** User space framework uses MC Portal in shared mode. Following change
  * introduces lock in MC FLIB
  */
-- 
2.7.4



[dpdk-dev] [PATCH v6 3/7] spinlock: use wfe to reduce contention on aarch64

2019-09-14 Thread Gavin Hu
In acquiring a spinlock, cores repeatedly poll the lock variable.
This is replaced by rte_wait_until_equal API.

Running the micro benchmarking and the testpmd and l3fwd traffic tests
on ThunderX2, Ampere eMAG80 and Arm N1SDP, everything went well and no
notable performance gain nor degradation was measured.

Signed-off-by: Gavin Hu 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Phil Yang 
Reviewed-by: Steve Capper 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Honnappa Nagarahalli 
Tested-by: Pavan Nikhilesh 
---
 .../common/include/arch/arm/rte_spinlock.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/lib/librte_eal/common/include/arch/arm/rte_spinlock.h 
b/lib/librte_eal/common/include/arch/arm/rte_spinlock.h
index 1a6916b..b61c055 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_spinlock.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_spinlock.h
@@ -16,6 +16,32 @@ extern "C" {
 #include 
 #include "generic/rte_spinlock.h"
 
+/* armv7a does support WFE, but an explicit wake-up signal using SEV is
+ * required (must be preceded by DSB to drain the store buffer) and
+ * this is less performant, so keep armv7a implementation unchanged.
+ */
+#ifndef RTE_FORCE_INTRINSICS
+static inline void
+rte_spinlock_lock(rte_spinlock_t *sl)
+{
+   unsigned int tmp;
+   /* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.
+* faqs/ka16809.html
+*/
+   asm volatile(
+   "1: ldaxr %w[tmp], %w[locked]\n"
+   "cbnz   %w[tmp], 2f\n"
+   "stxr   %w[tmp], %w[one], %w[locked]\n"
+   "cbnz   %w[tmp], 1b\n"
+   "ret\n"
+   "2: sevl\n"
+   "wfe\n"
+   "jmp1b\n"
+   : [tmp] "=&r" (tmp), [locked] "+Q"(sl->locked)
+   : [one] "r" (1)
+}
+#endif
+
 static inline int rte_tm_supported(void)
 {
return 0;
-- 
2.7.4



[dpdk-dev] [PATCH v6 0/7] use WFE for aarch64

2019-09-14 Thread Gavin Hu
V6:
- squash the RTE_ARM_USE_WFE configuration entry patch into the new API patch
- move the new configuration to the end of EAL
- add doxygen comments to reflect the relaxed and acquire semantics
- correct the meson configuration 
V5:
- add doxygen comments for the new APIs
- spinlock early exit without wfe if the spinlock not taken by others.
- add two patches on top for opdl and thunderx
V4:
- rename the config as CONFIG_RTE_ARM_USE_WFE to indicate it applys to arm only
- introduce a macro for assembly Skelton to reduce the duplication of code
- add one patch for nxp fslmc to address a compiling error
V3:
- Convert RFCs to patches
V2:
- Use inline functions instead of marcos
- Add load and compare in the beginning of the APIs
- Fix some style errors in asm inline 
V1:
- Add the new APIs and use it for ring and locks

DPDK has multiple use cases where the core repeatedly polls a location in
memory. This polling results in many cache and memory transactions.

Arm architecture provides WFE (Wait For Event) instruction, which allows
the cpu core to enter a low power state until woken up by the update to the
memory location being polled. Thus reducing the cache and memory
transactions.

x86 has the PAUSE hint instruction to reduce such overhead.

The rte_wait_until_equal_xxx APIs abstract the functionality of 'polling
for a memory location to become equal to a given value'.

For non-Arm platforms, these APIs are just wrappers around do-while loop
with rte_pause, so there are no performance differences.

For Arm platforms, use of WFE can be configured using CONFIG_RTE_USE_WFE
option. It is disabled by default.

Currently, use of WFE is supported only for aarch64 platforms. armv7
platforms do support the WFE instruction, but they require explicit wake up
events(sev) and are less performannt.

Testing shows that, performance varies across different platforms, with
some showing degradation.

CONFIG_RTE_ARM_USE_WFE should be enabled depending on the performance
benchmarking on the target platforms. Power saving should be an bonus,
but currenly we don't have ways to characterize that.

Gavin Hu (7):
  bus/fslmc: fix the conflicting dmb function
  eal: add the APIs to wait until equal
  spinlock: use wfe to reduce contention on aarch64
  ticketlock: use new API to reduce contention on aarch64
  ring: use wfe to wait for ring tail update on aarch64
  net/thunderx: use new API to save cycles on aarch64
  event/opdl: use new API to save cycles on aarch64

 config/arm/meson.build |   1 +
 config/common_base |   5 +
 drivers/bus/fslmc/mc/fsl_mc_sys.h  |  10 +-
 drivers/bus/fslmc/mc/mc_sys.c  |   3 +-
 drivers/event/opdl/opdl_ring.c |   5 +-
 drivers/net/thunderx/nicvf_rxtx.c  |   3 +-
 .../common/include/arch/arm/rte_pause_64.h |  30 ++
 .../common/include/arch/arm/rte_spinlock.h |  26 ++
 lib/librte_eal/common/include/generic/rte_pause.h  | 103 +
 .../common/include/generic/rte_ticketlock.h|   3 +-
 lib/librte_ring/rte_ring_c11_mem.h |   4 +-
 lib/librte_ring/rte_ring_generic.h |   3 +-
 12 files changed, 180 insertions(+), 16 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v6 2/7] eal: add the APIs to wait until equal

2019-09-14 Thread Gavin Hu
The rte_wait_until_equal_xx APIs abstract the functionality of
'polling for a memory location to become equal to a given value'.

Add the RTE_ARM_USE_WFE configuration entry for aarch64, disabled
by default. When it is enabled, the above APIs will call WFE instruction
to save CPU cycles and power.

Signed-off-by: Gavin Hu 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Steve Capper 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Honnappa Nagarahalli 
Reviewed-by: Phil Yang 
Acked-by: Pavan Nikhilesh 
---
 config/arm/meson.build |   1 +
 config/common_base |   5 +
 .../common/include/arch/arm/rte_pause_64.h |  30 ++
 lib/librte_eal/common/include/generic/rte_pause.h  | 103 +
 4 files changed, 139 insertions(+)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 979018e..b4b4cac 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -26,6 +26,7 @@ flags_common_default = [
['RTE_LIBRTE_AVP_PMD', false],
 
['RTE_SCHED_VECTOR', false],
+   ['RTE_ARM_USE_WFE', false],
 ]
 
 flags_generic = [
diff --git a/config/common_base b/config/common_base
index 8ef75c2..8861713 100644
--- a/config/common_base
+++ b/config/common_base
@@ -111,6 +111,11 @@ CONFIG_RTE_MAX_VFIO_CONTAINERS=64
 CONFIG_RTE_MALLOC_DEBUG=n
 CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n
 CONFIG_RTE_USE_LIBBSD=n
+# Use WFE instructions to implement the rte_wait_for_equal_xxx APIs,
+# calling these APIs put the cores in low power state while waiting
+# for the memory address to become equal to the expected value.
+# This is supported only by aarch64.
+CONFIG_RTE_ARM_USE_WFE=n
 
 #
 # Recognize/ignore the AVX/AVX512 CPU flags for performance/power testing.
diff --git a/lib/librte_eal/common/include/arch/arm/rte_pause_64.h 
b/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
index 93895d3..dabde17 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Cavium, Inc
+ * Copyright(c) 2019 Arm Limited
  */
 
 #ifndef _RTE_PAUSE_ARM64_H_
@@ -17,6 +18,35 @@ static inline void rte_pause(void)
asm volatile("yield" ::: "memory");
 }
 
+#ifdef RTE_ARM_USE_WFE
+#define __WAIT_UNTIL_EQUAL(name, asm_op, wide, type) \
+static __rte_always_inline void \
+rte_wait_until_equal_##name(volatile type * addr, type expected) \
+{ \
+   type tmp; \
+   asm volatile( \
+   #asm_op " %" #wide "[tmp], %[addr]\n" \
+   "cmp%" #wide "[tmp], %" #wide "[expected]\n" \
+   "b.eq   2f\n" \
+   "sevl\n" \
+   "1: wfe\n" \
+   #asm_op " %" #wide "[tmp], %[addr]\n" \
+   "cmp%" #wide "[tmp], %" #wide "[expected]\n" \
+   "bne1b\n" \
+   "2:\n" \
+   : [tmp] "=&r" (tmp) \
+   : [addr] "Q"(*addr), [expected] "r"(expected) \
+   : "cc", "memory"); \
+}
+/* Wait for *addr to be updated with expected value */
+__WAIT_UNTIL_EQUAL(relaxed_16, ldxrh, w, uint16_t)
+__WAIT_UNTIL_EQUAL(acquire_16, ldaxrh, w, uint16_t)
+__WAIT_UNTIL_EQUAL(relaxed_32, ldxr, w, uint32_t)
+__WAIT_UNTIL_EQUAL(acquire_32, ldaxr, w, uint32_t)
+__WAIT_UNTIL_EQUAL(relaxed_64, ldxr, x, uint64_t)
+__WAIT_UNTIL_EQUAL(acquire_64, ldaxr, x, uint64_t)
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/common/include/generic/rte_pause.h 
b/lib/librte_eal/common/include/generic/rte_pause.h
index 52bd4db..772a2ab 100644
--- a/lib/librte_eal/common/include/generic/rte_pause.h
+++ b/lib/librte_eal/common/include/generic/rte_pause.h
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Cavium, Inc
+ * Copyright(c) 2019 Arm Limited
  */
 
 #ifndef _RTE_PAUSE_H_
@@ -12,6 +13,10 @@
  *
  */
 
+#include 
+#include 
+#include 
+
 /**
  * Pause CPU execution for a short while
  *
@@ -20,4 +25,102 @@
  */
 static inline void rte_pause(void);
 
+/**
+ * Wait for *addr to be updated with a 16-bit expected value, with a relaxed 
memory
+ * ordering model meaning the loads around this API can be reordered.
+ *
+ * @param addr
+ *  A pointer to the memory location.
+ * @param expected
+ *  A 16-bit expected value to be in the memory location.
+ */
+__rte_always_inline
+static void
+rte_wait_until_equal_relaxed_16(volatile uint16_t *addr, uint16_t expected);
+
+/**
+ * Wait for *addr to be updated with a 32-bit expected value, with a relaxed 
memory
+ * ordering model meaning the loads around this API can be reordered.
+ *
+ * @param addr
+ *  A pointer to the memory location.
+ * @param expected
+ *  A 32-bit expected value to be in the memory location.
+ */
+__rte_always_inline
+static void
+rte_wait_until_equal_relaxed_32(volatile uint32_t *addr, uint32_t expected);
+
+/**
+ * Wait for *addr to be updated with a 64-bit expected value, with a relaxed 
memory
+ *

[dpdk-dev] [PATCH v6 4/7] ticketlock: use new API to reduce contention on aarch64

2019-09-14 Thread Gavin Hu
While using ticket lock, cores repeatedly poll the lock variable.
This is replaced by rte_wait_until_equal API.

Running ticketlock_autotest on ThunderX2, Ampere eMAG80, and Arm N1SDP[1],
there were variances between runs, but no notable performance gain or
degradation were seen with and without this patch.

[1] https://community.arm.com/developer/tools-software/oss-platforms/w/\
docs/440/neoverse-n1-sdp

Signed-off-by: Gavin Hu 
Reviewed-by: Honnappa Nagarahalli 
Tested-by: Phil Yang 
Tested-by: Pavan Nikhilesh 
Reviewed-by: Jerin Jacob 
---
 lib/librte_eal/common/include/generic/rte_ticketlock.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/generic/rte_ticketlock.h 
b/lib/librte_eal/common/include/generic/rte_ticketlock.h
index d9bec87..232bbe9 100644
--- a/lib/librte_eal/common/include/generic/rte_ticketlock.h
+++ b/lib/librte_eal/common/include/generic/rte_ticketlock.h
@@ -66,8 +66,7 @@ static inline void
 rte_ticketlock_lock(rte_ticketlock_t *tl)
 {
uint16_t me = __atomic_fetch_add(&tl->s.next, 1, __ATOMIC_RELAXED);
-   while (__atomic_load_n(&tl->s.current, __ATOMIC_ACQUIRE) != me)
-   rte_pause();
+   rte_wait_until_equal_acquire_16(&tl->s.current, me);
 }
 
 /**
-- 
2.7.4



[dpdk-dev] [PATCH v6 6/7] net/thunderx: use new API to save cycles on aarch64

2019-09-14 Thread Gavin Hu
Use the new API to wait in low power state instead of continuous
polling to save CPU cycles and power.

Signed-off-by: Gavin Hu 
Reviewed-by: Ruifeng Wang 
Acked-by: Jerin Jacob 
---
 drivers/net/thunderx/nicvf_rxtx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
index 1c42874..16f34c6 100644
--- a/drivers/net/thunderx/nicvf_rxtx.c
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -385,8 +385,7 @@ nicvf_fill_rbdr(struct nicvf_rxq *rxq, int to_fill)
ltail++;
}
 
-   while (__atomic_load_n(&rbdr->tail, __ATOMIC_RELAXED) != next_tail)
-   rte_pause();
+   rte_wait_until_equal_relaxed_32(&rbdr->tail, next_tail);
 
__atomic_store_n(&rbdr->tail, ltail, __ATOMIC_RELEASE);
nicvf_addr_write(door, to_fill);
-- 
2.7.4



[dpdk-dev] [PATCH v6 7/7] event/opdl: use new API to save cycles on aarch64

2019-09-14 Thread Gavin Hu
Use the new API to wait in low power state instead of continuous
polling to save CPU cycles and power.

Signed-off-by: Gavin Hu 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Jerin Jacob 
---
 drivers/event/opdl/opdl_ring.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c
index e8b29e2..f446fa3 100644
--- a/drivers/event/opdl/opdl_ring.c
+++ b/drivers/event/opdl/opdl_ring.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "opdl_ring.h"
 #include "opdl_log.h"
@@ -475,9 +476,7 @@ opdl_ring_input_multithread(struct opdl_ring *t, const void 
*entries,
/* If another thread started inputting before this one, but hasn't
 * finished, we need to wait for it to complete to update the tail.
 */
-   while (unlikely(__atomic_load_n(&s->shared.tail, __ATOMIC_ACQUIRE) !=
-   old_head))
-   rte_pause();
+   rte_wait_until_equal_acquire_32(&s->shared.tail, old_head);
 
__atomic_store_n(&s->shared.tail, old_head + num_entries,
__ATOMIC_RELEASE);
-- 
2.7.4



[dpdk-dev] [PATCH v6 5/7] ring: use wfe to wait for ring tail update on aarch64

2019-09-14 Thread Gavin Hu
Instead of polling for tail to be updated, use wfe instruction.

Signed-off-by: Gavin Hu 
Reviewed-by: Ruifeng Wang 
Reviewed-by: Steve Capper 
Reviewed-by: Ola Liljedahl 
Reviewed-by: Honnappa Nagarahalli 
---
 lib/librte_ring/rte_ring_c11_mem.h | 4 ++--
 lib/librte_ring/rte_ring_generic.h | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ring/rte_ring_c11_mem.h 
b/lib/librte_ring/rte_ring_c11_mem.h
index 0fb73a3..764d8f1 100644
--- a/lib/librte_ring/rte_ring_c11_mem.h
+++ b/lib/librte_ring/rte_ring_c11_mem.h
@@ -2,6 +2,7 @@
  *
  * Copyright (c) 2017,2018 HXT-semitech Corporation.
  * Copyright (c) 2007-2009 Kip Macy km...@freebsd.org
+ * Copyright (c) 2019 Arm Limited
  * All rights reserved.
  * Derived from FreeBSD's bufring.h
  * Used as BSD-3 Licensed with permission from Kip Macy.
@@ -21,8 +22,7 @@ update_tail(struct rte_ring_headtail *ht, uint32_t old_val, 
uint32_t new_val,
 * we need to wait for them to complete
 */
if (!single)
-   while (unlikely(ht->tail != old_val))
-   rte_pause();
+   rte_wait_until_equal_relaxed_32(&ht->tail, old_val);
 
__atomic_store_n(&ht->tail, new_val, __ATOMIC_RELEASE);
 }
diff --git a/lib/librte_ring/rte_ring_generic.h 
b/lib/librte_ring/rte_ring_generic.h
index 953cdbb..6828527 100644
--- a/lib/librte_ring/rte_ring_generic.h
+++ b/lib/librte_ring/rte_ring_generic.h
@@ -23,8 +23,7 @@ update_tail(struct rte_ring_headtail *ht, uint32_t old_val, 
uint32_t new_val,
 * we need to wait for them to complete
 */
if (!single)
-   while (unlikely(ht->tail != old_val))
-   rte_pause();
+   rte_wait_until_equal_relaxed_32(&ht->tail, old_val);
 
ht->tail = new_val;
 }
-- 
2.7.4



[dpdk-dev] [PATCH] git: ignore more build directories

2019-09-14 Thread Thomas Monjalon
Build directories commonly have compiler in their names.
In order to filter build directories not starting with "build-"
(common with make), patterns for gcc and clang are added to .gitignore.

Signed-off-by: Thomas Monjalon 
---
 .gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.gitignore b/.gitignore
index 5eda2c31e..9741ba076 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,6 @@ TAGS
 # ignore default build directory, and directories from test-meson-builds.sh
 build
 build-*
+# ignore other build directory patterns
+*-gcc*
+*-clang*
-- 
2.23.0



Re: [dpdk-dev] The type string in the malloc library is unused

2019-09-14 Thread Alexander Pshenichnikov
Hi Morten,

Look rte_memzone_reserve/rte_memzone_lookup



On Fri, Sep 13, 2019 at 4:32 PM Morten Brørup  
wrote:
>
> Hi Anatoly,
>
>
>
> The functions in the DPDK malloc library takes a "type" parameter (a string, 
> supposedly for debug purposes), but the underlying malloc_heap functions 
> (which take the same string parameter) don't store or use this string for 
> anything.
>
>
>
> Is the intention to implement this sometime in the future, or should it be 
> considered for removal?
>
>
>
> I was originally looking for a function for my primary process to allocate a 
> block of named memory in the huge-page area, so my secondary process could 
> look it up and use it. And I would simply use a unique type string for this, 
> and add an rte_malloc_lookup function. However, that obviously doesn't work 
> when the type parameter is not used during allocation.
>
>
>
>
>
> The simplest workaround I can come up with is using a named mempool with a 
> single element, where this element is my memory block. I get an element from 
> this mempool to find the address of my memory block, store the address, and 
> put the element back in the mempool, so the secondary process can get the 
> address the same way, i.e. by getting and putting the element back into the 
> mempool while storing the element's address underway.
>
>
>
> Any better ideas?
>
>
>
>
>
> Med venlig hilsen / kind regards
>
>
>
> Morten Brørup
>
> CTO
>
>
>
>
>
> SmartShare Systems A/S
>
> Tonsbakken 16-18
>
> DK-2740 Skovlunde
>
> Denmark
>
>
>
> Office  +45 70 20 00 93
>
> Direct  +45 89 93 50 22
>
> Mobile +45 25 40 82 12
>
>
>
> m...@smartsharesystems.com 
>
> www.smartsharesystems.com 
>
>
>


Re: [dpdk-dev] [PATCH v1 0/2] declare crypto asym xform immutable

2019-09-14 Thread Sunila Sahu
Hi Fiona, Anoob,

Fiona,

> Though above reasons are from a QAT perspective, they surely also apply to sw 
> PMDs and
> I'd guess they also apply to other hw devices - though would like feedback if 
> different.

Declaring crypto asym xform immutable does save allocation and copy of key data 
into OCTEON PMD
during session configuration.
But since hw requires a definitive alignment, xform data has to be copied for 
op enqueue. So in
this case session-less implementation is beneficial.
I think there is value in both the implementations depending on the PMD.

Anoob,

> Moreover, the same behavior could be
> achieved with session-less, if we declare that the number of operations done 
> is "few".

Not necessarily the number of operations done here is "few". It entirely 
depends on key usage.
If the key is ephemeral then your operation will be limited to a single 
transaction as in case of a key
exchange mechanism.
But for other operations as digital signature, the life-time of the session is 
not limited to a single operation.
Also, there can be different ops (public key or private key authentication) 
with a single session.
In that case, session implementation will have an advantage over sessionless.

Thanks,
Sunila


From: Trahe, Fiona 
Sent: Friday, September 6, 2019 4:55 PM
To: Anoob Joseph ; Shally Verma ; 
Kusztal, ArkadiuszX ; Ayuj Verma 
; akhil.go...@nxp.com 
Cc: Sunila Sahu ; Kanaka Durga Kotamarthy 
; dev@dpdk.org ; Trahe, Fiona 

Subject: [EXT] RE: [PATCH v1 0/2] declare crypto asym xform immutable

Hi Anoob, Arek, Shally,

The fundamental question here seems to be whether it's ok to specify the 
asymmetric xform to
have different behaviour to the symmetric xform.
In my opinion it is.
At least in terms of our QuickAssist PMD and its use by symmetric and
asymmetric applications I don't see any conflict with the xforms having 
different characteristics.
They are two different structures.

For rte_crypto_sym_xform, there are 2, usually small, params - key and iv - 
that need to be copied into
the descriptor to be sent to the hardware, so a copy can't be avoided there and 
it helps to get this
 copy out of the way during the session. This prep helps to make with-session 
symmetric more
performant than session-less would be.
And so I don't see any problem in an application re-using the sym_xforms as 
you've described, and
the API not constraining them to be immutable for the lifetime of the session.

For asymmetric on the other hand the rte_crypto_asym_xform has from 2 to 7 
larger buffers set up by the application
with input data to be used in the session. In QAT case, none of this data can 
be copied into the descriptor
and so the PMD would have to alloc duplicate structs and buffers for all this 
data and all the associated
meta-data (phys_addr ptrs) and copy it all, just to facilitate the application 
freeing the xform.
>From a performance perspective, these copies seem wasteful, especially for an 
>asymmetric session which is likely to have far fewer ops associate with it 
>than a symmetric session would.
>From a memory mgmt point of view it increases the memory resources needed.
>From a security perspective, minimising the copies of key data in memory is 
>preferable.
And it seems like a reasonable constraint on the Application to not free the 
xform - there are very few if any fields set up in it that it could re-use, so 
the only advantage I can see is that it would need a smaller pool of xforms if 
it could re-use them.

Though above reasons are from a QAT perspective, they surely also apply to sw 
PMDs and I'd guess they also apply to other hw devices - though would like 
feedback if different.
So I'm in favour of the API constraining the asym_xform and all its fields to 
be immutable for the lifetime of the session.
I get that this doesn't provide programmatic protection if an application 
ignores the API directive.
If you can suggest a way to protect this programmatically, that would be 
better, but even in the absence of this, I think it's worth
doing and think it's reasonable for application developers to be expected to 
follow the API documentation.

Fiona

> -Original Message-
> From: Anoob Joseph [mailto:ano...@marvell.com]
> Sent: Friday, September 6, 2019 7:08 AM
> To: Shally Verma ; Kusztal, ArkadiuszX 
> ; Ayuj
> Verma ; akhil.go...@nxp.com
> Cc: Sunila Sahu ; Kanaka Durga Kotamarthy 
> ;
> dev@dpdk.org; Trahe, Fiona 
> Subject: RE: [PATCH v1 0/2] declare crypto asym xform immutable
>
> Hi Shally, Arek,
>
> I still think it's a bit too early to take a decision on this. 'xform' is 
> being used for symmetric operations
> as well. Everywhere, 'xform' is treated as an input argument to PMD ops. 
> Making this change will
> define 'xform' in a different way, and that will be applicable only for 
> asymmetric. I believe we can wait
> till we have a PMD which will be able to fully leverage this. Moreover, the 
> same behavior could be
> achieved wi

Re: [dpdk-dev] [EXT] [PATCH v4 5/6] spinlock: use wfe to reduce contention on aarch64

2019-09-14 Thread Gavin Hu (Arm Technology China)
Hi Jerin,

Add the offlist discussion with Pavan to facilitate the review for the spinlock 
patch(currently in v6). Thanks Pavan and Jerin for review.

Best Regards,
Gavin

> -Original Message-
> From: Gavin Hu (Arm Technology China)
> Sent: Thursday, September 12, 2019 5:22 PM
> To: Pavan Nikhilesh Bhagavatula 
> Subject: RE: [EXT] [PATCH v4 5/6] spinlock: use wfe to reduce contention on
> aarch64
>
> Hi Pavan,
>
> Thanks for pointing this out, it was implemented in the API already.
> Spinlock did not use the API to save a comparison branch(loading 0 to a reg
> and compare against).
>
> Anyway it is also a good idea to add it into this asm code.
>
> Best Regards,
> Gavin
>
> > -Original Message-
> > From: Pavan Nikhilesh Bhagavatula 
> > Sent: Thursday, September 12, 2019 4:45 PM
> > To: Gavin Hu (Arm Technology China) 
> > Subject: RE: [EXT] [PATCH v4 5/6] spinlock: use wfe to reduce contention on
> > aarch64
> >
> > Hi Gavin, (Offlist)
> >
> > I there a reason why the below asm doesn't use early exit as discussed in
> > http://patches.dpdk.org/patch/55669/
> >
> > Regards,
> > Pavan.
> >
> > >+#ifndef RTE_FORCE_INTRINSICS
> > >+static inline void
> > >+rte_spinlock_lock(rte_spinlock_t *sl)
> > >+{
> > >+  unsigned int tmp;
> > >+  /*
> > >http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.
> > >+   * faqs/ka16809.html
> > >+   */
> > >+  asm volatile(
> > >+  "sevl\n"
> > >+  "1: wfe\n"
> > >+  "2: ldaxr %w[tmp], %w[locked]\n"
> > >+  "cbnz   %w[tmp], 1b\n"
> > >+  "stxr   %w[tmp], %w[one], %w[locked]\n"
> > >+  "cbnz   %w[tmp], 2b\n"
> > >+  : [tmp] "=&r" (tmp), [locked] "+Q"(sl->locked)
> > >+  : [one] "r" (1)
> > >+  : "cc", "memory");
> > >+}
> > >+#endif
> > >+
> > > static inline int rte_tm_supported(void)
> > > {
> > >   return 0;
> > >--
> > >2.7.4

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


Re: [dpdk-dev] [PATCH v1 1/5] ipsec: add inbound SAD API

2019-09-14 Thread Ananyev, Konstantin
> --- /dev/null
> +++ b/lib/librte_ipsec/rte_ipsec_sad.h
> @@ -0,0 +1,174 @@
> +
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2019 Intel Corporation
> + */
> +
> +#ifndef _RTE_IPSEC_SAD_H_
> +#define _RTE_IPSEC_SAD_H_
> +
> +#include 
> +
> +/**
> + * @file rte_ipsec_sad.h
> + * @b EXPERIMENTAL: this API may change without prior notice
> + *
> + * RTE IPsec security association database (SAD) support.
> + * It is not recommended to include this file directly,
> + * include  instead.
> + * Contains helper functions to lookup and maintain SAD
> + */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +struct rte_ipsec_sad;
> +
> +/** Type of key */
> +enum {
> + RTE_IPSEC_SAD_SPI_ONLY = 0,
> + RTE_IPSEC_SAD_SPI_DIP,
> + RTE_IPSEC_SAD_SPI_DIP_SIP,
> + RTE_IPSEC_SAD_KEY_TYPE_MASK,
> +};
> +
> +struct rte_ipsec_sadv4_key {
> + uint32_t spi;
> + uint32_t dip;
> + uint32_t sip;
> +};
> +
> +struct rte_ipsec_sadv6_key {
> + uint32_t spi;
> + uint8_t dip[16];
> + uint8_t sip[16];
> +};
> +
> +union rte_ipsec_sad_key {
> + struct rte_ipsec_sadv4_key  v4;
> + struct rte_ipsec_sadv6_key  v6;
> +};
> +
> +#define RTE_IPSEC_SAD_FLAG_IPV4  0x1
> +#define RTE_IPSEC_SAD_FLAG_IPV6  0x2

Don't think we need to values - ipv4/ipv6 flags are mutually exclusive here.
Might be better:
_ipv4=0, _ipv6=1 (or visa-versa) _mask=1

> +/** Flag to support reader writer concurrency */
> +#define RTE_IPSEC_SAD_FLAG_RW_CONCURRENCY0x4
> +
> +/** IPsec SAD configuration structure */
> +struct rte_ipsec_sad_conf {
> + int socket_id;
> + /** maximum number of SA for each type key */
> + uint32_tmax_sa[RTE_IPSEC_SAD_KEY_TYPE_MASK];
> + uint32_tflags;
> +};
> +
> +/**
> + * Add a rule into the SAD. Could be safely called with concurrent lookups
> + *  if RTE_IPSEC_SAD_FLAG_RW_CONCURRENCY flag was configured on creation 
> time.
> + *  While with this flag multi-reader - one-writer model Is MT safe,
> + *  multi-writer model is not and required extra synchronisation.
> + *
> + * @param sad
> + *   SAD object handle
> + * @param key
> + *   pointer to the key
> + * @param key_type
> + *   key type (spi only/spi+dip/spi+dip+sip)
> + * @param sa
> + *   Pointer associated with the key to save in a SAD
> + *   Must be 4 bytes aligned.
> + * @return
> + *   0 on success, negative value otherwise
> + */
> +__rte_experimental
> +int
> +rte_ipsec_sad_add(struct rte_ipsec_sad *sad, union rte_ipsec_sad_key *key,
> + int key_type, void *sa);
> +
> +/**
> + * Delete a rule from the SAD. Could be safely called with concurrent lookups
> + *  if RTE_IPSEC_SAD_FLAG_RW_CONCURRENCY flag was configured on creation 
> time.
> + *  While with this flag multi-reader - one-writer model Is MT safe,
> + *  multi-writer model is not and required extra synchronisation.
> + *
> + * @param sad
> + *   SAD object handle
> + * @param key
> + *   pointer to the key
> + * @param key_type
> + *   key type (spi only/spi+dip/spi+dip+sip)
> + * @return
> + *   0 on success, negative value otherwise
> + */
> +__rte_experimental
> +int
> +rte_ipsec_sad_del(struct rte_ipsec_sad *sad, union rte_ipsec_sad_key *key,
> + int key_type);
> +/*
> + * Create SAD
> + *
> + * @param name
> + *  SAD name
> + * @param conf
> + *  Structure containing the configuration
> + * @return
> + *  Handle to SAD object on success
> + *  NULL otherwise with rte_errno set to an appropriate values.
> + */
> +__rte_experimental
> +struct rte_ipsec_sad *
> +rte_ipsec_sad_create(const char *name, struct rte_ipsec_sad_conf *conf);

const struct rte_ipsec_sad_conf * 


> +
> +/**
> + * Find an existing SAD object and return a pointer to it.
> + *
> + * @param name
> + *  Name of the rib object as passed to rte_ipsec_sad_create()
> + * @return
> + *  Pointer to sad object or NULL if object not found with rte_errno
> + *  set appropriately. Possible rte_errno values include:
> + *   - ENOENT - required entry not available to return.
> + */
> +__rte_experimental
> +struct rte_ipsec_sad *
> +rte_ipsec_sad_find_existing(const char *name);
> +
> +/**
> + * Free SAD object.
> + *
> + * @param sad
> + *   pointer to the SAD object
> + * @return
> + *   None
> + */
> +__rte_experimental
> +void
> +rte_ipsec_sad_free(struct rte_ipsec_sad *sad);

As a nit - might be better name I _destroy.
Usually such API comes in pairs: create/destroy, alloc/free, etc.


> +
> +/**
> + * Lookup multiple keys in the SAD.
> + *
> + * @param sad
> + *   SAD object handle
> + * @param keys
> + *   Array of keys to be looked up in the SAD
> + * @param sa
> + *   Pointer assocoated with the keys.
> + *   If the lookup for the given key failed, then corresponding sa
> + *   will be NULL
> + * @param n
> + *   Number of elements in keys array to lookup.
> + *  @return
> + *   -EINVAL for incorrect arguments, otherwise 0
> + */
> +__rte_experimental
> +int
> +rte_ipsec_sad_loo