1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA Corporation & Affiliates
5 #ifndef BUS_AUXILIARY_PRIVATE_H
6 #define BUS_AUXILIARY_PRIVATE_H
10 #include <sys/queue.h>
12 #include "rte_bus_auxiliary.h"
14 extern struct rte_auxiliary_bus auxiliary_bus;
15 extern int auxiliary_bus_logtype;
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__,)))
22 /* Auxiliary bus iterators */
23 #define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \
24 TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next)
26 #define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \
27 TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next)
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);
35 * Structure describing the auxiliary bus
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 */
44 * Test whether the auxiliary device exist.
46 bool auxiliary_dev_exists(const char *name);
49 * Scan the content of the auxiliary bus, and the devices in the devices
52 int auxiliary_scan(void);
55 * Update a device being scanned.
57 void auxiliary_on_scan(struct rte_auxiliary_device *aux_dev);
60 * Validate whether a device with given auxiliary device should be ignored
63 bool auxiliary_is_ignored_device(const char *name);
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.
70 void auxiliary_add_device(struct rte_auxiliary_device *aux_dev);
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.
77 void auxiliary_insert_device(struct rte_auxiliary_device *exist_aux_dev,
78 struct rte_auxiliary_device *new_aux_dev);
81 * Match the auxiliary driver and device by driver function.
83 bool auxiliary_match(const struct rte_auxiliary_driver *aux_drv,
84 const struct rte_auxiliary_device *aux_dev);
87 * Iterate over devices, matching any device against the provided string.
89 void *auxiliary_dev_iterate(const void *start, const char *str,
90 const struct rte_dev_iterator *it);
92 #endif /* BUS_AUXILIARY_PRIVATE_H */