API Reference Manual  1.45.0
ODP PACKET IO

API Description

Packet IO interfaces.

Packet IO is the Ingress and Egress interface to ODP processing. It allows manipulation of the interface for setting such attributes as number of queues, MAC address etc. Pktio is usually followed by the classifier and a default class COS can be set so that the scheduler may distribute flows. The interface may be used directly in polled mode with odp_pktin_recv() and odp_pktout_send(). Diagnostic messages can be enhanced by using odp_pktio_to_u64 which will generate a printable reference for a pktio handle for use with the logging.

Data Structures

struct  odp_pktin_queue_t
 
struct  odp_pktout_queue_t
 
struct  odp_pktio_stats_t
 Packet IO statistics counters. More...
 
struct  odp_pktin_queue_stats_t
 Packet IO input queue specific statistics counters. More...
 
struct  odp_pktout_queue_stats_t
 Packet IO output queue specific statistics counters. More...
 
struct  odp_pktio_stats_capability_t
 Packet IO statistics capabilities. More...
 
struct  odp_pktio_extra_stat_info_t
 Packet IO extra statistics counter information. More...
 
union  odp_pktin_hash_proto_t
 Packet input hash protocols. More...
 
struct  odp_pktin_queue_param_ovr_t
 Packet input queue parameters override. More...
 
struct  odp_pktin_vector_config_t
 Packet input vector configuration. More...
 
struct  odp_pktin_queue_param_t
 Packet input queue parameters. More...
 
struct  odp_pktout_queue_param_t
 Packet output queue parameters. More...
 
struct  odp_pktio_param_t
 Packet IO parameters. More...
 
union  odp_pktin_config_opt_t
 Packet input configuration options bit field. More...
 
union  odp_pktout_config_opt_t
 Packet output configuration options bit field. More...
 
struct  odp_pktio_parser_config_t
 Parser configuration. More...
 
struct  odp_pktio_config_t
 Packet IO configuration options. More...
 
union  odp_pktio_set_op_t
 Packet IO set operations. More...
 
struct  odp_lso_capability_t
 Large Send Offload (LSO) capabilities. More...
 
struct  odp_pktin_vector_capability_t
 Packet input vector capabilities. More...
 
struct  odp_pktio_capability_t
 Packet IO capabilities. More...
 
struct  odp_lso_profile_param_t
 LSO profile parameters. More...
 
struct  odp_pktio_info_t
 Packet IO information. More...
 
struct  odp_pktio_link_info_t
 Packet IO link information. More...
 

Macros

#define ODP_PKTIO_INVALID   ((odp_pktio_t)0)
 Invalid packet IO handle.
 
#define ODP_LSO_PROFILE_INVALID   ((odp_lso_profile_t)0)
 Invalid LSO profile handle.
 
#define ODP_PKTIO_MAX_INDEX   63
 Maximum packet IO interface index. More...
 
#define ODP_PKTIO_MACADDR_MAXSIZE   16
 Minimum size of output buffer for odp_pktio_mac_addr() Actual MAC address sizes may be different.
 
#define ODP_PKTIN_NO_WAIT   0
 Do not wait on packet input.
 
#define ODP_PKTIN_MAX_QUEUES   64
 Maximum number of packet input queues supported by the API. More...
 
#define ODP_PKTOUT_MAX_QUEUES   64
 Maximum number of packet output queues supported by the API. More...
 
#define ODP_PKTIO_STATS_EXTRA_NAME_LEN   64
 Maximum packet IO extra statistics counter name length, including the null character.
 
#define ODP_LSO_MAX_CUSTOM   8
 Maximum number of custom LSO fields supported by ODP API.
 

Typedefs

typedef _odp_abi_pktio_todp_pktio_t
 Packet IO handle.
 
typedef _odp_abi_lso_profile_todp_lso_profile_t
 LSO profile handle.
 
typedef struct odp_pktin_queue_t odp_pktin_queue_t
 Direct packet input queue handle. More...
 
typedef struct odp_pktout_queue_t odp_pktout_queue_t
 Direct packet output queue handle. More...
 
typedef struct odp_pktio_stats_t odp_pktio_stats_t
 Packet IO statistics counters. More...
 
typedef struct odp_pktin_queue_stats_t odp_pktin_queue_stats_t
 Packet IO input queue specific statistics counters. More...
 
typedef struct odp_pktout_queue_stats_t odp_pktout_queue_stats_t
 Packet IO output queue specific statistics counters. More...
 
typedef struct odp_pktio_stats_capability_t odp_pktio_stats_capability_t
 Packet IO statistics capabilities.
 
typedef struct odp_pktio_extra_stat_info_t odp_pktio_extra_stat_info_t
 Packet IO extra statistics counter information.
 
typedef enum odp_pktin_mode_t odp_pktin_mode_t
 Packet input mode.
 
typedef enum odp_pktout_mode_t odp_pktout_mode_t
 Packet output mode.
 
typedef union odp_pktin_hash_proto_t odp_pktin_hash_proto_t
 Packet input hash protocols. More...
 
typedef enum odp_pktio_op_mode_t odp_pktio_op_mode_t
 Packet IO operation mode.
 
typedef struct odp_pktin_queue_param_ovr_t odp_pktin_queue_param_ovr_t
 Packet input queue parameters override.
 
typedef struct odp_pktin_vector_config_t odp_pktin_vector_config_t
 Packet input vector configuration.
 
typedef struct odp_pktin_queue_param_t odp_pktin_queue_param_t
 Packet input queue parameters.
 
typedef struct odp_pktout_queue_param_t odp_pktout_queue_param_t
 Packet output queue parameters. More...
 
typedef struct odp_pktio_param_t odp_pktio_param_t
 Packet IO parameters. More...
 
typedef union odp_pktin_config_opt_t odp_pktin_config_opt_t
 Packet input configuration options bit field. More...
 
typedef union odp_pktout_config_opt_t odp_pktout_config_opt_t
 Packet output configuration options bit field. More...
 
typedef struct odp_pktio_parser_config_t odp_pktio_parser_config_t
 Parser configuration.
 
typedef enum odp_pktio_link_pause_t odp_pktio_link_pause_t
 Ethernet flow control modes.
 
typedef struct odp_pktio_config_t odp_pktio_config_t
 Packet IO configuration options. More...
 
typedef union odp_pktio_set_op_t odp_pktio_set_op_t
 Packet IO set operations. More...
 
typedef enum odp_lso_modify_t odp_lso_modify_t
 LSO custom modification options.
 
typedef enum odp_lso_protocol_t odp_lso_protocol_t
 LSO protocol options. More...
 
typedef struct odp_lso_capability_t odp_lso_capability_t
 Large Send Offload (LSO) capabilities.
 
typedef struct odp_pktin_vector_capability_t odp_pktin_vector_capability_t
 Packet input vector capabilities.
 
typedef struct odp_pktio_capability_t odp_pktio_capability_t
 Packet IO capabilities. More...
 
typedef struct odp_lso_profile_param_t odp_lso_profile_param_t
 LSO profile parameters.
 
typedef enum odp_pktio_link_status_t odp_pktio_link_status_t
 Link status.
 
typedef struct odp_pktio_info_t odp_pktio_info_t
 Packet IO information.
 
typedef enum odp_pktio_link_autoneg_t odp_pktio_link_autoneg_t
 Autonegotiation mode.
 
typedef enum odp_pktio_link_duplex_t odp_pktio_link_duplex_t
 Duplex mode.
 
typedef struct odp_pktio_link_info_t odp_pktio_link_info_t
 Packet IO link information.
 

Enumerations

enum  odp_pktin_mode_t { ODP_PKTIN_MODE_DIRECT = 0 , ODP_PKTIN_MODE_SCHED , ODP_PKTIN_MODE_QUEUE , ODP_PKTIN_MODE_DISABLED }
 Packet input mode. More...
 
enum  odp_pktout_mode_t { ODP_PKTOUT_MODE_DIRECT = 0 , ODP_PKTOUT_MODE_QUEUE , ODP_PKTOUT_MODE_TM , ODP_PKTOUT_MODE_DISABLED }
 Packet output mode. More...
 
enum  odp_pktio_op_mode_t { ODP_PKTIO_OP_MT = 0 , ODP_PKTIO_OP_MT_UNSAFE }
 Packet IO operation mode. More...
 
