DPDK  21.02.0
rte_bus.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016 NXP
3  */
4 
5 #ifndef _RTE_BUS_H_
6 #define _RTE_BUS_H_
7 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdio.h>
22 #include <sys/queue.h>
23 
24 #include <rte_log.h>
25 #include <rte_dev.h>
26 
28 TAILQ_HEAD(rte_bus_list, rte_bus);
29 
30 
40  RTE_IOVA_DC = 0, /* Don't care mode */
41  RTE_IOVA_PA = (1 << 0), /* DMA using physical address */
42  RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */
43 };
44 
56 typedef int (*rte_bus_scan_t)(void);
57 
68 typedef int (*rte_bus_probe_t)(void);
69 
92 typedef struct rte_device *
93 (*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
94  const void *data);
95 
107 typedef int (*rte_bus_plug_t)(struct rte_device *dev);
108 
120 typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
121 
140 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
141 
160 typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
161  uint64_t iova, size_t len);
162 
181 typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
182  uint64_t iova, size_t len);
183 
196 typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
197 
211 typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
212 
217  RTE_BUS_SCAN_UNDEFINED,
218  RTE_BUS_SCAN_ALLOWLIST,
219  RTE_BUS_SCAN_BLOCKLIST,
220 };
221 
222 /* Backwards compatibility will be removed */
223 #define RTE_BUS_SCAN_WHITELIST \
224  RTE_DEPRECATED(RTE_BUS_SCAN_WHITELIST) RTE_BUS_SCAN_ALLOWLIST
225 #define RTE_BUS_SCAN_BLACKLIST \
226  RTE_DEPRECATED(RTE_BUS_SCAN_BLACKLIST) RTE_BUS_SCAN_BLOCKLIST
227 
231 struct rte_bus_conf {
233 };
234 
235 
247 
248 
252 struct rte_bus {
253  TAILQ_ENTRY(rte_bus) next;
254  const char *name;
271 };
272 
280 void rte_bus_register(struct rte_bus *bus);
281 
289 void rte_bus_unregister(struct rte_bus *bus);
290 
298 int rte_bus_scan(void);
299 
308 int rte_bus_probe(void);
309 
316 void rte_bus_dump(FILE *f);
317 
333 typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
334 
357 struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
358  const void *data);
359 
363 struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
364 
368 struct rte_bus *rte_bus_find_by_name(const char *busname);
369 
370 
379 
384 #define RTE_REGISTER_BUS(nm, bus) \
385 RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
386 {\
387  (bus).name = RTE_STR(nm);\
388  rte_bus_register(&bus); \
389 }
390 
391 #ifdef __cplusplus
392 }
393 #endif
394 
395 #endif /* _RTE_BUS_H */
enum rte_iova_mode(* rte_bus_get_iommu_class_t)(void)
Definition: rte_bus.h:246
void *(* rte_dev_iterate_t)(const void *start, const char *devstr, const struct rte_dev_iterator *it)
Definition: rte_dev.h:276
int(* rte_bus_sigbus_handler_t)(const void *failure_addr)
Definition: rte_bus.h:211
enum rte_iova_mode rte_bus_get_iommu_class(void)
void rte_bus_register(struct rte_bus *bus)
int(* rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus.h:181
struct rte_device *(* rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data)
Definition: rte_bus.h:93
rte_bus_unplug_t unplug
Definition: rte_bus.h:259
TAILQ_HEAD(rte_bus_list, rte_bus)
rte_bus_find_device_t find_device
Definition: rte_bus.h:257
rte_iova_mode
Definition: rte_bus.h:39
int rte_bus_probe(void)
struct rte_bus_conf conf
Definition: rte_bus.h:263
int(* rte_bus_cmp_t)(const struct rte_bus *bus, const void *data)
Definition: rte_bus.h:333
rte_dev_dma_unmap_t dma_unmap
Definition: rte_bus.h:262
rte_dev_dma_map_t dma_map
Definition: rte_bus.h:261
rte_bus_hot_unplug_handler_t hot_unplug_handler
Definition: rte_bus.h:266
TAILQ_ENTRY(rte_bus) next
int(* rte_dev_dma_map_t)(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
Definition: rte_bus.h:160
int(* rte_bus_plug_t)(struct rte_device *dev)
Definition: rte_bus.h:107
void rte_bus_dump(FILE *f)
rte_bus_parse_t parse
Definition: rte_bus.h:260
rte_dev_iterate_t dev_iterate
Definition: rte_bus.h:265
struct rte_bus * rte_bus_find_by_name(const char *busname)
int(* rte_bus_parse_t)(const char *name, void *addr)
Definition: rte_bus.h:140
rte_bus_sigbus_handler_t sigbus_handler
Definition: rte_bus.h:268
const char * name
Definition: rte_bus.h:254
rte_bus_scan_t scan
Definition: rte_bus.h:255
rte_bus_scan_mode
Definition: rte_bus.h:216
struct rte_bus * rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, const void *data)
int(* rte_bus_probe_t)(void)
Definition: rte_bus.h:68
rte_bus_probe_t probe
Definition: rte_bus.h:256
int(* rte_bus_hot_unplug_handler_t)(struct rte_device *dev)
Definition: rte_bus.h:196
struct rte_bus * rte_bus_find_by_device(const struct rte_device *dev)
rte_bus_get_iommu_class_t get_iommu_class
Definition: rte_bus.h:264
const char * name
Definition: rte_dev.h:94
void rte_bus_unregister(struct rte_bus *bus)
rte_bus_plug_t plug
Definition: rte_bus.h:258
enum rte_bus_scan_mode scan_mode
Definition: rte_bus.h:232
int(* rte_bus_scan_t)(void)
Definition: rte_bus.h:56
int(* rte_bus_unplug_t)(struct rte_device *dev)
Definition: rte_bus.h:120
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:190
int rte_bus_scan(void)