API Reference Manual  1.45.0
ODP PACKET

API Description

Packet event metadata and operations.

Operations on packet metadata flags

If user sets multiple conflicting packet metadata flags using odp_packet_has_XX_set() functions, only the last set flag value is guaranteed to hold. The values of other conflicting flags are implementation specific. The conflicting flag combinations are defined in function documentations.

Data Structures

struct  odp_packet_parse_result_flag_t
 Parse result flags. More...
 
struct  odp_packet_data_range
 Packet API data range specifier. More...
 
struct  odp_packet_reass_info_t
 Information about a completed reassembly. More...
 
struct  odp_packet_reass_partial_state_t
 Result from odp_packet_reass_partial_state() More...
 
union  odp_proto_chksums_t
 Flags to control packet data checksum checking. More...
 
struct  odp_packet_parse_param_t
 Packet parse parameters. More...
 
struct  odp_packet_parse_result_t
 Packet parse results. More...
 
struct  odp_packet_lso_opt_t
 LSO options. More...
 
struct  odp_packet_tx_compl_opt_t
 Packet transmit completion request options. More...
 
struct  odp_packet_proto_stats_opt_t
 Packet proto stats options. More...
 

Macros

#define ODP_PACKET_INVALID   ((odp_packet_t)0)
 Invalid packet.
 
#define ODP_PACKET_SEG_INVALID   ((odp_packet_seg_t)0)
 Invalid packet segment.
 
#define ODP_PACKET_BUF_INVALID   ((odp_packet_buf_t)0)
 Invalid packet buffer.
 
#define ODP_PACKET_OFFSET_INVALID   0xffff
 Invalid packet offset.
 
#define ODP_PACKET_VECTOR_INVALID   ((odp_packet_vector_t)0)
 Invalid packet vector.
 
#define ODP_PACKET_TX_COMPL_INVALID   ((odp_packet_tx_compl_t)0)
 Invalid packet Tx completion.
 
#define ODP_NUM_PACKET_COLORS   3
 Maximum number of packet colors which accommodates ODP_PACKET_GREEN, ODP_PACKET_YELLOW and ODP_PACKET_RED.
 
#define ODP_PROTO_L2_TYPE_NONE   0
 Layer 2 protocol type not defined.
 
#define ODP_PROTO_L2_TYPE_ETH   1
 Layer 2 protocol is Ethernet.
 
#define ODP_PROTO_L3_TYPE_NONE   0xFFFF
 Layer 3 protocol type not defined.
 
#define ODP_PROTO_L3_TYPE_ARP   0x0806
 Layer 3 protocol is ARP.
 
#define ODP_PROTO_L3_TYPE_RARP   0x8035
 Layer 3 protocol is RARP.
 
#define ODP_PROTO_L3_TYPE_MPLS   0x8847
 Layer 3 protocol is MPLS.
 
#define ODP_PROTO_L3_TYPE_IPV4   0x0800
 Layer 3 protocol type is IPv4.
 
#define ODP_PROTO_L3_TYPE_IPV6   0x86DD
 Layer 3 protocol type is IPv6.
 
#define ODP_PROTO_L4_TYPE_NONE   255
 Layer 4 protocol type not defined.
 
#define ODP_PROTO_L4_TYPE_ICMPV4   1
 Layer 4 protocol type is ICMPv4.
 
#define ODP_PROTO_L4_TYPE_IGMP   2
 Layer 4 protocol type is IGMP.
 
#define ODP_PROTO_L4_TYPE_IPV4   4
 Layer 4 protocol type is IPv4.
 
#define ODP_PROTO_L4_TYPE_TCP   6
 Layer 4 protocol type is TCP.
 
#define ODP_PROTO_L4_TYPE_UDP   17
 Layer 4 protocol type is UDP.
 
#define ODP_PROTO_L4_TYPE_IPV6   41
 Layer 4 protocol type is IPv6.
 
#define ODP_PROTO_L4_TYPE_GRE   47
 Layer 4 protocol type is GRE.
 
#define ODP_PROTO_L4_TYPE_ESP   50
 Layer 4 protocol type is IPSEC ESP.
 
#define ODP_PROTO_L4_TYPE_AH   51
 Layer 4 protocol type is IPSEC AH.
 
#define ODP_PROTO_L4_TYPE_ICMPV6   58
 Layer 4 protocol type is ICMPv6.
 
#define ODP_PROTO_L4_TYPE_NO_NEXT   59
 Layer 4 protocol type is No Next Header for IPv6.
 
#define ODP_PROTO_L4_TYPE_IPCOMP   108
 Layer 4 protocol type is IP Payload Compression Protocol.
 
#define ODP_PROTO_L4_TYPE_SCTP   132
 Layer 4 protocol type is SCTP.
 
#define ODP_PROTO_L4_TYPE_ROHC   142
 Layer 4 protocol type is ROHC.
 
#define ODP_PACKET_TX_COMPL_ALL   ODP_PACKET_TX_COMPL_EVENT
 For backwards compatibility, ODP_PACKET_TX_COMPL_ALL is synonym of ODP_PACKET_TX_COMPL_EVENT. More...
 

Typedefs

typedef _odp_abi_packet_todp_packet_t
 ODP packet.
 
typedef _odp_abi_packet_seg_todp_packet_seg_t
 ODP packet segment. More...
 
typedef _odp_abi_packet_buf_todp_packet_buf_t
 ODP packet buffer. More...
 
typedef _odp_abi_packet_vector_todp_packet_vector_t
 ODP packet vector.
 
typedef _odp_abi_packet_tx_compl_todp_packet_tx_compl_t
 ODP Packet Tx completion.
 
typedef struct odp_packet_parse_result_flag_t odp_packet_parse_result_flag_t
 Parse result flags.
 
typedef uint8_t odp_proto_l2_type_t
 Layer 2 protocol type.
 
typedef uint16_t odp_proto_l3_type_t
 Layer 3 protocol type.
 
typedef uint8_t odp_proto_l4_type_t
 Layer 4 protocol type.
 
typedef enum odp_proto_t odp_proto_t
 Protocol.
 
typedef enum odp_proto_layer_t odp_proto_layer_t
 Protocol layer.
 
typedef struct odp_packet_data_range odp_packet_data_range_t
 Packet API data range specifier.
 
typedef enum odp_packet_reass_status_t odp_packet_reass_status_t
 Reassembly status of a packet.
 
typedef struct odp_packet_reass_info_t odp_packet_reass_info_t
 Information about a completed reassembly.
 
typedef struct odp_packet_reass_partial_state_t odp_packet_reass_partial_state_t
 Result from odp_packet_reass_partial_state()
 
typedef union odp_proto_chksums_t odp_proto_chksums_t
 Flags to control packet data checksum checking.
 
typedef struct odp_packet_parse_param_t odp_packet_parse_param_t
 Packet parse parameters.
 
typedef struct odp_packet_parse_result_t odp_packet_parse_result_t
 Packet parse results.
 
typedef struct odp_packet_lso_opt_t odp_packet_lso_opt_t
 LSO options.
 
typedef enum odp_packet_tx_compl_mode_t odp_packet_tx_compl_mode_t
 Packet transmit completion mode.
 
typedef struct odp_packet_tx_compl_opt_t odp_packet_tx_compl_opt_t
 Packet transmit completion request options.
 
typedef enum odp_packet_free_ctrl_t odp_packet_free_ctrl_t
 Packet free control option.
 
typedef struct odp_packet_proto_stats_opt_t odp_packet_proto_stats_opt_t
 Packet proto stats options.
 

Enumerations

enum  odp_packet_color_t { ODP_PACKET_GREEN = 0 , ODP_PACKET_YELLOW = 1 , ODP_PACKET_RED = 2 , ODP_PACKET_ALL_COLORS = 3 }
 Packet Color. More...
 
enum  odp_packet_chksum_status_t { ODP_PACKET_CHKSUM_UNKNOWN = 0 , ODP_PACKET_CHKSUM_BAD , ODP_PACKET_CHKSUM_OK }
 Packet Checksum Status. More...
 
enum  odp_proto_t { ODP_PROTO_NONE = 0 , ODP_PROTO_ETH , ODP_PROTO_IPV4 , ODP_PROTO_IPV6 }
 Protocol. More...
 
enum  odp_proto_layer_t {
  ODP_PROTO_LAYER_NONE = 0 , ODP_PROTO_LAYER_L2 , ODP_PROTO_LAYER_L3 , ODP_PROTO_LAYER_L4 ,
  ODP_PROTO_LAYER_ALL
}
 Protocol layer. More...
 
enum  odp_packet_reass_status_t { ODP_PACKET_REASS_NONE = 0 , ODP_PACKET_REASS_INCOMPLETE , ODP_PACKET_REASS_COMPLETE }
 Reassembly status of a packet. More...
 
enum  odp_packet_tx_compl_mode_t { ODP_PACKET_TX_COMPL_DISABLED = 0 , ODP_PACKET_TX_COMPL_EVENT , ODP_PACKET_TX_COMPL_POLL }
 Packet transmit completion mode. More...
 
enum  odp_packet_free_ctrl_t { ODP_PACKET_FREE_CTRL_DISABLED = 0 , ODP_PACKET_FREE_CTRL_DONT_FREE }
 Packet free control option. More...
 

Functions

odp_event_subtype_t odp_packet_subtype (odp_packet_t packet)
 Event subtype of a packet. More...
 
odp_packet_t odp_packet_alloc (odp_pool_t pool, uint32_t len)
 Allocate a packet from a packet pool. More...
 
int odp_packet_alloc_multi (odp_pool_t pool, uint32_t len, odp_packet_t pkt[], int num)
 Allocate multiple packets from a packet pool. More...
 
void odp_packet_free (odp_packet_t pkt)
 Free packet. More...
 
void odp_packet_free_multi (const odp_packet_t pkt[], int num)
 Free multiple packets. More...
 
void odp_packet_free_sp (const odp_packet_t pkt[], int num)
 Free multiple packets to the same pool. More...
 
int odp_packet_reset (odp_packet_t pkt, uint32_t len)
 Reset packet. More...
 
uint32_t odp_packet_reset_max_len (odp_packet_t pkt)
 Maximum packet data reset length. More...
 
void odp_packet_reset_meta (odp_packet_t pkt)
 Reset packet metadata. More...
 
odp_packet_t odp_packet_from_event (odp_event_t ev)
 Get packet handle from event. More...
 
void odp_packet_from_event_multi (odp_packet_t pkt[], const odp_event_t ev[], int num)
 Convert multiple packet events to packet handles. More...
 
odp_event_t odp_packet_to_event (odp_packet_t pkt)
 Convert packet handle to event. More...
 
void odp_packet_to_event_multi (const odp_packet_t pkt[], odp_event_t ev[], int num)
 Convert multiple packet handles to events. More...
 
int odp_packet_reass_info (odp_packet_t pkt, odp_packet_reass_info_t *info)
 Get information about successful reassembly offload that has happened. More...
 
int odp_packet_reass_partial_state (odp_packet_t pkt, odp_packet_t frags[], odp_packet_reass_partial_state_t *res)
 Get partial reassembly state from a packet. More...
 
void * odp_packet_head (odp_packet_t pkt)
 Packet head address. More...
 
uint32_t odp_packet_buf_len (odp_packet_t pkt)
 Total packet buffer length. More...
 
void * odp_packet_data (odp_packet_t pkt)
 Packet data pointer. More...
 
uint32_t odp_packet_seg_len (odp_packet_t pkt)
 Packet data length following the data pointer. More...
 
void * odp_packet_data_seg_len (odp_packet_t pkt, uint32_t *seg_len)
 Packet data pointer with segment length. More...
 
uint32_t odp_packet_len (odp_packet_t pkt)
 Packet data length. More...
 
uint32_t odp_packet_headroom (odp_packet_t pkt)
 Packet headroom length. More...
 
uint32_t odp_packet_tailroom (odp_packet_t pkt)
 Packet tailroom length. More...
 
void * odp_packet_tail (odp_packet_t pkt)
 Packet tailroom pointer. More...
 
void * odp_packet_offset (odp_packet_t pkt, uint32_t offset, uint32_t *len, odp_packet_seg_t *seg)
 Packet offset pointer. More...
 
void odp_packet_prefetch (odp_packet_t pkt, uint32_t offset, uint32_t len)
 Packet data prefetch. More...
 
void * odp_packet_push_head (odp_packet_t pkt, uint32_t len)
 Push out packet head. More...
 
void * odp_packet_pull_head (odp_packet_t pkt, uint32_t len)
 Pull in packet head. More...
 
void * odp_packet_push_tail (odp_packet_t pkt, uint32_t len)
 Push out packet tail. More...
 
void * odp_packet_pull_tail (odp_packet_t pkt, uint32_t len)
 Pull in packet tail. More...
 
int odp_packet_extend_head (odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len)
 Extend packet head. More...
 
int odp_packet_trunc_head (odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len)
 Truncate packet head. More...
 
int odp_packet_extend_tail (odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len)
 Extend packet tail. More...
 
int odp_packet_trunc_tail (odp_packet_t *pkt, uint32_t len, void **tail_ptr, uint32_t *tailroom)
 Truncate packet tail. More...
 
int odp_packet_add_data (odp_packet_t *pkt, uint32_t offset, uint32_t len)
 Add data into an offset. More...
 
int odp_packet_rem_data (odp_packet_t *pkt, uint32_t offset, uint32_t len)
 Remove data from an offset. More...
 
int odp_packet_align (odp_packet_t *pkt, uint32_t offset, uint32_t len, uint32_t align)
 Align packet data. More...
 
int odp_packet_is_segmented (odp_packet_t pkt)
 Tests if packet is segmented. More...
 
int odp_packet_num_segs (odp_packet_t pkt)
 Number of segments. More...
 
odp_packet_seg_t odp_packet_first_seg (odp_packet_t pkt)
 First segment in packet. More...
 
odp_packet_seg_t odp_packet_last_seg (odp_packet_t pkt)
 Last segment in packet. More...
 
odp_packet_seg_t odp_packet_next_seg (odp_packet_t pkt, odp_packet_seg_t seg)
 Next segment in packet. More...
 
void * odp_packet_seg_data (odp_packet_t pkt, odp_packet_seg_t seg)
 Segment data pointer. More...
 
uint32_t odp_packet_seg_data_len (odp_packet_t pkt, odp_packet_seg_t seg)
 Segment data length. More...
 
int odp_packet_concat (odp_packet_t *dst, odp_packet_t src)
 Concatenate two packets. More...
 
int odp_packet_split (odp_packet_t *pkt, uint32_t len, odp_packet_t *tail)
 Split packet into two packets. More...
 
void * odp_packet_buf_head (odp_packet_buf_t pkt_buf)
 Packet buffer head pointer. More...
 
uint32_t odp_packet_buf_size (odp_packet_buf_t pkt_buf)
 Packet buffer size in bytes. More...
 
uint32_t odp_packet_buf_data_offset (odp_packet_buf_t pkt_buf)
 Packet buffer data offset. More...
 
uint32_t odp_packet_buf_data_len (odp_packet_buf_t pkt_buf)
 Packet buffer data length in bytes. More...
 
void odp_packet_buf_data_set (odp_packet_buf_t pkt_buf, uint32_t data_offset, uint32_t data_len)
 Packet buffer data set. More...
 
odp_packet_buf_t odp_packet_buf_from_head (odp_pool_t pool, void *head)
 Convert packet buffer head pointer to handle. More...
 
uint32_t odp_packet_disassemble (odp_packet_t pkt, odp_packet_buf_t pkt_buf[], uint32_t num)
 Disassemble packet into packet buffers. More...
 
odp_packet_t odp_packet_reassemble (odp_pool_t pool, odp_packet_buf_t pkt_buf[], uint32_t num)
 Reassemble packet from packet buffers. More...
 
odp_packet_t odp_packet_ref_static (odp_packet_t pkt)
 Create a static reference to a packet. More...
 
odp_packet_t odp_packet_ref (odp_packet_t pkt, uint32_t offset)
 Create a reference to a packet. More...
 
odp_packet_t odp_packet_ref_pkt (odp_packet_t pkt, uint32_t offset, odp_packet_t hdr)
 Create a reference to a packet with a header packet. More...
 
int odp_packet_has_ref (odp_packet_t pkt)
 Test if packet has multiple references. More...
 
odp_packet_t odp_packet_copy (odp_packet_t pkt, odp_pool_t pool)
 Full copy of a packet. More...
 
odp_packet_t odp_packet_copy_part (odp_packet_t pkt, uint32_t offset, uint32_t len, odp_pool_t pool)
 Partial copy of a packet. More...
 