enum  odp_pktio_link_pause_t { ODP_PKTIO_LINK_PAUSE_UNKNOWN = -1 , ODP_PKTIO_LINK_PAUSE_OFF = 0 , ODP_PKTIO_LINK_PAUSE_ON = 1 , ODP_PKTIO_LINK_PFC_ON = 2 }
 Ethernet flow control modes. More...
 
enum  odp_lso_modify_t { ODP_LSO_ADD_SEGMENT_NUM = 0x1 , ODP_LSO_ADD_PAYLOAD_LEN = 0x2 , ODP_LSO_ADD_PAYLOAD_OFFSET = 0x4 }
 LSO custom modification options. More...
 
enum  odp_lso_protocol_t {
  ODP_LSO_PROTO_NONE = 0 , ODP_LSO_PROTO_CUSTOM , ODP_LSO_PROTO_IPV4 , ODP_LSO_PROTO_IPV6 ,
  ODP_LSO_PROTO_TCP_IPV4 , ODP_LSO_PROTO_TCP_IPV6 , ODP_LSO_PROTO_SCTP_IPV4 , ODP_LSO_PROTO_SCTP_IPV6
}
 LSO protocol options. More...
 
enum  odp_pktio_link_status_t { ODP_PKTIO_LINK_STATUS_UNKNOWN = -1 , ODP_PKTIO_LINK_STATUS_DOWN = 0 , ODP_PKTIO_LINK_STATUS_UP = 1 }
 Link status. More...
 
enum  odp_pktio_link_autoneg_t { ODP_PKTIO_LINK_AUTONEG_UNKNOWN = -1 , ODP_PKTIO_LINK_AUTONEG_OFF = 0 , ODP_PKTIO_LINK_AUTONEG_ON = 1 }
 Autonegotiation mode. More...
 
enum  odp_pktio_link_duplex_t { ODP_PKTIO_LINK_DUPLEX_UNKNOWN = -1 , ODP_PKTIO_LINK_DUPLEX_HALF = 0 , ODP_PKTIO_LINK_DUPLEX_FULL = 1 }
 Duplex mode. More...
 

Functions

odp_pktio_t odp_pktio_open (const char *name, odp_pool_t pool, const odp_pktio_param_t *param)
 Open a packet IO interface. More...
 
int odp_pktio_capability (odp_pktio_t pktio, odp_pktio_capability_t *capa)
 Query packet IO interface capabilities. More...
 
unsigned int odp_pktio_max_index (void)
 Maximum packet IO interface index. More...
 
int odp_pktio_config (odp_pktio_t pktio, const odp_pktio_config_t *config)
 Configure packet IO interface options. More...
 
int odp_pktin_queue_config (odp_pktio_t pktio, const odp_pktin_queue_param_t *param)
 Configure packet input queues. More...
 
int odp_pktout_queue_config (odp_pktio_t pktio, const odp_pktout_queue_param_t *param)
 Configure packet output queues. More...
 
int odp_pktin_event_queue (odp_pktio_t pktio, odp_queue_t queues[], int num)
 Event queues for packet input. More...
 
int odp_pktin_queue (odp_pktio_t pktio, odp_pktin_queue_t queues[], int num)
 Direct packet input queues. More...
 
int odp_pktout_event_queue (odp_pktio_t pktio, odp_queue_t queues[], int num)
 Event queues for packet output. More...
 
int odp_pktout_queue (odp_pktio_t pktio, odp_pktout_queue_t queues[], int num)
 Direct packet output queues. More...
 
int odp_pktio_start (odp_pktio_t pktio)
 Start packet receive and transmit. More...
 
int odp_pktio_stop (odp_pktio_t pktio)
 Stop packet receive and transmit. More...
 
int odp_pktio_close (odp_pktio_t pktio)
 Close a packet IO interface. More...
 
odp_pktio_t odp_pktio_lookup (const char *name)
 Return a packet IO handle for an already open device. More...
 
int odp_pktin_recv (odp_pktin_queue_t queue, odp_packet_t packets[], int num)
 Receive packets directly from an interface input queue. More...
 
int odp_pktin_recv_tmo (odp_pktin_queue_t queue, odp_packet_t packets[], int num, uint64_t wait)
 Receive packets directly from an interface input queue with timeout. More...
 
int odp_pktin_recv_mq_tmo (const odp_pktin_queue_t queues[], uint32_t num_q, uint32_t *from, odp_packet_t packets[], int num, uint64_t wait)
 Receive packets directly from multiple interface input queues with timeout. More...
 
uint64_t odp_pktin_wait_time (uint64_t nsec)
 Packet input wait time. More...
 
int odp_pktout_send (odp_pktout_queue_t queue, const odp_packet_t packets[], int num)
 Send packets directly to an interface output queue. More...
 
void odp_lso_profile_param_init (odp_lso_profile_param_t *param)
 Initialize LSO profile parameters. More...
 
odp_lso_profile_t odp_lso_profile_create (odp_pktio_t pktio, const odp_lso_profile_param_t *param)
 Create LSO profile. More...
 
int odp_lso_profile_destroy (odp_lso_profile_t lso_profile)
 Destroy LSO profile. More...
 
int odp_pktout_send_lso (odp_pktout_queue_t queue, const odp_packet_t packet[], int num, const odp_packet_lso_opt_t *lso_opt)
 Send packets with segmentation offload. More...
 
int odp_pktio_promisc_mode_set (odp_pktio_t pktio, odp_bool_t enable)
 Set promiscuous mode. More...
 
int odp_pktio_promisc_mode (odp_pktio_t pktio)
 Determine if promiscuous mode is enabled for a packet IO interface. More...
 
uint32_t odp_pktin_maxlen (odp_pktio_t pktio)
 Maximum frame length at packet input. More...
 
uint32_t odp_pktout_maxlen (odp_pktio_t pktio)
 Maximum frame length at packet output. More...
 
int odp_pktio_maxlen_set (odp_pktio_t pktio, uint32_t maxlen_input, uint32_t maxlen_output)
 Set maximum frame lengths. More...
 
int odp_pktio_mac_addr (odp_pktio_t pktio, void *mac_addr, int size)
 Get the default MAC address of a packet IO interface. More...
 
int odp_pktio_mac_addr_set (odp_pktio_t pktio, const void *mac_addr, int size)
 Set the default MAC address of a packet IO interface. More...
 
int odp_pktio_default_cos_set (odp_pktio_t pktio, odp_cos_t default_cos)
 Setup per-port default class-of-service. More...
 
int odp_pktio_error_cos_set (odp_pktio_t pktio, odp_cos_t error_cos)
 Setup per-port error class-of-service. More...
 
int odp_pktio_skip_set (odp_pktio_t pktio, uint32_t offset)
 Setup per-port header offset. More...
 
int odp_pktio_headroom_set (odp_pktio_t pktio, uint32_t headroom)
 Specify per-port buffer headroom. More...
 
int odp_pktio_index (odp_pktio_t pktio)
 Get pktio interface index. More...
 
uint64_t odp_pktio_to_u64 (odp_pktio_t pktio)
 Get printable value for an odp_pktio_t. More...
 
void odp_pktio_param_init (odp_pktio_param_t *param)
 Initialize pktio params. More...
 
void odp_pktin_queue_param_init (odp_pktin_queue_param_t *param)
 Initialize packet input queue parameters. More...
 
void odp_pktout_queue_param_init (odp_pktout_queue_param_t *param)
 Initialize packet output queue parameters. More...
 
void odp_pktio_config_init (odp_pktio_config_t *config)
 Initialize packet IO configuration options. More...
 
void odp_pktio_print (odp_pktio_t pktio)
 Print pktio info to the console. More...
 
odp_pktio_link_status_t odp_pktio_link_status (odp_pktio_t pktio)
 Determine pktio link is up or down for a packet IO interface. More...
 
int odp_pktio_info (odp_pktio_t pktio, odp_pktio_info_t *info)
 Retrieve information about a pktio. More...
 
int odp_pktio_link_info (odp_pktio_t pktio, odp_pktio_link_info_t *info)
 Retrieve information about packet IO link status. More...
 
uint64_t odp_pktio_ts_res (odp_pktio_t pktio)
 Packet IO timestamp resolution in hertz. More...
 
