DPDK  22.03.0
rte_dev.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014 6WIND S.A.
3  */
4 
5 #ifndef _RTE_DEV_H_
6 #define _RTE_DEV_H_
7 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <stdio.h>
21 
22 #include <rte_config.h>
23 #include <rte_compat.h>
24 #include <rte_log.h>
25 
33 };
34 
35 typedef void (*rte_dev_event_cb_fn)(const char *device_name,
36  enum rte_dev_event_type event,
37  void *cb_arg);
38 
39 /* Macros to check for invalid function pointers */
40 #define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \
41  if ((func) == NULL) \
42  return retval; \
43 } while (0)
44 
45 #define RTE_FUNC_PTR_OR_RET(func) do { \
46  if ((func) == NULL) \
47  return; \
48 } while (0)
49 
54  RTE_DEV_ALLOWED,
55  RTE_DEV_BLOCKED,
56 };
57 
62  uint64_t phys_addr;
63  uint64_t len;
64  void *addr;
65 };
66 
70 struct rte_driver {
71  RTE_TAILQ_ENTRY(rte_driver) next;
72  const char *name;
73  const char *alias;
74 };
75 
76 /*
77  * Internal identifier length
78  * Sufficiently large to allow for UUID or PCI address
79  */
80 #define RTE_DEV_NAME_MAX_LEN 64
81 
85 struct rte_device {
86  RTE_TAILQ_ENTRY(rte_device) next;
87  const char *name;
88  const struct rte_driver *driver;
89  const struct rte_bus *bus;
90  int numa_node;
91  struct rte_devargs *devargs;
92 };
93 
102 int rte_dev_is_probed(const struct rte_device *dev);
103 
120 int rte_eal_hotplug_add(const char *busname, const char *devname,
121  const char *drvargs);
122 
134 int rte_dev_probe(const char *devargs);
135 
149 int rte_eal_hotplug_remove(const char *busname, const char *devname);
150 
162 int rte_dev_remove(struct rte_device *dev);
163 
183 typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
184 
185 #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
186 
187 #define RTE_PMD_EXPORT_NAME(name, idx) \
188 static const char RTE_PMD_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
189 __rte_used = RTE_STR(name)
190 
191 #define DRV_EXP_TAG(name, tag) __##name##_##tag
192 
193 #define RTE_PMD_REGISTER_PCI_TABLE(name, table) \
194 static const char DRV_EXP_TAG(name, pci_tbl_export)[] __rte_used = \
195 RTE_STR(table)
196 
197 #define RTE_PMD_REGISTER_PARAM_STRING(name, str) \
198 static const char DRV_EXP_TAG(name, param_string_export)[] \
199 __rte_used = str
200 
222 #define RTE_PMD_REGISTER_KMOD_DEP(name, str) \
223 static const char DRV_EXP_TAG(name, kmod_dep_export)[] \
224 __rte_used = str
225 
232  const char *dev_str;
233  const char *bus_str;
234  const char *cls_str;
235  struct rte_bus *bus;
236  struct rte_class *cls;
237  struct rte_device *device;
238  void *class_device;
239 };
240 
269 typedef void *(*rte_dev_iterate_t)(const void *start,
270  const char *devstr,
271  const struct rte_dev_iterator *it);
272 
293 __rte_experimental
294 int
295 rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
296 
313 __rte_experimental
314 struct rte_device *
316 
317 #define RTE_DEV_FOREACH(dev, devstr, it) \
318  for (rte_dev_iterator_init(it, devstr), \
319  dev = rte_dev_iterator_next(it); \
320  dev != NULL; \
321  dev = rte_dev_iterator_next(it))
322 
323 #ifdef __cplusplus
324 }
325 #endif
326 
346 __rte_experimental
347 int
348 rte_dev_event_callback_register(const char *device_name,
349  rte_dev_event_cb_fn cb_fn,
350  void *cb_arg);
351 
371 __rte_experimental
372 int
373 rte_dev_event_callback_unregister(const char *device_name,
374  rte_dev_event_cb_fn cb_fn,
375  void *cb_arg);
376 
389 __rte_experimental
390 void
391 rte_dev_event_callback_process(const char *device_name,
392  enum rte_dev_event_type event);
393 
404 __rte_experimental
405 int
407 
418 __rte_experimental
419 int
421 
432 __rte_experimental
433 int
435 
446 __rte_experimental
447 int
449 
470 __rte_experimental
471 int
472 rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
473 
494 __rte_experimental
495 int
496 rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova,
497  size_t len);
498 
499 #endif /* _RTE_DEV_H_ */
__rte_experimental int rte_dev_event_monitor_start(void)
struct rte_device * device
Definition: rte_dev.h:237
__rte_experimental int rte_dev_hotplug_handle_enable(void)
uint64_t len
Definition: rte_dev.h:63
const char * cls_str
Definition: rte_dev.h:234
int rte_dev_is_probed(const struct rte_device *dev)
__rte_experimental int rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str)
void * addr
Definition: rte_dev.h:64
void * class_device
Definition: rte_dev.h:238
int rte_dev_remove(struct rte_device *dev)
struct rte_class * cls
Definition: rte_dev.h:236
__rte_experimental int rte_dev_event_callback_register(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
rte_dev_event_type
Definition: rte_dev.h:29
int rte_dev_probe(const char *devargs)
__rte_experimental int rte_dev_event_callback_unregister(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)
uint64_t phys_addr
Definition: rte_dev.h:62
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs)
__rte_experimental int rte_dev_event_monitor_stop(void)
rte_dev_policy
Definition: rte_dev.h:53
__rte_experimental struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it)
struct rte_bus * bus
Definition: rte_dev.h:235
struct rte_devargs * devargs
Definition: rte_dev.h:91
int rte_eal_hotplug_remove(const char *busname, const char *devname)
int numa_node
Definition: rte_dev.h:90
__rte_experimental int rte_dev_hotplug_handle_disable(void)
const char * name
Definition: rte_dev.h:72
const char * bus_str
Definition: rte_dev.h:233
__rte_experimental void rte_dev_event_callback_process(const char *device_name, enum rte_dev_event_type event)
__rte_experimental int rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
const char * name
Definition: rte_dev.h:87
const char * alias
Definition: rte_dev.h:73
const char * dev_str
Definition: rte_dev.h:232
const struct rte_driver * driver
Definition: rte_dev.h:88
__rte_experimental int rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len)
const struct rte_bus * bus
Definition: rte_dev.h:89
int(* rte_dev_cmp_t)(const struct rte_device *dev, const void *data)
Definition: rte_dev.h:183