diff mbox

[v2] linux-generic: Replace printf with ODP_PRINT

Message ID 1416438857-17362-1-git-send-email-mike.holmes@linaro.org
State Accepted
Commit 7c671645c1478dcabc2288c7d736e5bca4888037
Headers show

Commit Message

Mike Holmes Nov. 19, 2014, 11:14 p.m. UTC
Current ODP APIs that print internal data on demand for the application do so
via printf.

Introduce ODP_PRI so that APIs that produce output may be channeled though
ODP_LOG to match the other logging types.

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
 platform/linux-generic/odp_buffer.c            |  4 +--
 platform/linux-generic/odp_buffer_pool.c       | 45 +++++++++++++-------------
 platform/linux-generic/odp_packet.c            |  2 +-
 platform/linux-generic/odp_shared_memory.c     | 32 +++++++++---------
 5 files changed, 56 insertions(+), 41 deletions(-)

Comments

Bill Fischofer Nov. 20, 2014, 12:31 a.m. UTC | #1
On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes <mike.holmes@linaro.org> wrote:

> Current ODP APIs that print internal data on demand for the application do
> so
> via printf.
>
> Introduce ODP_PRI so that APIs that produce output may be channeled though
> ODP_LOG to match the other logging types.
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>

Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>


> ---
>  platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>  platform/linux-generic/odp_buffer.c            |  4 +--
>  platform/linux-generic/odp_buffer_pool.c       | 45
> +++++++++++++-------------
>  platform/linux-generic/odp_packet.c            |  2 +-
>  platform/linux-generic/odp_shared_memory.c     | 32 +++++++++---------
>  5 files changed, 56 insertions(+), 41 deletions(-)
>
> diff --git a/platform/linux-generic/include/api/odp_debug.h
> b/platform/linux-generic/include/api/odp_debug.h
> index c9b2edd..5c3adde 100644
> --- a/platform/linux-generic/include/api/odp_debug.h
> +++ b/platform/linux-generic/include/api/odp_debug.h
> @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>         ODP_LOG_DBG,
>         ODP_LOG_ERR,
>         ODP_LOG_UNIMPLEMENTED,
> -       ODP_LOG_ABORT
> +       ODP_LOG_ABORT,
> +       ODP_LOG_PRINT
>  } odp_log_level_e;
>
>  /**
> @@ -94,6 +95,10 @@ do { \
>                         fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
>                         __LINE__, __func__, ##__VA_ARGS__); \
>                 break; \
> +       case ODP_LOG_PRINT: \
> +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
> +               __LINE__, __func__, ##__VA_ARGS__); \
> +               break; \
>         case ODP_LOG_ABORT: \
>                 fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>                 __LINE__, __func__, ##__VA_ARGS__); \
> @@ -111,6 +116,13 @@ do { \
>  } while (0)
>
>  /**
> + * Printing macro, which prints output when the application
> + * calls one of the ODP APIs specifically for dumping internal data.
> + */
> +#define ODP_PRINT(fmt, ...) \
> +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
> +
> +/**
>   * Debug printing macro, which prints output when DEBUG flag is set.
>   */
>  #define ODP_DBG(fmt, ...) \
> diff --git a/platform/linux-generic/odp_buffer.c
> b/platform/linux-generic/odp_buffer.c
> index e54e0e7..d9e211b 100644
> --- a/platform/linux-generic/odp_buffer.c
> +++ b/platform/linux-generic/odp_buffer.c
> @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n, odp_buffer_t
> buf)
>         int len = 0;
>
>         if (!odp_buffer_is_valid(buf)) {
> -               printf("Buffer is not valid.\n");
> +               ODP_PRINT("Buffer is not valid.\n");
>                 return len;
>         }
>
> @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>         len = odp_buffer_snprint(str, max_len-1, buf);
>         str[len] = 0;
>
> -       printf("\n%s\n", str);
> +       ODP_PRINT("\n%s\n", str);
>  }
>
>  void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src)
> diff --git a/platform/linux-generic/odp_buffer_pool.c
> b/platform/linux-generic/odp_buffer_pool.c
> index a48d7d6..6a0a6b2 100644
> --- a/platform/linux-generic/odp_buffer_pool.c
> +++ b/platform/linux-generic/odp_buffer_pool.c
> @@ -523,20 +523,20 @@ void odp_buffer_pool_print(odp_buffer_pool_t
> pool_hdl)
>         pool_id = pool_handle_to_index(pool_hdl);
>         pool    = get_pool_entry(pool_id);
>
> -       printf("Pool info\n");
> -       printf("---------\n");
> -       printf("  pool          %i\n",           pool->s.pool_hdl);
> -       printf("  name          %s\n",           pool->s.name);
> -       printf("  pool base     %p\n",           pool->s.pool_base_addr);
> -       printf("  buf base      0x%"PRIxPTR"\n", pool->s.buf_base);
> -       printf("  pool size     0x%"PRIx64"\n",  pool->s.pool_size);
> -       printf("  buf size      %zu\n",          pool->s.user_size);
> -       printf("  buf align     %zu\n",          pool->s.user_align);
> -       printf("  hdr size      %zu\n",          pool->s.hdr_size);
> -       printf("  alloc size    %zu\n",          pool->s.buf_size);
> -       printf("  offset to hdr %zu\n",          pool->s.buf_offset);
> -       printf("  num bufs      %"PRIu64"\n",    pool->s.num_bufs);
> -       printf("  free bufs     %"PRIu64"\n",    pool->s.free_bufs);
> +       ODP_PRINT("Pool info\n");
> +       ODP_PRINT("---------\n");
> +       ODP_PRINT("  pool          %i\n",           pool->s.pool_hdl);
> +       ODP_PRINT("  name          %s\n",           pool->s.name);
> +       ODP_PRINT("  pool base     %p\n",
>  pool->s.pool_base_addr);
> +       ODP_PRINT("  buf base      0x%"PRIxPTR"\n", pool->s.buf_base);
> +       ODP_PRINT("  pool size     0x%"PRIx64"\n",  pool->s.pool_size);
> +       ODP_PRINT("  buf size      %zu\n",          pool->s.user_size);
> +       ODP_PRINT("  buf align     %zu\n",          pool->s.user_align);
> +       ODP_PRINT("  hdr size      %zu\n",          pool->s.hdr_size);
> +       ODP_PRINT("  alloc size    %zu\n",          pool->s.buf_size);
> +       ODP_PRINT("  offset to hdr %zu\n",          pool->s.buf_offset);
> +       ODP_PRINT("  num bufs      %"PRIu64"\n",    pool->s.num_bufs);
> +       ODP_PRINT("  free bufs     %"PRIu64"\n",    pool->s.free_bufs);
>
>         /* first chunk */
>         chunk_hdr = pool->s.head;
> @@ -546,7 +546,7 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>                 return;
>         }
>
> -       printf("\n  First chunk\n");
> +       ODP_PRINT("\n  First chunk\n");
>
>         for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>                 uint32_t index;
> @@ -555,20 +555,21 @@ void odp_buffer_pool_print(odp_buffer_pool_t
> pool_hdl)
>                 index = chunk_hdr->chunk.buf_index[i];
>                 hdr   = index_to_hdr(pool, index);
>
> -               printf("  [%i] addr %p, id %"PRIu32"\n", i, hdr->addr,
> index);
> +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i, hdr->addr,
> +                         index);
>         }
>
> -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
> chunk_hdr->buf_hdr.addr,
> -              chunk_hdr->buf_hdr.index);
> +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
> chunk_hdr->buf_hdr.addr,
> +                 chunk_hdr->buf_hdr.index);
>
>         /* next chunk */
>         chunk_hdr = next_chunk(pool, chunk_hdr);
>
>         if (chunk_hdr) {
> -               printf("  Next chunk\n");
> -               printf("  addr %p, id %"PRIu32"\n",
> chunk_hdr->buf_hdr.addr,
> -                      chunk_hdr->buf_hdr.index);
> +               ODP_PRINT("  Next chunk\n");
> +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
> chunk_hdr->buf_hdr.addr,
> +                         chunk_hdr->buf_hdr.index);
>         }
>
> -       printf("\n");
> +       ODP_PRINT("\n");
>  }
> diff --git a/platform/linux-generic/odp_packet.c
> b/platform/linux-generic/odp_packet.c
> index 82ea879..a574de1 100644
> --- a/platform/linux-generic/odp_packet.c
> +++ b/platform/linux-generic/odp_packet.c
> @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>                         "  input        %u\n", hdr->input);
>         str[len] = '\0';
>
> -       printf("\n%s\n", str);
> +       ODP_PRINT("\n%s\n", str);
>  }
>
>  int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
> diff --git a/platform/linux-generic/odp_shared_memory.c
> b/platform/linux-generic/odp_shared_memory.c
> index 24a5d60..9d3e4cb 100644
> --- a/platform/linux-generic/odp_shared_memory.c
> +++ b/platform/linux-generic/odp_shared_memory.c
> @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>  {
>         int i;
>
> -       printf("\nShared memory\n");
> -       printf("--------------\n");
> -       printf("  page size:      %"PRIu64" kB\n", odp_sys_page_size() /
> 1024);
> -       printf("  huge page size: %"PRIu64" kB\n",
> -              odp_sys_huge_page_size() / 1024);
> -       printf("\n");
> +       ODP_PRINT("\nShared memory\n");
> +       ODP_PRINT("--------------\n");
> +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
> +                 odp_sys_page_size() / 1024);
> +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
> +                 odp_sys_huge_page_size() / 1024);
> +       ODP_PRINT("\n");
>
> -       printf("  id name                       kB align huge addr\n");
> +       ODP_PRINT("  id name                       kB align huge addr\n");
>
>         for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>                 odp_shm_block_t *block;
> @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>                 block = &odp_shm_tbl->block[i];
>
>                 if (block->addr) {
> -                       printf("  %2i %-24s %4"PRIu64"  %4"PRIu64" %2c
>  %p\n",
> -                              i,
> -                              block->name,
> -                              block->size/1024,
> -                              block->align,
> -                              (block->huge ? '*' : ' '),
> -                              block->addr);
> +                       ODP_PRINT("  %2i %-24s %4"PRIu64"  %4"PRIu64
> +                                 " %2c   %p\n",
> +                                 i,
> +                                 block->name,
> +                                 block->size/1024,
> +                                 block->align,
> +                                 (block->huge ? '*' : ' '),
> +                                 block->addr);
>                 }
>         }
>
> -       printf("\n");
> +       ODP_PRINT("\n");
>  }
> --
> 2.1.0
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Mike Holmes Nov. 20, 2014, 10:31 p.m. UTC | #2
ping any other comments ?

On 19 November 2014 19:31, Bill Fischofer <bill.fischofer@linaro.org> wrote:

>
>
> On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes <mike.holmes@linaro.org>
> wrote:
>
>> Current ODP APIs that print internal data on demand for the application
>> do so
>> via printf.
>>
>> Introduce ODP_PRI so that APIs that produce output may be channeled though
>> ODP_LOG to match the other logging types.
>>
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>>
>
> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
>
>
>> ---
>>  platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>>  platform/linux-generic/odp_buffer.c            |  4 +--
>>  platform/linux-generic/odp_buffer_pool.c       | 45
>> +++++++++++++-------------
>>  platform/linux-generic/odp_packet.c            |  2 +-
>>  platform/linux-generic/odp_shared_memory.c     | 32 +++++++++---------
>>  5 files changed, 56 insertions(+), 41 deletions(-)
>>
>> diff --git a/platform/linux-generic/include/api/odp_debug.h
>> b/platform/linux-generic/include/api/odp_debug.h
>> index c9b2edd..5c3adde 100644
>> --- a/platform/linux-generic/include/api/odp_debug.h
>> +++ b/platform/linux-generic/include/api/odp_debug.h
>> @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>>         ODP_LOG_DBG,
>>         ODP_LOG_ERR,
>>         ODP_LOG_UNIMPLEMENTED,
>> -       ODP_LOG_ABORT
>> +       ODP_LOG_ABORT,
>> +       ODP_LOG_PRINT
>>  } odp_log_level_e;
>>
>>  /**
>> @@ -94,6 +95,10 @@ do { \
>>                         fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
>>                         __LINE__, __func__, ##__VA_ARGS__); \
>>                 break; \
>> +       case ODP_LOG_PRINT: \
>> +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
>> +               __LINE__, __func__, ##__VA_ARGS__); \
>> +               break; \
>>         case ODP_LOG_ABORT: \
>>                 fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>>                 __LINE__, __func__, ##__VA_ARGS__); \
>> @@ -111,6 +116,13 @@ do { \
>>  } while (0)
>>
>>  /**
>> + * Printing macro, which prints output when the application
>> + * calls one of the ODP APIs specifically for dumping internal data.
>> + */
>> +#define ODP_PRINT(fmt, ...) \
>> +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
>> +
>> +/**
>>   * Debug printing macro, which prints output when DEBUG flag is set.
>>   */
>>  #define ODP_DBG(fmt, ...) \
>> diff --git a/platform/linux-generic/odp_buffer.c
>> b/platform/linux-generic/odp_buffer.c
>> index e54e0e7..d9e211b 100644
>> --- a/platform/linux-generic/odp_buffer.c
>> +++ b/platform/linux-generic/odp_buffer.c
>> @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n,
>> odp_buffer_t buf)
>>         int len = 0;
>>
>>         if (!odp_buffer_is_valid(buf)) {
>> -               printf("Buffer is not valid.\n");
>> +               ODP_PRINT("Buffer is not valid.\n");
>>                 return len;
>>         }
>>
>> @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>>         len = odp_buffer_snprint(str, max_len-1, buf);
>>         str[len] = 0;
>>
>> -       printf("\n%s\n", str);
>> +       ODP_PRINT("\n%s\n", str);
>>  }
>>
>>  void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src)
>> diff --git a/platform/linux-generic/odp_buffer_pool.c
>> b/platform/linux-generic/odp_buffer_pool.c
>> index a48d7d6..6a0a6b2 100644
>> --- a/platform/linux-generic/odp_buffer_pool.c
>> +++ b/platform/linux-generic/odp_buffer_pool.c
>> @@ -523,20 +523,20 @@ void odp_buffer_pool_print(odp_buffer_pool_t
>> pool_hdl)
>>         pool_id = pool_handle_to_index(pool_hdl);
>>         pool    = get_pool_entry(pool_id);
>>
>> -       printf("Pool info\n");
>> -       printf("---------\n");
>> -       printf("  pool          %i\n",           pool->s.pool_hdl);
>> -       printf("  name          %s\n",           pool->s.name);
>> -       printf("  pool base     %p\n",           pool->s.pool_base_addr);
>> -       printf("  buf base      0x%"PRIxPTR"\n", pool->s.buf_base);
>> -       printf("  pool size     0x%"PRIx64"\n",  pool->s.pool_size);
>> -       printf("  buf size      %zu\n",          pool->s.user_size);
>> -       printf("  buf align     %zu\n",          pool->s.user_align);
>> -       printf("  hdr size      %zu\n",          pool->s.hdr_size);
>> -       printf("  alloc size    %zu\n",          pool->s.buf_size);
>> -       printf("  offset to hdr %zu\n",          pool->s.buf_offset);
>> -       printf("  num bufs      %"PRIu64"\n",    pool->s.num_bufs);
>> -       printf("  free bufs     %"PRIu64"\n",    pool->s.free_bufs);
>> +       ODP_PRINT("Pool info\n");
>> +       ODP_PRINT("---------\n");
>> +       ODP_PRINT("  pool          %i\n",           pool->s.pool_hdl);
>> +       ODP_PRINT("  name          %s\n",           pool->s.name);
>> +       ODP_PRINT("  pool base     %p\n",
>>  pool->s.pool_base_addr);
>> +       ODP_PRINT("  buf base      0x%"PRIxPTR"\n", pool->s.buf_base);
>> +       ODP_PRINT("  pool size     0x%"PRIx64"\n",  pool->s.pool_size);
>> +       ODP_PRINT("  buf size      %zu\n",          pool->s.user_size);
>> +       ODP_PRINT("  buf align     %zu\n",          pool->s.user_align);
>> +       ODP_PRINT("  hdr size      %zu\n",          pool->s.hdr_size);
>> +       ODP_PRINT("  alloc size    %zu\n",          pool->s.buf_size);
>> +       ODP_PRINT("  offset to hdr %zu\n",          pool->s.buf_offset);
>> +       ODP_PRINT("  num bufs      %"PRIu64"\n",    pool->s.num_bufs);
>> +       ODP_PRINT("  free bufs     %"PRIu64"\n",    pool->s.free_bufs);
>>
>>         /* first chunk */
>>         chunk_hdr = pool->s.head;
>> @@ -546,7 +546,7 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>                 return;
>>         }
>>
>> -       printf("\n  First chunk\n");
>> +       ODP_PRINT("\n  First chunk\n");
>>
>>         for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>>                 uint32_t index;
>> @@ -555,20 +555,21 @@ void odp_buffer_pool_print(odp_buffer_pool_t
>> pool_hdl)
>>                 index = chunk_hdr->chunk.buf_index[i];
>>                 hdr   = index_to_hdr(pool, index);
>>
>> -               printf("  [%i] addr %p, id %"PRIu32"\n", i, hdr->addr,
>> index);
>> +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i, hdr->addr,
>> +                         index);
>>         }
>>
>> -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
>> chunk_hdr->buf_hdr.addr,
>> -              chunk_hdr->buf_hdr.index);
>> +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>> chunk_hdr->buf_hdr.addr,
>> +                 chunk_hdr->buf_hdr.index);
>>
>>         /* next chunk */
>>         chunk_hdr = next_chunk(pool, chunk_hdr);
>>
>>         if (chunk_hdr) {
>> -               printf("  Next chunk\n");
>> -               printf("  addr %p, id %"PRIu32"\n",
>> chunk_hdr->buf_hdr.addr,
>> -                      chunk_hdr->buf_hdr.index);
>> +               ODP_PRINT("  Next chunk\n");
>> +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
>> chunk_hdr->buf_hdr.addr,
>> +                         chunk_hdr->buf_hdr.index);
>>         }
>>
>> -       printf("\n");
>> +       ODP_PRINT("\n");
>>  }
>> diff --git a/platform/linux-generic/odp_packet.c
>> b/platform/linux-generic/odp_packet.c
>> index 82ea879..a574de1 100644
>> --- a/platform/linux-generic/odp_packet.c
>> +++ b/platform/linux-generic/odp_packet.c
>> @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>>                         "  input        %u\n", hdr->input);
>>         str[len] = '\0';
>>
>> -       printf("\n%s\n", str);
>> +       ODP_PRINT("\n%s\n", str);
>>  }
>>
>>  int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
>> diff --git a/platform/linux-generic/odp_shared_memory.c
>> b/platform/linux-generic/odp_shared_memory.c
>> index 24a5d60..9d3e4cb 100644
>> --- a/platform/linux-generic/odp_shared_memory.c
>> +++ b/platform/linux-generic/odp_shared_memory.c
>> @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>>  {
>>         int i;
>>
>> -       printf("\nShared memory\n");
>> -       printf("--------------\n");
>> -       printf("  page size:      %"PRIu64" kB\n", odp_sys_page_size() /
>> 1024);
>> -       printf("  huge page size: %"PRIu64" kB\n",
>> -              odp_sys_huge_page_size() / 1024);
>> -       printf("\n");
>> +       ODP_PRINT("\nShared memory\n");
>> +       ODP_PRINT("--------------\n");
>> +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
>> +                 odp_sys_page_size() / 1024);
>> +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
>> +                 odp_sys_huge_page_size() / 1024);
>> +       ODP_PRINT("\n");
>>
>> -       printf("  id name                       kB align huge addr\n");
>> +       ODP_PRINT("  id name                       kB align huge addr\n");
>>
>>         for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>>                 odp_shm_block_t *block;
>> @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>>                 block = &odp_shm_tbl->block[i];
>>
>>                 if (block->addr) {
>> -                       printf("  %2i %-24s %4"PRIu64"  %4"PRIu64" %2c
>>  %p\n",
>> -                              i,
>> -                              block->name,
>> -                              block->size/1024,
>> -                              block->align,
>> -                              (block->huge ? '*' : ' '),
>> -                              block->addr);
>> +                       ODP_PRINT("  %2i %-24s %4"PRIu64"  %4"PRIu64
>> +                                 " %2c   %p\n",
>> +                                 i,
>> +                                 block->name,
>> +                                 block->size/1024,
>> +                                 block->align,
>> +                                 (block->huge ? '*' : ' '),
>> +                                 block->addr);
>>                 }
>>         }
>>
>> -       printf("\n");
>> +       ODP_PRINT("\n");
>>  }
>> --
>> 2.1.0
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
Maxim Uvarov Nov. 21, 2014, 12:02 p.m. UTC | #3
Merged.

I think later we need some doc to structure all LOG, PRINT and ABORT 
functions with levels of usage.
Might be force doxygen to generate separate page for that functions.

Maxim.