int odp_packet_copy_to_mem (odp_packet_t pkt, uint32_t offset, uint32_t len, void *dst)
 Copy data from packet to memory. More...
 
int odp_packet_copy_from_mem (odp_packet_t pkt, uint32_t offset, uint32_t len, const void *src)
 Copy data from memory to packet. More...
 
int odp_packet_copy_from_pkt (odp_packet_t dst, uint32_t dst_offset, odp_packet_t src, uint32_t src_offset, uint32_t len)
 Copy data from another packet. More...
 
int odp_packet_copy_data (odp_packet_t pkt, uint32_t dst_offset, uint32_t src_offset, uint32_t len)
 Copy data within packet. More...
 
int odp_packet_move_data (odp_packet_t pkt, uint32_t dst_offset, uint32_t src_offset, uint32_t len)
 Move data within packet. More...
 
int odp_packet_parse (odp_packet_t pkt, uint32_t offset, const odp_packet_parse_param_t *param)
 Parse packet. More...
 
int odp_packet_parse_multi (const odp_packet_t pkt[], const uint32_t offset[], int num, const odp_packet_parse_param_t *param)
 Parse multiple packets. More...
 
void odp_packet_parse_result (odp_packet_t pkt, odp_packet_parse_result_t *result)
 Read parse results. More...
 
void odp_packet_parse_result_multi (const odp_packet_t pkt[], odp_packet_parse_result_t *result[], int num)
 Read parse results from multiple packets. More...
 
odp_pool_t odp_packet_pool (odp_packet_t pkt)
 Packet pool. More...
 
odp_pktio_t odp_packet_input (odp_packet_t pkt)
 Packet input interface. More...
 
void odp_packet_input_set (odp_packet_t pkt, odp_pktio_t pktio)
 Set packet input interface. More...
 
int odp_packet_input_index (odp_packet_t pkt)
 Packet input interface index. More...
 
void * odp_packet_user_ptr (odp_packet_t pkt)
 User context pointer. More...
 
void odp_packet_user_ptr_set (odp_packet_t pkt, const void *user_ptr)
 Set user context pointer. More...
 
void * odp_packet_user_area (odp_packet_t pkt)
 User area address. More...
 
uint32_t odp_packet_user_area_size (odp_packet_t pkt)
 User area size. More...
 
int odp_packet_user_flag (odp_packet_t pkt)
 Check user flag. More...
 
void odp_packet_user_flag_set (odp_packet_t pkt, int val)
 Set user flag. More...
 
void * odp_packet_l2_ptr (odp_packet_t pkt, uint32_t *len)
 Layer 2 start pointer. More...
 
uint32_t odp_packet_l2_offset (odp_packet_t pkt)
 Layer 2 start offset. More...
 
int odp_packet_l2_offset_set (odp_packet_t pkt, uint32_t offset)
 Set layer 2 start offset. More...
 
void * odp_packet_l3_ptr (odp_packet_t pkt, uint32_t *len)
 Layer 3 start pointer. More...
 
uint32_t odp_packet_l3_offset (odp_packet_t pkt)
 Layer 3 start offset. More...
 
int odp_packet_l3_offset_set (odp_packet_t pkt, uint32_t offset)
 Set layer 3 start offset. More...
 
void * odp_packet_l4_ptr (odp_packet_t pkt, uint32_t *len)
 Layer 4 start pointer. More...
 
uint32_t odp_packet_l4_offset (odp_packet_t pkt)
 Layer 4 start offset. More...
 
int odp_packet_l4_offset_set (odp_packet_t pkt, uint32_t offset)
 Set layer 4 start offset. More...
 
odp_proto_l2_type_t odp_packet_l2_type (odp_packet_t pkt)
 Layer 2 protocol type. More...
 
odp_proto_l3_type_t odp_packet_l3_type (odp_packet_t pkt)
 Layer 3 protocol type. More...
 
odp_proto_l4_type_t odp_packet_l4_type (odp_packet_t pkt)
 Layer 4 protocol type. More...
 
odp_packet_chksum_status_t odp_packet_l3_chksum_status (odp_packet_t pkt)
 Layer 3 checksum check status. More...
 
odp_packet_chksum_status_t odp_packet_l4_chksum_status (odp_packet_t pkt)
 Layer 4 checksum check status. More...
 
void odp_packet_l3_chksum_insert (odp_packet_t pkt, int insert)
 Layer 3 checksum insertion override. More...
 
void odp_packet_l4_chksum_insert (odp_packet_t pkt, int insert)
 Layer 4 checksum insertion override. More...
 
uint16_t odp_packet_ones_comp (odp_packet_t pkt, odp_packet_data_range_t *range)
 Ones' complement sum of packet data. More...
 
uint32_t odp_packet_flow_hash (odp_packet_t pkt)
 Packet flow hash value. More...
 
void odp_packet_flow_hash_set (odp_packet_t pkt, uint32_t flow_hash)
 Set packet flow hash value. More...
 
odp_time_t odp_packet_ts (odp_packet_t pkt)
 Packet timestamp. More...
 
void odp_packet_ts_set (odp_packet_t pkt, odp_time_t timestamp)
 Set packet timestamp. More...
 
void odp_packet_ts_request (odp_packet_t pkt, int enable)
 Request Tx timestamp capture. More...
 
odp_packet_color_t odp_packet_color (odp_packet_t pkt)
 Get packet color. More...
 
void odp_packet_color_set (odp_packet_t pkt, odp_packet_color_t color)
 Set packet color. More...
 
odp_bool_t odp_packet_drop_eligible (odp_packet_t pkt)
 Get drop eligible status. More...
 
void odp_packet_drop_eligible_set (odp_packet_t pkt, odp_bool_t status)
 Set drop eligible status. More...
 
int8_t odp_packet_shaper_len_adjust (odp_packet_t pkt)
 Get shaper length adjustment. More...
 
void odp_packet_shaper_len_adjust_set (odp_packet_t pkt, int8_t adj)
 Set shaper length adjustment. More...
 
uint64_t odp_packet_cls_mark (odp_packet_t pkt)
 Classification mark value. More...
 
int odp_packet_lso_request (odp_packet_t pkt, const odp_packet_lso_opt_t *lso_opt)
 Request Large Send Offload (LSO) for a packet. More...
 
void odp_packet_lso_request_clr (odp_packet_t pkt)
 Clear LSO request from a packet. More...
 
int odp_packet_has_lso_request (odp_packet_t pkt)
 Check if LSO is requested for the packet. More...
 
uint32_t odp_packet_payload_offset (odp_packet_t pkt)
 Payload data offset. More...
 
int odp_packet_payload_offset_set (odp_packet_t pkt, uint32_t offset)
 Set payload data start offset. More...
 
void odp_packet_aging_tmo_set (odp_packet_t pkt, uint64_t tmo_ns)
 Enable or disable Tx packet aging. More...
 
uint64_t odp_packet_aging_tmo (odp_packet_t pkt)
 Check if packet has Tx aging drop enabled. More...
 
int odp_packet_tx_compl_request (odp_packet_t pkt, const odp_packet_tx_compl_opt_t *opt)
 Request packet transmit completion. More...
 
int odp_packet_has_tx_compl_request (odp_packet_t pkt)
 Check if packet transmit completion is requested. More...
 
void odp_packet_free_ctrl_set (odp_packet_t pkt, odp_packet_free_ctrl_t ctrl)
 Set packet free control option. More...
 
odp_packet_free_ctrl_t odp_packet_free_ctrl (odp_packet_t pkt)
 Returns packet free control option value. More...
 
void odp_packet_proto_stats_request (odp_packet_t pkt, odp_packet_proto_stats_opt_t *opt)
 Request packet proto stats. More...
 
odp_proto_stats_t odp_packet_proto_stats (odp_packet_t pkt)
 Get proto stats object. More...
 
odp_packet_vector_t odp_packet_vector_from_event (odp_event_t ev)
 Get packet vector handle from event. More...
 
odp_event_t odp_packet_vector_to_event (odp_packet_vector_t pktv)
 Convert packet vector handle to event. More...
 
odp_packet_vector_t odp_packet_vector_alloc (odp_pool_t pool)
 Allocate a packet vector from a packet vector pool. More...
 
void odp_packet_vector_free (odp_packet_vector_t pktv)
 Free packet vector. More...
 
uint32_t odp_packet_vector_tbl (odp_packet_vector_t pktv, odp_packet_t **pkt_tbl)
 Get packet vector table. More...
 
uint32_t odp_packet_vector_size (odp_packet_vector_t pktv)
 Number of packets in a vector. More...
 
void odp_packet_vector_size_set (odp_packet_vector_t pktv, uint32_t size)
 Set the number of packets stored in a vector. More...
 
void * odp_packet_vector_user_area (odp_packet_vector_t pktv)
 Packet vector user area. More...
 
int odp_packet_vector_user_flag (odp_packet_vector_t pktv)
 Check user flag. More...
 
void odp_packet_vector_user_flag_set (odp_packet_vector_t pktv, int val)
 Set user flag. More...
 
int odp_packet_vector_valid (odp_packet_vector_t pktv)
 Check that packet vector is valid. More...
 
odp_pool_t odp_packet_vector_pool (odp_packet_vector_t pktv)
 Packet vector pool. More...
 
void odp_packet_vector_print (odp_packet_vector_t pktv)
 Print packet vector debug information. More...
 
uint64_t odp_packet_vector_to_u64 (odp_packet_vector_t hdl)
 Get printable value for an odp_packet_vector_t. More...
 
odp_packet_reass_status_t odp_packet_reass_status (odp_packet_t pkt)
 Check reassembly status of the packet. More...
 
odp_packet_tx_compl_t odp_packet_tx_compl_from_event (odp_event_t ev)
 Get packet Tx completion handle from event. More...
 
odp_event_t odp_packet_tx_compl_to_event (odp_packet_tx_compl_t tx_compl)
 Convert packet Tx completion to event. More...
 
void odp_packet_tx_compl_free (odp_packet_tx_compl_t tx_compl)
 Free packet Tx completion. More...
 
void * odp_packet_tx_compl_user_ptr (odp_packet_tx_compl_t tx_compl)
 User context pointer. More...
 
int odp_packet_tx_compl_done (odp_pktio_t pktio, uint32_t compl_id)
 Check packet transmit completion. More...
 
void odp_packet_print (odp_packet_t pkt)
 Print packet debug information. More...
 
void odp_packet_print_data (odp_packet_t pkt, uint32_t offset, uint32_t len)
 Print packet data. More...
 
int odp_packet_is_valid (odp_packet_t pkt)
 Check that packet is valid. More...
 
uint64_t odp_packet_to_u64 (odp_packet_t hdl)
 Get printable value for an odp_packet_t. More...
 
uint64_t odp_packet_seg_to_u64 (odp_packet_seg_t hdl)
 Get printable value for an odp_packet_seg_t. More...
 
int odp_packet_has_error (odp_packet_t pkt)
 Check for all parse errors in packet. More...
 
int odp_packet_has_l2_error (odp_packet_t pkt)
 Check for errors in layer 2. More...
 
int odp_packet_has_l3_error (odp_packet_t pkt)
 Check for errors in layer 3. More...
 
int odp_packet_has_l4_error (odp_packet_t pkt)
 Check for errors in layer 4. More...
 
int odp_packet_has_l2 (odp_packet_t pkt)
 Check for layer 2 protocols. More...
 
int odp_packet_has_l3 (odp_packet_t pkt)
 Check for layer 3 protocols. More...
 
int odp_packet_has_l4 (odp_packet_t pkt)
 Check for layer 4 protocols. More...
 
int odp_packet_has_eth (odp_packet_t pkt)
 Check for Ethernet header. More...
 
int odp_packet_has_eth_bcast (odp_packet_t pkt)
 Check for Ethernet broadcast address. More...
 
int odp_packet_has_eth_mcast (odp_packet_t pkt)
 Check for Ethernet multicast address. More...
 
int odp_packet_has_jumbo (odp_packet_t pkt)
 Check for jumbo frame. More...
 
int odp_packet_has_vlan (odp_packet_t pkt)
 Check for VLAN. More...
 
int odp_packet_has_vlan_qinq (odp_packet_t pkt)
 Check for VLAN QinQ (stacked VLAN) More...
 
int odp_packet_has_arp (odp_packet_t pkt)
 Check for ARP. More...
 
int odp_packet_has_ipv4 (odp_packet_t pkt)
 Check for IPv4. More...
 
int odp_packet_has_ipv6 (odp_packet_t pkt)
 Check for IPv6. More...
 
int odp_packet_has_ip_bcast (odp_packet_t pkt)
 Check for IP broadcast address. More...
 
int odp_packet_has_ip_mcast (odp_packet_t pkt)
 Check for IP multicast address. More...
 
int odp_packet_has_ipfrag (odp_packet_t pkt)
 Check for IP fragment. More...
 
int odp_packet_has_ipopt (odp_packet_t pkt)
 Check for IP options. More...
 
int odp_packet_has_ipsec (odp_packet_t pkt)
 Check for IPSec. More...
 
int odp_packet_has_udp (odp_packet_t pkt)
 Check for UDP. More...
 
int odp_packet_has_tcp (odp_packet_t pkt)
 Check for TCP. More...
 
int odp_packet_has_sctp (odp_packet_t pkt)
 Check for SCTP. More...
 
int odp_packet_has_icmp (odp_packet_t pkt)
 Check for ICMP. More...
 
int odp_packet_has_flow_hash (odp_packet_t pkt)
 Check for packet flow hash. More...
 
int odp_packet_has_ts (odp_packet_t pkt)
 Check for packet timestamp. More...
 
void odp_packet_has_l2_set (odp_packet_t pkt, int val)
 Set flag for L2 header, e.g. More...
 
void odp_packet_has_l3_set (odp_packet_t pkt, int val)
 Set flag for L3 header, e.g. More...
 
void odp_packet_has_l4_set (odp_packet_t pkt, int val)
 Set flag for L4 header, e.g. More...
 
void odp_packet_has_eth_set (odp_packet_t pkt, int val)
 Set flag for Ethernet header. More...
 
void odp_packet_has_eth_bcast_set (odp_packet_t pkt, int val)
 Set flag for Ethernet broadcast address. More...
 
void odp_packet_has_eth_mcast_set (odp_packet_t pkt, int val)
 Set flag for Ethernet multicast address. More...
 
void odp_packet_has_jumbo_set (odp_packet_t pkt, int val)
 Set flag for jumbo frame. More...
 
void odp_packet_has_vlan_set (odp_packet_t pkt, int val)
 Set flag for VLAN. More...
 
void odp_packet_has_vlan_qinq_set (odp_packet_t pkt, int val)
 Set flag for VLAN QinQ (stacked VLAN) More...
 
void odp_packet_has_arp_set (odp_packet_t pkt, int val)
 Set flag for ARP. More...
 
void odp_packet_has_ipv4_set (odp_packet_t pkt, int val)
 Set flag for IPv4. More...
 
void odp_packet_has_ipv6_set (odp_packet_t pkt, int val)
 Set flag for IPv6. More...
 
void odp_packet_has_ip_bcast_set (odp_packet_t pkt, int val)
 Set flag for IP broadcast address. More...
 
void odp_packet_has_ip_mcast_set (odp_packet_t pkt, int val)
 Set flag for IP multicast address. More...
 
void odp_packet_has_ipfrag_set (odp_packet_t pkt, int val)
 Set flag for IP fragment. More...
 
void odp_packet_has_ipopt_set (odp_packet_t pkt, int val)
 Set flag for IP options. More...
 
void odp_packet_has_ipsec_set (odp_packet_t pkt, int val)
 Set flag for IPSec. More...
 
void odp_packet_has_udp_set (odp_packet_t pkt, int val)
 Set flag for UDP. More...
 
void odp_packet_has_tcp_set (odp_packet_t pkt, int val)
 Set flag for TCP. More...
 
void odp_packet_has_sctp_set (odp_packet_t pkt, int val)
 Set flag for SCTP. More...
 
void odp_packet_has_icmp_set (odp_packet_t pkt, int val)
 Set flag for ICMP. More...
 
void odp_packet_has_flow_hash_clr (odp_packet_t pkt)
 Clear flag for packet flow hash. More...
 
void odp_packet_has_ts_clr (odp_packet_t pkt)
 Clear flag for packet timestamp. More...
 

Macro Definition Documentation

◆ ODP_PACKET_TX_COMPL_ALL

#define ODP_PACKET_TX_COMPL_ALL   ODP_PACKET_TX_COMPL_EVENT

For backwards compatibility, ODP_PACKET_TX_COMPL_ALL is synonym of ODP_PACKET_TX_COMPL_EVENT.

