1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* Copyright (c) 2013-2018, Linaro Limited
* Copyright (c) 2021-2022, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <odp/api/buffer.h>
#include <odp_buffer_internal.h>
#include <odp_debug_internal.h>
#include <odp_pool_internal.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
int _odp_buffer_type(odp_buffer_t buf)
{
odp_buffer_hdr_t *hdr = _odp_buf_hdr(buf);
return hdr->event_hdr.type;
}
void _odp_buffer_type_set(odp_buffer_t buf, int type)
{
odp_buffer_hdr_t *hdr = _odp_buf_hdr(buf);
hdr->event_hdr.type = type;
}
int odp_buffer_is_valid(odp_buffer_t buf)
{
if (odp_event_is_valid(odp_buffer_to_event(buf)) == 0)
return 0;
if (odp_event_type(odp_buffer_to_event(buf)) != ODP_EVENT_BUFFER)
return 0;
return 1;
}
void odp_buffer_print(odp_buffer_t buf)
{
odp_buffer_hdr_t *hdr;
pool_t *pool;
int len = 0;
int max_len = 512;
int n = max_len - 1;
char str[max_len];
if (!odp_buffer_is_valid(buf)) {
ODP_ERR("Buffer is not valid.\n");
return;
}
hdr = _odp_buf_hdr(buf);
pool = _odp_pool_entry(hdr->event_hdr.pool);
len += snprintf(&str[len], n - len, "Buffer\n------\n");
len += snprintf(&str[len], n - len, " pool index %u\n", pool->pool_idx);
len += snprintf(&str[len], n - len, " buffer index %u\n", hdr->event_hdr.index);
len += snprintf(&str[len], n - len, " addr %p\n", odp_buffer_addr(buf));
len += snprintf(&str[len], n - len, " size %u\n", odp_buffer_size(buf));
str[len] = 0;
ODP_PRINT("\n%s\n", str);
}
uint64_t odp_buffer_to_u64(odp_buffer_t hdl)
{
return _odp_pri(hdl);
}
|