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 * Bus type key in global devargs syntax.
31 * Legacy devargs parser doesn't use this key as bus type
32 * is resolved as first optional value separated by ":".
34 #define RTE_DEVARGS_KEY_BUS "bus"
37 * Class type key in global devargs syntax.
39 * Legacy devargs parser doesn't parse class type. PMD driver is
40 * encouraged to use this key to resolve class type.
42 #define RTE_DEVARGS_KEY_CLASS "class"
45 * Driver type key in global devargs syntax.
47 * Legacy devargs parser doesn't parse driver type. PMD driver is
48 * encouraged to use this key to resolve driver type.
50 #define RTE_DEVARGS_KEY_DRIVER "driver"
53 * Type of generic device
61 /* Backwards compatibility will be removed later */
62 #define RTE_DEVTYPE_WHITELISTED_PCI \
63 RTE_DEPRECATED(RTE_DEVTYPE_WHITELISTED_PCI) RTE_DEVTYPE_ALLOWED
64 #define RTE_DEVTYPE_BLACKLISTED_PCI \
65 RTE_DEPRECATED(RTE_DEVTYPE_BLACKLISTED_PCI) RTE_DEVTYPE_BLOCKED
68 * Structure that stores a device given by the user with its arguments
70 * A user device is a physical or a virtual device given by the user to
71 * the DPDK application at startup through command line arguments.
73 * The structure stores the configuration of the device, its PCI
74 * identifier if it's a PCI device or the driver name if it's a virtual
79 TAILQ_ENTRY(rte_devargs) next;
80 /** Type of device. */
81 enum rte_devtype type;
83 enum rte_dev_policy policy;
84 /** Name of the device. */
85 char name[RTE_DEV_NAME_MAX_LEN];
88 const char *args; /**< legacy name. */
89 const char *drv_str; /**< driver-related part of device string. */
91 struct rte_bus *bus; /**< bus handle. */
92 struct rte_class *cls; /**< class handle. */
93 const char *bus_str; /**< bus-related part of device string. */
94 const char *cls_str; /**< class-related part of device string. */
95 char *data; /**< raw string including bus, class and driver parts. */
99 * Parse a device string.
101 * Verify that a bus is capable of handling the device passed
102 * in argument. Store which bus will handle the device, its name
103 * and the eventual device parameters.
107 * bus:device_identifier,arg1=val1,arg2=val2
109 * where "bus:" is the bus name followed by any character separator.
110 * The bus name is optional. If no bus name is specified, each bus
111 * will attempt to recognize the device identifier. The first one
112 * to succeed will be used.
116 * pci:0000:05.00.0,arg=val
121 * The devargs structure holding the device information.
124 * String describing a device.
128 * - Negative errno on error.
131 rte_devargs_parse(struct rte_devargs *da, const char *dev);
134 * Parse a device string.
136 * Verify that a bus is capable of handling the device passed
137 * in argument. Store which bus will handle the device, its name
138 * and the eventual device parameters.
140 * The device string is built with a printf-like syntax.
144 * bus:device_identifier,arg1=val1,arg2=val2
146 * where "bus:" is the bus name followed by any character separator.
147 * The bus name is optional. If no bus name is specified, each bus
148 * will attempt to recognize the device identifier. The first one
149 * to succeed will be used.
153 * pci:0000:05.00.0,arg=val
158 * The devargs structure holding the device information.
160 * Format string describing a device.
164 * - Negative errno on error.
167 rte_devargs_parsef(struct rte_devargs *da,
168 const char *format, ...)
169 __rte_format_printf(2, 0);
172 * Free resources in devargs.
175 * The devargs structure holding the device information.
179 rte_devargs_reset(struct rte_devargs *da);
182 * Insert an rte_devargs in the global list.
185 * The devargs structure to insert.
186 * If a devargs for the same device is already inserted,
187 * it will be updated and returned. It means *da pointer can change.
191 * - Negative on error.
194 rte_devargs_insert(struct rte_devargs **da);
197 * Add a device to the user device list
198 * See rte_devargs_parse() for details.
201 * The type of the device.
203 * The arguments as given by the user.
207 * - A negative value on error
209 int rte_devargs_add(enum rte_devtype devtype, const char *devargs_str);
212 * Remove a device from the user device list.
213 * Its resources are freed.
214 * If the devargs cannot be found, nothing happens.
217 * The instance or a copy of devargs to remove.
222 * >0 if the devargs was not within the user device list.
224 int rte_devargs_remove(struct rte_devargs *devargs);
227 * Count the number of user devices of a specified type
230 * The type of the devices to counted.
233 * The number of devices.
236 rte_devargs_type_count(enum rte_devtype devtype);
239 * This function dumps the list of user device and their arguments.
242 * A pointer to a file for output
244 void rte_devargs_dump(FILE *f);
247 * Find next rte_devargs matching the provided bus name.
250 * Limit the iteration to devargs related to buses
251 * matching this name.
252 * Will return any next rte_devargs if NULL.
255 * Starting iteration point. The iteration will start at
256 * the first rte_devargs if NULL.
259 * Next rte_devargs entry matching the requested bus,
260 * NULL if there is none.
263 rte_devargs_next(const char *busname, const struct rte_devargs *start);
266 * Iterate over all rte_devargs for a specific bus.
268 #define RTE_EAL_DEVARGS_FOREACH(busname, da) \
269 for (da = rte_devargs_next(busname, NULL); \
271 da = rte_devargs_next(busname, da)) \
277 #endif /* _RTE_DEVARGS_H_ */