DPDK  17.08.2
rte_bus.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright 2016 NXP
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of NXP nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _RTE_BUS_H_
34 #define _RTE_BUS_H_
35 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #include <stdio.h>
50 #include <sys/queue.h>
51 
52 #include <rte_log.h>
53 #include <rte_dev.h>
54 
56 TAILQ_HEAD(rte_bus_list, rte_bus);
57 
69 typedef int (*rte_bus_scan_t)(void);
70 
81 typedef int (*rte_bus_probe_t)(void);
82 
105 typedef struct rte_device *
106 (*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
107  const void *data);
108 
120 typedef int (*rte_bus_plug_t)(struct rte_device *dev);
121 
133 typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
134 
153 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
154 
159  RTE_BUS_SCAN_UNDEFINED,
160  RTE_BUS_SCAN_WHITELIST,
161  RTE_BUS_SCAN_BLACKLIST,
162 };
163 
167 struct rte_bus_conf {
169 };
170 
174 struct rte_bus {
175  TAILQ_ENTRY(rte_bus) next;
176  const char *name;
184 };
185 
193 void rte_bus_register(struct rte_bus *bus);
194 
202 void rte_bus_unregister(struct rte_bus *bus);
203 
211 int rte_bus_scan(void);
212 
221 int rte_bus_probe(void);
222 
229 void rte_bus_dump(FILE *f);
230 
246 typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
247 
270 struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
271  const void *data);
272 
276 struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
277 
281 struct rte_bus *rte_bus_find_by_name(const char *busname);
282 
287 #define RTE_REGISTER_BUS(nm, bus) \
288 RTE_INIT_PRIO(businitfn_ ##nm, 110); \
289 static void businitfn_ ##nm(void) \
290 {\
291  (bus).name = RTE_STR(nm);\
292  rte_bus_register(&bus); \
293 }
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #endif /* _RTE_BUS_H */