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 EA34FA0559; Mon, 16 Mar 2020 17:09:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD4411C0AF; Mon, 16 Mar 2020 17:09:35 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 28D9E1C068 for ; Mon, 16 Mar 2020 17:09:34 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id f8so8205797plt.10 for ; Mon, 16 Mar 2020 09:09:34 -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=ujBoBJ6MksRkTGo8WjSaOKef1dILNKZPNJSRgokxTbQ=; b=ggsygWJYWGuZAMapdLMh7hLXhDfAIy5X/r+uYZezZMHYHbDVXA5IzRipbp9pBZQXtT 4yx/f080WrsMHSIwculC0YFIYKBxqojOAf3g5vtgl3yhynOhMwH7Oxgp5S56Zkx7yhPF VRjB0DF1MH4nFbrjZ6VE0yM+HJ+haM1VerRTkaw4zyogPMEGgNv9lGoXa/L2vEh6aRRS xkYwvoxZ+GBqqvtjaVzjYOpkv8xZOgkrlg2k0Ey1I7BgnKkugXvFqEsgOMIjSIS5LmM/ aXUjuUApVH8FyWxGNb4tFcQnkwbFtcz2cDoBcHrIztnC1urIaziYqf7w/oHysmN9zuBw s0mw== 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=ujBoBJ6MksRkTGo8WjSaOKef1dILNKZPNJSRgokxTbQ=; b=ZQzx7V3pfgiqS/sH9/tQsnS4gD3q4CyM6Zz/qWec1gu/BifAdPWv40u4iH4nSXsWEO vwFZgJfExb60vG6u8mWAwYNxv/k5qpcaif4dcTwBOnYYv7TWqxO+hB742yE7NzMyyDXB 7vFjUtKqThET/uQFYjh1gm5fMeIy/oDiIq6SOwJH002494w+709UyXl/NLAu8rmxY7Kt Md738wv8fq9vvGzitoh1pLaautbfY9cPjaaPUM0ENIUs7WPVkP4vdadbuf0Ek6b+E5RE o41tTjD9KR0CuH2xSpOuz5RBg6GPV/gDHbuV5UUvE4IDPfRL+JWWb90pVsMnm9mPH4pn O0yg== X-Gm-Message-State: ANhLgQ2DIIuVNbqpYzd7iViSA24H6dtYWj+wfuG8uaYHCbApHxMoj2R4 N/VWOnSRLIVbex0ksuYSA14/yWkK/OE= X-Google-Smtp-Source: ADFU+vu1/ewB19w7ZGlIiMaMXmTzW3q0Isyx1vzBW+z2IBBIt54laGxvRWmRU1UpbdAhk0jwWGMi2w== X-Received: by 2002:a17:902:9a42:: with SMTP id x2mr28600951plv.194.1584374972865; Mon, 16 Mar 2020 09:09:32 -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 w17sm361952pfi.59.2020.03.16.09.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 09:09:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 16 Mar 2020 09:09:18 -0700 Message-Id: <20200316160923.5335-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316160923.5335-1-stephen@networkplumber.org> References: <20200312172047.19973-1-stephen@networkplumber.org> <20200316160923.5335-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/6] rte_ethdev: add function to check if device is owned 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" 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. Signed-off-by: Stephen Hemminger --- 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(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 774c721b3484..6e2d0110f65e 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -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) { diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d1a593ad112a..3a8a4bcde4b7 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1693,6 +1693,19 @@ __rte_experimental int 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. * diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 3f32fdecf722..435df2dba149 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; }; -- 2.20.1