From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f170.google.com (mail-wr0-f170.google.com [209.85.128.170]) by dpdk.org (Postfix) with ESMTP id 7AC0A7CD7 for ; Wed, 24 May 2017 17:09:35 +0200 (CEST) Received: by mail-wr0-f170.google.com with SMTP id w50so56901038wrc.0 for ; Wed, 24 May 2017 08:09:35 -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; bh=LYGzHEhvzQCm3vYybLTh4htDEk0aFrKGHLwT1dTIe2c=; b=f+hg+iBh/p0eC1v4U7g3Hy07j42MClYb1+isQ6wfnPrqlJi5rNr5lLpEaZwbIv8KTb ZbPWQ4vZuTfFNkPQ5JQTXVBkXh55wWERt0Rskw4qU69IjLNJVAFCnRahjC0QE1K1wxze JHfM/eCtu8XRROuPUge2eGTZCDPtp3kEK5skny9nytqOYhKV6XqLE8PPVcp3yolkd5dv f/wnLWf+9TGp84LfVZpthnFMUPQiaqpy5HEZNGPofa9nogicc6s+Z8vK0CFOjFXxgByy d9WPsHlTejgaRXQsdrRproEiCXHNgIzpK8FAqhQX3o0tlX919vwIXwL0ivNtiiru5tve YoAQ== 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; bh=LYGzHEhvzQCm3vYybLTh4htDEk0aFrKGHLwT1dTIe2c=; b=hrGyjjrlLbB44BtrmrpqY+bOsjSAbbKLUopRxjuP5BqBxsVDxGKuZCXRphoN/5cgb7 DdXmnsKOh1xA6ARyOYt2VgHVKdu4MpaELHpTu0nZlUgXxD1ExskYzhkUuEKQocW8lAaq naRoSRQNAp1jxAgUpcnKDq/QhXlCcUvjLPYh6Lu2dwUgGhb0IN4/CpzV+2Amc+zFKksl woaQZDlZHTjczQCgnFaJ7Zp56O54bCLnjox6lFgNnGGe0KAT+qlhrgD7qRouzPkGP579 UaHVPudwqSaprjl/G0L2glWR+gE9jpha7+tYJl0eiRZuM/DEAMRiA6FpBCX0opMRqZ0B fj0g== X-Gm-Message-State: AODbwcBIEW1prwLZVPPAN+K0FYZO+hxpfPrI7ZhW4et/mpipPvr4Ozts 8JkiuwH+wPaNsO6g X-Received: by 10.223.165.14 with SMTP id i14mr24161836wrb.127.1495638575161; Wed, 24 May 2017 08:09:35 -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 m21sm3841342wma.30.2017.05.24.08.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 08:09:34 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , Jan Blunck Date: Wed, 24 May 2017 17:09:19 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] 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: Wed, 24 May 2017 15:09:35 -0000 Signed-off-by: Gaetan Rivet --- This patch depends on: bus: attach / detach API http://dpdk.org/ml/archives/dev/2017-May/066330.html http://dpdk.org/dev/patchwork/patch/24489/ --- lib/librte_eal/common/eal_common_pci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index b749991..8428006 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -512,10 +512,24 @@ 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(int (*match)(const struct rte_device *dev, const void *data), + const void *data) +{ + struct rte_pci_device *dev; + + FOREACH_DEVICE_ON_PCIBUS(dev) { + if (match(&dev->device, data)) + 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