[2/7] examples/l2fwd-cat: block attempts to use owned ports

Message ID 20200312172047.19973-3-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Headers
Series checking for owned ports in portmask |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Stephen Hemminger March 12, 2020, 5:20 p.m. UTC
  If a ethdev port is in use for a sub device, then it should not
be allowed in the portmask of application.

Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
Cc: matan@mellanox.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l2fwd-cat/Makefile    | 2 ++
 examples/l2fwd-cat/l2fwd-cat.c | 3 +++
 examples/l2fwd-cat/meson.build | 1 +
 3 files changed, 6 insertions(+)
  

Comments

Matan Azrad March 15, 2020, 7:51 a.m. UTC | #1
Hi Stephen

From: Stephen Hemminger

I think the correct terminology here is (can be the title):
Make the application be port ownership aware.

Some applications may be ownership aware and others not.

> If a ethdev port is in use for a sub device, then it should not be allowed in the
> portmask of application.
> Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> Cc: matan@mellanox.com
> Cc: stable@dpdk.org
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  examples/l2fwd-cat/Makefile    | 2 ++
>  examples/l2fwd-cat/l2fwd-cat.c | 3 +++
>  examples/l2fwd-cat/meson.build | 1 +
>  3 files changed, 6 insertions(+)
> 
> diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
> index b0e53c37e8d8..aa19347c1545 100644
> --- a/examples/l2fwd-cat/Makefile
> +++ b/examples/l2fwd-cat/Makefile
> @@ -20,6 +20,7 @@ static: build/$(APP)-static  PKGCONF ?= pkg-config
> 
>  PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
> +CFLAGS += -DALLOW_EXPERIMENTAL_API
>  CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)  LDFLAGS_SHARED =
> $(shell $(PKGCONF) --libs libdpdk)  LDFLAGS_STATIC = -Wl,-Bstatic $(shell
> $(PKGCONF) --static --libs libdpdk) @@ -65,6 +66,7 @@ endif
> 
>  EXTRA_CFLAGS += -O3 -g -Wfatal-errors
> 
> +CFLAGS += -DALLOW_EXPERIMENTAL_API
>  CFLAGS += -I$(PQOS_INSTALL_PATH)/../include
> 
>  LDLIBS += -L$(PQOS_INSTALL_PATH)
> diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-
> cat.c index 6838f288c621..c1c59b2d81f2 100644
> --- a/examples/l2fwd-cat/l2fwd-cat.c
> +++ b/examples/l2fwd-cat/l2fwd-cat.c
> @@ -42,6 +42,9 @@ port_init(uint16_t port, struct rte_mempool
> *mbuf_pool)
>  	if (!rte_eth_dev_is_valid_port(port))
>  		return -1;
> 
> +	if (!rte_eth_dev_is_owned_by(portid, RTE_ETH_DEV_NO_OWNER))
> {
> +		return -1;
> +
>  	/* Configure the Ethernet device. */
>  	retval = rte_eth_dev_configure(port, rx_rings, tx_rings,
> &port_conf);
>  	if (retval != 0)
> diff --git a/examples/l2fwd-cat/meson.build b/examples/l2fwd-
> cat/meson.build index 4e2777a03358..5c062c1354e3 100644
> --- a/examples/l2fwd-cat/meson.build
> +++ b/examples/l2fwd-cat/meson.build
> @@ -6,6 +6,7 @@
>  # To build this example as a standalone application with an already-installed
> # DPDK instance, use 'make'
> 
> +allow_experimental_apis = true
>  pqos = cc.find_library('pqos', required: false)  build = pqos.found()  ext_deps
> += pqos
> --
> 2.20.1
  

Patch

diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile
index b0e53c37e8d8..aa19347c1545 100644
--- a/examples/l2fwd-cat/Makefile
+++ b/examples/l2fwd-cat/Makefile
@@ -20,6 +20,7 @@  static: build/$(APP)-static
 PKGCONF ?= pkg-config
 
 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
@@ -65,6 +66,7 @@  endif
 
 EXTRA_CFLAGS += -O3 -g -Wfatal-errors
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -I$(PQOS_INSTALL_PATH)/../include
 
 LDLIBS += -L$(PQOS_INSTALL_PATH)
diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c
index 6838f288c621..c1c59b2d81f2 100644
--- a/examples/l2fwd-cat/l2fwd-cat.c
+++ b/examples/l2fwd-cat/l2fwd-cat.c
@@ -42,6 +42,9 @@  port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	if (!rte_eth_dev_is_valid_port(port))
 		return -1;
 
+	if (!rte_eth_dev_is_owned_by(portid, RTE_ETH_DEV_NO_OWNER)) {
+		return -1;
+
 	/* Configure the Ethernet device. */
 	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
 	if (retval != 0)
diff --git a/examples/l2fwd-cat/meson.build b/examples/l2fwd-cat/meson.build
index 4e2777a03358..5c062c1354e3 100644
--- a/examples/l2fwd-cat/meson.build
+++ b/examples/l2fwd-cat/meson.build
@@ -6,6 +6,7 @@ 
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 pqos = cc.find_library('pqos', required: false)
 build = pqos.found()
 ext_deps += pqos