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 864971B63E for ; Sun, 15 Apr 2018 17:08:29 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id q6so7218910wrd.6 for ; Sun, 15 Apr 2018 08:08:29 -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=vUuvBWcc4ijFNiKWTeYDhH72jHiQ5ehypfez7dZzPIuAOUGeobCj38mGlgbpVATljM yY0aUKygsP6dAb3bVImutgo8ciMAAhmVBy8cgzw4GFJKCA3A6D2I8+yiotYq+ceOqngD ueqMIjVKRq0JwoTo2HOSpB0rTVq3jxriROvgSzQjs3QEsP/mlz7EOBOTTpugacfiTxU1 8SqBEebNIkGAH3z2V3KguRPTyPC4HRV0jMXqehrkoFN1B4jJPuBE2wru51t4mRlTkxQt Spb4bmWGKIUjW80lviDElIFGq2VLauSIl46T0KqZfxhk2tOIi8DhwwnKFlImkPrZJ9vp vPFg== 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=cqT14uUJTnm/pkZ8BXfed6x1kXLfOr0xF3AiYu4Jw/ZV6eCHmUPMKnbW/prGIoI1TM +ATlupoqO9nKM16YpglmmY4Zo6/WjtgN6LSpVD7oqtZk6yo5Gz8bvSRjum1MuevLYWWv 3bLY1yz2v75sYA7yeta5uudvKwp/KhK+bGgUFRU2gmZhxeB08nDuMLKCphOwGlrXR26Y /u/abKxf2UOHTbUFCRGKfh8FPZiJJVqrBHzZEdsY6remNvRNkfA39itrJMFi3PAbmWj8 3p4drFNfZfRzeIt1s6HxHlUHBpXhXmCdx48qzI7GWCXSzUz3Et2xo3J4qWAkqqhQEqAf S8vw== X-Gm-Message-State: ALQs6tAkrLDGR76Z/zfmqxj2Au8ZsKhM6o6AT/u4xI+Jea6k1EmtbPCN 1gfp5Zb9T6qnm4DKR5l8VKBWYGFe X-Google-Smtp-Source: AIpwx4/RI2nkHcWk9x6UW7Wz1sQ/tmNCZS78/hZWxcPq9KsnOf6a+NycJexm/WQmfMwO2+OzJZ7sJQ== X-Received: by 10.28.147.83 with SMTP id v80mr3494437wmd.91.1523804907935; Sun, 15 Apr 2018 08:08:27 -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 r200sm13673438wmb.39.2018.04.15.08.08.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Apr 2018 08:08:26 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sun, 15 Apr 2018 17:07:43 +0200 Message-Id: <41951cada3e889f5dc598ce983cae62c8b6db826.1523804657.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 v7 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: Sun, 15 Apr 2018 15:08:29 -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