From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 57DD37CE7 for ; Thu, 29 Mar 2018 23:24:29 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id p9so12916579wmc.3 for ; Thu, 29 Mar 2018 14:24: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=QonXUXMV6Sx/byYBe/hWCV+hK1L1mAz+IjBGd34uLNo=; b=RNXrzLsSv4zc5PlmLxagLtNUhGY9K0oS3rwy/z5Kqd/X7a0da2FLVg+A3uyS8V5cp2 MpK/RVgbmBOfkbwI9Bi6b+/ZoCEhTNNutR+0jj4JVbF4YBkp3Ll54BPpfr/YztO5KWG7 rxEVuCX1F1Rk5KY+hLniNpWCTDTGt9Q4+9FE8Op1f5J7tB7GJrhGnsQE9q/FiGHw8y7D htEXVMxzP2DBrukpz4W7+BOm7zJO+dfR9mGrvzRcmf0nft1kQyMv8K5x2FkoLqdHt3yb aDFBZWZTe+UbC/yQ/4lnFUDqs5+KC/NPUwGaXpOd1P0WZAvluXmUxZOS+I2T7bIhc+UU 7JbQ== 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=QonXUXMV6Sx/byYBe/hWCV+hK1L1mAz+IjBGd34uLNo=; b=bqgtmx8OxTdImNEdMJgg1OHLZcpT7TTuKBOQh2dCaqGGa7f382Z/+no0h0HSGWp1B+ rdqdN9rABNdBEI5v5vKML6ZXDHY6pi3s5zBKYdUlmbL92AFdm/SUI6AWvXIREqbXVhej 2ORGKoCGpg5IaGDjtsefKHQPcsn2GtEozmBZ7LCI69ai6LFswylDWEOWDkrK+wvEgQ+2 xWKKnJwcdXZEUaMdIcrJu5Wa8suMo5QM6IcysTkTEKvW9wCINGonyay6VjwzlnUIq8ne 3bD4GNfd903zvOi0/jFTesRlmbkcaMXcmiZEpBN2kxvId3WMq5bAafpbAm0lRfOyAWJK P6fg== X-Gm-Message-State: AElRT7Fuz4cYb6f/TC844PQm5VbxU5KcR1vguJLq8tIIpluQI6H3VKKg E+ehGt6RkhyMBzVqLWOURfPy4/Vb X-Google-Smtp-Source: AIpwx48N8sZymcliI25WqATalLV5bj1xbVbI57Iegramk9vLUo6efDBnub1jsmHMof0uYM9MPFTOcw== X-Received: by 10.28.141.138 with SMTP id p132mr430309wmd.51.1522358668670; Thu, 29 Mar 2018 14:24:28 -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 m35sm11907457wrm.59.2018.03.29.14.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 14:24:27 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 29 Mar 2018 23:23:37 +0200 Message-Id: <244316b8a38b7e76fd1ec61b878b246df1c2a9d7.1522358422.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 v4 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: Thu, 29 Mar 2018 21:24: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 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..5ce2e5733 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 *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