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 <rte_compat.h>
28 * Bus type key in global devargs syntax.
30 * Legacy devargs parser doesn't use this key as bus type
31 * is resolved as first optional value separated by ":".
33 #define RTE_DEVARGS_KEY_BUS "bus"
36 * Class type key in global devargs syntax.
38 * Legacy devargs parser doesn't parse class type. PMD is
39 * encouraged to use this key to resolve class type.
41 #define RTE_DEVARGS_KEY_CLASS "class"
44 * Driver type key in global devargs syntax.
46 * Legacy devargs parser doesn't parse driver type. PMD is
47 * encouraged to use this key to resolve driver type.
49 #define RTE_DEVARGS_KEY_DRIVER "driver"
52 * Type of generic device
61 * Structure that stores a device given by the user with its arguments
63 * A user device is a physical or a virtual device given by the user to
64 * the DPDK application at startup through command line arguments.
66 * The structure stores the configuration of the device, its PCI
67 * identifier if it's a PCI device or the driver name if it's a virtual
72 RTE_TAILQ_ENTRY(rte_devargs) next;
73 /** Type of device. */
74 enum rte_devtype type;
76 enum rte_dev_policy policy;
77 /** Name of the device. */
78 char name[RTE_DEV_NAME_MAX_LEN];
81 const char *args; /**< legacy name. */
82 const char *drv_str; /**< driver-related part of device string. */
84 struct rte_bus *bus; /**< bus handle. */
85 struct rte_class *cls; /**< class handle. */
86 const char *bus_str; /**< bus-related part of device string. */
87 const char *cls_str; /**< class-related part of device string. */
88 char *data; /**< raw string including bus, class and driver parts. */
92 * Parse a device string.
94 * Verify that a bus is capable of handling the device passed
95 * in argument. Store which bus will handle the device, its name
96 * and the eventual device parameters.
100 * bus:device_identifier,arg1=val1,arg2=val2
102 * where "bus:" is the bus name followed by any character separator.
103 * The bus name is optional. If no bus name is specified, each bus
104 * will attempt to recognize the device identifier. The first one
105 * to succeed will be used.
109 * pci:0000:05.00.0,arg=val
114 * The devargs structure holding the device information.
117 * String describing a device.
121 * - Negative errno on error.
124 rte_devargs_parse(struct rte_devargs *da, const char *dev);
127 * Parse a device string.
129 * Verify that a bus is capable of handling the device passed
130 * in argument. Store which bus will handle the device, its name
131 * and the eventual device parameters.
133 * The device string is built with a printf-like syntax.
137 * bus:device_identifier,arg1=val1,arg2=val2
139 * where "bus:" is the bus name followed by any character separator.
140 * The bus name is optional. If no bus name is specified, each bus
141 * will attempt to recognize the device identifier. The first one
142 * to succeed will be used.
146 * pci:0000:05.00.0,arg=val
151 * The devargs structure holding the device information.
153 * Format string describing a device.
157 * - Negative errno on error.
160 rte_devargs_parsef(struct rte_devargs *da,
161 const char *format, ...)
162 __rte_format_printf(2, 0);
165 * Free resources in devargs.
168 * The devargs structure holding the device information.
172 rte_devargs_reset(struct rte_devargs *da);
175 * Insert an rte_devargs in the global list.
178 * The devargs structure to insert.
179 * If a devargs for the same device is already inserted,
180 * it will be updated and returned. It means *da pointer can change.
184 * - Negative on error.
187 rte_devargs_insert(struct rte_devargs **da);
190 * Add a device to the user device list
191 * See rte_devargs_parse() for details.
194 * The type of the device.
196 * The arguments as given by the user.
200 * - A negative value on error
202 int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
205 * Remove a device from the user device list.
206 * Its resources are freed.
207 * If the devargs cannot be found, nothing happens.
210 * The instance or a copy of devargs to remove.
215 * >0 if the devargs was not within the user device list.
217 int rte_devargs_remove(struct rte_devargs *devargs);
220 * Count the number of user devices of a specified type
223 * The type of the devices to counted.
226 * The number of devices.
229 rte_devargs_type_count(enum rte_devtype devtype);
232 * This function dumps the list of user device and their arguments.
235 * A pointer to a file for output
237 void rte_devargs_dump(FILE *f);
240 * Find next rte_devargs matching the provided bus name.
243 * Limit the iteration to devargs related to buses
244 * matching this name.
245 * Will return any next rte_devargs if NULL.
248 * Starting iteration point. The iteration will start at
249 * the first rte_devargs if NULL.
252 * Next rte_devargs entry matching the requested bus,
253 * NULL if there is none.
256 rte_devargs_next(const char *busname, const struct rte_devargs *start);
259 * Iterate over all rte_devargs for a specific bus.
261 #define RTE_EAL_DEVARGS_FOREACH(busname, da) \
262 for (da = rte_devargs_next(busname, NULL); \
264 da = rte_devargs_next(busname, da)) \
270 #endif /* _RTE_DEVARGS_H_ */