[v3,3/6] examples/l3fwd: make applicaton aware of port ownership

Message ID 20200402171953.13356-4-stephen@networkplumber.org (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series checking for owned ports in portmask |

Checks

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

Commit Message

Stephen Hemminger April 2, 2020, 5:19 p.m. UTC
  If a ethdev port is in use for a sub device, then it should not
be allowed in the portmask of l3fwd.

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

Patch

diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 59a110d12a49..59cd00abe6e9 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -25,6 +25,8 @@  CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
 	$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -50,6 +52,7 @@  RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index dda430d68a20..110d4cc109d1 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -221,6 +221,11 @@  check_port_config(void)
 			printf("port %u is not present on the board\n", portid);
 			return -1;
 		}
+
+		if (rte_eth_dev_owner_get(portid, NULL) == 0) {
+			printf("port %u is already in use\n", portid);
+			return -1;
+		}
 	}
 	return 0;
 }
diff --git a/examples/l3fwd/meson.build b/examples/l3fwd/meson.build
index ebed3b518c4b..7d72b1b365ae 100644
--- a/examples/l3fwd/meson.build
+++ b/examples/l3fwd/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
 deps += ['hash', 'lpm', 'eventdev']
 sources = files(
 	'l3fwd_em.c', 'l3fwd_lpm.c', 'l3fwd_event.c',