Added packet pool parameters for more fine grained pool configuration. The basic usage of the parameters is not changed, except that implementation may now round up 'num' by default. Application can limit the round up with new 'max_num' parameter. Another new parameter (prio) allows application to prioritize some pools (or parts of pools) over others. Implementation may use this information to decide e.g. on HW resource usage.
Additionally, pool configuration may be extended with a table of num/len/prio values. This gives application more flexibility to specify requirements for various packet sizes. Signed-off-by: Petri Savolainen <[email protected]> --- include/odp/api/spec/pool.h | 117 +++++++++++++++++++-- include/odp/arch/default/api/abi/pool.h | 2 + .../include/odp/api/plat/pool_types.h | 2 + 3 files changed, 110 insertions(+), 11 deletions(-) diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h index 6fc5b6b4..2bf37e5d 100644 --- a/include/odp/api/spec/pool.h +++ b/include/odp/api/spec/pool.h @@ -41,6 +41,9 @@ extern "C" { * Maximum pool name length in chars including null char */ +/** Maximum number of additional packet pool parameters */ +#define ODP_POOL_PKT_ADD_MAX 7 + /** * Pool capabilities */ @@ -127,6 +130,9 @@ typedef struct odp_pool_capability_t { * The value of zero means that limited only by the available * memory size for the pool. */ uint32_t max_uarea_size; + + /** Number of priority levels */ + uint8_t num_prio; } pkt; /** Timeout pool capabilities */ @@ -156,6 +162,28 @@ typedef struct odp_pool_capability_t { int odp_pool_capability(odp_pool_capability_t *capa); /** + * @def ODP_POOL_PRIO_DEFAULT + * + * Default pool priority. User does not care about the selected priority + * level. + */ + +/** + * Additional parameters for packet pool creation + */ +typedef struct odp_pool_param_pkt_add_t { + /** Number of packets */ + uint32_t num; + + /** Packet length in bytes */ + uint32_t len; + + /** Priority level */ + uint8_t prio; + +} odp_pool_param_pkt_add_t; + +/** * Pool parameters * Used to communicate pool creation options. * @note A single thread may not be able to allocate all 'num' elements @@ -185,25 +213,56 @@ typedef struct odp_pool_param_t { /** Parameters for packet pools */ struct { - /** The number of packets that the pool must provide - that are packet length 'len' bytes or smaller. - The maximum value is defined by pool capability - pkt.max_num. */ + /** The minimum number of packets that are packet length + * 'len' bytes or smaller. The maximum value is defined + * by pool capability pkt.max_num. An implementation + * may round up the value, as long as the 'max_num' + * parameter below is not violated. + */ uint32_t num; - /** Minimum packet length that the pool must provide - 'num' packets. The number of packets may be less - than 'num' when packets are larger than 'len'. - The maximum value is defined by pool capability - pkt.max_len. Use 0 for default. */ + /** The minimum packet length that at least 'num' + * packets are required. The maximum value is defined + * by pool capability pkt.max_len. Use 0 for default. + */ uint32_t len; + /** Priority level + * + * Priority indicates the relative service level + * between pools and packet length configuration + * within a pool. The highest priority level is zero. + * Number of priorities is defined by pool capability + * pkt.num_prio. Thus the lowest priority level is + * pkt.num_prio - 1. The default value is + * ODP_POOL_PRIO_DEFAULT. + */ + uint8_t prio; + + /** Number of additional packet pool parameters + * + * The number of pkt.add[] table entries filled. The + * value must not exceed ODP_POOL_PKT_ADD_MAX. + * The default value is 0. + */ + uint8_t num_add; + /** 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 (the pool maximum). */ uint32_t max_len; + /** 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 for no requirement for maximum number. + * The default value is 0. + */ + uint32_t max_num; + /** 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. @@ -214,6 +273,26 @@ typedef struct odp_pool_param_t { defined by pool capability pkt.max_uarea_size. Specify as 0 if no user area is needed. */ uint32_t uarea_size; + + /** Additional packet pool parameters + * + * This table gives more fine grained requirements for + * pool configuration. The table continues from + * num/len/prio specification above. Therefore, + * pkt.add[0].len must be greater than pkt.len, and + * pkt.add[0].num refers to packet lengths between + * pkt.len + 1 and pkt.add[0].len. + * + * Table enties must be ordered by the packet length. + * A number of packets figure (pkt.add[N].num) refers + * to packet lengths between pkt.add[N-1].len + 1 and + * pkt.add[N].len. Each number of packets requirement + * may be rounded up, as long as the 'max_num' + * parameter is not violated. Also, more than one + * number of packets requirement may not be fulfilled + * simultaneously. + */ + odp_pool_param_pkt_add_t add[ODP_POOL_PKT_ADD_MAX]; } pkt; /** Parameters for timeout pools */ @@ -278,8 +357,24 @@ odp_pool_t odp_pool_lookup(const char *name); * Used to get information about a pool. */ typedef struct odp_pool_info_t { - const char *name; /**< pool name */ - odp_pool_param_t params; /**< pool parameters */ + /** Pool name */ + const char *name; + + /** Copy of the pool parameters */ + odp_pool_param_t params; + + /** Packet pool info */ + struct { + /** Maximum number of packets of any length + * + * This many packets in maximum can be allocated from the pool. + * Application can use this e.g. to prepare enough per packet + * contexts. + */ + uint32_t max_num; + + } pkt; + } odp_pool_info_t; /** diff --git a/include/odp/arch/default/api/abi/pool.h b/include/odp/arch/default/api/abi/pool.h index 4637d19f..2e2eaf07 100644 --- a/include/odp/arch/default/api/abi/pool.h +++ b/include/odp/arch/default/api/abi/pool.h @@ -26,6 +26,8 @@ typedef _odp_abi_pool_t *odp_pool_t; #define ODP_POOL_NAME_LEN 32 +#define ODP_POOL_PRIO_DEFAULT 0 + typedef enum odp_pool_type_t { ODP_POOL_BUFFER = ODP_EVENT_BUFFER, ODP_POOL_PACKET = ODP_EVENT_PACKET, diff --git a/platform/linux-generic/include/odp/api/plat/pool_types.h b/platform/linux-generic/include/odp/api/plat/pool_types.h index 8bc816d4..7bab2fd6 100644 --- a/platform/linux-generic/include/odp/api/plat/pool_types.h +++ b/platform/linux-generic/include/odp/api/plat/pool_types.h @@ -36,6 +36,8 @@ typedef ODP_HANDLE_T(odp_pool_t); #define ODP_POOL_NAME_LEN 32 +#define ODP_POOL_PRIO_DEFAULT 0 + typedef enum odp_pool_type_t { ODP_POOL_BUFFER = ODP_EVENT_BUFFER, ODP_POOL_PACKET = ODP_EVENT_PACKET, -- 2.11.0
