DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset
@ 2018-08-14  0:19 Stephen Hemminger
  2018-08-14  5:52 ` Matan Azrad
  2018-08-16 22:44 ` [dpdk-dev] [PATCH 0/2] ethdev: minor ownership changes Stephen Hemminger
  0 siblings, 2 replies; 18+ messages in thread
From: Stephen Hemminger @ 2018-08-14  0:19 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

The rte_eth_dev_owner_unset function is unusable because
it always returns -EINVAL. This is because the magic (unowned)
value is flagged as not valid.

Move the validation of owner into set and unset as
separate calls.

Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_ethdev/rte_ethdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 4c320250589a..9398550a1189 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -443,10 +443,6 @@ _rte_eth_dev_owner_set(const uint16_t port_id, const uint64_t old_owner_id,
 		return -ENODEV;
 	}
 
-	if (!rte_eth_is_valid_owner_id(new_owner->id) &&
-	    !rte_eth_is_valid_owner_id(old_owner_id))
-		return -EINVAL;
-
 	port_owner = &rte_eth_devices[port_id].data->owner;
 	if (port_owner->id != old_owner_id) {
 		RTE_ETHDEV_LOG(ERR,
@@ -475,6 +471,9 @@ rte_eth_dev_owner_set(const uint16_t port_id,
 {
 	int ret;
 
+	if (!rte_eth_is_valid_owner_id(owner->id))
+		return -EINVAL;
+
 	rte_eth_dev_shared_data_prepare();
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
@@ -492,6 +491,9 @@ rte_eth_dev_owner_unset(const uint16_t port_id, const uint64_t owner_id)
 			{.id = RTE_ETH_DEV_NO_OWNER, .name = ""};
 	int ret;
 
+	if (!rte_eth_is_valid_owner_id(owner_id))
+		return -EINVAL;
+
 	rte_eth_dev_shared_data_prepare();
 
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
-- 
2.18.0

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-08-27 13:01 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-14  0:19 [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset Stephen Hemminger
2018-08-14  5:52 ` Matan Azrad
2018-08-14 16:55   ` Stephen Hemminger
2018-08-14 19:46     ` Matan Azrad
2018-08-24 13:55       ` Ferruh Yigit
2018-08-24 14:42         ` Stephen Hemminger
2018-08-16 22:44 ` [dpdk-dev] [PATCH 0/2] ethdev: minor ownership changes Stephen Hemminger
2018-08-16 22:44   ` [dpdk-dev] [PATCH 1/2] ethdev: silence error message on rte_eth_dev_owner_unset Stephen Hemminger
2018-08-21 10:04     ` Matan Azrad
2018-08-21 15:45     ` [dpdk-dev] [PATCH v3] " Stephen Hemminger
2018-08-21 15:53       ` Matan Azrad
2018-08-27 13:01         ` Ferruh Yigit
2018-08-16 22:44   ` [dpdk-dev] [PATCH 2/2] ethdev: make rte_eth_is_valid_owner_id return bool Stephen Hemminger
2018-08-21 10:20     ` Matan Azrad
2018-08-21 15:06       ` Stephen Hemminger
2018-08-21 15:48         ` Matan Azrad
2018-08-21 18:31           ` Stephen Hemminger
2018-08-26  7:49             ` Matan Azrad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).