For the v2 series:

Reviewed-and-tested-by: Bill Fischofer <[email protected]>

On Tue, Apr 26, 2016 at 5:40 AM, Petri Savolainen <
[email protected]> wrote:

> Removed pool configuration API from config.h and moved to
> use pool capability API instead.
>
> Removed entire all config validation tests, since all config APIs
> will move to various capability APIs.
>
> Signed-off-by: Petri Savolainen <[email protected]>
> ---
>  helper/test/chksum.c                               |  36 +++---
>  include/odp/api/spec/config.h                      |  82 -------------
>  platform/linux-generic/Makefile.am                 |   1 +
>  platform/linux-generic/include/odp/api/config.h    | 120
> -------------------
>  .../linux-generic/include/odp_buffer_internal.h    |   2 +-
>  .../linux-generic/include/odp_config_internal.h    | 132
> +++++++++++++++++++++
>  platform/linux-generic/include/odp_pool_internal.h |   2 +-
>  platform/linux-generic/odp_pool.c                  |  31 +++++
>  platform/linux-generic/odp_shared_memory.c         |   2 +-
>  platform/linux-generic/test/Makefile.am            |   1 -
>  test/m4/configure.m4                               |   1 -
>  test/validation/Makefile.am                        |   1 -
>  test/validation/config/.gitignore                  |   1 -
>  test/validation/config/Makefile.am                 |  10 --
>  test/validation/config/config.c                    |  62 ----------
>  test/validation/config/config.h                    |  28 -----
>  test/validation/config/config_main.c               |  11 --
>  test/validation/crypto/crypto.c                    |  11 +-
>  test/validation/packet/packet.c                    | 124
> ++++++++++++-------
>  test/validation/pktio/pktio.c                      |   8 +-
>  20 files changed, 279 insertions(+), 387 deletions(-)
>  create mode 100644 platform/linux-generic/include/odp_config_internal.h
>  delete mode 100644 test/validation/config/.gitignore
>  delete mode 100644 test/validation/config/Makefile.am
>  delete mode 100644 test/validation/config/config.c
>  delete mode 100644 test/validation/config/config.h
>  delete mode 100644 test/validation/config/config_main.c
>
> diff --git a/helper/test/chksum.c b/helper/test/chksum.c
> index 3e6c44e..f47fa64 100644
> --- a/helper/test/chksum.c
> +++ b/helper/test/chksum.c
> @@ -10,10 +10,6 @@
>  #include <odp/helper/ip.h>
>  #include <odp/helper/udp.h>
>
> -#define PACKET_BUF_LEN ODP_CONFIG_PACKET_SEG_LEN_MIN
> -/* Reserve some tailroom for tests */
> -#define PACKET_TAILROOM_RESERVE 4
> -
>  struct udata_struct {
>         uint64_t u64;
>         uint32_t u32;
> @@ -24,11 +20,6 @@ struct udata_struct {
>         "abcdefg",
>  };
>
> -static const uint32_t packet_len =     PACKET_BUF_LEN -
> -                                       ODP_CONFIG_PACKET_HEADROOM -
> -                                       ODP_CONFIG_PACKET_TAILROOM -
> -                                       PACKET_TAILROOM_RESERVE;
> -
>  /* Create additional dataplane threads */
>  int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
>  {
> @@ -46,15 +37,8 @@ int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
>         odph_ethaddr_t src;
>         uint32_t srcip;
>         uint32_t dstip;
> -       odp_pool_param_t params = {
> -               .pkt = {
> -                               .seg_len = PACKET_BUF_LEN,
> -                               .len     = PACKET_BUF_LEN,
> -                               .num     = 100,
> -                               .uarea_size = sizeof(struct udata_struct),
> -                       },
> -                       .type  = ODP_POOL_PACKET,
> -       };
> +       odp_pool_param_t params;
> +       odp_pool_capability_t capa;
>
>         if (odp_init_global(&instance, NULL, NULL)) {
>                 LOG_ERR("Error: ODP global init failed.\n");
> @@ -66,11 +50,24 @@ int main(int argc TEST_UNUSED, char *argv[]
> TEST_UNUSED)
>                 exit(EXIT_FAILURE);
>         }
>
> +       if (odp_pool_capability(&capa) < 0) {
> +               LOG_ERR("Error: ODP global init failed.\n");
> +               exit(EXIT_FAILURE);
> +       }
> +
> +       odp_pool_param_init(&params);
> +
> +       params.type           = ODP_POOL_PACKET;
> +       params.pkt.seg_len    = capa.pkt.min_seg_len;
> +       params.pkt.len        = capa.pkt.min_seg_len;
> +       params.pkt.num        = 100;
> +       params.pkt.uarea_size = sizeof(struct udata_struct);
> +
>         packet_pool = odp_pool_create("packet_pool", &params);
>         if (packet_pool == ODP_POOL_INVALID)
>                 return -1;
>
> -       test_packet = odp_packet_alloc(packet_pool, packet_len);
> +       test_packet = odp_packet_alloc(packet_pool, capa.pkt.min_seg_len);
>         if (odp_packet_is_valid(test_packet) == 0)
>                 return -1;
>
> @@ -79,6 +76,7 @@ int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
>         if (!udat || udat_size != sizeof(struct udata_struct))
>                 return -1;
>
> +       /* Bug: User area is not packet payload, it's user defined
> metadata */
>         memcpy(udat, &test_packet_udata, sizeof(struct udata_struct));
>
>         buf = odp_packet_data(test_packet);
> diff --git a/include/odp/api/spec/config.h b/include/odp/api/spec/config.h
> index 7a2d18b..a6b07b9 100644
> --- a/include/odp/api/spec/config.h
> +++ b/include/odp/api/spec/config.h
> @@ -33,12 +33,6 @@ extern "C" {
>   */
>
>  /**
> - * Maximum number of pools
> - * @return The maximum number of pools supported by this platform
> - */
> -int odp_config_pools(void);
> -
> -/**
>   * Maximum number of queues
>   * @return The maximum number of queues supported by this platform
>   */
> @@ -70,82 +64,6 @@ int odp_config_sched_grps(void);
>   */
>  int odp_config_pktio_entries(void);
>
> -/**
> - * Minimum buffer alignment
> - *
> - * @return The minimum buffer alignment supported by this platform
> - * @note Requests for values below this will be rounded up to this value.
> - */
> -int odp_config_buffer_align_min(void);
> -
> -/**
> - * Maximum buffer alignment
> - *
> - * This defines the maximum supported buffer alignment. Requests for
> values
> - * above this will fail.
> - *
> - * @return The maximum buffer alignment supported by this platform.
> - */
> -int odp_config_buffer_align_max(void);
> -
> -/**
> - * Default packet headroom
> - *
> - * This defines 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. Implementations may reserve a larger than minimum
> headroom
> - * size e.g. due to HW or a protocol specific alignment requirement.
> - *
> - * @return Default packet headroom in bytes
> - */
> -int odp_config_packet_headroom(void);
> -
> -/**
> - * Default packet tailroom
> - *
> - * This defines 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. Implementations are free to add to this as desired
> - * without restriction.
> - *
> - * @return The default packet tailroom in bytes
> - */
> -int odp_config_packet_tailroom(void);
> -
> -/**
> - * Minimum packet segment length
> - *
> - * This defines the minimum packet segment buffer length in bytes. The
> user
> - * defined segment length (seg_len in odp_pool_param_t) will be rounded
> up into
> - * this value.
> - *
> - * @return The minimum packet seg_len supported by this platform
> - */
> -int odp_config_packet_seg_len_min(void);
> -
> -/**
> - * Maximum packet segment length
> - *
> - * This defines the maximum packet segment buffer length in bytes. The
> user
> - * defined segment length (seg_len in odp_pool_param_t) must not be
> larger than
> - * this.
> - *
> - * @return The maximum packet seg_len supported by this platform
> - */
> -int odp_config_packet_seg_len_max(void);
> -
> -/**
> - * Maximum packet buffer length
> - *
> - * This defines the maximum number of bytes that can be stored into a
> packet
> - * (maximum return value of odp_packet_buf_len()). Attempts to allocate
> - * (including default head- and tailrooms) or extend packets to sizes
> larger
> - * than this limit will fail.
> - *
> - * @return The maximum packet buffer length supported by this platform
> - */
> -int odp_config_packet_buf_len_max(void);
> -
>  /** Maximum number of shared memory blocks.
>   *
>   * This the the number of separate SHM areas that can be reserved
> concurrently
> diff --git a/platform/linux-generic/Makefile.am
> b/platform/linux-generic/Makefile.am
> index 0c6dfde..cbcb59e 100644
> --- a/platform/linux-generic/Makefile.am
> +++ b/platform/linux-generic/Makefile.am
> @@ -99,6 +99,7 @@ noinst_HEADERS = \
>                   ${srcdir}/include/odp_classification_datamodel.h \
>                   ${srcdir}/include/odp_classification_inlines.h \
>                   ${srcdir}/include/odp_classification_internal.h \
> +                 ${srcdir}/include/odp_config_internal.h \
>                   ${srcdir}/include/odp_crypto_internal.h \
>                   ${srcdir}/include/odp_debug_internal.h \
>                   ${srcdir}/include/odp_forward_typedefs_internal.h \
> diff --git a/platform/linux-generic/include/odp/api/config.h
> b/platform/linux-generic/include/odp/api/config.h
> index e21b6f7..398e346 100644
> --- a/platform/linux-generic/include/odp/api/config.h
> +++ b/platform/linux-generic/include/odp/api/config.h
> @@ -23,15 +23,6 @@ extern "C" {
>   */
>
>  /**
> - * Maximum number of pools
> - */
> -#define ODP_CONFIG_POOLS 16
> -static inline int odp_config_pools(void)
> -{
> -       return ODP_CONFIG_POOLS;
> -}
> -
> -/**
>   * Maximum number of queues
>   */
>  #define ODP_CONFIG_QUEUES 1024
> @@ -76,117 +67,6 @@ static inline int odp_config_pktio_entries(void)
>         return ODP_CONFIG_PKTIO_ENTRIES;
>  }
>
> -/**
> - * Minimum buffer alignment
> - *
> - * This defines the minimum supported buffer alignment. Requests for
> values
> - * below this will be rounded up to this value.
> - */
> -#define ODP_CONFIG_BUFFER_ALIGN_MIN 16
> -static inline int odp_config_buffer_align_min(void)
> -{
> -       return ODP_CONFIG_BUFFER_ALIGN_MIN;
> -}
> -
> -/**
> - * Maximum buffer alignment
> - *
> - * This defines the maximum supported buffer alignment. Requests for
> values
> - * above this will fail.
> - */
> -#define ODP_CONFIG_BUFFER_ALIGN_MAX (4 * 1024)
> -static inline int odp_config_buffer_align_max(void)
> -{
> -       return ODP_CONFIG_BUFFER_ALIGN_MAX;
> -}
> -
> -/**
> - * Default packet headroom
> - *
> - * This defines 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. Implementations may reserve a larger than minimum
> headroom
> - * size e.g. due to HW or a protocol specific alignment requirement.
> - *
> - * @internal In linux-generic implementation:
> - * The default value (66) allows a 1500-byte packet to be received into a
> single
> - * segment with Ethernet offset alignment and room for some header
> expansion.
> - */
> -#define ODP_CONFIG_PACKET_HEADROOM 66
> -static inline int odp_config_packet_headroom(void)
> -{
> -       return ODP_CONFIG_PACKET_HEADROOM;
> -}
> -
> -/**
> - * Default packet tailroom
> - *
> - * This defines 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. Implementations are free to add to this as desired
> - * without restriction. Note that most implementations will automatically
> - * consider any unused portion of the last segment of a packet as tailroom
> - */
> -#define ODP_CONFIG_PACKET_TAILROOM 0
> -static inline int odp_config_packet_tailroom(void)
> -{
> -       return ODP_CONFIG_PACKET_TAILROOM;
> -}
> -
> -/**
> - * Minimum packet segment length
> - *
> - * This defines the minimum packet segment buffer length in bytes. The
> user
> - * defined segment length (seg_len in odp_pool_param_t) will be rounded
> up into
> - * this value.
> - */
> -#define ODP_CONFIG_PACKET_SEG_LEN_MIN 1598
> -static inline int odp_config_packet_seg_len_min(void)
> -{
> -       return ODP_CONFIG_PACKET_SEG_LEN_MIN;
> -}
> -
> -/**
> - * Maximum packet segment length
> - *
> - * This defines the maximum packet segment buffer length in bytes. The
> user
> - * defined segment length (seg_len in odp_pool_param_t) must not be
> larger than
> - * this.
> - */
> -#define ODP_CONFIG_PACKET_SEG_LEN_MAX (64 * 1024)
> -static inline int odp_config_packet_seg_len_max(void)
> -{
> -       return ODP_CONFIG_PACKET_SEG_LEN_MAX;
> -}
> -
> -/**
> - * Maximum packet buffer length
> - *
> - * This defines the maximum number of bytes that can be stored into a
> packet
> - * (maximum return value of odp_packet_buf_len(void)). Attempts to
> allocate
> - * (including default head- and tailrooms) or extend packets to sizes
> larger
> - * than this limit will fail.
> - *
> - * @internal In linux-generic implementation:
> - * - The value MUST be an integral number of segments
> - * - The value SHOULD be large enough to accommodate jumbo packets (9K)
> - */
> -#define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_SEG_LEN_MIN * 6)
> -static inline int odp_config_packet_buf_len_max(void)
> -{
> -       return ODP_CONFIG_PACKET_BUF_LEN_MAX;
> -}
> -
> -/** Maximum number of shared memory blocks.
> - *
> - * This the the number of separate SHM areas that can be reserved
> concurrently
> - */
> -#define ODP_CONFIG_SHM_BLOCKS (ODP_CONFIG_POOLS + 48)
> -static inline int odp_config_shm_blocks(void)
> -{
> -       return ODP_CONFIG_SHM_BLOCKS;
> -}
> -
>  #include <odp/api/spec/config.h>
>
>  /**
> diff --git a/platform/linux-generic/include/odp_buffer_internal.h
> b/platform/linux-generic/include/odp_buffer_internal.h
> index a7a3ffd..e4f96fe 100644
> --- a/platform/linux-generic/include/odp_buffer_internal.h
> +++ b/platform/linux-generic/include/odp_buffer_internal.h
> @@ -25,7 +25,7 @@ extern "C" {
>  #include <odp/api/debug.h>
>  #include <odp/api/align.h>
>  #include <odp_align_internal.h>
> -#include <odp/api/config.h>
> +#include <odp_config_internal.h>
>  #include <odp/api/byteorder.h>
>  #include <odp/api/thread.h>
>  #include <odp/api/event.h>
> diff --git a/platform/linux-generic/include/odp_config_internal.h
> b/platform/linux-generic/include/odp_config_internal.h
> new file mode 100644
> index 0000000..b7fcdbf
> --- /dev/null
> +++ b/platform/linux-generic/include/odp_config_internal.h
> @@ -0,0 +1,132 @@
> +/* Copyright (c) 2016, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#ifndef ODP_CONFIG_INTERNAL_H_
> +#define ODP_CONFIG_INTERNAL_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/*
> + * Maximum number of pools
> + */
> +#define ODP_CONFIG_POOLS 16
> +
> +/*
> + * Maximum number of queues
> + */
> +#define ODP_CONFIG_QUEUES 1024
> +
> +/*
> + * Number of ordered locks per queue
> + */
> +#define ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE 2
> +
> +/*
> + * Number of scheduling priorities
> + */
> +#define ODP_CONFIG_SCHED_PRIOS 8
> +
> +/*
> + * Number of scheduling groups
> + */
> +#define ODP_CONFIG_SCHED_GRPS 256
> +
> +/*
> + * Maximum number of packet IO resources
> + */
> +#define ODP_CONFIG_PKTIO_ENTRIES 64
> +
> +/*
> + * Minimum buffer alignment
> + *
> + * This defines the minimum supported buffer alignment. Requests for
> values
> + * below this will be rounded up to this value.
> + */
> +#define ODP_CONFIG_BUFFER_ALIGN_MIN 16
> +
> +/*
> + * Maximum buffer alignment
> + *
> + * This defines the maximum supported buffer alignment. Requests for
> values
> + * above this will fail.
> + */
> +#define ODP_CONFIG_BUFFER_ALIGN_MAX (4 * 1024)
> +
> +/*
> + * Default packet headroom
> + *
> + * This defines 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. Implementations may reserve a larger than minimum
> headroom
> + * size e.g. due to HW or a protocol specific alignment requirement.
> + *
> + * @internal In linux-generic implementation:
> + * The default value (66) allows a 1500-byte packet to be received into a
> single
> + * segment with Ethernet offset alignment and room for some header
> expansion.
> + */
> +#define ODP_CONFIG_PACKET_HEADROOM 66
> +
> +/*
> + * Default packet tailroom
> + *
> + * This defines 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. Implementations are free to add to this as desired
> + * without restriction. Note that most implementations will automatically
> + * consider any unused portion of the last segment of a packet as tailroom
> + */
> +#define ODP_CONFIG_PACKET_TAILROOM 0
> +
> +/*
> + * Maximum number of segments per packet
> + */
> +#define ODP_CONFIG_PACKET_MAX_SEGS 6
> +
> +/*
> + * Minimum packet segment length
> + *
> + * This defines the minimum packet segment buffer length in bytes. The
> user
> + * defined segment length (seg_len in odp_pool_param_t) will be rounded
> up into
> + * this value.
> + */
> +#define ODP_CONFIG_PACKET_SEG_LEN_MIN 1598
> +
> +/*
> + * Maximum packet segment length
> + *
> + * This defines the maximum packet segment buffer length in bytes. The
> user
> + * defined segment length (seg_len in odp_pool_param_t) must not be
> larger than
> + * this.
> + */
> +#define ODP_CONFIG_PACKET_SEG_LEN_MAX (64 * 1024)
> +
> +/*
> + * Maximum packet buffer length
> + *
> + * This defines the maximum number of bytes that can be stored into a
> packet
> + * (maximum return value of odp_packet_buf_len(void)). Attempts to
> allocate
> + * (including default head- and tailrooms) or extend packets to sizes
> larger
> + * than this limit will fail.
> + *
> + * @internal In linux-generic implementation:
> + * - The value MUST be an integral number of segments
> + * - The value SHOULD be large enough to accommodate jumbo packets (9K)
> + */
> +#define ODP_CONFIG_PACKET_BUF_LEN_MAX (ODP_CONFIG_PACKET_SEG_LEN_MIN * 6)
> +
> +/* Maximum number of shared memory blocks.
> + *
> + * This the the number of separate SHM areas that can be reserved
> concurrently
> + */
> +#define ODP_CONFIG_SHM_BLOCKS (ODP_CONFIG_POOLS + 48)
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/platform/linux-generic/include/odp_pool_internal.h
> b/platform/linux-generic/include/odp_pool_internal.h
> index d522c7e..3317bd0 100644
> --- a/platform/linux-generic/include/odp_pool_internal.h
> +++ b/platform/linux-generic/include/odp_pool_internal.h
> @@ -24,7 +24,7 @@ extern "C" {
>  #include <odp/api/pool.h>
>  #include <odp_buffer_internal.h>
>  #include <odp/api/hints.h>
> -#include <odp/api/config.h>
> +#include <odp_config_internal.h>
>  #include <odp/api/debug.h>
>  #include <odp/api/shared_memory.h>
>  #include <odp/api/atomic.h>
> diff --git a/platform/linux-generic/odp_pool.c
> b/platform/linux-generic/odp_pool.c
> index ee88d01..cb43f53 100644
> --- a/platform/linux-generic/odp_pool.c
> +++ b/platform/linux-generic/odp_pool.c
> @@ -148,6 +148,37 @@ int odp_pool_term_local(void)
>         return 0;
>  }
>
> +int odp_pool_capability(odp_pool_capability_t *capa)
> +{
> +       memset(capa, 0, sizeof(odp_pool_capability_t));
> +
> +       capa->max_pools = ODP_CONFIG_POOLS;
> +
> +       /* Buffer pools */
> +       capa->buf.max_pools = ODP_CONFIG_POOLS;
> +       capa->buf.max_align = ODP_CONFIG_BUFFER_ALIGN_MAX;
> +       capa->buf.max_size  = 0;
> +       capa->buf.max_num   = 0;
> +
> +       /* Packet pools */
> +       capa->pkt.max_pools        = ODP_CONFIG_POOLS;
> +       capa->pkt.max_len          = ODP_CONFIG_PACKET_MAX_SEGS *
> +                                    ODP_CONFIG_PACKET_SEG_LEN_MIN;
> +       capa->pkt.max_num          = 0;
> +       capa->pkt.min_headroom     = ODP_CONFIG_PACKET_HEADROOM;
> +       capa->pkt.min_tailroom     = ODP_CONFIG_PACKET_TAILROOM;
> +       capa->pkt.max_segs_per_pkt = ODP_CONFIG_PACKET_MAX_SEGS;
> +       capa->pkt.min_seg_len      = ODP_CONFIG_PACKET_SEG_LEN_MIN;
> +       capa->pkt.max_seg_len      = ODP_CONFIG_PACKET_SEG_LEN_MAX;
> +       capa->pkt.max_uarea_size   = 0;
> +
> +       /* Timeout pools */
> +       capa->tmo.max_pools = ODP_CONFIG_POOLS;
> +       capa->tmo.max_num   = 0;
> +
> +       return 0;
> +}
> +
>  /**
>   * Pool creation
>   */
> diff --git a/platform/linux-generic/odp_shared_memory.c
> b/platform/linux-generic/odp_shared_memory.c
> index 8820d01..a5c5aa3 100644
> --- a/platform/linux-generic/odp_shared_memory.c
> +++ b/platform/linux-generic/odp_shared_memory.c
> @@ -15,7 +15,7 @@
>  #include <odp_shm_internal.h>
>  #include <odp_debug_internal.h>
>  #include <odp_align_internal.h>
> -#include <odp/api/config.h>
> +#include <odp_config_internal.h>
>
>  #include <unistd.h>
>  #include <sys/mman.h>
> diff --git a/platform/linux-generic/test/Makefile.am
> b/platform/linux-generic/test/Makefile.am
> index a93fa8e..05998e3 100644
> --- a/platform/linux-generic/test/Makefile.am
> +++ b/platform/linux-generic/test/Makefile.am
> @@ -14,7 +14,6 @@ TESTS = pktio/pktio_run \
>         ${top_builddir}/test/validation/barrier/barrier_main$(EXEEXT) \
>         ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \
>
> ${top_builddir}/test/validation/classification/classification_main$(EXEEXT)
> \
> -       ${top_builddir}/test/validation/config/config_main$(EXEEXT) \
>         ${top_builddir}/test/validation/cpumask/cpumask_main$(EXEEXT) \
>         ${top_builddir}/test/validation/crypto/crypto_main$(EXEEXT) \
>         ${top_builddir}/test/validation/errno/errno_main$(EXEEXT) \
> diff --git a/test/m4/configure.m4 b/test/m4/configure.m4
> index e5b291a..5a74809 100644
> --- a/test/m4/configure.m4
> +++ b/test/m4/configure.m4
> @@ -10,7 +10,6 @@ AC_CONFIG_FILES([test/Makefile
>                  test/validation/buffer/Makefile
>                  test/validation/classification/Makefile
>                  test/validation/common/Makefile
> -                test/validation/config/Makefile
>                  test/validation/cpumask/Makefile
>                  test/validation/crypto/Makefile
>                  test/validation/errno/Makefile
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index 074da26..90cc549 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -2,7 +2,6 @@ ODP_MODULES = atomic \
>               barrier \
>               buffer \
>               classification \
> -             config \
>               cpumask \
>               crypto \
>               errno \
> diff --git a/test/validation/config/.gitignore
> b/test/validation/config/.gitignore
> deleted file mode 100644
> index dbfed8a..0000000
> --- a/test/validation/config/.gitignore
> +++ /dev/null
> @@ -1 +0,0 @@
> -config_main
> \ No newline at end of file
> diff --git a/test/validation/config/Makefile.am
> b/test/validation/config/Makefile.am
> deleted file mode 100644
> index a4985f4..0000000
> --- a/test/validation/config/Makefile.am
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -include ../Makefile.inc
> -
> -noinst_LTLIBRARIES = libtestconfig.la
> -libtestconfig_la_SOURCES = config.c
> -
> -test_PROGRAMS = config_main$(EXEEXT)
> -dist_config_main_SOURCES = config_main.c
> -config_main_LDADD = libtestconfig.la $(LIBCUNIT_COMMON) $(LIBODP)
> -
> -EXTRA_DIST = config.h
> diff --git a/test/validation/config/config.c
> b/test/validation/config/config.c
> deleted file mode 100644
> index 380163c..0000000
> --- a/test/validation/config/config.c
> +++ /dev/null
> @@ -1,62 +0,0 @@
> -/* Copyright (c) 2015, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:    BSD-3-Clause
> - */
> -
> -#include <odp_api.h>
> -#include "odp_cunit_common.h"
> -#include "config.h"
> -
> -int config_suite_init(void)
> -{
> -       return 0;
> -}
> -
> -int config_suite_term(void)
> -{
> -       return 0;
> -}
> -
> -void config_test(void)
> -{
> -       CU_ASSERT(odp_config_pools() == ODP_CONFIG_POOLS);
> -       CU_ASSERT(odp_config_queues() == ODP_CONFIG_QUEUES);
> -       CU_ASSERT(odp_config_max_ordered_locks_per_queue() ==
> -                 ODP_CONFIG_MAX_ORDERED_LOCKS_PER_QUEUE);
> -       CU_ASSERT(odp_config_sched_prios() == ODP_CONFIG_SCHED_PRIOS);
> -       CU_ASSERT(odp_config_sched_grps() == ODP_CONFIG_SCHED_GRPS);
> -       CU_ASSERT(odp_config_pktio_entries() == ODP_CONFIG_PKTIO_ENTRIES);
> -       CU_ASSERT(odp_config_buffer_align_min() ==
> ODP_CONFIG_BUFFER_ALIGN_MIN);
> -       CU_ASSERT(odp_config_buffer_align_max() ==
> ODP_CONFIG_BUFFER_ALIGN_MAX);
> -       CU_ASSERT(odp_config_packet_headroom() ==
> ODP_CONFIG_PACKET_HEADROOM);
> -       CU_ASSERT(odp_config_packet_tailroom() ==
> ODP_CONFIG_PACKET_TAILROOM);
> -       CU_ASSERT(odp_config_packet_seg_len_min() ==
> -                 ODP_CONFIG_PACKET_SEG_LEN_MIN);
> -       CU_ASSERT(odp_config_packet_seg_len_max() ==
> -                 ODP_CONFIG_PACKET_SEG_LEN_MAX);
> -       CU_ASSERT(odp_config_packet_buf_len_max() ==
> -                 ODP_CONFIG_PACKET_BUF_LEN_MAX);
> -       CU_ASSERT(odp_config_shm_blocks() == ODP_CONFIG_SHM_BLOCKS);
> -}
> -
> -odp_testinfo_t config_suite[] = {
> -       ODP_TEST_INFO(config_test),
> -       ODP_TEST_INFO_NULL,
> -};
> -
> -odp_suiteinfo_t config_suites[] = {
> -       {"config tests", config_suite_init,config_suite_term,
> -        config_suite},
> -       ODP_SUITE_INFO_NULL,
> -};
> -
> -int config_main(void)
> -{
> -       int ret = odp_cunit_register(config_suites);
> -
> -       if (ret == 0)
> -               ret = odp_cunit_run();
> -
> -       return ret;
> -}
> diff --git a/test/validation/config/config.h
> b/test/validation/config/config.h
> deleted file mode 100644
> index 55cb539..0000000
> --- a/test/validation/config/config.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Copyright (c) 2015, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:    BSD-3-Clause
> - */
> -
> -#ifndef _ODP_TEST_CONFIG_H_
> -#define _ODP_TEST_CONFIG_H_
> -
> -#include <odp_cunit_common.h>
> -
> -/* test functions: */
> -void config_test(void);
> -
> -/* test arrays: */
> -extern odp_testinfo_t config_suite[];
> -
> -/* test array init/term functions: */
> -int config_suite_init(void);
> -int config_suite_term(void);
> -
> -/* test registry: */
> -extern odp_suiteinfo_t config_suites[];
> -
> -/* main test program: */
> -int config_main(void);
> -
> -#endif
> diff --git a/test/validation/config/config_main.c
> b/test/validation/config/config_main.c
> deleted file mode 100644
> index 4e2038f..0000000
> --- a/test/validation/config/config_main.c
> +++ /dev/null
> @@ -1,11 +0,0 @@
> -/* Copyright (c) 2015, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:    BSD-3-Clause
> - */
> -#include "config.h"
> -
> -int main(void)
> -{
> -       return config_main();
> -}
> diff --git a/test/validation/crypto/crypto.c
> b/test/validation/crypto/crypto.c
> index 22a1586..be1fd3f 100644
> --- a/test/validation/crypto/crypto.c
> +++ b/test/validation/crypto/crypto.c
> @@ -26,24 +26,31 @@ int crypto_init(odp_instance_t *inst)
>         odp_pool_param_t params;
>         odp_pool_t pool;
>         odp_queue_t out_queue;
> +       odp_pool_capability_t pool_capa;
>
>         if (0 != odp_init_global(inst, NULL, NULL)) {
>                 fprintf(stderr, "error: odp_init_global() failed.\n");
>                 return -1;
>         }
> +
>         if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
>                 fprintf(stderr, "error: odp_init_local() failed.\n");
>                 return -1;
>         }
>
> +       if (odp_pool_capability(&pool_capa) < 0) {
> +               fprintf(stderr, "error: odp_pool_capability() failed.\n");
> +               return -1;
> +       }
> +
>         memset(&params, 0, sizeof(params));
>         params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
>         params.pkt.len     = SHM_PKT_POOL_BUF_SIZE;
>         params.pkt.num     = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUF_SIZE;
>         params.type        = ODP_POOL_PACKET;
>
> -       if (SHM_PKT_POOL_BUF_SIZE > odp_config_packet_buf_len_max())
> -               params.pkt.len = odp_config_packet_buf_len_max();
> +       if (SHM_PKT_POOL_BUF_SIZE > pool_capa.pkt.max_len)
> +               params.pkt.len = pool_capa.pkt.max_len;
>
>         pool = odp_pool_create("packet_pool", &params);
>
> diff --git a/test/validation/packet/packet.c
> b/test/validation/packet/packet.c
> index 4b9da46..e774797 100644
> --- a/test/validation/packet/packet.c
> +++ b/test/validation/packet/packet.c
> @@ -15,10 +15,9 @@
>  #define PACKET_TAILROOM_RESERVE  4
>
>  static odp_pool_t packet_pool;
> -static const uint32_t packet_len = PACKET_BUF_LEN -
> -                               PACKET_TAILROOM_RESERVE;
> +static uint32_t packet_len;
>
> -static uint32_t   segmented_packet_len = ODP_CONFIG_PACKET_BUF_LEN_MAX;
> +static uint32_t segmented_packet_len;
>  static odp_bool_t segmentation_supported = true;
>
>  odp_packet_t test_packet, segmented_test_packet;
> @@ -35,18 +34,31 @@ static struct udata_struct {
>
>  int packet_suite_init(void)
>  {
> -       odp_pool_param_t params = {
> -               .pkt = {
> -                       .seg_len = PACKET_BUF_LEN,
> -                       .len     = PACKET_BUF_LEN,
> -                       .num     = 100,
> -                       .uarea_size = sizeof(struct udata_struct),
> -               },
> -               .type  = ODP_POOL_PACKET,
> -       };
> +       odp_pool_param_t params;
> +       odp_pool_capability_t capa;
>         struct udata_struct *udat;
>         uint32_t udat_size;
>
> +       if (odp_pool_capability(&capa) < 0)
> +               return -1;
> +
> +       packet_len = capa.pkt.min_seg_len - PACKET_TAILROOM_RESERVE;
> +
> +       if (capa.pkt.max_len) {
> +               segmented_packet_len = capa.pkt.max_len;
> +       } else {
> +               segmented_packet_len = capa.pkt.min_seg_len *
> +                                      capa.pkt.max_segs_per_pkt;
> +       }
> +
> +       odp_pool_param_init(&params);
> +
> +       params.type           = ODP_POOL_PACKET;
> +       params.pkt.seg_len    = capa.pkt.min_seg_len;
> +       params.pkt.len        = capa.pkt.min_seg_len;
> +       params.pkt.num        = 100;
> +       params.pkt.uarea_size = sizeof(struct udata_struct);
> +
>         packet_pool = odp_pool_create("packet_pool", &params);
>         if (packet_pool == ODP_POOL_INVALID)
>                 return -1;
> @@ -59,7 +71,7 @@ int packet_suite_init(void)
>                 segmented_test_packet = odp_packet_alloc(packet_pool,
>
>  segmented_packet_len);
>                 if (segmented_test_packet == ODP_PACKET_INVALID)
> -                       segmented_packet_len -=
> ODP_CONFIG_BUFFER_ALIGN_MIN;
> +                       segmented_packet_len -= capa.pkt.min_seg_len;
>         } while (segmented_test_packet == ODP_PACKET_INVALID);
>
>         if (odp_packet_is_valid(test_packet) == 0 ||
> @@ -97,14 +109,17 @@ void packet_test_alloc_free(void)
>  {
>         odp_pool_t pool;
>         odp_packet_t packet;
> -       odp_pool_param_t params = {
> -               .pkt = {
> -                       .seg_len = PACKET_BUF_LEN,
> -                       .len     = PACKET_BUF_LEN,
> -                       .num     = 1,
> -               },
> -               .type  = ODP_POOL_PACKET,
> -       };
> +       odp_pool_param_t params;
> +       odp_pool_capability_t capa;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> +
> +       odp_pool_param_init(&params);
> +
> +       params.type           = ODP_POOL_PACKET;
> +       params.pkt.seg_len    = capa.pkt.min_seg_len;
> +       params.pkt.len        = capa.pkt.min_seg_len;
> +       params.pkt.num        = 1;
>
>         pool = odp_pool_create("packet_pool_alloc", &params);
>
> @@ -157,14 +172,17 @@ void packet_test_alloc_free_multi(void)
>         int i, ret;
>         odp_packet_t packet[2 * num_pkt + 1];
>         odp_packet_t inval_pkt[num_pkt];
> -       odp_pool_param_t params = {
> -               .pkt = {
> -                       .seg_len = PACKET_BUF_LEN,
> -                       .len     = PACKET_BUF_LEN,
> -                       .num     = num_pkt,
> -               },
> -               .type  = ODP_POOL_PACKET,
> -       };
> +       odp_pool_param_t params;
> +       odp_pool_capability_t capa;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> +
> +       odp_pool_param_init(&params);
> +
> +       params.type           = ODP_POOL_PACKET;
> +       params.pkt.seg_len    = capa.pkt.min_seg_len;
> +       params.pkt.len        = capa.pkt.min_seg_len;
> +       params.pkt.num        = num_pkt;
>
>         pool[0] = odp_pool_create("packet_pool_alloc_multi_0", &params);
>         pool[1] = odp_pool_create("packet_pool_alloc_multi_1", &params);
> @@ -215,9 +233,15 @@ void packet_test_alloc_free_multi(void)
>  void packet_test_alloc_segmented(void)
>  {
>         odp_packet_t pkt;
> -       const uint32_t len = ODP_CONFIG_PACKET_BUF_LEN_MAX -
> -                       ODP_CONFIG_PACKET_HEADROOM -
> -                       ODP_CONFIG_PACKET_TAILROOM;
> +       uint32_t len;
> +       odp_pool_capability_t capa;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> +
> +       if (capa.pkt.max_len)
> +               len = capa.pkt.max_len;
> +       else
> +               len = capa.pkt.min_seg_len * capa.pkt.max_segs_per_pkt;
>
>         pkt = odp_packet_alloc(packet_pool, len);
>         CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
> @@ -273,18 +297,18 @@ void packet_test_length(void)
>  {
>         odp_packet_t pkt = test_packet;
>         uint32_t buf_len, headroom, tailroom;
> +       odp_pool_capability_t capa;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
>
>         buf_len = odp_packet_buf_len(pkt);
>         headroom = odp_packet_headroom(pkt);
>         tailroom = odp_packet_tailroom(pkt);
>
>         CU_ASSERT(odp_packet_len(pkt) == packet_len);
> -#if ODP_CONFIG_PACKET_HEADROOM != 0 /* Avoid 'always true' warning */
> -       CU_ASSERT(headroom >= ODP_CONFIG_PACKET_HEADROOM);
> -#endif
> -#if ODP_CONFIG_PACKET_TAILROOM != 0 /* Avoid 'always true' warning */
> -       CU_ASSERT(tailroom >= ODP_CONFIG_PACKET_TAILROOM);
> -#endif
> +       CU_ASSERT(headroom >= capa.pkt.min_headroom);
> +       CU_ASSERT(tailroom >= capa.pkt.min_tailroom);
> +
>         CU_ASSERT(buf_len >= packet_len + headroom + tailroom);
>  }
>
> @@ -396,12 +420,14 @@ void packet_test_headroom(void)
>         uint32_t room;
>         uint32_t seg_data_len;
>         uint32_t push_val, pull_val;
> +       odp_pool_capability_t capa;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
>
>         room = odp_packet_headroom(pkt);
>
> -#if ODP_CONFIG_PACKET_HEADROOM != 0 /* Avoid 'always true' warning */
> -       CU_ASSERT(room >= ODP_CONFIG_PACKET_HEADROOM);
> -#endif
> +       CU_ASSERT(room >= capa.pkt.min_headroom);
> +
>         seg_data_len = odp_packet_seg_len(pkt);
>         CU_ASSERT(seg_data_len >= 1);
>         /** @todo: should be len - 1 */
> @@ -469,13 +495,15 @@ void packet_test_tailroom(void)
>         uint32_t room;
>         uint32_t seg_data_len;
>         uint32_t push_val, pull_val;
> +       odp_pool_capability_t capa;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
>
>         segment = odp_packet_last_seg(pkt);
>         CU_ASSERT(segment != ODP_PACKET_SEG_INVALID);
>         room = odp_packet_tailroom(pkt);
> -#if ODP_CONFIG_PACKET_TAILROOM != 0 /* Avoid 'always true' warning */
> -       CU_ASSERT(room >= ODP_CONFIG_PACKET_TAILROOM);
> -#endif
> +       CU_ASSERT(room >= capa.pkt.min_tailroom);
> +
>         seg_data_len = odp_packet_seg_data_len(pkt, segment);
>         CU_ASSERT(seg_data_len >= 1);
>         /** @todo: should be len - 1 */
> @@ -650,6 +678,12 @@ void packet_test_add_rem_data(void)
>         void *usr_ptr;
>         struct udata_struct *udat, *new_udat;
>         int ret;
> +       odp_pool_capability_t capa;
> +       uint32_t min_seg_len;
> +
> +       CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> +
> +       min_seg_len = capa.pkt.min_seg_len;
>
>         pkt = odp_packet_alloc(packet_pool, packet_len);
>         CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
> @@ -665,7 +699,7 @@ void packet_test_add_rem_data(void)
>
>         if (segmentation_supported) {
>                 /* Insert one more packet length in the middle of a packet
> */
> -               add_len = PACKET_BUF_LEN;
> +               add_len = min_seg_len;
>         } else {
>                 /* Add diff between largest and smaller packets
>                  * which is at least tailroom */
> diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
> index 2f98b10..a7983a9 100644
> --- a/test/validation/pktio/pktio.c
> +++ b/test/validation/pktio/pktio.c
> @@ -1636,6 +1636,12 @@ int pktio_check_send_failure(void)
>         odp_pktio_param_t pktio_param;
>         int iface_idx = 0;
>         const char *iface = iface_name[iface_idx];
> +       odp_pool_capability_t pool_capa;
> +
> +       if (odp_pool_capability(&pool_capa) < 0) {
> +               fprintf(stderr, "%s: pool capability failed\n", __func__);
> +               return ODP_TEST_INACTIVE;
> +       };
>
>         memset(&pktio_param, 0, sizeof(pktio_param));
>
> @@ -1652,7 +1658,7 @@ int pktio_check_send_failure(void)
>
>         odp_pktio_close(pktio_tx);
>
> -       if (mtu <= ODP_CONFIG_PACKET_BUF_LEN_MAX - 32)
> +       if (mtu <= pool_capa.pkt.max_len - 32)
>                 return ODP_TEST_ACTIVE;
>
>         return ODP_TEST_INACTIVE;
> --
> 2.8.1
>
> _______________________________________________
> lng-odp mailing list
> [email protected]
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to