From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id CC2A31BAA3 for ; Wed, 11 Apr 2018 02:04:57 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id c24so36843wrc.6 for ; Tue, 10 Apr 2018 17:04:57 -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=8G1hOkLIrezbK1lesisf81buwffa8SW3XhpWdPs2eQU=; b=jyn5JR/8DllgBxR4BejAR0jQhfjxcNfhAMubecwOoGdwqxHVAeKTcpjy2C+FvWwqz2 +6f+tZ6bDjtRPSw6ASKZBiMxyj/mqYiRWT8/gwQ2QlXuE4zzwhxKbt9WSEfsqv1imr14 0FH4WVHYiMrEbZz3EpdsW/bb23xgDnpYOv3H37/AhjmdnWVXAZoEhC9VwYfYgFVql9yL tbHtVc1mrBTzC00Cjz9NJeNW7+R2eARfg9UtlU3sAt0IO6F6MiSjPr7DNoeR0w+FaseD fLa4477cix0+xPd8Mb4qNFrBvgnZS37G9VQvyqEQqK/50T2UCHwavhDCDbOPsFqZE10r eN0Q== 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=8G1hOkLIrezbK1lesisf81buwffa8SW3XhpWdPs2eQU=; b=rujbIzSKCknAE/pSuObTd9ietZpr85itj8gU6oQbozRSqWr1DLGucTLK1pbjuhZ14K FEO5KeMv1D7LMBZ8/FSuKX7JAgdAgqcHcyuMixVWni4DzfQ18C/Oype4t0JkyJl+EYCK w0GcaT8K3zjCzd/vEAMb17D4fBNDX5n92LKdSpC8uBkDIXJ5DIef3PEDNyIpE9RQ/DYw 2ONIcWUJ3SnJu1so6dfMy5sPtFzQuDlFqHdMtKpUF/FqaXyl1LwdgjfEY827oZQu41OG /glHBMHSMYe0j9429ToR2cGiYLGoWyNCiuCst09a2SFdo0rJ3FJAaZjtXmXTzrtzTuUs 3+2g== X-Gm-Message-State: ALQs6tB1+zLryr16q32hvObkYWyeKtqNrMKbsULdI7WoYF7ddScz752v 4/12JoA8lGqtKl/lcDJIAOUGJ2l8 X-Google-Smtp-Source: AIpwx4+2OTV03v9bVaEcErf41EuMueuV/y4QAa7f9NDhb1XZjPTZ/h6eEjsrd/tOmYT1mwVmq1bm8g== X-Received: by 10.223.193.129 with SMTP id x1mr1647238wre.166.1523405097230; Tue, 10 Apr 2018 17:04: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 39sm7626563wry.89.2018.04.10.17.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 17:04:56 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Apr 2018 02:04:14 +0200 Message-Id: <8bad50b79dbabdd84dd9a89e4124128fd9272113.1523404469.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 v5 13/21] 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, 11 Apr 2018 00:04:58 -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 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..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