summaryrefslogtreecommitdiff
path: root/examples/vmdq
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-04-05 17:33:20 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-04-18 00:25:27 +0200
commit8728ccf37615904cf23fb8763895b05c9a3c6b0c (patch)
treeb6e895ec425d20d4933115f533da4be189be1f8a /examples/vmdq
parenta3d6026711d00183e308f1dd79933f6161840e04 (diff)
downloaddpdk-8728ccf37615904cf23fb8763895b05c9a3c6b0c.zip
dpdk-8728ccf37615904cf23fb8763895b05c9a3c6b0c.tar.gz
dpdk-8728ccf37615904cf23fb8763895b05c9a3c6b0c.tar.xz
fix ethdev ports enumeration
Some DPDK applications wrongly assume these requirements: - no hotplug, i.e. ports are never detached - all allocated ports are available to the application Such application iterates over ports by its own mean. The most common pattern is to request the port count and assume ports with index in the range [0..count[ can be used. There are three consequences when using such wrong design: - new ports having an index higher than the port count won't be seen - old ports being detached (RTE_ETH_DEV_UNUSED) can be seen as ghosts - failsafe sub-devices (RTE_ETH_DEV_DEFERRED) will be seen by the application Such mistake will be less common with growing hotplug awareness. All applications and examples inside this repository - except testpmd - must be fixed to use the iterator RTE_ETH_FOREACH_DEV. Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Diffstat (limited to 'examples/vmdq')
-rw-r--r--examples/vmdq/Makefile3
-rw-r--r--examples/vmdq/main.c2
-rw-r--r--examples/vmdq/meson.build1
3 files changed, 5 insertions, 1 deletions
diff --git a/examples/vmdq/Makefile b/examples/vmdq/Makefile
index 87abeab..e2d1149 100644
--- a/examples/vmdq/Makefile
+++ b/examples/vmdq/Makefile
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
include $(RTE_SDK)/mk/rte.vars.mk
+CFLAGS += -DALLOW_EXPERIMENTAL_API
CFLAGS += $(WERROR_FLAGS)
EXTRA_CFLAGS += -O3
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index d94a183..7284524 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -600,7 +600,7 @@ main(int argc, char *argv[])
rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
/* initialize all ports */
- for (portid = 0; portid < nb_ports; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << portid)) == 0) {
printf("\nSkipping disabled port %d\n", portid);
diff --git a/examples/vmdq/meson.build b/examples/vmdq/meson.build
index c34e11e..2b0a250 100644
--- a/examples/vmdq/meson.build
+++ b/examples/vmdq/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
sources = files(
'main.c'
)