From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 3081237A6 for ; Fri, 30 Jun 2017 20:20:06 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id j85so9318745wmj.0 for ; Fri, 30 Jun 2017 11:20:06 -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=A755sRFKJZ3/W0zIvcO19xa93rm6V37wUNTu2ZTno+sMXVMSqZoAGaNZA345TK6Aj1 OxPnyzyuw3cxGi6AWNDZKornwGvEhSQsPOYTnWO2sbbg37j+4PJRydXsxNdir3b0kYf8 bpkafWDAVrMjdWseJcvz0BvCPv6R/THeaAz3RX1VR7ZFu6ITYz7UeowHRgU+LxiuQkcL jME/oUSnoRWNM/ClE4l/mYejFpM7nd8Yp0c33Rbeu8ivtTWmh+EkaxexYSnThaK36/l8 sODTO77gJni6YUe0XqagthVQhGrGpLsRjXcjqllSGrlaXzu50p/YLrHgUbWbmkFWm++K r2Ug== 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=aqp9JCaWpNRhtInf3+6YU7TLJuiLFuXYaCzUt4u6E5ZMM08VgZ+pdUCyqKoQ33Mgeq vb9wiySDsustSY8/2y2DJK2p9K6ckyK3WsywJAJVSUf22iBrvXbP2zAf+qToHTZiv1v0 rj0NKYNKvTNvJ+VkbMOTbs4h/eTTwZChs8uitgKJVAp6WmNmlgVeJJl17kJCgfYD3htU KcImySRwSdnFfqOmjt0Lt1HVFltc0kjPmwrPump7kQwhS4RyOF888k8o95qHulN8AAu+ yuAsU+M6WXQlBEKUQXvvOZUOA8nfjimMErgb+2K820i49Z7AVq3WNzpAiKQdU+IOtftO Iq7w== X-Gm-Message-State: AKS2vOxi7WoTgRIJvCutzV001sFH6hjxCBt1o3zoj774U4ubLKkO+Z5M WVUGBEH7PNpr65bs X-Received: by 10.80.179.109 with SMTP id r42mr2994466edd.1.1498846805835; Fri, 30 Jun 2017 11:20:05 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id r28sm2826940edd.33.2017.06.30.11.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 11:20:04 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Fri, 30 Jun 2017 20:19:33 +0200 Message-Id: <20170630181943.23929-5-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v8 04/14] 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: Fri, 30 Jun 2017 18:20:06 -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