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 66F9437A6 for ; Fri, 30 Jun 2017 20:20:08 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id u23so9331539wma.2 for ; Fri, 30 Jun 2017 11:20:08 -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=cn/+KPXtP9puYuDhbASHM/xUE4CFH02Ry/E38rhEmaA=; b=fUj+1PHahPOBqkw/Em7XnSl9wTkLzKZ+xJY0Kz3GPoETVyVb/zMlvs4OTo4MJe/uYq u4z++hjAhZYPUC+igmJcKs/YFd43GRyJA6PvfbUsasKW18gaD0yjhmSSM/g/QDTHcZb0 0GYOq0xmyWj+Uq7N+lWBUrKe/fFMSh8GJc5G4c8EfYep+cmR9NOC6x7QmwXql2+gCtPR krb+/b0rlVcmLwG37lpnEAWAgrmBVUscZBNKqbUMDYJST1AJPDJHq4grPjCpREXoRtNh ib3qACGj2YHTGIVTAOdAZWF4mKxHdeezfwEywyfRRjOFNSWYNe80trWJ3VRwkE+81+6G 19Dg== 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=cn/+KPXtP9puYuDhbASHM/xUE4CFH02Ry/E38rhEmaA=; b=CU20aKvvGAthewyi6UyxQLhoD4QL9seKTUsAolCrvlz37GnAOTa+WYvxsbIAdhRdZQ SzHodG/LDC8v3XgS8+YuGk3gy+pZKtjx07uQ/52TkuJPXIdeM4LlIr2JwP8Zcs0rqTtn nhwjgtsmQi8eDoPULjYrVxLg5j7IuROWz7O3iSaFc/B0OD4ClyZfsdO/PYEU5322MS2k hmHkT7L54lY2DQXg/W9OlHEkGbQJMS6g5QUdMP1oaHz81QZOyKQizc0hKlEx4OeqxJvh jRnbs9cQAyFf9F01UDVznniMUvnGdkFBq9q+ieOD23cPTaSCmbd4iXXV4/Gljf43VVdr THaQ== X-Gm-Message-State: AKS2vOw50qhKj6BnuhPnE9cYzzMCHUVJUEw3g7zbPpZdDSignXZXDR5n fHPWHenIh6gk6KGq X-Received: by 10.80.210.197 with SMTP id q5mr6195948edg.147.1498846808037; Fri, 30 Jun 2017 11:20:08 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id r28sm2826940edd.33.2017.06.30.11.20.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 11:20:07 -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:35 +0200 Message-Id: <20170630181943.23929-7-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 06/14] bus: add helper to find which bus holds a device 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:08 -0000 Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 23 +++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 30 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index edf9d7d..458e3a6 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -198,5 +198,6 @@ DPDK_17.08 { global: rte_bus_find; + rte_bus_find_by_device; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 3094daa..5d06f5d 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -164,3 +164,26 @@ rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, } return bus; } + +static int +cmp_rte_device(const struct rte_device *dev1, const void *_dev2) +{ + const struct rte_device *dev2 = _dev2; + + return dev1 != dev2; +} + +static int +bus_find_device(const struct rte_bus *bus, const void *_dev) +{ + struct rte_device *dev; + + dev = bus->find_device(NULL, cmp_rte_device, _dev); + return dev == NULL; +} + +struct rte_bus * +rte_bus_find_by_device(const struct rte_device *dev) +{ + return rte_bus_find(NULL, bus_find_device, (const void *)dev); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 052ac8d..f8b3215 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -210,6 +210,11 @@ struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, const void *data); /** + * Find the registered bus for a particular device. + */ +struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); + +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. */ diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 944416e..3c193e4 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -203,5 +203,6 @@ DPDK_17.08 { global: rte_bus_find; + rte_bus_find_by_device; } DPDK_17.05; -- 2.9.4