aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-dpdk/include/odp/api/plat/packet_flag_inlines.h
blob: b6876e6d720b33baacbe375be4ccbe3ed31d33db (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/* Copyright (c) 2017-2018, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

/**
 * @file
 *
 * Packet flag inline functions
 */

#ifndef _ODP_PLAT_PACKET_FLAG_INLINES_H_
#define _ODP_PLAT_PACKET_FLAG_INLINES_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/abi/packet_types.h>
#include <odp/api/plat/packet_inline_types.h>

/** @cond _ODP_HIDE_FROM_DOXYGEN_ */

static inline uint64_t _odp_packet_input_flags(odp_packet_t pkt)
{
	return _odp_pkt_get(pkt, uint64_t, input_flags);
}

#ifndef _ODP_NO_INLINE
	/* Inline functions by default */
	#define _ODP_INLINE static inline
	#define odp_packet_has_l2 __odp_packet_has_l2
	#define odp_packet_has_l3 __odp_packet_has_l3
	#define odp_packet_has_l4 __odp_packet_has_l4
	#define odp_packet_has_eth __odp_packet_has_eth
	#define odp_packet_has_jumbo __odp_packet_has_jumbo
	#define odp_packet_has_flow_hash __odp_packet_has_flow_hash
	#define odp_packet_has_flow_hash_clr __odp_packet_has_flow_hash_clr
	#define odp_packet_has_ts __odp_packet_has_ts
	#define odp_packet_has_ipsec __odp_packet_has_ipsec
	#define odp_packet_has_eth_bcast __odp_packet_has_eth_bcast
	#define odp_packet_has_eth_mcast __odp_packet_has_eth_mcast
	#define odp_packet_has_vlan __odp_packet_has_vlan
	#define odp_packet_has_vlan_qinq __odp_packet_has_vlan_qinq
	#define odp_packet_has_arp __odp_packet_has_arp
	#define odp_packet_has_ipv4 __odp_packet_has_ipv4
	#define odp_packet_has_ipv6 __odp_packet_has_ipv6
	#define odp_packet_has_ip_bcast __odp_packet_has_ip_bcast
	#define odp_packet_has_ip_mcast __odp_packet_has_ip_mcast
	#define odp_packet_has_ipfrag __odp_packet_has_ipfrag
	#define odp_packet_has_ipopt __odp_packet_has_ipopt
	#define odp_packet_has_udp __odp_packet_has_udp
	#define odp_packet_has_tcp __odp_packet_has_tcp
	#define odp_packet_has_sctp __odp_packet_has_sctp
	#define odp_packet_has_icmp __odp_packet_has_icmp
	#define odp_packet_has_error __odp_packet_has_error
	#define odp_packet_has_l2_error __odp_packet_has_l2_error
	#define odp_packet_has_l3_error __odp_packet_has_l3_error
	#define odp_packet_has_l4_error __odp_packet_has_l4_error
#else
	#undef _ODP_INLINE
	#define _ODP_INLINE
#endif

_ODP_INLINE int odp_packet_has_l2(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.l2;
}

_ODP_INLINE int odp_packet_has_l3(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.l3;
}

_ODP_INLINE int odp_packet_has_l4(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.l4;
}

_ODP_INLINE int odp_packet_has_eth(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.eth;
}

_ODP_INLINE int odp_packet_has_jumbo(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.jumbo;
}

_ODP_INLINE int odp_packet_has_flow_hash(odp_packet_t pkt)
{
	return !!(_odp_pkt_get(pkt, uint64_t, ol_flags) & _odp_packet_inline.rss_flag);
}

_ODP_INLINE void odp_packet_has_flow_hash_clr(odp_packet_t pkt)
{
	uint64_t *ol_flags = &_odp_pkt_get(pkt, uint64_t, ol_flags);

	*ol_flags &= ~_odp_packet_inline.rss_flag;
}

_ODP_INLINE int odp_packet_has_ts(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.timestamp;
}

_ODP_INLINE int odp_packet_has_ipsec(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ipsec;
}

_ODP_INLINE int odp_packet_has_eth_bcast(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.eth_bcast;
}

_ODP_INLINE int odp_packet_has_eth_mcast(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.eth_mcast;
}

_ODP_INLINE int odp_packet_has_vlan(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.vlan;
}

_ODP_INLINE int odp_packet_has_vlan_qinq(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.vlan_qinq;
}

_ODP_INLINE int odp_packet_has_arp(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.arp;
}

_ODP_INLINE int odp_packet_has_ipv4(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ipv4;
}

_ODP_INLINE int odp_packet_has_ipv6(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ipv6;
}

_ODP_INLINE int odp_packet_has_ip_bcast(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ip_bcast;
}

_ODP_INLINE int odp_packet_has_ip_mcast(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ip_mcast;
}

_ODP_INLINE int odp_packet_has_ipfrag(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ipfrag;
}

_ODP_INLINE int odp_packet_has_ipopt(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.ipopt;
}

_ODP_INLINE int odp_packet_has_udp(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.udp;
}

_ODP_INLINE int odp_packet_has_tcp(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.tcp;
}

_ODP_INLINE int odp_packet_has_sctp(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.sctp;
}

_ODP_INLINE int odp_packet_has_icmp(odp_packet_t pkt)
{
	_odp_packet_input_flags_t flags;

	flags.all = _odp_packet_input_flags(pkt);
	return flags.icmp;
}

_ODP_INLINE int odp_packet_has_error(odp_packet_t pkt)
{
	_odp_packet_flags_t flags;

	flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags);
	return flags.all.error != 0;
}

_ODP_INLINE int odp_packet_has_l2_error(odp_packet_t pkt)
{
	_odp_packet_flags_t flags;

	flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags);

	/* L2 parsing is always done by default and hence
	no additional check is required. */
	return flags.snap_len_err;
}

_ODP_INLINE int odp_packet_has_l3_error(odp_packet_t pkt)
{
	_odp_packet_flags_t flags;

	flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags);

	return flags.ip_err;
}

_ODP_INLINE int odp_packet_has_l4_error(odp_packet_t pkt)
{
	_odp_packet_flags_t flags;

	flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags);

	return flags.tcp_err | flags.udp_err;
}

/** @endcond */

#ifdef __cplusplus
}
#endif

#endif