[lng-odp] [PATCHv3] validation: packet: do not require a max packet length

2017-03-23 Thread Bill Fischofer
Address bug https://bugs.linaro.org/show_bug.cgi?id=2908 by adding
appropriate pool capability checks to the packet, pktio, and crypto tests
to account for pkt.max_len, pkt.max_seg_len, or pkt.max_segs_per_pkt
being zero, indicating these limits are bound only by available
memory.

Signed-off-by: Bill Fischofer 
---
 test/common_plat/validation/api/crypto/crypto.c |  6 --
 test/common_plat/validation/api/packet/packet.c | 13 +++--
 test/common_plat/validation/api/pktio/pktio.c   | 11 +++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/test/common_plat/validation/api/crypto/crypto.c 
b/test/common_plat/validation/api/crypto/crypto.c
index e7c2bf3..94beb2f 100644
--- a/test/common_plat/validation/api/crypto/crypto.c
+++ b/test/common_plat/validation/api/crypto/crypto.c
@@ -48,12 +48,14 @@ int crypto_init(odp_instance_t *inst)
params.pkt.num = PKT_POOL_NUM;
params.type= ODP_POOL_PACKET;
 
-   if (PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
+   if (pool_capa.pkt.max_seg_len &&
+   PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
fprintf(stderr, "Warning: small packet segment length\n");
params.pkt.seg_len = pool_capa.pkt.max_seg_len;
}
 
-   if (PKT_POOL_LEN > pool_capa.pkt.max_len) {
+   if (pool_capa.pkt.max_len &&
+   PKT_POOL_LEN > pool_capa.pkt.max_len) {
fprintf(stderr, "Pool max packet length too small\n");
return -1;
}
diff --git a/test/common_plat/validation/api/packet/packet.c 
b/test/common_plat/validation/api/packet/packet.c
index 900c426..669122a 100644
--- a/test/common_plat/validation/api/packet/packet.c
+++ b/test/common_plat/validation/api/packet/packet.c
@@ -114,6 +114,8 @@ int packet_suite_init(void)
printf("pool_capability failed\n");
return -1;
}
+   if (capa.pkt.max_segs_per_pkt == 0)
+   capa.pkt.max_segs_per_pkt = 10;
 
/* Pick a typical packet size and decrement it to the single segment
 * limit if needed (min_seg_len maybe equal to max_len
@@ -366,6 +368,8 @@ void packet_test_alloc_segmented(void)
int ret, i, num_alloc;
 
CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
+   if (capa.pkt.max_segs_per_pkt == 0)
+   capa.pkt.max_segs_per_pkt = 10;
 
if (capa.pkt.max_len)
max_len = capa.pkt.max_len;
@@ -1847,6 +1851,9 @@ void packet_test_extend_ref(void)
 {
odp_packet_t max_pkt, ref;
uint32_t hr, tr, max_len;
+   odp_pool_capability_t capa;
+
+   CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
 
max_pkt = odp_packet_copy(segmented_test_packet,
  odp_packet_pool(segmented_test_packet));
@@ -1860,8 +1867,10 @@ void packet_test_extend_ref(void)
odp_packet_push_tail(max_pkt, tr);
 
/* Max packet should not be extendable at either end */
-   CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
-   CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
+   if (max_len == capa.pkt.max_len) {
+   CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
+   CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
+   }
 
/* See if we can trunc and extend anyway */
CU_ASSERT(odp_packet_trunc_tail(&max_pkt, hr + tr + 1,
diff --git a/test/common_plat/validation/api/pktio/pktio.c 
b/test/common_plat/validation/api/pktio/pktio.c
index 4f3c0c0..54f206e 100644
--- a/test/common_plat/validation/api/pktio/pktio.c
+++ b/test/common_plat/validation/api/pktio/pktio.c
@@ -124,7 +124,7 @@ static void set_pool_len(odp_pool_param_t *params, 
odp_pool_capability_t *capa)
 {
uint32_t seg_len;
 
-   seg_len = capa->pkt.max_seg_len;
+   seg_len = capa->pkt.max_seg_len ? capa->pkt.max_seg_len : PKT_BUF_SIZE;
 
switch (pool_segmentation) {
case PKT_POOL_SEGMENTED:
@@ -620,7 +620,8 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, 
pktio_info_t *pktio_b,
 
CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0);
 
-   if (packet_len > pool_capa.pkt.max_len)
+   if (pool_capa.pkt.max_len &&
+   packet_len > pool_capa.pkt.max_len)
packet_len = pool_capa.pkt.max_len;
}
 
@@ -1689,7 +1690,8 @@ int pktio_check_send_failure(void)
odp_pktio_close(pktio_tx);
 
/* Failure test supports only single segment */
-   if (pool_capa.pkt.max_seg_len < mtu + 32)
+   if (pool_capa.pkt.max_seg_len &&
+   pool_capa.pkt.max_seg_len < mtu + 32)
return ODP_TEST_INACTIVE;
 
return ODP_TEST_ACTIVE;
@@ -1728,7 +1730,8 @@ void pktio_test_send_failure(void)
 
CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0);
 
-   if (pool_capa.pkt.max_seg_len < mtu + 32) {
+   if (pool_capa.pkt.max_seg_l

Re: [lng-odp] [PATCHv3] validation: packet: do not require a max packet length

2017-03-24 Thread Krishna Garapati
Reviewed-by: Balakrishna Garapati 

/Krishna

On 23 March 2017 at 22:56, Bill Fischofer  wrote:

> Address bug https://bugs.linaro.org/show_bug.cgi?id=2908 by adding
> appropriate pool capability checks to the packet, pktio, and crypto tests
> to account for pkt.max_len, pkt.max_seg_len, or pkt.max_segs_per_pkt
> being zero, indicating these limits are bound only by available
> memory.
>
> Signed-off-by: Bill Fischofer 
> ---
>  test/common_plat/validation/api/crypto/crypto.c |  6 --
>  test/common_plat/validation/api/packet/packet.c | 13 +++--
>  test/common_plat/validation/api/pktio/pktio.c   | 11 +++
>  3 files changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/test/common_plat/validation/api/crypto/crypto.c
> b/test/common_plat/validation/api/crypto/crypto.c
> index e7c2bf3..94beb2f 100644
> --- a/test/common_plat/validation/api/crypto/crypto.c
> +++ b/test/common_plat/validation/api/crypto/crypto.c
> @@ -48,12 +48,14 @@ int crypto_init(odp_instance_t *inst)
> params.pkt.num = PKT_POOL_NUM;
> params.type= ODP_POOL_PACKET;
>
> -   if (PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> +   if (pool_capa.pkt.max_seg_len &&
> +   PKT_POOL_LEN > pool_capa.pkt.max_seg_len) {
> fprintf(stderr, "Warning: small packet segment length\n");
> params.pkt.seg_len = pool_capa.pkt.max_seg_len;
> }
>
> -   if (PKT_POOL_LEN > pool_capa.pkt.max_len) {
> +   if (pool_capa.pkt.max_len &&
> +   PKT_POOL_LEN > pool_capa.pkt.max_len) {
> fprintf(stderr, "Pool max packet length too small\n");
> return -1;
> }
> diff --git a/test/common_plat/validation/api/packet/packet.c
> b/test/common_plat/validation/api/packet/packet.c
> index 900c426..669122a 100644
> --- a/test/common_plat/validation/api/packet/packet.c
> +++ b/test/common_plat/validation/api/packet/packet.c
> @@ -114,6 +114,8 @@ int packet_suite_init(void)
> printf("pool_capability failed\n");
> return -1;
> }
> +   if (capa.pkt.max_segs_per_pkt == 0)
> +   capa.pkt.max_segs_per_pkt = 10;
>
> /* Pick a typical packet size and decrement it to the single
> segment
>  * limit if needed (min_seg_len maybe equal to max_len
> @@ -366,6 +368,8 @@ void packet_test_alloc_segmented(void)
> int ret, i, num_alloc;
>
> CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
> +   if (capa.pkt.max_segs_per_pkt == 0)
> +   capa.pkt.max_segs_per_pkt = 10;
>
> if (capa.pkt.max_len)
> max_len = capa.pkt.max_len;
> @@ -1847,6 +1851,9 @@ void packet_test_extend_ref(void)
>  {
> odp_packet_t max_pkt, ref;
> uint32_t hr, tr, max_len;
> +   odp_pool_capability_t capa;
> +
> +   CU_ASSERT_FATAL(odp_pool_capability(&capa) == 0);
>
> max_pkt = odp_packet_copy(segmented_test_packet,
>   odp_packet_pool(segmented_test_packet));
> @@ -1860,8 +1867,10 @@ void packet_test_extend_ref(void)
> odp_packet_push_tail(max_pkt, tr);
>
> /* Max packet should not be extendable at either end */
> -   CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL) < 0);
> -   CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL) < 0);
> +   if (max_len == capa.pkt.max_len) {
> +   CU_ASSERT(odp_packet_extend_tail(&max_pkt, 1, NULL, NULL)
> < 0);
> +   CU_ASSERT(odp_packet_extend_head(&max_pkt, 1, NULL, NULL)
> < 0);
> +   }
>
> /* See if we can trunc and extend anyway */
> CU_ASSERT(odp_packet_trunc_tail(&max_pkt, hr + tr + 1,
> diff --git a/test/common_plat/validation/api/pktio/pktio.c
> b/test/common_plat/validation/api/pktio/pktio.c
> index 4f3c0c0..54f206e 100644
> --- a/test/common_plat/validation/api/pktio/pktio.c
> +++ b/test/common_plat/validation/api/pktio/pktio.c
> @@ -124,7 +124,7 @@ static void set_pool_len(odp_pool_param_t *params,
> odp_pool_capability_t *capa)
>  {
> uint32_t seg_len;
>
> -   seg_len = capa->pkt.max_seg_len;
> +   seg_len = capa->pkt.max_seg_len ? capa->pkt.max_seg_len :
> PKT_BUF_SIZE;
>
> switch (pool_segmentation) {
> case PKT_POOL_SEGMENTED:
> @@ -620,7 +620,8 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a,
> pktio_info_t *pktio_b,
>
> CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0);
>
> -   if (packet_len > pool_capa.pkt.max_len)
> +   if (pool_capa.pkt.max_len &&
> +   packet_len > pool_capa.pkt.max_len)
> packet_len = pool_capa.pkt.max_len;
> }
>
> @@ -1689,7 +1690,8 @@ int pktio_check_send_failure(void)
> odp_pktio_close(pktio_tx);
>
> /* Failure test supports only single segment */
> -   if (pool_capa.pkt.max_seg_len < mtu + 32)
> +   if (pool_capa.pkt.max_seg_len &&
> +   pool_capa.pkt.max_seg_len <