Deprecated:
Use ODP_PACKET_TX_COMPL_EVENT instead.

Definition at line 446 of file api/spec/packet_types.h.

Typedef Documentation

◆ odp_packet_seg_t

ODP packet segment.

A packet segment refers to a contiguous part of packet data (in memory). Segments of a packet can be examined with odp_packet_seg_data(), odp_packet_seg_data_len() and other calls.

Definition at line 35 of file api/abi-default/packet_types.h.

◆ odp_packet_buf_t

ODP packet buffer.

Packet buffers are not part of any packet, but they result from a previous odp_packet_disassemble() call. A new packet is formed from packet buffers with a odp_packet_reassemble() call.

Definition at line 36 of file api/abi-default/packet_types.h.

Enumeration Type Documentation

◆ odp_packet_color_t

Packet Color.

Color of packet for shaper/drop processing.

Enumerator
ODP_PACKET_GREEN 

Packet is green.

ODP_PACKET_YELLOW 

Packet is yellow.

ODP_PACKET_RED 

Packet is red.

Definition at line 48 of file api/abi-default/packet_types.h.

◆ odp_packet_chksum_status_t

Packet Checksum Status.

Checksum check status in packet.

Enumerator
ODP_PACKET_CHKSUM_UNKNOWN 

Checksum was not checked.

Checksum check was not attempted or the attempt failed.

ODP_PACKET_CHKSUM_BAD 

Checksum was checked and it was not correct.

ODP_PACKET_CHKSUM_OK 

Checksum was checked and it was correct.

Definition at line 56 of file api/abi-default/packet_types.h.

◆ odp_proto_t

Protocol.

Enumerator
ODP_PROTO_NONE 

No protocol defined.

ODP_PROTO_ETH 

Ethernet (including VLAN)

ODP_PROTO_IPV4 

IP version 4.

ODP_PROTO_IPV6 

IP version 6.

Definition at line 215 of file api/spec/packet_types.h.

◆ odp_proto_layer_t

Protocol layer.

Enumerator
ODP_PROTO_LAYER_NONE 

No layers.

ODP_PROTO_LAYER_L2 

Layer L2 protocols (Ethernet, VLAN, etc)

ODP_PROTO_LAYER_L3 

Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc)

ODP_PROTO_LAYER_L4 

Layer L4 protocols (UDP, TCP, SCTP)

ODP_PROTO_LAYER_ALL 

All layers.

Definition at line 233 of file api/spec/packet_types.h.

◆ odp_packet_reass_status_t

Reassembly status of a packet.

Enumerator
ODP_PACKET_REASS_NONE 

Reassembly was not attempted.

ODP_PACKET_REASS_INCOMPLETE 

Reassembly was attempted but is incomplete.

Partial reassembly result can be accessed using odp_packet_reass_partial_state().

The packet does not contain valid packet data and cannot be used in normal packet operations.

ODP_PACKET_REASS_COMPLETE 

Reassembly was successfully done.

The packet has been reassembled from multiple received fragments.

Definition at line 266 of file api/spec/packet_types.h.

◆ odp_packet_tx_compl_mode_t

Packet transmit completion mode.

Enumerator
ODP_PACKET_TX_COMPL_DISABLED 

Disable packet transmit completion.

ODP_PACKET_TX_COMPL_EVENT 

Enable packet transmit completion event.

A packet transmit completion event is sent for both transmitted and dropped packets.

ODP_PACKET_TX_COMPL_POLL 

Enable packet transmit completion check through polling.

Packet transmit completion status is updated for both transmitted and dropped packets.

Definition at line 421 of file api/spec/packet_types.h.

◆ odp_packet_free_ctrl_t

Packet free control option.

Enumerator
ODP_PACKET_FREE_CTRL_DISABLED 

Packet free control disabled.

ODP_PACKET_FREE_CTRL_DONT_FREE 

Don't free packet after processing it.

Definition at line 490 of file api/spec/packet_types.h.

Function Documentation

◆ odp_packet_subtype()

odp_event_subtype_t odp_packet_subtype ( odp_packet_t  packet)

Event subtype of a packet.

Returns the subtype of a packet event. Subtype tells if the packet contains only basic metadata (ODP_EVENT_PACKET_BASIC) or in addition to that some specific metadata (e.g. ODP_EVENT_PACKET_CRYPTO or ODP_EVENT_PACKET_IPSEC).

Parameters
packetPacket handle
Returns
Packet subtype
Examples
odp_bench_packet.c.

◆ odp_packet_alloc()

odp_packet_t odp_packet_alloc ( odp_pool_t  pool,
uint32_t  len 
)

Allocate a packet from a packet pool.

Allocates a packet of the requested length from the specified packet pool. The pool must have been created with ODP_POOL_PACKET type. The packet is initialized with data pointers and lengths set according to the specified len, and the default headroom and tailroom length settings. All other packet metadata are set to their default values. Packet length must be greater than zero and not exceed packet pool parameter 'max_len' value.

Parameters
poolPool handle
lenPacket data length (1 ... pool max_len)
Returns
Handle of allocated packet
Return values
ODP_PACKET_INVALIDPacket could not be allocated
Note
The minimum headroom and tailroom used for packets is specified by pool capabilities min_headroom and min_tailroom.
Examples
odp_bench_packet.c, odp_cpu_bench.c, odp_crypto.c, odp_debug.c, odp_dma_perf.c, odp_dmafwd.c, odp_packet_gen.c, odp_pktio_perf.c, odp_sched_perf.c, and odp_traffic_mgmt.c.

◆ odp_packet_alloc_multi()

int odp_packet_alloc_multi ( odp_pool_t  pool,
uint32_t  len,
odp_packet_t  pkt[],
int  num 
)

Allocate multiple packets from a packet pool.

Otherwise like odp_packet_alloc(), but allocates multiple packets from a pool.

Parameters
poolPool handle
lenPacket data length (1 ... pool max_len)
[out]pktArray of packet handles for output
numMaximum number of packets to allocate
Returns
Number of packets actually allocated (0 ... num)
Return values
<0on failure
Examples
odp_bench_packet.c, odp_ipsec.c, odp_pool_latency.c, and odp_pool_perf.c.

◆ odp_packet_free()

◆ odp_packet_free_multi()

void odp_packet_free_multi ( const odp_packet_t  pkt[],
int  num 
)

Free multiple packets.

Otherwise like odp_packet_free(), but frees multiple packets to their originating pools.

Parameters
pktArray of packet handles
numNumber of packet handles to free
Examples
odp_bench_packet.c, odp_classifier.c, odp_dmafwd.c, odp_ipsecfwd.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_packet_gen.c, odp_pktio_perf.c, odp_pool_latency.c, odp_pool_perf.c, odp_sched_pktio.c, and odp_simple_pipeline.c.

◆ odp_packet_free_sp()

void odp_packet_free_sp ( const odp_packet_t  pkt[],
int  num 
)

Free multiple packets to the same pool.

Otherwise like odp_packet_free_multi(), but all packets must be from the same originating pool.

Parameters
pktArray of packet handles
numNumber of packets to free
Examples
odp_bench_packet.c, and odp_ipsec.c.

◆ odp_packet_reset()

int odp_packet_reset ( odp_packet_t  pkt,
uint32_t  len 
)

Reset packet.

Resets all packet metadata and adjusts packet data to start according to pool parameters (align, seg_len, headroom). Packet data length is set to 'len'. Maximum value for 'len' can be queried with odp_packet_reset_max_len() function. Passing larger 'len' than the maximum value is allowed, but will cause failure to be returned.

Packet reset maintains the original user area content. The operation may change data layout in packet segments and free possible extra segments. Data content may not be preserved. Packet is not modified on failure.

This function must not be called for packets with references or incomplete reassembly status (ODP_PACKET_REASS_INCOMPLETE).

Parameters
pktPacket handle
lenPacket data length (1 ... odp_packet_reset_max_len())
Return values
0on success
<0on failure
Examples
odp_bench_packet.c.

◆ odp_packet_reset_max_len()

uint32_t odp_packet_reset_max_len ( odp_packet_t  pkt)

Maximum packet data reset length.

Returns the maximum packet data reset length for odp_packet_reset() based on current packet buffer space and pool parameters (align, seg_len, headroom).

Parameters
pktPacket handle
Returns
Maximum packet data length for odp_packet_reset()
Examples
odp_bench_packet.c.

◆ odp_packet_reset_meta()

void odp_packet_reset_meta ( odp_packet_t  pkt)

Reset packet metadata.

Resets all packet metadata to their default values, except the ones listed below which are not modified:

  • Data pointer and length
  • Headroom and tailroom pointers and lengths
  • Packet segmentation
  • User area content
  • Dynamic reference count

This function must not be called for packets with static references or incomplete reassembly status (ODP_PACKET_REASS_INCOMPLETE).

Parameters
pktPacket handle
Examples
odp_bench_packet.c.

◆ odp_packet_from_event()

odp_packet_t odp_packet_from_event ( odp_event_t  ev)

Get packet handle from event.

Converts an ODP_EVENT_PACKET type event to a packet.

Parameters
evEvent handle
Returns
Packet handle
See also
odp_event_type()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, odp_cpu_bench.c, odp_dmafwd.c, odp_ipfragreass.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_packet_dump.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_perf.c, odp_sched_pktio.c, and odp_simple_pipeline.c.

◆ odp_packet_from_event_multi()

void odp_packet_from_event_multi ( odp_packet_t  pkt[],
const odp_event_t  ev[],
int  num 
)

Convert multiple packet events to packet handles.

All events must be of type ODP_EVENT_PACKET.

Parameters
[out]pktPacket handle array for output
evArray of event handles to convert
numNumber of packets and events
Examples
odp_bench_packet.c, odp_classifier.c, odp_l2fwd.c, odp_packet_gen.c, odp_sched_pktio.c, and odp_simple_pipeline.c.

◆ odp_packet_to_event()

odp_event_t odp_packet_to_event ( odp_packet_t  pkt)

Convert packet handle to event.

Parameters
pktPacket handle
Returns
Event handle
Examples
odp_bench_packet.c, odp_cpu_bench.c, odp_ipfragreass.c, odp_sched_perf.c, and odp_simple_pipeline.c.

◆ odp_packet_to_event_multi()

void odp_packet_to_event_multi ( const odp_packet_t  pkt[],
odp_event_t  ev[],
int  num 
)

Convert multiple packet handles to events.

Parameters
pktArray of packet handles to convert
[out]evEvent handle array for output
numNumber of packets and events
Examples
odp_bench_packet.c, odp_ipsecfwd.c, odp_l2fwd.c, and odp_simple_pipeline.c.

◆ odp_packet_reass_info()

int odp_packet_reass_info ( odp_packet_t  pkt,
odp_packet_reass_info_t info 
)

Get information about successful reassembly offload that has happened.

This function may be called only if the reassembly status of a packet is ODP_PACKET_REASS_COMPLETE.

Parameters
pktCompletely reassembled packet.
[out]infoPointer to the info structure to be filled
Return values
0on success
<0on failure

◆ odp_packet_reass_partial_state()

int odp_packet_reass_partial_state ( odp_packet_t  pkt,
odp_packet_t  frags[],
odp_packet_reass_partial_state_t res 
)

Get partial reassembly state from a packet.

In case of incomplete reassembly, a packet carries information on the time already used for the reassembly attempt and one or more fragments. The fragments are not necessarily the original received fragments but may be partially reassembled parts of the packet.

This function may be called only if the reassembly status of a packet is ODP_PACKET_REASS_INCOMPLETE.

Parameters
pktIncompletely reassembled packet. The packet will be consumed if the function succeeds.
[out]fragsPacket handle array for output. The size of this array must be at least odp_reass_config_t::max_num_frags.
[out]resPointer to result structure
Return values
0on success
<0on failure

◆ odp_packet_head()

void* odp_packet_head ( odp_packet_t  pkt)

Packet head address.

Returns start address of the first segment. Packet level headroom starts from here. Use odp_packet_data() or odp_packet_l2_ptr() to return the packet data start address.

Parameters
pktPacket handle
Returns
Pointer to the start address of the first packet segment
See also
odp_packet_data(), odp_packet_l2_ptr(), odp_packet_headroom()
Examples
odp_bench_packet.c.

◆ odp_packet_buf_len()

uint32_t odp_packet_buf_len ( odp_packet_t  pkt)

Total packet buffer length.

Returns sum of buffer lengths over all packet segments. Buffer length includes headroom, data, and tailroom lengths.

Parameters
pktPacket handle
Returns
Total packet buffer length in bytes
Examples
odp_bench_packet.c.

◆ odp_packet_data()

void* odp_packet_data ( odp_packet_t  pkt)

Packet data pointer.

Returns pointer to the first byte of packet data. When packet is segmented, only a portion of packet data follows the pointer. When unsure, use e.g. odp_packet_seg_len() to check the data length following the pointer. Packet level offsets are calculated relative to this position.

When a packet is received from packet input, this points to the first byte of the received packet. Pool configuration parameters may be used to ensure that the first packet segment contains all/most of the data relevant to the application.

User can adjust the data pointer with e.g. push_head/pull_head (does not modify segmentation) and extend_head/trunc_head (may modify segmentation) calls.

Parameters
pktPacket handle
Returns
Pointer to the packet data
See also
odp_packet_seg_len(), odp_packet_push_head(), odp_packet_extend_head()
Examples
ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, odp_cpu_bench.c, odp_crypto.c, odp_dma_perf.c, odp_ipfragreass.c, odp_ipsec.c, odp_l2fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_pktio_perf.c, odp_sched_perf.c, odp_sched_pktio.c, and odp_simple_pipeline.c.

◆ odp_packet_seg_len()

uint32_t odp_packet_seg_len ( odp_packet_t  pkt)

Packet data length following the data pointer.

Returns number of data bytes (in the segment) following the current data pointer position. When unsure, use this function to check how many bytes can be accessed linearly after data pointer (odp_packet_data()). This equals to odp_packet_len() for single segment packets.

Parameters
pktPacket handle
Returns
Segment data length in bytes following odp_packet_data()
See also
odp_packet_data()
Examples
odp_bench_packet.c, odp_l2fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, odp_pktio_ordered.c, odp_sched_perf.c, and odp_simple_pipeline.c.

◆ odp_packet_data_seg_len()

void* odp_packet_data_seg_len ( odp_packet_t  pkt,
uint32_t *  seg_len 
)

Packet data pointer with segment length.

Returns both data pointer and number of data bytes (in the segment) following it. This is equivalent to calling odp_packet_data() and odp_packet_seg_len().

Parameters
pktPacket handle
[out]seg_lenPointer to output segment length
Returns
Pointer to the packet data
See also
odp_packet_data(), odp_packet_seg_len()
Examples
odp_bench_packet.c.

◆ odp_packet_len()

uint32_t odp_packet_len ( odp_packet_t  pkt)

Packet data length.

Returns total data length over all packet segments. This equals the sum of segment level data lengths (odp_packet_seg_data_len()).

Parameters
pktPacket handle
Returns
Packet data length
See also
odp_packet_seg_len(), odp_packet_data(), odp_packet_seg_data_len()
Examples
odp_bench_packet.c, odp_classifier.c, odp_cpu_bench.c, odp_dmafwd.c, odp_ipfragreass.c, odp_ipsec.c, odp_l2fwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, and odp_pktio_ordered.c.

◆ odp_packet_headroom()

uint32_t odp_packet_headroom ( odp_packet_t  pkt)

Packet headroom length.

Returns the current packet level headroom length.

Parameters
pktPacket handle
Returns
Headroom length
Examples
odp_bench_packet.c, and odp_l2fwd.c.

◆ odp_packet_tailroom()

uint32_t odp_packet_tailroom ( odp_packet_t  pkt)

Packet tailroom length.

Returns the current packet level tailroom length.

Parameters
pktPacket handle
Returns
Tailroom length
Examples
odp_bench_packet.c.

◆ odp_packet_tail()

void* odp_packet_tail ( odp_packet_t  pkt)

Packet tailroom pointer.

Returns pointer to the start of the current packet level tailroom.

User can adjust the tail pointer with tail_push/tail_pull (does not modify segmentation) and add_data/rem_data calls (may modify segmentation).

Parameters
pktPacket handle
Returns
Tailroom pointer
See also
odp_packet_tailroom()
Examples
odp_bench_packet.c.

◆ odp_packet_offset()

void* odp_packet_offset ( odp_packet_t  pkt,
uint32_t  offset,
uint32_t *  len,
odp_packet_seg_t seg 
)

Packet offset pointer.

