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 09C54A056D; Thu, 12 Mar 2020 18:21:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A27F1C00E; Thu, 12 Mar 2020 18:20:58 +0100 (CET) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id 5C5F63B5 for ; Thu, 12 Mar 2020 18:20:56 +0100 (CET) Received: by mail-pj1-f68.google.com with SMTP id f15so2818568pjq.2 for ; Thu, 12 Mar 2020 10:20:56 -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=k2BET3TV0/rUuYMnnhFNCFyt8UbE4o/4ooL0fnRIFozqsR4AH0TZ0sTCuocxJUNCGp O8SR0xwoTDBnuCKq82h+N1QRxcpWJ39ZKAdpcOo6mdFvVS7wJA6VFdLDQEl3GwTmzDhM afgo4WuUlCTul+wIQuntvwoB5WadcliA+5+Etfp+J3HJgglI1B94LcPFeBXnyAbWneCC BGGv8FryeBzdQRp25O7eSIHu+1t1s4LtuV8HfJ8LaGwHPuX/BVrewLSTOkrqFVsMnAu6 dVUUvtDmYbjePO6so/PLp1ZP79UppR2LhwwyX6G/ukfG09mGBKQdUQPdahOMsNEu0lOD JbLg== X-Gm-Message-State: ANhLgQ1068Q9CKU4FXloyRvWijUt7xT4ZVLjO5Z31nmcyFFB3rf7fXLb j6jj5fOKXAGWc+5g4iaWN2jeJIq9JwM= 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-dev] [PATCH 1/7] ethdev: add function to test port ownership 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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