From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 1CCE62B83 for ; Tue, 14 Aug 2018 02:19:30 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id b11-v6so8419256pfo.3 for ; Mon, 13 Aug 2018 17:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=DqSQhoLw/TUj/38Yoi4cVivK7O22XXxkatHqcF/EzEo=; b=k53DBGqgWA8bGo8XjbdaB6JtnGzIzLzo1sOWRnAeOKCQ3rLTlfjrW4CtPCyUpoJGb6 GYlrNqPMTAJDmYry0n7hx15NBOUWRy4FDKPSZ0h+9YwYz/UvHdyv2i/r0Ui2wc3U0Pge GPupDnj3XzEPKDtiWsipyL+hSTUfMOE2UFeOi0nVAIGtjLjljjR2O/IWdyXrnjIj7QdR nGexCl0KoCQxCjJnLqIBQyy4RDQYatRHwcB/r5quUC4CSoxyDPG0LRey6JOoLf8upgPE ZNtJvXT5wa1Q3L3RU7IPLMLAhZ2sBp21Qd6M8pU7nwj7BeVSWA0rNqPEevgdU7RSQ2KU Z78A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DqSQhoLw/TUj/38Yoi4cVivK7O22XXxkatHqcF/EzEo=; b=AEJvvXpLzNMJbesJ2eaTyMVYBoER7Vno1n1xaR7wv429F4o5JHnnte90e+DveNq/Cb 6e6vo71lPCeLB5gyxG7tCxuAQtSo2qpYRXh+B7czUDOdt2C0UtaU0O8QRN5Zvv7U4kao 1QsldPq4XTRAg8kMBIS7HkTZLZN6Pv/j6yr9LHv86ocKpGF8/HgHfj4H62cf5+tiUmjc pSPERg3kVwARhyv1S2kUgb8CYryL52rgWlvU713UpDMzt16rrjvsDHQz4l6jESVBDV1X 52CVhYG4upZdqygE76QHCUVRRvh/MM8dtY6E5k6CECPVgPt+6T6Luoxqm1a56s0Bhsmu QTAA== X-Gm-Message-State: AOUpUlHF7tcZBOwHMnkgC8pC7kADpMz8tB8Ds8p1EsHeXQEBHRmHLxCX UEV+zHi4qQXLcjVXcYfitQkvKctLIwpSFQ== X-Google-Smtp-Source: AA+uWPx105NMu1D1w0LeZJdPc3kglpaghC6jgAqqP5g3N3NR5/7/Ukbm0NofF1fr0MiuAQklGQC0gw== X-Received: by 2002:a63:9f0a:: with SMTP id g10-v6mr18904563pge.324.1534205969712; Mon, 13 Aug 2018 17:19:29 -0700 (PDT) Received: from xeon-e3.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id m15-v6sm32471650pfk.149.2018.08.13.17.19.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 17:19:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 13 Aug 2018 17:19:26 -0700 Message-Id: <20180814001926.19630-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.18.0 Subject: [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2018 00:19:32 -0000 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 --- 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