Returns pointer to data in the packet offset. The packet level byte offset is calculated from the current odp_packet_data() position. Optionally outputs handle to the segment and number of data bytes in the segment following the pointer.

Parameters
pktPacket handle
offsetByte offset into the packet
[out]lenNumber of data bytes remaining in the segment (output). Ignored when NULL.
[out]segHandle to the segment containing the address (output). Ignored when NULL.
Returns
Pointer to the offset
Return values
NULLRequested offset exceeds packet length
Examples
odp_bench_packet.c, and odp_cpu_bench.c.

◆ odp_packet_prefetch()

void odp_packet_prefetch ( odp_packet_t  pkt,
uint32_t  offset,
uint32_t  len 
)

Packet data prefetch.

Prefetch 'len' bytes of packet data starting from 'offset' into various caches close to the calling thread.

Parameters
pktPacket handle
offsetByte offset into packet data
lenNumber of bytes to prefetch starting from 'offset'
Examples
odp_bench_packet.c, odp_l2fwd.c, odp_pktio_ordered.c, and odp_simple_pipeline.c.

◆ odp_packet_push_head()

void* odp_packet_push_head ( odp_packet_t  pkt,
uint32_t  len 
)

Push out packet head.

Increase packet data length by moving packet head into packet headroom. Packet headroom is decreased with the same amount. The packet head may be pushed out up to 'headroom' bytes. Packet is not modified if there's not enough headroom space.

odp_packet_xxx: seg_len += len len += len headroom -= len data -= len

Operation does not modify packet segmentation or move data. Handles and pointers remain valid. User is responsible to update packet metadata offsets when needed.

Parameters
pktPacket handle
lenNumber of bytes to push the head (0 ... headroom)
Returns
The new data pointer
Return values
NULLRequested offset exceeds available headroom
See also
odp_packet_headroom(), odp_packet_pull_head()
Examples
ipsec_api/odp_ipsec.c, odp_bench_packet.c, and odp_ipsecfwd.c.

◆ odp_packet_pull_head()

void* odp_packet_pull_head ( odp_packet_t  pkt,
uint32_t  len 
)

Pull in packet head.

Decrease packet data length by removing data from the head of the packet. Packet headroom is increased with the same amount. Packet head may be pulled in up to seg_len - 1 bytes (i.e. packet data pointer must stay in the first segment). Packet is not modified if there's not enough data.

odp_packet_xxx: seg_len -= len len -= len headroom += len data += len

Operation does not modify packet segmentation or move data. Handles and pointers remain valid. User is responsible to update packet metadata offsets when needed.

Parameters
pktPacket handle
lenNumber of bytes to pull the head (0 ... seg_len - 1)
Returns
The new data pointer
Return values
NULLRequested offset exceeds packet segment length
See also
odp_packet_seg_len(), odp_packet_push_head()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, and odp_ipsecfwd.c.

◆ odp_packet_push_tail()

void* odp_packet_push_tail ( odp_packet_t  pkt,
uint32_t  len 
)

Push out packet tail.

Increase packet data length by moving packet tail into packet tailroom. Packet tailroom is decreased with the same amount. The packet tail may be pushed out up to 'tailroom' bytes. Packet is not modified if there's not enough tailroom.

last_seg: data_len += len

odp_packet_xxx: len += len tail += len tailroom -= len

Operation does not modify packet segmentation or move data. Handles, pointers and offsets remain valid.

Parameters
pktPacket handle
lenNumber of bytes to push the tail (0 ... tailroom)
Returns
The old tail pointer
Return values
NULLRequested offset exceeds available tailroom
See also
odp_packet_tailroom(), odp_packet_pull_tail()
Examples
ipsec_crypto/odp_ipsec.c, and odp_bench_packet.c.

◆ odp_packet_pull_tail()

void* odp_packet_pull_tail ( odp_packet_t  pkt,
uint32_t  len 
)

Pull in packet tail.

Decrease packet data length by removing data from the tail of the packet. Packet tailroom is increased with the same amount. Packet tail may be pulled in up to last segment data_len - 1 bytes. (i.e. packet tail must stay in the last segment). Packet is not modified if there's not enough data.

last_seg: data_len -= len

odp_packet_xxx: len -= len tail -= len tailroom += len

Operation does not modify packet segmentation or move data. Handles and pointers remain valid. User is responsible to update packet metadata offsets when needed.

Parameters
pktPacket handle
lenNumber of bytes to pull the tail (0 ... last_seg:data_len - 1)
Returns
The new tail pointer
Return values
NULLThe specified offset exceeds allowable data length
Examples
ipsec_crypto/odp_ipsec.c, and odp_bench_packet.c.

◆ odp_packet_extend_head()

int odp_packet_extend_head ( odp_packet_t pkt,
uint32_t  len,
void **  data_ptr,
uint32_t *  seg_len 
)

Extend packet head.

Increase packet data length at packet head. Functionality is analogous to odp_packet_push_head() when data length is extended up to headroom size. When data length is increased more than that, new segments are added into the packet head and old segment handles become invalid.

A successful operation overwrites the packet handle with a new handle, which application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

User is responsible to update packet metadata offsets when needed. Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
lenNumber of bytes to extend the head
[out]data_ptrPointer to output the new data pointer. Ignored when NULL.
[out]seg_lenPointer to output segment length at 'data_ptr' above. Ignored when NULL.
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed (e.g. due to an allocation failure)
Examples
odp_bench_packet.c.

◆ odp_packet_trunc_head()

int odp_packet_trunc_head ( odp_packet_t pkt,
uint32_t  len,
void **  data_ptr,
uint32_t *  seg_len 
)

Truncate packet head.

Decrease packet data length at packet head. Functionality is analogous to odp_packet_pull_head() when data length is truncated less than the first segment data length. When data length is decreased more than that, some head segments are removed from the packet and old segment handles become invalid.

A successful operation overwrites the packet handle with a new handle, which application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

User is responsible to update packet metadata offsets when needed. Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
lenNumber of bytes to truncate the head (0 ... packet_len - 1)
[out]data_ptrPointer to output the new data pointer. Ignored when NULL.
[out]seg_lenPointer to output segment length at 'data_ptr' above. Ignored when NULL.
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_extend_tail()

int odp_packet_extend_tail ( odp_packet_t pkt,
uint32_t  len,
void **  data_ptr,
uint32_t *  seg_len 
)

Extend packet tail.

Increase packet data length at packet tail. Functionality is analogous to odp_packet_push_tail() when data length is extended up to tailroom size. When data length is increased more than that, new segments are added into the packet tail and old segment handles become invalid.

A successful operation overwrites the packet handle with a new handle, which application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

User is responsible to update packet metadata offsets when needed. Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
lenNumber of bytes to extend the tail
[out]data_ptrPointer to output pointer to the last 'len' bytes of the resulting packet (the previous tail). Ignored when NULL.
[out]seg_lenPointer to output segment length at 'data_ptr' above. Ignored when NULL.
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed (e.g. due to an allocation failure)
Examples
odp_bench_packet.c.

◆ odp_packet_trunc_tail()

int odp_packet_trunc_tail ( odp_packet_t pkt,
uint32_t  len,
void **  tail_ptr,
uint32_t *  tailroom 
)

Truncate packet tail.

Decrease packet data length at packet tail. Functionality is analogous to odp_packet_pull_tail() when data length is truncated less the last segment data length. When data length is decreased more than that, some tail segments are removed from the packet and old segment handles become invalid.

A successful operation overwrites the packet handle with a new handle, which application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

User is responsible to update packet metadata offsets when needed. Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
lenNumber of bytes to truncate the tail (0 ... packet_len - 1)
[out]tail_ptrPointer to output the new tail pointer. Ignored when NULL.
[out]tailroomPointer to output the new tailroom. Ignored when NULL.
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_add_data()

int odp_packet_add_data ( odp_packet_t pkt,
uint32_t  offset,
uint32_t  len 
)

Add data into an offset.

Increase packet data length by adding new data area into the specified offset. The operation may modify packet segmentation and move data.

A successful operation overwrites the packet handle with a new handle, which application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

User is responsible to update packet metadata offsets when needed. Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
offsetByte offset into the packet
lenNumber of bytes to add into the offset
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_rem_data()

int odp_packet_rem_data ( odp_packet_t pkt,
uint32_t  offset,
uint32_t  len 
)

Remove data from an offset.

Decrease packet data length by removing data area from the specified offset. The operation may modify packet segmentation and move data.

A successful operation overwrites the packet handle with a new handle, which application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

User is responsible to update packet metadata offsets when needed. Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
offsetByte offset into the packet
lenNumber of bytes to remove from the offset. When offset is zero: 0 ... packet_len - 1 bytes, otherwise 0 ... packet_len - offset bytes.
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_align()

int odp_packet_align ( odp_packet_t pkt,
uint32_t  offset,
uint32_t  len,
uint32_t  align 
)

Align packet data.

Modify packet data alignment so that 'len' bytes between 'offset' and 'offset' plus 'len' are contiguous in memory and have a minimum alignment of 'align' bytes.

A successful operation overwrites the packet handle with a new handle, which the application must use as the reference to the packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data outside of the requested area or metadata (e.g. user_area) were moved in memory during the operation. If some other memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, old pointers remain valid.

Packet is not modified if operation fails.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs the new packet handle.
offsetByte offset of the contiguous area
lenByte length of the contiguous area (0 ... packet_len)
alignMinimum byte alignment of the contiguous area. Valid values are powers of 2. Use 0 to indicate no special alignment requirement. All implementations support alignments of up to at least 32 bytes. Request will fail if requested alignment exceeds implementation limits.
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_is_segmented()

int odp_packet_is_segmented ( odp_packet_t  pkt)

Tests if packet is segmented.

Parameters
pktPacket handle
Return values
0Packet is not segmented
1Packet is segmented
Examples
odp_bench_packet.c.

◆ odp_packet_num_segs()

int odp_packet_num_segs ( odp_packet_t  pkt)

Number of segments.

Returns number of segments in the packet. A packet has always at least one segment.

Parameters
pktPacket handle
Returns
Number of segments (>0)
Examples
odp_bench_packet.c, and odp_l2fwd.c.

◆ odp_packet_first_seg()

odp_packet_seg_t odp_packet_first_seg ( odp_packet_t  pkt)

First segment in packet.

A packet has always the first segment (has at least one segment).

Parameters
pktPacket handle
Returns
Handle to the first segment
Examples
odp_bench_packet.c.

◆ odp_packet_last_seg()

odp_packet_seg_t odp_packet_last_seg ( odp_packet_t  pkt)

Last segment in packet.

A packet has always the last segment (has at least one segment).

Parameters
pktPacket handle
Returns
Handle to the last segment
Examples
odp_bench_packet.c.

◆ odp_packet_next_seg()

odp_packet_seg_t odp_packet_next_seg ( odp_packet_t  pkt,
odp_packet_seg_t  seg 
)

Next segment in packet.

Returns handle to the next segment after the current segment, or ODP_PACKET_SEG_INVALID if there are no more segments. Use odp_packet_first_seg() to get handle to the first segment.

Parameters
pktPacket handle
segCurrent segment handle
Returns
Handle to the next segment
Return values
ODP_PACKET_SEG_INVALIDif there are no more segments
Examples
odp_bench_packet.c.

◆ odp_packet_seg_data()

void* odp_packet_seg_data ( odp_packet_t  pkt,
odp_packet_seg_t  seg 
)

Segment data pointer.

Returns pointer to the first byte of data in the segment.

Parameters
pktPacket handle
segSegment handle
Returns
Pointer to the segment data
Return values
NULLon failure
See also
odp_packet_seg_data_len()
Examples
odp_bench_packet.c.

◆ odp_packet_seg_data_len()

uint32_t odp_packet_seg_data_len ( odp_packet_t  pkt,
odp_packet_seg_t  seg 
)

Segment data length.

Returns segment data length in bytes.

Parameters
pktPacket handle
segSegment handle
Returns
Segment data length in bytes
See also
odp_packet_seg_data()
Examples
odp_bench_packet.c.

◆ odp_packet_concat()

int odp_packet_concat ( odp_packet_t dst,
odp_packet_t  src 
)

Concatenate two packets.

Concatenate all packet data from 'src' packet into tail of 'dst' packet. Operation preserves 'dst' packet metadata in the resulting packet, while 'src' packet handle, metadata and old segment handles for both packets become invalid. Source and destination packet handles must not refer to the same packet.

A successful operation overwrites 'dst' packet handle with a new handle, which application must use as the reference to the resulting packet instead of the old handle. Depending on the implementation, the old and new handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

The resulting packet is always allocated from the same pool as the destination packet. The source packet may have been allocated from any pool.

On failure, both handles remain valid and packets are not modified.

Parameters
[in,out]dstPointer to destination packet handle. A successful operation outputs the new packet handle.
srcSource packet handle
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_split()

int odp_packet_split ( odp_packet_t pkt,
uint32_t  len,
odp_packet_t tail 
)

Split packet into two packets.

Split the packet after 'len' bytes. The first 'len' bytes of data and metadata remain in the head packet. A successful operation outputs a handle for the tail packet and overwrites 'pkt' packet handle with a new handle, which application must use as the reference to the resulting head packet. Depending on the implementation, the old and new 'pkt' handles may be equal.

The operation return value indicates if any packet data or metadata (e.g. user_area) were moved in memory during the operation. If some memory areas were moved, application must use new packet/segment handles to update data pointers. Otherwise, all old pointers remain valid.

The tail packet holds the rest of the data (odp_packet_len() - 'len' bytes). The packet is allocated from the same pool as the original packet and metadata is initialized with default values.

For performance reasons (zero copy), the head packet may have zero tailroom and the tail packet may have zero headroom length after the operation. Both packets may be extended normally.

The original packet is not modified on failure.

Parameters
[in,out]pktPointer to packet handle. A successful operation outputs a new packet handle for the head packet.
lenData length remaining in the head packet (1 ... packet_len - 1)
tailPointer to output the tail packet handle
Return values
0Operation successful, old pointers remain valid
>0Operation successful, old pointers need to be updated
<0Operation failed
Examples
odp_bench_packet.c.

◆ odp_packet_buf_head()

void* odp_packet_buf_head ( odp_packet_buf_t  pkt_buf)

Packet buffer head pointer.

Packet buffer start address. Buffer level headroom starts from here. For the first packet buffer of a packet this is equivalent to odp_packet_head().

Parameters
pkt_bufPacket buffer
Returns
Packet buffer head pointer

◆ odp_packet_buf_size()

uint32_t odp_packet_buf_size ( odp_packet_buf_t  pkt_buf)

Packet buffer size in bytes.

Packet buffer size is calculated from the buffer head pointer (see odp_packet_buf_head()). It contains all buffer level headroom, data, and tailroom. For a single segmented packet this is equivalent to odp_packet_buf_len().

Parameters
pkt_bufPacket buffer
Returns
Packet buffer size

◆ odp_packet_buf_data_offset()

uint32_t odp_packet_buf_data_offset ( odp_packet_buf_t  pkt_buf)

Packet buffer data offset.

Offset from the buffer head pointer to the first byte of packet data in the packet buffer. Valid values range from 0 to buf_size - 1. For the first packet buffer of a packet this is equivalent to odp_packet_headroom().

Parameters
pkt_bufPacket buffer
Returns
Packet buffer data offset

◆ odp_packet_buf_data_len()

uint32_t odp_packet_buf_data_len ( odp_packet_buf_t  pkt_buf)

Packet buffer data length in bytes.

Packet buffer contains this many bytes of packet data. Valid values range from 1 to buf_size - data_offset. For the first packet buffer of a packet this is equivalent to odp_packet_seg_len().

Parameters
pkt_bufPacket buffer
Returns
Packet buffer data length

◆ odp_packet_buf_data_set()

void odp_packet_buf_data_set ( odp_packet_buf_t  pkt_buf,
uint32_t  data_offset,
uint32_t  data_len 
)

Packet buffer data set.

Update packet data start offset and length in the packet buffer. Valid offset values range from 0 to buf_size - 1. Valid length values range from 1 to buf_size - data_offset.

Parameters
pkt_bufPacket buffer
data_offsetPacket buffer data offset in bytes (from the buffer head pointer)
data_lenPacket buffer data length in bytes

◆ odp_packet_buf_from_head()

odp_packet_buf_t odp_packet_buf_from_head ( odp_pool_t  pool,
void *  head 
)

Convert packet buffer head pointer to handle.

Converts a packet buffer head pointer (from a previous odp_packet_buf_head() call) to a packet buffer handle. This allows an application to save memory as it can store only buffer pointers (instead of pointers and handles) and convert those to handles when needed. This conversion may be done only for packet buffers that are not part of any packet (i.e. buffers between odp_packet_disassemble() and odp_packet_reassemble() calls).

This call can be used only for packets of an external memory pool (see odp_pool_ext_create()).

Parameters
poolPool from which the packet buffer (disassembled packet) originate from
headHead pointer
Returns
Packet buffer handle on success
Return values
ODP_PACKET_BUF_INVALIDon failure

◆ odp_packet_disassemble()

uint32_t odp_packet_disassemble ( odp_packet_t  pkt,
odp_packet_buf_t  pkt_buf[],
uint32_t  num 
)

Disassemble packet into packet buffers.

Breaks up a packet into a list of packet buffers. Outputs a packet buffer handle for each segment of the packet (see odp_packet_num_segs()). After a successful operation the packet handle must not be referenced anymore. Packet buffers are reassembled into a new packet (or several new packets) with a later odp_packet_reassemble() call(s). All packet buffers must be reassembled into a packet and freed into the originating pool before the pool is destroyed.

This call can be used only for packets of an external memory pool (see odp_pool_ext_create()).

Parameters
pktPacket to be disassembled
[out]pkt_bufPacket buffer handle array for output
numNumber of elements in packet buffer handle array. Must be equal to or larger than number of segments in the packet.
Returns
Number of handles written (equals the number of segments in the packet)
Return values
0on failure

◆ odp_packet_reassemble()

odp_packet_t odp_packet_reassemble ( odp_pool_t  pool,
odp_packet_buf_t  pkt_buf[],
uint32_t  num 
)

Reassemble packet from packet buffers.

Forms a new packet from packet buffers of a previous odp_packet_disassemble() call(s). Packet buffers from different disassembled packets may be used, but all buffers must be from packets of the same pool. Packet pool capability 'max_segs_per_pkt' defines the maximum number of packet buffers that can be reassembled to form a new packet.

Application may use odp_packet_buf_data_set() to adjust data_offset and data_len values in each packet buffer to match the current packet data placement. The operation maintains packet data content and position. Each buffer becomes a segment in the new packet. Packet metadata related to data length and position are set according data layout in the buffers. All other packet metadata are set to their default values. After a successful operation packet buffer handles must not be referenced anymore.

This call can be used only for packets of an external memory pool (see odp_pool_ext_create()).

Parameters
poolPool from which all packet buffers (disassembled packets) originate from
pkt_bufPacket buffers to form a new packet
numNumber of packet buffers. Must not exceed max_segs_per_pkt pool capability.
Returns
Handle of the newly formed packet
Return values
ODP_PACKET_INVALIDon failure

◆ odp_packet_ref_static()

odp_packet_t odp_packet_ref_static ( odp_packet_t  pkt)

Create a static reference to a packet.

A static reference is used to obtain an additional handle for referring to the entire packet as it is. As long as a packet has multiple (static) references, any of the references (including 'pkt') must not be used to modify the packet in any way - both data and metadata must remain static. The packet may be modified again when there is a single reference left. Static and dynamic references must not be mixed. Results are undefined if these restrictions are not observed.

While static references are inflexible they offer efficient way to do, e.g., packet retransmissions. Use odp_packet_ref() or odp_packet_ref_pkt() for more flexible, dynamic references.

Packet is not modified on failure.

Parameters
pktHandle of the packet for which a static reference is to be created.
Returns
Static reference to the packet
Return values
ODP_PACKET_INVALIDOn failure
Examples
odp_bench_packet.c, and odp_packet_gen.c.

◆ odp_packet_ref()

odp_packet_t odp_packet_ref ( odp_packet_t  pkt,
uint32_t  offset 
)

Create a reference to a packet.

Returns a new (dynamic) reference to a packet starting the shared part of the data at a specified byte offset. Metadata and data before the offset are not shared with other references of the packet. The rest of the data is shared and must be treated as read only. Initially the returned reference has metadata initialized to default values and does not contain unshared data. Packet (head) manipulation functions may be used normally to, e.g., add a unique header onto the shared payload. The shared part of the packet may be modified again when there is a single reference left. Static and dynamic references must not be mixed. Results are undefined if these restrictions are not observed.

The packet handle 'pkt' may itself be a (dynamic) reference to a packet.

If the caller does not intend to modify either the packet or the new reference to it, odp_packet_ref_static() may be used to create a static reference that is more optimized for that use case.

Packet is not modified on failure.

Parameters
pktHandle of the packet for which a reference is to be created.
offsetByte offset in the packet at which the shared part is to begin. This must be in the range 0 ... odp_packet_len(pkt)-1.
Returns
New reference to the packet
Return values
ODP_PACKET_INVALIDOn failure
Examples
odp_bench_packet.c.

◆ odp_packet_ref_pkt()

odp_packet_t odp_packet_ref_pkt ( odp_packet_t  pkt,
uint32_t  offset,
odp_packet_t  hdr 
)

Create a reference to a packet with a header packet.

This operation is otherwise identical to odp_packet_ref(), but it prepends a supplied 'hdr' packet as the head of the new reference. The resulting packet consists metadata and data of the 'hdr' packet, followed by the shared part of packet 'pkt'.

The packet handle ('pkt') may itself be a (dynamic) reference to a packet, but the header packet handle ('hdr') must be unique. Both packets must be have been allocated from the same pool and the handles must not refer to the same packet. Results are undefined if these restrictions are not observed.

Packets are not modified on failure. The header packet 'hdr' is consumed on success.

Parameters
pktHandle of the packet for which a reference is to be created.
offsetByte offset in 'pkt' at which the shared part is to begin. Must be in the range 0 ... odp_packet_len(pkt)-1.
hdrHandle of the header packet to be prefixed onto the new reference. Must be a unique reference.
Returns
New reference the reference packet
Return values
ODP_PACKET_INVALIDOn failure
Examples
odp_bench_packet.c.

◆ odp_packet_has_ref()

int odp_packet_has_ref ( odp_packet_t  pkt)

Test if packet has multiple references.

A packet that has multiple references share data with other packets. In case of a static reference it also shares metadata. Shared parts must be treated as read only.

New references are created with odp_packet_ref_static(), odp_packet_ref() and odp_packet_ref_pkt() calls. The intent of multiple references is to avoid packet copies, however some implementations may do a packet copy for some of the calls. If a copy is done, the new reference is actually a new, unique packet and this function returns '0' for it. When a real reference is created (instead of a copy), this function returns '1' for both packets (the original packet and the new reference).

Parameters
pktPacket handle
Return values
0This is the single reference to the packet
1Packet has multiple references
Examples
odp_bench_packet.c.

◆ odp_packet_copy()

odp_packet_t odp_packet_copy ( odp_packet_t  pkt,
odp_pool_t  pool 
)

Full copy of a packet.

Create a new copy of the packet. The new packet is exact copy of the source packet (incl. data and metadata). The pool must have been created with ODP_POOL_PACKET type.

Parameters
pktPacket handle
poolPacket pool for allocation of the new packet.
Returns
Handle to the copy of the packet
Return values
ODP_PACKET_INVALIDon failure
Examples
odp_bench_packet.c, odp_dmafwd.c, odp_ipfragreass.c, odp_l2fwd.c, odp_packet_gen.c, and odp_switch.c.

◆ odp_packet_copy_part()

odp_packet_t odp_packet_copy_part ( odp_packet_t  pkt,
uint32_t  offset,
uint32_t  len,
odp_pool_t  pool 
)

Partial copy of a packet.

Copy 'len' bytes of data starting from 'offset' into a new packet. Metadata in the new packet is initialized with default values. Maximum number of bytes to copy is packet data length minus the offset. The pool must be a packet pool.

Parameters
pktPacket handle
offsetByte offset into the packet
lenNumber of bytes to copy
poolPacket pool for allocation of the new packet
Returns
Handle for the new packet
Return values
ODP_PACKET_INVALIDon failure
Examples
odp_bench_packet.c.

◆ odp_packet_copy_to_mem()

int odp_packet_copy_to_mem ( odp_packet_t  pkt,
uint32_t  offset,
uint32_t  len,
void *  dst 
)

Copy data from packet to memory.

Copy 'len' bytes of data starting from 'offset' to the destination address. Maximum number of bytes to copy is packet data length minus the offset.

Parameters
pktPacket handle
offsetByte offset into the packet
lenNumber of bytes to copy
dstDestination address
Return values
0on success
<0on failure
Examples
odp_bench_packet.c, odp_ipsecfwd.c, odp_packet_dump.c, odp_packet_gen.c, odp_ping.c, and odp_pktio_perf.c.

◆ odp_packet_copy_from_mem()

int odp_packet_copy_from_mem ( odp_packet_t  pkt,
uint32_t  offset,
uint32_t  len,
const void *  src 
)

Copy data from memory to packet.

Copy 'len' bytes of data from the source address into the packet level offset. Maximum number of bytes to copy is packet data length minus the offset. Packet is not modified on an error.

Parameters
pktPacket handle
offsetByte offset into the packet
lenNumber of bytes to copy
srcSource address
Return values
0on success
<0on failure
Examples
ipsec_api/odp_ipsec.c, odp_bench_packet.c, odp_cpu_bench.c, odp_ipsec.c, odp_ipsecfwd.c, odp_packet_gen.c, and odp_pktio_perf.c.

◆ odp_packet_copy_from_pkt()

int odp_packet_copy_from_pkt ( odp_packet_t  dst,
uint32_t  dst_offset,
odp_packet_t  src,
uint32_t  src_offset,
uint32_t  len 
)

Copy data from another packet.

Copy 'len' bytes of data from 'src' packet to 'dst' packet. Copy starts from the specified source and destination packet offsets. Copied areas (offset ... offset + len) must not exceed their packet data lengths. Source and destination packet handles must not refer to the same packet (use odp_packet_copy_data() or odp_packet_move_data() for a single packet).

Packet is not modified on an error.

Parameters
dstDestination packet handle
dst_offsetByte offset into destination packet
srcSource packet handle
src_offsetByte offset into source packet
lenNumber of bytes to copy
Return values
0on success
<0on failure
Examples
odp_bench_packet.c.

◆ odp_packet_copy_data()

int odp_packet_copy_data ( odp_packet_t  pkt,
uint32_t  dst_offset,
uint32_t  src_offset,
uint32_t  len 
)

Copy data within packet.

Copy 'len' bytes of data from 'src_offset' to 'dst_offset'. Copied areas (offset ... offset + len) must not overlap or exceed packet data length. Packet is not modified on an error.

Parameters
pktPacket handle
dst_offsetDestination byte offset
src_offsetSource byte offset
lenNumber of bytes to copy
Return values
0on success
<0on failure
Examples
odp_bench_packet.c.

◆ odp_packet_move_data()

int odp_packet_move_data ( odp_packet_t  pkt,
uint32_t  dst_offset,
uint32_t  src_offset,
uint32_t  len 
)

Move data within packet.

Copy 'len' bytes of data from 'src_offset' to 'dst_offset'. Copied areas (offset ... offset + len) may overlap by any number of bytes, but must not exceed packet data length. When areas overlap, copying takes place as if source bytes are first copied into a temporary buffer, and then from there to the destination. Packet is not modified on an error.

Parameters
pktPacket handle
dst_offsetDestination byte offset
src_offsetSource byte offset
lenNumber of bytes to move
Return values
0on success
<0on failure
Examples
odp_bench_packet.c.

◆ odp_packet_parse()

int odp_packet_parse ( odp_packet_t  pkt,
uint32_t  offset,
const odp_packet_parse_param_t param 
)

Parse packet.

Parse protocol headers in packet data and update layer/protocol specific metadata (e.g. offsets, errors, protocols, checksum statuses, etc). Parsing starts at 'offset', which is the first header byte of protocol 'param.proto'. Parameter 'param.last_layer' defines the last layer application requests to check. Use ODP_PROTO_LAYER_ALL for all layers. A successful operation sets (or resets) packet metadata for all layers from the layer of 'param.proto' to the application defined last layer. In addition, offset (and pointer) to the next layer is set. Other layer/protocol specific metadata have undefined values. When operation fails, all layer/protocol specific metadata have undefined values.

Parameters
pktPacket handle
offsetByte offset into the packet
paramParse parameters. Proto and last_layer fields must be set. Clear all check bits that are not used.
Return values
0on success
<0on failure
Examples
odp_bench_packet.c, and odp_cpu_bench.c.

◆ odp_packet_parse_multi()

int odp_packet_parse_multi ( const odp_packet_t  pkt[],
const uint32_t  offset[],
int  num,
const odp_packet_parse_param_t param 
)

Parse multiple packets.

Otherwise like odp_packet_parse(), but parses multiple packets. Packets may have unique offsets, but must start with the same protocol. The same parse parameters are applied to all packets.

Parameters
pktPacket handle array
offsetByte offsets into the packets
numNumber of packets and offsets
paramParse parameters. Proto and last_layer fields must be set. Clear all check bits that are not used.
Returns
Number of packets parsed successfully (0 ... num)
Return values
<0on failure
Examples
odp_bench_packet.c.

◆ odp_packet_parse_result()

void odp_packet_parse_result ( odp_packet_t  pkt,
odp_packet_parse_result_t result 
)

Read parse results.

Read out the most commonly used packet parse results. The same information is available through individual function calls, but this call may be more efficient when reading multiple results from a packet.

Parameters
pktPacket handle
[out]resultPointer for parse result output

◆ odp_packet_parse_result_multi()

void odp_packet_parse_result_multi ( const odp_packet_t  pkt[],
odp_packet_parse_result_t result[],
int  num 
)

Read parse results from multiple packets.

Otherwise same functionality as odp_packet_parse_result() but handles multiple packets.

Parameters
pktPacket handle array
[out]resultParse result array for output
numNumber of packets and results

◆ odp_packet_pool()

odp_pool_t odp_packet_pool ( odp_packet_t  pkt)

Packet pool.

Returns handle to the packet pool where the packet was allocated from.

Parameters
pktPacket handle
Returns
Packet pool handle
Examples
odp_bench_packet.c, odp_classifier.c, and odp_l2fwd.c.

◆ odp_packet_input()

odp_pktio_t odp_packet_input ( odp_packet_t  pkt)

Packet input interface.

Returns handle to the packet IO interface which received the packet or ODP_PKTIO_INVALID when the packet was allocated/reset by the application.

Parameters
pktPacket handle
Returns
Packet interface handle
Return values
ODP_PKTIO_INVALIDPacket was not received on any interface
Examples
odp_bench_packet.c, odp_packet_dump.c, odp_ping.c, odp_pktio.c, and odp_pktio_ordered.c.

◆ odp_packet_input_set()

void odp_packet_input_set ( odp_packet_t  pkt,
odp_pktio_t  pktio 
)

Set packet input interface.

Set packet input interface to a valid packet IO handle or ODP_PKTIO_INVALID. An application may use this for testing or other purposes, when perception of the packet input interface need to be changed. The call updates both input interface handle (odp_packet_input()) and index (odp_packet_input_index()).

Parameters
pktPacket handle
pktioHandle to a valid packet input interface or ODP_PKTIO_INVALID. ODP_PKTIO_INVALID indicates that the packet was not received by any packet IO interface.

◆ odp_packet_input_index()

int odp_packet_input_index ( odp_packet_t  pkt)

Packet input interface index.

Returns the index of the packet I/O interface that received the packet, or <0 when the packet was allocated/reset by the application.

Parameters
pktPacket handle
Returns
Packet interface index (0..odp_pktio_max_index())
Return values
<0Packet was not received on any interface
Examples
odp_bench_packet.c, odp_dmafwd.c, odp_l2fwd.c, odp_packet_gen.c, odp_ping.c, and odp_sched_pktio.c.

◆ odp_packet_user_ptr()

void* odp_packet_user_ptr ( odp_packet_t  pkt)

User context pointer.

Return previously stored user context pointer. If not otherwise documented, the pointer value is maintained over packet manipulating operations. Implementation initializes the pointer value to NULL during new packet creation (e.g. alloc and packet input) and reset.

Parameters
pktPacket handle
Returns
User context pointer
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, and odp_ipsecfwd.c.

◆ odp_packet_user_ptr_set()

void odp_packet_user_ptr_set ( odp_packet_t  pkt,
const void *  user_ptr 
)

Set user context pointer.

Each packet has room for a user defined context pointer. The pointer value does not necessarily represent a valid address - e.g. user may store any value of type intptr_t. ODP may use the pointer for data prefetching, but must ignore any invalid addresses.

Parameters
pktPacket handle
user_ptrUser context pointer
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, and odp_ipsecfwd.c.

◆ odp_packet_user_area()

void* odp_packet_user_area ( odp_packet_t  pkt)

User area address.

Each packet has an area for user data. Size of the area is fixed and defined in packet pool parameters.

Parameters
pktPacket handle
Returns
User area address associated with the packet
Return values
NULLThe packet does not have user area
Examples
odp_bench_packet.c, odp_cpu_bench.c, odp_ipfragreass.c, odp_pktio_ordered.c, and odp_pool_latency.c.

◆ odp_packet_user_area_size()

uint32_t odp_packet_user_area_size ( odp_packet_t  pkt)

User area size.

The size is fixed and defined in packet pool parameters.

Parameters
pktPacket handle
Returns
User area size in bytes
Examples
odp_bench_packet.c, and odp_l2fwd.c.

◆ odp_packet_user_flag()

int odp_packet_user_flag ( odp_packet_t  pkt)

Check user flag.

Implementation clears user flag during new packet creation (e.g. alloc and packet input) and reset. User may set the flag with odp_packet_user_flag_set(). Implementation never sets the flag, only clears it. The flag may be useful e.g. to mark when the user area content is valid.

Parameters
pktPacket handle
Return values
0User flag is clear
>0User flag is set
Examples
odp_bench_packet.c.

◆ odp_packet_user_flag_set()

void odp_packet_user_flag_set ( odp_packet_t  pkt,
int  val 
)

Set user flag.

Set (or clear) the user flag.

Parameters
pktPacket handle
valNew value for the flag. Zero clears the flag, other values set the flag.
Examples
odp_bench_packet.c.

◆ odp_packet_l2_ptr()

void* odp_packet_l2_ptr ( odp_packet_t  pkt,
uint32_t *  len 
)

Layer 2 start pointer.

Returns pointer to the start of layer 2. Optionally, outputs number of data bytes in the segment following the pointer. The pointer value is generated from the current layer 2 offset.

Parameters
pktPacket handle
[out]lenNumber of data bytes remaining in the segment (output). Ignored when NULL.
Returns
Layer 2 start pointer
Return values
NULLLayer 2 offset has not been set
See also
odp_packet_l2_offset(), odp_packet_l2_offset_set(), odp_packet_has_l2()
Examples
ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, odp_classifier.c, odp_l2fwd_simple.c, odp_l3fwd.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, and odp_switch.c.

◆ odp_packet_l2_offset()

uint32_t odp_packet_l2_offset ( odp_packet_t  pkt)

Layer 2 start offset.

Returns offset to the start of layer 2. The offset is calculated from the current odp_packet_data() position in bytes. Packet parsing sets the offset according to parse configuration and layers recognized in the packet. Data start position updating functions (e.g. odp_packet_push_head()) do not modify the offset, but user sets a new value when needed.

Parameters
pktPacket handle
Returns
Layer 2 start offset
Return values
ODP_PACKET_OFFSET_INVALIDLayer 2 offset has not been set
See also
odp_packet_l2_offset_set(), odp_packet_has_l2()
Examples
odp_bench_packet.c, odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_l2_offset_set()

int odp_packet_l2_offset_set ( odp_packet_t  pkt,
uint32_t  offset 
)

Set layer 2 start offset.

Set offset to the start of layer 2. The offset is calculated from the current odp_packet_data() position in bytes. Offset must not exceed packet data length. Offset is not modified on an error.

Parameters
pktPacket handle
offsetLayer 2 start offset (0 ... odp_packet_len()-1)
Return values
0on success
<0on failure
Examples
ipsec_api/odp_ipsec.c, odp_bench_packet.c, and odp_pktio_perf.c.

◆ odp_packet_l3_ptr()

void* odp_packet_l3_ptr ( odp_packet_t  pkt,
uint32_t *  len 
)

Layer 3 start pointer.

Returns pointer to the start of layer 3. Optionally, outputs number of data bytes in the segment following the pointer. The pointer value is generated from the current layer 3 offset.

Parameters
pktPacket handle
[out]lenNumber of data bytes remaining in the segment (output). Ignored when NULL.
Returns
Layer 3 start pointer
Return values
NULLLayer 3 offset has not been set
See also
odp_packet_l3_offset(), odp_packet_l3_offset_set(), odp_packet_has_l3()
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_packet.c, odp_classifier.c, odp_l3fwd.c, odp_ping.c, and odp_pktio.c.

◆ odp_packet_l3_offset()

uint32_t odp_packet_l3_offset ( odp_packet_t  pkt)

Layer 3 start offset.

Returns offset to the start of layer 3. The offset is calculated from the current odp_packet_data() position in bytes. Packet parsing sets the offset according to parse configuration and layers recognized in the packet. Data start position updating functions (e.g. odp_packet_push_head()) do not modify the offset, but user sets a new value when needed.

Parameters
pktPacket handle
Returns
Layer 3 start offset
Return values
ODP_PACKET_OFFSET_INVALIDLayer 3 offset has not been set
See also
odp_packet_l3_offset_set(), odp_packet_has_l3()
Examples
ipsec_api/odp_ipsec.c, odp_bench_packet.c, odp_ipsecfwd.c, odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_l3_offset_set()

int odp_packet_l3_offset_set ( odp_packet_t  pkt,
uint32_t  offset 
)

Set layer 3 start offset.

Set offset to the start of layer 3. The offset is calculated from the current odp_packet_data() position in bytes. Offset must not exceed packet data length. Offset is not modified on an error.

Parameters
pktPacket handle
offsetLayer 3 start offset (0 ... odp_packet_len()-1)
Return values
0on success
<0on failure
Examples
odp_bench_packet.c, odp_ipsec.c, odp_packet_gen.c, and odp_pktio_perf.c.

◆ odp_packet_l4_ptr()

void* odp_packet_l4_ptr ( odp_packet_t  pkt,
uint32_t *  len 
)

Layer 4 start pointer.

Returns pointer to the start of layer 4. Optionally, outputs number of data bytes in the segment following the pointer. The pointer value is generated from the current layer 4 offset.

Parameters
pktPacket handle
[out]lenNumber of data bytes remaining in the segment (output). Ignored when NULL.
Returns
Layer 4 start pointer
Return values
NULLLayer 4 offset has not been set
See also
odp_packet_l4_offset(), odp_packet_l4_offset_set(), odp_packet_has_l4()
Examples
odp_bench_packet.c, odp_cpu_bench.c, odp_l3fwd.c, odp_packet_dump.c, odp_packet_gen.c, and odp_ping.c.

◆ odp_packet_l4_offset()

uint32_t odp_packet_l4_offset ( odp_packet_t  pkt)

Layer 4 start offset.

Returns offset to the start of layer 4. The offset is calculated from the current odp_packet_data() position in bytes. Packet parsing sets the offset according to parse configuration and layers recognized in the packet. Data start position updating functions (e.g. odp_packet_push_head()) do not modify the offset, but user sets a new value when needed.

Parameters
pktPacket handle
Returns
Layer 4 start offset
Return values
ODP_PACKET_OFFSET_INVALIDLayer 4 offset has not been set
See also
odp_packet_l4_offset_set(), odp_packet_has_l4()
Examples
odp_bench_packet.c, odp_cpu_bench.c, odp_ipsecfwd.c, odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_l4_offset_set()

int odp_packet_l4_offset_set ( odp_packet_t  pkt,
uint32_t  offset 
)

Set layer 4 start offset.

Set offset to the start of layer 4. The offset is calculated from the current odp_packet_data() position in bytes. Offset must not exceed packet data length. Offset is not modified on an error.

Parameters
pktPacket handle
offsetLayer 4 start offset (0 ... odp_packet_len()-1)
Return values
0on success
<0on failure
Examples
odp_bench_packet.c, odp_packet_gen.c, and odp_pktio_perf.c.

◆ odp_packet_l2_type()

odp_proto_l2_type_t odp_packet_l2_type ( odp_packet_t  pkt)

Layer 2 protocol type.

Returns layer 2 protocol type. Initial type value is ODP_PROTO_L2_TYPE_NONE.

Parameters
pktPacket handle
Returns
Layer 2 protocol type
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_l3_type()

odp_proto_l3_type_t odp_packet_l3_type ( odp_packet_t  pkt)

Layer 3 protocol type.

Returns layer 3 protocol type. Initial type value is ODP_PROTO_L3_TYPE_NONE.

In addition to protocol types specified in ODP_PROTO_L3_TYPE_* defines, the function may also return other L3 protocol types (e.g. from IEEE EtherTypes list) recognized by the parser. If protocol type is not recognized, ODP_PROTO_L3_TYPE_NONE is returned.

Parameters
pktPacket handle
Returns
Layer 3 protocol type
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_l4_type()

odp_proto_l4_type_t odp_packet_l4_type ( odp_packet_t  pkt)

Layer 4 protocol type.

Returns layer 4 protocol type. Initial type value is ODP_PROTO_L4_TYPE_NONE.

In addition to protocol types specified in ODP_PROTO_L4_TYPE_* defines, the function may also return other L4 protocol types (e.g. from IANA protocol number list) recognized by the parser. If protocol type is not recognized, ODP_PROTO_L4_TYPE_NONE is returned.

Parameters
pktPacket handle
Returns
Layer 4 protocol type
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_l3_chksum_status()

odp_packet_chksum_status_t odp_packet_l3_chksum_status ( odp_packet_t  pkt)

Layer 3 checksum check status.

Returns the result of the latest layer 3 checksum check done for the packet. The status tells if checksum check was attempted and the result of the attempt. It depends on packet input (or IPSEC) configuration, packet content and implementation capabilities if checksum check is attempted for a packet.

Parameters
pktPacket handle
Returns
L3 checksum check status

◆ odp_packet_l4_chksum_status()

odp_packet_chksum_status_t odp_packet_l4_chksum_status ( odp_packet_t  pkt)

Layer 4 checksum check status.

Returns the result of the latest layer 4 checksum check done for the packet. The status tells if checksum check was attempted and the result of the attempt. It depends on packet input (or IPSEC) configuration, packet content and implementation capabilities if checksum check is attempted for a packet.

When a UDP packet does not have a checksum (e.g. checksum field of a UDP/IPv4 packet is zero), checksum check result is ODP_PACKET_CHKSUM_OK.

Parameters
pktPacket handle
Returns
L4 checksum check status

◆ odp_packet_l3_chksum_insert()

void odp_packet_l3_chksum_insert ( odp_packet_t  pkt,
int  insert 
)

Layer 3 checksum insertion override.

Override checksum insertion configuration per packet. This per packet setting overrides a higher level configuration for checksum insertion into a L3 header during packet output processing.

Calling this function is always allowed but the checksum will not be inserted if the packet is output through a pktio that does not have the relevant checksum insertion enabled.

L3 type and L3 offset in packet metadata should provide valid protocol and header offset for checksum insertion purposes.

Parameters
pktPacket handle
insert0: do not insert L3 checksum 1: insert L3 checksum
See also
odp_packet_l3_offset(), odp_packet_has_ipv4(), odp_packet_has_ipv6()
Examples
odp_l2fwd.c.

◆ odp_packet_l4_chksum_insert()

void odp_packet_l4_chksum_insert ( odp_packet_t  pkt,
int  insert 
)

Layer 4 checksum insertion override.

Override checksum insertion configuration per packet. This per packet setting overrides a higher level configuration for checksum insertion into a L4 header during packet output processing.

Calling this function is always allowed but the checksum will not be inserted if the packet is output through a pktio that does not have the relevant checksum insertion enabled.

L3 type, L4 type, L3 offset and L4 offset in packet metadata should provide valid protocols and header offsets for checksum insertion purposes.

Parameters
pktPacket handle
insert0: do not insert L4 checksum 1: insert L4 checksum
See also
odp_packet_l3_offset(), odp_packet_has_ipv4(), odp_packet_has_ipv6()
odp_packet_l4_offset(), odp_packet_has_tcp(), odp_packet_has_udp()
odp_packet_has_sctp()
Examples
odp_l2fwd.c.

◆ odp_packet_ones_comp()

uint16_t odp_packet_ones_comp ( odp_packet_t  pkt,
odp_packet_data_range_t range 
)

Ones' complement sum of packet data.

Returns 16-bit ones' complement sum that was calculated over a portion of packet data during a packet processing operation (e.g. packet input or IPSEC offload). The data range is output with 'range' parameter, and usually includes IP payload (L4 headers and payload). When 'range.length' is zero, the sum has not been calculated. In case of odd number of bytes, calculation uses a zero byte as padding at the end. The sum may be used as part of e.g. UDP/TCP checksum checking, especially with IP fragments.

Parameters
pktPacket handle
[out]rangeData range of the sum (output). The calculation started from range.offset and included range.length bytes. When range.length is zero, the sum has not been calculated.
Returns
Ones' complement sum over the data range

◆ odp_packet_flow_hash()

uint32_t odp_packet_flow_hash ( odp_packet_t  pkt)

Packet flow hash value.

Returns the hash generated from the packet header. Use odp_packet_has_flow_hash() to check if packet contains a hash.

Parameters
pktPacket handle
Returns
Hash value
Note
Zero can be a valid hash value.
The hash algorithm and the header fields defining the flow (therefore used for hashing) is platform dependent. It is possible a platform doesn't generate any hash at all.
The returned hash is either the platform generated (if any), or if odp_packet_flow_hash_set() were called then the value set there.
Examples
odp_bench_packet.c, and odp_sched_pktio.c.

◆ odp_packet_flow_hash_set()

void odp_packet_flow_hash_set ( odp_packet_t  pkt,
uint32_t  flow_hash 
)

Set packet flow hash value.

Store the packet flow hash for the packet and sets the flow hash flag. This enables (but does not require!) application to reflect packet header changes in the hash.

Parameters
pktPacket handle
flow_hashHash value to set
Note
If the platform needs to keep the original hash value, it has to maintain it internally. Overwriting the platform provided value doesn't change how the platform handles this packet after it.
The application is not required to keep this hash valid for new or modified packets.
Examples
odp_bench_packet.c.

◆ odp_packet_ts()

odp_time_t odp_packet_ts ( odp_packet_t  pkt)

Packet timestamp.

Returns timestamp value recorded into the packet. Use odp_packet_has_ts() to check if the packet has a valid timestamp. Packet input uses packet IO interface specific time source and thus timestamp (or nanosecond) values from one interface cannot be mixed with values from another interface (or time source in general). Packet IO interface timestamp resolution can be checked with odp_pktio_ts_res() and current time with odp_pktio_time().

Time API operations (e.g. odp_time_diff()) can be used with packet timestamp values or when converting those into nanoseconds (odp_time_to_ns()).

Parameters
pktPacket handle
Returns
Timestamp value
Examples
odp_bench_packet.c, odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_ts_set()

void odp_packet_ts_set ( odp_packet_t  pkt,
odp_time_t  timestamp 
)

Set packet timestamp.

Stores timestamp value and sets timestamp flag for the packet.

Parameters
pktPacket handle
timestampTimestamp value
See also
odp_packet_ts(), odp_packet_has_ts(), odp_pktio_ts_from_ns()
Examples
odp_bench_packet.c.

◆ odp_packet_ts_request()

void odp_packet_ts_request ( odp_packet_t  pkt,
int  enable 
)

Request Tx timestamp capture.

Control whether timestamp needs to be captured when this packet is transmitted. By default, Tx timestamping is disabled. This API is allowed to be called always, but the Tx timestamp is not captured if the output packet IO device is not configured to enable timestamping.

Parameters
pktPacket handle
enable0: do not capture timestamp on Tx 1: capture timestamp on Tx
See also
odp_pktout_ts_read()

◆ odp_packet_color()

odp_packet_color_t odp_packet_color ( odp_packet_t  pkt)

Get packet color.

Parameters
pktPacket handle
Returns
packet color

◆ odp_packet_color_set()

void odp_packet_color_set ( odp_packet_t  pkt,
odp_packet_color_t  color 
)

Set packet color.

Parameters
pktPacket handle
colorColor to set
Examples
odp_traffic_mgmt.c.

◆ odp_packet_drop_eligible()

odp_bool_t odp_packet_drop_eligible ( odp_packet_t  pkt)

Get drop eligible status.

Parameters
pktPacket handle
Returns
Packet drop eligibility status
Return values
0Packet is not drop eligible
1Packet is drop

◆ odp_packet_drop_eligible_set()

void odp_packet_drop_eligible_set ( odp_packet_t  pkt,
odp_bool_t  status 
)

Set drop eligible status.

Parameters
pktPacket handle
statusDrop eligibility status
Examples
odp_traffic_mgmt.c.

◆ odp_packet_shaper_len_adjust()

int8_t odp_packet_shaper_len_adjust ( odp_packet_t  pkt)

