From patchwork Thu Jul 5 11:48:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 42335 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 584891BEBD; Thu, 5 Jul 2018 13:48:59 +0200 (CEST) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 338451BEB9 for ; Thu, 5 Jul 2018 13:48:58 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id v3-v6so6752252wmh.0 for ; Thu, 05 Jul 2018 04:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b6ho7lHB53sZcskjXG6xFjHaJrBQlUOxIDu4vpRh900=; b=hE3RuML2iAjAICj65ALfBRq1wqf3MYnFnFC1xw14Wml/Z7gNBo/je7uijOkq2IE3/k EDfP6EdmkHHjxBny1rr3zOi8ZmqE68kcQTC+87v9P3nUh/wUzc30LWC+P7zOYLMs66nz aD+wkwbcqew/XGA48jfIipyb+s4nTthojaRzx7wbbRIjh3ZgeAfPF6EO6MjxsYiHxtwf z3qfef+2KsaxGMAGTBQG4Bl2jMEANR7D2XfPRMHcybjSSLI5Col7V381faYF3X1AzSlm /yi1pMGy6M0xw4dhSn6hayIfDthKs+HEF9dd0LW+CRQrLuG0TzDOoaSp2GBL9FHg/8c7 L4AQ== 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; bh=b6ho7lHB53sZcskjXG6xFjHaJrBQlUOxIDu4vpRh900=; b=qmO1ajqy61CLkOckknLJRkuQ684aqLPQhx/jAitG5HU1alpiLtJZkjzU24OBg+jD3+ TCklHaEsDTApuDSZyJUs3AxWP1eqhMi9lMS8eqM51M/U8IUCCTaisvtQ29bgZrVUE9Lo Dl8wCsPjQFYvHGX808iJpduzeH3S7Qoaay4MkLFaCSV0P9x98NFE65Qg4D08KhGon7QP g2GQjjLF5zcCg6yj+/m3iTzqdy7Xg87i/GsQkCBwq29xhLegMkVyHvBgscwHC9T6wcjX o9g+OHK19NLT6etLdKxOjDUP+sG1NUZkhBSzuyZUBOl7zV6UxX9A/ZhkGjAfKGCUHoVy q0EA== X-Gm-Message-State: APt69E1yWEiuKhH7R7vyR/Fe6n5khEPsfG8bDvYnx3VdTRplfYHudBTu 3LOGKiVfu6zZ/wZEbik8O1hpALUu X-Google-Smtp-Source: AAOMgpd1bFKzRrzLVqv9yRN0eqcg7h29E/ILrV94bmN85O4gm1ib0HBaUX2nmN7hOkm9GXK6nNylwQ== X-Received: by 2002:adf:e285:: with SMTP id v5-v6mr4066008wri.54.1530791337193; Thu, 05 Jul 2018 04:48:57 -0700 (PDT) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id o42-v6sm15809183wrc.50.2018.07.05.04.48.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 04:48:56 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , Neil Horman , Keith Wiles , Matan Azrad , Shreyansh Jain , Bruce Richardson , Andrew Rybchenko Date: Thu, 5 Jul 2018 13:48:07 +0200 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v10 00/27] Device querying 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 patchset introduces a new EAL API for querying devices, filtered by arbitrary properties. The following elements are introduced to this end: * A new object, "rte_class", is used to describe the device class abstraction layer (eth, crypto, ...). * Both rte_bus and rte_class now offer a way to list their devices and filter the result using locally defined properties. * The rte_dev API now has an rte_dev_iterator, which is the way for the user to define the device filter and iterate upon the resulting set. As an example, the "eth" device class is implemented. Additionally, the device filters for + rte_bus_pci + rte_bus_vdev + rte_class_eth are implemented and can be used with some properties each, to show how to extend those. Some example of filters: "bus=pci/class=eth" "bus=pci" "class=eth" "class=eth,name=net_ring0" "bus=pci,id=00:00.0" "bus=vdev,driver=net_ring" --- v2: * Reworked the dev_iterate callback to simplify its implementation. Now dev_iterate implementation do not need to learn about the intricacies of the rte_dev_iterator. The rte_dev_iterator is managed purely by the rte_dev_iterator_next function. Buses and classes then do not have to care about settings things right. Additionally, dev_iterate implementations do not have to sanitize their dev string anymore, they are prepared by the rte_dev layer prior, which also reduces the number of dynamic allocations. v3: * Introduced central constructor priority list. * Removed lightweight kvarg parsing utility, using librte_kvargs instead. * Reversed dependencies of librte_kvargs and librte_eal. * Fixed a few bugs. * @Bruce: I have noted the request for meson support. I will install it and attempt it once the bulk of the work is done. v4: * Fixed a few bugs, added relevant acks, fixed some typos. * Made each matching functions actually check for a proper list of accepted properties. * rte_kvargs now includes rte_eal directly and keeps rte_log. * added generic string comparison function to rte_kvargs, as some kind of comparison should probably be shared by many layers. v5: * Rebased on master * Use strcspn instead of custom function. * Introduce private generic rte_eth_dev iterator. This could be generalized to other iterators (port_next, owner_id-aware, etc). * Attempted to support meson.build. Got lost in the implicit variables declared when inversing dependencies between kvargs and EAL. Removed anything related to meson. * Postponed genericization of work from device query to device declaration. Much bigger than anticipated, will let this part get in first and iterate over it. v6: * Rebased on master * Introduce RTE_PRIORITY_LAST, to explicitly set the lowest constructor priority. * Fix copyright notice for eth_privage.* files. v7: * Rebased on master * Fix rte_kvargs_strcmp return value. * Fix layer parsing error devstr "bus=pci/onemorelayer" now tells that the additional layer is not recognized. v8: * Rebased on master * Cleaned kvargs use: introduced a new parser function, that simplifies using the library for DPDK devargs. * Refactored devargs parsing in a single function within rte_devargs. This function is useful both for rte_dev parsing its iterator, and for rte_devargs parsing --dev parameters (not yet implemented). * A few small bugfixes. v9: * Rebased on master * Fixed cyclic dependency kvargs <-> eal * Fixed a few checkpatch issues * Added dynamic help to testpmd for new "show device" command * Added devargs processing stubs to primary buses / classes * Added new --dev generic device declaration option v10: * Support meson build Gaetan Rivet (27): devargs: add non-variadic parsing function kvargs: remove error logs kvargs: build before EAL kvargs: introduce a more flexible parsing function eal: introduce dtor macros eal: introduce device class abstraction eal/class: register destructor devargs: add function to parse device layers eal/dev: add device iterator interface eal/class: add device iteration eal/bus: add device iteration eal/dev: implement device iteration initialization eal/dev: implement device iteration kvargs: add generic string matching callback bus/pci: implement device iteration and comparison bus/pci: add device matching field id bus/vdev: implement device iteration bus/vdev: add device matching field driver ethdev: add private generic device iterator ethdev: register ether layer as a class ethdev: add device matching field name app/testpmd: add show device command bus/pci: pre-process declarative PCI devargs bus/vdev: pre-process declarative vdev devargs bus/pci: process declarative PCI devargs ethdev: process declarative eth devargs eal: add generic dev parameter app/test-pmd/cmdline.c | 54 +++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 +++ drivers/bus/pci/Makefile | 3 +- drivers/bus/pci/bsd/pci.c | 5 + drivers/bus/pci/linux/pci.c | 5 + drivers/bus/pci/meson.build | 6 +- drivers/bus/pci/pci_common.c | 6 +- drivers/bus/pci/pci_params.c | 139 ++++++++++++ drivers/bus/pci/private.h | 54 +++++ drivers/bus/vdev/Makefile | 3 +- drivers/bus/vdev/meson.build | 5 +- drivers/bus/vdev/vdev.c | 20 +- drivers/bus/vdev/vdev_params.c | 112 ++++++++++ drivers/bus/vdev/vdev_private.h | 32 +++ drivers/net/failsafe/failsafe_args.c | 2 +- drivers/net/failsafe/failsafe_eal.c | 2 +- lib/Makefile | 5 +- lib/librte_eal/bsdapp/eal/Makefile | 2 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_class.c | 62 ++++++ lib/librte_eal/common/eal_common_dev.c | 227 +++++++++++++++++++- lib/librte_eal/common/eal_common_devargs.c | 190 +++++++++++++++- lib/librte_eal/common/eal_common_options.c | 36 +++- lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_private.h | 27 +++ lib/librte_eal/common/include/rte_bus.h | 1 + lib/librte_eal/common/include/rte_class.h | 127 +++++++++++ lib/librte_eal/common/include/rte_common.h | 24 +++ lib/librte_eal/common/include/rte_dev.h | 97 +++++++++ lib/librte_eal/common/include/rte_devargs.h | 53 ++++- lib/librte_eal/common/meson.build | 2 + lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/meson.build | 1 + lib/librte_eal/rte_eal_version.map | 5 + lib/librte_ethdev/Makefile | 4 +- lib/librte_ethdev/eth_private.c | 31 +++ lib/librte_ethdev/eth_private.h | 31 +++ lib/librte_ethdev/meson.build | 4 +- lib/librte_ethdev/rte_class_eth.c | 147 +++++++++++++ lib/librte_ethdev/rte_ethdev.c | 9 +- lib/librte_kvargs/Makefile | 2 +- lib/librte_kvargs/meson.build | 5 + lib/librte_kvargs/rte_kvargs.c | 57 +++-- lib/librte_kvargs/rte_kvargs.h | 58 +++++ lib/librte_kvargs/rte_kvargs_version.map | 8 + lib/meson.build | 8 +- 46 files changed, 1637 insertions(+), 64 deletions(-) create mode 100644 drivers/bus/pci/pci_params.c create mode 100644 drivers/bus/vdev/vdev_params.c create mode 100644 drivers/bus/vdev/vdev_private.h create mode 100644 lib/librte_eal/common/eal_common_class.c create mode 100644 lib/librte_eal/common/include/rte_class.h create mode 100644 lib/librte_ethdev/eth_private.c create mode 100644 lib/librte_ethdev/eth_private.h create mode 100644 lib/librte_ethdev/rte_class_eth.c