On 11/21/2014 01:31 AM, Mike Holmes wrote:
> ping any other comments ?
>
> On 19 November 2014 19:31, Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>> wrote:
>
>
>
>     On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes
>     <mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>> wrote:
>
>         Current ODP APIs that print internal data on demand for the
>         application do so
>         via printf.
>
>         Introduce ODP_PRI so that APIs that produce output may be
>         channeled though
>         ODP_LOG to match the other logging types.
>
>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>         <mailto:mike.holmes@linaro.org>>
>
>
>     Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org
>     <mailto:bill.fischofer@linaro.org>>
>
>         ---
>          platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>          platform/linux-generic/odp_buffer.c |  4 +--
>          platform/linux-generic/odp_buffer_pool.c  | 45
>         +++++++++++++-------------
>          platform/linux-generic/odp_packet.c |  2 +-
>          platform/linux-generic/odp_shared_memory.c  | 32
>         +++++++++---------
>          5 files changed, 56 insertions(+), 41 deletions(-)
>
>         diff --git a/platform/linux-generic/include/api/odp_debug.h
>         b/platform/linux-generic/include/api/odp_debug.h
>         index c9b2edd..5c3adde 100644
>         --- a/platform/linux-generic/include/api/odp_debug.h
>         +++ b/platform/linux-generic/include/api/odp_debug.h
>         @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>                 ODP_LOG_DBG,
>                 ODP_LOG_ERR,
>                 ODP_LOG_UNIMPLEMENTED,
>         -       ODP_LOG_ABORT
>         +       ODP_LOG_ABORT,
>         +       ODP_LOG_PRINT
>          } odp_log_level_e;
>
>          /**
>         @@ -94,6 +95,10 @@ do { \
>                                 fprintf(stderr, "%s:%d:%s():" fmt,
>         __FILE__, \
>                                 __LINE__, __func__, ##__VA_ARGS__); \
>                         break; \
>         +       case ODP_LOG_PRINT: \
>         +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
>         +               __LINE__, __func__, ##__VA_ARGS__); \
>         +               break; \
>                 case ODP_LOG_ABORT: \
>                         fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>                         __LINE__, __func__, ##__VA_ARGS__); \
>         @@ -111,6 +116,13 @@ do { \
>          } while (0)
>
>          /**
>         + * Printing macro, which prints output when the application
>         + * calls one of the ODP APIs specifically for dumping
>         internal data.
>         + */
>         +#define ODP_PRINT(fmt, ...) \
>         +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
>         +
>         +/**
>           * Debug printing macro, which prints output when DEBUG flag
>         is set.
>           */
>          #define ODP_DBG(fmt, ...) \
>         diff --git a/platform/linux-generic/odp_buffer.c
>         b/platform/linux-generic/odp_buffer.c
>         index e54e0e7..d9e211b 100644
>         --- a/platform/linux-generic/odp_buffer.c
>         +++ b/platform/linux-generic/odp_buffer.c
>         @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n,
>         odp_buffer_t buf)
>                 int len = 0;
>
>                 if (!odp_buffer_is_valid(buf)) {
>         -               printf("Buffer is not valid.\n");
>         +               ODP_PRINT("Buffer is not valid.\n");
>                         return len;
>                 }
>
>         @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>                 len = odp_buffer_snprint(str, max_len-1, buf);
>                 str[len] = 0;
>
>         -       printf("\n%s\n", str);
>         +       ODP_PRINT("\n%s\n", str);
>          }
>
>          void odp_buffer_copy_scatter(odp_buffer_t buf_dst,
>         odp_buffer_t buf_src)
>         diff --git a/platform/linux-generic/odp_buffer_pool.c
>         b/platform/linux-generic/odp_buffer_pool.c
>         index a48d7d6..6a0a6b2 100644
>         --- a/platform/linux-generic/odp_buffer_pool.c
>         +++ b/platform/linux-generic/odp_buffer_pool.c
>         @@ -523,20 +523,20 @@ void
>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>                 pool_id = pool_handle_to_index(pool_hdl);
>                 pool    = get_pool_entry(pool_id);
>
>         -       printf("Pool info\n");
>         -       printf("---------\n");
>         -       printf("  pool          %i\n",  pool->s.pool_hdl);
>         -       printf("  name          %s\n",  pool->s.name
>         <http://s.name>);
>         -       printf("  pool base     %p\n",  pool->s.pool_base_addr);
>         -       printf("  buf base      0x%"PRIxPTR"\n",
>         pool->s.buf_base);
>         -       printf("  pool size     0x%"PRIx64"\n",
>         pool->s.pool_size);
>         -       printf("  buf size      %zu\n", pool->s.user_size);
>         -       printf("  buf align     %zu\n", pool->s.user_align);
>         -       printf("  hdr size      %zu\n", pool->s.hdr_size);
>         -       printf("  alloc size    %zu\n", pool->s.buf_size);
>         -       printf("  offset to hdr %zu\n", pool->s.buf_offset);
>         -       printf("  num bufs      %"PRIu64"\n", pool->s.num_bufs);
>         -       printf("  free bufs     %"PRIu64"\n", pool->s.free_bufs);
>         +       ODP_PRINT("Pool info\n");
>         +       ODP_PRINT("---------\n");
>         +       ODP_PRINT("  pool          %i\n",    pool->s.pool_hdl);
>         +       ODP_PRINT("  name          %s\n",    pool->s.name
>         <http://s.name>);
>         +       ODP_PRINT("  pool base     %p\n",  
>          pool->s.pool_base_addr);
>         +       ODP_PRINT("  buf base 0x%"PRIxPTR"\n", pool->s.buf_base);
>         +       ODP_PRINT("  pool size  0x%"PRIx64"\n", 
>         pool->s.pool_size);
>         +       ODP_PRINT("  buf size      %zu\n",     pool->s.user_size);
>         +       ODP_PRINT("  buf align     %zu\n",    
>         pool->s.user_align);
>         +       ODP_PRINT("  hdr size      %zu\n",     pool->s.hdr_size);
>         +       ODP_PRINT("  alloc size    %zu\n",     pool->s.buf_size);
>         +       ODP_PRINT("  offset to hdr %zu\n",    
>         pool->s.buf_offset);
>         +       ODP_PRINT("  num bufs %"PRIu64"\n",    pool->s.num_bufs);
>         +       ODP_PRINT("  free bufs  %"PRIu64"\n",   
>         pool->s.free_bufs);
>
>                 /* first chunk */
>                 chunk_hdr = pool->s.head;
>         @@ -546,7 +546,7 @@ void
>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>                         return;
>                 }
>
>         -       printf("\n  First chunk\n");
>         +       ODP_PRINT("\n  First chunk\n");
>
>                 for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>                         uint32_t index;
>         @@ -555,20 +555,21 @@ void
>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>                         index = chunk_hdr->chunk.buf_index[i];
>                         hdr   = index_to_hdr(pool, index);
>
>         -               printf("  [%i] addr %p, id %"PRIu32"\n", i,
>         hdr->addr, index);
>         +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>         hdr->addr,
>         +                         index);
>                 }
>
>         -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
>         chunk_hdr->buf_hdr.addr,
>         -              chunk_hdr->buf_hdr.index);
>         +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>         chunk_hdr->buf_hdr.addr,
>         +                 chunk_hdr->buf_hdr.index);
>
>                 /* next chunk */
>                 chunk_hdr = next_chunk(pool, chunk_hdr);
>
>                 if (chunk_hdr) {
>         -               printf("  Next chunk\n");
>         -               printf("  addr %p, id %"PRIu32"\n",
>         chunk_hdr->buf_hdr.addr,
>         - chunk_hdr->buf_hdr.index);
>         +               ODP_PRINT("  Next chunk\n");
>         +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
>         chunk_hdr->buf_hdr.addr,
>         +  chunk_hdr->buf_hdr.index);
>                 }
>
>         -       printf("\n");
>         +       ODP_PRINT("\n");
>          }
>         diff --git a/platform/linux-generic/odp_packet.c
>         b/platform/linux-generic/odp_packet.c
>         index 82ea879..a574de1 100644
>         --- a/platform/linux-generic/odp_packet.c
>         +++ b/platform/linux-generic/odp_packet.c
>         @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>                                 "  input        %u\n", hdr->input);
>                 str[len] = '\0';
>
>         -       printf("\n%s\n", str);
>         +       ODP_PRINT("\n%s\n", str);
>          }
>
>          int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
>         diff --git a/platform/linux-generic/odp_shared_memory.c
>         b/platform/linux-generic/odp_shared_memory.c
>         index 24a5d60..9d3e4cb 100644
>         --- a/platform/linux-generic/odp_shared_memory.c
>         +++ b/platform/linux-generic/odp_shared_memory.c
>         @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>          {
>                 int i;
>
>         -       printf("\nShared memory\n");
>         -       printf("--------------\n");
>         -       printf("  page size:      %"PRIu64" kB\n",
>         odp_sys_page_size() / 1024);
>         -       printf("  huge page size: %"PRIu64" kB\n",
>         -              odp_sys_huge_page_size() / 1024);
>         -       printf("\n");
>         +       ODP_PRINT("\nShared memory\n");
>         +       ODP_PRINT("--------------\n");
>         +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
>         +                 odp_sys_page_size() / 1024);
>         +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
>         +                 odp_sys_huge_page_size() / 1024);
>         +       ODP_PRINT("\n");
>
>         -       printf("  id name  kB align huge addr\n");
>         +       ODP_PRINT("  id name    kB align huge addr\n");
>
>                 for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>                         odp_shm_block_t *block;
>         @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>                         block = &odp_shm_tbl->block[i];
>
>                         if (block->addr) {
>         -                       printf("  %2i %-24s %4"PRIu64" 
>         %4"PRIu64" %2c   %p\n",
>         -                              i,
>         -                              block->name,
>         - block->size/1024,
>         -                              block->align,
>         -                              (block->huge ? '*' : ' '),
>         -                              block->addr);
>         +                       ODP_PRINT("  %2i %-24s %4"PRIu64" 
>         %4"PRIu64
>         +                                 " %2c   %p\n",
>         +                                 i,
>         +  block->name,
>         +  block->size/1024,
>         +  block->align,
>         +  (block->huge ? '*' : ' '),
>         +  block->addr);
>                         }
>                 }
>
>         -       printf("\n");
>         +       ODP_PRINT("\n");
>          }
>         --
>         2.1.0
>
>
>         _______________________________________________
>         lng-odp mailing list
>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>         http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
>
> -- 
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Mike Holmes Nov. 21, 2014, 1:16 p.m. UTC | #4
On 21 November 2014 07:02, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Merged.
>
> I think later we need some doc to structure all LOG, PRINT and ABORT
> functions with levels of usage.
> Might be force doxygen to generate separate page for that functions.
>

I agree, I think this is just one case of the larger issue of poor
documentation.

When we have to completed the code coverage effort, then we need a second
pass.

We have to look at the linux-generic implementation and accurately document
its behaviour and specifically and not just say 0 on success -1 on failure.
One we have an updated the doc, we need to improve the tests to ensure they
behave as described.