odp_time_t odp_pktio_ts_from_ns (odp_pktio_t pktio, uint64_t ns)
 Convert nanoseconds to packet IO time. More...
 
odp_time_t odp_pktio_time (odp_pktio_t pktio, odp_time_t *ts_global)
 Current packet IO time and global time. More...
 
int odp_pktout_ts_read (odp_pktio_t pktio, odp_time_t *ts)
 Read last captured Tx timestamp of a packet if available and clear it for next timestamp. More...
 
int odp_pktio_stats (odp_pktio_t pktio, odp_pktio_stats_t *stats)
 Get statistics for pktio handle. More...
 
int odp_pktin_queue_stats (odp_pktin_queue_t queue, odp_pktin_queue_stats_t *stats)
 Get statistics for direct packet input queue. More...
 
int odp_pktin_event_queue_stats (odp_pktio_t pktio, odp_queue_t queue, odp_pktin_queue_stats_t *stats)
 Get statistics for packet input event queue. More...
 
int odp_pktout_queue_stats (odp_pktout_queue_t queue, odp_pktout_queue_stats_t *stats)
 Get statistics for direct packet output queue. More...
 
int odp_pktout_event_queue_stats (odp_pktio_t pktio, odp_queue_t queue, odp_pktout_queue_stats_t *stats)
 Get statistics for packet output event queue. More...
 
int odp_pktio_stats_reset (odp_pktio_t pktio)
 Reset statistics for pktio handle. More...
 
int odp_pktio_extra_stat_info (odp_pktio_t pktio, odp_pktio_extra_stat_info_t info[], int num)
 Get extra statistics counter information for a packet IO interface. More...
 
int odp_pktio_extra_stats (odp_pktio_t pktio, uint64_t stats[], int num)
 Get extra statistics for a packet IO interface. More...
 
int odp_pktio_extra_stat_counter (odp_pktio_t pktio, uint32_t id, uint64_t *stat)
 Get extra statistic counter value. More...
 
void odp_pktio_extra_stats_print (odp_pktio_t pktio)
 Print extra statistics for a packet IO interface. More...
 

Link speed

Packet IO link speeds in Mbps

#define ODP_PKTIO_LINK_SPEED_UNKNOWN   0
 Link speed unknown.
 
#define ODP_PKTIO_LINK_SPEED_10M   10
 Link speed 10 Mbit/s.
 
#define ODP_PKTIO_LINK_SPEED_100M   100
 Link speed 100 Mbit/s.
 
#define ODP_PKTIO_LINK_SPEED_1G   1000
 Link speed 1 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_2_5G   2500
 Link speed 2.5 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_5G   5000
 Link speed 5 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_10G   10000
 Link speed 10 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_20G   20000
 Link speed 20 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_25G   25000
 Link speed 25 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_40G   40000
 Link speed 40 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_50G   50000
 Link speed 50 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_56G   56000
 Link speed 56 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_100G   100000
 Link speed 100 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_200G   200000
 Link speed 200 Gbit/s.
 
#define ODP_PKTIO_LINK_SPEED_400G   400000
 Link speed 400 Gbit/s.
 

Macro Definition Documentation

◆ ODP_PKTIO_MAX_INDEX

#define ODP_PKTIO_MAX_INDEX   63

Maximum packet IO interface index.

Use odp_pktio_max_index() to check the runtime maximum value, which may be smaller than this value.

Examples
odp_dmafwd.c, odp_l2fwd.c, odp_packet_gen.c, and odp_ping.c.

◆ ODP_PKTIN_MAX_QUEUES

#define ODP_PKTIN_MAX_QUEUES   64

Maximum number of packet input queues supported by the API.

Use odp_pktio_capability() to check the maximum number of queues per interface.

◆ ODP_PKTOUT_MAX_QUEUES

#define ODP_PKTOUT_MAX_QUEUES   64

Maximum number of packet output queues supported by the API.

Use odp_pktio_capability() to check the maximum number of queues per interface.

Typedef Documentation

◆ odp_pktin_queue_t

Direct packet input queue handle.

◆ odp_pktout_queue_t

Direct packet output queue handle.

◆ odp_pktio_stats_t

Packet IO statistics counters.

In the counter definitions the term successfully refers to packets which were not discarded or detected to contain errors by the packet IO interface. In case of Ethernet, it's implementation specific whether valid pause frames are included in the counters or not.

◆ odp_pktin_queue_stats_t

Packet IO input queue specific statistics counters.

Statistics counters for an individual packet input queue. Refer to packet IO level statistics odp_pktio_stats_t for counter definitions.

◆ odp_pktout_queue_stats_t

Packet IO output queue specific statistics counters.

Statistics counters for an individual packet output queue. Refer to packet IO level statistics odp_pktio_stats_t for counter definitions.

◆ odp_pktin_hash_proto_t

Packet input hash protocols.

The list of protocol header field combinations, which are included into packet input hash calculation.

◆ odp_pktout_queue_param_t

Packet output queue parameters.

These parameters are used in ODP_PKTOUT_MODE_DIRECT and ODP_PKTOUT_MODE_QUEUE modes.

◆ odp_pktio_param_t

Packet IO parameters.

Packet IO interface level parameters. Use odp_pktio_param_init() to initialize the structure with default values.

◆ odp_pktin_config_opt_t

Packet input configuration options bit field.

Packet input configuration options listed in a bit field structure. Packet input timestamping may be enabled for all packets or at least for those that belong to time synchronization protocol (PTP).

Packet input checksum checking may be enabled or disabled. When it is enabled, implementation will attempt to verify checksum correctness on incoming packets and depending on drop configuration either deliver erroneous packets with appropriate flags set (e.g. odp_packet_has_l3_error(), odp_packet_l3_chksum_status()) or drop those. When packet dropping is enabled, application will never receive a packet with the specified error and may avoid to check the error flag.

If checksum checking is enabled, IPv4 header checksum checking is always done for packets that do not have IP options and L4 checksum checking is done for unfragmented packets that do not have IPv4 options or IPv6 extension headers. In other cases checksum checking may or may not be done. For example, L4 checksum of fragmented packets is typically not checked.

IPv4 checksum checking may be enabled only when parsing level is ODP_PROTO_LAYER_L3 or higher. Similarly, L4 level checksum checking may be enabled only with parsing level ODP_PROTO_LAYER_L4 or higher.

Whether checksum checking was done and whether a checksum was correct can be queried for each received packet with odp_packet_l3_chksum_status() and odp_packet_l4_chksum_status().

◆ odp_pktout_config_opt_t

Packet output configuration options bit field.

Packet output configuration options listed in a bit field structure. Packet output checksum insertion may be enabled or disabled (e.g. ipv4_chksum_ena):

0: Disable checksum insertion. Application will not request checksum insertion for any packet. This is the default value for xxx_chksum_ena bits. 1: Enable checksum insertion. Application will request checksum insertion for some packets.

When checksum insertion is enabled, application may use configuration options to set the default behaviour on packet output (e.g. ipv4_chksum):

0: Do not insert checksum by default. This is the default value for xxx_chksum bits. 1: Calculate and insert checksum by default.

These defaults may be overridden on per packet basis using e.g. odp_packet_l4_chksum_insert().

For correct operation, packet metadata must provide valid offsets and type flags for the appropriate layer 3 and layer 4 protocols. L3 and L4 offsets can be updated with odp_packet_l3_offset_set() and odp_packet_l4_offset_set() calls. L3 and L4 type flags can be updated using odp_packet_has_*_set() calls For example, UDP checksum calculation needs both L3 and L4 types (IP and UDP) and L3 and L4 offsets (to access IP and UDP headers), while IP checksum calculation only needs L3 type (IP) and L3 offset (to access IP header). When application (e.g. a switch) does not modify L3/L4 data and thus checksum does not need to be updated, checksum insertion should be disabled for optimal performance.

UDP, TCP and SCTP checksum insertion must not be requested for IP fragments. Use checksum override function (odp_packet_l4_chksum_insert()) to disable checksumming when sending a fragment through a packet IO interface that has the relevant L4 checksum insertion enabled.

Result of checksum insertion at packet output is undefined if the protocol headers required for checksum calculation are not well formed. Packet must contain at least as many data bytes after L3/L4 offsets as the headers indicate. Other data bytes of the packet are ignored for the checksum insertion.

◆ odp_pktio_config_t

Packet IO configuration options.

