From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 250BFA056E for ; Thu, 12 Mar 2020 18:20:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F231E1C000; Thu, 12 Mar 2020 18:20:57 +0100 (CET) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id DE2E93B5 for ; Thu, 12 Mar 2020 18:20:55 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id w12so2904761pll.13 for ; Thu, 12 Mar 2020 10:20:55 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jAMlZhKs00QGjTkXwXYH7pTdJ2cb1OdnFOJC+pOtewo=; b=T0rYkyX/apGVYlUkQEF53TtS/fxUUaStIRIznjETKz4pE0x5pj0+94oswP9WYyAUxX VnVOmXm5g8H2nhMA0OXF/5QDg5TVHDyVZjIm7zkFWqGjLppVb/r6h61tlEYnqT2OS3x4 T9HeEMslslIQ7PLNZ/R92UoFJBhreisQy3NRAmavVqOmw3Fr1XwjxvOlSt3az0ppbmAg YdMr6cjVxqW6TMUNlSYP2KK3X7ZkeziUVtHZKgRmVIajlN8H8bArjE59uwM0lYvWi8T2 i30nApoW9KC+YyQK+PMJNf56S3x0UPxeRfP9bAZl9NVZU0YkU4H9ZtzUb2DT7j3U2iRs oMBA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jAMlZhKs00QGjTkXwXYH7pTdJ2cb1OdnFOJC+pOtewo=; b=fnGI8t0uLS+S8l4aBq7TIpmNyawRk6WXPZOxIkR6R/eVYFo2sI2w1PD0YFdOkjV47W fVQrA53Z9wQkCChk6AE27hrkttQhp9JayUPytxeU5LtqZiLfXCnDarOE9qbbKkvi9F4c WtH2weQIZ8lvuEirDWU4pzfDAFsVAj9MmsNUsplZfGqFTFAkENQwQdbpW349/Wf5BKn5 Bc3kmrhLHuZfqiGS7WgkMT2igEZZrJ+lTYZIfq+7Jo2VNmCEJVwKgdR50NEQv8iEpBF4 s/5A6st11HBu8lX5KnptDDsclnJLVSU6xt36nLGBY1qaXqZhBoAPTEIbSlzvR6CXBLUo T2oQ== X-Gm-Message-State: ANhLgQ22UO/rFVLotQ0G1qpCeRycQAA0fROMs9qNk4p9CJZ2WNq66nKs O5uKIsTF//B64tgozhzQTHQfUg== X-Google-Smtp-Source: ADFU+vucyRlnV6owRNPkWF1AJRxh4BEjo2r7Xlyyog9Xw9Z7Q85WI8CHLtO0qsaIEafIpIGK7Uzd5A== X-Received: by 2002:a17:902:db83:: with SMTP id m3mr9502100pld.166.1584033654916; Thu, 12 Mar 2020 10:20:54 -0700 (PDT) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id v1sm9447511pjy.35.2020.03.12.10.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 10:20:53 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , matan@mellanox.com, stable@dpdk.org Date: Thu, 12 Mar 2020 10:20:41 -0700 Message-Id: <20200312172047.19973-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312172047.19973-1-stephen@networkplumber.org> References: <20200312172047.19973-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 1/7] ethdev: add function to test port ownership X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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. Fixes: 5b7ba31148a8 ("ethdev: add port ownership") Cc: matan@mellanox.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- 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(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 774c721b3484..38f99f417dba 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -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.h b/lib/librte_ethdev/rte_ethdev.h index d1a593ad112a..91a8f9578282 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -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. * diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 3f32fdecf722..95231fe3410c 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -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