blob: dc8df8798efef053b02b4db087f5c9be06d4516c (
plain)
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
74
75
76
77
78
79
80
81
82
83
|
/* Copyright (c) 2015, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file
*
* ODP packet descriptor
*/
#ifndef ODP_PLAT_PACKET_H_
#define ODP_PLAT_PACKET_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <odp/std_types.h>
#include <odp/plat/event_types.h>
#include <odp/plat/packet_io_types.h>
#include <odp/plat/packet_types.h>
#include <odp/plat/buffer_types.h>
#include <odp/plat/pool_types.h>
/** @ingroup odp_packet
* @{
*/
extern const unsigned int buf_addr_offset;
extern const unsigned int data_off_offset;
extern const unsigned int pkt_len_offset;
extern const unsigned int seg_len_offset;
extern const unsigned int udata_len_offset;
extern const unsigned int udata_offset;
/*
* NOTE: These functions are inlined because they are on a performance hot path.
* As we can't force the application to directly include DPDK headers we have to
* export these fields through constants calculated compile time in
* odp_packet.c, where we can see the DPDK definitions.
*
*/
static inline uint32_t odp_packet_len(odp_packet_t pkt)
{
return *(uint32_t *)((char *)pkt + pkt_len_offset);
}
static inline uint32_t odp_packet_seg_len(odp_packet_t pkt)
{
return *(uint32_t *)((char *)pkt + seg_len_offset);
}
static inline void *odp_packet_user_area(odp_packet_t pkt)
{
return (void *)((char *)pkt + udata_offset);
}
static inline uint32_t odp_packet_user_area_size(odp_packet_t pkt)
{
return *(uint32_t *)((char *)pkt + udata_len_offset);
}
static inline void *odp_packet_data(odp_packet_t pkt)
{
char** buf_addr = (char **)((char *)pkt + buf_addr_offset);
uint16_t data_off = *(uint16_t *)((char *)pkt + data_off_offset);
return (void *)(*buf_addr + data_off);
}
/**
* @}
*/
#include <odp/api/packet.h>
#ifdef __cplusplus
}
#endif
#endif /* ODP_PLAT_PACKET_H_ */
|