>
> Maxim.
>
> On 11/21/2014 01:31 AM, Mike Holmes wrote:
>
>> ping any other comments ?
>>
>> On 19 November 2014 19:31, Bill Fischofer <bill.fischofer@linaro.org
>> <mailto:bill.fischofer@linaro.org>> wrote:
>>
>>
>>
>>     On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes
>>     <mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>> wrote:
>>
>>         Current ODP APIs that print internal data on demand for the
>>         application do so
>>         via printf.
>>
>>         Introduce ODP_PRI so that APIs that produce output may be
>>         channeled though
>>         ODP_LOG to match the other logging types.
>>
>>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>>         <mailto:mike.holmes@linaro.org>>
>>
>>
>>     Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org
>>     <mailto:bill.fischofer@linaro.org>>
>>
>>
>>         ---
>>          platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>>          platform/linux-generic/odp_buffer.c |  4 +--
>>          platform/linux-generic/odp_buffer_pool.c  | 45
>>         +++++++++++++-------------
>>          platform/linux-generic/odp_packet.c |  2 +-
>>          platform/linux-generic/odp_shared_memory.c  | 32
>>         +++++++++---------
>>          5 files changed, 56 insertions(+), 41 deletions(-)
>>
>>         diff --git a/platform/linux-generic/include/api/odp_debug.h
>>         b/platform/linux-generic/include/api/odp_debug.h
>>         index c9b2edd..5c3adde 100644
>>         --- a/platform/linux-generic/include/api/odp_debug.h
>>         +++ b/platform/linux-generic/include/api/odp_debug.h
>>         @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>>                 ODP_LOG_DBG,
>>                 ODP_LOG_ERR,
>>                 ODP_LOG_UNIMPLEMENTED,
>>         -       ODP_LOG_ABORT
>>         +       ODP_LOG_ABORT,
>>         +       ODP_LOG_PRINT
>>          } odp_log_level_e;
>>
>>          /**
>>         @@ -94,6 +95,10 @@ do { \
>>                                 fprintf(stderr, "%s:%d:%s():" fmt,
>>         __FILE__, \
>>                                 __LINE__, __func__, ##__VA_ARGS__); \
>>                         break; \
>>         +       case ODP_LOG_PRINT: \
>>         +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
>>         +               __LINE__, __func__, ##__VA_ARGS__); \
>>         +               break; \
>>                 case ODP_LOG_ABORT: \
>>                         fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>>                         __LINE__, __func__, ##__VA_ARGS__); \
>>         @@ -111,6 +116,13 @@ do { \
>>          } while (0)
>>
>>          /**
>>         + * Printing macro, which prints output when the application
>>         + * calls one of the ODP APIs specifically for dumping
>>         internal data.
>>         + */
>>         +#define ODP_PRINT(fmt, ...) \
>>         +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
>>         +
>>         +/**
>>           * Debug printing macro, which prints output when DEBUG flag
>>         is set.
>>           */
>>          #define ODP_DBG(fmt, ...) \
>>         diff --git a/platform/linux-generic/odp_buffer.c
>>         b/platform/linux-generic/odp_buffer.c
>>         index e54e0e7..d9e211b 100644
>>         --- a/platform/linux-generic/odp_buffer.c
>>         +++ b/platform/linux-generic/odp_buffer.c
>>         @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n,
>>         odp_buffer_t buf)
>>                 int len = 0;
>>
>>                 if (!odp_buffer_is_valid(buf)) {
>>         -               printf("Buffer is not valid.\n");
>>         +               ODP_PRINT("Buffer is not valid.\n");
>>                         return len;
>>                 }
>>
>>         @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>>                 len = odp_buffer_snprint(str, max_len-1, buf);
>>                 str[len] = 0;
>>
>>         -       printf("\n%s\n", str);
>>         +       ODP_PRINT("\n%s\n", str);
>>          }
>>
>>          void odp_buffer_copy_scatter(odp_buffer_t buf_dst,
>>         odp_buffer_t buf_src)
>>         diff --git a/platform/linux-generic/odp_buffer_pool.c
>>         b/platform/linux-generic/odp_buffer_pool.c
>>         index a48d7d6..6a0a6b2 100644
>>         --- a/platform/linux-generic/odp_buffer_pool.c
>>         +++ b/platform/linux-generic/odp_buffer_pool.c
>>         @@ -523,20 +523,20 @@ void
>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>                 pool_id = pool_handle_to_index(pool_hdl);
>>                 pool    = get_pool_entry(pool_id);
>>
>>         -       printf("Pool info\n");
>>         -       printf("---------\n");
>>         -       printf("  pool          %i\n",  pool->s.pool_hdl);
>>         -       printf("  name          %s\n",  pool->s.name
>>         <http://s.name>);
>>         -       printf("  pool base     %p\n",  pool->s.pool_base_addr);
>>         -       printf("  buf base      0x%"PRIxPTR"\n",
>>         pool->s.buf_base);
>>         -       printf("  pool size     0x%"PRIx64"\n",
>>         pool->s.pool_size);
>>         -       printf("  buf size      %zu\n", pool->s.user_size);
>>         -       printf("  buf align     %zu\n", pool->s.user_align);
>>         -       printf("  hdr size      %zu\n", pool->s.hdr_size);
>>         -       printf("  alloc size    %zu\n", pool->s.buf_size);
>>         -       printf("  offset to hdr %zu\n", pool->s.buf_offset);
>>         -       printf("  num bufs      %"PRIu64"\n", pool->s.num_bufs);
>>         -       printf("  free bufs     %"PRIu64"\n", pool->s.free_bufs);
>>         +       ODP_PRINT("Pool info\n");
>>         +       ODP_PRINT("---------\n");
>>         +       ODP_PRINT("  pool          %i\n",    pool->s.pool_hdl);
>>         +       ODP_PRINT("  name          %s\n",    pool->s.name
>>         <http://s.name>);
>>
>>         +       ODP_PRINT("  pool base     %p\n",
>>  pool->s.pool_base_addr);
>>         +       ODP_PRINT("  buf base 0x%"PRIxPTR"\n", pool->s.buf_base);
>>         +       ODP_PRINT("  pool size  0x%"PRIx64"\n",
>>  pool->s.pool_size);
>>         +       ODP_PRINT("  buf size      %zu\n",     pool->s.user_size);
>>         +       ODP_PRINT("  buf align     %zu\n",
>> pool->s.user_align);
>>         +       ODP_PRINT("  hdr size      %zu\n",     pool->s.hdr_size);
>>         +       ODP_PRINT("  alloc size    %zu\n",     pool->s.buf_size);
>>         +       ODP_PRINT("  offset to hdr %zu\n",
>> pool->s.buf_offset);
>>         +       ODP_PRINT("  num bufs %"PRIu64"\n",    pool->s.num_bufs);
>>         +       ODP_PRINT("  free bufs  %"PRIu64"\n",
>>  pool->s.free_bufs);
>>
>>                 /* first chunk */
>>                 chunk_hdr = pool->s.head;
>>         @@ -546,7 +546,7 @@ void
>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>                         return;
>>                 }
>>
>>         -       printf("\n  First chunk\n");
>>         +       ODP_PRINT("\n  First chunk\n");
>>
>>                 for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>>                         uint32_t index;
>>         @@ -555,20 +555,21 @@ void
>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>                         index = chunk_hdr->chunk.buf_index[i];
>>                         hdr   = index_to_hdr(pool, index);
>>
>>         -               printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>         hdr->addr, index);
>>         +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>         hdr->addr,
>>         +                         index);
>>                 }
>>
>>         -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>         chunk_hdr->buf_hdr.addr,
>>         -              chunk_hdr->buf_hdr.index);
>>         +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>         chunk_hdr->buf_hdr.addr,
>>         +                 chunk_hdr->buf_hdr.index);
>>
>>                 /* next chunk */
>>                 chunk_hdr = next_chunk(pool, chunk_hdr);
>>
>>                 if (chunk_hdr) {
>>         -               printf("  Next chunk\n");
>>         -               printf("  addr %p, id %"PRIu32"\n",
>>         chunk_hdr->buf_hdr.addr,
>>         - chunk_hdr->buf_hdr.index);
>>         +               ODP_PRINT("  Next chunk\n");
>>         +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
>>         chunk_hdr->buf_hdr.addr,
>>         +  chunk_hdr->buf_hdr.index);
>>                 }
>>
>>         -       printf("\n");
>>         +       ODP_PRINT("\n");
>>          }
>>         diff --git a/platform/linux-generic/odp_packet.c
>>         b/platform/linux-generic/odp_packet.c
>>         index 82ea879..a574de1 100644
>>         --- a/platform/linux-generic/odp_packet.c
>>         +++ b/platform/linux-generic/odp_packet.c
>>         @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>>                                 "  input        %u\n", hdr->input);
>>                 str[len] = '\0';
>>
>>         -       printf("\n%s\n", str);
>>         +       ODP_PRINT("\n%s\n", str);
>>          }
>>
>>          int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
>>         diff --git a/platform/linux-generic/odp_shared_memory.c
>>         b/platform/linux-generic/odp_shared_memory.c
>>         index 24a5d60..9d3e4cb 100644
>>         --- a/platform/linux-generic/odp_shared_memory.c
>>         +++ b/platform/linux-generic/odp_shared_memory.c
>>         @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>>          {
>>                 int i;
>>
>>         -       printf("\nShared memory\n");
>>         -       printf("--------------\n");
>>         -       printf("  page size:      %"PRIu64" kB\n",
>>         odp_sys_page_size() / 1024);
>>         -       printf("  huge page size: %"PRIu64" kB\n",
>>         -              odp_sys_huge_page_size() / 1024);
>>         -       printf("\n");
>>         +       ODP_PRINT("\nShared memory\n");
>>         +       ODP_PRINT("--------------\n");
>>         +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
>>         +                 odp_sys_page_size() / 1024);
>>         +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
>>         +                 odp_sys_huge_page_size() / 1024);
>>         +       ODP_PRINT("\n");
>>
>>         -       printf("  id name  kB align huge addr\n");
>>         +       ODP_PRINT("  id name    kB align huge addr\n");
>>
>>                 for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>>                         odp_shm_block_t *block;
>>         @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>>                         block = &odp_shm_tbl->block[i];
>>
>>                         if (block->addr) {
>>         -                       printf("  %2i %-24s %4"PRIu64"
>>  %4"PRIu64" %2c   %p\n",
>>         -                              i,
>>         -                              block->name,
>>         - block->size/1024,
>>         -                              block->align,
>>         -                              (block->huge ? '*' : ' '),
>>         -                              block->addr);
>>         +                       ODP_PRINT("  %2i %-24s %4"PRIu64"
>>  %4"PRIu64
>>         +                                 " %2c   %p\n",
>>         +                                 i,
>>         +  block->name,
>>         +  block->size/1024,
>>         +  block->align,
>>         +  (block->huge ? '*' : ' '),
>>         +  block->addr);
>>                         }
>>                 }
>>
>>         -       printf("\n");
>>         +       ODP_PRINT("\n");
>>          }
>>         --
>>         2.1.0
>>
>>
>>         _______________________________________________
>>         lng-odp mailing list
>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>
>>
>> --
>> *Mike Holmes*
>> Linaro  Sr Technical Manager
>> LNG - ODP
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Mike Holmes Nov. 22, 2014, 1:17 p.m. UTC | #5
ping can this go in ?
Once Taras has his weak override go in and all this moves to internal we
can fix the docs to suit.

On 21 November 2014 08:16, Mike Holmes <mike.holmes@linaro.org> wrote:

