diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/odp/api/abi-default/event.h | 11 | ||||
-rw-r--r-- | include/odp/api/abi-default/packet.h | 5 | ||||
-rw-r--r-- | include/odp/api/protocols.h | 26 | ||||
-rw-r--r-- | include/odp/api/spec/buffer.h | 14 | ||||
-rw-r--r-- | include/odp/api/spec/classification.h | 44 | ||||
-rw-r--r-- | include/odp/api/spec/event.h | 16 | ||||
-rw-r--r-- | include/odp/api/spec/ipsec.h | 175 | ||||
-rw-r--r-- | include/odp/api/spec/packet.h | 193 | ||||
-rw-r--r-- | include/odp/api/spec/packet_flags.h | 6 | ||||
-rw-r--r-- | include/odp/api/spec/packet_io.h | 83 | ||||
-rw-r--r-- | include/odp/api/spec/pool.h | 189 | ||||
-rw-r--r-- | include/odp/api/spec/protocols.h | 44 | ||||
-rw-r--r-- | include/odp/api/spec/timer.h | 21 |
14 files changed, 813 insertions, 16 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 32d8a6825..911cd92f9 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -34,6 +34,7 @@ odpapiinclude_HEADERS = \ odp/api/packet_flags.h \ odp/api/packet_io.h \ odp/api/packet_io_stats.h \ + odp/api/protocols.h \ odp/api/pool.h \ odp/api/queue.h \ odp/api/random.h \ @@ -84,6 +85,7 @@ odpapispecinclude_HEADERS = \ odp/api/spec/packet_flags.h \ odp/api/spec/packet_io.h \ odp/api/spec/packet_io_stats.h \ + odp/api/spec/protocols.h \ odp/api/spec/pool.h \ odp/api/spec/queue.h \ odp/api/spec/queue_types.h \ diff --git a/include/odp/api/abi-default/event.h b/include/odp/api/abi-default/event.h index c9d03735c..a63571ca0 100644 --- a/include/odp/api/abi-default/event.h +++ b/include/odp/api/abi-default/event.h @@ -25,15 +25,16 @@ typedef _odp_abi_event_t *odp_event_t; #define ODP_EVENT_INVALID ((odp_event_t)0) typedef enum { - ODP_EVENT_BUFFER = 1, - ODP_EVENT_PACKET = 2, - ODP_EVENT_TIMEOUT = 3, + ODP_EVENT_BUFFER = 1, + ODP_EVENT_PACKET = 2, + ODP_EVENT_TIMEOUT = 3, ODP_EVENT_CRYPTO_COMPL = 4, - ODP_EVENT_IPSEC_STATUS = 5 + ODP_EVENT_IPSEC_STATUS = 5, + ODP_EVENT_PACKET_VECTOR = 6 } odp_event_type_t; typedef enum { - ODP_EVENT_NO_SUBTYPE = 0, + ODP_EVENT_NO_SUBTYPE = 0, ODP_EVENT_PACKET_BASIC = 1, ODP_EVENT_PACKET_CRYPTO = 2, ODP_EVENT_PACKET_IPSEC = 3, diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h index 57e255c57..3660cfa29 100644 --- a/include/odp/api/abi-default/packet.h +++ b/include/odp/api/abi-default/packet.h @@ -19,16 +19,21 @@ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_packet_t; /** @internal Dummy type for strong typing */ typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_seg_t; +/** @internal Dummy type for strong typing */ +typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_vector_t; + /** @ingroup odp_packet * @{ */ typedef _odp_abi_packet_t *odp_packet_t; typedef _odp_abi_packet_seg_t *odp_packet_seg_t; +typedef _odp_abi_packet_vector_t *odp_packet_vector_t; #define ODP_PACKET_INVALID ((odp_packet_t)0) #define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)0) #define ODP_PACKET_OFFSET_INVALID 0xffff +#define ODP_PACKET_VECTOR_INVALID ((odp_packet_vector_t)0) typedef uint8_t odp_proto_l2_type_t; diff --git a/include/odp/api/protocols.h b/include/odp/api/protocols.h new file mode 100644 index 000000000..b5f3742a4 --- /dev/null +++ b/include/odp/api/protocols.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2020, Marvell + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP protocols + */ + +#ifndef ODP_API_PROTOCOLS_H_ +#define ODP_API_PROTOCOLS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/spec/protocols.h> + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/odp/api/spec/buffer.h b/include/odp/api/spec/buffer.h index 28eb7669b..82f5e2f72 100644 --- a/include/odp/api/spec/buffer.h +++ b/include/odp/api/spec/buffer.h @@ -74,7 +74,11 @@ void *odp_buffer_addr(odp_buffer_t buf); uint32_t odp_buffer_size(odp_buffer_t buf); /** - * Tests if buffer is valid + * Check that buffer is valid + * + * This function can be used for debugging purposes to check if a buffer handle represents + * a valid buffer. The level of error checks depends on the implementation. The call should not + * crash if the buffer handle is corrupted. * * @param buf Buffer handle * @@ -95,8 +99,8 @@ odp_pool_t odp_buffer_pool(odp_buffer_t buf); /** * Buffer alloc * - * The validity of a buffer can be checked at any time with - * odp_buffer_is_valid(). + * Allocates a buffer from the pool. Returns ODP_BUFFER_INVALID when a buffer + * can not be allocated. * * @param pool Pool handle * @@ -107,8 +111,8 @@ odp_buffer_t odp_buffer_alloc(odp_pool_t pool); /** * Allocate multiple buffers - - * Otherwise like odp_buffer_alloc(), but allocates multiple buffers from a pool + * + * Otherwise like odp_buffer_alloc(), but allocates multiple buffers from a pool. * * @param pool Pool handle * @param[out] buf Array of buffer handles for output diff --git a/include/odp/api/spec/classification.h b/include/odp/api/spec/classification.h index 176c53ff3..c33aca13f 100644 --- a/include/odp/api/spec/classification.h +++ b/include/odp/api/spec/classification.h @@ -103,7 +103,20 @@ typedef union odp_cls_pmr_terms_t { /** Custom layer 3 match rule. PMR offset is counted from * the start of layer 3 in the packet. */ uint64_t custom_l3:1; - + /** IGMP Group address, implies IPPROTO=2 */ + uint64_t igmp_grp_addr:1; + /** ICMP identifier, implies IPPROTO=1 and ICMP_TYPE=0 or ICMP_TYPE=8 */ + uint64_t icmp_id:1; + /** ICMP type, implies IPPROTO=1 */ + uint64_t icmp_type:1; + /** ICMP code, implies IPPROTO=1 */ + uint64_t icmp_code:1; + /** Source SCTP port, implies IPPROTO=132 */ + uint64_t sctp_sport:1; + /** Destination SCTP port, implies IPPROTO=132 */ + uint64_t sctp_dport:1; + /** GTPv1 tunnel endpoint identifier */ + uint64_t gtpv1_teid:1; } bit; /** All bits of the bit field structure */ uint64_t all_bits; @@ -285,6 +298,9 @@ typedef struct odp_cls_cos_param { /** Back Pressure configuration */ odp_bp_param_t bp; + + /** Packet input vector configuration */ + odp_pktin_vector_config_t vector; } odp_cls_cos_param_t; /** @@ -552,6 +568,32 @@ typedef enum { */ ODP_PMR_CUSTOM_L3, + /** IGMP Group address (val_sz = 4), implies IPPROTO=2 */ + ODP_PMR_IGMP_GRP_ADDR, + + /** ICMP identifier (val_sz = 2), implies IPPROTO=1 and ICMP_TYPE=0 or ICMP_TYPE=8 */ + ODP_PMR_ICMP_ID, + + /** ICMP type (val_sz = 1), implies IPPROTO=1 */ + ODP_PMR_ICMP_TYPE, + + /** ICMP code (val_sz = 1), implies IPPROTO=1 */ + ODP_PMR_ICMP_CODE, + + /** Source SCTP port (val_sz = 2), implies IPPROTO=132 */ + ODP_PMR_SCTP_SPORT, + + /** Destination SCTP port (val_sz = 2), implies IPPROTO=132 */ + ODP_PMR_SCTP_DPORT, + + /** GTPv1 tunnel endpoint identifier (val_sz = 4) + * + * Matches if and only if IP protocol is UDP, UDP destination port + * is 2152 and the UDP payload interpreted as GTP header has GTP + * version 1 and TEID as specified. + */ + ODP_PMR_GTPV1_TEID, + /** Inner header may repeat above values with this offset */ ODP_PMR_INNER_HDR_OFF = 32 diff --git a/include/odp/api/spec/event.h b/include/odp/api/spec/event.h index f9fe17dac..dc61b6e31 100644 --- a/include/odp/api/spec/event.h +++ b/include/odp/api/spec/event.h @@ -58,6 +58,8 @@ extern "C" { * - Crypto completion event (odp_crypto_compl_t) * - ODP_EVENT_IPSEC_STATUS * - IPSEC status update event (odp_ipsec_status_t) + * - ODP_EVENT_PACKET_VECTOR + * - Vector of packet events (odp_packet_t) as odp_packet_vector_t */ /** @@ -180,6 +182,20 @@ int odp_event_filter_packet(const odp_event_t event[], uint64_t odp_event_to_u64(odp_event_t hdl); /** + * Check that event is valid + * + * This function can be used for debugging purposes to check if an event handle represents + * a valid event. The level of error checks depends on the implementation. The call should not + * crash if the event handle is corrupted. + * + * @param event Event handle + * + * @retval 1 Event handle represents a valid event. + * @retval 0 Event handle does not represent a valid event. + */ +int odp_event_is_valid(odp_event_t event); + +/** * Free event * * Frees the event based on its type. Results are undefined if event diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h index 48b046e43..156d66019 100644 --- a/include/odp/api/spec/ipsec.h +++ b/include/odp/api/spec/ipsec.h @@ -21,6 +21,7 @@ extern "C" { #include <odp/api/crypto.h> #include <odp/api/support.h> #include <odp/api/packet_io.h> +#include <odp/api/protocols.h> #include <odp/api/classification.h> #include <odp/api/traffic_mngr.h> @@ -320,6 +321,14 @@ typedef struct odp_ipsec_config_t { /** IPSEC outbound processing configuration */ odp_ipsec_outbound_config_t outbound; + /** Enable stats collection + * + * Default value is false (stats collection disabled). + * + * @see odp_ipsec_stats(), odp_ipsec_stats_multi() + */ + odp_bool_t stats_en; + } odp_ipsec_config_t; /** @@ -773,6 +782,105 @@ typedef struct odp_ipsec_sa_param_t { } odp_ipsec_sa_param_t; /** + * IPSEC stats content + */ +typedef struct odp_ipsec_stats_t { + /** Number of packets processed successfully */ + uint64_t success; + + /** Number of packets with protocol errors */ + uint64_t proto_err; + + /** Number of packets with authentication errors */ + uint64_t auth_err; + + /** Number of packets with antireplay check failures */ + uint64_t antireplay_err; + + /** Number of packets with algorithm errors */ + uint64_t alg_err; + + /** Number of packes with MTU errors */ + uint64_t mtu_err; + + /** Number of packets with hard lifetime(bytes) expired */ + uint64_t hard_exp_bytes_err; + + /** Number of packets with hard lifetime(packets) expired */ + uint64_t hard_exp_pkts_err; +} odp_ipsec_stats_t; + +/** + * IPSEC SA information + */ +typedef struct odp_ipsec_sa_info_t { + /** Copy of IPSEC Security Association (SA) parameters */ + odp_ipsec_sa_param_t param; + + /** IPSEC SA direction dependent parameters */ + union { + /** Inbound specific parameters */ + struct { + /** Additional SA lookup parameters. */ + struct { + /** IP destination address (NETWORK ENDIAN) to + * be matched in addition to SPI value. */ + uint8_t dst_addr[ODP_IPV6_ADDR_SIZE]; + } lookup_param; + + /** Antireplay window size + * + * Antireplay window size configured for the SA. + * This value can be different from what application + * had requested. + */ + uint32_t antireplay_ws; + + /** Antireplay window top + * + * Sequence number representing a recent top of the + * anti-replay window. There may be a delay before the + * SA state is reflected in the value. The value will be + * zero if no packets have been processed or if the + * anti-replay service is not enabled. + */ + uint64_t antireplay_window_top; + } inbound; + + /** Outbound specific parameters */ + struct { + /** Sequence number + * + * Sequence number used for a recently processed packet. + * There may be a delay before the SA state is reflected + * in the value. When no packets have been processed, + * the value will be zero. + */ + uint64_t seq_num; + + /** Tunnel IP address */ + union { + /** IPv4 */ + struct { + /** IPv4 source address */ + uint8_t src_addr[ODP_IPV4_ADDR_SIZE]; + /** IPv4 destination address */ + uint8_t dst_addr[ODP_IPV4_ADDR_SIZE]; + } ipv4; + + /** IPv6 */ + struct { + /** IPv6 source address */ + uint8_t src_addr[ODP_IPV6_ADDR_SIZE]; + /** IPv6 destination address */ + uint8_t dst_addr[ODP_IPV6_ADDR_SIZE]; + } ipv6; + } tunnel; + } outbound; + }; +} odp_ipsec_sa_info_t; + +/** * Query IPSEC capabilities * * Outputs IPSEC capabilities on success. @@ -1189,7 +1297,13 @@ typedef struct odp_ipsec_out_inline_param_t { struct { /** Points to first byte of outer headers to be copied in * front of the outgoing IPSEC packet. Implementation copies - * the headers during odp_ipsec_out_inline() call. */ + * the headers during odp_ipsec_out_inline() call. + * + * Null value indicates that the outer headers are in the + * packet data, starting at L2 offset and ending at the byte + * before L3 offset. In this case, value of 'len' field must + * be greater than zero and set to L3 offset minus L2 offset. + */ const uint8_t *ptr; /** Outer header length in bytes */ @@ -1627,6 +1741,65 @@ int odp_ipsec_sa_mtu_update(odp_ipsec_sa_t sa, uint32_t mtu); void *odp_ipsec_sa_context(odp_ipsec_sa_t sa); /** + * Print global IPSEC configuration info + * + * Print implementation-defined information about the global IPSEC + * configuration. + */ +void odp_ipsec_print(void); + +/** + * Print IPSEC SA info + * + * @param sa SA handle + * + * Print implementation-defined IPSEC SA debug information to the ODP log. + */ +void odp_ipsec_sa_print(odp_ipsec_sa_t sa); + +/** + * Get IPSEC stats for the IPSEC SA handle + * + * @param sa IPSEC SA handle + * @param[out] stats Stats output + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_ipsec_stats(odp_ipsec_sa_t sa, odp_ipsec_stats_t *stats); + +/** + * Get IPSEC stats for multiple IPSEC SA handles + * + * @param sa Array of IPSEC SA handles + * @param[out] stats Stats array for output + * @param num Number of SA handles + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_ipsec_stats_multi(odp_ipsec_sa_t sa[], odp_ipsec_stats_t stats[], int num); + +/** + * Retrieve information about an IPSEC SA + * + * The cipher and auth key data(including key extra) will not be exposed and + * the corresponding pointers will be set to NULL. The IP address pointers + * will point to the corresponding buffers available in the SA info structure. + * + * The user defined SA context pointer is an opaque field and hence the value + * provided during the SA creation will be returned. + * + * @param sa The IPSEC SA for which to retrieve information + * @param[out] sa_info Pointer to caller allocated SA info structure to be + * filled in + * + * @retval 0 On success + * @retval <0 On failure + **/ +int odp_ipsec_sa_info(odp_ipsec_sa_t sa, odp_ipsec_sa_info_t *sa_info); + +/** * @} */ diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index fa56b5d02..44fc75924 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -177,6 +177,16 @@ extern "C" { */ /** + * @typedef odp_packet_vector_t + * ODP packet vector + */ + +/** + * @def ODP_PACKET_VECTOR_INVALID + * Invalid packet vector + */ + +/** * Protocol */ typedef enum odp_proto_t { @@ -2027,6 +2037,181 @@ uint64_t odp_packet_cls_mark(odp_packet_t pkt); /* * + * Packet vector handling routines + * ******************************************************** + * + */ + +/** + * Get packet vector handle from event + * + * Converts an ODP_EVENT_PACKET_VECTOR type event to a packet vector handle + * + * @param ev Event handle + * @return Packet vector handle + * + * @see odp_event_type() + */ +odp_packet_vector_t odp_packet_vector_from_event(odp_event_t ev); + +/** + * Convert packet vector handle to event + * + * @param pktv Packet vector handle + * + * @return Event handle + */ +odp_event_t odp_packet_vector_to_event(odp_packet_vector_t pktv); + +/** + * 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. + * + * @param pool Packet vector pool handle + * + * @return Handle of allocated packet vector + * @retval ODP_PACKET_VECTOR_INVALID Packet 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. + */ +odp_packet_vector_t odp_packet_vector_alloc(odp_pool_t pool); + +/** + * Free packet vector + * + * Frees the packet vector into the packet vector pool it was allocated from. + * + * @param pktv Packet 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. + */ +void odp_packet_vector_free(odp_packet_vector_t pktv); + +/** + * 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. + * + * @param pktv Packet vector handle + * @param[out] pkt_tbl Points to packet vector table + * + * @return 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. + * + * @note 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 + * + * @note 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. + * + * @note 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(). + * + * @note 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. + */ +uint32_t odp_packet_vector_tbl(odp_packet_vector_t pktv, odp_packet_t **pkt_tbl); + +/** + * Number of packets in a vector + * + * @param pktv Packet vector handle + * + * @return The number of packets available in the vector + */ +uint32_t odp_packet_vector_size(odp_packet_vector_t pktv); + +/** + * 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. + * + * @param pktv Packet vector handle + * @param size Number 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 + * + * @note All handles in the vector table (0 .. size - 1) need to be valid packet + * handles. + * + * @see odp_packet_vector_tbl() + * + */ +void odp_packet_vector_size_set(odp_packet_vector_t pktv, uint32_t size); + +/** + * 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. + * + * @param pktv Packet vector handle + * + * @retval 0 Packet vector is not valid + * @retval 1 Packet vector is valid + */ +int odp_packet_vector_valid(odp_packet_vector_t pktv); + +/** + * Packet vector pool + * + * Returns handle to the packet vector pool where the packet vector was + * allocated from. + * + * @param pktv Packet vector handle + * + * @return Packet vector pool handle + */ +odp_pool_t odp_packet_vector_pool(odp_packet_vector_t pktv); + +/** + * Print packet vector debug information + * + * Print all packet vector debug information to ODP log. + * + * @param pktv Packet vector handle + */ +void odp_packet_vector_print(odp_packet_vector_t pktv); + +/** + * Get printable value for an odp_packet_vector_t + * + * @param hdl odp_packet_vector_t handle to be printed + * + * @return 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. + */ +uint64_t odp_packet_vector_to_u64(odp_packet_vector_t hdl); + +/* + * * Debugging * ******************************************************** * @@ -2055,10 +2240,12 @@ void odp_packet_print(odp_packet_t pkt); void odp_packet_print_data(odp_packet_t pkt, uint32_t offset, uint32_t len); /** - * Perform full packet validity check + * Check that packet is valid * - * The operation may consume considerable number of cpu cycles depending on - * the check level. + * 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. * * @param pkt Packet handle * diff --git a/include/odp/api/spec/packet_flags.h b/include/odp/api/spec/packet_flags.h index 0e4243968..7c1386cb6 100644 --- a/include/odp/api/spec/packet_flags.h +++ b/include/odp/api/spec/packet_flags.h @@ -27,7 +27,7 @@ extern "C" { */ /** - * Check for all errors in packet + * 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 @@ -35,6 +35,10 @@ extern "C" { * 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(). + * * @param pkt Packet handle * * @retval non-zero Packet has errors diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index d25d29751..940b712fa 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -160,6 +160,50 @@ typedef struct odp_pktin_queue_param_ovr_t { } odp_pktin_queue_param_ovr_t; /** + * Packet input vector configuration + */ +typedef struct odp_pktin_vector_config_t { + /** Enable packet input vector + * + * When true, packet input vector is enabled and configured with vector + * config parameters. Otherwise, packet input vector configuration + * parameters are ignored. + */ + odp_bool_t enable; + + /** Vector pool + * + * Vector pool to allocate the vectors to hold packets. + * The pool must have been created with the ODP_POOL_VECTOR type. + */ + odp_pool_t pool; + + /** Maximum time to wait for packets + * + * Maximum timeout in nanoseconds to wait for the producer to form the + * vector of packet events (odp_packet_vector_t). This value should be + * in the range of odp_pktin_vector_capability_t::min_tmo_ns to + * odp_pktin_vector_capability_t::max_tmo_ns. + */ + uint64_t max_tmo_ns; + + /** Maximum number of packets in a vector + * + * The packet input subsystem forms packet vector events when either + * it reaches odp_pktin_vector_config_t::max_tmo_ns or producer reaches + * max_size packets. This value should be in the range of + * odp_pktin_vector_capability_t::min_size to + * odp_pktin_vector_capability_t::max_size. + * + * @note The maximum number of packets this vector can hold is defined + * by odp_pool_param_t::vector::max_size with odp_pktin_vector_config_t::pool. + * The max_size should not be greater than odp_pool_param_t::vector::max_size. + */ + uint32_t max_size; + +} odp_pktin_vector_config_t; + +/** * Packet input queue parameters */ typedef struct odp_pktin_queue_param_t { @@ -226,6 +270,10 @@ typedef struct odp_pktin_queue_param_t { * NULL. */ odp_pktin_queue_param_ovr_t *queue_param_ovr; + + /** Packet input vector configuration */ + odp_pktin_vector_config_t vector; + } odp_pktin_queue_param_t; /** @@ -570,6 +618,37 @@ typedef union odp_pktio_set_op_t { } odp_pktio_set_op_t; /** + * Packet input vector capabilities + */ +typedef struct odp_pktin_vector_capability_t { + /** Packet input vector availability */ + odp_support_t supported; + + /** Maximum number of packets that can be accumulated into a packet + * vector by a producer + * + * odp_pktin_vector_config_t::max_size should not be greater than this + * value. */ + uint32_t max_size; + + /** Minimum value allowed to be configured to + * odp_pktin_vector_config_t::max_size */ + uint32_t min_size; + + /** Maximum timeout in nanoseconds for the producer to wait for the + * vector of packets + * + * odp_pktin_vector_config_t::max_tmo_ns should not be greater than this + * value. */ + uint64_t max_tmo_ns; + + /** Minimum value allowed to be configured to + * odp_pktin_vector_config_t::max_tmo_ns */ + uint64_t min_tmo_ns; + +} odp_pktin_vector_capability_t; + +/** * Packet IO capabilities */ typedef struct odp_pktio_capability_t { @@ -590,6 +669,10 @@ typedef struct odp_pktio_capability_t { /** @deprecated Use enable_loop inside odp_pktin_config_t */ odp_bool_t ODP_DEPRECATE(loop_supported); + + /** Packet input vector capability */ + odp_pktin_vector_capability_t vector; + } odp_pktio_capability_t; /** diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h index cdc7f5fef..c30d937e5 100644 --- a/include/odp/api/spec/pool.h +++ b/include/odp/api/spec/pool.h @@ -45,6 +45,85 @@ extern "C" { #define ODP_POOL_MAX_SUBPARAMS 7 /** + * Pool statistics counters options + * + * Pool statistics counters listed in a bit field structure. + */ +typedef union odp_pool_stats_opt_t { + /** Option flags */ + struct { + /** @see odp_pool_stats_t::available */ + uint64_t available : 1; + + /** @see odp_pool_stats_t::alloc_ops */ + uint64_t alloc_ops : 1; + + /** @see odp_pool_stats_t::alloc_fails */ + uint64_t alloc_fails : 1; + + /** @see odp_pool_stats_t::free_ops */ + uint64_t free_ops : 1; + + /** @see odp_pool_stats_t::total_ops */ + uint64_t total_ops : 1; + + /** @see odp_pool_stats_t::cache_available */ + uint64_t cache_available : 1; + + /** @see odp_pool_stats_t::cache_alloc_ops */ + uint64_t cache_alloc_ops : 1; + + /** @see odp_pool_stats_t::cache_free_ops */ + uint64_t cache_free_ops : 1; + } bit; + + /** All bits of the bit field structure + * + * This field can be used to set/clear all flags, or for bitwise + * operations over the entire structure. */ + uint64_t all; + +} odp_pool_stats_opt_t; + +/** + * Pool statistics counters + * + * In addition to API alloc and free calls, statistics counters may be updated + * by alloc/free operations from implementation internal software or hardware + * components. + */ +typedef struct odp_pool_stats_t { + /** The number of available events in the pool */ + uint64_t available; + + /** The number of alloc operations from the pool. Includes both + * successful and failed operations (pool empty). */ + uint64_t alloc_ops; + + /** The number of failed alloc operations (pool empty) */ + uint64_t alloc_fails; + + /** The number of free operations to the pool */ + uint64_t free_ops; + + /** The total number of alloc and free operations. Includes both + * successful and failed operations (pool empty). */ + uint64_t total_ops; + + /** The number of available events in the local caches of all threads + * using the pool */ + uint64_t cache_available; + + /** The number of successful alloc operations from pool caches (returned + * at least one event). */ + uint64_t cache_alloc_ops; + + /** The number of free operations, which stored events to pool caches. */ + uint64_t cache_free_ops; + +} odp_pool_stats_t; + +/** * Pool capabilities */ typedef struct odp_pool_capability_t { @@ -76,6 +155,9 @@ typedef struct odp_pool_capability_t { /** Maximum size of thread local cache */ uint32_t max_cache_size; + + /** Supported statistics counters */ + odp_pool_stats_opt_t stats; } buf; /** Packet pool capabilities */ @@ -161,6 +243,9 @@ typedef struct odp_pool_capability_t { /** Maximum size of thread local cache */ uint32_t max_cache_size; + + /** Supported statistics counters */ + odp_pool_stats_opt_t stats; } pkt; /** Timeout pool capabilities */ @@ -179,8 +264,35 @@ typedef struct odp_pool_capability_t { /** Maximum size of thread local cache */ uint32_t max_cache_size; + + /** Supported statistics counters */ + odp_pool_stats_opt_t stats; } tmo; + /** Vector pool capabilities */ + struct { + /** Maximum number of vector pools */ + unsigned int max_pools; + + /** Maximum number of vector events in a pool + * + * The value of zero means that limited only by the available + * memory size for the pool. */ + uint32_t max_num; + + /** Maximum number of general types, such as odp_packet_t, in a vector. */ + uint32_t max_size; + + /** Minimum size of thread local cache */ + uint32_t min_cache_size; + + /** Maximum size of thread local cache */ + uint32_t max_cache_size; + + /** Supported statistics counters */ + odp_pool_stats_opt_t stats; + } vector; + } odp_pool_capability_t; /** @@ -359,6 +471,29 @@ typedef struct odp_pool_param_t { uint32_t cache_size; } tmo; + /** Parameters for vector pools */ + struct { + /** Number of vectors in the pool */ + uint32_t num; + + /** Maximum number of general types, such as odp_packet_t, in a vector. */ + uint32_t max_size; + + /** Maximum number of vectors cached locally per thread + * + * See buf.cache_size documentation for details. + */ + uint32_t cache_size; + } vector; + + /** + * Configure statistics counters + * + * An application can read the enabled statistics counters using + * odp_pool_stats(). For optimal performance an application should + * enable only the required counters. + */ + odp_pool_stats_opt_t stats; } odp_pool_param_t; /** Packet pool*/ @@ -367,6 +502,13 @@ typedef struct odp_pool_param_t { #define ODP_POOL_BUFFER ODP_EVENT_BUFFER /** Timeout pool */ #define ODP_POOL_TIMEOUT ODP_EVENT_TIMEOUT +/** Vector pool + * + * The pool to hold a vector of general type such as odp_packet_t. + * Each vector holds an array of generic types of the same type. + * @see ODP_EVENT_PACKET_VECTOR + */ +#define ODP_POOL_VECTOR (ODP_POOL_TIMEOUT + 1) /** * Create a pool @@ -499,6 +641,53 @@ uint64_t odp_pool_to_u64(odp_pool_t hdl); void odp_pool_param_init(odp_pool_param_t *param); /** + * Maximum pool index + * + * Return the maximum pool index. Pool indexes (e.g. returned by odp_pool_index()) + * range from zero to this maximum value. + * + * @return Maximum pool index + */ +unsigned int odp_pool_max_index(void); + +/** + * Get pool index + * + * @param pool Pool handle + * + * @return Pool index (0..odp_pool_max_index()) + * @retval <0 on failure + */ +int odp_pool_index(odp_pool_t pool); + +/** + * Get statistics for pool handle + * + * Read the statistics counters enabled using odp_pool_stats_opt_t during pool + * creation. The inactive counters are set to zero by the implementation. + * + * @param pool Pool handle + * @param[out] stats Output buffer for counters + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_pool_stats(odp_pool_t pool, odp_pool_stats_t *stats); + +/** + * Reset statistics for pool handle + * + * Reset all statistics counters to zero except: odp_pool_stats_t::available, + * odp_pool_stats_t::cache_available + * + * @param pool Pool handle + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_pool_stats_reset(odp_pool_t pool); + +/** * @} */ diff --git a/include/odp/api/spec/protocols.h b/include/odp/api/spec/protocols.h new file mode 100644 index 000000000..71fc59909 --- /dev/null +++ b/include/odp/api/spec/protocols.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2020, Marvell + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP protocols + */ + +#ifndef ODP_API_SPEC_PROTOCOLS_H_ +#define ODP_API_SPEC_PROTOCOLS_H_ +#include <odp/visibility_begin.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup odp_protocols + * @details + * <b> Protocols </b> + * + * @{ + */ + +/** IPv4 address size */ +#define ODP_IPV4_ADDR_SIZE 4 + +/** IPv6 address size */ +#define ODP_IPV6_ADDR_SIZE 16 + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#include <odp/visibility_end.h> +#endif diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h index 1f49e7b40..22c4fbef8 100644 --- a/include/odp/api/spec/timer.h +++ b/include/odp/api/spec/timer.h @@ -216,6 +216,27 @@ typedef struct { */ odp_timer_res_capability_t max_tmo; + /** + * Scheduled queue destination support + * + * This defines whether schedule queues are supported as timeout + * destination queues. + * 0: Scheduled queues are not supported as timeout destination queues + * 1: Scheduled queues are supported as timeout destination queues + * @see odp_timer_alloc() + */ + odp_bool_t queue_type_sched; + + /** + * Plain queue destination support + * + * This defines whether plain queues are supported as timeout + * destination queues. + * 0: Plain queues are not supported as timeout destination queues + * 1: Plain queues are supported as timeout destination queues + * @see odp_timer_alloc() + */ + odp_bool_t queue_type_plain; } odp_timer_capability_t; /** |