From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id E41FF2C2E for ; Tue, 27 Jun 2017 18:11:43 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id b184so31873542wme.1 for ; Tue, 27 Jun 2017 09:11:43 -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=IQ1iIS41lnZc6inXb9CD6dmzDzsvg3X1Ab8IIgNsj9c=; b=wlwxYKCUybcb41m0pBZKva/GrgOTu8wjSdT40dlUNZCpejIYqWLhQHxps58RIZHgAQ j/n3o5J0baAjPENNEa+S5eACvvEXZHmJwgUexHBJwFJliKLWDJ67q6PZDGeJSgsYxQMY lkcMR5zyq5KAN9qSM75FOruBuMqAN5js+XiEIRGpuySRRt1J7Qs8rP2LywmlY9j+th2U bnGITSREhZGzumeTMbLpCh/tFRWcbW9r/waHg0zgQXmHFxPrUFN6WDzuZov5fRb+FFSt TOOP7u6g8as7t2E69ZVd2tpDv+ZkFRb0Pu+xwgDknhV10SSUdd+R1nuCE/eMzC5WV1Pi MygQ== 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=IQ1iIS41lnZc6inXb9CD6dmzDzsvg3X1Ab8IIgNsj9c=; b=MNtjfZ4OwOmFF3enWzTlVgGc+wKUFGDQKJW2p7Qrmb/hmdBZIxAMjGY5FRyIK6VNIP JibZ00OurCVFQWC5R15p6PcEKqxQiE5eZQ2bTTRvwfBFZpYUmxiouGdxf9SgDYxp3cLb iRSb42nWgHqLC8Y3tmVR90/0lc2ERzqzXxQA9v0Q/o1gTlGnU2NMTZelnCsvZSJQyC/s YG6vR3ErNu1k9qns7+dez7xPDx428x33JzUwghTdqPr7HY7weQWV9WGoZQNXzqFjP2GZ LbA4/S3nUjcLFWDkmROa+f2CoU8IQYYMfD7cXl6nTKl28GhjypKZhdNVw8kdvCbS/f2m ESMw== X-Gm-Message-State: AKS2vOw8pL8BSx9N7Q33v6nt6zdmGFfVLZmw2zo3ttNBD3RFUhc7XUYf CitNJC5RdexcLxtmdJ4= X-Received: by 10.28.46.3 with SMTP id u3mr3879585wmu.68.1498579903320; Tue, 27 Jun 2017 09:11:43 -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 v13sm4080465wmd.5.2017.06.27.09.11.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 09:11:42 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 27 Jun 2017 18:11:16 +0200 Message-Id: <5fe2e5fb2759d1f6d3f86e5dfae5c3fc177299da.1498577192.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 09/11] pci: implement find_device bus operation 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: Tue, 27 Jun 2017 16:11:44 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 78b097e..ab55041 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -488,10 +488,31 @@ rte_pci_remove_device(struct rte_pci_device *pci_dev) TAILQ_REMOVE(&rte_pci_bus.device_list, pci_dev, next); } +static struct rte_device * +pci_find_device(rte_dev_cmp_t cmp, + const void *data, + const struct rte_device *start) +{ + struct rte_pci_device *dev; + int start_found = !!(start == NULL); + + FOREACH_DEVICE_ON_PCIBUS(dev) { + if (!start_found) { + if (&dev->device == start) + start_found = 1; + continue; + } + if (cmp(&dev->device, data) == 0) + return &dev->device; + } + return NULL; +} + struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan, .probe = rte_pci_probe, + .find_device = pci_find_device, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), -- 2.1.4