xref: /dpdk/drivers/bus/auxiliary/private.h (revision f1f6ebc0)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2021 NVIDIA Corporation & Affiliates
3  */
4 
5 #ifndef BUS_AUXILIARY_PRIVATE_H
6 #define BUS_AUXILIARY_PRIVATE_H
7 
8 #include <stdbool.h>
9 #include <stdio.h>
10 #include <sys/queue.h>
11 
12 #include "rte_bus_auxiliary.h"
13 
14 extern struct rte_auxiliary_bus auxiliary_bus;
15 extern int auxiliary_bus_logtype;
16 
17 #define AUXILIARY_LOG(level, ...) \
18 	rte_log(RTE_LOG_ ## level, auxiliary_bus_logtype, \
19 		RTE_FMT("auxiliary bus: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
20 			RTE_FMT_TAIL(__VA_ARGS__,)))
21 
22 /* Auxiliary bus iterators */
23 #define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \
24 		TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next)
25 
26 #define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \
27 		TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next)
28 
29 /* List of auxiliary devices. */
30 TAILQ_HEAD(rte_auxiliary_device_list, rte_auxiliary_device);
31 /* List of auxiliary drivers. */
32 TAILQ_HEAD(rte_auxiliary_driver_list, rte_auxiliary_driver);
33 
34 /*
35  * Structure describing the auxiliary bus
36  */
37 struct rte_auxiliary_bus {
38 	struct rte_bus bus;                  /* Inherit the generic class */
39 	struct rte_auxiliary_device_list device_list;  /* List of devices */
40 	struct rte_auxiliary_driver_list driver_list;  /* List of drivers */
41 };
42 
43 /*
44  * Test whether the auxiliary device exist.
45  */
46 bool auxiliary_dev_exists(const char *name);
47 
48 /*
49  * Scan the content of the auxiliary bus, and the devices in the devices
50  * list.
51  */
52 int auxiliary_scan(void);
53 
54 /*
55  * Update a device being scanned.
56  */
57 void auxiliary_on_scan(struct rte_auxiliary_device *aux_dev);
58 
59 /*
60  * Validate whether a device with given auxiliary device should be ignored
61  * or not.
62  */
63 bool auxiliary_is_ignored_device(const char *name);
64 
65 /*
66  * Add an auxiliary device to the auxiliary bus (append to auxiliary device
67  * list). This function also updates the bus references of the auxiliary
68  * device and the generic device object embedded within.
69  */
70 void auxiliary_add_device(struct rte_auxiliary_device *aux_dev);
71 
72 /*
73  * Insert an auxiliary device in the auxiliary bus at a particular location
74  * in the device list. It also updates the auxiliary bus reference of the
75  * new devices to be inserted.
76  */
77 void auxiliary_insert_device(struct rte_auxiliary_device *exist_aux_dev,
78 			     struct rte_auxiliary_device *new_aux_dev);
79 
80 /*
81  * Match the auxiliary driver and device by driver function.
82  */
83 bool auxiliary_match(const struct rte_auxiliary_driver *aux_drv,
84 		     const struct rte_auxiliary_device *aux_dev);
85 
86 /*
87  * Iterate over devices, matching any device against the provided string.
88  */
89 void *auxiliary_dev_iterate(const void *start, const char *str,
90 			    const struct rte_dev_iterator *it);
91 
92 #endif /* BUS_AUXILIARY_PRIVATE_H */
93