From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 92B9C378E for ; Thu, 29 Jun 2017 20:22:31 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id p204so4072409wmg.1 for ; Thu, 29 Jun 2017 11:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=YKtz0KBh2CRzNew9WesZ5M5Z+lUfOZyvrqzmSJ32r2g=; b=OfuhVrD3LWjkTK76FGotec4+ZD1nZn4xKClZCAoPS6D5qaTAIIRIG64sznbaJ7ckgj phWMCYuRGWPxa4cH9QRY0/cOza/qRyG/ipjfJQ55a3vHUkmdWnsh+yYcnxxawPEY5/zs fa0VMFjvBijApDQ7w8rB+HTiTt/K1HPh1YqO8sGHawJIPy8KHq5UdCKn4yHUbQ3QdX2b qldSrOrMdeofoSBHloiE5x5DCkwLD/HyyQJxnc2Ne1MKClgmt9nbmXgwAu3heLUinZbP vBALqkWtfGHyanmwtVt3+lE6kMf86wYATJdEVkECJClsQO2yp3HNTJcMNZE/lBXcVQhU Uu2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=YKtz0KBh2CRzNew9WesZ5M5Z+lUfOZyvrqzmSJ32r2g=; b=X5Swspa0pu4/8fK76ITHlpImONYR1YBjL7QYljkwFNy5SSRGV1TnzhTl7aiE4hNl+W WfBIgo/FJaROI6QKCD3YsVMYGu62hniI6eLpKynW68S4EThCqKRrC8DEmit/GSYGxfaD Ap8JRmrnFUjgKA8jaCGQ52Ws7ifL4dqAO5UNH9HzyXzulvSGEeoWcw96zys4YGfbeM5U JdCe2jKeeAHN9RYt3/T8gvX4MdNHETDJbQLUN0Dq8L1Kf99GJuEi9CIm4tHOsRqN895C lkbIrp7namnU6CzVWbpBntb+g0Z9C0Uo7sFn/d2UT5mnGgHM7LV9IY+84Nqug9gvEvmo mqGw== X-Gm-Message-State: AKS2vOzqW+fja8Ie4pw/HTzUg0C/O39mC3D+gOD/tDDVk4Mg2zQZNepK HoyWt+eTVUyOLmur X-Received: by 10.80.135.175 with SMTP id a44mr2675923eda.90.1498760551022; Thu, 29 Jun 2017 11:22:31 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id e28sm1446366ede.14.2017.06.29.11.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 11:22:30 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Thu, 29 Jun 2017 20:21:55 +0200 Message-Id: <20170629182206.1072-5-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v7 04/15] 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: Thu, 29 Jun 2017 18:22:32 -0000 Signed-off-by: Jan Blunck --- 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 479c62d..e449758 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -485,10 +485,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(const struct rte_device *start, rte_dev_cmp_t cmp, + const void *data) +{ + struct rte_pci_device *dev; + bool start_found = !start; + + 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.9.4