Packet IO interface level configuration options. Use odp_pktio_capability() to see which options are supported by the implementation. Use odp_pktio_config_init() to initialize the structure with default values.

◆ odp_pktio_set_op_t

Packet IO set operations.

Supported packet IO interface set operations listed in a bit field structure.

◆ odp_lso_protocol_t

LSO protocol options.

An LSO operation may perform segmentation on these protocols.

◆ odp_pktio_capability_t

Packet IO capabilities.

Note that interface capabilities may differ between packet output modes. For example, LSO may not be supported in ODP_PKTOUT_MODE_TM mode, while it is supported in ODP_PKTOUT_MODE_DIRECT mode.

Enumeration Type Documentation

◆ odp_pktin_mode_t

Packet input mode.

Enumerator
ODP_PKTIN_MODE_DIRECT 

Direct packet input from the interface.

ODP_PKTIN_MODE_SCHED 

Packet input through scheduler and scheduled event queues.

ODP_PKTIN_MODE_QUEUE 

Packet input through plain event queues.

ODP_PKTIN_MODE_DISABLED 

Application will never receive from this interface.

Definition at line 93 of file api/spec/packet_io_types.h.

◆ odp_pktout_mode_t

Packet output mode.

Enumerator
ODP_PKTOUT_MODE_DIRECT 

Direct packet output on the interface.

ODP_PKTOUT_MODE_QUEUE 

Packet output through event queues.

ODP_PKTOUT_MODE_TM 

Packet output through traffic manager API.

ODP_PKTOUT_MODE_DISABLED 

Application will never send to this interface.

Definition at line 107 of file api/spec/packet_io_types.h.

◆ odp_pktio_op_mode_t

Packet IO operation mode.

Enumerator
ODP_PKTIO_OP_MT 

Multithread safe operation.

Direct packet IO operation (recv or send) is multithread safe. Any
number of application threads may perform the operation
concurrently. 
ODP_PKTIO_OP_MT_UNSAFE 

Not multithread safe operation.

Direct packet IO operation (recv or send) may not be multithread
safe. Application ensures synchronization between threads so that
simultaneously only single thread attempts the operation on
the same (pktin or pktout) queue. 

Definition at line 151 of file api/spec/packet_io_types.h.

◆ odp_pktio_link_pause_t

Ethernet flow control modes.

Enumerator
ODP_PKTIO_LINK_PAUSE_UNKNOWN 

Flow control mode is unknown.

ODP_PKTIO_LINK_PAUSE_OFF 

No flow control.

ODP_PKTIO_LINK_PAUSE_ON 

Pause frame flow control enabled.

ODP_PKTIO_LINK_PFC_ON 

Priority-based Flow Control (PFC) enabled.

Definition at line 568 of file api/spec/packet_io_types.h.

◆ odp_lso_modify_t

LSO custom modification options.

Enumerator
ODP_LSO_ADD_SEGMENT_NUM 

Add current segment number.

Numbering starts from zero.

ODP_LSO_ADD_PAYLOAD_LEN 

Add number of payload bytes in the segment.

ODP_LSO_ADD_PAYLOAD_OFFSET 

Add number of payload bytes in all previous segments.

Definition at line 772 of file api/spec/packet_io_types.h.

◆ odp_lso_protocol_t

LSO protocol options.

An LSO operation may perform segmentation on these protocols.

Enumerator
ODP_LSO_PROTO_NONE 

Protocol not selected.

ODP_LSO_PROTO_CUSTOM 

Custom protocol.

LSO performs only custom field updates to the packet headers.

ODP_LSO_PROTO_IPV4 

LSO performs IPv4 fragmentation.

IP header length and checksum fields are updated. IP fragmentation related fields are
filled and IPv4 Identification field value is copied from the original packet. 
ODP_LSO_PROTO_IPV6 

LSO performs IPv6 fragmentation.

ODP_LSO_PROTO_TCP_IPV4 

LSO performs TCP segmentation on top of IPv4.

IP header length and checksum fields are updated. IP fragmentation is not performed
and IPv4 Don't Fragment bit is not set. Unique IPv4 Identification field values
are generated. Those are usually increments of the IPv4 ID field value in the packet.
ODP_LSO_PROTO_TCP_IPV6 

LSO performs TCP segmentation on top of IPv6.

ODP_LSO_PROTO_SCTP_IPV4 

LSO performs SCTP segmentation on top of IPv4.

ODP_LSO_PROTO_SCTP_IPV6 

LSO performs SCTP segmentation on top of IPv6.

Definition at line 788 of file api/spec/packet_io_types.h.

◆ odp_pktio_link_status_t

Link status.

Enumerator
ODP_PKTIO_LINK_STATUS_UNKNOWN 

Link status is unknown.

ODP_PKTIO_LINK_STATUS_DOWN 

Link status is down.

ODP_PKTIO_LINK_STATUS_UP 

Link status is up.

Definition at line 1127 of file api/spec/packet_io_types.h.

◆ odp_pktio_link_autoneg_t

Autonegotiation mode.

Enumerator
ODP_PKTIO_LINK_AUTONEG_UNKNOWN 

Autonegotiation state unknown.

ODP_PKTIO_LINK_AUTONEG_OFF 

Autonegotiation disabled.

ODP_PKTIO_LINK_AUTONEG_ON 

Autonegotiation enabled.

Definition at line 1195 of file api/spec/packet_io_types.h.

◆ odp_pktio_link_duplex_t

Duplex mode.

Enumerator
ODP_PKTIO_LINK_DUPLEX_UNKNOWN 

Link duplex mode is unknown.

ODP_PKTIO_LINK_DUPLEX_HALF 

Half duplex mode.

ODP_PKTIO_LINK_DUPLEX_FULL 

Full duplex mode.

Definition at line 1206 of file api/spec/packet_io_types.h.

Function Documentation

◆ odp_pktio_open()

odp_pktio_t odp_pktio_open ( const char *  name,
odp_pool_t  pool,
const odp_pktio_param_t param 
)

Open a packet IO interface.

An ODP program can open a single packet IO interface per device, attempts to open an already open device will fail, returning ODP_PKTIO_INVALID. Use odp_pktio_lookup() to obtain a handle to an already open device. Packet IO parameters provide interface level configuration options.

Use odp_pktio_param_init() to initialize packet IO parameters into their default values. Default values are also used when 'param' pointer is NULL.

Packet input queue configuration must be setup with odp_pktin_queue_config() before odp_pktio_start() is called. When packet input mode is ODP_PKTIN_MODE_DISABLED, odp_pktin_queue_config() call is optional and will ignore all parameters.

Packet output queue configuration must be setup with odp_pktout_queue_config() before odp_pktio_start() is called. When packet output mode is ODP_PKTOUT_MODE_DISABLED or ODP_PKTOUT_MODE_TM, odp_pktout_queue_config() call is optional and will ignore all parameters.

Advanced packet IO interface offload features and options can be setup with odp_pktio_config() before the interface is started. These features include e.g. checksum, segmentation (LSO), reassembly and inline IPSEC offloads. When odp_pktio_config() is not used, the interface is started with the default values of odp_pktio_config_t.

Packet receive and transmit on the interface is enabled with a call to odp_pktio_start(). If not specified otherwise, any interface level configuration must not be changed when the interface is active (between start and stop calls).

In summary, a typical pktio interface setup sequence is ...

... and tear down sequence is:

Parameters
namePacket IO device name
poolDefault pool from which to allocate storage for packets received over this interface, must be of type ODP_POOL_PACKET
paramPacket IO parameters. Uses defaults when NULL.
Returns
Packet IO handle
Return values
ODP_PKTIO_INVALIDon failure
Note
The device name "loop" is a reserved name for a loopback device used for testing purposes.
Packets arriving via this interface assigned to a CoS by the classifier are received into the pool associated with that CoS. This will occur either because this pktio is assigned a default CoS via the odp_pktio_default_cos_set() routine, or because a matching PMR assigned the packet to a specific CoS. The default pool specified here is applicable only for those packets that are not assigned to a more specific CoS that specifies another pool.
See also
odp_pktio_start(), odp_pktio_stop(), odp_pktio_close()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_debug.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, odp_switch.c, and odp_sysinfo.c.

◆ odp_pktio_capability()

int odp_pktio_capability ( odp_pktio_t  pktio,
odp_pktio_capability_t capa 
)

Query packet IO interface capabilities.

Outputs packet IO interface capabilities on success.

Parameters
pktioPacket IO handle
[out]capaPointer to capability structure for output
Return values
0on success
<0on failure
Examples
ipsec_api/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_sched_pktio.c, odp_switch.c, and odp_sysinfo.c.

◆ odp_pktio_max_index()

unsigned int odp_pktio_max_index ( void  )

Maximum packet IO interface index.

Return the maximum packet IO interface index. Interface indexes (e.g. returned by odp_pktio_index()) range from zero to this maximum value. The return value does not exceed ODP_PKTIO_MAX_INDEX.

Returns
Maximum packet IO interface index

◆ odp_pktio_config()

int odp_pktio_config ( odp_pktio_t  pktio,
const odp_pktio_config_t config 
)

Configure packet IO interface options.

Select interface level configuration options before the interface is activated (before odp_pktio_start() call). This step is optional in pktio interface setup sequence. Use odp_pktio_capability() to query configuration capabilities. Use odp_pktio_config_init() to initialize configuration options into their default values. Default values are used when 'config' pointer is NULL.

Parameters
pktioPacket IO handle
configPacket IO interface configuration. Uses defaults when NULL.
Return values
0on success
<0on failure
Examples
ipsec_api/odp_ipsec.c, odp_classifier.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktin_queue_config()

int odp_pktin_queue_config ( odp_pktio_t  pktio,
const odp_pktin_queue_param_t param 
)

Configure packet input queues.

Setup a number of packet input queues and configure those. The maximum number of queues is platform dependent and can be queried with odp_pktio_capability(). Use odp_pktin_queue_param_init() to initialize parameters into their default values. Default values are also used when 'param' pointer is NULL.

Queue handles for input queues can be requested with odp_pktin_queue() or odp_pktin_event_queue() after this call. All requested queues are setup on success, no queues are setup on failure. Each call reconfigures input queues and may invalidate all previous queue handles.

Parameters
pktioPacket IO handle
paramPacket input queue configuration parameters. Uses defaults when NULL.
Return values
0on success
<0on failure
See also
odp_pktio_capability(), odp_pktin_queue(), odp_pktin_event_queue()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_debug.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktout_queue_config()

int odp_pktout_queue_config ( odp_pktio_t  pktio,
const odp_pktout_queue_param_t param 
)

Configure packet output queues.

Setup a number of packet output queues and configure those. The maximum number of queues is platform dependent and can be queried with odp_pktio_capability(). Use odp_pktout_queue_param_init() to initialize parameters into their default values. Default values are also used when 'param' pointer is NULL.

Queue handles for output queues can be requested with odp_pktout_queue() or odp_pktout_event_queue() after this call. All requested queues are setup on success, no queues are setup on failure. Each call reconfigures output queues and may invalidate all previous queue handles.

Parameters
pktioPacket IO handle
paramPacket output queue configuration parameters. Uses defaults when NULL.
Return values
0on success
<0on failure
See also
odp_pktio_capability(), odp_pktout_queue(), odp_pktout_event_queue()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_debug.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktin_event_queue()

int odp_pktin_event_queue ( odp_pktio_t  pktio,
odp_queue_t  queues[],
int  num 
)

Event queues for packet input.

Returns the number of input queues configured for the interface in ODP_PKTIN_MODE_QUEUE and ODP_PKTIN_MODE_SCHED modes. Outputs up to 'num' queue handles when the 'queues' array pointer is not NULL. If return value is larger than 'num', there are more queues than the function was allowed to output. If return value (N) is less than 'num', only queues[0 ... N-1] have been written.

In addition to packet input, application and other parts of ODP (e.g. timer) may enqueue events into these queues. Depending on the queue mode, application uses either odp_queue_deq() or odp_schedule() (or variants of those) to receive packets and other events from these queues.

Parameters
pktioPacket IO handle
[out]queuesPoints to an array of queue handles for output
numMaximum number of queue handles to output
Returns
Number of packet input queues
Return values
<0on failure
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_l2fwd.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, and odp_sched_pktio.c.

◆ odp_pktin_queue()

int odp_pktin_queue ( odp_pktio_t  pktio,
odp_pktin_queue_t  queues[],
int  num 
)

Direct packet input queues.

Returns the number of input queues configured for the interface in ODP_PKTIN_MODE_DIRECT mode. Outputs up to 'num' queue handles when the 'queues' array pointer is not NULL. If return value is larger than 'num', there are more queues than the function was allowed to output. If return value (N) is less than 'num', only queues[0 ... N-1] have been written.

Packets from these queues are received with odp_pktin_recv().

Parameters
pktioPacket IO handle
[out]queuesPoints to an array of queue handles for output
numMaximum number of queue handles to output
Returns
Number of packet input queues
Return values
<0on failure
Examples
odp_bench_pktio_sp.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktout_event_queue()

int odp_pktout_event_queue ( odp_pktio_t  pktio,
odp_queue_t  queues[],
int  num 
)

Event queues for packet output.

Returns the number of output queues configured for the interface in ODP_PKTOUT_MODE_QUEUE. Outputs up to 'num' queue handles when the 'queues' array pointer is not NULL. If return value is larger than 'num', there are more queues than the function was allowed to output. If return value (N) is less than 'num', only queues[0 ... N-1] have been written.

Packets are enqueued to these queues with odp_queue_enq() or odp_queue_enq_multi(). Behaviour is undefined if other events than packets are enqueued. Application cannot dequeue from these queues.

Parameters
pktioPacket IO handle
[out]queuesPoints to an array of queue handles for output
numMaximum number of queue handles to output
Returns
Number of packet output queues
Return values
<0on failure
Examples
odp_bench_pktio_sp.c, odp_ipsecfwd.c, and odp_l2fwd.c.

◆ odp_pktout_queue()

int odp_pktout_queue ( odp_pktio_t  pktio,
odp_pktout_queue_t  queues[],
int  num 
)

Direct packet output queues.

Returns the number of output queues configured for the interface in ODP_PKTOUT_MODE_DIRECT mode. Outputs up to 'num' queue handles when the 'queues' array pointer is not NULL. If return value is larger than 'num', there are more queues than the function was allowed to output. If return value (N) is less than 'num', only queues[0 ... N-1] have been written.

Packets are sent to these queues with odp_pktout_send().

Parameters
pktioPacket IO handle
[out]queuesPoints to an array of queue handles for output
numMaximum number of queue handles to output
Returns
Number of packet output queues
Return values
<0on failure
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktio_start()

int odp_pktio_start ( odp_pktio_t  pktio)

Start packet receive and transmit.

Activate packet receive and transmit on a previously opened or stopped interface. The interface can be stopped with a call to odp_pktio_stop().

Parameters
pktioPacket IO handle
Return values
0on success
<0on failure
See also
odp_pktio_open(), odp_pktio_stop()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_debug.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktio_stop()

int odp_pktio_stop ( odp_pktio_t  pktio)

Stop packet receive and transmit.

Stop packet receive and transmit on a previously started interface. New packets are not received from or transmitted to the network. Packets already received from the network may be still available from interface and application can receive those normally. New packets may not be accepted for transmit. Packets already stored for transmit are not freed. A following odp_packet_start() call restarts packet receive and transmit.

Parameters
pktioPacket IO handle
Return values
0on success
<0on failure
See also
odp_pktio_start(), odp_pktio_close()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_debug.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktio_close()

int odp_pktio_close ( odp_pktio_t  pktio)

Close a packet IO interface.

Close a stopped packet IO interface. This call frees all remaining packets stored in pktio receive and transmit side buffers. The pktio is destroyed and the handle must not be used for other calls. After a successful call, the same pktio device can be opened again with a odp_pktio_open() call.

Parameters
pktioPacket IO handle
Return values
0on success
<0on failure
See also
odp_pktio_stop(), odp_pktio_open()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, odp_classifier.c, odp_debug.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, odp_switch.c, and odp_sysinfo.c.

◆ odp_pktio_lookup()

odp_pktio_t odp_pktio_lookup ( const char *  name)

Return a packet IO handle for an already open device.

Parameters
namePacket IO device name
Returns
Packet IO handle
Return values
ODP_PKTIO_INVALIDon failure
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_pktio_sp.c, and odp_pktio.c.

