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 <bus_driver.h> 13 14 #include "bus_auxiliary_driver.h" 15 16 extern int auxiliary_bus_logtype; 17 #define RTE_LOGTYPE_AUXILIARY_BUS auxiliary_bus_logtype 18 19 #define AUXILIARY_LOG(level, ...) \ 20 RTE_LOG_LINE(level, AUXILIARY_BUS, __VA_ARGS__) 21 22 /* 23 * Structure describing the auxiliary bus 24 */ 25 struct rte_auxiliary_bus { 26 struct rte_bus bus; /* Inherit the generic class */ 27 TAILQ_HEAD(, rte_auxiliary_device) device_list; /* List of devices */ 28 TAILQ_HEAD(, rte_auxiliary_driver) driver_list; /* List of drivers */ 29 }; 30 31 extern struct rte_auxiliary_bus auxiliary_bus; 32 33 /* Auxiliary bus iterators */ 34 #define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \ 35 TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next) 36 37 #define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \ 38 TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next) 39 40 /* 41 * Test whether the auxiliary device exist. 42 */ 43 bool auxiliary_dev_exists(const char *name); 44 45 /* 46 * Scan the content of the auxiliary bus, and the devices in the devices 47 * list. 48 */ 49 int auxiliary_scan(void); 50 51 /* 52 * Update a device being scanned. 53 */ 54 void auxiliary_on_scan(struct rte_auxiliary_device *aux_dev); 55 56 /* 57 * Validate whether a device with given auxiliary device should be ignored 58 * or not. 59 */ 60 bool auxiliary_is_ignored_device(const char *name); 61 62 /* 63 * Add an auxiliary device to the auxiliary bus (append to auxiliary device 64 * list). This function also updates the bus references of the auxiliary 65 * device and the generic device object embedded within. 66 */ 67 void auxiliary_add_device(struct rte_auxiliary_device *aux_dev); 68 69 /* 70 * Insert an auxiliary device in the auxiliary bus at a particular location 71 * in the device list. It also updates the auxiliary bus reference of the 72 * new devices to be inserted. 73 */ 74 void auxiliary_insert_device(struct rte_auxiliary_device *exist_aux_dev, 75 struct rte_auxiliary_device *new_aux_dev); 76 77 /* 78 * Match the auxiliary driver and device by driver function. 79 */ 80 bool auxiliary_match(const struct rte_auxiliary_driver *aux_drv, 81 const struct rte_auxiliary_device *aux_dev); 82 83 /* 84 * Iterate over devices, matching any device against the provided string. 85 */ 86 void *auxiliary_dev_iterate(const void *start, const char *str, 87 const struct rte_dev_iterator *it); 88 89 #endif /* BUS_AUXILIARY_PRIVATE_H */ 90