rte_dev.h(3)
β¨ NAME β¨
rte_dev.h β bestie, that's it, that's the whole name. Just the header file, no extra lore. π
(This one lives in the Library Functions Manual, section 3, so when you're yelling for it you're yelling for rte_dev.h(3).) π«Ά
πΈ SYNOPSIS πΈ
Okay so first things first, you gotta pull in the whole friend group:
#include <stdio.h>
#include <rte_config.h>
#include <rte_common.h>
#include <rte_log.h>
And then here's the entire cast of characters this header hands you. Buckle up, it's a lot, but we're built for this. π
π Data Structures
struct rte_mem_resourcestruct rte_dev_iterator
π¦ Typedefs
typedef int(* rte_dev_cmp_t) (const struct rte_device *dev, const void *data)typedef void *(* rte_dev_iterate_t) (const void *start, const char *devstr, const struct rte_dev_iterator *it)
π Enumerations
enum rte_dev_event_type { RTE_DEV_EVENT_ADD, RTE_DEV_EVENT_REMOVE, RTE_DEV_EVENT_MAX }enum rte_dev_policy
π§ Functions
Like, the entire roster, no skips, no "you'll figure it out":
const char * rte_driver_name (const struct rte_driver *driver)const struct rte_bus * rte_dev_bus (const struct rte_device *dev)const char * rte_dev_bus_info (const struct rte_device *dev)const struct rte_devargs * rte_dev_devargs (const struct rte_device *dev)const struct rte_driver * rte_dev_driver (const struct rte_device *dev)const char * rte_dev_name (const struct rte_device *dev)int rte_dev_numa_node (const struct rte_device *dev)int rte_dev_is_probed (const struct rte_device *dev)int rte_eal_hotplug_add (const char *busname, const char *devname, const char *drvargs)int rte_dev_probe (const char *devargs)int rte_eal_hotplug_remove (const char *busname, const char *devname)int rte_dev_remove (struct rte_device *dev)int rte_dev_iterator_init (struct rte_dev_iterator *it, const char *str)struct rte_device * rte_dev_iterator_next (struct rte_dev_iterator *it)int rte_dev_event_callback_register (const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)int rte_dev_event_callback_unregister (const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg)void rte_dev_event_callback_process (const char *device_name, enum rte_dev_event_type event)int rte_dev_event_monitor_start (void)int rte_dev_event_monitor_stop (void)int rte_dev_hotplug_handle_enable (void)int rte_dev_hotplug_handle_disable (void)int rte_dev_dma_map (struct rte_device *dev, void *addr, uint64_t iova, size_t len)int rte_dev_dma_unmap (struct rte_device *dev, void *addr, uint64_t iova, size_t len)
π Detailed Description π
RTE PMD Registration Interface β that's the whole vibe of this file, bestie.
Real talk though: this file manages the list of device drivers. That's the job. That's what it does. π«‘
Definition in file rte_dev.h.
π Typedef Documentation π
π typedef int(* rte_dev_cmp_t) (const struct rte_device *dev, const void *data)
Device comparison function. β¨
So this is the type of function you use when you wanna compare an rte_device against some arbitrary data. Lowkey a matchmaker, highkey a sorting tool. π
Parameters
devβ Device handle. (the little guy we're checking)dataβ Data to compare against. The type of this parameter is determined by the kind of comparison performed by the function. (so like, you decide whatdataeven means, no pressure π« )
Returns
0if the device matches the data.!0if the device does not match.<0if ordering is possible and the device is lower than the data.>0if ordering is possible and the device is greater than the data.
Definition at line 233 of file rte_dev.h.
π typedef void *(* rte_dev_iterate_t) (const void *start, const char *devstr, const struct rte_dev_iterator *it)
Device iteration function. π¦
Find the next device matching properties passed in parameters. The function takes an additional start parameter, that is used as starting context when relevant.
The function returns the current element in the iteration. This return value will potentially be used as a start parameter in subsequent calls to the function. (yes bestie, it's a lil relay race πββοΈπ¨)
The additional iterator parameter is only there if a specific implementation needs additional context. It must not be modified by the iteration function itself. No touching. π ββοΈ
Parameters
startβ Starting iteration context.devstrβ Device description string.itβ Device iterator.
Returns
The address of the current element matching the device description string. π
Definition at line 278 of file rte_dev.h.
π Enumeration Type Documentation π
β enum rte_dev_event_type
The device event type.
Enumerator
RTE_DEV_EVENT_ADDβ device being added πRTE_DEV_EVENT_REMOVEβ device being removed πRTE_DEV_EVENT_MAXβ max value of this enum (the ceiling, the limit, the final boss π)
Definition at line 34 of file rte_dev.h.
β enum rte_dev_policy
Device policies. That's the description, bestie, that's all they gave us. π
Definition at line 47 of file rte_dev.h.
β¦and that's only part 1, so don't you dare close the tab β more is coming π«Ά
β¨ FUNCTION DOCUMENTATION β¨
okay bestie we're in the big one now β this is where the actual functions live. grab a snack, this is giving β¨reference manualβ¨ but make it cute. every single one of these is real, and yes, I kept every param and every return value, no cap π
rte_driver_name</p>
const char * rte_driver_name(const struct rte_driver *driver);
Pull the driver name out, girl. that's it, that's the function.
Parameters
driverβ a pointer to a driver structure.
Returns
- a pointer to the driver name string.
rte_dev_bus</p>
const struct rte_bus * rte_dev_bus(const struct rte_device *dev);
Which bus does this device live on? find out here π
Parameters
devβ a pointer to a device structure.
Returns
- a pointer to this device's bus.
rte_dev_bus_info</p>
const char * rte_dev_bus_info(const struct rte_device *dev);
Grab the bus-specific tea about a device β
Parameters
devβ a pointer to a device structure.
Returns
- a string describing this device, or
NULLif there isn't one available. (iykyk, always check for theNULLπ)
rte_dev_devargs</p>
const struct rte_devargs * rte_dev_devargs(const struct rte_device *dev);
Get the devargs for a device.
Parameters
devβ a pointer to a device structure.
Returns
- a pointer to this device's devargs.
rte_dev_driver</p>
const struct rte_driver * rte_dev_driver(const struct rte_device *dev);
The driver this device is vibing with. periodt.
Parameters
devβ a pointer to a device structure.
Returns
- a pointer to this device's driver.
rte_dev_name</p>
const char * rte_dev_name(const struct rte_device *dev);
What's the device called? name reveal π
Parameters
devβ a pointer to a device structure.
Returns
- a pointer to this device's name.
rte_dev_numa_node</p>
int rte_dev_numa_node(const struct rte_device *dev);
Which NUMA node is this device on? lowkey essential info π§
Parameters
devβ a pointer to a device structure.
Returns
- a pointer to this device's numa node. (that's genuinely what the doc says for an
intreturn, bestie β I'm just the messenger, not about to rewrite the docs on you π)
rte_dev_is_probed</p>
int rte_dev_is_probed(const struct rte_device *dev);
Status check on a device β has it been probed or not?
Parameters
devβ generic device pointer.
Returns
(int)trueif it's already been probed successfully,0otherwise.
rte_eal_hotplug_add</p>
int rte_eal_hotplug_add(const char *busname, const char *devname, const char *drvargs);
Hotplug-add a given device to a specific bus π₯π
Multi-process heads up: in multi-process, it will ask the other processes to add the same device. A failure, in any process, will rollback the action. so no half-done chaos, it's all or nothing β¨
Parameters
busnameβ the bus name the device is being added to.devnameβ the device name. based on this name, eal will find a driver capable of handling it and hand it over to the driver's probing function.drvargsβ device arguments to pass to the driver.
Returns
0on success, negative on error.
rte_dev_probe</p>
int rte_dev_probe(const char *devargs);
Add matching devices. matching era π―
Multi-process heads up: in multi-process, it will ask the other processes to add the same device. A failure, in any process, will rollback the action.
Parameters
devargsβ device arguments, including bus, class and driver properties.
Returns
0on success, negative on error.
rte_eal_hotplug_remove</p>
int rte_eal_hotplug_remove(const char *busname, const char *devname);
Hotplug-remove a given device from a specific bus. bye bestie ππ
Multi-process heads up: in multi-process, it will ask the other processes to remove the same device. A failure, in any process, will rollback the action.
Parameters
busnameβ the bus name the device is being removed from.devnameβ the device name being removed.
Returns
0on success, negative on error.
rte_dev_remove</p>
int rte_dev_remove(struct rte_device *dev);
Remove one device. one. singular. not a group thing π€
Multi-process heads up: in multi-process, it will ask the other processes to remove the same device. A failure, in any process, will rollback the action.
Parameters
devβ data structure of the device to remove.
Returns
0on success, negative on error.
rte_dev_iterator_init</p>
int rte_dev_iterator_init(struct rte_dev_iterator *it, const char *str);
Initializes a device iterator β¨
This iterator lets you access a whole list of devices matching some criteria. The matching happens across all buses and classes that are currently registered, filtered by the device description you pass in as the parameter.
Big selling point: this function will not allocate any memory. it is safe to stop the iteration at any moment and just let the iterator go out of context. no cleanup drama, no leaks, we love to see it π«Ά
Parameters
itβ device iterator handle.strβ device description string.
Returns
0on successful initialization.<0on error.
rte_dev_iterator_next</p>
struct rte_device * rte_dev_iterator_next(struct rte_dev_iterator *it);
Iterates on a device iterator β‘οΈ
Generates a new rte_device handle corresponding to the next element in the list that the iterator is describing.
The next object gets returned, and the iterator is updated.
Parameters
itβ device iterator handle.
Returns
- an
rte_devicehandle if one is found. NULLif an error occurred (rte_errnois set).NULLif no device could be found (rte_errnois not set).
Careful, bestie: those twoNULLs mean completely different things. checkrte_errnobefore you panic π
rte_dev_event_callback_register</p>
int rte_dev_event_callback_register(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg);
Registers the callback for the specific device. and yes, multiple callbacks can be registered at the same time β the more the merrier π
Parameters
device_nameβ the device name, that is the paramnameof the structrte_device. a null value means it applies to all devices.cb_fnβ callback address.cb_argβ address of the parameter for the callback.
Returns
- on success, zero.
- on failure, a negative value.
rte_dev_event_callback_unregister</p>
int rte_dev_event_callback_unregister(const char *device_name, rte_dev_event_cb_fn cb_fn, void *cb_arg);
Unregisters the callback according to the specified device. clean up after yourself queen π
Parameters
device_nameβ the device name, that is the paramnameof the structrte_device. a null value means it applies to all devices and their callbacks.cb_fnβ callback address.cb_argβ address of the parameter for the callback.(void *)-1means remove all registered ones that have the same callback address.
Returns
- on success, it returns the number of callback entities removed.
- on failure, a negative value.
rte_dev_event_callback_process</p>
void rte_dev_event_callback_process(const char *device_name, enum rte_dev_event_type event);
Executes all the user-application-registered callbacks for that specific device. everyone gets their moment π€
Parameters
device_nameβ the device name.eventβ the device event type.
rte_dev_event_monitor_start</p>
int rte_dev_event_monitor_start(void);
Start the device event monitoring. it's watching πβ¨
Returns
- on success, zero.
- on failure, a negative value.
rte_dev_event_monitor_stop</p>
int rte_dev_event_monitor_stop(void);
Stop the device event monitoring. okay it's done watching, go home π
Returns
- on success, zero.
- on failure, a negative value.
rte_dev_hotplug_handle_enable</p>
int rte_dev_hotplug_handle_enable(void);
Enable hotplug handling for devices ππ₯
Returns
- on success, zero.
- on failure, a negative value.
rte_dev_hotplug_handle_disable</p>
int rte_dev_hotplug_handle_disable(void);
Disable hotplug handling for devices. shutting it down π«
Returns
- on success, zero.
- on failure, a negative value.
rte_dev_dma_map</p>
int rte_dev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
Device-level DMA map function. after a successful call, the memory segment will be mapped to the given device πΊοΈ
NOTE: memory must be registered in advance using the rte_extmem_* APIs. no prereg, no mapping, that's the rule π«Ά
Parameters
devβ device pointer.addrβ virtual address to map.iovaβ IOVA address to map.lenβ length of the memory segment being mapped.
Returns
0if the mapping was successful. a negative value andrte_errnois set otherwise.
rte_dev_dma_unmap</p>
int rte_dev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len);
Device-level DMA unmap function. after a successful call, the memory segment will no longer be accessible by the given device. it's giving β¨goneβ¨
NOTE: memory must be registered in advance using the rte_extmem_* APIs.
Parameters
devβ device pointer.addrβ virtual address to unmap.iovaβ IOVA address to unmap.lenβ length of the memory segment being mapped.
Returns
0if the un-mapping was successful. a negative value andrte_errnois set otherwise.
β¨ AUTHOR β¨
Generated automatically by Doxygen for DPDK from the source code. (yes girl, the docs wrote themselves β very main character energy of them π)
and that's a wrap on rte_dev.h(3), bestie!! π you made it through the entire function list, every param, every return value, every <0 β I'm so proud, genuinely. this page came from DPDK, Version 25.11.3, and it's dated rte_dev.h(3) β that's the source/version/date footer, in case you ever need to cite your girl. go forth and hotplug responsibly ππ¦
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms