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 CBDE6A0562; Thu, 2 Apr 2020 19:20:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B9A2D1BE96; Thu, 2 Apr 2020 19:20:06 +0200 (CEST) Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by dpdk.org (Postfix) with ESMTP id BEB751BE95 for ; Thu, 2 Apr 2020 19:20:04 +0200 (CEST) Received: by mail-pj1-f67.google.com with SMTP id m15so1760887pje.3 for ; Thu, 02 Apr 2020 10:20:04 -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=Dni1E08RrXy/pBTuiDbFkCqpLf0DRVsUw8wv/ugDYdI=; b=snjEnk+dSnOAAXGT/wtQdj+rRO/DYcZMfrhI2vQOxLwa83iH23xQDZp90CwsWLxIIW jZ9sl0DGRjVPCF3jhMFlOKTCUoBeg9eYoqoqWcxBc05IvfAiuugufiDbI3PJGQM6Xpw1 xfCF2iYr61H+FNGpFgK7fINZetjhw/JD+fXOJmwciTVoTqBupjrf61iWGds6cQhu7TEx rt+HIZQ1B9BpO8k027a03fLQJU96CnUSJJQnd/eiWEt6AfrnLMm7RA6xhHhg/Pc4vaRB ZESz7c6XIJXwJwxniFySHTeU5AioayhvdY86VEJG4qGBc19krxtD7Hh43yfRXb+wiqW7 nUlQ== 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=Dni1E08RrXy/pBTuiDbFkCqpLf0DRVsUw8wv/ugDYdI=; b=BVPZrmpy6GJ47pjzVoR57njAGsdMdFwdTHZcHJqqn+FzdGWAOuDNmvkc/pYdtOrO5M EE9P6Rn2PJmAyKUin0x1XDrvxu2rqkBs5lslYnCkGb2yR7bISXtBRBr45DA2PrfRK3wx 0Duq+0EtZduArqAaC+6kEk2D6vzEVBKVEGJeSQc+LUr6QC+sYgJ1DmPrP0qpCp82pmqn VQ209k9bbWywxjJMTuN06VWAbL2lxDJpPhlr+01mZkqYW8CvA/DZ3r9kWMJ7C4eJxX4b qVPuPE+ccvN9KLwpRlu6DNQ0gedAEYKxTPyVfbUnfY46bTWuClG/Qgc8xPQWOR3tPeLf rKWA== X-Gm-Message-State: AGi0PuZH0gP5Kr2x/gDx0f5AKOFtCazYWR+VVDKZEhTHmS3uhwG2lOJA CcK98ePH7w1KMUwOPq0Sg2sFJVAvQUbuKQ== X-Google-Smtp-Source: APiQypLIfq319ZqB5Ri5ypbrqEP+DqUk/DPhqmy1ckmyJBxrfKPZ2Ornkw+u3xNkrqGBgXwVB1/dKg== X-Received: by 2002:a17:902:bb91:: with SMTP id m17mr3771146pls.223.1585848002408; Thu, 02 Apr 2020 10:20:02 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id y28sm4152347pfp.128.2020.04.02.10.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:20:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 2 Apr 2020 10:19:48 -0700 Message-Id: <20200402171953.13356-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402171953.13356-1-stephen@networkplumber.org> References: <20200312172047.19973-1-stephen@networkplumber.org> <20200402171953.13356-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 1/6] rte_ethdev: change rte_eth_dev_owner_get to return error if unowned 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" For applications that want to check if device is owned, change the return value of rte_eth_dev_owner_get to return -ENOENT if there is no owner for the device. Change the two drivers (failsafe and netvsc) that are using this experimental API to handle the new return value. Signed-off-by: Stephen Hemminger --- drivers/net/failsafe/failsafe_eal.c | 4 ++-- drivers/net/netvsc/hn_vf.c | 11 +++++------ lib/librte_ethdev/rte_ethdev.c | 4 +++- lib/librte_ethdev/rte_ethdev.h | 6 ++++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index b9fc508673f2..8a1b5e068840 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -63,8 +63,8 @@ fs_bus_init(struct rte_eth_dev *dev) * The NEW callback tried to take ownership, check * whether it succeed or didn't. */ - rte_eth_dev_owner_get(pid, &pid_owner); - if (pid_owner.id != PRIV(dev)->my_owner.id) { + if (rte_eth_dev_owner_get(pid, &pid_owner) == 0 && + pid_owner.id != PRIV(dev)->my_owner.id) { INFO("sub_device %d owner(%s_%016"PRIX64") is not my," " owner(%s_%016"PRIX64"), will try again later", i, pid_owner.name, pid_owner.id, diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c index 7a3734cadfa4..b56f60b28a62 100644 --- a/drivers/net/netvsc/hn_vf.c +++ b/drivers/net/netvsc/hn_vf.c @@ -63,16 +63,15 @@ static int hn_vf_attach(struct hn_data *hv, uint16_t port_id) } ret = rte_eth_dev_owner_get(port_id, &owner); - if (ret < 0) { - PMD_DRV_LOG(ERR, "Can not find owner for port %d", port_id); - return ret; - } - - if (owner.id != RTE_ETH_DEV_NO_OWNER) { + if (ret == 0) { PMD_DRV_LOG(ERR, "Port %u already owned by other device %s", port_id, owner.name); return -EBUSY; } + if (ret != -ENOENT) { + PMD_DRV_LOG(ERR, "Can not find owner for port %d", port_id); + return ret; + } ret = rte_eth_dev_owner_set(port_id, &hv->owner); if (ret < 0) { diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 0854ef883270..0c4645cf9832 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -729,7 +729,9 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner) RTE_ETHDEV_LOG(ERR, "Port id %"PRIu16" is not allocated\n", port_id); ret = -ENODEV; - } else { + } else if (ethdev->data->owner.id == RTE_ETH_DEV_NO_OWNER) { + ret = -ENOENT; + } else if (owner != NULL) { rte_memcpy(owner, ðdev->data->owner, sizeof(*owner)); } diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d1a593ad112a..0e59d39de54c 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1685,9 +1685,11 @@ int rte_eth_dev_owner_delete(const uint64_t owner_id); * @param port_id * The port identifier. * @param owner - * The owner structure pointer to fill. + * The owner structure pointer to fill (optional can be NULL) * @return - * 0 on success, negative errno value on error.. + * 0 on success, + * -ENODEV if port_id is not valid + * -ENOENT if the device is ownerless. */ __rte_experimental int rte_eth_dev_owner_get(const uint16_t port_id, -- 2.20.1