Get shaper length adjustment.

Parameters
pktPacket handle
Returns
Shaper adjustment (-128..127)

◆ odp_packet_shaper_len_adjust_set()

void odp_packet_shaper_len_adjust_set ( odp_packet_t  pkt,
int8_t  adj 
)

Set shaper length adjustment.

Parameters
pktPacket handle
adjSigned adjustment value
Examples
odp_traffic_mgmt.c.

◆ odp_packet_cls_mark()

uint64_t odp_packet_cls_mark ( odp_packet_t  pkt)

Classification mark value.

Get the value of the CLS mark of the packet. The mark value is zero by default, but may be changed by the classification subsystem.

Parameters
pktPacket handle
Returns
mark value
See also
odp_cls_capability_t::max_mark, odp_pmr_create_opt_t::mark, odp_cls_pmr_create_opt()

◆ odp_packet_lso_request()

int odp_packet_lso_request ( odp_packet_t  pkt,
const odp_packet_lso_opt_t lso_opt 
)

Request Large Send Offload (LSO) for a packet.

Setup packet metadata which requests LSO segmentation to be performed during packet output. The selected LSO profile specifies details of the segmentation operation to be done. Depending on LSO profile options, additional metadata (e.g. L3/L4 protocol header offsets) may need to be set on the packet.

Parameters
pktPacket handle
lso_optLSO options
Return values
0On success
<0On failure

◆ odp_packet_lso_request_clr()

void odp_packet_lso_request_clr ( odp_packet_t  pkt)

Clear LSO request from a packet.

Clears packet metadata not to request LSO segmentation.

Parameters
pktPacket handle

◆ odp_packet_has_lso_request()

int odp_packet_has_lso_request ( odp_packet_t  pkt)

Check if LSO is requested for the packet.

Parameters
pktPacket handle
Return values
non-zeroLSO is requested
0LSO is not requested

◆ odp_packet_payload_offset()

uint32_t odp_packet_payload_offset ( odp_packet_t  pkt)

Payload data offset.

Returns offset to the start of payload data. Packet data before this offset is considered as protocol headers. The offset is calculated from the current odp_packet_data() position in bytes. Data start position updating functions (e.g. odp_packet_push_head()) do not modify the offset, but user sets a new value when needed.

Packet parsing does not set this offset. Initial offset value is undefined. Application may utilize the offset for internal purposes or when requesting LSO segmentation for the packet.

Parameters
pktPacket handle
Returns
Payload data offset
Return values
ODP_PACKET_OFFSET_INVALIDPayload data offset has not been set

◆ odp_packet_payload_offset_set()

int odp_packet_payload_offset_set ( odp_packet_t  pkt,
uint32_t  offset 
)

Set payload data start offset.

Set offset to the start of payload data. The offset is calculated from the current odp_packet_data() position in bytes. Offset must not exceed packet data length. Offset is not modified on an error.

Parameters
pktPacket handle
offsetPayload data start offset (0 ... odp_packet_len()-1) or ODP_PACKET_OFFSET_INVALID
Return values
0on success
<0on failure

◆ odp_packet_aging_tmo_set()

void odp_packet_aging_tmo_set ( odp_packet_t  pkt,
uint64_t  tmo_ns 
)

Enable or disable Tx packet aging.

Enable or disable Tx packet drop based on packet age. When enabled, packet will be dropped if it is in Tx pktout queue or traffic shapers/schedulers for longer than timeout set.

When tmo_ns is !0: Aging is enabled 0: Aging is disabled

Aging is disabled by default. Maximum tmo value is defined by max_tx_aging_tmo_ns capa.

Parameters
pktPacket handle
tmo_nsPacket aging drop timeout in nsec. When 0, aging drop is disabled (default).
See also
odp_pktio_capability_t::max_tx_aging_tmo_ns

◆ odp_packet_aging_tmo()

uint64_t odp_packet_aging_tmo ( odp_packet_t  pkt)

Check if packet has Tx aging drop enabled.

Parameters
pktPacket handle
Returns
Aging drop timeout if enabled.
Return values
>0Aging drop timeout in nano seconds and implies aging drop is enabled.
0If Aging drop is disabled.

◆ odp_packet_tx_compl_request()

int odp_packet_tx_compl_request ( odp_packet_t  pkt,
const odp_packet_tx_compl_opt_t opt 
)

Request packet transmit completion.

Enables or disables packet transmit completion request for the packet. Completion may be requested either in event (ODP_PACKET_TX_COMPL_EVENT) or poll (ODP_PACKET_TX_COMPL_POLL) mode. When event mode is enabled, an event of type ODP_EVENT_PACKET_TX_COMPL will be sent to the destination queue to signal transmit completion. When poll mode is enabled, odp_packet_tx_compl_done() is used with the provided completion identifier to check the completion. In both cases, transmit completion is reported only after pktio interface has finished processing the packet.

A previously enabled request can be disabled by setting the mode to ODP_PACKET_TX_COMPL_DISABLED. Transmit completion request is disabled by default.

Parameters
pktPacket handle
optPacket transmit completion request options
Return values
0On success
<0On failure
Examples
odp_l2fwd.c.

◆ odp_packet_has_tx_compl_request()

int odp_packet_has_tx_compl_request ( odp_packet_t  pkt)

Check if packet transmit completion is requested.

Parameters
pktPacket handle
Return values
non-zeroTransmit completion is requested
0Transmit completion is not requested
Examples
odp_l2fwd.c.

◆ odp_packet_free_ctrl_set()

void odp_packet_free_ctrl_set ( odp_packet_t  pkt,
odp_packet_free_ctrl_t  ctrl 
)

Set packet free control option.

This option enables application to control if a packet is freed/not freed back into a pool after an ODP offload feature has finished processing it. The option does not have an effect on odp_packet_free() or other direct free calls. It affects only packets that are sent directly through a packet output interface queue (odp_pktout_queue_t or odp_queue_t), also when packets are LSO offloaded. Packets transmitted through inline IPsec or TM are not affected.

Packet output interface frees transmitted packets by default. When the option is set to ODP_PACKET_FREE_CTRL_DONT_FREE, packet output will not free the packet after transmit and application may reuse or free the packet as soon as its transmission is complete (see e.g. odp_packet_tx_compl_done()). Check packet IO interface capability free_ctrl.dont_free (odp_pktio_capability_t.free_ctrl) for the option support. When an interface does not support the option, it ignores the value.

The option must not be enabled on packets that have multiple references. The default value is ODP_PACKET_FREE_CTRL_DISABLED.

Parameters
pktPacket handle
ctrlPacket free control option value
Examples
odp_packet_gen.c.

◆ odp_packet_free_ctrl()

odp_packet_free_ctrl_t odp_packet_free_ctrl ( odp_packet_t  pkt)

Returns packet free control option value.

Parameters
pktPacket handle
Returns
The current value of the packet free control option

◆ odp_packet_proto_stats_request()

void odp_packet_proto_stats_request ( odp_packet_t  pkt,
odp_packet_proto_stats_opt_t opt 
)

Request packet proto stats.

The statistics enabled in the proto stats object are updated for the packet in packet output when the packet is transmitted or dropped. The statistics update is done as the last step of output processing after possible packet transformations (e.g. fragmentation, IPsec) that may occur. If a packet is fragmented or segmented to multiple packets as part of output processing, all the resulting packets inherit the proto stats object association from the original packet.

The relevant octet counts will be updated with the actual packet length at the time of transmission or drop plus the respective adjustment value passed in the 'opt' parameter. The octet counts thus include possible additional headers added by ODP during packet output (e.g. ESP header added by inline outbound IPsec processing). Ethernet padding and FCS are not included in the octet counts. The adjustment value is added only if the respective capability field is true and otherwise ignored.

Parameters
pktPacket handle
optProto stats options. If NULL, then proto stats update is disabled for this packet.
See also
odp_proto_stats_capability_t::tx

◆ odp_packet_proto_stats()

odp_proto_stats_t odp_packet_proto_stats ( odp_packet_t  pkt)

Get proto stats object.

Get the proto stats object associated with the given packet.

Parameters
pktPacket handle
Returns
Proto stats object handle or ODP_PROTO_STATS_INVALID if not set.

◆ odp_packet_vector_from_event()

odp_packet_vector_t odp_packet_vector_from_event ( odp_event_t  ev)

Get packet vector handle from event.

Converts an ODP_EVENT_PACKET_VECTOR type event to a packet vector handle

Parameters
evEvent handle
Returns
Packet vector handle
See also
odp_event_type()
Examples
odp_ipsec.c, and odp_l2fwd.c.

◆ odp_packet_vector_to_event()

odp_event_t odp_packet_vector_to_event ( odp_packet_vector_t  pktv)

Convert packet vector handle to event.

Parameters
pktvPacket vector handle
Returns
Event handle

◆ odp_packet_vector_alloc()

odp_packet_vector_t odp_packet_vector_alloc ( odp_pool_t  pool)

Allocate a packet vector from a packet vector pool.

Allocates a packet vector from the specified packet vector pool. The pool must have been created with the ODP_POOL_VECTOR type.

Parameters
poolPacket vector pool handle
Returns
Handle of allocated packet vector
Return values
ODP_PACKET_VECTOR_INVALIDPacket vector could not be allocated
Note
A newly allocated vector shall not contain any packets, instead, alloc operation shall reserve the space for odp_pool_param_t::vector::max_size packets.
Examples
odp_pool_latency.c.

◆ odp_packet_vector_free()

void odp_packet_vector_free ( odp_packet_vector_t  pktv)

Free packet vector.

Frees the packet vector into the packet vector pool it was allocated from.

Parameters
pktvPacket vector handle
Note
This API just frees the vector, not any packets inside the vector. Application can use odp_event_free() to free the vector and packets inside the vector.
Examples
odp_ipsec.c, odp_l2fwd.c, and odp_pool_latency.c.

◆ odp_packet_vector_tbl()

uint32_t odp_packet_vector_tbl ( odp_packet_vector_t  pktv,
odp_packet_t **  pkt_tbl 
)

Get packet vector table.

Packet vector table is an array of packets (odp_packet_t) stored in contiguous memory location. Upon completion of this API, the implementation returns the packet table pointer in pkt_tbl.

Parameters
pktvPacket vector handle
[out]pkt_tblPoints to packet vector table
Returns
Number of packets available in the vector.
Note
When pktin subsystem is producing the packet vectors, odp_pktin_vector_config_t::pool shall be used to configure the pool to form the vector table.
The maximum number of packets this vector can hold is defined by odp_pool_param_t::vector::max_size. The return value of this function will not be greater than odp_pool_param_t::vector::max_size
The pkt_tbl points to the packet vector table. Application can edit the packet handles in the table directly (up to odp_pool_param_t::vector::max_size). Application must update the size of the table using odp_packet_vector_size_set() when there is a change in the size of the vector.
Invalid packet handles (ODP_PACKET_INVALID) are not allowed to be stored in the table to allow consumers of odp_packet_vector_t handle to have optimized implementation. So consumption of packets in the middle of the vector would call for moving the remaining packets up to form a contiguous array of packets and update the size of the new vector using odp_packet_vector_size_set().
The table memory is backed by a vector pool buffer. The ownership of the table memory is linked to the ownership of the event. I.e. after sending the event to a queue, the sender loses ownership to the table also.
Examples
odp_ipsec.c, and odp_l2fwd.c.

◆ odp_packet_vector_size()

uint32_t odp_packet_vector_size ( odp_packet_vector_t  pktv)

Number of packets in a vector.

Parameters
pktvPacket vector handle
Returns
The number of packets available in the vector
Examples
odp_ipsec.c.

◆ odp_packet_vector_size_set()

void odp_packet_vector_size_set ( odp_packet_vector_t  pktv,
uint32_t  size 
)

Set the number of packets stored in a vector.

Update the number of packets stored in a vector. When the application is producing a packet vector, this function shall be used by the application to set the number of packets available in this vector.

Parameters
pktvPacket vector handle
sizeNumber of packets in this vector
Note
The maximum number of packets this vector can hold is defined by odp_pool_param_t::vector::max_size. The size value must not be greater than odp_pool_param_t::vector::max_size
All handles in the vector table (0 .. size - 1) need to be valid packet handles.
See also
odp_packet_vector_tbl()

◆ odp_packet_vector_user_area()

void* odp_packet_vector_user_area ( odp_packet_vector_t  pktv)

Packet vector user area.

Returns pointer to the user area associated with the packet vector. Size of the area is fixed and defined in vector pool parameters.

Parameters
pktvPacket vector handle
Returns
Pointer to the user area of the packet vector
Return values
NULLThe packet vector does not have user area
Examples
odp_pool_latency.c.

◆ odp_packet_vector_user_flag()

int odp_packet_vector_user_flag ( odp_packet_vector_t  pktv)

Check user flag.

Implementation clears user flag during new packet vector creation (e.g. alloc and packet input) and reset. User may set the flag with odp_packet_vector_user_flag_set(). Implementation never sets the flag, only clears it. The flag may be useful e.g. to mark when the user area content is valid.

Parameters
pktvPacket vector handle
Return values
0User flag is clear
>0User flag is set

◆ odp_packet_vector_user_flag_set()

void odp_packet_vector_user_flag_set ( odp_packet_vector_t  pktv,
int  val 
)

Set user flag.

Set (or clear) the user flag.

Parameters
pktvPacket vector handle
valNew value for the flag. Zero clears the flag, other values set the flag.

◆ odp_packet_vector_valid()

int odp_packet_vector_valid ( odp_packet_vector_t  pktv)

Check that packet vector is valid.

This function can be used for debugging purposes to check if a packet vector handle represents a valid packet vector. The level of error checks depends on the implementation. Considerable number of cpu cycles may be consumed depending on the level. The call should not crash if the packet vector handle is corrupted.

Parameters
pktvPacket vector handle
Return values
0Packet vector is not valid
1Packet vector is valid

◆ odp_packet_vector_pool()

odp_pool_t odp_packet_vector_pool ( odp_packet_vector_t  pktv)

Packet vector pool.

Returns handle to the packet vector pool where the packet vector was allocated from.

Parameters
pktvPacket vector handle
Returns
Packet vector pool handle

◆ odp_packet_vector_print()

void odp_packet_vector_print ( odp_packet_vector_t  pktv)

Print packet vector debug information.

Print all packet vector debug information to ODP log.

Parameters
pktvPacket vector handle

◆ odp_packet_vector_to_u64()

uint64_t odp_packet_vector_to_u64 ( odp_packet_vector_t  hdl)

Get printable value for an odp_packet_vector_t.

Parameters
hdlodp_packet_vector_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_packet_vector_t handle.

◆ odp_packet_reass_status()

odp_packet_reass_status_t odp_packet_reass_status ( odp_packet_t  pkt)

Check reassembly status of the packet.

Parameters
pktPacket handle
Returns
Reassembly status

◆ odp_packet_tx_compl_from_event()

odp_packet_tx_compl_t odp_packet_tx_compl_from_event ( odp_event_t  ev)

Get packet Tx completion handle from event.

Converts an ODP_EVENT_PACKET_TX_COMPL type event to packet Tx completion handle.

Parameters
evEvent handle
Returns
Packet Tx completion handle
See also
odp_event_type()

◆ odp_packet_tx_compl_to_event()

odp_event_t odp_packet_tx_compl_to_event ( odp_packet_tx_compl_t  tx_compl)

Convert packet Tx completion to event.

Parameters
tx_complPacket Tx completion
Returns
Event handle

◆ odp_packet_tx_compl_free()

void odp_packet_tx_compl_free ( odp_packet_tx_compl_t  tx_compl)

Free packet Tx completion.

Frees the packet Tx completion back to platform. It frees packet Tx completion that gets allocated as part of packet Tx completion request for a given packet.

Parameters
tx_complPacket Tx completion handle
See also
odp_packet_tx_compl_request()

◆ odp_packet_tx_compl_user_ptr()

void* odp_packet_tx_compl_user_ptr ( odp_packet_tx_compl_t  tx_compl)

User context pointer.

Return user context pointer from packet Tx completion event. This is the same value set to packet using odp_packet_user_ptr_set().

Parameters
tx_complPacket Tx completion handle
Returns
User context pointer
See also
odp_packet_user_ptr_set()

◆ odp_packet_tx_compl_done()

int odp_packet_tx_compl_done ( odp_pktio_t  pktio,
uint32_t  compl_id 
)

Check packet transmit completion.

Checks if a previously sent packet with a ODP_PACKET_TX_COMPL_POLL type transmit completion request (see odp_packet_tx_compl_opt_t) has been transmitted. The packet send function call clears completion identifier status, and 0 is returned while the transmit is in progress. When >0 is returned, transmit of the packet is complete and the completion identifier may be reused for another transmit.

