aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api
diff options
context:
space:
mode:
Diffstat (limited to 'include/odp/api')
-rw-r--r--include/odp/api/abi-default/packet.h143
-rw-r--r--include/odp/api/abi-default/packet_types.h169
-rw-r--r--include/odp/api/abi-default/proto_stats.h20
-rw-r--r--include/odp/api/abi-default/proto_stats_types.h37
-rw-r--r--include/odp/api/abi-default/queue.h17
-rw-r--r--include/odp/api/abi-default/queue_types.h36
-rw-r--r--include/odp/api/abi-default/std.h (renamed from include/odp/api/abi-default/std_clib.h)12
-rw-r--r--include/odp/api/abi-default/std_types.h8
-rw-r--r--include/odp/api/abi-default/traffic_mngr.h4
-rw-r--r--include/odp/api/classification.h4
-rw-r--r--include/odp/api/comp.h2
-rw-r--r--include/odp/api/crypto.h4
-rw-r--r--include/odp/api/packet.h2
-rw-r--r--include/odp/api/packet_io.h4
-rw-r--r--include/odp/api/packet_types.h28
-rw-r--r--include/odp/api/proto_stats.h31
-rw-r--r--include/odp/api/proto_stats_types.h28
-rw-r--r--include/odp/api/queue.h1
-rw-r--r--include/odp/api/queue_types.h28
-rw-r--r--include/odp/api/spec/classification.h173
-rw-r--r--include/odp/api/spec/ipsec.h40
-rw-r--r--include/odp/api/spec/packet.h559
-rw-r--r--include/odp/api/spec/packet_io.h5
-rw-r--r--include/odp/api/spec/packet_types.h466
-rw-r--r--include/odp/api/spec/pool.h620
-rw-r--r--include/odp/api/spec/pool_types.h772
-rw-r--r--include/odp/api/spec/proto_stats.h132
-rw-r--r--include/odp/api/spec/proto_stats_types.h126
-rw-r--r--include/odp/api/spec/queue.h17
-rw-r--r--include/odp/api/spec/queue_types.h15
-rw-r--r--include/odp/api/spec/schedule.h2
-rw-r--r--include/odp/api/spec/std.h (renamed from include/odp/api/spec/std_clib.h)28
-rw-r--r--include/odp/api/spec/std_types.h14
-rw-r--r--include/odp/api/spec/traffic_mngr.h380
-rw-r--r--include/odp/api/std.h (renamed from include/odp/api/std_clib.h)8
-rw-r--r--include/odp/api/timer.h2
36 files changed, 2681 insertions, 1256 deletions
diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h
index 712f83ef6..3f6e82c5c 100644
--- a/include/odp/api/abi-default/packet.h
+++ b/include/odp/api/abi-default/packet.h
@@ -11,148 +11,7 @@
extern "C" {
#endif
-#include <stdint.h>
-
-/** @internal Dummy type for strong typing */
-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;
-
-/** @internal Dummy type for strong typing */
-typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_tx_compl_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;
-typedef _odp_abi_packet_tx_compl_t *odp_packet_tx_compl_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)
-#define ODP_PACKET_TX_COMPL_INVALID ((odp_packet_tx_compl_t)0)
-
-typedef uint8_t odp_proto_l2_type_t;
-
-#define ODP_PROTO_L2_TYPE_NONE 0
-#define ODP_PROTO_L2_TYPE_ETH 1
-
-typedef uint8_t odp_proto_l3_type_t;
-
-#define ODP_PROTO_L3_TYPE_NONE 0
-#define ODP_PROTO_L3_TYPE_ARP 1
-#define ODP_PROTO_L3_TYPE_RARP 2
-#define ODP_PROTO_L3_TYPE_MPLS 3
-#define ODP_PROTO_L3_TYPE_IPV4 4
-#define ODP_PROTO_L3_TYPE_IPV6 6
-
-typedef uint8_t odp_proto_l4_type_t;
-
-/* Numbers from IANA Assigned Internet Protocol Numbers list */
-#define ODP_PROTO_L4_TYPE_NONE 0
-#define ODP_PROTO_L4_TYPE_ICMPV4 1
-#define ODP_PROTO_L4_TYPE_IGMP 2
-#define ODP_PROTO_L4_TYPE_IPV4 4
-#define ODP_PROTO_L4_TYPE_TCP 6
-#define ODP_PROTO_L4_TYPE_UDP 17
-#define ODP_PROTO_L4_TYPE_IPV6 41
-#define ODP_PROTO_L4_TYPE_GRE 47
-#define ODP_PROTO_L4_TYPE_ESP 50
-#define ODP_PROTO_L4_TYPE_AH 51
-#define ODP_PROTO_L4_TYPE_ICMPV6 58
-#define ODP_PROTO_L4_TYPE_NO_NEXT 59
-#define ODP_PROTO_L4_TYPE_IPCOMP 108
-#define ODP_PROTO_L4_TYPE_SCTP 132
-#define ODP_PROTO_L4_TYPE_ROHC 142
-
-typedef enum {
- ODP_PACKET_GREEN = 0,
- ODP_PACKET_YELLOW = 1,
- ODP_PACKET_RED = 2,
- ODP_PACKET_ALL_COLORS = 3,
-} odp_packet_color_t;
-
-typedef enum {
- ODP_PACKET_CHKSUM_UNKNOWN = 0,
- ODP_PACKET_CHKSUM_BAD,
- ODP_PACKET_CHKSUM_OK
-} odp_packet_chksum_status_t;
-
-/** Parse result flags */
-typedef struct odp_packet_parse_result_flag_t {
- /** Flags union */
- union {
- /** All flags as a 64 bit word */
- uint64_t all;
-
- /** Flags as a bitfield struct */
- struct {
- /** @see odp_packet_has_error() */
- uint64_t has_error : 1;
- /** @see odp_packet_has_l2_error() */
- uint64_t has_l2_error : 1;
- /** @see odp_packet_has_l3_error() */
- uint64_t has_l3_error : 1;
- /** @see odp_packet_has_l4_error() */
- uint64_t has_l4_error : 1;
- /** @see odp_packet_has_l2() */
- uint64_t has_l2 : 1;
- /** @see odp_packet_has_l3() */
- uint64_t has_l3 : 1;
- /** @see odp_packet_has_l4() */
- uint64_t has_l4 : 1;
- /** @see odp_packet_has_eth() */
- uint64_t has_eth : 1;
- /** @see odp_packet_has_eth_bcast() */
- uint64_t has_eth_bcast : 1;
- /** @see odp_packet_has_eth_mcast() */
- uint64_t has_eth_mcast : 1;
- /** @see odp_packet_has_jumbo() */
- uint64_t has_jumbo : 1;
- /** @see odp_packet_has_vlan() */
- uint64_t has_vlan : 1;
- /** @see odp_packet_has_vlan_qinq() */
- uint64_t has_vlan_qinq : 1;
- /** @see odp_packet_has_arp() */
- uint64_t has_arp : 1;
- /** @see odp_packet_has_ipv4() */
- uint64_t has_ipv4 : 1;
- /** @see odp_packet_has_ipv6() */
- uint64_t has_ipv6 : 1;
- /** @see odp_packet_has_ip_bcast() */
- uint64_t has_ip_bcast : 1;
- /** @see odp_packet_has_ip_mcast() */
- uint64_t has_ip_mcast : 1;
- /** @see odp_packet_has_ipfrag() */
- uint64_t has_ipfrag : 1;
- /** @see odp_packet_has_ipopt() */
- uint64_t has_ipopt : 1;
- /** @see odp_packet_has_ipsec() */
- uint64_t has_ipsec : 1;
- /** @see odp_packet_has_udp() */
- uint64_t has_udp : 1;
- /** @see odp_packet_has_tcp() */
- uint64_t has_tcp : 1;
- /** @see odp_packet_has_sctp() */
- uint64_t has_sctp : 1;
- /** @see odp_packet_has_icmp() */
- uint64_t has_icmp : 1;
- };
- };
-
-} odp_packet_parse_result_flag_t;
-
-/**
- * @}
- */
+/* Empty header required due to the packet inline functions */
#ifdef __cplusplus
}
diff --git a/include/odp/api/abi-default/packet_types.h b/include/odp/api/abi-default/packet_types.h
new file mode 100644
index 000000000..9b886aa10
--- /dev/null
+++ b/include/odp/api/abi-default/packet_types.h
@@ -0,0 +1,169 @@
+/* Copyright (c) 2017-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_ABI_PACKET_TYPES_H_
+#define ODP_ABI_PACKET_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+/** @internal Dummy type for strong typing */
+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_buf_t;
+
+/** @internal Dummy type for strong typing */
+typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_vector_t;
+
+/** @internal Dummy type for strong typing */
+typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_tx_compl_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_buf_t *odp_packet_buf_t;
+typedef _odp_abi_packet_vector_t *odp_packet_vector_t;
+typedef _odp_abi_packet_tx_compl_t *odp_packet_tx_compl_t;
+
+#define ODP_PACKET_INVALID ((odp_packet_t)0)
+#define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)0)
+#define ODP_PACKET_BUF_INVALID ((odp_packet_buf_t)0)
+#define ODP_PACKET_OFFSET_INVALID 0xffff
+#define ODP_PACKET_VECTOR_INVALID ((odp_packet_vector_t)0)
+#define ODP_PACKET_TX_COMPL_INVALID ((odp_packet_tx_compl_t)0)
+
+typedef uint8_t odp_proto_l2_type_t;
+
+#define ODP_PROTO_L2_TYPE_NONE 0
+#define ODP_PROTO_L2_TYPE_ETH 1
+
+typedef uint8_t odp_proto_l3_type_t;
+
+#define ODP_PROTO_L3_TYPE_NONE 0
+#define ODP_PROTO_L3_TYPE_ARP 1
+#define ODP_PROTO_L3_TYPE_RARP 2
+#define ODP_PROTO_L3_TYPE_MPLS 3
+#define ODP_PROTO_L3_TYPE_IPV4 4
+#define ODP_PROTO_L3_TYPE_IPV6 6
+
+typedef uint8_t odp_proto_l4_type_t;
+
+/* Numbers from IANA Assigned Internet Protocol Numbers list */
+#define ODP_PROTO_L4_TYPE_NONE 0
+#define ODP_PROTO_L4_TYPE_ICMPV4 1
+#define ODP_PROTO_L4_TYPE_IGMP 2
+#define ODP_PROTO_L4_TYPE_IPV4 4
+#define ODP_PROTO_L4_TYPE_TCP 6
+#define ODP_PROTO_L4_TYPE_UDP 17
+#define ODP_PROTO_L4_TYPE_IPV6 41
+#define ODP_PROTO_L4_TYPE_GRE 47
+#define ODP_PROTO_L4_TYPE_ESP 50
+#define ODP_PROTO_L4_TYPE_AH 51
+#define ODP_PROTO_L4_TYPE_ICMPV6 58
+#define ODP_PROTO_L4_TYPE_NO_NEXT 59
+#define ODP_PROTO_L4_TYPE_IPCOMP 108
+#define ODP_PROTO_L4_TYPE_SCTP 132
+#define ODP_PROTO_L4_TYPE_ROHC 142
+
+/** Packet Color */
+typedef enum {
+ ODP_PACKET_GREEN = 0,
+ ODP_PACKET_YELLOW = 1,
+ ODP_PACKET_RED = 2,
+ ODP_PACKET_ALL_COLORS = 3,
+} odp_packet_color_t;
+
+/** Packet Checksum Status */
+typedef enum {
+ ODP_PACKET_CHKSUM_UNKNOWN = 0,
+ ODP_PACKET_CHKSUM_BAD,
+ ODP_PACKET_CHKSUM_OK
+} odp_packet_chksum_status_t;
+
+/** Parse result flags */
+typedef struct odp_packet_parse_result_flag_t {
+ /** Flags union */
+ union {
+ /** All flags as a 64 bit word */
+ uint64_t all;
+
+ /** Flags as a bitfield struct */
+ struct {
+ /** @see odp_packet_has_error() */
+ uint64_t has_error : 1;
+ /** @see odp_packet_has_l2_error() */
+ uint64_t has_l2_error : 1;
+ /** @see odp_packet_has_l3_error() */
+ uint64_t has_l3_error : 1;
+ /** @see odp_packet_has_l4_error() */
+ uint64_t has_l4_error : 1;
+ /** @see odp_packet_has_l2() */
+ uint64_t has_l2 : 1;
+ /** @see odp_packet_has_l3() */
+ uint64_t has_l3 : 1;
+ /** @see odp_packet_has_l4() */
+ uint64_t has_l4 : 1;
+ /** @see odp_packet_has_eth() */
+ uint64_t has_eth : 1;
+ /** @see odp_packet_has_eth_bcast() */
+ uint64_t has_eth_bcast : 1;
+ /** @see odp_packet_has_eth_mcast() */
+ uint64_t has_eth_mcast : 1;
+ /** @see odp_packet_has_jumbo() */
+ uint64_t has_jumbo : 1;
+ /** @see odp_packet_has_vlan() */
+ uint64_t has_vlan : 1;
+ /** @see odp_packet_has_vlan_qinq() */
+ uint64_t has_vlan_qinq : 1;
+ /** @see odp_packet_has_arp() */
+ uint64_t has_arp : 1;
+ /** @see odp_packet_has_ipv4() */
+ uint64_t has_ipv4 : 1;
+ /** @see odp_packet_has_ipv6() */
+ uint64_t has_ipv6 : 1;
+ /** @see odp_packet_has_ip_bcast() */
+ uint64_t has_ip_bcast : 1;
+ /** @see odp_packet_has_ip_mcast() */
+ uint64_t has_ip_mcast : 1;
+ /** @see odp_packet_has_ipfrag() */
+ uint64_t has_ipfrag : 1;
+ /** @see odp_packet_has_ipopt() */
+ uint64_t has_ipopt : 1;
+ /** @see odp_packet_has_ipsec() */
+ uint64_t has_ipsec : 1;
+ /** @see odp_packet_has_udp() */
+ uint64_t has_udp : 1;
+ /** @see odp_packet_has_tcp() */
+ uint64_t has_tcp : 1;
+ /** @see odp_packet_has_sctp() */
+ uint64_t has_sctp : 1;
+ /** @see odp_packet_has_icmp() */
+ uint64_t has_icmp : 1;
+ };
+ };
+
+} odp_packet_parse_result_flag_t;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/abi-default/proto_stats.h b/include/odp/api/abi-default/proto_stats.h
new file mode 100644
index 000000000..dd7ff09b7
--- /dev/null
+++ b/include/odp/api/abi-default/proto_stats.h
@@ -0,0 +1,20 @@
+/* Copyright (c) 2021, Marvell
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_ABI_PROTO_STATS_H_
+#define ODP_ABI_PROTO_STATS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Empty header required to enable API function inlining */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/abi-default/proto_stats_types.h b/include/odp/api/abi-default/proto_stats_types.h
new file mode 100644
index 000000000..2e8e4aeef
--- /dev/null
+++ b/include/odp/api/abi-default/proto_stats_types.h
@@ -0,0 +1,37 @@
+/* Copyright (c) 2021, Marvell
+ * Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_ABI_PROTO_STATS_TYPES_H_
+#define ODP_ABI_PROTO_STATS_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+/** @internal Dummy type for strong typing */
+typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_proto_stats_t;
+
+/** @ingroup odp_proto_stats
+ * Operations on a proto stats object.
+ * @{
+ */
+
+typedef _odp_abi_proto_stats_t *odp_proto_stats_t;
+
+#define ODP_PROTO_STATS_INVALID ((odp_proto_stats_t)0)
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/abi-default/queue.h b/include/odp/api/abi-default/queue.h
index 007ded719..f74080dbb 100644
--- a/include/odp/api/abi-default/queue.h
+++ b/include/odp/api/abi-default/queue.h
@@ -11,22 +11,7 @@
extern "C" {
#endif
-/** @internal Dummy type for strong typing */
-typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_queue_t;
-
-/** @ingroup odp_queue
- * @{
- */
-
-typedef _odp_abi_queue_t *odp_queue_t;
-
-#define ODP_QUEUE_INVALID ((odp_queue_t)0)
-
-#define ODP_QUEUE_NAME_LEN 32
-
-/**
- * @}
- */
+/* Empty header required due to the queue inline functions */
#ifdef __cplusplus
}
diff --git a/include/odp/api/abi-default/queue_types.h b/include/odp/api/abi-default/queue_types.h
new file mode 100644
index 000000000..bf9862149
--- /dev/null
+++ b/include/odp/api/abi-default/queue_types.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2017-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_ABI_QUEUE_TYPES_H_
+#define ODP_ABI_QUEUE_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @internal Dummy type for strong typing */
+typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_queue_t;
+
+/** @ingroup odp_queue
+ * @{
+ */
+
+typedef _odp_abi_queue_t *odp_queue_t;
+
+#define ODP_QUEUE_INVALID ((odp_queue_t)0)
+
+#define ODP_QUEUE_NAME_LEN 32
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/abi-default/std_clib.h b/include/odp/api/abi-default/std.h
index 15bb79536..2500af800 100644
--- a/include/odp/api/abi-default/std_clib.h
+++ b/include/odp/api/abi-default/std.h
@@ -4,19 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-/**
- * @file
- *
- * ODP barrier
- */
-
-#ifndef ODP_ABI_STD_CLIB_H_
-#define ODP_ABI_STD_CLIB_H_
+#ifndef ODP_ABI_STD_H_
+#define ODP_ABI_STD_H_
#ifdef __cplusplus
extern "C" {
#endif
+/* Empty header required due to the inline functions */
+
#ifdef __cplusplus
}
#endif
diff --git a/include/odp/api/abi-default/std_types.h b/include/odp/api/abi-default/std_types.h
index 27c6a75cc..df7bd8db5 100644
--- a/include/odp/api/abi-default/std_types.h
+++ b/include/odp/api/abi-default/std_types.h
@@ -4,12 +4,6 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-/**
- * @file
- *
- * Standard C language types and definitions for ODP.
- */
-
#ifndef ODP_ABI_STD_TYPES_H_
#define ODP_ABI_STD_TYPES_H_
@@ -26,7 +20,7 @@ extern "C" {
/* true and false for odp_bool_t */
#include <stdbool.h>
-/** @addtogroup odp_system ODP SYSTEM
+/** @addtogroup odp_std
* @{
*/
diff --git a/include/odp/api/abi-default/traffic_mngr.h b/include/odp/api/abi-default/traffic_mngr.h
index 9c01ef98f..155123304 100644
--- a/include/odp/api/abi-default/traffic_mngr.h
+++ b/include/odp/api/abi-default/traffic_mngr.h
@@ -46,13 +46,13 @@ extern "C" {
/**
* The smallest SCHED weight is 1 (i.e. 0 is not a legal WFQ/WRR value).
*/
-#define ODP_TM_MIN_SCHED_WEIGHT 1
+#define ODP_TM_MIN_SCHED_WEIGHT 1U
/** The ODP_TM_MAX_SCHED_WEIGHT constant is the largest weight any TM system
* can support (at least from a configuration standpoint). A given TM system
* could have a smaller value.
*/
-#define ODP_TM_MAX_SCHED_WEIGHT 255
+#define ODP_TM_MAX_SCHED_WEIGHT 255U
/** The ODP_TM_MAX_TM_QUEUES constant is the largest number of tm_queues
* that can be handled by any one TM system.
diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index 643033228..e96e9c906 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -20,9 +20,9 @@ extern "C" {
#include <odp/api/std_types.h>
#include <odp/api/abi/pool.h>
#include <odp/api/abi/classification.h>
-#include <odp/api/abi/packet.h>
+#include <odp/api/abi/packet_types.h>
#include <odp/api/abi/packet_io.h>
-#include <odp/api/abi/queue.h>
+#include <odp/api/abi/queue_types.h>
#include <odp/api/spec/classification.h>
diff --git a/include/odp/api/comp.h b/include/odp/api/comp.h
index 59d4f52a3..c3294e79e 100644
--- a/include/odp/api/comp.h
+++ b/include/odp/api/comp.h
@@ -19,7 +19,7 @@ extern "C" {
#include <odp/api/abi/comp.h>
#include <odp/api/abi/event.h>
-#include <odp/api/abi/queue.h>
+#include <odp/api/abi/queue_types.h>
#include <odp/api/spec/comp.h>
diff --git a/include/odp/api/crypto.h b/include/odp/api/crypto.h
index 5f68e6701..1986d1b2e 100644
--- a/include/odp/api/crypto.h
+++ b/include/odp/api/crypto.h
@@ -18,11 +18,11 @@ extern "C" {
#endif
#include <odp/api/std_types.h>
-#include <odp/api/abi/packet.h>
+#include <odp/api/abi/packet_types.h>
#include <odp/api/abi/crypto.h>
#include <odp/api/abi/buffer.h>
#include <odp/api/abi/pool.h>
-#include <odp/api/queue.h>
+#include <odp/api/abi/queue_types.h>
/** @ingroup odp_crypto
* @{
diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
index e4b2427a0..231a5aecd 100644
--- a/include/odp/api/packet.h
+++ b/include/odp/api/packet.h
@@ -20,8 +20,8 @@ extern "C" {
#include <odp/api/std_types.h>
#include <odp/api/abi/event.h>
#include <odp/api/abi/packet_io.h>
+#include <odp/api/abi/packet_types.h>
#include <odp/api/abi/packet.h>
-#include <odp/api/abi/queue.h>
#include <odp/api/abi/buffer.h>
#include <odp/api/abi/pool.h>
diff --git a/include/odp/api/packet_io.h b/include/odp/api/packet_io.h
index a7edf17cb..9de59f51e 100644
--- a/include/odp/api/packet_io.h
+++ b/include/odp/api/packet_io.h
@@ -20,9 +20,9 @@ extern "C" {
#include <odp/api/std_types.h>
#include <odp/api/abi/pool.h>
#include <odp/api/abi/classification.h>
-#include <odp/api/abi/packet.h>
+#include <odp/api/abi/packet_types.h>
#include <odp/api/abi/packet_io.h>
-#include <odp/api/abi/queue.h>
+#include <odp/api/abi/queue_types.h>
/** @ingroup odp_packet_io
* @{
diff --git a/include/odp/api/packet_types.h b/include/odp/api/packet_types.h
new file mode 100644
index 000000000..02ffe956b
--- /dev/null
+++ b/include/odp/api/packet_types.h
@@ -0,0 +1,28 @@
+/* Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP packet
+ */
+
+#ifndef ODP_API_PACKET_TYPES_H_
+#define ODP_API_PACKET_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/abi/packet_types.h>
+
+#include <odp/api/spec/packet_types.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/proto_stats.h b/include/odp/api/proto_stats.h
new file mode 100644
index 000000000..bceaeaac9
--- /dev/null
+++ b/include/odp/api/proto_stats.h
@@ -0,0 +1,31 @@
+/* Copyright (c) 2021, Marvell
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP proto stats
+ */
+
+#ifndef ODP_API_PROTO_STATS_H_
+#define ODP_API_PROTO_STATS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/std_types.h>
+#include <odp/api/abi/queue.h>
+#include <odp/api/abi/proto_stats_types.h>
+#include <odp/api/abi/proto_stats.h>
+
+#include <odp/api/spec/proto_stats.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/proto_stats_types.h b/include/odp/api/proto_stats_types.h
new file mode 100644
index 000000000..b12a0f34f
--- /dev/null
+++ b/include/odp/api/proto_stats_types.h
@@ -0,0 +1,28 @@
+/* Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP proto stats types
+ */
+
+#ifndef ODP_API_PROTO_STATS_TYPES_H_
+#define ODP_API_PROTO_STATS_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/abi/proto_stats_types.h>
+
+#include <odp/api/spec/proto_stats_types.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/queue.h b/include/odp/api/queue.h
index b8b5e48cc..4046d4e1b 100644
--- a/include/odp/api/queue.h
+++ b/include/odp/api/queue.h
@@ -19,6 +19,7 @@ extern "C" {
#include <odp/api/std_types.h>
#include <odp/api/abi/event.h>
+#include <odp/api/abi/queue_types.h>
#include <odp/api/abi/queue.h>
#include <odp/api/abi/buffer.h>
#include <odp/api/abi/pool.h>
diff --git a/include/odp/api/queue_types.h b/include/odp/api/queue_types.h
new file mode 100644
index 000000000..7c9a83bfe
--- /dev/null
+++ b/include/odp/api/queue_types.h
@@ -0,0 +1,28 @@
+/* Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP queue
+ */
+
+#ifndef ODP_API_QUEUE_TYPES_H_
+#define ODP_API_QUEUE_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/abi/queue_types.h>
+
+#include <odp/api/spec/queue_types.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/odp/api/spec/classification.h b/include/odp/api/spec/classification.h
index 31ce3e794..f3cfea78b 100644
--- a/include/odp/api/spec/classification.h
+++ b/include/odp/api/spec/classification.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2014-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -128,8 +129,9 @@ typedef union odp_cls_pmr_terms_t {
* threshold values. RED is enabled when 'red_enable' boolean is true and
* the resource usage is equal to or greater than the minimum threshold value.
* Resource usage could be defined either as the percentage of pool being full
- * or the number of packets/bytes occupied in the queue depening on the platform
- * capabilities.
+ * or the number of packets/bytes occupied in the queue depending on the
+ * platform capabilities.
+ *
* When RED is enabled for a particular flow then further incoming packets are
* assigned a drop probability based on the size of the pool/queue.
*
@@ -178,6 +180,64 @@ typedef struct odp_bp_param_t {
} odp_bp_param_t;
/**
+ * Classifier queue specific statistics counters
+ *
+ * Counters are incremented per packet destined to the queue per originating
+ * CoS. Note that a single queue can be a destination for multiple CoS's.
+ */
+typedef struct odp_cls_queue_stats_t {
+ /** Number of octets in successfully delivered packets. In case of
+ * Ethernet, packet size includes MAC header. */
+ uint64_t octets;
+
+ /** Number of successfully delivered packets. */
+ uint64_t packets;
+
+ /** Number of discarded packets due to other reasons (e.g. RED) than
+ * errors. */
+ uint64_t discards;
+
+ /** Number of packets with errors. Depending on packet input
+ * configuration, packets with errors may be dropped or not. */
+ uint64_t errors;
+
+} odp_cls_queue_stats_t;
+
+/**
+ * Classifier statistics capabilities
+ */
+typedef struct odp_cls_stats_capability_t {
+ /** Queue level capabilities */
+ struct {
+ /** Supported counters */
+ union {
+ /** Statistics counters in a bit field structure */
+ struct {
+ /** @see odp_cls_queue_stats_t::octets */
+ uint64_t octets : 1;
+
+ /** @see odp_cls_queue_stats_t::packets */
+ uint64_t packets : 1;
+
+ /** @see odp_cls_queue_stats_t::discards */
+ uint64_t discards : 1;
+
+ /** @see odp_cls_queue_stats_t::errors */
+ uint64_t errors : 1;
+
+ } counter;
+
+ /** 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_counters;
+ };
+ } queue;
+
+} odp_cls_stats_capability_t;
+
+/**
* Classification capabilities
* This capability structure defines system level classification capability
*/
@@ -196,7 +256,7 @@ typedef struct odp_cls_capability_t {
/** Maximum number of CoS supported */
unsigned int max_cos;
- /** Maximun number of queue supported per CoS
+ /** Maximun number of queues supported per CoS
* if the value is 1, then hashing is not supported*/
unsigned int max_hash_queues;
@@ -221,14 +281,17 @@ typedef struct odp_cls_capability_t {
/** Maximum value of odp_pmr_create_opt_t::mark */
uint64_t max_mark;
+ /** Statistics counters capabilities */
+ odp_cls_stats_capability_t stats;
+
} odp_cls_capability_t;
/**
* class of service packet drop policies
*/
typedef enum {
- ODP_COS_DROP_POOL, /**< Follow buffer pool drop policy */
- ODP_COS_DROP_NEVER, /**< Never drop, ignoring buffer pool policy */
+ ODP_COS_DROP_POOL, /**< Follow buffer pool drop policy */
+ ODP_COS_DROP_NEVER, /**< Never drop, ignoring buffer pool policy */
} odp_cls_drop_t;
/**
@@ -264,12 +327,12 @@ typedef struct odp_cls_cos_param {
* and application need not configure any queue to the class of service.
* When hashing is disabled application has to configure the queue to
* the class of service.
- * Depening on the implementation this number might be rounded-off to
+ * Depending on the implementation this number might be rounded-off to
* nearest supported value (e.g power of 2)
*/
uint32_t num_queue;
- /** Variant mapping for queue hash configurataion */
+ /** Variant mapping for queue hash configuration */
union {
/** Mapping used when num_queue = 1, hashing is disabled in
* this case and application has to configure this queue and
@@ -339,8 +402,8 @@ int odp_cls_capability(odp_cls_capability_t *capability);
* @retval ODP_COS_INVALID on failure.
*
* @note ODP_QUEUE_INVALID and ODP_POOL_INVALID are valid values for queue
- * and pool associated with a class of service and when any one of these values
- * are configured as INVALID then the packets assigned to the CoS gets dropped.
+ * and pool associated with a class of service. When either of these values
+ * is configured as INVALID packets assigned to the CoS get dropped.
*/
odp_cos_t odp_cls_cos_create(const char *name,
const odp_cls_cos_param_t *param);
@@ -351,7 +414,7 @@ odp_cos_t odp_cls_cos_create(const char *name,
* based on the packet parameters and hash protocol field configured with the
* class of service.
*
- * @param cos class of service
+ * @param cos CoS handle
* @param packet Packet handle
*
* @retval Returns the queue handle on which this packet will be enqueued.
@@ -364,62 +427,61 @@ odp_queue_t odp_cls_hash_result(odp_cos_t cos, odp_packet_t packet);
/**
* Discard a class-of-service along with all its associated resources
*
- * @param cos_id class-of-service instance.
+ * @param cos CoS handle
*
* @retval 0 on success
* @retval <0 on failure
*/
-int odp_cos_destroy(odp_cos_t cos_id);
+int odp_cos_destroy(odp_cos_t cos);
/**
* Assign a queue for a class-of-service
*
- * @param cos_id class-of-service instance.
- * @param queue_id Identifier of a queue where all packets of this specific
+ * @param cos CoS handle
+ * @param queue Handle of the queue where all packets of this specific
* class of service will be enqueued.
*
* @retval 0 on success
* @retval <0 on failure
*/
-int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id);
+int odp_cos_queue_set(odp_cos_t cos, odp_queue_t queue);
/**
* Get the queue associated with the specific class-of-service
*
-* @param cos_id class-of-service instance.
+* @param cos CoS handle
*
* @retval Queue handle associated with the given class-of-service
* @retval ODP_QUEUE_INVALID on failure
*/
-odp_queue_t odp_cos_queue(odp_cos_t cos_id);
+odp_queue_t odp_cos_queue(odp_cos_t cos);
/**
* Get the number of queues linked with the specific class-of-service
*
- * @param cos_id class-of-service instance.
+ * @param cos CoS handle
*
* @return Number of queues linked with the class-of-service.
*/
-uint32_t odp_cls_cos_num_queue(odp_cos_t cos_id);
+uint32_t odp_cls_cos_num_queue(odp_cos_t cos);
/**
* Get the list of queue associated with the specific class-of-service
*
- * @param cos_id class-of-service instance.
+ * @param cos CoS handle
* @param[out] queue Array of queue handles associated with
* the class-of-service.
* @param num Maximum number of queue handles to output.
*
* @return Number of queues linked with CoS
- * @retval on 0 failure
+ * @retval 0 on failure
*/
-uint32_t odp_cls_cos_queues(odp_cos_t cos_id, odp_queue_t queue[],
- uint32_t num);
+uint32_t odp_cls_cos_queues(odp_cos_t cos, odp_queue_t queue[], uint32_t num);
/**
* Assign packet drop policy for specific class-of-service
*
- * @param cos_id class-of-service instance.
+ * @param cos CoS handle
* @param drop_policy Desired packet drop policy for this class.
*
* @retval 0 on success
@@ -427,16 +489,16 @@ uint32_t odp_cls_cos_queues(odp_cos_t cos_id, odp_queue_t queue[],
*
* @note Optional.
*/
-int odp_cos_drop_set(odp_cos_t cos_id, odp_cls_drop_t drop_policy);
+int odp_cos_drop_set(odp_cos_t cos, odp_cls_drop_t drop_policy);
/**
* Get the drop policy configured for a specific class-of-service instance.
*
-* @param cos_id class-of-service instance.
+* @param cos CoS handle
*
* @retval Drop policy configured with the given class-of-service
*/
-odp_cls_drop_t odp_cos_drop(odp_cos_t cos_id);
+odp_cls_drop_t odp_cos_drop(odp_cos_t cos);
/**
* Request to override per-port class of service
@@ -479,6 +541,28 @@ int odp_cos_with_l3_qos(odp_pktio_t pktio_in,
odp_bool_t l3_preference);
/**
+ * Get statistics for a queue assigned to a CoS
+ *
+ * The statistics counters are incremented only for packets originating from the
+ * given CoS. Queue handles can be requested with odp_cos_queue() and
+ * odp_cls_cos_queues().
+ *
+ * Counters not supported by the queue are set to zero.
+ *
+ * It's implementation defined if odp_pktio_stats_reset() call affects these
+ * counters.
+ *
+ * @param cos CoS handle
+ * @param queue Queue handle
+ * @param[out] stats Statistics structure for output
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_cls_queue_stats(odp_cos_t cos, odp_queue_t queue,
+ odp_cls_queue_stats_t *stats);
+
+/**
* @typedef odp_pmr_t
* PMR - Packet Matching Rule
* Up to 32 bit of ternary matching of one of the available header fields
@@ -608,7 +692,8 @@ typedef enum {
* an exception to this (uint32_t in CPU endian).
*/
typedef struct odp_pmr_param_t {
- odp_cls_pmr_term_t term; /**< Packet Matching Rule term */
+ /** Packet Matching Rule term */
+ odp_cls_pmr_term_t term;
/** True if the value is range and false if match */
odp_bool_t range_term;
@@ -700,6 +785,7 @@ void odp_cls_pmr_create_opt_init(odp_pmr_create_opt_t *opt);
* This packet matching rule is applied on all packets arriving at the source
* class of service and packets satisfying this PMR are sent to the destination
* class of service.
+ *
* A composite PMR rule is created when the number of terms in the match rule
* is more than one. The composite rule is considered as matching only if
* the packet satisfies all the terms in Packet Match Rule.
@@ -751,50 +837,53 @@ odp_pmr_t odp_cls_pmr_create_opt(const odp_pmr_create_opt_t *opt,
odp_cos_t src_cos, odp_cos_t dst_cos);
/**
* Function to destroy a packet match rule
+ *
* Destroying a PMR removes the link between the source and destination
* class of service and this PMR will no longer be applied for packets arriving
- * at the source class of service. All the resource associated with the PMR
- * be release but the class of service will remain intact.
+ * at the source class of service. All the resources associated with the PMR
+ * will be released but the class of service will remain intact.
+ *
* Depending on the implementation details, destroying a composite rule
* may not guarantee the availability of hardware resources to create the
* same or essentially similar rule.
*
- * @param pmr_id Identifier of the PMR to be destroyed
+ * @param pmr Handle of the PMR to be destroyed
*
* @retval 0 on success
* @retval <0 on failure
*/
-int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
+int odp_cls_pmr_destroy(odp_pmr_t pmr);
/**
-* Assigns a packet pool for a specific class of service.
+* Assigns a packet pool for a specific class of service
+*
* All the packets belonging to the given class of service will
* be allocated from the assigned packet pool.
* The packet pool associated with class of service will supersede the
* packet pool associated with the pktio interface.
*
-* @param cos_id class of service handle
-* @param pool_id packet pool handle
+* @param cos CoS handle
+* @param pool_id Packet pool handle
*
* @retval 0 on success
* @retval <0 on failure
*/
-int odp_cls_cos_pool_set(odp_cos_t cos_id, odp_pool_t pool_id);
+int odp_cls_cos_pool_set(odp_cos_t cos, odp_pool_t pool_id);
/**
* Get the pool associated with the given class of service
*
-* @param cos_id class of service handle
+* @param cos CoS handle
*
* @retval pool handle of the associated pool
* @retval ODP_POOL_INVALID if no associated pool found or in case of an error
*/
-odp_pool_t odp_cls_cos_pool(odp_cos_t cos_id);
+odp_pool_t odp_cls_cos_pool(odp_cos_t cos);
/**
* Get printable value for an odp_cos_t
*
- * @param hdl odp_cos_t handle to be printed
+ * @param cos CoS handle to be printed
*
* @return uint64_t value that can be used to print/display this handle
*
@@ -802,12 +891,12 @@ odp_pool_t odp_cls_cos_pool(odp_cos_t cos_id);
* to enable applications to generate a printable value that represents
* an odp_cos_t handle.
*/
-uint64_t odp_cos_to_u64(odp_cos_t hdl);
+uint64_t odp_cos_to_u64(odp_cos_t cos);
/**
* Get printable value for an odp_pmr_t
*
- * @param hdl odp_pmr_t handle to be printed
+ * @param pmr odp_pmr_t handle to be printed
*
* @return uint64_t value that can be used to print/display this handle
*
@@ -815,7 +904,7 @@ uint64_t odp_cos_to_u64(odp_cos_t hdl);
* to enable applications to generate a printable value that represents
* an odp_pmr_t handle.
*/
-uint64_t odp_pmr_to_u64(odp_pmr_t hdl);
+uint64_t odp_pmr_to_u64(odp_pmr_t pmr);
/**
* Print classifier info
diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index f1a9d4b7d..3441d83c9 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2016-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -392,6 +393,8 @@ typedef struct odp_ipsec_auth_capability_t {
/** Key length in bytes */
uint32_t key_len;
+ /** ICV length in bytes */
+ uint32_t icv_len;
} odp_ipsec_auth_capability_t;
/**
@@ -543,6 +546,37 @@ typedef struct odp_ipsec_crypto_param_t {
*/
odp_crypto_key_t auth_key_extra;
+ /**
+ * Length of integrity check value (ICV) in bytes.
+ *
+ * Some algorithms support multiple ICV lengths when used with IPsec.
+ * This field can be used to select a non-default ICV length.
+ *
+ * Zero value indicates that the default ICV length shall be used.
+ * The default length depends on the selected algorithm as follows:
+ *
+ * Algorithm Default length Other lengths
+ * ----------------------------------------------------------------
+ * ODP_AUTH_ALG_NULL 0
+ * ODP_AUTH_ALG_MD5_HMAC 12
+ * ODP_AUTH_ALG_SHA1_HMAC 12
+ * ODP_AUTH_ALG_SHA256_HMAC 16
+ * ODP_AUTH_ALG_SHA384_HMAC 24
+ * ODP_AUTH_ALG_SHA512_HMAC 32
+ * ODP_AUTH_ALG_AES_GCM 16 8, 12
+ * ODP_AUTH_ALG_AES_GMAC 16
+ * ODP_AUTH_ALG_AES_CCM 16 8, 12
+ * ODP_AUTH_ALG_AES_CMAC 12
+ * ODP_AUTH_ALG_AES_XCBC_MAC 12
+ * ODP_AUTH_ALG_CHACHA20_POLY1305 16
+ *
+ * The requested ICV length must be supported for the selected
+ * algorithm as indicated by odp_ipsec_auth_capability().
+ *
+ * The default value is 0.
+ */
+ uint32_t icv_len;
+
} odp_ipsec_crypto_param_t;
/** IPv4 header parameters */
@@ -1065,11 +1099,9 @@ int odp_ipsec_cipher_capability(odp_cipher_alg_t cipher,
* Query supported IPSEC authentication algorithm capabilities
*
* Outputs all supported configuration options for the algorithm. Output is
- * sorted (from the smallest to the largest) first by digest length, then by key
+ * sorted (from the smallest to the largest) first by ICV length, then by key
* length. Use this information to select key lengths, etc authentication
- * algorithm options for SA creation (odp_ipsec_crypto_param_t). Application
- * must ignore values for AAD length capabilities as those are not relevant for
- * IPSEC API (fixed in IPSEC RFCs).
+ * algorithm options for SA creation (odp_ipsec_crypto_param_t).
*
* @param auth Authentication algorithm
* @param[out] capa Array of capability structures for output
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index eef7bae8a..2285a857d 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -19,7 +19,9 @@
extern "C" {
#endif
+#include <odp/api/proto_stats_types.h>
#include <odp/api/time.h>
+#include <odp/api/packet_types.h>
/** @defgroup odp_packet ODP PACKET
* Packet event metadata and operations.
@@ -27,259 +29,6 @@ extern "C" {
*/
/**
- * @typedef odp_packet_t
- * ODP packet
- */
-
-/**
- * @def ODP_PACKET_INVALID
- * Invalid packet
- */
-
-/**
- * @def ODP_PACKET_OFFSET_INVALID
- * Invalid packet offset
- */
-
-/**
- * @typedef odp_packet_seg_t
- * ODP packet segment
- */
-
-/**
- * @def ODP_PACKET_SEG_INVALID
- * Invalid packet segment
- */
-
-/**
- * @enum odp_packet_color_t
- * Color of packet for shaper/drop processing
- *
- * @var ODP_PACKET_GREEN
- * Packet is green
- *
- * @var ODP_PACKET_YELLOW
- * Packet is yellow
- *
- * @var ODP_PACKET_RED
- * Packet is red
- */
-
-/**
- * Maximum number of packet colors which accommodates ODP_PACKET_GREEN, ODP_PACKET_YELLOW and
- * ODP_PACKET_RED.
- */
-#define ODP_NUM_PACKET_COLORS 3
-
-/**
- * @typedef odp_proto_l2_type_t
- * Layer 2 protocol type
- */
-
-/**
- * @def ODP_PROTO_L2_TYPE_NONE
- * Layer 2 protocol type not defined
- *
- * @def ODP_PROTO_L2_TYPE_ETH
- * Layer 2 protocol is Ethernet
- */
-
-/**
- * @typedef odp_proto_l3_type_t
- * Layer 3 protocol type
- */
-
-/**
- * @def ODP_PROTO_L3_TYPE_NONE
- * Layer 3 protocol type not defined
- *
- * @def ODP_PROTO_L3_TYPE_ARP
- * Layer 3 protocol is ARP
- *
- * @def ODP_PROTO_L3_TYPE_RARP
- * Layer 3 protocol is RARP
- *
- * @def ODP_PROTO_L3_TYPE_MPLS
- * Layer 3 protocol is MPLS
- *
- * @def ODP_PROTO_L3_TYPE_IPV4
- * Layer 3 protocol type is IPv4
- *
- * @def ODP_PROTO_L3_TYPE_IPV6
- * Layer 3 protocol type is IPv6
- */
-
-/**
- * @typedef odp_proto_l4_type_t
- * Layer 4 protocol type
- */
-
-/**
- * @def ODP_PROTO_L4_TYPE_NONE
- * Layer 4 protocol type not defined
- *
- * @def ODP_PROTO_L4_TYPE_ICMPV4
- * Layer 4 protocol type is ICMPv4
- *
- * @def ODP_PROTO_L4_TYPE_IGMP
- * Layer 4 protocol type is IGMP
- *
- * @def ODP_PROTO_L4_TYPE_IPV4
- * Layer 4 protocol type is IPv4
- *
- * @def ODP_PROTO_L4_TYPE_TCP
- * Layer 4 protocol type is TCP
- *
- * @def ODP_PROTO_L4_TYPE_UDP
- * Layer 4 protocol type is UDP
- *
- * @def ODP_PROTO_L4_TYPE_IPV6
- * Layer 4 protocol type is IPv6
- *
- * @def ODP_PROTO_L4_TYPE_GRE
- * Layer 4 protocol type is GRE
- *
- * @def ODP_PROTO_L4_TYPE_ESP
- * Layer 4 protocol type is IPSEC ESP
- *
- * @def ODP_PROTO_L4_TYPE_AH
- * Layer 4 protocol type is IPSEC AH
- *
- * @def ODP_PROTO_L4_TYPE_ICMPV6
- * Layer 4 protocol type is ICMPv6
- *
- * @def ODP_PROTO_L4_TYPE_NO_NEXT
- * Layer 4 protocol type is "No Next Header".
- * Protocol / next header number is 59.
- *
- * @def ODP_PROTO_L4_TYPE_IPCOMP
- * Layer 4 protocol type is IP Payload Compression Protocol
- *
- * @def ODP_PROTO_L4_TYPE_SCTP
- * Layer 4 protocol type is SCTP
- *
- * @def ODP_PROTO_L4_TYPE_ROHC
- * Layer 4 protocol type is ROHC
- */
-
-/**
- * @enum odp_packet_chksum_status_t
- * Checksum check status in packet
- *
- * @var ODP_PACKET_CHKSUM_UNKNOWN
- * Checksum was not checked. Checksum check was not
- * attempted or the attempt failed.
- *
- * @var ODP_PACKET_CHKSUM_BAD
- * Checksum was checked and it was not correct.
- *
- * @var ODP_PACKET_CHKSUM_OK
- * Checksum was checked and it was correct.
- */
-
-/**
- * @typedef odp_packet_vector_t
- * ODP packet vector
- */
-
-/**
- * @def ODP_PACKET_VECTOR_INVALID
- * Invalid packet vector
- */
-
-/**
- * @typedef odp_packet_tx_compl_t
- * ODP Packet Tx completion
- */
-
-/**
- * @def ODP_PACKET_TX_COMPL_INVALID
- * Invalid packet Tx completion
- */
-
-/**
- * Protocol
- */
-typedef enum odp_proto_t {
- /** No protocol defined */
- ODP_PROTO_NONE = 0,
-
- /** Ethernet (including VLAN) */
- ODP_PROTO_ETH,
-
- /** IP version 4 */
- ODP_PROTO_IPV4,
-
- /** IP version 6 */
- ODP_PROTO_IPV6
-
-} odp_proto_t;
-
-/**
- * Protocol layer
- */
-typedef enum odp_proto_layer_t {
- /** No layers */
- ODP_PROTO_LAYER_NONE = 0,
-
- /** Layer L2 protocols (Ethernet, VLAN, etc) */
- ODP_PROTO_LAYER_L2,
-
- /** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */
- ODP_PROTO_LAYER_L3,
-
- /** Layer L4 protocols (UDP, TCP, SCTP) */
- ODP_PROTO_LAYER_L4,
-
- /** All layers */
- ODP_PROTO_LAYER_ALL
-
-} odp_proto_layer_t;
-
-/**
- * Packet API data range specifier
- */
-typedef struct odp_packet_data_range {
- /** Offset from beginning of packet */
- uint32_t offset;
-
- /** Length of data to operate on */
- uint32_t length;
-
-} odp_packet_data_range_t;
-
-/**
- * Reassembly status of a packet
- */
-typedef enum odp_packet_reass_status_t {
- /** Reassembly was not attempted */
- ODP_PACKET_REASS_NONE = 0,
-
- /** 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_INCOMPLETE,
-
- /** Reassembly was successfully done. The packet has been
- * reassembled from multiple received fragments. */
- ODP_PACKET_REASS_COMPLETE,
-} odp_packet_reass_status_t;
-
-/**
- * Result from odp_packet_reass_partial_state()
- */
-typedef struct odp_packet_reass_partial_state_t {
- /** Number of fragments returned */
- uint16_t num_frags;
-
- /** Time, in ns, since the reception of the first received fragment */
- uint64_t elapsed_time;
-} odp_packet_reass_partial_state_t;
-
-/**
* Event subtype of a packet
*
* Returns the subtype of a packet event. Subtype tells if the packet contains
@@ -1155,6 +904,135 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src);
*/
int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail);
+/**
+ * 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().
+ *
+ * @param pkt_buf Packet buffer
+ *
+ * @return Packet buffer head pointer
+ */
+void *odp_packet_buf_head(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().
+ *
+ * @param pkt_buf Packet buffer
+ *
+ * @return Packet buffer size
+ */
+uint32_t odp_packet_buf_size(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().
+ *
+ * @param pkt_buf Packet buffer
+ *
+ * @return Packet buffer data offset
+ */
+uint32_t odp_packet_buf_data_offset(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().
+ *
+ * @param pkt_buf Packet buffer
+ *
+ * @return Packet buffer data length
+ */
+uint32_t odp_packet_buf_data_len(odp_packet_buf_t pkt_buf);
+
+/**
+ * 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.
+ *
+ * @param pkt_buf Packet buffer
+ * @param data_offset Packet buffer data offset in bytes (from the buffer head pointer)
+ * @param data_len Packet buffer data length in bytes
+ */
+void odp_packet_buf_data_set(odp_packet_buf_t pkt_buf, uint32_t data_offset, uint32_t data_len);
+
+/**
+ * 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()).
+ *
+ * @param pool Pool from which the packet buffer (disassembled packet) originate from
+ * @param head Head pointer
+ *
+ * @return Packet buffer handle on success
+ * @retval ODP_PACKET_BUF_INVALID on failure
+ */
+odp_packet_buf_t odp_packet_buf_from_head(odp_pool_t pool, void *head);
+
+/**
+ * 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()).
+ *
+ * @param pkt Packet to be disassembled
+ * @param[out] pkt_buf Packet buffer handle array for output
+ * @param num Number of elements in packet buffer handle array. Must be equal to or
+ * larger than number of segments in the packet.
+ *
+ * @return Number of handles written (equals the number of segments in the packet)
+ * @retval 0 on failure
+ */
+uint32_t odp_packet_disassemble(odp_packet_t pkt, 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()).
+ *
+ * @param pool Pool from which all packet buffers (disassembled packets) originate from
+ * @param pkt_buf Packet buffers to form a new packet
+ * @param num Number of packet buffers. Must not exceed max_segs_per_pkt pool capability.
+ *
+ * @return Handle of the newly formed packet
+ * @retval ODP_PACKET_INVALID on failure
+ */
+odp_packet_t odp_packet_reassemble(odp_pool_t pool, odp_packet_buf_t pkt_buf[], uint32_t num);
+
/*
*
* References
@@ -1421,52 +1299,6 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset,
*/
/**
- * Flags to control packet data checksum checking
- */
-typedef union odp_proto_chksums_t {
- /** Individual checksum bits. */
- struct {
- /** IPv4 header checksum */
- uint32_t ipv4 : 1;
-
- /** UDP checksum */
- uint32_t udp : 1;
-
- /** TCP checksum */
- uint32_t tcp : 1;
-
- /** SCTP checksum */
- uint32_t sctp : 1;
-
- } chksum;
-
- /** All checksum bits. This can be used to set/clear all flags. */
- uint32_t all_chksum;
-
-} odp_proto_chksums_t;
-
-/**
- * Packet parse parameters
- */
-typedef struct odp_packet_parse_param_t {
- /** Protocol header at parse starting point. Valid values for this
- * field are: ODP_PROTO_ETH, ODP_PROTO_IPV4, ODP_PROTO_IPV6. */
- odp_proto_t proto;
-
- /** Continue parsing until this layer. Must be the same or higher
- * layer than the layer of 'proto'. */
- odp_proto_layer_t last_layer;
-
- /** Flags to control payload data checksums checks up to the selected
- * parse layer. Checksum checking status can be queried for each packet
- * with odp_packet_l3_chksum_status() and
- * odp_packet_l4_chksum_status().
- */
- odp_proto_chksums_t chksums;
-
-} odp_packet_parse_param_t;
-
-/**
* Parse packet
*
* Parse protocol headers in packet data and update layer/protocol specific
@@ -1510,35 +1342,6 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset,
int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[],
int num, const odp_packet_parse_param_t *param);
-/** Packet parse results */
-typedef struct odp_packet_parse_result_t {
- /** Parse result flags */
- odp_packet_parse_result_flag_t flag;
-
- /** @see odp_packet_len() */
- uint32_t packet_len;
-
- /** @see odp_packet_l2_offset() */
- uint32_t l2_offset;
- /** @see odp_packet_l3_offset() */
- uint32_t l3_offset;
- /** @see odp_packet_l4_offset() */
- uint32_t l4_offset;
-
- /** @see odp_packet_l3_chksum_status() */
- odp_packet_chksum_status_t l3_chksum_status;
- /** @see odp_packet_l4_chksum_status() */
- odp_packet_chksum_status_t l4_chksum_status;
-
- /** @see odp_packet_l2_type() */
- odp_proto_l2_type_t l2_type;
- /** @see odp_packet_l3_type() */
- odp_proto_l3_type_t l3_type;
- /** @see odp_packet_l4_type() */
- odp_proto_l4_type_t l4_type;
-
-} odp_packet_parse_result_t;
-
/**
* Read parse results
*
@@ -2101,42 +1904,6 @@ void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj);
uint64_t odp_packet_cls_mark(odp_packet_t pkt);
/**
- * LSO options
- */
-typedef struct odp_packet_lso_opt_t {
- /** LSO profile handle
- *
- * 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. See LSO documentation
- * (e.g. odp_pktout_send_lso() and odp_lso_protocol_t) for additional metadata
- * requirements.
- */
- odp_lso_profile_t lso_profile;
-
- /** LSO payload offset
- *
- * LSO operation considers packet data before 'payload_offset' as
- * protocol headers and copies those in front of every created segment. It will modify
- * protocol headers according to the LSO profile before segment transmission.
- *
- * When stored into a packet, this offset can be read with odp_packet_payload_offset() and
- * modified with odp_packet_payload_offset_set().
- */
- uint32_t payload_offset;
-
- /** Maximum payload length in an LSO segment
- *
- * Max_payload_len parameter defines the maximum number of payload bytes in each
- * created segment. Depending on the implementation, segments with less payload may be
- * created. However, this value is used typically to divide packet payload evenly over
- * all segments except the last one, which contains the remaining payload bytes.
- */
- uint32_t max_payload_len;
-
-} odp_packet_lso_opt_t;
-
-/**
* Request Large Send Offload (LSO) for a packet
*
* Setup packet metadata which requests LSO segmentation to be performed during packet output.
@@ -2234,32 +2001,6 @@ void odp_packet_aging_tmo_set(odp_packet_t pkt, uint64_t tmo_ns);
*/
uint64_t odp_packet_aging_tmo(odp_packet_t pkt);
-/** Packet Tx completion mode */
-typedef enum odp_packet_tx_compl_mode_t {
- /** Packet Tx completion event is disabled
- *
- * When mode is disabled, all other fields of odp_packet_tx_compl_opt_t are ignored.
- */
- ODP_PACKET_TX_COMPL_DISABLED,
- /** Packet Tx completion event is sent for all packets (both transmitted and dropped) */
- ODP_PACKET_TX_COMPL_ALL,
-} odp_packet_tx_compl_mode_t;
-
-/**
- * Tx completion request options
- */
-typedef struct odp_packet_tx_compl_opt_t {
- /** Queue handle
- *
- * Tx completion event will be posted to ODP queue identified by this handle.
- */
- odp_queue_t queue;
-
- /** Packet Tx completion event mode */
- odp_packet_tx_compl_mode_t mode;
-
-} odp_packet_tx_compl_opt_t;
-
/**
* Request Tx completion event.
*
@@ -2290,6 +2031,44 @@ int odp_packet_tx_compl_request(odp_packet_t pkt, const odp_packet_tx_compl_opt_
*/
int odp_packet_has_tx_compl_request(odp_packet_t pkt);
+/**
+ * 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.
+ *
+ * @param pkt Packet handle
+ * @param opt Proto stats options. If NULL, then proto stats update is
+ * disabled for this packet.
+ *
+ * @see odp_proto_stats_capability_t::tx
+ */
+void odp_packet_proto_stats_request(odp_packet_t pkt, odp_packet_proto_stats_opt_t *opt);
+
+/**
+ * Get proto stats object.
+ *
+ * Get the proto stats object associated with the given packet.
+ *
+ * @param pkt Packet handle
+ *
+ * @return Proto stats object handle or ODP_PROTO_STATS_INVALID if not set.
+ */
+odp_proto_stats_t odp_packet_proto_stats(odp_packet_t pkt);
+
/*
*
* Packet vector handling routines
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index d723ef11a..2ccd7b4c8 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -21,7 +21,7 @@ extern "C" {
#include <odp/api/deprecated.h>
#include <odp/api/packet_io_stats.h>
-#include <odp/api/queue.h>
+#include <odp/api/queue_types.h>
#include <odp/api/reassembly.h>
#include <odp/api/time.h>
#include <odp/api/packet.h>
@@ -506,6 +506,9 @@ typedef union odp_pktout_config_opt_t {
*/
uint64_t tx_compl_ena : 1;
+ /** Enable packet protocol stats update */
+ uint64_t proto_stats_ena : 1;
+
} bit;
/** All bits of the bit field structure
diff --git a/include/odp/api/spec/packet_types.h b/include/odp/api/spec/packet_types.h
new file mode 100644
index 000000000..5549f03aa
--- /dev/null
+++ b/include/odp/api/spec/packet_types.h
@@ -0,0 +1,466 @@
+/* Copyright (c) 2013-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP packet types
+ */
+
+#ifndef ODP_API_SPEC_PACKET_TYPES_H_
+#define ODP_API_SPEC_PACKET_TYPES_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/proto_stats_types.h>
+#include <odp/api/queue_types.h>
+
+/** @addtogroup odp_packet
+ * @{
+ */
+
+/**
+ * @typedef odp_packet_t
+ * ODP packet
+ */
+
+/**
+ * @def ODP_PACKET_INVALID
+ * Invalid packet
+ */
+
+/**
+ * @def ODP_PACKET_OFFSET_INVALID
+ * Invalid packet offset
+ */
+
+/**
+ * @typedef 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.
+ */
+
+/**
+ * @def ODP_PACKET_SEG_INVALID
+ * Invalid packet segment
+ */
+
+/**
+ * @typedef 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.
+ */
+
+/**
+ * @def ODP_PACKET_BUF_INVALID
+ * Invalid packet buffer
+ */
+
+/**
+ * @typedef odp_packet_color_t
+ * Color of packet for shaper/drop processing
+ *
+ * @var ODP_PACKET_GREEN
+ * Packet is green
+ *
+ * @var ODP_PACKET_YELLOW
+ * Packet is yellow
+ *
+ * @var ODP_PACKET_RED
+ * Packet is red
+ */
+
+/**
+ * Maximum number of packet colors which accommodates ODP_PACKET_GREEN, ODP_PACKET_YELLOW and
+ * ODP_PACKET_RED.
+ */
+#define ODP_NUM_PACKET_COLORS 3
+
+/**
+ * @typedef odp_proto_l2_type_t
+ * Layer 2 protocol type
+ */
+
+/**
+ * @def ODP_PROTO_L2_TYPE_NONE
+ * Layer 2 protocol type not defined
+ *
+ * @def ODP_PROTO_L2_TYPE_ETH
+ * Layer 2 protocol is Ethernet
+ */
+
+/**
+ * @typedef odp_proto_l3_type_t
+ * Layer 3 protocol type
+ */
+
+/**
+ * @def ODP_PROTO_L3_TYPE_NONE
+ * Layer 3 protocol type not defined
+ *
+ * @def ODP_PROTO_L3_TYPE_ARP
+ * Layer 3 protocol is ARP
+ *
+ * @def ODP_PROTO_L3_TYPE_RARP
+ * Layer 3 protocol is RARP
+ *
+ * @def ODP_PROTO_L3_TYPE_MPLS
+ * Layer 3 protocol is MPLS
+ *
+ * @def ODP_PROTO_L3_TYPE_IPV4
+ * Layer 3 protocol type is IPv4
+ *
+ * @def ODP_PROTO_L3_TYPE_IPV6
+ * Layer 3 protocol type is IPv6
+ */
+
+/**
+ * @typedef odp_proto_l4_type_t
+ * Layer 4 protocol type
+ */
+
+/**
+ * @def ODP_PROTO_L4_TYPE_NONE
+ * Layer 4 protocol type not defined
+ *
+ * @def ODP_PROTO_L4_TYPE_ICMPV4
+ * Layer 4 protocol type is ICMPv4
+ *
+ * @def ODP_PROTO_L4_TYPE_IGMP
+ * Layer 4 protocol type is IGMP
+ *
+ * @def ODP_PROTO_L4_TYPE_IPV4
+ * Layer 4 protocol type is IPv4
+ *
+ * @def ODP_PROTO_L4_TYPE_TCP
+ * Layer 4 protocol type is TCP
+ *
+ * @def ODP_PROTO_L4_TYPE_UDP
+ * Layer 4 protocol type is UDP
+ *
+ * @def ODP_PROTO_L4_TYPE_IPV6
+ * Layer 4 protocol type is IPv6
+ *
+ * @def ODP_PROTO_L4_TYPE_GRE
+ * Layer 4 protocol type is GRE
+ *
+ * @def ODP_PROTO_L4_TYPE_ESP
+ * Layer 4 protocol type is IPSEC ESP
+ *
+ * @def ODP_PROTO_L4_TYPE_AH
+ * Layer 4 protocol type is IPSEC AH
+ *
+ * @def ODP_PROTO_L4_TYPE_ICMPV6
+ * Layer 4 protocol type is ICMPv6
+ *
+ * @def ODP_PROTO_L4_TYPE_NO_NEXT
+ * Layer 4 protocol type is "No Next Header".
+ * Protocol / next header number is 59.
+ *
+ * @def ODP_PROTO_L4_TYPE_IPCOMP
+ * Layer 4 protocol type is IP Payload Compression Protocol
+ *
+ * @def ODP_PROTO_L4_TYPE_SCTP
+ * Layer 4 protocol type is SCTP
+ *
+ * @def ODP_PROTO_L4_TYPE_ROHC
+ * Layer 4 protocol type is ROHC
+ */
+
+/**
+ * @typedef odp_packet_chksum_status_t
+ * Checksum check status in packet
+ *
+ * @var ODP_PACKET_CHKSUM_UNKNOWN
+ * Checksum was not checked. Checksum check was not
+ * attempted or the attempt failed.
+ *
+ * @var ODP_PACKET_CHKSUM_BAD
+ * Checksum was checked and it was not correct.
+ *
+ * @var ODP_PACKET_CHKSUM_OK
+ * Checksum was checked and it was correct.
+ */
+
+/**
+ * @typedef odp_packet_vector_t
+ * ODP packet vector
+ */
+
+/**
+ * @def ODP_PACKET_VECTOR_INVALID
+ * Invalid packet vector
+ */
+
+/**
+ * @typedef odp_packet_tx_compl_t
+ * ODP Packet Tx completion
+ */
+
+/**
+ * @def ODP_PACKET_TX_COMPL_INVALID
+ * Invalid packet Tx completion
+ */
+
+/**
+ * Protocol
+ */
+typedef enum odp_proto_t {
+ /** No protocol defined */
+ ODP_PROTO_NONE = 0,
+
+ /** Ethernet (including VLAN) */
+ ODP_PROTO_ETH,
+
+ /** IP version 4 */
+ ODP_PROTO_IPV4,
+
+ /** IP version 6 */
+ ODP_PROTO_IPV6
+
+} odp_proto_t;
+
+/**
+ * Protocol layer
+ */
+typedef enum odp_proto_layer_t {
+ /** No layers */
+ ODP_PROTO_LAYER_NONE = 0,
+
+ /** Layer L2 protocols (Ethernet, VLAN, etc) */
+ ODP_PROTO_LAYER_L2,
+
+ /** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */
+ ODP_PROTO_LAYER_L3,
+
+ /** Layer L4 protocols (UDP, TCP, SCTP) */
+ ODP_PROTO_LAYER_L4,
+
+ /** All layers */
+ ODP_PROTO_LAYER_ALL
+
+} odp_proto_layer_t;
+
+/**
+ * Packet API data range specifier
+ */
+typedef struct odp_packet_data_range {
+ /** Offset from beginning of packet */
+ uint32_t offset;
+
+ /** Length of data to operate on */
+ uint32_t length;
+
+} odp_packet_data_range_t;
+
+/**
+ * Reassembly status of a packet
+ */
+typedef enum odp_packet_reass_status_t {
+ /** Reassembly was not attempted */
+ ODP_PACKET_REASS_NONE = 0,
+
+ /** 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_INCOMPLETE,
+
+ /** Reassembly was successfully done. The packet has been
+ * reassembled from multiple received fragments. */
+ ODP_PACKET_REASS_COMPLETE,
+} odp_packet_reass_status_t;
+
+/**
+ * Result from odp_packet_reass_partial_state()
+ */
+typedef struct odp_packet_reass_partial_state_t {
+ /** Number of fragments returned */
+ uint16_t num_frags;
+
+ /** Time, in ns, since the reception of the first received fragment */
+ uint64_t elapsed_time;
+} odp_packet_reass_partial_state_t;
+
+/**
+ * Flags to control packet data checksum checking
+ */
+typedef union odp_proto_chksums_t {
+ /** Individual checksum bits. */
+ struct {
+ /** IPv4 header checksum */
+ uint32_t ipv4 : 1;
+
+ /** UDP checksum */
+ uint32_t udp : 1;
+
+ /** TCP checksum */
+ uint32_t tcp : 1;
+
+ /** SCTP checksum */
+ uint32_t sctp : 1;
+
+ } chksum;
+
+ /** All checksum bits. This can be used to set/clear all flags. */
+ uint32_t all_chksum;
+
+} odp_proto_chksums_t;
+
+/**
+ * Packet parse parameters
+ */
+typedef struct odp_packet_parse_param_t {
+ /** Protocol header at parse starting point. Valid values for this
+ * field are: ODP_PROTO_ETH, ODP_PROTO_IPV4, ODP_PROTO_IPV6. */
+ odp_proto_t proto;
+
+ /** Continue parsing until this layer. Must be the same or higher
+ * layer than the layer of 'proto'. */
+ odp_proto_layer_t last_layer;
+
+ /** Flags to control payload data checksums checks up to the selected
+ * parse layer. Checksum checking status can be queried for each packet
+ * with odp_packet_l3_chksum_status() and
+ * odp_packet_l4_chksum_status().
+ */
+ odp_proto_chksums_t chksums;
+
+} odp_packet_parse_param_t;
+
+/**
+ * Packet parse results
+ */
+typedef struct odp_packet_parse_result_t {
+ /** Parse result flags */
+ odp_packet_parse_result_flag_t flag;
+
+ /** @see odp_packet_len() */
+ uint32_t packet_len;
+
+ /** @see odp_packet_l2_offset() */
+ uint32_t l2_offset;
+ /** @see odp_packet_l3_offset() */
+ uint32_t l3_offset;
+ /** @see odp_packet_l4_offset() */
+ uint32_t l4_offset;
+
+ /** @see odp_packet_l3_chksum_status() */
+ odp_packet_chksum_status_t l3_chksum_status;
+ /** @see odp_packet_l4_chksum_status() */
+ odp_packet_chksum_status_t l4_chksum_status;
+
+ /** @see odp_packet_l2_type() */
+ odp_proto_l2_type_t l2_type;
+ /** @see odp_packet_l3_type() */
+ odp_proto_l3_type_t l3_type;
+ /** @see odp_packet_l4_type() */
+ odp_proto_l4_type_t l4_type;
+
+} odp_packet_parse_result_t;
+
+/**
+ * LSO options
+ */
+typedef struct odp_packet_lso_opt_t {
+ /** LSO profile handle
+ *
+ * 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. See LSO documentation
+ * (e.g. odp_pktout_send_lso() and odp_lso_protocol_t) for additional metadata
+ * requirements.
+ */
+ odp_lso_profile_t lso_profile;
+
+ /** LSO payload offset
+ *
+ * LSO operation considers packet data before 'payload_offset' as
+ * protocol headers and copies those in front of every created segment. It will modify
+ * protocol headers according to the LSO profile before segment transmission.
+ *
+ * When stored into a packet, this offset can be read with odp_packet_payload_offset() and
+ * modified with odp_packet_payload_offset_set().
+ */
+ uint32_t payload_offset;
+
+ /** Maximum payload length in an LSO segment
+ *
+ * Max_payload_len parameter defines the maximum number of payload bytes in each
+ * created segment. Depending on the implementation, segments with less payload may be
+ * created. However, this value is used typically to divide packet payload evenly over
+ * all segments except the last one, which contains the remaining payload bytes.
+ */
+ uint32_t max_payload_len;
+
+} odp_packet_lso_opt_t;
+
+/**
+ * Packet Tx completion mode
+ */
+typedef enum odp_packet_tx_compl_mode_t {
+ /** Packet Tx completion event is disabled
+ *
+ * When mode is disabled, all other fields of odp_packet_tx_compl_opt_t are ignored.
+ */
+ ODP_PACKET_TX_COMPL_DISABLED,
+ /** Packet Tx completion event is sent for all packets (both transmitted and dropped) */
+ ODP_PACKET_TX_COMPL_ALL,
+} odp_packet_tx_compl_mode_t;
+
+/**
+ * Tx completion request options
+ */
+typedef struct odp_packet_tx_compl_opt_t {
+ /** Queue handle
+ *
+ * Tx completion event will be posted to ODP queue identified by this handle.
+ */
+ odp_queue_t queue;
+
+ /** Packet Tx completion event mode */
+ odp_packet_tx_compl_mode_t mode;
+
+} odp_packet_tx_compl_opt_t;
+
+/**
+ * Packet proto stats options
+ */
+typedef struct odp_packet_proto_stats_opt_t {
+ /** Packet proto stats object handle
+ *
+ * Stats in the packet proto stats object will be updated.
+ */
+ odp_proto_stats_t stat;
+
+ /** Octet counter 0 adjust */
+ int32_t oct_count0_adj;
+
+ /** Octet counter 1 adjust */
+ int32_t oct_count1_adj;
+} odp_packet_proto_stats_opt_t;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h
index c30d937e5..6314b827c 100644
--- a/include/odp/api/spec/pool.h
+++ b/include/odp/api/spec/pool.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
- * Copyright (c) 2020, Nokia
+ * Copyright (c) 2020-2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -20,6 +20,7 @@ extern "C" {
#endif
#include <odp/api/std_types.h>
+#include <odp/api/spec/pool_types.h>
/** @defgroup odp_pool ODP POOL
* Packet and buffer (event) pools.
@@ -27,275 +28,6 @@ extern "C" {
*/
/**
- * @typedef odp_pool_t
- * ODP pool
- */
-
-/**
- * @def ODP_POOL_INVALID
- * Invalid pool
- */
-
-/**
- * @def ODP_POOL_NAME_LEN
- * Maximum pool name length in chars including null char
- */
-
-/** Maximum number of packet pool subparameters */
-#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 {
- /** Maximum number of pools of any type */
- unsigned int max_pools;
-
- /** Buffer pool capabilities */
- struct {
- /** Maximum number of buffer pools */
- unsigned int max_pools;
-
- /** Maximum buffer data alignment in bytes */
- uint32_t max_align;
-
- /** Maximum buffer data size in bytes
- *
- * The value of zero means that size is limited only by the
- * available memory size for the pool. */
- uint32_t max_size;
-
- /** Maximum number of buffers of any size
- *
- * The value of zero means that limited only by the available
- * memory size for the pool. */
- uint32_t max_num;
-
- /** 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;
- } buf;
-
- /** Packet pool capabilities */
- struct {
- /** Maximum number of packet pools */
- unsigned int max_pools;
-
- /** Maximum packet data length in bytes
- *
- * This defines the maximum packet data length that can be
- * stored into a packet. Attempts to allocate or extend packets
- * to sizes larger than this limit will fail.
- *
- * The value of zero means that limited only by the available
- * memory size for the pool. */
- uint32_t max_len;
-
- /** Maximum number of packets of any length
- *
- * The value of zero means that limited only by the available
- * memory size for the pool. */
- uint32_t max_num;
-
- /** Maximum packet data alignment in bytes
- *
- * This is the maximum value of packet pool alignment
- * (pkt.align) parameter. */
- uint32_t max_align;
-
- /** Minimum packet level headroom length in bytes
- *
- * The minimum number of headroom bytes that newly created
- * packets have by default. The default apply to both ODP
- * packet input and user allocated packets.*/
- uint32_t min_headroom;
-
- /** Maximum packet level headroom length in bytes
- *
- * The maximum value of packet pool headroom parameter
- * that can be configured. This value applies to both ODP
- * packet input and user allocated packets.*/
- uint32_t max_headroom;
-
- /** Minimum packet level tailroom length in bytes
- *
- * The minimum number of tailroom bytes that newly created
- * packets have by default. The default apply to both ODP
- * packet input and user allocated packets.*/
- uint32_t min_tailroom;
-
- /** Maximum number of segments per packet */
- uint32_t max_segs_per_pkt;
-
- /** Minimum packet segment data length in bytes
- *
- * The user defined segment length (seg_len in
- * odp_pool_param_t) will be rounded up into this value. */
- uint32_t min_seg_len;
-
- /** Maximum packet segment data length in bytes
- *
- * The user defined segment length (seg_len in odp_pool_param_t)
- * must not be larger than this.
- *
- * The value of zero means that limited only by the available
- * memory size for the pool. */
- uint32_t max_seg_len;
-
- /** Maximum user area size in bytes
- *
- * The value of zero means that limited only by the available
- * memory size for the pool. */
- uint32_t max_uarea_size;
-
- /** Maximum number of subparameters
- *
- * Maximum number of packet pool subparameters. Valid range is
- * 0 ... ODP_POOL_MAX_SUBPARAMS. */
- uint8_t max_num_subparam;
-
- /** 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;
- } pkt;
-
- /** Timeout pool capabilities */
- struct {
- /** Maximum number of timeout pools */
- unsigned int max_pools;
-
- /** Maximum number of timeout events in a pool
- *
- * The value of zero means that limited only by the available
- * memory size for the pool. */
- uint32_t max_num;
-
- /** 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;
- } 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;
-
-/**
* Query pool capabilities
*
* Outputs pool capabilities on success.
@@ -308,209 +40,6 @@ typedef struct odp_pool_capability_t {
int odp_pool_capability(odp_pool_capability_t *capa);
/**
- * Packet pool subparameters
- */
-typedef struct odp_pool_pkt_subparam_t {
- /** Number of 'len' byte packets. */
- uint32_t num;
-
- /** Packet length in bytes */
- uint32_t len;
-
-} odp_pool_pkt_subparam_t;
-
-/**
- * Pool parameters
- */
-typedef struct odp_pool_param_t {
- /** Pool type */
- int type;
-
- /** Parameters for buffer pools */
- struct {
- /** Number of buffers in the pool */
- uint32_t num;
-
- /** Buffer size in bytes. The maximum number of bytes
- * application will store in each buffer.
- */
- uint32_t size;
-
- /** Minimum buffer alignment in bytes. Valid values are
- * powers of two. Use 0 for default alignment.
- * Default will always be a multiple of 8.
- */
- uint32_t align;
-
- /** Maximum number of buffers cached locally per thread
- *
- * A non-zero value allows implementation to cache buffers
- * locally per each thread. Thread local caching may improve
- * performance, but requires application to take account that
- * some buffers may be stored locally per thread and thus are
- * not available for allocation from other threads.
- *
- * This is the maximum number of buffers to be cached per
- * thread. The actual cache size is implementation specific.
- * The value must not be less than 'min_cache_size' or exceed
- * 'max_cache_size' capability. The default value is
- * implementation specific and set by odp_pool_param_init().
- */
- uint32_t cache_size;
- } buf;
-
- /** Parameters for packet pools */
- struct {
- /** Minimum number of 'len' byte packets.
- *
- * The pool must contain at least this many packets that are
- * 'len' bytes or smaller. An implementation may round up the
- * value, as long as the 'max_num' parameter below is not
- * violated. The maximum value for this field is defined by
- * pool capability pkt.max_num.
- */
- uint32_t num;
-
- /** Maximum number of packets.
- *
- * This is the maximum number of packets of any length that can
- * be allocated from the pool. The maximum value is defined by
- * pool capability pkt.max_num. Use 0 when there's no
- * requirement for the maximum number of packets. The default
- * value is 0.
- */
- uint32_t max_num;
-
- /** Minimum length of 'num' packets.
- *
- * The pool must contain at least 'num' packets up to this
- * packet length (1 ... 'len' bytes). The maximum value for
- * this field is defined by pool capability pkt.max_len.
- * Use 0 for default.
- */
- uint32_t len;
-
- /** Maximum packet length that will be allocated from
- * the pool. The maximum value is defined by pool capability
- * pkt.max_len. Use 0 for default.
- */
- uint32_t max_len;
-
- /** Minimum packet data alignment in bytes.
- *
- * Valid values are powers of two. User allocated packets have
- * start of data (@see odp_packet_data()) aligned to this or
- * a higher alignment (power of two value). This parameter
- * does not apply to packets that ODP allocates internally
- * (e.g. packets from packet input).
- *
- * The maximum value is defined by pool capability
- * pkt.max_align. Use 0 for default alignment.
- */
- uint32_t align;
-
- /** Minimum number of packet data bytes that are stored in the
- * first segment of a packet. The maximum value is defined by
- * pool capability pkt.max_seg_len. Use 0 for default.
- */
- uint32_t seg_len;
-
- /** User area size in bytes. The maximum value is defined by
- * pool capability pkt.max_uarea_size. Specify as 0 if no user
- * area is needed.
- */
- uint32_t uarea_size;
-
- /** Minimum headroom size in bytes. Each newly allocated
- * packet from the pool must have at least this much headroom.
- * The maximum value is defined by pool capability
- * pkt.max_headroom. Use zero if headroom is not needed.
- */
- uint32_t headroom;
-
- /** Number of subparameters
- *
- * The number of subparameter table entries used. The maximum
- * value is defined by pool capability pkt.max_num_subparam.
- * The default value is 0.
- */
- uint8_t num_subparam;
-
- /** Subparameter table
- *
- * Subparameters continue pool configuration with additional
- * packet length requirements. The first table entry follows
- * the num/len specification above. So that, sub[0].len > 'len'
- * and sub[0].num refers to packet lengths between 'len' + 1
- * and sub[0].len. Similarly, sub[1] follows sub[0]
- * specification, and so on.
- *
- * Each requirement is supported separately and may be rounded
- * up, as long as the 'max_num' parameter is not violated. It's
- * implementation specific if some requirements are supported
- * simultaneously (e.g. due to subpool design).
- */
- odp_pool_pkt_subparam_t sub[ODP_POOL_MAX_SUBPARAMS];
-
- /** Maximum number of packets cached locally per thread
- *
- * See buf.cache_size documentation for details.
- */
- uint32_t cache_size;
- } pkt;
-
- /** Parameters for timeout pools */
- struct {
- /** Number of timeouts in the pool */
- uint32_t num;
-
- /** Maximum number of timeouts cached locally per thread
- *
- * See buf.cache_size documentation for details.
- */
- 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*/
-#define ODP_POOL_PACKET ODP_EVENT_PACKET
-/** Buffer pool */
-#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
*
* This routine is used to create a pool. The use of pool name is optional.
@@ -553,49 +82,6 @@ int odp_pool_destroy(odp_pool_t pool);
odp_pool_t odp_pool_lookup(const char *name);
/**
- * Pool information struct
- * Used to get information about a pool.
- */
-typedef struct odp_pool_info_t {
- /** Pool name */
- const char *name;
-
- /** Copy of pool parameters */
- odp_pool_param_t params;
-
- /** Additional info for packet pools */
- struct {
- /** Maximum number of packets of any length
- *
- * This is the maximum number of packets that can be allocated
- * from the pool at anytime. Application can use this e.g.
- * to prepare enough per packet contexts.
- */
- uint32_t max_num;
-
- } pkt;
-
- /** Minimum data address.
- *
- * This is the minimum address that application accessible
- * data of any object (event) allocated from the pool may
- * locate. When there's no application accessible data
- * (e.g. ODP_POOL_TIMEOUT pools), the value may be zero.
- */
- uintptr_t min_data_addr;
-
- /** Maximum data address.
- *
- * This is the maximum address that application accessible
- * data of any object (event) allocated from the pool may
- * locate. When there's no application accessible data
- * (e.g. ODP_POOL_TIMEOUT pools), the value may be zero.
- */
- uintptr_t max_data_addr;
-
-} odp_pool_info_t;
-
-/**
* Retrieve information about a pool
*
* @param pool Pool handle
@@ -688,6 +174,108 @@ int odp_pool_stats(odp_pool_t pool, odp_pool_stats_t *stats);
int odp_pool_stats_reset(odp_pool_t pool);
/**
+ * Query capabilities of an external memory pool type
+ *
+ * Outputs pool capabilities on success. Returns failure if a bad pool type is used. When
+ * the requested pool type is valid but not supported, sets the value of 'max_pools' to zero.
+ *
+ * @param type Pool type
+ * @param[out] capa Pointer to capability structure for output
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_pool_ext_capability(odp_pool_type_t type, odp_pool_ext_capability_t *capa);
+
+/**
+ * Initialize pool params
+ *
+ * Initialize an odp_pool_ext_param_t to its default values for all fields
+ * based on the selected pool type.
+ *
+ * @param type Pool type
+ * @param param odp_pool_ext_param_t to be initialized
+ */
+void odp_pool_ext_param_init(odp_pool_type_t type, odp_pool_ext_param_t *param);
+
+/**
+ * Create an external memory pool
+ *
+ * This routine is used to create a pool. The use of pool name is optional.
+ * Unique names are not required. However, odp_pool_lookup() returns only a
+ * single matching pool. Use odp_pool_ext_param_init() to initialize parameters
+ * into their default values.
+ *
+ * @param name Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN.
+ * @param param Pool parameters
+ *
+ * @return Pool handle on success
+ * @retval ODP_POOL_INVALID on failure
+ */
+odp_pool_t odp_pool_ext_create(const char *name, const odp_pool_ext_param_t *param);
+
+/**
+ * Populate external memory pool with buffer memory
+ *
+ * Populate can be called multiple times to add memory buffers into the pool. Application must
+ * populate the pool with the exact number of buffers specified in pool parameters. The pool is
+ * ready to be used for allocations only after all populate calls have returned successfully.
+ * Application marks the last populate call with ODP_POOL_POPULATE_DONE flag.
+ *
+ * Depending on pool usage (and ODP implementation), the memory may need to be accessible by
+ * HW accelerators. Application may use e.g. odp_shm_reserve() with ODP_SHM_HW_ACCESS flag to
+ * ensure HW access. The memory area used for one pool, starting from (or before) the lowest
+ * addressed buffer and extending to the end (or after) of the highest addressed buffer, must not
+ * overlap with the memory area used for any other pool. Pool capabilities
+ * (odp_pool_ext_capability_t) specify the minimum alignment of the memory area.
+ *
+ * Pool type defines memory buffer layout and where the buffer pointer (buf[N]) points
+ * in the layout. Pool capabilities specify requirements for buffer size, layout and
+ * pointer alignment.
+ *
+ * For packet pools, packet buffer layout is shown below. The packet headroom (odp_packet_head())
+ * starts immediately after the application header. For a segmented packet, each segment has this
+ * same layout. Buffer size includes all headers, headroom, data, tailroom and trailer.
+ *
+ * @code{.unparsed}
+ *
+ * +-------------------------------+ -- --
+ * buf[N] ---> | | | |
+ * | ODP header (optional) | > odp_header_size |
+ * | | | |
+ * +-------------------------------+ -- |
+ * | | | |
+ * | Application header (optional) | > app_header_size |
+ * | | | > buf_size
+ * +-------------------------------+ -- |
+ * odp_packet_head()--> | | |
+ * | Packet data | |
+ * | (headroom, data, tailroom) | |
+ * | | |
+ * | | |
+ * +-------------------------------+ -- |
+ * | | | |
+ * | ODP trailer (optional) | > odp_trailer_size |
+ * | | | |
+ * +-------------------------------+ -- --
+ *
+ * @endcode
+ *
+ * @param pool External memory pool
+ * @param buf Buffer pointers to be populated into the pool
+ * @param buf_size Buffer size
+ * @param num Number of buffer pointers
+ * @param flags 0: No flags
+ * ODP_POOL_POPULATE_DONE: Marks the last populate call and completes the pool
+ * population phase
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_pool_ext_populate(odp_pool_t pool, void *buf[], uint32_t buf_size, uint32_t num,
+ uint32_t flags);
+
+/**
* @}
*/
diff --git a/include/odp/api/spec/pool_types.h b/include/odp/api/spec/pool_types.h
new file mode 100644
index 000000000..44d9297c1
--- /dev/null
+++ b/include/odp/api/spec/pool_types.h
@@ -0,0 +1,772 @@
+/* Copyright (c) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * Type definitions for pools
+ */
+
+#ifndef ODP_API_SPEC_POOL_TYPES_H_
+#define ODP_API_SPEC_POOL_TYPES_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/std_types.h>
+
+/** @addtogroup odp_pool
+ * @{
+ */
+
+/**
+ * @typedef odp_pool_t
+ * ODP pool
+ */
+
+/**
+ * @def ODP_POOL_INVALID
+ * Invalid pool
+ */
+
+/**
+ * @def ODP_POOL_NAME_LEN
+ * Maximum pool name length in chars including null char
+ */
+
+/** Maximum number of packet pool subparameters */
+#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 {
+ /** Maximum number of pools of any type */
+ unsigned int max_pools;
+
+ /** Buffer pool capabilities */
+ struct {
+ /** Maximum number of buffer pools */
+ unsigned int max_pools;
+
+ /** Maximum buffer data alignment in bytes */
+ uint32_t max_align;
+
+ /** Maximum buffer data size in bytes
+ *
+ * The value of zero means that size is limited only by the
+ * available memory size for the pool. */
+ uint32_t max_size;
+
+ /** Maximum number of buffers of any size
+ *
+ * The value of zero means that limited only by the available
+ * memory size for the pool. */
+ uint32_t max_num;
+
+ /** 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;
+ } buf;
+
+ /** Packet pool capabilities */
+ struct {
+ /** Maximum number of packet pools */
+ unsigned int max_pools;
+
+ /** Maximum packet data length in bytes
+ *
+ * This defines the maximum packet data length that can be
+ * stored into a packet. Attempts to allocate or extend packets
+ * to sizes larger than this limit will fail.
+ *
+ * The value of zero means that limited only by the available
+ * memory size for the pool. */
+ uint32_t max_len;
+
+ /** Maximum number of packets of any length
+ *
+ * The value of zero means that limited only by the available
+ * memory size for the pool. */
+ uint32_t max_num;
+
+ /** Maximum packet data alignment in bytes
+ *
+ * This is the maximum value of packet pool alignment
+ * (pkt.align) parameter. */
+ uint32_t max_align;
+
+ /** Minimum packet level headroom length in bytes
+ *
+ * The minimum number of headroom bytes that newly created
+ * packets have by default. The default apply to both ODP
+ * packet input and user allocated packets.*/
+ uint32_t min_headroom;
+
+ /** Maximum packet level headroom length in bytes
+ *
+ * The maximum value of packet pool headroom parameter
+ * that can be configured. This value applies to both ODP
+ * packet input and user allocated packets.*/
+ uint32_t max_headroom;
+
+ /** Minimum packet level tailroom length in bytes
+ *
+ * The minimum number of tailroom bytes that newly created
+ * packets have by default. The default apply to both ODP
+ * packet input and user allocated packets.*/
+ uint32_t min_tailroom;
+
+ /** Maximum number of segments per packet */
+ uint32_t max_segs_per_pkt;
+
+ /** Minimum packet segment data length in bytes
+ *
+ * The user defined segment length (seg_len in
+ * odp_pool_param_t) will be rounded up into this value. */
+ uint32_t min_seg_len;
+
+ /** Maximum packet segment data length in bytes
+ *
+ * The user defined segment length (seg_len in odp_pool_param_t)
+ * must not be larger than this.
+ *
+ * The value of zero means that limited only by the available
+ * memory size for the pool. */
+ uint32_t max_seg_len;
+
+ /** Maximum user area size in bytes
+ *
+ * The value of zero means that limited only by the available
+ * memory size for the pool. */
+ uint32_t max_uarea_size;
+
+ /** Maximum number of subparameters
+ *
+ * Maximum number of packet pool subparameters. Valid range is
+ * 0 ... ODP_POOL_MAX_SUBPARAMS. */
+ uint8_t max_num_subparam;
+
+ /** 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;
+ } pkt;
+
+ /** Timeout pool capabilities */
+ struct {
+ /** Maximum number of timeout pools */
+ unsigned int max_pools;
+
+ /** Maximum number of timeout events in a pool
+ *
+ * The value of zero means that limited only by the available
+ * memory size for the pool. */
+ uint32_t max_num;
+
+ /** 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;
+ } 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;
+
+/**
+ * Packet pool subparameters
+ */
+typedef struct odp_pool_pkt_subparam_t {
+ /** Number of 'len' byte packets. */
+ uint32_t num;
+
+ /** Packet length in bytes */
+ uint32_t len;
+
+} odp_pool_pkt_subparam_t;
+
+/**
+ * Pool types
+ */
+typedef enum odp_pool_type_t {
+ /** Packet pool*/
+ ODP_POOL_PACKET = ODP_EVENT_PACKET,
+
+ /** Buffer pool */
+ ODP_POOL_BUFFER = ODP_EVENT_BUFFER,
+
+ /** Timeout pool */
+ 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
+ */
+ ODP_POOL_VECTOR = (ODP_POOL_TIMEOUT + 1)
+
+} odp_pool_type_t;
+
+/**
+ * Pool parameters
+ */
+typedef struct odp_pool_param_t {
+ /** Pool type */
+ odp_pool_type_t type;
+
+ /** Parameters for buffer pools */
+ struct {
+ /** Number of buffers in the pool */
+ uint32_t num;
+
+ /** Buffer size in bytes. The maximum number of bytes
+ * application will store in each buffer.
+ */
+ uint32_t size;
+
+ /** Minimum buffer alignment in bytes. Valid values are
+ * powers of two. Use 0 for default alignment.
+ * Default will always be a multiple of 8.
+ */
+ uint32_t align;
+
+ /** Maximum number of buffers cached locally per thread
+ *
+ * A non-zero value allows implementation to cache buffers
+ * locally per each thread. Thread local caching may improve
+ * performance, but requires application to take account that
+ * some buffers may be stored locally per thread and thus are
+ * not available for allocation from other threads.
+ *
+ * This is the maximum number of buffers to be cached per
+ * thread. The actual cache size is implementation specific.
+ * The value must not be less than 'min_cache_size' or exceed
+ * 'max_cache_size' capability. The default value is
+ * implementation specific and set by odp_pool_param_init().
+ */
+ uint32_t cache_size;
+ } buf;
+
+ /** Parameters for packet pools */
+ struct {
+ /** Minimum number of 'len' byte packets.
+ *
+ * The pool must contain at least this many packets that are
+ * 'len' bytes or smaller. An implementation may round up the
+ * value, as long as the 'max_num' parameter below is not
+ * violated. The maximum value for this field is defined by
+ * pool capability pkt.max_num.
+ */
+ uint32_t num;
+
+ /** Maximum number of packets.
+ *
+ * This is the maximum number of packets of any length that can
+ * be allocated from the pool. The maximum value is defined by
+ * pool capability pkt.max_num. Use 0 when there's no
+ * requirement for the maximum number of packets. The default
+ * value is 0.
+ */
+ uint32_t max_num;
+
+ /** Minimum length of 'num' packets.
+ *
+ * The pool must contain at least 'num' packets up to this
+ * packet length (1 ... 'len' bytes). The maximum value for
+ * this field is defined by pool capability pkt.max_len.
+ * Use 0 for default.
+ */
+ uint32_t len;
+
+ /** Maximum packet length that will be allocated from
+ * the pool. The maximum value is defined by pool capability
+ * pkt.max_len. Use 0 for default.
+ */
+ uint32_t max_len;
+
+ /** Minimum packet data alignment in bytes.
+ *
+ * Valid values are powers of two. User allocated packets have
+ * start of data (@see odp_packet_data()) aligned to this or
+ * a higher alignment (power of two value). This parameter
+ * does not apply to packets that ODP allocates internally
+ * (e.g. packets from packet input).
+ *
+ * The maximum value is defined by pool capability
+ * pkt.max_align. Use 0 for default alignment.
+ */
+ uint32_t align;
+
+ /** Minimum number of packet data bytes that are stored in the
+ * first segment of a packet. The maximum value is defined by
+ * pool capability pkt.max_seg_len. Use 0 for default.
+ */
+ uint32_t seg_len;
+
+ /** User area size in bytes. The maximum value is defined by
+ * pool capability pkt.max_uarea_size. Specify as 0 if no user
+ * area is needed.
+ */
+ uint32_t uarea_size;
+
+ /** Minimum headroom size in bytes. Each newly allocated
+ * packet from the pool must have at least this much headroom.
+ * The maximum value is defined by pool capability
+ * pkt.max_headroom. Use zero if headroom is not needed.
+ */
+ uint32_t headroom;
+
+ /** Number of subparameters
+ *
+ * The number of subparameter table entries used. The maximum
+ * value is defined by pool capability pkt.max_num_subparam.
+ * The default value is 0.
+ */
+ uint8_t num_subparam;
+
+ /** Subparameter table
+ *
+ * Subparameters continue pool configuration with additional
+ * packet length requirements. The first table entry follows
+ * the num/len specification above. So that, sub[0].len > 'len'
+ * and sub[0].num refers to packet lengths between 'len' + 1
+ * and sub[0].len. Similarly, sub[1] follows sub[0]
+ * specification, and so on.
+ *
+ * Each requirement is supported separately and may be rounded
+ * up, as long as the 'max_num' parameter is not violated. It's
+ * implementation specific if some requirements are supported
+ * simultaneously (e.g. due to subpool design).
+ */
+ odp_pool_pkt_subparam_t sub[ODP_POOL_MAX_SUBPARAMS];
+
+ /** Maximum number of packets cached locally per thread
+ *
+ * See buf.cache_size documentation for details.
+ */
+ uint32_t cache_size;
+ } pkt;
+
+ /** Parameters for timeout pools */
+ struct {
+ /** Number of timeouts in the pool */
+ uint32_t num;
+
+ /** Maximum number of timeouts cached locally per thread
+ *
+ * See buf.cache_size documentation for details.
+ */
+ 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;
+
+/**
+ * External memory pool population done
+ *
+ * Application uses this flag to mark the last odp_pool_ext_populate() call, which completes
+ * external memory pool population phase.
+ */
+#define ODP_POOL_POPULATE_DONE 0x1
+
+/**
+ * External memory pool capabilities
+ *
+ * Generic fields (not specific to a pool type) contain capabilities
+ * of the requested pool type.
+ */
+typedef struct odp_pool_ext_capability_t {
+ /** Requested pool type
+ *
+ * Pool type from the odp_pool_ext_capability() call is recorded here for reference. */
+ odp_pool_type_t type;
+
+ /** Maximum number of pools
+ *
+ * Maximum number of external memory pools of the requested type. */
+ uint32_t max_pools;
+
+ /** 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;
+
+ /** Packet pool capabilities */
+ struct {
+ /** Maximum number of packet buffers */
+ uint32_t max_num_buf;
+
+ /** Maximum packet buffer size in bytes */
+ uint32_t max_buf_size;
+
+ /** ODP header size in bytes
+ *
+ * Application must reserve this many bytes from the start of a packet buffer
+ * for ODP implementation usage. When the value is zero, ODP implementation does
+ * not need header space to be reserved for it. Application will not modify this
+ * memory area (after buffer populate call).
+ */
+ uint32_t odp_header_size;
+
+ /** ODP trailer size in bytes
+ *
+ * Application must reserve this many bytes from the end of a packet buffer
+ * for ODP implementation usage. When the value is zero, ODP implementation does
+ * not need trailer space to be reserved for it. Application will not modify this
+ * memory area (after buffer populate call).
+ */
+ uint32_t odp_trailer_size;
+
+ /** Minimum packet pool memory area alignment in bytes
+ *
+ * The memory area used for a packet pool, starting from (or before) the lowest
+ * addressed buffer and extending to the end (or after) of the highest addressed
+ * buffer, must have at least this (power of two) alignment. The value is 1 when
+ * there is no alignment requirement.
+ */
+ uint32_t min_mem_align;
+
+ /** Minimum packet buffer pointer alignment in bytes
+ *
+ * Packet buffer pointers populated into a pool must be evenly divisible with
+ * this value. The value is 1 when there is no alignment requirement.
+ */
+ uint32_t min_buf_align;
+
+ /** Minimum packet headroom alignment in bytes
+ *
+ * Packet buffers populated into a pool must have their headroom start address
+ * evenly divisible with this value. The value is 1 when there is no alignment
+ * requirement.
+ */
+ uint32_t min_head_align;
+
+ /** Packet buffer alignment flags
+ *
+ * These flags specify additional alignment requirements for packet buffers.
+ * If not stated otherwise, min_buf_align and min_head_align alignment
+ * requirements apply also.
+ */
+ struct {
+ /** Packet buffers are size aligned
+ *
+ * When set, packet buffer pointers must be aligned to the buffer size.
+ * For example, if the buffer size would be 2304 bytes (0x900),
+ * each buffer start address must be a multiple of 0x900
+ * (e.g. 0x12000900, 0x12001200, 0x12004800, etc). */
+ uint16_t buf_size_aligned : 1;
+
+ };
+
+ /** Maximum headroom parameter value
+ *
+ * The packet pool headroom parameter may not exceed this value.
+ */
+ uint32_t max_headroom;
+
+ /** Maximum headroom size in bytes
+ *
+ * Any newly allocated packet will have at most this much headroom. Application
+ * may use this to ensure that packet buffer size is large enough to fit both
+ * buffer headers, headroom and data.
+ */
+ uint32_t max_headroom_size;
+
+ /** Maximum number of segments per packet */
+ uint32_t max_segs_per_pkt;
+
+ /** Maximum user area size in bytes */
+ uint32_t max_uarea_size;
+
+ } pkt;
+
+} odp_pool_ext_capability_t;
+
+/**
+ * External memory pool parameters
+ */
+typedef struct odp_pool_ext_param_t {
+ /** Pool type */
+ odp_pool_type_t type;
+
+ /** Maximum thread local cache size for the pool
+ *
+ * Valid value range is from min_cache_size to max_cache_size capability.
+ * The default value is implementation specific. See odp_pool_param_t (buf.cache_size)
+ * for more detailed documentation.
+ */
+ uint32_t cache_size;
+
+ /**
+ * Pool statistics configuration
+ *
+ * All pool statistics are disabled by default. For optimal performance, enable only those
+ * counters that are actually used. Counters may be read with odp_pool_stats().
+ */
+ odp_pool_stats_opt_t stats;
+
+ /** Parameters for packet pools */
+ struct {
+ /** Number of packet buffers
+ *
+ * The number of packet buffers application will populate into the pool.
+ * The maximum value is defined by pool capability pkt.max_num_buf.
+ */
+ uint32_t num_buf;
+
+ /** Packet buffer size
+ *
+ * Total buffer size in bytes including all headers, trailer, head-/tailroom
+ * and data. This is calculated from buffer start pointer to the end of buffer
+ * data area (including tailroom) or ODP trailer (see odp_trailer_size capability).
+ * All packet buffers application populates into the pool are of this size.
+ */
+ uint32_t buf_size;
+
+ /** Application header size
+ *
+ * Application reserves this many bytes for its own buffer header usage.
+ * The application header follows immediately the ODP buffer header
+ * (see odp_header_size capability). ODP implementation will not modify this
+ * memory area. The default value is 0.
+ */
+ uint32_t app_header_size;
+
+ /** User area size
+ *
+ * Per packet user area size in bytes. As with normal pools, user area location
+ * is ODP implementation specific. Use zero if no user area is needed.
+ * The maximum value is defined by pool capability pkt.max_uarea_size.
+ * The default value is 0.
+ */
+ uint32_t uarea_size;
+
+ /** Minimum headroom size
+ *
+ * Each newly allocated packet from the pool must have at least this much
+ * headroom in bytes. The configuration applies to both ODP packet input and
+ * application allocated packets. Use zero if headroom is not needed. The maximum
+ * value is defined by pool capability pkt.max_headroom. Implementation may
+ * round up the initial headroom size up to pool capability pkt.max_headroom_size.
+ */
+ uint32_t headroom;
+
+ } pkt;
+
+} odp_pool_ext_param_t;
+
+/**
+ * Pool information struct
+ * Used to get information about a pool.
+ */
+typedef struct odp_pool_info_t {
+ /** Pool name */
+ const char *name;
+
+ /** External memory pool
+ *
+ * 0: Pool is a normal pool
+ * 1: Pool is an external memory pool
+ */
+ odp_bool_t pool_ext;
+
+ /** Pool parameters union */
+ union {
+ /** Copy of pool parameters. This is set when pool_ext is 0. */
+ odp_pool_param_t params;
+
+ /** Copy of external memory pool parameters. This is set when pool_ext is 1. */
+ odp_pool_ext_param_t pool_ext_param;
+ };
+
+ /** Additional info for packet pools */
+ struct {
+ /** Maximum number of packets of any length
+ *
+ * This is the maximum number of packets that can be allocated
+ * from the pool at anytime. Application can use this e.g.
+ * to prepare enough per packet contexts.
+ */
+ uint32_t max_num;
+
+ } pkt;
+
+ /** Minimum data address.
+ *
+ * This is the minimum address that application accessible
+ * data of any object (event) allocated from the pool may
+ * locate. When there's no application accessible data
+ * (e.g. ODP_POOL_TIMEOUT pools), the value may be zero.
+ */
+ uintptr_t min_data_addr;
+
+ /** Maximum data address.
+ *
+ * This is the maximum address that application accessible
+ * data of any object (event) allocated from the pool may
+ * locate. When there's no application accessible data
+ * (e.g. ODP_POOL_TIMEOUT pools), the value may be zero.
+ */
+ uintptr_t max_data_addr;
+
+} odp_pool_info_t;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/include/odp/api/spec/proto_stats.h b/include/odp/api/spec/proto_stats.h
new file mode 100644
index 000000000..0957c9e0e
--- /dev/null
+++ b/include/odp/api/spec/proto_stats.h
@@ -0,0 +1,132 @@
+/* Copyright (c) 2021, Marvell
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Proto Stats
+ */
+
+#ifndef ODP_API_SPEC_PROTO_STATS_H_
+#define ODP_API_SPEC_PROTO_STATS_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/proto_stats_types.h>
+
+/** @defgroup odp_proto_stats ODP PROTO STATS
+ * Flow specific packet statistics.
+ * @{
+ */
+
+/**
+ * Initialize proto stats parameters
+ *
+ * Initialize an odp_proto_stats_param_t to its default values.
+ * By default all the statistics are disabled.
+ *
+ * @param param Proto stats parameter pointer.
+ */
+void odp_proto_stats_param_init(odp_proto_stats_param_t *param);
+
+/**
+ * Get proto stats capability
+ *
+ * Get supported protocol statistics and metadata for a PKTIO.
+ *
+ * @param pktio Packet IO handle
+ * @param[out] capa Pointer where capabilities are updated
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_proto_stats_capability(odp_pktio_t pktio, odp_proto_stats_capability_t *capa);
+
+/**
+ * Create a proto stats object
+ *
+ * Create a proto stats object with given name and parameters.
+ * A proto stats object can be created with any set of statistics but only the
+ * statistics that are supported by a PKTIO are updated in a proto stats object
+ * for that PKTIO associated packets. Same proto stats object can be used with
+ * any PKTIO.
+ *
+ * @param name Object name
+ * @param param Proto stats parameters
+ *
+ * @return Proto stats object handle
+ * @retval ODP_PROTO_STATS_INVALID on failure
+ */
+odp_proto_stats_t odp_proto_stats_create(const char *name, const odp_proto_stats_param_t *param);
+
+/**
+ * Lookup a proto stats object by name
+ *
+ * Lookup an already created proto stats object by name.
+ *
+ * @param name Proto stats object name
+ *
+ * @return Proto stats object handle
+ * @retval ODP_PROTO_STATS_INVALID on failure
+ */
+odp_proto_stats_t odp_proto_stats_lookup(const char *name);
+
+/**
+ * Destroy a proto stats object
+ *
+ * Destroy a proto stats object already created.
+ *
+ * Before destroying proto stats object having tx statistics enabled,
+ * for all PKTIO devices to which packets were Tx'ed earlier with
+ * this proto stats object, odp_pktio_stop() must be called. Additionally,
+ * existing packets that refer to the proto stats object being destroyed
+ * must not be sent at the same time as or after the proto stats object
+ * destruction.
+ *
+ * @param stat Proto stats handle
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_proto_stats_destroy(odp_proto_stats_t stat);
+
+/**
+ * Get all proto stats counters
+ *
+ * Get current values of all counters of the proto stats object.
+ * The values of counters that are not enabled in the proto stats object are undefined.
+ *
+ * @param stat Proto stats object handle
+ * @param[out] data Pointer to a caller allocated structure where the statistics will
+ * be written to.
+ *
+ * @retval =0 on success
+ * @retval <0 on failure
+ */
+int odp_proto_stats(odp_proto_stats_t stat, odp_proto_stats_data_t *data);
+
+/**
+ * Print proto stats object info to ODP log.
+ *
+ * Print implementation-defined proto stats debug information to ODP log.
+ *
+ * @param stat Proto stats object handle
+ */
+void odp_proto_stats_print(odp_proto_stats_t stat);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/include/odp/api/spec/proto_stats_types.h b/include/odp/api/spec/proto_stats_types.h
new file mode 100644
index 000000000..ff5f352b9
--- /dev/null
+++ b/include/odp/api/spec/proto_stats_types.h
@@ -0,0 +1,126 @@
+/* Copyright(C) 2021, Marvell
+ * Copyright(C) 2021, Nokia
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP proto stats types
+ */
+
+#ifndef ODP_API_SPEC_PROTO_STATS_TYPES_H_
+#define ODP_API_SPEC_PROTO_STATS_TYPES_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/std_types.h>
+
+/** @addtogroup odp_proto_stats
+ * @{
+ */
+
+/**
+ * @def ODP_PROTO_STATS_INVALID
+ * Invalid proto stats handle
+ */
+
+/** ODP proto stats counters
+ *
+ * Statistics that can be enabled in proto stats object. For Tx stats counters,
+ * Pktout config `odp_pktout_config_opt_t::bit::proto_stats_ena` needs to be
+ * enabled.
+ *
+ * Tx packet and octet sent/drop statistics might include packets sent/dropped via
+ * Traffic Manager or Tx packet Aging or due to any other Tx errors. It is
+ * implementation specific as to what all Tx sent/drop events are accounted for.
+ */
+typedef union odp_proto_stats_counters_t {
+ /** Option flags */
+ struct {
+ /** Tx packet sent count */
+ uint64_t tx_pkts : 1;
+
+ /** Tx packet drop count */
+ uint64_t tx_pkt_drops : 1;
+
+ /** Tx packet sent Octet counter 0 */
+ uint64_t tx_oct_count0 : 1;
+
+ /** Tx packet drop Octet counter 0 */
+ uint64_t tx_oct_count0_drops : 1;
+
+ /** Tx packet sent octet counter 1 */
+ uint64_t tx_oct_count1 : 1;
+
+ /** Tx packet drop octet counter 1 */
+ uint64_t tx_oct_count1_drops : 1;
+ } bit;
+
+ /** All bits of the bit field structure
+ *
+ * This field can be used to set/clear all flags, or bitwise
+ * operations over the entire structure.
+ */
+ uint64_t all_bits;
+} odp_proto_stats_counters_t;
+
+/** ODP proto stats params */
+typedef struct odp_proto_stats_param_t {
+ /** Stats counters to enable */
+ odp_proto_stats_counters_t counters;
+} odp_proto_stats_param_t;
+
+/**
+ * Proto stats capabilities
+ */
+typedef struct odp_proto_stats_capability_t {
+ /** Tx capabilities */
+ struct {
+ /** Stats counters supported */
+ odp_proto_stats_counters_t counters;
+
+ /** Packet adjust support for Octet counter 0 */
+ odp_bool_t oct_count0_adj;
+
+ /** Packet adjust support for Octet counter 1 */
+ odp_bool_t oct_count1_adj;
+ } tx;
+} odp_proto_stats_capability_t;
+
+/** ODP proto stats counters */
+typedef struct odp_proto_stats_data_t {
+ /** Packet sent count */
+ uint64_t tx_pkts;
+
+ /** Packet drop count */
+ uint64_t tx_pkt_drops;
+
+ /** Packet sent Octet counter 0 */
+ uint64_t tx_oct_count0;
+
+ /** Packet drop Octet counter 0 */
+ uint64_t tx_oct_count0_drops;
+
+ /** Packet sent octet counter 1 */
+ uint64_t tx_oct_count1;
+
+ /** Packet drop octet counter 1 */
+ uint64_t tx_oct_count1_drops;
+} odp_proto_stats_data_t;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/include/odp/api/spec/queue.h b/include/odp/api/spec/queue.h
index 005229e35..9c677c926 100644
--- a/include/odp/api/spec/queue.h
+++ b/include/odp/api/spec/queue.h
@@ -19,7 +19,7 @@ extern "C" {
#endif
#include <odp/api/event.h>
-#include <odp/api/spec/queue_types.h>
+#include <odp/api/queue_types.h>
/** @defgroup odp_queue ODP QUEUE
* Queues for event passing and scheduling.
@@ -27,21 +27,6 @@ extern "C" {
*/
/**
- * @typedef odp_queue_t
- * ODP queue
- */
-
-/**
- * @def ODP_QUEUE_INVALID
- * Invalid queue
- */
-
-/**
- * @def ODP_QUEUE_NAME_LEN
- * Maximum queue name length in chars including null char
- */
-
-/**
* Queue create
*
* Create a queue according to the queue parameters. Queue type is specified by
diff --git a/include/odp/api/spec/queue_types.h b/include/odp/api/spec/queue_types.h
index a6899c31c..cff47ee60 100644
--- a/include/odp/api/spec/queue_types.h
+++ b/include/odp/api/spec/queue_types.h
@@ -26,6 +26,21 @@ extern "C" {
*/
/**
+ * @typedef odp_queue_t
+ * ODP queue
+ */
+
+/**
+ * @def ODP_QUEUE_INVALID
+ * Invalid queue
+ */
+
+/**
+ * @def ODP_QUEUE_NAME_LEN
+ * Maximum queue name length in chars including null char
+ */
+
+/**
* Queue type
*/
typedef enum odp_queue_type_t {
diff --git a/include/odp/api/spec/schedule.h b/include/odp/api/spec/schedule.h
index e07c92b7e..12da88f7d 100644
--- a/include/odp/api/spec/schedule.h
+++ b/include/odp/api/spec/schedule.h
@@ -20,7 +20,7 @@ extern "C" {
#include <odp/api/std_types.h>
#include <odp/api/event.h>
-#include <odp/api/queue.h>
+#include <odp/api/queue_types.h>
#include <odp/api/schedule_types.h>
#include <odp/api/thrmask.h>
diff --git a/include/odp/api/spec/std_clib.h b/include/odp/api/spec/std.h
index fd65e7f5e..0341f734e 100644
--- a/include/odp/api/spec/std_clib.h
+++ b/include/odp/api/spec/std.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2015-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -7,23 +8,24 @@
/**
* @file
*
- * ODP version of often used C library calls
+ * ODP standard types and optimized C library functions
*/
-#ifndef ODP_API_SPEC_STD_CLIB_H_
-#define ODP_API_SPEC_STD_CLIB_H_
+#ifndef ODP_API_SPEC_STD_H_
+#define ODP_API_SPEC_STD_H_
#include <odp/visibility_begin.h>
#ifdef __cplusplus
extern "C" {
#endif
+#include <odp/api/std_types.h>
+
/**
- * @defgroup odp_std_clib ODP STD CLIB
- * Performance optimized versions of selected C library functions.
+ * @defgroup odp_std ODP STD
+ * Standard types and performance optimized versions of selected C library
+ * functions.
*
- * @details
- * ODP version of often used C library calls
* @{
*/
@@ -75,6 +77,18 @@ void *odp_memset(void *ptr, int value, size_t num);
int odp_memcmp(const void *ptr1, const void *ptr2, size_t num);
/**
+ * Convert fractional number (u64) to double
+ *
+ * Converts value of the unsigned 64 bit fractional number to a double-precision
+ * floating-point value.
+ *
+ * @param fract Pointer to a fractional number
+ *
+ * @return Value of the fractional number as double
+ */
+double odp_fract_u64_to_dbl(const odp_fract_u64_t *fract);
+
+/**
* @}
*/
diff --git a/include/odp/api/spec/std_types.h b/include/odp/api/spec/std_types.h
index 4b2af87ef..5dc350a24 100644
--- a/include/odp/api/spec/std_types.h
+++ b/include/odp/api/spec/std_types.h
@@ -24,7 +24,7 @@
extern "C" {
#endif
-/** @addtogroup odp_system ODP SYSTEM
+/** @addtogroup odp_std ODP STD
* @{
*/
@@ -96,18 +96,6 @@ typedef struct odp_fract_u64_t {
} odp_fract_u64_t;
/**
- * Convert fractional number (u64) to double
- *
- * Converts value of the unsigned 64 bit fractional number to a double-precision
- * floating-point value.
- *
- * @param fract Pointer to a fractional number
- *
- * @return Value of the fractional number as double
- */
-double odp_fract_u64_to_dbl(const odp_fract_u64_t *fract);
-
-/**
* @}
*/
diff --git a/include/odp/api/spec/traffic_mngr.h b/include/odp/api/spec/traffic_mngr.h
index 699d0bb26..57c11c486 100644
--- a/include/odp/api/spec/traffic_mngr.h
+++ b/include/odp/api/spec/traffic_mngr.h
@@ -1,4 +1,5 @@
-/** Copyright (c) 2015-2018, Linaro Limited
+/* Copyright (c) 2015-2018, Linaro Limited
+ * Copyright (c) 2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -37,7 +38,7 @@ extern "C" {
* based systems or one or more hybrid systems - where because of
* hardware constraints some of the packet scheduling is done in hardware
* and some is done in software. In addition, there may also be additional
- * API's beyond those described here for (a) controlling advanced capabilities
+ * APIs beyond those described here for (a) controlling advanced capabilities
* supported by specific hardware, software or hybrid subsystems or (b)
* dealing with constraints and limitations of specific implementations.
*/
@@ -189,6 +190,63 @@ extern "C" {
* tree/hierarchy of nodes.
*/
+/**
+ * TM queue specific statistics counters
+ */
+typedef struct odp_tm_queue_stats_t {
+ /** Number of octets in successfully transmitted packets. In case of
+ * Ethernet, packet size includes MAC header. */
+ uint64_t octets;
+
+ /** Number of successfully transmitted packets. */
+ uint64_t packets;
+
+ /** Number of packets discarded due to other reasons (e.g. aging) than
+ * errors. */
+ uint64_t discards;
+
+ /** Number of octets in packets discarded due to other reasons (e.g.
+ * aging) than errors. */
+ uint64_t discard_octets;
+
+ /** Number of packets with transmission errors. */
+ uint64_t errors;
+
+} odp_tm_queue_stats_t;
+
+/**
+ * TM queue level statistics capabilities
+ */
+typedef struct odp_tm_queue_stats_capability_t {
+ /** Supported counters */
+ union {
+ /** Statistics counters in a bit field structure */
+ struct {
+ /** @see odp_tm_queue_stats_t::octets */
+ uint64_t octets : 1;
+
+ /** @see odp_tm_queue_stats_t::packets */
+ uint64_t packets : 1;
+
+ /** @see odp_tm_queue_stats_t::discards */
+ uint64_t discards : 1;
+
+ /** @see odp_tm_queue_stats_t::discard_octets */
+ uint64_t discard_octets : 1;
+
+ /** @see odp_tm_queue_stats_t::errors */
+ uint64_t errors : 1;
+
+ } counter;
+
+ /** 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_counters;
+ };
+} odp_tm_queue_stats_capability_t;
+
/** Per Level Capabilities
*
* The odp_tm_level_capabilities_t record is used to describe the capabilities
@@ -213,12 +271,12 @@ typedef struct {
/** min_weight only has significance when the weights_supported field
* below is true, in which case it specifies the smallest value
* of the weights allowed at this level. */
- uint8_t min_weight;
+ uint32_t min_weight;
/** max_weight only has significance when the weights_supported field
* below is true, in which case it specifies the largest value
* of the weights allowed at this level. */
- uint8_t max_weight;
+ uint32_t max_weight;
/** tm_node_shaper_supported indicates that the tm_nodes at this level
* all support TM shaping, */
@@ -248,8 +306,39 @@ typedef struct {
* When true the min_weight and max_weight fields above specify
* the legal range of such weights. */
odp_bool_t weights_supported;
+
+ /** tm_node_threshold indicates that the tm_nodes at this
+ * level support threshold profiles. */
+ odp_bool_t tm_node_threshold;
} odp_tm_level_capabilities_t;
+/** The tm_pkt_prio_mode_t enumeration type is used to indicate different
+ * modes a tm system supports with respect to assigning priority to a packet
+ * and propagating it across TM system. All the nodes in a TM system can
+ * function only on single mode specified at time of odp_tm_create().
+ */
+typedef enum odp_tm_pkt_prio_mode {
+ /** Indicates Packet priority preserve mode. In this mode, a packet gets
+ * its priority based on a TM queue it gets enqueued to and then it
+ * carries the same priority along with it as long as it is in the TM
+ * system. At every TM node in the topology, that specific pkt is
+ * scheduled as per that priority.
+ */
+ ODP_TM_PKT_PRIO_MODE_PRESERVE,
+
+ /** Indicates Packet priority overwrite mode. In this mode, a packet
+ * gets a new priority every time it passes through a TM queue or a
+ * TM node. All the packets fed by a fan-in node will get the same
+ * priority and that will be valid until overwritten again by another TM
+ * node. This priority is part of the TM fan-in node parameters and is
+ * fixed at node creation time.
+ */
+ ODP_TM_PKT_PRIO_MODE_OVERWRITE,
+
+ /** Max enum of Packet priority mode */
+ ODP_TM_PKT_PRIO_MODE_MAX,
+} odp_tm_pkt_prio_mode_t;
+
/** TM Capabilities Record.
*
* The odp_tm_capabilities_t record type is used to describe the feature set
@@ -283,7 +372,7 @@ typedef struct {
* proper TM shaping. Note that TM Shaping is NOT the same thing as
* Ingress Metering/Policing as specified by RFC 2697 (A Single Rate
* Three Color Marker) or RFC 2698 (A Two Rate Three Color Marker).
- * These RFC's can be used for a Diffserv traffic conditioner, or
+ * These RFCs can be used for a Diffserv traffic conditioner, or
* other ingress policing. They make no mention of and have no
* algorithms for delaying packets - which is what TM shapers are
* expected to do. */
@@ -385,6 +474,44 @@ typedef struct {
* the parameters of the threshold profile of any TM node or TM queue.
*/
odp_bool_t dynamic_threshold_update;
+
+ /** TM queue statistics counter capabilities */
+ odp_tm_queue_stats_capability_t queue_stats;
+
+ /** tm_queue_threshold indicates support for threshold profile on a
+ * TM queue. When TRUE, users can set/clear/update threshold profile
+ * on a TM queue. When false none of it is supported.
+ */
+ odp_bool_t tm_queue_threshold;
+
+ /** tm_queue_query_flags indicates supported types of TM queue query.
+ * Types of TM queue query are same as query_flags that are passed to
+ * odp_tm_queue_query(), odp_tm_priority_query() and
+ * odp_tm_total_query(). When zero, none of the queue query API's are
+ * supported. When non-zero, only the only supported types of passed
+ * query_flags are taken into account and corresponding fields updated.
+ *
+ * @see ODP_TM_QUERY_PKT_CNT, ODP_TM_QUERY_BYTE_CNT,
+ * ODP_TM_QUERY_THRESHOLDS.
+ */
+ uint32_t tm_queue_query_flags;
+
+ /** Indicates the packet priority modes supported by TM systems on a
+ * platform. A platform can support multiple packet priority modes. The
+ * actual mode a TM system runs with is defined by
+ * odp_tm_requirements_t.
+ */
+ odp_bool_t pkt_prio_modes[ODP_TM_PKT_PRIO_MODE_MAX];
+
+ /** Maximum number of schedulers supported by a TM node at any level.
+ * A TM node contains a WFQ/WRR scheduler for each packet priority level
+ * for which the node has more than one possible input. TM topology and
+ * priority configuration must be made so that the resulting number of
+ * WFQ/WRR schedulers does not exceed this capability in any TM node.
+ *
+ * The value can vary between 0 and ODP_TM_MAX_PRIORITIES.
+ */
+ uint8_t max_schedulers_per_node;
} odp_tm_capabilities_t;
/** Per Level Requirements
@@ -411,12 +538,12 @@ typedef struct {
/** min_weight only has significance when the weights_supported field
* below is true, in which case it specifies the smallest value
* of the weights that will be used at this level. */
- uint8_t min_weight;
+ uint32_t min_weight;
/** max_weight only has significance when the weights_supported field
* below is true, in which case it specifies the largest value
* of the weights that will be used at this level. */
- uint8_t max_weight;
+ uint32_t max_weight;
/** tm_node_shaper_needed indicates that the tm_nodes at this level
* are expected to do TM shaping, */
@@ -437,11 +564,15 @@ typedef struct {
* disciplines. */
odp_bool_t fair_queuing_needed;
- /** weights_needd indicates that the tm_node schedulers at this
+ /** weights_needed indicates that the tm_node schedulers at this
* level are expected have different weights for their different
* fanins. When true the min_weight and max_weight fields above
* specify the used range of such weights. */
odp_bool_t weights_needed;
+
+ /** tm_node_threshold_needed indicates that the tm_nodes at this
+ * level may use threshold profile support */
+ odp_bool_t tm_node_threshold_needed;
} odp_tm_level_requirements_t;
/** TM Requirements Record.
@@ -471,6 +602,10 @@ typedef struct {
* ignored if tm_queue_wred_needed above is false. */
odp_bool_t tm_queue_dual_slope_needed;
+ /** tm_queue_threshold_needed indicates that the tm_queues are
+ * expected to use threshold profile support */
+ odp_bool_t tm_queue_threshold_needed;
+
/** vlan_marking_needed indicates that the ODP application expects
* to use some form of VLAN egress marking using the
* odp_tm_vlan_marking() function. See also comments for
@@ -494,9 +629,15 @@ typedef struct {
* the application will not enable this color for vlan marking,
* ecn marking nor drop precedence marking. A value of TRUE means that
* the application expects to use this color in conjunction with one or
- * more of the marking API's. */
+ * more of the marking APIs. */
odp_bool_t marking_colors_needed[ODP_NUM_PACKET_COLORS];
+ /** Packet priority mode.
+ * TM capabilities indicate which modes are supported.
+ * The default value is ODP_TM_PKT_PRIO_MODE_PRESERVE.
+ */
+ odp_tm_pkt_prio_mode_t pkt_prio_mode;
+
/** The per_level array specifies the TM system requirements that
* can vary based upon the tm_node level. */
odp_tm_level_requirements_t per_level[ODP_TM_MAX_LEVELS];
@@ -556,19 +697,23 @@ void odp_tm_egress_init(odp_tm_egress_t *egress);
/** Query All TM Capabilities
*
- * The odp_tm_capabilities() function can be used to obtain the complete set of
- * TM limits supported by this implementation. The reason that this returns
- * a SET of capabilities and not just one, is because it is expected that
- * many HW based implementations may have one set of limits for the HW and
- * also support a SW TM implementation with a (presumably larger) different
- * set of limits. There are also cases where there could be more than
- * SW implementation (one supporting say tens of thousands of tm_queues and
- * a variant supporting tens of millions of tm_queues).
+ * @deprecated Use odp_tm_egress_capabilities() instead that also additionally
+ * takes egress as input to provide capabilities specific to a given egress.
+ *
+ * This function returns the set of TM capabilities that are common for all
+ * egresses. The reason that this returns a SET of capabilities and not just
+ * one, is because it is expected that many HW based implementations may have
+ * one set of limits for the HW and also support a SW TM implementation with a
+ * (presumably larger) different set of limits. There are also cases where
+ * there could be more than one SW implementation (one supporting say tens of
+ * thousands of tm_queues and a variant supporting tens of millions of
+ * tm_queues). It returns capabilities that are valid for all egresses.
* The caller passes in an array of odp_tm_capabilities_t records and the
- * number of such records. Then the first N of these records will be filled
- * in by the implementation and the number N will be returned. In the event
- * that N is larger than the capabilities_size, N will still be returned,
- * but only capabilities_size records will be filled in.
+ * maximum number of such records to output. If number of such records
+ * implementation supports is larger than caller requested number, then
+ * only caller requested number of records are written and return value is
+ * max number of records implementation supports.
+ * Caller then may again call with larger number of records to be returned.
*
* @param[out] capabilities An array of odp_tm_capabilities_t records to
* be filled in.
@@ -580,8 +725,32 @@ void odp_tm_egress_init(odp_tm_egress_t *egress);
* implementations supports. *NOTE* that this
* number can be > capabilities_size!
*/
-int odp_tm_capabilities(odp_tm_capabilities_t capabilities[],
- uint32_t capabilities_size);
+int ODP_DEPRECATE(odp_tm_capabilities)(odp_tm_capabilities_t capabilities[],
+ uint32_t capabilities_size);
+
+/** Query TM Capabilities specific to an egress
+ *
+ * The function returns the set of TM limits supported by this implementation
+ * for a given egress. Unlike odp_tm_capability() which return's capabilities
+ * of already created TM system which are limited by its requirements, this
+ * function returns maximum TM system limits.
+ *
+ * Lack of TM support in the given egress does not cause this
+ * function to return a failure. Lack of TM support is indicated
+ * by zero max_tm_queues capability.
+ *
+ * If the pktio of an egress of the pktio kind has not been opened
+ * in the ODP_PKTOUT_MODE_TM pktout mode, the capabilities will
+ * indicate that TM is not supported.
+ *
+ * @param[out] capabilities odp_tm_capabilities_t record to be filled in.
+ * @param egress Only capabilities compatible with this egress
+ * are returned.
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_tm_egress_capabilities(odp_tm_capabilities_t *capabilities,
+ const odp_tm_egress_t *egress);
/** Create/instantiate a TM Packet Scheduling system.
*
@@ -645,8 +814,7 @@ odp_tm_t odp_tm_find(const char *name,
* In addition, ODP TM implementations should fail API requests that "exceed"
* the limits or features contracted for in the requirements.
*
- * @param odp_tm The odp_tm_t value of the TM system to be
- * queried.
+ * @param tm TM handle
* @param[out] capabilities A pointer to an odp_tm_capabilities_t record
* where the actual limits used by the TM system are
* copied into. Note that these limits do NOT
@@ -654,10 +822,11 @@ odp_tm_t odp_tm_find(const char *name,
* a TM system was created by odp_tm_create,
* but of course these limits in some cases could
* be larger.
+ *
* @return Returns 0 upon success, < 0 upon failure (which
* indicates that the odp_tm value did not exist).
*/
-int odp_tm_capability(odp_tm_t odp_tm, odp_tm_capabilities_t *capabilities);
+int odp_tm_capability(odp_tm_t tm, odp_tm_capabilities_t *capabilities);
/**
* Start a TM system
@@ -665,7 +834,7 @@ int odp_tm_capability(odp_tm_t odp_tm, odp_tm_capabilities_t *capabilities);
* odp_tm_start() needs to be used to start an already created or found TM
* system. By default, all the TM systems are in stopped state.
*
- * @param tm TM system to be started
+ * @param tm TM handle
*
* @retval 0 on success
* @retval <0 on failure
@@ -688,7 +857,7 @@ int odp_tm_start(odp_tm_t tm);
* A following call to odp_tm_start() restarts TM system and its scheduling/shaping
* on existing and new packets.
*
- * @param tm TM system to be stopped
+ * @param tm TM handle
*
* @retval 0 on success
* @retval <0 on failure
@@ -715,11 +884,11 @@ int odp_tm_stop(odp_tm_t tm);
* TM system, other than EVENTUALLY these packets will be either sent (in ANY
* order) or freed.
*
- * @param odp_tm The odp_tm_t value of the TM system to be destroyed (and
- * hence destroyed (and hence freed).
+ * @param tm The handle of the TM system to be destroyed (and hence freed).
+ *
* @return 0 upon success, < 0 upon failure.
*/
-int odp_tm_destroy(odp_tm_t odp_tm);
+int odp_tm_destroy(odp_tm_t tm);
/** Marking APIs */
@@ -736,15 +905,16 @@ int odp_tm_destroy(odp_tm_t odp_tm);
* calls to this function with drop_eligible_enabled == FALSE - i.e. must
* always return 0 when disabling this feature.
*
- * @param odp_tm Odp_tm is used to identify the TM system
- * whose egress behavior is being changed.
+ * @param tm Handle of the TM system whose egress behavior
+ * is being changed.
* @param color The packet color whose egress marking is
* being changed.
* @param drop_eligible_enabled If true then will set the DEI bit for
* egressed VLAN tagged pkts with this color.
+ *
* @return 0 upon success, < 0 upon failure.
*/
-int odp_tm_vlan_marking(odp_tm_t odp_tm,
+int odp_tm_vlan_marking(odp_tm_t tm,
odp_packet_color_t color,
odp_bool_t drop_eligible_enabled);
@@ -765,8 +935,8 @@ int odp_tm_vlan_marking(odp_tm_t odp_tm,
* calls to this function with ecn_ce_enabled == FALSE - i.e. must always
* return 0 when disabling this feature.
*
- * @param odp_tm Odp_tm is used to identify the TM system whose
- * egress behavior is being changed.
+ * @param tm Handle of the TM system whose egress behavior is being
+ * changed.
* @param color The packet color whose egress marking is
* being changed.
* @param ecn_ce_enabled If true then egressed IPv4/IPv6 pkts whose
@@ -774,9 +944,10 @@ int odp_tm_vlan_marking(odp_tm_t odp_tm,
* either one of the two values 1 or 2, will set this
* subfield to the value ECN_CE - i.e. Congestion
* Experienced (whose value is 3).
+ *
* @return 0 upon success, < 0 upon failure.
*/
-int odp_tm_ecn_marking(odp_tm_t odp_tm,
+int odp_tm_ecn_marking(odp_tm_t tm,
odp_packet_color_t color,
odp_bool_t ecn_ce_enabled);
@@ -805,17 +976,18 @@ int odp_tm_ecn_marking(odp_tm_t odp_tm,
* calls to this function with drop_prec_enabled == FALSE - i.e. must always
* return 0 when disabling this feature.
*
- * @param odp_tm Odp_tm is used to identify the TM system whose
- * egress behavior is being changed.
+ * @param tm Handle of the TM system whose egress behavior is
+ * being changed.
* @param color The packet color whose egress marking is
* being changed.
* @param drop_prec_enabled If true then egressed IPv4/IPv6 pkts with this
* color will have the pkt's Drop Precedence
* sub-subfield of the DSCP subfield set to
* LOW, MEDIUM or HIGH drop precedence.
+ *
* @return 0 upon success, < 0 upon failure.
*/
-int odp_tm_drop_prec_marking(odp_tm_t odp_tm,
+int odp_tm_drop_prec_marking(odp_tm_t tm,
odp_packet_color_t color,
odp_bool_t drop_prec_enabled);
@@ -1004,11 +1176,11 @@ typedef struct {
/** In the case that sched_modes for a given strict priority level
* indicates the use of weighted scheduling, this field supplies the
* weighting factors. The weights - when defined - are used such that
- * the (adjusted) frame lengths are divided by these 8-bit weights
+ * the (adjusted) frame lengths are divided by these weights
* (i.e. they are divisors and not multipliers). Consequently a
* weight of 0 (when sched_mode is ODP_TM_BYTE_BASED_WEIGHTS) is
* illegal. */
- uint8_t sched_weights[ODP_TM_MAX_PRIORITIES];
+ uint32_t sched_weights[ODP_TM_MAX_PRIORITIES];
} odp_tm_sched_params_t;
/** odp_tm_sched_params_init() must be called to initialize any
@@ -1351,6 +1523,22 @@ typedef struct {
* greater levels may be connected to the fan-in of tm_node's with
* numerically smaller levels. */
uint8_t level;
+
+ /** New strict priority level assigned to packets going through this
+ * node when packet priority mode is ODP_TM_PKT_PRIO_MODE_OVERWRITE.
+ * In other packet priority modes this field is ignored. The new
+ * priority does not affect packet processing in this node but in
+ * its destination node.
+ *
+ * The value must be in the range 0..ODP_TM_MAX_PRIORITIES-1.
+ * Additionally, the total number of possible priorities seen by
+ * the destination node must not exceed the max priority configured
+ * for the destination node.
+ *
+ * @see odp_tm_pkt_prio_mode_t
+ * @see odp_tm_level_requirements_t::max_priority
+ */
+ uint8_t priority;
} odp_tm_node_params_t;
/** odp_tm_node_params_init() must be called to initialize any
@@ -1368,17 +1556,18 @@ void odp_tm_node_params_init(odp_tm_node_params_t *params);
* strict priority levels for an tm_node cannot be changed after tm_node
* creation. The level parameter MUST be in the range 0..max_level - 1.
*
- * @param odp_tm Odp_tm is used to identify the TM system into which this
- * odp_tm_node object is created.
+ * @param tm Handle of the TM system into which this odp_tm_node object is
+ * created.
* @param name Optional name that can be used later later to find this
* same odp_tm_node_t. Can be NULL, otherwise must be
* unique across all odp_tm_node objects.
* @param params A pointer to a record holding (an extensible) set of
* properties/attributes of this tm_node.
+ *
* @return Returns ODP_TM_INVALID upon failure, otherwise returns
* a valid odp_tm_node_t handle if successful.
*/
-odp_tm_node_t odp_tm_node_create(odp_tm_t odp_tm, const char *name,
+odp_tm_node_t odp_tm_node_create(odp_tm_t tm, const char *name,
const odp_tm_node_params_t *params);
/** Destroy a tm_node object.
@@ -1455,14 +1644,13 @@ int odp_tm_node_wred_config(odp_tm_node_t tm_node,
/** odp_tm_node_lookup() can be used to find the tm_node object created with
* the specified name.
*
- * @param odp_tm Odp_tm is used to identify the TM system into which this
- * odp_tm_node object is created.
+ * @param tm TM handle
* @param name Name of a previously created tm_node. Cannot be NULL.
*
* @return Returns ODP_TM_INVALID upon failure, or the tm_node
* handle created with this name.
*/
-odp_tm_node_t odp_tm_node_lookup(odp_tm_t odp_tm, const char *name);
+odp_tm_node_t odp_tm_node_lookup(odp_tm_t tm, const char *name);
/** odp_tm_node_context() can be used to get the user_context value that is
* associated with the given tm_node.
@@ -1518,6 +1706,12 @@ typedef struct {
* have the same single strict priority level and this level must be
* in the range 0..max_priority. */
uint8_t priority;
+
+ /** Maintain original packet order of the source queue when enqueuing
+ * packets to this queue while holding ordered or atomic queue
+ * synchronization context. Default value of this flag is true.
+ */
+ odp_bool_t ordered_enqueue;
} odp_tm_queue_params_t;
/** odp_tm_queue_params_init() must be called to initialize any
@@ -1536,14 +1730,15 @@ void odp_tm_queue_params_init(odp_tm_queue_params_t *params);
* number of buffers and instead limit the queue memory usage by buffer counts
* versus strictly using byte counts.
*
- * @param odp_tm Odp_tm is used to identify the TM system into which this
- * odp_tm_queue object is created.
+ * @param tm Handle of the TM system into which this odp_tm_queue object is
+ * created.
* @param params A pointer to a record holding (an extensible) set of
* properties/attributes of this tm_queue.
+ *
* @return Returns ODP_TM_INVALID upon failure, otherwise a valid
* odp_tm_queue_t handle.
*/
-odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm,
+odp_tm_queue_t odp_tm_queue_create(odp_tm_t tm,
const odp_tm_queue_params_t *params);
/** Destroy an tm_queue object. The odp_tm_queue_destroy frees the resources
@@ -1561,7 +1756,7 @@ int odp_tm_queue_destroy(odp_tm_queue_t tm_queue);
* @param tm_queue Specifies the tm_queue whose user_context is to be
* returned.
* @return Returns the user_context pointer associated with this
- * tm_queue. Returns NULL if the tm_quue is not valid OR
+ * tm_queue. Returns NULL if the tm_queue is not valid OR
* if the user_context was NULL.
*/
void *odp_tm_queue_context(odp_tm_queue_t tm_queue);
@@ -1719,6 +1914,22 @@ int odp_tm_queue_disconnect(odp_tm_queue_t tm_queue);
*/
int odp_tm_enq(odp_tm_queue_t tm_queue, odp_packet_t pkt);
+/** The odp_tm_enq_multi() function is used to add packets to a given TM system.
+ * This function enqueues multiple packets but is otherwise similar to
+ * odp_tm_enq(). Packets dropped by WRED or other queue management action do not
+ * cause this function to return a failure. Such packets get consumed just like
+ * the packets that are not dropped.
+ *
+ * @param tm_queue Specifies the tm_queue (and indirectly the TM system).
+ * @param packets Array of packets to enqueue.
+ * @param num Number of packets to send.
+ *
+ * @retval >0 on success indicating number of packets consumed
+ * @retval <=0 on failure.
+ */
+int odp_tm_enq_multi(odp_tm_queue_t tm_queue, const odp_packet_t packets[],
+ int num);
+
/** The odp_tm_enq_with_cnt() function behaves identically to odp_tm_enq(),
* except that it also returns (an approximation to?) the current tm_queue
* packet queue count.
@@ -1862,7 +2073,7 @@ typedef struct {
odp_tm_wred_t wred_profile[ODP_NUM_PACKET_COLORS];
/** The next_tm_node is the "next" node in the tree - i.e. the fanout
- * of this tm_queu. Can be ODP_TM_ROOT if this tm_queue directly
+ * of this tm_queue. Can be ODP_TM_ROOT if this tm_queue directly
* connects to the egress spigot and can be ODP_TM_INVALID if this
* tm_queue is disconnected from the TM system tree. */
odp_tm_node_t next_tm_node;
@@ -1956,12 +2167,10 @@ typedef struct {
} odp_tm_query_info_t;
/** The odp_tm_queue_query() function can be used to check a single tm_queue's
- * queue utilization. The query_flags indicate whether or not packet counts,
- * byte counts or both are being requested. It is an error to request
- * neither. The implementation may still return both sets of counts
- * regardless of query_flags if the cost of returning all the counts is
- * comparable to the cost of checking the query_flags. The info structure is
- * written only on success.
+ * queue utilization. The query flags indicate which information is being
+ * requested.
+ * The implementation may choose to return additional information that was not
+ * requested. The info structure is written only on success.
*
* @param tm_queue Specifies the tm_queue (and indirectly the
* TM system).
@@ -1976,12 +2185,10 @@ int odp_tm_queue_query(odp_tm_queue_t tm_queue,
odp_tm_query_info_t *info);
/** The odp_tm_priority_query() function can be used to check the queue
- * utilization of all tm_queue's with the given priority. The query_flags
- * indicate whether or not packet counts, byte counts or both are being
- * requested. It is an error to request neither. The implementation may
- * still return both sets of counts regardless of query_flags if the cost of
- * returning all the counts is comparable to the cost of checking the
- * query_flags. The info structure is written only on success.
+ * utilization of all tm_queue's with the given priority. The query flags
+ * indicate which information is being requested. The implementation may
+ * choose to return additional information that was not requested.
+ * The info structure is written only on success.
*
* @param odp_tm Specifies the TM system.
* @param priority Supplies the strict priority level used to specify
@@ -1999,11 +2206,9 @@ int odp_tm_priority_query(odp_tm_t odp_tm,
/** The odp_tm_total_query() function can be used to check the queue
* utilization of all tm_queue's in a single TM system. The query_flags
- * indicate whether or not packet counts, byte counts or both are being
- * requested. It is an error to request neither. The implementation may
- * still return both sets of counts regardless of query_flags if the cost of
- * returning all the counts is comparable to the cost of checking the
- * query_flags. The info structure is written only on success.
+ * indicate which information is being requested. The implementation may
+ * choose to return additional information that was not requested.
+ * The info structure is written only on success.
*
* @param odp_tm Specifies the TM system.
* @param query_flags A set of flag bits indicating which counters are
@@ -2041,13 +2246,14 @@ int odp_tm_priority_threshold_config(odp_tm_t odp_tm,
* other than returning these queue threshold values in the
* odp_tm_query_info_t record.
*
- * @param odp_tm Specifies the TM system.
+ * @param tm TM handle
* @param thresholds_profile Specifies the queue threshold profile that
* should now be used for the entire TM
* system.
+ *
* @return Returns 0 upon success and < 0 upon failure.
*/
-int odp_tm_total_threshold_config(odp_tm_t odp_tm,
+int odp_tm_total_threshold_config(odp_tm_t tm,
odp_tm_threshold_t thresholds_profile);
/** The odp_tm_is_idle function is used to determine if the specified ODP
@@ -2059,23 +2265,41 @@ int odp_tm_total_threshold_config(odp_tm_t odp_tm,
* since for some implementations this call could take a fairly long time
* to execute!
*
- * @param odp_tm Specifies the TM system.
+ * @param tm TM handle
+ *
* @return Returns 1 if the TM system is idle and 0 otherwise.
*/
-odp_bool_t odp_tm_is_idle(odp_tm_t odp_tm);
+odp_bool_t odp_tm_is_idle(odp_tm_t tm);
/** The odp_tm_stats_print function is used to write implementation-defined
* information about the specified TM system to the ODP log. The intended use
* is for debugging.
*
- * @param odp_tm Specifies the TM system.
+ * @param tm TM handle
*/
-void odp_tm_stats_print(odp_tm_t odp_tm);
+void odp_tm_stats_print(odp_tm_t tm);
+
+/**
+ * Get statistics for a TM queue
+ *
+ * Counters not supported by the queue are set to zero.
+ *
+ * It's implementation defined if odp_pktio_stats_reset() call affects these
+ * counters.
+ *
+ * @param tm_queue TM queue handle
+ * @param[out] stats Statistics structure for output
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_tm_queue_stats(odp_tm_queue_t tm_queue, odp_tm_queue_stats_t *stats);
/**
* Get printable value for an odp_tm_t
*
- * @param hdl odp_tm_t handle to be printed
+ * @param tm TM handle
+ *
* @return uint64_t value that can be used to print/display this
* handle
*
@@ -2083,7 +2307,7 @@ void odp_tm_stats_print(odp_tm_t odp_tm);
* to enable applications to generate a printable value that represents
* an odp_tm_t handle.
*/
-uint64_t odp_tm_to_u64(odp_tm_t hdl);
+uint64_t odp_tm_to_u64(odp_tm_t tm);
/**
* Get printable value for an odp_tm_queue_t
diff --git a/include/odp/api/std_clib.h b/include/odp/api/std.h
index 43ba7506e..6af95b55a 100644
--- a/include/odp/api/std_clib.h
+++ b/include/odp/api/std.h
@@ -4,17 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef ODP_API_STD_CLIB_H_
-#define ODP_API_STD_CLIB_H_
+#ifndef ODP_API_STD_H_
+#define ODP_API_STD_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <odp/api/abi/std_types.h>
-#include <odp/api/abi/std_clib.h>
+#include <odp/api/abi/std.h>
-#include <odp/api/spec/std_clib.h>
+#include <odp/api/spec/std.h>
#ifdef __cplusplus
}
diff --git a/include/odp/api/timer.h b/include/odp/api/timer.h
index 12d3f999e..7c0dd95b6 100644
--- a/include/odp/api/timer.h
+++ b/include/odp/api/timer.h
@@ -20,7 +20,7 @@ extern "C" {
#include <odp/api/std_types.h>
#include <odp/api/abi/event.h>
#include <odp/api/abi/pool.h>
-#include <odp/api/abi/queue.h>
+#include <odp/api/abi/queue_types.h>
#include <odp/api/abi/timer.h>
#include <odp/api/spec/timer.h>