CNDP 22.08.0
Loading...
Searching...
No Matches
pktmbuf_offload.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2010-2022 Intel Corporation.
3 * Copyright (c) 2014 6WIND S.A.
4 */
5
6#ifndef _PKTMBUF_OFFLOAD_H_
7#define _PKTMBUF_OFFLOAD_H_
8
18
19#include <stdint.h>
20
21#include <cne_common.h>
22#include <cne_byteorder.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/*
29 * Packet Offload Features Flags. It also carry packet type information.
30 * Critical resources. Both rx/tx shared these bits. Be cautious on any change
31 *
32 * - RX flags start at bit position zero, and get added to the left of previous
33 * flags.
34 * - The most-significant 3 bits are reserved for generic mbuf flags
35 * - TX flags therefore start at bit position 60 (i.e. 63-3), and new flags get
36 * added to the right of the previously defined flags i.e. they should count
37 * downwards, not upwards.
38 *
39 * Keep these flags synchronized with cne_get_rx_ol_flag_name() and
40 * cne_get_tx_ol_flag_name().
41 */
42
50#define CNE_MBUF_F_RX_VLAN (1ULL << 0)
51
53#define CNE_MBUF_F_RX_RSS_HASH (1ULL << 1)
54
56#define CNE_MBUF_F_RX_FDIR (1ULL << 2)
57
62#define CNE_MBUF_F_RX_OUTER_IP_CKSUM_BAD (1ULL << 5)
63
70#define CNE_MBUF_F_RX_VLAN_STRIPPED (1ULL << 6)
71
80#define CNE_MBUF_F_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7))
81
82#define CNE_MBUF_F_RX_IP_CKSUM_UNKNOWN 0
83#define CNE_MBUF_F_RX_IP_CKSUM_BAD (1ULL << 4)
84#define CNE_MBUF_F_RX_IP_CKSUM_GOOD (1ULL << 7)
85#define CNE_MBUF_F_RX_IP_CKSUM_NONE ((1ULL << 4) | (1ULL << 7))
86
95#define CNE_MBUF_F_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8))
96
97#define CNE_MBUF_F_RX_L4_CKSUM_UNKNOWN 0
98#define CNE_MBUF_F_RX_L4_CKSUM_BAD (1ULL << 3)
99#define CNE_MBUF_F_RX_L4_CKSUM_GOOD (1ULL << 8)
100#define CNE_MBUF_F_RX_L4_CKSUM_NONE ((1ULL << 3) | (1ULL << 8))
101
103#define CNE_MBUF_F_RX_IEEE1588_PTP (1ULL << 9)
104
106#define CNE_MBUF_F_RX_IEEE1588_TMST (1ULL << 10)
107
109#define CNE_MBUF_F_RX_FDIR_ID (1ULL << 13)
110
112#define CNE_MBUF_F_RX_FDIR_FLX (1ULL << 14)
113
129#define CNE_MBUF_F_RX_QINQ_STRIPPED (1ULL << 15)
130
136#define CNE_MBUF_F_RX_LRO (1ULL << 16)
137
138/* There is no flag defined at offset 17. It is free for any future use. */
139
143#define CNE_MBUF_F_RX_SEC_OFFLOAD (1ULL << 18)
144
148#define CNE_MBUF_F_RX_SEC_OFFLOAD_FAILED (1ULL << 19)
149
158#define CNE_MBUF_F_RX_QINQ (1ULL << 20)
159
175#define CNE_MBUF_F_RX_OUTER_L4_CKSUM_MASK ((1ULL << 21) | (1ULL << 22))
176
177#define CNE_MBUF_F_RX_OUTER_L4_CKSUM_UNKNOWN 0
178#define CNE_MBUF_F_RX_OUTER_L4_CKSUM_BAD (1ULL << 21)
179#define CNE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22)
180#define CNE_MBUF_F_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22))
181
182/* add new RX flags here, don't forget to update CNE_MBUF_F_FIRST_FREE */
183
184#define CNE_MBUF_F_FIRST_FREE (1ULL << 23)
185#define CNE_MBUF_F_LAST_FREE (1ULL << 40)
186
187/* add new TX flags here, don't forget to update CNE_MBUF_F_LAST_FREE */
188
198#define CNE_MBUF_F_TX_OUTER_UDP_CKSUM (1ULL << 41)
199
205#define CNE_MBUF_F_TX_UDP_SEG (1ULL << 42)
206
212#define CNE_MBUF_F_TX_SEC_OFFLOAD (1ULL << 43)
213
218#define CNE_MBUF_F_TX_MACSEC (1ULL << 44)
219
229#define CNE_MBUF_F_TX_TUNNEL_VXLAN (0x1ULL << 45)
230#define CNE_MBUF_F_TX_TUNNEL_GRE (0x2ULL << 45)
231#define CNE_MBUF_F_TX_TUNNEL_IPIP (0x3ULL << 45)
232#define CNE_MBUF_F_TX_TUNNEL_GENEVE (0x4ULL << 45)
234#define CNE_MBUF_F_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
235#define CNE_MBUF_F_TX_TUNNEL_VXLAN_GPE (0x6ULL << 45)
236#define CNE_MBUF_F_TX_TUNNEL_GTP (0x7ULL << 45)
237#define CNE_MBUF_F_TX_TUNNEL_ESP (0x8ULL << 45)
249#define CNE_MBUF_F_TX_TUNNEL_IP (0xDULL << 45)
262#define CNE_MBUF_F_TX_TUNNEL_UDP (0xEULL << 45)
263/* add new TX TUNNEL type here */
264#define CNE_MBUF_F_TX_TUNNEL_MASK (0xFULL << 45)
265
271#define CNE_MBUF_F_TX_QINQ (1ULL << 49)
272
282#define CNE_MBUF_F_TX_TCP_SEG (1ULL << 50)
283
285#define CNE_MBUF_F_TX_IEEE1588_TMST (1ULL << 51)
286
287/*
288 * Bits 52+53 used for L4 packet type with checksum enabled: 00: Reserved,
289 * 01: TCP checksum, 10: SCTP checksum, 11: UDP checksum. To use hardware
290 * L4 checksum offload, the user needs to:
291 * - fill l2_len and l3_len in mbuf
292 * - set the flags CNE_MBUF_F_TX_TCP_CKSUM, CNE_MBUF_F_TX_SCTP_CKSUM or
293 * CNE_MBUF_F_TX_UDP_CKSUM
294 * - set the flag CNE_MBUF_F_TX_IPV4 or CNE_MBUF_F_TX_IPV6
295 */
296
298#define CNE_MBUF_F_TX_L4_NO_CKSUM (0ULL << 52)
299
301#define CNE_MBUF_F_TX_TCP_CKSUM (1ULL << 52)
302
304#define CNE_MBUF_F_TX_SCTP_CKSUM (2ULL << 52)
305
307#define CNE_MBUF_F_TX_UDP_CKSUM (3ULL << 52)
308
310#define CNE_MBUF_F_TX_L4_MASK (3ULL << 52)
311
318#define CNE_MBUF_F_TX_IP_CKSUM (1ULL << 54)
319
326#define CNE_MBUF_F_TX_IPV4 (1ULL << 55)
327
334#define CNE_MBUF_F_TX_IPV6 (1ULL << 56)
335
341#define CNE_MBUF_F_TX_VLAN (1ULL << 57)
342
349#define CNE_MBUF_F_TX_OUTER_IP_CKSUM (1ULL << 58)
350
356#define CNE_MBUF_F_TX_OUTER_IPV4 (1ULL << 59)
357
363#define CNE_MBUF_F_TX_OUTER_IPV6 (1ULL << 60)
364
365#define CNE_MBUF_TYPE_MCAST (1ULL << 61)
366#define CNE_MBUF_TYPE_BCAST (1ULL << 62)
367#define CNE_MBUF_TYPE_IPv6 (1ULL << 63)
368#define CNE_MBUF_TYPE_MASK \
369 (CNE_MBUF_TYPE_MCAST | CNE_MBUF_TYPE_BCAST | \
370 CNE_MBUF_TYPE_IPv6)
371#define CNE_MBUF_IS_MCAST \
372 (CNE_MBUF_TYPE_MCAST | CNE_MBUF_TYPE_BCAST)
373
378#define CNE_MBUF_F_TX_OFFLOAD_MASK \
379 (CNE_MBUF_F_TX_OUTER_IPV6 | CNE_MBUF_F_TX_OUTER_IPV4 | CNE_MBUF_F_TX_OUTER_IP_CKSUM | \
380 CNE_MBUF_F_TX_VLAN | CNE_MBUF_F_TX_IPV6 | CNE_MBUF_F_TX_IPV4 | CNE_MBUF_F_TX_IP_CKSUM | \
381 CNE_MBUF_F_TX_L4_MASK | CNE_MBUF_F_TX_IEEE1588_TMST | CNE_MBUF_F_TX_TCP_SEG | \
382 CNE_MBUF_F_TX_QINQ | CNE_MBUF_F_TX_TUNNEL_MASK | CNE_MBUF_F_TX_MACSEC | \
383 CNE_MBUF_F_TX_SEC_OFFLOAD | CNE_MBUF_F_TX_UDP_SEG | CNE_MBUF_F_TX_OUTER_UDP_CKSUM)
384
388#define CNE_MBUF_F_EXTERNAL (1ULL << 61)
389
390#define CNE_MBUF_F_INDIRECT (1ULL << 62)
391
396enum {
397 CNE_MBUF_L2_LEN_BITS = 7,
398 CNE_MBUF_L3_LEN_BITS = 9,
399 CNE_MBUF_L4_LEN_BITS = 8,
400 CNE_MBUF_TSO_SEGSZ_BITS = 16,
401 CNE_MBUF_OUTL3_LEN_BITS = 9,
402 CNE_MBUF_OUTL2_LEN_BITS = 7,
403 CNE_MBUF_TXOFLD_UNUSED_BITS = sizeof(uint64_t) * CHAR_BIT - CNE_MBUF_L2_LEN_BITS -
404 CNE_MBUF_L3_LEN_BITS - CNE_MBUF_L4_LEN_BITS -
405 CNE_MBUF_TSO_SEGSZ_BITS - CNE_MBUF_OUTL3_LEN_BITS -
406 CNE_MBUF_OUTL2_LEN_BITS,
407 CNE_MBUF_L2_LEN_OFS = 0,
408 CNE_MBUF_L3_LEN_OFS = CNE_MBUF_L2_LEN_OFS + CNE_MBUF_L2_LEN_BITS,
409 CNE_MBUF_L4_LEN_OFS = CNE_MBUF_L3_LEN_OFS + CNE_MBUF_L3_LEN_BITS,
410 CNE_MBUF_TSO_SEGSZ_OFS = CNE_MBUF_L4_LEN_OFS + CNE_MBUF_L4_LEN_BITS,
411 CNE_MBUF_OUTL3_LEN_OFS = CNE_MBUF_TSO_SEGSZ_OFS + CNE_MBUF_TSO_SEGSZ_BITS,
412 CNE_MBUF_OUTL2_LEN_OFS = CNE_MBUF_OUTL3_LEN_OFS + CNE_MBUF_OUTL3_LEN_BITS,
413 CNE_MBUF_TXOFLD_UNUSED_OFS = CNE_MBUF_OUTL2_LEN_OFS + CNE_MBUF_OUTL2_LEN_BITS,
414};
415
416#ifdef __cplusplus
417}
418#endif
419
420#endif /* _PKTMBUF_OFFLOAD_H_ */