checking for owned ports in portmask
Subsystems (2)
cover checking for owned ports in portmask
The failsafe, bonding, and netvsc PMD use eth dev port ownership to control sub devices. These sub devices are hidden in the normal iteration over ports but some applications use a direct port mask. In these cases, user may still (incorrectly) try to directly use the sub devices.
This patch set introduces a helper function to check if a port is under ownership. And the follow on patches use that.
IMHO this should not be marked as experimental and done as a bug fix back to DPDK 18.11 because then it will get picked up in LTS and users won't run into it on Azure.
An alternative proposed in earlier discussion is to have each application try and own the port. But this solution would be more invasive, and does not handle the case if secondary process exits prematurely without releasing ownership. It makes more sense to keep the concept of ownership as strictly part of the device model and not part of the application layer.
Stephen Hemminger (7):
ethdev: add function to test port ownership examples/l2fwd-cat: block attempts to use owned ports examples/l3fwd: block attempts to use owned ports examples/l3fwd-acl: block attempts to use owned ports examples/l3fwd-power: block attempts to use owned ports examples/tep_termination: block attempts to use owned ports examples/vhost: block attempts to use owned ports
examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + examples/l3fwd-power/main.c | 4 ++++ examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 4 ++++ examples/l3fwd/meson.build | 1 + examples/tep_termination/Makefile | 2 ++ examples/tep_termination/main.c | 2 +- examples/tep_termination/meson.build | 1 + examples/vhost/main.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 9 +++++++++ lib/librte_ethdev/rte_ethdev.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 17 files changed, 58 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/7 ethdev: add function to test port ownership
Applications using a port mask need a method to be able to test for (and reject) ethdev ports that are in use for other purposes.
--- lib/librte_ethdev/rte_ethdev.c | 9 +++++++++ lib/librte_ethdev/rte_ethdev.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 3 files changed, 27 insertions(+)
lib/librte_ethdev/rte_ethdev.c +9 -0
@@ -685,6 +685,15 @@ rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id)return ret; } +int +rte_eth_dev_is_owned_by (uint16_t port_id,uint64_t owner_id) +{ +if (!rte_eth_dev_is_valid_port (port_id)) +return 0 ; + +return rte_eth_devices[port_id].data->owner.id == owner_id; +} +int rte_eth_dev_owner_delete (const uint64_t owner_id) {
lib/librte_ethdev/rte_ethdev.h +15 -0
@@ -1530,6 +1530,21 @@ uint64_t rte_eth_find_next_owned_by(uint16_t port_id, (unsigned int )p < (unsigned int )RTE_MAX_ETHPORTS ; \ p = rte_eth_find_next_owned_by(p + 1, o)) +/** +* Test if a port is owned +* +* @param port_id +* The port identifier of the Ethernet device +* @param owner_id +* The owner identifier. +* RTE_ETH_DEV_NO_OWNER means test if port is not owned. +* @return +* - 0 if port is out of range or not owned by owner_id +* - 1 if device is associated with owner_id +*/ +__rte_experimental +int rte_eth_dev_is_owned_by(uint16_t port_id, uint64_t owner_id); +/** * Iterates over valid ethdev ports. *
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -230,4 +230,7 @@ EXPERIMENTAL { # added in 20.02 rte_flow_dev_dump; + + # added in 20.05 + rte_eth_dev_is_owned_by; };
Signature · 1 line
2.20.1
PATCH 2/7 examples/l2fwd-cat: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + 3 files changed, 6 insertions(+)
examples/l2fwd-cat/Makefile +2 -0
@@ -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)
examples/l2fwd-cat/l2fwd-cat.c +3 -0
@@ -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 )
examples/l2fwd-cat/meson.build +1 -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
Signature · 1 line
2.20.1
PATCH 3/7 examples/l3fwd: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd.
--- examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 4 ++++ examples/l3fwd/meson.build | 1 + 3 files changed, 8 insertions(+)
examples/l3fwd/Makefile +3 -0
@@ -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)
examples/l3fwd/main.c +4 -0
@@ -221,6 +221,10 @@ check_port_config(void)printf ("port %u is not present on the board\n" , portid);return -1 ; } +if (!rte_eth_dev_is_owned_by (portid,RTE_ETH_DEV_NO_OWNER )) { +printf ("port %u is already in use\n" , portid); +return -1 ; + } }return 0 ; }
examples/l3fwd/meson.build +1 -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 deps += ['hash', 'lpm', 'eventdev'] sources = files( 'l3fwd_em.c', 'l3fwd_lpm.c', 'l3fwd_event.c',
Signature · 1 line
2.20.1
PATCH 4/7 examples/l3fwd-acl: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + 3 files changed, 8 insertions(+)
examples/l3fwd-acl/Makefile +3 -0
@@ -20,7 +20,9 @@ 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)
@@ -51,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/l3fwd-acl/main.c +4 -0
@@ -1470,6 +1470,10 @@ check_port_config(void)printf ("port %u is not present on the board\n" , portid);return -1 ; } +if (!rte_eth_dev_is_owned_by (portid,RTE_ETH_DEV_NO_OWNER )) { +printf ("port %u is already in use\n" , portid); +return -1 ; + } }return 0 ; }
examples/l3fwd-acl/meson.build +1 -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 deps += ['acl', 'lpm', 'hash'] sources = files( 'main.c'
Signature · 1 line
2.20.1
PATCH 5/7 examples/l3fwd-power: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd.
--- examples/l3fwd-power/main.c | 4 ++++ 1 file changed, 4 insertions(+)
examples/l3fwd-power/main.c +4 -0
@@ -1396,6 +1396,10 @@ check_port_config(void) portid);return -1 ; } +if (!rte_eth_dev_is_owned_by (portid,RTE_ETH_DEV_NO_OWNER )) { +printf ("port %u is already in use\n" , portid); +return -1 ; + } }return 0 ; }
Signature · 1 line
2.20.1
PATCH 6/7 examples/tep_termination: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/tep_termination/Makefile | 2 ++ examples/tep_termination/main.c | 2 +- examples/tep_termination/meson.build | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
examples/tep_termination/Makefile +2 -0
@@ -26,6 +26,7 @@ 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 CFLAGS += -Wno-deprecated-declarations build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
@@ -61,6 +62,7 @@ endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-deprecated-declarations +CFLAGS += -DALLOW_EXPERIMENTAL_API include $(RTE_SDK)/mk/rte.extapp.mk endif
examples/tep_termination/main.c +1 -1
@@ -507,7 +507,7 @@ check_ports_num(unsigned max_nb_ports) }for (portid =0 ; portid < nb_ports; portid++) { -if (!rte_eth_dev_is_valid_port (ports[portid])) { +if (!rte_eth_dev_is_owned_by (portid,RTE_ETH_DEV_NO_OWNER )) {RTE_LOG (INFO ,VHOST_PORT ,"\nSpecified port ID(%u) is not valid\n" , ports[portid]);
examples/tep_termination/meson.build +1 -0
@@ -9,6 +9,7 @@ if not is_linux build = false endif +allow_experimental_apis = true deps += ['hash', 'vhost'] cflags += '-Wno-deprecated-declarations' sources = files(
Signature · 1 line
2.20.1
PATCH 7/7 examples/vhost: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/vhost/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vhost/main.c +1 -1
@@ -669,7 +669,7 @@ static unsigned check_ports_num(unsigned nb_ports) }for (portid =0 ; portid < num_ports; portid ++) { -if (!rte_eth_dev_is_valid_port (ports[portid])) { +if (!rte_eth_dev_is_owned_by (portid,RTE_ETH_DEV_NO_OWNER )) {RTE_LOG (INFO ,VHOST_PORT ,"\nSpecified port ID(%u) is not valid\n" , ports[portid]);
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 1/7] ethdev: add function to test port ownership
In reply to Stephen HemmingerHi Stephen
From: Stephen Hemminger
Quoted 3 lines
Applications using a port mask need a method to be able to test for (and reject) ethdev ports that are in use for other purposes.
There is already function which is thread safe to get this information:rte_eth_dev_owner_get.
I don't think we need one more.
Quoted 70 lines
Fixes 5b7ba31148a8 ("ethdev: add port ownership")Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 9 +++++++++ lib/librte_ethdev/rte_ethdev.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 3 files changed, 27 insertions(+)lib/librte_ethdev/rte_ethdev.c +7
-0@@ -685,6 +685,15 @@ rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id) return ret; } +int +rte_eth_dev_is_owned_by (uint16_t port_id,uint64_t owner_id) { +if (!rte_eth_dev_is_valid_port (port_id)) +return 0 ; + +return rte_eth_devices[port_id].data->owner.id == owner_id; } +int rte_eth_dev_owner_delete(const uint64_t owner_id) { diff --git
a/lib/librte_ethdev/rte_ethdev.hb/lib/librte_ethdev/rte_ethdev.hindexd1a593ad112a..91a8f9578282100644lib/librte_ethdev/rte_ethdev.h +15
-0@@ -1530,6 +1530,21 @@ uint64_t rte_eth_find_next_owned_by(uint16_t port_id, (unsigned int )p < (unsigned int )RTE_MAX_ETHPORTS ; \ p = rte_eth_find_next_owned_by(p + 1, o)) +/** +* Test if a port is owned +* +* @param port_id +* The port identifier of the Ethernet device +* @param owner_id +* The owner identifier. +* RTE_ETH_DEV_NO_OWNER means test if port is not owned. +* @return +* - 0 if port is out of range or not owned by owner_id +* - 1 if device is associated with owner_id +*/ +__rte_experimental +int rte_eth_dev_is_owned_by(uint16_t port_id, uint64_t owner_id); +/** * Iterates over valid ethdev ports. *
lib/librte_ethdev/rte_ethdev_version.map +3
-1@@ -230,4 +230,7 @@ EXPERIMENTAL { # added in 20.02 rte_flow_dev_dump; + + # added in 20.05 + rte_eth_dev_is_owned_by; }; --2.20.1
Re: [dpdk-dev] [PATCH 2/7] examples/l2fwd-cat: block attempts to use owned ports
In reply to Stephen HemmingerHi 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.
Quoted 60 lines
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")Signed-off-by Stephen Hemminger <[email protected]>--- examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + 3 files changed, 6 insertions(+)examples/l2fwd-cat/Makefile +1
-0@@ -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-errorsexamples/l2fwd-cat/Makefile +1
-0+CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -I$(PQOS_INSTALL_PATH)/../include LDLIBS += -L$(PQOS_INSTALL_PATH)examples/l2fwd-cat/l2fwd- renamed from examples/l2fwd-cat/l2fwd-cat.c +0
-0
cat.cindex6838f288c621..c1c59b2d81f2100644examples/l2fwd-cat/l2fwd-cat.c +3
-0@@ -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);examples/l2fwd-cat/l2fwd-cat.c +0
-0if (retval !=0 )examples/l2fwd- renamed from examples/l2fwd-cat/meson.build +0
-0cat/meson.build index
4e2777a03358..5c062c1354e3100644examples/l2fwd-cat/meson.build +2
-1@@ -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
v2 cover check for owned ports in portmask
In reply to Stephen HemmingerThe failsafe, bonding, and netvsc PMD use eth dev port ownership to control sub devices. These sub devices are hidden in the normal iteration over ports but some applications use a direct port mask. In these cases, user may still (incorrectly) try to directly use the sub devices.
This patch set introduces a helper function to check if a port is under ownership. And the follow on patches use that.
An alternative proposed in earlier discussion is to have each application try and own the port. But this solution would be more invasive, and does not handle the case if secondary process exits prematurely without releasing ownership. It makes more sense to keep the concept of ownership as strictly part of the device model and not part of the application layer.
v2 - rename the helper function and use rte_eth_dev_owner_get
Stephen Hemminger (6):
rte_ethdev: add function to check if device is owned examples/l2fwd-cat: block attempts to use owned ports examples/l3fwd: block attempts to use owned ports examples/l3fwd-acl: block attempts to use owned ports examples/l3fwd-power: block attempts to use owned ports examples/tep_termination: block attempts to use owned ports
examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + examples/l3fwd-power/main.c | 4 ++++ examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 5 +++++ examples/l3fwd/meson.build | 1 + examples/tep_termination/Makefile | 2 ++ examples/tep_termination/main.c | 2 +- examples/tep_termination/meson.build | 1 + lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ lib/librte_ethdev/rte_ethdev.h | 13 +++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 16 files changed, 59 insertions(+), 1 deletion(-)
Signature · 1 line
2.20.1
PATCH v2 1/6 rte_ethdev: add function to check if device is owned
This is a simple helper function to check if device is owned (being used as a sub-device). It is more convienent than having applications call rte_eth_dev_owner_get and check the result.
---
v2 - rename the helper function and use rte_eth_dev_owner_get
lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ lib/librte_ethdev/rte_ethdev.h | 13 +++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 3 files changed, 28 insertions(+)
lib/librte_ethdev/rte_ethdev.c +12 -0
@@ -737,6 +737,18 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)return ret; } +int +rte_eth_dev_is_owned (uint16_t port_id) +{ +struct rte_eth_dev_owner owner; +int ret; + + ret =rte_eth_dev_owner_get (port_id, &owner); +if (ret ==0 ) + ret = (owner.id !=RTE_ETH_DEV_NO_OWNER ); +return ret; +} +int rte_eth_dev_socket_id (uint16_t port_id) {
lib/librte_ethdev/rte_ethdev.h +13 -0
@@ -1693,6 +1693,19 @@ __rte_experimentalint rte_eth_dev_owner_get (const uint16_t port_id,struct rte_eth_dev_owner *owner); +/** +* Check if port_id is part of a sub-device +* +* @param port_id +* The port identifier of the Ethernet device +* @return +* - 1 if device is associated with an owner +* - 0 if port is not owned +* - negative errno value on error. +*/ +__rte_experimental +int rte_eth_dev_is_owned(uint16_t port_id); +/** * Get the number of ports which are usable for the application. *
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -230,4 +230,7 @@ EXPERIMENTAL { # added in 20.02 rte_flow_dev_dump; + + # added in 20.05 + rte_eth_dev_is_owned; };
Signature · 1 line
2.20.1
PATCH v2 2/6 examples/l2fwd-cat: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + 3 files changed, 6 insertions(+)
examples/l2fwd-cat/Makefile +2 -0
@@ -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)
examples/l2fwd-cat/l2fwd-cat.c +3 -0
@@ -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 (portid)) +return -1 ; +/* Configure the Ethernet device. */ retval =rte_eth_dev_configure (port, rx_rings, tx_rings, &port_conf);if (retval !=0 )
examples/l2fwd-cat/meson.build +1 -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
Signature · 1 line
2.20.1
PATCH v2 3/6 examples/l3fwd: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd.
--- examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 5 +++++ examples/l3fwd/meson.build | 1 + 3 files changed, 9 insertions(+)
examples/l3fwd/Makefile +3 -0
@@ -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)
examples/l3fwd/main.c +5 -0
@@ -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_is_owned (portid)) { +printf ("port %u is already in use\n" , portid); +return -1 ; + } }return 0 ; }
examples/l3fwd/meson.build +1 -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 deps += ['hash', 'lpm', 'eventdev'] sources = files( 'l3fwd_em.c', 'l3fwd_lpm.c', 'l3fwd_event.c',
Signature · 1 line
2.20.1
PATCH v2 4/6 examples/l3fwd-acl: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + 3 files changed, 8 insertions(+)
examples/l3fwd-acl/Makefile +3 -0
@@ -20,7 +20,9 @@ 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)
@@ -51,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/l3fwd-acl/main.c +4 -0
@@ -1470,6 +1470,10 @@ check_port_config(void)printf ("port %u is not present on the board\n" , portid);return -1 ; } +if (rte_eth_dev_is_owned (portid)) { +printf ("port %u is already in use\n" , portid); +return -1 ; + } }return 0 ; }
examples/l3fwd-acl/meson.build +1 -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 deps += ['acl', 'lpm', 'hash'] sources = files( 'main.c'
Signature · 1 line
2.20.1
PATCH v2 5/6 examples/l3fwd-power: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd.
--- examples/l3fwd-power/main.c | 4 ++++ 1 file changed, 4 insertions(+)
examples/l3fwd-power/main.c +4 -0
@@ -1396,6 +1396,10 @@ check_port_config(void) portid);return -1 ; } +if (rte_eth_dev_is_owned (portid)) { +printf ("port %u is already in use\n" , portid); +return -1 ; + } }return 0 ; }
Signature · 1 line
2.20.1
PATCH v2 6/6 examples/tep_termination: block attempts to use owned ports
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/tep_termination/Makefile | 2 ++ examples/tep_termination/main.c | 2 +- examples/tep_termination/meson.build | 1 + 3 files changed, 4 insertions(+), 1 deletion(-)
examples/tep_termination/Makefile +2 -0
@@ -26,6 +26,7 @@ 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 CFLAGS += -Wno-deprecated-declarations build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
@@ -61,6 +62,7 @@ endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-deprecated-declarations +CFLAGS += -DALLOW_EXPERIMENTAL_API include $(RTE_SDK)/mk/rte.extapp.mk endif
examples/tep_termination/main.c +1 -1
@@ -507,7 +507,7 @@ check_ports_num(unsigned max_nb_ports) }for (portid =0 ; portid < nb_ports; portid++) { -if (!rte_eth_dev_is_valid_port (ports[portid])) { +if (rte_eth_dev_is_owned (portid) !=0 ) {RTE_LOG (INFO ,VHOST_PORT ,"\nSpecified port ID(%u) is not valid\n" , ports[portid]);
examples/tep_termination/meson.build +1 -0
@@ -9,6 +9,7 @@ if not is_linux build = false endif +allow_experimental_apis = true deps += ['hash', 'vhost'] cflags += '-Wno-deprecated-declarations' sources = files(
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 0/6] check for owned ports in portmask
In reply to Stephen HemmingerFrom: Stephen Hemminger
Quoted 8 lines
The failsafe, bonding, and netvsc PMD use eth dev port ownership to control sub devices. These sub devices are hidden in the normal iteration over ports but some applications use a direct port mask. In these cases, user may still (incorrectly) try to directly use the sub devices.
This patch set introduces a helper function to check if a port is under ownership. And the follow on patches use that.
Quoted 7 lines
An alternative proposed in earlier discussion is to have each application try and own the port. But this solution would be more invasive, and does not handle the case if secondary process exits prematurely without releasing ownership. It makes more sense to keep the concept of ownership as strictly part of the device model and not part of the application layer.
v2 - rename the helper function and use
rte_eth_dev_owner_get
Quoted 28 lines
Stephen Hemminger (6):
rte_ethdev: add function to check if device is owned examples/l2fwd-cat: block attempts to use owned ports examples/l3fwd: block attempts to use owned ports examples/l3fwd-acl: block attempts to use owned ports examples/l3fwd-power: block attempts to use owned ports examples/tep_termination: block attempts to use owned portsexamples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + examples/l3fwd-power/main.c | 4 ++++ examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 5 +++++ examples/l3fwd/meson.build | 1 + examples/tep_termination/Makefile | 2 ++ examples/tep_termination/main.c | 2 +- examples/tep_termination/meson.build | 1 + lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ lib/librte_ethdev/rte_ethdev.h | 13 +++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 16 files changed, 59 insertions(+), 1 deletion(-)--
2.20.1
Re: [dpdk-dev] [PATCH v2 1/6] rte_ethdev: add function to check if device is owned
In reply to Stephen Hemminger16/03/2020 17:09, Stephen Hemminger:
Quoted 2 lines
This is a simple helper function to check if device is owned (being used as a sub-device).
I would suggest not restricting ownership to sub-device case.
Quoted 2 lines
It is more convienent than having
applications callrte_eth_dev_owner_getand check the result.
Yes it is more convenient but I don't like adding such simple wrapper.
I propose to extend rte_eth_dev_owner_get() behaviour:
if the owner pointer is NULL, the function returns 0 only if an owner (not RTE_ETH_DEV_NO_OWNER) is found.
So instead of using your wrapper:
if (rte_eth_dev_is_owned(port_id)) you can use: if (rte_eth_dev_owner_get(port_id, NULL) == 0)
[...]
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+int +rte_eth_dev_is_owned (uint16_t port_id) +{ +struct rte_eth_dev_owner owner; +int ret; + + ret =rte_eth_dev_owner_get (port_id, &owner); +if (ret ==0 ) + ret = (owner.id !=RTE_ETH_DEV_NO_OWNER ); +return ret; +}
Re: [dpdk-dev] [PATCH v2 1/6] rte_ethdev: add function to check if device is owned
Quoted 11 lines · On Wed, 01 Apr 2020 23:42:44 +0200 Thomas Monjalon <[email protected]> wrote:
16/03/2020 17:09, Stephen Hemminger:
Quoted 2 lines
This is a simple helper function to check if device is owned (being used as a sub-device).
I would suggest not restricting ownership to sub-device case.
Quoted 2 lines
It is more convienent than having
applications callrte_eth_dev_owner_getand check the result.Yes it is more convenient but I don't like adding such simple wrapper.
Quoted 8 lines
I propose to extend
rte_eth_dev_owner_get()behaviour:
if the owner pointer is NULL, the function returns 0 only if an owner (notRTE_ETH_DEV_NO_OWNER) is found.So instead of using your wrapper:
if (rte_eth_dev_is_owned(port_id)) you can use: if (rte_eth_dev_owner_get(port_id, NULL) == 0)
That is not how rte_eth_dev_owner_get works now.
Passing NULL to it would crash.
And if devices is not owned rte_eth_dev_owner_get() returns 0 and owner is set to a magic value. We could change the ABI for this since it is marked experimental. But that seems more risky.
Re: [dpdk-dev] [PATCH v2 1/6] rte_ethdev: add function to check if device is owned
02/04/2020 00:24, Stephen Hemminger:
Quoted 18 lines
Quoted 15 lines · On Wed, 01 Apr 2020 23:42:44 +0200 Thomas Monjalon <[email protected]> wrote:
16/03/2020 17:09, Stephen Hemminger:
Quoted 2 lines
This is a simple helper function to check if device is owned (being used as a sub-device).
I would suggest not restricting ownership to sub-device case.
Quoted 2 lines
It is more convienent than having
applications callrte_eth_dev_owner_getand check the result.Yes it is more convenient but I don't like adding such simple wrapper.
I propose to extend
rte_eth_dev_owner_get()behaviour:
if the owner pointer is NULL, the function returns 0 only if an owner (notRTE_ETH_DEV_NO_OWNER) is found.
Quoted 7 lines
Quoted 4 lines
So instead of using your wrapper:
if (rte_eth_dev_is_owned(port_id)) you can use: if (rte_eth_dev_owner_get(port_id, NULL) == 0)That is not how
rte_eth_dev_owner_getworks now.
Passing NULL to it would crash.
Indeed this is why I am proposing to extend it
and fill this case.
Quoted 3 lines
And if devices is not owned
rte_eth_dev_owner_get()returns 0 and owner is set to a magic value. We could change the ABI for this since it is marked experimental. But that seems more risky.
This is not an ABI change.
Just manage a case which was crashing previously.
v3 cover checking for owned ports in portmask
In reply to Stephen HemmingerThe failsafe, bonding, and netvsc PMD use eth dev port ownership to control sub devices. These sub devices are hidden in the normal iteration over ports but some applications use a direct port mask. In these cases, user may still (incorrectly) try to directly use the sub devices.
This patch set changes the rte_eth_dev_owner_get function so that it can be used to test for any ownership. And the follow on patches use that.
An alternative proposed in earlier discussion is to have each application try and own the port. But this solution would be more invasive, and does not handle the case if secondary process exits prematurely without releasing ownership. It makes more sense to keep the concept of ownership as strictly part of the device model and not part of the application layer.
v3 - use rte_eth_dev_owner_get directly, and change the function return
rework port setup in tep_termination example
v2 - rename the helper function and use rte_eth_dev_owner_get
Stephen Hemminger (6):
rte_ethdev: change rte_eth_dev_owner_get to return error if unowned examples/l2fwd-cat: make applicaton aware of port ownership examples/l3fwd: make applicaton aware of port ownership examples/l3fwd-acl: make applicaton aware of port ownership examples/l3fwd-power: make applicaton aware of port ownership examples/tep_termination: rework the port setup logic
drivers/net/failsafe/failsafe_eal.c | 4 +- drivers/net/netvsc/hn_vf.c | 11 ++--- examples/l2fwd-cat/Makefile | 2 + examples/l2fwd-cat/l2fwd-cat.c | 3 ++ examples/l2fwd-cat/meson.build | 1 + examples/l3fwd-acl/Makefile | 3 ++ examples/l3fwd-acl/main.c | 4 ++ examples/l3fwd-acl/meson.build | 1 + examples/l3fwd-power/main.c | 4 ++ examples/l3fwd/Makefile | 3 ++ examples/l3fwd/main.c | 5 ++ examples/l3fwd/meson.build | 1 + examples/tep_termination/Makefile | 2 + examples/tep_termination/main.c | 70 ++++++++++------------------ examples/tep_termination/meson.build | 1 + lib/librte_ethdev/rte_ethdev.c | 4 +- lib/librte_ethdev/rte_ethdev.h | 6 ++- 17 files changed, 69 insertions(+), 56 deletions(-)
Signature · 1 line
2.20.1
PATCH v3 1/6 rte_ethdev: change rte_eth_dev_owner_get to return error if unowned
For applications that want to check if device is owned, change the return value of rte_eth_dev_owner_get to return -ENOENT if there is no owner for the device.
Change the two drivers (failsafe and netvsc) that are using this experimental API to handle the new return value.
--- drivers/net/failsafe/failsafe_eal.c | 4 ++-- drivers/net/netvsc/hn_vf.c | 11 +++++------ lib/librte_ethdev/rte_ethdev.c | 4 +++- lib/librte_ethdev/rte_ethdev.h | 6 ++++-- 4 files changed, 14 insertions(+), 11 deletions(-)
drivers/net/failsafe/failsafe_eal.c +2 -2
@@ -63,8 +63,8 @@ fs_bus_init(struct rte_eth_dev *dev)* The NEW callback tried to take ownership, check * whether it succeed or didn't. */ -rte_eth_dev_owner_get (pid, &pid_owner); -if (pid_owner.id !=PRIV (dev)->my_owner.id) { +if (rte_eth_dev_owner_get (pid, &pid_owner) ==0 && + pid_owner.id !=PRIV (dev)->my_owner.id) { INFO("sub_device %d owner(%s_%016"PRIX64") is not my," " owner(%s_%016"PRIX64"), will try again later", i, pid_owner.name, pid_owner.id,
drivers/net/netvsc/hn_vf.c +5 -6
@@ -63,16 +63,15 @@ static int hn_vf_attach(struct hn_data *hv, uint16_t port_id) } ret =rte_eth_dev_owner_get (port_id, &owner); -if (ret <0 ) { -PMD_DRV_LOG (ERR ,"Can not find owner for port %d" , port_id); -return ret; - } - -if (owner.id !=RTE_ETH_DEV_NO_OWNER ) { +if (ret ==0 ) {PMD_DRV_LOG (ERR ,"Port %u already owned by other device %s" , port_id, owner.name);return -EBUSY ; } +if (ret != -ENOENT ) { +PMD_DRV_LOG (ERR ,"Can not find owner for port %d" , port_id); +return ret; + } ret =rte_eth_dev_owner_set (port_id, &hv->owner);if (ret <0 ) {
lib/librte_ethdev/rte_ethdev.c +3 -1
@@ -729,7 +729,9 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)RTE_ETHDEV_LOG (ERR ,"Port id %" PRIu16" is not allocated\n" , port_id); ret = -ENODEV ; - }else { + }else if (ethdev->data->owner.id ==RTE_ETH_DEV_NO_OWNER ) { + ret = -ENOENT ; + }else if (owner !=NULL ) {rte_memcpy (owner, ðdev->data->owner,sizeof (*owner)); }
lib/librte_ethdev/rte_ethdev.h +4 -2
@@ -1685,9 +1685,11 @@ int rte_eth_dev_owner_delete(const uint64_t owner_id);* @param port_id * The port identifier. * @param owner -* The owner structure pointer to fill. +* The owner structure pointer to fill (optional can be NULL) * @return -* 0 on success, negative errno value on error.. +* 0 on success, +* -ENODEV if port_id is not valid +* -ENOENT if the device is ownerless. */ __rte_experimental int rte_eth_dev_owner_get(const uint16_t port_id,
Signature · 1 line
2.20.1
PATCH v3 2/6 examples/l2fwd-cat: make applicaton aware of port ownership
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + 3 files changed, 6 insertions(+)
examples/l2fwd-cat/Makefile +2 -0
@@ -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)
examples/l2fwd-cat/l2fwd-cat.c +3 -0
@@ -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 )
examples/l2fwd-cat/meson.build +1 -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
Signature · 1 line
2.20.1
PATCH v3 3/6 examples/l3fwd: make applicaton aware of port ownership
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd.
--- examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 5 +++++ examples/l3fwd/meson.build | 1 + 3 files changed, 9 insertions(+)
examples/l3fwd/Makefile +3 -0
@@ -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)
examples/l3fwd/main.c +5 -0
@@ -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 ; }
examples/l3fwd/meson.build +1 -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 deps += ['hash', 'lpm', 'eventdev'] sources = files( 'l3fwd_em.c', 'l3fwd_lpm.c', 'l3fwd_event.c',
Signature · 1 line
2.20.1
PATCH v3 4/6 examples/l3fwd-acl: make applicaton aware of port ownership
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application.
--- examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + 3 files changed, 8 insertions(+)
examples/l3fwd-acl/Makefile +3 -0
@@ -20,7 +20,9 @@ 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)
@@ -51,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
examples/l3fwd-acl/main.c +4 -0
@@ -1470,6 +1470,10 @@ 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 ; }
examples/l3fwd-acl/meson.build +1 -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 deps += ['acl', 'lpm', 'hash'] sources = files( 'main.c'
Signature · 1 line
2.20.1
PATCH v3 5/6 examples/l3fwd-power: make applicaton aware of port ownership
In reply to Stephen HemmingerIf a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd.
--- examples/l3fwd-power/main.c | 4 ++++ 1 file changed, 4 insertions(+)
examples/l3fwd-power/main.c +4 -0
@@ -1396,6 +1396,10 @@ check_port_config(void) 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 ; }
Signature · 1 line
2.20.1
PATCH v3 6/6 examples/tep_termination: rework the port setup logic
In reply to Stephen HemmingerThe handling of ports in this application had many problems. It was checking for things that can never happen with current DPDK library (like rte_ethdev_avail_count() >= RTE_MAX_ETHPORTS) and it was not checking if the port was owned and should not be used directly. Also the variable nb_ports was used as both local and global variable.
Fix by rewriting the initialization logic to iterate over valid ports and check if there are any leftovers.
--- examples/tep_termination/Makefile | 2 + examples/tep_termination/main.c | 70 ++++++++++------------------ examples/tep_termination/meson.build | 1 + 3 files changed, 28 insertions(+), 45 deletions(-)
examples/tep_termination/Makefile +2 -0
@@ -26,6 +26,7 @@ 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 CFLAGS += -Wno-deprecated-declarations build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
@@ -61,6 +62,7 @@ endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-deprecated-declarations +CFLAGS += -DALLOW_EXPERIMENTAL_API include $(RTE_SDK)/mk/rte.extapp.mk endif
examples/tep_termination/main.c +25 -45
113 lines not on this page · raw message
examples/tep_termination/meson.build +1 -0
@@ -9,6 +9,7 @@ if not is_linux build = false endif +allow_experimental_apis = true deps += ['hash', 'vhost'] cflags += '-Wno-deprecated-declarations' sources = files(
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 1/6] rte_ethdev: change rte_eth_dev_owner_get to return error if unowned
In reply to Stephen HemmingerQuoted 8 lines · Stephen Hemminger
For applications that want to check if device is owned, change the return value of
rte_eth_dev_owner_getto return-ENOENTif there is no owner for the device.Change the two drivers (failsafe and netvsc) that are using this experimental API to handle the new return value.
Signed-off-by Stephen Hemminger <[email protected]>
<...>
lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_owner_delete(const uint64_t owner_id); · line 1692
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +4
-2@@ -1685,9 +1685,11 @@ int rte_eth_dev_owner_delete(const uint64_t owner_id);* @param port_id * The port identifier. * @param owner -* The owner structure pointer to fill. +* The owner structure pointer to fill (optional can be NULL) * @return -* 0 on success, negative errno value on error.. +* 0 on success, +* -ENODEV if port_id is not valid +* -ENOENT if the device is ownerless.
Not sure if port not having an owner is error, I understand the motivation but what about send a special value, like 1, instead of error:
0: get owner success, port owned
1: get owner success, port not owned-ENODEV: get owner failed, port_id is not valid
Re: [dpdk-dev] [dpdk-stable] [PATCH v3 2/6] examples/l2fwd-cat: make applicaton aware of port ownership
In reply to Stephen HemmingerQuoted 7 lines · Stephen Hemminger
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")Signed-off-by Stephen Hemminger <[email protected]>
<...>
examples/l2fwd-cat/l2fwd-cat.c port_init(uint16_t port, struct rte_mempool *mbuf_pool) · line 46
Quoted 6 lines
examples/l2fwd-cat/l2fwd-cat.c +2
-0@@ -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.
Re: [dpdk-dev] [dpdk-stable] [PATCH v3 6/6] examples/tep_termination: rework the port setup logic
In reply to Stephen HemmingerQuoted 33 lines · Stephen Hemminger
The handling of ports in this application had many problems. It was checking for things that can never happen with current DPDK library (like
rte_ethdev_avail_count()>=RTE_MAX_ETHPORTS) and it was not checking if the port was owned and should not be used directly. Also the variablenb_portswas used as both local and global variable.Fix by rewriting the initialization logic to iterate over valid ports and check if there are any leftovers.
Fixes a50245ede72a ("examples/tep_term: initialize VXLAN sample")Signed-off-by Stephen Hemminger <[email protected]>--- examples/tep_termination/Makefile | 2 + examples/tep_termination/main.c | 70 ++++++++++------------------ examples/tep_termination/meson.build | 1 + 3 files changed, 28 insertions(+), 45 deletions(-)examples/tep_termination/Makefile +1
-0@@ -26,6 +26,7 @@ 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 CFLAGS += -Wno-deprecated-declarations build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
examples/tep_termination/Makefile endif · line 65
Quoted 4 lines
examples/tep_termination/Makefile +1
-0@@ -61,6 +62,7 @@ endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-deprecated-declarations +CFLAGS += -DALLOW_EXPERIMENTAL_API
Why 'ALLOW_EXPERIMENTAL_API' added in this patch, what is the experimental API started to use?
<...>
examples/tep_termination/Makefile endif
Quoted 7 lines
examples/tep_termination/Makefile +0
-6- for (portid = 0; portid < nb_ports; portid++) { - if (!rte_eth_dev_is_valid_port(ports[portid])) { - RTE_LOG(INFO, VHOST_PORT, - "\nSpecified port ID(%u) is not valid\n", - ports[portid]); - ports[portid] = INVALID_PORT_ID;
'INVALID_PORT_ID' macro seems can be removed now.