1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2014 6WIND S.A.
5 #ifndef _RTE_DEVARGS_H_
6 #define _RTE_DEVARGS_H_
11 * RTE devargs: list of devices and their user arguments
13 * This file stores a list of devices and their arguments given by
14 * the user when a DPDK application is started. These devices can be PCI
15 * devices or virtual devices. These devices are stored at startup in a
16 * list of rte_devargs structures.
24 #include <sys/queue.h>
25 #include <rte_compat.h>
29 * Type of generic device
37 /* Backwards compatibility will be removed later */
38 #define RTE_DEVTYPE_WHITELISTED_PCI \
39 RTE_DEPRECATED(RTE_DEVTYPE_WHITELISTED_PCI) RTE_DEVTYPE_ALLOWED
40 #define RTE_DEVTYPE_BLACKLISTED_PCI \
41 RTE_DEPRECATED(RTE_DEVTYPE_BLACKLISTED_PCI) RTE_DEVTYPE_BLOCKED
44 * Structure that stores a device given by the user with its arguments
46 * A user device is a physical or a virtual device given by the user to
47 * the DPDK application at startup through command line arguments.
49 * The structure stores the configuration of the device, its PCI
50 * identifier if it's a PCI device or the driver name if it's a virtual
55 TAILQ_ENTRY(rte_devargs) next;
56 /** Type of device. */
57 enum rte_devtype type;
59 enum rte_dev_policy policy;
60 /** Name of the device. */
61 char name[RTE_DEV_NAME_MAX_LEN];
64 /** Arguments string as given by user or "" for no argument. */
68 struct rte_bus *bus; /**< bus handle. */
69 struct rte_class *cls; /**< class handle. */
70 const char *bus_str; /**< bus-related part of device string. */
71 const char *cls_str; /**< class-related part of device string. */
72 const char *data; /**< Device string storage. */
76 * Parse a device string.
78 * Verify that a bus is capable of handling the device passed
79 * in argument. Store which bus will handle the device, its name
80 * and the eventual device parameters.
84 * bus:device_identifier,arg1=val1,arg2=val2
86 * where "bus:" is the bus name followed by any character separator.
87 * The bus name is optional. If no bus name is specified, each bus
88 * will attempt to recognize the device identifier. The first one
89 * to succeed will be used.
93 * pci:0000:05.00.0,arg=val
98 * The devargs structure holding the device information.
101 * String describing a device.
105 * - Negative errno on error.
108 rte_devargs_parse(struct rte_devargs *da, const char *dev);
111 * Parse a device string.
113 * Verify that a bus is capable of handling the device passed
114 * in argument. Store which bus will handle the device, its name
115 * and the eventual device parameters.
117 * The device string is built with a printf-like syntax.
121 * bus:device_identifier,arg1=val1,arg2=val2
123 * where "bus:" is the bus name followed by any character separator.
124 * The bus name is optional. If no bus name is specified, each bus
125 * will attempt to recognize the device identifier. The first one
126 * to succeed will be used.
130 * pci:0000:05.00.0,arg=val
135 * The devargs structure holding the device information.
137 * Format string describing a device.
141 * - Negative errno on error.
144 rte_devargs_parsef(struct rte_devargs *da,
145 const char *format, ...)
146 __rte_format_printf(2, 0);
149 * Insert an rte_devargs in the global list.
152 * The devargs structure to insert.
153 * If a devargs for the same device is already inserted,
154 * it will be updated and returned. It means *da pointer can change.
158 * - Negative on error.
161 rte_devargs_insert(struct rte_devargs **da);
164 * Add a device to the user device list
165 * See rte_devargs_parse() for details.
168 * The type of the device.
170 * The arguments as given by the user.
174 * - A negative value on error
176 int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
179 * Remove a device from the user device list.
180 * Its resources are freed.
181 * If the devargs cannot be found, nothing happens.
184 * The instance or a copy of devargs to remove.
189 * >0 if the devargs was not within the user device list.
191 int rte_devargs_remove(struct rte_devargs *devargs);
194 * Count the number of user devices of a specified type
197 * The type of the devices to counted.
200 * The number of devices.
203 rte_devargs_type_count(enum rte_devtype devtype);
206 * This function dumps the list of user device and their arguments.
209 * A pointer to a file for output
211 void rte_devargs_dump(FILE *f);
214 * Find next rte_devargs matching the provided bus name.
217 * Limit the iteration to devargs related to buses
218 * matching this name.
219 * Will return any next rte_devargs if NULL.
222 * Starting iteration point. The iteration will start at
223 * the first rte_devargs if NULL.
226 * Next rte_devargs entry matching the requested bus,
227 * NULL if there is none.
230 rte_devargs_next(const char *busname, const struct rte_devargs *start);
233 * Iterate over all rte_devargs for a specific bus.
235 #define RTE_EAL_DEVARGS_FOREACH(busname, da) \
236 for (da = rte_devargs_next(busname, NULL); \
238 da = rte_devargs_next(busname, da)) \
244 #endif /* _RTE_DEVARGS_H_ */