DPDK  19.11.14
Data Structures | Typedefs | Functions
rte_rawdev_pmd.h File Reference
#include <string.h>
#include <rte_dev.h>
#include <rte_malloc.h>
#include <rte_log.h>
#include <rte_common.h>
#include "rte_rawdev.h"

Go to the source code of this file.

Data Structures

struct  rte_rawdev_ops
 

Typedefs

typedef void(* rawdev_info_get_t) (struct rte_rawdev *dev, rte_rawdev_obj_t dev_info)
 
typedef int(* rawdev_configure_t) (const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 
typedef int(* rawdev_start_t) (struct rte_rawdev *dev)
 
typedef void(* rawdev_stop_t) (struct rte_rawdev *dev)
 
typedef int(* rawdev_close_t) (struct rte_rawdev *dev)
 
typedef int(* rawdev_reset_t) (struct rte_rawdev *dev)
 
typedef void(* rawdev_queue_conf_get_t) (struct rte_rawdev *dev, uint16_t queue_id, rte_rawdev_obj_t queue_conf)
 
typedef int(* rawdev_queue_setup_t) (struct rte_rawdev *dev, uint16_t queue_id, rte_rawdev_obj_t queue_conf)
 
typedef int(* rawdev_queue_release_t) (struct rte_rawdev *dev, uint16_t queue_id)
 
typedef uint16_t(* rawdev_queue_count_t) (struct rte_rawdev *dev)
 
typedef int(* rawdev_enqueue_bufs_t) (struct rte_rawdev *dev, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)
 
typedef int(* rawdev_dequeue_bufs_t) (struct rte_rawdev *dev, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)
 
typedef int(* rawdev_dump_t) (struct rte_rawdev *dev, FILE *f)
 
typedef int(* rawdev_get_attr_t) (struct rte_rawdev *dev, const char *attr_name, uint64_t *attr_value)
 
typedef int(* rawdev_set_attr_t) (struct rte_rawdev *dev, const char *attr_name, const uint64_t attr_value)
 
typedef int(* rawdev_xstats_get_t) (const struct rte_rawdev *dev, const unsigned int ids[], uint64_t values[], unsigned int n)
 
typedef int(* rawdev_xstats_reset_t) (struct rte_rawdev *dev, const uint32_t ids[], uint32_t nb_ids)
 
typedef int(* rawdev_xstats_get_names_t) (const struct rte_rawdev *dev, struct rte_rawdev_xstats_name *xstats_names, unsigned int size)
 
typedef uint64_t(* rawdev_xstats_get_by_name_t) (const struct rte_rawdev *dev, const char *name, unsigned int *id)
 
typedef int(* rawdev_firmware_status_get_t) (struct rte_rawdev *dev, rte_rawdev_obj_t status_info)
 
typedef int(* rawdev_firmware_version_get_t) (struct rte_rawdev *dev, rte_rawdev_obj_t version_info)
 
typedef int(* rawdev_firmware_load_t) (struct rte_rawdev *dev, rte_rawdev_obj_t firmware_buf)
 
typedef int(* rawdev_firmware_unload_t) (struct rte_rawdev *dev)
 
typedef int(* rawdev_selftest_t) (uint16_t dev_id)
 

Functions

static struct rte_rawdev * rte_rawdev_pmd_get_named_dev (const char *name)
 
static unsigned rte_rawdev_pmd_is_valid_dev (uint8_t dev_id)
 
struct rte_rawdev * rte_rawdev_pmd_allocate (const char *name, size_t dev_private_size, int socket_id)
 
int rte_rawdev_pmd_release (struct rte_rawdev *rawdev)
 
struct rte_rawdev * rte_rawdev_pmd_init (const char *name, size_t dev_private_size, int socket_id)
 
int rte_rawdev_pmd_uninit (const char *name)
 

Detailed Description

RTE RAW PMD APIs

Note
Driver facing APIs for a raw device. These are not to be called directly by any application.

Definition in file rte_rawdev_pmd.h.

Typedef Documentation

◆ rawdev_info_get_t

typedef void(* rawdev_info_get_t) (struct rte_rawdev *dev, rte_rawdev_obj_t dev_info)

Definitions of all functions exported by a driver through the generic structure of type rawdev_ops supplied in the rte_rawdev structure associated with a device. Get device information of a device.

Parameters
devRaw device pointer
dev_infoRaw device information structure
Returns
Returns 0 on success

Definition at line 145 of file rte_rawdev_pmd.h.

◆ rawdev_configure_t

typedef int(* rawdev_configure_t) (const struct rte_rawdev *dev, rte_rawdev_obj_t config)

Configure a device.

Parameters
devRaw device pointer
configVoid object containing device specific configuration
Returns
Returns 0 on success

Definition at line 159 of file rte_rawdev_pmd.h.

◆ rawdev_start_t

typedef int(* rawdev_start_t) (struct rte_rawdev *dev)

Start a configured device.

Parameters
devRaw device pointer
Returns
Returns 0 on success

Definition at line 171 of file rte_rawdev_pmd.h.

◆ rawdev_stop_t

typedef void(* rawdev_stop_t) (struct rte_rawdev *dev)

Stop a configured device.

Parameters
devRaw device pointer

Definition at line 179 of file rte_rawdev_pmd.h.

◆ rawdev_close_t

typedef int(* rawdev_close_t) (struct rte_rawdev *dev)

Close a configured device.

Parameters
devRaw device pointer
Returns
  • 0 on success
  • (-EAGAIN) if can't close as device is busy

Definition at line 191 of file rte_rawdev_pmd.h.

◆ rawdev_reset_t

typedef int(* rawdev_reset_t) (struct rte_rawdev *dev)

Reset a configured device.

Parameters
devRaw device pointer
Returns
0 for success !0 for failure

Definition at line 202 of file rte_rawdev_pmd.h.

◆ rawdev_queue_conf_get_t

typedef void(* rawdev_queue_conf_get_t) (struct rte_rawdev *dev, uint16_t queue_id, rte_rawdev_obj_t queue_conf)

Retrieve the current raw queue configuration.

Parameters
devRaw device pointer
queue_idRaw device queue index
[out]queue_confRaw device queue configuration structure

Definition at line 215 of file rte_rawdev_pmd.h.

◆ rawdev_queue_setup_t

typedef int(* rawdev_queue_setup_t) (struct rte_rawdev *dev, uint16_t queue_id, rte_rawdev_obj_t queue_conf)

Setup an raw queue.

Parameters
devRaw device pointer
queue_idRawqueue index
queue_confRawqueue configuration structure
Returns
Returns 0 on success.

Definition at line 232 of file rte_rawdev_pmd.h.

◆ rawdev_queue_release_t

typedef int(* rawdev_queue_release_t) (struct rte_rawdev *dev, uint16_t queue_id)

Release resources allocated by given raw queue.

Parameters
devRaw device pointer
queue_idRaw queue index

Definition at line 245 of file rte_rawdev_pmd.h.

◆ rawdev_queue_count_t

typedef uint16_t(* rawdev_queue_count_t) (struct rte_rawdev *dev)

Get the count of number of queues configured on this device.

Another way to fetch this information is to fetch the device configuration. But, that assumes that the device configuration managed by the driver has that kind of information.

This function helps in getting queue count supported, independently. It can help in cases where iterator needs to be implemented.

Parameters
Rawdevice pointer
Returns
Number of queues; 0 is assumed to be a valid response.

Definition at line 264 of file rte_rawdev_pmd.h.

◆ rawdev_enqueue_bufs_t

typedef int(* rawdev_enqueue_bufs_t) (struct rte_rawdev *dev, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)

Enqueue an array of raw buffers to the device.

Buffer being used is opaque - it can be obtained from mempool or from any other source. Interpretation of buffer is responsibility of driver.

Parameters
devRaw device pointer
bufsarray of buffers
countnumber of buffers passed
contextan opaque object representing context of the call; for example, an application can pass information about the queues on which enqueue needs to be done. Or, the enqueue operation might be passed reference to an object containing a callback (agreed upon between application and driver).
Returns
>=0 Count of buffers successfully enqueued (0: no buffers enqueued) <0 Error count in case of error

Definition at line 288 of file rte_rawdev_pmd.h.

◆ rawdev_dequeue_bufs_t

typedef int(* rawdev_dequeue_bufs_t) (struct rte_rawdev *dev, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)

Dequeue an array of raw buffers from the device.

Parameters
devRaw device pointer
bufsarray of buffers
countMax buffers expected to be dequeued
contextan opaque object representing context of the call. Based on this object, the application and driver can coordinate for dequeue operation involving agreed upon semantics. For example, queue information/id on which Dequeue needs to be performed.
Returns
>0, ~0: Count of buffers returned <0: Error Whether short dequeue is success or failure is decided between app and driver.

Definition at line 313 of file rte_rawdev_pmd.h.

◆ rawdev_dump_t

typedef int(* rawdev_dump_t) (struct rte_rawdev *dev, FILE *f)

Dump internal information

Parameters
devRaw device pointer
fA pointer to a file for output
Returns
0 for success, !0 Error

Definition at line 330 of file rte_rawdev_pmd.h.

◆ rawdev_get_attr_t

typedef int(* rawdev_get_attr_t) (struct rte_rawdev *dev, 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.

Parameters
devRaw device pointer
attr_nameOpaque 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.

Definition at line 347 of file rte_rawdev_pmd.h.

◆ rawdev_set_attr_t

typedef int(* rawdev_set_attr_t) (struct rte_rawdev *dev, 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
devRaw device pointer
attr_nameOpaque object representing an attribute in implementation.
attr_valueValue of the attribute represented by attr_name
Returns
0 for success !0 Error

Definition at line 365 of file rte_rawdev_pmd.h.

◆ rawdev_xstats_get_t

typedef int(* rawdev_xstats_get_t) (const struct rte_rawdev *dev, const unsigned int ids[], uint64_t values[], unsigned int n)

Retrieve a set of statistics from device. Note: Being a raw device, the stats are specific to the device being implemented thus represented as xstats.

Parameters
devRaw device pointer
idsThe stat ids to retrieve
valuesThe returned stat values
nThe number of id values and entries in the values array
Returns
The number of stat values successfully filled into the values array

Definition at line 385 of file rte_rawdev_pmd.h.

◆ rawdev_xstats_reset_t

typedef int(* rawdev_xstats_reset_t) (struct rte_rawdev *dev, const uint32_t ids[], uint32_t nb_ids)

Resets the statistic values in xstats for the device.

Definition at line 391 of file rte_rawdev_pmd.h.

◆ rawdev_xstats_get_names_t

typedef int(* rawdev_xstats_get_names_t) (const struct rte_rawdev *dev, struct rte_rawdev_xstats_name *xstats_names, unsigned int size)

Get names of extended stats of an raw device

Parameters
devRaw device pointer
xstats_namesArray of name values to be filled in
sizeNumber of values in the xstats_names array
Returns
When size >= the number of stats, return the number of stat values filled into the array. When size < the number of available stats, return the number of stats values, and do not fill in any data into xstats_names.

Definition at line 410 of file rte_rawdev_pmd.h.

◆ rawdev_xstats_get_by_name_t

typedef uint64_t(* rawdev_xstats_get_by_name_t) (const struct rte_rawdev *dev, const char *name, unsigned int *id)

Get value of one stats and optionally return its id

Parameters
devRaw device pointer
nameThe name of the stat to retrieve
idPointer to an unsigned int where we store the stat-id. This pointer may be null if the id is not required.
Returns
The value of the stat, or (uint64_t)-1 if the stat is not found. If the stat is not found, the id value will be returned as (unsigned)-1, if id pointer is non-NULL

Definition at line 429 of file rte_rawdev_pmd.h.

◆ rawdev_firmware_status_get_t

typedef int(* rawdev_firmware_status_get_t) (struct rte_rawdev *dev, rte_rawdev_obj_t status_info)

Get firmware/device-stack status. Implementation to allocate buffer for returning information.

Parameters
devRaw device pointer
statusvoid block containing device specific status information
Returns
0 for success, !0 for failure, with undefined value in status_info

Definition at line 445 of file rte_rawdev_pmd.h.

◆ rawdev_firmware_version_get_t

typedef int(* rawdev_firmware_version_get_t) (struct rte_rawdev *dev, rte_rawdev_obj_t version_info)

Get firmware version information

Parameters
devRaw device pointer
version_infovoid pointer to version information returned by device
Returns
0 for success, !0 for failure, with undefined value in version_info

Definition at line 459 of file rte_rawdev_pmd.h.

◆ rawdev_firmware_load_t

typedef int(* rawdev_firmware_load_t) (struct rte_rawdev *dev, rte_rawdev_obj_t firmware_buf)

Load firmware from a buffer (DMA'able)

Parameters
devRaw device pointer
firmware_filefile pointer to firmware area
Returns
>0, ~0: for successful load <0: for failure
See also
Application may use 'firmware_version_get` for ascertaining successful load

Definition at line 476 of file rte_rawdev_pmd.h.

◆ rawdev_firmware_unload_t

typedef int(* rawdev_firmware_unload_t) (struct rte_rawdev *dev)

Unload firmware

Parameters
devRaw device pointer
Returns
>0, ~0 for successful unloading <0 for failure in unloading

Note: Application can use the firmware_status_get or firmware_version_get to get result of unload.

Definition at line 491 of file rte_rawdev_pmd.h.

◆ rawdev_selftest_t

typedef int(* rawdev_selftest_t) (uint16_t dev_id)

Start rawdev selftest

Returns
Return 0 on success

Definition at line 499 of file rte_rawdev_pmd.h.

Function Documentation

◆ rte_rawdev_pmd_get_named_dev()

static struct rte_rawdev* rte_rawdev_pmd_get_named_dev ( const char *  name)
static

The pool of rte_rawdev structures. Get the rte_rawdev structure device pointer for the named device.

Parameters
namedevice name to select the device structure.
Returns
  • The rte_rawdev structure pointer for the given device ID.

Definition at line 86 of file rte_rawdev_pmd.h.

◆ rte_rawdev_pmd_is_valid_dev()

static unsigned rte_rawdev_pmd_is_valid_dev ( uint8_t  dev_id)
inlinestatic

Validate if the raw device index is a valid attached raw device.

Parameters
dev_idraw device index.
Returns
  • If the device index is valid (1) or not (0).

Definition at line 114 of file rte_rawdev_pmd.h.

◆ rte_rawdev_pmd_allocate()

struct rte_rawdev* rte_rawdev_pmd_allocate ( const char *  name,
size_t  dev_private_size,
int  socket_id 
)

Allocates a new rawdev slot for an raw device and returns the pointer to that slot for the driver to use.

Parameters
nameUnique identifier name for each device
dev_private_sizeSize of private data memory allocated within rte_rawdev object. Set to 0 to disable internal memory allocation and allow for self-allocation.
socket_idSocket to allocate resources on.
Returns
  • Slot in the rte_dev_devices array for a new device;

◆ rte_rawdev_pmd_release()

int rte_rawdev_pmd_release ( struct rte_rawdev *  rawdev)

Release the specified rawdev device.

Parameters
rawdevThe rawdev pointer is the address of the rte_rawdev structure.
Returns
  • 0 on success, negative on error

◆ rte_rawdev_pmd_init()

struct rte_rawdev* rte_rawdev_pmd_init ( const char *  name,
size_t  dev_private_size,
int  socket_id 
)

Creates a new raw device and returns the pointer to that device.

Parameters
namePointer to a character array containing name of the device
dev_private_sizeSize of raw PMDs private data
socket_idSocket to allocate resources on.
Returns
  • Raw device pointer if device is successfully created.
  • NULL if device cannot be created.

◆ rte_rawdev_pmd_uninit()

int rte_rawdev_pmd_uninit ( const char *  name)

Destroy a raw device

Parameters
nameName of the device
Returns
  • 0 on success, negative on error