From patchwork Thu Apr 2 17:19:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 67664 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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, From patchwork Thu Apr 2 17:19:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 67665 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 680ECA0562; Thu, 2 Apr 2020 19:20:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 136051BED5; Thu, 2 Apr 2020 19:20:08 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 7B0771BE95 for ; Thu, 2 Apr 2020 19:20:05 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id n10so2064513pff.3 for ; Thu, 02 Apr 2020 10:20:05 -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=htzPMTkkQt3wtNYQl5Pc2vBv0EMDeHc+HNJPHQ4h7nQ=; b=ELX+J+lCarPfI0P3qDxrg9s5Or/B3eFiKdVnyK8Jv643cmYRmdnW5WFZ7PZPnZgHou qAru4PuFdBFAb+m9AM0ujoMV7rM9/AHWJ4w0NeDp+kjNevm5IAKuOWGbqwYR9z83ljK+ Zpi4P2PHzPGU7uyFCr8WS/Ivy4vm4naJ3R5/dk8dJ8zminP0thdcwNqnXy9YLAxwkAqH Ydp6XNOi6uFCJI+Zb5FIQ8ZuLHITu7dkh2WNzP7R/Ir4aZdr4MckAKxe1xRqzIo8hI6C PivhD4gYfh12y6yzURoDhestlJ1v07N+mFD1AffGx1x6IAHBStUaeM60pQJfFsmHj1u4 pehg== 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=htzPMTkkQt3wtNYQl5Pc2vBv0EMDeHc+HNJPHQ4h7nQ=; b=b3EslGgJQC/0X5iJd85zVKKph8gU31sllLB7cPLhKZf75+LEODnox61LHPhVfsqVQR JXZK1XlxX302UKzrwYsnXRHB6AlcpA6nerDRcC8pTgN6UnXaNaRTl2gTlrbquGWYAfm5 ViqFYrW3v7oP5/59Qxw/L+15gXRBCH5IaX5VyKRGWZ57id3C06E6A+Lvel5LXnwSaKbq 6/rPbFWCcElsYh5vvYxeAIlbvVTJCnroavjlDXiYP6NcTJeFLG0H9b/MnXIIiRSZzXgz 7KWcecJS6DCM8PZF3yS0qp+KZpQC+So1znug2m24bOOCTEeBwhblDSVo+zTBWnonH7Yb /Mjw== X-Gm-Message-State: AGi0PubqMeSWzIMzZmIlSp0WuRXxfYF+eRJ1RyEVFuu9MTuHBkULoIE9 bEXYOLXjoFCCK+hdefdG0t3mWKmUozClOA== X-Google-Smtp-Source: APiQypKoPkgdI6HM5ZY9jGpKNZqz2PnwkZj+pWHE60HFzx3yAF/3w9bbtrh40EG6eInfFUwEPX2Tzg== X-Received: by 2002:aa7:9a8e:: with SMTP id w14mr4113941pfi.113.1585848003935; Thu, 02 Apr 2020 10:20:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:20:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , matan@mellanox.com, stable@dpdk.org Date: Thu, 2 Apr 2020 10:19:49 -0700 Message-Id: <20200402171953.13356-3-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 Subject: [dpdk-dev] [PATCH v3 2/6] examples/l2fwd-cat: make applicaton aware of 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" If a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application. Fixes: 5b7ba31148a8 ("ethdev: add port ownership") Cc: matan@mellanox.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/l2fwd-cat/Makefile | 2 ++ examples/l2fwd-cat/l2fwd-cat.c | 3 +++ examples/l2fwd-cat/meson.build | 1 + 3 files changed, 6 insertions(+) diff --git a/examples/l2fwd-cat/Makefile b/examples/l2fwd-cat/Makefile index b0e53c37e8d8..aa19347c1545 100644 --- a/examples/l2fwd-cat/Makefile +++ b/examples/l2fwd-cat/Makefile @@ -20,6 +20,7 @@ static: build/$(APP)-static PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) @@ -65,6 +66,7 @@ endif EXTRA_CFLAGS += -O3 -g -Wfatal-errors +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -I$(PQOS_INSTALL_PATH)/../include LDLIBS += -L$(PQOS_INSTALL_PATH) diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c index 6838f288c621..e370efeaf1f8 100644 --- a/examples/l2fwd-cat/l2fwd-cat.c +++ b/examples/l2fwd-cat/l2fwd-cat.c @@ -42,6 +42,9 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; + if (rte_eth_dev_owner_get(port, NULL) == 0) + return -1; + /* Configure the Ethernet device. */ retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf); if (retval != 0) diff --git a/examples/l2fwd-cat/meson.build b/examples/l2fwd-cat/meson.build index 4e2777a03358..5c062c1354e3 100644 --- a/examples/l2fwd-cat/meson.build +++ b/examples/l2fwd-cat/meson.build @@ -6,6 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +allow_experimental_apis = true pqos = cc.find_library('pqos', required: false) build = pqos.found() ext_deps += pqos From patchwork Thu Apr 2 17:19:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 67666 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 961F3A0562; Thu, 2 Apr 2020 19:20:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 88EA41BEE1; Thu, 2 Apr 2020 19:20:09 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by dpdk.org (Postfix) with ESMTP id DE0181BEB1 for ; Thu, 2 Apr 2020 19:20:06 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id c21so2058843pfo.5 for ; Thu, 02 Apr 2020 10:20:06 -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=WD7UANVVWh1Z4K+ERaNWSshHykUbX739UMEJYD62aHg=; b=bujfX7nDQ9DjEq84PPu85rzQkkiUdFOGIqpyLXG95gzNnkmml/ZNSq8KY4SgC8ZQlr DdXGA0OBB0zQZIwPGPVqNZ2Ephg0c7y3zB/Rg3RzHY+OcH/nEJnRps0GuFy0dNd4KaHI Ahj3Fruhw4A2JfM5CPofUYngBHAmUEoudamSuo9iAipcIIsvEWVX0/NVMP517IA+A0Xn GvN+2lptAq7OJzsSzM5Na70MFBt5Ni889ubna7KklJfVZ1pcK/lw9P43LJ0BVrBiMhHu 9DPAx6ES7poArawrRBBRAbWurVHWYJ54iyE0tdBxihnv8dbouzQBpJ4xghj/NOrIj1CI 4RHQ== 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=WD7UANVVWh1Z4K+ERaNWSshHykUbX739UMEJYD62aHg=; b=EuVsdx47MfdNxcr8plb0Z+kK/qYtkBEKjbog7LK4ozrGc2394ugIIQXB7sx5fhx2eM uBgPbtQ8mRMFS8TcpaNJSHGFyCs12ie7ZGce7CM7UEs3xWJpD7HPadlrNgwoTVXMxX86 6pgDLqICla06xf73HgpS/3Y+khHC8CjpoXW8wvxT63clzoQ0JXn/ifSti8uFhCoXuY8r 20Dk//D8e9AErCCdTfcn4V1gMjhNz8Rt2gfg7gC7x38zeibOB+X5HsaqsNaVJWoupkSk CjtbSLj1HuuLN5caS8XOz/uIRA2rNqRiWA10daYOePCO02zMhxpN+MY+k/jpb+wl7Fvi eUtQ== X-Gm-Message-State: AGi0PuYBg6I5YyAWt0sueFcSigyJWWOFwjh/sPmcgK39x0+3WlFlb/AP SpnJvW5V1RlG5sao9yzM8A6rVLg7eN06qg== X-Google-Smtp-Source: APiQypJCEVzWuLamNiY2pf3TSXsTd6R9CdyHa68nmf9DvOwyuAdnNIuNHsVzHeNGxN/yCVSSDDcPfQ== X-Received: by 2002:a62:e101:: with SMTP id q1mr4035335pfh.84.1585848005563; Thu, 02 Apr 2020 10:20:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:20:04 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , matan@mellanox.com, stable@dpdk.org Date: Thu, 2 Apr 2020 10:19:50 -0700 Message-Id: <20200402171953.13356-4-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 Subject: [dpdk-dev] [PATCH v3 3/6] examples/l3fwd: make applicaton aware of 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" If a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd. Fixes: 5b7ba31148a8 ("ethdev: add port ownership") Cc: matan@mellanox.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/l3fwd/Makefile | 3 +++ examples/l3fwd/main.c | 5 +++++ examples/l3fwd/meson.build | 1 + 3 files changed, 9 insertions(+) diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile index 59a110d12a49..59cd00abe6e9 100644 --- a/examples/l3fwd/Makefile +++ b/examples/l3fwd/Makefile @@ -25,6 +25,8 @@ CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +CFLAGS += -DALLOW_EXPERIMENTAL_API + build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) @@ -50,6 +52,7 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf include $(RTE_SDK)/mk/rte.vars.mk +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -I$(SRCDIR) CFLAGS += -O3 $(USER_FLAGS) CFLAGS += $(WERROR_FLAGS) diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index dda430d68a20..110d4cc109d1 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -221,6 +221,11 @@ check_port_config(void) printf("port %u is not present on the board\n", portid); return -1; } + + if (rte_eth_dev_owner_get(portid, NULL) == 0) { + printf("port %u is already in use\n", portid); + return -1; + } } return 0; } diff --git a/examples/l3fwd/meson.build b/examples/l3fwd/meson.build index ebed3b518c4b..7d72b1b365ae 100644 --- a/examples/l3fwd/meson.build +++ b/examples/l3fwd/meson.build @@ -6,6 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +allow_experimental_apis = true deps += ['hash', 'lpm', 'eventdev'] sources = files( 'l3fwd_em.c', 'l3fwd_lpm.c', 'l3fwd_event.c', From patchwork Thu Apr 2 17:19:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 67667 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23B84A0562; Thu, 2 Apr 2020 19:20:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C7DEE1BF26; Thu, 2 Apr 2020 19:20:10 +0200 (CEST) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id 7878D1BED0 for ; Thu, 2 Apr 2020 19:20:08 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id ng8so1798606pjb.2 for ; Thu, 02 Apr 2020 10:20:08 -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=YugD632XLy8IW/yOBAT1NsvfKKAvA7yxzcqVl83JtW8=; b=CRroZWLxjY4z8NH7+AtnCDn8CEkYa/T6+Pra0HT158eXZJCqlcJGBEQWqraxYNZNML eANHk485409wple6RSmKfpqUGAjpWcE2Rn6iI2X6ShShz5M4yPR6NegmHxKpz0+YSq2m EmlG72ePIIiSgvvRMQbJdPiH5RI623Li5WxouWuK5t0SZiPZ61KSlqR8UIIlFapttHSA aTv1y8AWMTZ40h3W9OgVR7790Nljk15vGbux7ZvcgbTu0fmnaObkCwPvtzDN8RhdsuLL jiBENZkX0jozWhgeILRKAD/880XcR7GQ8dh83Qdx6tPlCTC28i0Rn7Nn+bTc2EqgtwTa QmEA== 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=YugD632XLy8IW/yOBAT1NsvfKKAvA7yxzcqVl83JtW8=; b=AMpR1VxH56Plzlm7BgFxI96MMOt8thXk4fJ1DO0y7XebIy7xbbbBEiQJ4I+/pgWTdq qSHH7gbKxJSL9pPkh2fHOz6rhNK5ALynG5PF75ML7YWiafyznVg4ZxD/yhk5yUcfcd0R gEJ80TgjCMzDNIYgrttbuKPaWTY1CEcQbm5exaYUUio3WjwzGXddg3gz4xgB/MOmc6M2 FFST9gUWnCpvHEpdFpiCSpxB/8G9M86Sd6K6nE4fg6smUmhBso1xpNeO8UY0Xtsw2MfW L0r336nbA21BD2ha+akf7ZDRi6ZANcdKbSK/hn296E1h/+xD1vEZ8mzWwz4G7lXn/D5F PHQA== X-Gm-Message-State: AGi0PubRP0Pz0eQnLsdeQOrOd2lm2qLc3d/s1qq5x4Dwz1xjPp0dksjr xe0cquEBOy0gLBb138xgMQ5KmzcRhpfcPQ== X-Google-Smtp-Source: APiQypJlbgv3JvnRbW/TMkhTwHBoj81Zw6sSS46AWXrHgCQjFjdSIOVzC3uq3S//tiVLFo4qJ5Ng/g== X-Received: by 2002:a17:90b:292:: with SMTP id az18mr4861197pjb.126.1585848007133; Thu, 02 Apr 2020 10:20:07 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:20:06 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , matan@mellanox.com, stable@dpdk.org Date: Thu, 2 Apr 2020 10:19:51 -0700 Message-Id: <20200402171953.13356-5-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 Subject: [dpdk-dev] [PATCH v3 4/6] examples/l3fwd-acl: make applicaton aware of 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" If a ethdev port is in use for a sub device, then it should not be allowed in the portmask of application. Fixes: 5b7ba31148a8 ("ethdev: add port ownership") Cc: matan@mellanox.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/l3fwd-acl/Makefile | 3 +++ examples/l3fwd-acl/main.c | 4 ++++ examples/l3fwd-acl/meson.build | 1 + 3 files changed, 8 insertions(+) diff --git a/examples/l3fwd-acl/Makefile b/examples/l3fwd-acl/Makefile index d9909584b1c6..ff14b4fdd593 100644 --- a/examples/l3fwd-acl/Makefile +++ b/examples/l3fwd-acl/Makefile @@ -20,7 +20,9 @@ static: build/$(APP)-static PKGCONF ?= pkg-config PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) + LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) @@ -51,6 +53,7 @@ include $(RTE_SDK)/mk/rte.vars.mk CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index fa92a2829740..dbdea8db241a 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -1470,6 +1470,10 @@ check_port_config(void) printf("port %u is not present on the board\n", portid); return -1; } + if (rte_eth_dev_owner_get(portid, NULL) == 0) { + printf("port %u is already in use\n", portid); + return -1; + } } return 0; } diff --git a/examples/l3fwd-acl/meson.build b/examples/l3fwd-acl/meson.build index 7096e00c1073..6fa468b3aa9c 100644 --- a/examples/l3fwd-acl/meson.build +++ b/examples/l3fwd-acl/meson.build @@ -6,6 +6,7 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' +allow_experimental_apis = true deps += ['acl', 'lpm', 'hash'] sources = files( 'main.c' From patchwork Thu Apr 2 17:19:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 67668 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20587A0562; Thu, 2 Apr 2020 19:20:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A9AC1BF6D; Thu, 2 Apr 2020 19:20:12 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id F36431BECB for ; Thu, 2 Apr 2020 19:20:09 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id t4so1566665plq.12 for ; Thu, 02 Apr 2020 10:20:09 -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=WOoBkVa4caNZLFoqQs8rTBhk4L5yWAR7OIx+1YexLi8=; b=XvupP6Iv+IiPzem5eLyG0Mk7GG8aLa7hc/BhQznBid8jVvpf8ynETSPLAQqq3vRJ/J ZfjBxfR3arY7BoFI7LEO3ZDoPVPDiQlDP4bkxfDUbpHiLb5VpLO44l3PDVozOcAF3V0M d+pK0KsdWbCVzz+xZhMfr3EWsDf2SnOFXxNjjsO/eErL8TLTZukbFNmCOe2+A8NTGGTZ n/pAh+uAlAchz8VgZ3I5IrYN5rQ3Dpkp5+EgTgPh3CgeSCmlxQ8GmqbEjVFqCOEDVVlf 6oBOELqNq4561ruBRpCzog4Bb7rYXNPzyziGnqQiM+er0krOnoVeatBDp4tIk8vsvKOu blJg== 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=WOoBkVa4caNZLFoqQs8rTBhk4L5yWAR7OIx+1YexLi8=; b=eP1qMdqy9QzWGijhR+3Kjoi1kguYGb0CtSaaNA4aZQkaykvunA8EnSUNy8vQ1ebcKl +a3m6IxZYfc2H02DWJU2TL/GrfmEcuXVO1a8h5zd3VOOl/jYOpexzmJ/oyX3SvMglI3z gab/Wvygqk4JfGmGaXJO3ZHlDoLMPti2Z6xX47GALgS43qU2Lpw+zETv3+rl9kohqUaA S0eErFqaiha2XN0sv9Hz0UD18Lug9KueEN9OIhGnPONdhHN4ihGrVp4eypY1LPQ9pWGC avtSiy38jjHd8NgYtKDb0HMdeXeoo+81eCq1dxgKu7Wr4RMZwTJsaSlG7mpko5eGj0cd xC/Q== X-Gm-Message-State: AGi0PubzdMzI/vA1xfHAdcvaJ3xMbG4AIZWbze7I3mRBubaiEL21dIVv U+9d+ppM+Eupv7ElWk2xOnqLcbaU1Z8KXA== X-Google-Smtp-Source: APiQypKWvtU4rNRQ/6S8HB3zFUkCHtSAVOCf65isNVt3PNq8su6STicQAELrM0Jjk43JacKUYh6k+w== X-Received: by 2002:a17:90a:1b6b:: with SMTP id q98mr4917395pjq.107.1585848008654; Thu, 02 Apr 2020 10:20:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:20:07 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , matan@mellanox.com, stable@dpdk.org Date: Thu, 2 Apr 2020 10:19:52 -0700 Message-Id: <20200402171953.13356-6-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 Subject: [dpdk-dev] [PATCH v3 5/6] examples/l3fwd-power: make applicaton aware of 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" If a ethdev port is in use for a sub device, then it should not be allowed in the portmask of l3fwd. Fixes: 5b7ba31148a8 ("ethdev: add port ownership") Cc: matan@mellanox.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/l3fwd-power/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index c7fe0ec03495..186d6ac8e271 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1396,6 +1396,10 @@ check_port_config(void) portid); return -1; } + if (rte_eth_dev_owner_get(portid, NULL) == 0) { + printf("port %u is already in use\n", portid); + return -1; + } } return 0; } From patchwork Thu Apr 2 17:19:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 67669 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D63BA0562; Thu, 2 Apr 2020 19:21:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B4B8F1BFD1; Thu, 2 Apr 2020 19:20:13 +0200 (CEST) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by dpdk.org (Postfix) with ESMTP id 801CA1BF4F for ; Thu, 2 Apr 2020 19:20:11 +0200 (CEST) Received: by mail-pg1-f173.google.com with SMTP id r4so667983pgg.4 for ; Thu, 02 Apr 2020 10:20:11 -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=sUMR01S/YIkpWMDDAJP2AboXvR5VIfAsd2eiFf5CcZg=; b=jVq09ixKJ0i7RCme+TMeGUcBCUwEpL8Z7bLbIH6/XJ9kSzy2M9bDTJaY1Vjf9G437h dJEnt3WhMsJAW26Eul8bUTZRhCI7NWtw/CMqB01qd5FVaxIiUUmb1m9XhI2OGErcAf1m zWZkNJadr4/gPOFeqecCuoa2wJgAqv1Dg8ACOzGFiU8h2u6Zk58IBwDMRfbFVfdQMoYq eFu5gKAy5ci6bdj2EI3ZyfVbEj/dtiYoXtEYNYQWidX09obSh3Vo1XRVD3W4vDWs01ld ztr/SEuVaT/JYSsE1iBmxOjGk2iNdej5UTNM8UjDDnzoVxrS0X+HNsPjiNjaolIix6Jv E1XA== 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=sUMR01S/YIkpWMDDAJP2AboXvR5VIfAsd2eiFf5CcZg=; b=Ia9nxvAC9KoORlf/R9zWzhhnqlR25jozh2P22JOcoJoKDO9sQhl1qPTck1myrxp2/z wODWmqIA/S8YT9+W1fj1MDg0NWwW67HQAdl0fRidCSxuQNfrfhVMIj4GaN96zgCedgwg zR4/FAS+AqwFFvnL9TWVP4cVey4O3z/Tu+e/bjnqW9YgTvhgKH62/I3DiCvaReqpsG4p zokuVP2KAzh8FStEbyRxYfSCpvxCd+MOC6pxSbcmGYfeVI97cQLea0TIjxuBmekstr5U g2nW1c8cTsLbrLLp+oJEWungaumEmAW+E1YmedLGxogKAqVfsZLcZchs0LovmF8bCF9c I2hA== X-Gm-Message-State: AGi0Pub02NzmgclZivcvjWEz1SFL5E+dtRL3zJu6WYCM8Hk9FhOAEUev MFU1Mn2Nb+zfePr7BTOsTfAxOiQEAseMlA== X-Google-Smtp-Source: APiQypIZ6WSJI6wiAR661mPBK+6wjvu/gGI66l9ZE/GxBBb4WqIY68D2GiErtdHQCHGHlJBHUXKJXw== X-Received: by 2002:a65:6250:: with SMTP id q16mr4414506pgv.9.1585848010167; Thu, 02 Apr 2020 10:20:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:20:09 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , jijiang.liu@intel.com, stable@dpdk.org Date: Thu, 2 Apr 2020 10:19:53 -0700 Message-Id: <20200402171953.13356-7-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 Subject: [dpdk-dev] [PATCH v3 6/6] examples/tep_termination: rework the port setup logic 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" The handling of ports in this application had many problems. It was checking for things that can never happen with current DPDK library (like rte_ethdev_avail_count() >= RTE_MAX_ETHPORTS) and it was not checking if the port was owned and should not be used directly. Also the variable nb_ports was used as both local and global variable. Fix by rewriting the initialization logic to iterate over valid ports and check if there are any leftovers. Fixes: a50245ede72a ("examples/tep_term: initialize VXLAN sample") Cc: jijiang.liu@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- examples/tep_termination/Makefile | 2 + examples/tep_termination/main.c | 70 ++++++++++------------------ examples/tep_termination/meson.build | 1 + 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/examples/tep_termination/Makefile b/examples/tep_termination/Makefile index 645112498d33..f55331fb24c2 100644 --- a/examples/tep_termination/Makefile +++ b/examples/tep_termination/Makefile @@ -26,6 +26,7 @@ CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -Wno-deprecated-declarations build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build @@ -61,6 +62,7 @@ endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-deprecated-declarations +CFLAGS += -DALLOW_EXPERIMENTAL_API include $(RTE_SDK)/mk/rte.extapp.mk endif diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c index ab956ad7ce96..beb3ff7d78e0 100644 --- a/examples/tep_termination/main.c +++ b/examples/tep_termination/main.c @@ -149,8 +149,6 @@ static char dev_basename[MAX_BASENAME_SZ] = "vhost-net"; static unsigned lcore_ids[RTE_MAX_LCORE]; uint16_t ports[RTE_MAX_ETHPORTS]; -static unsigned nb_ports; /**< The number of ports specified in command line */ - /* ethernet addresses of ports */ struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; @@ -268,7 +266,6 @@ tep_termination_parse_args(int argc, char **argv) { int opt, ret; int option_index; - unsigned i; const char *prgname = argv[0]; static struct option long_option[] = { {CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0}, @@ -474,18 +471,6 @@ tep_termination_parse_args(int argc, char **argv) } } - for (i = 0; i < RTE_MAX_ETHPORTS; i++) { - if (enabled_port_mask & (1 << i)) - ports[nb_ports++] = (uint8_t)i; - } - - if ((nb_ports == 0) || (nb_ports > MAX_SUP_PORTS)) { - RTE_LOG(INFO, VHOST_PORT, "Current enabled port number is %u," - "but only %u port can be enabled\n", nb_ports, - MAX_SUP_PORTS); - return -1; - } - return 0; } @@ -493,28 +478,29 @@ tep_termination_parse_args(int argc, char **argv) * Update the global var NB_PORTS and array PORTS * according to system ports number and return valid ports number */ -static unsigned -check_ports_num(unsigned max_nb_ports) +static unsigned int +get_ports(void) { - unsigned valid_nb_ports = nb_ports; - unsigned portid; - - if (nb_ports > max_nb_ports) { - RTE_LOG(INFO, VHOST_PORT, "\nSpecified port number(%u) " - " exceeds total system port number(%u)\n", - nb_ports, max_nb_ports); - nb_ports = max_nb_ports; + uint32_t port_mask = enabled_port_mask; + unsigned int valid_nb_ports = 0; + uint16_t portid; + + RTE_ETH_FOREACH_DEV(portid) { + uint32_t mask = 1u << portid; + + if ((mask & port_mask) == 0) + continue; + + port_mask &= ~mask; + ports[valid_nb_ports++] = portid; } - for (portid = 0; portid < nb_ports; portid++) { - if (!rte_eth_dev_is_valid_port(ports[portid])) { - RTE_LOG(INFO, VHOST_PORT, - "\nSpecified port ID(%u) is not valid\n", - ports[portid]); - ports[portid] = INVALID_PORT_ID; - valid_nb_ports--; - } + if (port_mask != 0) { + RTE_LOG(INFO, VHOST_PORT, + "\nInvalid ports %#x specified in portmask\n", + port_mask); } + return valid_nb_ports; } @@ -1123,7 +1109,7 @@ main(int argc, char *argv[]) { struct rte_mempool *mbuf_pool = NULL; unsigned lcore_id, core_id = 0; - unsigned nb_ports, valid_nb_ports; + unsigned int valid_nb_ports; int ret; uint16_t portid; uint16_t queue_id; @@ -1148,20 +1134,14 @@ main(int argc, char *argv[]) /* set the number of swithcing cores available */ nb_switching_cores = rte_lcore_count()-1; - /* Get the number of physical ports. */ - nb_ports = rte_eth_dev_count_avail(); - - /* - * Update the global var NB_PORTS and global array PORTS - * and get value of var VALID_NB_PORTS according to system ports number - */ - valid_nb_ports = check_ports_num(nb_ports); - - if ((valid_nb_ports == 0) || (valid_nb_ports > MAX_SUP_PORTS)) { + /* Set ports[] array based on system ports and port mask */ + valid_nb_ports = get_ports(); + if (valid_nb_ports == 0 || valid_nb_ports > MAX_SUP_PORTS) { rte_exit(EXIT_FAILURE, "Current enabled port number is %u," - "but only %u port can be enabled\n", nb_ports, + "but only %u port can be enabled\n", valid_nb_ports, MAX_SUP_PORTS); } + /* Create the mbuf pool. */ mbuf_pool = rte_pktmbuf_pool_create( "MBUF_POOL", diff --git a/examples/tep_termination/meson.build b/examples/tep_termination/meson.build index f65d689802a3..ddadf1c2aede 100644 --- a/examples/tep_termination/meson.build +++ b/examples/tep_termination/meson.build @@ -9,6 +9,7 @@ if not is_linux build = false endif +allow_experimental_apis = true deps += ['hash', 'vhost'] cflags += '-Wno-deprecated-declarations' sources = files(