When transmit of a packet is complete, it indicates that transmit of other packets sent before the packet through the same queue have also completed.

Returns initially 0 for all configured completion identifiers.

Parameters
pktioPacket IO interface that was used to send the packet
compl_idCompletion identifier that was used in the transmit completion request
Return values
>0Packet transmit is complete
0Packet transmit is not complete
<0Failed to read packet transmit status
Examples
odp_l2fwd.c.

◆ odp_packet_print()

void odp_packet_print ( odp_packet_t  pkt)

Print packet debug information.

Print all packet debug information to the ODP log.

Parameters
pktPacket handle
Examples
odp_debug.c, and odp_packet_dump.c.

◆ odp_packet_print_data()

void odp_packet_print_data ( odp_packet_t  pkt,
uint32_t  offset,
uint32_t  len 
)

Print packet data.

Print packet debug information with packet data to the ODP log. Operation prints 'len' bytes of packet data starting from 'offset' byte. Offset plus length must not exceed packet length (odp_packet_len()).

Parameters
pktPacket handle
offsetByte offset into the packet
lenNumber of bytes to print
Examples
odp_classifier.c, odp_debug.c, and odp_ipsec.c.

◆ odp_packet_is_valid()

int odp_packet_is_valid ( odp_packet_t  pkt)

Check that packet is valid.

This function can be used for debugging purposes to check if a packet handle represents a valid packet. The level of error checks depends on the implementation. Considerable number of cpu cycles may be consumed depending on the level. The call should not crash if the packet handle is corrupted.

Parameters
pktPacket handle
Return values
0Packet is not valid
1Packet is valid
Examples
odp_ipfragreass.c, and odp_pktio.c.

◆ odp_packet_to_u64()

uint64_t odp_packet_to_u64 ( odp_packet_t  hdl)

Get printable value for an odp_packet_t.

Parameters
hdlodp_packet_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_packet_t handle.

◆ odp_packet_seg_to_u64()

uint64_t odp_packet_seg_to_u64 ( odp_packet_seg_t  hdl)

Get printable value for an odp_packet_seg_t.

Parameters
hdlodp_packet_seg_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_packet_seg_t handle.

◆ odp_packet_has_error()

int odp_packet_has_error ( odp_packet_t  pkt)

Check for all parse errors in packet.

Check if packet parsing has found any errors in the packet. The level of error checking depends on the parse configuration (e.g. included layers and checksums). Protocol layer functions (e.g. odp_packet_has_l3()) indicate which layers have been checked, and layer error functions (e.g. odp_packet_has_l3_error()) which layers have errors.

If packet subtype is ODP_EVENT_PACKET_IPSEC, odp_packet_has_error() would indicate parsing errors after IPSEC processing. IPSEC errors/warnings need to be checked using odp_ipsec_result().

Parameters
pktPacket handle
Return values
non-zeroPacket has errors
0No errors were found
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_classifier.c, odp_ipsecfwd.c, odp_l2fwd.c, odp_l3fwd.c, odp_ping.c, and odp_pktio.c.

◆ odp_packet_has_l2_error()

int odp_packet_has_l2_error ( odp_packet_t  pkt)

Check for errors in layer 2.

When layer 2 is included in the parse configuration, check if any errors were found in layer 2 of the packet.

Parameters
pktPacket handle
Return values
non-zeroPacket has errors in layer 2
0No errors were found in layer 2

◆ odp_packet_has_l3_error()

int odp_packet_has_l3_error ( odp_packet_t  pkt)

Check for errors in layer 3.

When layer 3 is included in the parse configuration, check if any errors were found in layer 3 of the packet.

Parameters
pktPacket handle
Return values
non-zeroPacket has errors in layer 3
0No errors found in layer 3

◆ odp_packet_has_l4_error()

int odp_packet_has_l4_error ( odp_packet_t  pkt)

Check for errors in layer 4.

When layer 4 is included in the parse configuration, check if any errors were found in layer 4 of the packet.

Parameters
pktPacket handle
Return values
non-zeroPacket has errors in layer 4
0No errors were found in layer 4

◆ odp_packet_has_l2()

int odp_packet_has_l2 ( odp_packet_t  pkt)

Check for layer 2 protocols.

When layer 2 is included in the parse configuration, check if packet parsing has found and checked a layer 2 protocol (e.g. Ethernet) in the packet.

Parameters
pktPacket handle
Return values
non-zeroA layer 2 protocol header was found and checked
0No layer 2 protocol was found
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_has_l3()

int odp_packet_has_l3 ( odp_packet_t  pkt)

Check for layer 3 protocols.

When layer 3 is included in the parse configuration, check if packet parsing has found and checked a layer 3 protocol (e.g. IPv4, IPv6) in the packet.

Parameters
pktPacket handle
Return values
non-zeroA layer 3 protocol header was found and checked
0No layer 3 protocol was found
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_has_l4()

int odp_packet_has_l4 ( odp_packet_t  pkt)

Check for layer 4 protocols.

When layer 4 is included in the parse configuration, check if packet parsing has found and checked a layer 4 protocol (e.g. UDP, TCP, SCTP) in the packet.

Parameters
pktPacket handle
Return values
non-zeroA layer 4 protocol header was found and checked
0No layer 4 protocol was found
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_has_eth()

int odp_packet_has_eth ( odp_packet_t  pkt)

Check for Ethernet header.

Parameters
pktPacket handle
Return values
non-zeroPacket contains an Ethernet header
0Packet does not contain an Ethernet header
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_classifier.c, odp_l2fwd_simple.c, odp_packet_dump.c, odp_ping.c, odp_pktio.c, odp_pktio_ordered.c, odp_simple_pipeline.c, and odp_switch.c.

◆ odp_packet_has_eth_bcast()

int odp_packet_has_eth_bcast ( odp_packet_t  pkt)

Check for Ethernet broadcast address.

ODP recognizes the destination MAC address FF:FF:FF:FF:FF:FF as a broadcast address. All others are considered non-broadcast.

Parameters
pktPacket handle
Return values
non-zeroEthernet destination address is the broadcast address
0Ethernet destination address is not the broadcast address

◆ odp_packet_has_eth_mcast()

int odp_packet_has_eth_mcast ( odp_packet_t  pkt)

Check for Ethernet multicast address.

ODP recognizes the destination MAC address as multicast if bit 7 is 1.

Parameters
pktPacket handle
Return values
non-zeroEthernet destination address is a multicast address
0Ethernet destination address is not a multicast address

◆ odp_packet_has_jumbo()

int odp_packet_has_jumbo ( odp_packet_t  pkt)

Check for jumbo frame.

Parameters
pktPacket handle
Return values
non-zeroPacket is a jumbo frame
0Packet is not a jumbo frame

◆ odp_packet_has_vlan()

int odp_packet_has_vlan ( odp_packet_t  pkt)

Check for VLAN.

Check if packet contains normal or QinQ VLAN header.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a VLAN header
0Packet does not contain a VLAN header
Examples
odp_packet_dump.c.

◆ odp_packet_has_vlan_qinq()

int odp_packet_has_vlan_qinq ( odp_packet_t  pkt)

Check for VLAN QinQ (stacked VLAN)

Check if packet contains QinQ VLAN header.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a VLAN QinQ header
0Packet does not contain a VLAN QinQ header
Examples
odp_packet_dump.c.

◆ odp_packet_has_arp()

int odp_packet_has_arp ( odp_packet_t  pkt)

Check for ARP.

Parameters
pktPacket handle
Return values
non-zeroPacket contains an ARP message
0Packet does not contain an ARP message

◆ odp_packet_has_ipv4()

int odp_packet_has_ipv4 ( odp_packet_t  pkt)

Check for IPv4.

Parameters
pktPacket handle
Return values
non-zeroPacket contains an IPv4 header
0Packet does not contain an IPv4 header
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_classifier.c, odp_l3fwd.c, odp_packet_dump.c, odp_ping.c, and odp_pktio.c.

◆ odp_packet_has_ipv6()

int odp_packet_has_ipv6 ( odp_packet_t  pkt)

Check for IPv6.

Parameters
pktPacket handle
Return values
non-zeroPacket contains an IPv6 header
0Packet does not contain an IPv6 header
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_has_ip_bcast()

int odp_packet_has_ip_bcast ( odp_packet_t  pkt)

Check for IP broadcast address.

For IPv4, ODP recognizes the destination IP address 255.255.255.255 as a broadcast address. All other addresses are considered non-broadcast.

For IPv6, no destination addresses are recognized as broadcast addresses.

Parameters
pktPacket handle
Return values
non-zeroIP destination address is a broadcast address
0IP destination address is not a broadcast address

◆ odp_packet_has_ip_mcast()

int odp_packet_has_ip_mcast ( odp_packet_t  pkt)

Check for IP multicast address.

For IPv4 ODP recognizes destination IP addresses in the range 224.0.0.0 through 239.255.255.255 as multicast addresses.

For IPv6 ODP recognizes destination IP addresses with prefixes FF00:: through FFFF:: as multicast addresses.

Parameters
pktPacket handle
Return values
non-zeroIP destination address is a multicast address
0IP destination address is not a multicast address

◆ odp_packet_has_ipfrag()

int odp_packet_has_ipfrag ( odp_packet_t  pkt)

Check for IP fragment.

Parameters
pktPacket handle
Return values
non-zeroPacket is an IP fragment
0Packet is not an IP fragment

◆ odp_packet_has_ipopt()

int odp_packet_has_ipopt ( odp_packet_t  pkt)

Check for IP options.

Parameters
pktPacket handle
Return values
non-zeroPacket contains IP options
0Packet does not contain IP options

◆ odp_packet_has_ipsec()

int odp_packet_has_ipsec ( odp_packet_t  pkt)

Check for IPSec.

Parameters
pktPacket handle
Return values
non-zeroPacket requires IPSec processing
0Packet does not require IPSec processing
Examples
odp_ipsecfwd.c.

◆ odp_packet_has_udp()

int odp_packet_has_udp ( odp_packet_t  pkt)

Check for UDP.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a UDP header
0Packet does not contain a UDP header
Examples
odp_ipsecfwd.c, odp_l3fwd.c, and odp_packet_dump.c.

◆ odp_packet_has_tcp()

int odp_packet_has_tcp ( odp_packet_t  pkt)

Check for TCP.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a TCP header
0Packet does not contain a TCP header
Examples
odp_l3fwd.c, and odp_packet_dump.c.

◆ odp_packet_has_sctp()

int odp_packet_has_sctp ( odp_packet_t  pkt)

Check for SCTP.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a SCTP header
0Packet does not contain a SCTP header
Examples
odp_packet_dump.c.

◆ odp_packet_has_icmp()

int odp_packet_has_icmp ( odp_packet_t  pkt)

Check for ICMP.

Parameters
pktPacket handle
Return values
non-zeroPacket contains an ICMP header
0Packet does not contain an ICMP header
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_has_flow_hash()

int odp_packet_has_flow_hash ( odp_packet_t  pkt)

Check for packet flow hash.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a hash value
0Packet does not contain a hash value
Examples
odp_sched_pktio.c.

◆ odp_packet_has_ts()

int odp_packet_has_ts ( odp_packet_t  pkt)

Check for packet timestamp.

Parameters
pktPacket handle
Return values
non-zeroPacket contains a timestamp value
0Packet does not contain a timestamp value
See also
odp_packet_has_ts_clr()
Examples
odp_packet_dump.c, and odp_ping.c.

◆ odp_packet_has_l2_set()

void odp_packet_has_l2_set ( odp_packet_t  pkt,
int  val 
)

Set flag for L2 header, e.g.

ethernet

Parameters
pktPacket handle
valValue

◆ odp_packet_has_l3_set()

void odp_packet_has_l3_set ( odp_packet_t  pkt,
int  val 
)

Set flag for L3 header, e.g.

IPv4, IPv6

Parameters
pktPacket handle
valValue

◆ odp_packet_has_l4_set()

void odp_packet_has_l4_set ( odp_packet_t  pkt,
int  val 
)

Set flag for L4 header, e.g.

UDP, TCP, SCTP (also ICMP)

Parameters
pktPacket handle
valValue

◆ odp_packet_has_eth_set()

void odp_packet_has_eth_set ( odp_packet_t  pkt,
int  val 
)

Set flag for Ethernet header.

Parameters
pktPacket handle
valValue
Examples
odp_packet_gen.c.

◆ odp_packet_has_eth_bcast_set()

void odp_packet_has_eth_bcast_set ( odp_packet_t  pkt,
int  val 
)

Set flag for Ethernet broadcast address.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_eth_mcast_set()

void odp_packet_has_eth_mcast_set ( odp_packet_t  pkt,
int  val 
)

Set flag for Ethernet multicast address.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_jumbo_set()

void odp_packet_has_jumbo_set ( odp_packet_t  pkt,
int  val 
)

Set flag for jumbo frame.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_vlan_set()

void odp_packet_has_vlan_set ( odp_packet_t  pkt,
int  val 
)

Set flag for VLAN.

Set when packet contains normal VLAN header. Only one VLAN flag (VLAN/VLAN QinQ) can be set simultaneously.

Parameters
pktPacket handle
valValue
Examples
odp_packet_gen.c.

◆ odp_packet_has_vlan_qinq_set()

void odp_packet_has_vlan_qinq_set ( odp_packet_t  pkt,
int  val 
)

Set flag for VLAN QinQ (stacked VLAN)

Set when packet contains QinQ VLAN header. Only one VLAN flag (VLAN/VLAN QinQ) can be set simultaneously.

Parameters
pktPacket handle
valValue
Examples
odp_packet_gen.c.

◆ odp_packet_has_arp_set()

void odp_packet_has_arp_set ( odp_packet_t  pkt,
int  val 
)

Set flag for ARP.

Only one of ARP/IPv4/IPv6 flags can be set simultaneously.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_ipv4_set()

void odp_packet_has_ipv4_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IPv4.

Only one of ARP/IPv4/IPv6 flags can be set simultaneously.

Parameters
pktPacket handle
valValue
Examples
odp_packet_gen.c.

◆ odp_packet_has_ipv6_set()

void odp_packet_has_ipv6_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IPv6.

Only one of ARP/IPv4/IPv6 flags can be set simultaneously.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_ip_bcast_set()

void odp_packet_has_ip_bcast_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IP broadcast address.

Only one of IP broadcast/multicast flags can be set simultaneously.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_ip_mcast_set()

void odp_packet_has_ip_mcast_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IP multicast address.

Only one of IP broadcast/multicast flags can be set simultaneously.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_ipfrag_set()

void odp_packet_has_ipfrag_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IP fragment.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_ipopt_set()

void odp_packet_has_ipopt_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IP options.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_ipsec_set()

void odp_packet_has_ipsec_set ( odp_packet_t  pkt,
int  val 
)

Set flag for IPSec.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_udp_set()

void odp_packet_has_udp_set ( odp_packet_t  pkt,
int  val 
)

Set flag for UDP.

Only one of TCP/UDP/SCTP/ICMP flags can be set simultaneously.

Parameters
pktPacket handle
valValue
Examples
odp_packet_gen.c.

◆ odp_packet_has_tcp_set()

void odp_packet_has_tcp_set ( odp_packet_t  pkt,
int  val 
)

Set flag for TCP.

Only one of TCP/UDP/SCTP/ICMP flags can be set simultaneously.

Parameters
pktPacket handle
valValue
Examples
odp_packet_gen.c.

◆ odp_packet_has_sctp_set()

void odp_packet_has_sctp_set ( odp_packet_t  pkt,
int  val 
)

Set flag for SCTP.

Only one of TCP/UDP/SCTP/ICMP flags can be set simultaneously.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_icmp_set()

void odp_packet_has_icmp_set ( odp_packet_t  pkt,
int  val 
)

Set flag for ICMP.

Only one of TCP/UDP/SCTP/ICMP flags can be set simultaneously.

Parameters
pktPacket handle
valValue

◆ odp_packet_has_flow_hash_clr()

void odp_packet_has_flow_hash_clr ( odp_packet_t  pkt)

Clear flag for packet flow hash.

Parameters
pktPacket handle
Note
Set this flag is only possible through odp_packet_flow_hash_set()

◆ odp_packet_has_ts_clr()

void odp_packet_has_ts_clr ( odp_packet_t  pkt)

Clear flag for packet timestamp.

This call clears the timestamp flag. A odp_packet_ts_set() call sets the flag in addition to the timestamp value.

Parameters
pktPacket handle
See also
odp_packet_has_ts(), odp_packet_ts_set()