◆ odp_pktin_recv()

int odp_pktin_recv ( odp_pktin_queue_t  queue,
odp_packet_t  packets[],
int  num 
)

Receive packets directly from an interface input queue.

Receives up to 'num' packets from the pktio interface input queue. Returns the number of packets received.

When input queue parameter 'op_mode' has been set to ODP_PKTIO_OP_MT_UNSAFE, the operation is optimized for single thread operation per queue and the same queue must not be accessed simultaneously from multiple threads.

Parameters
queuePacket input queue handle for receiving packets
[out]packets[]Packet handle array for output of received packets
numMaximum number of packets to receive
Returns
Number of packets received
Return values
<0on failure
See also
odp_pktin_queue()
Examples
odp_ipsecfwd.c, odp_l2fwd.c, odp_l3fwd.c, odp_packet_gen.c, odp_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktin_recv_tmo()

int odp_pktin_recv_tmo ( odp_pktin_queue_t  queue,
odp_packet_t  packets[],
int  num,
uint64_t  wait 
)

Receive packets directly from an interface input queue with timeout.

Provides the same functionality as odp_pktin_recv(), except that waits if there are no packets available. Wait time is specified by the 'wait' parameter.

Parameters
queuePacket input queue handle for receiving packets
[out]packets[]Packet handle array for output of received packets
numMaximum number of packets to receive
waitWait time specified as as follows:
  • ODP_PKTIN_NO_WAIT: Do not wait
  • Other values specify the minimum time to wait. Use odp_pktin_wait_time() to convert nanoseconds to a valid parameter value. Wait time may be rounded up a small, platform specific amount.
Returns
Number of packets received
Return values
<0on failure
Examples
odp_l2fwd_simple.c.

◆ odp_pktin_recv_mq_tmo()

int odp_pktin_recv_mq_tmo ( const odp_pktin_queue_t  queues[],
uint32_t  num_q,
uint32_t *  from,
odp_packet_t  packets[],
int  num,
uint64_t  wait 
)

Receive packets directly from multiple interface input queues with timeout.

Receives up to 'num' packets from one of the specified pktio interface input queues. The index of the source queue is stored into 'from' output parameter. If there are no packets available on any of the queues, waits for packets depending on 'wait' parameter value. Returns the number of packets received.

When an input queue has been configured with 'op_mode' value ODP_PKTIO_OP_MT_UNSAFE, the operation is optimized for single thread operation and the same queue must not be accessed simultaneously from multiple threads.

