|
CNDP 22.08.0
|
#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <cne_common.h>#include <cne_lport.h>#include <netdev_funcs.h>#include <pktmbuf.h>Go to the source code of this file.
Macros | |
| #define | PKTDEV_STARTED (1 << 1) |
| #define | pktdev_admin_state_up(_pid) |
Typedefs | |
| typedef uint16_t(*) | cne_rx_callback_fn(uint16_t lport_id, pktmbuf_t *pkts[], uint16_t nb_pkts, uint16_t max_pkts, void *user_param) |
| typedef uint16_t(*) | cne_tx_callback_fn(uint16_t lport_id, pktmbuf_t *pkts[], uint16_t nb_pkts, void *user_param) |
Functions | |
| CNDP_API uint16_t | pktdev_port_count (void) |
| CNDP_API int | pktdev_start (uint16_t lport_id) |
| CNDP_API int | pktdev_stop (uint16_t lport_id) |
| CNDP_API int | pktdev_set_admin_state_up (uint16_t lport_id) |
| CNDP_API int | pktdev_set_admin_state_down (uint16_t lport_id) |
| CNDP_API int | pktdev_close (uint16_t lport_id) |
| CNDP_API int | pktdev_close_all (void) |
| CNDP_API int | pktdev_stats_get (uint16_t lport_id, lport_stats_t *stats) |
| CNDP_API int | pktdev_stats_reset (uint16_t lport_id) |
| CNDP_API int | pktdev_macaddr_get (uint16_t lport_id, struct ether_addr *mac_addr) |
| CNDP_API int | pktdev_offloads_get (uint16_t lport_id, struct offloads *off) |
| CNDP_API int | pktdev_info_get (uint16_t lport_id, struct pktdev_info *dev_info) |
| CNDP_API int | pktdev_get_mtu (uint16_t lport_id, uint16_t *mtu) |
| CNDP_API int | pktdev_set_mtu (uint16_t lport_id, uint16_t mtu) |
| CNDP_API int | pktdev_get_name_by_port (uint16_t lport_id, char *name, uint32_t len) |
| CNDP_API int | pktdev_get_port_by_name (const char *name, uint16_t *lport_id) |
| CNDP_API const char * | pktdev_port_name (uint16_t lport_id) |
| CNDP_API int | pktdev_is_valid_port (uint16_t lport_id) |
| CNDP_API int | pktdev_socket_id (uint16_t lport_id) |
| CNDP_API struct cne_pktdev * | pktdev_get (uint16_t lport_id) |
| CNDP_API int | pktdev_portid (struct cne_pktdev *dev) |
| CNDP_API int | pktdev_port_setup (lport_cfg_t *c) |
| CNDP_API void | lport_cfg_dump (FILE *f, lport_cfg_t *c) |
| CNDP_API bool | pktdev_admin_state (uint16_t lport_id) |
| CNDP_API int | pktdev_admin_state_set (uint16_t lport_id, bool state) |
| CNDP_API void * | pktdev_arg_get (uint16_t lport_id) |
| CNDP_API int | pktdev_buf_alloc (int lport_id, pktmbuf_t **bufs, uint16_t nb_bufs) |
pktdev structures and APIs.
Definition in file pktdev_api.h.
| #define PKTDEV_STARTED (1 << 1) |
Device state: STARTED(1) / STOPPED(0).
Definition at line 52 of file pktdev_api.h.
| #define pktdev_admin_state_up | ( | _pid | ) |
Macros to enable/disable admin state of a port.
Definition at line 431 of file pktdev_api.h.
| typedef uint16_t(*) cne_rx_callback_fn(uint16_t lport_id, pktmbuf_t *pkts[], uint16_t nb_pkts, uint16_t max_pkts, void *user_param) |
Function type used for RX packet processing packet callbacks.
The callback function is called on RX with a burst of packets that have been received on the given lport and queue.
| lport_id | The Ethernet lport on which RX is being performed. |
| pkts | The burst of packets that have just been received. |
| nb_pkts | The number of packets in the burst pointed to by "pkts". |
| max_pkts | The max number of packets that can be stored in the "pkts" array. |
| user_param | The arbitrary user parameter passed in by the application when the callback was originally configured. |
Definition at line 74 of file pktdev_api.h.
| typedef uint16_t(*) cne_tx_callback_fn(uint16_t lport_id, pktmbuf_t *pkts[], uint16_t nb_pkts, void *user_param) |
Function type used for TX packet processing packet callbacks.
The callback function is called on TX with a burst of packets immediately before the packets are put onto the hardware queue for transmission.
| lport_id | The Ethernet lport on which TX is being performed. |
| pkts | The burst of packets that are about to be transmitted. |
| nb_pkts | The number of packets in the burst pointed to by "pkts". |
| user_param | The arbitrary user parameter passed in by the application when the callback was originally configured. |
Definition at line 95 of file pktdev_api.h.
| CNDP_API uint16_t pktdev_port_count | ( | void | ) |
Get the number of lports which are usable for the application.
| CNDP_API int pktdev_start | ( | uint16_t | lport_id | ) |
Start an Ethernet device.
The device start step is the last one and consists of setting the configured offload features and in starting the transmit and the receive units of the device.
On success, all basic functions exported by the Ethernet API (link status, receive/transmit, and so on) can be invoked.
| lport_id | The lport identifier of the Ethernet device. |
| CNDP_API int pktdev_stop | ( | uint16_t | lport_id | ) |
Stop an Ethernet device. The device can be restarted with a call to pktdev_start()
| lport_id | The lport identifier of the Ethernet device. |
| CNDP_API int pktdev_set_admin_state_up | ( | uint16_t | lport_id | ) |
Set admin state to UP
Set admin state up will re-enable the stream functionality after it is previously set down.
| lport_id | The lport identifier of the Ethernet device. |
| CNDP_API int pktdev_set_admin_state_down | ( | uint16_t | lport_id | ) |
Set admin state to DOWN
The stream functionality will be disabled if success, and it can be re-enabled with a call to pktdev_set_admin_state_up()
| lport_id | The lport identifier of the Ethernet device. |
| CNDP_API int pktdev_close | ( | uint16_t | lport_id | ) |
Close a stopped Ethernet device. The device cannot be restarted!
The function frees all lport resources if the driver supports the flag PKTDEV_DEV_CLOSE_REMOVE.
| lport_id | The lport identifier of the Ethernet device. |
| CNDP_API int pktdev_close_all | ( | void | ) |
Close all devices
| CNDP_API int pktdev_stats_get | ( | uint16_t | lport_id, |
| lport_stats_t * | stats ) |
Retrieve the general I/O statistics of an Ethernet device.
| lport_id | The lport identifier of the Ethernet device. |
| stats | A pointer to a structure of type lport_stats to be filled with the values of device counters for the following set of statistics:
|
| CNDP_API int pktdev_stats_reset | ( | uint16_t | lport_id | ) |
Reset the general I/O statistics of an Ethernet device.
| lport_id | The lport identifier of the Ethernet device. |
| CNDP_API int pktdev_macaddr_get | ( | uint16_t | lport_id, |
| struct ether_addr * | mac_addr ) |
Retrieve the Ethernet address of an Ethernet device.
| lport_id | The lport identifier of the Ethernet device. |
| mac_addr | A pointer to a structure of type ether_addr to be filled with the Ethernet address of the Ethernet device. |
| CNDP_API int pktdev_offloads_get | ( | uint16_t | lport_id, |
| struct offloads * | off ) |
Retrieve the offloads configuration of a netdevice.
| lport_id | The lport identifier of the Ethernet device. |
| off | A pointer to a structure of type struct offloads to be filled with the offloads configuration of the netdevice |
| CNDP_API int pktdev_info_get | ( | uint16_t | lport_id, |
| struct pktdev_info * | dev_info ) |
Retrieve the contextual information of an Ethernet device.
As part of this function, a number of of fields in dev_info will be initialized as follows:
device = dev->device min_mtu = CNE_ETHER_MIN_MTU max_mtu = UINT16_MAX
The following fields will be populated if support for dev_infos_get() exists for the device and the cne_pktdev 'dev' has been populated successfully with a call to it:
driver_name = dev->device->driver->name nb_rx_queues = dev->data->nb_rx_queues nb_tx_queues = dev->data->nb_tx_queues
| lport_id | The lport identifier of the Ethernet device. |
| dev_info | A pointer to a structure of type pktdev_info to be filled with the contextual information of the Ethernet device. |
| CNDP_API int pktdev_get_mtu | ( | uint16_t | lport_id, |
| uint16_t * | mtu ) |
Retrieve the MTU of an Ethernet device.
| lport_id | The lport identifier of the Ethernet device. |
| mtu | A pointer to a uint16_t where the retrieved MTU is to be stored. |
| CNDP_API int pktdev_set_mtu | ( | uint16_t | lport_id, |
| uint16_t | mtu ) |
Change the MTU of an Ethernet device.
| lport_id | The lport identifier of the Ethernet device. |
| mtu | A uint16_t for the MTU to be applied. |
| CNDP_API int pktdev_get_name_by_port | ( | uint16_t | lport_id, |
| char * | name, | ||
| uint32_t | len ) |
Get the lport name by lport id
| lport_id | The lport id or index into the pktdev_devices array |
| name | Pointer to a string array to put the name, will be null terminated. |
| len | Length of the name buffer pointer |
| CNDP_API int pktdev_get_port_by_name | ( | const char * | name, |
| uint16_t * | lport_id ) |
Get lport id by name of lport
| name | Pointer to lport name string |
| lport_id | Pointer to uint16_t value to return lport id |
| CNDP_API const char * pktdev_port_name | ( | uint16_t | lport_id | ) |
Return constructed lport name from lport id
| lport_id | The lport id to create lport name |
| CNDP_API int pktdev_is_valid_port | ( | uint16_t | lport_id | ) |
Test if lport is a valid lport id
| lport_id | The lport id to test |
| CNDP_API int pktdev_socket_id | ( | uint16_t | lport_id | ) |
return socket id of the lport
| lport_id | The lport to access for socket id |
| CNDP_API struct cne_pktdev * pktdev_get | ( | uint16_t | lport_id | ) |
Return the pktdev_devices[lport_id] pointer
| lport_id | The lport id to use to locate cne_pktdev structure |
| CNDP_API int pktdev_portid | ( | struct cne_pktdev * | dev | ) |
Returns the pktdev lportid index
| dev | Pointer to a valid pktdev_devices structure. |
| CNDP_API int pktdev_port_setup | ( | lport_cfg_t * | c | ) |
Port setup helper routine to simplify bring up a lport using the defaults
| c | The structure to use for setting up the lport. See the structure and driver docs to see how this structure is used. |
| CNDP_API void lport_cfg_dump | ( | FILE * | f, |
| lport_cfg_t * | c ) |
Dump out a lport_cfg_t structure.
| f | The FILE descriptor to use or NULL for stdout. |
| c | The lport_cfg_t pointer |
| CNDP_API bool pktdev_admin_state | ( | uint16_t | lport_id | ) |
Get the packet stream state flag for the given lport.
| lport_id | The lport id to use to locate cne_pktdev structure |
| CNDP_API int pktdev_admin_state_set | ( | uint16_t | lport_id, |
| bool | state ) |
Set the packet stream state flag for the given lport.
| lport_id | The lport id to use to locate cne_pktdev structure |
| state | Packet stream state flag |
| CNDP_API void * pktdev_arg_get | ( | uint16_t | lport_id | ) |
Get the argument value for alloc/free routines.
| lport_id | The lport ID value. |
| CNDP_API int pktdev_buf_alloc | ( | int | lport_id, |
| pktmbuf_t ** | bufs, | ||
| uint16_t | nb_bufs ) |
Allocate a set of buffers using the user supplied allocate/free routines
| lport_id | The lport ID value |
| bufs | The array of buffer pointers to be allocated. |
| nb_bufs | The number of buffers to be allocated |