[v3,2/6] examples/l2fwd-cat: make applicaton aware of port ownership
Checks
Commit Message
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
On 4/2/2020 6:19 PM, Stephen Hemminger wrote:
> 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>
<...>
> @@ -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_owner_get(port, NULL) == 0)
> + return -1;
'port_init' is called by the loop:
RTE_ETH_FOREACH_DEV(portid)
if (port_init(portid, mbuf_pool) != 0)
And 'RTE_ETH_FOREACH_DEV' already iterates only on ports not owned, so this
check is redundant.
@@ -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)
@@ -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_owner_get(port, NULL) == 0)
+ return -1;
+
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
@@ -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