It is implementation specific in which order the queues are checked for packets. Application may improve fairness of queue service levels by circulating queue handles between consecutive calls (e.g. [q0, q1, q2, q3] -> [q1, q2, q3, q0] -> [q2, q3, ...).

Parameters
queues[]Packet input queue handles for receiving packets
num_qNumber of input queues
[out]fromPointer for output of the source queue index. Ignored when NULL.
[out]packets[]Packet handle array for output of received packets
numMaximum number of packets to receive
waitWait time specified as as follows:
  • ODP_PKTIN_NO_WAIT: Do not wait
  • Other values specify the minimum time to wait. Use odp_pktin_wait_time() to convert nanoseconds to a valid parameter value. Wait time may be rounded up a small, platform specific amount.
Returns
Number of packets received
Return values
<0on failure

◆ odp_pktin_wait_time()

uint64_t odp_pktin_wait_time ( uint64_t  nsec)

Packet input wait time.

Converts nanoseconds to wait time values for packet input functions.

Parameters
nsecMinimum number of nanoseconds to wait
Returns
Wait parameter value for packet input functions
Examples
odp_l2fwd_simple.c.

◆ odp_pktout_send()

int odp_pktout_send ( odp_pktout_queue_t  queue,
const odp_packet_t  packets[],
int  num 
)

Send packets directly to an interface output queue.

Sends out a number of packets to the interface output queue. When output queue parameter 'op_mode' has been set to ODP_PKTIO_OP_MT_UNSAFE, the operation is optimized for single thread operation per queue and the same queue must not be accessed simultaneously from multiple threads.

A successful call returns the actual number of packets accepted for transmit. If return value is less than 'num', the remaining packets at the end of packets[] array are not consumed, and the caller has to take care of them. Transmitted packets are freed back into their originating pools by default. If interface supports ODP_PACKET_FREE_CTRL_DONT_FREE option and it is set (odp_packet_free_ctrl_set()) in a packet, the packet is not freed but application owns it again after its transmit is complete. Application may use odp_packet_tx_compl_request() to request an indication when transmit of a packet is complete.

Entire packet data is sent out (odp_packet_len() bytes of data, starting from odp_packet_data()). All other packet metadata is ignored unless otherwise specified e.g. for protocol offload purposes. Link protocol specific frame checksum and padding are added to frames before transmission.

Parameters
queuePacket output queue handle for sending packets
packets[]Array of packets to send
numNumber of packets to send
Returns
Number of packets accepted for transmit
Return values
<0on failure
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_classifier.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_lso_profile_param_init()

void odp_lso_profile_param_init ( odp_lso_profile_param_t param)

Initialize LSO profile parameters.

Initialize an odp_lso_profile_param_t to its default values for all fields.

Parameters
paramAddress of the odp_lso_profile_param_t to be initialized

◆ odp_lso_profile_create()

odp_lso_profile_t odp_lso_profile_create ( odp_pktio_t  pktio,
const odp_lso_profile_param_t param 
)

Create LSO profile.

LSO profile defines the set of segmentation operations to be performed to a packet. LSO profiles are created before the packet IO interface is started (after odp_pktio_config() and before odp_pktio_start()).

See odp_lso_capability_t for maximum number of profiles supported and other LSO capabilities.

Parameters
pktioPacket IO interface which is used with this LSO profile
paramLSO profile parameters
Returns
LSO profile handle
Return values
ODP_LSO_PROFILE_INVALIDon failure

◆ odp_lso_profile_destroy()

int odp_lso_profile_destroy ( odp_lso_profile_t  lso_profile)

Destroy LSO profile.

LSO profiles can be destroyed only when the packet IO interface is not active (i.e. after it has been stopped).

Parameters
lso_profileLSO profile to be destroyed
Return values
0on success
<0on failure

◆ odp_pktout_send_lso()

int odp_pktout_send_lso ( odp_pktout_queue_t  queue,
const odp_packet_t  packet[],
int  num,
const odp_packet_lso_opt_t lso_opt 
)

Send packets with segmentation offload.

Like odp_pktout_send(), but splits a packet payload into 'max_payload_len' or smaller segments during output. Packet headers (before 'payload_offset') are copied into each segment and automatically modified before transmission. Header updates are based on segmentation protocol selection (odp_lso_profile_param_t::lso_proto) in LSO profile. Header checksums are updated after modifications. L3/L4 header modifications (see e.g. ODP_LSO_PROTO_TCP_IPV4) require that L3/L4 layer offsets in the packet are valid (see e.g. odp_packet_l3_offset()).

In addition, custom field updates may be used to cover unsupported or proprietary protocols. Custom fields must not overlap with each other and can be used only when ODP_LSO_PROTO_CUSTOM is selected.

Packets are processed and transmitted in the array order. Segments of each packet are transmitted in ascending order.

When all packets share the same LSO options, usage of 'lso_opt' parameter may improve performance as a number of packet metadata writes/reads are avoided. Results are undefined if 'lso_opt' is NULL and a packet misses LSO options.

Packets with less than (or equal to) 'max_payload_len' payload bytes can be sent also, however odp_pktout_send() should be more optimal for those than this function.

Check LSO support level from packet IO capabilities (odp_pktio_capability_t).

Parameters
queuePacket output queue handle
packet[]Array of packets to be LSO processed and sent
numNumber of packets
lso_optWhen set, LSO options to be used for all packets. When NULL, LSO options are read from each packet (see odp_packet_lso_request()).
Returns
Number of packets successfully segmented (0 ... num)
Return values
<0on failure

◆ odp_pktio_promisc_mode_set()

int odp_pktio_promisc_mode_set ( odp_pktio_t  pktio,
odp_bool_t  enable 
)

Set promiscuous mode.

Enable or disable promiscuous mode on a packet IO interface. Use packet IO capability odp_pktio_set_op_t::promisc_mode to check if an interface supports this operation. When the operation is supported, promiscuous mode is disabled by default.

Parameters
pktioPacket IO handle.
enable1 to enable, 0 to disable.
Return values
0on success
<0on failure
Examples
odp_classifier.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, and odp_switch.c.

◆ odp_pktio_promisc_mode()

int odp_pktio_promisc_mode ( odp_pktio_t  pktio)

Determine if promiscuous mode is enabled for a packet IO interface.

Parameters
pktioPacket IO handle.
Return values
1if promiscuous mode is enabled.
0if promiscuous mode is disabled.
<0on failure
Examples
odp_classifier.c, odp_debug.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, and odp_switch.c.

◆ odp_pktin_maxlen()

uint32_t odp_pktin_maxlen ( odp_pktio_t  pktio)

Maximum frame length at packet input.

Maximum frame length in bytes that the packet IO interface can receive. For Ethernet, the frame length bytes start with MAC addresses and continue to the end of the payload. So, Ethernet checksum, interpacket gap and preamble bytes are excluded from the length.

Parameters
pktioPacket IO handle.
Returns
Maximum frame length at packet input
Return values
0on failure
Examples
odp_debug.c, and odp_l2fwd_simple.c.

◆ odp_pktout_maxlen()

uint32_t odp_pktout_maxlen ( odp_pktio_t  pktio)

Maximum frame length at packet output.

Maximum frame length in bytes that the packet IO interface can transmit. For Ethernet, the frame length bytes start with MAC addresses and continue to the end of the payload. So, Ethernet checksum, interpacket gap and preamble bytes are excluded from the length.

Parameters
pktioPacket IO handle.
Returns
Maximum frame length at packet output
Return values
0on failure
Examples
odp_debug.c, and odp_l2fwd_simple.c.

◆ odp_pktio_maxlen_set()

int odp_pktio_maxlen_set ( odp_pktio_t  pktio,
uint32_t  maxlen_input,
uint32_t  maxlen_output 
)

Set maximum frame lengths.

Set the maximum frame lengths in bytes that the packet IO interface can receive and transmit. For Ethernet, the frame length bytes start with MAC addresses and continue to the end of the payload. So, Ethernet checksum, interpacket gap, and preamble bytes are excluded from the lengths.

Use odp_pktio_capability() to query interface capabilities. If setting maximum frame length is only supported in input or output direction, the parameter for the unsupported direction has to be set to zero. When 'equal' flag in odp_pktio_capability_t::maxlen is set, the same maximum frame length value has to be used for both input and output directions.

Parameters
pktioPacket IO handle
maxlen_inputMaximum frame length at packet input
maxlen_outputMaximum frame length at packet output
Return values
0on success
<0on failure
See also
odp_pktin_maxlen(), odp_pktout_maxlen()
Examples
odp_l2fwd.c, and odp_packet_gen.c.

◆ odp_pktio_mac_addr()

int odp_pktio_mac_addr ( odp_pktio_t  pktio,
void *  mac_addr,
int  size 
)

Get the default MAC address of a packet IO interface.

Parameters
pktioPacket IO handle
[out]mac_addrOutput buffer (use ODP_PKTIO_MACADDR_MAXSIZE)
sizeSize of output buffer
Returns
Number of bytes written (actual size of MAC address)
Return values
<0on failure
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_classifier.c, odp_debug.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, and odp_simple_pipeline.c.

◆ odp_pktio_mac_addr_set()

int odp_pktio_mac_addr_set ( odp_pktio_t  pktio,
const void *  mac_addr,
int  size 
)

Set the default MAC address of a packet IO interface.

Support of this operation on a packet IO interface is reported through ‘mac_addr’ set operation capability.

Parameters
pktioPacket IO handle
mac_addrMAC address to be set as default address
sizeSize of the MAC address
Returns
0 on success
Return values
<0on failure

◆ odp_pktio_default_cos_set()

int odp_pktio_default_cos_set ( odp_pktio_t  pktio,
odp_cos_t  default_cos 
)

Setup per-port default class-of-service.

Parameters
pktioIngress port pktio handle.
default_cosClass-of-service set to all packets arriving at this ingress port. Use ODP_COS_INVALID to remove the default CoS.
Return values
0on success
<0on failure
Note
The default_cos has to be unique per odp_pktio_t instance.
Examples
odp_bench_pktio_sp.c, and odp_classifier.c.

◆ odp_pktio_error_cos_set()

int odp_pktio_error_cos_set ( odp_pktio_t  pktio,
odp_cos_t  error_cos 
)

Setup per-port error class-of-service.

Parameters
pktioIngress port pktio handle.
error_cosclass-of-service set to all packets arriving at this ingress port that contain an error.
Return values
0on success
<0on failure
Note
Optional.

◆ odp_pktio_skip_set()

int odp_pktio_skip_set ( odp_pktio_t  pktio,
uint32_t  offset 
)

Setup per-port header offset.

Parameters
pktioIngress port pktio handle.
offsetNumber of bytes the classifier must skip.

This option is input to packet input parser/classifier indicating how many bytes of data should be skipped from start of packet, before parsing starts. So this option effects all packet input protocol identification and other offloads.

Return values
0on success
<0on failure
Note
Optional.

◆ odp_pktio_headroom_set()

int odp_pktio_headroom_set ( odp_pktio_t  pktio,
uint32_t  headroom 
)

Specify per-port buffer headroom.

Parameters
pktioIngress port pktio handle.
headroomNumber of bytes of space preceding packet data to reserve for use as headroom. Must not exceed the implementation defined ODP_PACKET_MAX_HEADROOM.
Return values
0on success
<0on failure
Note
Optional.

◆ odp_pktio_index()

int odp_pktio_index ( odp_pktio_t  pktio)

Get pktio interface index.

Parameters
pktioPacket I/O handle
Returns
Packet interface index (0..odp_pktio_max_index())
Return values
<0On failure (e.g., handle not valid)
Examples
odp_debug.c, odp_dmafwd.c, odp_l2fwd.c, odp_packet_gen.c, odp_ping.c, and odp_sched_pktio.c.

◆ odp_pktio_to_u64()

uint64_t odp_pktio_to_u64 ( odp_pktio_t  pktio)

Get printable value for an odp_pktio_t.

Parameters
pktioodp_pktio_t handle to be printed
Returns
uint64_t value that can be used to print/display this handle
Note
This routine is intended to be used for diagnostic purposes to enable applications to generate a printable value that represents an odp_pktio_t handle.
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_classifier.c, odp_debug.c, odp_pktio.c, odp_pktio_ordered.c, and odp_switch.c.

◆ odp_pktio_param_init()

◆ odp_pktin_queue_param_init()

void odp_pktin_queue_param_init ( odp_pktin_queue_param_t param)

◆ odp_pktout_queue_param_init()

void odp_pktout_queue_param_init ( odp_pktout_queue_param_t param)

Initialize packet output queue parameters.

Initialize an odp_pktout_queue_param_t to its default values.

Parameters
paramOutput queue parameter structure to be initialized
Examples
odp_bench_pktio_sp.c, odp_classifier.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktio_config_init()

void odp_pktio_config_init ( odp_pktio_config_t config)

Initialize packet IO configuration options.

Initialize an odp_pktio_config_t to its default values.

Parameters
configPacket IO interface configuration
Examples
ipsec_api/odp_ipsec.c, odp_classifier.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_pktio.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_pktio_print()

void odp_pktio_print ( odp_pktio_t  pktio)

Print pktio info to the console.

Print implementation-defined pktio debug information to the console.

Parameters
pktioPacket IO handle
Examples
odp_debug.c, odp_l2fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, and odp_sched_pktio.c.

◆ odp_pktio_link_status()

odp_pktio_link_status_t odp_pktio_link_status ( odp_pktio_t  pktio)

Determine pktio link is up or down for a packet IO interface.

Parameters
pktioPacket IO handle.
Return values
ODP_PKTIO_LINK_STATUS_UPor ODP_PKTIO_LINK_STATUS_DOWN on success
ODP_PKTIO_LINK_STATUS_UNKNOWNon failure
Examples
odp_debug.c, and odp_packet_gen.c.

◆ odp_pktio_info()

int odp_pktio_info ( odp_pktio_t  pktio,
odp_pktio_info_t info 
)

Retrieve information about a pktio.

Fills in packet IO information structure with current parameter values. May be called any time with a valid pktio handle. The call is not synchronized with configuration changing calls. The application should ensure that it does not simultaneously change the configuration and retrieve it with this call. The call is not intended for fast path use. The info structure is written only on success.

Parameters
pktioPacket IO handle
[out]infoPointer to packet IO info struct for output
Return values
0on success
<0on failure
Examples
odp_l2fwd.c, odp_packet_dump.c, and odp_ping.c.

◆ odp_pktio_link_info()

int odp_pktio_link_info ( odp_pktio_t  pktio,
odp_pktio_link_info_t info 
)

Retrieve information about packet IO link status.

Fills in link information structure with the current link status values. May be called any time with a valid pktio handle. The call is not intended for fast path use. The info structure is written only on success.

Parameters
pktioPacket IO handle
[out]infoPointer to packet IO link info struct for output
Return values
0on success
<0on failure
Examples
odp_debug.c, and odp_packet_gen.c.

◆ odp_pktio_ts_res()

uint64_t odp_pktio_ts_res ( odp_pktio_t  pktio)

Packet IO timestamp resolution in hertz.

This is the resolution of packet input and output timestamps using a packet IO time source.

Parameters
pktioPacket IO handle
Returns
Packet IO timestamp resolution in hertz
Return values
0on failure
Examples
odp_debug.c.

◆ odp_pktio_ts_from_ns()

odp_time_t odp_pktio_ts_from_ns ( odp_pktio_t  pktio,
uint64_t  ns 
)

Convert nanoseconds to packet IO time.

Packet IO time source is used for timestamping incoming and outgoing packets. This function is used to convert nanosecond time to packet input or output timestamp time.

Parameters
pktioPacket IO handle
nsTime in nanoseconds
Returns
Packet IO timestamp
Return values
ODP_TIME_NULLon failure

◆ odp_pktio_time()

odp_time_t odp_pktio_time ( odp_pktio_t  pktio,
odp_time_t ts_global 
)

Current packet IO time and global time.

Returns current packet IO time and optionally global time. The returned global time is that of global time source, where as the packet IO time is of packet IO time source that is used to timestamp incoming and outgoing packets.

Parameters
pktioPacket IO handle
[out]ts_globalPointer to odp_time_t for output or NULL. On success, global timestamp will be taken at the same point of time as packet IO time.
Returns
Current packet IO time
Return values
ODP_TIME_NULLon failure
Examples
odp_packet_dump.c.

◆ odp_pktout_ts_read()

int odp_pktout_ts_read ( odp_pktio_t  pktio,
odp_time_t ts 
)

Read last captured Tx timestamp of a packet if available and clear it for next timestamp.

Parameters
pktioPacket IO handle
[out]tsPointer to odp_time_t for output
Return values
0on success
>0Timestamp not available either because none has been requested or the requested timestamp is not yet available. In case it is the latter, then retry again later for retrieving the timestamp.
<0on failure

◆ odp_pktio_stats()

int odp_pktio_stats ( odp_pktio_t  pktio,
odp_pktio_stats_t stats 
)

Get statistics for pktio handle.

Counters not supported by the interface are set to zero.

Parameters
pktioPacket IO handle
[out]statsOutput buffer for counters
Return values
0on success
<0on failure
Examples
odp_bench_pktio_sp.c.

◆ odp_pktin_queue_stats()

int odp_pktin_queue_stats ( odp_pktin_queue_t  queue,
odp_pktin_queue_stats_t stats 
)

Get statistics for direct packet input queue.

Packet input queue handles can be requested with odp_pktin_queue(). Counters not supported by the interface are set to zero.

Parameters
queuePacket input queue handle
[out]statsOutput buffer for counters
Return values
0on success
<0on failure
Examples
odp_bench_pktio_sp.c.

◆ odp_pktin_event_queue_stats()

int odp_pktin_event_queue_stats ( odp_pktio_t  pktio,
odp_queue_t  queue,
odp_pktin_queue_stats_t stats 
)

Get statistics for packet input event queue.

The queue must be a packet input event queue. Event queue handles can be requested with odp_pktin_event_queue(). Counters not supported by the interface are set to zero.

Parameters
pktioPacket IO handle
queuePacket input event queue handle
[out]statsOutput buffer for counters
Return values
0on success
<0on failure
Examples
odp_bench_pktio_sp.c.

◆ odp_pktout_queue_stats()

int odp_pktout_queue_stats ( odp_pktout_queue_t  queue,
odp_pktout_queue_stats_t stats 
)

Get statistics for direct packet output queue.

Packet output queue handles can be requested with odp_pktout_queue(). Counters not supported by the interface are set to zero.

Parameters
queuePacket output queue handle
[out]statsOutput buffer for counters
Return values
0on success
<0on failure
Examples
odp_bench_pktio_sp.c.

◆ odp_pktout_event_queue_stats()

int odp_pktout_event_queue_stats ( odp_pktio_t  pktio,
odp_queue_t  queue,
odp_pktout_queue_stats_t stats 
)

Get statistics for packet output event queue.

The queue must be a packet output event queue. Event queue handles can be requested with odp_pktout_event_queue(). Counters not supported by the interface are set to zero.

Parameters
pktioPacket IO handle
queuePacket output event queue handle
[out]statsOutput buffer for counters
Return values
0on success
<0on failure
Examples
odp_bench_pktio_sp.c.

◆ odp_pktio_stats_reset()

int odp_pktio_stats_reset ( odp_pktio_t  pktio)

Reset statistics for pktio handle.

Reset all interface level statistics counters (odp_pktio_stats_t) to zero. It's implementation defined if other packet IO related statistics are affected.

Parameters
pktioPacket IO handle
Return values
0on success
<0on failure
Examples
odp_bench_pktio_sp.c.

◆ odp_pktio_extra_stat_info()

int odp_pktio_extra_stat_info ( odp_pktio_t  pktio,
odp_pktio_extra_stat_info_t  info[],
int  num 
)

Get extra statistics counter information for a packet IO interface.

Returns the number of implementation specific packet IO extra statistics counters supported by the interface. Outputs up to 'num' extra statistics counter info structures when the 'info' array pointer is not NULL. If the return value is larger than 'num', there are more extra counters than the function was allowed to output. If the return value (N) is less than 'num', only info[0 ... N-1] have been written.

The index of a counter in the 'info' array can be used to read the value of the individual counter with odp_pktio_extra_stat_counter(). The order of counters in the output array matches with odp_pktio_extra_stats().

Parameters
pktioPacket IO handle
[out]infoArray of extra statistics info structs for output
numMaximum number of info structs to output
Returns
Number of extra statistics
Return values
<0on failure
Examples
odp_l2fwd.c.

◆ odp_pktio_extra_stats()

int odp_pktio_extra_stats ( odp_pktio_t  pktio,
uint64_t  stats[],
int  num 
)

Get extra statistics for a packet IO interface.

Returns the number of implementation specific packet IO extra statistics counters supported by the interface. Outputs up to 'num' counters when the 'stats' array pointer is not NULL. If the return value is larger than 'num', there are more counters than the function was allowed to output. If the return value (N) is less than 'num', only stats[0 ... N-1] have been written.

The index of a counter in the 'stats' array can be used to read the value of the individual counter with odp_pktio_extra_stat_counter(). The order of counters in the output array matches with odp_pktio_extra_stat_info().

Parameters
pktioPacket IO handle
[out]statsArray of extra statistics for output
numMaximum number of extra statistics to output
Returns
Number of extra statistics
Return values
<0on failure

◆ odp_pktio_extra_stat_counter()

int odp_pktio_extra_stat_counter ( odp_pktio_t  pktio,
uint32_t  id,
uint64_t *  stat 
)

Get extra statistic counter value.

'id' is the index of the particular counter in the output array of odp_pktio_extra_stat_info() or odp_pktio_extra_stats().

Parameters
pktioPacket IO handle
idID of the extra statistics counter
[out]statPointer for statistic counter output
Return values
0on success
<0on failure

◆ odp_pktio_extra_stats_print()

void odp_pktio_extra_stats_print ( odp_pktio_t  pktio)

Print extra statistics for a packet IO interface.

Print all packet IO device extra statistics to ODP log.

Parameters
pktioPacket IO handle
Examples
odp_debug.c, and odp_l2fwd.c.