From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 1ED92A492 for ; Wed, 21 Mar 2018 18:16:14 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id o1so5961444wro.10 for ; Wed, 21 Mar 2018 10:16:14 -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=CldOI3z/2PAM0UPpWS0kzu0+wRaGi7NwttfVws7l+IE=; b=J39j74QU+M0dc45jUUv0iMjnFx2S/1rncz/Is1mmgZI/w10fDgQjP7pcvpNtVRqAZO buJhR91aLWfCRk9prDCvVxLqG1430snVo72BWdZqMGctE5W4vL3Q0TjimSQHhDjFuJok B5rGjjIe7Aq3SsrBarqU8H2w//mJ3ko/ckzK2pUdAVCqH40PlpitOxLRofLIWRxZJyy0 VGiu9CiWQHTbIbZG5Tesk9zCDV8delRsFsJwVqYmL3fgWcdqR3hw8dVmn7QDTM66Zw2B qJ7O6pxlC4gSZYK93V7SsAfsFKQ+OZYFz2oF9JUfRWuBejzCGxNJGugs8cb6JK6VMSC0 WDqQ== 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=CldOI3z/2PAM0UPpWS0kzu0+wRaGi7NwttfVws7l+IE=; b=qWmjAlXVzR8U4RWy3aDGA6HkObHOYM/83VwyNtg8wAEUfP5w8gam83XpSvFFey5NXz XOVbaxyPySsb0hWfLGTTq2pyidE0LVescN78mDRnfe3db8eC1PO1pK6cpTtn9GzAX87e 0ThNdlstroQxPxngQWyRH62EVDFx2lRoUbc6MCQ2DPfyqLWLuWy3T2zoIEP7WrxSlbMs 4hrw2+X+CrjBtMbx/IK+ZTRWAgmGqx+Aivrc/3slmbYHEslj+r5O4A/0aPBUyn7wQgSb RTGd9oHmfiFXv8b4W2dFS7xgjPjrtr7OvARh4cpzmu+3Ujx5R1E3sJuYiSEX0GwnRv78 MvHQ== X-Gm-Message-State: AElRT7G/cwlx7EUDsRfeDeHat4AQRDWPHx/+IcEm0F9QJnu+L9NwOiIo brqqWHFVNr0EIWl1vB7A+MrZhAar X-Google-Smtp-Source: AG47ELsOiS8cUxw5gLNWQTTM0/pGhb5/P68p6+3PWQeNB8CKKnZZBPH+YRmfHtg2260oM5c/9zdNjw== X-Received: by 10.223.174.2 with SMTP id x2mr18079226wrc.211.1521652573230; Wed, 21 Mar 2018 10:16:13 -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 l10sm4224101wrf.37.2018.03.21.10.16.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 10:16:12 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Mar 2018 18:15:32 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 11/18] 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: Wed, 21 Mar 2018 17:16:14 -0000 Signed-off-by: Gaetan Rivet --- drivers/bus/pci/Makefile | 2 +- drivers/bus/pci/pci_common.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/Makefile b/drivers/bus/pci/Makefile index f3df1c4ce..73498dc77 100644 --- a/drivers/bus/pci/Makefile +++ b/drivers/bus/pci/Makefile @@ -50,7 +50,7 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common CFLAGS += -I$(RTE_SDK)/lib/librte_eal/$(SYSTEM)app/eal 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..59a776305 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,38 @@ pci_unplug(struct rte_device *dev) return ret; } +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, NULL); + 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 +539,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