>
>
> On 21 November 2014 07:02, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>
>> Merged.
>>
>> I think later we need some doc to structure all LOG, PRINT and ABORT
>> functions with levels of usage.
>> Might be force doxygen to generate separate page for that functions.
>>
>
> I agree, I think this is just one case of the larger issue of poor
> documentation.
>
> When we have to completed the code coverage effort, then we need a second
> pass.
>
> We have to look at the linux-generic implementation and accurately
> document its behaviour and specifically and not just say 0 on success -1 on
> failure.
> One we have an updated the doc, we need to improve the tests to ensure
> they behave as described.
>
>
>
>>
>> Maxim.
>>
>> On 11/21/2014 01:31 AM, Mike Holmes wrote:
>>
>>> ping any other comments ?
>>>
>>> On 19 November 2014 19:31, Bill Fischofer <bill.fischofer@linaro.org
>>> <mailto:bill.fischofer@linaro.org>> wrote:
>>>
>>>
>>>
>>>     On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes
>>>     <mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>> wrote:
>>>
>>>         Current ODP APIs that print internal data on demand for the
>>>         application do so
>>>         via printf.
>>>
>>>         Introduce ODP_PRI so that APIs that produce output may be
>>>         channeled though
>>>         ODP_LOG to match the other logging types.
>>>
>>>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>>>         <mailto:mike.holmes@linaro.org>>
>>>
>>>
>>>     Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org
>>>     <mailto:bill.fischofer@linaro.org>>
>>>
>>>
>>>         ---
>>>          platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>>>          platform/linux-generic/odp_buffer.c |  4 +--
>>>          platform/linux-generic/odp_buffer_pool.c  | 45
>>>         +++++++++++++-------------
>>>          platform/linux-generic/odp_packet.c |  2 +-
>>>          platform/linux-generic/odp_shared_memory.c  | 32
>>>         +++++++++---------
>>>          5 files changed, 56 insertions(+), 41 deletions(-)
>>>
>>>         diff --git a/platform/linux-generic/include/api/odp_debug.h
>>>         b/platform/linux-generic/include/api/odp_debug.h
>>>         index c9b2edd..5c3adde 100644
>>>         --- a/platform/linux-generic/include/api/odp_debug.h
>>>         +++ b/platform/linux-generic/include/api/odp_debug.h
>>>         @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>>>                 ODP_LOG_DBG,
>>>                 ODP_LOG_ERR,
>>>                 ODP_LOG_UNIMPLEMENTED,
>>>         -       ODP_LOG_ABORT
>>>         +       ODP_LOG_ABORT,
>>>         +       ODP_LOG_PRINT
>>>          } odp_log_level_e;
>>>
>>>          /**
>>>         @@ -94,6 +95,10 @@ do { \
>>>                                 fprintf(stderr, "%s:%d:%s():" fmt,
>>>         __FILE__, \
>>>                                 __LINE__, __func__, ##__VA_ARGS__); \
>>>                         break; \
>>>         +       case ODP_LOG_PRINT: \
>>>         +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
>>>         +               __LINE__, __func__, ##__VA_ARGS__); \
>>>         +               break; \
>>>                 case ODP_LOG_ABORT: \
>>>                         fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>>>                         __LINE__, __func__, ##__VA_ARGS__); \
>>>         @@ -111,6 +116,13 @@ do { \
>>>          } while (0)
>>>
>>>          /**
>>>         + * Printing macro, which prints output when the application
>>>         + * calls one of the ODP APIs specifically for dumping
>>>         internal data.
>>>         + */
>>>         +#define ODP_PRINT(fmt, ...) \
>>>         +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
>>>         +
>>>         +/**
>>>           * Debug printing macro, which prints output when DEBUG flag
>>>         is set.
>>>           */
>>>          #define ODP_DBG(fmt, ...) \
>>>         diff --git a/platform/linux-generic/odp_buffer.c
>>>         b/platform/linux-generic/odp_buffer.c
>>>         index e54e0e7..d9e211b 100644
>>>         --- a/platform/linux-generic/odp_buffer.c
>>>         +++ b/platform/linux-generic/odp_buffer.c
>>>         @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n,
>>>         odp_buffer_t buf)
>>>                 int len = 0;
>>>
>>>                 if (!odp_buffer_is_valid(buf)) {
>>>         -               printf("Buffer is not valid.\n");
>>>         +               ODP_PRINT("Buffer is not valid.\n");
>>>                         return len;
>>>                 }
>>>
>>>         @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>>>                 len = odp_buffer_snprint(str, max_len-1, buf);
>>>                 str[len] = 0;
>>>
>>>         -       printf("\n%s\n", str);
>>>         +       ODP_PRINT("\n%s\n", str);
>>>          }
>>>
>>>          void odp_buffer_copy_scatter(odp_buffer_t buf_dst,
>>>         odp_buffer_t buf_src)
>>>         diff --git a/platform/linux-generic/odp_buffer_pool.c
>>>         b/platform/linux-generic/odp_buffer_pool.c
>>>         index a48d7d6..6a0a6b2 100644
>>>         --- a/platform/linux-generic/odp_buffer_pool.c
>>>         +++ b/platform/linux-generic/odp_buffer_pool.c
>>>         @@ -523,20 +523,20 @@ void
>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>                 pool_id = pool_handle_to_index(pool_hdl);
>>>                 pool    = get_pool_entry(pool_id);
>>>
>>>         -       printf("Pool info\n");
>>>         -       printf("---------\n");
>>>         -       printf("  pool          %i\n",  pool->s.pool_hdl);
>>>         -       printf("  name          %s\n",  pool->s.name
>>>         <http://s.name>);
>>>         -       printf("  pool base     %p\n",  pool->s.pool_base_addr);
>>>         -       printf("  buf base      0x%"PRIxPTR"\n",
>>>         pool->s.buf_base);
>>>         -       printf("  pool size     0x%"PRIx64"\n",
>>>         pool->s.pool_size);
>>>         -       printf("  buf size      %zu\n", pool->s.user_size);
>>>         -       printf("  buf align     %zu\n", pool->s.user_align);
>>>         -       printf("  hdr size      %zu\n", pool->s.hdr_size);
>>>         -       printf("  alloc size    %zu\n", pool->s.buf_size);
>>>         -       printf("  offset to hdr %zu\n", pool->s.buf_offset);
>>>         -       printf("  num bufs      %"PRIu64"\n", pool->s.num_bufs);
>>>         -       printf("  free bufs     %"PRIu64"\n", pool->s.free_bufs);
>>>         +       ODP_PRINT("Pool info\n");
>>>         +       ODP_PRINT("---------\n");
>>>         +       ODP_PRINT("  pool          %i\n",    pool->s.pool_hdl);
>>>         +       ODP_PRINT("  name          %s\n",    pool->s.name
>>>         <http://s.name>);
>>>
>>>         +       ODP_PRINT("  pool base     %p\n",
>>>  pool->s.pool_base_addr);
>>>         +       ODP_PRINT("  buf base 0x%"PRIxPTR"\n", pool->s.buf_base);
>>>         +       ODP_PRINT("  pool size  0x%"PRIx64"\n",
>>>  pool->s.pool_size);
>>>         +       ODP_PRINT("  buf size      %zu\n",
>>>  pool->s.user_size);
>>>         +       ODP_PRINT("  buf align     %zu\n",
>>> pool->s.user_align);
>>>         +       ODP_PRINT("  hdr size      %zu\n",     pool->s.hdr_size);
>>>         +       ODP_PRINT("  alloc size    %zu\n",     pool->s.buf_size);
>>>         +       ODP_PRINT("  offset to hdr %zu\n",
>>> pool->s.buf_offset);
>>>         +       ODP_PRINT("  num bufs %"PRIu64"\n",    pool->s.num_bufs);
>>>         +       ODP_PRINT("  free bufs  %"PRIu64"\n",
>>>  pool->s.free_bufs);
>>>
>>>                 /* first chunk */
>>>                 chunk_hdr = pool->s.head;
>>>         @@ -546,7 +546,7 @@ void
>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>                         return;
>>>                 }
>>>
>>>         -       printf("\n  First chunk\n");
>>>         +       ODP_PRINT("\n  First chunk\n");
>>>
>>>                 for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>>>                         uint32_t index;
>>>         @@ -555,20 +555,21 @@ void
>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>                         index = chunk_hdr->chunk.buf_index[i];
>>>                         hdr   = index_to_hdr(pool, index);
>>>
>>>         -               printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>>         hdr->addr, index);
>>>         +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>>         hdr->addr,
>>>         +                         index);
>>>                 }
>>>
>>>         -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>>         chunk_hdr->buf_hdr.addr,
>>>         -              chunk_hdr->buf_hdr.index);
>>>         +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>>         chunk_hdr->buf_hdr.addr,
>>>         +                 chunk_hdr->buf_hdr.index);
>>>
>>>                 /* next chunk */
>>>                 chunk_hdr = next_chunk(pool, chunk_hdr);
>>>
>>>                 if (chunk_hdr) {
>>>         -               printf("  Next chunk\n");
>>>         -               printf("  addr %p, id %"PRIu32"\n",
>>>         chunk_hdr->buf_hdr.addr,
>>>         - chunk_hdr->buf_hdr.index);
>>>         +               ODP_PRINT("  Next chunk\n");
>>>         +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
>>>         chunk_hdr->buf_hdr.addr,
>>>         +  chunk_hdr->buf_hdr.index);
>>>                 }
>>>
>>>         -       printf("\n");
>>>         +       ODP_PRINT("\n");
>>>          }
>>>         diff --git a/platform/linux-generic/odp_packet.c
>>>         b/platform/linux-generic/odp_packet.c
>>>         index 82ea879..a574de1 100644
>>>         --- a/platform/linux-generic/odp_packet.c
>>>         +++ b/platform/linux-generic/odp_packet.c
>>>         @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>>>                                 "  input        %u\n", hdr->input);
>>>                 str[len] = '\0';
>>>
>>>         -       printf("\n%s\n", str);
>>>         +       ODP_PRINT("\n%s\n", str);
>>>          }
>>>
>>>          int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
>>>         diff --git a/platform/linux-generic/odp_shared_memory.c
>>>         b/platform/linux-generic/odp_shared_memory.c
>>>         index 24a5d60..9d3e4cb 100644
>>>         --- a/platform/linux-generic/odp_shared_memory.c
>>>         +++ b/platform/linux-generic/odp_shared_memory.c
>>>         @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>>>          {
>>>                 int i;
>>>
>>>         -       printf("\nShared memory\n");
>>>         -       printf("--------------\n");
>>>         -       printf("  page size:      %"PRIu64" kB\n",
>>>         odp_sys_page_size() / 1024);
>>>         -       printf("  huge page size: %"PRIu64" kB\n",
>>>         -              odp_sys_huge_page_size() / 1024);
>>>         -       printf("\n");
>>>         +       ODP_PRINT("\nShared memory\n");
>>>         +       ODP_PRINT("--------------\n");
>>>         +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
>>>         +                 odp_sys_page_size() / 1024);
>>>         +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
>>>         +                 odp_sys_huge_page_size() / 1024);
>>>         +       ODP_PRINT("\n");
>>>
>>>         -       printf("  id name  kB align huge addr\n");
>>>         +       ODP_PRINT("  id name    kB align huge addr\n");
>>>
>>>                 for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>>>                         odp_shm_block_t *block;
>>>         @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>>>                         block = &odp_shm_tbl->block[i];
>>>
>>>                         if (block->addr) {
>>>         -                       printf("  %2i %-24s %4"PRIu64"
>>>  %4"PRIu64" %2c   %p\n",
>>>         -                              i,
>>>         -                              block->name,
>>>         - block->size/1024,
>>>         -                              block->align,
>>>         -                              (block->huge ? '*' : ' '),
>>>         -                              block->addr);
>>>         +                       ODP_PRINT("  %2i %-24s %4"PRIu64"
>>>  %4"PRIu64
>>>         +                                 " %2c   %p\n",
>>>         +                                 i,
>>>         +  block->name,
>>>         +  block->size/1024,
>>>         +  block->align,
>>>         +  (block->huge ? '*' : ' '),
>>>         +  block->addr);
>>>                         }
>>>                 }
>>>
>>>         -       printf("\n");
>>>         +       ODP_PRINT("\n");
>>>          }
>>>         --
>>>         2.1.0
>>>
>>>
>>>         _______________________________________________
>>>         lng-odp mailing list
>>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>>
>>>
>>>
>>>
>>> --
>>> *Mike Holmes*
>>> Linaro  Sr Technical Manager
>>> LNG - ODP
>>>
>>>
>>> _______________________________________________
>>> lng-odp mailing list
>>> lng-odp@lists.linaro.org
>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
>
> --
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
Mike Holmes Nov. 24, 2014, 2:46 p.m. UTC | #6
ping this has been reviewed.

On 22 November 2014 08:17, Mike Holmes <mike.holmes@linaro.org> wrote:

