From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 92D811E20 for ; Mon, 8 Oct 2018 00:26:01 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 403FB21F00; Sun, 7 Oct 2018 18:26:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:26:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=81tzICOLx0 3Nj7QVFFZTJC9FmxIEvQydc+tZmzSVJrE=; b=g6jlTVTXOg9+rW0GSArBjgb8PY HX+j8VLBFRJvBFO1D/d0kivJ1iFS3+wvFArPk4h31q+KRHvV7b1h0yrxSi6MeD8L 1TaCh1sQJuM8ZYKQLpE2ufaeAn95+g1GD6IqJgdcpg1ppXTP/HsVtC92SoAeGZfB 8UJetPvxAUzWgynro= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=81tzICOLx03Nj7QVFFZTJC9FmxIEvQydc+tZmzSVJrE=; b=Y39CqAoV zHfsUfI9mpYzSozlyeuZAXQ1vzAzbpjruxl59jgJn/KH1ZrElyZbYR2ZU4WzH4q6 rUKj1VpbTOrFyUVjVRUZ6Kj+/9qOzGBSFFtAMAdmIgQgz8us6dMrV5uZ8uNF0C32 fF15ondLCxvGuDwz1WDRcPWKf+J9d313pi3TJq7ExZbE+XJm+/7o1fEgk7LgwctV Hd6LkktHwiFf3oygWH3UiU8b6Pdzaff14Rcpkd0J81DytMJM65eZb2JeLPoA0fgr xHj2wGXR5ea+djw+eUAzEt6aOfq/hYFO64dNq6AlCiIg+ByPEBqkHs/TBkdnYPya Zv+tJDRZlddrRA== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 47529E48A7; Sun, 7 Oct 2018 18:26:00 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:52 +0200 Message-Id: <20181007222554.4886-4-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 3/5] ethdev: allow iterating with only class filter 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: , X-List-Received-Date: Sun, 07 Oct 2018 22:26:01 -0000 If no rte_device is given in the iterator, eth_dev_match() is looking at all ports without any restriction, except the ethdev kvargs filter. It allows to iterate with a devargs filter referencing only some ethdev parameters. The format (from the new devargs syntax) is: class=eth,paramY=Y Fixes: e815a7f69371 ("ethdev: register as a class") Signed-off-by: Thomas Monjalon --- lib/librte_ethdev/rte_class_eth.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c index 84b646291..f0af51c36 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -42,7 +42,7 @@ eth_dev_match(const struct rte_eth_dev *edev, if (edev->state == RTE_ETH_DEV_UNUSED) return -1; - if (edev->device != arg->device) + if (arg->device != NULL && arg->device != edev->device) return -1; if (kvlist == NULL) /* Empty string matches everything. */ diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 83ab28c23..a43e0ab3a 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -199,10 +199,18 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) * The devargs string may use various syntaxes: * - 0000:08:00.0,representor=[1-3] * - pci:0000:06:00.0,representor=[0,5] + * - class=eth,mac=00:11:22:33:44:55 * A new syntax is in development (not yet supported): * - bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z */ + /* Handle a case from future syntax, without any bus-level argument. */ + if (strncmp(devargs_str, iter_anybus_str, + strlen(iter_anybus_str)) == 0) { + iter->cls_str = devargs_str + strlen(iter_anybus_str); + goto end; + } + /* Split bus, device and parameters. */ ret = rte_devargs_parse(&devargs, devargs_str); if (ret != 0) @@ -239,6 +247,7 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) } iter->bus_str = bus_str; +end: iter->cls = rte_class_find_by_name("eth"); return 0; } @@ -250,7 +259,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter) return RTE_MAX_ETHPORTS; do { /* loop for matching rte_device */ - if (iter->class_device == NULL) { + if (iter->bus != NULL && iter->class_device == NULL) { iter->device = iter->bus->dev_iterate( iter->device, iter->bus_str, iter); if (iter->device == NULL) @@ -260,7 +269,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter) iter->class_device, iter->cls_str, iter); if (iter->class_device != NULL) return eth_dev_to_id(iter->class_device); - } while (iter->class_device == NULL); + } while (iter->bus != NULL && iter->class_device == NULL); /* No more ethdev port to iterate. */ free(RTE_CAST_FIELD(iter, bus_str, char *)); /* workaround const */ -- 2.19.0