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 44BADA497 for ; Tue, 27 Mar 2018 01:19:21 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id 80so19432245wrb.2 for ; Mon, 26 Mar 2018 16:19:21 -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=dd6qW/mxVyvzDt7evZi0QkEefs4HLSEMdhBTmXGrgXhJdzBduGdqt0z8as5j1Rx2ZB a9ZEQOoQduPZLL5Gb5EVyVY5mstT/DthPlaLekcX7YNZM7LArbiBKtEEO+sJ72sEQyzT wvNB0OITwSEyq9DskoLQ12k0MF61uWSuVgxdPAWGKCVXtgNPkm8tR20teEH5nL3UHqCw /H1pcStTZPIDNhYjm3i4DO+UR6Gy5u6hoJ5Ajv03xoPxRfiYPMnExdXzJ1o1P7g4yDkV k/WfhgbPCcrS6IH/LNzbptgzyjXzdqrK2PejKrw42nZXaDeIXLdNhyvG8NKOijtD8pAh NbrQ== 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=O8Hzh9CGMg1EWNAQo9UnXx1dosvoZeRyRXGY06L3oZlSXnK9fQ2yEj7FuVfSkA/3/h EhaOsXJb09LwjtYN5QR6uHVTU8UO41meQFjBrMEmiXpAVUdndO5ZWLZXQH1M5K4mK9s6 7mvRfMJWN7ZPvQbEasUzJKx2NMcnM/KCEHr8qZ2VfEn/B2w52u3Zy8vhO2mJa5yr9690 S66poABzeNFDOx3Kzg1rPresqiYipae8RyXRyNdLZcziRMk9x1ZJryMoiuE8TCsRYfdC XZBs/uSvylbDyB92MhDbKlP9sGLomQa+tArpmtaSS+4FE1N5P40ndWrmnwJ05ckiW+SA BTng== X-Gm-Message-State: AElRT7E5es2FT5U+tl3hvqfwf3xg7MXuuV8KBWH4VaKBRXLdRwtoo2hv 37WDrt68mSzPrESbUxgAnSlEof4u X-Google-Smtp-Source: AG47ELth+bScq6wSm7bh5on9N2eaevGpEeHlJPEI5Q6llTXiFGbVzyIZW3GlGO5zQ5Og8geUYQ1zsg== X-Received: by 10.223.155.154 with SMTP id d26mr30854821wrc.8.1522106360598; Mon, 26 Mar 2018 16:19:20 -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 67sm343712wra.9.2018.03.26.16.19.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 16:19:19 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 27 Mar 2018 01:18:37 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 13/20] 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: Mon, 26 Mar 2018 23:19:21 -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