From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 936A61C17D for ; Fri, 13 Apr 2018 15:23:15 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id s12so8268665wrc.8 for ; Fri, 13 Apr 2018 06:23:15 -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 :in-reply-to:references; bh=4VSLZvntN76SlAdM4C1P7HMw2Cv0U8fSaHCnNpNFNcg=; b=YX+f38kHzqT2KHXa5d1VAvDw+u23YgDRPl4vnVhaorOFfNJ5PVC07NiOTtFuVavHjx tF9UDnpFKYjW7XwnWfYqpZGqt7jLPtX06oHESV++X1n29ECn8OrtQeaDr13+y6HOStuW DlpDKXmr9qs4iwjzLGxKZk5sH/m/jQcAc5sor5Wzq/EHhR7YA2Yddv9JVBvqNyd2rxpW eb5zbSZ1sY4iTns7CbnY1VQbHkfAqbh9VpQ6mTx6mey3IK5i5uBfIr2ZjeV6qlIlJM5V /BEzCE5b5BhPlLgMWO1Gt9v2dYsvUYd62NkET5CjCCLCYgFD3V5lqczo8T2SaU7eKHt8 PfUw== 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:in-reply-to:references; bh=4VSLZvntN76SlAdM4C1P7HMw2Cv0U8fSaHCnNpNFNcg=; b=brFx3ED9xlKrS3lCGqCAxjd7AFscxVUvpNiu/NZqMlo6Pv76QASO92oktWc1QNwBvO 3m/he3wzJrRVtdl8reEL1zaWAdlkCLR/zaibaun4MZbQ5KsU3+oCy9Z/bWKSR5ePOwkD 5fM2IJbS5rX5pE/i1ZMCsFHcoApXLAHh8vYbv+Oe9irH3CAXkl5TrNz4gXtmbCHeEFS1 amBgR6GK6fwSOf3gt7FFh7zTnth9LailQfQd86fMdrDbNSWIS9BDkEC1tu4iZiRKP9B0 GE/2L6DPy6St2ucYj8ldDTP5ahdu8ZTRur82cDcLRXSyEXOvuwVPvKDkz+V3zfg8HbZ/ GtyQ== X-Gm-Message-State: ALQs6tB2xuJRcAuQlDqSUq+6Ifn0u4dg9msu6yJ8+i/OPPRbfZrBrpFX OTYuT5EsCXC+Tt7AUN/MAvpDdvST X-Google-Smtp-Source: AIpwx49ZYQYe+IqFcvlvr750Vu7USukc26/POzgYgAxdxnTQQvKw1NoxaWeo2h/WpimGD5Wuq5sSmw== X-Received: by 10.223.144.195 with SMTP id i61mr4040521wri.227.1523625794966; Fri, 13 Apr 2018 06:23:14 -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 r200sm2377244wmb.9.2018.04.13.06.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Apr 2018 06:23:14 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 13 Apr 2018 15:22:29 +0200 Message-Id: <1b5f5b9e63268e1e5114c7ce8aff1d6b1f557013.1523625525.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 14/22] bus/pci: implement device iteration and comparison 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: Fri, 13 Apr 2018 13:23:15 -0000 Signed-off-by: Gaetan Rivet --- drivers/bus/pci/Makefile | 2 +- drivers/bus/pci/pci_common.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/Makefile b/drivers/bus/pci/Makefile index 804a198d1..bbda567c1 100644 --- a/drivers/bus/pci/Makefile +++ b/drivers/bus/pci/Makefile @@ -53,7 +53,7 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_eal/$(SYSTEM)app/eal CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -LDLIBS += -lrte_ethdev -lrte_pci +LDLIBS += -lrte_ethdev -lrte_pci -lrte_kvargs include $(RTE_SDK)/drivers/bus/pci/$(SYSTEM)/Makefile SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) := $(addprefix $(SYSTEM)/,$(SRCS)) diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 2c45f8151..bd9ecddc6 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -497,6 +498,46 @@ pci_unplug(struct rte_device *dev) return ret; } +enum pci_params { + RTE_PCI_PARAMS_MAX, +}; + +static const char * const pci_params_keys[] = { + [RTE_PCI_PARAMS_MAX] = NULL, +}; + +static int +pci_dev_match(const struct rte_device *dev, + const void *_kvlist) +{ + const struct rte_kvargs *kvlist = _kvlist; + + (void) dev; + (void) kvlist; + return 0; +} + +static void * +pci_dev_iterate(const void *start, + const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ + struct rte_device *dev; + struct rte_kvargs *kvargs = NULL; + + if (str != NULL) { + kvargs = rte_kvargs_parse(str, pci_params_keys); + if (kvargs == NULL) { + RTE_LOG(ERR, EAL, "cannot parse argument list\n"); + rte_errno = EINVAL; + return NULL; + } + } + dev = pci_find_device(start, pci_dev_match, kvargs); + rte_kvargs_free(kvargs); + return dev; +} + struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan, @@ -506,6 +547,7 @@ struct rte_pci_bus rte_pci_bus = { .unplug = pci_unplug, .parse = pci_parse, .get_iommu_class = rte_pci_get_iommu_class, + .dev_iterate = pci_dev_iterate, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), -- 2.11.0