---
name: "rte_rawdev_get_attr"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_rawdev.h"
---

# rte\_rawdev\_get\_attr(3)

Part of [rte\_rawdev.h(3)](/rte_rawdev.h/3.md).

## NAME

rte\_rawdev.h

## 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)\
 uint16\_t **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.

This API allow applications to configure and use generic devices having no specific type already available in DPDK.

Definition in file **rte\_rawdev.h**.

## Macro Definition Documentation

### #define RTE\_RAW\_DEV\_XSTATS\_NAME\_SIZE 64

Maximum name length for extended statistics counters

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.

**Returns**

The total number of usable raw devices.

### uint16\_t rte\_rawdev\_get\_dev\_id (const char \* name)

Get the device identifier for the named raw device.

**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.

**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.

**Parameters**

*dev\_id* The identifier of the device.\
 *dev\_info* A pointer to a structure of type *rte\_rawdev\_info* to be filled with the contextual information of the device. The dev\_info-\>dev\_private field should point to an appropriate buffer space for holding the device- specific info for that hardware. If the dev\_private field is set to NULL, 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 by dev\_private in dev\_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. 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 into rte\_rawdev\_info object. 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, a `queue_id` type 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 by dev\_private in dev\_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 to **rte\_rawdev\_configure()**. \
 *queue\_conf* The pointer to the default raw queue configuration data. \
 *queue\_conf\_size* The size of the structure pointed to by queue\_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.

**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 to **rte\_rawdev\_configure()**. \
 *queue\_conf* The pointer to the configuration data to be used for the raw queue. NULL value is allowed, in which case default configuration used. \
 *queue\_conf\_size* The size of the structure pointed to by queue\_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.

**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 to **rte\_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

**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()**

**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.

**Parameters**

*dev\_id* Raw device identifier

**Returns**

- •

  0 on successfully closing device

- •

  \<0 on 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.

**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*.

**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.

**Returns**

0 for success !0 Error; attr\_value remains untouched in case of error.

### int rte\_rawdev\_set\_attr (uint16\_t dev\_id, const char \* attr\_name, const uint64\_t attr\_value)

Set an attribute value. Attribute is an opaque handle agreed upon between application and PMD.

**Parameters**

*dev\_id* The identifier of the device to configure. \
 *attr\_name* Opaque object representing an attribute in implementation. \
 *attr\_value* Value of the attribute represented by attr\_name

**Returns**

0 for success !0 Error

### int rte\_rawdev\_enqueue\_buffers (uint16\_t dev\_id, struct rte\_rawdev\_buf \*\* buffers, unsigned int count, rte\_rawdev\_obj\_t context)

Enqueue a stream of buffers to the device.

Rather than specifying a queue, this API passes along an opaque object to the driver implementation. That object can be a queue or any other contextual information necessary for the device to enqueue buffers.

**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**

\>=0 for buffers enqueued !0 for failure. Whether partial enqueue is failure or success is defined between app and driver implementation.

### int rte\_rawdev\_dequeue\_buffers (uint16\_t dev\_id, struct rte\_rawdev\_buf \*\* buffers, unsigned int count, rte\_rawdev\_obj\_t context)

Dequeue a stream of buffers from the device.

Rather than specifying a queue, this API passes along an opaque object to the driver implementation. That object can be a queue or any other contextual information necessary for the device to dequeue buffers.

Application should have allocated enough space to store `count` response buffers. Releasing buffers dequeued is responsibility of the application.

**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**

\>=0 for buffers dequeued !0 for failure. Whether partial enqueue is failure or success is defined between app and driver implementation.

### int rte\_rawdev\_xstats\_names\_get (uint16\_t dev\_id, struct rte\_rawdev\_xstats\_name \* xstats\_names, unsigned int size)

Retrieve names of extended statistics of a raw device.

**Parameters**

*dev\_id* The identifier of the raw device. \
 *xstats\_names* Block of memory to insert names into. Must be at least size in capacity. If set to NULL, function returns required capacity. \
 *size* Capacity of xstats\_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.

- •

  negative value on error: -ENODEV for invalid *dev\_id* -ENOTSUP if the device doesn't support this function.

### int rte\_rawdev\_xstats\_get (uint16\_t dev\_id, const unsigned int ids\[\], uint64\_t values\[\], unsigned int n)

Retrieve extended statistics of a raw device.

**Parameters**

*dev\_id* The identifier of the device. \
 *ids* The id numbers of the stats to get. The ids can be got from the stat position in the stat list from rte\_rawdev\_get\_xstats\_names(), or by using rte\_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 values array

- •

  negative value on error: -ENODEV for invalid *dev\_id* -ENOTSUP if the device doesn't support this function.

### uint64\_t rte\_rawdev\_xstats\_by\_name\_get (uint16\_t dev\_id, const char \* name, unsigned int \* id)

Retrieve the value of a single stat by requesting it by name.

**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 using rte\_rawdev\_xstats\_get, which will be faster as 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: -EINVAL if stat not found, -ENOTSUP if not supported.

### int rte\_rawdev\_xstats\_reset (uint16\_t dev\_id, const uint32\_t ids\[\], uint32\_t nb\_ids)

Reset the values of the xstats of the selected component in the device.

**Parameters**

*dev\_id* The identifier of the device \
 *ids* Selects specific statistics to be reset. When NULL, all statistics will be reset. If non-NULL, must point to array of at least *nb\_ids* size. \
 *nb\_ids* The number of ids available from the *ids* array. Ignored when ids is NULL.

**Returns**

- •

  zero: successfully reset the statistics to zero

- •

  negative value: -EINVAL invalid parameters, -ENOTSUP if not supported.

### int rte\_rawdev\_firmware\_status\_get (uint16\_t dev\_id, rte\_rawdev\_obj\_t status\_info)

Get Firmware status of the device.. Returns a memory allocated by driver/implementation containing status information block. It is responsibility of caller to release the buffer.

**Parameters**

*dev\_id* Raw device identifier \
 *status\_info* Pointer to status information area. Caller is responsible for releasing the memory associated.

**Returns**

0 for success, !0 for failure, `status_info` argument state is undefined

### int rte\_rawdev\_firmware\_version\_get (uint16\_t dev\_id, rte\_rawdev\_obj\_t version\_info)

Get Firmware version of the device. Returns a memory allocated by driver/implementation containing version information block. It is responsibility of caller to release the buffer.

**Parameters**

*dev\_id* Raw device identifier \
 *version\_info* Pointer to version information area. Caller is responsible for releasing the memory associated.

**Returns**

0 for success, !0 for failure, `version_info` argument state is undefined

### int rte\_rawdev\_firmware\_load (uint16\_t dev\_id, rte\_rawdev\_obj\_t firmware\_image)

Load firmware on the device. TODO: In future, methods like directly flashing from file too can be supported.

**Parameters**

*dev\_id* Raw device identifier \
 *firmware\_image* Pointer to buffer containing image binary data

**Returns**

0 for successful load !0 for failure to load the provided image, or image incorrect.

### int rte\_rawdev\_firmware\_unload (uint16\_t dev\_id)

Unload firmware from the device.

**Parameters**

*dev\_id* Raw device identifiers

**Returns**

0 for successful Unload !0 for failure in unloading

### int rte\_rawdev\_selftest (uint16\_t dev\_id)

Trigger the rawdev self test.

**Parameters**

*dev\_id* The identifier of the device

**Returns**

- •

  0: Selftest successful

- •

  \-ENOTSUP if the device doesn't support selftest

- •

  other values \< 0 on failure.

## Author

Generated automatically by Doxygen for DPDK from the source code.