> ping can this go in ?
> Once Taras has his weak override go in and all this moves to internal we
> can fix the docs to suit.
>
> On 21 November 2014 08:16, Mike Holmes <mike.holmes@linaro.org> wrote:
>
>>
>>
>> On 21 November 2014 07:02, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>
>>> Merged.
>>>
>>> I think later we need some doc to structure all LOG, PRINT and ABORT
>>> functions with levels of usage.
>>> Might be force doxygen to generate separate page for that functions.
>>>
>>
>> I agree, I think this is just one case of the larger issue of poor
>> documentation.
>>
>> When we have to completed the code coverage effort, then we need a second
>> pass.
>>
>> We have to look at the linux-generic implementation and accurately
>> document its behaviour and specifically and not just say 0 on success -1 on
>> failure.
>> One we have an updated the doc, we need to improve the tests to ensure
>> they behave as described.
>>
>>
>>
>>>
>>> Maxim.
>>>
>>> On 11/21/2014 01:31 AM, Mike Holmes wrote:
>>>
>>>> ping any other comments ?
>>>>
>>>> On 19 November 2014 19:31, Bill Fischofer <bill.fischofer@linaro.org
>>>> <mailto:bill.fischofer@linaro.org>> wrote:
>>>>
>>>>
>>>>
>>>>     On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes
>>>>     <mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>> wrote:
>>>>
>>>>         Current ODP APIs that print internal data on demand for the
>>>>         application do so
>>>>         via printf.
>>>>
>>>>         Introduce ODP_PRI so that APIs that produce output may be
>>>>         channeled though
>>>>         ODP_LOG to match the other logging types.
>>>>
>>>>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>>>>         <mailto:mike.holmes@linaro.org>>
>>>>
>>>>
>>>>     Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org
>>>>     <mailto:bill.fischofer@linaro.org>>
>>>>
>>>>
>>>>         ---
>>>>          platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>>>>          platform/linux-generic/odp_buffer.c |  4 +--
>>>>          platform/linux-generic/odp_buffer_pool.c  | 45
>>>>         +++++++++++++-------------
>>>>          platform/linux-generic/odp_packet.c |  2 +-
>>>>          platform/linux-generic/odp_shared_memory.c  | 32
>>>>         +++++++++---------
>>>>          5 files changed, 56 insertions(+), 41 deletions(-)
>>>>
>>>>         diff --git a/platform/linux-generic/include/api/odp_debug.h
>>>>         b/platform/linux-generic/include/api/odp_debug.h
>>>>         index c9b2edd..5c3adde 100644
>>>>         --- a/platform/linux-generic/include/api/odp_debug.h
>>>>         +++ b/platform/linux-generic/include/api/odp_debug.h
>>>>         @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>>>>                 ODP_LOG_DBG,
>>>>                 ODP_LOG_ERR,
>>>>                 ODP_LOG_UNIMPLEMENTED,
>>>>         -       ODP_LOG_ABORT
>>>>         +       ODP_LOG_ABORT,
>>>>         +       ODP_LOG_PRINT
>>>>          } odp_log_level_e;
>>>>
>>>>          /**
>>>>         @@ -94,6 +95,10 @@ do { \
>>>>                                 fprintf(stderr, "%s:%d:%s():" fmt,
>>>>         __FILE__, \
>>>>                                 __LINE__, __func__, ##__VA_ARGS__); \
>>>>                         break; \
>>>>         +       case ODP_LOG_PRINT: \
>>>>         +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
>>>>         +               __LINE__, __func__, ##__VA_ARGS__); \
>>>>         +               break; \
>>>>                 case ODP_LOG_ABORT: \
>>>>                         fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>>>>                         __LINE__, __func__, ##__VA_ARGS__); \
>>>>         @@ -111,6 +116,13 @@ do { \
>>>>          } while (0)
>>>>
>>>>          /**
>>>>         + * Printing macro, which prints output when the application
>>>>         + * calls one of the ODP APIs specifically for dumping
>>>>         internal data.
>>>>         + */
>>>>         +#define ODP_PRINT(fmt, ...) \
>>>>         +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
>>>>         +
>>>>         +/**
>>>>           * Debug printing macro, which prints output when DEBUG flag
>>>>         is set.
>>>>           */
>>>>          #define ODP_DBG(fmt, ...) \
>>>>         diff --git a/platform/linux-generic/odp_buffer.c
>>>>         b/platform/linux-generic/odp_buffer.c
>>>>         index e54e0e7..d9e211b 100644
>>>>         --- a/platform/linux-generic/odp_buffer.c
>>>>         +++ b/platform/linux-generic/odp_buffer.c
>>>>         @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n,
>>>>         odp_buffer_t buf)
>>>>                 int len = 0;
>>>>
>>>>                 if (!odp_buffer_is_valid(buf)) {
>>>>         -               printf("Buffer is not valid.\n");
>>>>         +               ODP_PRINT("Buffer is not valid.\n");
>>>>                         return len;
>>>>                 }
>>>>
>>>>         @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>>>>                 len = odp_buffer_snprint(str, max_len-1, buf);
>>>>                 str[len] = 0;
>>>>
>>>>         -       printf("\n%s\n", str);
>>>>         +       ODP_PRINT("\n%s\n", str);
>>>>          }
>>>>
>>>>          void odp_buffer_copy_scatter(odp_buffer_t buf_dst,
>>>>         odp_buffer_t buf_src)
>>>>         diff --git a/platform/linux-generic/odp_buffer_pool.c
>>>>         b/platform/linux-generic/odp_buffer_pool.c
>>>>         index a48d7d6..6a0a6b2 100644
>>>>         --- a/platform/linux-generic/odp_buffer_pool.c
>>>>         +++ b/platform/linux-generic/odp_buffer_pool.c
>>>>         @@ -523,20 +523,20 @@ void
>>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>>                 pool_id = pool_handle_to_index(pool_hdl);
>>>>                 pool    = get_pool_entry(pool_id);
>>>>
>>>>         -       printf("Pool info\n");
>>>>         -       printf("---------\n");
>>>>         -       printf("  pool          %i\n",  pool->s.pool_hdl);
>>>>         -       printf("  name          %s\n",  pool->s.name
>>>>         <http://s.name>);
>>>>         -       printf("  pool base     %p\n",  pool->s.pool_base_addr);
>>>>         -       printf("  buf base      0x%"PRIxPTR"\n",
>>>>         pool->s.buf_base);
>>>>         -       printf("  pool size     0x%"PRIx64"\n",
>>>>         pool->s.pool_size);
>>>>         -       printf("  buf size      %zu\n", pool->s.user_size);
>>>>         -       printf("  buf align     %zu\n", pool->s.user_align);
>>>>         -       printf("  hdr size      %zu\n", pool->s.hdr_size);
>>>>         -       printf("  alloc size    %zu\n", pool->s.buf_size);
>>>>         -       printf("  offset to hdr %zu\n", pool->s.buf_offset);
>>>>         -       printf("  num bufs      %"PRIu64"\n", pool->s.num_bufs);
>>>>         -       printf("  free bufs     %"PRIu64"\n",
>>>> pool->s.free_bufs);
>>>>         +       ODP_PRINT("Pool info\n");
>>>>         +       ODP_PRINT("---------\n");
>>>>         +       ODP_PRINT("  pool          %i\n",    pool->s.pool_hdl);
>>>>         +       ODP_PRINT("  name          %s\n",    pool->s.name
>>>>         <http://s.name>);
>>>>
>>>>         +       ODP_PRINT("  pool base     %p\n",
>>>>  pool->s.pool_base_addr);
>>>>         +       ODP_PRINT("  buf base 0x%"PRIxPTR"\n",
>>>> pool->s.buf_base);
>>>>         +       ODP_PRINT("  pool size  0x%"PRIx64"\n",
>>>>  pool->s.pool_size);
>>>>         +       ODP_PRINT("  buf size      %zu\n",
>>>>  pool->s.user_size);
>>>>         +       ODP_PRINT("  buf align     %zu\n",
>>>> pool->s.user_align);
>>>>         +       ODP_PRINT("  hdr size      %zu\n",
>>>>  pool->s.hdr_size);
>>>>         +       ODP_PRINT("  alloc size    %zu\n",
>>>>  pool->s.buf_size);
>>>>         +       ODP_PRINT("  offset to hdr %zu\n",
>>>> pool->s.buf_offset);
>>>>         +       ODP_PRINT("  num bufs %"PRIu64"\n",
>>>> pool->s.num_bufs);
>>>>         +       ODP_PRINT("  free bufs  %"PRIu64"\n",
>>>>  pool->s.free_bufs);
>>>>
>>>>                 /* first chunk */
>>>>                 chunk_hdr = pool->s.head;
>>>>         @@ -546,7 +546,7 @@ void
>>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>>                         return;
>>>>                 }
>>>>
>>>>         -       printf("\n  First chunk\n");
>>>>         +       ODP_PRINT("\n  First chunk\n");
>>>>
>>>>                 for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>>>>                         uint32_t index;
>>>>         @@ -555,20 +555,21 @@ void
>>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>>                         index = chunk_hdr->chunk.buf_index[i];
>>>>                         hdr   = index_to_hdr(pool, index);
>>>>
>>>>         -               printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>         hdr->addr, index);
>>>>         +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>         hdr->addr,
>>>>         +                         index);
>>>>                 }
>>>>
>>>>         -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>         chunk_hdr->buf_hdr.addr,
>>>>         -              chunk_hdr->buf_hdr.index);
>>>>         +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>         chunk_hdr->buf_hdr.addr,
>>>>         +                 chunk_hdr->buf_hdr.index);
>>>>
>>>>                 /* next chunk */
>>>>                 chunk_hdr = next_chunk(pool, chunk_hdr);
>>>>
>>>>                 if (chunk_hdr) {
>>>>         -               printf("  Next chunk\n");
>>>>         -               printf("  addr %p, id %"PRIu32"\n",
>>>>         chunk_hdr->buf_hdr.addr,
>>>>         - chunk_hdr->buf_hdr.index);
>>>>         +               ODP_PRINT("  Next chunk\n");
>>>>         +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
>>>>         chunk_hdr->buf_hdr.addr,
>>>>         +  chunk_hdr->buf_hdr.index);
>>>>                 }
>>>>
>>>>         -       printf("\n");
>>>>         +       ODP_PRINT("\n");
>>>>          }
>>>>         diff --git a/platform/linux-generic/odp_packet.c
>>>>         b/platform/linux-generic/odp_packet.c
>>>>         index 82ea879..a574de1 100644
>>>>         --- a/platform/linux-generic/odp_packet.c
>>>>         +++ b/platform/linux-generic/odp_packet.c
>>>>         @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>>>>                                 "  input        %u\n", hdr->input);
>>>>                 str[len] = '\0';
>>>>
>>>>         -       printf("\n%s\n", str);
>>>>         +       ODP_PRINT("\n%s\n", str);
>>>>          }
>>>>
>>>>          int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
>>>>         diff --git a/platform/linux-generic/odp_shared_memory.c
>>>>         b/platform/linux-generic/odp_shared_memory.c
>>>>         index 24a5d60..9d3e4cb 100644
>>>>         --- a/platform/linux-generic/odp_shared_memory.c
>>>>         +++ b/platform/linux-generic/odp_shared_memory.c
>>>>         @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>>>>          {
>>>>                 int i;
>>>>
>>>>         -       printf("\nShared memory\n");
>>>>         -       printf("--------------\n");
>>>>         -       printf("  page size:      %"PRIu64" kB\n",
>>>>         odp_sys_page_size() / 1024);
>>>>         -       printf("  huge page size: %"PRIu64" kB\n",
>>>>         -              odp_sys_huge_page_size() / 1024);
>>>>         -       printf("\n");
>>>>         +       ODP_PRINT("\nShared memory\n");
>>>>         +       ODP_PRINT("--------------\n");
>>>>         +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
>>>>         +                 odp_sys_page_size() / 1024);
>>>>         +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
>>>>         +                 odp_sys_huge_page_size() / 1024);
>>>>         +       ODP_PRINT("\n");
>>>>
>>>>         -       printf("  id name  kB align huge addr\n");
>>>>         +       ODP_PRINT("  id name    kB align huge addr\n");
>>>>
>>>>                 for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>>>>                         odp_shm_block_t *block;
>>>>         @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>>>>                         block = &odp_shm_tbl->block[i];
>>>>
>>>>                         if (block->addr) {
>>>>         -                       printf("  %2i %-24s %4"PRIu64"
>>>>  %4"PRIu64" %2c   %p\n",
>>>>         -                              i,
>>>>         -                              block->name,
>>>>         - block->size/1024,
>>>>         -                              block->align,
>>>>         -                              (block->huge ? '*' : ' '),
>>>>         -                              block->addr);
>>>>         +                       ODP_PRINT("  %2i %-24s %4"PRIu64"
>>>>    %4"PRIu64
>>>>         +                                 " %2c   %p\n",
>>>>         +                                 i,
>>>>         +  block->name,
>>>>         +  block->size/1024,
>>>>         +  block->align,
>>>>         +  (block->huge ? '*' : ' '),
>>>>         +  block->addr);
>>>>                         }
>>>>                 }
>>>>
>>>>         -       printf("\n");
>>>>         +       ODP_PRINT("\n");
>>>>          }
>>>>         --
>>>>         2.1.0
>>>>
>>>>
>>>>         _______________________________________________
>>>>         lng-odp mailing list
>>>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Mike Holmes*
>>>> Linaro  Sr Technical Manager
>>>> LNG - ODP
>>>>
>>>>
>>>> _______________________________________________
>>>> lng-odp mailing list
>>>> lng-odp@lists.linaro.org
>>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>>
>>>
>>>
>>> _______________________________________________
>>> lng-odp mailing list
>>> lng-odp@lists.linaro.org
>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>
>>
>>
>> --
>> *Mike Holmes*
>> Linaro  Sr Technical Manager
>> LNG - ODP
>>
>
>
>
> --
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
Mike Holmes Nov. 24, 2014, 2:47 p.m. UTC | #7
Sorry, I see this is in now

On 24 November 2014 09:46, Mike Holmes <mike.holmes@linaro.org> wrote:

> ping this has been reviewed.
>
> On 22 November 2014 08:17, Mike Holmes <mike.holmes@linaro.org> wrote:
>
>> ping can this go in ?
>> Once Taras has his weak override go in and all this moves to internal we
>> can fix the docs to suit.
>>
>> On 21 November 2014 08:16, Mike Holmes <mike.holmes@linaro.org> wrote:
>>
>>>
>>>
>>> On 21 November 2014 07:02, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>>
>>>> Merged.
>>>>
>>>> I think later we need some doc to structure all LOG, PRINT and ABORT
>>>> functions with levels of usage.
>>>> Might be force doxygen to generate separate page for that functions.
>>>>
>>>
>>> I agree, I think this is just one case of the larger issue of poor
>>> documentation.
>>>
>>> When we have to completed the code coverage effort, then we need a
>>> second pass.
>>>
>>> We have to look at the linux-generic implementation and accurately
>>> document its behaviour and specifically and not just say 0 on success -1 on
>>> failure.
>>> One we have an updated the doc, we need to improve the tests to ensure
>>> they behave as described.
>>>
>>>
>>>
>>>>
>>>> Maxim.
>>>>
>>>> On 11/21/2014 01:31 AM, Mike Holmes wrote:
>>>>
>>>>> ping any other comments ?
>>>>>
>>>>> On 19 November 2014 19:31, Bill Fischofer <bill.fischofer@linaro.org
>>>>> <mailto:bill.fischofer@linaro.org>> wrote:
>>>>>
>>>>>
>>>>>
>>>>>     On Wed, Nov 19, 2014 at 5:14 PM, Mike Holmes
>>>>>     <mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>> wrote:
>>>>>
>>>>>         Current ODP APIs that print internal data on demand for the
>>>>>         application do so
>>>>>         via printf.
>>>>>
>>>>>         Introduce ODP_PRI so that APIs that produce output may be
>>>>>         channeled though
>>>>>         ODP_LOG to match the other logging types.
>>>>>
>>>>>         Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>>>>>         <mailto:mike.holmes@linaro.org>>
>>>>>
>>>>>
>>>>>     Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org
>>>>>     <mailto:bill.fischofer@linaro.org>>
>>>>>
>>>>>
>>>>>         ---
>>>>>          platform/linux-generic/include/api/odp_debug.h | 14 +++++++-
>>>>>          platform/linux-generic/odp_buffer.c |  4 +--
>>>>>          platform/linux-generic/odp_buffer_pool.c  | 45
>>>>>         +++++++++++++-------------
>>>>>          platform/linux-generic/odp_packet.c |  2 +-
>>>>>          platform/linux-generic/odp_shared_memory.c  | 32
>>>>>         +++++++++---------
>>>>>          5 files changed, 56 insertions(+), 41 deletions(-)
>>>>>
>>>>>         diff --git a/platform/linux-generic/include/api/odp_debug.h
>>>>>         b/platform/linux-generic/include/api/odp_debug.h
>>>>>         index c9b2edd..5c3adde 100644
>>>>>         --- a/platform/linux-generic/include/api/odp_debug.h
>>>>>         +++ b/platform/linux-generic/include/api/odp_debug.h
>>>>>         @@ -76,7 +76,8 @@ typedef enum odp_log_level {
>>>>>                 ODP_LOG_DBG,
>>>>>                 ODP_LOG_ERR,
>>>>>                 ODP_LOG_UNIMPLEMENTED,
>>>>>         -       ODP_LOG_ABORT
>>>>>         +       ODP_LOG_ABORT,
>>>>>         +       ODP_LOG_PRINT
>>>>>          } odp_log_level_e;
>>>>>
>>>>>          /**
>>>>>         @@ -94,6 +95,10 @@ do { \
>>>>>                                 fprintf(stderr, "%s:%d:%s():" fmt,
>>>>>         __FILE__, \
>>>>>                                 __LINE__, __func__, ##__VA_ARGS__); \
>>>>>                         break; \
>>>>>         +       case ODP_LOG_PRINT: \
>>>>>         +               fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
>>>>>         +               __LINE__, __func__, ##__VA_ARGS__); \
>>>>>         +               break; \
>>>>>                 case ODP_LOG_ABORT: \
>>>>>                         fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
>>>>>                         __LINE__, __func__, ##__VA_ARGS__); \
>>>>>         @@ -111,6 +116,13 @@ do { \
>>>>>          } while (0)
>>>>>
>>>>>          /**
>>>>>         + * Printing macro, which prints output when the application
>>>>>         + * calls one of the ODP APIs specifically for dumping
>>>>>         internal data.
>>>>>         + */
>>>>>         +#define ODP_PRINT(fmt, ...) \
>>>>>         +               ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
>>>>>         +
>>>>>         +/**
>>>>>           * Debug printing macro, which prints output when DEBUG flag
>>>>>         is set.
>>>>>           */
>>>>>          #define ODP_DBG(fmt, ...) \
>>>>>         diff --git a/platform/linux-generic/odp_buffer.c
>>>>>         b/platform/linux-generic/odp_buffer.c
>>>>>         index e54e0e7..d9e211b 100644
>>>>>         --- a/platform/linux-generic/odp_buffer.c
>>>>>         +++ b/platform/linux-generic/odp_buffer.c
>>>>>         @@ -52,7 +52,7 @@ int odp_buffer_snprint(char *str, size_t n,
>>>>>         odp_buffer_t buf)
>>>>>                 int len = 0;
>>>>>
>>>>>                 if (!odp_buffer_is_valid(buf)) {
>>>>>         -               printf("Buffer is not valid.\n");
>>>>>         +               ODP_PRINT("Buffer is not valid.\n");
>>>>>                         return len;
>>>>>                 }
>>>>>
>>>>>         @@ -98,7 +98,7 @@ void odp_buffer_print(odp_buffer_t buf)
>>>>>                 len = odp_buffer_snprint(str, max_len-1, buf);
>>>>>                 str[len] = 0;
>>>>>
>>>>>         -       printf("\n%s\n", str);
>>>>>         +       ODP_PRINT("\n%s\n", str);
>>>>>          }
>>>>>
>>>>>          void odp_buffer_copy_scatter(odp_buffer_t buf_dst,
>>>>>         odp_buffer_t buf_src)
>>>>>         diff --git a/platform/linux-generic/odp_buffer_pool.c
>>>>>         b/platform/linux-generic/odp_buffer_pool.c
>>>>>         index a48d7d6..6a0a6b2 100644
>>>>>         --- a/platform/linux-generic/odp_buffer_pool.c
>>>>>         +++ b/platform/linux-generic/odp_buffer_pool.c
>>>>>         @@ -523,20 +523,20 @@ void
>>>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>>>                 pool_id = pool_handle_to_index(pool_hdl);
>>>>>                 pool    = get_pool_entry(pool_id);
>>>>>
>>>>>         -       printf("Pool info\n");
>>>>>         -       printf("---------\n");
>>>>>         -       printf("  pool          %i\n",  pool->s.pool_hdl);
>>>>>         -       printf("  name          %s\n",  pool->s.name
>>>>>         <http://s.name>);
>>>>>         -       printf("  pool base     %p\n",
>>>>> pool->s.pool_base_addr);
>>>>>         -       printf("  buf base      0x%"PRIxPTR"\n",
>>>>>         pool->s.buf_base);
>>>>>         -       printf("  pool size     0x%"PRIx64"\n",
>>>>>         pool->s.pool_size);
>>>>>         -       printf("  buf size      %zu\n", pool->s.user_size);
>>>>>         -       printf("  buf align     %zu\n", pool->s.user_align);
>>>>>         -       printf("  hdr size      %zu\n", pool->s.hdr_size);
>>>>>         -       printf("  alloc size    %zu\n", pool->s.buf_size);
>>>>>         -       printf("  offset to hdr %zu\n", pool->s.buf_offset);
>>>>>         -       printf("  num bufs      %"PRIu64"\n",
>>>>> pool->s.num_bufs);
>>>>>         -       printf("  free bufs     %"PRIu64"\n",
>>>>> pool->s.free_bufs);
>>>>>         +       ODP_PRINT("Pool info\n");
>>>>>         +       ODP_PRINT("---------\n");
>>>>>         +       ODP_PRINT("  pool          %i\n",    pool->s.pool_hdl);
>>>>>         +       ODP_PRINT("  name          %s\n",    pool->s.name
>>>>>         <http://s.name>);
>>>>>
>>>>>         +       ODP_PRINT("  pool base     %p\n",
>>>>>  pool->s.pool_base_addr);
>>>>>         +       ODP_PRINT("  buf base 0x%"PRIxPTR"\n",
>>>>> pool->s.buf_base);
>>>>>         +       ODP_PRINT("  pool size  0x%"PRIx64"\n",
>>>>>  pool->s.pool_size);
>>>>>         +       ODP_PRINT("  buf size      %zu\n",
>>>>>  pool->s.user_size);
>>>>>         +       ODP_PRINT("  buf align     %zu\n",
>>>>> pool->s.user_align);
>>>>>         +       ODP_PRINT("  hdr size      %zu\n",
>>>>>  pool->s.hdr_size);
>>>>>         +       ODP_PRINT("  alloc size    %zu\n",
>>>>>  pool->s.buf_size);
>>>>>         +       ODP_PRINT("  offset to hdr %zu\n",
>>>>> pool->s.buf_offset);
>>>>>         +       ODP_PRINT("  num bufs %"PRIu64"\n",
>>>>> pool->s.num_bufs);
>>>>>         +       ODP_PRINT("  free bufs  %"PRIu64"\n",
>>>>>  pool->s.free_bufs);
>>>>>
>>>>>                 /* first chunk */
>>>>>                 chunk_hdr = pool->s.head;
>>>>>         @@ -546,7 +546,7 @@ void
>>>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>>>                         return;
>>>>>                 }
>>>>>
>>>>>         -       printf("\n  First chunk\n");
>>>>>         +       ODP_PRINT("\n  First chunk\n");
>>>>>
>>>>>                 for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
>>>>>                         uint32_t index;
>>>>>         @@ -555,20 +555,21 @@ void
>>>>>         odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
>>>>>                         index = chunk_hdr->chunk.buf_index[i];
>>>>>                         hdr   = index_to_hdr(pool, index);
>>>>>
>>>>>         -               printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>>         hdr->addr, index);
>>>>>         +               ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>>         hdr->addr,
>>>>>         +                         index);
>>>>>                 }
>>>>>
>>>>>         -       printf("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>>         chunk_hdr->buf_hdr.addr,
>>>>>         -              chunk_hdr->buf_hdr.index);
>>>>>         +       ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i,
>>>>>         chunk_hdr->buf_hdr.addr,
>>>>>         +                 chunk_hdr->buf_hdr.index);
>>>>>
>>>>>                 /* next chunk */
>>>>>                 chunk_hdr = next_chunk(pool, chunk_hdr);
>>>>>
>>>>>                 if (chunk_hdr) {
>>>>>         -               printf("  Next chunk\n");
>>>>>         -               printf("  addr %p, id %"PRIu32"\n",
>>>>>         chunk_hdr->buf_hdr.addr,
>>>>>         - chunk_hdr->buf_hdr.index);
>>>>>         +               ODP_PRINT("  Next chunk\n");
>>>>>         +               ODP_PRINT("  addr %p, id %"PRIu32"\n",
>>>>>         chunk_hdr->buf_hdr.addr,
>>>>>         +  chunk_hdr->buf_hdr.index);
>>>>>                 }
>>>>>
>>>>>         -       printf("\n");
>>>>>         +       ODP_PRINT("\n");
>>>>>          }
>>>>>         diff --git a/platform/linux-generic/odp_packet.c
>>>>>         b/platform/linux-generic/odp_packet.c
>>>>>         index 82ea879..a574de1 100644
>>>>>         --- a/platform/linux-generic/odp_packet.c
>>>>>         +++ b/platform/linux-generic/odp_packet.c
>>>>>         @@ -346,7 +346,7 @@ void odp_packet_print(odp_packet_t pkt)
>>>>>                                 "  input        %u\n", hdr->input);
>>>>>                 str[len] = '\0';
>>>>>
>>>>>         -       printf("\n%s\n", str);
>>>>>         +       ODP_PRINT("\n%s\n", str);
>>>>>          }
>>>>>
>>>>>          int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t
>>>>> pkt_src)
>>>>>         diff --git a/platform/linux-generic/odp_shared_memory.c
>>>>>         b/platform/linux-generic/odp_shared_memory.c
>>>>>         index 24a5d60..9d3e4cb 100644
>>>>>         --- a/platform/linux-generic/odp_shared_memory.c
>>>>>         +++ b/platform/linux-generic/odp_shared_memory.c
>>>>>         @@ -285,14 +285,15 @@ void odp_shm_print_all(void)
>>>>>          {
>>>>>                 int i;
>>>>>
>>>>>         -       printf("\nShared memory\n");
>>>>>         -       printf("--------------\n");
>>>>>         -       printf("  page size:      %"PRIu64" kB\n",
>>>>>         odp_sys_page_size() / 1024);
>>>>>         -       printf("  huge page size: %"PRIu64" kB\n",
>>>>>         -              odp_sys_huge_page_size() / 1024);
>>>>>         -       printf("\n");
>>>>>         +       ODP_PRINT("\nShared memory\n");
>>>>>         +       ODP_PRINT("--------------\n");
>>>>>         +       ODP_PRINT("  page size:      %"PRIu64" kB\n",
>>>>>         +                 odp_sys_page_size() / 1024);
>>>>>         +       ODP_PRINT("  huge page size: %"PRIu64" kB\n",
>>>>>         +                 odp_sys_huge_page_size() / 1024);
>>>>>         +       ODP_PRINT("\n");
>>>>>
>>>>>         -       printf("  id name  kB align huge addr\n");
>>>>>         +       ODP_PRINT("  id name    kB align huge addr\n");
>>>>>
>>>>>                 for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
>>>>>                         odp_shm_block_t *block;
>>>>>         @@ -300,15 +301,16 @@ void odp_shm_print_all(void)
>>>>>                         block = &odp_shm_tbl->block[i];
>>>>>
>>>>>                         if (block->addr) {
>>>>>         -                       printf("  %2i %-24s %4"PRIu64"
>>>>>  %4"PRIu64" %2c   %p\n",
>>>>>         -                              i,
>>>>>         -                              block->name,
>>>>>         - block->size/1024,
>>>>>         -                              block->align,
>>>>>         -                              (block->huge ? '*' : ' '),
>>>>>         -                              block->addr);
>>>>>         +                       ODP_PRINT("  %2i %-24s %4"PRIu64"
>>>>>    %4"PRIu64
>>>>>         +                                 " %2c   %p\n",
>>>>>         +                                 i,
>>>>>         +  block->name,
>>>>>         +  block->size/1024,
>>>>>         +  block->align,
>>>>>         +  (block->huge ? '*' : ' '),
>>>>>         +  block->addr);
>>>>>                         }
>>>>>                 }
>>>>>
>>>>>         -       printf("\n");
>>>>>         +       ODP_PRINT("\n");
>>>>>          }
>>>>>         --
>>>>>         2.1.0
>>>>>
>>>>>
>>>>>         _______________________________________________
>>>>>         lng-odp mailing list
>>>>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>>>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Mike Holmes*
>>>>> Linaro  Sr Technical Manager
>>>>> LNG - ODP
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> lng-odp mailing list
>>>>> lng-odp@lists.linaro.org
>>>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> lng-odp mailing list
>>>> lng-odp@lists.linaro.org
>>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>>
>>>
>>>
>>>
>>> --
>>> *Mike Holmes*
>>> Linaro  Sr Technical Manager
>>> LNG - ODP
>>>
>>
>>
>>
>> --
>> *Mike Holmes*
>> Linaro  Sr Technical Manager
>> LNG - ODP
>>
>
>
>
> --
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h
index c9b2edd..5c3adde 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -76,7 +76,8 @@  typedef enum odp_log_level {
 	ODP_LOG_DBG,
 	ODP_LOG_ERR,
 	ODP_LOG_UNIMPLEMENTED,
-	ODP_LOG_ABORT
+	ODP_LOG_ABORT,
+	ODP_LOG_PRINT
 } odp_log_level_e;
 
 /**
@@ -94,6 +95,10 @@  do { \
 			fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
 			__LINE__, __func__, ##__VA_ARGS__); \
 		break; \
+	case ODP_LOG_PRINT: \
+		fprintf(stdout, "%s:%d:%s():" fmt, __FILE__, \
+		__LINE__, __func__, ##__VA_ARGS__); \
+		break; \
 	case ODP_LOG_ABORT: \
 		fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
 		__LINE__, __func__, ##__VA_ARGS__); \
@@ -111,6 +116,13 @@  do { \
 } while (0)
 
 /**
+ * Printing macro, which prints output when the application
+ * calls one of the ODP APIs specifically for dumping internal data.
+ */
+#define ODP_PRINT(fmt, ...) \
+		ODP_LOG(ODP_LOG_PRINT, fmt, ##__VA_ARGS__)
+
+/**
  * Debug printing macro, which prints output when DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \
diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c
index e54e0e7..d9e211b 100644
--- a/platform/linux-generic/odp_buffer.c
+++ b/platform/linux-generic/odp_buffer.c
@@ -52,7 +52,7 @@  int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf)
 	int len = 0;
 
 	if (!odp_buffer_is_valid(buf)) {
-		printf("Buffer is not valid.\n");
+		ODP_PRINT("Buffer is not valid.\n");
 		return len;
 	}
 
@@ -98,7 +98,7 @@  void odp_buffer_print(odp_buffer_t buf)
 	len = odp_buffer_snprint(str, max_len-1, buf);
 	str[len] = 0;
 
-	printf("\n%s\n", str);
+	ODP_PRINT("\n%s\n", str);
 }
 
 void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src)
diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c
index a48d7d6..6a0a6b2 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -523,20 +523,20 @@  void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
 	pool_id = pool_handle_to_index(pool_hdl);
 	pool    = get_pool_entry(pool_id);
 
-	printf("Pool info\n");
-	printf("---------\n");
-	printf("  pool          %i\n",           pool->s.pool_hdl);
-	printf("  name          %s\n",           pool->s.name);
-	printf("  pool base     %p\n",           pool->s.pool_base_addr);
-	printf("  buf base      0x%"PRIxPTR"\n", pool->s.buf_base);
-	printf("  pool size     0x%"PRIx64"\n",  pool->s.pool_size);
-	printf("  buf size      %zu\n",          pool->s.user_size);
-	printf("  buf align     %zu\n",          pool->s.user_align);
-	printf("  hdr size      %zu\n",          pool->s.hdr_size);
-	printf("  alloc size    %zu\n",          pool->s.buf_size);
-	printf("  offset to hdr %zu\n",          pool->s.buf_offset);
-	printf("  num bufs      %"PRIu64"\n",    pool->s.num_bufs);
-	printf("  free bufs     %"PRIu64"\n",    pool->s.free_bufs);
+	ODP_PRINT("Pool info\n");
+	ODP_PRINT("---------\n");
+	ODP_PRINT("  pool          %i\n",           pool->s.pool_hdl);
+	ODP_PRINT("  name          %s\n",           pool->s.name);
+	ODP_PRINT("  pool base     %p\n",           pool->s.pool_base_addr);
+	ODP_PRINT("  buf base      0x%"PRIxPTR"\n", pool->s.buf_base);
+	ODP_PRINT("  pool size     0x%"PRIx64"\n",  pool->s.pool_size);
+	ODP_PRINT("  buf size      %zu\n",          pool->s.user_size);
+	ODP_PRINT("  buf align     %zu\n",          pool->s.user_align);
+	ODP_PRINT("  hdr size      %zu\n",          pool->s.hdr_size);
+	ODP_PRINT("  alloc size    %zu\n",          pool->s.buf_size);
+	ODP_PRINT("  offset to hdr %zu\n",          pool->s.buf_offset);
+	ODP_PRINT("  num bufs      %"PRIu64"\n",    pool->s.num_bufs);
+	ODP_PRINT("  free bufs     %"PRIu64"\n",    pool->s.free_bufs);
 
 	/* first chunk */
 	chunk_hdr = pool->s.head;
@@ -546,7 +546,7 @@  void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
 		return;
 	}
 
