Skip to content

Commit

Permalink
linux-gen: buffer: make code platform agnostic
Browse files Browse the repository at this point in the history
Enable usage of buffer debug code with ODP-DPDK.

Signed-off-by: Matias Elo <[email protected]>
  • Loading branch information
MatiasElo committed Sep 13, 2024
1 parent 079f663 commit 91591bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
9 changes: 8 additions & 1 deletion platform/linux-generic/include/odp_buffer_internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2019-2021 Nokia
* Copyright (c) 2019-2024 Nokia
*/

/**
Expand All @@ -27,7 +27,9 @@ extern "C" {
#include <odp/api/thread.h>
#include <odp/api/event.h>
#include <odp_event_internal.h>

#include <stddef.h>
#include <stdint.h>

/* Internal buffer header */
typedef struct ODP_ALIGNED_CACHE odp_buffer_hdr_t {
Expand Down Expand Up @@ -58,6 +60,11 @@ static inline void _odp_buffer_subtype_set(odp_buffer_t buffer, int subtype)
buf_hdr->event_hdr.subtype = subtype;
}

static inline uint32_t _odp_buffer_index(odp_buffer_t buf)
{
return _odp_buf_hdr(buf)->event_hdr.index.event;
}

#ifdef __cplusplus
}
#endif
Expand Down
22 changes: 9 additions & 13 deletions platform/linux-generic/odp_buffer.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2019-2022 Nokia
* Copyright (c) 2019-2024 Nokia
*/

#include <odp/api/align.h>
#include <odp/api/buffer.h>

#include <odp/api/plat/buffer_inline_types.h>
#include <odp/api/plat/strong_types.h>

#include <odp_pool_internal.h>
#include <odp_buffer_internal.h>
#include <odp_debug_internal.h>
#include <odp_string_internal.h>

#include <string.h>
#include <stdio.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>

#include <odp/visibility_begin.h>

Expand All @@ -28,7 +28,6 @@ const _odp_buffer_inline_offset_t _odp_buffer_inline_offset ODP_ALIGNED_CACHE =

void odp_buffer_print(odp_buffer_t buf)
{
odp_buffer_hdr_t *hdr;
int len = 0;
int max_len = 512;
int n = max_len - 1;
Expand All @@ -39,19 +38,16 @@ void odp_buffer_print(odp_buffer_t buf)
return;
}

hdr = _odp_buf_hdr(buf);

len += _odp_snprint(&str[len], n - len, "Buffer info\n");
len += _odp_snprint(&str[len], n - len, "-----------\n");
len += _odp_snprint(&str[len], n - len, " handle 0x%" PRIx64 "\n",
odp_buffer_to_u64(buf));
len += _odp_snprint(&str[len], n - len, " pool index %u\n", hdr->event_hdr.index.pool);
len += _odp_snprint(&str[len], n - len, " buffer index %u\n",
hdr->event_hdr.index.event);
len += _odp_snprint(&str[len], n - len, " addr %p\n",
(void *)hdr->event_hdr.base_data);
len += _odp_snprint(&str[len], n - len, " pool index %u\n",
odp_pool_index(odp_buffer_pool(buf)));
len += _odp_snprint(&str[len], n - len, " buffer index %u\n", _odp_buffer_index(buf));
len += _odp_snprint(&str[len], n - len, " addr %p\n", odp_buffer_addr(buf));
len += _odp_snprint(&str[len], n - len, " size %u\n", odp_buffer_size(buf));
len += _odp_snprint(&str[len], n - len, " user area %p\n", hdr->uarea_addr);
len += _odp_snprint(&str[len], n - len, " user area %p\n", odp_buffer_user_area(buf));
str[len] = 0;

_ODP_PRINT("%s\n", str);
Expand Down

0 comments on commit 91591bd

Please sign in to comment.