rte_rawdev.h(3)
π rte_rawdev.h(3) β the raw device glow-up manual π
okay bestie, listen β this is rte_rawdev.h(3), the library functions manual for DPDK's generic device abstraction. It's literally the header that lets your app talk to devices that don't fit into any of DPDK's cute little pre-made categories. No cap. π
β¨ SYNOPSIS β¨
#include <rte_common.h>
#include <rte_memory.h>
π Data Structures
struct rte_rawdev_xstats_name
π§ Macros
#define RTE_RAW_DEV_XSTATS_NAME_SIZE 64
π Functions
uint8_t rte_rawdev_count (void)
int rte_rawdev_get_dev_id (const char *name)
int rte_rawdev_socket_id (uint16_t dev_id)
int rte_rawdev_info_get (uint16_t dev_id, struct rte_rawdev_info *dev_info, size_t dev_private_size)
int rte_rawdev_configure (uint16_t dev_id, struct rte_rawdev_info *dev_conf, size_t dev_private_size)
int rte_rawdev_queue_conf_get (uint16_t dev_id, uint16_t queue_id, rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
int rte_rawdev_queue_setup (uint16_t dev_id, uint16_t queue_id, rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
int rte_rawdev_queue_release (uint16_t dev_id, uint16_t queue_id)
uint16_t rte_rawdev_queue_count (uint16_t dev_id)
int rte_rawdev_start (uint16_t dev_id)
void rte_rawdev_stop (uint16_t dev_id)
int rte_rawdev_close (uint16_t dev_id)
int rte_rawdev_reset (uint16_t dev_id)
int rte_rawdev_dump (uint16_t dev_id, FILE *f)
int rte_rawdev_get_attr (uint16_t dev_id, const char *attr_name, uint64_t *attr_value)
int rte_rawdev_set_attr (uint16_t dev_id, const char *attr_name, const uint64_t attr_value)
int rte_rawdev_enqueue_buffers (uint16_t dev_id, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)
int rte_rawdev_dequeue_buffers (uint16_t dev_id, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)
int rte_rawdev_xstats_names_get (uint16_t dev_id, struct rte_rawdev_xstats_name *xstats_names, unsigned int size)
int rte_rawdev_xstats_get (uint16_t dev_id, const unsigned int ids[], uint64_t values[], unsigned int n)
uint64_t rte_rawdev_xstats_by_name_get (uint16_t dev_id, const char *name, unsigned int *id)
int rte_rawdev_xstats_reset (uint16_t dev_id, const uint32_t ids[], uint32_t nb_ids)
int rte_rawdev_firmware_status_get (uint16_t dev_id, rte_rawdev_obj_t status_info)
int rte_rawdev_firmware_version_get (uint16_t dev_id, rte_rawdev_obj_t version_info)
int rte_rawdev_firmware_load (uint16_t dev_id, rte_rawdev_obj_t firmware_image)
int rte_rawdev_firmware_unload (uint16_t dev_id)
int rte_rawdev_selftest (uint16_t dev_id)
πΈ Detailed Description πΈ
Generic device abstraction APIs.
Bestie, this whole API is here so your app can configure and use generic devices that literally have no specific type already available in DPDK. Like, the device shows up, it's not a NIC, not a crypto thing, not an eventdev β it's justβ¦ a device. And this header handles it. π
Defined in file rte_rawdev.h.
π Macro Definition Documentation π
π #define RTE_RAW_DEV_XSTATS_NAME_SIZE 64
Maximum name length for extended statistics counters. That's it, that's the whole macro β 64 characters of name budget, use them wisely queen. β¨
Definition at line 443 of file rte_rawdev.h.
π Function Documentation π
π« uint8_t rte_rawdev_count (void )
Get the total number of raw devices that have been successfully initialised. If it didn't init, it doesn't count. Periodt.
Returns
The total number of usable raw devices.
π« int rte_rawdev_get_dev_id (const char * name)
Get the device identifier for the named raw device. You bring the name, it gives you the id. π
Parameters
nameβ Raw device name to select the raw device identifier.
Returns
Returns raw device identifier on success.
<0: Failure to find named raw device. π
π« int rte_rawdev_socket_id (uint16_t dev_id)
Return the NUMA socket to which a device is connected. Your device has a home and statistically it's a socket. π
Parameters
dev_idβ The identifier of the device.
Returns
The NUMA socket id to which the device is connected, or a default of zero if the socket could not be determined. -(-EINVAL) dev_id value is out of range.
π« int rte_rawdev_info_get (uint16_t dev_id, struct rte_rawdev_info * dev_info, size_t dev_private_size)
Retrieve the contextual information of a raw device. It's giving "tell me everything about yourself". π
Parameters
dev_idβ The identifier of the device.dev_infoβ A pointer to a structure of typerte_rawdev_infoto be filled with the contextual information of the device. Thedev_info->dev_privatefield should point to an appropriate buffer space for holding the device-specific info for that hardware. If thedev_privatefield is set toNULL, then the device-specific info function will not be called and only basic information about the device will be returned. This can be used to safely query the type of a rawdev instance without needing to know the size of the private data to return.dev_private_sizeβ The length of the memory space pointed to bydev_privateindev_info. This should be set to the size of the expected private structure to be returned, and may be checked by drivers to ensure the expected struct type is provided.
Returns
0: Success, driver updates the contextual information of the raw device<0: Error code returned by the driver info get function.
π« int rte_rawdev_configure (uint16_t dev_id, struct rte_rawdev_info * dev_conf, size_t dev_private_size)
Configure a raw device. π οΈ
This function must be invoked first before any other function in the API. Like, FIRST first. No skipping the queue bestie. This function can also be re-invoked when a device is in the stopped state.
The caller may use rte_rawdev_info_get() to get the capability of each resources available for this raw device.
Parameters
dev_idβ The identifier of the device to configure.dev_confβ The raw device configuration structure encapsulated intorte_rawdev_infoobject. It is assumed that the opaque object has enough information which the driver/implementation can use to configure the device. It is also assumed that once the configuration is done, aqueue_idtype field can be used to refer to some arbitrary internal representation of a queue.dev_private_sizeβ The length of the memory space pointed to bydev_privateindev_info. This should be set to the size of the expected private structure to be used by the driver, and may be checked by drivers to ensure the expected struct type is provided.
Returns
0: Success, device configured.<0: Error code returned by the driver configuration function.
π« int rte_rawdev_queue_conf_get (uint16_t dev_id, uint16_t queue_id, rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
Retrieve the current configuration information of a raw queue designated by its queue_id from the raw driver for a raw device. π
This function intended to be used in conjunction with rte_raw_queue_setup() where caller needs to set up the queue by overriding few default values.
Parameters
dev_idβ The identifier of the device.queue_idβ The index of the raw queue to get the configuration information. The value must be in the range[0, nb_raw_queues - 1]previously supplied torte_rawdev_configure().queue_confβ The pointer to the default raw queue configuration data.queue_conf_sizeβ The size of the structure pointed to byqueue_conf
Returns
0: Success, driver updates the default raw queue configuration data.<0: Error code returned by the driver info get function.
See also
rte_raw_queue_setup()
π« int rte_rawdev_queue_setup (uint16_t dev_id, uint16_t queue_id, rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
Allocate and set up a raw queue for a raw device. Building the queue from scratch, main character energy. π
Parameters
dev_idβ The identifier of the device.queue_idβ The index of the raw queue to setup. The value must be in the range[0, nb_raw_queues - 1]previously supplied torte_rawdev_configure().queue_confβ The pointer to the configuration data to be used for the raw queue.NULLvalue is allowed, in which case default configuration used.queue_conf_sizeβ The size of the structure pointed to byqueue_conf
See also
rte_rawdev_queue_conf_get()
Returns
0: Success, raw queue correctly set up.<0: raw queue configuration failed
π« int rte_rawdev_queue_release (uint16_t dev_id, uint16_t queue_id)
Release and deallocate a raw queue from a raw device. Say bye bye π to that queue, she's done.
Parameters
dev_idβ The identifier of the device.queue_idβ The index of the raw queue to release. The value must be in the range[0, nb_raw_queues - 1]previously supplied torte_rawdev_configure().
See also
rte_rawdev_queue_conf_get()
Returns
0: Success, raw queue released.<0: raw queue configuration failed
π« uint16_t rte_rawdev_queue_count (uint16_t dev_id)
Get the number of raw queues on a specific raw device. Count 'em up, bestie. π’
Parameters
dev_idβ Raw device identifier.
Returns
- The number of configured raw queues
π« int rte_rawdev_start (uint16_t dev_id)
Start a raw device. π
The device start step is the last one and consists of setting the raw queues to start accepting the raws and schedules to raw ports.
On success, all basic functions exported by the API (raw enqueue, raw dequeue and so on) can be invoked.
Parameters
dev_idβ Raw device identifier
Returns
0: Success, device started.< 0: Failure
π« void rte_rawdev_stop (uint16_t dev_id)
Stop a raw device. The device can be restarted with a call to rte_rawdev_start(). So it's not over, it's just a pause. π«Ά
Parameters
dev_idβ Raw device identifier.
π« int rte_rawdev_close (uint16_t dev_id)
Close a raw device. The device cannot be restarted after this call. π Like, this one is FINAL final. Don't do it unless you mean it.
Parameters
dev_idβ Raw device identifier
Returns
0on successfully closing device<0on failure to close device(-EAGAIN)if device is busy
π« int rte_rawdev_reset (uint16_t dev_id)
Reset a raw device. This is different from cycle of rte_rawdev_start->rte_rawdev_stop in the sense similar to hard or soft reset. So basically, it's not just stop-and-go, it's a whole vibe reset. π
Parameters
dev_idβ Raw device identifiers
Returns
0 for successful reset, !0 for failure in resetting
π« int rte_rawdev_dump (uint16_t dev_id, FILE * f)
Dump internal information about dev_id to the FILE* provided in f. Spill the tea, device, into this file. β
Parameters
dev_idβ The identifier of the device.fβ A pointer to a file for output
Returns
0: on success<0: on failure.
π« int rte_rawdev_get_attr (uint16_t dev_id, const char * attr_name, uint64_t * attr_value)
Get an attribute value from implementation. Attribute is an opaque handle agreed upon between application and PMD. π€
Implementations are expected to maintain an array of attribute-value pairs based on application calls. Memory management for this structure is shared responsibility of implementation and application.
Parameters
dev_idβ The identifier of the device to configure.attr_nameβ Opaque object representing an attribute in implementation.attr_valueβ[out]Opaque response to the attribute value. In case of error, this remains untouched. This is double pointer of void type.
okay that's part 1 bestie, don't go anywhere β there's more incoming π
okay bestie, we're picking up RIGHT where we left off β no recap, no nothing, just vibes and return values π
β¦and that last function we were talking about? its Returns go like this:
0for success,!0Error;attr_valueremains untouched in case of error.
rte_rawdev_set_attr π
int rte_rawdev_set_attr (uint16_t dev_id, const char * attr_name, const uint64_t attr_value)
Okay so this one sets an attribute value. The attribute itself is an opaque handle β meaning it's agreed upon between the application and the PMD, and nobody else gets to have opinions about it. iykyk. β¨
Parameters
dev_idβ the identifier of the device you wanna configure. π«Άattr_nameβ opaque object representing an attribute in the implementation.attr_valueβ the value of the attribute thatattr_nameis pointing at.
Returns
0for success,!0Error. no in-between, no maybe, periodt. π
rte_rawdev_enqueue_buffers π
int rte_rawdev_enqueue_buffers (uint16_t dev_id, struct rte_rawdev_buf ** buffers, unsigned int count, rte_rawdev_obj_t context)
Sends a whole stream of buffers into the device, slay.
And here's the lil twist: instead of specifying a queue like a normal API, this one just passes along an opaque object straight to the driver implementation. That object can be a queue, or literally any other contextual info the device needs to actually enqueue the buffers. main character energy fr fr. π
Parameters
dev_idβ the identifier of the device to configure.buffersβ collection of buffers for enqueuing. πcountβ count of buffers to enqueue.contextβ opaque context information.
Returns
>=0for buffers enqueued,!0for failure. Whether a partial enqueue counts as failure or success is defined between the app and the driver implementation β so like, that's a you-and-your-driver conversation, not a me conversation. π€
rte_rawdev_dequeue_buffers π¦
int rte_rawdev_dequeue_buffers (uint16_t dev_id, struct rte_rawdev_buf ** buffers, unsigned int count, rte_rawdev_obj_t context)
The reverse vibe: pulls a stream of buffers OUT of the device. π
Same deal as before β no queue specified, just an opaque object handed over to the driver implementation, which can be a queue or any other contextual info needed to dequeue buffers.
β οΈ Heads up bestie: the application should have allocated enough space to store count response buffers. And releasing the buffers you dequeued? That's on the application. No take-backs, no free cleanup, it's giving responsibility. π
Parameters
dev_idβ the identifier of the device to configure.buffersβ collection of buffers dequeued.countβ max buffers expected to be dequeued.contextβ opaque context information.
Returns
>=0for buffers dequeued,!0for failure. Whether partial enqueue is failure or success is defined between app and driver implementation.
rte_rawdev_xstats_names_get β¨
int rte_rawdev_xstats_names_get (uint16_t dev_id, struct rte_rawdev_xstats_name * xstats_names, unsigned int size)
Grabs the names of the extended statistics of a raw device. It's giving "tell me what you're measuring, king". π
Parameters
dev_idβ the identifier of the raw device.xstats_namesβ block of memory to insert names into. Must be at leastsizein capacity. If set toNULL, the function returns the required capacity instead. πsizeβ capacity ofxstats_names(number of names).
Returns
- positive value lower or equal to
size: success! π The return value is the number of entries filled in the stats table. - positive value higher than
size: error β the given statistics table is too small. The return value corresponds to the size that should be given to succeed. The entries in the table are not valid and shall not be used by the caller. do not touch. π - negative value on error:
-ENODEVfor invaliddev_id,-ENOTSUPif the device doesn't support this function.
rte_rawdev_xstats_get πΈ
int rte_rawdev_xstats_get (uint16_t dev_id, const unsigned int ids[], uint64_t values[], unsigned int n)
Retrieves the actual extended statistics of a raw device. numbers time, let's go. π₯
Parameters
dev_idβ the identifier of the device.idsβ the id numbers of the stats to get. You can get these ids from the stat position in the stat list fromrte_rawdev_get_xstats_names(), or by usingrte_rawdev_get_xstats_by_name().valuesβ the values for each stats request by ID.nβ the number of stats requested.
Returns
- positive value: number of stat entries filled into the
valuesarray. - negative value on error:
-ENODEVfor invaliddev_id,-ENOTSUPif the device doesn't support this function.
rte_rawdev_xstats_by_name_get π
uint64_t rte_rawdev_xstats_by_name_get (uint16_t dev_id, const char * name, unsigned int * id)
Retrieves the value of a single stat</b> by requesting it by name β iconic behavior, honestly.
Parameters
dev_idβ the identifier of the device.nameβ the stat name to retrieve.idβ if non-NULL, the numerical id of the stat will be returned, so that further requests for the stat can be got usingrte_rawdev_xstats_get, which will be faster because it doesn't need to scan a list of names for the stat. If the stat cannot be found, the id returned will be(unsigned)-1. π«
Returns
- positive value or zero: the stat value.
- negative value:
-EINVALif stat not found,-ENOTSUPif not supported.
rte_rawdev_xstats_reset π
int rte_rawdev_xstats_reset (uint16_t dev_id, const uint32_t ids[], uint32_t nb_ids)
Resets the values of the xstats of the selected component in the device. clean slate, fresh start, we love a reset arc. π
Parameters
dev_idβ the identifier of the device.idsβ selects specific statistics to be reset. WhenNULL, all statistics will be reset. If non-NULL, must point to an array of at leastnb_idssize.nb_idsβ the number of ids available from theidsarray. Ignored whenidsisNULL.
Returns
- zero: successfully reset the statistics to zero. π
- negative value:
-EINVALinvalid parameters,-ENOTSUPif not supported.
rte_rawdev_firmware_status_get π§
int rte_rawdev_firmware_status_get (uint16_t dev_id, rte_rawdev_obj_t status_info)
Gets the Firmware status of the device. Returns a memory allocated by the driver/implementation containing the status information block.
β οΈ bestie listen: it is the responsibility of the caller to release the buffer. yes, you. you release it. π
Parameters
dev_idβ raw device identifier.status_infoβ pointer to status information area. Caller is responsible for releasing the memory associated.
Returns
0for success,!0for failure, and thestatus_infoargument state is undefined. don't trust it, it's going through something. π
rte_rawdev_firmware_version_get β
int rte_rawdev_firmware_version_get (uint16_t dev_id, rte_rawdev_obj_t version_info)
Gets the Firmware version of the device. Same situation as above β returns memory allocated by the driver/implementation containing the version information block.
β οΈ again: it is responsibility of caller to release the buffer. same rules, bestie, we been knew. π
Parameters
dev_idβ raw device identifier.version_infoβ pointer to version information area. Caller is responsible for releasing the memory associated.
Returns
0for success,!0for failure, and theversion_infoargument state is undefined.
rte_rawdev_firmware_load π₯
int rte_rawdev_firmware_load (uint16_t dev_id, rte_rawdev_obj_t firmware_image)
Loads firmware onto the device. glow up incoming. β¨
π TODO note straight from the source: in future, methods like directly flashing from file too can be supported. so likeβ¦ not yet. manifesting. π
Parameters
dev_idβ raw device identifier.firmware_imageβ pointer to buffer containing image binary data.
Returns
0for successful load,!0for failure to load the provided image, or if the image is incorrect.
rte_rawdev_firmware_unload π«Ά
int rte_rawdev_firmware_unload (uint16_t dev_id)
Unloads firmware from the device. bye bye firmware, it was real. π
Parameters
dev_idβ raw device identifiers.
Returns
0for successful Unload,!0for failure in unloading. π
rte_rawdev_selftest π
int rte_rawdev_selftest (uint16_t dev_id)
Triggers the rawdev self test. let's see if you pass the vibe check, king. π
Parameters
dev_idβ the identifier of the device.
Returns
0: Selftest successful. π-ENOTSUPif the device doesn't support selftest.- other values
< 0on failure.
π AUTHOR π
Generated automatically by Doxygen for DPDK from the source code. (yes, a robot wrote this, and it ate, no cap π€π )
and that's a wrap on rte_rawdev.h(3) bestie!! π¦ this one came from DPDK, sitting at Version 25.11.3, and the page is literally called rte_rawdev.h(3). go forth and rawdev responsibly, mwah πβ¨
π¦ 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