-	printf("\n  First chunk\n");
+	ODP_PRINT("\n  First chunk\n");
 
 	for (i = 0; i < chunk_hdr->chunk.num_bufs - 1; i++) {
 		uint32_t index;
@@ -555,20 +555,21 @@  void odp_buffer_pool_print(odp_buffer_pool_t pool_hdl)
 		index = chunk_hdr->chunk.buf_index[i];
 		hdr   = index_to_hdr(pool, index);
 
-		printf("  [%i] addr %p, id %"PRIu32"\n", i, hdr->addr, index);
+		ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i, hdr->addr,
+			  index);
 	}
 
-	printf("  [%i] addr %p, id %"PRIu32"\n", i, chunk_hdr->buf_hdr.addr,
-	       chunk_hdr->buf_hdr.index);
+	ODP_PRINT("  [%i] addr %p, id %"PRIu32"\n", i, chunk_hdr->buf_hdr.addr,
+		  chunk_hdr->buf_hdr.index);
 
 	/* next chunk */
 	chunk_hdr = next_chunk(pool, chunk_hdr);
 
 	if (chunk_hdr) {
-		printf("  Next chunk\n");
-		printf("  addr %p, id %"PRIu32"\n", chunk_hdr->buf_hdr.addr,
-		       chunk_hdr->buf_hdr.index);
+		ODP_PRINT("  Next chunk\n");
+		ODP_PRINT("  addr %p, id %"PRIu32"\n", chunk_hdr->buf_hdr.addr,
+			  chunk_hdr->buf_hdr.index);
 	}
 
-	printf("\n");
+	ODP_PRINT("\n");
 }
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 82ea879..a574de1 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -346,7 +346,7 @@  void odp_packet_print(odp_packet_t pkt)
 			"  input        %u\n", hdr->input);
 	str[len] = '\0';
 
-	printf("\n%s\n", str);
+	ODP_PRINT("\n%s\n", str);
 }
 
 int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src)
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 24a5d60..9d3e4cb 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -285,14 +285,15 @@  void odp_shm_print_all(void)
 {
 	int i;
 
-	printf("\nShared memory\n");
-	printf("--------------\n");
-	printf("  page size:      %"PRIu64" kB\n", odp_sys_page_size() / 1024);
-	printf("  huge page size: %"PRIu64" kB\n",
-	       odp_sys_huge_page_size() / 1024);
-	printf("\n");
+	ODP_PRINT("\nShared memory\n");
+	ODP_PRINT("--------------\n");
+	ODP_PRINT("  page size:      %"PRIu64" kB\n",
+		  odp_sys_page_size() / 1024);
+	ODP_PRINT("  huge page size: %"PRIu64" kB\n",
+		  odp_sys_huge_page_size() / 1024);
+	ODP_PRINT("\n");
 
-	printf("  id name                       kB align huge addr\n");
+	ODP_PRINT("  id name                       kB align huge addr\n");
 
 	for (i = 0; i < ODP_SHM_NUM_BLOCKS; i++) {
 		odp_shm_block_t *block;
@@ -300,15 +301,16 @@  void odp_shm_print_all(void)
 		block = &odp_shm_tbl->block[i];
 
 		if (block->addr) {
-			printf("  %2i %-24s %4"PRIu64"  %4"PRIu64" %2c   %p\n",
-			       i,
-			       block->name,
-			       block->size/1024,
-			       block->align,
-			       (block->huge ? '*' : ' '),
-			       block->addr);
+			ODP_PRINT("  %2i %-24s %4"PRIu64"  %4"PRIu64
+				  " %2c   %p\n",
+				  i,
+				  block->name,
+				  block->size/1024,
+				  block->align,
+				  (block->huge ? '*' : ' '),
+				  block->addr);
 		}
 	}
 
-	printf("\n");
+	ODP_PRINT("\n");
 }